[LLVMdev] Throwing function being marked nounwind under optimzation?

Jim Grosbach grosbach at apple.com
Sun Aug 16 11:46:20 PDT 2009


All,

The following relatively simple function is behaving oddly under SJLJ  
exception handling. Specifically, it's being diagnosed by the  
optimizer as being a nounwind function, which is obviously incorrect.

 From what I can tell so far, something is going wrong analyzing the  
call to __cxa_end_catch()
   invoke arm_apcscc  void @__cxa_end_catch()
           to label %Unwind unwind label %lpad121
Something thinks that this invoke will always take the unwind path,  
which isn't the case, and marks the Unwind block as unreachable. As a  
consequence of that, the call to _Unwind_SjLj_Resume() is optimized  
away, and thus the function is considered to not throw in PruneEH.cpp.  
Very strange stuff.

Thoughts on how to proceed in figuring out the root cause of what's  
going wrong?


bool ShouldThrow;

int throws()
   try
{
   if (ShouldThrow) throw 7; return 123;
} catch (...) {
   printf("'throws' threw an exception: rethrowing!\n");
   throw;
}




More information about the llvm-dev mailing list