[llvm-commits] [llvm] r140719 - /llvm/trunk/lib/Target/ARM/ARMSjLjLoweringPass.cpp

Bill Wendling isanbard at gmail.com
Wed Sep 28 13:29:45 PDT 2011


Author: void
Date: Wed Sep 28 15:29:45 2011
New Revision: 140719

URL: http://llvm.org/viewvc/llvm-project?rev=140719&view=rev
Log:
Perform the lowering only if there are invokes.

Modified:
    llvm/trunk/lib/Target/ARM/ARMSjLjLoweringPass.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMSjLjLoweringPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSjLjLoweringPass.cpp?rev=140719&r1=140718&r2=140719&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMSjLjLoweringPass.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMSjLjLoweringPass.cpp Wed Sep 28 15:29:45 2011
@@ -35,14 +35,14 @@
   LLVMContext *Context;
 
   MachineFunction *MF;
-  const Function *Fn;
+  const Function *F;
   const TargetLowering *TLI;
   const TargetInstrInfo *TII;
   const TargetRegisterInfo *TRI;
 
-  /// createFunctionContext - Create the function context on the stack. This
-  /// returns the nonnegative identifier representing it in the FrameInfo.
-  int createFunctionContext();
+  /// setupFunctionContext - Setup the function context on the stack. Some of
+  /// the fields were set by the SjLj EH prepare pass.
+  int setupFunctionContext();
 
 public:
   static char ID;
@@ -67,19 +67,29 @@
   if (!EnableNewSjLjEHPrepare) return false;
 
   MF = &mf;
-  Fn = MF->getFunction();
-  Context = &Fn->getContext();
+  F = MF->getFunction();
+  Context = &F->getContext();
   TLI = MF->getTarget().getTargetLowering();
   TII = MF->getTarget().getInstrInfo();
   TRI = MF->getTarget().getRegisterInfo();
 
-  int FrameIdx = createFunctionContext(); (void)FrameIdx;
+  // Perform the lowering only if there are invokes.
+  bool HasInvokes = false;
+  for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
+    if (isa<InvokeInst>(BB->getTerminator())) {
+      HasInvokes = true;
+      break;
+    }
+
+  if (!HasInvokes) return false;
+
+  int FrameIdx = setupFunctionContext(); (void)FrameIdx;
 
   return true;
 }
 
-/// createFunctionContext - Create the function context on the stack.
-int ARMSjLjLowering::createFunctionContext() {
+/// setupFunctionContext - Create the function context on the stack.
+int ARMSjLjLowering::setupFunctionContext() {
   // struct _Unwind_FunctionContext {
   //   // next function in stack of handlers.
   //   struct _Unwind_FunctionContext *prev;





More information about the llvm-commits mailing list