[llvm-branch-commits] [clang] 082b2fc - strict-dwarf in backend
Chen Zheng via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 26 18:13:08 PDT 2021
Author: Chen Zheng
Date: 2021-04-22T21:28:07-04:00
New Revision: 082b2fc0e5a78bd45840c1faa392354ff856de11
URL: https://github.com/llvm/llvm-project/commit/082b2fc0e5a78bd45840c1faa392354ff856de11
DIFF: https://github.com/llvm/llvm-project/commit/082b2fc0e5a78bd45840c1faa392354ff856de11.diff
LOG: strict-dwarf in backend
Added:
llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
Modified:
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/CommandFlags.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 7edca6fb30730..a499877bb2a98 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -598,6 +598,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
+ Options.DebugStrictDwarf = CodeGenOpts.DebugStrictDwarf;
return true;
}
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h
index e18ee36445363..072df9dce1ee2 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -140,6 +140,8 @@ bool getForceDwarfFrameSection();
bool getXRayOmitFunctionIndex();
+bool getDebugStrictDwarf();
+
/// Create this object with static storage to register codegen-related command
/// line options.
struct RegisterCodeGenFlags {
diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
index 651dbe163a811..fd82afed14b38 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -141,6 +141,7 @@ namespace llvm {
SupportsDebugEntryValues(false), EnableDebugEntryValues(false),
PseudoProbeForProfiling(false), ValueTrackingVariableLocations(false),
ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false),
+ DebugStrictDwarf(false),
FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}
/// DisableFramePointerElim - This returns true if frame pointer elimination
@@ -331,6 +332,10 @@ namespace llvm {
/// Emit XRay Function Index section
unsigned XRayOmitFunctionIndex : 1;
+ /// When set to true, don't use DWARF extensions in later DWARF versions.
+ /// By default, it is set to false.
+ unsigned DebugStrictDwarf : 1;
+
/// Stack protector guard offset to use.
unsigned StackProtectorGuardOffset = -1U;
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp
index de560559b6fe0..a0c748fdf2de7 100644
--- a/llvm/lib/CodeGen/CommandFlags.cpp
+++ b/llvm/lib/CodeGen/CommandFlags.cpp
@@ -97,6 +97,7 @@ CGOPT(bool, PseudoProbeForProfiling)
CGOPT(bool, ValueTrackingVariableLocations)
CGOPT(bool, ForceDwarfFrameSection)
CGOPT(bool, XRayOmitFunctionIndex)
+CGOPT(bool, DebugStrictDwarf)
codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
#define CGBINDOPT(NAME) \
@@ -471,6 +472,10 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
cl::init(false));
CGBINDOPT(XRayOmitFunctionIndex);
+ static cl::opt<bool> DebugStrictDwarf(
+ "strict-dwarf", cl::desc("use strict dwarf"), cl::init(false));
+ CGBINDOPT(DebugStrictDwarf);
+
#undef CGBINDOPT
mc::RegisterMCTargetOptionsFlags();
@@ -567,6 +572,7 @@ codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) {
Options.ValueTrackingVariableLocations = getValueTrackingVariableLocations();
Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex();
+ Options.DebugStrictDwarf = getDebugStrictDwarf();
Options.MCOptions = mc::InitMCTargetOptionsFromFlags();
diff --git a/llvm/test/DebugInfo/PowerPC/strict-dwarf.ll b/llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
new file mode 100644
index 0000000000000..b64fd426e8eab
--- /dev/null
+++ b/llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
@@ -0,0 +1,60 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN: llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN: FileCheck %s
+
+; FIXME: when -strict-dwarf=true is specified, we should check "STRICT" to tell
+; that with DWARF 4, we should not generate DWARF 5 attribute DW_AT_noreturn and
+; DW_AT_alignment.
+
+; CHECK: DW_AT_alignment
+; CHECK: DW_AT_noreturn
+; STRICT-NOT: DW_AT_noreturn
+; STRICT-NOT: DW_AT_alignment
+
+ at _ZL3var = internal global i32 0, align 16, !dbg !0
+
+; Function Attrs: noinline noreturn optnone uwtable mustprogress
+define dso_local void @_Z1fv() #0 !dbg !12 {
+entry:
+ call void @_Z4exitv(), !dbg !15
+ ret void, !dbg !16
+}
+
+declare void @_Z4exitv()
+
+; Function Attrs: noinline nounwind optnone uwtable mustprogress
+define dso_local signext i32 @_Z3foov() !dbg !17 {
+entry:
+ %0 = load i32, i32* @_ZL3var, align 16, !dbg !21
+ ret i32 %0, !dbg !22
+}
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!7, !8, !9, !10}
+!llvm.ident = !{!11}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "var", linkageName: "_ZL3var", scope: !2, file: !3, line: 2, type: !6, isLocal: true, isDefinition: true, align: 128)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "t.cpp", directory: "./")
+!4 = !{}
+!5 = !{!0}
+!6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}
+!10 = !{i32 7, !"uwtable", i32 1}
+!11 = !{!"clang version 13.0.0"}
+!12 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !3, file: !3, line: 4, type: !13, scopeLine: 4, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!13 = !DISubroutineType(types: !14)
+!14 = !{null}
+!15 = !DILocation(line: 5, column: 1, scope: !12)
+!16 = !DILocation(line: 7, column: 1, scope: !12)
+!17 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !3, file: !3, line: 10, type: !18, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!18 = !DISubroutineType(types: !19)
+!19 = !{!20}
+!20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!21 = !DILocation(line: 12, column: 18, scope: !17)
+!22 = !DILocation(line: 12, column: 11, scope: !17)
More information about the llvm-branch-commits
mailing list