[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/aeubanks approved this pull request. https://github.com/llvm/llvm-project/pull/173694 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH 1/3] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
>From 805d7b8f4c1bb9d394a6d0760bc7de2a274fda30 Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Wed, 14 Jan 2026 17:22:23 +
Subject: [PATCH 2/3] feedback
Created using spr 1.3.7
---
.../Scalar/DeadStoreElimination.cpp | 27 ++--
.../Transforms/DeadStoreElimination/simple.ll | 31 +--
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 78734beac4bbe..20436b92412f9 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1018,16 +1018,19 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
for (Argument &AI : F.args()) {
- if (AI.hasPassPointeeByValueCopyAttr() ||
- (AI.getType()->isPointerTy() &&
- AI.getDeadOnReturnInfo().coversAllReachableMemory()))
+ if (AI.hasPassPointeeByValueCopyAttr()) {
InvisibleToCallerAfterRet.insert({&AI, true});
- if (AI.getType()->isPointerTy() &&
- !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
-if (uint64_t DeadOnReturnBytes =
-AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
- InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+continue;
}
+
+ if (!AI.getType()->isPointerTy())
+continue;
+
+ const DeadOnReturnInfo &Info = AI.getDeadOnReturnInfo();
+ if (Info.coversAllReachableMemory())
+InvisibleToCallerAfterRet.insert({&AI, true});
+ else if (uint64_t DeadBytes = Info.getNumberOfDeadBytes())
+InvisibleToCallerAfterRetBounded.insert({&AI, DeadBytes});
}
// Collect whether there is any irreducible control flow in the function.
@@ -1225,8 +1228,11 @@ struct DSEState {
const Value *BaseValue =
GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
assert(BaseValue == V);
- if (ValueOffset + StoreSize.toRaw() <
- InvisibleToCallerAfterRetBounded[BaseValue])
+ // This store is only invisible after return if we are in bounds of the
+ // range marked dead.
+ if (ValueOffset + StoreSize.getValue() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
return true;
}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
@@ -1899,6 +1905,7 @@ struct DSEState {
if (CapturedBeforeReturn.erase(UO))
ShouldIterateEndOfFunctionDSE = true;
InvisibleToCallerAfterRet.erase(UO);
+ I
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH 1/3] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
>From 805d7b8f4c1bb9d394a6d0760bc7de2a274fda30 Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Wed, 14 Jan 2026 17:22:23 +
Subject: [PATCH 2/3] feedback
Created using spr 1.3.7
---
.../Scalar/DeadStoreElimination.cpp | 27 ++--
.../Transforms/DeadStoreElimination/simple.ll | 31 +--
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 78734beac4bbe..20436b92412f9 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1018,16 +1018,19 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
for (Argument &AI : F.args()) {
- if (AI.hasPassPointeeByValueCopyAttr() ||
- (AI.getType()->isPointerTy() &&
- AI.getDeadOnReturnInfo().coversAllReachableMemory()))
+ if (AI.hasPassPointeeByValueCopyAttr()) {
InvisibleToCallerAfterRet.insert({&AI, true});
- if (AI.getType()->isPointerTy() &&
- !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
-if (uint64_t DeadOnReturnBytes =
-AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
- InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+continue;
}
+
+ if (!AI.getType()->isPointerTy())
+continue;
+
+ const DeadOnReturnInfo &Info = AI.getDeadOnReturnInfo();
+ if (Info.coversAllReachableMemory())
+InvisibleToCallerAfterRet.insert({&AI, true});
+ else if (uint64_t DeadBytes = Info.getNumberOfDeadBytes())
+InvisibleToCallerAfterRetBounded.insert({&AI, DeadBytes});
}
// Collect whether there is any irreducible control flow in the function.
@@ -1225,8 +1228,11 @@ struct DSEState {
const Value *BaseValue =
GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
assert(BaseValue == V);
- if (ValueOffset + StoreSize.toRaw() <
- InvisibleToCallerAfterRetBounded[BaseValue])
+ // This store is only invisible after return if we are in bounds of the
+ // range marked dead.
+ if (ValueOffset + StoreSize.getValue() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
return true;
}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
@@ -1899,6 +1905,7 @@ struct DSEState {
if (CapturedBeforeReturn.erase(UO))
ShouldIterateEndOfFunctionDSE = true;
InvisibleToCallerAfterRet.erase(UO);
+ I
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH 1/3] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
>From 805d7b8f4c1bb9d394a6d0760bc7de2a274fda30 Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Wed, 14 Jan 2026 17:22:23 +
Subject: [PATCH 2/3] feedback
Created using spr 1.3.7
---
.../Scalar/DeadStoreElimination.cpp | 27 ++--
.../Transforms/DeadStoreElimination/simple.ll | 31 +--
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 78734beac4bbe..20436b92412f9 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1018,16 +1018,19 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
for (Argument &AI : F.args()) {
- if (AI.hasPassPointeeByValueCopyAttr() ||
- (AI.getType()->isPointerTy() &&
- AI.getDeadOnReturnInfo().coversAllReachableMemory()))
+ if (AI.hasPassPointeeByValueCopyAttr()) {
InvisibleToCallerAfterRet.insert({&AI, true});
- if (AI.getType()->isPointerTy() &&
- !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
-if (uint64_t DeadOnReturnBytes =
-AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
- InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+continue;
}
+
+ if (!AI.getType()->isPointerTy())
+continue;
+
+ const DeadOnReturnInfo &Info = AI.getDeadOnReturnInfo();
+ if (Info.coversAllReachableMemory())
+InvisibleToCallerAfterRet.insert({&AI, true});
+ else if (uint64_t DeadBytes = Info.getNumberOfDeadBytes())
+InvisibleToCallerAfterRetBounded.insert({&AI, DeadBytes});
}
// Collect whether there is any irreducible control flow in the function.
@@ -1225,8 +1228,11 @@ struct DSEState {
const Value *BaseValue =
GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
assert(BaseValue == V);
- if (ValueOffset + StoreSize.toRaw() <
- InvisibleToCallerAfterRetBounded[BaseValue])
+ // This store is only invisible after return if we are in bounds of the
+ // range marked dead.
+ if (ValueOffset + StoreSize.getValue() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
return true;
}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
@@ -1899,6 +1905,7 @@ struct DSEState {
if (CapturedBeforeReturn.erase(UO))
ShouldIterateEndOfFunctionDSE = true;
InvisibleToCallerAfterRet.erase(UO);
+ I
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH 1/3] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
>From 805d7b8f4c1bb9d394a6d0760bc7de2a274fda30 Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Wed, 14 Jan 2026 17:22:23 +
Subject: [PATCH 2/3] feedback
Created using spr 1.3.7
---
.../Scalar/DeadStoreElimination.cpp | 27 ++--
.../Transforms/DeadStoreElimination/simple.ll | 31 +--
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 78734beac4bbe..20436b92412f9 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1018,16 +1018,19 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
for (Argument &AI : F.args()) {
- if (AI.hasPassPointeeByValueCopyAttr() ||
- (AI.getType()->isPointerTy() &&
- AI.getDeadOnReturnInfo().coversAllReachableMemory()))
+ if (AI.hasPassPointeeByValueCopyAttr()) {
InvisibleToCallerAfterRet.insert({&AI, true});
- if (AI.getType()->isPointerTy() &&
- !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
-if (uint64_t DeadOnReturnBytes =
-AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
- InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+continue;
}
+
+ if (!AI.getType()->isPointerTy())
+continue;
+
+ const DeadOnReturnInfo &Info = AI.getDeadOnReturnInfo();
+ if (Info.coversAllReachableMemory())
+InvisibleToCallerAfterRet.insert({&AI, true});
+ else if (uint64_t DeadBytes = Info.getNumberOfDeadBytes())
+InvisibleToCallerAfterRetBounded.insert({&AI, DeadBytes});
}
// Collect whether there is any irreducible control flow in the function.
@@ -1225,8 +1228,11 @@ struct DSEState {
const Value *BaseValue =
GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
assert(BaseValue == V);
- if (ValueOffset + StoreSize.toRaw() <
- InvisibleToCallerAfterRetBounded[BaseValue])
+ // This store is only invisible after return if we are in bounds of the
+ // range marked dead.
+ if (ValueOffset + StoreSize.getValue() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
return true;
}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
@@ -1899,6 +1905,7 @@ struct DSEState {
if (CapturedBeforeReturn.erase(UO))
ShouldIterateEndOfFunctionDSE = true;
InvisibleToCallerAfterRet.erase(UO);
+ I
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH 1/3] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
>From 805d7b8f4c1bb9d394a6d0760bc7de2a274fda30 Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Wed, 14 Jan 2026 17:22:23 +
Subject: [PATCH 2/3] feedback
Created using spr 1.3.7
---
.../Scalar/DeadStoreElimination.cpp | 27 ++--
.../Transforms/DeadStoreElimination/simple.ll | 31 +--
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 78734beac4bbe..20436b92412f9 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1018,16 +1018,19 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
for (Argument &AI : F.args()) {
- if (AI.hasPassPointeeByValueCopyAttr() ||
- (AI.getType()->isPointerTy() &&
- AI.getDeadOnReturnInfo().coversAllReachableMemory()))
+ if (AI.hasPassPointeeByValueCopyAttr()) {
InvisibleToCallerAfterRet.insert({&AI, true});
- if (AI.getType()->isPointerTy() &&
- !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
-if (uint64_t DeadOnReturnBytes =
-AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
- InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+continue;
}
+
+ if (!AI.getType()->isPointerTy())
+continue;
+
+ const DeadOnReturnInfo &Info = AI.getDeadOnReturnInfo();
+ if (Info.coversAllReachableMemory())
+InvisibleToCallerAfterRet.insert({&AI, true});
+ else if (uint64_t DeadBytes = Info.getNumberOfDeadBytes())
+InvisibleToCallerAfterRetBounded.insert({&AI, DeadBytes});
}
// Collect whether there is any irreducible control flow in the function.
@@ -1225,8 +1228,11 @@ struct DSEState {
const Value *BaseValue =
GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
assert(BaseValue == V);
- if (ValueOffset + StoreSize.toRaw() <
- InvisibleToCallerAfterRetBounded[BaseValue])
+ // This store is only invisible after return if we are in bounds of the
+ // range marked dead.
+ if (ValueOffset + StoreSize.getValue() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
return true;
}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
@@ -1899,6 +1905,7 @@ struct DSEState {
if (CapturedBeforeReturn.erase(UO))
ShouldIterateEndOfFunctionDSE = true;
InvisibleToCallerAfterRet.erase(UO);
+ I
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1206,11 +1217,24 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
auto I = InvisibleToCallerAfterRet.insert({V, false});
+if (I.second && 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() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
+return true;
+}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
boomanaiden154 wrote:
We only end up in this case if we inserted into the array (i.e., the pointer is
not explicitly marked `dead_on_return`) but is marked `dead_on_unwind`. For
objects marked dead_on_return the underlying object will always be explicitly
marked, so we will never insert at this point anyways. If they're not marked
dead_on_return, we get the same behavior.
We also do not want to potentially insert true into `InvisibleToCallerAfterRet`
because then we would not be looking at bounds information when we should be.
Also realizing now after looking at this we do not want to be inserting into
`InvisibleToCallerAfterRet` at all before we check for bounded dead_on_return
annotations because otherwise we might erroneously report false if we have two
stores at the end of a function to the same underlying object. Fixed +
regression test added.
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1206,11 +1217,24 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
auto I = InvisibleToCallerAfterRet.insert({V, false});
+if (I.second && 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() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
+return true;
+}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
aeubanks wrote:
why can we skip these checks when using dead_on_return is sized? feels like the
added code should also set `I.first->second`
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/antoniofrighetto approved this pull request. LG, please wait on additional approval. https://github.com/llvm/llvm-project/pull/173694 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1016,11 +1017,18 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
-for (Argument &AI : F.args())
+for (Argument &AI : F.args()) {
if (AI.hasPassPointeeByValueCopyAttr() ||
(AI.getType()->isPointerTy() &&
AI.getDeadOnReturnInfo().coversAllReachableMemory()))
InvisibleToCallerAfterRet.insert({&AI, true});
+ if (AI.getType()->isPointerTy() &&
+ !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
+if (uint64_t DeadOnReturnBytes =
+AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
+ InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+ }
+}
boomanaiden154 wrote:
Done. That definitely makes things a lot more readable.
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -965,6 +965,7 @@ struct DSEState {
// Keep track of all of the objects that are invisible to the caller after
// the function returns.
DenseMap InvisibleToCallerAfterRet;
+ DenseMap InvisibleToCallerAfterRetBounded;
boomanaiden154 wrote:
Done.
I don't think it should be strictly necessary for correctness (we would just be
seeing if values exist in the map that we will never see again), but good to
add either way.
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1206,11 +1214,21 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
auto I = InvisibleToCallerAfterRet.insert({V, false});
+if (I.second && InvisibleToCallerAfterRetBounded.contains(V)) {
+ int64_t ValueOffset;
+ const Value *BaseValue =
+ GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
boomanaiden154 wrote:
Ah, yep. Can't believe I missed that one. Updated the code and also added a
regression test.
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1206,11 +1214,21 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
auto I = InvisibleToCallerAfterRet.insert({V, false});
+if (I.second && InvisibleToCallerAfterRetBounded.contains(V)) {
+ int64_t ValueOffset;
+ const Value *BaseValue =
+ GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
+ assert(BaseValue == V);
+ if (ValueOffset + StoreSize.toRaw() <
+ InvisibleToCallerAfterRetBounded[BaseValue])
boomanaiden154 wrote:
Done. Unsure why I decided to use `toRaw()` here originally. We do not need to
use `isPrecise()` given the value stored should be a conservative estimate.
Also updated the boundary conditions and added a regression test that covers
both the upper and lower boundary extremes.
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH 1/2] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
>From 805d7b8f4c1bb9d394a6d0760bc7de2a274fda30 Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Wed, 14 Jan 2026 17:22:23 +
Subject: [PATCH 2/2] feedback
Created using spr 1.3.7
---
.../Scalar/DeadStoreElimination.cpp | 27 ++--
.../Transforms/DeadStoreElimination/simple.ll | 31 +--
2 files changed, 46 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 78734beac4bbe..20436b92412f9 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1018,16 +1018,19 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
for (Argument &AI : F.args()) {
- if (AI.hasPassPointeeByValueCopyAttr() ||
- (AI.getType()->isPointerTy() &&
- AI.getDeadOnReturnInfo().coversAllReachableMemory()))
+ if (AI.hasPassPointeeByValueCopyAttr()) {
InvisibleToCallerAfterRet.insert({&AI, true});
- if (AI.getType()->isPointerTy() &&
- !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
-if (uint64_t DeadOnReturnBytes =
-AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
- InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+continue;
}
+
+ if (!AI.getType()->isPointerTy())
+continue;
+
+ const DeadOnReturnInfo &Info = AI.getDeadOnReturnInfo();
+ if (Info.coversAllReachableMemory())
+InvisibleToCallerAfterRet.insert({&AI, true});
+ else if (uint64_t DeadBytes = Info.getNumberOfDeadBytes())
+InvisibleToCallerAfterRetBounded.insert({&AI, DeadBytes});
}
// Collect whether there is any irreducible control flow in the function.
@@ -1225,8 +1228,11 @@ struct DSEState {
const Value *BaseValue =
GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
assert(BaseValue == V);
- if (ValueOffset + StoreSize.toRaw() <
- InvisibleToCallerAfterRetBounded[BaseValue])
+ // This store is only invisible after return if we are in bounds of the
+ // range marked dead.
+ if (ValueOffset + StoreSize.getValue() <=
+ InvisibleToCallerAfterRetBounded[BaseValue] &&
+ ValueOffset >= 0)
return true;
}
if (I.second && isInvisibleToCallerOnUnwind(V) && isNoAliasCall(V))
@@ -1899,6 +1905,7 @@ struct DSEState {
if (CapturedBeforeReturn.erase(UO))
ShouldIterateEndOfFunctionDSE = true;
InvisibleToCallerAfterRet.erase(UO);
+ I
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -965,6 +965,7 @@ struct DSEState {
// Keep track of all of the objects that are invisible to the caller after
// the function returns.
DenseMap InvisibleToCallerAfterRet;
+ DenseMap InvisibleToCallerAfterRetBounded;
antoniofrighetto wrote:
No need to erase elements too for InvisibleToCallerAfterRetBounded in
deleteDeadInstruction?
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1016,11 +1017,18 @@ struct DSEState {
// Treat byval, inalloca or dead on return arguments the same as Allocas,
// stores to them are dead at the end of the function.
-for (Argument &AI : F.args())
+for (Argument &AI : F.args()) {
if (AI.hasPassPointeeByValueCopyAttr() ||
(AI.getType()->isPointerTy() &&
AI.getDeadOnReturnInfo().coversAllReachableMemory()))
InvisibleToCallerAfterRet.insert({&AI, true});
+ if (AI.getType()->isPointerTy() &&
+ !AI.getDeadOnReturnInfo().coversAllReachableMemory()) {
+if (uint64_t DeadOnReturnBytes =
+AI.getDeadOnReturnInfo().getNumberOfDeadBytes())
+ InvisibleToCallerAfterRetBounded.insert({&AI, DeadOnReturnBytes});
+ }
+}
antoniofrighetto wrote:
Perhaps the code could be reordered a bit here, I'd favour readability:
```cpp
for (Argument &AI : F.args()) {
if (AI.hasPassPointeeByValueCopyAttr()) {
InvisibleToCallerAfterRet.insert({&AI, true});
continue;
}
if (!AI.getType()->isPointerTy())
continue;
const auto &Info = AI.getDeadOnReturnInfo();
if (Info.coversAllReachableMemory())
InvisibleToCallerAfterRet.insert({&AI, true});
else if (uint64_t DeadBytes = Info.getNumberOfDeadBytes())
InvisibleToCallerAfterRetBounded.insert({&AI, DeadBytes});
}
```
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1206,11 +1214,21 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
auto I = InvisibleToCallerAfterRet.insert({V, false});
+if (I.second && InvisibleToCallerAfterRetBounded.contains(V)) {
+ int64_t ValueOffset;
+ const Value *BaseValue =
+ GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
+ assert(BaseValue == V);
+ if (ValueOffset + StoreSize.toRaw() <
+ InvisibleToCallerAfterRetBounded[BaseValue])
antoniofrighetto wrote:
Should use getValue() instead (don't think it's necessary to check isPrecise()
here though).
Also, the store may still be eliminated with `<=`, right? (E.g., a store at
offset 0 with size 8 and dead_on_return(8)).
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
@@ -1206,11 +1214,21 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
auto I = InvisibleToCallerAfterRet.insert({V, false});
+if (I.second && InvisibleToCallerAfterRetBounded.contains(V)) {
+ int64_t ValueOffset;
+ const Value *BaseValue =
+ GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
antoniofrighetto wrote:
Don't we miss checking GEP negative indexes here?
https://github.com/llvm/llvm-project/pull/173694
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [DSE] Make DSE eliminate stores to objects with a sized dead_on_return (PR #173694)
https://github.com/boomanaiden154 updated
https://github.com/llvm/llvm-project/pull/173694
>From ba9d3c13c2efe720833d62f1c6cbc150eb399ceb Mon Sep 17 00:00:00 2001
From: Aiden Grossman
Date: Sat, 27 Dec 2025 02:05:36 +
Subject: [PATCH] formatting
Created using spr 1.3.7
---
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 9 ++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 25d473b5beb72..78734beac4bbe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1214,7 +1214,8 @@ struct DSEState {
return OW_None;
}
- bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr, const
LocationSize StoreSize) {
+ bool isInvisibleToCallerAfterRet(const Value *V, const Value *Ptr,
+ const LocationSize StoreSize) {
if (isa(V))
return true;
@@ -1774,7 +1775,8 @@ struct DSEState {
BasicBlock *MaybeKillingBlock = UseInst->getParent();
if (PostOrderNumbers.find(MaybeKillingBlock)->second <
PostOrderNumbers.find(MaybeDeadAccess->getBlock())->second) {
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
LLVM_DEBUG(dbgs()
<< "... found killing def " << *UseInst << "\n");
KillingDefs.insert(UseInst);
@@ -1792,7 +1794,8 @@ struct DSEState {
// For accesses to locations visible after the function returns, make sure
// that the location is dead (=overwritten) along all paths from
// MaybeDeadAccess to the exit.
-if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
KillingLoc.Size)) {
+if (!isInvisibleToCallerAfterRet(KillingUndObj, KillingLoc.Ptr,
+ KillingLoc.Size)) {
SmallPtrSet KillingBlocks;
for (Instruction *KD : KillingDefs)
KillingBlocks.insert(KD->getParent());
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
