aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2012-10-18 21:52:18 +0000
committerEric Christopher <echristo@gmail.com>2012-10-18 21:52:18 +0000
commitda3301eec823fe770bfa49a1cb19649506caa698 (patch)
tree73a65232b124c08da8196175ac4b1891a70ded8b
parent5b341da0eb6478c22b9587f03572a249ebbd00dc (diff)
Add a new option for and disable column number information as there
are no known current users of column info. Robustify and fix up a few tests in the process. Reduces the size of debug information by a small amount. Part of PR14106 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166236 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/CC1Options.td2
-rw-r--r--include/clang/Driver/Options.td1
-rw-r--r--include/clang/Frontend/CodeGenOptions.h3
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp2
-rw-r--r--lib/Driver/Tools.cpp2
-rw-r--r--lib/Frontend/CompilerInvocation.cpp3
-rw-r--r--test/CodeGen/debug-info-iv.c2
-rw-r--r--test/CodeGen/debug-info-line3.c4
-rw-r--r--test/CodeGen/debug-info-line4.c11
-rw-r--r--test/CodeGen/debug-line-1.c2
-rw-r--r--test/CodeGenCXX/debug-info-globalinit.cpp2
-rw-r--r--test/CodeGenCXX/destructor-debug-info.cpp2
12 files changed, 30 insertions, 6 deletions
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index d65bf20991..32b7a5e6f4 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -143,6 +143,8 @@ def fdebug_compilation_dir : Separate<"-fdebug-compilation-dir">,
HelpText<"The compilation directory to embed in the debug info.">;
def dwarf_debug_flags : Separate<"-dwarf-debug-flags">,
HelpText<"The string to embed in the Dwarf debug flags record.">;
+def dwarf_column_info : Flag<"-dwarf-column-info">,
+ HelpText<"Turn on column location information.">;
def fforbid_guard_variables : Flag<"-fforbid-guard-variables">,
HelpText<"Emit an error if a C++ static local initializer would need a guard variable">;
def no_implicit_float : Flag<"-no-implicit-float">,
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index b1bb0695ee..dc05e49a73 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -716,6 +716,7 @@ def gno_record_gcc_switches : Flag<"-gno-record-gcc-switches">,
Group<g_flags_Group>;
def gstrict_dwarf : Flag<"-gstrict-dwarf">, Group<g_flags_Group>;
def gno_strict_dwarf : Flag<"-gno-strict-dwarf">, Group<g_flags_Group>;
+def gcolumn_info : Flag<"-gcolumn-info">, Group<g_flags_Group>;
def headerpad__max__install__names : Joined<"-headerpad_max_install_names">;
def help : Flag<"-help">, Flags<[CC1Option]>,
HelpText<"Display available options">;
diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h
index 3b0d599577..d42803152e 100644
--- a/include/clang/Frontend/CodeGenOptions.h
+++ b/include/clang/Frontend/CodeGenOptions.h
@@ -145,6 +145,9 @@ public:
/// The kind of generated debug info.
DebugInfoKind DebugInfo;
+ /// Whether or not to use column information in debug info.
+ bool DebugColumnInfo;
+
/// The string to embed in the debug information for the compile unit, if
/// non-empty.
std::string DwarfDebugFlags;
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index f0c85326ec..e6e7ecf571 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -259,6 +259,8 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc) {
if (Loc.isInvalid() && CurLoc.isInvalid())
return 0;
+ if (!CGM.getCodeGenOpts().DebugColumnInfo)
+ return 0;
SourceManager &SM = CGM.getContext().getSourceManager();
PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
return PLoc.isValid()? PLoc.getColumn() : 0;
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index dd2d80c9d6..80691ee9c4 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2050,6 +2050,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
Args.ClaimAllArgs(options::OPT_g_flags_Group);
+ if (Args.hasArg(options::OPT_gcolumn_info))
+ CmdArgs.push_back("-dwarf-column-info");
Args.AddAllArgs(CmdArgs, options::OPT_ffunction_sections);
Args.AddAllArgs(CmdArgs, options::OPT_fdata_sections);
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 09c48ccfdb..4f0cfa8001 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -197,6 +197,8 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts, ToArgsList &Res) {
Res.push_back("-fno-limit-debug-info");
break;
}
+ if (Opts.DebugColumnInfo)
+ Res.push_back("-gcolumn-info");
if (Opts.DisableLLVMOpts)
Res.push_back("-disable-llvm-optzns");
if (Opts.DisableRedZone)
@@ -1228,6 +1230,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
else
Opts.DebugInfo = CodeGenOptions::FullDebugInfo;
}
+ Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);
Opts.DisableLLVMOpts = Args.hasArg(OPT_disable_llvm_optzns);
Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
diff --git a/test/CodeGen/debug-info-iv.c b/test/CodeGen/debug-info-iv.c
index 6684fe3469..aafd71d2ec 100644
--- a/test/CodeGen/debug-info-iv.c
+++ b/test/CodeGen/debug-info-iv.c
@@ -27,7 +27,7 @@ int main() {
Array[i][j] = 0;
test_indvars(Array[0], Array);
-//CHECK: .loc 2 31 8
+//CHECK: .loc 2 31
for (i=0; i < 100; i+=2)
for (j=0; j < 200; j++)
sum += Array[i][j];
diff --git a/test/CodeGen/debug-info-line3.c b/test/CodeGen/debug-info-line3.c
index a4e35e753d..d01b023b82 100644
--- a/test/CodeGen/debug-info-line3.c
+++ b/test/CodeGen/debug-info-line3.c
@@ -12,5 +12,5 @@ void func(char c, char* d)
}
-// CHECK: ret void, !dbg !17
-// CHECK: !17 = metadata !{i32 6,
+// CHECK: ret void, !dbg [[LINE:.*]]
+// CHECK: [[LINE]] = metadata !{i32 6,
diff --git a/test/CodeGen/debug-info-line4.c b/test/CodeGen/debug-info-line4.c
new file mode 100644
index 0000000000..004176c7a5
--- /dev/null
+++ b/test/CodeGen/debug-info-line4.c
@@ -0,0 +1,11 @@
+// RUN: %clang %s -g -gcolumn-info -S -emit-llvm -o - | FileCheck %s
+// Checks that clang emits column information when -gcolumn-info is passed.
+
+int foo(int a, int b) { int c = a + b;
+
+
+ return c;
+}
+
+// Without column information we wouldn't change locations for b.
+// CHECK: metadata !{i32 4, i32 20,
diff --git a/test/CodeGen/debug-line-1.c b/test/CodeGen/debug-line-1.c
index 0c2d185832..be1da08209 100644
--- a/test/CodeGen/debug-line-1.c
+++ b/test/CodeGen/debug-line-1.c
@@ -4,7 +4,7 @@
// Check to make sure that we emit the block for the break so that we can count the line.
// CHECK: sw.bb: ; preds = %entry
-// CHECK: br label %sw.epilog, !dbg !19
+// CHECK: br label %sw.epilog, !dbg !
extern int atoi(const char *);
diff --git a/test/CodeGenCXX/debug-info-globalinit.cpp b/test/CodeGenCXX/debug-info-globalinit.cpp
index ff50fac4cf..b3891c148e 100644
--- a/test/CodeGenCXX/debug-info-globalinit.cpp
+++ b/test/CodeGenCXX/debug-info-globalinit.cpp
@@ -27,4 +27,4 @@ int main(void) {}
// CHECK-NOT: dbg
// CHECK: store i32 %[[C1]], i32* @_ZL1j, align 4
//
-// CHECK: ![[LINE]] = metadata !{i32 13, i32 16
+// CHECK: ![[LINE]] = metadata !{i32 13, i32
diff --git a/test/CodeGenCXX/destructor-debug-info.cpp b/test/CodeGenCXX/destructor-debug-info.cpp
index 385c86d9be..f2e2a39bd6 100644
--- a/test/CodeGenCXX/destructor-debug-info.cpp
+++ b/test/CodeGenCXX/destructor-debug-info.cpp
@@ -19,4 +19,4 @@ void foo() {
}
}
// Check there is a line number entry for line 19 where b1 is destructed.
-// CHECK: i32 19, i32 3, metadata
+// CHECK: i32 19, i32 0, metadata