[PATCH] D41192: Use protected visibility in llvm
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 12:03:27 PST 2017
rafael created this revision.
rafael added reviewers: rnk, ruiu, dim, emaste.
Herald added a subscriber: mgorny.
This should probably not be committed until it is easy to compile a program that uses a library with protected visibility.
This works for llvm's own programs because they are compiled with -fPIC.
On the particular machine I tested this in check-llvm wall time went from 58.32s to 51.30s. The task-clock reported by perf went from 1114528.526654 ms to 933402.530481ms, or about 3 minutes less.
https://reviews.llvm.org/D41192
Files:
cmake/modules/HandleLLVMOptions.cmake
include/llvm/Support/Compiler.h
utils/unittest/UnitTestMain/TestMain.cpp
Index: utils/unittest/UnitTestMain/TestMain.cpp
===================================================================
--- utils/unittest/UnitTestMain/TestMain.cpp
+++ utils/unittest/UnitTestMain/TestMain.cpp
@@ -21,7 +21,7 @@
const char *TestMainArgv0;
-int main(int argc, char **argv) {
+LLVM_PREEMPTIBLE_VISIBILITY int main(int argc, char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal(argv[0],
true /* Disable crash reporting */);
Index: include/llvm/Support/Compiler.h
===================================================================
--- include/llvm/Support/Compiler.h
+++ include/llvm/Support/Compiler.h
@@ -101,8 +101,10 @@
#if (__has_attribute(visibility) || LLVM_GNUC_PREREQ(4, 0, 0)) && \
!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(LLVM_ON_WIN32)
#define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
+#define LLVM_PREEMPTIBLE_VISIBILITY __attribute__ ((visibility("default")))
#else
#define LLVM_LIBRARY_VISIBILITY
+#define LLVM_PREEMPTIBLE_VISIBILITY
#endif
#if defined(__GNUC__)
Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -229,6 +229,9 @@
# MinGW warns if -fvisibility-inlines-hidden is used.
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)
+
+ check_cxx_compiler_flag("-fvisibility=protected" SUPPORTS_FVISIBILITY_PROTECTED_FLAG)
+ append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility=protected" CMAKE_CXX_FLAGS)
endif()
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41192.126802.patch
Type: text/x-patch
Size: 1828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171213/f7edf33d/attachment.bin>
More information about the llvm-commits
mailing list