[PATCH] D54487: Implement llvm.commandline named metadata
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 13 12:06:51 PST 2018
scott.linder created this revision.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Implement a new special named metadata, `llvm.commandline`, to support frontends embedding their command-line options in IR/ASM/code-objects. Specifically this supports adding the `-frecord-gcc-switches` option to Clang.
This differs from the GCC implementation in a few ways, and I am looking for feedback on whether these differences are reasonable/correct.
In GCC there is only one command-line possible per compilation-unit, in LLVM it mirrors `llvm.ident` and multiple are allowed. In GCC it is emitted to an ELF section named `.GCC.command.line`, for LLVM it is emitted to an ELF section named `.LLVM.command.line`. In GCC there is no special syntax in ASM (.section/.ascii/.zero are used), in LLVM there is a special `.commandline` directive.
For the ELF section, in the case of GCC the options are null-terminated (e.g. '-foo\0-bar\0-baz\0'); in LLVM, in order to differentiate multiple merged command-lines, the null byte instead separates entire command-lines (e.g. '\0compiler1 -foo -bar -baz\0compiler2 -qux\0'). This is the biggest departure in terms of implementation, but in the face of section merging I don't understand how the GCC approach works in any meaningful way. The advantage I see to the GCC approach is unambiguously separating individual arguments without relying on shell-style parsing.
Repository:
rL LLVM
https://reviews.llvm.org/D54487
Files:
include/llvm/CodeGen/AsmPrinter.h
include/llvm/MC/MCAsmInfo.h
include/llvm/MC/MCELFStreamer.h
include/llvm/MC/MCStreamer.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/IR/Verifier.cpp
lib/MC/MCAsmInfoELF.cpp
lib/MC/MCAsmStreamer.cpp
lib/MC/MCELFStreamer.cpp
lib/MC/MCParser/ELFAsmParser.cpp
test/CodeGen/X86/commandline-metadata.ll
test/Linker/Inputs/commandline.a.ll
test/Linker/Inputs/commandline.b.ll
test/Linker/commandline.ll
test/MC/ELF/commandline.s
test/Verifier/commandline-meta1.ll
test/Verifier/commandline-meta2.ll
test/Verifier/commandline-meta3.ll
test/Verifier/commandline-meta4.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54487.173890.patch
Type: text/x-patch
Size: 14851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181113/f4a4db80/attachment.bin>
More information about the llvm-commits
mailing list