Skip to content

[AMDGPU] LiveIntervals is inaccurate after TwoAddressInstructionPass #98741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paperchalice opened this issue Jul 13, 2024 · 1 comment · Fixed by #104610
Closed

[AMDGPU] LiveIntervals is inaccurate after TwoAddressInstructionPass #98741

paperchalice opened this issue Jul 13, 2024 · 1 comment · Fixed by #104610

Comments

@paperchalice
Copy link
Contributor

paperchalice commented Jul 13, 2024

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.

@llvmbot
Copy link
Member

llvmbot commented Jul 13, 2024

@llvm/issue-subscribers-backend-amdgpu

Author: None (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: https://github.com/llvm/llvm-project/blob/ae63db78828621feca713016e33f34717da626a5/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp#L3949-L3961 The live interval of `DefReg` is no longer valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants