; Check that one of the memcpy's are removed.
;; FIXME: PR 8643 We should be able to eliminate the last memcpy here.
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: call void @ccoshl
; CHECK: call void @llvm.memcpy
; CHECK-NOT: llvm.memcpy
; CHECK: ret void
}
-declare void @ccoshl(%0* sret , x86_fp80, x86_fp80) nounwind
+declare void @ccoshl(%0* nocapture sret, x86_fp80, x86_fp80) nounwind
; The intermediate alloca and one of the memcpy's should be eliminated, the
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %Q, i8* %R, i32 32, i32 16, i1 false)
ret void
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: call void @llvm.memmove{{.*}}(i8* %Q, i8* %P
; CHECK-NEXT: ret void
}
%agg.result2 = bitcast %0* %agg.result to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %agg.result2, i8* %x.01, i32 32, i32 16, i1 false)
ret void
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: %agg.result1 = bitcast
; CHECK-NEXT: call void @llvm.memcpy
; CHECK-NEXT: ret void
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* %P, i64 8, i32 4, i1 false)
call void @test4a(i8* align 1 byval %a)
ret void
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: call void @test4a(
}
declare void @test4a(i8* align 1 byval)
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
+declare void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* nocapture, i8 addrspace(1)* nocapture, i64, i32, i1) nounwind
%struct.S = type { i128, [4 x i8]}
%y = alloca %struct.S, align 16
%tmp = bitcast %struct.S* %y to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast (%struct.S* @sS to i8*), i64 32, i32 16, i1 false)
- %a = getelementptr %struct.S* %y, i64 0, i32 1, i64 0
+ %a = getelementptr %struct.S, %struct.S* %y, i64 0, i32 1, i64 0
store i8 4, i8* %a
call void @test5a(%struct.S* align 16 byval %y)
ret i32 0
- ; CHECK: @test5(
+ ; CHECK-LABEL: @test5(
; CHECK: store i8 4
; CHECK: call void @test5a(%struct.S* byval align 16 %y)
}
define void @test6(i8 *%P) {
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %P, i64 8, i32 4, i1 false)
ret void
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: ret void
}
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* %tmp1, i64 48, i32 4, i1 false)
%call = call i32 @g(%struct.p* align 8 byval %agg.tmp) nounwind
ret i32 %call
-; CHECK: @test7
-; CHECK: call i32 @g(%struct.p* align 8 byval %q) nounwind
+; CHECK-LABEL: @test7(
+; CHECK: call i32 @g(%struct.p* byval align 8 %q) [[NUW:#[0-9]+]]
}
declare i32 @g(%struct.p* align 8 byval)
; CHECK: test8
; CHECK-NOT: memcpy
%A = tail call i8* @malloc(i32 10)
- %B = getelementptr inbounds i8* %A, i64 2
- tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %B, i8* getelementptr inbounds ([7 x i8]* @test8.str, i64 0, i64 0), i32 7, i32 1, i1 false)
+ %B = getelementptr inbounds i8, i8* %A, i64 2
+ tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %B, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @test8.str, i64 0, i64 0), i32 7, i32 1, i1 false)
%C = tail call i8* @malloc(i32 10)
- %D = getelementptr inbounds i8* %C, i64 2
+ %D = getelementptr inbounds i8, i8* %C, i64 2
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %D, i8* %B, i32 7, i32 1, i1 false)
ret void
; CHECK: ret void
; rdar://11341081
%struct.big = type { [50 x i32] }
+define void @test9_addrspacecast() nounwind ssp uwtable {
+entry:
+; CHECK-LABEL: @test9_addrspacecast(
+; CHECK: f1
+; CHECK-NOT: memcpy
+; CHECK: f2
+ %b = alloca %struct.big, align 4
+ %tmp = alloca %struct.big, align 4
+ call void @f1(%struct.big* sret %tmp)
+ %0 = addrspacecast %struct.big* %b to i8 addrspace(1)*
+ %1 = addrspacecast %struct.big* %tmp to i8 addrspace(1)*
+ call void @llvm.memcpy.p1i8.p1i8.i64(i8 addrspace(1)* %0, i8 addrspace(1)* %1, i64 200, i32 4, i1 false)
+ call void @f2(%struct.big* %b)
+ ret void
+}
+
define void @test9() nounwind ssp uwtable {
entry:
; CHECK: test9
ret void
}
-declare void @f1(%struct.big* sret)
+; rdar://14073661.
+; Test10 triggered assertion when the compiler try to get the size of the
+; opaque type of *x, where the x is the formal argument with attribute 'sret'.
+
+%opaque = type opaque
+declare void @foo(i32* noalias nocapture)
+
+define void @test10(%opaque* noalias nocapture sret %x, i32 %y) {
+ %a = alloca i32, align 4
+ store i32 %y, i32* %a
+ call void @foo(i32* noalias nocapture %a)
+ %c = load i32, i32* %a
+ %d = bitcast %opaque* %x to i32*
+ store i32 %c, i32* %d
+ ret void
+}
+
+declare void @f1(%struct.big* nocapture sret)
declare void @f2(%struct.big*)
+
+; CHECK: attributes [[NUW]] = { nounwind }
+; CHECK: attributes #1 = { argmemonly nounwind }
+; CHECK: attributes #2 = { nounwind ssp }
+; CHECK: attributes #3 = { nounwind ssp uwtable }