mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-31 12:30:06 +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
111 lines
3.3 KiB
LLVM
111 lines
3.3 KiB
LLVM
; RUN: opt < %s -tbaa -basicaa -aa-eval -evaluate-aa-metadata -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s
|
|
|
|
; Generated with "clang -cc1 -disable-llvm-optzns -O1 -emit-llvm"
|
|
; #include <new>
|
|
; struct Foo { long i; };
|
|
; struct Bar { void *p; };
|
|
; long foo(int n) {
|
|
; Foo *f = new Foo;
|
|
; f->i = 1;
|
|
; for (int i=0; i<n; ++i) {
|
|
; Bar *b = new (f) Bar;
|
|
; b->p = 0;
|
|
; f = new (f) Foo;
|
|
; f->i = i;
|
|
; }
|
|
; return f->i;
|
|
; }
|
|
|
|
; Basic AA says MayAlias, TBAA says NoAlias
|
|
; CHECK: MayAlias: i64* %i5, i8** %p
|
|
; CHECK: NoAlias: store i64 %conv, i64* %i5, align 8, !tbaa !6 <-> store i8* null, i8** %p, align 8, !tbaa !9
|
|
|
|
%struct.Foo = type { i64 }
|
|
%struct.Bar = type { i8* }
|
|
|
|
define i64 @_Z3fooi(i32 %n) #0 {
|
|
entry:
|
|
%n.addr = alloca i32, align 4
|
|
%f = alloca %struct.Foo*, align 8
|
|
%i1 = alloca i32, align 4
|
|
%b = alloca %struct.Bar*, align 8
|
|
store i32 %n, i32* %n.addr, align 4, !tbaa !0
|
|
%call = call noalias i8* @_Znwm(i64 8)
|
|
%0 = bitcast i8* %call to %struct.Foo*
|
|
store %struct.Foo* %0, %struct.Foo** %f, align 8, !tbaa !4
|
|
%1 = load %struct.Foo** %f, align 8, !tbaa !4
|
|
%i = getelementptr inbounds %struct.Foo* %1, i32 0, i32 0
|
|
store i64 1, i64* %i, align 8, !tbaa !6
|
|
store i32 0, i32* %i1, align 4, !tbaa !0
|
|
br label %for.cond
|
|
|
|
for.cond:
|
|
%2 = load i32* %i1, align 4, !tbaa !0
|
|
%3 = load i32* %n.addr, align 4, !tbaa !0
|
|
%cmp = icmp slt i32 %2, %3
|
|
br i1 %cmp, label %for.body, label %for.end
|
|
|
|
for.body:
|
|
%4 = load %struct.Foo** %f, align 8, !tbaa !4
|
|
%5 = bitcast %struct.Foo* %4 to i8*
|
|
%new.isnull = icmp eq i8* %5, null
|
|
br i1 %new.isnull, label %new.cont, label %new.notnull
|
|
|
|
new.notnull:
|
|
%6 = bitcast i8* %5 to %struct.Bar*
|
|
br label %new.cont
|
|
|
|
new.cont:
|
|
%7 = phi %struct.Bar* [ %6, %new.notnull ], [ null, %for.body ]
|
|
store %struct.Bar* %7, %struct.Bar** %b, align 8, !tbaa !4
|
|
%8 = load %struct.Bar** %b, align 8, !tbaa !4
|
|
%p = getelementptr inbounds %struct.Bar* %8, i32 0, i32 0
|
|
store i8* null, i8** %p, align 8, !tbaa !9
|
|
%9 = load %struct.Foo** %f, align 8, !tbaa !4
|
|
%10 = bitcast %struct.Foo* %9 to i8*
|
|
%new.isnull2 = icmp eq i8* %10, null
|
|
br i1 %new.isnull2, label %new.cont4, label %new.notnull3
|
|
|
|
new.notnull3:
|
|
%11 = bitcast i8* %10 to %struct.Foo*
|
|
br label %new.cont4
|
|
|
|
new.cont4:
|
|
%12 = phi %struct.Foo* [ %11, %new.notnull3 ], [ null, %new.cont ]
|
|
store %struct.Foo* %12, %struct.Foo** %f, align 8, !tbaa !4
|
|
%13 = load i32* %i1, align 4, !tbaa !0
|
|
%conv = sext i32 %13 to i64
|
|
%14 = load %struct.Foo** %f, align 8, !tbaa !4
|
|
%i5 = getelementptr inbounds %struct.Foo* %14, i32 0, i32 0
|
|
store i64 %conv, i64* %i5, align 8, !tbaa !6
|
|
br label %for.inc
|
|
|
|
for.inc:
|
|
%15 = load i32* %i1, align 4, !tbaa !0
|
|
%inc = add nsw i32 %15, 1
|
|
store i32 %inc, i32* %i1, align 4, !tbaa !0
|
|
br label %for.cond
|
|
|
|
for.end:
|
|
%16 = load %struct.Foo** %f, align 8, !tbaa !4
|
|
%i6 = getelementptr inbounds %struct.Foo* %16, i32 0, i32 0
|
|
%17 = load i64* %i6, align 8, !tbaa !6
|
|
ret i64 %17
|
|
}
|
|
|
|
declare noalias i8* @_Znwm(i64)
|
|
|
|
attributes #0 = { nounwind }
|
|
|
|
!0 = !{!1, !1, i64 0}
|
|
!1 = !{!"int", !2, i64 0}
|
|
!2 = !{!"omnipotent char", !3, i64 0}
|
|
!3 = !{!"Simple C/C++ TBAA"}
|
|
!4 = !{!5, !5, i64 0}
|
|
!5 = !{!"any pointer", !2, i64 0}
|
|
!6 = !{!7, !8, i64 0}
|
|
!7 = !{!"_ZTS3Foo", !8, i64 0}
|
|
!8 = !{!"long", !2, i64 0}
|
|
!9 = !{!10, !5, i64 0}
|
|
!10 = !{!"_ZTS3Bar", !5, i64 0}
|