This is an archive of the discontinued LLVM Phabricator instance.

[PHIElimination] Enable machine verification after this pass
ClosedPublic

Authored by foad on Oct 3 2021, 1:14 AM.

Diff Detail

Event Timeline

foad created this revision.Oct 3 2021, 1:14 AM
foad requested review of this revision.Oct 3 2021, 1:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 3 2021, 1:14 AM
MatzeB accepted this revision.Oct 4 2021, 9:37 AM

LGTM

This revision is now accepted and ready to land.Oct 4 2021, 9:37 AM
This revision was automatically updated to reflect the committed changes.

Hi,

I ran into a verifier error after PHIElimination with this patch.

I saw this for my out-of-tree target, but I think the following mir-testcase exposes the same thing on X86:

llc -verify-machineinstrs -o /dev/null bbi-61405_x86.mir -run-pass=livevars,phi-node-elimination,twoaddressinstruction

Result:

*** Bad machine code: LiveVariables: Block should not be in AliveBlocks ***
- function:    f245
- basic block: %bb.1  (0x7353b68)
Virtual register %6 is not needed live through the block.
LLVM ERROR: Found 1 machine code errors.

It seems to be the undef use of %6 in

dead %2:gr16 = PHI undef %6, %bb.1, undef %3, %bb.5

that trips PHI Elimination over.
Without it, the inserted COPY for the other PHI gets a kill marking on its source (%6), and all is fine.
But with the "undef %6" operand in the second PHI, the kill marking is skipped and then we get the verifier error.

foad added a comment.Oct 11 2021, 7:19 AM

Hi @uabelho, can you share the test case?

Hi @uabelho, can you share the test case?

Oh, I forgot that! Here it is!

Thanks!

foad added a comment.Oct 11 2021, 8:23 AM

D111552 should fix it.

D111552 should fix it.

Yep, thanks!