diff options
author | John McCall <rjmccall@apple.com> | 2013-01-25 23:36:19 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-01-25 23:36:19 +0000 |
commit | f3bbb155beb69cdad1c6b0472bc0ca20cece6c50 (patch) | |
tree | 54a2c2d60c319cf3aa3cf73af349db1e084ba583 /test/CodeGenCXX/arm.cpp | |
parent | 96fcde0b8ed8bdf99d326312ca7be6447b0fe5fc (diff) |
ARM says that the array cookie should always be eight bytes.
ARM is not thinking about over-aligned structures.
Overrule ARM in both our generic-ARM and iOS ABI implementations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/arm.cpp')
-rw-r--r-- | test/CodeGenCXX/arm.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/CodeGenCXX/arm.cpp b/test/CodeGenCXX/arm.cpp index 6c60f3057c..fc910af7ad 100644 --- a/test/CodeGenCXX/arm.cpp +++ b/test/CodeGenCXX/arm.cpp @@ -357,6 +357,58 @@ namespace test8 { } } +// rdar://12836470 +// Use a larger-than-mandated array cookie when allocating an +// array whose type is overaligned. +namespace test9 { + class __attribute__((aligned(16))) A { + float data[4]; + public: + A(); + ~A(); + }; + + A *testNew(unsigned n) { + return new A[n]; + } +// CHECK: define [[TEST9:%.*]]* @_ZN5test97testNewEj(i32 +// CHECK: [[N_VAR:%.*]] = alloca i32, align 4 +// CHECK: [[N:%.*]] = load i32* [[N_VAR]], align 4 +// CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 16) +// CHECK-NEXT: [[O0:%.*]] = extractvalue { i32, i1 } [[T0]], 1 +// CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 0 +// CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[T1]], i32 16) +// CHECK-NEXT: [[O1:%.*]] = extractvalue { i32, i1 } [[T2]], 1 +// CHECK-NEXT: [[OVERFLOW:%.*]] = or i1 [[O0]], [[O1]] +// CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0 +// CHECK-NEXT: [[T4:%.*]] = select i1 [[OVERFLOW]], i32 -1, i32 [[T3]] +// CHECK-NEXT: [[ALLOC:%.*]] = call noalias i8* @_Znam(i32 [[T4]]) +// CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[ALLOC]] to i32* +// CHECK-NEXT: store i32 16, i32* [[T0]] +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i32* [[T0]], i32 1 +// CHECK-NEXT: store i32 [[N]], i32* [[T1]] +// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds i8* [[ALLOC]], i64 16 +// CHECK-NEXT: bitcast i8* [[T0]] to [[TEST9]]* +// Array allocation follows. + + void testDelete(A *array) { + delete[] array; + } +// CHECK: define void @_ZN5test910testDeleteEPNS_1AE( +// CHECK: [[BEGIN:%.*]] = load [[TEST9]]** +// CHECK-NEXT: [[T0:%.*]] = icmp eq [[TEST9]]* [[BEGIN]], null +// CHECK-NEXT: br i1 [[T0]], +// CHECK: [[T0:%.*]] = bitcast [[TEST9]]* [[BEGIN]] to i8* +// CHECK-NEXT: [[ALLOC:%.*]] = getelementptr inbounds i8* [[T0]], i64 -16 +// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds i8* [[ALLOC]], i64 4 +// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to i32* +// CHECK-NEXT: [[N:%.*]] = load i32* [[T1]] +// CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[TEST9]]* [[BEGIN]], i32 [[N]] +// CHECK-NEXT: [[T0:%.*]] = icmp eq [[TEST9]]* [[BEGIN]], [[END]] +// CHECK-NEXT: br i1 [[T0]], +// Array deallocation follows. +} + // CHECK: define linkonce_odr [[C:%.*]]* @_ZTv0_n12_N5test21CD1Ev( // CHECK: call [[C]]* @_ZN5test21CD1Ev( // CHECK: ret [[C]]* undef |