diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 4ce518009bd3e..89415a1ecd16c 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -798,7 +798,11 @@ class DebugTypeInfoRemoval { return getReplacementMDNode(N); }; - Replacements[N] = doRemap(N); + + // Intentionally separate rvalue and lvalue that may access the same memory + // location to guarantee the evaluation order. + auto value = doRemap(N); + Replacements[N] = value; } /// Do the remapping traversal.