LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 11345 - debug info generated for functions that are not emitted
Summary: debug info generated for functions that are not emitted
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: LLVM Codegen (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-08 19:44 PST by Nick Lewycky
Modified: 2012-01-23 19:13 PST (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Lewycky 2011-11-08 19:44:51 PST
Consider this testcase:

  class locale {
  private:
    void _M_add_reference() const throw() {
    }
  };
  class ios_base {
    locale _M_ios_locale;
  public:
    class Init {
    };
  };
  static ios_base::Init __ioinit;

When built without debug info, GCC and clang agree, the resulting assembly is:
        .local  _ZL8__ioinit
        .comm   _ZL8__ioinit,1,1

but where things get exciting is the debug info. Besides the filename/directory/compiler identifier, the strings that GCC emits are

.LASF4:
        .string "Init"
.LASF5:
        .string "__ioinit"

which makes sense, there's one object named __ioinit of type Init (technically "ios_base::Init", so emitting that would be fine too). Clang emits:

.Lstring3:
        .ascii   "__ioinit"
        .zero   1
.Lstring4:
        .ascii   "_ZL8__ioinit"
        .zero   1
.Lstring5:
        .ascii   "Init"
        .zero   1
.Lstring6:
        .ascii   "_M_ios_locale"
        .zero   1
.Lstring7:
        .ascii   "_ZNK6locale16_M_add_referenceEv"
        .zero   1
.Lstring8:
        .ascii   "_M_add_reference"
        .zero   1
.Lstring9:
        .ascii   "locale"
        .zero   1
.Lstring10:
        .ascii   "ios_base"
        .zero   1

Yow! We never emitted code for any of those functions at the very least. My estimate is that this is causing about 60% of the extra strings. (Only an estimate because there are other sources of differences, such as clang emitting all case names for a given enum, while gcc only emits the used ones. I consider clang's behaviour better.)
Comment 1 Eric Christopher 2011-11-08 21:30:48 PST
Well, that's heinous. We should come up with some way to deal with that.
Comment 2 Devang Patel 2011-11-30 14:05:03 PST
These strings, except _ZNK6locale16_M_add_referenceEv, are used for method declaration descriptions. One way to filter them would be following untested patch, if Nick's measurement indicates overall win.

Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp	(revision 145502)
+++ lib/CodeGen/CGDebugInfo.cpp	(working copy)
@@ -867,7 +867,7 @@
         E = RD->method_end(); I != E; ++I) {
     const CXXMethodDecl *Method = *I;
     
-    if (Method->isImplicit() && !Method->isUsed())
+    if (Method->isImplicit()) // && !Method->isUsed())
       continue;
 
     EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy));
Comment 3 Eric Christopher 2012-01-23 19:13:31 PST
Fixed this last week.