[llvm-commits] [llvm] r136313 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp

John McCall rjmccall at apple.com
Wed Jul 27 21:39:49 PDT 2011


On Jul 27, 2011, at 6:55 PM, Bill Wendling wrote:
> On Jul 27, 2011, at 6:23 PM, John McCall wrote:
>> +/// mergeLandingPadClauses - Visit all of the landing pad instructions merge the
>> +/// clauses from the new destination (the caller's landing pad).
>> +void InvokeInliningInfo::mergeLandingPadClauses(ResumeInst *RI) {
>> +  for (SmallVectorImpl<LandingPadInst*>::iterator
>> +         I = CalleeLPads.begin(), E = CalleeLPads.end(); I != E; ++I)
>> +    for (unsigned i = 0, e = CallerLPad->getNumClauses(); i != e; ++i)
>> +      (*I)->addClause(CallerLPad->getClauseType(i),
>> +                      CallerLPad->getClauseValue(i));
>> +}
>> 
>> I don't see the value in queuing up the landingpad instructions here;
>> just merge in the caller's clauses as you find them.  That would have
>> the added advantage of not adding the clauses twice if you find two
>> or more resume instructions in the callee.
>> 
>> Also, you're not merging the cleanup bit.
>> 
> Is that the correct semantics? I know I need to keep the cleanup bit on the callee's landingpad instruction, but what about the caller's cleanup bit?

Unless the inner landing pad can't resume unwinding, yes;  otherwise, the combined landing pad has all the cleanups of both landing pads, so the unwinder needs to land there even if there are no handlers in either landing pad.

The minimal example would be an inner function with a catch(int) but no cleanups, and an outer function with cleanups but no handlers.  The unwinder has to stop at this landing pad to run the cleanups even if the exception is not an int.

Incidentally, that same example also demonstrates a constraint on front-ends that may not be obvious:  every landing pad that can resume unwinding must be prepared for the unwinder to "spuriously" land there, even if it has no cleanups, just in case the inliner inlines it into an invoke.

If you decide to have a bit on the landingpad instruction that says that it can't resume unwinding, I suggest spelling it "noresume".

John.



More information about the llvm-commits mailing list