1 ; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
3 ; Check that module flags are structurally correct.
5 ; CHECK: incorrect number of operands in module flag
8 ; CHECK: invalid behavior operand in module flag (expected constant integer)
10 !1 = !{!"foo", !"foo", i32 42}
11 ; CHECK: invalid behavior operand in module flag (unexpected constant)
13 !2 = !{i32 999, !"foo", i32 43}
14 ; CHECK: invalid ID operand in module flag (expected metadata string)
16 !3 = !{i32 1, i32 1, i32 44}
17 ; CHECK: invalid value for 'require' module flag (expected metadata pair)
19 !4 = !{i32 3, !"bla", i32 45}
20 ; CHECK: invalid value for 'require' module flag (expected metadata pair)
22 !5 = !{i32 3, !"bla", !{i32 46}}
23 ; CHECK: invalid value for 'require' module flag (first value operand should be a string)
25 !6 = !{i32 3, !"bla", !{i32 47, i32 48}}
27 ; Check that module flags only have unique IDs.
29 ; CHECK: module flag identifiers must be unique (or of 'require' type)
30 !7 = !{i32 1, !"foo", i32 49}
31 !8 = !{i32 2, !"foo", i32 50}
32 ; CHECK-NOT: module flag identifiers must be unique
33 !9 = !{i32 2, !"bar", i32 51}
34 !10 = !{i32 3, !"bar", !{!"bar", i32 51}}
36 ; Check that any 'append'-type module flags are valid.
37 ; CHECK: invalid value for 'append'-type module flag (expected a metadata node)
38 !16 = !{i32 5, !"flag-2", i32 56}
39 ; CHECK: invalid value for 'append'-type module flag (expected a metadata node)
40 !17 = !{i32 5, !"flag-3", i32 57}
41 ; CHECK-NOT: invalid value for 'append'-type module flag (expected a metadata node)
42 !18 = !{i32 5, !"flag-4", !{i32 57}}
44 ; Check that any 'max' module flags are valid.
45 ; CHECK: invalid value for 'max' module flag (expected constant integer)
46 !19 = !{i32 7, !"max", !"max"}
48 ; Check that any 'min' module flags are valid.
49 ; CHECK: invalid value for 'min' module flag (expected constant non-negative integer)
50 !20 = !{i32 8, !"min", !"min"}
51 ; CHECK: invalid value for 'min' module flag (expected constant non-negative integer)
52 !21 = !{i32 8, !"min", i32 -1}
54 ; Check that any 'require' module flags are valid.
55 ; CHECK: invalid requirement on flag, flag is not present in module
56 !11 = !{i32 3, !"bar", !{!"no-such-flag", i32 52}}
57 ; CHECK: invalid requirement on flag, flag does not have the required value
58 !12 = !{i32 1, !"flag-0", i32 53}
59 !13 = !{i32 3, !"bar", !{!"flag-0", i32 54}}
60 ; CHECK-NOT: invalid requirement on flag, flag is not present in module
61 ; CHECK-NOT: invalid requirement on flag, flag does not have the required value
62 !14 = !{i32 1, !"flag-1", i32 55}
63 !15 = !{i32 3, !"bar", !{!"flag-1", i32 55}}
65 !llvm.module.flags = !{
66 !0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15,
67 !16, !17, !18, !19, !20, !21 }