[cfe-dev] Sometimes throwing constructors / destructors
David Chisnall
David.Chisnall at cl.cam.ac.uk
Fri Jul 25 02:38:14 PDT 2014
On 25 Jul 2014, at 10:14, Arnaud A. de Grandmaison <arnaud.degrandmaison at arm.com> wrote:
> I understand your point but what bothers me is that if the first constructor call fails, I agree that there is no destructions to do, but the fact that it failed should still be signalled (with a resume, not a ret) so that I can be handled properly.
I think you misunderstand how exceptions work in LLVM IR. If a function that is called (not invoked) throws an exception, then the unwinder will not find a landing pad in the function and so will keep going. No code after the call will be reached in the case that an exception is thrown. The following are equivalent:
call @foo()
br label %1
and
invoke @foo() to label %1 unwind to label %2
: <label>%2
resume
The only difference is that, if an exception *is* thrown (and no optimisers turned the second form into the first) then the first form will be faster at run time because the personality function will not find a cleanup, call back into the function, then be called back. The unwind tables and generated code will also be smaller.
David
More information about the cfe-dev
mailing list