<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 13, 2017 at 5:04 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> +/// Check if the given user is an alias (looking through bit casts).<br>
> +static bool userIsAlias(Value *V) {<br>
> +  if (isa<GlobalAlias>(V))<br>
> +    return true;<br>
> +  if (BitCastOperator *BC = dyn_cast<BitCastOperator>(V)) {<br>
> +    for (Use &U : BC->materialized_uses()) {<br>
> +      return userIsAlias(U.getUser());<br>
<br>
Using a for that always returns in the first iteration looks a bit odd<br>
IMHO.<br></blockquote><div><br></div><div>Mehdi pointed that out too - will change to assert that there is a single use without a loop.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> +/// Like replaceAllUsesWith but doesn't replace any uses that are<br>
> +/// aliases, so that we can just replace uses of the original value<br>
> +/// with the new private aliasee, but keep the original value name<br>
> +/// as an alias to it.<br>
> +static void replaceAllUsesWithExceptAliase<wbr>s(Value *Old, Value *New) {<br>
<br>
When first reading the code I got the impression that this would convert<br>
<br>
@foo = weak alias @bar<br>
<br>
....<br>
call @foo<br>
...<br>
<br>
into calling @bar directly. Please add that to the test to show that it<br>
is not the case. In fact, I think a good test would be<br>
<br>
@bar = global...<br>
@foo = alias @bar<br>
<br>
...<br>
use @bar<br>
...<br>
use @foo<br>
<br>
and check that we still have a use of @bar and a use of @foo, but now<br>
@bar and @foo are an alias to a private global.<br></blockquote><div><br></div><div>Enhanced the existing test to check that existing references (not from alias definition) are not renamed. Will upload when I upload the other fixes.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
> +<br>
> +    // Don't make malformed IR (will be caught by verifier) worse.<br>
> +    if (GO->isDeclarationForLinker())<br>
> +      continue;<br>
<br>
When is a pass expected to be run on malformed IR?<br></blockquote><div><br></div><div>I hit this in a test case. If I don't add this then the test was asserting somewhere instead of hitting the expected verification error.</div><div><br></div><div>Thanks,</div><div>Teresa</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>