<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 8/17/2017 12:01 PM, (IIIT) Siddharth
Bhat via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPipc=2pJJCDfZ6tqV5tLx4JwScNg3pJE9QyNRSp_TZr31kKpA@mail.gmail.com">
<div dir="ltr">Sure. Essentially, I'm trying to replace malloc and
free with custom variants of these calls. However, in certain
situations, we receive these calls within bitcasts, for
example,
<div><br>
</div>
<div>
<div><font face="monospace">call void bitcast (void (i8*)*
@free to void (%struct.fson_string*)*)</font></div>
<div><font face="monospace"> (%struct.fson_string* %13) #2</font></div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>A simple replaceAllUsesWith is not going to work, because
the <font face="monospace">@free</font> is within a bitcast,
which is a <font face="monospace">ConstantExpr</font>. Unless
I did something wrong, this particular occurence of <font
face="monospace">@free</font> was not replaced even when I
called <font face="monospace">replaceAllUsesOf</font> on the
<font face="monospace">@free</font> object.</div>
</div>
</blockquote>
<br>
You likely did something wrong; clang does this all the time, and it
works. See, for example, CodeGenModule::GetOrCreateLLVMGlobal.<br>
<br>
-Eli
<pre class="moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
</body>
</html>