aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
diff options
context:
space:
mode:
authorOCHyams <orlando.hyams@sony.com>2023-01-20 14:24:57 +0000
committerOCHyams <orlando.hyams@sony.com>2023-01-20 14:30:26 +0000
commite3a00d51864e05b6755601543c5e2a2df44081d1 (patch)
treeeb44df2589337f845ac2a821dd4dd74b42105751 /llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
parenta4898b437dbd76bf62c6fc2c5f015c327aa19190 (diff)
downloadllvm-e3a00d51864e05b6755601543c5e2a2df44081d1.zip
llvm-e3a00d51864e05b6755601543c5e2a2df44081d1.tar.gz
llvm-e3a00d51864e05b6755601543c5e2a2df44081d1.tar.bz2
[Assignment Tracking] Fix invalidated iterator usage
The iterator `FirstOverlap` is invalidated after the call to `insert` - avoid dereferencing the iterator after the call to `insert`. Reviewed By: CarlosAlbertoEnciso Differential Revision: https://reviews.llvm.org/D141854
Diffstat (limited to 'llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp')
-rw-r--r--llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index 16782a3..7098824 100644
--- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -651,14 +651,19 @@ class MemLocFragmentFill {
// [ - i - ]
// +
// [ i ][ f ][ i ]
+
+ // Save values for use after inserting a new interval.
auto EndBitOfOverlap = FirstOverlap.stop();
+ unsigned OverlapValue = FirstOverlap.value();
+
+ // Shorten the overlapping interval.
FirstOverlap.setStop(StartBit);
insertMemLoc(BB, Before, Var, FirstOverlap.start(), StartBit,
- *FirstOverlap, VarLoc.DL);
+ OverlapValue, VarLoc.DL);
// Insert a new interval to represent the end part.
- FragMap.insert(EndBit, EndBitOfOverlap, *FirstOverlap);
- insertMemLoc(BB, Before, Var, EndBit, EndBitOfOverlap, *FirstOverlap,
+ FragMap.insert(EndBit, EndBitOfOverlap, OverlapValue);
+ insertMemLoc(BB, Before, Var, EndBit, EndBitOfOverlap, OverlapValue,
VarLoc.DL);
// Insert the new (middle) fragment now there is space.