llvm.org GIT mirror llvm / 1b3af3b
[ThinLTO] Delay metadata materializtion in function importer The function importer was still materializing metadata when modules were loaded for function importing. We only want to materialize it when we are going to invoke the metadata linking postpass. Materializing it before function importing is not only unnecessary, but also causes metadata referenced by imported functions to be mapped in early, and then not connected to the rest of the module level metadata when it is ultimately linked in. Augmented the test case to specifically check for the metadata being properly connected, which it wasn't before this fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257171 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 4 years ago
2 changed file(s) with 21 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4040 LLVMContext &Context) {
4141 SMDiagnostic Err;
4242 DEBUG(dbgs() << "Loading '" << FileName << "'\n");
43 std::unique_ptr Result = getLazyIRFileModule(FileName, Err, Context);
43 // Metadata isn't loaded or linked until after all functions are
44 // imported, after which it will be materialized and linked.
45 std::unique_ptr Result =
46 getLazyIRFileModule(FileName, Err, Context,
47 /* ShouldLazyLoadMetadata = */ true);
4448 if (!Result) {
4549 Err.print("function-import", errs());
4650 return nullptr;
4751 }
48
49 Result->materializeMetadata();
50 UpgradeDebugInfo(*Result);
5152
5253 return Result;
5354 }
323324 ModuleToTempMDValsMap) {
324325 // Load the specified source module.
325326 auto &SrcModule = ModuleLoaderCache(SME.getKey());
327 // The modules were created with lazy metadata loading. Materialize it
328 // now, before linking it.
329 SrcModule.materializeMetadata();
330 UpgradeDebugInfo(SrcModule);
326331
327332 // Link in all necessary metadata from this module.
328333 if (TheLinker.linkInMetadata(SrcModule, SME.getValue().get()))
66 ; RUN: opt -function-import -summary-file %t3.thinlto.bc %s -S | FileCheck %s
77
88 ; CHECK: define available_externally void @func()
9 ; CHECK: distinct !DISubprogram(name: "main"
10 ; CHECK: distinct !DISubprogram(name: "func"
9
10 ; Check that we have exactly two subprograms (that func's subprogram wasn't
11 ; linked more than once for example), and that they are connected to
12 ; the subprogram list on a compute unit.
13 ; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs1:[0-9]+]]
14 ; CHECK: ![[SPs1]] = !{![[MAINSP:[0-9]+]]}
15 ; CHECK: ![[MAINSP]] = distinct !DISubprogram(name: "main"
16 ; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs2:[0-9]+]]
17 ; CHECK-NOT: ![[SPs2]] = !{{{.*}}null{{.*}}}
18 ; CHECK: ![[SPs2]] = !{![[FUNCSP:[0-9]+]]}
19 ; CHECK: ![[FUNCSP]] = distinct !DISubprogram(name: "func"
20 ; CHECK-NOT: distinct !DISubprogram
1121
1222 ; ModuleID = 'funcimport_debug.o'
1323 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"