Files
clang-p2996/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
David Tenty d9c1d3cbcb [clang][AIX] Don't ignore XCOFF visibility by default
D87451 added -mignore-xcoff-visibility for AIX targets and made it the default (which mimicked the behaviour of the XL 16.1 compiler on AIX).

However, ignoring hidden visibility has unwanted side effects and some libraries depend on visibility to hide non-ABI facing entities from user headers and
reserve the right to change these implementation details based on this (https://libcxx.llvm.org/DesignDocs/VisibilityMacros.html). This forces us to use
internal linkage fallbacks for these cases on AIX and creates an unwanted divergence in implementations on the plaform.

For these reasons, it's preferable to not add -mignore-xcoff-visibility by default, which is what this patch does.

Reviewed By: DiggerLin

Differential Revision: https://reviews.llvm.org/D125141
2022-05-11 13:27:48 -04:00

74 lines
2.8 KiB
C++

// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s | \
// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -emit-llvm -round-trip-args -o - -x c++ %s | \
// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s | \
// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -round-trip-args -o - -x c++ %s | \
// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s | \
// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -fvisibility default -round-trip-args -emit-llvm -o - -x c++ %s | \
// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
__attribute__((visibility("hidden"))) void foo_h(int *p) {
(*p)++;
}
__attribute__((visibility("protected"))) int b;
extern __attribute__((visibility("hidden"))) void zoo_extern_h(void);
void (*foo_p)(void) = zoo_extern_h;
__attribute__((visibility("protected"))) void bar() {
foo_h(&b);
foo_p();
}
class TestClass {
public:
__attribute__((__visibility__("hidden"))) int value() const noexcept { return 0; }
};
int main() {
TestClass TC;
return TC.value();
}
template <class T>
class basic {
public:
__attribute__((__visibility__("protected"))) int getdata() { return 1; }
};
template class basic<int>;
#pragma GCC visibility push(hidden)
int pramb;
void prambar() {}
#pragma GCC visibility pop
// VISIBILITY-IR: @b = protected global i32 0
// VISIBILITY-IR: @pramb = hidden global i32 0
// VISIBILITY-IR: define hidden void @_Z5foo_hPi(i32* noundef %p)
// VISIBILITY-IR: declare hidden void @_Z12zoo_extern_hv()
// VISIBILITY-IR: define protected void @_Z3barv()
// VISIBILITY-IR: define linkonce_odr hidden noundef i32 @_ZNK9TestClass5valueEv(%class.TestClass* {{[^,]*}} %this)
// VISIBILITY-IR: define weak_odr protected noundef i32 @_ZN5basicIiE7getdataEv(%class.basic* {{[^,]*}} %this)
// VISIBILITY-IR: define hidden void @_Z7prambarv()
// NOVISIBILITY-IR: @b = global i32 0
// NOVISIBILITY-IR: @pramb = global i32 0
// NOVISIBILITY-IR: define void @_Z5foo_hPi(i32* noundef %p)
// NOVISIBILITY-IR: declare void @_Z12zoo_extern_hv()
// NOVISIBILITY-IR: define void @_Z3barv()
// NOVISIBILITY-IR: define linkonce_odr noundef i32 @_ZNK9TestClass5valueEv(%class.TestClass* {{[^,]*}} %this)
// NOVISIBILITY-IR: define weak_odr noundef i32 @_ZN5basicIiE7getdataEv(%class.basic* {{[^,]*}} %this)
// NOVISIBILITY-IR: define void @_Z7prambarv()