llvm-6502/test/Assembler/metadata.ll
Duncan P. N. Exon Smith ae3211466a IR: Add assembly/bitcode support for function metadata attachments
Add serialization support for function metadata attachments (added in
r235783).  The syntax is:

    define @foo() !attach !0 {

Metadata attachments are only allowed on functions with bodies.  Since
they come before the `{`, they're not really part of the body; since
they require a body, they're not really part of the header.  In
`LLParser` I gave them a separate function called from `ParseDefine()`,
`ParseOptionalFunctionMetadata()`.

In bitcode, I'm using the same `METADATA_ATTACHMENT` record used by
instructions.  Instruction metadata attachments are included in a
special "attachment" block at the end of a `Function`.  The attachment
records are laid out like this:

    InstID (KindID MetadataID)+

Note that these records always have an odd number of fields.  The new
code takes advantage of this to recognize function attachments (which
don't need an instruction ID):

    (KindID MetadataID)+

This means we can use the same attachment block already used for
instructions.

This is part of PR23340.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235785 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-24 22:04:41 +00:00

35 lines
816 B
LLVM

; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
; RUN: verify-uselistorder %s
; CHECK: @test
; CHECK: ret void, !bar !1, !foo !0
define void @test() {
add i32 2, 1, !bar !0
add i32 1, 2, !foo !1
call void @llvm.dbg.func.start(metadata !"foo")
extractvalue {{i32, i32}, i32} undef, 0, 1, !foo !0
ret void, !foo !0, !bar !1
}
; CHECK: define void @test2() !foo !2 !baz !3
define void @test2() !foo !2 !baz !3 {
unreachable
}
; CHECK: define void @test3() !bar !3
; CHECK: unreachable, !bar !4
define void @test3() !bar !3 {
unreachable, !bar !4
}
!0 = !MDLocation(line: 662302, column: 26, scope: !1)
!1 = !MDSubprogram(name: "foo")
!2 = distinct !{}
!3 = distinct !{}
!4 = distinct !{}
declare void @llvm.dbg.func.start(metadata) nounwind readnone
!foo = !{ !0 }
!bar = !{ !1 }