[PATCH] D77592: [NFC][CodeGen] Add enum for selecting the layout of components in the vtable
Leonard Chan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 23 09:43:38 PDT 2020
leonardchan updated this revision to Diff 259602.
leonardchan added a comment.
Updated to reflect the changes in D72959 <https://reviews.llvm.org/D72959> which make the vtable 4-byte aligned under the `Relative` layout.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77592/new/
https://reviews.llvm.org/D77592
Files:
clang/include/clang/AST/VTableBuilder.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/VTableBuilder.cpp
Index: clang/lib/AST/VTableBuilder.cpp
===================================================================
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -2221,8 +2221,9 @@
VTableLayout::~VTableLayout() { }
-ItaniumVTableContext::ItaniumVTableContext(ASTContext &Context)
- : VTableContextBase(/*MS=*/false) {}
+ItaniumVTableContext::ItaniumVTableContext(
+ ASTContext &Context, VTableComponentLayout ComponentLayout)
+ : VTableContextBase(/*MS=*/false), ComponentLayout(ComponentLayout) {}
ItaniumVTableContext::~ItaniumVTableContext() {}
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -10463,6 +10463,8 @@
if (Target->getCXXABI().isMicrosoft())
VTContext.reset(new MicrosoftVTableContext(*this));
else
+ // TODO: Specify that we want to use the Relative VTableComponentLayout
+ // here once we add the option for selecting it for Fuchsia.
VTContext.reset(new ItaniumVTableContext(*this));
}
return VTContext.get();
Index: clang/include/clang/AST/VTableBuilder.h
===================================================================
--- clang/include/clang/AST/VTableBuilder.h
+++ clang/include/clang/AST/VTableBuilder.h
@@ -371,7 +371,20 @@
void computeVTableRelatedInformation(const CXXRecordDecl *RD) override;
public:
- ItaniumVTableContext(ASTContext &Context);
+ enum VTableComponentLayout {
+ /// Components in the vtable are pointers to other structs/functions.
+ /// Offsets are of size ptrdiff_t, making the entire vtable pointer aligned.
+ /// This is the default layout.
+ Pointer,
+
+ /// Components in the vtable are relative 32-bit offsets between the vtable
+ /// and other structs/functions. Offsets will be 32-bits, making the entire
+ /// vtable 4-byte aligned.
+ Relative,
+ };
+
+ ItaniumVTableContext(ASTContext &Context,
+ VTableComponentLayout ComponentLayout = Pointer);
~ItaniumVTableContext() override;
const VTableLayout &getVTableLayout(const CXXRecordDecl *RD) {
@@ -402,6 +415,16 @@
static bool classof(const VTableContextBase *VT) {
return !VT->isMicrosoft();
}
+
+ VTableComponentLayout getVTableComponentLayout() const {
+ return ComponentLayout;
+ }
+
+ bool isPointerLayout() const { return ComponentLayout == Pointer; }
+ bool isRelativeLayout() const { return ComponentLayout == Relative; }
+
+private:
+ VTableComponentLayout ComponentLayout;
};
/// Holds information about the inheritance path to a virtual base or function
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77592.259602.patch
Type: text/x-patch
Size: 2663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200423/3d51e2b1/attachment-0001.bin>
More information about the cfe-commits
mailing list