[PATCH] D134296: [SIE] Always enable the .debug_aranges section when using LTO
Matthew Voss via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 20 14:47:37 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45c7da241f12: [PS4] Always enable the .debug_aranges section when using LTO (authored by ormris).
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134296/new/
https://reviews.llvm.org/D134296
Files:
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/debug-options.c
clang/test/Driver/ps4-ps5-linker-jmc.c
Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===================================================================
--- clang/test/Driver/ps4-ps5-linker-jmc.c
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -6,10 +6,10 @@
// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
-// CHECK-PS4-NOT: "-enable-jmc-instrument"
+// CHECK-PS4-NOT: -enable-jmc-instrument
-// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
-// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument
+// CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument
// CHECK-PS5-NOT: "-enable-jmc-instrument"
Index: clang/test/Driver/debug-options.c
===================================================================
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -107,6 +107,14 @@
// RUN: | FileCheck -check-prefix=CI %s
// RUN: %clang -### -c %s -gsce -target x86_64-unknown-linux 2>&1 \
// RUN: | FileCheck -check-prefix=NOCI %s
+// RUN: %clang -### %s -g -flto=thin -target x86_64-scei-ps4 2>&1 \
+// RUN: | FileCheck -check-prefix=SNLDTLTOGARANGE %s
+// RUN: %clang -### %s -g -flto=full -target x86_64-scei-ps4 2>&1 \
+// RUN: | FileCheck -check-prefix=SNLDFLTOGARANGE %s
+// RUN: %clang -### %s -g -flto -target x86_64-scei-ps5 2>&1 \
+// RUN: | FileCheck -check-prefix=LLDGARANGE %s
+// RUN: %clang -### %s -g -target x86_64-scei-ps5 2>&1 \
+// RUN: | FileCheck -check-prefix=LDGARANGE %s
// On the AIX, -g defaults to -gdbx and limited debug info.
// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
@@ -365,6 +373,13 @@
// NOPUB-NOT: -ggnu-pubnames
// NOPUB-NOT: -gpubnames
//
+
+// LDGARANGE: {{".*ld.*"}} {{.*}}
+// LDGARANGE-NOT: "-generate-arange-section"
+// LLDGARANGE: {{".*lld.*"}} {{.*}} "-generate-arange-section"
+// SNLDTLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-thin-debug-options=-generate-arange-section"
+// SNLDFLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-debug-options=-generate-arange-section"
+
// PUB: -gpubnames
//
// RNGBSE: -fdebug-ranges-base-address
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===================================================================
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -159,17 +159,32 @@
const bool IsPS5 = TC.getTriple().isPS5();
assert(IsPS4 || IsPS5);
+ ArgStringList DbgOpts;
+
// This tells LTO to perform JustMyCode instrumentation.
- if (UseLTO && UseJMC) {
- if (IsPS4 && D.getLTOMode() == LTOK_Thin) {
- CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument");
- } else if (IsPS4 && D.getLTOMode() == LTOK_Full) {
- CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument");
- } else if (IsPS5) {
- CmdArgs.push_back("-mllvm");
- CmdArgs.push_back("-enable-jmc-instrument");
- } else
- llvm_unreachable("new LTO mode?");
+ if (UseLTO && UseJMC)
+ DbgOpts.push_back("-enable-jmc-instrument");
+
+ // We default to creating the arange section, but LTO does not. Enable it
+ // here.
+ if (UseLTO)
+ DbgOpts.push_back("-generate-arange-section");
+
+ if (UseLTO) {
+ if (IsPS4) {
+ StringRef F = (D.getLTOMode() == LTOK_Thin) ?
+ "-lto-thin-debug-options=" : "-lto-debug-options=";
+ F = makeArgString(Args, F.data(), DbgOpts.front(), "");
+ DbgOpts.erase(DbgOpts.begin());
+ for (auto X : DbgOpts)
+ F = makeArgString(Args, F.data(), " ", X);
+ CmdArgs.push_back(F.data());
+ } else {
+ for (auto D : DbgOpts) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(D);
+ }
+ }
}
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134296.461718.patch
Type: text/x-patch
Size: 4046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220920/7f5b6579/attachment-0001.bin>
More information about the cfe-commits
mailing list