<div dir="ltr">Ah, right. I hacked my local source with this (I'm guessing this isn't safe...) to see the subsequent problem:<br><br>Index: lib/Analysis/Loads.cpp<br>===================================================================<br>--- lib/Analysis/Loads.cpp    (revision 290827)<br>+++ lib/Analysis/Loads.cpp    (working copy)<br>@@ -382,8 +382,8 @@<br>           return nullptr;<br> <br>         if (IsLoadCSE)<br>-          *IsLoadCSE = false;<br>-        return SI->getOperand(0);<br>+          *IsLoadCSE = isa<LoadInst>(SI->getValueOperand());<br>+        return SI->getValueOperand();<br>       }<br> <br>       // If both StrippedPtr and StorePtr reach all the way to an alloca or<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 3, 2017 at 9:11 AM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Jan 3, 2017 at 7:58 AM, Sanjay Patel <<a href="mailto:spatel@rotateright.com">spatel@rotateright.com</a>> wrote:<br>
> That's what the code comment would have us believe, but... :)<br>
><br>
> define i8* @isa_impl_wrap(i8** %x) {<br>
>   %t2 = alloca i8*<br>
>   %t4 = load i8*, i8** %x, !nonnull !0<br>
>   store i8* %t4, i8** %t2<br>
>   %t6 = load i8*, i8** %t2<br>
>   ret i8* %t6<br>
> }<br>
> !0 = !{}<br>
><br>
> $ ./opt -instcombine cse_nonnull.ll -S<br>
> ...<br>
> define i8* @isa_impl_wrap(i8** %x) {<br>
>   %t4 = load i8*, i8** %x, align 8, !nonnull !0 <--- nonnull preserved when<br>
> earlier instruction has it<br>
>   ret i8* %t4<br>
> }<br>
><br>
<br>
</span>So, it's not that `combineMetadataForCSE` not behaving ideally. When<br>
instcombine runs on your intermediate you don't call it at all.<br>
<br>
Debug:<br>
IC: Visiting:   %t6 = load i8*, i8** %t2<br>
[...]<br>
<br>
(gdb) p LI.dump()<br>
  %t6 = load i8*, i8** %t2, align 8<br>
$2 = void<br>
(gdb) p IsLoadCSE<br>
$3 = false<br>
(gdb) list<br>
853       if (Value *AvailableVal = FindAvailableLoadedValue(<br>
854               &LI, LI.getParent(), BBI, DefMaxInstsToScan, AA,<br>
&IsLoadCSE)) {<br>
855         if (IsLoadCSE)<br>
856           combineMetadataForCSE(cast<<wbr>LoadInst>(AvailableVal), &LI);<br>
857<br>
858         return replaceInstUsesWith(<br>
859             LI, Builder-><wbr>CreateBitOrPointerCast(<wbr>AvailableVal, LI.getType(),<br>
860                                                 LI.getName() + ".cast"));<br>
861       }<br>
<br>
So we call RAUW without combining metadata, (unless I'm missing something).<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Davide<br>
<br>
"There are no solved problems; there are only problems that are more<br>
or less solved" -- Henri Poincare<br>
</div></div></blockquote></div><br></div>