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
0 answers

Move LLVM IR out of SSA form

I am attempting to write a pass which would eliminate phi nodes in llvm IR. Although I have converted the llvm IR to CSSA form I am not sure how to actually remove the phi nodes. From a broader perspective, I want to do RA directly from LLVM IR. The…
ssarangi
  • 602
  • 1
  • 10
  • 28
0
votes
2 answers

Use of inserted instruction is necessary or not

In LLVM is it necessary that if we insert some instruction in LLVM IR through LLVM Pass ,than also we have to insert an instruction which will use the result of our previous inserted instruction or we have to store result of our inserted instruction…
techcomp
  • 370
  • 3
  • 16
0
votes
1 answer

LLVM IR instruction insertion

In a Function iterator loop when i put the following code for(BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE; ++BI) { if(isa(&(*BI)) ) { if(i==0) …
techcomp
  • 370
  • 3
  • 16
0
votes
0 answers

LLVM getBackedgeTakenCount() behavior

I have the following loop for(i=5;i<5000;i++){ } I am using getBackedgeTakenCount() from Scalar Evolution. The above loop has determinable loop count, then why is the function giving me Cannot Compute? Am I missing something. I have used…
coder hacker
  • 4,819
  • 1
  • 25
  • 50
0
votes
1 answer

llvm: visitInstruction does not visit every instruction in a basic block?

I am trying to write a Simple pass on basic block and the code is as follows: struct SimplePass : BasicBlockPass, InstVisitor { ... some initialisation and some finalization code virtual bool runOnBasicBlock(BasicBlock& B) { …
Bob Fang
  • 6,963
  • 10
  • 39
  • 72
0
votes
2 answers

how to make clang compile to LLVM IR with textual labels for simple function

Hello I have to parse some LLVM IR code for a compiler course. I am very new to LLVM. I have clang and LLVM on my computer, and when I compile a simple C program: #include int main(int argc, char *argv[]) { for (int i = 0; i < 10;…
slmyers
  • 767
  • 1
  • 8
  • 21
0
votes
1 answer

Undefined symbols for architecture x86_64 on Mac OS X when compiling using LLVM

I am trying to make the compiler in this project using LLVM shipped in Mac OS X Yosemite and getting the following error mentioned in this Issue on Github https://github.com/lsegal/my_toy_compiler/issues/17 When running the make all command, it…
Encore PTL
  • 8,084
  • 10
  • 43
  • 78
0
votes
2 answers

LLVM C++ Program Compilation

Hi I have written a simple C++ code with the LLVM Api #include #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/IRBuilder.h" int main() { llvm::LLVMContext& context = llvm::getGlobalContext(); …
user1423561
  • 327
  • 1
  • 3
  • 18
0
votes
0 answers

LLVM Basic Program : Linker Error

I am just getting started with llvm. Here's code I am trying to compile: #include #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/IRBuilder.h" int main() { llvm::LLVMContext& context =…
user1423561
  • 327
  • 1
  • 3
  • 18
0
votes
1 answer

LLVM: Defining a new type via OCaml bindings

I'm using the LLVM OCaml bindings to build a compiler for an untyped language. Unfortunately, the only reference I have is llvm.mli from the source. So, I tried declaring a value_t as follows: let llar = [| i64_type; array_type i8_type…
artagnon
  • 3,609
  • 3
  • 23
  • 26
0
votes
1 answer

Create global vector using LLVM IR Builder

I want to build up LLVM IR for the following expression to add a scalar to a vector [1,2,3,4]+1 I have found the correct methods to create the add and the scalar expression but not for the vector. Value *L = //Missing code here Value *R =…
jap
  • 617
  • 3
  • 13
0
votes
1 answer

LLVM - What optimizations frontend has done

I know that frontend (such as llvm-clang or llvm-gcc ) has also done some optimizations from native code to IR level. But what's optimizations that frontend has done ? Is there a list or a document I can check. Thanks.
Sam
  • 4,521
  • 13
  • 46
  • 81
0
votes
1 answer

LLVM create function with type "Instruction*"

I want to use Function::Create method to create a function whose input parameter type is llvm::Instruction* but I didn't find any direct method in class Type to do that. Can anyone give me some hints? Also For a concrete compare Instruction *pi, I…
Min Gao
  • 383
  • 4
  • 16
0
votes
1 answer

Trouble understanding llvm.global.annotations

I am trying to understand the global annotations which I get with a kernel from llvm but I am kinda confused on a couple of things. @sgv = internal constant [4 x i8] c"222\00" @fgv = internal constant [0 x i8] zeroinitializer @lvgv = internal…
ssarangi
  • 602
  • 1
  • 10
  • 28
0
votes
1 answer

Print a dot file from llvm pass

I know that from your llvm pass you can call : viewCFG() or viewCFGOnly to view a graphviz representation of a function. These creates and store the .dot files somewhere in the \tmp folder under linux. Is there any way to specify in which file to…
Kyriakos
  • 757
  • 8
  • 23