[LLVMdev] JIT simple module and accessing the value fails

Tobias Pankrath tobias at pankrath.net
Thu Jan 8 08:11:15 PST 2015


I'm using the llvm-c API and want to use the JIT. I've created the following 
module

; ModuleID = '_tmp'

@a = global i64 5

define i64 @__tempfunc() {
entry:
  %a_val = load i64* @a
  ret i64 %a_val
}

This output is generated by LLVMDumpModule just before I call LLVMRunFunction. 
Which yields a LLVMGenericValueRef. However converting the result to a 64bit 
integer via LLVMGenericValueToInt(gv, true), it results in 360287970189639680 
or something similar - not 5. Converting via LLVMGenericValueToInt(gv, false) 
didn't help either.

How can I use global variables in a JIT situation? Is anything wrong with the 
IR?



More information about the llvm-dev mailing list