<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
On 5/20/11 5:46 PM, Nabila ABDESSAIED wrote:
<blockquote
cite="mid:BANLkTikvm=gQyYDJdcdGWHmR5tx+qmN+uQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<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>
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>
<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 class="moz-txt-link-freetext" href="http://safecode.cs.illinois.edu">http://safecode.cs.illinois.edu</a> under the Download link). I think
it is similar to what you want to do.<br>
<br>
-- John T.<br>
<br>
<blockquote
cite="mid:BANLkTikvm=gQyYDJdcdGWHmR5tx+qmN+uQ@mail.gmail.com"
type="cite">
<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 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>
<div><br>
</div>
<div>Any help</div>
<div>thanks</div>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>