llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.51k stars 11.79k forks source link

Can't build x64 SEH with LLVM-C interface #30133

Open llvmbot opened 7 years ago

llvmbot commented 7 years ago
Bugzilla Link 30785
Version 3.9
OS All
Attachments Patch to current trunk sources
Reporter LLVM Bugzilla Contributor

Extended Description

The LLVM-C interface provides no means to construct catchswitch, catchpad, catchret, cleanuppad, or cleanupret instructions.

Patch file attached. I haven't tested this yet because of LLVM build problems on my machine which I am sorting out now. I will test it today or tomorrow. More functionality could be added for catchswitch handlers, similar to the clause functionality for landingpads, but this will be enough to allow us to start using these instructions.

llvmbot commented 7 years ago

Have now tested LLVMBuildCallInPad, and it works. I don't think I need LLVMBuildInvokeInPad.

llvmbot commented 7 years ago

third version of patch, including LLVMBuild*InPad() My cleanuppad blocks need to call/invoke other functions (typically a finally block in a try/finally is compiled into a function), which means they need to generate "funclet operand bundles" and attach them to call/invoke instructions. These two new functions are intended to allow that from LLVM-C (but I haven't yet tested them).

llvmbot commented 7 years ago

No, that won't work, will it, because the cleanupret just tells the personality where to unwind to next. So I'll create a patch which implements LLVMBuildCallWithFuncletBundle() and LLVMBuildInvokeWithFuncletBundle().

llvmbot commented 7 years ago

Also can't make funclet operand bundles for cleanuppads which make function calls (e.g. for "finally" blocks). I don't have a patch for this yet. I think I can workaround that by doing a cleanupret to a new basic block and make the call from there.

llvmbot commented 7 years ago

second version of patch, including LLVMConstTokenNone() Patch including LLVMConstTokenNone().

llvmbot commented 7 years ago

To make catchpad and cleanuppad useful, we also need the constant token none, and there is no way of getting that from LLVM-C either. I'll make a new patch in the morning.