@@ -1154,16 +1154,16 @@ llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
1154
1154
}
1155
1155
1156
1156
namespace {
1157
- class CallEndCleanup : public EHScopeStack ::Cleanup {
1158
- public:
1159
- typedef ArrayRef<llvm::Value *> CleanupValuesTy;
1160
- private:
1157
+ template <size_t N> class CallEndCleanup : public EHScopeStack ::Cleanup {
1161
1158
llvm::Value *Callee;
1162
- llvm::SmallVector<llvm:: Value *, 8 > Args;
1159
+ llvm::Value *Args[N] ;
1163
1160
1164
1161
public:
1165
- CallEndCleanup (llvm::Value *Callee, CleanupValuesTy Args)
1166
- : Callee(Callee), Args(Args.begin(), Args.end()) {}
1162
+ CallEndCleanup (llvm::Value *Callee, ArrayRef<llvm::Value *> CleanupArgs)
1163
+ : Callee(Callee) {
1164
+ assert (CleanupArgs.size () == N);
1165
+ std::copy (CleanupArgs.begin (), CleanupArgs.end (), std::begin (Args));
1166
+ }
1167
1167
void Emit (CodeGenFunction &CGF, Flags /* flags*/ ) override {
1168
1168
CGF.EmitRuntimeCall (Callee, Args);
1169
1169
}
@@ -1184,7 +1184,7 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF,
1184
1184
getCriticalRegionLock (CriticalName)};
1185
1185
CGF.EmitRuntimeCall (createRuntimeFunction (OMPRTL__kmpc_critical), Args);
1186
1186
// Build a call to __kmpc_end_critical
1187
- CGF.EHStack .pushCleanup <CallEndCleanup>(
1187
+ CGF.EHStack .pushCleanup <CallEndCleanup<std::extent< decltype (Args)>::value> >(
1188
1188
NormalAndEHCleanup, createRuntimeFunction (OMPRTL__kmpc_end_critical),
1189
1189
llvm::makeArrayRef (Args));
1190
1190
emitInlinedDirective (CGF, CriticalOpGen);
@@ -1220,9 +1220,11 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF,
1220
1220
llvm::Value *Args[] = {emitUpdateLocation (CGF, Loc), getThreadID (CGF, Loc)};
1221
1221
auto *IsMaster =
1222
1222
CGF.EmitRuntimeCall (createRuntimeFunction (OMPRTL__kmpc_master), Args);
1223
+ typedef CallEndCleanup<std::extent<decltype (Args)>::value>
1224
+ MasterCallEndCleanup;
1223
1225
emitIfStmt (CGF, IsMaster, [&](CodeGenFunction &CGF) -> void {
1224
1226
CodeGenFunction::RunCleanupsScope Scope (CGF);
1225
- CGF.EHStack .pushCleanup <CallEndCleanup >(
1227
+ CGF.EHStack .pushCleanup <MasterCallEndCleanup >(
1226
1228
NormalAndEHCleanup, createRuntimeFunction (OMPRTL__kmpc_end_master),
1227
1229
llvm::makeArrayRef (Args));
1228
1230
MasterOpGen (CGF);
@@ -1326,9 +1328,11 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF,
1326
1328
llvm::Value *Args[] = {emitUpdateLocation (CGF, Loc), getThreadID (CGF, Loc)};
1327
1329
auto *IsSingle =
1328
1330
CGF.EmitRuntimeCall (createRuntimeFunction (OMPRTL__kmpc_single), Args);
1331
+ typedef CallEndCleanup<std::extent<decltype (Args)>::value>
1332
+ SingleCallEndCleanup;
1329
1333
emitIfStmt (CGF, IsSingle, [&](CodeGenFunction &CGF) -> void {
1330
1334
CodeGenFunction::RunCleanupsScope Scope (CGF);
1331
- CGF.EHStack .pushCleanup <CallEndCleanup >(
1335
+ CGF.EHStack .pushCleanup <SingleCallEndCleanup >(
1332
1336
NormalAndEHCleanup, createRuntimeFunction (OMPRTL__kmpc_end_single),
1333
1337
llvm::makeArrayRef (Args));
1334
1338
SingleOpGen (CGF);
@@ -1391,7 +1395,7 @@ void CGOpenMPRuntime::emitOrderedRegion(CodeGenFunction &CGF,
1391
1395
llvm::Value *Args[] = {emitUpdateLocation (CGF, Loc), getThreadID (CGF, Loc)};
1392
1396
CGF.EmitRuntimeCall (createRuntimeFunction (OMPRTL__kmpc_ordered), Args);
1393
1397
// Build a call to __kmpc_end_ordered
1394
- CGF.EHStack .pushCleanup <CallEndCleanup>(
1398
+ CGF.EHStack .pushCleanup <CallEndCleanup<std::extent< decltype (Args)>::value> >(
1395
1399
NormalAndEHCleanup, createRuntimeFunction (OMPRTL__kmpc_end_ordered),
1396
1400
llvm::makeArrayRef (Args));
1397
1401
emitInlinedDirective (CGF, OrderedOpGen);
@@ -1991,6 +1995,8 @@ void CGOpenMPRuntime::emitTaskCall(
1991
1995
// TODO: add check for untied tasks.
1992
1996
CGF.EmitRuntimeCall (createRuntimeFunction (OMPRTL__kmpc_omp_task), TaskArgs);
1993
1997
};
1998
+ typedef CallEndCleanup<std::extent<decltype (TaskArgs)>::value>
1999
+ IfCallEndCleanup;
1994
2000
auto &&ElseCodeGen =
1995
2001
[this , &TaskArgs, ThreadID, NewTaskNewTaskTTy, TaskEntry](
1996
2002
CodeGenFunction &CGF) {
@@ -1999,7 +2005,7 @@ void CGOpenMPRuntime::emitTaskCall(
1999
2005
createRuntimeFunction (OMPRTL__kmpc_omp_task_begin_if0), TaskArgs);
2000
2006
// Build void __kmpc_omp_task_complete_if0(ident_t *, kmp_int32 gtid,
2001
2007
// kmp_task_t *new_task);
2002
- CGF.EHStack .pushCleanup <CallEndCleanup >(
2008
+ CGF.EHStack .pushCleanup <IfCallEndCleanup >(
2003
2009
NormalAndEHCleanup,
2004
2010
createRuntimeFunction (OMPRTL__kmpc_omp_task_complete_if0),
2005
2011
llvm::makeArrayRef (TaskArgs));
@@ -2191,11 +2197,12 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
2191
2197
ThreadId, // i32 <gtid>
2192
2198
Lock // kmp_critical_name *&<lock>
2193
2199
};
2194
- CGF.EHStack .pushCleanup <CallEndCleanup>(
2195
- NormalAndEHCleanup,
2196
- createRuntimeFunction (WithNowait ? OMPRTL__kmpc_end_reduce_nowait
2197
- : OMPRTL__kmpc_end_reduce),
2198
- llvm::makeArrayRef (EndArgs));
2200
+ CGF.EHStack
2201
+ .pushCleanup <CallEndCleanup<std::extent<decltype (EndArgs)>::value>>(
2202
+ NormalAndEHCleanup,
2203
+ createRuntimeFunction (WithNowait ? OMPRTL__kmpc_end_reduce_nowait
2204
+ : OMPRTL__kmpc_end_reduce),
2205
+ llvm::makeArrayRef (EndArgs));
2199
2206
for (auto *E : ReductionOps) {
2200
2207
CGF.EmitIgnoredExpr (E);
2201
2208
}
0 commit comments