1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[DSE,MemorySSA] Check for underlying objects first.

isWriteAtEndOfFunction needs to check all memory uses of Def, which is
much more expensive than getting the underlying objects in practice.
Switch the call order, as recommended by the TODO, which was added as
per an earlier review.

This shaves off a bit of compile-time.
This commit is contained in:
Florian Hahn 2020-08-14 15:25:01 +01:00
parent 53df467cf7
commit 5e27736c76

View File

@ -2045,16 +2045,13 @@ struct DSEState {
!isRemovable(Def->getMemoryInst()))
continue;
// TODO: Consider doing the underlying object check first, if it is
// beneficial compile-time wise.
if (isWriteAtEndOfFunction(Def)) {
Instruction *DefI = Def->getMemoryInst();
// See through pointer-to-pointer bitcasts
SmallVector<const Value *, 4> Pointers;
getUnderlyingObjects(getLocForWriteEx(DefI)->Ptr, Pointers);
auto DefLoc = getLocForWriteEx(DefI);
if (!DefLoc)
continue;
getUnderlyingObjects(DefLoc->Ptr, Pointers);
LLVM_DEBUG(dbgs() << " ... MemoryDef is not accessed until the end "
"of the function\n");
bool CanKill = true;
for (const Value *Pointer : Pointers) {
if (!InvisibleToCallerAfterRet.count(Pointer)) {
@ -2063,13 +2060,15 @@ struct DSEState {
}
}
if (CanKill) {
if (CanKill && isWriteAtEndOfFunction(Def)) {
// See through pointer-to-pointer bitcasts
LLVM_DEBUG(dbgs() << " ... MemoryDef is not accessed until the end "
"of the function\n");
deleteDeadInstruction(DefI);
++NumFastStores;
MadeChange = true;
}
}
}
return MadeChange;
}