blob: 08b2dad1022fce6f42e04cf4c3edf93b98a86754 [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.");
Alexey Bataev18095712014-10-10 12:19:54 +0000235 if (OpenMPLocThreadIDMap.count(CGF.CurFn))
236 OpenMPLocThreadIDMap.erase(CGF.CurFn);
Alexey Bataev9959db52014-05-06 10:08:46 +0000237}
238
239llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
240 return llvm::PointerType::getUnqual(IdentTy);
241}
242
243llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() {
244 return llvm::PointerType::getUnqual(Kmpc_MicroTy);
245}
246
247llvm::Constant *
248CGOpenMPRuntime::CreateRuntimeFunction(OpenMPRTLFunction Function) {
249 llvm::Constant *RTLFn = nullptr;
250 switch (Function) {
251 case OMPRTL__kmpc_fork_call: {
252 // Build void __kmpc_fork_call(ident_t *loc, kmp_int32 argc, kmpc_micro
253 // microtask, ...);
Alexey Bataev23b69422014-06-18 07:08:49 +0000254 llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty,
255 getKmpc_MicroPointerTy()};
Alexey Bataev9959db52014-05-06 10:08:46 +0000256 llvm::FunctionType *FnTy =
257 llvm::FunctionType::get(CGM.VoidTy, TypeParams, true);
258 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_fork_call");
259 break;
260 }
261 case OMPRTL__kmpc_global_thread_num: {
262 // Build kmp_int32 __kmpc_global_thread_num(ident_t *loc);
Alexey Bataev23b69422014-06-18 07:08:49 +0000263 llvm::Type *TypeParams[] = {getIdentTyPointerTy()};
Alexey Bataev9959db52014-05-06 10:08:46 +0000264 llvm::FunctionType *FnTy =
265 llvm::FunctionType::get(CGM.Int32Ty, TypeParams, false);
266 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_global_thread_num");
267 break;
268 }
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000269 case OMPRTL__kmpc_critical: {
Alexey Bataevf9472182014-09-22 12:32:31 +0000270 // Build void __kmpc_critical(ident_t *loc, kmp_int32 global_tid,
271 // kmp_critical_name *crit);
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000272 llvm::Type *TypeParams[] = {
273 getIdentTyPointerTy(), CGM.Int32Ty,
274 llvm::PointerType::getUnqual(KmpCriticalNameTy)};
275 llvm::FunctionType *FnTy =
276 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
277 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_critical");
278 break;
279 }
280 case OMPRTL__kmpc_end_critical: {
Alexey Bataevf9472182014-09-22 12:32:31 +0000281 // Build void __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid,
282 // kmp_critical_name *crit);
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000283 llvm::Type *TypeParams[] = {
284 getIdentTyPointerTy(), CGM.Int32Ty,
285 llvm::PointerType::getUnqual(KmpCriticalNameTy)};
286 llvm::FunctionType *FnTy =
287 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
288 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_end_critical");
289 break;
290 }
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000291 case OMPRTL__kmpc_barrier: {
292 // Build void __kmpc_barrier(ident_t *loc, kmp_int32 global_tid);
293 llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty};
294 llvm::FunctionType *FnTy =
295 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
296 RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name*/ "__kmpc_barrier");
297 break;
298 }
Alexey Bataev9959db52014-05-06 10:08:46 +0000299 }
300 return RTLFn;
301}
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000302
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000303void CGOpenMPRuntime::EmitOMPParallelCall(CodeGenFunction &CGF,
304 SourceLocation Loc,
305 llvm::Value *OutlinedFn,
306 llvm::Value *CapturedStruct) {
307 // Build call __kmpc_fork_call(loc, 1, microtask, captured_struct/*context*/)
308 llvm::Value *Args[] = {
309 EmitOpenMPUpdateLocation(CGF, Loc),
310 CGF.Builder.getInt32(1), // Number of arguments after 'microtask' argument
311 // (there is only one additional argument - 'context')
312 CGF.Builder.CreateBitCast(OutlinedFn, getKmpc_MicroPointerTy()),
313 CGF.EmitCastToVoidPtr(CapturedStruct)};
314 auto RTLFn = CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_fork_call);
315 CGF.EmitRuntimeCall(RTLFn, Args);
316}
317
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000318llvm::Value *CGOpenMPRuntime::GetCriticalRegionLock(StringRef CriticalName) {
319 SmallString<256> Buffer;
320 llvm::raw_svector_ostream Out(Buffer);
321 Out << ".gomp_critical_user_" << CriticalName << ".var";
322 auto RuntimeCriticalName = Out.str();
323 auto &Elem = CriticalRegionVarNames.GetOrCreateValue(RuntimeCriticalName);
324 if (Elem.getValue() != nullptr)
325 return Elem.getValue();
326
327 auto Lock = new llvm::GlobalVariable(
328 CGM.getModule(), KmpCriticalNameTy, /*IsConstant*/ false,
329 llvm::GlobalValue::CommonLinkage,
330 llvm::Constant::getNullValue(KmpCriticalNameTy), Elem.getKey());
331 Elem.setValue(Lock);
332 return Lock;
333}
334
335void CGOpenMPRuntime::EmitOMPCriticalRegionStart(CodeGenFunction &CGF,
336 llvm::Value *RegionLock,
337 SourceLocation Loc) {
338 // Prepare other arguments and build a call to __kmpc_critical
339 llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc),
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000340 GetOpenMPThreadID(CGF, Loc), RegionLock};
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000341 auto RTLFn = CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_critical);
342 CGF.EmitRuntimeCall(RTLFn, Args);
343}
344
345void CGOpenMPRuntime::EmitOMPCriticalRegionEnd(CodeGenFunction &CGF,
346 llvm::Value *RegionLock,
347 SourceLocation Loc) {
Alexey Bataevf9472182014-09-22 12:32:31 +0000348 // Prepare other arguments and build a call to __kmpc_end_critical
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000349 llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc),
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000350 GetOpenMPThreadID(CGF, Loc), RegionLock};
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000351 auto RTLFn =
352 CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_end_critical);
353 CGF.EmitRuntimeCall(RTLFn, Args);
354}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000355
356void CGOpenMPRuntime::EmitOMPBarrierCall(CodeGenFunction &CGF,
357 SourceLocation Loc,
358 OpenMPLocationFlags Flags) {
359 // Build call __kmpc_barrier(loc, thread_id)
360 llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc, Flags),
361 GetOpenMPThreadID(CGF, Loc)};
362 auto RTLFn = CreateRuntimeFunction(CGOpenMPRuntime::OMPRTL__kmpc_barrier);
363 CGF.EmitRuntimeCall(RTLFn, Args);
364}
365