aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorStephen Tozer <Stephen.Tozer@Sony.com>2021-07-05 09:45:08 +0100
committerStephen Tozer <Stephen.Tozer@Sony.com>2021-07-05 10:35:19 +0100
commit14b62f7e2f07db548779fc17550a5265ef374413 (patch)
tree483edf1514b2190bbaef07028f4e8b1498ec1cd7 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parentb8173c317812a51354e2874ee6dd5c3150d98ac8 (diff)
downloadllvm-14b62f7e2f07db548779fc17550a5265ef374413.zip
llvm-14b62f7e2f07db548779fc17550a5265ef374413.tar.gz
llvm-14b62f7e2f07db548779fc17550a5265ef374413.tar.bz2
[DebugInfo] CGP+HWasan: Handle dbg.values with duplicate location ops
This patch fixes an issue which occurred in CodeGenPrepare and HWAddressSanitizer, which both at some point create a map of Old->New instructions and update dbg.value uses of these. They did this by iterating over the dbg.value's location operands, and if an instance of the old instruction was found, replaceVariableLocationOp would be called on that dbg.value. This would cause an error if the same operand appeared multiple times as a location operand, as the first call to replaceVariableLocationOp would update all uses of the old instruction, invalidating the old iterator and eventually hitting an assertion. This has been fixed by no longer iterating over the dbg.value's location operands directly, but by first collecting them into a set and then iterating over that, ensuring that we never attempt to replace a duplicated operand multiple times. Differential Revision: https://reviews.llvm.org/D105129
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index baf674c..163236c 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -7994,7 +7994,9 @@ bool CodeGenPrepare::fixupDbgValue(Instruction *I) {
// Does this dbg.value refer to a sunk address calculation?
bool AnyChange = false;
- for (Value *Location : DVI.getValues()) {
+ SmallDenseSet<Value *> LocationOps(DVI.location_ops().begin(),
+ DVI.location_ops().end());
+ for (Value *Location : LocationOps) {
WeakTrackingVH SunkAddrVH = SunkAddrs[Location];
Value *SunkAddr = SunkAddrVH.pointsToAliveValue() ? SunkAddrVH : nullptr;
if (SunkAddr) {