This is an archive of the discontinued LLVM Phabricator instance.

[Greedy RA] Add a check to MachineVerifier
ClosedPublic

Authored by skatkov on Apr 14 2021, 10:11 PM.

Details

Summary

If Virtual Register is alive in landing pad its def must be
before the call causing the exception or it should be statepoint instruction itself and
in this case def actually means the relocation of gc pointer and is alive in
landing pad.

The test shows the triggering this check for an option under development
use-registers-for-gc-values-in-landing-pad which is off by default until
it is functionally correct.

Diff Detail

Event Timeline

skatkov created this revision.Apr 14 2021, 10:11 PM
skatkov requested review of this revision.Apr 14 2021, 10:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2021, 10:11 PM
Herald added a subscriber: wdng. · View Herald Transcript
rnk added a comment.Apr 15 2021, 11:31 AM

Seems reasonable

llvm/lib/CodeGen/MachineVerifier.cpp
2976–2977

I don't see anything statepoint-specific below, so I'm not sure how the second part of this comment is relevant. The first sentence makes sense: EH pads have a special rule that requires virtual registers to be defined before the last call in each predecessor, rather than before the first terminator.

2978–2979

Please use braces when there is an inner compound statement that uses braces. The style guide has an example that supports this interpretation:
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

// Use braces for the outer `if` since the nested `for` is braced.
if (isa<FunctionDecl>(D)) {
  for (auto *A : D.attrs()) {
    // In this for loop body, it is necessary that we explain the situation
    // with this surprisingly long comment, forcing braces on the `for` block.
    handleAttr(A);
  }
}
2981

I believe this is the correct condition.

skatkov updated this revision to Diff 337967.Apr 15 2021, 7:51 PM

@rnk, Reid, thank you very much for the review. Please take a look into updated version.

BTW, I plan to upload a series patches for Greedy RA to fix the crash caused by the adding check, will you be the right person to add you as reviewer for GreedyRA?

rnk accepted this revision.Apr 16 2021, 3:31 PM

lgtm with a nit

llvm/lib/CodeGen/MachineVerifier.cpp
2976

This isEHPad if should use braces as well by the same style rule.

This revision is now accepted and ready to land.Apr 16 2021, 3:31 PM
This revision was automatically updated to reflect the committed changes.