This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][AsmParser] Fix matching immediate literals.
ClosedPublic

Authored by kosarev on Jan 20 2023, 2:11 AM.

Details

Summary

Prevents potential matching of literal offsets to non-literal operands.

Diff Detail

Event Timeline

kosarev created this revision.Jan 20 2023, 2:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 2:11 AM
kosarev requested review of this revision.Jan 20 2023, 2:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 2:11 AM

I'm not sure there's a way to prepare a reliable regression test for this.

foad added a comment.Jan 20 2023, 2:20 AM

What does this fix?

kosarev updated this revision to Diff 490782.Jan 20 2023, 4:16 AM

Update commit message.

kosarev edited the summary of this revision. (Show Details)Jan 20 2023, 4:16 AM

What does this fix?

The description should now hopefully answer this.

I'm not sure there's a way to prepare a reliable regression test for this.

If there's a literal parsing issue seems like it should be straightforward?

kosarev added a comment.EditedJan 20 2023, 6:30 AM

If there's a literal parsing issue seems like it should be straightforward?

There is no reproducer, and even if we have one, it would still be not reliable, because the order in which the internal AsmParser machinery tries to match operands is generally beyond our control.

What's interesting about this change is that defaultSMRDOffset8() and defaultSMRDLiteralOffset() are not updated to add ImmTyNone operands instead of ImmTyOffset and we still pass the tests. That's because we don't really have any GFX6 tests with these operands dropped, so no default values used. (Addressed in D142231.)

dp added a comment.Jan 24 2023, 3:04 AM

Does your patch fix this bug?

s_load_dword s5, s[2:3], glc

Assembler should trigger an error for GFX7, but glc is misinterpreted as offset operand.
I think your patch should fix this bug, so you may add this code as a test.

kosarev updated this revision to Diff 495813.Feb 8 2023, 5:44 AM

Added the suggested test.

Does your patch fix this bug?

s_load_dword s5, s[2:3], glc

It does, thanks! Is there a ticket to be mentioned in the commit message?

dp added a comment.Feb 8 2023, 8:00 AM

Is there a ticket to be mentioned in the commit message?

There is no ticket. I found this bug while analyzing your patch and trying to break the parser.

dp accepted this revision.Feb 8 2023, 8:06 AM

LGTM, but I suggest moving the test to some other place. *_unsupported.s are used solely to test identification of unsupported opcodes. gfx7_err_pos.s may be a better place for this test.

This revision is now accepted and ready to land.Feb 8 2023, 8:06 AM
kosarev updated this revision to Diff 496076.Feb 9 2023, 3:45 AM

Moved the test to gfx7_err_pos.s.

This revision was landed with ongoing or failed builds.Feb 10 2023, 3:36 AM
This revision was automatically updated to reflect the committed changes.