@@ -302,11 +302,11 @@ LazySwiftMaterializationUnit::Create(SwiftJIT &JIT, CompilerInstance &CI) {
302
302
continue ;
303
303
}
304
304
auto Ref = Source.getSILDeclRef ();
305
- if (Ref.getDefinitionLinkage () != SILLinkage::Public)
306
- continue ;
307
305
const auto &SymbolName = Entry.getKey ();
308
- const auto Flags =
309
- llvm::JITSymbolFlags::Exported | llvm::JITSymbolFlags::Callable;
306
+ auto Flags = llvm::JITSymbolFlags::Callable;
307
+ if (Ref.getDefinitionLinkage () == SILLinkage::Public) {
308
+ Flags |= llvm::JITSymbolFlags::Exported;
309
+ }
310
310
auto MangledName = mangle (SymbolName);
311
311
PublicInterface[JIT.intern (MangledName)] = Flags;
312
312
}
@@ -368,22 +368,30 @@ void LazySwiftMaterializationUnit::materialize(
368
368
369
369
// Register all global values, including global
370
370
// variables and functions
371
- for (const auto &GV : Module->global_values ()) {
372
- // Ignore all symbols that will not appear in symbol table
373
- if (GV.hasLocalLinkage () || GV.hasAppendingLinkage () ||
374
- GV.isDeclaration ()) {
375
- continue ;
376
- }
371
+ for (auto &GV : Module->global_values ()) {
377
372
auto Name = JIT.mangle (GV.getName ());
378
373
auto itr = Renamings.find (Name);
374
+ if (GV.hasAppendingLinkage () || GV.isDeclaration ()) {
375
+ continue ;
376
+ }
379
377
if (itr == Renamings.end ()) {
378
+ if (GV.hasLocalLinkage ()) {
379
+ continue ;
380
+ }
380
381
LazilyDiscoveredSymbols[JIT.intern (Name)] =
381
382
llvm::JITSymbolFlags::fromGlobalValue (GV);
383
+ // Ignore all symbols that will not appear in symbol table
382
384
} else {
385
+ // Promote linkage of requested symbols that will
386
+ // not appear in symbol table otherwise
387
+ if (GV.hasLocalLinkage ()) {
388
+ GV.setLinkage (llvm::GlobalValue::ExternalLinkage);
389
+ GV.setVisibility (llvm::GlobalValue::HiddenVisibility);
390
+ }
383
391
DefinedSymbols.insert (itr->getValue ());
384
392
}
385
393
}
386
-
394
+
387
395
llvm::orc::SymbolFlagsMap UnrequestedSymbols;
388
396
for (auto &[Sym, Flags] : MR->getSymbols ()) {
389
397
if (!DefinedSymbols.contains (Sym)) {
0 commit comments