[llvm] r348416 - ThinLTO: Do not import debug info for imported global constants

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 13:42:17 PST 2018


Author: dblaikie
Date: Wed Dec  5 13:42:17 2018
New Revision: 348416

URL: http://llvm.org/viewvc/llvm-project?rev=348416&view=rev
Log:
ThinLTO: Do not import debug info for imported global constants

It looks like this isn't necessary (in any tests I've done, it results
in the global being described with no location or value in the imported
side - while it's still fully described in the place it's imported from)
& results in significant/pathological debug info growth to home these
location-less global variable descriptions on the import side.

This is a rather pressing/important issue to address - this regressed
executable size for one example I'm looking at by 15%, object size is probably
similar though I haven't measured it, and a 22x increase in the number of CUs
in the cu_index in split DWARF DWP files, creating a similarly large regression
in the time it takes llvm-symbolizer to run on such binaries.

Reviewers: tejohnson, evgeny777

Differential Revision: https://reviews.llvm.org/D55309

Modified:
    llvm/trunk/lib/Linker/IRMover.cpp
    llvm/trunk/test/ThinLTO/X86/index-const-prop.ll
    llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll

Modified: llvm/trunk/lib/Linker/IRMover.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=348416&r1=348415&r2=348416&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp (original)
+++ llvm/trunk/lib/Linker/IRMover.cpp Wed Dec  5 13:42:17 2018
@@ -1062,6 +1062,16 @@ void IRLinker::prepareCompileUnitsForImp
     ValueMap.MD()[CU->getRawEnumTypes()].reset(nullptr);
     ValueMap.MD()[CU->getRawMacros()].reset(nullptr);
     ValueMap.MD()[CU->getRawRetainedTypes()].reset(nullptr);
+    // The original definition (or at least its debug info - if the variable is
+    // internalized an optimized away) will remain in the source module, so
+    // there's no need to import them.
+    // If LLVM ever does more advanced optimizations on global variables
+    // (removing/localizing write operations, for instance) that can track
+    // through debug info, this decision may need to be revisited - but do so
+    // with care when it comes to debug info size. Emitting small CUs containing
+    // only a few imported entities into every destination module may be very
+    // size inefficient.
+    ValueMap.MD()[CU->getRawGlobalVariables()].reset(nullptr);
 
     // Imported entities only need to be mapped in if they have local
     // scope, as those might correspond to an imported entity inside a

Modified: llvm/trunk/test/ThinLTO/X86/index-const-prop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/index-const-prop.ll?rev=348416&r1=348415&r2=348416&view=diff
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/index-const-prop.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/index-const-prop.ll Wed Dec  5 13:42:17 2018
@@ -21,7 +21,7 @@
 
 ; IMPORT: @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 4, !dbg !0
 ; IMPORT-NEXT: @gBar = internal local_unnamed_addr global i32 2, align 4, !dbg !5
-; IMPORT: !DICompileUnit({{.*}}, globals: !{{[0-9]+}})
+; IMPORT: !DICompileUnit({{.*}})
 
 ; OPTIMIZE:        define i32 @main
 ; OPTIMIZE-NEXT:     ret i32 3

Modified: llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll?rev=348416&r1=348415&r2=348416&view=diff
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/index-const-prop2.ll Wed Dec  5 13:42:17 2018
@@ -34,7 +34,7 @@
 
 ; IMPORT:       @gFoo.llvm.0 = internal unnamed_addr global i32 1, align 4
 ; IMPORT-NEXT:  @gBar = internal local_unnamed_addr global i32 2, align 4
-; IMPORT:       !DICompileUnit({{.*}}, globals: !{{[0-9]+}})
+; IMPORT:       !DICompileUnit({{.*}})
 
 ; CODEGEN:        i32 @main()
 ; CODEGEN-NEXT:     ret i32 3




More information about the llvm-commits mailing list