]> granicus.if.org Git - clang/commitdiff
[Driver] Alias -fvisibility=internal to -fvisibility=hidden
authorReid Kleckner <rnk@google.com>
Wed, 21 Oct 2015 22:01:02 +0000 (22:01 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 21 Oct 2015 22:01:02 +0000 (22:01 +0000)
The ELF symbol visibilities are:
- internal: Not visibile across DSOs, cannot pass address across DSOs
- hidden: Not visibile across DSOs, can be called indirectly
- default: Usually visible across DSOs, possibly interposable
- protected: Visible across DSOs, not interposable

LLVM only supports the latter 3 visibilities. Internal visibility is in
theory useful, as it allows you to assume that the caller is maintaining
a PIC register for you in %ebx, or in some other pre-arranged location.
As far as LLVM is concerned, this isn't worth the trouble. Using hidden
visibility is always correct, so we can just do that.

Resolves PR9183.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250954 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/CompilerInvocation.cpp
test/CodeGenCXX/visibility.cpp

index 6e234112d7d5014de96078096fd93e98a0cd55cb..7cece2b3dd90cc4bc4ebe4d13e72fecf471d8214 100644 (file)
@@ -1296,7 +1296,7 @@ static Visibility parseVisibility(Arg *arg, ArgList &args,
   StringRef value = arg->getValue();
   if (value == "default") {
     return DefaultVisibility;
-  } else if (value == "hidden") {
+  } else if (value == "hidden" || value == "internal") {
     return HiddenVisibility;
   } else if (value == "protected") {
     // FIXME: diagnose if target does not support protected visibility
index 7239cbe00225189340a45d78cce636c4e94e9a26..aff6554282caf57f0de5b5db9b0d6fee8a58371f 100644 (file)
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
+// For clang, "internal" is just an alias for "hidden". We could use it for some
+// optimization purposes on 32-bit x86, but it's not worth it.
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility internal -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
 
 #define HIDDEN __attribute__((visibility("hidden")))
 #define PROTECTED __attribute__((visibility("protected")))