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

LLVM front end register class error OpenCL -- GPU target

I've recently been encountering this error when compiling OpenCL kernel files with my LLVM_IR pass: aoc: ../../../TargetRegisterInfo.cpp:89: const llvm::TargetRegisterClass* llvm::TargetRegisterInfo::getMinimalPhysRegClass(unsigned int, llvm::EVT)…
0
votes
0 answers

How can i use a global variable in IR llvm

I want to insert an add instruction in LLVM IR format, something like x = 0 ; ... x = x + 1, where x is global variable. I have tried this: Value *ZERO = ConstantInt::get(Type::getInt32Ty(Context),0); GlobalVariable *gVar = new…
Mos Moh
  • 317
  • 3
  • 15
0
votes
1 answer

Why doesn't Clang vectorise big-int XOR?

When I compile this simple word-wise XOR example, Clang 3.4 does not vectorise it. Why? It seems simpler than the examples in http://llvm.org/docs/Vectorizers.html#features and we do not have data-dependency between single words. So in theory, this…
cpt. jazz
  • 1,336
  • 12
  • 21
0
votes
1 answer

Tracking global definitions in LLVM

I am trying to manually build a list of instructions where a particular variable is getting assigned a value in the LLVM IR. For local variables in a function, i can easily get the right set of instructions by using the instruction iterator and…
vPraetor
  • 313
  • 1
  • 3
  • 13
0
votes
1 answer

replacealluseswith does not work

The SWL is a map where i have store address as key and the constant as its corresponding value. However when i check this store being used in load i try to replace the uses of the store instruction with the constant. Doing so does not replace the…
user3342227
  • 123
  • 1
  • 5
0
votes
2 answers

LLVM-IR array pointer assignment

In C++/C you can do this: unsigned char A[12]; unsigned int *B; int *C; B = malloc(sizeof(unsigned int)); C = malloc(2*sizeof(int)); A[0] = *B; A[4] = *C; //Then go on to access A byte by byte. I was wondering if this was possible in LLVM-IR, or…
redratio1
  • 5
  • 4
0
votes
1 answer

LLVM-IR GEP for OpenCL local array access

I created a local array in my OpenCL kernel via llvm, call it lookuptable of size [ 256 x i32 ]. Later I insert code via llvm to fill the array with values. My issue is that when I attempt to generate code that accesses the array I cannot seem to…
redratio1
  • 5
  • 4
0
votes
1 answer

Can't figure out if SLEM library is usable

I would like to generate LLVM IR for a toy language whose compiler is written in Scala. SLEM seems to be exactly what I need but I can't figure out if it's usable in its current state. I tried to download the sources but I am unable to compile…
anotherCode245
  • 703
  • 1
  • 8
  • 20
0
votes
1 answer

How LLVM generates bitcodes(IR) for structure

I searched the source code of LLVM, but I failed to find the exact code slices which show how LLVM generate bitcodes(IR) for structure. I search the keyword 'StructType::create' and 'StructType::get', but there are so many occurrences. Could anyone…
0
votes
1 answer

Need insights about writing a pass

For my source code, I have the following IR: ; ModuleID = '' @.str = private unnamed_addr constant [9 x i8] c"SOME_ENV_VAR\00", align 1 @.str1 = private unnamed_addr constant [26 x i8] c"Need to set $ENV_Variable.\0A\00", align 1 ;…
t7t0t0t7t
  • 362
  • 3
  • 5
0
votes
1 answer

LLVM Post-processing binary file with IR Pass

I have created a function that checks the integrity of a portion of binary code. The function is added with a llvm pass. It needs the begin and end address plus a check value. The check value is the result of a computation on a binary code. Saddly,…
0
votes
2 answers

Changing source code at compilation time (using LLVM)

#include #include int foo(char* a) { char str[10]; if (strlen(a)<10) { sprintf(str,"Yes"); puts(str); return 0; } else { sprintf(str,"No"); puts(str); …
t7t0t0t7t
  • 362
  • 3
  • 5
0
votes
1 answer

LLVM : generating a "ir" file for specifically z80 processor using llvm

I am working on LLVM, and want to generate the files according to specific target architecure e.g-z80. I have downloaded z80 source code and clang. I used --target in clang command to specify z80 but it is not working. can anybody help me out in…
0
votes
1 answer

Change in source code

I have two question I have done some changes in C-backend of LLVM-2.9 source code. Now what I wanna is how can I reflect these changes in build folder? What does make update do ? When I run this command this is what happen in my…
Arpit Sancheti
  • 248
  • 2
  • 12
0
votes
1 answer

Will GetElementPtr work as expected

I am writing llvm code using C++. I have a place in my code where the below scenario happens 1. %117 = phi <2 x double>* [ %105, %aligned ], [ %159, %116 ] 7. %123 = getelementptr <2 x double>* %117, i32 0 8. %127 = getelementptr <2 x double>*…
Kaniks
  • 277
  • 1
  • 4
  • 8