diff options
| author | Yong He <yonghe@outlook.com> | 2024-08-18 21:57:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-18 21:57:24 -0700 |
| commit | ecf85df6eee3da76ef54b14e4ab083f22da89e46 (patch) | |
| tree | 4656f9c11a1f7f40550d469fecbcd7a16c541f52 /source/slang/slang-ir-ssa.cpp | |
| parent | ca5d303748517889a5d5849224671fa8945e1c6d (diff) | |
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.
Diffstat (limited to 'source/slang/slang-ir-ssa.cpp')
| -rw-r--r-- | source/slang/slang-ir-ssa.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
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<IRBlock*> &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<IRBlock*> 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); } |
