[LLVMdev] inserting a fucntion call at the end of basic bloc

Nabila ABDESSAIED nabila.abdessaied at gmail.com
Tue Apr 26 04:38:15 PDT 2011


I have defined the fucntion in another object file and linked it to the
in fact the fucntion is :
void consume(int ,  int * );


 std::vector<Value*> int32_16_params;
int32_16_params.push_back(inValue);//inValue is ConstantInt* inValue
int32_16_params.push_back(gvar_int32_y);
CallInst* int32_16 = CallInst::Create(func_consume, int32_16_params.begin(),
int32_16_params.end(), "", ii);

compilation without errors
Now when i tried this pass an error says:
Wrong type for attribute noalias
tail call void @consume(i32 noalias 3, i32* @y) nounwind
Wrong type for attribute noalias
  tail call void @consume(i32 noalias 3, i32* @y) nounwind
Broken module found, compilation aborted!
0  libLLVM-2.8.so.1 0x019bc628
Stack dump:
0. Program arguments: opt -load
/home/inspiron/PhdWork/llvm-2.8/Release/lib/Example.so -Example2
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'Module Verifier' on function '@main'
Aborted
Any help?

2011/4/25 Duncan Sands <baldrick at free.fr>

> Hi Nabila,
>
>
>  My problem is how to call a method
>> suppose this fucntion
>> void A(int x)
>> {
>>   x=x+1;
>>
>> }
>>
>> should i define this function and declare it at the beginig of the module
>> and
>> create for it a basic bloc?
>>
>
> you can just declare the function (i.e. no need to give it a body), and
> call it.
> You can then link with an object file that defines it.  This is simpler
> than
> injecting the function into each module (though that is easy to do too).
>
>
>  and then how to call it before each basic bloc terminitor
>>
>
> Use an IRBuilder.  Pass the basic block terminator to SetInsertPoint.  Use
> one
> of the CreateCall IRBuilder methods to insert a call instruction.
>
> Ciao, Duncan.
>
>
>>    ...
>>
>>     > i tried to see an example with the demo, i saw that it instead of
>> calling the
>>     > function, it repeats all the instruction that are existing in the
>> function
>>     > Any help?
>>
>>    Turn off optimization in the demo (optimization level "None").
>>
>>    Ciao, Duncan.
>>    _______________________________________________
>>    LLVM Developers mailing list
>>    LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>
>> http://llvm.cs.uiuc.edu
>>
>>    http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110426/b5fa3a0c/attachment.html>


More information about the llvm-dev mailing list