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

Error in ModulePass with setting the successor of a BasicBlock

In The following code in LLVM unsigned ii=0; BasicBlock* Bb = &*i; TerminatorInst *TI = i->getTerminator(); for( std::set::iterator rit=Result.begin(); rit!=Result.end();++rit,++ii) { TI->setSuccessor(ii,(*rit)); …
R.Omar
  • 645
  • 1
  • 6
  • 18
0
votes
1 answer

Outputting input's constant char array from llvm pass

all I want to know how a llvm pass output constant char array defined from the input source. Here's an example that I want to do. Test input source char* msg = "hello, world\n"; void msg_out(char * in) { printf("msg: %s \n", in); } main ()…
kjee
  • 359
  • 5
  • 19
0
votes
1 answer

Vector Addition Program in LLVM

I am trying to write a 5-element vector addition program in LLVM and can't figure out how to return the entire resultant vector. My code is below, and the error is LLVM ERROR: Invalid return type of main() supplied @veca = global [5 x i32] [i32…
FCo
  • 485
  • 5
  • 17
0
votes
1 answer

C++ how to call IR function

I have a C++ file, which hassome functions, such as:int myMax(int a,int b), and compile it to a llvm IR. Now I want to operate the IR in another C++ file, I don't know how to call the function(such as: myMax)in my C++ file.
Kun Lee
  • 97
  • 1
  • 8
0
votes
1 answer

Why it's so trouble when I want to insert some instructions in basicblock?

I found it so trouble when I try to insert some instruction in basicblock. AllocaInst* pa = new AllocaInst(Type::getInt32Ty(getGlobalContext()), 0, 4, "dataKey"); Value* dataValue = ConstantInt::get(IntegerType::get(getGlobalContext(),6) ,…
Kun Lee
  • 97
  • 1
  • 8
0
votes
2 answers

How to get variable definition line number etc. using dbg metadata?

As far as I know, when I need to get the line number of a local variable I had to look for the invocation of the llvm.dbg.declare intrinsics and get the dbg metadata(since AllocaInst itself does not contain any dbg info). However there seems no…
Hongxu Chen
  • 5,240
  • 2
  • 45
  • 85
0
votes
1 answer

Array Detection in Function arg list LLVM opt pass

suppose I have the following LLVM IR define void @foo(i32* %a, i32* %m) nounwind { ... and I call foo by passing an array for the first arg and passing a variable's address for m. Now, I need to analyse the arg list of foo and determine which arg is…
earlence
  • 323
  • 1
  • 4
  • 11
-1
votes
1 answer

static analysis of linux kernel on source code or LLVM IR?

in https://www.usenix.org/system/files/sec21-tan.pdf the authors do static analysis on LLVM IR of linux kernel (a pass for call graph construction, a pass for data flow analysis and alias analysis and ...). and in some other papers I see they do…
saha
  • 23
  • 5
-1
votes
1 answer

Converting string to lltype in order to utilize struct_set_body?

I'm trying to generate LLVM ir, and currently have this let fill_structs = StringMap.iter (fun k v -> L.struct_set_body k v false ) structs (* more let...in statements *) The error message I'm getting is over my 'k' that I pass into…
Shisui
  • 1,051
  • 1
  • 8
  • 23
-1
votes
1 answer

Load globalvariable raw data value in llvm

When I iterate GlobalVariable and use: Constant *initializer = gv->getInitializer(); ConstantDataSequential *cdata = dyn_cast(initializer); const char *array=cdata->getRawDataValues().data() to put them into a char array, I…
Luba A
  • 81
  • 9
-1
votes
1 answer

How to extract constant in the branch condition?

I need to extract the constant involved in a branch condition. For instance, in the branch if(a > 10), 10 is what I want to extract. I wonder how to do that using LLVM? The corresponding LLVM instruction for the above branch is %cmp = icmp sgt i32…
Dingbao Xie
  • 716
  • 9
  • 21
-1
votes
1 answer

LLVM - code generation flow

When I went through the LLVM document, There are meanings in some terms that I dont fully understand. Please provide feedbacks if you know any. [Frontend] Source code --> Tokeniser (Token stream) --> Parser ( Parser Action ) Can someone explain…
Sam
  • 4,521
  • 13
  • 46
  • 81
-1
votes
1 answer

LLVM converting a Constant to a Value

I am using custom LLVM pass where if I encounter a store to where the compiler converts the value to a Constant; e.g. there is an explicit store: X[gidx] = 10; Then LLVM will generate this error: aoc: ../../../Instructions.cpp:1056: void…
-2
votes
1 answer

How to generate code from LLVM which is then I want to given as the input to the Z3 prover

I have to generate an intermediate code from LLVM and I have to given that as the input to the Z3 prover. Is it possible?
-2
votes
1 answer

Does LLVM IR has scope for duplicated variable name?

I'm new to LLVM, does LLVM IR has scope for duplicated variable name ? For example: @x = global i32 0 define void @hello() { %x = alloca i32, align 4 } Does @x variable name duplicates with %x ?
linrongbin
  • 2,967
  • 6
  • 31
  • 59
1 2 3
84
85