[LLVMdev] UpgradeExceptionHandling

Garrison Venn gvenn.cfe.dev at gmail.com
Thu Sep 22 07:37:58 PDT 2011

For those of you who want to get their exception handling code (NON SJLJ), working 
with the new 3.0 exception infrastructure, the core developers have created a handy
function in AutoUpgrade (#include "llvm/AutoUpgrade.h") called:
UpgradeExceptionHandling(...). This function will convert all the functions in a
module using the pre 3.0 exception intrinsics into use of the new 3.0 landingpad
instruction. This function must be run before the llvm::verifyFunction(...) as the
verifier will now complain if the an invoke instruction's unwind block does not
contain a landingpad instruction. In converting over my own exception handling
code, I ran across this utility which worked fine in my case. 

However, ... as UpgradeExceptionHandling(...) will go away in 3.1, one should upgrade
their pre 3.0 exception handling code to the 3.0 system as soon as possible. The
new system is more concise, and therefore cleaner, as it merges in the old 
llvm::Intrinsic::eh_selector, and llvm::Intrinsic::eh_exception intrinsics into one landpad 
instruction. Also I'm not sure if use of UpgradeExceptionHandling(...) is an approved
approach so depending on it may be at one's own expense.

As I found the implementation of the UpgradeExceptionHandling(...) to be pretty cool,
I thought I would take the time to advertise this discovered function. Now back to my 
conversion. :-)


More information about the llvm-dev mailing list