[llvm] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 00:02:41 PDT 2023


================
@@ -1184,7 +1186,18 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces(
       if (C != Replace) {
         LLVM_DEBUG(dbgs() << "Inserting replacement const cast: " << Replace
                           << ": " << *Replace << '\n');
-        C->replaceAllUsesWith(Replace);
+        VMap[C] = Replace;
+        for (User *U : make_early_inc_range(C->users())) {
+          for (auto It = df_begin(U), E = df_end(U); It != E;) {
----------------
arsenm wrote:

Why do you need df ordering? 

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


More information about the llvm-commits mailing list