diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index f96309eb4d1..301ee2f663b 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -266,8 +266,8 @@ static bool isRemovable(Instruction *I) { } } - if (CallSite(I)) // If we assume hasMemoryWrite(I) is true, - return true; // then there's nothing left to check. + if (CallSite CS = I) + return CS.getInstruction()->use_empty(); return false; } diff --git a/test/Transforms/DeadStoreElimination/libcalls.ll b/test/Transforms/DeadStoreElimination/libcalls.ll index b83780b399d..ffdf62b2150 100644 --- a/test/Transforms/DeadStoreElimination/libcalls.ll +++ b/test/Transforms/DeadStoreElimination/libcalls.ll @@ -44,3 +44,13 @@ define void @test4(i8* %src) { ret void } +define void @test5(i8* nocapture %src) { +; CHECK: @test5 + %dest = alloca [100 x i8], align 16 + %arraydecay = getelementptr inbounds [100 x i8]* %dest, i64 0, i64 0 + %call = call i8* @strcpy(i8* %arraydecay, i8* %src) +; CHECK: %call = call i8* @strcpy + %arrayidx = getelementptr inbounds i8* %call, i64 10 + store i8 97, i8* %arrayidx, align 1 + ret void +}