[llvm] r233643 - DebugLoc: Remove getFromDILexicalBlock()

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Mar 30 16:47:26 PDT 2015


Author: dexonsmith
Date: Mon Mar 30 18:47:26 2015
New Revision: 233643

URL: http://llvm.org/viewvc/llvm-project?rev=233643&view=rev
Log:
DebugLoc: Remove getFromDILexicalBlock()

The only user of `DebugLoc::getFromDILexicalBlock()` was creating a new
`MDLocation` as convenient API for passing an `MDScope`.  Stop doing
that, and remove the API.  If in the future we actually *want* to create
new DebugLocs, calling `MDLexicalBlock::get()` makes more sense.

Modified:
    llvm/trunk/include/llvm/CodeGen/LexicalScopes.h
    llvm/trunk/include/llvm/IR/DebugLoc.h
    llvm/trunk/lib/CodeGen/LexicalScopes.cpp
    llvm/trunk/lib/IR/DebugLoc.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LexicalScopes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LexicalScopes.h?rev=233643&r1=233642&r2=233643&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LexicalScopes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LexicalScopes.h Mon Mar 30 18:47:26 2015
@@ -200,9 +200,14 @@ public:
   LexicalScope *getOrCreateAbstractScope(const MDLocalScope *Scope);
 
 private:
-  /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
+  /// getOrCreateLexicalScope - Find lexical scope for the given Scope/IA. If
   /// not available then create new lexical scope.
-  LexicalScope *getOrCreateLexicalScope(const MDLocation *DL);
+  LexicalScope *getOrCreateLexicalScope(const MDLocalScope *Scope,
+                                        const MDLocation *IA = nullptr);
+  LexicalScope *getOrCreateLexicalScope(const MDLocation *DL) {
+    return DL ? getOrCreateLexicalScope(DL->getScope(), DL->getInlinedAt())
+              : nullptr;
+  }
 
   /// getOrCreateRegularScope - Find or create a regular lexical scope.
   LexicalScope *getOrCreateRegularScope(const MDLocalScope *Scope);

Modified: llvm/trunk/include/llvm/IR/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugLoc.h?rev=233643&r1=233642&r2=233643&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugLoc.h (original)
+++ llvm/trunk/include/llvm/IR/DebugLoc.h Mon Mar 30 18:47:26 2015
@@ -90,12 +90,6 @@ namespace llvm {
     static DebugLoc get(unsigned Line, unsigned Col, MDNode *Scope,
                         MDNode *InlinedAt = nullptr);
 
-    /// \brief Translate the DILexicalBlock into a DebugLoc.
-    ///
-    /// FIXME: Remove this.  It has only one user, and the user just wants to
-    /// pass an \a MDScope around.
-    static DebugLoc getFromDILexicalBlock(MDNode *N);
-
     unsigned getLine() const;
     unsigned getCol() const;
     MDNode *getScope() const;

Modified: llvm/trunk/lib/CodeGen/LexicalScopes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=233643&r1=233642&r2=233643&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LexicalScopes.cpp (original)
+++ llvm/trunk/lib/CodeGen/LexicalScopes.cpp Mon Mar 30 18:47:26 2015
@@ -134,15 +134,13 @@ LexicalScope *LexicalScopes::findLexical
 
 /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
 /// not available then create new lexical scope.
-LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocation *DL) {
-  if (!DL)
-    return nullptr;
-  MDLocalScope *Scope = DL->getScope();
-  if (auto *InlinedAt = DL->getInlinedAt()) {
+LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocalScope *Scope,
+                                                     const MDLocation *IA) {
+  if (IA) {
     // Create an abstract scope for inlined function.
     getOrCreateAbstractScope(Scope);
     // Create an inlined scope for inlined function.
-    return getOrCreateInlinedScope(Scope, InlinedAt);
+    return getOrCreateInlinedScope(Scope, IA);
   }
 
   return getOrCreateRegularScope(Scope);
@@ -158,11 +156,10 @@ LexicalScopes::getOrCreateRegularScope(c
   if (I != LexicalScopeMap.end())
     return &I->second;
 
+  // FIXME: Should the following dyn_cast be MDLexicalBlock?
   LexicalScope *Parent = nullptr;
-  if (isa<MDLexicalBlockBase>(Scope)) // FIXME: Should this be MDLexicalBlock?
-    Parent =
-        getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(
-                                    const_cast<MDLocalScope *>(Scope)).get());
+  if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope))
+    Parent = getOrCreateLexicalScope(Block->getScope());
   I = LexicalScopeMap.emplace(std::piecewise_construct,
                               std::forward_as_tuple(Scope),
                               std::forward_as_tuple(Parent, Scope, nullptr,

Modified: llvm/trunk/lib/IR/DebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugLoc.cpp?rev=233643&r1=233642&r2=233643&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugLoc.cpp (original)
+++ llvm/trunk/lib/IR/DebugLoc.cpp Mon Mar 30 18:47:26 2015
@@ -66,15 +66,6 @@ DebugLoc DebugLoc::get(unsigned Line, un
   return MDLocation::get(Scope->getContext(), Line, Col, Scope, InlinedAt);
 }
 
-/// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc.
-DebugLoc DebugLoc::getFromDILexicalBlock(MDNode *N) {
-  DILexicalBlock LexBlock(N);
-  MDNode *Scope = LexBlock.getContext();
-  if (!Scope) return DebugLoc();
-  return get(LexBlock.getLineNumber(), LexBlock.getColumnNumber(), Scope,
-             nullptr);
-}
-
 void DebugLoc::dump() const {
 #ifndef NDEBUG
   if (!Loc)





More information about the llvm-commits mailing list