[llvm] r278355 - Hexagon: Avoid dereferencing end() in HexagonCopyToCombine::findPairable
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 09:40:04 PDT 2016
Author: dexonsmith
Date: Thu Aug 11 11:40:03 2016
New Revision: 278355
URL: http://llvm.org/viewvc/llvm-project?rev=278355&view=rev
Log:
Hexagon: Avoid dereferencing end() in HexagonCopyToCombine::findPairable
Check for end() before skipping through debug values. This avoids
dereferencing end() when the instruction is the final one in the basic
block. (It still assumes that a debug value will not be the final
instruction in the basic block. No tests seemed to violate that.)
Many Hexagon tests trigger this, but they happen to magically pass right
now. I found this because WIP patches for PR26753 convert them into
crashes.
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp?rev=278355&r1=278354&r2=278355&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp Thu Aug 11 11:40:03 2016
@@ -505,8 +505,9 @@ MachineInstr *HexagonCopyToCombine::find
bool AllowC64) {
MachineBasicBlock::iterator I2 = std::next(MachineBasicBlock::iterator(I1));
- while (I2->isDebugValue())
- ++I2;
+ if (I2 != I1.getParent()->end())
+ while (I2->isDebugValue())
+ ++I2;
unsigned I1DestReg = I1.getOperand(0).getReg();
More information about the llvm-commits
mailing list