[llvm] ead3979 - [MemoryLocation] Move DSE intrinsic handling to MemoryLocation. (NFC)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 3 08:00:58 PST 2021
Author: Florian Hahn
Date: 2021-12-03T16:00:39Z
New Revision: ead3979a92fc33add4710c4510d6906260dcb4ad
URL: https://github.com/llvm/llvm-project/commit/ead3979a92fc33add4710c4510d6906260dcb4ad
DIFF: https://github.com/llvm/llvm-project/commit/ead3979a92fc33add4710c4510d6906260dcb4ad.diff
LOG: [MemoryLocation] Move DSE intrinsic handling to MemoryLocation. (NFC)
Suggested in D114872.
Added:
Modified:
llvm/lib/Analysis/MemoryLocation.cpp
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/MemoryLocation.cpp b/llvm/lib/Analysis/MemoryLocation.cpp
index 18ba50c7b4e12..44136a7c36e0e 100644
--- a/llvm/lib/Analysis/MemoryLocation.cpp
+++ b/llvm/lib/Analysis/MemoryLocation.cpp
@@ -130,8 +130,19 @@ MemoryLocation MemoryLocation::getForDest(const AnyMemIntrinsic *MI) {
Optional<MemoryLocation>
MemoryLocation::getForDest(const CallBase *CB, const TargetLibraryInfo &TLI) {
- if (auto *MemInst = dyn_cast<AnyMemIntrinsic>(CB))
- return getForDest(MemInst);
+ if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(CB)) {
+ if (auto *MemInst = dyn_cast<AnyMemIntrinsic>(CB))
+ return getForDest(MemInst);
+
+ switch (II->getIntrinsicID()) {
+ default:
+ return None;
+ case Intrinsic::init_trampoline:
+ return MemoryLocation::getForArgument(CB, 0, TLI);
+ case Intrinsic::masked_store:
+ return MemoryLocation::getForArgument(CB, 1, TLI);
+ }
+ }
LibFunc LF;
if (TLI.getLibFunc(*CB, LF) && TLI.has(LF)) {
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 497d327e25f05..a28a9ac9f4e5c 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1032,15 +1032,6 @@ struct DSEState {
!CB->onlyAccessesInaccessibleMemOrArgMem())
return None;
- switch (CB->getIntrinsicID()) {
- case Intrinsic::init_trampoline:
- return {MemoryLocation::getAfter(CB->getArgOperand(0))};
- case Intrinsic::masked_store:
- return {MemoryLocation::getForArgument(CB, 1, TLI)};
- default:
- break;
- }
-
return MemoryLocation::getForDest(CB, TLI);
}
More information about the llvm-commits
mailing list