xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/no-opt-volatile-memcpy.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple=x86_64-apple-darwin  -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc // rdar://11861085
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc struct s {
5*f4a2713aSLionel Sambuc   char filler [128];
6*f4a2713aSLionel Sambuc   volatile int x;
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc struct s gs;
10*f4a2713aSLionel Sambuc 
foo(void)11*f4a2713aSLionel Sambuc void foo (void) {
12*f4a2713aSLionel Sambuc   struct s ls;
13*f4a2713aSLionel Sambuc   ls = ls;
14*f4a2713aSLionel Sambuc   gs = gs;
15*f4a2713aSLionel Sambuc   ls = gs;
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @foo()
18*f4a2713aSLionel Sambuc // CHECK: %[[LS:.*]] = alloca %struct.s, align 4
19*f4a2713aSLionel Sambuc // CHECK-NEXT: %[[ZERO:.*]] = bitcast %struct.s* %[[LS]] to i8*
20*f4a2713aSLionel Sambuc // CHECK-NEXT: %[[ONE:.*]] = bitcast %struct.s* %[[LS]] to i8*
21*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* %[[ZERO]], i8* %[[ONE]], i64 132, i32 4, i1 true)
22*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
23*f4a2713aSLionel Sambuc // CHECK-NEXT: %[[TWO:.*]] = bitcast %struct.s* %[[LS]] to i8*
24*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* %[[TWO]], i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc struct s1 {
28*f4a2713aSLionel Sambuc   struct s y;
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc struct s1 s;
32*f4a2713aSLionel Sambuc 
fee(void)33*f4a2713aSLionel Sambuc void fee (void) {
34*f4a2713aSLionel Sambuc   s = s;
35*f4a2713aSLionel Sambuc   s.y = gs;
36*f4a2713aSLionel Sambuc }
37*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @fee()
38*f4a2713aSLionel Sambuc // CHECK: call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.s1* @s, i32 0, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.s1* @s, i32 0, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
39*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.s1* @s, i32 0, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
40*f4a2713aSLionel Sambuc 
41