diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2017-11-02 14:25:34 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2017-11-02 14:25:34 +0000 |
| commit | 0e1b45897ec9ac5de93a578edfe55021eb64bf5c (patch) | |
| tree | 7ce91106f740ad548aa05a386acfd900d9778f2e /clang/lib/CodeGen | |
| parent | 96087f38254ac1a655ceaea816937323b13e0dcf (diff) | |
| download | bcm5719-llvm-0e1b45897ec9ac5de93a578edfe55021eb64bf5c.tar.gz bcm5719-llvm-0e1b45897ec9ac5de93a578edfe55021eb64bf5c.zip | |
[OPENMP] Fix PR35156: Get correct thread id with windows exceptions.
If the thread id is requested in windows mode within funclets, we may
generate incorrect function call that could lead to broken codegen.
llvm-svn: 317208
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 35929af95e5..779617adc21 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1451,7 +1451,8 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF, return ThreadID; } // If exceptions are enabled, do not use parameter to avoid possible crash. - if (!CGF.getInvokeDest()) { + if (!CGF.getInvokeDest() || + CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) { if (auto *OMPRegionInfo = dyn_cast_or_null<CGOpenMPRegionInfo>(CGF.CapturedStmtInfo)) { if (OMPRegionInfo->getThreadIDVariable()) { @@ -1475,12 +1476,13 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF, // function. CGBuilderTy::InsertPointGuard IPG(CGF.Builder); CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt); - ThreadID = - CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_global_thread_num), - emitUpdateLocation(CGF, Loc)); + auto *Call = CGF.Builder.CreateCall( + createRuntimeFunction(OMPRTL__kmpc_global_thread_num), + emitUpdateLocation(CGF, Loc)); + Call->setCallingConv(CGF.getRuntimeCC()); auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn); - Elem.second.ThreadID = ThreadID; - return ThreadID; + Elem.second.ThreadID = Call; + return Call; } void CGOpenMPRuntime::functionFinished(CodeGenFunction &CGF) { |

