From 84c2da47f9bbe2e9fb61b3ba28c5bb3039f40c7d Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 18 Aug 2016 17:58:09 +0000 Subject: AArch64: Don't call getIterator() on iterators Remove an unnecessary round-trip: iterator => operator->() => getIterator() In some cases, the iterator is end(), so the dereference of operator-> is invalid (UB). The testcase only crashes with r278974 (currently reverted to investigate this), which adds an assertion for invalid dereferences of ilist nodes. Fixes PR29035. llvm-svn: 279104 --- llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'llvm/lib/Target') diff --git a/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp b/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp index 26a1f5d7047..9e916ef8dd7 100644 --- a/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp +++ b/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp @@ -156,8 +156,7 @@ bool AArch64RedundantCopyElimination::optimizeCopy(MachineBasicBlock *MBB) { MBB->addLiveIn(TargetReg); // Clear any kills of TargetReg between CompBr and the last removed COPY. - for (MachineInstr &MMI : - make_range(MBB->begin()->getIterator(), LastChange->getIterator())) + for (MachineInstr &MMI : make_range(MBB->begin(), LastChange)) MMI.clearRegisterKills(SmallestDef, TRI); return true; -- cgit v1.2.3