Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / volatile-complex.c
blob7d3c0c6b85511302d9df447bcf48b135c6e63b9b
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3 // Validate that volatile _Complex loads and stores are generated
4 // properly, including their alignment (even when overaligned).
5 //
6 // This test assumes that floats are 32-bit aligned and doubles are
7 // 64-bit aligned, and uses x86-64 as a target that should have this
8 // property.
10 volatile _Complex float cf;
11 volatile _Complex double cd;
12 volatile _Complex float cf32 __attribute__((aligned(32)));
13 volatile _Complex double cd32 __attribute__((aligned(32)));
15 // CHECK-LABEL: define{{.*}} void @test_cf()
16 void test_cf(void) {
17 // CHECK: load volatile float, ptr @cf, align 4
18 // CHECK-NEXT: load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf, i32 0, i32 1), align 4
19 (void)(cf);
20 // CHECK-NEXT: [[R:%.*]] = load volatile float, ptr @cf, align 4
21 // CHECK-NEXT: [[I:%.*]] = load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf, i32 0, i32 1), align 4
22 // CHECK-NEXT: store volatile float [[R]], ptr @cf, align 4
23 // CHECK-NEXT: store volatile float [[I]], ptr getelementptr inbounds nuw ({ float, float }, ptr @cf, i32 0, i32 1), align 4
24 (void)(cf=cf);
25 // CHECK-NEXT: ret void
28 // CHECK-LABEL: define{{.*}} void @test_cd()
29 void test_cd(void) {
30 // CHECK: load volatile double, ptr @cd, align 8
31 // CHECK-NEXT: load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd, i32 0, i32 1), align 8
32 (void)(cd);
33 // CHECK-NEXT: [[R:%.*]] = load volatile double, ptr @cd, align 8
34 // CHECK-NEXT: [[I:%.*]] = load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd, i32 0, i32 1), align 8
35 // CHECK-NEXT: store volatile double [[R]], ptr @cd, align 8
36 // CHECK-NEXT: store volatile double [[I]], ptr getelementptr inbounds nuw ({ double, double }, ptr @cd, i32 0, i32 1), align 8
37 (void)(cd=cd);
38 // CHECK-NEXT: ret void
41 // CHECK-LABEL: define{{.*}} void @test_cf32()
42 void test_cf32(void) {
43 // CHECK: load volatile float, ptr @cf32, align 32
44 // CHECK-NEXT: load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf32, i32 0, i32 1), align 4
45 (void)(cf32);
46 // CHECK-NEXT: [[R:%.*]] = load volatile float, ptr @cf32, align 32
47 // CHECK-NEXT: [[I:%.*]] = load volatile float, ptr getelementptr inbounds nuw ({ float, float }, ptr @cf32, i32 0, i32 1), align 4
48 // CHECK-NEXT: store volatile float [[R]], ptr @cf32, align 32
49 // CHECK-NEXT: store volatile float [[I]], ptr getelementptr inbounds nuw ({ float, float }, ptr @cf32, i32 0, i32 1), align 4
50 (void)(cf32=cf32);
51 // CHECK-NEXT: ret void
54 // CHECK-LABEL: define{{.*}} void @test_cd32()
55 void test_cd32(void) {
56 // CHECK: load volatile double, ptr @cd32, align 32
57 // CHECK-NEXT: load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd32, i32 0, i32 1), align 8
58 (void)(cd32);
59 // CHECK-NEXT: [[R:%.*]] = load volatile double, ptr @cd32, align 32
60 // CHECK-NEXT: [[I:%.*]] = load volatile double, ptr getelementptr inbounds nuw ({ double, double }, ptr @cd32, i32 0, i32 1), align 8
61 // CHECK-NEXT: store volatile double [[R]], ptr @cd32, align 32
62 // CHECK-NEXT: store volatile double [[I]], ptr getelementptr inbounds nuw ({ double, double }, ptr @cd32, i32 0, i32 1), align 8
63 (void)(cd32=cd32);
64 // CHECK-NEXT: ret void