Skip to content

Commit c9ee494

Browse files
committed
Add a check to ensure entry shader stage is the same as target profile
for non-library target profile compilation. Add a test to verify the check triggers diagnostic report appropriately.
1 parent 45da9fb commit c9ee494

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ static void translateMetadata(Module &M, const DXILResourceMap &DRM,
330330
uint64_t EntryShaderFlags =
331331
(MMDI.ShaderProfile == Triple::EnvironmentType::Library) ? 0
332332
: ShaderFlags;
333+
if (MMDI.ShaderProfile != Triple::EnvironmentType::Library) {
334+
if (EntryProp.ShaderStage != MMDI.ShaderProfile) {
335+
M.getContext().diagnose(DiagnosticInfoModuleFormat(
336+
M, "Non-library shader: Stage of Shader entry different from "
337+
"target profile"));
338+
}
339+
}
333340
EntryFnMDNodes.emplace_back(emitEntryMD(EntryProp, Signatures, ResourceMD,
334341
EntryShaderFlags,
335342
MMDI.ShaderProfile));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: not opt -S -dxil-translate-metadata %s 2>&1 | FileCheck %s
2+
3+
target triple = "dxil-pc-shadermodel6.6-pixel"
4+
5+
; CHECK: Non-library shader: Stage of Shader entry different from target profile
6+
7+
define void @entry() #0 {
8+
entry:
9+
ret void
10+
}
11+
12+
attributes #0 = { noinline nounwind "exp-shader"="cs" "hlsl.numthreads"="1,2,1" "hlsl.shader"="compute" }

0 commit comments

Comments
 (0)