[PATCH] D18706: [DWARF] Force a linkage_name on an inlined subprogram's abstract origin

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 5 09:28:54 PDT 2016


Oh, and if you're interested in mangled names, you might be interested in
some old patches I came across yesterday related to them. I haven't double
checked the behavior, but according to my patch descriptions it sounds like
it might be describing some holes/inconsistencies in our frontend handling
of mangled names that may impact your scenarios.

On Tue, Apr 5, 2016 at 9:24 AM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Mon, Apr 4, 2016 at 3:34 PM, Paul Robinson via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> probinson added a comment.
>>
>> Built Clang with Clang 3 times: linkage names Enabled, linkage names
>> Disabled but with the patch, linkage names Disabled without the patch (aka:
>> all names, some names, no names).
>> 'all names' and 'no names' are the options we have today;
>
>
> Which option(s) are you referring to here ^ (do we have a flag or somesuch
> that allows enabling/disabling linkage names?)
>
>
>> this patch replaces 'no names' with 'some names.'
>>
>> Total ELF size of 'all names' is 11.2% larger than 'no names'; sum of all
>> .debug_* sections is 11.9% larger.
>> Total ELF size of 'some names' is 0.6% larger than 'no names'; sum of all
>> .debug_* sections is 0.6% larger.
>> The bulk of the difference obviously in .debug_str, with some in
>> .debug_info and .debug_abbrev.
>>
>> (Debug info turns out to be about 95% of the total ELF size, without LTO
>> or .debug_types or any other deduplication; hence the ELF and .debug_*
>> percentages are naturally very similar.)
>
>
>> A size cost of <1% seems pretty reasonable here.
>>
>>
>> http://reviews.llvm.org/D18706
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160405/c04450ba/attachment.html>
-------------- next part --------------
commit 238da0c9f6ffdc618235af35da807d7f0fe3f250
Author: David Blaikie <dblaikie at gmail.com>
Date:   Sat Feb 15 14:58:49 2014 -0800

    DebugInfo: Emit mangled names for externally visible member functions even when they are members of function-local types

diff --git lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.cpp
index 46d8731..b2024aa 100644
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1019,16 +1019,6 @@ llvm::DICompositeType CGDebugInfo::getOrCreateInstanceMethodType(
   return DBuilder.createSubroutineType(Unit, EltTypeArray, Flags);
 }
 
-/// isFunctionLocalClass - Return true if CXXRecordDecl is defined
-/// inside a function.
-static bool isFunctionLocalClass(const CXXRecordDecl *RD) {
-  if (const CXXRecordDecl *NRD = dyn_cast<CXXRecordDecl>(RD->getDeclContext()))
-    return isFunctionLocalClass(NRD);
-  if (isa<FunctionDecl>(RD->getDeclContext()))
-    return true;
-  return false;
-}
-
 /// CreateCXXMemberFunction - A helper function to create a DISubprogram for
 /// a single member function GlobalDecl.
 llvm::DISubprogram
@@ -1044,7 +1034,7 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method,
   // Since a single ctor/dtor corresponds to multiple functions, it doesn't
   // make sense to give a single ctor/dtor a linkage name.
   StringRef MethodLinkageName;
-  if (!IsCtorOrDtor && !isFunctionLocalClass(Method->getParent()))
+  if (!IsCtorOrDtor && Method->isExternallyVisible())
     MethodLinkageName = CGM.getMangledName(Method);
 
   // Get the location for the method.

commit 429acad25d4b7227163cd25ed269249185f122d5
Author: David Blaikie <dblaikie at gmail.com>
Date:   Sat Feb 15 14:01:00 2014 -0800

    DebugInfo: Don't include mangled names for local functions.
    
    (consistent with GCC, though open to discussion about where we should
    and should not be emitting mangled names - this is also somewhat
    consistent with our approach for member function mangled names (where we
    don't include them for function-local classes - which I assume is meant
    to be the same test, but isn't quite right - fix coming soon))

diff --git lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.cpp
index dddc7e7..46d8731 100644
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2484,7 +2484,8 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
     Name = getFunctionName(FD);
     // Use mangled name as linkage name for C/C++ functions.
     if (FD->hasPrototype()) {
-      LinkageName = CGM.getMangledName(GD);
+      if (FD->isExternallyVisible())
+        LinkageName = CGM.getMangledName(GD);
       Flags |= llvm::DIDescriptor::FlagPrototyped;
     }
     // No need to replicate the linkage name if it isn't different from the
diff --git test/CodeGenCXX/debug-info-static-fns.cpp test/CodeGenCXX/debug-info-static-fns.cpp
index 136261c..48b7fd2 100644
--- test/CodeGenCXX/debug-info-static-fns.cpp
+++ test/CodeGenCXX/debug-info-static-fns.cpp
@@ -6,5 +6,5 @@ namespace A {
   int b(int c) { return c + a(c); }
 }
 
-// Verify that a is present and mangled.
-// CHECK: metadata !"_ZN1AL1aEi", {{.*}}, i32 (i32)* @_ZN1AL1aEi, {{.*}} ; [ DW_TAG_subprogram ] [line 4] [local] [def] [a]
+// Verify that we don't emit the mangled name of 'a' since it's an file-local function.
+// CHECK: metadata !"a", metadata !"", {{.*}}, i32 (i32)* @_ZN1AL1aEi, {{.*}} ; [ DW_TAG_subprogram ] [line 4] [local] [def] [a]


More information about the llvm-commits mailing list