Skip to content

Commit 00b77d9

Browse files
committed
[DSE] Remove alloc function check in canSkipDef()
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
1 parent 4b22ffe commit 00b77d9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,17 +699,14 @@ bool isNoopIntrinsic(Instruction *I) {
699699
}
700700

701701
// Check if we can ignore \p D for DSE.
702-
bool canSkipDef(MemoryDef *D, bool DefVisibleToCaller,
703-
const TargetLibraryInfo &TLI) {
702+
bool canSkipDef(MemoryDef *D, bool DefVisibleToCaller) {
704703
Instruction *DI = D->getMemoryInst();
705704
// Calls that only access inaccessible memory cannot read or write any memory
706705
// locations we consider for elimination.
707706
if (auto *CB = dyn_cast<CallBase>(DI))
708-
if (CB->onlyAccessesInaccessibleMemory()) {
709-
if (isAllocLikeFn(DI, &TLI))
710-
return false;
707+
if (CB->onlyAccessesInaccessibleMemory())
711708
return true;
712-
}
709+
713710
// We can eliminate stores to locations not visible to the caller across
714711
// throwing instructions.
715712
if (DI->mayThrow() && !DefVisibleToCaller)
@@ -1264,8 +1261,8 @@ struct DSEState {
12641261
MemoryDef *CurrentDef = cast<MemoryDef>(Current);
12651262
Instruction *CurrentI = CurrentDef->getMemoryInst();
12661263

1267-
if (canSkipDef(CurrentDef, !isInvisibleToCallerBeforeRet(KillingUndObj),
1268-
TLI)) {
1264+
if (canSkipDef(CurrentDef,
1265+
!isInvisibleToCallerBeforeRet(KillingUndObj))) {
12691266
CanOptimize = false;
12701267
continue;
12711268
}

0 commit comments

Comments
 (0)