[llvm] r286108 - [AliasSetTracker] Make AST smarter about assume intrinsics that don't actually affect memory.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 06:11:46 PST 2016


Author: mcrosier
Date: Mon Nov  7 08:11:45 2016
New Revision: 286108

URL: http://llvm.org/viewvc/llvm-project?rev=286108&view=rev
Log:
[AliasSetTracker] Make AST smarter about assume intrinsics that don't actually affect memory.

Differential Revision: https://reviews.llvm.org/D26252

Added:
    llvm/trunk/test/Analysis/AliasSet/intrinsics.ll
Modified:
    llvm/trunk/lib/Analysis/AliasSetTracker.cpp

Modified: llvm/trunk/lib/Analysis/AliasSetTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasSetTracker.cpp?rev=286108&r1=286107&r2=286108&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasSetTracker.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasSetTracker.cpp Mon Nov  7 08:11:45 2016
@@ -413,6 +413,18 @@ void AliasSetTracker::add(MemTransferIns
 void AliasSetTracker::addUnknown(Instruction *Inst) {
   if (isa<DbgInfoIntrinsic>(Inst))
     return; // Ignore DbgInfo Intrinsics.
+
+  if (auto *II = dyn_cast<IntrinsicInst>(Inst)) {
+    // These intrinsics will show up as affecting memory, but they are just
+    // markers.
+    switch (II->getIntrinsicID()) {
+    default:
+      break;
+      // FIXME: Add lifetime/invariant intrinsics (See: PR30807).
+    case Intrinsic::assume:
+      return;
+    }
+  }
   if (!Inst->mayReadOrWriteMemory())
     return; // doesn't alias anything
 

Added: llvm/trunk/test/Analysis/AliasSet/intrinsics.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/AliasSet/intrinsics.ll?rev=286108&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/AliasSet/intrinsics.ll (added)
+++ llvm/trunk/test/Analysis/AliasSet/intrinsics.ll Mon Nov  7 08:11:45 2016
@@ -0,0 +1,19 @@
+; RUN: opt -basicaa -print-alias-sets -S -o - < %s 2>&1 | FileCheck %s
+
+; CHECK: Alias sets for function 'test1':
+; CHECK: Alias Set Tracker: 2 alias sets for 2 pointer values.
+; CHECK:   AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod       Pointers: (i8* %a, 1)
+; CHECK-NOT: 1 Unknown instruction
+; CHECK:   AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod       Pointers: (i8* %b, 1)
+define void @test1(i32 %c) {
+entry:
+  %a = alloca i8, align 1
+  %b = alloca i8, align 1
+  store i8 1, i8* %a, align 1
+  %cond1 = icmp ne i32 %c, 0
+  call void @llvm.assume(i1 %cond1)
+  store i8 1, i8* %b, align 1
+  ret void
+}
+
+declare void @llvm.assume(i1)




More information about the llvm-commits mailing list