summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2015-03-02 00:17:18 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2015-03-02 00:17:18 +0000
commite5d1466ab3979eac267d0f421e67e299b704c47c (patch)
tree6bca9db6ac8c50fcd37cfcaf529998e94ea89554 /llvm/lib/Target
parent201a48471b38dfe994dc6a25077b667d3ff0fd59 (diff)
downloadbcm5719-llvm-e5d1466ab3979eac267d0f421e67e299b704c47c.tar.gz
bcm5719-llvm-e5d1466ab3979eac267d0f421e67e299b704c47c.zip
[AArch64] fix an invalid-iterator-use bug.
Summary: In AArch64PromoteConstant::appendAndTransferDominatedUses, `InsertPts[NewPt]` invalidates IPI. Therefore, `InsertPts[NewPt] = std::move(IPI->second)` is not legal. This was caught by running `make check` with http://reviews.llvm.org/D7931. Reviewers: t.p.northover, grosbach, bkramer Reviewed By: bkramer Subscribers: aemerson, llvm-commits Differential Revision: http://reviews.llvm.org/D7988 llvm-svn: 230923
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp b/llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp
index c037c86c152..4a4118ae775 100644
--- a/llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp
+++ b/llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp
@@ -189,9 +189,11 @@ private:
IPI->second.push_back(&Use);
// Transfer the dominated uses of IPI to NewPt
// Inserting into the DenseMap may invalidate existing iterator.
- // Keep a copy of the key to find the iterator to erase.
+ // Keep a copy of the key to find the iterator to erase. Keep a copy of the
+ // value so that we don't have to dereference IPI->second.
Instruction *OldInstr = IPI->first;
- InsertPts[NewPt] = std::move(IPI->second);
+ Uses OldUses = std::move(IPI->second);
+ InsertPts[NewPt] = std::move(OldUses);
// Erase IPI.
InsertPts.erase(OldInstr);
}
OpenPOWER on IntegriCloud