@@ -1107,9 +1107,8 @@ bool SemaHLSL::handleRootSignatureElements(
1107
1107
using ResourceRange = llvm::hlsl::rootsig::ResourceRange;
1108
1108
using GroupT = std::pair<ResourceClass, /* Space*/ uint32_t >;
1109
1109
1110
- // Introduce a mapping from the collected RangeInfos back to the
1111
- // RootSignatureElement that will retain its diagnostics info
1112
- llvm::DenseMap<size_t , const hlsl::RootSignatureElement *> InfoIndexMap;
1110
+ // Each RangeInfo will contain an index back to its associated
1111
+ // RootSignatureElement in our Elements ArrayRef
1113
1112
size_t InfoIndex = 0 ;
1114
1113
1115
1114
// 1. Collect RangeInfos
@@ -1127,8 +1126,7 @@ bool SemaHLSL::handleRootSignatureElements(
1127
1126
Info.Space = Descriptor->Space ;
1128
1127
Info.Visibility = Descriptor->Visibility ;
1129
1128
1130
- Info.Index = InfoIndex++;
1131
- InfoIndexMap[Info.Index ] = &RootSigElem;
1129
+ Info.Index = InfoIndex;
1132
1130
Infos.push_back (Info);
1133
1131
} else if (const auto *Constants =
1134
1132
std::get_if<llvm::hlsl::rootsig::RootConstants>(&Elem)) {
@@ -1140,8 +1138,7 @@ bool SemaHLSL::handleRootSignatureElements(
1140
1138
Info.Space = Constants->Space ;
1141
1139
Info.Visibility = Constants->Visibility ;
1142
1140
1143
- Info.Index = InfoIndex++;
1144
- InfoIndexMap[Info.Index ] = &RootSigElem;
1141
+ Info.Index = InfoIndex;
1145
1142
Infos.push_back (Info);
1146
1143
} else if (const auto *Sampler =
1147
1144
std::get_if<llvm::hlsl::rootsig::StaticSampler>(&Elem)) {
@@ -1153,8 +1150,7 @@ bool SemaHLSL::handleRootSignatureElements(
1153
1150
Info.Space = Sampler->Space ;
1154
1151
Info.Visibility = Sampler->Visibility ;
1155
1152
1156
- Info.Index = InfoIndex++;
1157
- InfoIndexMap[Info.Index ] = &RootSigElem;
1153
+ Info.Index = InfoIndex;
1158
1154
Infos.push_back (Info);
1159
1155
} else if (const auto *Clause =
1160
1156
std::get_if<llvm::hlsl::rootsig::DescriptorTableClause>(
@@ -1171,8 +1167,7 @@ bool SemaHLSL::handleRootSignatureElements(
1171
1167
Info.Space = Clause->Space ;
1172
1168
1173
1169
// Note: Clause does not hold the visibility this will need to
1174
- Info.Index = InfoIndex++;
1175
- InfoIndexMap[Info.Index ] = &RootSigElem;
1170
+ Info.Index = InfoIndex;
1176
1171
Infos.push_back (Info);
1177
1172
} else if (const auto *Table =
1178
1173
std::get_if<llvm::hlsl::rootsig::DescriptorTable>(&Elem)) {
@@ -1186,6 +1181,8 @@ bool SemaHLSL::handleRootSignatureElements(
1186
1181
for (RangeInfo &Info : TableInfos)
1187
1182
Info.Visibility = Table->Visibility ;
1188
1183
}
1184
+
1185
+ InfoIndex++;
1189
1186
}
1190
1187
1191
1188
// 2. Sort the RangeInfo's by their GroupT to form groupings
@@ -1219,14 +1216,13 @@ bool SemaHLSL::handleRootSignatureElements(
1219
1216
};
1220
1217
1221
1218
// Helper to report diagnostics
1222
- auto ReportOverlap = [this , InfoIndexMap , &HadOverlap](
1223
- const RangeInfo *Info, const RangeInfo *OInfo) {
1219
+ auto ReportOverlap = [this , &Elements , &HadOverlap](const RangeInfo *Info,
1220
+ const RangeInfo *OInfo) {
1224
1221
HadOverlap = true ;
1225
1222
auto CommonVis = Info->Visibility == llvm::dxbc::ShaderVisibility::All
1226
1223
? OInfo->Visibility
1227
1224
: Info->Visibility ;
1228
- const hlsl::RootSignatureElement *Elem = InfoIndexMap.at (Info->Index );
1229
- SourceLocation InfoLoc = Elem->getLocation ();
1225
+ SourceLocation InfoLoc = Elements[Info->Index ].getLocation ();
1230
1226
this ->Diag (InfoLoc, diag::err_hlsl_resource_range_overlap)
1231
1227
<< llvm::to_underlying (Info->Class ) << Info->LowerBound
1232
1228
<< /* unbounded=*/ (Info->UpperBound == RangeInfo::Unbounded)
@@ -1235,8 +1231,7 @@ bool SemaHLSL::handleRootSignatureElements(
1235
1231
<< /* unbounded=*/ (OInfo->UpperBound == RangeInfo::Unbounded)
1236
1232
<< OInfo->UpperBound << Info->Space << CommonVis;
1237
1233
1238
- const hlsl::RootSignatureElement *OElem = InfoIndexMap.at (OInfo->Index );
1239
- SourceLocation OInfoLoc = OElem->getLocation ();
1234
+ SourceLocation OInfoLoc = Elements[OInfo->Index ].getLocation ();
1240
1235
this ->Diag (OInfoLoc, diag::note_hlsl_resource_range_here);
1241
1236
};
1242
1237
0 commit comments