Skip to content

Commit b377521

Browse files
committed
Fix errors.
1 parent d5e6d19 commit b377521

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

source/slang/slang-emit.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,17 @@ void calcRequiredLoweringPassSet(RequiredLoweringPassSet& result, CodeGenContext
332332
result.byteAddressBuffer = true;
333333
break;
334334
}
335+
if (!result.generics || !result.existentialTypeLayout)
336+
{
337+
// If any instruction has an interface type, we need to run
338+
// the generics lowering pass.
339+
auto type = inst->getDataType();
340+
if (type && type->getOp() == kIROp_InterfaceType)
341+
{
342+
result.generics = true;
343+
result.existentialTypeLayout = true;
344+
}
345+
}
335346
for (auto child : inst->getDecorationsAndChildren())
336347
{
337348
calcRequiredLoweringPassSet(result, codeGenContext, child);

source/slang/slang-lower-to-ir.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -10839,7 +10839,7 @@ RefPtr<IRModule> generateIRForTranslationUnit(
1083910839
bool minimumOptimizations = linkage->m_optionSet.getBoolOption(CompilerOptionName::MinimumSlangOptimization);
1084010840
if (!minimumOptimizations)
1084110841
{
10842-
simplifyCFG(module, CFGSimplificationOptions::getFast());
10842+
simplifyCFG(module, CFGSimplificationOptions::getDefault());
1084310843
auto peepholeOptions = PeepholeOptimizationOptions::getPrelinking();
1084410844
peepholeOptimize(nullptr, module, peepholeOptions);
1084510845
}
@@ -10900,11 +10900,12 @@ RefPtr<IRModule> generateIRForTranslationUnit(
1090010900
{
1090110901
for (auto func : modifiedFuncs.getHashSet())
1090210902
{
10903+
auto codeInst = as<IRGlobalValueWithCode>(func);
1090310904
changed |= constructSSA(func);
1090410905
changed |= applySparseConditionalConstantPropagation(func, compileRequest->getSink());
1090510906
changed |= peepholeOptimize(nullptr, func);
10906-
changed |= simplifyCFG(codeInst, CFGSimplificationOptions::getFast())
10907-
eliminateDeadCode(func);
10907+
changed |= simplifyCFG(codeInst, CFGSimplificationOptions::getFast());
10908+
eliminateDeadCode(func, dceOptions);
1090810909
}
1090910910
}
1091010911
}
@@ -10920,6 +10921,7 @@ RefPtr<IRModule> generateIRForTranslationUnit(
1092010921
propagateConstExpr(module, compileRequest->getSink());
1092110922

1092210923
checkForUsingUninitializedOutParams(module, compileRequest->getSink());
10924+
1092310925
// TODO: give error messages if any `undefined` or
1092410926
// instructions remain.
1092510927

0 commit comments

Comments
 (0)