Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -O0 -triple=x86_64-apple-darwin  -emit-llvm -o - %s | FileCheck %s
      2 // rdar://11861085
      3 
      4 struct s {
      5   char filler [128];
      6   volatile int x;
      7 };
      8 
      9 struct s gs;
     10 
     11 void foo (void) {
     12   struct s ls;
     13   ls = ls;
     14   gs = gs;
     15   ls = gs;
     16 }
     17 // CHECK: define void @_Z3foov()
     18 // CHECK: %[[LS:.*]] = alloca %struct.s, align 4
     19 // CHECK-NEXT: %[[ZERO:.*]] = bitcast %struct.s* %[[LS]] to i8*
     20 // CHECK-NEXT:  %[[ONE:.*]] = bitcast %struct.s* %[[LS]] to i8*
     21 // CHECK-NEXT:  call void @llvm.memcpy.{{.*}}(i8* %[[ZERO]], i8* %[[ONE]], i64 132, i32 4, i1 true)
     22 // 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 // CHECK-NEXT:  %[[TWO:.*]] = bitcast %struct.s* %[[LS]] to i8*
     24 // 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 
     26 
     27 struct s1 {
     28   struct s y;
     29 };
     30 
     31 struct s1 s;
     32 
     33 void fee (void) {
     34   s = s;
     35   s.y = gs;
     36 }
     37 // CHECK: define void @_Z3feev()
     38 // 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 // 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 
     41 struct d : s1 {
     42 };
     43 
     44 d gd;
     45 
     46 void gorf(void) {
     47   gd = gd;
     48 }
     49 // CHECK: define void @_Z4gorfv()
     50 // CHECK:   call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.d* @gd, i32 0, i32 0, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.d* @gd, i32 0, i32 0, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
     51