[llvm] r270323 - [LiveIntervalAnalysis] Don't dereference an end iterator in repairIntervalsInRange

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Sat May 21 09:03:53 PDT 2016


Author: hfinkel
Date: Sat May 21 11:03:50 2016
New Revision: 270323

URL: http://llvm.org/viewvc/llvm-project?rev=270323&view=rev
Log:
[LiveIntervalAnalysis] Don't dereference an end iterator in repairIntervalsInRange

This fixes a bug introduced in:

  r262115 - CodeGen: Take MachineInstr& in SlotIndexes and LiveIntervals, NFC

The iterator End here might == MBB->end(), and so we can't unconditionally
dereference it. This often goes unnoticed (I don't have a test case that always
crashes, and ASAN does not catch it either) because the function call arguments are
turned right back into iterators. MachineInstrBundleIterator's constructor,
however, does have an assert which might randomly fire.

Modified:
    llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=270323&r1=270322&r2=270323&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Sat May 21 11:03:50 2016
@@ -1496,7 +1496,7 @@ LiveIntervals::repairIntervalsInRange(Ma
   else
     endIdx = getInstructionIndex(*End);
 
-  Indexes->repairIndexesInRange(MBB, *Begin, *End);
+  Indexes->repairIndexesInRange(MBB, Begin, End);
 
   for (MachineBasicBlock::iterator I = End; I != Begin;) {
     --I;




More information about the llvm-commits mailing list