[llvm] [llvm] Avoid out-of-order evaluation in DebugInfo (PR #125116)
Elvin Wang via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 13:08:41 PST 2025
https://github.com/elvinw-intel created https://github.com/llvm/llvm-project/pull/125116
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.
>From f7894558e3055f07dab54690d6814c79f4fa136c Mon Sep 17 00:00:00 2001
From: Elvin Wang <elvin.wang at intel.com>
Date: Thu, 30 Jan 2025 13:05:13 -0800
Subject: [PATCH] Avoid out-of-order evaluation in DebugInfo
This is an upstream proposal from https://github.com/intel/intel-graphics-compiler/commit/e60884cb98c4332a0eecff8396eb353c5b86cd35
We experienced 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.
---
llvm/lib/IR/DebugInfo.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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.
More information about the llvm-commits
mailing list