Skip to content

Commit 7737bd9

Browse files
committedOct 21, 2015
[Driver] Alias -fvisibility=internal to -fvisibility=hidden
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. llvm-svn: 250954
1 parent 9dfde98 commit 7737bd9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎clang/lib/Frontend/CompilerInvocation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ static Visibility parseVisibility(Arg *arg, ArgList &args,
12961296
StringRef value = arg->getValue();
12971297
if (value == "default") {
12981298
return DefaultVisibility;
1299-
} else if (value == "hidden") {
1299+
} else if (value == "hidden" || value == "internal") {
13001300
return HiddenVisibility;
13011301
} else if (value == "protected") {
13021302
// FIXME: diagnose if target does not support protected visibility

‎clang/test/CodeGenCXX/visibility.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
22
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
3+
// For clang, "internal" is just an alias for "hidden". We could use it for some
4+
// optimization purposes on 32-bit x86, but it's not worth it.
5+
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility internal -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
36

47
#define HIDDEN __attribute__((visibility("hidden")))
58
#define PROTECTED __attribute__((visibility("protected")))

0 commit comments

Comments
 (0)