mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[MemorySSA] Don't hoist stores if interfering uses (as calls) exist.
llvm-svn: 373674
This commit is contained in:
parent
47a80aaad6
commit
e0abdc6f76
@ -1248,12 +1248,22 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
|
||||
// FIXME: More precise: no Uses that alias SI.
|
||||
if (!Flags->IsSink && !MSSA->dominates(SIMD, MU))
|
||||
return false;
|
||||
} else if (const auto *MD = dyn_cast<MemoryDef>(&MA))
|
||||
} else if (const auto *MD = dyn_cast<MemoryDef>(&MA)) {
|
||||
if (auto *LI = dyn_cast<LoadInst>(MD->getMemoryInst())) {
|
||||
(void)LI; // Silence warning.
|
||||
assert(!LI->isUnordered() && "Expected unordered load");
|
||||
return false;
|
||||
}
|
||||
// Any call, while it may not be clobbering SI, it may be a use.
|
||||
if (auto *CI = dyn_cast<CallInst>(MD->getMemoryInst())) {
|
||||
// Check if the call may read from the memory locattion written
|
||||
// to by SI. Check CI's attributes and arguments; the number of
|
||||
// such checks performed is limited above by NoOfMemAccTooLarge.
|
||||
ModRefInfo MRI = AA->getModRefInfo(CI, MemoryLocation::get(SI));
|
||||
if (isModOrRefSet(MRI))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto *Source = MSSA->getSkipSelfWalker()->getClobberingMemoryAccess(SI);
|
||||
|
34
test/Analysis/MemorySSA/pr43540.ll
Normal file
34
test/Analysis/MemorySSA/pr43540.ll
Normal file
@ -0,0 +1,34 @@
|
||||
; RUN: opt -S -licm -enable-mssa-loop-dependency=true %s | FileCheck %s
|
||||
@v_1 = global i8 0, align 1
|
||||
@v_2 = global i8 0, align 1
|
||||
|
||||
; CHECK-LABEL: @foo()
|
||||
; CHECK: for.cond:
|
||||
; CHECK-NOT: store
|
||||
; CHECK: for.body:
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
||||
; CHECK: store
|
||||
define void @foo() {
|
||||
entry:
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.body, %entry
|
||||
%0 = phi i16 [ %inc, %for.body ], [ 0, %entry ]
|
||||
%cmp = icmp slt i16 %0, 1
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
call void @llvm.memcpy.p0i8.p0i8.i64(i8* @v_1, i8 * @v_2, i64 1, i1 false)
|
||||
store i8 1, i8 * @v_2, align 1
|
||||
%inc = add nsw i16 %0, 1
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: argmemonly nounwind willreturn
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8 * noalias nocapture readonly, i64, i1 immarg) #2
|
||||
|
||||
attributes #2 = { argmemonly nounwind willreturn }
|
||||
|
@ -84,7 +84,7 @@ loop:
|
||||
}
|
||||
|
||||
; But can hoist if the side effect is hoisted with MSSA
|
||||
define void @test2b_prime(i1 %cond, i32* %ptr) {
|
||||
define void @test2b_prime(i1 %cond, i32* noalias %ptr) {
|
||||
; MSSA-LABEL: @test2b_prime(
|
||||
; MSSA-NEXT: entry:
|
||||
; MSSA-NEXT: [[P2:%.*]] = getelementptr i32, i32* [[PTR:%.*]], i32 1
|
||||
|
Loading…
Reference in New Issue
Block a user