Previously, we only checked for clobbers when merging into a READ of
the physreg, but not when merging from a WRITE to the physreg.
Details
Diff Detail
- Build Status
Buildable 2788 Build 2788: arc lint + arc unit
Event Timeline
Makes sense, I am surprised this didn't hit us before.
Could you create a .mir based test that just runs the coalescer instead of the .ll one?
I noted the existing MIR test in AArch64/regcoal-physreg.mir, and added another test-case there.
I also noticed while writing this new test case that MachineRegisterInfo::isConstantPhysReg treats any register without a visible def in the function as "constant". And thus, the newly added test case doesn't work -- it will coalesce -- without the "%x18 = COPY %xzr" line.
I'm not sure this is correct behavior, since it *also* fails to take into account regmasks, but I also don't know if there's a situation where it would actually matter -- in the actual case I'm looking at, the inlineasm is a def of the register, so that's fine.
test/CodeGen/AArch64/regcoal-physreg.mir | ||
---|---|---|
77 ↗ | (On Diff #84126) | That sounds like a bug to me. Could you investigate please? |
LGTM
The "no-def+!allocatable => constant" rule has been there for a long time in MachineRegisterInfo::isConstantPhysReg(), not sure we need to check/question it as part of this commit...
The "no-def+!allocatable => constant" rule has been there for a long time in MachineRegisterInfo::isConstantPhysReg()
Oh, I missed the !allocatable in the description of the problem.
Yeah, no need to investigate then.
llvm/trunk/test/CodeGen/AArch64/regcoal-physreg.mir | ||
---|---|---|
78 ↗ | (On Diff #84337) | You could use something else than x18 to avoid the !allocatable case that Matthias mentioned, right? |
llvm/trunk/test/CodeGen/AArch64/regcoal-physreg.mir | ||
---|---|---|
78 ↗ | (On Diff #84337) | The bug only exhibits for reserved registers in the first place (and only, then, if it is also clobbered by a call), so another register wouldn't be appropriate. |