]> granicus.if.org Git - clang/commitdiff
Add a new option for and disable column number information as there
authorEric Christopher <echristo@gmail.com>
Thu, 18 Oct 2012 21:52:18 +0000 (21:52 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 18 Oct 2012 21:52:18 +0000 (21:52 +0000)
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

12 files changed:
include/clang/Driver/CC1Options.td
include/clang/Driver/Options.td
include/clang/Frontend/CodeGenOptions.h
lib/CodeGen/CGDebugInfo.cpp
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
test/CodeGen/debug-info-iv.c
test/CodeGen/debug-info-line3.c
test/CodeGen/debug-info-line4.c [new file with mode: 0644]
test/CodeGen/debug-line-1.c
test/CodeGenCXX/debug-info-globalinit.cpp
test/CodeGenCXX/destructor-debug-info.cpp

index d65bf209915148352f44e40be88ec4a5169841be..32b7a5e6f4bb9f34aee5154d3d80f952b90433b3 100644 (file)
@@ -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">,
index b1bb0695ee48e68af8e3e1d5407ad8551e6f0370..dc05e49a73931fb4913fa92761bc03d39ff1e48f 100644 (file)
@@ -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">;
index 3b0d59957721fd11f5572cb38507e698514a56ec..d42803152e433f1486b5d1869705b06862f98370 100644 (file)
@@ -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;
index f0c85326ec75001345aa0c5ff906e422cfca4f3a..e6e7ecf5711028d927794211a8e5d0f5aac0afbb 100644 (file)
@@ -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;
index dd2d80c9d6d1664ee7d056fdf6ffd57c4d35df82..80691ee9c404509a655f7308690542c3c413bd75 100644 (file)
@@ -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);
index 09c48ccfdba0e98cccd600c31bc8a901b29b5a60..4f0cfa800194990a62ec7b2f4c0d61959d00a1e3 100644 (file)
@@ -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);
index 6684fe346992d3d42b97deae8bea757e83914e06..aafd71d2ec2a4225564e4ecb79a6aeb0671a9230 100644 (file)
@@ -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];
index a4e35e753d7486f5bb9b6a3389ff3406b61b0c6e..d01b023b82d3f0e3071a6298d561a3545545b749 100644 (file)
@@ -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 (file)
index 0000000..004176c
--- /dev/null
@@ -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,
index 0c2d18583298dc5861025d65722e260e47366807..be1da08209313f6569a8fadaeeb139f13a8b0a6a 100644 (file)
@@ -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 *);
 
index ff50fac4cfa3661c90eba31b95a7ce9683971fcd..b3891c148e3e4495eb066558f37d31a80da283f1 100644 (file)
@@ -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
index 385c86d9be19f8619b06ff33e40d1ca093443af1..f2e2a39bd6b6b9b03b0b78f63767c46701ea9d67 100644 (file)
@@ -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