diff options
Diffstat (limited to 'source/slang/slang-ir-link.cpp')
| -rw-r--r-- | source/slang/slang-ir-link.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp index 1cdc2cfc9..1102ecb3e 100644 --- a/source/slang/slang-ir-link.cpp +++ b/source/slang/slang-ir-link.cpp @@ -1339,15 +1339,26 @@ LinkedIR linkIR( state->irModule = sharedContext->module; + auto linkage = compileRequest->getLinkage(); + // We need to be able to look up IR definitions for any symbols in // modules that the program depends on (transitively). To // accelerate lookup, we will create a symbol table for looking // up IR definitions by their mangled name. // + + List<IRModule*> irModules; program->enumerateIRModules([&](IRModule* irModule) { - insertGlobalValueSymbols(sharedContext, irModule); + irModules.add(irModule); }); + irModules.addRange(linkage->m_libModules.getBuffer()->readRef(), linkage->m_libModules.getCount()); + + // Add any modules that were loaded as libraries + for (IRModule* irModule : irModules) + { + insertGlobalValueSymbols(sharedContext, irModule); + } // We will also insert the IR global symbols from the IR module // attached to the `TargetProgram`, since this module is @@ -1374,7 +1385,6 @@ LinkedIR linkIR( cloneGlobalValue(context, (IRWitnessTable*)sym.Value->irGlobalValue); } - // Next, we make sure to clone the global value for // the entry point function itself, and rely on // this step to recursively copy over anything else @@ -1401,17 +1411,18 @@ LinkedIR linkIR( // In the long run we do not want to *ever* iterate over all the // instructions in all the input modules. // - program->enumerateIRModules([&](IRModule* irModule) + + for (IRModule* irModule : irModules) { - for(auto inst : irModule->getGlobalInsts()) + for (auto inst : irModule->getGlobalInsts()) { auto bindInst = as<IRBindGlobalGenericParam>(inst); - if(!bindInst) + if (!bindInst) continue; cloneValue(context, bindInst); } - }); + } // TODO: *technically* we should consider the case where // we have global variables with initializers, since |
