Skip to content

Commit b4d773f

Browse files
authored
[SER] Validate MakeMiss (#7372)
Validate: HitObject_MakeMiss Rules: No undef MissShaderIndex or RayFlags SER implementation tracker: #7214
1 parent 0f7af1b commit b4d773f

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

lib/DxilValidation/DxilValidation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,12 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
19491949
ValCtx.EmitInstrError(
19501950
CI, ValidationRule::InstrMayReorderThreadUndefCoherenceHintParam);
19511951
} break;
1952+
case DXIL::OpCode::HitObject_MakeMiss: {
1953+
DxilInst_HitObject_MakeMiss MakeMiss(CI);
1954+
if (isa<UndefValue>(MakeMiss.get_RayFlags()) ||
1955+
isa<UndefValue>(MakeMiss.get_MissShaderIndex()))
1956+
ValCtx.EmitInstrError(CI, ValidationRule::InstrNoReadingUninitialized);
1957+
} break;
19521958

19531959
case DXIL::OpCode::HitObject_LoadLocalRootTableConstant: {
19541960
Value *HitObject = CI->getArgOperand(1);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; REQUIRES: dxil-1-9
2+
; RUN: not %dxv %s 2>&1 | FileCheck %s
3+
4+
target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64"
5+
target triple = "dxil-ms-dx"
6+
7+
%dx.types.HitObject = type { i8* }
8+
9+
; CHECK: Function: ?main@@YAXXZ: error: Instructions should not read uninitialized value.
10+
; CHECK: note: at '%r265_udmiss = call %dx.types.HitObject @dx.op.hitObject_MakeMiss(i32 265, i32 4, i32 undef, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 9.999000e+03)' in block '#0' of function '?main@@YAXXZ'.
11+
; CHECK: Function: ?main@@YAXXZ: error: Instructions should not read uninitialized value.
12+
; CHECK: note: at '%r265_udflags = call %dx.types.HitObject @dx.op.hitObject_MakeMiss(i32 265, i32 undef, i32 0, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 9.999000e+03)' in block '#0' of function '?main@@YAXXZ'.
13+
; CHECK: Validation failed.
14+
15+
; Function Attrs: nounwind
16+
define void @"\01?main@@YAXXZ"() #0 {
17+
%r265_udflags = call %dx.types.HitObject @dx.op.hitObject_MakeMiss(i32 265, i32 undef, i32 0, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 9.999000e+03) ; HitObject_MakeMiss(RayFlags,MissShaderIndex,Origin_X,Origin_Y,Origin_Z,TMin,Direction_X,Direction_Y,Direction_Z,TMax)
18+
%r265_udmiss = call %dx.types.HitObject @dx.op.hitObject_MakeMiss(i32 265, i32 4, i32 undef, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 9.999000e+03) ; HitObject_MakeMiss(RayFlags,MissShaderIndex,Origin_X,Origin_Y,Origin_Z,TMin,Direction_X,Direction_Y,Direction_Z,TMax)
19+
ret void
20+
}
21+
22+
; Function Attrs: nounwind readnone
23+
declare %dx.types.HitObject @dx.op.hitObject_MakeMiss(i32, i32, i32, float, float, float, float, float, float, float, float) #1
24+
25+
attributes #0 = { nounwind }
26+
attributes #1 = { nounwind readnone }
27+
28+
!dx.version = !{!0}
29+
!dx.valver = !{!0}
30+
!dx.shaderModel = !{!1}
31+
!dx.typeAnnotations = !{!2}
32+
!dx.entryPoints = !{!9, !11}
33+
34+
!0 = !{i32 1, i32 9}
35+
!1 = !{!"lib", i32 6, i32 9}
36+
!2 = !{i32 1, void ()* @"\01?main@@YAXXZ", !3}
37+
!3 = !{!4}
38+
!4 = !{i32 1, !5, !5}
39+
!5 = !{}
40+
!9 = !{null, !"", null, null, !10}
41+
!10 = !{i32 0, i64 0}
42+
!11 = !{void ()* @"\01?main@@YAXXZ", !"\01?main@@YAXXZ", null, null, !12}
43+
!12 = !{i32 8, i32 7, i32 5, !13}
44+
!13 = !{i32 0}

0 commit comments

Comments
 (0)