[llvm] 00b77d9 - [DSE] Remove alloc function check in canSkipDef()

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 17 00:25:49 PST 2022


Author: Nikita Popov
Date: 2022-01-17T09:23:51+01:00
New Revision: 00b77d917cd8e062b93e080f35cfd5aa15348f31

URL: https://github.com/llvm/llvm-project/commit/00b77d917cd8e062b93e080f35cfd5aa15348f31
DIFF: https://github.com/llvm/llvm-project/commit/00b77d917cd8e062b93e080f35cfd5aa15348f31.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 04b13188e932c..c18f33a930b6f 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -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)
@@ -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;
       }


        


More information about the llvm-commits mailing list