Skip to content

Commit 79829a4

Browse files
committed
Revert "[clang] Add -fc++-abi= flag for specifying which C++ ABI to use"
This reverts commits 683b308 and 8487bfd. We will go for a more restricted approach that does not give freedom to everyone to change ABIs on whichever platform. See the discussion on https://reviews.llvm.org/D85802.
1 parent 1992e30 commit 79829a4

File tree

12 files changed

+138
-213
lines changed

12 files changed

+138
-213
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "clang/Basic/SanitizerBlacklist.h"
4040
#include "clang/Basic/SourceLocation.h"
4141
#include "clang/Basic/Specifiers.h"
42-
#include "clang/Basic/TargetCXXABI.h"
4342
#include "clang/Basic/XRayLists.h"
4443
#include "llvm/ADT/APSInt.h"
4544
#include "llvm/ADT/ArrayRef.h"
@@ -698,11 +697,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
698697
return FullSourceLoc(Loc,SourceMgr);
699698
}
700699

701-
/// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
702-
/// at compile time with `-fc++-abi=`. If this is not provided, we instead use
703-
/// the default ABI set by the target.
704-
TargetCXXABI::Kind getCXXABIKind() const;
705-
706700
/// All comments in this translation unit.
707701
RawCommentList Comments;
708702

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,4 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognize
524524

525525
def err_drv_invalid_sve_vector_bits : Error<
526526
"'-msve-vector-bits' is not supported without SVE enabled">;
527-
528-
def err_invalid_cxx_abi : Error<"invalid C++ ABI name '%0'">;
529527
}

clang/include/clang/Basic/LangOptions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "clang/Basic/LLVM.h"
1919
#include "clang/Basic/ObjCRuntime.h"
2020
#include "clang/Basic/Sanitizers.h"
21-
#include "clang/Basic/TargetCXXABI.h"
2221
#include "clang/Basic/Visibility.h"
2322
#include "llvm/ADT/FloatingPointMode.h"
2423
#include "llvm/ADT/StringRef.h"
@@ -295,10 +294,6 @@ class LangOptions : public LangOptionsBase {
295294
/// host code generation.
296295
std::string OMPHostIRFile;
297296

298-
/// C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
299-
/// This overrides the default ABI used by the target.
300-
llvm::Optional<TargetCXXABI::Kind> CXXABI;
301-
302297
/// Indicates whether the front-end is explicitly told that the
303298
/// input is a header file (i.e. -x c-header).
304299
bool IsHeaderFile = false;

clang/include/clang/Basic/TargetCXXABI.def

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

clang/include/clang/Basic/TargetCXXABI.h

Lines changed: 124 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define LLVM_CLANG_BASIC_TARGETCXXABI_H
1717

1818
#include "clang/Basic/LLVM.h"
19-
#include "llvm/ADT/StringMap.h"
2019
#include "llvm/Support/ErrorHandling.h"
2120

2221
namespace clang {
@@ -26,8 +25,105 @@ class TargetCXXABI {
2625
public:
2726
/// The basic C++ ABI kind.
2827
enum Kind {
29-
#define CXXABI(Name, Str) Name,
30-
#include "TargetCXXABI.def"
28+
/// The generic Itanium ABI is the standard ABI of most open-source
29+
/// and Unix-like platforms. It is the primary ABI targeted by
30+
/// many compilers, including Clang and GCC.
31+
///
32+
/// It is documented here:
33+
/// http://www.codesourcery.com/public/cxx-abi/
34+
GenericItanium,
35+
36+
/// The generic ARM ABI is a modified version of the Itanium ABI
37+
/// proposed by ARM for use on ARM-based platforms.
38+
///
39+
/// These changes include:
40+
/// - the representation of member function pointers is adjusted
41+
/// to not conflict with the 'thumb' bit of ARM function pointers;
42+
/// - constructors and destructors return 'this';
43+
/// - guard variables are smaller;
44+
/// - inline functions are never key functions;
45+
/// - array cookies have a slightly different layout;
46+
/// - additional convenience functions are specified;
47+
/// - and more!
48+
///
49+
/// It is documented here:
50+
/// http://infocenter.arm.com
51+
/// /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
52+
GenericARM,
53+
54+
/// The iOS ABI is a partial implementation of the ARM ABI.
55+
/// Several of the features of the ARM ABI were not fully implemented
56+
/// in the compilers that iOS was launched with.
57+
///
58+
/// Essentially, the iOS ABI includes the ARM changes to:
59+
/// - member function pointers,
60+
/// - guard variables,
61+
/// - array cookies, and
62+
/// - constructor/destructor signatures.
63+
iOS,
64+
65+
/// The iOS 64-bit ABI is follows ARM's published 64-bit ABI more
66+
/// closely, but we don't guarantee to follow it perfectly.
67+
///
68+
/// It is documented here:
69+
/// http://infocenter.arm.com
70+
/// /help/topic/com.arm.doc.ihi0059a/IHI0059A_cppabi64.pdf
71+
iOS64,
72+
73+
/// WatchOS is a modernisation of the iOS ABI, which roughly means it's
74+
/// the iOS64 ABI ported to 32-bits. The primary difference from iOS64 is
75+
/// that RTTI objects must still be unique at the moment.
76+
WatchOS,
77+
78+
/// The generic AArch64 ABI is also a modified version of the Itanium ABI,
79+
/// but it has fewer divergences than the 32-bit ARM ABI.
80+
///
81+
/// The relevant changes from the generic ABI in this case are:
82+
/// - representation of member function pointers adjusted as in ARM.
83+
/// - guard variables are smaller.
84+
GenericAArch64,
85+
86+
/// The generic Mips ABI is a modified version of the Itanium ABI.
87+
///
88+
/// At the moment, only change from the generic ABI in this case is:
89+
/// - representation of member function pointers adjusted as in ARM.
90+
GenericMIPS,
91+
92+
/// The WebAssembly ABI is a modified version of the Itanium ABI.
93+
///
94+
/// The changes from the Itanium ABI are:
95+
/// - representation of member function pointers is adjusted, as in ARM;
96+
/// - member functions are not specially aligned;
97+
/// - constructors and destructors return 'this', as in ARM;
98+
/// - guard variables are 32-bit on wasm32, as in ARM;
99+
/// - unused bits of guard variables are reserved, as in ARM;
100+
/// - inline functions are never key functions, as in ARM;
101+
/// - C++11 POD rules are used for tail padding, as in iOS64.
102+
///
103+
/// TODO: At present the WebAssembly ABI is not considered stable, so none
104+
/// of these details is necessarily final yet.
105+
WebAssembly,
106+
107+
/// The Fuchsia ABI is a modified version of the Itanium ABI.
108+
///
109+
/// The relevant changes from the Itanium ABI are:
110+
/// - constructors and destructors return 'this', as in ARM.
111+
Fuchsia,
112+
113+
/// The XL ABI is the ABI used by IBM xlclang compiler and is a modified
114+
/// version of the Itanium ABI.
115+
///
116+
/// The relevant changes from the Itanium ABI are:
117+
/// - static initialization is adjusted to use sinit and sterm functions;
118+
XL,
119+
120+
/// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and
121+
/// compatible compilers).
122+
///
123+
/// FIXME: should this be split into Win32 and Win64 variants?
124+
///
125+
/// Only scattered and incomplete official documentation exists.
126+
Microsoft
31127
};
32128

33129
private:
@@ -36,20 +132,7 @@ class TargetCXXABI {
36132
// audit the users to pass it by reference instead.
37133
Kind TheKind;
38134

39-
static const auto &getABIMap() {
40-
static llvm::StringMap<Kind> ABIMap = {
41-
#define CXXABI(Name, Str) {Str, Name},
42-
#include "TargetCXXABI.def"
43-
};
44-
return ABIMap;
45-
}
46-
47135
public:
48-
static Kind getKind(StringRef Name) { return getABIMap().lookup(Name); }
49-
static bool isABI(StringRef Name) {
50-
return getABIMap().find(Name) != getABIMap().end();
51-
}
52-
53136
/// A bogus initialization of the platform ABI.
54137
TargetCXXABI() : TheKind(GenericItanium) {}
55138

@@ -64,11 +147,19 @@ class TargetCXXABI {
64147
/// Does this ABI generally fall into the Itanium family of ABIs?
65148
bool isItaniumFamily() const {
66149
switch (getKind()) {
67-
#define CXXABI(Name, Str)
68-
#define ITANIUM_CXXABI(Name, Str) case Name:
69-
#include "TargetCXXABI.def"
150+
case Fuchsia:
151+
case GenericAArch64:
152+
case GenericItanium:
153+
case GenericARM:
154+
case iOS:
155+
case iOS64:
156+
case WatchOS:
157+
case GenericMIPS:
158+
case WebAssembly:
159+
case XL:
70160
return true;
71-
default:
161+
162+
case Microsoft:
72163
return false;
73164
}
74165
llvm_unreachable("bad ABI kind");
@@ -77,12 +168,20 @@ class TargetCXXABI {
77168
/// Is this ABI an MSVC-compatible ABI?
78169
bool isMicrosoft() const {
79170
switch (getKind()) {
80-
#define CXXABI(Name, Str)
81-
#define MICROSOFT_CXXABI(Name, Str) case Name:
82-
#include "TargetCXXABI.def"
83-
return true;
84-
default:
171+
case Fuchsia:
172+
case GenericAArch64:
173+
case GenericItanium:
174+
case GenericARM:
175+
case iOS:
176+
case iOS64:
177+
case WatchOS:
178+
case GenericMIPS:
179+
case WebAssembly:
180+
case XL:
85181
return false;
182+
183+
case Microsoft:
184+
return true;
86185
}
87186
llvm_unreachable("bad ABI kind");
88187
}

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,10 +1371,6 @@ def fno_experimental_relative_cxx_abi_vtables : Flag<["-"], "fno-experimental-re
13711371
Group<f_Group>, Flags<[CC1Option]>,
13721372
HelpText<"Do not use the experimental C++ class ABI for classes with virtual tables">;
13731373

1374-
def fcxx_abi_EQ : Joined<["-"], "fc++-abi=">,
1375-
Group<f_clang_Group>, Flags<[CC1Option]>,
1376-
HelpText<"C++ ABI to use. This will override the target C++ ABI.">;
1377-
13781374
def flat__namespace : Flag<["-"], "flat_namespace">;
13791375
def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, Group<f_Group>,
13801376
HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, Flags<[CC1Option]>;

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -879,15 +879,10 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
879879
return CanonTTP;
880880
}
881881

882-
TargetCXXABI::Kind ASTContext::getCXXABIKind() const {
883-
auto Kind = getTargetInfo().getCXXABI().getKind();
884-
return getLangOpts().CXXABI.getValueOr(Kind);
885-
}
886-
887882
CXXABI *ASTContext::createCXXABI(const TargetInfo &T) {
888883
if (!LangOpts.CPlusPlus) return nullptr;
889884

890-
switch (getCXXABIKind()) {
885+
switch (T.getCXXABI().getKind()) {
891886
case TargetCXXABI::Fuchsia:
892887
case TargetCXXABI::GenericARM: // Same as Itanium at this level
893888
case TargetCXXABI::iOS:

0 commit comments

Comments
 (0)