This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add an option to emit the Tag_RISCV_arch attribute based on the assembler's subtarget
ClosedPublic

Authored by craig.topper on Apr 19 2023, 10:12 PM.

Details

Summary

This adds an option to emit the command line -mattr/-march into the
attributes of an object file. This can useful to get objdump to
disassemble instructions that aren't in the base without forcing
users to add a .attribute to the assembly file.

The binutils assembler does this by default.

Similar option exists for ARM. I will wire it to a clang option in
another patch. Similar to https://reviews.llvm.org/D31813

Diff Detail

Event Timeline

craig.topper created this revision.Apr 19 2023, 10:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 10:12 PM
craig.topper requested review of this revision.Apr 19 2023, 10:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 10:12 PM
kito-cheng accepted this revision.Apr 20 2023, 12:08 AM

LGTM, this would be very useful for assembly files, since I believe most developer won't write attribute when writing assembly code, and arch attribute is also kind of hard to write it correctly by human - and it even need to sync with build system (-march option for assembler)! so I believe auto generate that is right way to go.

This revision is now accepted and ready to land.Apr 20 2023, 12:08 AM
asb added a comment.Apr 20 2023, 1:49 AM

LGTM, modulo my comment about testing stack align attribute behaviour.

llvm/test/MC/RISCV/default-build-attributes.s
10

As I understand it, your intent is that the stack alignment attribute isn't emitted with -riscv-add-build-attributes (which I assume matches GNU behaviuor) This file should probably test for that.

Add -NOT checks for stack align

asb accepted this revision.Apr 20 2023, 9:54 AM

LGTM, thanks.

This revision was landed with ongoing or failed builds.Apr 20 2023, 10:00 AM
This revision was automatically updated to reflect the committed changes.