forked from OSchip/llvm-project
[AsmPrinter] fix nullptr dereference for MBBs with hasAddressTaken property without BB
Basic block pointer is dereferenced unconditionally for MBBs with hasAddressTaken property. MBBs might have hasAddressTaken property without reference to BB. Backend developers must assign fake BB to MBB to workaround this issue and it should be fixed. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D108092
This commit is contained in:
parent
83457d398d
commit
913b5d2f7a
|
@ -3270,21 +3270,21 @@ void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
|
|||
// reference the block. It is possible that there is more than one label
|
||||
// here, because multiple LLVM BB's may have been RAUW'd to this block after
|
||||
// the references were generated.
|
||||
const BasicBlock *BB = MBB.getBasicBlock();
|
||||
if (MBB.hasAddressTaken()) {
|
||||
const BasicBlock *BB = MBB.getBasicBlock();
|
||||
if (isVerbose())
|
||||
OutStreamer->AddComment("Block address taken");
|
||||
|
||||
// MBBs can have their address taken as part of CodeGen without having
|
||||
// their corresponding BB's address taken in IR
|
||||
if (BB->hasAddressTaken())
|
||||
if (BB && BB->hasAddressTaken())
|
||||
for (MCSymbol *Sym : MMI->getAddrLabelSymbolToEmit(BB))
|
||||
OutStreamer->emitLabel(Sym);
|
||||
}
|
||||
|
||||
// Print some verbose block comments.
|
||||
if (isVerbose()) {
|
||||
if (const BasicBlock *BB = MBB.getBasicBlock()) {
|
||||
if (BB) {
|
||||
if (BB->hasName()) {
|
||||
BB->printAsOperand(OutStreamer->GetCommentOS(),
|
||||
/*PrintType=*/false, BB->getModule());
|
||||
|
|
Loading…
Reference in New Issue