[llvm-dev] -fhash-long-section-names=N, -fhashed-section-names=map.csv
Christopher Friedt via llvm-dev
llvm-dev at lists.llvm.org
Thu Nov 25 06:15:55 PST 2021
Made some progress and would still very much like to get some feedback
from LLVM devs.
I ended up implementing an AST matcher via the tutorial[1] and have a
PoC here[2] which works[3]. I do need to move the matcher out of the
custom tool that I created and into Sema still. Also added some
regression tests (although, I think I might need to move that logic to
unit tests instead).
One thing I've come to realize a bit more though is that I might need
to target LangOptions rather than CodeGenOptions. Is anyone able to
confirm that is the correct location for this option?
Working with the AST and SemaCXX has surprisingly little to do with
specific machine code generation. I guess that's just how LLVM is
architected. There is one exception in this case though; I still need
to somehow determine if the target object file is MachO in order to
decide whether to call MCSectionMachO::ParseSectionSpecifier().
Is there an easy way to determine the target object file format via
the ASTContext?
[1] https://clang.llvm.org/docs/LibASTMatchersTutorial.html
[2] https://github.com/llvm/llvm-project/compare/main...cfriedt:fhash-long-section-names
[3]
% long-section-converter clang/test/SemaCXX/attr-section-hashed-macos.cpp \
-- -fhash-long-section-names=16
VarDecl 0x1470cdec0 <.../attr-section-hashed-macos.cpp:1:1, line:2:5>
col:5 foo 'int'
`-SectionAttr 0x1470cdf28 <line:1:16, col:59> section
"__RODATA,ip9RNVxH27rCS+Ix"
VarDecl 0x1470ce390 parent 0x14702fc08
<.../attr-section-hashed-macos.cpp:8:3, col:24> col:14 used start_foo
'int[]' extern
`-AsmLabelAttr 0x1470ce408 <col:32>
"section$start$__RODATA$ip9RNVxH27rCS+Ix" IsLiteralLabel
VarDecl 0x147808e00 parent 0x14702fc08
<.../attr-section-hashed-macos.cpp:9:3, col:22> col:14 used end_foo
'int[]' extern
`-AsmLabelAttr 0x147808e78 <col:30>
"section$end$__RODATA$ip9RNVxH27rCS+Ix" IsLiteralLabel
More information about the llvm-dev
mailing list