MachineBasicBlocks 是否应该隐含地落入他们的继任者?
Are MachineBasicBlocks supposed to implicitly fall through to their successors?
我正在调试一个 LLVM 目标后端,我正在解决一个问题,其中某个基本块最终跳转到 "nothing",即在函数结束后,在启用优化的情况下进行编译.
我注意到的一件事是,在指令选择之后,机器基本块有一个后继但没有真正跳转到那里的指令:
BB#1: derived from LLVM BB %switch.lookup
Predecessors according to CFG: BB#0
%vreg5<def> = SEXT %vreg2, %SREG<imp-def,dead>; DLDREGS:%vreg5 GPR8:%vreg2
%vreg6<def,tied1> = ANDIWRdK %vreg5<tied0>, -2, %SREG<imp-def,dead>; DLDREGS:%vreg6,%vreg5
%vreg7<def> = LDIWRdK 4; DLDREGS:%vreg7
%vreg8<def> = LDIRdK 0; LD8:%vreg8
%vreg9<def> = LDIRdK 1; LD8:%vreg9
CPWRdRr %vreg6<kill>, %vreg7<kill>, %SREG<imp-def>; DLDREGS:%vreg6,%vreg7
%vreg0<def> = Select8 %vreg9<kill>, %vreg8<kill>, 1, %SREG<imp-use>; GPR8:%vreg0 LD8:%vreg9,%vreg8
Successors according to CFG: BB#2(?%)
我从 x86 LLVM 后端看到类似的 ISel 结果,并且最终结果没有跳转到虚无,所以我认为这本身不是问题:
BB#1: derived from LLVM BB %switch.lookup
Predecessors according to CFG: BB#0
%vreg7<def> = MOVSX32rr8 %vreg3; GR32:%vreg7 GR8:%vreg3
%vreg8<def,tied1> = AND32ri %vreg7<tied0>, 65534, %EFLAGS<imp-def,dead>; GR32:%vreg8,%vreg7
%vreg9<def,tied1> = SUB32ri8 %vreg8<tied0>, 4, %EFLAGS<imp-def>; GR32:%vreg9,%vreg8
%vreg0<def> = SETNEr %EFLAGS<imp-use>; GR8:%vreg0
Successors according to CFG: BB#2(?%)
所以我的问题是:应该将这些 CFG 指定的后继者转化为真正的跳跃的机制是什么?x86 后端是否为此实现了一些特殊的东西?我正在调试的后端没有工作吗?
我是否应该将我的 ISelLowering
class 更改为将 Select8
降低到以显式跳转结尾的东西,或者是不必要的(甚至可能不利于某些优化的启动) ) 我还需要做一些其他的魔法才能正确降低这些隐式后继?
It is perfectly valid for a MachineBasicBlock to fall through to the next Block:
That is valid. Passes that want to reorder basic blocks should only do
so if the AnalyzeBranch
and related target hooks (Insert
/Remove
) allow
it.
我正在调试一个 LLVM 目标后端,我正在解决一个问题,其中某个基本块最终跳转到 "nothing",即在函数结束后,在启用优化的情况下进行编译.
我注意到的一件事是,在指令选择之后,机器基本块有一个后继但没有真正跳转到那里的指令:
BB#1: derived from LLVM BB %switch.lookup
Predecessors according to CFG: BB#0
%vreg5<def> = SEXT %vreg2, %SREG<imp-def,dead>; DLDREGS:%vreg5 GPR8:%vreg2
%vreg6<def,tied1> = ANDIWRdK %vreg5<tied0>, -2, %SREG<imp-def,dead>; DLDREGS:%vreg6,%vreg5
%vreg7<def> = LDIWRdK 4; DLDREGS:%vreg7
%vreg8<def> = LDIRdK 0; LD8:%vreg8
%vreg9<def> = LDIRdK 1; LD8:%vreg9
CPWRdRr %vreg6<kill>, %vreg7<kill>, %SREG<imp-def>; DLDREGS:%vreg6,%vreg7
%vreg0<def> = Select8 %vreg9<kill>, %vreg8<kill>, 1, %SREG<imp-use>; GPR8:%vreg0 LD8:%vreg9,%vreg8
Successors according to CFG: BB#2(?%)
我从 x86 LLVM 后端看到类似的 ISel 结果,并且最终结果没有跳转到虚无,所以我认为这本身不是问题:
BB#1: derived from LLVM BB %switch.lookup
Predecessors according to CFG: BB#0
%vreg7<def> = MOVSX32rr8 %vreg3; GR32:%vreg7 GR8:%vreg3
%vreg8<def,tied1> = AND32ri %vreg7<tied0>, 65534, %EFLAGS<imp-def,dead>; GR32:%vreg8,%vreg7
%vreg9<def,tied1> = SUB32ri8 %vreg8<tied0>, 4, %EFLAGS<imp-def>; GR32:%vreg9,%vreg8
%vreg0<def> = SETNEr %EFLAGS<imp-use>; GR8:%vreg0
Successors according to CFG: BB#2(?%)
所以我的问题是:应该将这些 CFG 指定的后继者转化为真正的跳跃的机制是什么?x86 后端是否为此实现了一些特殊的东西?我正在调试的后端没有工作吗?
我是否应该将我的 ISelLowering
class 更改为将 Select8
降低到以显式跳转结尾的东西,或者是不必要的(甚至可能不利于某些优化的启动) ) 我还需要做一些其他的魔法才能正确降低这些隐式后继?
It is perfectly valid for a MachineBasicBlock to fall through to the next Block:
That is valid. Passes that want to reorder basic blocks should only do so if the
AnalyzeBranch
and related target hooks (Insert
/Remove
) allow it.