summaryrefslogtreecommitdiffstats
path: root/test/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/GVN/2010-05-08-OneBit.ll63
-rw-r--r--test/Transforms/Inline/2010-05-12-ValueMap.ll28
-rw-r--r--test/Transforms/InstCombine/cast.ll33
-rw-r--r--test/Transforms/Mem2Reg/ConvertDebugInfo.ll61
-rw-r--r--test/Transforms/SimplifyCFG/trapping-load-unreachable.ll20
-rw-r--r--test/Transforms/SimplifyLibCalls/memcmp.ll14
-rw-r--r--test/Transforms/Sink/basic.ll22
-rw-r--r--test/Transforms/Sink/dg.exp3
8 files changed, 216 insertions, 28 deletions
diff --git a/test/Transforms/GVN/2010-05-08-OneBit.ll b/test/Transforms/GVN/2010-05-08-OneBit.ll
new file mode 100644
index 0000000..1809cf0
--- /dev/null
+++ b/test/Transforms/GVN/2010-05-08-OneBit.ll
@@ -0,0 +1,63 @@
+; RUN: opt < %s -gvn
+; PR7052
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @main(i32 %argc, i8** nocapture %argv) {
+entry:
+ %0 = getelementptr inbounds i8* undef, i64 5 ; <i8*> [#uses=1]
+ %1 = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
+ store i32 undef, i32* %1, align 1
+ br i1 undef, label %k121.i.i, label %l117.i.i
+
+l117.i.i: ; preds = %entry
+ invoke fastcc void @foo()
+ to label %.noexc5 unwind label %landing_pad
+
+.noexc5: ; preds = %l117.i.i
+ unreachable
+
+k121.i.i: ; preds = %entry
+ br i1 undef, label %l129.i.i, label %k133.i.i
+
+l129.i.i: ; preds = %k121.i.i
+ invoke fastcc void @foo()
+ to label %.noexc7 unwind label %landing_pad
+
+.noexc7: ; preds = %l129.i.i
+ unreachable
+
+k133.i.i: ; preds = %k121.i.i
+ %2 = getelementptr i8* undef, i64 5 ; <i8*> [#uses=1]
+ %3 = bitcast i8* %2 to i1* ; <i1*> [#uses=1]
+ %4 = load i1* %3 ; <i1> [#uses=1]
+ br i1 %4, label %k151.i.i, label %l147.i.i
+
+l147.i.i: ; preds = %k133.i.i
+ invoke fastcc void @foo()
+ to label %.noexc10 unwind label %landing_pad
+
+.noexc10: ; preds = %l147.i.i
+ unreachable
+
+k151.i.i: ; preds = %k133.i.i
+ ret i32 0
+
+landing_pad: ; preds = %l147.i.i, %l129.i.i, %l117.i.i
+ switch i32 undef, label %fin [
+ i32 1, label %catch1
+ i32 2, label %catch
+ ]
+
+fin: ; preds = %landing_pad
+ unreachable
+
+catch: ; preds = %landing_pad
+ ret i32 1
+
+catch1: ; preds = %landing_pad
+ ret i32 2
+}
+
+declare fastcc void @foo()
diff --git a/test/Transforms/Inline/2010-05-12-ValueMap.ll b/test/Transforms/Inline/2010-05-12-ValueMap.ll
new file mode 100644
index 0000000..f9cc13f
--- /dev/null
+++ b/test/Transforms/Inline/2010-05-12-ValueMap.ll
@@ -0,0 +1,28 @@
+; RUN: opt %s -inline -mergefunc -disable-output
+
+; This tests for a bug where the inliner kept the functions in a ValueMap after
+; it had completed and a ModulePass started to run. LLVM would crash deleting
+; a function that was still a key in the ValueMap.
+
+define internal fastcc void @list_Cdr1918() nounwind inlinehint {
+ unreachable
+}
+
+define internal fastcc void @list_PairSecond1927() nounwind inlinehint {
+ call fastcc void @list_Cdr1918() nounwind inlinehint
+ unreachable
+}
+
+define internal fastcc void @list_Cdr3164() nounwind inlinehint {
+ unreachable
+}
+
+define internal fastcc void @list_Nconc3167() nounwind inlinehint {
+ call fastcc void @list_Cdr3164() nounwind inlinehint
+ unreachable
+}
+
+define void @term_Equal() nounwind {
+ call fastcc void @list_Cdr3164() nounwind inlinehint
+ unreachable
+}
diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll
index 878da68..77fccdf 100644
--- a/test/Transforms/InstCombine/cast.ll
+++ b/test/Transforms/InstCombine/cast.ll
@@ -605,3 +605,36 @@ define i64 @test59(i8 %A, i8 %B) nounwind {
; CHECK-NOT: i32
; CHECK: ret i64 %H
}
+
+define <3 x i32> @test60(<4 x i32> %call4) nounwind {
+ %tmp11 = bitcast <4 x i32> %call4 to i128
+ %tmp9 = trunc i128 %tmp11 to i96
+ %tmp10 = bitcast i96 %tmp9 to <3 x i32>
+ ret <3 x i32> %tmp10
+
+; CHECK: @test60
+; CHECK-NEXT: shufflevector
+; CHECK-NEXT: ret
+}
+
+define <4 x i32> @test61(<3 x i32> %call4) nounwind {
+ %tmp11 = bitcast <3 x i32> %call4 to i96
+ %tmp9 = zext i96 %tmp11 to i128
+ %tmp10 = bitcast i128 %tmp9 to <4 x i32>
+ ret <4 x i32> %tmp10
+; CHECK: @test61
+; CHECK-NEXT: shufflevector
+; CHECK-NEXT: ret
+}
+
+define <4 x i32> @test62(<3 x float> %call4) nounwind {
+ %tmp11 = bitcast <3 x float> %call4 to i96
+ %tmp9 = zext i96 %tmp11 to i128
+ %tmp10 = bitcast i128 %tmp9 to <4 x i32>
+ ret <4 x i32> %tmp10
+; CHECK: @test62
+; CHECK-NEXT: bitcast
+; CHECK-NEXT: shufflevector
+; CHECK-NEXT: ret
+}
+
diff --git a/test/Transforms/Mem2Reg/ConvertDebugInfo.ll b/test/Transforms/Mem2Reg/ConvertDebugInfo.ll
index a013a1d..37d27d4 100644
--- a/test/Transforms/Mem2Reg/ConvertDebugInfo.ll
+++ b/test/Transforms/Mem2Reg/ConvertDebugInfo.ll
@@ -1,32 +1,45 @@
; RUN: opt < %s -mem2reg -S | FileCheck %s
-target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
-
-define double @testfunc(i32 %i, double %j) {
- %I = alloca i32 ; <i32*> [#uses=4]
- call void @llvm.dbg.declare(metadata !{i32* %I}, metadata !0)
- %J = alloca double ; <double*> [#uses=2]
- call void @llvm.dbg.declare(metadata !{double* %J}, metadata !1)
+define double @testfunc(i32 %i, double %j) nounwind ssp {
+entry:
+ %i_addr = alloca i32 ; <i32*> [#uses=2]
+ %j_addr = alloca double ; <double*> [#uses=2]
+ %retval = alloca double ; <double*> [#uses=2]
+ %0 = alloca double ; <double*> [#uses=2]
+ %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
+ call void @llvm.dbg.declare(metadata !{i32* %i_addr}, metadata !0), !dbg !8
; CHECK: call void @llvm.dbg.value(metadata !{i32 %i}, i64 0, metadata !0)
- store i32 %i, i32* %I
-; CHECK: call void @llvm.dbg.value(metadata !{double %j}, i64 0, metadata !1), !dbg !3
- store double %j, double* %J, !dbg !3
- %t1 = load i32* %I ; <i32> [#uses=1]
- %t2 = add i32 %t1, 1 ; <i32> [#uses=1]
- store i32 %t2, i32* %I
- %t3 = load i32* %I ; <i32> [#uses=1]
- %t4 = sitofp i32 %t3 to double ; <double> [#uses=1]
- %t5 = load double* %J ; <double> [#uses=1]
- %t6 = fmul double %t4, %t5 ; <double> [#uses=1]
- ret double %t6
+; CHECK: call void @llvm.dbg.value(metadata !{double %j}, i64 0, metadata !8)
+ store i32 %i, i32* %i_addr
+ call void @llvm.dbg.declare(metadata !{double* %j_addr}, metadata !9), !dbg !8
+ store double %j, double* %j_addr
+ %1 = load i32* %i_addr, align 4, !dbg !10 ; <i32> [#uses=1]
+ %2 = add nsw i32 %1, 1, !dbg !10 ; <i32> [#uses=1]
+ %3 = sitofp i32 %2 to double, !dbg !10 ; <double> [#uses=1]
+ %4 = load double* %j_addr, align 8, !dbg !10 ; <double> [#uses=1]
+ %5 = fadd double %3, %4, !dbg !10 ; <double> [#uses=1]
+ store double %5, double* %0, align 8, !dbg !10
+ %6 = load double* %0, align 8, !dbg !10 ; <double> [#uses=1]
+ store double %6, double* %retval, align 8, !dbg !10
+ br label %return, !dbg !10
+
+return: ; preds = %entry
+ %retval1 = load double* %retval, !dbg !10 ; <double> [#uses=1]
+ ret double %retval1, !dbg !10
}
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
-!bar = !{!0}
-!foo = !{!2}
+!0 = metadata !{i32 524545, metadata !1, metadata !"i", metadata !2, i32 2, metadata !7} ; [ DW_TAG_arg_variable ]
+!1 = metadata !{i32 524334, i32 0, metadata !2, metadata !"testfunc", metadata !"testfunc", metadata !"testfunc", metadata !2, i32 2, metadata !4, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false} ; [ DW_TAG_subprogram ]
+!2 = metadata !{i32 524329, metadata !"testfunc.c", metadata !"/tmp", metadata !3} ; [ DW_TAG_file_type ]
+!3 = metadata !{i32 524305, i32 0, i32 1, metadata !"testfunc.c", metadata !"/tmp", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
+!4 = metadata !{i32 524309, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !5, i32 0, null} ; [ DW_TAG_subroutine_type ]
+!5 = metadata !{metadata !6, metadata !7, metadata !6}
+!6 = metadata !{i32 524324, metadata !2, metadata !"double", metadata !2, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ]
+!7 = metadata !{i32 524324, metadata !2, metadata !"int", metadata !2, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
+!8 = metadata !{i32 2, i32 0, metadata !1, null}
+!9 = metadata !{i32 524545, metadata !1, metadata !"j", metadata !2, i32 2, metadata !6} ; [ DW_TAG_arg_variable ]
+!10 = metadata !{i32 3, i32 0, metadata !11, null}
+!11 = metadata !{i32 524299, metadata !1, i32 2, i32 0} ; [ DW_TAG_lexical_block ]
-!0 = metadata !{i32 459008, metadata !1, metadata !"foo", metadata !2, i32 5, metadata !"foo"} ; [ DW_TAG_auto_variable ]
-!1 = metadata !{i32 459008, metadata !1, metadata !"foo", metadata !0, i32 5, metadata !1} ; [ DW_TAG_auto_variable ]
-!2 = metadata !{i32 458804, i32 0, metadata !2, metadata !"foo", metadata !"bar", metadata !"bar", metadata !2, i32 3, metadata !0, i1 false, i1 true} ; [ DW_TAG_variable ]
-!3 = metadata !{i32 4, i32 0, metadata !0, null}
diff --git a/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
index 0c9cc8b..6956faa 100644
--- a/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
+++ b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
@@ -1,19 +1,33 @@
-; RUN: opt < %s -simplifycfg -S | grep {volatile load}
+; RUN: opt < %s -simplifycfg -S | FileCheck %s
; PR2967
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32"
target triple = "i386-pc-linux-gnu"
-define void @foo(i32 %x) nounwind {
+define void @test1(i32 %x) nounwind {
entry:
%0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
br i1 %0, label %bb, label %return
bb: ; preds = %entry
- %1 = volatile load i32* null ; <i32> [#uses=0]
+ %1 = volatile load i32* null
unreachable
+
br label %return
return: ; preds = %entry
ret void
+; CHECK: @test1
+; CHECK: volatile load
+}
+
+; rdar://7958343
+define void @test2() nounwind {
+entry:
+ store i32 4,i32* null
+ ret void
+
+; CHECK: @test2
+; CHECK: call void @llvm.trap
+; CHECK: unreachable
}
diff --git a/test/Transforms/SimplifyLibCalls/memcmp.ll b/test/Transforms/SimplifyLibCalls/memcmp.ll
index 640d232..ee99501 100644
--- a/test/Transforms/SimplifyLibCalls/memcmp.ll
+++ b/test/Transforms/SimplifyLibCalls/memcmp.ll
@@ -1,5 +1,5 @@
; Test that the memcmpOptimizer works correctly
-; RUN: opt < %s -simplify-libcalls -S | not grep {call.*memcmp}
+; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
@h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=0]
@hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=0]
@@ -9,14 +9,26 @@ declare i32 @memcmp(i8*, i8*, i32)
define void @test(i8* %P, i8* %Q, i32 %N, i32* %IP, i1* %BP) {
%A = call i32 @memcmp( i8* %P, i8* %P, i32 %N ) ; <i32> [#uses=1]
+; CHECK-NOT: call {{.*}} memcmp
+; CHECK: volatile store
volatile store i32 %A, i32* %IP
%B = call i32 @memcmp( i8* %P, i8* %Q, i32 0 ) ; <i32> [#uses=1]
+; CHECK-NOT: call {{.*}} memcmp
+; CHECK: volatile store
volatile store i32 %B, i32* %IP
%C = call i32 @memcmp( i8* %P, i8* %Q, i32 1 ) ; <i32> [#uses=1]
+; CHECK: load
+; CHECK: zext
+; CHECK: load
+; CHECK: zext
+; CHECK: sub
+; CHECK: volatile store
volatile store i32 %C, i32* %IP
%F = call i32 @memcmp(i8* getelementptr ([4 x i8]* @hel, i32 0, i32 0),
i8* getelementptr ([8 x i8]* @hello_u, i32 0, i32 0),
i32 3)
+; CHECK-NOT: call {{.*}} memcmp
+; CHECK: volatile store
volatile store i32 %F, i32* %IP
ret void
}
diff --git a/test/Transforms/Sink/basic.ll b/test/Transforms/Sink/basic.ll
new file mode 100644
index 0000000..beb9481
--- /dev/null
+++ b/test/Transforms/Sink/basic.ll
@@ -0,0 +1,22 @@
+; RUN: opt < %s -sink -S | FileCheck %s
+
+@A = external global i32
+@B = external global i32
+
+; Sink should sink the load past the store (which doesn't overlap) into
+; the block that uses it.
+
+; CHECK: @foo
+; CHECK: true:
+; CHECK-NEXT: %l = load i32* @A
+; CHECK-NEXT: ret i32 %l
+
+define i32 @foo(i1 %z) {
+ %l = load i32* @A
+ store i32 0, i32* @B
+ br i1 %z, label %true, label %false
+true:
+ ret i32 %l
+false:
+ ret i32 0
+}
diff --git a/test/Transforms/Sink/dg.exp b/test/Transforms/Sink/dg.exp
new file mode 100644
index 0000000..f200589
--- /dev/null
+++ b/test/Transforms/Sink/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
OpenPOWER on IntegriCloud