Skip to content

Commit

Permalink
Backed out changeset 870b38a3dc28 (bug 1602482) for as per dev's requ…
Browse files Browse the repository at this point in the history
…est. a=backout
  • Loading branch information
dgluca committed Dec 10, 2019
1 parent 690e903 commit e070fba
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/build-clang/clang-android.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"patches": [
"static-llvm-symbolizer.patch",
"find_symbolizer_linux.patch",
"rename_gcov_flush.patch",
"rG7e18aeba5062.patch",
"revert-r362047-and-r362065.patch"
]
Expand Down
1 change: 1 addition & 0 deletions build/build-clang/clang-linux64-aarch64-cross.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"patches": [
"static-llvm-symbolizer.patch",
"find_symbolizer_linux.patch",
"rename_gcov_flush.patch",
"rG7e18aeba5062.patch",
"android-mangling-error.patch"
]
Expand Down
1 change: 1 addition & 0 deletions build/build-clang/clang-linux64-cross.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"patches": [
"static-llvm-symbolizer.patch",
"find_symbolizer_linux.patch",
"rename_gcov_flush.patch",
"android-mangling-error.patch",
"revert-r359260-due-to-bug41817.patch",
"r372020-r372182-profiler-linkage.patch",
Expand Down
1 change: 1 addition & 0 deletions build/build-clang/clang-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"patches": [
"static-llvm-symbolizer.patch",
"find_symbolizer_linux.patch",
"rename_gcov_flush.patch",
"rG7e18aeba5062.patch",
"android-mangling-error.patch"
]
Expand Down
1 change: 1 addition & 0 deletions build/build-clang/clang-macosx64.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ld": "{MOZ_FETCHES_DIR}/clang/bin/clang",
"patches": [
"static-llvm-symbolizer.patch",
"rename_gcov_flush.patch",
"rG7e18aeba5062.patch",
"compiler-rt-cross-compile.patch",
"compiler-rt-no-codesign.patch"
Expand Down
40 changes: 40 additions & 0 deletions build/build-clang/rename_gcov_flush.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Index: compiler-rt/lib/profile/GCDAProfiling.c
===================================================================
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -619,7 +619,7 @@
fn_list_insert(&flush_fn_list, fn);
}

-void __gcov_flush() {
+void __custom_llvm_gcov_flush() {
struct fn_node* curr = flush_fn_list.head;

while (curr) {
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 9af64ed332c..bcebe303ff4 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -647,7 +647,7 @@
for (auto I : ForkAndExecs) {
IRBuilder<> Builder(I);
FunctionType *FTy = FunctionType::get(Builder.getVoidTy(), {}, false);
- FunctionCallee GCOVFlush = M->getOrInsertFunction("__gcov_flush", FTy);
+ FunctionCallee GCOVFlush = M->getOrInsertFunction("__custom_llvm_gcov_flush", FTy);
Builder.CreateCall(GCOVFlush);
I->getParent()->splitBasicBlock(I);
}
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index e113f9a679..b3a07b18c0 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1122,7 +1122,7 @@
// runtime's functionality.
if (hasExportSymbolDirective(Args)) {
if (needsGCovInstrumentation(Args)) {
- addExportedSymbol(CmdArgs, "___gcov_flush");
+ addExportedSymbol(CmdArgs, "___custom_llvm_gcov_flush");
addExportedSymbol(CmdArgs, "_flush_fn_list");
addExportedSymbol(CmdArgs, "_writeout_fn_list");
} else {
8 changes: 8 additions & 0 deletions tools/code-coverage/CodeCoverageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ using namespace mozilla;
// __gcov_flush is protected by a mutex in GCC, but not in LLVM, so we are using
// a CrossProcessMutex to protect it.

// We rename __gcov_flush to __custom_llvm_gcov_flush in our build of LLVM for
// Linux, to avoid naming clashes in builds which mix GCC and LLVM. So, when we
// are building with LLVM exclusively, we need to use __custom_llvm_gcov_flush
// instead.
#if !defined(XP_WIN) && defined(__clang__)
# define __gcov_flush __custom_llvm_gcov_flush
#endif

extern "C" void __gcov_flush();

StaticAutoPtr<CodeCoverageHandler> CodeCoverageHandler::instance;
Expand Down

0 comments on commit e070fba

Please sign in to comment.