diff options
author | Eli Friedman <efriedma@quicinc.com> | 2022-08-16 16:15:44 -0700 |
---|---|---|
committer | Eli Friedman <efriedma@quicinc.com> | 2022-08-16 16:15:44 -0700 |
commit | cfd2c5ce580fce744f6fd6ba34e869cab05e94c3 (patch) | |
tree | ca1395331cdc448d042dd192c0856e7a9c141943 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | d9198f64d9be149acdad109cd053b6acdd9635d2 (diff) | |
download | llvm-cfd2c5ce580fce744f6fd6ba34e869cab05e94c3.zip llvm-cfd2c5ce580fce744f6fd6ba34e869cab05e94c3.tar.gz llvm-cfd2c5ce580fce744f6fd6ba34e869cab05e94c3.tar.bz2 |
Untangle the mess which is MachineBasicBlock::hasAddressTaken().
There are two different senses in which a block can be "address-taken".
There can be a BlockAddress involved, which means we need to map the
IR-level value to some specific block of machine code. Or there can be
constructs inside a function which involve using the address of a basic
block to implement certain kinds of control flow.
Mixing these together causes a problem: if target-specific passes are
marking random blocks "address-taken", if we have a BlockAddress, we
can't actually tell which MachineBasicBlock corresponds to the
BlockAddress.
So split this into two separate bits: one for BlockAddress, and one for
the machine-specific bits.
Discovered while trying to sort out related stuff on D102817.
Differential Revision: https://reviews.llvm.org/D124697
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 7381c7e6..7fd51c8 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -476,6 +476,28 @@ void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags, os << "bb." << getNumber(); bool hasAttributes = false; + auto PrintBBRef = [&](const BasicBlock *bb) { + os << "%ir-block."; + if (bb->hasName()) { + os << bb->getName(); + } else { + int slot = -1; + + if (moduleSlotTracker) { + slot = moduleSlotTracker->getLocalSlot(bb); + } else if (bb->getParent()) { + ModuleSlotTracker tmpTracker(bb->getModule(), false); + tmpTracker.incorporateFunction(*bb->getParent()); + slot = tmpTracker.getLocalSlot(bb); + } + + if (slot == -1) + os << "<ir-block badref>"; + else + os << slot; + } + }; + if (printNameFlags & PrintNameIr) { if (const auto *bb = getBasicBlock()) { if (bb->hasName()) { @@ -483,29 +505,21 @@ void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags, } else { hasAttributes = true; os << " ("; - - int slot = -1; - - if (moduleSlotTracker) { - slot = moduleSlotTracker->getLocalSlot(bb); - } else if (bb->getParent()) { - ModuleSlotTracker tmpTracker(bb->getModule(), false); - tmpTracker.incorporateFunction(*bb->getParent()); - slot = tmpTracker.getLocalSlot(bb); - } - - if (slot == -1) - os << "<ir-block badref>"; - else - os << (Twine("%ir-block.") + Twine(slot)).str(); + PrintBBRef(bb); } } } if (printNameFlags & PrintNameAttributes) { - if (hasAddressTaken()) { + if (isMachineBlockAddressTaken()) { + os << (hasAttributes ? ", " : " ("); + os << "machine-block-address-taken"; + hasAttributes = true; + } + if (isIRBlockAddressTaken()) { os << (hasAttributes ? ", " : " ("); - os << "address-taken"; + os << "ir-block-address-taken "; + PrintBBRef(getAddressTakenIRBlock()); hasAttributes = true; } if (isEHPad()) { |