[LLVMdev] Linearscan allocator bug?
Vladimir Prus
ghost at cs.msu.su
Wed Jun 23 01:00:02 PDT 2004
Chris Lattner wrote:
> On Tue, 22 Jun 2004, Vladimir Prus wrote:
> > First, I attach two files -- LLVM asm and the asm for my target. The
> > problem with assembler is: on line 171 it uses register gr2, which is
> > copied from gr6 above, on line 161. The only predecessor of this basic
> > block is jump on line 90. The problem is that gr6 is not initialized in
> > the interval from the function entry till the jump.
>
> Okay, I see the problem. You need to tell the compiler that the
> conditional branches are terminators. You're getting code that looks like
> this:
>
> <LBB7> // // shortcirc_next.0.selectcont.selectcont
> gr1 = gr1;
> gr1 = gr1;
> gr5 = 0;
> gr2 - gr5;
> if <>0 goto LBB11;
> * gr2 = gr4;
> * gr5 = gr1;
> * gr6 = gr4;
> * gr1 = gr1;
> goto LBB8;
>
> I'm guessing that those copies are inserted by the register allocator, and
> in particular, that is probably where gr6 is supposed to get it's value.
> If you set the isTerminator flag on your 'if <>0 goto LBB11;' things will
> probably magically start working for you, as the copies will be inserted
> BEFORE the branch instead of after it.
Hmm.. this is what I have in td file already:
let isTerminator = 1 in
def GOTO : Unknown<"goto">;
def IFEQ : Unknown<"if =0 goto">;
def IFNEQ : Unknown<"if <>0 goto">;
.....
Should this work?
> Also, if you haven't already, you might want to teach TargetInstrInfo
> that '=' is a move instruction (implement isMoveInstr), so instructinos
> like 'gr1 = gr1' will go away and you'll get coallescing. :)
BTW, is it possible to set some instruction flag, instead of overriding a
function? Something like:
let isMove = 1 in
def MOVE :.....
?
- Volodya
More information about the llvm-dev
mailing list