[llvm] r233650 - DebugInfo: Remove LexicalBlockFile scope/context distinction

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Mar 30 17:10:38 PDT 2015


Author: dexonsmith
Date: Mon Mar 30 19:10:37 2015
New Revision: 233650

URL: http://llvm.org/viewvc/llvm-project?rev=233650&view=rev
Log:
DebugInfo: Remove LexicalBlockFile scope/context distinction

Two things here:

 1. I read `getScope()` and `getContext()` backwards in r233640.  There
    was no need for `getScopeOfScope()`.  Obviously not enough test
    coverage here (as I said in that commit, I'm going to come back to
    that), but anyway I'm reverting to the behaviour before r233640.
 2. The callers that use `DILexicalBlockFile::getContext()` don't seem
    to care about the difference.  Just have it redirect to `getScope()`
    so I can't get confused again.

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

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=233650&r1=233649&r2=233650&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Mar 30 19:10:37 2015
@@ -908,13 +908,7 @@ public:
     return *get();
   }
 
-  DIScope getContext() const {
-    // FIXME: This logic is horrible.  getScope() returns a DILexicalBlock, but
-    // then we check if it's a subprogram?  WHAT?!?
-    if (getScope().isSubprogram())
-      return getScope();
-    return getScope().getContext();
-  }
+  DIScope getContext() const { return getScope(); }
   unsigned getLineNumber() const { return getScope().getLineNumber(); }
   unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
   DILexicalBlock getScope() const {

Modified: llvm/trunk/lib/CodeGen/LexicalScopes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=233650&r1=233649&r2=233650&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LexicalScopes.cpp (original)
+++ llvm/trunk/lib/CodeGen/LexicalScopes.cpp Mon Mar 30 19:10:37 2015
@@ -104,15 +104,6 @@ void LexicalScopes::extractLexicalScopes
   }
 }
 
-static MDLocalScope *getScopeOfScope(const MDLexicalBlockFile *File) {
-  // FIXME: Why double-walk the scope list?  Are these just being encoded
-  // awkwardly?
-  auto *Scope = File->getScope();
-  if (auto *Block = dyn_cast<MDLexicalBlockBase>(Scope))
-    return Block->getScope();
-  return Scope;
-}
-
 /// findLexicalScope - Find lexical scope, either regular or inlined, for the
 /// given DebugLoc. Return NULL if not found.
 LexicalScope *LexicalScopes::findLexicalScope(const MDLocation *DL) {
@@ -123,7 +114,7 @@ LexicalScope *LexicalScopes::findLexical
   // The scope that we were created with could have an extra file - which
   // isn't what we care about in this case.
   if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope))
-    Scope = getScopeOfScope(File);
+    Scope = File->getScope();
 
   if (auto *IA = DL->getInlinedAt()) {
     auto I = InlinedLexicalScopeMap.find(std::make_pair(Scope, IA));
@@ -150,7 +141,7 @@ LexicalScope *LexicalScopes::getOrCreate
 LexicalScope *
 LexicalScopes::getOrCreateRegularScope(const MDLocalScope *Scope) {
   if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope))
-    Scope = getScopeOfScope(File);
+    Scope = File->getScope();
 
   auto I = LexicalScopeMap.find(Scope);
   if (I != LexicalScopeMap.end())
@@ -204,7 +195,7 @@ LexicalScopes::getOrCreateAbstractScope(
   assert(Scope && "Invalid Scope encoding!");
 
   if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope))
-    Scope = getScopeOfScope(File);
+    Scope = File->getScope();
   auto I = AbstractScopeMap.find(Scope);
   if (I != AbstractScopeMap.end())
     return &I->second;





More information about the llvm-commits mailing list