forked from OSchip/llvm-project
[OPENMP] Fix for PR33922: New ident_t flags for
__kmpc_for_static_fini(). Added special flags for calls of __kmpc_for_static_fini(), like previous ly for __kmpc_for_static_init(). Added flag OMP_IDENT_WORK_DISTRIBUTE for distribute cnstruct, OMP_IDENT_WORK_SECTIONS for sections-based constructs and OMP_IDENT_WORK_LOOP for loop-based constructs in location flags. llvm-svn: 312642
This commit is contained in:
parent
818d50a93d
commit
f43f714213
|
@ -3059,11 +3059,19 @@ void CGOpenMPRuntime::emitDistributeStaticInit(
|
|||
}
|
||||
|
||||
void CGOpenMPRuntime::emitForStaticFinish(CodeGenFunction &CGF,
|
||||
SourceLocation Loc) {
|
||||
SourceLocation Loc,
|
||||
OpenMPDirectiveKind DKind) {
|
||||
if (!CGF.HaveInsertPoint())
|
||||
return;
|
||||
// Call __kmpc_for_static_fini(ident_t *loc, kmp_int32 tid);
|
||||
llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
|
||||
llvm::Value *Args[] = {
|
||||
emitUpdateLocation(CGF, Loc,
|
||||
isOpenMPDistributeDirective(DKind)
|
||||
? OMP_IDENT_WORK_DISTRIBUTE
|
||||
: isOpenMPLoopDirective(DKind)
|
||||
? OMP_IDENT_WORK_LOOP
|
||||
: OMP_IDENT_WORK_SECTIONS),
|
||||
getThreadID(CGF, Loc)};
|
||||
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_for_static_fini),
|
||||
Args);
|
||||
}
|
||||
|
|
|
@ -883,8 +883,10 @@ public:
|
|||
///
|
||||
/// \param CGF Reference to current CodeGenFunction.
|
||||
/// \param Loc Clang source location.
|
||||
/// \param DKind Kind of the directive for which the static finish is emitted.
|
||||
///
|
||||
virtual void emitForStaticFinish(CodeGenFunction &CGF, SourceLocation Loc);
|
||||
virtual void emitForStaticFinish(CodeGenFunction &CGF, SourceLocation Loc,
|
||||
OpenMPDirectiveKind DKind);
|
||||
|
||||
/// Call __kmpc_dispatch_next(
|
||||
/// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter,
|
||||
|
|
|
@ -1692,7 +1692,8 @@ void CodeGenFunction::EmitOMPOuterLoop(
|
|||
// Tell the runtime we are done.
|
||||
auto &&CodeGen = [DynamicOrOrdered, &S](CodeGenFunction &CGF) {
|
||||
if (!DynamicOrOrdered)
|
||||
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd());
|
||||
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(),
|
||||
S.getDirectiveKind());
|
||||
};
|
||||
OMPCancelStack.emitExit(*this, S.getDirectiveKind(), CodeGen);
|
||||
}
|
||||
|
@ -2256,7 +2257,8 @@ bool CodeGenFunction::EmitOMPWorksharingLoop(
|
|||
EmitBlock(LoopExit.getBlock());
|
||||
// Tell the runtime we are done.
|
||||
auto &&CodeGen = [&S](CodeGenFunction &CGF) {
|
||||
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd());
|
||||
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(),
|
||||
S.getDirectiveKind());
|
||||
};
|
||||
OMPCancelStack.emitExit(*this, S.getDirectiveKind(), CodeGen);
|
||||
} else {
|
||||
|
@ -2487,7 +2489,8 @@ void CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
|
|||
[](CodeGenFunction &) {});
|
||||
// Tell the runtime we are done.
|
||||
auto &&CodeGen = [&S](CodeGenFunction &CGF) {
|
||||
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd());
|
||||
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(),
|
||||
S.getDirectiveKind());
|
||||
};
|
||||
CGF.OMPCancelStack.emitExit(CGF, S.getDirectiveKind(), CodeGen);
|
||||
CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_parallel);
|
||||
|
@ -3120,7 +3123,7 @@ void CodeGenFunction::EmitOMPDistributeLoop(const OMPLoopDirective &S,
|
|||
[](CodeGenFunction &) {});
|
||||
EmitBlock(LoopExit.getBlock());
|
||||
// Tell the runtime we are done.
|
||||
RT.emitForStaticFinish(*this, S.getLocStart());
|
||||
RT.emitForStaticFinish(*this, S.getLocStart(), S.getDirectiveKind());
|
||||
} else {
|
||||
// Emit the outer loop, which requests its work chunk [LB..UB] from
|
||||
// runtime and runs the inner loop to process it.
|
||||
|
|
|
@ -83,7 +83,7 @@ void without_schedule_clause(float *a, float *b, float *c, float *d) {
|
|||
// CHECK: [[BBINNEND]]:
|
||||
// CHECK: br label %[[LPEXIT:.+]]
|
||||
// CHECK: [[LPEXIT]]:
|
||||
// CHECK: call void @__kmpc_for_static_fini(%ident_t* [[DEF_LOC_0]], i32 [[GBL_TIDV]])
|
||||
// CHECK: call void @__kmpc_for_static_fini(%ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
|
||||
// CHECK: ret void
|
||||
|
||||
|
||||
|
@ -145,7 +145,7 @@ void static_not_chunked(float *a, float *b, float *c, float *d) {
|
|||
// CHECK: [[BBINNEND]]:
|
||||
// CHECK: br label %[[LPEXIT:.+]]
|
||||
// CHECK: [[LPEXIT]]:
|
||||
// CHECK: call void @__kmpc_for_static_fini(%ident_t* [[DEF_LOC_0]], i32 [[GBL_TIDV]])
|
||||
// CHECK: call void @__kmpc_for_static_fini(%ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
|
||||
// CHECK: ret void
|
||||
|
||||
|
||||
|
@ -207,7 +207,7 @@ void static_chunked(float *a, float *b, float *c, float *d) {
|
|||
// CHECK: [[BBINNEND]]:
|
||||
// CHECK: br label %[[LPEXIT:.+]]
|
||||
// CHECK: [[LPEXIT]]:
|
||||
// CHECK: call void @__kmpc_for_static_fini(%ident_t* [[DEF_LOC_0]], i32 [[GBL_TIDV]])
|
||||
// CHECK: call void @__kmpc_for_static_fini(%ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
|
||||
// CHECK: ret void
|
||||
|
||||
// CHECK-LABEL: test_precond
|
||||
|
|
|
@ -52,7 +52,7 @@ void without_schedule_clause(float *a, float *b, float *c, float *d) {
|
|||
// CHECK-NEXT: br label %{{.+}}
|
||||
}
|
||||
// CHECK: [[LOOP1_END]]
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID]])
|
||||
// CHECK-NOT: __kmpc_barrier
|
||||
// CHECK: ret void
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void static_not_chunked(float *a, float *b, float *c, float *d) {
|
|||
// CHECK-NEXT: br label %{{.+}}
|
||||
}
|
||||
// CHECK: [[LOOP1_END]]
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID]])
|
||||
// CHECK: call {{.+}} @__kmpc_barrier([[IDENT_T_TY]]* [[IMPLICIT_BARRIER_LOC]], i32 [[GTID]])
|
||||
// CHECK: ret void
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ void static_chunked(float *a, float *b, float *c, float *d) {
|
|||
// CHECK-NEXT: store i32 [[ADD_UB]], i32* [[OMP_UB]]
|
||||
|
||||
// CHECK: [[O_LOOP1_END]]
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID]])
|
||||
// CHECK: call {{.+}} @__kmpc_barrier([[IDENT_T_TY]]* [[IMPLICIT_BARRIER_LOC]], i32 [[GTID]])
|
||||
// CHECK: ret void
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ void with_var_schedule() {
|
|||
// CHECK: [[CHUNK_VAL:%.+]] = load i8, i8* [[CHUNK]],
|
||||
// CHECK: [[CHUNK_SIZE:%.+]] = sext i8 [[CHUNK_VAL]] to i64
|
||||
// CHECK: call void @__kmpc_for_static_init_8u([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID:%[^,]+]], i32 33, i32* [[IS_LAST:%[^,]+]], i64* [[OMP_LB:%[^,]+]], i64* [[OMP_UB:%[^,]+]], i64* [[OMP_ST:%[^,]+]], i64 1, i64 [[CHUNK_SIZE]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[DEFAULT_LOC:@[^,]+]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID]])
|
||||
#pragma omp parallel for schedule(static, char(a))
|
||||
for (unsigned long long i = 1; i < 2; ++i) {
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void without_schedule_clause(float *a, float *b, float *c, float *d) {
|
|||
// CHECK-NEXT: br label %{{.+}}
|
||||
}
|
||||
// CHECK: [[LOOP1_END]]
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID]])
|
||||
// CHECK: ret void
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ void static_not_chunked(float *a, float *b, float *c, float *d) {
|
|||
// CHECK-NEXT: br label %{{.+}}
|
||||
}
|
||||
// CHECK: [[LOOP1_END]]
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID]])
|
||||
// CHECK: ret void
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ void static_chunked(float *a, float *b, float *c, float *d) {
|
|||
// CHECK-NEXT: store i32 [[ADD_UB]], i32* [[OMP_UB]]
|
||||
|
||||
// CHECK: [[O_LOOP1_END]]
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 [[GTID]])
|
||||
// CHECK: ret void
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ int main() {
|
|||
// CHECK-NEXT: br label %[[INNER_FOR_COND]]
|
||||
// CHECK: [[INNER_LOOP_END]]
|
||||
}
|
||||
// CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_for_static_fini(%{{.+}}* [[SECTIONS_LOC]], i32 [[GTID]])
|
||||
// CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_SECTIONS_LOC]],
|
||||
#pragma omp sections nowait
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue