llvm-mirror/test/Verifier/module-flags-1.ll
Duncan P. N. Exon Smith 9c5542c040 IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly.  These
are the matching assembly changes for the metadata/value split in
r223802.

  - Only use the `metadata` type when referencing metadata from a call
    intrinsic -- i.e., only when it's used as a `Value`.

  - Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
    when referencing it from call intrinsics.

So, assembly like this:

    define @foo(i32 %v) {
      call void @llvm.foo(metadata !{i32 %v}, metadata !0)
      call void @llvm.foo(metadata !{i32 7}, metadata !0)
      call void @llvm.foo(metadata !1, metadata !0)
      call void @llvm.foo(metadata !3, metadata !0)
      call void @llvm.foo(metadata !{metadata !3}, metadata !0)
      ret void, !bar !2
    }
    !0 = metadata !{metadata !2}
    !1 = metadata !{i32* @global}
    !2 = metadata !{metadata !3}
    !3 = metadata !{}

turns into this:

    define @foo(i32 %v) {
      call void @llvm.foo(metadata i32 %v, metadata !0)
      call void @llvm.foo(metadata i32 7, metadata !0)
      call void @llvm.foo(metadata i32* @global, metadata !0)
      call void @llvm.foo(metadata !3, metadata !0)
      call void @llvm.foo(metadata !{!3}, metadata !0)
      ret void, !bar !2
    }
    !0 = !{!2}
    !1 = !{i32* @global}
    !2 = !{!3}
    !3 = !{}

I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines).  I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.

This is part of PR21532.

llvm-svn: 224257
2014-12-15 19:07:53 +00:00

58 lines
2.3 KiB
LLVM

; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
; Check that module flags are structurally correct.
;
; CHECK: incorrect number of operands in module flag
; CHECK: metadata !0
!0 = !{i32 1}
; CHECK: invalid behavior operand in module flag (expected constant integer)
; CHECK: metadata !"foo"
!1 = !{!"foo", !"foo", i32 42}
; CHECK: invalid behavior operand in module flag (unexpected constant)
; CHECK: i32 999
!2 = !{i32 999, !"foo", i32 43}
; CHECK: invalid ID operand in module flag (expected metadata string)
; CHECK: i32 1
!3 = !{i32 1, i32 1, i32 44}
; CHECK: invalid value for 'require' module flag (expected metadata pair)
; CHECK: i32 45
!4 = !{i32 3, !"bla", i32 45}
; CHECK: invalid value for 'require' module flag (expected metadata pair)
; CHECK: metadata !
!5 = !{i32 3, !"bla", !{i32 46}}
; CHECK: invalid value for 'require' module flag (first value operand should be a string)
; CHECK: i32 47
!6 = !{i32 3, !"bla", !{i32 47, i32 48}}
; Check that module flags only have unique IDs.
;
; CHECK: module flag identifiers must be unique (or of 'require' type)
!7 = !{i32 1, !"foo", i32 49}
!8 = !{i32 2, !"foo", i32 50}
; CHECK-NOT: module flag identifiers must be unique
!9 = !{i32 2, !"bar", i32 51}
!10 = !{i32 3, !"bar", !{!"bar", i32 51}}
; Check that any 'append'-type module flags are valid.
; CHECK: invalid value for 'append'-type module flag (expected a metadata node)
!16 = !{i32 5, !"flag-2", i32 56}
; CHECK: invalid value for 'append'-type module flag (expected a metadata node)
!17 = !{i32 5, !"flag-3", i32 57}
; CHECK-NOT: invalid value for 'append'-type module flag (expected a metadata node)
!18 = !{i32 5, !"flag-4", !{i32 57}}
; Check that any 'require' module flags are valid.
; CHECK: invalid requirement on flag, flag is not present in module
!11 = !{i32 3, !"bar", !{!"no-such-flag", i32 52}}
; CHECK: invalid requirement on flag, flag does not have the required value
!12 = !{i32 1, !"flag-0", i32 53}
!13 = !{i32 3, !"bar", !{!"flag-0", i32 54}}
; CHECK-NOT: invalid requirement on flag, flag is not present in module
; CHECK-NOT: invalid requirement on flag, flag does not have the required value
!14 = !{i32 1, !"flag-1", i32 55}
!15 = !{i32 3, !"bar", !{!"flag-1", i32 55}}
!llvm.module.flags = !{
!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15,
!16, !17, !18 }