[llvm] [DSE] Consider the aliasing through global variable while checking clobber (PR #120044)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 07:07:49 PST 2025


================
@@ -2276,6 +2284,13 @@ DSEState::getInitializesArgMemLoc(const Instruction *I) {
       Inits = InitializesAttr.getValueAsConstantRangeList();
 
     Value *CurArg = CB->getArgOperand(Idx);
+    // Check whether "CurArg" could alias with global variables. We require
+    // either it's function local and isn't captured before or the "CB" only
+    // accesses arg or inaccessible mem.
+    if (!Inits.empty() && !isFuncLocalAndNotCaptured(CurArg, CB, EA) &&
+        !CB->onlyAccessesInaccessibleMemOrArgMem())
----------------
nikic wrote:

I'd check onlyAccessesInaccessibleMemOrArgMem before isFuncLocalAndNotCaptured as it's cheaper.

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


More information about the llvm-commits mailing list