From d3ae853c3d08b4a6ad98ea83b5bc672d7288d3e4 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Fri, 10 Apr 2015 05:32:31 +0000 Subject: [PATCH] [OPENMP] Fixed incompatibility with MSVC, NFC. llvm-svn: 234568 --- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 74e175b..8d06d316 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -983,20 +983,23 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc) { - auto RegionLock = getCriticalRegionLock(CriticalName); + auto *RegionLock = getCriticalRegionLock(CriticalName); // __kmpc_critical(ident_t *, gtid, Lock); // CriticalOpGen(); // __kmpc_end_critical(ident_t *, gtid, Lock); // Prepare arguments and build a call to __kmpc_critical - llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc), - RegionLock}; { 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); emitInlinedDirective(CGF, CriticalOpGen); // Build a call to __kmpc_end_critical CGF.EHStack.pushCleanup( - 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), Args); }); @@ -1029,7 +1032,9 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF, // __kmpc_end_master(ident_t *, gtid); // } // 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 = CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_master), Args); emitIfStmt(CGF, IsMaster, [&](CodeGenFunction &CGF) -> void { @@ -1052,7 +1057,8 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF, // fallthrough rather than pushing a normal cleanup for it. // Build a call to __kmpc_end_critical CGF.EHStack.pushCleanup( - NormalAndEHCleanup, [this, Args](CodeGenFunction &CGF) { + NormalAndEHCleanup, [this, ULoc, ThreadID](CodeGenFunction &CGF) { + llvm::Value *Args[] = {ULoc, ThreadID}; CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_master), Args); }); @@ -1161,7 +1167,9 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF, CGF.InitTempAlloca(DidIt, CGF.Builder.getInt32(0)); } // 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 = CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_single), Args); emitIfStmt(CGF, IsSingle, [&](CodeGenFunction &CGF) -> void { @@ -1187,7 +1195,8 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF, // It is analyzed in Sema, so we can just call __kmpc_end_single() on // fallthrough rather than pushing a normal cleanup for it. CGF.EHStack.pushCleanup( - NormalAndEHCleanup, [this, Args](CodeGenFunction &CGF) { + NormalAndEHCleanup, [this, ULoc, ThreadID](CodeGenFunction &CGF) { + llvm::Value *Args[] = {ULoc, ThreadID}; CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_end_single), Args); }); -- 2.7.4