From ecf85df6eee3da76ef54b14e4ab083f22da89e46 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 18 Aug 2024 21:57:24 -0700 Subject: Variadic Generics Part 2: IR lowering and specialization. (#4849) * Variadic Generics Part 2: IR lowering and specialization. * Update design doc status. * Update design doc. * Resolve review comments. --- source/slang/slang-ir-ssa.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-ir-ssa.cpp') diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index 788c9a391..e44c4079b 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -146,7 +146,8 @@ bool allUsesLeadToLoads(IRInst* inst) // Is the given variable one that we can promote to SSA form? bool isPromotableVar( ConstructSSAContext* /*context*/, - IRVar* var) + IRVar* var, + HashSet &knownBlocks) { // We want to identify variables such that we can always // determine what they will contain at a point in the @@ -226,8 +227,13 @@ bool isPromotableVar( } break; } + + // If the use is outside of known blocks, then we can't promote it. + if (!knownBlocks.contains(getBlock(user))) + return false; } + // If all of the uses passed our checking, then // we are good to go. return true; @@ -237,6 +243,12 @@ bool isPromotableVar( void identifyPromotableVars( ConstructSSAContext* context) { + HashSet knownBlocks; + for (auto bb = context->globalVal->getFirstBlock(); bb; bb = bb->getNextBlock()) + { + knownBlocks.add(bb); + } + for (auto bb = context->globalVal->getFirstBlock(); bb; bb = bb->getNextBlock()) { for (auto ii = bb->getFirstInst(); ii; ii = ii->getNextInst()) @@ -246,7 +258,7 @@ void identifyPromotableVars( IRVar* var = (IRVar*)ii; - if (isPromotableVar(context, var)) + if (isPromotableVar(context, var, knownBlocks)) { context->promotableVars.add(var); } -- cgit v1.2.3