Skip to content

Commit de17ed2

Browse files
svenvhsys-ce-bb
authored andcommitted
Fix UB in UntypedPtrTyMap (#3283)
SmallDenseMap requires sentinel values out of the `SPIRVStorageClassKind` range. This became a build error after llvm-project commit `38f82534bbe9 ("Reject out-of-bounds enum sentinels in DenseMap/DenseSet. (#150308)", 2025-07-24)`. As the `SPIRVStorageClassKind` enum comes from an external header we cannot change it to an enum class or add an underlying type. This is actually solved in the `spirv.hpp11` header, but migrating to that header requires more widespread changes; just switch to a `std::unordered_map` for now. Original commit: KhronosGroup/SPIRV-LLVM-Translator@db0ec312a9cacf9
1 parent d9e725c commit de17ed2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ class SPIRVModuleImpl : public SPIRVModule {
634634
SPIRVUnknownStructFieldMap UnknownStructFieldMap;
635635
SPIRVTypeBool *BoolTy;
636636
SPIRVTypeVoid *VoidTy;
637-
SmallDenseMap<SPIRVStorageClassKind, SPIRVTypeUntypedPointerKHR *>
637+
std::unordered_map<SPIRVStorageClassKind, SPIRVTypeUntypedPointerKHR *>
638638
UntypedPtrTyMap;
639639
SmallDenseMap<unsigned, SPIRVTypeInt *, 4> IntTypeMap;
640640
SmallDenseMap<std::pair<unsigned, unsigned>, SPIRVTypeFloat *, 4>

0 commit comments

Comments
 (0)