Serge Pavlov | 3760518 | 2018-07-28 15:33:03 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -S -emit-llvm -fsanitize=alignment %s -o - | FileCheck %s |
| 2 | |
| 3 | struct alignas(32) S1 { |
| 4 | int x; |
| 5 | S1(); |
| 6 | }; |
| 7 | |
| 8 | struct alignas(32) S2 { |
| 9 | int x; |
| 10 | }; |
| 11 | |
| 12 | struct alignas(32) S3 { |
| 13 | int x; |
| 14 | S3(int *p = new int[4]); |
| 15 | }; |
| 16 | |
| 17 | struct S4 : public S3 { |
| 18 | S4() : S3() {} |
| 19 | }; |
| 20 | |
| 21 | typedef __attribute__((ext_vector_type(2), aligned(32))) float float32x2_t; |
| 22 | |
| 23 | struct S5 { |
| 24 | float32x2_t x; |
| 25 | }; |
| 26 | |
| 27 | void *operator new (unsigned long, void *p) { return p; } |
| 28 | void *operator new[] (unsigned long, void *p) { return p; } |
| 29 | |
| 30 | S1 *func_01() { |
| 31 | // CHECK-LABEL: define {{.*}} @_Z7func_01v |
| 32 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 33 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 34 | // CHECK: call void @_ZN2S1C1Ev( |
| 35 | // CHECK-NOT: and i64 %{{.*}}, 31 |
| 36 | // CHECK: ret %struct.S1* |
| 37 | return new S1[20]; |
| 38 | } |
| 39 | |
| 40 | S2 *func_02() { |
| 41 | // CHECK-LABEL: define {{.*}} @_Z7func_02v |
| 42 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 43 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 44 | // CHECK: ret %struct.S2* |
| 45 | return new S2; |
| 46 | } |
| 47 | |
| 48 | S2 *func_03() { |
| 49 | // CHECK-LABEL: define {{.*}} @_Z7func_03v |
| 50 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 51 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 52 | // CHECK-NOT: and i64 %{{.*}}, 31 |
| 53 | // CHECK: ret %struct.S2* |
| 54 | return new S2[20]; |
| 55 | } |
| 56 | |
| 57 | float32x2_t *func_04() { |
| 58 | // CHECK-LABEL: define {{.*}} @_Z7func_04v |
| 59 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 60 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 61 | // CHECK: ret <2 x float>* |
| 62 | return new float32x2_t; |
| 63 | } |
| 64 | |
| 65 | float32x2_t *func_05() { |
| 66 | // CHECK-LABEL: define {{.*}} @_Z7func_05v |
| 67 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 68 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 69 | // CHECK-NOT: and i64 %{{.*}}, 31 |
| 70 | // CHECK: ret <2 x float>* |
| 71 | return new float32x2_t[20]; |
| 72 | } |
| 73 | |
| 74 | S3 *func_07() { |
| 75 | // CHECK-LABEL: define {{.*}} @_Z7func_07v |
| 76 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 77 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 78 | // CHECK: and i64 %{{.*}}, 3, !nosanitize |
| 79 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 80 | // CHECK: ret %struct.S3* |
| 81 | return new S3; |
| 82 | } |
| 83 | |
| 84 | S3 *func_08() { |
| 85 | // CHECK-LABEL: define {{.*}} @_Z7func_08v |
| 86 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 87 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 88 | // CHECK: and i64 %{{.*}}, 3, !nosanitize |
| 89 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 90 | // CHECK: ret %struct.S3* |
| 91 | return new S3[10]; |
| 92 | } |
| 93 | |
| 94 | |
| 95 | S2 *func_10(void *p) { |
| 96 | // CHECK-LABEL: define {{.*}} @_Z7func_10Pv |
| 97 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 98 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 99 | // CHECK: ret %struct.S2* |
| 100 | return new(p) S2; |
| 101 | } |
| 102 | |
| 103 | S2 *func_11(void *p) { |
| 104 | // CHECK-LABEL: define {{.*}} @_Z7func_11Pv |
| 105 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 106 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 107 | // CHECK-NOT: and i64 %{{.*}}, 31, !nosanitize |
| 108 | // CHECK-NOT: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 109 | // CHECK: ret %struct.S2* |
| 110 | return new(p) S2[10]; |
| 111 | } |
| 112 | |
| 113 | float32x2_t *func_12() { |
| 114 | // CHECK-LABEL: define {{.*}} @_Z7func_12v |
| 115 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 116 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 117 | // CHECK: ret <2 x float>* |
| 118 | return new float32x2_t; |
| 119 | } |
| 120 | |
| 121 | float32x2_t *func_13() { |
| 122 | // CHECK-LABEL: define {{.*}} @_Z7func_13v |
| 123 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 124 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 125 | // CHECK-NOT: and i64 %{{.*}}, 31 |
| 126 | // CHECK: ret <2 x float>* |
| 127 | return new float32x2_t[20]; |
| 128 | } |
| 129 | |
| 130 | S4 *func_14() { |
| 131 | // CHECK-LABEL: define {{.*}} @_Z7func_14v |
| 132 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 133 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 134 | // CHECK-NOT: and i64 %{{.*}}, 31 |
| 135 | // CHECK: ret %struct.S4* |
| 136 | return new S4; |
| 137 | } |
| 138 | |
| 139 | S5 *func_15(const S5 *ptr) { |
| 140 | // CHECK-LABEL: define {{.*}} @_Z7func_15PK2S5 |
| 141 | // CHECK: and i64 %{{.*}}, 31, !nosanitize |
| 142 | // CHECK: icmp eq i64 %{{.*}}, 0, !nosanitize |
| 143 | // CHECK-NOT: and i64 |
| 144 | // CHECK: ret %struct.S5* |
| 145 | return new S5(*ptr); |
| 146 | } |