[llvm] d95d1c3 - [DSE] Return std::optional from getPointerSize() (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 06:13:49 PDT 2023


Author: Nikita Popov
Date: 2023-10-23T15:13:14+02:00
New Revision: d95d1c382bfc6abdf4b7764d57ba7e6098e98f5b

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

LOG: [DSE] Return std::optional from getPointerSize() (NFC)

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 026758e3206ea66..7074dbc2c7b905c 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -205,16 +205,17 @@ static bool isShortenableAtTheBeginning(Instruction *I) {
   return isa<AnyMemSetInst>(I);
 }
 
-static uint64_t getPointerSize(const Value *V, const DataLayout &DL,
-                               const TargetLibraryInfo &TLI,
-                               const Function *F) {
+static std::optional<uint64_t> getPointerSize(const Value *V,
+                                              const DataLayout &DL,
+                                              const TargetLibraryInfo &TLI,
+                                              const Function *F) {
   uint64_t Size;
   ObjectSizeOpts Opts;
   Opts.NullIsUnknownSize = NullPointerIsDefined(F);
 
   if (getObjectSize(V, Size, DL, &TLI, Opts))
     return Size;
-  return MemoryLocation::UnknownSize;
+  return std::nullopt;
 }
 
 namespace {
@@ -951,9 +952,9 @@ struct DSEState {
     // case the size/offset of the dead store does not matter.
     if (DeadUndObj == KillingUndObj && KillingLocSize.isPrecise() &&
         isIdentifiedObject(KillingUndObj)) {
-      uint64_t KillingUndObjSize = getPointerSize(KillingUndObj, DL, TLI, &F);
-      if (KillingUndObjSize != MemoryLocation::UnknownSize &&
-          KillingUndObjSize == KillingLocSize.getValue())
+      std::optional<uint64_t> KillingUndObjSize =
+          getPointerSize(KillingUndObj, DL, TLI, &F);
+      if (KillingUndObjSize && *KillingUndObjSize == KillingLocSize.getValue())
         return OW_Complete;
     }
 


        


More information about the llvm-commits mailing list