llvm.org GIT mirror llvm / 9c1b0af
Move Split DWARF handling to an MC option/command line argument rather than using metadata Since Split DWARF needs to name the actual .dwo file that is generated, it can't be known at the time the llvm::Module is produced as it may be merged with other Modules before the object is generated and that object may be generated with any name. By passing the Split DWARF file name when LLVM is producing object code the .dwo file name in the object file can match correctly. The support for Split DWARF for implicit modules remains the same - using metadata to store the dwo name and dwo id so that potentially multiple skeleton CUs referring to different dwo files can be generated from one llvm::Module. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301062 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 3 years ago
19 changed file(s) with 32 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
5353 int DwarfVersion = 0;
5454
5555 std::string ABIName;
56 std::string SplitDwarfFile;
5657
5758 /// Additional paths to search for `.include` directives when using the
5859 /// integrated assembler.
9090 cl::init(Default));
9191
9292 static cl::opt
93 SplitDwarf("split-dwarf", cl::Hidden,
94 cl::desc("Output DWARF5 split debug info."),
95 cl::values(clEnumVal(Default, "Default for platform"),
96 clEnumVal(Enable, "Enabled"),
97 clEnumVal(Disable, "Disabled")),
98 cl::init(Default));
99
100 static cl::opt
10193 DwarfPubSections("generate-dwarf-pub-sections", cl::Hidden,
10294 cl::desc("Generate DWARF pubnames and pubtypes sections"),
10395 cl::values(clEnumVal(Default, "Default for platform"),
252244
253245 HasAppleExtensionAttributes = tuneForLLDB();
254246
255 // Handle split DWARF. Off by default for now.
256 if (SplitDwarf == Default)
257 HasSplitDwarf = false;
258 else
259 HasSplitDwarf = SplitDwarf == Enable;
247 // Handle split DWARF.
248 HasSplitDwarf = !Asm->TM.Options.MCOptions.SplitDwarfFile.empty();
260249
261250 // Pubnames/pubtypes on by default for GDB.
262251 if (DwarfPubSections == Default)
411400 if (useSplitDwarf()) {
412401 NewCU.setSkeleton(constructSkeletonCU(NewCU));
413402 NewCU.addString(Die, dwarf::DW_AT_GNU_dwo_name,
414 DIUnit->getSplitDebugFilename());
403 Asm->TM.Options.MCOptions.SplitDwarfFile);
415404 }
416405
417406 // LTO with assembly output shares a single line table amongst multiple CUs.
18841873 void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,
18851874 std::unique_ptr NewU) {
18861875 NewU->addString(Die, dwarf::DW_AT_GNU_dwo_name,
1887 U.getCUNode()->getSplitDebugFilename());
1876 Asm->TM.Options.MCOptions.SplitDwarfFile);
18881877
18891878 if (!CompilationDir.empty())
18901879 NewU->addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
None ; RUN: llc -split-dwarf=Disable -dwarf-version=4 -generate-type-units \
0 ; RUN: llc -dwarf-version=4 -generate-type-units \
11 ; RUN: -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu < %s \
22 ; RUN: | llvm-dwarfdump - | FileCheck %s --check-prefix=SINGLE-4
33
4 ; RUN: llc -split-dwarf=Enable -dwarf-version=4 -generate-type-units \
4 ; RUN: llc -split-dwarf-file=foo.dwo -dwarf-version=4 -generate-type-units \
55 ; RUN: -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu < %s \
66 ; RUN: | llvm-dwarfdump - | FileCheck %s --check-prefix=SPLIT-4
77
8 ; RUN: llc -split-dwarf=Disable -dwarf-version=5 -generate-type-units \
8 ; RUN: llc -dwarf-version=5 -generate-type-units \
99 ; RUN: -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu < %s \
1010 ; RUN: | llvm-dwarfdump - | FileCheck %s --check-prefix=SINGLE-5
1111
12 ; RUN: llc -split-dwarf=Enable -dwarf-version=5 -generate-type-units \
12 ; RUN: llc -split-dwarf-file=foo.dwo -dwarf-version=5 -generate-type-units \
1313 ; RUN: -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu < %s \
1414 ; RUN: | llvm-dwarfdump - | FileCheck %s --check-prefix=SPLIT-5
1515
0 ; REQUIRES: object-emission
11
22 ; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump - | FileCheck %s
3 ; RUN: %llc_dwarf -split-dwarf=Enable < %s -filetype=obj | llvm-dwarfdump - | FileCheck --check-prefix=FISSION %s
3 ; RUN: %llc_dwarf -split-dwarf-file=foo.dwo < %s -filetype=obj | llvm-dwarfdump - | FileCheck --check-prefix=FISSION %s
44
55 ; darwin has a workaround for a linker bug so it always emits one line table entry
66 ; XFAIL: darwin
None ; RUN: llc -split-dwarf=Enable -mtriple=powerpc64-unknown-linux-gnu -O0 -filetype=asm < %s | FileCheck %s
0 ; RUN: llc -split-dwarf-file=foo.dwo -mtriple=powerpc64-unknown-linux-gnu -O0 -filetype=asm < %s | FileCheck %s
11
22 ; FIXME: add relocation and DWARF expression support to llvm-dwarfdump & use
33 ; that here instead of raw assembly printing
None ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
0 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
11 ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s
22 ; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=CHECK-RELOCS %s
33
None ; RUN: llc -split-dwarf=Enable -O0 %s -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
0 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
11 ; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=FUNCTION-SECTIONS %s
22 ; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS %s
33
4 ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
4 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
55 ; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=NO-FUNCTION-SECTIONS %s
66
77 ; From:
None ; RUN: llc -mtriple=x86_64-pc-linux-gnu -split-dwarf=Enable %s -o - | FileCheck %s
0 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -split-dwarf-file=foo.dwo %s -o - | FileCheck %s
11 ; Derived from:
22
33 ; int main (void) {
0 ; RUN: llc -mtriple i686-pc-cygwin < %s -filetype=obj | llvm-dwarfdump - | FileCheck %s
1 ; RUN: llc -mtriple i686-pc-cygwin -split-dwarf=Enable < %s -filetype=obj | llvm-dwarfdump - | FileCheck --check-prefix=FISSION %s
1 ; RUN: llc -mtriple i686-pc-cygwin -split-dwarf-file=foo.dwo < %s -filetype=obj | llvm-dwarfdump - | FileCheck --check-prefix=FISSION %s
22
33 ; Expect no line table entry since there are no functions and file references in this compile unit
44 ; CHECK: .debug_line contents:
None ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
0 ; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
11 ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s
22 ; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
33 ; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
None ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
0 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
11 ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s
22
33 ; The source is an empty file.
None ; RUN: llc -split-dwarf=Enable -O0 < %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj > %t
0 ; RUN: llc -split-dwarf-file=foo.dwo -O0 < %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj > %t
11 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
22 ; RUN: llvm-objdump -r %t | FileCheck --check-prefix=RELOCS %s
33
None ; RUN: llc -split-dwarf=Enable -O0 < %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s
0 ; RUN: llc -split-dwarf-file=foo.dwo -O0 < %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s
11
22 ; CHECK-NOT: DW_TAG_subprogram
33
None ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
0 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
11 ; RUN: llvm-dwarfdump %t | FileCheck %s
22 ; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
33
33 ; RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=SINGLE %s
44 ; RUN: llvm-readobj -s -t %t | FileCheck --check-prefix=OBJ_SINGLE %s
55
6 ; RUN: llc < %s -split-dwarf=Enable -o %t -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu
6 ; RUN: llc < %s -split-dwarf-file=foo.dwo -o %t -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu
77 ; RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=FISSION %s
88 ; RUN: llvm-readobj -s -t %t | FileCheck --check-prefix=OBJ_FISSION %s
99
None ; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
0 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
11 ; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s --check-prefix=CHECK-DWO
22
33 ; Based on the debuginfo-tests/sret.cpp code.
33 ; RUN: llc %s -o - -filetype=asm -O0 -mtriple=i386-linux-gnu \
44 ; RUN: | FileCheck --check-prefix=NOEMU --check-prefix=SINGLE --check-prefix=SINGLE-32 --check-prefix=GNUOP %s
55
6 ; RUN: llc %s -o - -filetype=asm -O0 -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable \
6 ; RUN: llc %s -o - -filetype=asm -O0 -mtriple=x86_64-unknown-linux-gnu -split-dwarf-file=foo.dwo \
77 ; RUN: | FileCheck --check-prefix=NOEMU --check-prefix=FISSION --check-prefix=GNUOP %s
88
99 ; RUN: llc %s -o - -filetype=asm -O0 -mtriple=x86_64-scei-ps4 \
0 ; REQUIRES: object-emission
11
2 ; RUN: llc -split-dwarf=Enable -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu < %s \
2 ; RUN: llc -split-dwarf-file=foo.dwo -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu < %s \
33 ; RUN: | llvm-dwarfdump - | FileCheck %s
44
5 ; RUN: llc -split-dwarf=Disable -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu < %s \
5 ; RUN: llc -filetype=obj -O0 -generate-type-units -mtriple=x86_64-unknown-linux-gnu < %s \
66 ; RUN: | llvm-dwarfdump - | FileCheck --check-prefix=SINGLE %s
77
88 ; Test case built from:
8989 static cl::opt
9090 TargetTriple("mtriple", cl::desc("Override target triple for module"));
9191
92 static cl::opt SplitDwarfFile(
93 "split-dwarf-file",
94 cl::desc(
95 "Specify the name of the .dwo file to encode in the DWARF output"));
96
9297 static cl::opt NoVerify("disable-verify", cl::Hidden,
9398 cl::desc("Do not verify input module"));
9499
449454 Options.MCOptions.AsmVerbose = AsmVerbose;
450455 Options.MCOptions.PreserveAsmComments = PreserveComments;
451456 Options.MCOptions.IASSearchPaths = IncludeDirs;
457 Options.MCOptions.SplitDwarfFile = SplitDwarfFile;
452458
453459 std::unique_ptr Target(
454460 TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr, FeaturesStr,