Skip to content

Commit

Permalink
Process subrecord decls in spirv backend (#6879)
Browse files Browse the repository at this point in the history
The spir-v backend does not recurse into structs defined in struct in
doRecoredDecl. This causes us to miss some declarations.

Fixes #5916
  • Loading branch information
s-perron authored Aug 28, 2024
1 parent 6c99ecf commit b766b43
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,8 @@ void SpirvEmitter::doRecordDecl(const RecordDecl *recordDecl) {
doVarDecl(varDecl);
} else if (auto *enumDecl = dyn_cast<EnumDecl>(subDecl)) {
doEnumDecl(enumDecl);
} else if (auto recordDecl = dyn_cast<RecordDecl>(subDecl)) {
doRecordDecl(recordDecl);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions tools/clang/test/CodeGenSPIRV/nested.static.var.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %dxc -T cs_6_0 -E main -fcgl %s -spirv 2>&1 | FileCheck %s

// Check that the variable `value` is defined, and set to 6 in the entry point wrapper.
// CHECK: %value = OpVariable %_ptr_Private_uint Private
// CHECK: %main = OpFunction %void None
// CHECK-NEXT: OpLabel
// CHECK-NEXT: OpStore %value %uint_6

struct A {
struct B { static const uint value = 6u; };
};

[[vk::binding(0,4)]] RWStructuredBuffer<uint> a;

[numthreads(1,1,1)]
void main() {
a[0] = A::B::value;
}

0 comments on commit b766b43

Please sign in to comment.