[llvm-dev] LLVMAddGlobalMapping after optimization

Henning Thielemann via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 18 09:11:12 PDT 2016

On Tue, 30 Aug 2016, Henning Thielemann wrote:

> I use MCJIT on LLVM-3.8 and use LLVMAddGlobalMapping to register call-back 
> functions. LLVMAddGlobalMapping needs a LLVMValueRef to a function call 
> value. However, is this still valid after optimization? I always suspected 
> that this is not true, but it worked in many occasions anyway. Now, I think I 
> hit a case where it fails.

Aha, it seems that optimization does not change the LLVMValueRef of a 
function during optimization. However, optimization may remove an unused 
function completely, which makes the LLVMValueRef invalid. Now I retrieve 
the LLVMValueRefs via LLVMGetNamedFunction and check for NULL pointers.

More information about the llvm-dev mailing list