Currently SelectionDAGBuilder::visitBr() doesn’t emit unconditional fall-through branches (to next block) without reference of optimization level. So the following LLVM IR
br label %return, !dbg !26
return: ; preds = %entry
ret void, !dbg !27
has no generated DAG node for “br” instruction. If we are going to generate debug line table for this branch in -O0 mode, we should leave it in place. For example such a branch can be generated by a FE for some “return;” statement at the end of void function or for one of “break;” statement if switch-related exit block is next to BB of the “break;”.
This change emits all unconditional branches in -O0 mode:
@@ -1584,8 +1584,8 @@ void SelectionDAGBuilder::visitBr(const BranchInst
// Update machine-CFG edges.
// If this is not a fall-through branch, emit the branch.
if (Succ0MBB != NextBlock)
// If this is not a fall-through branch or optimizations are off
if (Succ0MBB != NextBlock || CodeGenOpt::None == TM.getOptLevel())
emit_uncond_br.patch (669 Bytes)