<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><br></div><div>I currently have a really hacky way of achieving this: I expand every <font face="monospace">ConstantExpr</font> that uses this <font face="monospace">Value</font> into Instructions, on which I then call <font face="monospace">replaceUsesOfWith</font>.</div><div><br></div><div>However, a neater solution would be appreciated.</div><div><br></div><div>Cheers,</div><div>Siddharth.</div><div>On Thu, 17 Aug 2017 at 10:22 Nemanja Ivanovic via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Siddarth,<br>Perhaps to provide a short explanation why you want to RAUW ConstantExpr's. Then others are likely to be able to provide you with more useful feedback for how you can accomplish your goal.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 17, 2017 at 8:53 AM, (IIIT) Siddharth Bhat via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I see. Is there a pre-existing way to do this in LLVM?<div><br></div><div>Cheers,</div><div>~Siddharth.</div></div><div class="m_2569216384254635254HOEnZb"><div class="m_2569216384254635254h5"><br><div class="gmail_quote"><div dir="ltr">On Thu, 17 Aug 2017 at 02:12 Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">ConstantExprs are immutable, they can't be changed once they are created. And a ConstantExpr can reference other ConstantExprs. So replacing all uses of a Value in a ConstantExpr would require creating a new immutable object for each ConstantExpr that references the one you're changing. And that would continue rippling outward.</div><div class="gmail_extra"><br clear="all"><div><div class="m_2569216384254635254m_535050674654066251m_-4296670739728889239gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 16, 2017 at 5:01 PM, (IIIT) Siddharth Bhat via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Whoops, sorry, I meant "value->replaceAllUsesWith".</p>
<p dir="ltr">Should I create a new post with an updated title?</p>
<p dir="ltr">Thanks <br><span class="m_2569216384254635254m_535050674654066251m_-4296670739728889239HOEnZb"><font color="#888888">
Siddharth </font></span></p><span class="m_2569216384254635254m_535050674654066251m_-4296670739728889239im m_2569216384254635254m_535050674654066251m_-4296670739728889239HOEnZb">
<br><div class="gmail_quote"><div dir="ltr">On Thu 17 Aug, 2017, 01:05 Tim Northover <<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 16 August 2017 at 15:39, (IIIT) Siddharth Bhat via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> From what I have observed, using `Inst->replaceAllUsesWith` does not replace<br>
> uses of the `Inst` in `ConstantExpr`s. Is there some way to have a universal<br>
> replaceAllUsesWith?<br>
<br>
Where are you seeing instructions used in ConstantExprs? That sounds<br>
really dodgy to me. Instructions are horribly non-Constant so I'd have<br>
thought it would be banned (even for technically plausible things like<br>
"and(i32 %inst, 0)").<br>
<br>
Cheers.<br>
<br>
Tim.<br>
</blockquote></div></span><div class="m_2569216384254635254m_535050674654066251m_-4296670739728889239HOEnZb"><div class="m_2569216384254635254m_535050674654066251m_-4296670739728889239h5"><div dir="ltr">-- <br></div><div class="m_2569216384254635254m_535050674654066251m_-4296670739728889239m_2887562354550737643gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>
</div></div><br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><div dir="ltr">-- <br></div><div class="m_2569216384254635254m_535050674654066251gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>
</div></div><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div></div><div dir="ltr">-- <br></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>