Skip to content

Commit e8f08a1

Browse files
committed
[SER] Validate MakeMiss
Validate: HitObject_MakeMiss Rules: No undef MissIndex or RayFlags SER implementation tracker: #7214
1 parent ea95489 commit e8f08a1

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

lib/DxilValidation/DxilValidation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,12 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
19091909
ValCtx.EmitInstrError(
19101910
CI, ValidationRule::InstrMayReorderThreadUndefCoherenceHintParam);
19111911
} break;
1912+
case DXIL::OpCode::HitObject_MakeMiss: {
1913+
DxilInst_HitObject_MakeMiss MakeMiss(CI);
1914+
if (isa<UndefValue>(MakeMiss.get_RayFlags()) ||
1915+
isa<UndefValue>(MakeMiss.get_MissShaderIndex()))
1916+
ValCtx.EmitInstrError(CI, ValidationRule::InstrNoReadingUninitialized);
1917+
} break;
19121918

19131919
case DXIL::OpCode::AtomicBinOp:
19141920
case DXIL::OpCode::AtomicCompareExchange: {
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)