[llvm] Fix potential Out-of-order Evaluation in DebugInfo (PR #124385)
Elvin Wang via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 24 19:01:28 PST 2025
https://github.com/NaiveWang created https://github.com/llvm/llvm-project/pull/124385
In DebugTypeInfoRemoval, DenseMap Replacements's assignment's rvalue is a recursive function that may access Replacements itself. Since C++17 such an "right to left" order cannot get guaranteed. This change is to separate 1 line into 2, avoid such a case.
>From 9b12e06da755ea145312312cebb4977f5bc217fa Mon Sep 17 00:00:00 2001
From: Elvin Wang <wanhzhiwen at gmail.com>
Date: Fri, 24 Jan 2025 18:59:51 -0800
Subject: [PATCH] Fix potential Out-of-order Evaluation in DebugInfo
In DebugTypeInfoRemoval, DenseMap Replacements's assignment's rvalue is a recursive function that may access Replacements itself. Since C++17 such an "right to left" order cannot get guaranteed.
This change is to separate 1 line into 2.
---
llvm/lib/IR/DebugInfo.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 4ce518009bd3ea..f4080ce532ef38 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -798,7 +798,8 @@ class DebugTypeInfoRemoval {
return getReplacementMDNode(N);
};
- Replacements[N] = doRemap(N);
+ auto value = doRemap(N);
+ Replacements[N] = value;
}
/// Do the remapping traversal.
More information about the llvm-commits
mailing list