114 lines · plain
1; RUN: split-file %s %t2; RUN: not opt -S --dxil-translate-metadata %t/args.ll 2>&1 | FileCheck %t/args.ll3; RUN: not opt -S --dxil-translate-metadata %t/bad-count.ll 2>&1 | FileCheck %t/bad-count.ll4; RUN: not opt -S --dxil-translate-metadata %t/invalid-disable.ll 2>&1 | FileCheck %t/invalid-disable.ll5; RUN: not opt -S --dxil-translate-metadata %t/invalid-full.ll 2>&1 | FileCheck %t/invalid-full.ll6 7; Test that loop metadata is validated as with the DXIL validator8 9;--- args.ll10 11; CHECK: Invalid "llvm.loop" metadata: Provided conflicting hints12 13target triple = "dxilv1.0-unknown-shadermodel6.0-library"14 15define void @example_loop(i32 %n) {16entry:17 br label %loop.header18 19loop.header:20 %i = phi i32 [ 0, %entry ], [ %i.next, %loop.body ]21 %cmp = icmp slt i32 %i, %n22 br i1 %cmp, label %loop.body, label %exit23 24loop.body:25 %i.next = add nsw i32 %i, 126 br label %loop.header, !llvm.loop !127 28exit:29 ret void30}31 32!1 = !{!1, !2, !3} ; conflicting args33!2 = !{!"llvm.loop.unroll.full"}34!3 = !{!"llvm.loop.unroll.disable"}35 36;--- bad-count.ll37 38; CHECK: "llvm.loop.unroll.count" must have 2 operands and the second must be a constant integer39 40target triple = "dxilv1.0-unknown-shadermodel6.0-library"41 42define void @example_loop(i32 %n) {43entry:44 br label %loop.header45 46loop.header:47 %i = phi i32 [ 0, %entry ], [ %i.next, %loop.body ]48 %cmp = icmp slt i32 %i, %n49 br i1 %cmp, label %loop.body, label %exit50 51loop.body:52 %i.next = add nsw i32 %i, 153 br label %loop.header, !llvm.loop !154 55exit:56 ret void57}58 59!1 = !{!1, !2}60!2 = !{!"llvm.loop.unroll.count", !"not an int"} ; invalid count parameters61 62;--- invalid-disable.ll63 64; CHECK: Invalid "llvm.loop" metadata: "llvm.loop.unroll.disable" and "llvm.loop.unroll.full" must be provided as a single operand65 66target triple = "dxilv1.0-unknown-shadermodel6.0-library"67 68define void @example_loop(i32 %n) {69entry:70 br label %loop.header71 72loop.header:73 %i = phi i32 [ 0, %entry ], [ %i.next, %loop.body ]74 %cmp = icmp slt i32 %i, %n75 br i1 %cmp, label %loop.body, label %exit76 77loop.body:78 %i.next = add nsw i32 %i, 179 br label %loop.header, !llvm.loop !180 81exit:82 ret void83}84 85!1 = !{!1, !2}86!2 = !{!"llvm.loop.unroll.disable", i32 0} ; invalid second operand87 88 89;--- invalid-full.ll90 91; CHECK: Invalid "llvm.loop" metadata: "llvm.loop.unroll.disable" and "llvm.loop.unroll.full" must be provided as a single operand92 93target triple = "dxilv1.0-unknown-shadermodel6.0-library"94 95define void @example_loop(i32 %n) {96entry:97 br label %loop.header98 99loop.header:100 %i = phi i32 [ 0, %entry ], [ %i.next, %loop.body ]101 %cmp = icmp slt i32 %i, %n102 br i1 %cmp, label %loop.body, label %exit103 104loop.body:105 %i.next = add nsw i32 %i, 1106 br label %loop.header, !llvm.loop !1107 108exit:109 ret void110}111 112!1 = !{!1, !2}113!2 = !{!"llvm.loop.unroll.full", i32 0} ; invalid second operand114