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
8
votes
2 answers

Possible to auto-generate llvm c++ api code from LLVM-IR?

The clang 3.0 online demo page http://llvm.org/demo/index.cgi provides an option to output LLVM C++ API code" representing the LLVM-IR for the input program. Is "produce LLVM C++ API code" output a clang option (and if so, what is it)? Or is it an…
Bogatyr
  • 19,255
  • 7
  • 59
  • 72
8
votes
1 answer

What is LLVM Comdat?

What does comdat in LLVM represents? You can find the source here:Comdata An example from source level program representation (c++) would be very much helpful. If you need more info, please feel free to ask. I find it in many places in llvm code…
PreeJackie
  • 587
  • 4
  • 14
8
votes
1 answer

How can I create an executable from LLVM ir?

I am currently using llc to convert a .ll file to a .s using the commandline. Then I want to take this file and then use nasm to create an executable from it. While the first step seems to work fine, I can't get the second step to work. the…
lncr
  • 826
  • 8
  • 16
8
votes
1 answer

what does "materialize" mean in llvm GlobalValue.h

I'm a beginner of LLVM. When I go through the LLVM's API, I have a naive question: what does the "materialize" mean in llvm GlobalValue.h in the doxygen: http://llvm.org/doxygen/classllvm_1_1GlobalValue.html#ac1b5643f40dd3c7b92a548027eb13de0 it…
ignorer
  • 327
  • 1
  • 11
8
votes
1 answer

How to generate LLVM SSA Format

I write the following C code where variable X is being assigned twice: int main() { int x; x = 10; x = 20; return 0; } Compile and generate IR representation using the following command clang -emit-llvm -c ssa.c IR…
Shehbaz Jaffer
  • 1,944
  • 8
  • 23
  • 30
8
votes
1 answer

Execute LLVM IR code generated from Rust/Python source code

When I generate LLVM IR Code from C++, I can use the console command clang++ -emit-llvm –S test.cpp to get a test.ll file which is the LLVM IR I want. To get an executable these are the steps to follow: llvm-as test.ll -> gives me the test.bc…
Philipp
  • 745
  • 2
  • 7
  • 20
8
votes
1 answer

restrict qualifier in C vs noalias attribute in LLVM IR

my question is related to the different semantics of the restrict qualifier in C and the noalias attribute in LLVM when they are used as function parameters. According to the LLVM documentation for noalias: This indicates that objects accessed via…
Kiko Fernandez
  • 857
  • 10
  • 26
8
votes
1 answer

Passing structs by-value in LLVM IR

I'm generating LLVM IR for JIT purposes, and I notice that LLVM's calling conventions don't seem to match the C calling conventions when aggregate values are involved. For instance, when I declare a function as taking a {i32, i32} (that is, a struct…
Dolda2000
  • 25,216
  • 4
  • 51
  • 92
8
votes
1 answer

LLVM MCJIT / SEH Exception handling

Lately, I've been attempting to get SEH exception handling to work in LLVM (3.8.1) together with MCJIT. So far without any luck. From what I understand from the website ( http://llvm.org/docs/ExceptionHandling.html ), this is pretty much how this…
atlaste
  • 30,418
  • 3
  • 57
  • 87
8
votes
1 answer

LLVM struct array iteration

While compiling this code with LLVM: struct bar { int int1; int int2; char char1; char char2; char char3; }; struct foo { struct bar array[16]; }; int func(struct foo *f, int num) { for(int i = 0; i < num; i++){ …
Eitan Ziv
  • 81
  • 2
8
votes
3 answers

Using swift compiler for bare metal?

I would really like to use swift for embedded programming as I feel like its a much better replacement for c++, The processor I'm using is an ARM Cortex-M4F(http://www.ti.com/tool/ek-tm4c123gxl). Looking at the swift compiler page, it says you can…
jack sexton
  • 1,227
  • 1
  • 9
  • 28
8
votes
1 answer

How to parse LLVM IR line by line

I specifically need to parse LLVM IR code line by line during runtime of my c++ code where I need to know what operation is happening on what operands on each line. For example, if the IR code is: %0 = load i32* %a, align 4 I would like to know…
Saksham Jain
  • 81
  • 1
  • 2
8
votes
1 answer

Building V8 with Clang and emitting LLVM IR

I am attempting to build the V8 Javascript engine with Clang and output an .ll file(s). I am trying to combine the information here and here to do this. However, when I try to make, it fails, saying "No rule to make target." I am lost. I've tried…
PitaJ
  • 12,969
  • 6
  • 36
  • 55
8
votes
1 answer

Identifying user define function through llvm pass

Is there anyway by which I can identify whether the callee function is a user define or not? For example: void foo() { printf("hello world again"); } int main() { printf("hello world\n"); foo(); } As in this case foo() is a user define,…
Abhinash Jain
  • 169
  • 10
8
votes
3 answers

How to save IR to a file and build it to an executable file?

Now I use clang build my .c file to .s file. And I have used the llvm API modify the IR. However, now I can't save my modified IR to a file. I want to use "LLVMWriteBitcodeToFile", but I can't find the struct of "LLVMOpaqueModule"; I want to use…
Kun Lee
  • 97
  • 1
  • 8