Skip to content

Commit 320c703

Browse files
committed
Added MachineBasicBlock::getFullName() to standardize/factor codegen diagnostics.
llvm-svn: 152176
1 parent 5297d8d commit 320c703

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

llvm/include/llvm/CodeGen/MachineBasicBlock.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ class MachineBasicBlock : public ilist_node<MachineBasicBlock> {
117117
/// "(null)".
118118
StringRef getName() const;
119119

120+
/// getFullName - Return a formatted string to identify this block and its
121+
/// parent function.
122+
std::string getFullName() const;
123+
120124
/// hasAddressTaken - Test whether this block is potentially the target
121125
/// of an indirect branch.
122126
bool hasAddressTaken() const { return AddressTaken; }

llvm/lib/CodeGen/MachineBasicBlock.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,18 @@ StringRef MachineBasicBlock::getName() const {
238238
return "(null)";
239239
}
240240

241+
/// Return a hopefully unique identifier for this block.
242+
std::string MachineBasicBlock::getFullName() const {
243+
std::string Name;
244+
if (getParent())
245+
Name = (getParent()->getFunction()->getName() + ":").str();
246+
if (getBasicBlock())
247+
Name += getBasicBlock()->getName();
248+
else
249+
Name += (Twine("BB") + Twine(getNumber())).str();
250+
return Name;
251+
}
252+
241253
void MachineBasicBlock::print(raw_ostream &OS, SlotIndexes *Indexes) const {
242254
const MachineFunction *MF = getParent();
243255
if (!MF) {

0 commit comments

Comments
 (0)