<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 7 August 2015 at 05:02, Mikael Holmén <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"><span class=""><br>
<br>
On 08/07/2015 01:53 PM, Caldarale, Charles R wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]<br>
On Behalf Of Mikael Holmén via llvm-dev<br>
Subject: [llvm-dev] load instruction erroneously removed by GVN<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
But between the load and the alloca there is also<br>
call fastcc void @format_long(i16* %_tmp30, i16 10, i32 10), !dbg !22<br>
which will use %_tmp30 to write in the alloca'd buffer.<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Shoulnd't MemoryDependenceAnalysis::getDependency rather return the call?<br>
</blockquote>
<br>
Depends. What is the exact declaration of format_long?<br>
</blockquote>
<br></span>
In the input .ll file it is:<br>
<br>
; Function Attrs: minsize optsize<br>
define internal i16 @format_long(i16* %res.8.par, i16 %base.9.par, i32 %x.10.par) #3 {<br>
<br>
which is later changed somewhere in opt to:<br>
<br>
; Function Attrs: minsize nounwind optsize<br>
define internal fastcc i16 @format_long(i16* %res.8.par, i16 %base.9.par, i32 %x.10.par) #2 {<br></blockquote><div><br></div><div>That's part of it, but we also need to see what #3 and #2 refer to in this context. Those should be grouped at the end of your .ll, something like</div><div><br></div><div>attributes #3 = { nobuiltin nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }</div><div><br></div><div>or</div><div><br></div><div>attributes #2 = { nounwind readonly }</div><div><br></div><div>If @format_long is marked with the 'readonly' or 'readnone' attribute then GVN would be justified in doing the transformation you've described.<br></div><div><br></div><div>Nick</div></div></div></div>