[llvm-bugs] [Bug 37273] New: Stack overflow in PeepHoleOptimizer

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 27 10:18:55 PDT 2018


            Bug ID: 37273
           Summary: Stack overflow in PeepHoleOptimizer
           Product: libraries
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: david.l.kreitzer at intel.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20236
  --> https://bugs.llvm.org/attachment.cgi?id=20236&action=edit
Reproducer compile as "llc bugpoint-reduced-function.bc"

The attached test case crashes llc due to deep recursion in this function:

  getNewSource(MachineRegisterInfo *MRI, const TargetInstrInfo *TII,
               TargetInstrInfo::RegSubRegPair Def,
               PeepholeOptimizer::RewriteMapTy &RewriteMap,
               bool HandleMultipleSources = true) {

I think this is because PeepholeOptimizer::findNextSource returns true even
though the RewritePHILimit is reached.

I confirmed that the following patch fixes the problem even though it was
intended to be NFC. It restructured the findNextSource code in such a way that
exceeding RewritePHILimit will always cause the routine to return false.

commit e5f83314a1df7ef7843f904da01f2aa236bbe7f0
Author: Matthias Braun <matze at braunis.de>
Date:   Thu Jan 11 22:59:33 2018 +0000

    PeepholeOpt cleanup/refactor; NFC

    - Less unnecessary use of `auto`
    - Add early `using RegSubRegPair(AndIdx) =` to avoid countless
      `TargetInstrInfo::` qualifications.
    - Use references instead of pointers where possible.
    - Remove unused parameters.
    - Rewrite the CopyRewriter class hierarchy:
       - Pull out uncoalescable copy rewriting functionality into
         PeepholeOptimizer class.
       - Use an abstract base class to make it clear that rewriters are
    - Remove unnecessary \brief in doxygen comments.
    - Remove unused constructor and method from ValueTracker.
    - Replace UseAdvancedTracking of ValueTracker with DisableAdvCopyOpt use.

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/20180427/639600bf/attachment.html>

More information about the llvm-bugs mailing list