This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Add VRFrame and VRFrameLocal to integer register classes
ClosedPublic

Authored by asavonic on Sep 21 2021, 6:26 AM.

Details

Summary

These registers are used as operands for instructions that expect an
integer register, so they should be added to Int32Regs or Int64Regs
register classes. Otherwise the machine verifier emits an error for
the following LIT tests when LLVM_ENABLE_MACHINE_VERIFIER=1
environment variable is set:

*** Bad machine code: Illegal physical register for instruction ***
- function:    kernel_func
- basic block: %bb.0 entry (0x55c8903d5438)
- instruction: %3:int64regs = LEA_ADDRi64 $vrframelocal, 0
- operand 1:   $vrframelocal
$vrframelocal is not a Int64Regs register.

CodeGen/NVPTX/call-with-alloca-buffer.ll
CodeGen/NVPTX/disable-opt.ll
CodeGen/NVPTX/lower-alloca.ll
CodeGen/NVPTX/lower-args.ll
CodeGen/NVPTX/param-align.ll
CodeGen/NVPTX/reg-types.ll
DebugInfo/NVPTX/dbg-declare-alloca.ll
DebugInfo/NVPTX/dbg-value-const-byref.ll

Diff Detail

Event Timeline

asavonic created this revision.Sep 21 2021, 6:26 AM
asavonic requested review of this revision.Sep 21 2021, 6:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2021, 6:26 AM
asavonic edited the summary of this revision. (Show Details)Sep 21 2021, 6:27 AM
asavonic edited the summary of this revision. (Show Details)
asavonic edited the summary of this revision. (Show Details)

While the patch does silence the error, I don't think that assigning
the same register to different register classes (for 32- and 64-bit
triple) is the right thing to do.

Instead, I guess we can define new set of registers (VRFrame64 and
VRFrameLocal64), and use them depending on a triple. Let me know if
this is an acceptable solution, or we should do something else.

tra added a comment.Sep 21 2021, 10:15 AM

I agree. Those registers should match the pointer size. Adding a 64-bit variant is probably the way to go.

asavonic updated this revision to Diff 378539.Oct 10 2021, 3:58 PM
asavonic edited the summary of this revision. (Show Details)
tra added a comment.Oct 11 2021, 11:01 AM

LGTM in general.

It would be great to add two test runs (for 32 and 64-bit modes) in test/CodeGen/NVPTX/local-stack-frame.ll with -verify-machineinstrs to make sure it does work as intended.

asavonic updated this revision to Diff 379084.Oct 12 2021, 9:32 AM
  • Added -verify-machineinstrs to local-stack-frame.ll
tra accepted this revision.Oct 12 2021, 10:42 AM
This revision is now accepted and ready to land.Oct 12 2021, 10:42 AM
asavonic updated this revision to Diff 379327.Oct 13 2021, 3:39 AM
  • Updated debug-info.ll LIT test.

Not sure why it is changed though.

tra added a comment.Oct 13 2021, 10:05 AM
  • Updated debug-info.ll LIT test.

Not sure why it is changed though.

The order of .reg directives is not guaranteed. The tests should've used CHECK-DAG for them. We may as well fix it now, too.

asavonic updated this revision to Diff 379487.Oct 13 2021, 12:03 PM
  • Updated debug-info.ll to use CHECK-DAG for .reg checks.