[llvm] [llvm][NVPTX] Fix RAUW bug in NVPTXProxyRegErasure (PR #105871)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 13:29:05 PDT 2024


================
@@ -78,7 +78,11 @@ bool NVPTXProxyRegErasure::runOnMachineFunction(MachineFunction &MF) {
         assert(InOp.isReg() && "ProxyReg input should be a register.");
         assert(OutOp.isReg() && "ProxyReg output should be a register.");
         RemoveList.push_back(&MI);
-        RAUWBatch.try_emplace(OutOp.getReg(), InOp.getReg());
+        Register replacement = InOp.getReg();
+        // Check if the replacement itself has been replaced.
+        if (auto it = RAUWBatch.find(replacement); it != RAUWBatch.end())
+          replacement = it->second;
----------------
Artem-B wrote:

Will it deal with longer chains of ProxyReg? It would be great to add a test for that.

Perhaps we should iteratively apply replacements until they produce no more changes. 



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


More information about the llvm-commits mailing list