Skip to content

Commit

Permalink
[DSE] Remove alloc function check in canSkipDef()
Browse files Browse the repository at this point in the history
canSkipDef() currently skips inaccessiblememonly calls, but not
if they are allocation functions. This check was added in D103009,
but actually seems to be a leftover from a previous implementation
in D101440. canSkipDef() is not used on the storeIsNoop() path,
where the relevant transform ended up being implemented.

Differential Revision: https://reviews.llvm.org/D117005
  • Loading branch information
nikic committed Jan 17, 2022
1 parent 4b22ffe commit 00b77d9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Expand Up @@ -699,17 +699,14 @@ bool isNoopIntrinsic(Instruction *I) {
}

// Check if we can ignore \p D for DSE.
bool canSkipDef(MemoryDef *D, bool DefVisibleToCaller,
const TargetLibraryInfo &TLI) {
bool canSkipDef(MemoryDef *D, bool DefVisibleToCaller) {
Instruction *DI = D->getMemoryInst();
// Calls that only access inaccessible memory cannot read or write any memory
// locations we consider for elimination.
if (auto *CB = dyn_cast<CallBase>(DI))
if (CB->onlyAccessesInaccessibleMemory()) {
if (isAllocLikeFn(DI, &TLI))
return false;
if (CB->onlyAccessesInaccessibleMemory())
return true;
}

// We can eliminate stores to locations not visible to the caller across
// throwing instructions.
if (DI->mayThrow() && !DefVisibleToCaller)
Expand Down Expand Up @@ -1264,8 +1261,8 @@ struct DSEState {
MemoryDef *CurrentDef = cast<MemoryDef>(Current);
Instruction *CurrentI = CurrentDef->getMemoryInst();

if (canSkipDef(CurrentDef, !isInvisibleToCallerBeforeRet(KillingUndObj),
TLI)) {
if (canSkipDef(CurrentDef,
!isInvisibleToCallerBeforeRet(KillingUndObj))) {
CanOptimize = false;
continue;
}
Expand Down

0 comments on commit 00b77d9

Please sign in to comment.