<div dir="ltr">LGTM</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 10:15 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, chandlerc, hfinkel, reames, sanjoy.<br>
gberry added a subscriber: llvm-commits.<br>
Herald added a subscriber: mcrosier.<br>
<br>
<a href="http://reviews.llvm.org/D19730" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19730</a><br>
<br>
Files:<br>
lib/Analysis/BasicAliasAnalysis.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,17 @@<br>
+; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %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/Analysis/BasicAliasAnalysis.cpp<br>
===================================================================<br>
--- lib/Analysis/BasicAliasAnalysis.cpp<br>
+++ lib/Analysis/BasicAliasAnalysis.cpp<br>
@@ -575,6 +575,12 @@<br>
if (F->doesNotAccessMemory())<br>
return FMRB_DoesNotAccessMemory;<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 (F->getIntrinsicID() == Intrinsic::assume)<br>
+ return FMRB_DoesNotAccessMemory;<br>
+<br>
FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior;<br>
<br>
// If the function declares it only reads memory, go with that.<br>
<br>
<br>
</blockquote></div><br></div>