[cfe-commits] r166236 - in /cfe/trunk: 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 test/CodeGen/debug-line-1.c test/CodeGenCXX/debug-info-globalinit.cpp test/CodeGenCXX/destructor-debug-info.cpp

Eric Christopher echristo at gmail.com
Thu Oct 18 14:52:19 PDT 2012


Author: echristo
Date: Thu Oct 18 16:52:18 2012
New Revision: 166236

URL: http://llvm.org/viewvc/llvm-project?rev=166236&view=rev
Log:
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

Added:
    cfe/trunk/test/CodeGen/debug-info-line4.c
Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/include/clang/Frontend/CodeGenOptions.h
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/test/CodeGen/debug-info-iv.c
    cfe/trunk/test/CodeGen/debug-info-line3.c
    cfe/trunk/test/CodeGen/debug-line-1.c
    cfe/trunk/test/CodeGenCXX/debug-info-globalinit.cpp
    cfe/trunk/test/CodeGenCXX/destructor-debug-info.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Oct 18 16:52:18 2012
@@ -143,6 +143,8 @@
   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">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 18 16:52:18 2012
@@ -716,6 +716,7 @@
   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">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Thu Oct 18 16:52:18 2012
@@ -145,6 +145,9 @@
   /// 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;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 18 16:52:18 2012
@@ -259,6 +259,8 @@
 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;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct 18 16:52:18 2012
@@ -2050,6 +2050,8 @@
 
   // 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);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Oct 18 16:52:18 2012
@@ -197,6 +197,8 @@
       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 @@
     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);

Modified: cfe/trunk/test/CodeGen/debug-info-iv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-iv.c?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-iv.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-iv.c Thu Oct 18 16:52:18 2012
@@ -27,7 +27,7 @@
       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];

Modified: cfe/trunk/test/CodeGen/debug-info-line3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-line3.c?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-line3.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-line3.c Thu Oct 18 16:52:18 2012
@@ -12,5 +12,5 @@
   
 }
 
-// CHECK: ret void, !dbg !17
-// CHECK: !17 = metadata !{i32 6,
+// CHECK: ret void, !dbg [[LINE:.*]]
+// CHECK: [[LINE]] = metadata !{i32 6,

Added: cfe/trunk/test/CodeGen/debug-info-line4.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-line4.c?rev=166236&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-line4.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-line4.c Thu Oct 18 16:52:18 2012
@@ -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,

Modified: cfe/trunk/test/CodeGen/debug-line-1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-line-1.c?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/debug-line-1.c (original)
+++ cfe/trunk/test/CodeGen/debug-line-1.c Thu Oct 18 16:52:18 2012
@@ -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 *);
 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-globalinit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-globalinit.cpp?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-globalinit.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-globalinit.cpp Thu Oct 18 16:52:18 2012
@@ -27,4 +27,4 @@
 // CHECK-NOT: dbg
 // CHECK: store i32 %[[C1]], i32* @_ZL1j, align 4
 // 
-// CHECK: ![[LINE]] = metadata !{i32 13, i32 16
+// CHECK: ![[LINE]] = metadata !{i32 13, i32

Modified: cfe/trunk/test/CodeGenCXX/destructor-debug-info.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/destructor-debug-info.cpp?rev=166236&r1=166235&r2=166236&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/destructor-debug-info.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/destructor-debug-info.cpp Thu Oct 18 16:52:18 2012
@@ -19,4 +19,4 @@
   }
 }
 // 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





More information about the cfe-commits mailing list