Skip to content

[AMDGPU] LiveIntervals is inaccurate after TwoAddressInstructionPass #98741

Closed
@paperchalice

Description

@paperchalice

There are some test failures in pull request #98632 when LiveIntervals analysis happens before TwoAddressInstructionPass, because SIInstrInfo::convertToThreeAddress doesn't handle live intervals after folding immediate values:

const auto killDef = [&]() -> void {
const MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo();
// The only user is the instruction which will be killed.
Register DefReg = DefMI->getOperand(0).getReg();
if (!MRI.hasOneNonDBGUse(DefReg))
return;
// We cannot just remove the DefMI here, calling pass will crash.
DefMI->setDesc(get(AMDGPU::IMPLICIT_DEF));
for (unsigned I = DefMI->getNumOperands() - 1; I != 0; --I)
DefMI->removeOperand(I);
if (LV)
LV->getVarInfo(DefReg).AliveBlocks.clear();
};

The live interval of DefReg is no longer valid.


In #66775, -early-live-intervals will not work when using -run-pass, the Liveintervals LIS in TwoAddressInstructionPass is nullptr when I debugging this part. A possible way to test -early-live-intervals is using:

llc -march=amdgcn -mcpu=gfx1010 %s -run-pass liveintervals -run-pass twoaddressinstruction -verify-machineinstrs -o -

but llc will crash.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions