mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-28 02:37:37 +00:00
[MemorySSA] Update last_access_in_block check.
The check for "was there an access in this block" should be: is the last access in this block and is it not a newly inserted phi. Resolves new test in PR43438. Also fix a typo when simplifying trivial Phis to match the comment. llvm-svn: 373380
This commit is contained in:
parent
2cee0e2d97
commit
ae40dfc1e3
@ -303,7 +303,12 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) {
|
||||
|
||||
// See if we had a local def, and if not, go hunting.
|
||||
MemoryAccess *DefBefore = getPreviousDef(MD);
|
||||
bool DefBeforeSameBlock = DefBefore->getBlock() == MD->getBlock();
|
||||
bool DefBeforeSameBlock = false;
|
||||
if (DefBefore->getBlock() == MD->getBlock() &&
|
||||
!(isa<MemoryPhi>(DefBefore) &&
|
||||
std::find(InsertedPHIs.begin(), InsertedPHIs.end(), DefBefore) !=
|
||||
InsertedPHIs.end()))
|
||||
DefBeforeSameBlock = true;
|
||||
|
||||
// There is a def before us, which means we can replace any store/phi uses
|
||||
// of that thing with us, since we are in the way of whatever was there
|
||||
@ -628,7 +633,7 @@ void MemorySSAUpdater::updatePhisWhenInsertingUniqueBackedgeBlock(
|
||||
|
||||
// If NewMPhi is a trivial phi, remove it. Its use in the header MPhi will be
|
||||
// replaced with the unique value.
|
||||
tryRemoveTrivialPhi(MPhi);
|
||||
tryRemoveTrivialPhi(NewMPhi);
|
||||
}
|
||||
|
||||
void MemorySSAUpdater::updateForClonedLoop(const LoopBlocksRPO &LoopBlocks,
|
||||
|
@ -44,3 +44,57 @@ if.end569: ; preds = %if.else568, %if.the
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
; CHECK-LABEL: @f()
|
||||
; CHECK: 8 = MemoryPhi(
|
||||
; CHECK: 7 = MemoryPhi(
|
||||
; CHECK: 11 = MemoryPhi(
|
||||
; CHECK: 10 = MemoryPhi(
|
||||
; CHECK: 9 = MemoryPhi(
|
||||
define void @f() {
|
||||
entry:
|
||||
%e = alloca i16, align 1
|
||||
br label %lbl1
|
||||
|
||||
lbl1: ; preds = %if.else, %for.end5, %entry
|
||||
store i16 undef, i16* %e, align 1
|
||||
%0 = load i16, i16* %e, align 1
|
||||
%call = call i16 @g(i16 %0)
|
||||
br i1 undef, label %for.end, label %if.else
|
||||
|
||||
for.end: ; preds = %if.then
|
||||
br i1 true, label %for.cond2, label %lbl2
|
||||
|
||||
lbl2: ; preds = %for.body4, %if.end
|
||||
br label %for.cond2
|
||||
|
||||
for.cond2: ; preds = %lbl3
|
||||
br i1 undef, label %for.body4, label %for.end5
|
||||
|
||||
for.body4: ; preds = %for.cond2
|
||||
br label %lbl2
|
||||
|
||||
for.end5: ; preds = %for.cond2
|
||||
switch i32 undef, label %unreachable [
|
||||
i32 0, label %if.end12
|
||||
i32 2, label %lbl1
|
||||
]
|
||||
|
||||
if.else: ; preds = %lbl1
|
||||
switch i32 undef, label %unreachable [
|
||||
i32 0, label %if.end12
|
||||
i32 2, label %lbl1
|
||||
]
|
||||
|
||||
if.end12: ; preds = %cleanup.cont11s, %cleanup.cont
|
||||
call void @llvm.lifetime.end.p0i8(i64 1, i8* undef)
|
||||
ret void
|
||||
|
||||
unreachable: ; preds = %if.else, %for.end5
|
||||
unreachable
|
||||
}
|
||||
|
||||
declare i16 @g(i16)
|
||||
|
||||
; Function Attrs: argmemonly nounwind willreturn
|
||||
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
|
||||
|
Loading…
Reference in New Issue
Block a user