Hi Jonas,
On Jun 11, 2014, at 11:50 AM, Lang Hames <lhames at gmail.com> wrote:
> Hi Jonas,
>
> > These operands are not supposed to be around… they are added a bit
later in the method.
>
> I'm not quite sure what you mean here?
>
> I think that assertion is there to catch the case where a rematerialized
instruction is implicitly clobbering the flags register, which is fairly common.
I don't think the coalescer knows how to deal with implicit operands in
general.
>
> Are you able to tell us anything about the nature of the instruction (and
implicit use) that you're trying to rematerialize?
>
> Cheers,
> Lang.
>
>
> On Wed, Jun 11, 2014 at 6:42 AM, Jonas Paulsson <jonas.paulsson at
ericsson.com> wrote:
> Hi,
>
>
>
> I am a bit confused in the method
RegisterCoalescer::reMaterializeTrivialDef().
>
>
>
> It seems that
>
>
>
> TII->reMaterialize(*MBB, MII, DstReg, SrcIdx, DefMI, *TRI);
>
>
>
> simply clones the instruction.
>
>
>
> In my case, some implicit use operands exist, so they are also added to the
NewMI.
>
This method only handles trivial def. I.e., instructions that do not have any
actual uses.
If you have implicit use operands, then the rematerialization may be wrong.
E.g..
v1 = remat_inst <implicit-use R3>
R3 =
<— If you rematerialize here you will use of different value of R3 and that
may change the value of v1.
If the value of the implicit uses do not change the value of the def, I guess
you shouldn’t specify them in the first place.
An alternative in that case is to use a pseudo instruction that you will lower
with the implicit use later (though I do not see why you would need it if they
do not change the result).
The bottom line is if you have registers uses (implicit or not), then you cannot
trivially rematerialize this instruction.
Cheers,
-Quentin>
>
> This however, triggers the assert:
>
>
>
> // NewMI may have dead implicit defs (E.g. EFLAGS for MOV<bits>r0
on X86).
>
> // We need to remember these so we can add intervals once we insert
>
> // NewMI into SlotIndexes.
>
> SmallVector<unsigned, 4> NewMIImplDefs;
>
> for (unsigned i = NewMI->getDesc().getNumOperands(),
>
> e = NewMI->getNumOperands(); i != e; ++i) {
>
> MachineOperand &MO = NewMI->getOperand(i);
>
> if (MO.isReg()) {
>
> assert(MO.isDef() && MO.isImplicit() && MO.isDead()
&&
>
> TargetRegisterInfo::isPhysicalRegister(MO.getReg()));
>
>
>
> These operands are not supposed to be around… they are added a bit later in
the method.
>
>
>
> I don’t see any other targets handling these types of operands in their
rematerialize() definitions. Should I override this and make sure that these
implicit use ops are omitted?
>
> Or am I missing something?
>
>
>
> Thanks in advance,
>
>
>
> Jonas Paulsson
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140611/433604a4/attachment.html>