[LLVMdev] Live intervals and aliasing registers problem
Christopher Lamb
christopher.lamb at gmail.com
Tue Apr 3 15:45:45 PDT 2007
On Mar 27, 2007, at 3:25 PM, Evan Cheng wrote:
>
> On Mar 25, 2007, at 7:12 AM, Christopher Lamb wrote:
>
>> While beginning to add vector registers to a back end I came
>> across the following problem: as soon as I define two sets of
>> registers that have a many-to-one mapping the live interval pass
>> appears to double-kill the mapped-onto register. I have the
>> following excerpts from my RegisterInfo.td.
>>
>> def V4R0 : R4v<0 , "V4R0 ", []>, DwarfRegNum<0>;
>>
>> def R0 : Rg<0 , "R0", [V4R0]>, DwarfRegNum<0>;
>> def R1 : Rg<1 , "R1", [V4R0]>, DwarfRegNum<1>;
>
> How are R4v and Rg defined?
class Rg<bits<6> num, string n, list<Register> aliases> : MyReg<n>
{
let Num = num;
let Aliases = aliases;
}
class R4v<bits<6> num, string n, list<Register> aliases> : MyReg<n> {
let Num = num;
let Aliases = aliases;
}
>>
>> when trying to compile:
>>
>> define void @_Z3fooii(i32 %a, i32 %b) {
>> entry:
>> %retval = select i1 false, i32 %a, i32 %b ;
>> <i32> [#uses=0]
>> ret void
>> }
>>
>> I get this error:
>>
>> entry (0x8503b90, LLVM BB @0x8501b00, ID#0):
>> %reg1024 = ORI %R0, 0
>> %reg1025 = ORI %R1, 0
>> RETL
>> Machine Function
>> ********** REWRITING TWO-ADDR INSTRS **********
>> ********** Function: _Z3fooff
>>
>> ********** COMPUTING LIVE INTERVALS **********
>> ********** Function: _Z3fooii
>> entry:
>> livein register: R0 killed +[0,2:0)
>> livein register: V4R0 killed +[0,2:0) <=== this
>> is bad
>> livein register: R1 killed +[0,6:0)
>> livein register: V4R0 killed +[0,2:1)
>> lib/CodeGen/LiveInterval.cpp:189: failed assertion `B->end <=
>> Start && "Cannot overlap two LiveRanges with differing ValID's"
>> " (did you def the same reg twice in a MachineInstr?)"'
>
> V4R0 should not have been killed twice. The second ORI instruction
> is the last use of V4R0. Are you adding the correct livein's (just
> R0 and R1) to the function?
Yes, only R0 and R1 are being added.
> Can you dump out the machine basic block? It should have an
> implicit use of V4R0 at first ORI but it should not be marked kill.
> If it is marked kill, then you need to walk LiveVariables.cpp to
> find out why.
Here is the beginning of the BB dump.
entry (0x8503c80, LLVM BB @0x8501af0, ID#0):
Live Ins: %R0 %R1
%reg1024 = ORI %R0<kill>, 0
%reg1025 = ORI %R1<kill>, 0
V4R0 is getting killed because handleLiveInRegister() is called on
all results of getAliasSet() for each of the liveins (this is in
LiveIntervals::computeIntervals() ).
handleRegisterDef() does a similar thing where calls
handlePhysicalRegisterDef() on all members of getAliasSet() returned
for the def, which also triggers this problem.
Is it calling handle*() on the alias set of a register thats the
culprit, or is it some mishandling in KillsRegister()?
Thanks
--
Christopher Lamb
More information about the llvm-dev
mailing list