There's no real read of the register, so the copy introduced a new
live value. Make sure we introduce a replacement implicit_def instead
of just erasing the copy.
Found from llvm-reduce since it tries to set undef on everything.
Differential D127516
RegisterCoalescer: Fix verifier error when merging copy of undef arsenm on Jun 10 2022, 11:19 AM. Authored by
Details
Diff Detail Event TimelineComment Actions I am not sure I understand this change... Wasn't the intention of the existing that code that when you have something like: %2 = COPY undef %1 USE %2 that you merge the regs to remove the copy and add an undef to the use operands? => USE undef %1 Why are we starting to use IMPLICIT_DEFs here? Is this related to subregs? Comment Actions Yes, but in this situation the output register was a phi def so we need to keep a phi def in the same block in the coalesced register
Because it's a live out value, so you need a phi def in the block. It's not related to subregs. This is analagous to the case where ProcessImplicitDefs won't delete IMPLICIT_DEFs that feed phi uses. Comment Actions For background: My understanding of IMPLICIT_DEF is that it was a bit of a workaround/hack necessary because for a given VReg on a control flow join you can have different "undef"/"not undef" merge. Unfortunately being out of SSA form we can't just attach an undef flag to the respective PHI operand as there is no PHI anymore. I always felt a bit uneasy with IMPLICIT_DEF getting used in other situations where they are not at the end of a block just for joining with a different definition/live value in the next block... Though I have a feeling restricting IMPLICIT_DEFs just to this particular use case may be a loosing battle now since I think I've seen them pop-up in other situations... Also I don't remember fully, but I think we also trouble with undef flags being unable to express partially defined registers when subreg liveness is enabled.
Comment Actions I still feel like I don't fully understand why the change in undef-subreg-use-after-coalesce.mir makes things better, but either way the code changes seem reasonable and in the interest of not blocking this any further, go ahead! LGTM |