diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2016-04-27 20:39:53 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-04-27 20:39:53 +0000 |
| commit | a8b2f7c0d7d2432c4574cc564b6b4488c6f970b7 (patch) | |
| tree | a2e99c8c523cbd9ff2fa7963cedfc91f014f088b /clang/test/CodeGenCXX/bitset-inference.cpp | |
| parent | 60c4e6aafa8904eecb79a2109ed4c8b8be942005 (diff) | |
| download | bcm5719-llvm-a8b2f7c0d7d2432c4574cc564b6b4488c6f970b7.tar.gz bcm5719-llvm-a8b2f7c0d7d2432c4574cc564b6b4488c6f970b7.zip | |
Rework interface for bitset-using features to use a notion of LTO visibility.
Bitsets, and the compiler features they rely on (vtable opt, CFI),
only have visibility within the LTO'd part of the linkage unit. Therefore,
only enable these features for classes with hidden LTO visibility. This
notion is based on object file visibility or (on Windows)
dllimport/dllexport attributes.
We provide the [[clang::lto_visibility_public]] attribute to override the
compiler's LTO visibility inference in cases where the class is defined
in the non-LTO'd part of the linkage unit, or where the ABI supports
calling classes derived from abstract base classes with hidden visibility
in other linkage units (e.g. COM on Windows).
If the cross-DSO CFI mode is enabled, bitset checks are emitted even for
classes with public LTO visibility, as that mode uses a separate mechanism
to cause bitsets to be exported.
This mechanism replaces the whole-program-vtables blacklist, so remove the
-fwhole-program-vtables-blacklist flag.
Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the
support for the special attr:uuid blacklist entry is removed.
Differential Revision: http://reviews.llvm.org/D18635
llvm-svn: 267784
Diffstat (limited to 'clang/test/CodeGenCXX/bitset-inference.cpp')
| -rw-r--r-- | clang/test/CodeGenCXX/bitset-inference.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/bitset-inference.cpp b/clang/test/CodeGenCXX/bitset-inference.cpp new file mode 100644 index 00000000000..d9528609ff2 --- /dev/null +++ b/clang/test/CodeGenCXX/bitset-inference.cpp @@ -0,0 +1,107 @@ +// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -std=c++11 -fms-extensions -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=ITANIUM %s +// RUN: %clang_cc1 -flto -triple x86_64-pc-windows-msvc -std=c++11 -fms-extensions -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=MS --check-prefix=MS-STD %s +// RUN: %clang_cc1 -flto -triple x86_64-pc-windows-msvc -std=c++11 -fms-extensions -fwhole-program-vtables -flto-visibility-public-std -emit-llvm -o - %s | FileCheck --check-prefix=MS --check-prefix=MS-NOSTD %s + +struct C1 { + virtual void f(); +}; + +struct __attribute__((visibility("default"))) C2 { + virtual void f(); +}; + +struct __declspec(dllexport) C3 { + virtual void f(); +}; + +struct __declspec(dllimport) C4 { + virtual void f(); +}; + +struct [[clang::lto_visibility_public]] C5 { + virtual void f(); +}; + +struct __declspec(uuid("00000000-0000-0000-0000-000000000000")) C6 { + virtual void f(); +}; + +namespace std { + +struct C7 { + virtual void f(); + struct C8 { + virtual void f(); + }; +}; + +} + +extern "C++" { + +namespace stdext { + +struct C9 { + virtual void f(); +}; + +} + +} + +namespace other { + +struct C10 { + virtual void f(); +}; + +} + +namespace { + +struct C11 { + virtual void f(); +}; + +} + +void f(C1 *c1, C2 *c2, C3 *c3, C4 *c4, C5 *c5, C6 *c6, std::C7 *c7, + std::C7::C8 *c8, stdext::C9 *c9, other::C10 *c10) { + // ITANIUM: bitset.test{{.*}}!"_ZTS2C1" + // MS: bitset.test{{.*}}!"?AUC1@@" + c1->f(); + // ITANIUM-NOT: bitset.test{{.*}}!"_ZTS2C2" + // MS: bitset.test{{.*}}!"?AUC2@@" + c2->f(); + // ITANIUM: bitset.test{{.*}}!"_ZTS2C3" + // MS-NOT: bitset.test{{.*}}!"?AUC3@@" + c3->f(); + // ITANIUM: bitset.test{{.*}}!"_ZTS2C4" + // MS-NOT: bitset.test{{.*}}!"?AUC4@@" + c4->f(); + // ITANIUM-NOT: bitset.test{{.*}}!"_ZTS2C5" + // MS-NOT: bitset.test{{.*}}!"?AUC5@@" + c5->f(); + // ITANIUM-NOT: bitset.test{{.*}}!"_ZTS2C6" + // MS-NOT: bitset.test{{.*}}!"?AUC6@@" + c6->f(); + // ITANIUM: bitset.test{{.*}}!"_ZTSSt2C7" + // MS-STD: bitset.test{{.*}}!"?AUC7@std@@" + // MS-NOSTD-NOT: bitset.test{{.*}}!"?AUC7@std@@" + c7->f(); + // ITANIUM: bitset.test{{.*}}!"_ZTSNSt2C72C8E" + // MS-STD: bitset.test{{.*}}!"?AUC8@C7@std@@" + // MS-NOSTD-NOT: bitset.test{{.*}}!"?AUC8@C7@std@@" + c8->f(); + // ITANIUM: bitset.test{{.*}}!"_ZTSN6stdext2C9E" + // MS-STD: bitset.test{{.*}}!"?AUC9@stdext@@" + // MS-NOSTD-NOT: bitset.test{{.*}}!"?AUC9@stdext@@" + c9->f(); + // ITANIUM: bitset.test{{.*}}!"_ZTSN5other3C10E" + // MS: bitset.test{{.*}}!"?AUC10@other@@" + c10->f(); + // ITANIUM: bitset.test{{.*}}!{{[0-9]}} + // MS: bitset.test{{.*}}!{{[0-9]}} + C11 *c11; + c11->f(); +} |

