recursive.ll 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. ; RUN: %dxv %s | FileCheck %s
  2. ; CHECK: Recursion is not permitted
  3. ; This test originally covered two validator error messages:
  4. ; 1. recursion not allowed
  5. ; 2. functions with parameters are not allowed
  6. ;
  7. ; The recursion error is now handled earlier in the pipeline, and so there
  8. ; is no coverage for error #2. But we do need the validator to check for this
  9. ; in case someone decides to remove this. So instead, we validate the assembly
  10. ; we would have had, which we can generate with this command:
  11. ;
  12. ; dxc -Vd -T ps_6_0 recursive.hlsl
  13. ;
  14. ; void test_inout(inout float4 m, float4 a) {
  15. ; if (a.x > 1)
  16. ; test_inout(m, a-1);
  17. ; m = abs(m+a*a.yxxx);
  18. ; }
  19. ;
  20. ; float4 main(float4 a : A, float4 b:B) : SV_TARGET {
  21. ; float4 x = b;
  22. ; test_inout(x, a);
  23. ; return x;
  24. ; }
  25. ;
  26. ; Input signature:
  27. ;
  28. ; Name Index Mask Register SysValue Format Used
  29. ; -------------------- ----- ------ -------- -------- ------- ------
  30. ; A 0 xyzw 0 NONE float
  31. ; B 0 xyzw 1 NONE float
  32. ;
  33. ;
  34. ; Output signature:
  35. ;
  36. ; Name Index Mask Register SysValue Format Used
  37. ; -------------------- ----- ------ -------- -------- ------- ------
  38. ; SV_Target 0 xyzw 0 TARGET float xyzw
  39. ;
  40. ;
  41. ; Pipeline Runtime Information:
  42. ;
  43. ; Pixel Shader
  44. ; DepthOutput=0
  45. ; SampleFrequency=0
  46. ;
  47. ;
  48. ; Input signature:
  49. ;
  50. ; Name Index InterpMode
  51. ; -------------------- ----- ----------------------
  52. ; A 0 linear
  53. ; B 0 linear
  54. ;
  55. ; Output signature:
  56. ;
  57. ; Name Index InterpMode
  58. ; -------------------- ----- ----------------------
  59. ; SV_Target 0
  60. ;
  61. ; Buffer Definitions:
  62. ;
  63. ;
  64. ; Resource Bindings:
  65. ;
  66. ; Name Type Format Dim ID HLSL Bind Count
  67. ; ------------------------------ ---------- ------- ----------- ------- -------------- ------
  68. ;
  69. target datalayout = "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
  70. target triple = "dxil-ms-dx"
  71. ; Function Attrs: alwaysinline nounwind
  72. define internal fastcc void @"\01?test_inout@@YAXAAV?$vector@M$03@@V1@@Z"(<4 x float>* nocapture dereferenceable(16) %m, <4 x float> %a) #0 {
  73. entry:
  74. %a.i0 = extractelement <4 x float> %a, i32 0
  75. %a.i1 = extractelement <4 x float> %a, i32 1
  76. %a.i2 = extractelement <4 x float> %a, i32 2
  77. %a.i3 = extractelement <4 x float> %a, i32 3
  78. %0 = load <4 x float>, <4 x float>* %m, align 4
  79. %.i05 = extractelement <4 x float> %0, i32 0
  80. %.i16 = extractelement <4 x float> %0, i32 1
  81. %.i27 = extractelement <4 x float> %0, i32 2
  82. %.i38 = extractelement <4 x float> %0, i32 3
  83. %1 = alloca <4 x float>, align 4
  84. %cmp = fcmp ogt float %a.i0, 1.000000e+00
  85. br i1 %cmp, label %if.then, label %if.end
  86. if.then: ; preds = %entry
  87. store <4 x float> %0, <4 x float>* %1, align 4
  88. %sub.i0 = fadd float %a.i0, -1.000000e+00
  89. %sub.i1 = fadd float %a.i1, -1.000000e+00
  90. %sub.i2 = fadd float %a.i2, -1.000000e+00
  91. %sub.i3 = fadd float %a.i3, -1.000000e+00
  92. %sub.upto0 = insertelement <4 x float> undef, float %sub.i0, i32 0
  93. %sub.upto1 = insertelement <4 x float> %sub.upto0, float %sub.i1, i32 1
  94. %sub.upto2 = insertelement <4 x float> %sub.upto1, float %sub.i2, i32 2
  95. %sub = insertelement <4 x float> %sub.upto2, float %sub.i3, i32 3
  96. call fastcc void @"\01?test_inout@@YAXAAV?$vector@M$03@@V1@@Z"(<4 x float>* nonnull dereferenceable(16) %1, <4 x float> %sub)
  97. %2 = load <4 x float>, <4 x float>* %1, align 4
  98. %.i0 = extractelement <4 x float> %2, i32 0
  99. %.i1 = extractelement <4 x float> %2, i32 1
  100. %.i2 = extractelement <4 x float> %2, i32 2
  101. %.i3 = extractelement <4 x float> %2, i32 3
  102. br label %if.end
  103. if.end: ; preds = %if.then, %entry
  104. %.0.i0 = phi float [ %.i0, %if.then ], [ %.i05, %entry ]
  105. %.0.i1 = phi float [ %.i1, %if.then ], [ %.i16, %entry ]
  106. %.0.i2 = phi float [ %.i2, %if.then ], [ %.i27, %entry ]
  107. %.0.i3 = phi float [ %.i3, %if.then ], [ %.i38, %entry ]
  108. %mul.i0 = fmul float %a.i0, %a.i1
  109. %mul.i2 = fmul float %a.i2, %a.i0
  110. %mul.i3 = fmul float %a.i3, %a.i0
  111. %add.i0 = fadd float %mul.i0, %.0.i0
  112. %add.i1 = fadd float %mul.i0, %.0.i1
  113. %add.i2 = fadd float %mul.i2, %.0.i2
  114. %add.i3 = fadd float %mul.i3, %.0.i3
  115. %FAbs = call float @dx.op.unary.f32(i32 6, float %add.i0) ; FAbs(value)
  116. %3 = insertelement <4 x float> undef, float %FAbs, i64 0
  117. %FAbs2 = call float @dx.op.unary.f32(i32 6, float %add.i1) ; FAbs(value)
  118. %4 = insertelement <4 x float> %3, float %FAbs2, i64 1
  119. %FAbs3 = call float @dx.op.unary.f32(i32 6, float %add.i2) ; FAbs(value)
  120. %5 = insertelement <4 x float> %4, float %FAbs3, i64 2
  121. %FAbs4 = call float @dx.op.unary.f32(i32 6, float %add.i3) ; FAbs(value)
  122. %6 = insertelement <4 x float> %5, float %FAbs4, i64 3
  123. store <4 x float> %6, <4 x float>* %m, align 4
  124. ret void
  125. }
  126. define void @main() {
  127. entry:
  128. %0 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  129. %1 = insertelement <4 x float> undef, float %0, i64 0
  130. %2 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  131. %3 = insertelement <4 x float> %1, float %2, i64 1
  132. %4 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  133. %5 = insertelement <4 x float> %3, float %4, i64 2
  134. %6 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 3, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  135. %7 = insertelement <4 x float> %5, float %6, i64 3
  136. %8 = call float @dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  137. %9 = insertelement <4 x float> undef, float %8, i64 0
  138. %10 = call float @dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  139. %11 = insertelement <4 x float> %9, float %10, i64 1
  140. %12 = call float @dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  141. %13 = insertelement <4 x float> %11, float %12, i64 2
  142. %14 = call float @dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 3, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  143. %15 = insertelement <4 x float> %13, float %14, i64 3
  144. %16 = alloca <4 x float>, align 4
  145. store <4 x float> %7, <4 x float>* %16, align 4
  146. call fastcc void @"\01?test_inout@@YAXAAV?$vector@M$03@@V1@@Z"(<4 x float>* nonnull dereferenceable(16) %16, <4 x float> %15)
  147. %17 = load <4 x float>, <4 x float>* %16, align 4
  148. %18 = extractelement <4 x float> %17, i64 0
  149. call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %18) ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  150. %19 = extractelement <4 x float> %17, i64 1
  151. call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %19) ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  152. %20 = extractelement <4 x float> %17, i64 2
  153. call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %20) ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  154. %21 = extractelement <4 x float> %17, i64 3
  155. call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float %21) ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  156. ret void
  157. }
  158. ; Function Attrs: nounwind readnone
  159. declare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #1
  160. ; Function Attrs: nounwind
  161. declare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2
  162. ; Function Attrs: nounwind readnone
  163. declare float @dx.op.unary.f32(i32, float) #1
  164. attributes #0 = { alwaysinline nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="0" "unsafe-fp-math"="false" "use-soft-float"="false" }
  165. attributes #1 = { nounwind readnone }
  166. attributes #2 = { nounwind }
  167. !llvm.ident = !{!0}
  168. !dx.version = !{!1}
  169. !dx.shaderModel = !{!2}
  170. !dx.typeAnnotations = !{!3}
  171. !dx.entryPoints = !{!12}
  172. !0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
  173. !1 = !{i32 1, i32 0}
  174. !2 = !{!"ps", i32 6, i32 0}
  175. !3 = !{i32 1, void (<4 x float>*, <4 x float>)* @"\01?test_inout@@YAXAAV?$vector@M$03@@V1@@Z", !4, void ()* @main, !10}
  176. !4 = !{!5, !7, !9}
  177. !5 = !{i32 1, !6, !6}
  178. !6 = !{}
  179. !7 = !{i32 2, !8, !6}
  180. !8 = !{i32 7, i32 9}
  181. !9 = !{i32 0, !8, !6}
  182. !10 = !{!11}
  183. !11 = !{i32 0, !6, !6}
  184. !12 = !{void ()* @main, !"main", !13, null, null}
  185. !13 = !{!14, !18, null}
  186. !14 = !{!15, !17}
  187. !15 = !{i32 0, !"A", i8 9, i8 0, !16, i8 2, i32 1, i8 4, i32 0, i8 0, null}
  188. !16 = !{i32 0}
  189. !17 = !{i32 1, !"B", i8 9, i8 0, !16, i8 2, i32 1, i8 4, i32 1, i8 0, null}
  190. !18 = !{!19}
  191. !19 = !{i32 0, !"SV_Target", i8 9, i8 16, !16, i8 0, i32 1, i8 4, i32 0, i8 0, null}