Skip to content

Commit

Permalink
[SPIR-V] Fix invalid optional read (microsoft#6221)
Browse files Browse the repository at this point in the history
When the env isn't valid, we emit an error. But instead of returning, we
continued and still tried to load the optional value, which triggered an
assert.

Signed-off-by: Nathan Gauër <[email protected]>
  • Loading branch information
Keenuts authored Jan 30, 2024
1 parent 8019c71 commit fadd627
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/clang/lib/SPIRV/FeatureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ FeatureManager::FeatureManager(DiagnosticsEngine &de,
emitNote("allowed options are:\n vulkan1.0\n vulkan1.1\n "
"vulkan1.1spirv1.4\n vulkan1.2\n vulkan1.3\n universal1.5",
{});
return;
}
targetEnv = *targetEnvOpt;

Expand Down
6 changes: 6 additions & 0 deletions tools/clang/test/CodeGenSPIRV/spirv.environment.invalid.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: not %dxc -T cs_6_0 -E main -fspv-target-env=vulkan1.1spirv1.3 %s -spirv 2>&1 | FileCheck %s

[numthreads(1, 1, 1)]
void main() { }

// CHECK: error: unknown SPIR-V target environment 'vulkan1.1spirv1.3'

0 comments on commit fadd627

Please sign in to comment.