Skip to content

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?

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
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
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.
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