Skip to content

Commit e0c83a8

Browse files
authored
[SPIR-V] Fix crash when using entrypoint prototype (microsoft#6760)
When the prototype of an entrypoint was defined, the codegen crashed because it failed to filter this partial declaration when adding functions to the work-queue. Fixes microsoft#6750 Signed-off-by: Nathan Gauër <[email protected]>
1 parent 4f46fbc commit e0c83a8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ void SpirvEmitter::HandleTranslationUnit(ASTContext &context) {
770770
funcDecl, /*isEntryFunction*/ false);
771771
}
772772
} else {
773-
if (funcDecl->getName() == hlslEntryFunctionName) {
773+
const bool isPrototype = !funcDecl->isThisDeclarationADefinition();
774+
if (funcDecl->getName() == hlslEntryFunctionName && !isPrototype) {
774775
addFunctionToWorkQueue(spvContext.getCurrentShaderModelKind(),
775776
funcDecl, /*isEntryFunction*/ true);
776777
numEntryPoints++;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %dxc -T cs_6_6 -E main -spirv %s | FileCheck %s
2+
3+
void main();
4+
5+
// CHECK: OpEntryPoint GLCompute %main "main"
6+
[numthreads(1, 1, 1)]
7+
void main() {
8+
}

0 commit comments

Comments
 (0)