[llvm-commits] [llvm] r84134 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h

Chris Lattner clattner at apple.com
Sun Jan 3 21:12:40 PST 2010


On Oct 14, 2009, at 2:08 PM, Devang Patel wrote:
> Author: dpatel
> Date: Wed Oct 14 16:08:09 2009
> New Revision: 84134
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=84134&view=rev
> Log:
> Add support to record DbgScope as inlined scope.

Devang, why does InlinedAt need to be a WeakVH here?  WeakVH is much more expensive than it looks.

-Chris

> 
> Modified:
>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=84134&r1=84133&r2=84134&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Oct 14 16:08:09 2009
> @@ -145,7 +145,10 @@
> class VISIBILITY_HIDDEN DbgScope {
>   DbgScope *Parent;                   // Parent to this scope.
>   DIDescriptor Desc;                  // Debug info descriptor for scope.
> -                                      // Either subprogram or block.
> +                                      // FIXME use WeakVH for Desc.
> +  WeakVH InlinedAt;                   // If this scope represents inlined
> +                                      // function body then this is the location
> +                                      // where this body is inlined.
>   unsigned StartLabelID;              // Label ID of the beginning of scope.
>   unsigned EndLabelID;                // Label ID of the end of scope.
>   const MachineInstr *LastInsn;       // Last instruction of this scope.
> @@ -157,14 +160,17 @@
>   // Private state for dump()
>   mutable unsigned IndentLevel;
> public:
> -  DbgScope(DbgScope *P, DIDescriptor D)
> -    : Parent(P), Desc(D), StartLabelID(0), EndLabelID(0), LastInsn(0),
> -      FirstInsn(0), IndentLevel(0) {}
> +  DbgScope(DbgScope *P, DIDescriptor D, MDNode *I = 0)
> +    : Parent(P), Desc(D), InlinedAt(I), StartLabelID(0), EndLabelID(0), 
> +      LastInsn(0), FirstInsn(0), IndentLevel(0) {}
>   virtual ~DbgScope();
> 
>   // Accessors.
>   DbgScope *getParent()          const { return Parent; }
>   DIDescriptor getDesc()         const { return Desc; }
> +  MDNode *getInlinedAt()   const { 
> +    return dyn_cast_or_null<MDNode>(InlinedAt); 
> +  }
>   unsigned getStartLabelID()     const { return StartLabelID; }
>   unsigned getEndLabelID()       const { return EndLabelID; }
>   SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
> @@ -1296,29 +1302,39 @@
> 
> /// getOrCreateScope - Returns the scope associated with the given descriptor.
> ///
> -DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI) {
> +DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI,
> +                                  MDNode *InlinedAt) {
>   DbgScope *&Slot = DbgScopeMap[N];
>   if (Slot) return Slot;
> 
>   DbgScope *Parent = NULL;
> 
> -  DIDescriptor Scope(N);
> -  if (Scope.isCompileUnit()) {
> -    return NULL;
> -  } else if (Scope.isSubprogram()) {
> -    DISubprogram SP(N);
> -    DIDescriptor ParentDesc = SP.getContext();
> -    if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit())
> -      Parent = getDbgScope(ParentDesc.getNode(), MI);
> -  } else if (Scope.isLexicalBlock()) {
> -    DILexicalBlock DB(N);
> -    DIDescriptor ParentDesc = DB.getContext();
> -    if (!ParentDesc.isNull())
> -      Parent = getDbgScope(ParentDesc.getNode(), MI);
> -  } else
> -    assert (0 && "Unexpected scope info");
> +  if (InlinedAt) {
> +    DILocation IL(InlinedAt);
> +    assert (!IL.isNull() && "Invalid InlindAt location!");
> +    DenseMap<MDNode *, DbgScope *>::iterator DSI = 
> +      DbgScopeMap.find(IL.getScope().getNode());
> +    assert (DSI != DbgScopeMap.end() && "Unable to find InlineAt scope!");
> +    Parent = DSI->second;
> +  } else {
> +    DIDescriptor Scope(N);
> +    if (Scope.isCompileUnit()) {
> +      return NULL;
> +    } else if (Scope.isSubprogram()) {
> +      DISubprogram SP(N);
> +      DIDescriptor ParentDesc = SP.getContext();
> +      if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit())
> +        Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt);
> +    } else if (Scope.isLexicalBlock()) {
> +      DILexicalBlock DB(N);
> +      DIDescriptor ParentDesc = DB.getContext();
> +      if (!ParentDesc.isNull())
> +        Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt);
> +    } else
> +      assert (0 && "Unexpected scope info");
> +  }
> 
> -  Slot = new DbgScope(Parent, DIDescriptor(N));
> +  Slot = new DbgScope(Parent, DIDescriptor(N), InlinedAt);
>   Slot->setFirstInsn(MI);
> 
>   if (Parent)
> @@ -1795,7 +1811,10 @@
>     DIVariable DV (Var);
>     if (DV.isNull()) continue;
>     unsigned VSlot = VI->second;
> -    DbgScope *Scope = getDbgScope(DV.getContext().getNode(),  NULL);
> +    DenseMap<MDNode *, DbgScope *>::iterator DSI = 
> +      DbgScopeMap.find(DV.getContext().getNode());
> +    assert (DSI != DbgScopeMap.end() && "Unable to find variable scope!");
> +    DbgScope *Scope = DSI->second;
>     Scope->AddVariable(new DbgVariable(DV, VSlot, false));
>   }
> }
> @@ -1849,7 +1868,7 @@
>       // into a scope DIE at the end.
>       DIDescriptor D(DLT.Scope);
>       if (!D.isCompileUnit()) {
> -        DbgScope *Scope = getDbgScope(DLT.Scope, MInsn);
> +        DbgScope *Scope = getDbgScope(DLT.Scope, MInsn, DLT.InlinedAtLoc);
>         Scope->setLastInsn(MInsn);
>       }
>     }
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=84134&r1=84133&r2=84134&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Oct 14 16:08:09 2009
> @@ -364,7 +364,7 @@
>   /// getDbgScope - Returns the scope associated with the given descriptor.
>   ///
>   DbgScope *getOrCreateScope(MDNode *N);
> -  DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI);
> +  DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt);
> 
>   /// ConstructDbgScope - Construct the components of a scope.
>   ///
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list