aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/IntrinsicInst.cpp
diff options
context:
space:
mode:
authorOCHyams <orlando.hyams@sony.com>2023-04-11 16:56:05 +0100
committerOCHyams <orlando.hyams@sony.com>2023-04-11 17:05:20 +0100
commitc95b322b738b63abedb0483bafe08b92c3de8e31 (patch)
treefc9fb20548383961f09abdae34f525bcba2a6cf9 /llvm/lib/IR/IntrinsicInst.cpp
parentb4563ee17ce45728a323c2708e549627b0a8ee9c (diff)
downloadllvm-c95b322b738b63abedb0483bafe08b92c3de8e31.zip
llvm-c95b322b738b63abedb0483bafe08b92c3de8e31.tar.gz
llvm-c95b322b738b63abedb0483bafe08b92c3de8e31.tar.bz2
[Assignment Tracking] Fix replaceVariableLocationOp for dbg.assign with DIArgList
The last time this function was updated DIArgLists were not supported for dbg.assigns. Without this patch it's possible to now dereference an invalid (the end) iterator. This occurs when the Address component gets replaced and there's a DIArgList for the Value component (the contained values are irrelevant). The added unittest crashes without the code change in this patch. Reviewed By: jmorse Differential Revision: https://reviews.llvm.org/D147922
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r--llvm/lib/IR/IntrinsicInst.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 1c78d4b..9270d70 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -135,14 +135,14 @@ void DbgVariableIntrinsic::replaceVariableLocationOp(Value *OldValue,
assert(NewValue && "Values must be non-null");
auto Locations = location_ops();
auto OldIt = find(Locations, OldValue);
- assert((OldIt != Locations.end() || DbgAssignAddrReplaced) &&
- "OldValue must be a current location");
+ if (OldIt == Locations.end()) {
+ assert(DbgAssignAddrReplaced &&
+ "OldValue must be dbg.assign addr if unused in DIArgList");
+ return;
+ }
+
+ assert(OldIt != Locations.end() && "OldValue must be a current location");
if (!hasArgList()) {
- // Additional check necessary to avoid unconditionally replacing this
- // operand when a dbg.assign address is replaced (DbgAssignAddrReplaced is
- // true).
- if (OldValue != getVariableLocationOp(0))
- return;
Value *NewOperand = isa<MetadataAsValue>(NewValue)
? NewValue
: MetadataAsValue::get(