2009-12-22 14:04:26 +08:00
|
|
|
; Test CFG simplify removal of branch instructions.
|
2002-05-06 10:37:38 +08:00
|
|
|
;
|
2009-12-22 14:04:26 +08:00
|
|
|
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
2002-05-06 10:37:38 +08:00
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test1() {
|
2010-12-13 13:10:30 +08:00
|
|
|
br label %1
|
2008-03-18 11:45:45 +08:00
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2009-12-22 14:04:26 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2002-05-06 10:37:38 +08:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test2() {
|
|
|
|
ret void
|
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2009-12-22 14:04:26 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
; CHECK-NEXT: }
|
2002-05-06 10:37:38 +08:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test3(i1 %T) {
|
2010-12-13 13:10:30 +08:00
|
|
|
br i1 %T, label %1, label %1
|
2008-03-18 11:45:45 +08:00
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
2009-12-22 14:04:26 +08:00
|
|
|
; CHECK-NEXT: ret void
|
2002-05-06 10:37:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-22 14:07:30 +08:00
|
|
|
; PR5795
|
|
|
|
define void @test5(i32 %A) {
|
|
|
|
switch i32 %A, label %return [
|
2010-12-13 13:10:30 +08:00
|
|
|
i32 2, label %1
|
|
|
|
i32 10, label %2
|
2009-12-22 14:07:30 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
ret void
|
|
|
|
|
|
|
|
ret void
|
|
|
|
|
|
|
|
return: ; preds = %entry
|
|
|
|
ret void
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
2009-12-22 14:07:30 +08:00
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
}
|
2014-01-29 00:56:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
; PR14893
|
|
|
|
define i8 @test6f() {
|
|
|
|
; CHECK-LABEL: @test6f
|
|
|
|
; CHECK: alloca i8, align 1
|
|
|
|
; CHECK-NEXT: call i8 @test6g
|
|
|
|
; CHECK-NEXT: icmp eq i8 %tmp, 0
|
|
|
|
; CHECK-NEXT: load i8* %r, align 1{{$}}
|
|
|
|
|
|
|
|
bb0:
|
|
|
|
%r = alloca i8, align 1
|
|
|
|
%tmp = call i8 @test6g(i8* %r)
|
|
|
|
%tmp1 = icmp eq i8 %tmp, 0
|
|
|
|
br i1 %tmp1, label %bb2, label %bb1
|
|
|
|
bb1:
|
|
|
|
%tmp3 = load i8* %r, align 1, !range !2, !tbaa !1
|
|
|
|
%tmp4 = icmp eq i8 %tmp3, 1
|
|
|
|
br i1 %tmp4, label %bb2, label %bb3
|
|
|
|
bb2:
|
|
|
|
br label %bb3
|
|
|
|
bb3:
|
|
|
|
%tmp6 = phi i8 [ 0, %bb2 ], [ 1, %bb1 ]
|
|
|
|
ret i8 %tmp6
|
|
|
|
}
|
|
|
|
declare i8 @test6g(i8*)
|
|
|
|
|
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-16 03:07:53 +08:00
|
|
|
!0 = !{!1, !1, i64 0}
|
|
|
|
!1 = !{!"foo"}
|
|
|
|
!2 = !{i8 0, i8 2}
|