diff options
| author | Yong He <yonghe@outlook.com> | 2023-04-28 23:28:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-28 23:28:23 -0700 |
| commit | c571bcb025009f9c662e8d631fa49dbfed560287 (patch) | |
| tree | 3ade836c28920210b3dc1af5e8447d4804dc03ad /source/slang/slang-emit-spirv.cpp | |
| parent | 5adecbe837d27cf4e0a554ae13a0338743a8cb4b (diff) | |
SSA Register Allocation improvements. (#2857)
* SSA Register Allocation improvements.
* Fix.
* Rename `Use`->`UseOrPseudoUse`.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index fc2505d63..b17ccf483 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -1473,7 +1473,20 @@ struct SPIRVEmitContext // for( auto irBlock : irFunc->getBlocks() ) { - emitInst(spvFunc, irBlock, SpvOpLabel, kResultID); + auto spvBlock = emitInst(spvFunc, irBlock, SpvOpLabel, kResultID); + if (irBlock == irFunc->getFirstBlock()) + { + // OpVariable + // All variables used in the function must be declared before anything else. + for (auto block : irFunc->getBlocks()) + { + for (auto inst : block->getChildren()) + { + if (as<IRVar>(inst)) + emitLocalInst(spvBlock, inst); + } + } + } // In addition to normal basic blocks, // all loops gets a header block. @@ -1517,6 +1530,9 @@ struct SPIRVEmitContext // Any instructions local to the block will be emitted as children // of the block. // + // Skip vars because they are already emitted. + if (as<IRVar>(irInst)) + continue; emitLocalInst(spvBlock, irInst); if (irInst->getOp() == kIROp_loop) pendingLoopInsts.add(as<IRLoop>(irInst)); |
