Added MachineBasicBlock::getFullName() to standardize/factor codegen diagnostics.
authorAndrew Trick <atrick@apple.com>
Wed, 7 Mar 2012 00:18:18 +0000 (00:18 +0000)
committerAndrew Trick <atrick@apple.com>
Wed, 7 Mar 2012 00:18:18 +0000 (00:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152176 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineBasicBlock.h
lib/CodeGen/MachineBasicBlock.cpp

index 576ce944469ed44df178652c642a6b07863baa14..ef9c0c200584a9f3194f2d8c9e856383b6d75f41 100644 (file)
@@ -117,6 +117,10 @@ public:
   /// "(null)".
   StringRef getName() const;
 
+  /// getFullName - Return a formatted string to identify this block and its
+  /// parent function.
+  std::string getFullName() const;
+
   /// hasAddressTaken - Test whether this block is potentially the target
   /// of an indirect branch.
   bool hasAddressTaken() const { return AddressTaken; }
index 611b045691468067bce641d78c610d90815a735d..ca8a8e8072ad4422ca3e740f59c0c72016679192 100644 (file)
@@ -238,6 +238,18 @@ StringRef MachineBasicBlock::getName() const {
     return "(null)";
 }
 
+/// Return a hopefully unique identifier for this block.
+std::string MachineBasicBlock::getFullName() const {
+  std::string Name;
+  if (getParent())
+    Name = (getParent()->getFunction()->getName() + ":").str();
+  if (getBasicBlock())
+    Name += getBasicBlock()->getName();
+  else
+    Name += (Twine("BB") + Twine(getNumber())).str();
+  return Name;
+}
+
 void MachineBasicBlock::print(raw_ostream &OS, SlotIndexes *Indexes) const {
   const MachineFunction *MF = getParent();
   if (!MF) {