forked from OSchip/llvm-project
[OPENMP] Capture global variables in all target executable regions.
Capturing of the global variables occurs only in target regions. Patch fixes it and allows capturing of globals in all target executable directives. llvm-svn: 312024
This commit is contained in:
parent
4431bfe88c
commit
61498fb88f
|
@ -1278,7 +1278,7 @@ VarDecl *Sema::IsOpenMPCapturedDecl(ValueDecl *D) {
|
|||
//
|
||||
auto *VD = dyn_cast<VarDecl>(D);
|
||||
if (VD && !VD->hasLocalStorage()) {
|
||||
if (DSAStack->getCurrentDirective() == OMPD_target &&
|
||||
if (isOpenMPTargetExecutionDirective(DSAStack->getCurrentDirective()) &&
|
||||
!DSAStack->isClauseParsingMode())
|
||||
return VD;
|
||||
if (DSAStack->hasDirective(
|
||||
|
|
|
@ -83,6 +83,8 @@ struct TT{
|
|||
ty Y;
|
||||
};
|
||||
|
||||
int global;
|
||||
|
||||
// CHECK: define {{.*}}[[FOO:@.+]](
|
||||
int foo(int n) {
|
||||
int a = 0;
|
||||
|
@ -178,6 +180,7 @@ int foo(int n) {
|
|||
{
|
||||
a += 1;
|
||||
aa += 1;
|
||||
global += 1;
|
||||
}
|
||||
|
||||
// We capture 3 VLA sizes in this target region
|
||||
|
@ -372,6 +375,7 @@ int foo(int n) {
|
|||
// CHECK: [[AA_ADDR:%.+]] = alloca i[[SZ]], align
|
||||
// CHECK: [[A_CASTED:%.+]] = alloca i[[SZ]], align
|
||||
// CHECK: [[AA_CASTED:%.+]] = alloca i[[SZ]], align
|
||||
// CHECK: [[GLOBAL_CASTED:%.+]] = alloca i[[SZ]], align
|
||||
// CHECK-DAG: store i[[SZ]] %{{.+}}, i[[SZ]]* [[A_ADDR]], align
|
||||
// CHECK-DAG: store i[[SZ]] %{{.+}}, i[[SZ]]* [[AA_ADDR]], align
|
||||
// CHECK-64-DAG:[[A_CADDR:%.+]] = bitcast i[[SZ]]* [[A_ADDR]] to i32*
|
||||
|
@ -384,18 +388,28 @@ int foo(int n) {
|
|||
// CHECK-DAG: [[AA:%.+]] = load i16, i16* [[AA_CADDR]], align
|
||||
// CHECK-DAG: [[AA_C:%.+]] = bitcast i[[SZ]]* [[AA_CASTED]] to i16*
|
||||
// CHECK-DAG: store i16 [[AA]], i16* [[AA_C]], align
|
||||
// CHECK-DAG: [[GLOBAL:%.+]] = load i32, i32* @global, align
|
||||
// CHECK-64-DAG:[[GLOBAL_C:%.+]] = bitcast i[[SZ]]* [[GLOBAL_CASTED]] to i32*
|
||||
// CHECK-64-DAG:store i32 [[GLOBAL]], i32* [[GLOBAL_C]], align
|
||||
// CHECK-32-DAG:store i32 [[GLOBAL]], i32* [[GLOBAL_CASTED]], align
|
||||
// CHECK-DAG: [[PARAM1:%.+]] = load i[[SZ]], i[[SZ]]* [[A_CASTED]], align
|
||||
// CHECK-DAG: [[PARAM2:%.+]] = load i[[SZ]], i[[SZ]]* [[AA_CASTED]], align
|
||||
// CHECK-DAG: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i[[SZ]], i[[SZ]])* [[OMP_OUTLINED3:@.+]] to void (i32*, i32*, ...)*), i[[SZ]] [[PARAM1]], i[[SZ]] [[PARAM2]])
|
||||
// CHECK-DAG: [[PARAM3:%.+]] = load i[[SZ]], i[[SZ]]* [[GLOBAL_CASTED]], align
|
||||
// CHECK-DAG: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC]], i32 3, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i[[SZ]], i[[SZ]], i[[SZ]])* [[OMP_OUTLINED3:@.+]] to void (i32*, i32*, ...)*), i[[SZ]] [[PARAM1]], i[[SZ]] [[PARAM2]], i[[SZ]] [[PARAM3]])
|
||||
//
|
||||
//
|
||||
// CHECK: define internal {{.*}}void [[OMP_OUTLINED3]](i32* noalias %.global_tid., i32* noalias %.bound_tid., i[[SZ]] %{{.+}}, i[[SZ]] %{{.+}})
|
||||
// CHECK: define internal {{.*}}void [[OMP_OUTLINED3]](i32* noalias %.global_tid., i32* noalias %.bound_tid., i[[SZ]] %{{.+}}, i[[SZ]] %{{.+}}, i[[SZ]] %{{.+}})
|
||||
// CHECK: [[A_ADDR:%.+]] = alloca i[[SZ]], align
|
||||
// CHECK: [[AA_ADDR:%.+]] = alloca i[[SZ]], align
|
||||
// CHECK: [[GLOBAL_ADDR:%.+]] = alloca i[[SZ]], align
|
||||
// CHECK-DAG: store i[[SZ]] %{{.+}}, i[[SZ]]* [[A_ADDR]], align
|
||||
// CHECK-DAG: store i[[SZ]] %{{.+}}, i[[SZ]]* [[AA_ADDR]], align
|
||||
// CHECK-DAG: store i[[SZ]] %{{.+}}, i[[SZ]]* [[GLOBAL_ADDR]], align
|
||||
// CHECK-64-DAG:[[A_CADDR:%.+]] = bitcast i[[SZ]]* [[A_ADDR]] to i32*
|
||||
// CHECK-DAG: [[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i16*
|
||||
// CHECK-64-DAG:[[GLOBAL_CADDR:%.+]] = bitcast i[[SZ]]* [[GLOBAL_ADDR]] to i32*
|
||||
// CHECK-64: store i32 {{.+}}, i32* [[GLOBAL_CADDR]],
|
||||
// CHECK-32: store i32 {{.+}}, i32* [[GLOBAL_ADDR]],
|
||||
// CHECK: ret void
|
||||
// CHECK-NEXT: }
|
||||
|
||||
|
|
Loading…
Reference in New Issue