forked from OSchip/llvm-project
[OPENMP50]Codegen for 'destroy' clause in depobj directive.
If the destroy clause is appplied, the previously allocated memory for the dependency object must be destroyed.
This commit is contained in:
parent
f545ede91c
commit
b27ff4d07d
|
@ -5318,6 +5318,18 @@ Address CGOpenMPRuntime::emitDependClause(
|
|||
return DependenciesArray;
|
||||
}
|
||||
|
||||
void CGOpenMPRuntime::emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
|
||||
SourceLocation Loc) {
|
||||
llvm::Value *DepObjAddr = CGF.EmitLoadOfScalar(DepobjLVal, Loc);
|
||||
llvm::Value *ThreadID = getThreadID(CGF, Loc);
|
||||
// Use default allocator.
|
||||
llvm::Value *Allocator = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
|
||||
llvm::Value *Args[] = {ThreadID, DepObjAddr, Allocator};
|
||||
|
||||
// _kmpc_free(gtid, addr, nullptr);
|
||||
(void)CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_free), Args);
|
||||
}
|
||||
|
||||
void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
|
||||
const OMPExecutableDirective &D,
|
||||
llvm::Function *TaskFunction,
|
||||
|
|
|
@ -1786,6 +1786,11 @@ public:
|
|||
CodeGenFunction &CGF,
|
||||
ArrayRef<std::pair<OpenMPDependClauseKind, const Expr *>> Dependencies,
|
||||
bool ForDepobj, SourceLocation Loc);
|
||||
|
||||
/// Emits the code to destroy the dependency object provided in depobj
|
||||
/// directive.
|
||||
void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
|
||||
SourceLocation Loc);
|
||||
};
|
||||
|
||||
/// Class supports emissionof SIMD-only code.
|
||||
|
|
|
@ -3811,6 +3811,11 @@ void CodeGenFunction::EmitOMPDepobjDirective(const OMPDepobjDirective &S) {
|
|||
Address DepAddr = CGM.getOpenMPRuntime().emitDependClause(
|
||||
*this, Dependencies, /*ForDepobj=*/true, DC->getBeginLoc());
|
||||
EmitStoreOfScalar(DepAddr.getPointer(), DOLVal);
|
||||
return;
|
||||
}
|
||||
if (const auto *DC = S.getSingleClause<OMPDestroyClause>()) {
|
||||
CGM.getOpenMPRuntime().emitDestroyClause(*this, DOLVal, DC->getBeginLoc());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
// CHECK-LABEL: @main
|
||||
// CHECK: [[B_ADDR:%.+]] = alloca i8*,
|
||||
// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
|
||||
// CHECK: [[DEP_ADDR_VOID:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 72, i8* null)
|
||||
// CHECK: [[DEP_ADDR:%.+]] = bitcast i8* [[DEP_ADDR_VOID]] to [3 x %struct.kmp_depend_info]*
|
||||
|
@ -61,8 +62,11 @@ int main(int argc, char **argv) {
|
|||
// CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 0
|
||||
// CHECK: [[DEP:%.+]] = bitcast %struct.kmp_depend_info* [[BASE_ADDR]] to i8*
|
||||
// CHECK: store i8* [[DEP]], i8** [[MAIN_A]],
|
||||
// CHECK: [[B:%.+]] = load i8*, i8** [[B_ADDR]],
|
||||
// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[B]], i8* null)
|
||||
|
||||
// CHECK-LABEL: tmain
|
||||
// CHECK: [[ARGC_ADDR:%.+]] = alloca i8*,
|
||||
// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
|
||||
// CHECK: [[DEP_ADDR_VOID:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 48, i8* null)
|
||||
// CHECK: [[DEP_ADDR:%.+]] = bitcast i8* [[DEP_ADDR_VOID]] to [2 x %struct.kmp_depend_info]*
|
||||
|
@ -79,5 +83,7 @@ int main(int argc, char **argv) {
|
|||
// CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [2 x %struct.kmp_depend_info], [2 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 0
|
||||
// CHECK: [[DEP:%.+]] = bitcast %struct.kmp_depend_info* [[BASE_ADDR]] to i8*
|
||||
// CHECK: store i8* [[DEP]], i8** [[TMAIN_A]],
|
||||
// CHECK: [[ARGC:%.+]] = load i8*, i8** [[ARGC_ADDR]],
|
||||
// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[ARGC]], i8* null)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue