[llvm-commits] Workaround for PR1508
Chris Lattner
clattner at apple.com
Wed Jun 13 13:12:57 PDT 2007
On Jun 13, 2007, at 10:55 AM, Duncan Sands wrote:
> Look for eh.filter and eh.selector intrinsics in the
> successor to an empty (exception for a branch) landing pad.
> The big FIXME comment explains more. Testcase included,
> along with an XFAIL for a test which uses eh.selector in a
> routine with no landing pads (not possible in llvm-gcc
> generated code).
Seems fine to me, minor comments:
Please use SmallSet<CallInst*, 4> instead of std::set.
+ // Inform the MachineModuleInfo of the personality for this
landing pad.
+ ConstantExpr *CE = dyn_cast<ConstantExpr>(I.getOperand(2));
+ assert(CE && CE->getOpcode() == Instruction::BitCast &&
Please just use cast<> instead of dyn_cast, which guarantees no null
return.
+ if (Br && Br->isUnconditional() && LLVMBB->size() == 1) {
+ // Smells like a critical edge: look for eh intrinsics in
the successor.
+ BasicBlock *S = Br->getSuccessor(0);
+
+ assert(!FuncInfo.MBBMap[S]->isLandingPad() &&
+ "Chained landing pads!");
+ for (BasicBlock::iterator I = S->begin(), E = --S->end(); I !
= E; ++I)
+ if (CallInst *C = dyn_cast<CallInst>(I))
+ if (Function *F = C->getCalledFunction())
+ if (F->isDeclaration())
+ if (unsigned IID = F->getIntrinsicID())
+ if (IID == Intrinsic::eh_selector ||
+ IID == Intrinsic::eh_filter) {
+ addCatchInfo(*C, MMI, BB, IID ==
Intrinsic::eh_filter);
+#ifndef NDEBUG
+ FuncInfo.SelectorsFound.insert(C);
+#endif
+ }
Please split this out into a helper predicate function. Inside the
loop, please use continue to avoid nesting so much:
if (!F->isDeclaration()) continue;
...
if (IID != .. && IID != ..) continue;
-Chris
More information about the llvm-commits
mailing list