[DeadStoreElimination] Check function modref behavior before considering memory clobbered

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

llvm-svn: 296625
This commit is contained in:
Igor Laevsky 2017-03-01 14:38:29 +00:00
parent 7835d8c042
commit d9a0db4f6e
2 changed files with 13 additions and 1 deletions

View File

@ -551,7 +551,7 @@ static bool memoryIsNotModifiedBetween(Instruction *FirstI,
Instruction *I = &*BI;
if (I->mayWriteToMemory() && I != SecondI) {
auto Res = AA->getModRefInfo(I, MemLoc);
if (Res != MRI_NoModRef)
if (Res & MRI_Mod)
return false;
}
}

View File

@ -41,3 +41,15 @@ define void @test3() {
store i64 0, i64* %s
ret void
}
declare noalias i8* @calloc(i64, i64)
define void @test4() {
; CHECK-LABEL: @test4
%local_obj = call i8* @calloc(i64 1, i64 4)
call void @foo() ["deopt" (i8* %local_obj)]
store i8 0, i8* %local_obj, align 4
; CHECK-NOT: store i8 0, i8* %local_obj, align 4
call void @bar(i8* nocapture %local_obj)
ret void
}