Questions tagged [llvm-ir]

The LLVM Intermediate Representation

The idea behind the LLVM IR is to be "light-weight and low-level while being expressive, typed, and extensible at the same time." This is achieved by being as low-level as possible while it still being possible to map higher level concepts to the IR. The LLVM IR also provides type information, which can be useful for some optimizations.

Source: Aalto University Wiki (LLVM IR Advanced Course on Compilers)

1263 questions
0
votes
1 answer

lli Instruction not interpretable yet

Can someone explain to me why lli on instruction "%broadcast.splatinsert.i = insertelement <4 x i32> undef, i32 %reverse.idx.i, i32 0" prints "Instruction not interpretable yet! ? lli ver 3.3 full source…
llvmuser12
  • 33
  • 2
0
votes
1 answer

How to JIT compile IR code from string

I've got such a problem. I've written my own IR code generator. It saves IR into a string. And now I want to JIT compile this IR code using LLVM. But all functions and API's I've found only gets llvm::Function as an arg. But how can I compile an IR…
0
votes
1 answer

When and where did the LLVM IR Instruction set it's parent BasicBlock?

When I insert an Instruction into a BasicBlock with the method BasicBlock::getInstList().push_front(*Instruction); But when did it set the Instruction's parent to current BasicBlock? The code is as follow and worked well. I just want…
wangbo15
  • 191
  • 1
  • 13
0
votes
1 answer

LLVM passes 0 as argument to external function call

Ok, maybe somebody can help me. I am writing a small LLVM IR testprogram: ; ModuleID = 'main' target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-cygwin" define i32 @my_main() { entry: %0 = alloca i64 store…
Rick
  • 680
  • 1
  • 7
  • 20
0
votes
1 answer

LLVM: run-time error in creating a function of empty input and output

I want to create an empty function in LLVM IR void foo(){ } I use LLVMContext Context; std::unique_ptr Owner(new Module("test", Context)); Module *M = Owner.get(); Function *foo = cast(M->getOrInsertFunction("foo",…
zell
  • 9,830
  • 10
  • 62
  • 115
0
votes
1 answer

LLVM ParseIR Segfault

I'm trying to compile a function ("fun") to LLVM IR and create a Module using the ParseIR function. The program segfaults at the call to ParseIR. I'm using LLVM 3.5 and the code is below. #include #include #include…
agg212
  • 407
  • 1
  • 4
  • 17
0
votes
1 answer

phi Instruction does not dominate all uses

I have llvm-IR function When i try it convert to .bc, llvm-as has showed a lot of error. For example: Instruction does not dominate all uses! %rightBoundary.1.i = phi i32 [ %dec.i, %while.cond1.i ], [ %rightBoundary.046.i,…
llvmuser12
  • 33
  • 2
0
votes
1 answer

Unable to read the LLVM IR corresponding to HelloWorld.bc using llvm-dis

I have the program HelloWorld.c #include int main() { printf("hello world\n"); return 0; } which is compiled to the bitcode helloWorld.bc using the command : clang -emit-llvm HelloWorld.c -c -o HelloWorld.bc In order to print the LLVM…
zell
  • 9,830
  • 10
  • 62
  • 115
0
votes
1 answer

How does llvm IR order alloca instruction

I noticed that llvm IR tries to allocate spaces in the very beginning of a function regardless of the location of declaring variables inside of the function in the C source code. I want to know how these alloca instructions are ordered. My guess is…
Min Gao
  • 383
  • 4
  • 16
0
votes
1 answer

how to use llvm intrinsics @llvm.read_register?

I noticed that llvm.read_register() could read the value of stack pointer, as well as llvm.write_register() could set the value of stack pointer. I add main function to the stackpointer.ll which could be found in the llvm src: ;stackpointer.ll …
winter333
  • 337
  • 1
  • 2
  • 10
0
votes
1 answer

LLVM IR gen - find stack allocated variable by name

I have created an AllocaInst using new AllocaInst(...) within some block and have provided a name for it. Having done this, is it possible for me to search for this stack variable by the name I gave for it (assume the AllocaInst* returned is not…
user855
  • 19,048
  • 38
  • 98
  • 162
0
votes
2 answers

How can I get the name of function from StoreInst's Value In LLVM

I have a structure and it has a pointer to function as follows. typedef struct { void (*p)(); int n; } myStruct; I used it as folllowing: myStruct * a = malloc( sizeof(myStruct)); a->n=88; a->p = &booooo; a->p() In LLVM, How can I get…
Dalia
  • 135
  • 2
  • 9
0
votes
0 answers

How to make llvm IR code run in c?

I want a c program to execute a function using llvm IR instead of the c code. Is it possible? I do not want to convert the entire module. Only one function needs to be called in the end.
ajarmani
  • 269
  • 1
  • 2
  • 9
0
votes
0 answers

How do I JIT the trampoline intrinsic using the llvm JIT engine?

I'm trying to JIT the llvm trampoline intrinsics, but I can't find the functionality for that in the llvm::IRBuilder class. Does anyone know if it's possible to do with the current JIT engine? I'm not looking for the semantics of the trampoline…
maxywb
  • 2,275
  • 1
  • 19
  • 25
0
votes
1 answer

LLVM Induction Variable Simplify Pass

I want to have only canonical induction variable in my IR before I pass it to one of my other passes to do some transformation. However the pass -indvars doesn't seem to do it. How can I achieve this task?
coder hacker
  • 4,819
  • 1
  • 25
  • 50