This is an archive of the discontinued LLVM Phabricator instance.

[NFC][AssemblyWriter]Allow AssemblyWriter::printBasicBlock() to print blocks that don't have parents.
ClosedPublic

Authored by xiaoqing_wu on Jul 15 2021, 10:15 PM.

Details

Summary

Remove the assert in AssemblyWriter::printBasicBlock() and in BasicBlock::isEntryBlock() that require blocks to have parents. Instead, have BasicBlock::isEntryBlock() return false for unattached blocks. This allows us to call these functions for blocks that are not yet added to a module which is a useful debugging capability.

Diff Detail

Event Timeline

xiaoqing_wu created this revision.Jul 15 2021, 10:15 PM
xiaoqing_wu requested review of this revision.Jul 15 2021, 10:15 PM

This version contains the correct diff.

xiaoqing_wu retitled this revision from Allow AssemblyWriter::printBasicBlock() to print blocks that don't have parents. to [NFC][AssemblyWriter]Allow AssemblyWriter::printBasicBlock() to print blocks that don't have parents..Jul 20 2021, 11:48 AM
xiaoqing_wu added a reviewer: nikic.
jyknight added inline comments.Jul 20 2021, 1:20 PM
llvm/lib/IR/AsmWriter.cpp
3849

I'd suggest to make this be:
bool IsEntryBlock = BB->getParent() && BB->isEntryBlock();
instead of modifying isEntryBlock.

Updated the patch based on review feedback.

xiaoqing_wu marked an inline comment as done.Jul 20 2021, 2:01 PM
xiaoqing_wu added inline comments.
llvm/lib/IR/AsmWriter.cpp
3849

Thanks for the suggestion.

xiaoqing_wu marked an inline comment as done.Jul 20 2021, 2:01 PM
jyknight accepted this revision.Jul 20 2021, 2:40 PM

Please make sure to update the description to match the new code before committing.

This revision is now accepted and ready to land.Jul 20 2021, 2:40 PM
martong removed a subscriber: martong.Jul 28 2021, 9:19 AM