[llvm] r234819 - DebugInfo: Move DILocation::getDiscriminator() to MDLocation

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Apr 13 17:05:13 PDT 2015


Author: dexonsmith
Date: Mon Apr 13 19:05:13 2015
New Revision: 234819

URL: http://llvm.org/viewvc/llvm-project?rev=234819&view=rev
Log:
DebugInfo: Move DILocation::getDiscriminator() to MDLocation

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h
    llvm/trunk/include/llvm/IR/DebugInfoMetadata.h

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234819&r1=234818&r2=234819&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 13 19:05:13 2015
@@ -701,23 +701,7 @@ public:
   DILocation getOrigLocation() const { return get()->getInlinedAt(); }
   StringRef getFilename() const { return get()->getFilename(); }
   StringRef getDirectory() const { return get()->getDirectory(); }
-
-  /// \brief Get the DWAF discriminator.
-  ///
-  /// DWARF discriminators are used to distinguish identical file locations for
-  /// instructions that are on different basic blocks. If two instructions are
-  /// inside the same lexical block and are in different basic blocks, we
-  /// create a new lexical block with identical location as the original but
-  /// with a different discriminator value
-  /// (lib/Transforms/Util/AddDiscriminators.cpp for details).
-  unsigned getDiscriminator() const {
-    // Since discriminators are associated with lexical blocks, make
-    // sure this location is a lexical block before retrieving its
-    // value.
-    if (auto *F = dyn_cast<MDLexicalBlockFile>(get()->getScope()))
-      return F->getDiscriminator();
-    return 0;
-  }
+  unsigned getDiscriminator() const { return get()->getDiscriminator(); }
 
   /// \brief Generate a new discriminator value for this location.
   unsigned computeNewDiscriminator(LLVMContext &Ctx);

Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234819&r1=234818&r2=234819&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr 13 19:05:13 2015
@@ -1203,6 +1203,12 @@ public:
     return getFilename() != RHS.getFilename() || getLine() != RHS.getLine();
   }
 
+  /// \brief Get the DWARF discriminator.
+  ///
+  /// DWARF discriminators distinguish identical file locations between
+  /// instructions that are on different basic blocks.
+  inline unsigned getDiscriminator() const;
+
   Metadata *getRawScope() const { return getOperand(0); }
   Metadata *getRawInlinedAt() const {
     if (getNumOperands() == 2)
@@ -1528,6 +1534,12 @@ public:
   }
 };
 
+unsigned MDLocation::getDiscriminator() const {
+  if (auto *F = dyn_cast<MDLexicalBlockFile>(getScope()))
+    return F->getDiscriminator();
+  return 0;
+}
+
 class MDNamespace : public MDScope {
   friend class LLVMContextImpl;
   friend class MDNode;





More information about the llvm-commits mailing list