[llvm] [SPIRV] Emit NonSemantic DebugTypeArray. (PR #211537)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 24 06:23:58 PDT 2026
================
@@ -712,6 +730,38 @@ std::optional<MCRegister> SPIRVNonSemanticDebugHandler::emitDebugTypeVector(
ExtInstSetReg, {BTIt->second, CountReg}, MAI);
}
+std::optional<MCRegister> SPIRVNonSemanticDebugHandler::emitDebugTypeArray(
+ const DICompositeType *AT, MCRegister ExtInstSetReg,
+ SPIRV::ModuleAnalysisInfo &MAI) {
+ // The element (base) type must already be in DebugTypeRegs. Unlike
+ // DebugTypeVector, the element may be any debug type, not only a basic type.
+ auto BaseRegOpt = lookupOptReg(DebugTypeRegs, AT->getBaseType());
+ if (!BaseRegOpt)
+ return std::nullopt;
+
+ MCRegister VoidTypeReg = getOrEmitOpTypeVoidReg(MAI);
+ MCRegister I32TypeReg = getOrEmitOpTypeInt32Reg(MAI);
+
+ SmallVector<MCRegister> Ops;
+ Ops.push_back(*BaseRegOpt);
+
+ // One component count per DISubrange, in DWARF subrange order. Emit 0 for
+ // counts that are not a compile-time constant (dynamic arrays). This matches
+ // OpTypeRuntimeArray.
+ for (const DINode *Element : AT->getElements()) {
+ const auto *SR = dyn_cast<DISubrange>(Element);
+ if (!SR)
+ continue;
+ uint32_t Count = 0;
+ if (const auto *CI = dyn_cast_if_present<ConstantInt *>(SR->getCount()))
+ Count = static_cast<uint32_t>(CI->getZExtValue());
----------------
jmmartinez wrote:
I really don't expect to see an array so big we overflow `uint32_t`. But what do you think about saturating the `Count` or using `0` instead of truncating?
https://github.com/llvm/llvm-project/pull/211537
More information about the llvm-commits
mailing list