llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[IfConverter/BranchFolding] An empty, non-reachable MBB is not removed.

Open JonPsson opened this issue 10 years ago • 1 comments

Bugzilla Link 27657
Resolution INVALID
Resolved on May 09, 2016 04:37
Version trunk
OS Linux
Attachments llc input
CC @dexonsmith,@hfinkel

Extended Description

The IfConverter should remove a block and its successor/predecessor edges from MF because it is not reachable. BranchFolding fails to assist with this. Interesting is to note that the probability of the edge to that block is 0, which is another observation which means it could be removed.

Not having empty blocks is good generally for algorithms (I am experimenting currently with something like global scheduler states to propagate processor resources usage between regions.)

BB#0: derived from LLVM BB %entry Live Ins: %R2D CGHI %R2D, 0, %CC BRC 14, 6, <BB#2>, %CC Successors according to CFG: BB#1(0x30000000 / 0x80000000 = 37.50%) BB#2(0x50000000 / 0x80000000 = 62.50%)

BB#1: derived from LLVM BB %return Predecessors according to CFG: BB#0 %R2D = LGHI 0 Return %R2D

BB#2: derived from LLVM BB %if.end Live Ins: %R2D Predecessors according to CFG: BB#0 CallJG ga:@Perl_newSVsv

=>

BB#0: derived from LLVM BB %entry Live Ins: %R2D CGHI %R2D, 0, %CC CallBRCL 14, 6, ga:@Perl_newSVsv Successors according to CFG: BB#1(0x80000000 / 0x80000000 = 100.00%) BB#2(0x00000000 / 0x80000000 = 0.00%)

BB#1: derived from LLVM BB %return Predecessors according to CFG: BB#0 %R2D = LGHI 0 Return %R2D

BB#2: derived from LLVM BB %if.end Live Ins: %R2D Predecessors according to CFG: BB#0

./bin/llc ./minperlio.ll -mtriple=s390x-linux-gnu -mcpu=z13

Could this be done in BranchFolder.cpp? I am not sure if there could be cases lika a call to an empty block without successors to replace it..?

JonPsson avatar May 05 '16 17:05 JonPsson

Tried to fix this, but it turns out that empty blocks with either no predecessors or successors are the only empty blocks left, which seems to be difficult / unnecessary to get rid of. For the first block in function, removing it triggers an assert that a loop header should not be first block in function. As to empty blocks without successors, I am not sure if there could still be a jump to such a block but it however seems harmless.

So, I close this bug without any changes, sorry for spamming.

JonPsson avatar May 09 '16 11:05 JonPsson