1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

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

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

llvm-svn: 286108
This commit is contained in:
Chad Rosier 2016-11-07 14:11:45 +00:00
parent 39cc4bbf20
commit f56813d057
2 changed files with 31 additions and 0 deletions

View File

@ -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

View File

@ -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)