[llvm-branch-commits] [llvm-branch] r107648 - in /llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG: SelectionDAGBuilder.cpp SelectionDAGBuilder.h

Bill Wendling isanbard at gmail.com
Tue Jul 6 03:58:13 PDT 2010


Author: void
Date: Tue Jul  6 05:58:13 2010
New Revision: 107648

URL: http://llvm.org/viewvc/llvm-project?rev=107648&view=rev
Log:
- There is no longer just one landing pad per invoke instruction. Reflect this
  in the LowerCallTo call. There is a bit of nastiness because of needing to
  pass in a null vector of catch blocks. That might be fixable in the future.

- Add the filter IDs to the machine function now that we have that hook in. This
  gives us ready access for those IDs when generating the DWARF EH tables.

Modified:
    llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h

Modified: llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=107648&r1=107647&r2=107648&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Jul  6 05:58:13 2010
@@ -1646,13 +1646,16 @@
 
   // Retrieve successors.
   MachineBasicBlock *Return = FuncInfo.MBBMap[I.getSuccessor(0)];
-  MachineBasicBlock *LandingPad = FuncInfo.MBBMap[I.getSuccessor(1)];
+  SmallVector<MachineBasicBlock*, 8> CatchBlocks;
+
+  for (unsigned i = 1, e = I.getNumSuccessors(); i != e; ++i)
+    CatchBlocks.push_back(FuncInfo.MBBMap[I.getSuccessor(i)]);
 
   const Value *Callee = I.getCalledValue();
   if (isa<InlineAsm>(Callee))
     visitInlineAsm(&I);
   else
-    LowerCallTo(&I, getValue(Callee), false, LandingPad);
+    LowerCallTo(&I, getValue(Callee), false, CatchBlocks);
 
   // If the value of the invoke is used outside of its defining block, make it
   // available as a virtual register.
@@ -1660,7 +1663,10 @@
 
   // Update successor info
   InvokeMBB->addSuccessor(Return);
-  InvokeMBB->addSuccessor(LandingPad);
+
+  for (SmallVectorImpl<MachineBasicBlock*>::iterator
+         i = CatchBlocks.begin(), e = CatchBlocks.end(); i != e; ++i)
+    InvokeMBB->addSuccessor(*i);
 
   // Drop into normal successor.
   DAG.setRoot(DAG.getNode(ISD::BR, getCurDebugLoc(),
@@ -4157,6 +4163,14 @@
       MMI.setVariableDbgInfo(Variable, FI, DI.getDebugLoc());
     return 0;
   }
+  case Intrinsic::eh_filter: {
+    // Add the filter IDs to the machine function.
+    MachineFunction &MF = DAG.getMachineFunction();
+    for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i)
+      MF.addFilterID(I.getArgOperand(i)->stripPointerCasts());
+
+    return 0;
+  }
   case Intrinsic::eh_exception: {
     // Insert the EXCEPTIONADDR instruction.
     assert(FuncInfo.MBBMap[I.getParent()]->isLandingPad() &&
@@ -4169,6 +4183,7 @@
     return 0;
   }
 
+///EH-FIXME: Remove eh_selector and eh_typeid_for.
   case Intrinsic::eh_selector: {
     MachineBasicBlock *CallMBB = FuncInfo.MBBMap[I.getParent()];
     MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI();
@@ -4540,9 +4555,15 @@
   }
 }
 
-void SelectionDAGBuilder::LowerCallTo(ImmutableCallSite CS, SDValue Callee,
-                                      bool isTailCall,
-                                      MachineBasicBlock *LandingPad) {
+void SelectionDAGBuilder::
+LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool isTailCall) {
+  SmallVector<MachineBasicBlock*, 1> CatchBlocks;
+  LowerCallTo(CS, Callee, isTailCall, CatchBlocks);
+}
+
+void SelectionDAGBuilder::
+LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool isTailCall,
+            SmallVectorImpl<MachineBasicBlock*> &CatchBlocks) {
   const PointerType *PT = cast<PointerType>(CS.getCalledValue()->getType());
   const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
   const Type *RetTy = FTy->getReturnType();
@@ -4604,7 +4625,7 @@
     Args.push_back(Entry);
   }
 
-  if (LandingPad) {
+  if (!CatchBlocks.empty()) {
     // Insert a label before the invoke call to mark the try range.  This can be
     // used to detect deletion of the invoke via the MachineModuleInfo.
     BeginLabel = MMI.getContext().CreateTempSymbol();
@@ -4614,6 +4635,7 @@
     unsigned CallSiteIndex = MMI.getCurrentCallSite();
     if (CallSiteIndex) {
       MMI.setCallSiteBeginLabel(BeginLabel, CallSiteIndex);
+
       // Now that the call site is handled, stop tracking it.
       MMI.setCurrentCallSite(0);
     }
@@ -4639,10 +4661,12 @@
                     isTailCall,
                     !CS.getInstruction()->use_empty(),
                     Callee, Args, DAG, getCurDebugLoc());
+
   assert((isTailCall || Result.second.getNode()) &&
          "Non-null chain expected with non-tail call!");
   assert((Result.second.getNode() || !Result.first.getNode()) &&
          "Null value expected with tail call!");
+
   if (Result.first.getNode()) {
     setValue(CS.getInstruction(), Result.first);
   } else if (!CanLowerReturn && Result.second.getNode()) {
@@ -4706,14 +4730,14 @@
   else
     HasTailCall = true;
 
-  if (LandingPad) {
+  if (!CatchBlocks.empty()) {
     // Insert a label at the end of the invoke call to mark the try range.  This
     // can be used to detect deletion of the invoke via the MachineModuleInfo.
     MCSymbol *EndLabel = MMI.getContext().CreateTempSymbol();
     DAG.setRoot(DAG.getEHLabel(getCurDebugLoc(), getRoot(), EndLabel));
 
     // Inform MachineModuleInfo of range.
-    MMI.addInvoke(LandingPad, BeginLabel, EndLabel);
+///EH-FIXME:    MMI.addInvoke(LandingPad, BeginLabel, EndLabel);
   }
 }
 

Modified: llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=107648&r1=107647&r2=107648&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original)
+++ llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Tue Jul  6 05:58:13 2010
@@ -376,8 +376,9 @@
   bool isExportableFromCurrentBlock(const Value *V, const BasicBlock *FromBB);
   void CopyToExportRegsIfNeeded(const Value *V);
   void ExportFromCurrentBlock(const Value *V);
+  void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall);
   void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall,
-                   MachineBasicBlock *LandingPad = NULL);
+                   SmallVectorImpl<MachineBasicBlock*> &CatchBlocks);
 
 private:
   // Terminator instructions.
@@ -385,7 +386,7 @@
   void visitBr(const BranchInst &I);
   void visitSwitch(const SwitchInst &I);
   void visitIndirectBr(const IndirectBrInst &I);
-  void visitUnreachable(const UnreachableInst &I) { /* noop */ }
+  void visitUnreachable(const UnreachableInst &) { /* noop */ }
 
   // Helpers for visitSwitch
   bool handleSmallSwitchRange(CaseRec& CR,
@@ -494,10 +495,10 @@
   void visitVAEnd(const CallInst &I);
   void visitVACopy(const CallInst &I);
 
-  void visitUserOp1(const Instruction &I) {
+  void visitUserOp1(const Instruction &) {
     llvm_unreachable("UserOp1 should not exist at instruction selection time!");
   }
-  void visitUserOp2(const Instruction &I) {
+  void visitUserOp2(const Instruction &) {
     llvm_unreachable("UserOp2 should not exist at instruction selection time!");
   }
   





More information about the llvm-branch-commits mailing list