Skip to content

Commit eff9a58

Browse files
committed
testcases_added
1 parent 4762b11 commit eff9a58

20 files changed

+1469
-7
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8258,7 +8258,7 @@ class MappableExprsHandler {
82588258
}
82598259

82608260
// At this stage, if ElementType was a base pointer and we are in the
8261-
// first iteration, it has been computed.
8261+
// first iteration, it has been computed.
82628262
if (ElementType) {
82638263
// For the case that having pointer as base, we need to remove one
82648264
// level of indirection.

clang/test/OpenMP/target_update_codegen.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ void foo(int arg) {
11771177
// CK21: [[STRUCT_ST:%.+]] = type { [10 x [10 x [10 x ptr]]] }
11781178
// CK21: [[STRUCT_DESCRIPTOR:%.+]] = type { i64, i64, i64 }
11791179

1180-
// CK21: [[SIZE:@.+]] = private unnamed_addr constant [2 x i64] zeroinitializer
1180+
// CK21: [[SIZE:@.+]] = private unnamed_addr constant [2 x i64] [i64 0, i64 4]
11811181
// CK21: [[MTYPE:@.+]] = {{.+}}constant [2 x i64] [i64 0, i64 299067162755073]
11821182

11831183
struct ST {
@@ -1221,11 +1221,8 @@ struct ST {
12211221
// CK21: store i64 1, ptr [[COUNT_4]],
12221222
// CK21: [[STRIDE_4:%.+]] = getelementptr inbounds nuw [[STRUCT_DESCRIPTOR]], ptr [[DIM_4]], {{.+}} 0, {{.+}} 2
12231223
// CK21: store i64 {{4|8}}, ptr [[STRIDE_4]],
1224-
// CK21-DAG: call void @__tgt_target_data_update_mapper(ptr @{{.+}}, i64 -1, i32 2, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[GEPSZ:%.+]], ptr [[MTYPE]]{{.+}})
1225-
// CK21-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP]]
1226-
// CK21-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
1227-
// CK21-DAG: [[PTRS:%.+]] = getelementptr inbounds [2 x ptr], ptr %.offload_ptrs, i32 0, i32 0
1228-
// CK21-DAG: store ptr [[DIMS]], ptr [[PTRS]],
1224+
// CK21: call void @__tgt_target_data_update_mapper(ptr @1, i64 -1, i32 2, ptr %{{[0-9]+}}, ptr %{{[0-9]+}}, ptr %{{[0-9]+}}, ptr @.offload_maptypes, ptr null, ptr null)
1225+
// CK21: ret void
12291226
#pragma omp target update to(dptr[0:2][1:3][0:4])
12301227
}
12311228
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3+
4+
extern void *malloc(unsigned long);
5+
extern void free(void *);
6+
7+
int main(int argc, char **argv) {
8+
int len = 16;
9+
double *data = (double *)malloc(len * sizeof(double));
10+
11+
// Valid strided array sections with FROM
12+
#pragma omp target update from(data[0:8:2]) // OK - even indices
13+
{}
14+
15+
#pragma omp target update from(data[1:4:3]) // OK - odd start with stride
16+
{}
17+
18+
#pragma omp target update from(data[2:3:5]) // OK - large stride
19+
{}
20+
21+
// Missing stride (default = 1)
22+
#pragma omp target update from(data[0:8]) // OK - default stride
23+
{}
24+
25+
#pragma omp target update from(data[4:len-4]) // OK - computed length
26+
{}
27+
28+
// Invalid stride expressions
29+
#pragma omp target update from(data[0:8:0]) // expected-error {{section stride is evaluated to a non-positive value 0}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
30+
31+
#pragma omp target update from(data[0:4:-1]) // expected-error {{section stride is evaluated to a non-positive value -1}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
32+
33+
#pragma omp target update from(data[1:5:-2]) // expected-error {{section stride is evaluated to a non-positive value -2}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
34+
35+
// Syntax errors
36+
#pragma omp target update from(data[0:4 2]) // expected-error {{expected ']'}} expected-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
37+
{}
38+
39+
#pragma omp target update from(data[0:4:2:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
40+
{}
41+
42+
free(data);
43+
return 0;
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3+
4+
extern void *malloc(unsigned long);
5+
extern void free(void *);
6+
7+
int main(int argc, char **argv) {
8+
int len = 16;
9+
double *data = (double *)malloc(len * sizeof(double));
10+
11+
// Valid strided array sections with TO
12+
#pragma omp target update to(data[0:8:2]) // OK - even indices
13+
{}
14+
15+
#pragma omp target update to(data[1:4:3]) // OK - odd start with stride
16+
{}
17+
18+
#pragma omp target update to(data[2:3:5]) // OK - large stride
19+
{}
20+
21+
// Missing stride (default = 1)
22+
#pragma omp target update to(data[0:8]) // OK - default stride
23+
{}
24+
25+
#pragma omp target update to(data[4:len-4]) // OK - computed length
26+
{}
27+
28+
// Invalid stride expressions
29+
#pragma omp target update to(data[0:8:0]) // expected-error {{section stride is evaluated to a non-positive value 0}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
30+
31+
#pragma omp target update to(data[0:4:-1]) // expected-error {{section stride is evaluated to a non-positive value -1}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
32+
33+
#pragma omp target update to(data[1:5:-2]) // expected-error {{section stride is evaluated to a non-positive value -2}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
34+
35+
// Syntax errors
36+
#pragma omp target update to(data[0:4 2]) // expected-error {{expected ']'}} expected-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
37+
{}
38+
39+
#pragma omp target update to(data[0:4:2:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
40+
{}
41+
42+
free(data);
43+
return 0;
44+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3+
4+
extern void *malloc(unsigned long);
5+
extern void free(void *);
6+
7+
double *data;
8+
double *data1;
9+
double *data2;
10+
11+
int main(int argc, char **argv) {
12+
int len = 12;
13+
14+
// Allocate memory for explicit pointers
15+
data = (double *)malloc(len * sizeof(double));
16+
data1 = (double *)malloc(len * sizeof(double));
17+
data2 = (double *)malloc(len * sizeof(double));
18+
19+
// Valid multiple strided array sections
20+
#pragma omp target update from(data1[0:6:2], data2[0:4:3]) // OK - different strides
21+
{}
22+
23+
#pragma omp target update from(data1[1:2:3], data2[2:3:2]) // OK - with offsets
24+
{}
25+
26+
// Mixed strided and regular sections
27+
#pragma omp target update from(data1[0:len], data2[0:4:2]) // OK - mixed
28+
{}
29+
30+
#pragma omp target update from(data1[1:3:2], data2[0:len]) // OK - reversed mix
31+
{}
32+
33+
// Using the single data pointer with strides
34+
#pragma omp target update from(data[0:4:2]) // OK - single pointer
35+
{}
36+
37+
// Invalid stride in one of multiple sections
38+
#pragma omp target update from(data1[0:3:4], data2[0:2:0]) // expected-error {{section stride is evaluated to a non-positive value 0}}
39+
40+
#pragma omp target update from(data1[0:3:-1], data2[0:2:2]) // expected-error {{section stride is evaluated to a non-positive value -1}}
41+
42+
#pragma omp target update from(data[0:4:0], data1[0:2:1]) // expected-error {{section stride is evaluated to a non-positive value 0}}
43+
44+
// Complex expressions in multiple arrays
45+
int stride1 = 2, stride2 = 3;
46+
#pragma omp target update from(data1[1:4:stride1+1], data2[0:3:stride2-1]) // OK - expressions
47+
{}
48+
49+
// Mix all three pointers
50+
#pragma omp target update from(data[0:2:3], data1[1:3:2], data2[2:2:4]) // OK - three arrays
51+
{}
52+
53+
// Syntax errors in multiple arrays
54+
#pragma omp target update from(data1[0:4:2], data2[0:3 4]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
55+
56+
#pragma omp target update from(data1[0:4:2:3], data2[0:3:2]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
57+
58+
#pragma omp target update from(data[0:4:2], data1[0:3:2:1], data2[0:2:3]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
59+
60+
free(data);
61+
free(data1);
62+
free(data2);
63+
return 0;
64+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3+
4+
extern void *malloc(unsigned long);
5+
extern void free(void *);
6+
7+
double *data;
8+
double *data1;
9+
double *data2;
10+
11+
int main(int argc, char **argv) {
12+
int len = 12;
13+
14+
// Allocate memory for explicit pointers
15+
data = (double *)malloc(len * sizeof(double));
16+
data1 = (double *)malloc(len * sizeof(double));
17+
data2 = (double *)malloc(len * sizeof(double));
18+
19+
// Valid multiple strided array sections
20+
#pragma omp target update to(data1[0:6:2], data2[0:4:3]) // OK - different strides
21+
{}
22+
23+
#pragma omp target update to(data1[1:2:3], data2[2:3:2]) // OK - with offsets
24+
{}
25+
26+
// Mixed strided and regular sections
27+
#pragma omp target update to(data1[0:len], data2[0:4:2]) // OK - mixed
28+
{}
29+
30+
#pragma omp target update to(data1[1:3:2], data2[0:len]) // OK - reversed mix
31+
{}
32+
33+
// Using the single data pointer with strides
34+
#pragma omp target update to(data[0:4:2]) // OK - single pointer
35+
{}
36+
37+
// Invalid stride in one of multiple sections
38+
#pragma omp target update to(data1[0:3:4], data2[0:2:0]) // expected-error {{section stride is evaluated to a non-positive value 0}}
39+
40+
#pragma omp target update to(data1[0:3:-1], data2[0:2:2]) // expected-error {{section stride is evaluated to a non-positive value -1}}
41+
42+
#pragma omp target update to(data[0:4:0], data1[0:2:1]) // expected-error {{section stride is evaluated to a non-positive value 0}}
43+
44+
// Complex expressions in multiple arrays
45+
int stride1 = 2, stride2 = 3;
46+
#pragma omp target update to(data1[1:4:stride1+1], data2[0:3:stride2-1]) // OK - expressions
47+
{}
48+
49+
// Mix all three pointers
50+
#pragma omp target update to(data[0:2:3], data1[1:3:2], data2[2:2:4]) // OK - three arrays
51+
{}
52+
53+
// Syntax errors in multiple arrays
54+
#pragma omp target update to(data1[0:4:2], data2[0:3 4]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
55+
56+
#pragma omp target update to(data1[0:4:2:3], data2[0:3:2]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
57+
58+
#pragma omp target update to(data[0:4:2], data1[0:3:2:1], data2[0:2:3]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
59+
60+
free(data);
61+
free(data1);
62+
free(data2);
63+
return 0;
64+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3+
4+
extern void *malloc(unsigned long);
5+
extern void free(void *);
6+
7+
int main(int argc, char **argv) {
8+
int len = 11;
9+
double *data = (double *)malloc(len * sizeof(double));
10+
11+
// Valid partial strided sections with FROM
12+
#pragma omp target update from(data[0:2:3]) // OK - partial coverage
13+
{}
14+
15+
#pragma omp target update from(data[1:3:4]) // OK - offset with partial stride
16+
{}
17+
18+
#pragma omp target update from(data[2:2:5]) // OK - large partial stride
19+
{}
20+
21+
// Stride larger than remaining elements
22+
#pragma omp target update from(data[0:2:10]) // OK - stride > array size
23+
{}
24+
25+
#pragma omp target update from(data[0:3:len]) // OK - stride = len
26+
{}
27+
28+
// Complex expressions
29+
int offset = 1;
30+
int stride = 2;
31+
32+
// Runtime-dependent invalid strides
33+
#pragma omp target update from(data[0:4:offset-1]) // OK if offset > 1
34+
{}
35+
36+
// Compile-time invalid strides
37+
#pragma omp target update from(data[1:2:-3]) // expected-error {{section stride is evaluated to a non-positive value -3}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
38+
39+
free(data);
40+
return 0;
41+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3+
4+
extern void *malloc(unsigned long);
5+
extern void free(void *);
6+
7+
int main(int argc, char **argv) {
8+
int len = 11;
9+
double *data = (double *)malloc(len * sizeof(double));
10+
11+
// Valid partial strided sections with TO
12+
#pragma omp target update to(data[0:2:3]) // OK - partial coverage
13+
{}
14+
15+
#pragma omp target update to(data[1:3:4]) // OK - offset with partial stride
16+
{}
17+
18+
#pragma omp target update to(data[2:2:5]) // OK - large partial stride
19+
{}
20+
21+
// Stride larger than remaining elements
22+
#pragma omp target update to(data[0:2:10]) // OK - stride > array size
23+
{}
24+
25+
#pragma omp target update to(data[0:3:len]) // OK - stride = len
26+
{}
27+
28+
int offset = 1;
29+
int stride = 2;
30+
31+
// Runtime-dependent invalid strides
32+
#pragma omp target update to(data[0:4:offset-1]) // OK if offset > 1
33+
{}
34+
35+
// Compile-time invalid strides
36+
#pragma omp target update to(data[1:2:-3]) // expected-error {{section stride is evaluated to a non-positive value -3}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
37+
38+
free(data);
39+
return 0;
40+
}

0 commit comments

Comments
 (0)