summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Puchert <aaron.puchert@sap.com>2019-06-15 15:38:51 +0000
committerAaron Puchert <aaron.puchert@sap.com>2019-06-15 15:38:51 +0000
commite1dc495e63023cc1df573f35a9714f5b43a9d8d8 (patch)
treecabc7455ce7bf234ea04b94c5fa04067b8646080
parent2d51adcb571408a9556d2af95371c3c9174d1407 (diff)
downloadbcm5719-llvm-e1dc495e63023cc1df573f35a9714f5b43a9d8d8.tar.gz
bcm5719-llvm-e1dc495e63023cc1df573f35a9714f5b43a9d8d8.zip
[Clang] Harmonize Split DWARF options with llc
Summary: With Split DWARF the resulting object file (then called skeleton CU) contains the file name of another ("DWO") file with the debug info. This can be a problem for remote compilation, as it will contain the name of the file on the compilation server, not on the client. To use Split DWARF with remote compilation, one needs to either * make sure only relative paths are used, and mirror the build directory structure of the client on the server, * inject the desired file name on the client directly. Since llc already supports the latter solution, we're just copying that over. We allow setting the actual output filename separately from the value of the DW_AT_[GNU_]dwo_name attribute in the skeleton CU. Fixes PR40276. Reviewers: dblaikie, echristo, tejohnson Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D59673 llvm-svn: 363496
-rw-r--r--clang/include/clang/Basic/CodeGenOptions.h7
-rw-r--r--clang/include/clang/Driver/CC1Options.td2
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp5
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp9
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp1
-rw-r--r--clang/test/CodeGen/split-debug-filename.c6
-rw-r--r--clang/test/CodeGen/split-debug-output.c7
-rw-r--r--clang/test/CodeGen/split-debug-single-file.c8
-rw-r--r--clang/test/CodeGen/thinlto-split-dwarf.c12
-rw-r--r--clang/test/Driver/split-debug.c16
-rw-r--r--llvm/include/llvm/LTO/Config.h10
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp7
13 files changed, 63 insertions, 29 deletions
diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h
index f8c82b4f0e6..7c936c49d3e 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -185,8 +185,11 @@ public:
/// file, for example with -save-temps.
std::string MainFileName;
- /// The name for the split debug info file that we'll break out. This is used
- /// in the backend for setting the name in the skeleton cu.
+ /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
+ /// attribute in the skeleton CU.
+ std::string SplitDwarfFile;
+
+ /// Output filename for the split debug info, not used in the skeleton CU.
std::string SplitDwarfOutput;
/// The name of the relocation model to use.
diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td
index ec102a06bbc..526688116a9 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -696,6 +696,8 @@ def enable_split_dwarf : Flag<["-"], "enable-split-dwarf">,
HelpText<"Use DWARF fission in 'split' mode">;
def enable_split_dwarf_EQ : Joined<["-"], "enable-split-dwarf=">,
HelpText<"Set DWARF fission mode to either 'split' or 'single'">, Values<"split,single">;
+def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
+ HelpText<"Name of the split dwarf debug info file to encode in the object file">;
def fno_wchar : Flag<["-"], "fno-wchar">,
HelpText<"Disable C++ builtin type wchar_t">;
def fconstant_string_class : Separate<["-"], "fconstant-string-class">,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 4d04a86ea6b..46b075ff126 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -472,7 +472,7 @@ static void initTargetOptions(llvm::TargetOptions &Options,
Options.EmitAddrsig = CodeGenOpts.Addrsig;
if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
- Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfOutput;
+ Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
@@ -1428,7 +1428,8 @@ static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
Conf.RemarksFilename = CGOpts.OptRecordFile;
Conf.RemarksPasses = CGOpts.OptRecordPasses;
- Conf.DwoPath = CGOpts.SplitDwarfOutput;
+ Conf.SplitDwarfFile = CGOpts.SplitDwarfFile;
+ Conf.SplitDwarfOutput = CGOpts.SplitDwarfOutput;
switch (Action) {
case Backend_EmitNothing:
Conf.PreCodeGenModuleHook = [](size_t Task, const Module &Mod) {
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index ff2caeaf8a4..af9bac9b388 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -616,7 +616,7 @@ void CGDebugInfo::CreateCompileUnit() {
CGOpts.DwarfDebugFlags, RuntimeVers,
(CGOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
? ""
- : CGOpts.SplitDwarfOutput,
+ : CGOpts.SplitDwarfFile,
EmissionKind, DwoId, CGOpts.SplitDwarfInlining,
CGOpts.DebugInfoForProfiling,
CGM.getTarget().getTriple().isNVPTX()
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 17eff885819..e75c5d1a92e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4108,11 +4108,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
TC.getTriple().isOSBinFormatELF() &&
(isa<AssembleJobAction>(JA) || isa<CompileJobAction>(JA) ||
isa<BackendJobAction>(JA));
- const char *SplitDWARFOut;
if (SplitDWARF) {
- CmdArgs.push_back("-split-dwarf-output");
- SplitDWARFOut = SplitDebugName(Args, Input, Output);
+ const char *SplitDWARFOut = SplitDebugName(Args, Input, Output);
+ CmdArgs.push_back("-split-dwarf-file");
CmdArgs.push_back(SplitDWARFOut);
+ if (DwarfFission == DwarfFissionKind::Split) {
+ CmdArgs.push_back("-split-dwarf-output");
+ CmdArgs.push_back(SplitDWARFOut);
+ }
}
// Pass the linker version in use.
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 45b0d1d6499..da7ed04bc4c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -726,6 +726,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
+ Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
Opts.SplitDwarfOutput = Args.getLastArgValue(OPT_split_dwarf_output);
Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
diff --git a/clang/test/CodeGen/split-debug-filename.c b/clang/test/CodeGen/split-debug-filename.c
index b73a6863624..ff45ad61791 100644
--- a/clang/test/CodeGen/split-debug-filename.c
+++ b/clang/test/CodeGen/split-debug-filename.c
@@ -1,7 +1,7 @@
// REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-output foo.dwo -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf -split-dwarf-output foo.dwo -S -emit-llvm -o - %s | FileCheck --check-prefix=VANILLA %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-output %t.dwo -emit-obj -o - %s | llvm-readobj -S - | FileCheck --check-prefix=O %s
+// RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck --check-prefix=VANILLA %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file %t.dwo -split-dwarf-output %t.dwo -emit-obj -o - %s | llvm-readobj -S - | FileCheck --check-prefix=O %s
// RUN: llvm-readobj -S %t.dwo | FileCheck --check-prefix=DWO %s
int main (void) {
diff --git a/clang/test/CodeGen/split-debug-output.c b/clang/test/CodeGen/split-debug-output.c
new file mode 100644
index 00000000000..e312dd9cc84
--- /dev/null
+++ b/clang/test/CodeGen/split-debug-output.c
@@ -0,0 +1,7 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file foo.dwo -split-dwarf-output %t -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s
+// RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
+
+int f() { return 0; }
+
+// CHECK: DW_AT_GNU_dwo_name ("foo.dwo")
diff --git a/clang/test/CodeGen/split-debug-single-file.c b/clang/test/CodeGen/split-debug-single-file.c
index d572e015b84..a963ef577ac 100644
--- a/clang/test/CodeGen/split-debug-single-file.c
+++ b/clang/test/CodeGen/split-debug-single-file.c
@@ -2,19 +2,19 @@
// Testing to ensure -enable-split-dwarf=single allows to place .dwo sections into regular output object.
// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
-// RUN: -enable-split-dwarf=single -split-dwarf-output %t.o -emit-obj -o %t.o %s -fno-experimental-new-pass-manager
+// RUN: -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o %s -fno-experimental-new-pass-manager
// RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SINGLE %s
// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
-// RUN: -enable-split-dwarf=single -split-dwarf-output %t.o -emit-obj -o %t.o %s -fexperimental-new-pass-manager
+// RUN: -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o %s -fexperimental-new-pass-manager
// RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SINGLE %s
// MODE-SINGLE: .dwo
// Testing to ensure -enable-split-dwarf=split does not place .dwo sections into regular output object.
// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
-// RUN: -enable-split-dwarf=split -split-dwarf-output %t.o -emit-obj -o %t.o %s -fno-experimental-new-pass-manager
+// RUN: -enable-split-dwarf=split -split-dwarf-file %t.dwo -split-dwarf-output %t.dwo -emit-obj -o %t.o %s -fno-experimental-new-pass-manager
// RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SPLIT %s
// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
-// RUN: -enable-split-dwarf=split -split-dwarf-output %t.o -emit-obj -o %t.o %s -fexperimental-new-pass-manager
+// RUN: -enable-split-dwarf=split -split-dwarf-file %t.dwo -split-dwarf-output %t.dwo -emit-obj -o %t.o %s -fexperimental-new-pass-manager
// RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SPLIT %s
// MODE-SPLIT-NOT: .dwo
diff --git a/clang/test/CodeGen/thinlto-split-dwarf.c b/clang/test/CodeGen/thinlto-split-dwarf.c
index ded58416e26..60649b0881b 100644
--- a/clang/test/CodeGen/thinlto-split-dwarf.c
+++ b/clang/test/CodeGen/thinlto-split-dwarf.c
@@ -10,12 +10,14 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
// RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \
-// RUN: -o %t.native.o -split-dwarf-output %t.native.dwo -x ir %t.o
+// RUN: -o %t.native.o -split-dwarf-file %t.file.dwo \
+// RUN: -split-dwarf-output %t.output.dwo -x ir %t.o
-// RUN: llvm-readobj -S %t.native.o | FileCheck --check-prefix=O %s
-// RUN: llvm-readobj -S %t.native.dwo | FileCheck --check-prefix=DWO %s
+// RUN: llvm-dwarfdump %t.native.o | FileCheck --check-prefix=O %s
+// RUN: llvm-dwarfdump %t.output.dwo | FileCheck --check-prefix=DWO %s
-// O-NOT: .dwo
-// DWO: .dwo
+// O: DW_AT_GNU_dwo_name ("{{.*}}.file.dwo")
+// O-NOT: DW_TAG_subprogram
+// DWO: DW_TAG_subprogram
int main() {}
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index a6d56317cec..05861ea280d 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -3,7 +3,7 @@
// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
//
-// CHECK-ACTIONS: "-split-dwarf-output" "split-debug.dwo"
+// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
@@ -14,12 +14,14 @@
// RUN: FileCheck -check-prefix=CHECK-ACTIONS-SINGLE-SPLIT < %t %s
//
// CHECK-ACTIONS-SINGLE-SPLIT: "-enable-split-dwarf=single"
-// CHECK-ACTIONS-SINGLE-SPLIT: "-split-dwarf-output" "split-debug.o"
+// CHECK-ACTIONS-SINGLE-SPLIT: "-split-dwarf-file" "split-debug.o"
+// CHECK-ACTIONS-SINGLE-SPLIT-NOT: "-split-dwarf-output"
// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf=single -c -### -o %tfoo.o %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-SINGLE-SPLIT-FILENAME < %t %s
//
-// CHECK-SINGLE-SPLIT-FILENAME: "-split-dwarf-output" "{{.*}}foo.o"
+// CHECK-SINGLE-SPLIT-FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
+// CHECK-SINGLE-SPLIT-FILENAME-NOT: "-split-dwarf-output"
// RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
@@ -41,7 +43,7 @@
// RUN: %clang -target amdgcn-amd-amdhsa -gsplit-dwarf -c -### %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-OPTION < %t %s
//
-// CHECK-OPTION: "-split-dwarf-output" "split-debug.dwo"
+// CHECK-OPTION: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -S -### %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-ASM < %t %s
@@ -58,6 +60,7 @@
//
// CHECK-GMLT-WITH-SPLIT: "-enable-split-dwarf"
// CHECK-GMLT-WITH-SPLIT: "-debug-info-kind=line-tables-only"
+// CHECK-GMLT-WITH-SPLIT: "-split-dwarf-file"
// CHECK-GMLT-WITH-SPLIT: "-split-dwarf-output"
// RUN: %clang -target x86_64-unknown-linux-gnu -g -fno-split-dwarf-inlining -S -### %s 2> %t
@@ -86,12 +89,14 @@
//
// CHECK-GMLT-OVER-SPLIT-NOT: "-enable-split-dwarf"
// CHECK-GMLT-OVER-SPLIT: "-debug-info-kind=line-tables-only"
+// CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf-file"
// CHECK-GMLT-OVER-SPLIT-NOT: "-split-dwarf-output"
// RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -S -### %s 2> %t
// RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-GMLT < %t %s
//
// CHECK-SPLIT-OVER-GMLT: "-enable-split-dwarf" "-debug-info-kind=limited"
+// CHECK-SPLIT-OVER-GMLT: "-split-dwarf-file"
// CHECK-SPLIT-OVER-GMLT: "-split-dwarf-output"
// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -g0 -fno-split-dwarf-inlining -S -### %s 2> %t
@@ -99,6 +104,7 @@
//
// CHECK-G0-OVER-SPLIT-NOT: "-enable-split-dwarf"
// CHECK-G0-OVER-SPLIT-NOT: "-debug-info-kind
+// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-file"
// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-output"
// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -g0 -S -### %s 2> %t
@@ -108,6 +114,7 @@
//
// CHECK-G0-OVER-SPLIT-NOT: "-enable-split-dwarf"
// CHECK-G0-OVER-SPLIT-NOT: "-debug-info-kind
+// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-file"
// CHECK-G0-OVER-SPLIT-NOT: "-split-dwarf-output"
// RUN: %clang -target x86_64-unknown-linux-gnu -g0 -gsplit-dwarf -S -### %s 2> %t
@@ -116,4 +123,5 @@
// RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-G0 < %t %s
//
// CHECK-SPLIT-OVER-G0: "-enable-split-dwarf" "-debug-info-kind=limited"
+// CHECK-SPLIT-OVER-G0: "-split-dwarf-file"
// CHECK-SPLIT-OVER-G0: "-split-dwarf-output"
diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h
index 6db722d2133..25c423715f1 100644
--- a/llvm/include/llvm/LTO/Config.h
+++ b/llvm/include/llvm/LTO/Config.h
@@ -88,10 +88,16 @@ struct Config {
/// The directory to store .dwo files.
std::string DwoDir;
+ /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
+ /// attribute in the skeleton CU. This should generally only be used when
+ /// running an individual backend directly via thinBackend(), as otherwise
+ /// all objects would use the same .dwo file. Not used as output path.
+ std::string SplitDwarfFile;
+
/// The path to write a .dwo file to. This should generally only be used when
/// running an individual backend directly via thinBackend(), as otherwise
- /// all .dwo files will be written to the same path.
- std::string DwoPath;
+ /// all .dwo files will be written to the same path. Not used in skeleton CU.
+ std::string SplitDwarfOutput;
/// Optimization remarks file path.
std::string RemarksFilename = "";
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 317d0163674..b0a7c434b67 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -314,7 +314,7 @@ void codegen(Config &Conf, TargetMachine *TM, AddStreamFn AddStream,
return;
std::unique_ptr<ToolOutputFile> DwoOut;
- SmallString<1024> DwoFile(Conf.DwoPath);
+ SmallString<1024> DwoFile(Conf.SplitDwarfOutput);
if (!Conf.DwoDir.empty()) {
std::error_code EC;
if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
@@ -323,11 +323,12 @@ void codegen(Config &Conf, TargetMachine *TM, AddStreamFn AddStream,
DwoFile = Conf.DwoDir;
sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
- }
+ TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
+ } else
+ TM->Options.MCOptions.SplitDwarfFile = Conf.SplitDwarfFile;
if (!DwoFile.empty()) {
std::error_code EC;
- TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
DwoOut = llvm::make_unique<ToolOutputFile>(DwoFile, EC, sys::fs::F_None);
if (EC)
report_fatal_error("Failed to open " + DwoFile + ": " + EC.message());
OpenPOWER on IntegriCloud