2012-02-22 17:37:52 +00:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
|
2017-02-13 23:49:55 +00:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -fsanitize=signed-integer-overflow -o - | FileCheck --check-prefix=SIO %s
|
2012-02-22 17:37:52 +00:00
|
|
|
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
// CHECK: @[[ABC4:.*]] = {{.*}} constant [4 x i8] c"abc\00"
|
|
|
|
// CHECK: @[[ABC15:.*]] = {{.*}} constant [15 x i8] c"abc\00\00\00\00
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z2fni
|
2012-02-22 17:37:52 +00:00
|
|
|
void fn(int n) {
|
|
|
|
// CHECK: icmp ult i{{32|64}} %{{[^ ]+}}, 3
|
|
|
|
// CHECK: store i32 1
|
|
|
|
// CHECK: store i32 2
|
|
|
|
// CHECK: store i32 3
|
2014-06-03 06:58:52 +00:00
|
|
|
// CHECK: sub {{.*}}, 12
|
|
|
|
// CHECK: call void @llvm.memset
|
2012-02-22 17:37:52 +00:00
|
|
|
new int[n] { 1, 2, 3 };
|
|
|
|
}
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z11const_exactv
|
2012-02-22 17:37:52 +00:00
|
|
|
void const_exact() {
|
|
|
|
// CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
|
|
|
|
// CHECK-NOT: icmp eq i32*
|
|
|
|
new int[3] { 1, 2, 3 };
|
|
|
|
}
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z16const_sufficientv
|
2012-02-22 17:37:52 +00:00
|
|
|
void const_sufficient() {
|
|
|
|
// CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
|
|
|
|
new int[4] { 1, 2, 3 };
|
|
|
|
// CHECK: ret void
|
|
|
|
}
|
2014-06-03 06:58:52 +00:00
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z22check_array_value_initv
|
2014-06-03 06:58:52 +00:00
|
|
|
void check_array_value_init() {
|
|
|
|
struct S;
|
|
|
|
new (int S::*[3][4][5]) ();
|
|
|
|
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: call noalias noundef nonnull i8* @_Zna{{.}}(i{{32 noundef 240|64 noundef 480}})
|
2015-02-27 19:18:17 +00:00
|
|
|
// CHECK: getelementptr inbounds i{{32|64}}, i{{32|64}}* {{.*}}, i{{32|64}} 60
|
2014-06-03 06:58:52 +00:00
|
|
|
|
|
|
|
// CHECK: phi
|
|
|
|
// CHECK: store i{{32|64}} -1,
|
2015-02-27 19:18:17 +00:00
|
|
|
// CHECK: getelementptr inbounds i{{32|64}}, i{{32|64}}* {{.*}}, i{{32|64}} 1
|
2014-06-03 06:58:52 +00:00
|
|
|
// CHECK: icmp eq
|
|
|
|
// CHECK: br i1
|
|
|
|
}
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z15string_nonconsti
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
void string_nonconst(int n) {
|
|
|
|
// CHECK: icmp slt i{{32|64}} %{{[^ ]+}}, 4
|
|
|
|
// FIXME: Conditionally throw an exception rather than passing -1 to alloc function
|
|
|
|
// CHECK: select
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: %[[PTR:.*]] = call noalias noundef nonnull i8* @_Zna{{.}}(i{{32|64}}
|
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-19 17:12:54 +00:00
|
|
|
// CHECK: call void @llvm.memcpy{{.*}}(i8* align {{[0-9]+}} %[[PTR]], i8* align {{[0-9]+}} getelementptr inbounds ([4 x i8], [4 x i8]* @[[ABC4]], i32 0, i32 0), i32 4,
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
// CHECK: %[[REST:.*]] = getelementptr inbounds i8, i8* %[[PTR]], i32 4
|
|
|
|
// CHECK: %[[RESTSIZE:.*]] = sub {{.*}}, 4
|
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-19 17:12:54 +00:00
|
|
|
// CHECK: call void @llvm.memset{{.*}}(i8* align {{[0-9]+}} %[[REST]], i8 0, i{{32|64}} %[[RESTSIZE]],
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
new char[n] { "abc" };
|
|
|
|
}
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z12string_exactv
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
void string_exact() {
|
|
|
|
// CHECK-NOT: icmp
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: %[[PTR:.*]] = call noalias noundef nonnull i8* @_Zna{{.}}(i{{32|64}} noundef 4)
|
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-19 17:12:54 +00:00
|
|
|
// CHECK: call void @llvm.memcpy{{.*}}(i8* align {{[0-9]+}} %[[PTR]], i8* align {{[0-9]+}} getelementptr inbounds ([4 x i8], [4 x i8]* @[[ABC4]], i32 0, i32 0), i32 4,
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
// CHECK-NOT: memset
|
|
|
|
new char[4] { "abc" };
|
|
|
|
}
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z17string_sufficientv
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
void string_sufficient() {
|
|
|
|
// CHECK-NOT: icmp
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: %[[PTR:.*]] = call noalias noundef nonnull i8* @_Zna{{.}}(i{{32|64}} noundef 15)
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
// FIXME: For very large arrays, it would be preferable to emit a small copy and a memset.
|
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-19 17:12:54 +00:00
|
|
|
// CHECK: call void @llvm.memcpy{{.*}}(i8* align {{[0-9]+}} %[[PTR]], i8* align {{[0-9]+}} getelementptr inbounds ([15 x i8], [15 x i8]* @[[ABC15]], i32 0, i32 0), i32 15,
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
// CHECK-NOT: memset
|
|
|
|
new char[15] { "abc" };
|
|
|
|
}
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z10aggr_exactv
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
void aggr_exact() {
|
|
|
|
// CHECK-NOT: icmp
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: %[[MEM:.*]] = call noalias noundef nonnull i8* @_Zna{{.}}(i{{32|64}} noundef 16)
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
// CHECK: %[[PTR0:.*]] = bitcast i8* %[[MEM]] to %[[AGGR:.*]]*
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR0]], i32 0, i32 0{{$}}
|
|
|
|
// CHECK: store i32 1, i32* %[[FIELD]]
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR0]], i32 0, i32 1{{$}}
|
|
|
|
// CHECK: store i32 2, i32* %[[FIELD]]
|
|
|
|
// CHECK: %[[PTR1:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR0]], i32 1{{$}}
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR1]], i32 0, i32 0{{$}}
|
|
|
|
// CHECK: store i32 3, i32* %[[FIELD]]
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR1]], i32 0, i32 1{{$}}
|
|
|
|
// CHECK: store i32 0, i32* %[[FIELD]]
|
|
|
|
// CHECK-NOT: store
|
|
|
|
// CHECK-NOT: memset
|
|
|
|
struct Aggr { int a, b; };
|
|
|
|
new Aggr[2] { 1, 2, 3 };
|
|
|
|
}
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z15aggr_sufficienti
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
void aggr_sufficient(int n) {
|
|
|
|
// CHECK: icmp ult i32 %{{.*}}, 2
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: %[[MEM:.*]] = call noalias noundef nonnull i8* @_Zna{{.}}(
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
// CHECK: %[[PTR0:.*]] = bitcast i8* %[[MEM]] to %[[AGGR:.*]]*
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR0]], i32 0, i32 0{{$}}
|
|
|
|
// CHECK: store i32 1, i32* %[[FIELD]]
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR0]], i32 0, i32 1{{$}}
|
|
|
|
// CHECK: store i32 2, i32* %[[FIELD]]
|
|
|
|
// CHECK: %[[PTR1:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR0]], i32 1{{$}}
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR1]], i32 0, i32 0{{$}}
|
|
|
|
// CHECK: store i32 3, i32* %[[FIELD]]
|
|
|
|
// CHECK: %[[FIELD:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR1]], i32 0, i32 1{{$}}
|
|
|
|
// CHECK: store i32 0, i32* %[[FIELD]]
|
|
|
|
// CHECK: %[[PTR2:.*]] = getelementptr inbounds %[[AGGR]], %[[AGGR]]* %[[PTR1]], i32 1{{$}}
|
|
|
|
// CHECK: %[[REMAIN:.*]] = sub i32 {{.*}}, 16
|
|
|
|
// CHECK: %[[MEM:.*]] = bitcast %[[AGGR]]* %[[PTR2]] to i8*
|
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-19 17:12:54 +00:00
|
|
|
// CHECK: call void @llvm.memset{{.*}}(i8* align {{[0-9]+}} %[[MEM]], i8 0, i32 %[[REMAIN]],
|
PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).
This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.
llvm-svn: 283406
2016-10-05 22:41:02 +00:00
|
|
|
struct Aggr { int a, b; };
|
|
|
|
new Aggr[n] { 1, 2, 3 };
|
|
|
|
}
|
2017-02-13 23:49:55 +00:00
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// SIO-LABEL: define{{.*}} void @_Z14constexpr_testv
|
2017-02-13 23:49:55 +00:00
|
|
|
void constexpr_test() {
|
2021-10-15 19:45:30 +09:00
|
|
|
// SIO: call noalias noundef nonnull i8* @_Zna{{.}}(i32 noundef 4)
|
2017-02-13 23:49:55 +00:00
|
|
|
new int[0+1]{0};
|
|
|
|
}
|
2019-05-06 03:47:15 +00:00
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z13unknown_boundv
|
2019-05-06 03:47:15 +00:00
|
|
|
void unknown_bound() {
|
|
|
|
struct Aggr { int x, y, z; };
|
|
|
|
new Aggr[]{1, 2, 3, 4};
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: call {{.*}}_Znaj(i32 noundef 24)
|
2019-05-06 03:47:15 +00:00
|
|
|
// CHECK: store i32 1
|
|
|
|
// CHECK: store i32 2
|
|
|
|
// CHECK: store i32 3
|
|
|
|
// CHECK: store i32 4
|
|
|
|
// CHECK: store i32 0
|
|
|
|
// CHECK: store i32 0
|
|
|
|
// CHECK-NOT: store
|
|
|
|
// CHECK: }
|
|
|
|
}
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @_Z20unknown_bound_stringv
|
2019-05-06 03:47:15 +00:00
|
|
|
void unknown_bound_string() {
|
|
|
|
new char[]{"hello"};
|
2021-10-15 19:45:30 +09:00
|
|
|
// CHECK: call {{.*}}_Znaj(i32 noundef 6)
|
2019-05-06 03:47:15 +00:00
|
|
|
// CHECK: memcpy{{.*}} i32 6,
|
|
|
|
}
|