Skip to content

Commit dd588d1

Browse files
SunilKuravinakopSunil Kuravinakop
authored andcommitted
Automerge: [Clang][OpenMP] Bug fix Default clause variable category (#165276)
In the default clause taking care of new comments in the previous "Support for Default clause variable category" [157063](llvm/llvm-project#157063) and adding a new test case. --------- Co-authored-by: Sunil Kuravinakop <[email protected]>
2 parents 7dcf005 + 39774f9 commit dd588d1

File tree

2 files changed

+95
-3
lines changed

2 files changed

+95
-3
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,15 +1364,15 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
13641364
DefaultDataSharingAttributes IterDA = Iter->DefaultAttr;
13651365
switch (Iter->DefaultVCAttr) {
13661366
case DSA_VC_aggregate:
1367-
if (!VD->getType()->isAggregateType())
1367+
if (!D->getType()->isAggregateType())
13681368
IterDA = DSA_none;
13691369
break;
13701370
case DSA_VC_pointer:
1371-
if (!VD->getType()->isPointerType())
1371+
if (!D->getType()->isPointerType())
13721372
IterDA = DSA_none;
13731373
break;
13741374
case DSA_VC_scalar:
1375-
if (!VD->getType()->isScalarType())
1375+
if (!D->getType()->isScalarType())
13761376
IterDA = DSA_none;
13771377
break;
13781378
case DSA_VC_all:
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// RUN: %clangxx -Xclang -verify -Wno-vla -fopenmp -fopenmp-version=60 -x c++ -S -emit-llvm %s -o - | FileCheck %s
2+
// expected-no-diagnostics
3+
#ifndef HEADER
4+
#define HEADER
5+
6+
#include <vector>
7+
8+
int global;
9+
#define VECTOR_SIZE 4
10+
int main (int argc, char **argv) {
11+
int i,n;
12+
int x;
13+
14+
n = VECTOR_SIZE;
15+
16+
#pragma omp parallel masked firstprivate(x) num_threads(2)
17+
{
18+
int *xPtr = nullptr;
19+
// scalar
20+
#pragma omp task default(shared:scalar)
21+
{
22+
xPtr = &x;
23+
}
24+
#pragma omp taskwait
25+
26+
// pointer
27+
#pragma omp task default(shared:pointer) shared(x)
28+
{
29+
xPtr = &x;
30+
}
31+
#pragma omp taskwait
32+
}
33+
34+
int *aggregate[VECTOR_SIZE] = {0,0,0,0};
35+
36+
#pragma omp parallel masked num_threads(2)
37+
{
38+
// aggregate
39+
#pragma omp task default(shared:aggregate)
40+
for(i=0;i<n;i++) {
41+
aggregate[i] = &x;
42+
}
43+
#pragma omp taskwait
44+
45+
#pragma omp task default(shared:aggregate) shared(x)
46+
for(i=0;i<n;i++) {
47+
aggregate[i] = &x;
48+
}
49+
#pragma omp taskwait
50+
51+
// all
52+
#pragma omp task default(shared:all)
53+
for(i=0;i<n;i++) {
54+
aggregate[i] = &x;
55+
}
56+
#pragma omp taskwait
57+
}
58+
}
59+
60+
#endif
61+
62+
// CHECK-LABEL: define {{.*}}main.omp_outlined{{.*}}
63+
// CHECK-NEXT: entry:
64+
// CHECK: %x.addr = alloca{{.*}}
65+
// CHECK: %xPtr = alloca{{.*}}
66+
// CHECK: store ptr null, ptr %xPtr{{.*}}
67+
// CHECK: store ptr %xPtr{{.*}}
68+
// CHECK: store ptr %x.addr{{.*}}
69+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
70+
// CHECK: ret void
71+
//
72+
// CHECK: define {{.*}}main.omp_outlined{{.*}}
73+
// CHECK-NEXT: entry:
74+
// CHECK-DAG: %i.addr = alloca{{.*}}
75+
// CHECK-DAG: %n.addr = alloca{{.*}}
76+
// CHECK-DAG: %aggregate.addr = alloca{{.*}}
77+
// CHECK-DAG: %x.addr = alloca{{.*}}
78+
// CHECK: [[TMP0:%.*]] = load{{.*}}%i.addr{{.*}}
79+
// CHECK-NEXT: [[TMP1:%.*]] = load{{.*}}%n.addr{{.*}}
80+
// CHECK-NEXT: [[TMP2:%.*]] = load{{.*}}%aggregate.addr{{.*}}
81+
// CHECK-NEXT: [[TMP3:%.*]] = load{{.*}}%x.addr{{.*}}
82+
// CHECK: store ptr [[TMP2]]{{.*}}
83+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
84+
// CHECK: store ptr [[TMP2]]{{.*}}
85+
// CHECK: store ptr [[TMP3]]{{.*}}
86+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
87+
// CHECK: store ptr [[TMP0]]{{.*}}
88+
// CHECK: store ptr [[TMP1]]{{.*}}
89+
// CHECK: store ptr [[TMP2]]{{.*}}
90+
// CHECK: store ptr [[TMP3]]{{.*}}
91+
// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
92+
// CHECK: ret void

0 commit comments

Comments
 (0)