Skip to content

Commit 5556a5c

Browse files
committed
Revert r267784, r267824 and r267830.
It makes compiler-rt tests fail if the gold plugin is enabled. Revert "Rework interface for bitset-using features to use a notion of LTO visibility." Revert "Driver: only produce CFI -fvisibility= error when compiling." Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would be non-cfi." llvm-svn: 267871
1 parent 801d9b0 commit 5556a5c

35 files changed

+209
-435
lines changed

clang/docs/ControlFlowIntegrity.rst

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,13 @@ As currently implemented, all schemes rely on link-time optimization (LTO);
2525
so it is required to specify ``-flto``, and the linker used must support LTO,
2626
for example via the `gold plugin`_.
2727

28-
To allow the checks to be implemented efficiently, the program must
29-
be structured such that certain object files are compiled with CFI
28+
To allow the checks to be implemented efficiently, the program must be
29+
structured such that certain object files are compiled with CFI
3030
enabled, and are statically linked into the program. This may preclude
31-
the use of shared libraries in some cases.
32-
33-
The compiler will only produce CFI checks for a class if it can infer hidden
34-
LTO visibility for that class. LTO visibility is a property of a class that
35-
is inferred from flags and attributes. For more details, see the documentation
36-
for :doc:`LTO visibility <LTOVisibility>`.
37-
38-
The ``-fsanitize=cfi-{vcall,nvcall,derived-cast,unrelated-cast}`` flags
39-
require that a ``-fvisibility=`` flag also be specified. This is because the
40-
default visibility setting is ``-fvisibility=default``, which would disable
41-
CFI checks for classes without visibility attributes. Most users will want
42-
to specify ``-fvisibility=hidden``, which enables CFI checks for such classes.
43-
44-
Experimental support for :ref:`cross-DSO control flow integrity
45-
<cfi-cross-dso>` exists that does not require classes to have hidden LTO
46-
visibility. This cross-DSO support has unstable ABI at this time.
31+
the use of shared libraries in some cases. Experimental support for
32+
:ref:`cross-DSO control flow integrity <cfi-cross-dso>` exists that
33+
does not have these requirements. This cross-DSO support has unstable
34+
ABI at this time.
4735

4836
.. _gold plugin: http://llvm.org/docs/GoldPlugin.html
4937

@@ -245,6 +233,11 @@ A :doc:`SanitizerSpecialCaseList` can be used to relax CFI checks for certain
245233
source files, functions and types using the ``src``, ``fun`` and ``type``
246234
entity types.
247235

236+
In addition, if a type has a ``uuid`` attribute and the blacklist contains
237+
the type entry ``attr:uuid``, CFI checks are suppressed for that type. This
238+
allows all COM types to be easily blacklisted, which is useful as COM types
239+
are typically defined outside of the linked program.
240+
248241
.. code-block:: bash
249242
250243
# Suppress checking for code in a file.
@@ -254,6 +247,8 @@ entity types.
254247
fun:*MyFooBar*
255248
# Ignore all types in the standard library.
256249
type:std::*
250+
# Ignore all types with a uuid attribute.
251+
type:attr:uuid
257252
258253
.. _cfi-cross-dso:
259254

@@ -265,11 +260,6 @@ flow integrity mode, which allows all CFI schemes listed above to
265260
apply across DSO boundaries. As in the regular CFI, each DSO must be
266261
built with ``-flto``.
267262

268-
Normally, CFI checks will only be performed for classes that have hidden LTO
269-
visibility. With this flag enabled, the compiler will emit cross-DSO CFI
270-
checks for all classes, except for those which appear in the CFI blacklist
271-
or which use a ``no_sanitize`` attribute.
272-
273263
Design
274264
======
275265

clang/docs/LTOVisibility.rst

Lines changed: 0 additions & 111 deletions
This file was deleted.

clang/docs/UsersManual.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,17 @@ are listed below.
10561056
.. option:: -fwhole-program-vtables
10571057

10581058
Enable whole-program vtable optimizations, such as single-implementation
1059-
devirtualization and virtual constant propagation, for classes with
1060-
:doc:`hidden LTO visibility <LTOVisibility>`. Requires ``-flto``.
1059+
devirtualization and virtual constant propagation. Requires ``-flto``.
1060+
1061+
By default, the compiler will assume that all type hierarchies are
1062+
closed except those in the ``std`` namespace, the ``stdext`` namespace
1063+
and classes with the ``__declspec(uuid())`` attribute.
1064+
1065+
.. option:: -fwhole-program-vtables-blacklist=path
1066+
1067+
Allows the user to specify the path to a list of additional classes to
1068+
blacklist from whole-program vtable optimizations. This list is in the
1069+
:ref:`CFI blacklist <cfi-blacklist>` format.
10611070

10621071
.. option:: -fno-assume-sane-operator-new
10631072

clang/docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Using Clang as a Compiler
3131
SanitizerStats
3232
SanitizerSpecialCaseList
3333
ControlFlowIntegrity
34-
LTOVisibility
3534
SafeStack
3635
Modules
3736
MSVCCompatibility

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,12 +1611,6 @@ def WeakRef : InheritableAttr {
16111611
let Documentation = [Undocumented];
16121612
}
16131613

1614-
def LTOVisibilityPublic : InheritableAttr {
1615-
let Spellings = [CXX11<"clang", "lto_visibility_public">];
1616-
let Subjects = SubjectList<[Record]>;
1617-
let Documentation = [LTOVisibilityDocs];
1618-
}
1619-
16201614
def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
16211615
// NOTE: If you add any additional spellings, ARMInterrupt's,
16221616
// MSP430Interrupt's and MipsInterrupt's spellings must match.

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,10 +2380,3 @@ The ``ifunc`` attribute may only be used on a function declaration. A function
23802380
Not all targets support this attribute. ELF targets support this attribute when using binutils v2.20.1 or higher and glibc v2.11.1 or higher. Non-ELF targets currently do not support this attribute.
23812381
}];
23822382
}
2383-
2384-
def LTOVisibilityDocs : Documentation {
2385-
let Category = DocCatType;
2386-
let Content = [{
2387-
See :doc:`LTOVisibility`.
2388-
}];
2389-
}

clang/include/clang/Driver/CC1Options.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">,
282282
def fprofile_instrument_use_path_EQ :
283283
Joined<["-"], "fprofile-instrument-use-path=">,
284284
HelpText<"Specify the profile path in PGO use compilation">;
285-
def flto_visibility_public_std:
286-
Flag<["-"], "flto-visibility-public-std">,
287-
HelpText<"Use public LTO visibility for classes in std and stdext namespaces">;
288285

289286
//===----------------------------------------------------------------------===//
290287
// Dependency Output Options

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,9 @@ def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, Group<f_Grou
11521152
Flags<[CC1Option]>,
11531153
HelpText<"Enables whole-program vtable optimization. Requires -flto">;
11541154
def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, Group<f_Group>;
1155+
def fwhole_program_vtables_blacklist_EQ : Joined<["-"], "fwhole-program-vtables-blacklist=">,
1156+
Group<f_Group>, Flags<[CC1Option]>,
1157+
HelpText<"Path to a blacklist file for whole-program vtable optimization">;
11551158
def fwrapv : Flag<["-"], "fwrapv">, Group<f_Group>, Flags<[CC1Option]>,
11561159
HelpText<"Treat signed integer overflow as two's complement">;
11571160
def fwritable_strings : Flag<["-"], "fwritable-strings">, Group<f_Group>, Flags<[CC1Option]>,

clang/include/clang/Frontend/CodeGenOptions.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
187187
CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
188188
/// vtable optimization.
189189

190-
/// Whether to use public LTO visibility for entities in std and stdext
191-
/// namespaces. This is enabled by clang-cl's /MT and /MTd flags.
192-
CODEGENOPT(LTOVisibilityPublicStd, 1, 0)
193-
194190
/// The user specified number of registers to be used for integral arguments,
195191
/// or 0 if unspecified.
196192
VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)

clang/include/clang/Frontend/CodeGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
199199
/// \brief A list of all -fno-builtin-* function names (e.g., memset).
200200
std::vector<std::string> NoBuiltinFuncs;
201201

202+
/// List of blacklist files for the whole-program vtable optimization feature.
203+
std::vector<std::string> WholeProgramVTablesBlacklistFiles;
204+
202205
public:
203206
// Define accessors/mutators for code generation options of enumeration type.
204207
#define CODEGENOPT(Name, Bits, Default)

0 commit comments

Comments
 (0)