[PATCH] D47005: [WebAssembly] Add isEHScopeEntry / setIsEHScopeEntry

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 17 01:17:27 PDT 2018


aheejin created this revision.
aheejin added reviewers: majnemer, dschuff.
Herald added subscribers: llvm-commits, sunfish, jgravelle-google, sbc100.

`MachineBasicBlock::isEHFuncletEntry` and
`MachineBasicBlock::setIsEHFuncletEntry` have been used to refer to both
the EH scope created by catchpad/cleanuppad instructions in IR and
funclets to be outlined in AsmPrinter. This patch splits these functions
into two and add `isEHScopeEntry` and `setIsEHScopeEntry`, which will be
used to denote scoped EH IR related functionalities. This became
necessary because wasm uses scope-based EH but does not outline
funclets. This change is in the same vein as https://reviews.llvm.org/D45559.


Repository:
  rL LLVM

https://reviews.llvm.org/D47005

Files:
  include/llvm/CodeGen/MachineBasicBlock.h
  lib/CodeGen/Analysis.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp


Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1379,7 +1379,10 @@
   auto Pers = classifyEHPersonality(FuncInfo.Fn->getPersonalityFn());
   bool IsMSVCCXX = Pers == EHPersonality::MSVC_CXX;
   bool IsCoreCLR = Pers == EHPersonality::CoreCLR;
+  bool IsSEH = isAsynchronousEHPersonality(Pers);
   MachineBasicBlock *CatchPadMBB = FuncInfo.MBB;
+  if (!IsSEH)
+    CatchPadMBB->setIsEHScopeEntry();
   // In MSVC C++ and CoreCLR, catchblocks are funclets and need prologues.
   if (IsMSVCCXX || IsCoreCLR)
     CatchPadMBB->setIsEHFuncletEntry();
@@ -1427,7 +1430,8 @@
 
 void SelectionDAGBuilder::visitCleanupPad(const CleanupPadInst &CPI) {
   // Don't emit any special code for the cleanuppad instruction. It just marks
-  // the start of a funclet.
+  // the start of an EH scope/funclet.
+  FuncInfo.MBB->setIsEHScopeEntry();
   FuncInfo.MBB->setIsEHFuncletEntry();
   FuncInfo.MBB->setIsCleanupFuncletEntry();
 }
@@ -1461,15 +1465,15 @@
       // Stop on cleanup pads. Cleanups are always funclet entries for all known
       // personalities.
       UnwindDests.emplace_back(FuncInfo.MBBMap[EHPadBB], Prob);
-      UnwindDests.back().first->setIsEHFuncletEntry();
+      UnwindDests.back().first->setIsEHScopeEntry();
       break;
     } else if (auto *CatchSwitch = dyn_cast<CatchSwitchInst>(Pad)) {
       // Add the catchpad handlers to the possible destinations.
       for (const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
         UnwindDests.emplace_back(FuncInfo.MBBMap[CatchPadBB], Prob);
         // For MSVC++ and the CLR, catchblocks are funclets and need prologues.
         if (IsMSVCCXX || IsCoreCLR)
-          UnwindDests.back().first->setIsEHFuncletEntry();
+          UnwindDests.back().first->setIsEHScopeEntry();
       }
       NewEHPadBB = CatchSwitch->getUnwindDest();
     } else {
Index: lib/CodeGen/Analysis.cpp
===================================================================
--- lib/CodeGen/Analysis.cpp
+++ lib/CodeGen/Analysis.cpp
@@ -676,7 +676,7 @@
   SmallVector<const MachineBasicBlock *, 16> SEHCatchPads;
   SmallVector<std::pair<const MachineBasicBlock *, int>, 16> CatchRetSuccessors;
   for (const MachineBasicBlock &MBB : MF) {
-    if (MBB.isEHFuncletEntry()) {
+    if (MBB.isEHScopeEntry()) {
       FuncletBlocks.push_back(&MBB);
     } else if (IsSEH && MBB.isEHPad()) {
       SEHCatchPads.push_back(&MBB);
Index: include/llvm/CodeGen/MachineBasicBlock.h
===================================================================
--- include/llvm/CodeGen/MachineBasicBlock.h
+++ include/llvm/CodeGen/MachineBasicBlock.h
@@ -115,6 +115,9 @@
   /// branch.
   bool AddressTaken = false;
 
+  /// Indicate that this basic block is the entry block of an EH scope.
+  bool IsEHScopeEntry = false;
+
   /// Indicate that this basic block is the entry block of an EH funclet.
   bool IsEHFuncletEntry = false;
 
@@ -375,6 +378,12 @@
 
   bool hasEHPadSuccessor() const;
 
+  /// Returns true if this is the entry block of an EH scope.
+  bool isEHScopeEntry() const { return IsEHScopeEntry; }
+
+  /// Indicates if this is the entry block of an EH scope.
+  void setIsEHScopeEntry(bool V = true) { IsEHScopeEntry = V; }
+
   /// Returns true if this is the entry block of an EH funclet.
   bool isEHFuncletEntry() const { return IsEHFuncletEntry; }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47005.147260.patch
Type: text/x-patch
Size: 3489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180517/525b4b41/attachment.bin>


More information about the llvm-commits mailing list