Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIR][Codegen] RTTI support for virtual class inheritence #259

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

htyu
Copy link
Contributor

@htyu htyu commented Sep 14, 2023

This patch adds RTTI support for C++ virtual inheritance.

This patch does not include LLVM lowering support.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding RTTI support for vbases

clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Outdated Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Outdated Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Outdated Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Outdated Show resolved Hide resolved
continue;
emitError() << "expected GlobalViewAttr attribute";
emitError() << "expected GlobalViewAttr or IntAttr attribute";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that TypeInfo now supports a IntAttr seems a bit arbitrary in this PR, what does it mean? Can you add some docs to TypeInfoAttr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integers are for

  // Itanium C++ ABI 2.9.5p6c:
  //   __flags is a word with flags describing details about the class
  //   structure, which may be referenced by using the __flags_masks
  //   enumeration. These flags refer to both direct and indirect bases.
  unsigned Flags = ComputeVMIClassTypeInfoFlags(RD);
  Fields.push_back(mlir::cir::IntAttr::get(UnsignedIntLTy, Flags));

and

// Itanium C++ ABI 2.9.5p6c:
 //   __base_count is a word with the number of direct proper base class
 //   descriptions that follow.

Fields.push_back(mlir::cir::IntAttr::get(UnsignedIntLTy, RD->getNumBases()));

Updated doc for TypeInfoAttr

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more curious about the meaning of those, which I just explained better in the other comment: use enum kind attributes for the flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use a enum attribute for the flags, but the int attribute is still needed for getNumBases?

clang/test/CIR/CodeGen/vbase.cpp Show resolved Hide resolved
@@ -303,7 +303,8 @@ def TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> {

The verifier enforces that the output type is always a `!cir.struct`,
and that the ArrayAttr element types match the equivalent member type
for the resulting struct.
for the resulting struct, i.e, a GlobalViewAttr for symbol reference or
an IntAttr for flags.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still would prefer not to use an IntAttr but a enum kind attr that contains BCTI_Virtual, BCTI_Public, etc (and incrementally add the enums as we get usecases). Using IntAttr feels too opaque and already LLVM-like. Are there restrictions to doing such approach?

clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Outdated Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Show resolved Hide resolved
continue;
emitError() << "expected GlobalViewAttr attribute";
emitError() << "expected GlobalViewAttr or IntAttr attribute";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more curious about the meaning of those, which I just explained better in the other comment: use enum kind attributes for the flags.

clang/test/CIR/CodeGen/vbase.cpp Show resolved Hide resolved
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is good to go, I'll file some issues so we can later improve specific bits.

@htyu htyu merged commit fd263e4 into llvm:main Oct 18, 2023
bcardosolopes pushed a commit that referenced this pull request Oct 19, 2023
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
lanza pushed a commit that referenced this pull request Oct 25, 2023
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Oct 25, 2023
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
lanza pushed a commit that referenced this pull request Oct 27, 2023
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Oct 27, 2023
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
lanza pushed a commit that referenced this pull request Dec 20, 2023
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Dec 20, 2023
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
lanza pushed a commit that referenced this pull request Jan 29, 2024
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Jan 29, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
lanza pushed a commit to lanza/llvm-project that referenced this pull request Feb 8, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on llvm/clangir#259
lanza pushed a commit that referenced this pull request Mar 23, 2024
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Mar 23, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on llvm#259
lanza pushed a commit that referenced this pull request Apr 29, 2024
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Apr 29, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
lanza pushed a commit that referenced this pull request Apr 29, 2024
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Apr 29, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Apr 29, 2024
This patch adds RTTI support for C++ virtual inheritance. 

This patch does not include LLVM lowering support.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Apr 29, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on llvm#259
lanza pushed a commit that referenced this pull request Apr 29, 2024
This patch adds RTTI support for C++ virtual inheritance.

This patch does not include LLVM lowering support.
lanza pushed a commit that referenced this pull request Apr 29, 2024
Lowering Vtable and RTTI globals. Also lowering AddressPoint.

based on #259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants