[LLVMbugs] [Bug 2669] New: Branch Folding pass leaves double unconditional branches to a BB.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Aug 12 04:58:27 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2669

           Summary: Branch Folding pass leaves double unconditional branches
                    to a BB.
           Product: libraries
           Version: 2.3
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: hkultala at cs.tut.fi
                CC: llvmbugs at cs.uiuc.edu


BranchFolding::CanFallThru method documentation states:

"This should return false if it can reach the block after it, but it uses an
explicit branch to do so (e.g. a table jump)."

But in the method there is a code 


  // If there is some explicit branch to the fallthrough block, it can
obviously
  // reach, even though the branch should get folded to fall through
implicitly.
  if (MachineFunction::iterator(TBB) == Fallthrough ||
      MachineFunction::iterator(FBB) == Fallthrough) return true;


Which means it returns true where the documentation states it should return
false.



This return value is later used at OptimizeBlock method

          if (CurFallsThru) {
            MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB));
            CurCond.clear();
            TII->InsertBranch(*MBB, NextBB, 0, CurCond);
          }

So it inserts an additional unconditional branch instruction to the following
BB even though there can already be one unconditional branch instruction to
that.



This is not just a performance problem because this also can make further
TargetInstrInfo::AnalyzeBranch and TargetInstrInfo::RemoveBranch calls fail.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list