@@ -1086,9 +1086,8 @@ bool SemaHLSL::handleRootSignatureElements(
1086
1086
using RangeInfo = llvm::hlsl::rootsig::RangeInfo;
1087
1087
using OverlappingRanges = llvm::hlsl::rootsig::OverlappingRanges;
1088
1088
1089
- // Introduce a mapping from the collected RangeInfos back to the
1090
- // RootSignatureElement that will retain its diagnostics info
1091
- llvm::DenseMap<size_t , const hlsl::RootSignatureElement *> InfoIndexMap;
1089
+ // Each RangeInfo will contain an index back to its associated
1090
+ // RootSignatureElement in our Elements ArrayRef
1092
1091
size_t InfoIndex = 0 ;
1093
1092
1094
1093
// 1. Collect RangeInfos
@@ -1106,8 +1105,7 @@ bool SemaHLSL::handleRootSignatureElements(
1106
1105
Info.Space = Descriptor->Space ;
1107
1106
Info.Visibility = Descriptor->Visibility ;
1108
1107
1109
- Info.Index = InfoIndex++;
1110
- InfoIndexMap[Info.Index ] = &RootSigElem;
1108
+ Info.Index = InfoIndex;
1111
1109
Infos.push_back (Info);
1112
1110
} else if (const auto *Constants =
1113
1111
std::get_if<llvm::hlsl::rootsig::RootConstants>(&Elem)) {
@@ -1119,8 +1117,7 @@ bool SemaHLSL::handleRootSignatureElements(
1119
1117
Info.Space = Constants->Space ;
1120
1118
Info.Visibility = Constants->Visibility ;
1121
1119
1122
- Info.Index = InfoIndex++;
1123
- InfoIndexMap[Info.Index ] = &RootSigElem;
1120
+ Info.Index = InfoIndex;
1124
1121
Infos.push_back (Info);
1125
1122
} else if (const auto *Sampler =
1126
1123
std::get_if<llvm::hlsl::rootsig::StaticSampler>(&Elem)) {
@@ -1132,8 +1129,7 @@ bool SemaHLSL::handleRootSignatureElements(
1132
1129
Info.Space = Sampler->Space ;
1133
1130
Info.Visibility = Sampler->Visibility ;
1134
1131
1135
- Info.Index = InfoIndex++;
1136
- InfoIndexMap[Info.Index ] = &RootSigElem;
1132
+ Info.Index = InfoIndex;
1137
1133
Infos.push_back (Info);
1138
1134
} else if (const auto *Clause =
1139
1135
std::get_if<llvm::hlsl::rootsig::DescriptorTableClause>(
@@ -1150,8 +1146,7 @@ bool SemaHLSL::handleRootSignatureElements(
1150
1146
Info.Space = Clause->Space ;
1151
1147
1152
1148
// Note: Clause does not hold the visibility this will need to
1153
- Info.Index = InfoIndex++;
1154
- InfoIndexMap[Info.Index ] = &RootSigElem;
1149
+ Info.Index = InfoIndex;
1155
1150
Infos.push_back (Info);
1156
1151
} else if (const auto *Table =
1157
1152
std::get_if<llvm::hlsl::rootsig::DescriptorTable>(&Elem)) {
@@ -1165,17 +1160,18 @@ bool SemaHLSL::handleRootSignatureElements(
1165
1160
for (RangeInfo &Info : TableInfos)
1166
1161
Info.Visibility = Table->Visibility ;
1167
1162
}
1163
+
1164
+ InfoIndex++;
1168
1165
}
1169
1166
1170
1167
// Helper to report diagnostics
1171
- auto ReportOverlap = [this , &InfoIndexMap ](OverlappingRanges Overlap) {
1168
+ auto ReportOverlap = [this , &Elements ](OverlappingRanges Overlap) {
1172
1169
const RangeInfo *Info = Overlap.A ;
1173
1170
const RangeInfo *OInfo = Overlap.B ;
1174
1171
auto CommonVis = Info->Visibility == llvm::dxbc::ShaderVisibility::All
1175
1172
? OInfo->Visibility
1176
1173
: Info->Visibility ;
1177
- const hlsl::RootSignatureElement *Elem = InfoIndexMap.at (Info->Index );
1178
- SourceLocation InfoLoc = Elem->getLocation ();
1174
+ SourceLocation InfoLoc = Elements[Info->Index ].getLocation ();
1179
1175
this ->Diag (InfoLoc, diag::err_hlsl_resource_range_overlap)
1180
1176
<< llvm::to_underlying (Info->Class ) << Info->LowerBound
1181
1177
<< /* unbounded=*/ (Info->UpperBound == RangeInfo::Unbounded)
@@ -1184,8 +1180,7 @@ bool SemaHLSL::handleRootSignatureElements(
1184
1180
<< /* unbounded=*/ (OInfo->UpperBound == RangeInfo::Unbounded)
1185
1181
<< OInfo->UpperBound << Info->Space << CommonVis;
1186
1182
1187
- const hlsl::RootSignatureElement *OElem = InfoIndexMap.at (OInfo->Index );
1188
- SourceLocation OInfoLoc = OElem->getLocation ();
1183
+ SourceLocation OInfoLoc = Elements[OInfo->Index ].getLocation ();
1189
1184
this ->Diag (OInfoLoc, diag::note_hlsl_resource_range_here);
1190
1185
};
1191
1186
0 commit comments