<div dir="ltr"><div>I have defined the fucntion in another object file and linked it to the </div><div>in fact the fucntion is :</div><div>void consume(int ,  int * );</div><div><br></div><div> </div><div><div> std::vector<Value*> int32_16_params;</div>
<div>int32_16_params.push_back(inValue);//inValue is ConstantInt* inValue</div><div>int32_16_params.push_back(gvar_int32_y);</div></div><div><div>CallInst* int32_16 = CallInst::Create(func_consume, int32_16_params.begin(), int32_16_params.end(), "", ii);</div>
<div>                </div></div><div>compilation without errors</div><div>Now when i tried this pass an error says:</div><div>Wrong type for attribute noalias</div><div>tail call void @consume(i32 noalias 3, i32* @y) nounwind</div>
<div><div>Wrong type for attribute noalias</div><div>  tail call void @consume(i32 noalias 3, i32* @y) nounwind</div><div>Broken module found, compilation aborted!</div><div>0  libLLVM-2.8.so.1 0x019bc628</div><div>Stack dump:</div>
<div>0.<span class="Apple-tab-span" style="white-space:pre">    </span>Program arguments: opt -load /home/inspiron/PhdWork/llvm-2.8/Release/lib/Example.so -Example2 </div><div>1.<span class="Apple-tab-span" style="white-space:pre">     </span>Running pass 'Function Pass Manager' on module '<stdin>'.</div>
<div>2.<span class="Apple-tab-span" style="white-space:pre">    </span>Running pass 'Module Verifier' on function '@main'</div><div>Aborted</div></div><div>Any help?</div><br><div class="gmail_quote">2011/4/25 Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Nabila,<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
My problem is how to call a method<br>
suppose this fucntion<br>
void A(int x)<br>
{<br>
   x=x+1;<br>
<br>
}<br>
<br>
should i define this function and declare it at the beginig of the module and<br>
create for it a basic bloc?<br>
</blockquote>
<br></div>
you can just declare the function (i.e. no need to give it a body), and call it.<br>
You can then link with an object file that defines it.  This is simpler than<br>
injecting the function into each module (though that is easy to do too).<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
and then how to call it before each basic bloc terminitor<br>
</blockquote>
<br></div>
Use an IRBuilder.  Pass the basic block terminator to SetInsertPoint.  Use one<br>
of the CreateCall IRBuilder methods to insert a call instruction.<br>
<br>
Ciao, Duncan.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
    ...<br>
<br>
     > i tried to see an example with the demo, i saw that it instead of calling the<br>
     > function, it repeats all the instruction that are existing in the function<br>
     > Any help?<br>
<br>
    Turn off optimization in the demo (optimization level "None").<br>
<br>
    Ciao, Duncan.<br>
    _______________________________________________<br>
    LLVM Developers mailing list<br></div>
    <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><div class="im">
<br>
    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
<br>
</div></blockquote>
<br>
</blockquote></div><br></div>