зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1599436 - Backport LLVM patch to add a critical section in gcov_flush r=marco
In order to avoid crashes when we're dumping gcda files, we backport a llvm/compiler-rt patch which fix this issue in adding a critical section around flush. Differential Revision: https://phabricator.services.mozilla.com/D56559 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
54a20a3bfa
Коммит
f6c15104f5
|
@ -12,6 +12,7 @@
|
|||
"static-llvm-symbolizer.patch",
|
||||
"find_symbolizer_linux.patch",
|
||||
"rename_gcov_flush_7.patch",
|
||||
"critical_section_on_gcov_flush.patch",
|
||||
"r350774.patch",
|
||||
"android-mangling-error.patch"
|
||||
]
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
"static-llvm-symbolizer.patch",
|
||||
"find_symbolizer_linux.patch",
|
||||
"rename_gcov_flush.patch",
|
||||
"critical_section_on_gcov_flush.patch",
|
||||
"rG7e18aeba5062.patch",
|
||||
"revert-r362047-and-r362065.patch"
|
||||
]
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"static-llvm-symbolizer.patch",
|
||||
"find_symbolizer_linux.patch",
|
||||
"rename_gcov_flush.patch",
|
||||
"critical_section_on_gcov_flush.patch",
|
||||
"rG7e18aeba5062.patch",
|
||||
"android-mangling-error.patch"
|
||||
]
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"static-llvm-symbolizer.patch",
|
||||
"find_symbolizer_linux.patch",
|
||||
"rename_gcov_flush.patch",
|
||||
"critical_section_on_gcov_flush.patch",
|
||||
"android-mangling-error.patch",
|
||||
"revert-r359260-due-to-bug41817.patch",
|
||||
"r372020-r372182-profiler-linkage.patch",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"static-llvm-symbolizer.patch",
|
||||
"find_symbolizer_linux.patch",
|
||||
"rename_gcov_flush.patch",
|
||||
"critical_section_on_gcov_flush.patch",
|
||||
"rG7e18aeba5062.patch",
|
||||
"android-mangling-error.patch"
|
||||
]
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"patches": [
|
||||
"static-llvm-symbolizer.patch",
|
||||
"rename_gcov_flush.patch",
|
||||
"critical_section_on_gcov_flush.patch",
|
||||
"rG7e18aeba5062.patch",
|
||||
"compiler-rt-cross-compile.patch",
|
||||
"compiler-rt-no-codesign.patch"
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
|
||||
index b7257db10e7..d4abc4181ed 100644
|
||||
--- a/compiler-rt/lib/profile/GCDAProfiling.c
|
||||
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
|
||||
@@ -62,8 +62,27 @@ typedef unsigned long long uint64_t;
|
||||
#include "InstrProfiling.h"
|
||||
#include "InstrProfilingUtil.h"
|
||||
|
||||
-/* #define DEBUG_GCDAPROFILING */
|
||||
+#ifndef _WIN32
|
||||
+#include <pthread.h>
|
||||
+static pthread_mutex_t gcov_flush_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
+static __inline void gcov_flush_lock() {
|
||||
+ pthread_mutex_lock(&gcov_flush_mutex);
|
||||
+}
|
||||
+static __inline void gcov_flush_unlock() {
|
||||
+ pthread_mutex_unlock(&gcov_flush_mutex);
|
||||
+}
|
||||
+#else
|
||||
+#include <windows.h>
|
||||
+static SRWLOCK gcov_flush_mutex = SRWLOCK_INIT;
|
||||
+static __inline void gcov_flush_lock() {
|
||||
+ AcquireSRWLockExclusive(&gcov_flush_mutex);
|
||||
+}
|
||||
+static __inline void gcov_flush_unlock() {
|
||||
+ ReleaseSRWLockExclusive(&gcov_flush_mutex);
|
||||
+}
|
||||
+#endif
|
||||
|
||||
+/* #define DEBUG_GCDAPROFILING */
|
||||
/*
|
||||
* --- GCOV file format I/O primitives ---
|
||||
*/
|
||||
@@ -620,12 +639,16 @@ void llvm_register_flush_function(fn_ptr fn) {
|
||||
}
|
||||
|
||||
void __custom_llvm_gcov_flush() {
|
||||
+ gcov_flush_lock();
|
||||
+
|
||||
struct fn_node* curr = flush_fn_list.head;
|
||||
|
||||
while (curr) {
|
||||
curr->fn();
|
||||
curr = curr->next;
|
||||
}
|
||||
+
|
||||
+ gcov_flush_unlock();
|
||||
}
|
||||
|
||||
COMPILER_RT_VISIBILITY
|
||||
--
|
||||
2.24.0
|
||||
|
Загрузка…
Ссылка в новой задаче