Skip to content
Snippets Groups Projects
Commit f416ad1f authored by Alexey Bataev's avatar Alexey Bataev
Browse files

[OPENMP] Fixed incompatibility with MSVC, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234568 91177308-0d34-0410-b5e6-96231b3b80d8
parent 9392962e
No related branches found
No related tags found
No related merge requests found
...@@ -983,20 +983,23 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF, ...@@ -983,20 +983,23 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF,
StringRef CriticalName, StringRef CriticalName,
const RegionCodeGenTy &CriticalOpGen, const RegionCodeGenTy &CriticalOpGen,
SourceLocation Loc) { SourceLocation Loc) {
auto RegionLock = getCriticalRegionLock(CriticalName); auto *RegionLock = getCriticalRegionLock(CriticalName);
// __kmpc_critical(ident_t *, gtid, Lock); // __kmpc_critical(ident_t *, gtid, Lock);
// CriticalOpGen(); // CriticalOpGen();
// __kmpc_end_critical(ident_t *, gtid, Lock); // __kmpc_end_critical(ident_t *, gtid, Lock);
// Prepare arguments and build a call to __kmpc_critical // Prepare arguments and build a call to __kmpc_critical
llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
RegionLock};
{ {
CodeGenFunction::RunCleanupsScope Scope(CGF); CodeGenFunction::RunCleanupsScope Scope(CGF);
auto *ULoc = emitUpdateLocation(CGF, Loc);
auto *ThreadID = getThreadID(CGF, Loc);
llvm::Value *Args[] = {ULoc, ThreadID, RegionLock};
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_critical), Args); CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_critical), Args);
emitInlinedDirective(CGF, CriticalOpGen); emitInlinedDirective(CGF, CriticalOpGen);
// Build a call to __kmpc_end_critical // Build a call to __kmpc_end_critical
CGF.EHStack.pushCleanup<CallEndCleanup>( CGF.EHStack.pushCleanup<CallEndCleanup>(
NormalAndEHCleanup, [this, Args](CodeGenFunction &CGF) { NormalAndEHCleanup,
[this, ULoc, ThreadID, RegionLock](CodeGenFunction &CGF) {
llvm::Value *Args[] = {ULoc, ThreadID, RegionLock};
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_critical), CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_critical),
Args); Args);
}); });
...@@ -1029,7 +1032,9 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF, ...@@ -1029,7 +1032,9 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF,
// __kmpc_end_master(ident_t *, gtid); // __kmpc_end_master(ident_t *, gtid);
// } // }
// Prepare arguments and build a call to __kmpc_master // Prepare arguments and build a call to __kmpc_master
llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)}; auto *ULoc = emitUpdateLocation(CGF, Loc);
auto *ThreadID = getThreadID(CGF, Loc);
llvm::Value *Args[] = {ULoc, ThreadID};
auto *IsMaster = auto *IsMaster =
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_master), Args); CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_master), Args);
emitIfStmt(CGF, IsMaster, [&](CodeGenFunction &CGF) -> void { emitIfStmt(CGF, IsMaster, [&](CodeGenFunction &CGF) -> void {
...@@ -1052,7 +1057,8 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF, ...@@ -1052,7 +1057,8 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF,
// fallthrough rather than pushing a normal cleanup for it. // fallthrough rather than pushing a normal cleanup for it.
// Build a call to __kmpc_end_critical // Build a call to __kmpc_end_critical
CGF.EHStack.pushCleanup<CallEndCleanup>( CGF.EHStack.pushCleanup<CallEndCleanup>(
NormalAndEHCleanup, [this, Args](CodeGenFunction &CGF) { NormalAndEHCleanup, [this, ULoc, ThreadID](CodeGenFunction &CGF) {
llvm::Value *Args[] = {ULoc, ThreadID};
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_master), CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_master),
Args); Args);
}); });
...@@ -1161,7 +1167,9 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF, ...@@ -1161,7 +1167,9 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF,
CGF.InitTempAlloca(DidIt, CGF.Builder.getInt32(0)); CGF.InitTempAlloca(DidIt, CGF.Builder.getInt32(0));
} }
// Prepare arguments and build a call to __kmpc_single // Prepare arguments and build a call to __kmpc_single
llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)}; auto *ULoc = emitUpdateLocation(CGF, Loc);
auto *ThreadID = getThreadID(CGF, Loc);
llvm::Value *Args[] = {ULoc, ThreadID};
auto *IsSingle = auto *IsSingle =
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_single), Args); CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_single), Args);
emitIfStmt(CGF, IsSingle, [&](CodeGenFunction &CGF) -> void { emitIfStmt(CGF, IsSingle, [&](CodeGenFunction &CGF) -> void {
...@@ -1187,7 +1195,8 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF, ...@@ -1187,7 +1195,8 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF,
// It is analyzed in Sema, so we can just call __kmpc_end_single() on // It is analyzed in Sema, so we can just call __kmpc_end_single() on
// fallthrough rather than pushing a normal cleanup for it. // fallthrough rather than pushing a normal cleanup for it.
CGF.EHStack.pushCleanup<CallEndCleanup>( CGF.EHStack.pushCleanup<CallEndCleanup>(
NormalAndEHCleanup, [this, Args](CodeGenFunction &CGF) { NormalAndEHCleanup, [this, ULoc, ThreadID](CodeGenFunction &CGF) {
llvm::Value *Args[] = {ULoc, ThreadID};
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_single), CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_single),
Args); Args);
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment