[llvm] AlignmentFromAssumptions should only track pointer operand users (PR #73370)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 11:32:15 PST 2023


================
@@ -267,11 +263,19 @@ bool AlignmentFromAssumptionsPass::processAssumption(CallInst *ACall,
     // Now that we've updated that use of the pointer, look for other uses of
     // the pointer to update.
     Visited.insert(J);
-    for (User *UJ : J->users()) {
-      Instruction *K = cast<Instruction>(UJ);
-      if (!Visited.count(K))
-        WorkList.push_back(K);
-    }
+    if (auto UJ = dyn_cast<User>(J))
+      for (auto &U : UJ->uses()) {
+        if (U->getType()->isPointerTy()) {
+          if (isa<GetElementPtrInst>(J) || isa<PHINode>(J)) {
+            Instruction *K = cast<Instruction>(U.getUser());
+            StoreInst *SI = dyn_cast<StoreInst>(K);
+            if (SI && SI->getPointerOperandIndex() != U.getOperandNo())
----------------
nikic wrote:

I don't think this is the right place for this check. This should be above where `StoreInst` is actually handled. Otherwise you will not handle this correctly if the initial pointer is used in a store value operand (without having to follow through an extra instruction).

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


More information about the llvm-commits mailing list