[clang] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 23 02:19:47 PST 2026


================
@@ -1206,10 +1217,23 @@ struct DSEState {
     return OW_None;
   }
 
-  bool isInvisibleToCallerAfterRet(const Value *V) {
+  bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+                                   const LocationSize StoreSize) {
     if (isa<AllocaInst>(V))
       return true;
 
+    if (InvisibleToCallerAfterRetBounded.contains(V)) {
+      int64_t ValueOffset;
+      const Value *BaseValue =
+          GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
+      assert(BaseValue == V);
+      // This store is only invisible after return if we are in bounds of the
+      // range marked dead.
+      if (ValueOffset + StoreSize.getValue() <=
----------------
nikic wrote:

This will crash for a store of scalable vector a variable-length memset.

https://github.com/llvm/llvm-project/pull/173694


More information about the cfe-commits mailing list