[llvm] [llvm] Avoid out-of-order evaluation in DebugInfo (PR #125116)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 13:09:31 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Elvin Wang (elvinw-intel)
<details>
<summary>Changes</summary>
This is an upstream proposal from https://github.com/intel/intel-graphics-compiler/commit/e60884cb98c4332a0eecff8396eb353c5b86cd35
We observed malfunctioning StripNonLineTableDebugInfo during debugging and it's caused by out-of-order evaluation, this is a C++ level semantic ambiguity issue, refer https://en.cppreference.com/w/cpp/language/eval_order
Solution is simply separating one line into two.
---
Full diff: https://github.com/llvm/llvm-project/pull/125116.diff
1 Files Affected:
- (modified) llvm/lib/IR/DebugInfo.cpp (+5-1)
``````````diff
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 4ce518009bd3ea..ea1d79d436041f 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);
+ // Seperate recursive doRemap and operator [] into 2 lines to avoid
+ // out-of-order evaluations since both of them can access the same memory
+ // location in map Replacements.
+ auto Value = doRemap(N);
+ Replacements[N] = Value;
}
/// Do the remapping traversal.
``````````
</details>
https://github.com/llvm/llvm-project/pull/125116
More information about the llvm-commits
mailing list