<div dir="ltr">So, should we not just move this into getModRefInfo?<div><br></div><div>(It seems like general applicable alias knowledge that requires no computation)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 28, 2016 at 11:49 AM, Geoff Berry <span dir="ltr"><<a href="mailto:gberry@codeaurora.org" target="_blank">gberry@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">gberry created this revision.<br>
gberry added reviewers: dberlin, george.burgess.iv.<br>
gberry added a subscriber: llvm-commits.<br>
Herald added a subscriber: mcrosier.<br>
<br>
Treat assume intrinsics as not reading/writing memory despite<br>
AA->getModRefInfo() saying they do, as is done in BasicAliasAnalysis.<br>
<br>
<a href="http://reviews.llvm.org/D19676" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19676</a><br>
<br>
Files:<br>
lib/Transforms/Utils/MemorySSA.cpp<br>
test/Transforms/Util/MemorySSA/assume.ll<br>
<br>
Index: test/Transforms/Util/MemorySSA/assume.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/Transforms/Util/MemorySSA/assume.ll<br>
@@ -0,0 +1,18 @@<br>
+; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %s 2>&1 | FileCheck %s<br>
+; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>' -verify-memoryssa -disable-output < %s 2>&1 | FileCheck %s<br>
+;<br>
+; Ensures that assumes are treated as not reading or writing memory.<br>
+<br>
+declare void @llvm.assume(i1)<br>
+<br>
+define i32 @foo(i32* %a, i32* %b, i1 %c) {<br>
+; CHECK: 1 = MemoryDef(liveOnEntry)<br>
+; CHECK-NEXT: store i32 4<br>
+ store i32 4, i32* %a, align 4<br>
+; CHECK: call void @llvm.assume<br>
+ call void @llvm.assume(i1 %c)<br>
+; CHECK: MemoryUse(1)<br>
+; CHECK-NEXT: %1 = load i32<br>
+ %1 = load i32, i32* %a, align 4<br>
+ ret i32 %1<br>
+}<br>
Index: lib/Transforms/Utils/MemorySSA.cpp<br>
===================================================================<br>
--- lib/Transforms/Utils/MemorySSA.cpp<br>
+++ lib/Transforms/Utils/MemorySSA.cpp<br>
@@ -364,6 +364,14 @@<br>
bool Def = bool(ModRef & MRI_Mod);<br>
bool Use = bool(ModRef & MRI_Ref);<br>
<br>
+ // While the assume intrinsic is marked as arbitrarily writing so that<br>
+ // proper control dependencies will be maintained, it never aliases any<br>
+ // particular memory location.<br>
+ if (match(I, PatternMatch::m_Intrinsic<Intrinsic::assume>())) {<br>
+ Def = false;<br>
+ Use = false;<br>
+ }<br>
+<br>
// It's possible for an instruction to not modify memory at all. During<br>
// construction, we ignore them.<br>
if (IgnoreNonMemory && !Def && !Use)<br>
<br>
<br>
</blockquote></div><br></div>