[llvm-commits] [patch] Change how clang produces computed gotos

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Mon Jun 6 22:03:19 PDT 2011


On 2011-06-06 21:09, Bob Wilson wrote:
> The early tail dup pass is supposed to handle this, but it's not very
> smart and I know it can fail in some cases.  I spent some time trying
> to improve it but never got the code finished to the point where I
> could commit it.  I still hope to go back to that sometime.  I'd be
> curious to know more about why it's failing.

I am still not sure exactly what the problem is, but I think I found
something interesting.

By the time we get to tail duplication, the indirectgoto bb looks like

BB#4193: derived from LLVM BB %indirectgoto
    Predecessors according to CFG: .....
	%vreg5207<def> = PHI ....
	%vreg5208<def> = PHI ....
	%vreg5209<def> = PHI ....
	%vreg5210<def> = PHI ....
	%vreg5211<def> = PHI ....
	%vreg5212<def> = PHI ....
	%vreg5213<def> = PHI ....
	%vreg5214<def> = PHI ....
	%vreg5215<def> = PHI ....
	%vreg5216<def> = PHI ...
	%vreg5292<def> = MOV64ri64i32 4; GR64:%vreg5292
	%vreg5291<def> = MOV32ri -1; GR32:%vreg5291
	%vreg5290<def> = MOV32r0 %EFLAGS<imp-def,dead>; GR32:%vreg5290
	%vreg5289<def> = MOV64ri32 -2; GR64:%vreg5289
	%vreg5288<def> = MOV64ri64i32 2; GR64:%vreg5288
	JMP64m %vreg5216, 1, %noreg, 0, %noreg; mem:LD8[%indirect.goto.dest.in]
GR64:%vreg5216
    Successors according to CFG: ....


Some statistics from the register allocator

unpatched clang:
53934 regalloc         - Number of copies inserted for splitting

patched clang:
indirect:
7636 regalloc         - Number of copies inserted for splitting

So it looks like what the patch really does is help the register
allocator. Another interesting ones

unpatched clang -disable-early-taildup:
 1105 regalloc         - Number of copies inserted for splitting

patched clang -disable-early-taildup:
6714 regalloc         - Number of copies inserted for splitting

>From the above my guess is that the register allocator is getting really
confused by the extra live ranges introduced. Tail dup in particular
seems to do it in a way that is worse than the regular out of ssa pass.

Is there any cleanup pass that we currently only run before tail dup but
should try to run after it too?

Cheers,
Rafael



More information about the llvm-commits mailing list