[llvm-dev] (Beginner) How to lower EHPadBB

Ben Craig via llvm-dev llvm-dev at lists.llvm.org
Sun Oct 24 16:42:03 PDT 2021


Apologies on the poorly formed question.

I'm trying to figure out how to fetch and plumb the unwind label of an invoke instruction down to the call lowering code for x86.  What I'm doing (poorly) right now is adding an SDValue UnwindDest to CallLoweringInfo, and populating that inside SelectionDAGBuilder::LowerCallTo with getValue(EHPadBB).  getValue doesn't support BasicBlocks though, and so I'm not sure which kind of thing I should be passing around.  Is there a way to convert or fetch a BlockAddress or a GlobalConstant from a BasicBlock that I should be using as the arg for getValue?  Or am I on entirely the wrong path?

Context:
I'm attempting to prototype a different exception ABI on x86.  On the caller side, this will involve having a special multi-byte nop immediately follow the call instruction.  Normally, a 7-byte nop on x86 would be 0f 1f 80 00 00 00 00, but I'm planning on stuffing a PC-relative address containing the EH pad location in the 4 zero bytes of the nop instruction.  At runtime, some code will treat the return address of the function as data, dereference it to extract those 4 bytes, then compute a jump target based on that to get to the landing pad.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211024/58cb097a/attachment.html>


More information about the llvm-dev mailing list