[llvm] r233610 - LexicalScopes: Use MDLocation directly instead of DebugLoc

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


Author: dexonsmith
Date: Mon Mar 30 16:54:46 2015
New Revision: 233610

URL: http://llvm.org/viewvc/llvm-project?rev=233610&view=rev
Log:
LexicalScopes: Use MDLocation directly instead of DebugLoc

There's no benefit to using `DebugLoc` here.  Moreover, this will let a
follow-up commit work with `MDScope` directly instead of `DebugLoc`.

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

Modified: llvm/trunk/include/llvm/CodeGen/LexicalScopes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LexicalScopes.h?rev=233610&r1=233609&r2=233610&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LexicalScopes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LexicalScopes.h Mon Mar 30 16:54:46 2015
@@ -158,16 +158,16 @@ public:
   /// getMachineBasicBlocks - Populate given set using machine basic blocks
   /// which have machine instructions that belong to lexical scope identified by
   /// DebugLoc.
-  void getMachineBasicBlocks(DebugLoc DL,
+  void getMachineBasicBlocks(const MDLocation *DL,
                              SmallPtrSetImpl<const MachineBasicBlock *> &MBBs);
 
   /// dominates - Return true if DebugLoc's lexical scope dominates at least one
   /// machine instruction's lexical scope in a given machine basic block.
-  bool dominates(DebugLoc DL, MachineBasicBlock *MBB);
+  bool dominates(const MDLocation *DL, MachineBasicBlock *MBB);
 
   /// findLexicalScope - Find lexical scope, either regular or inlined, for the
   /// given DebugLoc. Return NULL if not found.
-  LexicalScope *findLexicalScope(DebugLoc DL);
+  LexicalScope *findLexicalScope(const MDLocation *DL);
 
   /// getAbstractScopesList - Return a reference to list of abstract scopes.
   ArrayRef<LexicalScope *> getAbstractScopesList() const {
@@ -201,7 +201,7 @@ public:
 private:
   /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
   /// not available then create new lexical scope.
-  LexicalScope *getOrCreateLexicalScope(DebugLoc DL);
+  LexicalScope *getOrCreateLexicalScope(const MDLocation *DL);
 
   /// getOrCreateRegularScope - Find or create a regular lexical scope.
   LexicalScope *getOrCreateRegularScope(MDNode *Scope);

Modified: llvm/trunk/lib/CodeGen/LexicalScopes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=233610&r1=233609&r2=233610&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LexicalScopes.cpp (original)
+++ llvm/trunk/lib/CodeGen/LexicalScopes.cpp Mon Mar 30 16:54:46 2015
@@ -106,18 +106,17 @@ void LexicalScopes::extractLexicalScopes
 
 /// findLexicalScope - Find lexical scope, either regular or inlined, for the
 /// given DebugLoc. Return NULL if not found.
-LexicalScope *LexicalScopes::findLexicalScope(DebugLoc DL) {
-  auto *Scope = DL.getScope();
+LexicalScope *LexicalScopes::findLexicalScope(const MDLocation *DL) {
+  MDLocalScope *Scope = DL->getScope();
   if (!Scope)
     return nullptr;
 
   // The scope that we were created with could have an extra file - which
   // isn't what we care about in this case.
-  DIDescriptor D = DIDescriptor(Scope);
-  if (D.isLexicalBlockFile())
-    Scope = DILexicalBlockFile(Scope).getScope();
+  if (auto *File = dyn_cast<MDLexicalBlockFile>(Scope))
+    Scope = File->getScope();
 
-  if (auto *IA = DL.getInlinedAt()) {
+  if (auto *IA = DL->getInlinedAt()) {
     auto I = InlinedLexicalScopeMap.find(std::make_pair(Scope, IA));
     return I != InlinedLexicalScopeMap.end() ? &I->second : nullptr;
   }
@@ -126,12 +125,11 @@ LexicalScope *LexicalScopes::findLexical
 
 /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
 /// not available then create new lexical scope.
-LexicalScope *LexicalScopes::getOrCreateLexicalScope(DebugLoc DL) {
+LexicalScope *LexicalScopes::getOrCreateLexicalScope(const MDLocation *DL) {
   if (!DL)
     return nullptr;
-
-  MDNode *Scope = DL.getScope();
-  if (auto *InlinedAt = DL.getInlinedAt()) {
+  MDScope *Scope = DL->getScope();
+  if (auto *InlinedAt = DL->getInlinedAt()) {
     // Create an abstract scope for inlined function.
     getOrCreateAbstractScope(Scope);
     // Create an inlined scope for inlined function.
@@ -276,7 +274,7 @@ void LexicalScopes::assignInstructionRan
 /// have machine instructions that belong to lexical scope identified by
 /// DebugLoc.
 void LexicalScopes::getMachineBasicBlocks(
-    DebugLoc DL, SmallPtrSetImpl<const MachineBasicBlock *> &MBBs) {
+    const MDLocation *DL, SmallPtrSetImpl<const MachineBasicBlock *> &MBBs) {
   MBBs.clear();
   LexicalScope *Scope = getOrCreateLexicalScope(DL);
   if (!Scope)
@@ -299,7 +297,7 @@ void LexicalScopes::getMachineBasicBlock
 
 /// dominates - Return true if DebugLoc's lexical scope dominates at least one
 /// machine instruction's lexical scope in a given machine basic block.
-bool LexicalScopes::dominates(DebugLoc DL, MachineBasicBlock *MBB) {
+bool LexicalScopes::dominates(const MDLocation *DL, MachineBasicBlock *MBB) {
   LexicalScope *Scope = getOrCreateLexicalScope(DL);
   if (!Scope)
     return false;





More information about the llvm-commits mailing list