[LLVMdev] How to always generate epilogue code?
Kai Nacke
kai.nacke at redstar.de
Sun May 26 04:22:23 PDT 2013
Hi!
I am still working on the Win64 EH code and now have a pretty usable
result. (The MC part is already posted to llvm-commits, the other
part follows soon. If you are curious the whole patch is here:
http://www.redstar.de/ldc/win64eh_all_20130524.diff.)
However, in one case I have a problem with LLVM being too smart.
Consider the following D code:
void doIt()
{
printf("doIt: start\n");
try
{
printf("doIt: try\n");
throw new Exception("Failure");
}
finally
{
printf("doIt: finally\n");
}
printf("doIt: end\n");
}
The code after the throw statement is unreachable. The last instruction
of the finally block is a resume. LLVM now removes the last printf call
and the epilogue code because it is all dead code. In fact the last
instruction generated for this function is a call to the unwind_resume
library function.
Unfortunately Windows 64bit requires the epilogue code to perform the
stack unwinding. In this special case it is not dead code but another
form of metadata. See here:
http://msdn.microsoft.com/en-us/library/8ydc79k6.aspx.
Is there a simple way to always enforce the generation of the epilogue?
E.g. can I mark the epilogue as always reachable?
Regards
Kai
More information about the llvm-dev
mailing list