diff options
author | Mandeep Singh Grang <mgrang@codeaurora.org> | 2017-11-28 20:41:13 +0000 |
---|---|---|
committer | Mandeep Singh Grang <mgrang@codeaurora.org> | 2017-11-28 20:41:13 +0000 |
commit | b14fb6a216f0d9e289fb6c2294cb27adfa6ea733 (patch) | |
tree | efc00e0c5e730eeb544fa56742af87e97187b97c /clang | |
parent | 2017d52b54c181f2236e6c94d43f4aa43c30583f (diff) | |
download | bcm5719-llvm-b14fb6a216f0d9e289fb6c2294cb27adfa6ea733.tar.gz bcm5719-llvm-b14fb6a216f0d9e289fb6c2294cb27adfa6ea733.zip |
[OpenMP] Stable sort Privates to remove non-deterministic ordering
Summary:
This fixes the following failures uncovered by D39245:
Clang :: OpenMP/task_firstprivate_codegen.cpp
Clang :: OpenMP/task_private_codegen.cpp
Clang :: OpenMP/taskloop_firstprivate_codegen.cpp
Clang :: OpenMP/taskloop_lastprivate_codegen.cpp
Clang :: OpenMP/taskloop_private_codegen.cpp
Clang :: OpenMP/taskloop_simd_firstprivate_codegen.cpp
Clang :: OpenMP/taskloop_simd_lastprivate_codegen.cpp
Clang :: OpenMP/taskloop_simd_private_codegen.cpp
Reviewers: rjmccall, ABataev, AndreyChurbanov
Reviewed By: rjmccall, ABataev
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D39947
llvm-svn: 319222
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 3de5d3d84fe..5aab7722b99 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -4056,9 +4056,9 @@ emitTaskPrivateMappingFunction(CodeGenModule &CGM, SourceLocation Loc, return TaskPrivatesMap; } -static int array_pod_sort_comparator(const PrivateDataTy *P1, - const PrivateDataTy *P2) { - return P1->first < P2->first ? 1 : (P2->first < P1->first ? -1 : 0); +static bool stable_sort_comparator(const PrivateDataTy P1, + const PrivateDataTy P2) { + return P1.first > P2.first; } /// Emit initialization for private variables in task-based directives. @@ -4286,8 +4286,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, /*PrivateElemInit=*/nullptr))); ++I; } - llvm::array_pod_sort(Privates.begin(), Privates.end(), - array_pod_sort_comparator); + std::stable_sort(Privates.begin(), Privates.end(), stable_sort_comparator); auto KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1); // Build type kmp_routine_entry_t (if not built yet). emitKmpRoutineEntryT(KmpInt32Ty); |