diff options
| author | Devang Patel <dpatel@apple.com> | 2009-01-15 18:25:17 +0000 | 
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2009-01-15 18:25:17 +0000 | 
| commit | 8bdc6983367273c562d2acaf55a3f2b1b8e7fd83 (patch) | |
| tree | 46e8d66ffd275e50983a394d3131fb8b3e2dae63 /llvm/lib/CodeGen | |
| parent | 707f6436e026b545851d04f1b62d1cec95007e72 (diff) | |
| download | bcm5719-llvm-8bdc6983367273c562d2acaf55a3f2b1b8e7fd83.tar.gz bcm5719-llvm-8bdc6983367273c562d2acaf55a3f2b1b8e7fd83.zip | |
Use variable's context to identify respective DbgScope.
Use light weight DebugInfo object directly.
llvm-svn: 62269
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 36 | 
1 files changed, 25 insertions, 11 deletions
| diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 0adbf174f15..d73f2fe5bfb 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -1212,7 +1212,7 @@ public:  class DbgScope {  private:    DbgScope *Parent;                   // Parent to this scope. -  DIDescriptor *Desc;                 // Debug info descriptor for scope. +  DIDescriptor Desc;                 // Debug info descriptor for scope.                                        // Either subprogram or block.    unsigned StartLabelID;              // Label ID of the beginning of scope.    unsigned EndLabelID;                // Label ID of the end of scope. @@ -1220,7 +1220,7 @@ private:    SmallVector<DbgVariable *, 8> Variables;// Variables declared in scope.  public: -  DbgScope(DbgScope *P, DIDescriptor *D) +  DbgScope(DbgScope *P, DIDescriptor D)    : Parent(P), Desc(D), StartLabelID(0), EndLabelID(0), Scopes(), Variables()    {}    ~DbgScope() { @@ -1230,7 +1230,7 @@ public:    // Accessors.    DbgScope *getParent()        const { return Parent; } -  DIDescriptor *getDesc()       const { return Desc; } +  DIDescriptor getDesc()       const { return Desc; }    unsigned getStartLabelID()     const { return StartLabelID; }    unsigned getEndLabelID()       const { return EndLabelID; }    SmallVector<DbgScope *, 4> &getScopes() { return Scopes; } @@ -1307,7 +1307,7 @@ private:    ///    bool shouldEmit; -  // RootScope - Top level scope for the current function. +  // RootDbgScope - Top level scope for the current function.    //    DbgScope *RootDbgScope; @@ -2009,13 +2009,14 @@ private:      if (!Slot) {        // FIXME - breaks down when the context is an inlined function.        DIDescriptor ParentDesc; -      DIDescriptor *DB = new DIDescriptor(V); -      if (DIBlock *Block = dyn_cast<DIBlock>(DB)) { -        ParentDesc = Block->getContext(); +      DIDescriptor Desc(V); +      if (Desc.getTag() == dwarf::DW_TAG_lexical_block) { +        DIBlock Block(V); +        ParentDesc = Block.getContext();        }        DbgScope *Parent = ParentDesc.isNull() ?           NULL : getOrCreateScope(ParentDesc.getGV()); -      Slot = new DbgScope(Parent, DB); +      Slot = new DbgScope(Parent, Desc);        if (Parent) {          Parent->AddScope(Slot);        } else if (RootDbgScope) { @@ -2091,10 +2092,12 @@ private:    void ConstructRootDbgScope(DbgScope *RootScope) {      // Exit if there is no root scope.      if (!RootScope) return; -    if (RootScope->getDesc()->isNull()) return; +    DIDescriptor Desc = RootScope->getDesc(); +    if (Desc.isNull()) +      return;      // Get the subprogram debug information entry. -    DISubprogram SPD(RootScope->getDesc()->getGV()); +    DISubprogram SPD(Desc.getGV());      // Get the compile unit context.      CompileUnit *Unit = FindCompileUnit(SPD.getCompileUnit()); @@ -3123,7 +3126,18 @@ public:    /// RecordVariable - Indicate the declaration of  a local variable.    ///    void RecordVariable(GlobalVariable *GV, unsigned FrameIndex) { -    DbgScope *Scope = getOrCreateScope(GV); +    DIDescriptor Desc(GV); +    DbgScope *Scope = NULL; +    if (Desc.getTag() == DW_TAG_variable) { +      // GV is a global variable. +      DIGlobalVariable DG(GV); +      Scope = getOrCreateScope(DG.getContext().getGV()); +    } else { +      // or GV is a local variable. +      DIVariable DV(GV); +      Scope = getOrCreateScope(DV.getContext().getGV()); +    } +    assert (Scope && "Unable to find variable' scope");      DIVariable *VD = new DIVariable(GV);      DbgVariable *DV = new DbgVariable(VD, FrameIndex);      Scope->AddVariable(DV); | 

