Perform the lowering only if there are invokes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140719 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2011-09-28 20:29:45 +00:00
parent 39689c8154
commit b18abd077e

View File

@ -35,14 +35,14 @@ class ARMSjLjLowering : public MachineFunctionPass {
LLVMContext *Context; LLVMContext *Context;
MachineFunction *MF; MachineFunction *MF;
const Function *Fn; const Function *F;
const TargetLowering *TLI; const TargetLowering *TLI;
const TargetInstrInfo *TII; const TargetInstrInfo *TII;
const TargetRegisterInfo *TRI; const TargetRegisterInfo *TRI;
/// createFunctionContext - Create the function context on the stack. This /// setupFunctionContext - Setup the function context on the stack. Some of
/// returns the nonnegative identifier representing it in the FrameInfo. /// the fields were set by the SjLj EH prepare pass.
int createFunctionContext(); int setupFunctionContext();
public: public:
static char ID; static char ID;
@ -67,19 +67,29 @@ bool ARMSjLjLowering::runOnMachineFunction(MachineFunction &mf) {
if (!EnableNewSjLjEHPrepare) return false; if (!EnableNewSjLjEHPrepare) return false;
MF = &mf; MF = &mf;
Fn = MF->getFunction(); F = MF->getFunction();
Context = &Fn->getContext(); Context = &F->getContext();
TLI = MF->getTarget().getTargetLowering(); TLI = MF->getTarget().getTargetLowering();
TII = MF->getTarget().getInstrInfo(); TII = MF->getTarget().getInstrInfo();
TRI = MF->getTarget().getRegisterInfo(); 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; return true;
} }
/// createFunctionContext - Create the function context on the stack. /// setupFunctionContext - Create the function context on the stack.
int ARMSjLjLowering::createFunctionContext() { int ARMSjLjLowering::setupFunctionContext() {
// struct _Unwind_FunctionContext { // struct _Unwind_FunctionContext {
// // next function in stack of handlers. // // next function in stack of handlers.
// struct _Unwind_FunctionContext *prev; // struct _Unwind_FunctionContext *prev;