[llvm] [InferAddrSpaces] Correctly replace identical operands of insts (PR #82610)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 03:40:44 PST 2024


================
@@ -1311,7 +1311,9 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces(
 
           while (isa<PHINode>(InsertPos))
             ++InsertPos;
-          U.set(new AddrSpaceCastInst(NewV, V->getType(), "", &*InsertPos));
+          // This instruction may contain multiple uses of V, update them all.
----------------
jayfoad wrote:

The `skipToNextUser` on line 1227 means that this for loop runs once for each `User`, not once for each `Use`, so every instance of `U.set` seems wrong, since it will leave other uses in the same instruction untouched.

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


More information about the llvm-commits mailing list