<div dir="ltr"><br><br><div class="gmail_quote">2011/5/20 John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div text="#000000" bgcolor="#ffffff"><div class="im">
On 5/20/11 5:46 PM, Nabila ABDESSAIED wrote:
<blockquote type="cite">
<div dir="ltr">
<div>Hi all, </div>
<div><br>
</div>
<div>Please i need help, I have a method that takes 2 arguments
with type char *:</div>
<div>void branchPredict(char *b1, char *b2){</div>
<div>---</div>
<div>--</div>
<div>}</div>
<div>i'm supposed to add this method, in an IR basic bloc:</div>
<div>to add it into a basic bloc i do:</div>
</div>
</blockquote>
<br></div>
The problem is that you are passing arrays to the function instead
of passing pointers to arrays. Instead of making tbname and pbname
arguments to the function, you need to create GlobalVariable's that
have, as their initializer, the Constant's tbname and pbname.<br></div></blockquote><div>i couldn't use that sollution because i repeat the process in each basic bloc in a function.</div><div>the globalvariable could be initiallized with constants that have the same array type but in my case the constants i get in each basic bloc haven't the same array type</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div text="#000000" bgcolor="#ffffff">
<br>
You may also have to take the GlobalVariables and insert a cast
instruction (bitcast) to cast them from pointers to arrays to
pointers of i8. However, that is easy to do.<br>
<br>
See line 138 of lib/DebugInstrumentation/DebugInstrumentation.cpp in
the SAFECode source tree (directions for getting it from SVN are at
<a href="http://safecode.cs.illinois.edu" target="_blank">http://safecode.cs.illinois.edu</a> under the Download link). I think
it is similar to what you want to do.<br></div></blockquote><div>ok , i will use this. </div><div><br></div><div><br></div><div>i have seen it and here is what i did</div><div><br></div><div><div> std::string fbname =i->getNameStr();</div>
<div> std::string tbname = i->getPrevNode()->getNameStr();</div><div> Constant * tname = ConstantArray::get(Context, tbname);</div><div> Constant * fname = ConstantArray::get(Context, fbname);</div>
<div> Value * TBloc, *FBloc;</div><div> TBloc = new GlobalVariable(M,</div><div> tname->getType(),</div><div> true,</div>
<div> GlobalValue::InternalLinkage,</div><div> tname,</div><div> "tBloc");</div><div> FBloc = new GlobalVariable(M,</div>
<div> fname->getType(),</div><div> true,</div><div> GlobalValue::InternalLinkage,</div><div> fname,</div>
<div> "fBloc");</div><div> std::vector<Value*> void_43_params;</div><div> void_43_params.push_back(TBloc);</div>
<div> void_43_params.push_back(FBloc);</div><div> CallInst* void_43 = CallInst::Create(func_branchPredict, void_43_params.begin(), void_43_params.end(), "", i->getTerminator());</div>
<div> </div></div><div>but i have error :</div><div><br></div><div><div>Call parameter type does not match function signature!</div><div>[3 x i8]* @tBloc</div><div> i8* call void @branchPredict([3 x i8]* @tBloc, [3 x i8]* @fBloc)</div>
<div>Call parameter type does not match function signature!</div><div>[4 x i8]* @tBloc3</div><div> i8* call void @branchPredict([4 x i8]* @tBloc3, [4 x i8]* @fBloc4)</div><div>Broken module found, compilation aborted!</div>
<div>0 libLLVM-2.8.so.1 0x014c7628</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 -Example6 </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> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div text="#000000" bgcolor="#ffffff">
<br>
-- John T.<br>
<br>
<blockquote type="cite"><div class="im">
<div dir="ltr">
<div><br>
</div>
<div>//i: is the basic bloc</div>
<div>
<div>std::vector<Value*> void_43_params;</div>
<div>Constant* tbname =
ConstantArray::get(M.getContext(),i->getNameStr() ,
true);</div>
<div>Constant* pbname = ConstantArray::get(M.getContext(),
i->getPrevNode()->getNameStr(), true);</div>
<div>void_43_params.push_back(tbname); </div>
<div>void_43_params.push_back(pbname);</div>
<div>CallInst* void_43 = CallInst::Create(func_branchPredict,
void_43_params.begin(), void_43_params.end(), "",
i->getTerminator());</div>
</div>
<div><br>
</div>
<div>when i execute the pass (opt -load ....) i get an error:
</div>
<div><br>
</div>
<div>
<div>Call parameter type does not match function signature!</div>
<div>[3 x i8] c"bb\00"</div>
<div> i8* call void @branchPredict([3 x i8] c"bb\00", [4 x
i8] c"bb1\00")</div>
<div>Call parameter type does not match function signature!</div>
<div>[4 x i8] c"bb5\00"</div>
<div> i8* call void @branchPredict([4 x i8] c"bb5\00", [18 x
i8] c"bb3.bb3_crit_edge\00")</div>
<div>Broken module found, compilation aborted!</div>
<div>0 libLLVM-2.8.so.1 0x01421628</div>
<div>Stack dump:</div>
<div>0.<span style="white-space:pre-wrap">
</span>Program arguments: opt -load
/home/inspiron/PhdWork/llvm-2.8/Release/lib/Example.so
-Example6 </div>
<div>1.<span style="white-space:pre-wrap">
</span>Running pass 'Function Pass Manager' on module
'<stdin>'.</div>
<div>2.<span style="white-space:pre-wrap">
</span>Running pass 'Module Verifier' on function '@main'</div>
<div>Aborted</div>
</div>
<div> </div>
<div><br>
</div>
<div>Any help</div>
<div>thanks</div>
</div>
</div><pre><fieldset></fieldset>
_______________________________________________
LLVM Developers mailing list
<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>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div><br></div>