diff options
| author | Chad Rosier <mcrosier@codeaurora.org> | 2016-11-07 14:11:45 +0000 |
|---|---|---|
| committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-11-07 14:11:45 +0000 |
| commit | 8f348017b006125befee82425865feb4499cc3b1 (patch) | |
| tree | cc75c52a499b28cb0f70b71f47f0423e1b64f799 | |
| parent | b03e0879fccd3e5fedd51df18a9e7055fee8db95 (diff) | |
| download | bcm5719-llvm-8f348017b006125befee82425865feb4499cc3b1.tar.gz bcm5719-llvm-8f348017b006125befee82425865feb4499cc3b1.zip | |
[AliasSetTracker] Make AST smarter about assume intrinsics that don't actually affect memory.
Differential Revision: https://reviews.llvm.org/D26252
llvm-svn: 286108
| -rw-r--r-- | llvm/lib/Analysis/AliasSetTracker.cpp | 12 | ||||
| -rw-r--r-- | llvm/test/Analysis/AliasSet/intrinsics.ll | 19 |
2 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp index 954b22037ed..701b0e1a592 100644 --- a/llvm/lib/Analysis/AliasSetTracker.cpp +++ b/llvm/lib/Analysis/AliasSetTracker.cpp @@ -413,6 +413,18 @@ void AliasSetTracker::add(MemTransferInst *MTI) { 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 diff --git a/llvm/test/Analysis/AliasSet/intrinsics.ll b/llvm/test/Analysis/AliasSet/intrinsics.ll new file mode 100644 index 00000000000..100b5a10134 --- /dev/null +++ b/llvm/test/Analysis/AliasSet/intrinsics.ll @@ -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) |

