[llvm-commits] [Patch] Exception Handling Documentation

John McCall rjmccall at apple.com
Tue Aug 2 18:38:17 PDT 2011


On Aug 2, 2011, at 2:29 PM, Bill Wendling wrote:
> On Aug 2, 2011, at 1:24 PM, Chris Lattner wrote:
>> @@ -3372,17 +3384,18 @@
>>   successors.</p>
>> 
>> <h5>Arguments:</h5>
>> -<p>The '<tt>resume</tt>' instruction's argument must have the same type as the
>> -   result of any '<tt>landingpad</tt>' instruction in the same function.</p>
>> +<p>The '<tt>resume</tt>' instruction requires one argument, which must have the
>> +   same type as the result of any '<tt>landingpad</tt>' instruction in the same
>> +   function.</p>
>> 
>> Thanks for mentioning this.  As a devil's advocate question: shouldn't this be forced to match the landingpad instruction that interrupted the unwind?  isn't it theoretically possible to have code like this:
>> 
>> 
>> invoke @somefunc  -> unwind %landingpadbb
>> 
>> landingpadbb:
>> %A = landingpad ...
>> call foo(%A)
>> unreachable
>> 
>> void foo( ... %A) {
>> resume %A
>> }
>> 
>> In other words, does the resume actually have to be in the same function as the landing pad?
>> 
> Interesting. No, it doesn't need to be in the same function.

I don't think this is true;  the exceptions ABI strongly suggests that the
call to _Unwind_Resume should happen from the "landing pad", i.e.
from the function that unwinding stopped at.  I would not be surprised
if some existing implementations broke if you "outlined" the call to
_Unwind_Resume, and I certainly see no value in supporting it.

It should be undefined behavior to reach a resume and give it an
operand that does not correspond to the value of a landingpad
instruction from the same execution context.  (That's a dynamic
constraint about the data content of the value, not an SSA
constraint about the form of the operand).

>> +  <li>A landing pad blcok must have a '<tt>landingpad</tt>' instruction as its
>> +      first non-PHI instruction.</li>
>> +  <li>The '<tt>landingpad</tt>' instruction must be the first non-PHI
>> +      instruction in the landing pad block.</li>
>> 
>> typo "blcok".  It's not clear to me what the difference between these two points is.

It's two directions of implication.  If you have a landing pad block,
its first non-PHI instruction is a landingpad instruction, and if you
have a landingpad instruction, it is the first non-PHI instruction in
a landing pad block.

John.



More information about the llvm-commits mailing list