Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
- Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
+ Options.MCOptions.MCUseDwarfDirectory =
+ CodeGenOpts.NoDwarfDirectoryAsm
+ ? llvm::MCTargetOptions::DisableDwarfDirectory
+ : llvm::MCTargetOptions::EnableDwarfDirectory;
Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
Options.MCOptions.MCIncrementalLinkerCompatible =
CodeGenOpts.IncrementalLinkerCompatible;
/// the .loc/.file directives. Defaults to true.
bool UsesDwarfFileAndLocDirectives = true;
+ /// True if DWARF `.file directory' directive syntax is used by
+ /// default.
+ bool EnableDwarfFileDirectoryDefault = true;
+
/// True if the target needs the DWARF section length in the header (if any)
/// of the DWARF section in the assembly file. Defaults to true.
bool DwarfSectionSizeRequired = true;
return DwarfSectionSizeRequired;
}
+ bool enableDwarfFileDirectoryDefault() const {
+ return EnableDwarfFileDirectoryDefault;
+ }
+
void addInitialFrameState(const MCCFIInstruction &Inst);
const std::vector<MCCFIInstruction> &getInitialFrameState() const {
bool MCNoDeprecatedWarn : 1;
bool MCNoTypeCheck : 1;
bool MCSaveTempLabels : 1;
- bool MCUseDwarfDirectory : 1;
bool MCIncrementalLinkerCompatible : 1;
bool ShowMCEncoding : 1;
bool ShowMCInst : 1;
bool Dwarf64 : 1;
int DwarfVersion = 0;
+ enum DwarfDirectory {
+ // Force disable
+ DisableDwarfDirectory,
+ // Force enable, for assemblers that support
+ // `.file fileno directory filename' syntax
+ EnableDwarfDirectory,
+ // Default is based on the target
+ DefaultDwarfDirectory
+ };
+ DwarfDirectory MCUseDwarfDirectory;
+
std::string ABIName;
std::string AssemblyLanguage;
std::string SplitDwarfFile;
if (Options.MCOptions.ShowMCEncoding)
MCE.reset(getTarget().createMCCodeEmitter(MII, Context));
+ bool UseDwarfDirectory = false;
+ switch (Options.MCOptions.MCUseDwarfDirectory) {
+ case MCTargetOptions::DisableDwarfDirectory:
+ UseDwarfDirectory = false;
+ break;
+ case MCTargetOptions::EnableDwarfDirectory:
+ UseDwarfDirectory = true;
+ break;
+ case MCTargetOptions::DefaultDwarfDirectory:
+ UseDwarfDirectory = MAI.enableDwarfFileDirectoryDefault();
+ break;
+ }
+
std::unique_ptr<MCAsmBackend> MAB(
getTarget().createMCAsmBackend(STI, MRI, Options.MCOptions));
auto FOut = std::make_unique<formatted_raw_ostream>(Out);
MCStreamer *S = getTarget().createAsmStreamer(
Context, std::move(FOut), Options.MCOptions.AsmVerbose,
- Options.MCOptions.MCUseDwarfDirectory, InstPrinter, std::move(MCE),
- std::move(MAB), Options.MCOptions.ShowMCInst);
+ UseDwarfDirectory, InstPrinter, std::move(MCE), std::move(MAB),
+ Options.MCOptions.ShowMCInst);
AsmStreamer.reset(S);
break;
}
MCTargetOptions::MCTargetOptions()
: MCRelaxAll(false), MCNoExecStack(false), MCFatalWarnings(false),
- MCNoWarn(false), MCNoDeprecatedWarn(false),
- MCNoTypeCheck(false), MCSaveTempLabels(false),
- MCUseDwarfDirectory(false), MCIncrementalLinkerCompatible(false),
- ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false),
- PreserveAsmComments(true), Dwarf64(false) {}
+ MCNoWarn(false), MCNoDeprecatedWarn(false), MCNoTypeCheck(false),
+ MCSaveTempLabels(false), MCUseDwarfDirectory(DefaultDwarfDirectory),
+ MCIncrementalLinkerCompatible(false), ShowMCEncoding(false),
+ ShowMCInst(false), AsmVerbose(false), PreserveAsmComments(true),
+ Dwarf64(false) {}
StringRef MCTargetOptions::getABIName() const {
return ABIName;
// Avoid using parens for identifiers starting with $ - ptxas does
// not expect them.
UseParensForDollarSignNames = false;
+
+ // ptxas does not support DWARF `.file fileno directory filename'
+ // syntax as of v11.X.
+ EnableDwarfFileDirectoryDefault = false;
}
-; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda -dwarf-directory=0 | FileCheck %s
+; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda | FileCheck %s
; CHECK: .target sm_20, debug
ret void, !dbg !11
}
-; CHECK-DAG: .file [[FOO]] "{{.*}}foo.h"
-; CHECK-DAG: .file [[BAR]] "{{.*}}bar.cu"
+; CHECK-DAG: .file [[FOO]] "/source/dir/foo.h"
+; CHECK-DAG: .file [[BAR]] "/source/dir/bar.cu"
; CHECK-NOT: .section .debug{{.*}}
ret void, !dbg !11
}
-; CHECK-DAG: .file [[FOO]] "{{.*}}foo.h"
-; CHECK-DAG: .file [[BAR]] "{{.*}}bar.cu"
+; CHECK-DAG: .file [[FOO]] "/source/dir/foo.h"
+; CHECK-DAG: .file [[BAR]] "/source/dir/bar.cu"
; CHECK: .section .debug_abbrev
; CHECK-NEXT: {
; CHECK-NEXT: .b8 1 // Abbreviation Code
-; RUN: llc -mtriple=nvptx64-nvidia-cuda -dwarf-directory=0 < %s | FileCheck %s
+; RUN: llc -mtriple=nvptx64-nvidia-cuda < %s | FileCheck %s
; CHECK: .target sm_{{[0-9]+}}, debug
--- /dev/null
+; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda | FileCheck --check-prefix=CHECK-NODIR %s
+; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda -dwarf-directory=1 | FileCheck --check-prefix=CHECK-DIR %s
+
+; CHECK-NODIR: .file {{[0-9]+}} "/tmp/dbginfo/a/a.cpp"
+;
+; ptxas does not support .file directory syntax, but it can still be
+; forced by -dwarf-directory=1
+; CHECK-DIR: .file {{[0-9]+}} "/tmp/dbginfo/a" "a.cpp"
+
+define void @_Z4funcv() !dbg !4 {
+entry:
+ ret void, !dbg !5
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8, !9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
+!1 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo/a")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "func", linkageName: "_Z4funcv", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !1, type: !6, retainedNodes: !2)
+!5 = !DILocation(line: 2, scope: !4)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}
+!8 = !{i32 2, !"Dwarf Version", i32 4}
+!9 = !{i32 1, !"Debug Info Version", i32 3}
+
TargetMachine::parseBinutilsVersion(BinutilsVersion);
Options.DisableIntegratedAS = NoIntegratedAssembler;
Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
- Options.MCOptions.MCUseDwarfDirectory = DwarfDirectory;
Options.MCOptions.AsmVerbose = AsmVerbose;
Options.MCOptions.PreserveAsmComments = PreserveComments;
Options.MCOptions.IASSearchPaths = IncludeDirs;
Options.MCOptions.SplitDwarfFile = SplitDwarfFile;
+ if (DwarfDirectory.getPosition()) {
+ Options.MCOptions.MCUseDwarfDirectory =
+ DwarfDirectory ? MCTargetOptions::EnableDwarfDirectory
+ : MCTargetOptions::DisableDwarfDirectory;
+ } else {
+ // -dwarf-directory is not set explicitly. Some assemblers
+ // (e.g. GNU as or ptxas) do not support `.file directory'
+ // syntax prior to DWARFv5. Let the target decide the default
+ // value.
+ Options.MCOptions.MCUseDwarfDirectory =
+ MCTargetOptions::DefaultDwarfDirectory;
+ }
};
Optional<Reloc::Model> RM = codegen::getExplicitRelocModel();