Skip to content

[CIR] Add support for DumpRecordLayouts #1667

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

Merged
merged 4 commits into from
Jun 9, 2025

Conversation

Andres-Salamanca
Copy link
Contributor

This PR adds support for the -fdump-record-layouts flag. It enables printing both the CIRGenRecordLayout and the ASTRecordLayout, similar to what is done in CodeGen.

@Andres-Salamanca
Copy link
Contributor Author

@andykaylor @xlauko

Copy link
Collaborator

@andykaylor andykaylor 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 implementing this! Can you add a test to verify the output?

@@ -201,6 +201,7 @@ class CIRGenRecordLayout {
assert(it != BitFields.end() && "Unable to find bitfield info");
return it->second;
}
void print(raw_ostream &os) const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's very handy to have an additional method, dump() which prints to llvm::errs() and is marked with LLVM_DUMP_METHOD. This lets you print the object from a debugger.

os << "<CIRecordLayout\n";
os << " CIR Type:" << CompleteObjectType << "\n";
if (BaseSubobjectType)
os << " NonVirtualBaseLLVMType:" << BaseSubobjectType << "\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
os << " NonVirtualBaseLLVMType:" << BaseSubobjectType << "\n";
os << " NonVirtualBaseCIRType:" << BaseSubobjectType << "\n";

@bcardosolopes bcardosolopes merged commit 960c0b0 into llvm:main Jun 9, 2025
9 checks passed
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.

3 participants