[LLVMdev] leave uncodnitional fall-through branches in llc -O0
Fukalov, Daniil
Daniil.Fukalov at amd.com
Fri Mar 21 05:37:27 PDT 2014
Currently SelectionDAGBuilder::visitBr() doesn't emit unconditional fall-through branches (to next block) without reference of optimization level. So the following LLVM IR
entry:
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:
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1584,8 +1584,8 @@ void SelectionDAGBuilder::visitBr(const BranchInst
// Update machine-CFG edges.
BrMBB->addSuccessor(Succ0MBB);
- // 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())
DAG.setRoot(DAG.getNode(ISD::BR, getCurSDLoc(),
MVT::Other, getControlRoot(),
DAG.getBasicBlock(Succ0MBB)));
Regards,
Daniil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140321/45a9e410/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: emit_uncond_br.patch
Type: application/octet-stream
Size: 669 bytes
Desc: emit_uncond_br.patch
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140321/45a9e410/attachment.obj>
More information about the llvm-dev
mailing list