mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[DSE,MSSA] Check if Def is removable only wen we try to remove it.
Non-removable MemoryDefs can still eliminate other defs. Update the isRemovable checks to only candidates for removal.
This commit is contained in:
parent
6927c576ff
commit
d5068f51ec
@ -1535,7 +1535,7 @@ struct DSEState {
|
||||
|
||||
auto *MD = dyn_cast_or_null<MemoryDef>(MA);
|
||||
if (MD && State.MemDefs.size() < MemorySSADefsPerBlockLimit &&
|
||||
State.getLocForWriteEx(&I) && isRemovable(&I))
|
||||
State.getLocForWriteEx(&I))
|
||||
State.MemDefs.push_back(MD);
|
||||
|
||||
// Track whether alloca and alloca-like objects are visible in the
|
||||
@ -1980,7 +1980,8 @@ struct DSEState {
|
||||
<< "Trying to eliminate MemoryDefs at the end of the function\n");
|
||||
for (int I = MemDefs.size() - 1; I >= 0; I--) {
|
||||
MemoryDef *Def = MemDefs[I];
|
||||
if (SkipStores.find(Def) != SkipStores.end())
|
||||
if (SkipStores.find(Def) != SkipStores.end() ||
|
||||
!isRemovable(Def->getMemoryInst()))
|
||||
continue;
|
||||
|
||||
// TODO: Consider doing the underlying object check first, if it is
|
||||
@ -2069,7 +2070,7 @@ bool eliminateDeadStoresMemorySSA(Function &F, AliasAnalysis &AA,
|
||||
const Value *SILocUnd = GetUnderlyingObject(SILoc.Ptr, DL);
|
||||
|
||||
// Check if the store is a no-op.
|
||||
if (State.storeIsNoop(KillingDef, SILoc, SILocUnd)) {
|
||||
if (isRemovable(SI) && State.storeIsNoop(KillingDef, SILoc, SILocUnd)) {
|
||||
LLVM_DEBUG(dbgs() << "DSE: Remove No-Op Store:\n DEAD: " << *SI << '\n');
|
||||
State.deleteDeadInstruction(SI);
|
||||
NumNoopStores++;
|
||||
|
@ -700,7 +700,6 @@ define void @test44_volatile(i32* %P) {
|
||||
|
||||
define void @test45_volatile(i32* %P) {
|
||||
; CHECK-LABEL: @test45_volatile(
|
||||
; CHECK-NEXT: store i32 1, i32* [[P:%.*]], align 4
|
||||
; CHECK-NEXT: store volatile i32 2, i32* [[P]], align 4
|
||||
; CHECK-NEXT: store volatile i32 3, i32* [[P]], align 4
|
||||
; CHECK-NEXT: ret void
|
||||
@ -714,7 +713,6 @@ define void @test45_volatile(i32* %P) {
|
||||
define void @test46_volatile(i32* %P) {
|
||||
; CHECK-LABEL: @test46_volatile(
|
||||
; CHECK-NEXT: store volatile i32 2, i32* [[P:%.*]], align 4
|
||||
; CHECK-NEXT: store i32 1, i32* [[P]], align 4
|
||||
; CHECK-NEXT: store volatile i32 3, i32* [[P]], align 4
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user