diff options
Diffstat (limited to 'source/slang/ir-ssa.cpp')
| -rw-r--r-- | source/slang/ir-ssa.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/slang/ir-ssa.cpp b/source/slang/ir-ssa.cpp index e97298969..6c4cfa8ff 100644 --- a/source/slang/ir-ssa.cpp +++ b/source/slang/ir-ssa.cpp @@ -350,6 +350,24 @@ IRInst* readVar( SSABlockInfo* blockInfo, IRVar* var); +/// Try to take any name hint on `var` and apply it to `val`. +/// +/// Doesn't do anything if `val` already has a name hint, +/// or if `var` doesn't have one to transfer over. +/// +void maybeApplyNameHint( + ConstructSSAContext* context, + IRVar* var, + IRInst* val) +{ + if( auto nameHint = var->findDecoration<IRNameHintDecoration>() ) + { + if( !val->findDecoration<IRNameHintDecoration>() ) + { + context->getBuilder()->addDecoration<IRNameHintDecoration>(val)->name = nameHint->name; + } + } +} // Add a phi node to represent the given variable PhiInfo* addPhi( @@ -365,6 +383,7 @@ PhiInfo* addPhi( valueType = context->getBuilder()->getRateQualifiedType(rate, valueType); } IRParam* phi = builder->createParam(valueType); + maybeApplyNameHint(context, var, phi); RefPtr<PhiInfo> phiInfo = new PhiInfo(); context->phiInfos.Add(phi, phiInfo); @@ -755,6 +774,8 @@ void processBlock( // block. auto val = readVar(context, blockInfo, var); + maybeApplyNameHint(context, var, val); + val = applyAccessChain(context, &blockInfo->builder, ptrArg, val); // We can just replace all uses of this |
