This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][Disassembler] Fix a spurious error message in an instruction comment.
ClosedPublic

Authored by kosarev on Apr 24 2023, 3:08 AM.

Details

Summary

The patch prevents pollution of instruction comments with error messages
generated during unsuccessful decoding attempts.

Diff Detail

Event Timeline

kosarev created this revision.Apr 24 2023, 3:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 3:08 AM
kosarev requested review of this revision.Apr 24 2023, 3:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 3:08 AM

Note that with the change in place no comments passed to AMDGPUDisassembler::errOperand() may ever be visible to the user, because that function returns a default-constructed MCOperand, which is considered invalid by addOperand() defined in AMDGPUDisassembler.cpp and so instructions having such operands will always be seen as failed decoding attempts. To expose the error messages we would need to support erroneous operands as the comment in AMDGPUDisassembler::errOperand() proposes or find another way.

foad added a comment.Apr 24 2023, 3:19 AM

Do we have any tests that errors like "Error: cannot read literal..." are still emitted when they actually cause the disassembly to fail?

llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
415–416

Is this still required?

foad added a comment.Apr 24 2023, 3:21 AM

Do we have any tests that errors like "Error: cannot read literal..." are still emitted when they actually cause the disassembly to fail?

Oh, I see you have just answered this.

kosarev updated this revision to Diff 516417.Apr 24 2023, 8:15 AM

Remove the now not needed assignment.

kosarev marked an inline comment as done.Apr 24 2023, 8:16 AM
kosarev added inline comments.
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
415–416

Removed, thanks.

Shouldn't error messages not get written to the comment stream in the first place? It seems like you're just trying to avoid getting them in the final output

foad accepted this revision.Apr 25 2023, 1:27 AM

I guess this OK as it fixes a bug, but I'd be happier if we had a plan for what to do with these error messages.

Shouldn't error messages not get written to the comment stream in the first place? It seems like you're just trying to avoid getting them in the final output

I think we want error messages if decoding fails, but not from a failed attempt that was followed by a successful attempt.

This revision is now accepted and ready to land.Apr 25 2023, 1:27 AM
This revision was landed with ongoing or failed builds.Apr 26 2023, 4:50 AM
This revision was automatically updated to reflect the committed changes.
kosarev marked an inline comment as done.