[llvm-bugs] [Bug 37252] New: Incorrect removal of entries in PressureDiff::addPressureChange

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 26 02:38:09 PDT 2018


            Bug ID: 37252
           Summary: Incorrect removal of entries in
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: tetra2005 at gmail.com
                CC: llvm-bugs at lists.llvm.org

I've recently came across a weird behavior in addPressureChange function. The
problematic commit is r250595:

  + // Remove entry
  + PressureDiff::iterator J;
  + for (J = std::next(I); J != E && J->isValid(); ++J, ++I)
  +   *I = *J;
  + if (J != E)
  +   *I = *J;

This code is that it fails to reset isValid() status on last element of
PressureDiff::PressureChanges i.e. if J == E (and thus I == E – 1). In such
case the last two elements of PressureChanges hold
the same PSetID:
  + [13] {PSetID=242 UnitInc=-6 } llvm::PressureChange
  + [14] {PSetID=249 UnitInc=-6 } llvm::PressureChange
  + [15] {PSetID=249 UnitInc=-6 } llvm::PressureChange

Apart from making debug output in updatePressureDiffs weird (as it prints these
trailing duplicate elements) this effectively steals 1 location in
PressureChange because now PSetIDs which are greater than 249 will not be
stored there.
Maybe the last 2 lines should instead be changed to 
  *I = PressureChange();

I'm on a private branch so don't have a ready-made reproducer but hopefully
description above makes sense as is...

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180426/1d6c7a3c/attachment.html>

More information about the llvm-bugs mailing list