brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · fdfc006 Raw
92 lines · c
1// RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s2 3struct X { int x[6]; };4struct Y { char x[13]; struct X y; } __attribute((packed));5struct Y g;6void f(struct X);7struct X foo(void);8 9struct X test1(void) {10  // CHECK: @test111  // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}}, ptr align 1 getelementptr inbounds nuw (%struct.Y, ptr @g, i32 0, i32 1), i64 24, i1 false)12  return g.y;13}14struct X test2(void) {15  // CHECK: @test216  // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}}, ptr align 1 getelementptr inbounds nuw (%struct.Y, ptr @g, i32 0, i32 1), i64 24, i1 false)17  struct X a = g.y;18  return a;19}20 21void test3(struct X a) {22  // CHECK: @test323  // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 getelementptr inbounds nuw (%struct.Y, ptr @g, i32 0, i32 1), ptr {{.*}}, i64 24, i1 false)24  g.y = a;25}26 27void test4(void) {28  // CHECK: @test429  // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}}, ptr align 1 getelementptr inbounds nuw (%struct.Y, ptr @g, i32 0, i32 1), i64 24, i1 false)30  f(g.y);31}32 33// PR1239534int test5(void) {35  // CHECK: @test536  // CHECK: load i32, ptr getelementptr inbounds nuw (%struct.Y, ptr @g, i32 0, i32 1), align 137  return g.y.x[0];38}39 40void test6(void) {41  // CHECK: @test642  // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 getelementptr inbounds nuw (%struct.Y, ptr @g, i32 0, i32 1), ptr align 4 %{{.*}}, i64 24, i1 false)43  g.y = foo();44}45 46 47struct XBitfield {48  unsigned b1 : 10;49  unsigned b2 : 12;50  unsigned b3 : 10;51};52struct YBitfield {53  char x;54  struct XBitfield y;55} __attribute((packed));56struct YBitfield gbitfield;57 58unsigned test7(void) {59  // CHECK: @test760  // CHECK: load i32, ptr getelementptr inbounds nuw (%struct.YBitfield, ptr @gbitfield, i32 0, i32 1), align 161  return gbitfield.y.b2;62}63 64void test8(unsigned x) {65  // CHECK: @test866  // CHECK: load i32, ptr getelementptr inbounds nuw (%struct.YBitfield, ptr @gbitfield, i32 0, i32 1), align 167  // CHECK: store i32 {{.*}}, ptr getelementptr inbounds nuw (%struct.YBitfield, ptr @gbitfield, i32 0, i32 1), align 168  gbitfield.y.b2 = x;69}70 71struct TBitfield72{73  long a;74  char b;75  unsigned c:15;76};77struct TBitfield tbitfield;78 79unsigned test9(void) {80  // CHECK: @test981  // CHECK: load i16, ptr getelementptr inbounds nuw (%struct.TBitfield, ptr @tbitfield, i32 0, i32 2), align 182  return tbitfield.c;83}84 85void test10(unsigned x) {86  // CHECK: @test1087  // CHECK: load i16, ptr getelementptr inbounds nuw (%struct.TBitfield, ptr @tbitfield, i32 0, i32 2), align 188  // CHECK: store i16 {{.*}}, ptr getelementptr inbounds nuw (%struct.TBitfield, ptr @tbitfield, i32 0, i32 2), align 189  tbitfield.c = x;90}91 92