[llvm-bugs] [Bug 28049] New: [Thumb] Crash when running tail merge after basic block placement

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 8 02:18:12 PDT 2016


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

            Bug ID: 28049
           Summary: [Thumb] Crash when running tail merge after basic
                    block placement
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: diana.picus at linaro.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

r271925 broke our thumb selfhosting bot:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/3602


To quote Haicheng's analysis on the mailing list:
"My patch tries to run Tail Merging after Block Placement to reduce code size. 
In the failing case, I have following four consecutive MBBs after the Block
Placement

BB#187: derived from LLVM BB %if.then.i.i.i673
        t2Bcc <BB#193>, pred:3, pred:%CPSR<kill>
        t2B <BB#188>, pred:14, pred:%noreg

BB#190: derived from LLVM BB %if.then9.i.i.i
        t2Bcc <BB#188>, pred:2, pred:%CPSR<kill>

BB#193: derived from LLVM BB %if.then2.i
...

BB#188: derived from LLVM BB %if.end5.i
...

BB#187 and BB#190 are regarded the same (both only contain branches that have
same conditions and same targets) and can be merged.  Tail Merging calls
ReplaceTailWithBranchTo() to replace the two branches in BB#187 with an
unconditional branch to BB#190.  It seems only Thumb2 overwrites
ReplaceTailWithBranchTo() and all the other targets just use
TargetInstrInfo::ReplaceTailWithBranchTo().

The crash comes from the following five lines of
Thumb2InstrInfo::ReplaceTailWithBranchTo()

  // If the first instruction of Tail is predicated, we may have to update
  // the IT instruction.
  unsigned PredReg = 0;
  ARMCC::CondCodes CC = getInstrPredicate(*Tail, PredReg);
  MachineBasicBlock::iterator MBBI = Tail;
  if (CC != ARMCC::AL)
    // Expecting at least the t2IT instruction before it.
    --MBBI;

Variable Tail points to the first instruction of BB#187.  --MBBI then triggers
the assertion."

Since we probably don't want to disable this for thumb, we should try to fix
the underlying bug and then try to reapply r271925.

-- 
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/20160608/e727cadf/attachment.html>


More information about the llvm-bugs mailing list