[PATCH] D133092: [clang] fix generation of .debug_aranges with LTO
Azat Khuzhin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 31 22:42:51 PDT 2022
azat created this revision.
Herald added a subscriber: inglorion.
Herald added a project: All.
azat requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.
Right now in case of LTO the section is not emited:
$ cat test.c
void __attribute__((optnone)) bar()
{
}
void __attribute__((optnone)) foo()
{
bar();
}
int main()
{
foo();
}
$ clang -flto=thin -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out | fgrep -c -e foo -e bar
0
$ clang -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out | fgrep -c -e foo -e bar
2
Fix this by passing explicitly -mllvm -generate-arange-section.
P.S. although this looks like a hack, since none of -mllvm was passed to
the lld before.
Signed-off-by: Azat Khuzhin <a.khuzhin at semrush.com>
Suggested-by: OCHyams <orlando.hyams at sony.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133092
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -506,6 +506,9 @@
Suffix,
Plugin);
CmdArgs.push_back(Args.MakeArgString(Plugin));
+ } else if (Args.hasArg(options::OPT_gdwarf_aranges)) {
+ CmdArgs.push_back(Args.MakeArgString("-mllvm"));
+ CmdArgs.push_back(Args.MakeArgString("-generate-arange-section"));
}
// Try to pass driver level flags relevant to LTO code generation down to
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133092.457178.patch
Type: text/x-patch
Size: 591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220901/b3de74dd/attachment.bin>
More information about the cfe-commits
mailing list