2013-02-02 09:13:06 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -S -emit-llvm -o - %s -Wno-address-of-temporary | FileCheck %s
|
2012-02-29 08:00:28 +08:00
|
|
|
|
2012-12-21 11:17:28 +08:00
|
|
|
// CHECK: @[[THREE_NULL_MEMPTRS:.*]] = private constant [3 x i32] [i32 -1, i32 -1, i32 -1]
|
|
|
|
|
2012-02-29 08:00:28 +08:00
|
|
|
struct A { int a[1]; };
|
|
|
|
typedef A x[];
|
|
|
|
int f() {
|
|
|
|
x{{{1}}};
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @_Z1fv
|
2012-02-29 08:00:28 +08:00
|
|
|
// CHECK: store i32 1
|
|
|
|
// (It's okay if the output changes here, as long as we don't crash.)
|
2012-12-21 11:17:28 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ValueInitArrayOfMemPtr {
|
|
|
|
struct S {};
|
|
|
|
typedef int (S::*p);
|
|
|
|
typedef p a[3];
|
|
|
|
void f(const a &);
|
|
|
|
|
|
|
|
struct Agg1 {
|
|
|
|
int n;
|
|
|
|
p x;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Agg2 {
|
|
|
|
int n;
|
|
|
|
a x;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct S1 {
|
|
|
|
p x;
|
|
|
|
S1();
|
|
|
|
};
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_ZN22ValueInitArrayOfMemPtr1fEi
|
2012-12-21 11:17:28 +08:00
|
|
|
void f(int n) {
|
|
|
|
Agg1 a = { n };
|
|
|
|
// CHECK: store i32 -1,
|
|
|
|
|
|
|
|
Agg2 b = { n };
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 bitcast ([3 x i32]* @[[THREE_NULL_MEMPTRS]] to i8*), i32 12, i1 false)
|
2012-12-21 11:17:28 +08:00
|
|
|
}
|
|
|
|
|
2015-03-07 21:37:13 +08:00
|
|
|
// Test dynamic initialization.
|
|
|
|
// CHECK-LABEL: define void @_ZN22ValueInitArrayOfMemPtr1gEMNS_1SEi
|
|
|
|
void g(p ptr) {
|
2012-12-21 11:17:28 +08:00
|
|
|
// CHECK: store i32 -1,
|
2015-03-07 21:37:13 +08:00
|
|
|
f(a{ptr});
|
2012-12-21 11:17:28 +08:00
|
|
|
}
|
2012-02-29 08:00:28 +08:00
|
|
|
}
|
2013-02-02 09:13:06 +08:00
|
|
|
|
|
|
|
namespace array_dtor {
|
|
|
|
struct S { S(); ~S(); };
|
|
|
|
using T = S[3];
|
|
|
|
void f(const T &);
|
2013-02-02 10:14:45 +08:00
|
|
|
void f(T *);
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_ZN10array_dtor1gEv(
|
2013-02-02 09:13:06 +08:00
|
|
|
void g() {
|
|
|
|
// CHECK: %[[ARRAY:.*]] = alloca [3 x
|
|
|
|
// CHECK: br
|
|
|
|
|
|
|
|
// Construct loop.
|
|
|
|
// CHECK: call void @_ZN10array_dtor1SC1Ev(
|
|
|
|
// CHECK: br i1
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE(
|
|
|
|
// CHECK: br
|
|
|
|
|
|
|
|
// Destruct loop.
|
|
|
|
// CHECK: call void @_ZN10array_dtor1SD1Ev(
|
|
|
|
// CHECK: br i1
|
2013-02-02 10:14:45 +08:00
|
|
|
f(T{});
|
2013-02-02 09:13:06 +08:00
|
|
|
|
|
|
|
// CHECK: ret void
|
|
|
|
}
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_ZN10array_dtor1hEv(
|
2013-02-02 09:13:06 +08:00
|
|
|
void h() {
|
|
|
|
// CHECK: %[[ARRAY:.*]] = alloca [3 x
|
|
|
|
// CHECK: br
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN10array_dtor1SC1Ev(
|
|
|
|
// CHECK: br i1
|
|
|
|
T &&t = T{};
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE(
|
|
|
|
// CHECK: br
|
|
|
|
f(t);
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN10array_dtor1SD1Ev(
|
|
|
|
// CHECK: br i1
|
|
|
|
|
2013-02-02 10:14:45 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
}
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_ZN10array_dtor1iEv(
|
2013-02-02 10:14:45 +08:00
|
|
|
void i() {
|
|
|
|
// CHECK: %[[ARRAY:.*]] = alloca [3 x
|
|
|
|
// CHECK: br
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN10array_dtor1SC1Ev(
|
|
|
|
// CHECK: br i1
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN10array_dtor1fEPA3_NS_1SE(
|
|
|
|
// CHECK: br
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN10array_dtor1SD1Ev(
|
|
|
|
// CHECK: br i1
|
|
|
|
f(&T{});
|
|
|
|
|
2013-02-02 09:13:06 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
}
|
|
|
|
}
|