blob: b3e5c1123ce2ab30eebbe9e13d5692a7640a4b82 [file] [log] [blame]
Alexey Bataev9959db52014-05-06 10:08:46 +00001//===----- CGOpenMPRuntime.cpp - Interface to OpenMP Runtimes -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This provides a class for OpenMP runtime code generation.
11//
12//===----------------------------------------------------------------------===//
13
14#include "CGOpenMPRuntime.h"
15#include "CodeGenFunction.h"
Alexey Bataev18095712014-10-10 12:19:54 +000016#include "clang/AST/StmtOpenMP.h"
Alexey Bataev9959db52014-05-06 10:08:46 +000017#include "clang/AST/Decl.h"
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/IR/DerivedTypes.h"
20#include "llvm/IR/GlobalValue.h"
21#include "llvm/IR/Value.h"
22#include "llvm/Support/raw_ostream.h"
Alexey Bataev23b69422014-06-18 07:08:49 +000023#include <cassert>
Alexey Bataev9959db52014-05-06 10:08:46 +000024
25using namespace clang;
26using namespace CodeGen;
27
Benjamin Kramerc52193f2014-10-10 13:57:57 +000028namespace {
Alexey Bataev18095712014-10-10 12:19:54 +000029/// \brief API for captured statement code generation in OpenMP constructs.
30class CGOpenMPRegionInfo : public CodeGenFunction::CGCapturedStmtInfo {
31public:
32 CGOpenMPRegionInfo(const OMPExecutableDirective &D, const CapturedStmt &CS,
33 const VarDecl *ThreadIDVar)
34 : CGCapturedStmtInfo(CS, CR_OpenMP), ThreadIDVar(ThreadIDVar),
35 Directive(D) {
36 assert(ThreadIDVar != nullptr && "No ThreadID in OpenMP region.");
37 }
38
Alexey Bataev18095712014-10-10 12:19:54 +000039 /// \brief Gets a variable or parameter for storing global thread id
40 /// inside OpenMP construct.
41 const VarDecl *getThreadIDVariable() const { return ThreadIDVar; }
42
43 /// \brief Gets an LValue for the current ThreadID variable.
44 LValue getThreadIDVariableLValue(CodeGenFunction &CGF);
45
46 static bool classof(const CGCapturedStmtInfo *Info) {
47 return Info->getKind() == CR_OpenMP;
48 }
49
50 /// \brief Emit the captured statement body.
Benjamin Kramerc52193f2014-10-10 13:57:57 +000051 void EmitBody(CodeGenFunction &CGF, Stmt *S) override;
Alexey Bataev18095712014-10-10 12:19:54 +000052
53 /// \brief Get the name of the capture helper.
Benjamin Kramerc52193f2014-10-10 13:57:57 +000054 StringRef getHelperName() const override { return ".omp_outlined."; }
Alexey Bataev18095712014-10-10 12:19:54 +000055
56private:
57 /// \brief A variable or parameter storing global thread id for OpenMP
58 /// constructs.
59 const VarDecl *ThreadIDVar;
60 /// \brief OpenMP executable directive associated with the region.
61 const OMPExecutableDirective &Directive;
62};
Benjamin Kramerc52193f2014-10-10 13:57:57 +000063} // namespace
Alexey Bataev18095712014-10-10 12:19:54 +000064
65LValue CGOpenMPRegionInfo::getThreadIDVariableLValue(CodeGenFunction &CGF) {
66 return CGF.MakeNaturalAlignAddrLValue(
67 CGF.GetAddrOfLocalVar(ThreadIDVar),
68 CGF.getContext().getPointerType(ThreadIDVar->getType()));
69}
70
Alexey Bataev4a5bb772014-10-08 14:01:46 +000071void CGOpenMPRegionInfo::EmitBody(CodeGenFunction &CGF, Stmt *S) {
Alexey Bataev435ad7b2014-10-10 09:48:26 +000072 CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
73 CGF.EmitOMPFirstprivateClause(Directive, PrivateScope);
74 if (PrivateScope.Privatize()) {
Alexey Bataev4a5bb772014-10-08 14:01:46 +000075 // Emit implicit barrier to synchronize threads and avoid data races.
76 auto Flags = static_cast<CGOpenMPRuntime::OpenMPLocationFlags>(
77 CGOpenMPRuntime::OMP_IDENT_KMPC |
78 CGOpenMPRuntime::OMP_IDENT_BARRIER_IMPL);
79 CGF.CGM.getOpenMPRuntime().EmitOMPBarrierCall(CGF, Directive.getLocStart(),
80 Flags);
Alexey Bataev4a5bb772014-10-08 14:01:46 +000081 }
82 CGCapturedStmtInfo::EmitBody(CGF, S);
Alexey Bataev4a5bb772014-10-08 14:01:46 +000083}
84
Alexey Bataev9959db52014-05-06 10:08:46 +000085CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM)
86 : CGM(CGM), DefaultOpenMPPSource(nullptr) {
87 IdentTy = llvm::StructType::create(
88 "ident_t", CGM.Int32Ty /* reserved_1 */, CGM.Int32Ty /* flags */,
89 CGM.Int32Ty /* reserved_2 */, CGM.Int32Ty /* reserved_3 */,
Alexander Musmanfdfa8552014-09-11 08:10:57 +000090 CGM.Int8PtrTy /* psource */, nullptr);
Alexey Bataev9959db52014-05-06 10:08:46 +000091 // Build void (*kmpc_micro)(kmp_int32 *global_tid, kmp_int32 *bound_tid,...)
Alexey Bataev23b69422014-06-18 07:08:49 +000092 llvm::Type *MicroParams[] = {llvm::PointerType::getUnqual(CGM.Int32Ty),
93 llvm::PointerType::getUnqual(CGM.Int32Ty)};
Alexey Bataev9959db52014-05-06 10:08:46 +000094 Kmpc_MicroTy = llvm::FunctionType::get(CGM.VoidTy, MicroParams, true);
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +000095 KmpCriticalNameTy = llvm::ArrayType::get(CGM.Int32Ty, /*NumElements*/ 8);
Alexey Bataev9959db52014-05-06 10:08:46 +000096}
97
98llvm::Value *
Alexey Bataev18095712014-10-10 12:19:54 +000099CGOpenMPRuntime::EmitOpenMPOutlinedFunction(const OMPExecutableDirective &D,
100 const VarDecl *ThreadIDVar) {
101 const CapturedStmt *CS = cast<CapturedStmt>(D.getAssociatedStmt());
102 CodeGenFunction CGF(CGM, true);
103 CGOpenMPRegionInfo CGInfo(D, *CS, ThreadIDVar);
104 CGF.CapturedStmtInfo = &CGInfo;
105 return CGF.GenerateCapturedStmtFunction(*CS);
106}
107
108llvm::Value *
Alexey Bataev9959db52014-05-06 10:08:46 +0000109CGOpenMPRuntime::GetOrCreateDefaultOpenMPLocation(OpenMPLocationFlags Flags) {
Alexey Bataev15007ba2014-05-07 06:18:01 +0000110 llvm::Value *Entry = OpenMPDefaultLocMap.lookup(Flags);
Alexey Bataev9959db52014-05-06 10:08:46 +0000111 if (!Entry) {
112 if (!DefaultOpenMPPSource) {
113 // Initialize default location for psource field of ident_t structure of
114 // all ident_t objects. Format is ";file;function;line;column;;".
115 // Taken from
116 // http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp_str.c
117 DefaultOpenMPPSource =
118 CGM.GetAddrOfConstantCString(";unknown;unknown;0;0;;");
119 DefaultOpenMPPSource =
120 llvm::ConstantExpr::getBitCast(DefaultOpenMPPSource, CGM.Int8PtrTy);
121 }
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000122 auto DefaultOpenMPLocation = new llvm::GlobalVariable(
123 CGM.getModule(), IdentTy, /*isConstant*/ true,
124 llvm::GlobalValue::PrivateLinkage, /*Initializer*/ nullptr);
Alexey Bataev9959db52014-05-06 10:08:46 +0000125 DefaultOpenMPLocation->setUnnamedAddr(true);
Alexey Bataev9959db52014-05-06 10:08:46 +0000126
127 llvm::Constant *Zero = llvm::ConstantInt::get(CGM.Int32Ty, 0, true);
Alexey Bataev23b69422014-06-18 07:08:49 +0000128 llvm::Constant *Values[] = {Zero,
129 llvm::ConstantInt::get(CGM.Int32Ty, Flags),
130 Zero, Zero, DefaultOpenMPPSource};
Alexey Bataev9959db52014-05-06 10:08:46 +0000131 llvm::Constant *Init = llvm::ConstantStruct::get(IdentTy, Values);
132 DefaultOpenMPLocation->setInitializer(Init);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000133 OpenMPDefaultLocMap[Flags] = DefaultOpenMPLocation;
Alexey Bataev9959db52014-05-06 10:08:46 +0000134 return DefaultOpenMPLocation;
135 }
136 return Entry;
137}
138
139llvm::Value *CGOpenMPRuntime::EmitOpenMPUpdateLocation(
140 CodeGenFunction &CGF, SourceLocation Loc, OpenMPLocationFlags Flags) {
141 // If no debug info is generated - return global default location.
142 if (CGM.getCodeGenOpts().getDebugInfo() == CodeGenOptions::NoDebugInfo ||
143 Loc.isInvalid())
144 return GetOrCreateDefaultOpenMPLocation(Flags);
145
146 assert(CGF.CurFn && "No function in current CodeGenFunction.");
147
Alexey Bataev9959db52014-05-06 10:08:46 +0000148 llvm::Value *LocValue = nullptr;
Alexey Bataev18095712014-10-10 12:19:54 +0000149 OpenMPLocThreadIDMapTy::iterator I = OpenMPLocThreadIDMap.find(CGF.CurFn);
150 if (I != OpenMPLocThreadIDMap.end()) {
151 LocValue = I->second.DebugLoc;
Alexey Bataev9959db52014-05-06 10:08:46 +0000152 } else {
Alexey Bataev15007ba2014-05-07 06:18:01 +0000153 // Generate "ident_t .kmpc_loc.addr;"
154 llvm::AllocaInst *AI = CGF.CreateTempAlloca(IdentTy, ".kmpc_loc.addr");
Alexey Bataev9959db52014-05-06 10:08:46 +0000155 AI->setAlignment(CGM.getDataLayout().getPrefTypeAlignment(IdentTy));
Alexey Bataev18095712014-10-10 12:19:54 +0000156 auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
157 Elem.second.DebugLoc = AI;
Alexey Bataev9959db52014-05-06 10:08:46 +0000158 LocValue = AI;
159
160 CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
161 CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
162 CGF.Builder.CreateMemCpy(LocValue, GetOrCreateDefaultOpenMPLocation(Flags),
163 llvm::ConstantExpr::getSizeOf(IdentTy),
164 CGM.PointerAlignInBytes);
165 }
166
167 // char **psource = &.kmpc_loc_<flags>.addr.psource;
168 llvm::Value *PSource =
169 CGF.Builder.CreateConstInBoundsGEP2_32(LocValue, 0, IdentField_PSource);
170
Alexey Bataevf002aca2014-05-30 05:48:40 +0000171 auto OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc.getRawEncoding());
172 if (OMPDebugLoc == nullptr) {
173 SmallString<128> Buffer2;
174 llvm::raw_svector_ostream OS2(Buffer2);
175 // Build debug location
176 PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
177 OS2 << ";" << PLoc.getFilename() << ";";
178 if (const FunctionDecl *FD =
179 dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl)) {
180 OS2 << FD->getQualifiedNameAsString();
181 }
182 OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
183 OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(OS2.str());
184 OpenMPDebugLocMap[Loc.getRawEncoding()] = OMPDebugLoc;
Alexey Bataev9959db52014-05-06 10:08:46 +0000185 }
Alexey Bataev9959db52014-05-06 10:08:46 +0000186 // *psource = ";<File>;<Function>;<Line>;<Column>;;";
Alexey Bataevf002aca2014-05-30 05:48:40 +0000187 CGF.Builder.CreateStore(OMPDebugLoc, PSource);
188
Alexey Bataev9959db52014-05-06 10:08:46 +0000189 return LocValue;
190}
191
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000192llvm::Value *CGOpenMPRuntime::GetOpenMPThreadID(CodeGenFunction &CGF,
193 SourceLocation Loc) {
Alexey Bataev9959db52014-05-06 10:08:46 +0000194 assert(CGF.CurFn && "No function in current CodeGenFunction.");
195
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000196 llvm::Value *ThreadID = nullptr;
Alexey Bataev18095712014-10-10 12:19:54 +0000197 // Check whether we've already cached a load of the thread id in this
198 // function.
199 OpenMPLocThreadIDMapTy::iterator I = OpenMPLocThreadIDMap.find(CGF.CurFn);
200 if (I != OpenMPLocThreadIDMap.end()) {
201 ThreadID = I->second.ThreadID;
202 } else if (auto OMPRegionInfo =
203 dyn_cast_or_null<CGOpenMPRegionInfo>(CGF.CapturedStmtInfo)) {
204 // Check if this an outlined function with thread id passed as argument.
205 auto ThreadIDVar = OMPRegionInfo->getThreadIDVariable();
206 auto LVal = OMPRegionInfo->getThreadIDVariableLValue(CGF);
207 auto RVal = CGF.EmitLoadOfLValue(LVal, Loc);
208 LVal = CGF.MakeNaturalAlignAddrLValue(RVal.getScalarVal(),
209 ThreadIDVar->getType());
210 ThreadID = CGF.EmitLoadOfLValue(LVal, Loc).getScalarVal();
211 // If value loaded in entry block, cache it and use it everywhere in
212 // function.
213 if (CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
214 auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
215 Elem.second.ThreadID = ThreadID;
Alexey Bataevd6c57552014-07-25 07:55:17 +0000216 }
Alexey Bataev18095712014-10-10 12:19:54 +0000217 } else {
218 // This is not an outlined function region - need to call __kmpc_int32
219 // kmpc_global_thread_num(ident_t *loc).
220 // Generate thread id value and cache this value for use across the
221 // function.
222 CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
223 CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
224 llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc)};
225 ThreadID = CGF.EmitRuntimeCall(
226 CreateRuntimeFunction(OMPRTL__kmpc_global_thread_num), Args);
227 auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
228 Elem.second.ThreadID = ThreadID;
Alexey Bataev9959db52014-05-06 10:08:46 +0000229 }
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000230 return ThreadID;
Alexey Bataev9959db52014-05-06 10:08:46 +0000231}
232
233void CGOpenMPRuntime::FunctionFinished(CodeGenFunction &CGF) {
234 assert(CGF.CurFn && "No function in current CodeGenFunction.");
Benjamin Kramerad8e0792014-10-10 15:32:48 +0000235 OpenMPLocThreadIDMap.erase(CGF.CurFn);
Alexey Bataev9959db52014-05-06 10:08:46 +0000236}
237
238llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
239 return llvm::PointerType::getUnqual(IdentTy);
240}
241
242llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() {
243 return llvm::PointerType::getUnqual(Kmpc_MicroTy);
244}
245
246llvm::Constant *
247CGOpenMPRuntime::CreateRuntimeFunction(OpenMPRTLFunction Function) {
248 llvm::Constant *RTLFn = nullptr;
249 switch (Function) {
250 case OMPRTL__kmpc_fork_call: {
251 // Build void __kmpc_fork_call(ident_t *loc, kmp_int32 argc, kmpc_micro
252 // microtask, ...);
Alexey Bataev23b69422014-06-18 07:08:49 +0000253 llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty,
254 getKmpc_MicroPointerTy()};
Alexey Bataev9959db52014-05-06 10:08:46 +0000255 llvm::FunctionType *FnTy =
256 llvm::FunctionType::get(CGM.VoidTy, TypeParams, true);
257 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_fork_call");
258 break;
259 }
260 case OMPRTL__kmpc_global_thread_num: {
261 // Build kmp_int32 __kmpc_global_thread_num(ident_t *loc);
Alexey Bataev23b69422014-06-18 07:08:49 +0000262 llvm::Type *TypeParams[] = {getIdentTyPointerTy()};
Alexey Bataev9959db52014-05-06 10:08:46 +0000263 llvm::FunctionType *FnTy =
264 llvm::FunctionType::get(CGM.Int32Ty, TypeParams, false);
265 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_global_thread_num");
266 break;
267 }
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000268 case OMPRTL__kmpc_critical: {
Alexey Bataevf9472182014-09-22 12:32:31 +0000269 // Build void __kmpc_critical(ident_t *loc, kmp_int32 global_tid,
270 // kmp_critical_name *crit);
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000271 llvm::Type *TypeParams[] = {
272 getIdentTyPointerTy(), CGM.Int32Ty,
273 llvm::PointerType::getUnqual(KmpCriticalNameTy)};
274 llvm::FunctionType *FnTy =
275 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
276 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_critical");
277 break;
278 }
279 case OMPRTL__kmpc_end_critical: {
Alexey Bataevf9472182014-09-22 12:32:31 +0000280 // Build void __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid,
281 // kmp_critical_name *crit);
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000282 llvm::Type *TypeParams[] = {
283 getIdentTyPointerTy(), CGM.Int32Ty,
284 llvm::PointerType::getUnqual(KmpCriticalNameTy)};
285 llvm::FunctionType *FnTy =
286 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
287 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_end_critical");
288 break;
289 }
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000290 case OMPRTL__kmpc_barrier: {
291 // Build void __kmpc_barrier(ident_t *loc, kmp_int32 global_tid);
292 llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty};
293 llvm::FunctionType *FnTy =
294 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
295 RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name*/ "__kmpc_barrier");
296 break;
297 }
Alexey Bataev9959db52014-05-06 10:08:46 +0000298 }
299 return RTLFn;
300}
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000301
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000302void CGOpenMPRuntime::EmitOMPParallelCall(CodeGenFunction &CGF,
303 SourceLocation Loc,
304 llvm::Value *OutlinedFn,
305 llvm::Value *CapturedStruct) {
306 // Build call __kmpc_fork_call(loc, 1, microtask, captured_struct/*context*/)
307 llvm::Value *Args[] = {
308 EmitOpenMPUpdateLocation(CGF, Loc),
309 CGF.Builder.getInt32(1), // Number of arguments after 'microtask' argument
310 // (there is only one additional argument - 'context')
311 CGF.Builder.CreateBitCast(OutlinedFn, getKmpc_MicroPointerTy()),
312 CGF.EmitCastToVoidPtr(CapturedStruct)};
313 auto RTLFn = CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_fork_call);
314 CGF.EmitRuntimeCall(RTLFn, Args);
315}
316
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000317llvm::Value *CGOpenMPRuntime::GetCriticalRegionLock(StringRef CriticalName) {
318 SmallString<256> Buffer;
319 llvm::raw_svector_ostream Out(Buffer);
320 Out << ".gomp_critical_user_" << CriticalName << ".var";
321 auto RuntimeCriticalName = Out.str();
322 auto &Elem = CriticalRegionVarNames.GetOrCreateValue(RuntimeCriticalName);
323 if (Elem.getValue() != nullptr)
324 return Elem.getValue();
325
326 auto Lock = new llvm::GlobalVariable(
327 CGM.getModule(), KmpCriticalNameTy, /*IsConstant*/ false,
328 llvm::GlobalValue::CommonLinkage,
329 llvm::Constant::getNullValue(KmpCriticalNameTy), Elem.getKey());
330 Elem.setValue(Lock);
331 return Lock;
332}
333
334void CGOpenMPRuntime::EmitOMPCriticalRegionStart(CodeGenFunction &CGF,
335 llvm::Value *RegionLock,
336 SourceLocation Loc) {
337 // Prepare other arguments and build a call to __kmpc_critical
338 llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc),
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000339 GetOpenMPThreadID(CGF, Loc), RegionLock};
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000340 auto RTLFn = CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_critical);
341 CGF.EmitRuntimeCall(RTLFn, Args);
342}
343
344void CGOpenMPRuntime::EmitOMPCriticalRegionEnd(CodeGenFunction &CGF,
345 llvm::Value *RegionLock,
346 SourceLocation Loc) {
Alexey Bataevf9472182014-09-22 12:32:31 +0000347 // Prepare other arguments and build a call to __kmpc_end_critical
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000348 llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc),
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000349 GetOpenMPThreadID(CGF, Loc), RegionLock};
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000350 auto RTLFn =
351 CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_end_critical);
352 CGF.EmitRuntimeCall(RTLFn, Args);
353}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000354
355void CGOpenMPRuntime::EmitOMPBarrierCall(CodeGenFunction &CGF,
356 SourceLocation Loc,
357 OpenMPLocationFlags Flags) {
358 // Build call __kmpc_barrier(loc, thread_id)
359 llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc, Flags),
360 GetOpenMPThreadID(CGF, Loc)};
361 auto RTLFn = CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_barrier);
362 CGF.EmitRuntimeCall(RTLFn, Args);
363}
364