@@ -1716,6 +1716,8 @@ static bool doesTargetAllowUnresolvedFuncSymbol(TargetRequest* req)
1716
1716
}
1717
1717
}
1718
1718
1719
+
1720
+
1719
1721
static void diagnoseUnresolvedSymbols (TargetRequest* req, DiagnosticSink* sink, IRModule* module)
1720
1722
{
1721
1723
for (auto globalSym : module->getGlobalInsts ())
@@ -1727,10 +1729,17 @@ static void diagnoseUnresolvedSymbols(TargetRequest* req, DiagnosticSink* sink,
1727
1729
if (auto constant = as<IRGlobalConstant>(globalSym))
1728
1730
{
1729
1731
if (constant->getOperandCount () == 0 )
1732
+ {
1733
+ if (globalSym->findDecoration <IRDownstreamModuleImportDecoration>())
1734
+ {
1735
+ break ;
1736
+ }
1737
+
1730
1738
sink->diagnose (
1731
- globalSym->sourceLoc ,
1732
- Diagnostics::unresolvedSymbol,
1733
- globalSym);
1739
+ globalSym->sourceLoc ,
1740
+ Diagnostics::unresolvedSymbol,
1741
+ globalSym);
1742
+ }
1734
1743
}
1735
1744
else if (auto genericSym = as<IRGeneric>(globalSym))
1736
1745
{
@@ -2017,14 +2026,16 @@ void cloneUsedWitnessTableEntries(IRSpecContext* context)
2017
2026
LinkedIR linkIR (CodeGenContext* codeGenContext)
2018
2027
{
2019
2028
SLANG_PROFILE;
2020
-
2029
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2030
+ printf (" Failed to link IR\n " );
2021
2031
auto linkage = codeGenContext->getLinkage ();
2022
2032
auto program = codeGenContext->getProgram ();
2023
2033
auto session = codeGenContext->getSession ();
2024
2034
auto target = codeGenContext->getTargetFormat ();
2025
2035
auto targetProgram = codeGenContext->getTargetProgram ();
2026
2036
auto targetReq = codeGenContext->getTargetReq ();
2027
-
2037
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2038
+ printf (" Failed to link IR\n " );
2028
2039
// TODO: We need to make sure that the program we are being asked
2029
2040
// to compile has been "resolved" so that it has no outstanding
2030
2041
// unsatisfied requirements.
@@ -2035,10 +2046,12 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2035
2046
state->target = target;
2036
2047
state->targetReq = targetReq;
2037
2048
auto & irModules = stateStorage.contextStorage .irModules ;
2038
-
2049
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2050
+ printf (" Failed to link IR\n " );
2039
2051
auto sharedContext = state->getSharedContext ();
2040
2052
initializeSharedSpecContext (sharedContext, session, nullptr , target, targetReq);
2041
-
2053
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2054
+ printf (" Failed to link IR\n " );
2042
2055
state->irModule = sharedContext->module ;
2043
2056
2044
2057
// We need to be able to look up IR definitions for any symbols in
@@ -2050,7 +2063,8 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2050
2063
List<IRModule*> builtinModules;
2051
2064
for (auto & m : globalSession->coreModules )
2052
2065
builtinModules.add (m->getIRModule ());
2053
-
2066
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2067
+ printf (" Failed to link IR\n " );
2054
2068
// Link modules in the program.
2055
2069
program->enumerateIRModules (
2056
2070
[&](IRModule* module)
@@ -2060,7 +2074,8 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2060
2074
else
2061
2075
irModules.add (module);
2062
2076
});
2063
-
2077
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2078
+ printf (" Failed to link IR\n " );
2064
2079
// We will also consider the IR global symbols from the IR module
2065
2080
// attached to the `TargetProgram`, since this module is
2066
2081
// responsible for associating layout information to those
@@ -2073,7 +2088,8 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2073
2088
Index userModuleCount = irModules.getCount ();
2074
2089
irModules.addRange (builtinModules);
2075
2090
ArrayView<IRModule*> userModules = irModules.getArrayView (0 , userModuleCount);
2076
-
2091
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2092
+ printf (" Failed to link IR\n " );
2077
2093
// Check if any user module uses auto-diff, if so we will need to link
2078
2094
// additional witnesses and decorations.
2079
2095
for (IRModule* irModule : userModules)
@@ -2094,14 +2110,17 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2094
2110
}
2095
2111
addGlobalHashedStringLiterals (pool, state->irModule );
2096
2112
}
2097
-
2113
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2114
+ printf (" Failed to link IR\n " );
2115
+
2098
2116
// Set up shared and builder insert point
2099
2117
2100
2118
context->shared = sharedContext;
2101
2119
context->builder = &sharedContext->builderStorage ;
2102
2120
2103
2121
context->builder ->setInsertInto (context->getModule ()->getModuleInst ());
2104
-
2122
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2123
+ printf (" Failed to link IR\n " );
2105
2124
// Next, we make sure to clone the global value for
2106
2125
// the entry point function itself, and rely on
2107
2126
// this step to recursively copy over anything else
@@ -2126,7 +2145,8 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2126
2145
entryPoint,
2127
2146
nameOverride.getUnownedSlice ()));
2128
2147
}
2129
-
2148
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2149
+ printf (" Failed to link IR\n " );
2130
2150
// Layout information for global shader parameters is also required,
2131
2151
// and in particular every global parameter that is part of the layout
2132
2152
// should be present in the initial IR module so that steps that
@@ -2143,7 +2163,8 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2143
2163
cast<IRVarLayout>(cloneValue (context, irOriginalGlobalScopeVarLayout));
2144
2164
}
2145
2165
}
2146
-
2166
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2167
+ printf (" Failed to link IR\n " );
2147
2168
// Bindings for global generic parameters are currently represented
2148
2169
// as stand-alone global-scope instructions in the IR module for
2149
2170
// `SpecializedComponentType`s. These instructions are required for
@@ -2167,7 +2188,8 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2167
2188
}
2168
2189
}
2169
2190
}
2170
-
2191
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2192
+ printf (" Failed to link IR\n " );
2171
2193
bool shouldCopyGlobalParams =
2172
2194
linkage->m_optionSet .getBoolOption (CompilerOptionName::PreserveParameters);
2173
2195
@@ -2190,7 +2212,8 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2190
2212
}
2191
2213
}
2192
2214
}
2193
-
2215
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2216
+ printf (" Failed to link IR\n " );
2194
2217
// In previous steps, we have skipped cloning the witness table entries, and
2195
2218
// registered any used witness table entry keys to context->deferredWitnessTableEntryKeys
2196
2219
// for on-demand cloning. Now we will use the deferred keys to clone the witness table
@@ -2234,21 +2257,25 @@ LinkedIR linkIR(CodeGenContext* codeGenContext)
2234
2257
}
2235
2258
}
2236
2259
}
2237
-
2260
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2261
+ printf (" Failed to link IR\n " );
2238
2262
// Specialize target_switch branches to use the best branch for the target.
2239
2263
specializeTargetSwitch (targetReq, state->irModule , codeGenContext->getSink ());
2240
-
2264
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2265
+ printf (" Failed to link IR\n " );
2241
2266
// Diagnose on unresolved symbols if we are compiling into a target that does
2242
2267
// not allow incomplete symbols.
2243
2268
// At this point, we should not see any [import] symbols that does not have a
2244
2269
// definition.
2245
2270
diagnoseUnresolvedSymbols (targetReq, codeGenContext->getSink (), state->irModule );
2246
-
2271
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2272
+ printf (" Failed to link IR\n " );
2247
2273
// type-use reformatter of GLSL types (only if compiler is set to AllowGLSL mode)
2248
2274
// which are not supported by SPIRV->Vulkan but is supported by GLSL->Vulkan through
2249
2275
// compiler magic tricks
2250
2276
GLSLReplaceAtomicUint (context, targetProgram, state->irModule );
2251
-
2277
+ if (codeGenContext->getSink ()->getErrorCount () != 0 )
2278
+ printf (" Failed to link IR\n " );
2252
2279
// TODO: *technically* we should consider the case where
2253
2280
// we have global variables with initializers, since
2254
2281
// these should get run whether or not the entry point
0 commit comments