[llvm] [DSE] Apply initializes attribute to DSE (PR #107282)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 18:11:54 PDT 2024
================
@@ -2181,6 +2263,75 @@ struct DSEState {
bool eliminateDeadDefs(const MemoryDefWrapper &KillingDefWrapper);
};
+SmallVector<MemoryLocation, 1>
+DSEState::getInitializesArgMemLoc(const Instruction *I) {
+ const CallBase *CB = dyn_cast<CallBase>(I);
+ if (!CB)
+ return {};
+
+ // Collect aliasing arguments and their initializes ranges.
+ SmallMapVector<Value *, SmallVector<ArgumentInitInfo, 2>, 2> Arguments;
+ for (unsigned Idx = 0, Count = CB->arg_size(); Idx < Count; ++Idx) {
+ ConstantRangeList Inits;
+ Attribute InitializesAttr = CB->getParamAttr(Idx, Attribute::Initializes);
+ if (InitializesAttr.isValid())
+ Inits = InitializesAttr.getValueAsConstantRangeList();
+
+ Value *CurArg = CB->getArgOperand(Idx);
+ // We don't perform incorrect DSE on unwind edges in the current function,
+ // and use the "initializes" attribute to kill dead stores if:
+ // - The call does not throw exceptions, "CB->doesNotThrow()".
----------------
antoniofrighetto wrote:
Is nounwind checked in getIntersectedInitRangeList, no need to check it in within IsDeadOrInvisibleOnUnwind as the others?
https://github.com/llvm/llvm-project/pull/107282
More information about the llvm-commits
mailing list