Displaying 20 results from an estimated 9000 matches similar to: "[LLVMdev] How do I insert a printf call in the IR?"
2008 Nov 16
2
[LLVMdev] How do I insert a printf call in the IR?
Thanks a lot Nick
-march=cpp was very helpful.
But I still have a small problem, I am trying to insert a printf in a transformation pass.
So when the original program already has a printf, on executing the transformation pass, it tries to create function "printf1" instead of "printf"
Am I missing something here?
Thanks again!
Mrunal
----- Original Message -----
From:
2008 Nov 16
0
[LLVMdev] How do I insert a printf call in the IR?
Shah, Mrunal J wrote:
> Once I have the function
> to make a call to this function I use
>
> CallInst::Create(myPrint, args.begin(), args.end(),"", B);
>
> But I am not being able to pass a string into the argument vector.
> should I define args as
> std::vector<const Type*> args;
> or
> std::vector<const PointerType*> args;
> or
>
2008 Nov 17
2
[LLVMdev] Assertion `castIsValid(getOpcode(), S, Ty) && "Illegal BitCast"' failed.
ok.. So I am trying out what you have suggested. I have written the below code which basically tries to write the constant 10 to a file. myprint is a function pointer to a function which takes char * parameter and writes it to file.
Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
AllocaInst *AI = new AllocaInst(Type::Int32Ty);
Value
2008 Nov 17
1
[LLVMdev] Assertion `InReg && "Value not in map!"' failed
Ah! I get it now. Thanks a lot !
I changed it to BitCastInst(AI,VoidPtrTy,"",j);
And now I am getting the following error :(. I have been stuck with this error before also. I know I am missing out something silly. What is the cause of this error and Please let me know how to fix it.
/home/bhavani/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1130: llvm::SDOperand
2008 Nov 17
1
[LLVMdev] Assertion `InReg && "Value not in map!"' failed
Thanks Nick! ok. I ran through the verifier and this is the issue:
verifying... Instruction does not dominate all uses!
%tmp3 = add i32 %b, %a ; <i32> [#uses=2]
store i32 %tmp3, i32* %0, align 4
Broken module found, compilation aborted!
add is existing instruction in function. store is the instruction I have added to the function. How do I fix this now :(?
Thanks,
Bhavani
--- On Mon,
2006 May 01
2
[LLVMdev] printf decleration
I am writing a pass where I need to make a function deceleration for
printf. Below is the code I'm trying to use.
-----
bool MyPass::runOnModule(Module &m) {
vector<const Type*> args;
args.push_back(PointerType::get(Type::SByteTy));
Function* f = m.getOrInsertFunction("printf",
FunctionType::get(Type::IntTy, args, true));
-----
When I insert a call
2008 Dec 07
1
[LLVMdev] How to extract loop body into a new function?
False Alarm!!
Still don't know how to do it!
I am trying to write a transformation pass to extract a loop body into a function.
For example:
The Loop in question is:
for (i2 = 0; i2 < LOOP_SIZE; i2++) {
A[B[i2]] = 2 * B[i2];
}
The IR for which is:
bb13: ; preds = %bb13, %bb
%i2.0.reg2mem.0 = phi i32 [ 0, %bb ], [ %indvar.next62, %bb13 ] ; <i32>
2006 May 01
0
[LLVMdev] printf decleration
Ok, I think I figured it out. I talked to someone, and we figured out
that when I make a call to printf with a constant string, I need to make
a global variable and use getElementPtr to reference it. The modified
call for accessing the printf is:
/* m is Module*, f is Function*, i is Instruction* */
Constant* constStr = ConstantArray::get("test\n");
GlobalVariable* gv =
2008 Dec 07
0
[LLVMdev] How to extract loop body into a new function?
Sorry!
It worked with ExtractBasicBlock()
----- Original Message -----
From: "Mrunal J Shah" <mrunal.shah at gatech.edu>
To: "llvmdev" <llvmdev at cs.uiuc.edu>
Sent: Saturday, December 6, 2008 8:30:33 PM GMT -05:00 US/Canada Eastern
Subject: [LLVMdev] How to extract loop body into a new function?
Hi All,
I am having trouble extracting loop body into a new
2013 Dec 16
3
[LLVMdev] Add call printf instructions problems
Hello, everyone!
I want to write a pass which can insert a call "printf" instructions
before every instruction in the LLVM IR. here is what I wrote:
namespace {
class call_print : public FunctionPass{
private:
DenseMap<const Value*, int> inst_map;
public:
static char ID;
call_print() : FunctionPass(ID){}
//define a extern function "printf"
static llvm::Function*
2008 Nov 16
1
[LLVMdev] How do I get the result of an instruction?
Hi,
I am writing an optimization pass where I need to instrument the code such that I need to store the results of some instructions in file. Using llc -march=cpp option I figured out how to add a function(say writeToFile) which takes char* parameter and writes to file. Now, I need put in a CallInst which calls writeToFile passing the Instruction result as parameter. How do I do this?
So, in my
2008 Dec 07
2
[LLVMdev] How to extract loop body into a new function?
Hi All,
I am having trouble extracting loop body into a new function. The ExtractLoop() or ExtractBasicBlock() extracts the entire loop along with the header into a new function. All I want is to extract the body of the loop into a new function(without the header).
Is this possible?
Thanks,
Mrunal
2018 Apr 04
1
Call printf with new args
Hello,
My code: (CallInst *CI, IRBuilder<> &B)
SmallVector<Value *, 8> args;
Value *v = B.CreateGlobalString("hi", "str");
args.push_back(v);
SmallVector<Type*, 8> params;
params.push_back(v->getType());
Module *M = B.GetInsertBlock()->getParent()->getParent();
FunctionType *printfType =
2013 Dec 16
0
[LLVMdev] Add call printf instructions problems
Hi Jin,
It's difficult to say just from looking at a pass, but one thing looked odd:
> CallInst *call_print = CallInst::Create(call_print,paramArrayRef,"",ins_temp);
This looks very dodgy. The "call_print" being used as an argument is
the (uninitialised) one that's just been declared. This could be the
source of the assertion failure (though a segfault is just as
2009 May 21
3
[LLVMdev] Passing a pointer to a function
I recently began hacking around with my first LLVM pass. The big
picture is that I would like to insert function calls for each
instruction type, and pass some parameters based on the instruction
type. Then I will link the output to some C file that implements those
functions.
Things were going well until I started trying to make function calls
with a pointer as a parameter. For example, I would
2011 Apr 05
0
[LLVMdev] inserting a print statement into IR
Hi George,
> This is the seg fault I am getting.
>
> dyld: lazy symbol binding failed: Symbol not found:
> __ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE
> Referenced from:
> /Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMArrayBoundsCheck.dylib
> Expected in: flat namespace
>
> dyld: Symbol not found:
2011 Apr 05
2
[LLVMdev] inserting a print statement into IR
This is the seg fault I am getting.
dyld: lazy symbol binding failed: Symbol not found:
__ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE
Referenced from:
/Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMArrayBoundsCheck.dylib
Expected in: flat namespace
dyld: Symbol not found:
__ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE
Referenced from:
2007 Aug 17
1
[LLVMdev] Inserting trace information during opt transformations
Hi all,
In several of the transformations I'm working on I need to embed the
logical equivalent of puts/printf/etc. calls inline with code. I am
having some difficulties getting the transformation code right. As I
understand it, I should be creating a ConstantArray based on the string
(in this case I'm taking an instruction, 'disassembling' it to an
ostringstream then turning
2008 Nov 17
0
[LLVMdev] Assertion `InReg && "Value not in map!"' failed
ok 1 last question for the day...
I created a function in C.
void writeToFile(char *str)
{
FILE *f;
if((f=fopen("example","a"))==NULL){
printf("could not open file");
}
else{
fprintf(f,str);
fclose(f);}
}
used this to create .bc then using llc -march=cpp I got the cpp code to create this function.
While instrumenting my code, I place call to this function.
2013 Aug 19
4
[LLVMdev] Generating GetElementPtr inlined in a function argument list programmatically
Hello LLVMDev List,
It's my first time sending a message to the List - I have been working on a tool for my research project using LLVM. Thanks for your awesome work!
I have come across some bytecode like the following with an GetElementPtr instruction in brackets:
Bytecode:%3 = call i32 @_Z4funcPKc(i8* getelementptr inbounds ([5 x i8]* @.str2, i32 0, i32 0))
C++ code:func("bleh");