mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-21 02:29:22 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
87 lines
2.6 KiB
LLVM
87 lines
2.6 KiB
LLVM
; RUN: opt < %s -tbaa -basicaa -functionattrs -S | FileCheck %s
|
|
|
|
; FunctionAttrs should make use of TBAA.
|
|
|
|
; Add the readnone attribute, since the only access is a store which TBAA
|
|
; says is to constant memory.
|
|
;
|
|
; It's unusual to see a store to constant memory, but it isn't necessarily
|
|
; invalid, as it's possible that this only happens after optimization on a
|
|
; code path which isn't ever executed.
|
|
|
|
; CHECK: define void @test0_yes(i32* nocapture %p) #0 {
|
|
define void @test0_yes(i32* %p) nounwind {
|
|
store i32 0, i32* %p, !tbaa !1
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test0_no(i32* nocapture %p) #1 {
|
|
define void @test0_no(i32* %p) nounwind {
|
|
store i32 0, i32* %p, !tbaa !2
|
|
ret void
|
|
}
|
|
|
|
; Add the readonly attribute, since there's just a call to a function which
|
|
; TBAA says doesn't modify any memory.
|
|
|
|
; CHECK: define void @test1_yes(i32* nocapture %p) #2 {
|
|
define void @test1_yes(i32* %p) nounwind {
|
|
call void @callee(i32* %p), !tbaa !1
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test1_no(i32* %p) #1 {
|
|
define void @test1_no(i32* %p) nounwind {
|
|
call void @callee(i32* %p), !tbaa !2
|
|
ret void
|
|
}
|
|
|
|
; Add the readonly attribute, as above, but this time BasicAA will say
|
|
; that the function accesses memory through its arguments, which TBAA
|
|
; still says that the function doesn't write to memory.
|
|
;
|
|
; This is unusual, since the function is memcpy, but as above, this
|
|
; isn't necessarily invalid.
|
|
|
|
; CHECK: define void @test2_yes(i8* nocapture %p, i8* nocapture %q, i64 %n) #0 {
|
|
define void @test2_yes(i8* %p, i8* %q, i64 %n) nounwind {
|
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 %n, i32 1, i1 false), !tbaa !1
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define void @test2_no(i8* nocapture %p, i8* nocapture readonly %q, i64 %n) #1 {
|
|
define void @test2_no(i8* %p, i8* %q, i64 %n) nounwind {
|
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 %n, i32 1, i1 false), !tbaa !2
|
|
ret void
|
|
}
|
|
|
|
; Similar to the others, va_arg only accesses memory through its operand.
|
|
|
|
; CHECK: define i32 @test3_yes(i8* nocapture %p) #0 {
|
|
define i32 @test3_yes(i8* %p) nounwind {
|
|
%t = va_arg i8* %p, i32, !tbaa !1
|
|
ret i32 %t
|
|
}
|
|
|
|
; CHECK: define i32 @test3_no(i8* nocapture %p) #1 {
|
|
define i32 @test3_no(i8* %p) nounwind {
|
|
%t = va_arg i8* %p, i32, !tbaa !2
|
|
ret i32 %t
|
|
}
|
|
|
|
declare void @callee(i32* %p) nounwind
|
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1) nounwind
|
|
|
|
; CHECK: attributes #0 = { nounwind readnone }
|
|
; CHECK: attributes #1 = { nounwind }
|
|
; CHECK: attributes #2 = { nounwind readonly }
|
|
|
|
; Root note.
|
|
!0 = !{ }
|
|
|
|
; Invariant memory.
|
|
!1 = !{!3, !3, i64 0, i1 1 }
|
|
; Not invariant memory.
|
|
!2 = !{!3, !3, i64 0, i1 0 }
|
|
!3 = !{ !"foo", !0 }
|