@@ -1051,7 +1051,7 @@ DeclResultIdMapper::createFnParam(const ParmVarDecl *param,
1051
1051
fnParamInstr->setContainsAliasComponent (isAlias);
1052
1052
1053
1053
assert (astDecls[param].instr == nullptr );
1054
- astDecls[ param]. instr = fnParamInstr;
1054
+ registerVariableForDecl ( param, fnParamInstr) ;
1055
1055
1056
1056
if (spirvOptions.debugInfoRich ) {
1057
1057
// Add DebugLocalVariable information
@@ -1100,7 +1100,7 @@ DeclResultIdMapper::createFnVar(const VarDecl *var,
1100
1100
bool isAlias = false ;
1101
1101
(void )getTypeAndCreateCounterForPotentialAliasVar (var, &isAlias);
1102
1102
varInstr->setContainsAliasComponent (isAlias);
1103
- astDecls[ var]. instr = varInstr;
1103
+ registerVariableForDecl ( var, varInstr) ;
1104
1104
return varInstr;
1105
1105
}
1106
1106
@@ -1145,7 +1145,7 @@ DeclResultIdMapper::createFileVar(const VarDecl *var,
1145
1145
bool isAlias = false ;
1146
1146
(void )getTypeAndCreateCounterForPotentialAliasVar (var, &isAlias);
1147
1147
varInstr->setContainsAliasComponent (isAlias);
1148
- astDecls[ var]. instr = varInstr;
1148
+ registerVariableForDecl ( var, varInstr) ;
1149
1149
1150
1150
createDebugGlobalVariable (varInstr, type, loc, name);
1151
1151
@@ -1267,7 +1267,7 @@ SpirvVariable *DeclResultIdMapper::createExternVar(const VarDecl *var,
1267
1267
}
1268
1268
}
1269
1269
1270
- astDecls[ var] = createDeclSpirvInfo (varInstr);
1270
+ registerVariableForDecl ( var, createDeclSpirvInfo (varInstr) );
1271
1271
1272
1272
createDebugGlobalVariable (varInstr, type, loc, name);
1273
1273
@@ -1305,7 +1305,7 @@ SpirvInstruction *DeclResultIdMapper::createResultId(const VarDecl *var) {
1305
1305
}
1306
1306
1307
1307
SpirvInstruction *init = theEmitter.doExpr (var->getInit ());
1308
- astDecls[ var] = createDeclSpirvInfo (init);
1308
+ registerVariableForDecl ( var, createDeclSpirvInfo (init) );
1309
1309
return init;
1310
1310
}
1311
1311
@@ -1324,7 +1324,7 @@ DeclResultIdMapper::createOrUpdateStringVar(const VarDecl *var) {
1324
1324
const StringLiteral *stringLiteral =
1325
1325
dyn_cast<StringLiteral>(var->getInit ()->IgnoreParenCasts ());
1326
1326
SpirvString *init = spvBuilder.getString (stringLiteral->getString ());
1327
- astDecls[ var] = createDeclSpirvInfo (init);
1327
+ registerVariableForDecl ( var, createDeclSpirvInfo (init) );
1328
1328
return init;
1329
1329
}
1330
1330
@@ -1483,7 +1483,7 @@ SpirvVariable *DeclResultIdMapper::createCTBuffer(const HLSLBufferDecl *decl) {
1483
1483
if (isResourceType (varDecl->getType ()))
1484
1484
continue ;
1485
1485
1486
- astDecls[ varDecl] = createDeclSpirvInfo (bufferVar, index++);
1486
+ registerVariableForDecl ( varDecl, createDeclSpirvInfo (bufferVar, index++) );
1487
1487
}
1488
1488
// If it does not contains a member with non-resource type, we do not want to
1489
1489
// set a dedicated binding number.
@@ -1549,7 +1549,7 @@ SpirvVariable *DeclResultIdMapper::createPushConstant(const VarDecl *decl) {
1549
1549
}
1550
1550
1551
1551
// Register the VarDecl
1552
- astDecls[ decl] = createDeclSpirvInfo (var);
1552
+ registerVariableForDecl ( decl, createDeclSpirvInfo (var) );
1553
1553
1554
1554
// Do not push this variable into resourceVars since it does not need
1555
1555
// descriptor set.
@@ -1600,7 +1600,7 @@ DeclResultIdMapper::createShaderRecordBuffer(const VarDecl *decl,
1600
1600
}
1601
1601
1602
1602
// Register the VarDecl
1603
- astDecls[ decl] = createDeclSpirvInfo (var);
1603
+ registerVariableForDecl ( decl, createDeclSpirvInfo (var) );
1604
1604
1605
1605
// Do not push this variable into resourceVars since it does not need
1606
1606
// descriptor set.
@@ -1638,7 +1638,7 @@ DeclResultIdMapper::createShaderRecordBuffer(const HLSLBufferDecl *decl,
1638
1638
if (isResourceType (varDecl->getType ()))
1639
1639
continue ;
1640
1640
1641
- astDecls[ varDecl] = createDeclSpirvInfo (bufferVar, index++);
1641
+ registerVariableForDecl ( varDecl, createDeclSpirvInfo (bufferVar, index++) );
1642
1642
}
1643
1643
return bufferVar;
1644
1644
}
@@ -1688,7 +1688,7 @@ void DeclResultIdMapper::createGlobalsCBuffer(const VarDecl *var) {
1688
1688
if (isResourceType (varDecl->getType ()))
1689
1689
continue ;
1690
1690
1691
- astDecls[ varDecl] = createDeclSpirvInfo (globals, index++);
1691
+ registerVariableForDecl ( varDecl, createDeclSpirvInfo (globals, index++) );
1692
1692
}
1693
1693
}
1694
1694
@@ -1801,7 +1801,7 @@ DeclResultIdMapper::getCounterVarFields(const DeclaratorDecl *decl) {
1801
1801
void DeclResultIdMapper::registerSpecConstant (const VarDecl *decl,
1802
1802
SpirvInstruction *specConstant) {
1803
1803
specConstant->setRValue ();
1804
- astDecls[ decl] = createDeclSpirvInfo (specConstant);
1804
+ registerVariableForDecl ( decl, createDeclSpirvInfo (specConstant) );
1805
1805
}
1806
1806
1807
1807
void DeclResultIdMapper::createCounterVar (
@@ -4817,7 +4817,7 @@ void DeclResultIdMapper::tryToCreateImplicitConstVar(const ValueDecl *decl) {
4817
4817
SpirvInstruction *constVal =
4818
4818
spvBuilder.getConstantInt (astContext.UnsignedIntTy , val->getInt ());
4819
4819
constVal->setRValue (true );
4820
- astDecls[ varDecl]. instr = constVal;
4820
+ registerVariableForDecl ( varDecl, constVal) ;
4821
4821
}
4822
4822
4823
4823
void DeclResultIdMapper::decorateWithIntrinsicAttrs (
@@ -4880,6 +4880,21 @@ spv::ExecutionMode DeclResultIdMapper::getInterlockExecutionMode() {
4880
4880
spv::ExecutionMode::PixelInterlockOrderedEXT);
4881
4881
}
4882
4882
4883
+ void DeclResultIdMapper::registerVariableForDecl (const VarDecl *var,
4884
+ SpirvInstruction *varInstr) {
4885
+ DeclSpirvInfo spirvInfo;
4886
+ spirvInfo.instr = varInstr;
4887
+ spirvInfo.indexInCTBuffer = -1 ;
4888
+ registerVariableForDecl (var, spirvInfo);
4889
+ }
4890
+
4891
+ void DeclResultIdMapper::registerVariableForDecl (const VarDecl *var,
4892
+ DeclSpirvInfo spirvInfo) {
4893
+ for (const auto *v : var->redecls ()) {
4894
+ astDecls[v] = spirvInfo;
4895
+ }
4896
+ }
4897
+
4883
4898
void DeclResultIdMapper::copyHullOutStageVarsToOutputPatch (
4884
4899
SpirvInstruction *hullMainOutputPatch, const ParmVarDecl *outputPatchDecl,
4885
4900
QualType outputControlPointType, uint32_t numOutputControlPoints) {
0 commit comments