[llvm-bugs] [Bug 34447] New: Potential Unbounded recursion in MachineLICM::InitRegPressure

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 3 22:34:14 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34447

            Bug ID: 34447
           Summary: Potential Unbounded recursion in
                    MachineLICM::InitRegPressure
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: joker.eph at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19096
  --> https://bugs.llvm.org/attachment.cgi?id=19096&action=edit
Machine function that explodes the recursion stack

We enter the recursion here:

```
  // If the preheader has only a single predecessor and it ends with a
  // fallthrough or an unconditional branch, then scan its predecessor for live
  // defs as well. This happens whenever the preheader is created by splitting
  // the critical edge from the loop predecessor to the loop header.
  if (BB->pred_size() == 1) {
    MachineBasicBlock *TBB = nullptr, *FBB = nullptr;
    SmallVector<MachineOperand, 4> Cond;
    if (!TII->analyzeBranch(*BB, TBB, FBB, Cond, false) && Cond.empty())
      InitRegPressure(*BB->pred_begin());
  }
```

The attached function triggers a very deep recursion that crashes the program.
I'm not sure from the comment if it is intended that this can recurse more than
a single level. So it is possible that some preconditions are not enforced
before we reach this point.

If on the other hand the deep recursion is legit here, then we need to modify
the logic to make it iterative.

-- 
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/20170904/d0b29f41/attachment.html>


More information about the llvm-bugs mailing list