forked from OSchip/llvm-project
[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
This commit is contained in:
parent
2017d52b54
commit
b14fb6a216
|
@ -4056,9 +4056,9 @@ emitTaskPrivateMappingFunction(CodeGenModule &CGM, SourceLocation Loc,
|
||||||
return TaskPrivatesMap;
|
return TaskPrivatesMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int array_pod_sort_comparator(const PrivateDataTy *P1,
|
static bool stable_sort_comparator(const PrivateDataTy P1,
|
||||||
const PrivateDataTy *P2) {
|
const PrivateDataTy P2) {
|
||||||
return P1->first < P2->first ? 1 : (P2->first < P1->first ? -1 : 0);
|
return P1.first > P2.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit initialization for private variables in task-based directives.
|
/// Emit initialization for private variables in task-based directives.
|
||||||
|
@ -4286,8 +4286,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
|
||||||
/*PrivateElemInit=*/nullptr)));
|
/*PrivateElemInit=*/nullptr)));
|
||||||
++I;
|
++I;
|
||||||
}
|
}
|
||||||
llvm::array_pod_sort(Privates.begin(), Privates.end(),
|
std::stable_sort(Privates.begin(), Privates.end(), stable_sort_comparator);
|
||||||
array_pod_sort_comparator);
|
|
||||||
auto KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1);
|
auto KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1);
|
||||||
// Build type kmp_routine_entry_t (if not built yet).
|
// Build type kmp_routine_entry_t (if not built yet).
|
||||||
emitKmpRoutineEntryT(KmpInt32Ty);
|
emitKmpRoutineEntryT(KmpInt32Ty);
|
||||||
|
|
Loading…
Reference in New Issue