This is an archive of the discontinued LLVM Phabricator instance.

[TwoAddressInstruction] Don't run machine verification on unclean targets
AbandonedPublic

Authored by foad on Oct 11 2021, 7:42 AM.

Details

Summary

When -early-live-intervals is used, TwoAddressInstruction runs some
extra ad hoc machine verification, but it does this even for targets
that are marked as "not machine verifier clean". Fix this so that we
don't get spurious failures that are not related to live intervals.

Diff Detail

Event Timeline

foad created this revision.Oct 11 2021, 7:42 AM
foad requested review of this revision.Oct 11 2021, 7:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 11 2021, 7:42 AM
fhahn added a comment.Oct 11 2021, 8:24 AM

Sounds good to me. Is it possible to add a test case?

foad updated this revision to Diff 378691.Oct 11 2021, 8:56 AM

Add test coverage.

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

This is the only way I could think of to test it. Without the change to TwoAddressInstructionPass, enabling -early-live-intervals on Lanai (an unclean target) would throw up known errors like:

*** Bad machine code: MBB exits via conditional branch/fall-through but ends with a barrier instruction! ***
- function:    clz32
- basic block: %bb.0  (0x73a5a68) [0B;64B)
fhahn accepted this revision.Oct 11 2021, 9:03 AM

LGTM, thanks!

This revision is now accepted and ready to land.Oct 11 2021, 9:03 AM
MatzeB added inline comments.Oct 11 2021, 9:35 AM
llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
1659–1665

Could we just remove this code? Doesn't seem like we miss much since this is the last step of the pass before we would have a verifier pass scheduled anyway...

foad added inline comments.Oct 11 2021, 12:33 PM
llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
1659–1665

There is actually a subtle difference: if this pass is the last user of an analysis like LiveVariables, then calling MF->verify() here will verify that analysis, but scheduling a MachineVerifier pass afterwards will not, because the pass manager frees analyses immediately after their last user.

Because of that, this call to MF->verify() catches more problems than -verify-machineinstrs (or enabling LLVM_ENABLE_EXPENSIVE_CHECKS) does.

But I'd still be happy to remove it. I'll prepare a patch...

foad abandoned this revision.Oct 15 2021, 4:40 AM

Superseded by D111618.

llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
1659–1665