First you need a place to store it, assuming that's on the stack, use an alloca:
%o = alloca %Object, align 8
Now to store into the i8 in it, you have to get the element pointer (GEP) for it, and store into that like so:
%gep0 = getelementptr inbounds %Object* %o, i32 0, i32 0 store i8 97, i8* %gep0, align 1
To store into the double, that would be:
%gep4 = getelementptr inbounds %Object* %o, i32 0, i32 4 store double 1.0, double* %gep4, align 8
Loading from the i8 looks like this:
%v = load i8, i8* %gep0
You can read about GEPs here: http://llvm.org/docs/LangRef.html#getelementptr-instruction
Take a look here: http://llvm.org/bugs/show_bug.cgi?id=11174
There is a patch; maybe you can apply it to your version.
Note: I found this by googling "G_ATOMIC_LOCK_FREE defined, but incapable of lock-free atomics" - it's a very useful first line strategy! Although I did then check this mailing list post which led me to the bug report.
There may be more to this problem - I would suggest looking at the other bugs and such referenced from that llvm bug report. I get the feeling it's something fixed in later versions though.
llvmlite.ir.Builder.if_then
is a context manager, which means it's intended to be used with a `with
` statement, in which you generate all the inner code inside of the `if_then
` context.
The following is a minimal example that works for me:
https://repl.it/repls/HuskyJumboSoftwaresuite
import llvmlite.ir as L
module = L.Module(name="test") func = L.Function(module, L.FunctionType(L.VoidType(), ()), name="f") block = func.append_basic_block(name="entry") builder = L.IRBuilder(block)
# if x < 5 { # print(x) # }
x = builder.alloca(L.DoubleType(), name='x') less_than = builder.fcmp_ordered('<', x, L.Constant(L.DoubleType(), 5)) f_print = L.Function(module, L.FunctionType(L.VoidType(), [L.DoubleType()]), name='print')
with builder.if_then(less_than): builder.call(f_print, [builder.load(x)])
builder.ret_void()
print(module)
Figured it out. Per this Kratos guide, add this compiler option:
-- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
AFAIK there is no clang 5.1. Clang/LLVM share a source tree, the current release version will be 3.5. Your folder structures also suggests that you're trying to build a llvm-2.6 tree, this is very old.
What do you try to achieve? Do you explicitly require llvm-2.9 for your work, or is any (newer) llvm sufficient? If so, I suggest that you try building llvm/clang with this guide: http://clang.llvm.org/get_started.html