This commit does a lot more than just revert 71158, and I'm getting a lot of asserts in debug info generation now. Can you revert this and re-revert 71158?<div><br></div><div> - Daniel<br><br><div class="gmail_quote">On Thu, May 7, 2009 at 10:26 AM, Bill Wendling <span dir="ltr"><<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Author: void<br>
Date: Thu May  7 12:26:14 2009<br>
New Revision: 71165<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=71165&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=71165&view=rev</a><br>
Log:<br>
Temporarily revert r71158. It was causing a failure during a full bootstrap:<br>
<br>
checking for bcopy... no<br>
checking for getc_unlocked... Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.<br>

/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decUtility.c:360: internal compiler error: Abort trap<br>
Please submit a full bug report,<br>
with preprocessed source if appropriate.<br>
See <URL:<a href="http://developer.apple.com/bugreporter" target="_blank">http://developer.apple.com/bugreporter</a>> for instructions.<br>
make[4]: *** [decUtility.o] Error 1<br>
make[4]: *** Waiting for unfinished jobs....<br>
Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511.<br>
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decNumber.c:5591: internal compiler error: Abort trap<br>
Please submit a full bug report,<br>
with preprocessed source if appropriate.<br>
See <URL:<a href="http://developer.apple.com/bugreporter" target="_blank">http://developer.apple.com/bugreporter</a>> for instructions.<br>
make[4]: *** [decNumber.o] Error 1<br>
make[3]: *** [all-stage2-libdecnumber] Error 2<br>
make[3]: *** Waiting for unfinished jobs....<br>
<br>
<br>
Removed:<br>
    llvm/trunk/test/Transforms/InstCombine/constant-fold-ptr-casts.ll<br>
Modified:<br>
    llvm/trunk/include/llvm/Analysis/DebugInfo.h<br>
    llvm/trunk/include/llvm/CodeGen/DwarfWriter.h<br>
    llvm/trunk/lib/Analysis/ConstantFolding.cpp<br>
    llvm/trunk/lib/Analysis/DebugInfo.cpp<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=71165&r1=71164&r2=71165&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=71165&r1=71164&r2=71165&view=diff</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu May  7 12:26:14 2009<br>
@@ -321,6 +321,19 @@<br>
     bool describes(const Function *F);<br>
   };<br>
<br>
+  /// DIInlinedSubprogram - This is a wrapper for an inlined subprogram.<br>
+  class DIInlinedSubprogram : public DIGlobal {<br>
+  public:<br>
+    explicit DIInlinedSubprogram(GlobalVariable *GV = 0);<br>
+    DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }<br>
+<br>
+    /// Verify - Verify that an inlined subprogram descriptor is well formed.<br>
+    bool Verify() const;<br>
+<br>
+    /// dump - print inlined subprogram.<br>
+    void dump() const;<br>
+  };<br>
+<br>
   /// DIGlobalVariable - This is a wrapper for a global variable.<br>
   class DIGlobalVariable : public DIGlobal {<br>
   public:<br>
@@ -363,6 +376,7 @@<br>
   public:<br>
     explicit DIBlock(GlobalVariable *GV = 0);<br>
<br>
+    DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(1); }<br>
     DIDescriptor getContext() const { return getDescriptorField(1); }<br>
   };<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/DwarfWriter.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DwarfWriter.h?rev=71165&r1=71164&r2=71165&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DwarfWriter.h?rev=71165&r1=71164&r2=71165&view=diff</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/include/llvm/CodeGen/DwarfWriter.h (original)<br>
+++ llvm/trunk/include/llvm/CodeGen/DwarfWriter.h Thu May  7 12:26:14 2009<br>
@@ -91,7 +91,7 @@<br>
   unsigned RecordRegionStart(GlobalVariable *V);<br>
<br>
   /// RecordRegionEnd - Indicate the end of a region.<br>
-  unsigned RecordRegionEnd(GlobalVariable *V);<br>
+  unsigned RecordRegionEnd(GlobalVariable *V, DISubprogram &SP);<br>
<br>
   /// getRecordSourceLineCount - Count source lines.<br>
   unsigned getRecordSourceLineCount();<br>
<br>
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=71165&r1=71164&r2=71165&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=71165&r1=71164&r2=71165&view=diff</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Thu May  7 12:26:14 2009<br>
@@ -16,7 +16,6 @@<br>
 #include "llvm/Constants.h"<br>
 #include "llvm/DerivedTypes.h"<br>
 #include "llvm/Function.h"<br>
-#include "llvm/GlobalVariable.h"<br>
 #include "llvm/Instructions.h"<br>
 #include "llvm/Intrinsics.h"<br>
 #include "llvm/ADT/SmallVector.h"<br>
@@ -384,43 +383,12 @@<br>
     // the int size is >= the ptr size.  This requires knowing the width of a<br>
     // pointer, so it can't be done in ConstantExpr::getCast.<br>
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[0])) {<br>
-      if (TD &&<br>
+      if (TD && CE->getOpcode() == Instruction::PtrToInt &&<br>
           TD->getPointerSizeInBits() <=<br>
           CE->getType()->getPrimitiveSizeInBits()) {<br>
-        if (CE->getOpcode() == Instruction::PtrToInt) {<br>
-          Constant *Input = CE->getOperand(0);<br>
-          Constant *C = FoldBitCast(Input, DestTy, *TD);<br>
-          return C ? C : ConstantExpr::getBitCast(Input, DestTy);<br>
-        }<br>
-        // If there's a constant offset added to the integer value before<br>
-        // it is casted back to a pointer, see if the expression can be<br>
-        // converted into a GEP.<br>
-        if (CE->getOpcode() == Instruction::Add)<br>
-          if (ConstantInt *L = dyn_cast<ConstantInt>(CE->getOperand(0)))<br>
-            if (ConstantExpr *R = dyn_cast<ConstantExpr>(CE->getOperand(1)))<br>
-              if (R->getOpcode() == Instruction::PtrToInt)<br>
-                if (GlobalVariable *GV =<br>
-                      dyn_cast<GlobalVariable>(R->getOperand(0))) {<br>
-                  const PointerType *GVTy = cast<PointerType>(GV->getType());<br>
-                  if (const ArrayType *AT =<br>
-                        dyn_cast<ArrayType>(GVTy->getElementType())) {<br>
-                    const Type *ElTy = AT->getElementType();<br>
-                    uint64_t PaddedSize = TD->getTypePaddedSize(ElTy);<br>
-                    APInt PSA(L->getValue().getBitWidth(), PaddedSize);<br>
-                    if (ElTy == cast<PointerType>(DestTy)->getElementType() &&<br>
-                        L->getValue().urem(PSA) == 0) {<br>
-                      APInt ElemIdx = L->getValue().udiv(PSA);<br>
-                      if (ElemIdx.ult(APInt(ElemIdx.getBitWidth(),<br>
-                                            AT->getNumElements()))) {<br>
-                        Constant *Index[] = {<br>
-                          Constant::getNullValue(CE->getType()),<br>
-                          ConstantInt::get(ElemIdx)<br>
-                        };<br>
-                        return ConstantExpr::getGetElementPtr(GV, &Index[0], 2);<br>
-                      }<br>
-                    }<br>
-                  }<br>
-                }<br>
+        Constant *Input = CE->getOperand(0);<br>
+        Constant *C = FoldBitCast(Input, DestTy, *TD);<br>
+        return C ? C : ConstantExpr::getBitCast(Input, DestTy);<br>
       }<br>
     }<br>
     return ConstantExpr::getCast(Opcode, Ops[0], DestTy);<br>
<br>
Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=71165&r1=71164&r2=71165&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=71165&r1=71164&r2=71165&view=diff</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Thu May  7 12:26:14 2009<br>
@@ -59,6 +59,9 @@<br>
   case DW_TAG_subprogram:<br>
     assert(DISubprogram(GV).Verify() && "Invalid DebugInfo value");<br>
     break;<br>
+  case DW_TAG_inlined_subroutine:<br>
+    assert(DIInlinedSubprogram(GV).Verify() && "Invalid DebugInfo value");<br>
+    break;<br>
   case DW_TAG_lexical_block:<br>
     /// FIXME. This interfers with the quality of generated code when<br>
     /// during optimization.<br>
@@ -146,6 +149,8 @@<br>
   : DIType(GV, dwarf::DW_TAG_base_type) {}<br>
 DISubprogram::DISubprogram(GlobalVariable *GV)<br>
   : DIGlobal(GV, dwarf::DW_TAG_subprogram) {}<br>
+DIInlinedSubprogram::DIInlinedSubprogram(GlobalVariable *GV)<br>
+  : DIGlobal(GV, dwarf::DW_TAG_inlined_subroutine) {}<br>
 DIGlobalVariable::DIGlobalVariable(GlobalVariable *GV)<br>
   : DIGlobal(GV, dwarf::DW_TAG_variable) {}<br>
 DIBlock::DIBlock(GlobalVariable *GV)<br>
@@ -286,6 +291,25 @@<br>
   return true;<br>
 }<br>
<br>
+/// Verify - Verify that an inlined subprogram descriptor is well formed.<br>
+bool DIInlinedSubprogram::Verify() const {<br>
+  if (isNull())<br>
+    return false;<br>
+<br>
+  if (getContext().isNull())<br>
+    return false;<br>
+<br>
+  DICompileUnit CU = getCompileUnit();<br>
+  if (!CU.Verify())<br>
+    return false;<br>
+<br>
+  DICompositeType Ty = getType();<br>
+  if (!Ty.isNull() && !Ty.Verify())<br>
+    return false;<br>
+<br>
+  return true;<br>
+}<br>
+<br>
 /// Verify - Verify that a global variable descriptor is well formed.<br>
 bool DIGlobalVariable::Verify() const {<br>
   if (isNull())<br>
@@ -983,7 +1007,8 @@<br>
<br>
 /// dump - print descriptor.<br>
 void DIDescriptor::dump() const {<br>
-  cerr << " [" << dwarf::TagString(getTag()) << "]\n";<br>
+  cerr << "[" << dwarf::TagString(getTag()) << "] ";<br>
+  cerr << std::hex << "[GV:" << GV << "]" << std::dec;<br>
 }<br>
<br>
 /// dump - print compile unit.<br>
@@ -1085,6 +1110,11 @@<br>
   DIGlobal::dump();<br>
 }<br>
<br>
+/// dump - print subprogram.<br>
+void DIInlinedSubprogram::dump() const {<br>
+  DIGlobal::dump();<br>
+}<br>
+<br>
 /// dump - print global variable.<br>
 void DIGlobalVariable::dump() const {<br>
   cerr << " ["; getGlobal()->dump(); cerr << "] ";<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=71165&r1=71164&r2=71165&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=71165&r1=71164&r2=71165&view=diff</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Thu May  7 12:26:14 2009<br>
@@ -1094,7 +1094,7 @@<br>
 ///<br>
 class DbgVariable {<br>
   DIVariable Var;                   // Variable Descriptor.<br>
-  unsigned FrameIndex;               // Variable frame index.<br>
+  unsigned FrameIndex;              // Variable frame index.<br>
 public:<br>
   DbgVariable(DIVariable V, unsigned I) : Var(V), FrameIndex(I)  {}<br>
<br>
@@ -1280,14 +1280,32 @@<br>
   /// DbgInlinedScopeMap - Tracks inlined scopes in the current function.<br>
   DenseMap<GlobalVariable *, SmallVector<DbgScope *, 2> > DbgInlinedScopeMap;<br>
<br>
-  /// InlineInfo - Keep track of inlined functions and their location.<br>
-  /// This information is used to populate debug_inlined section.<br>
+  /// InlineInfo - Keep track of inlined functions and their location. This<br>
+  /// information is used to populate debug_inlined section.<br>
   DenseMap<GlobalVariable *, SmallVector<unsigned, 4> > InlineInfo;<br>
<br>
   /// InlinedVariableScopes - Scopes information for the inlined subroutine<br>
   /// variables.<br>
   DenseMap<const MachineInstr *, DbgScope *> InlinedVariableScopes;<br>
<br>
+  /// AbstractInstanceRootMap - Map of abstract instance roots of inlined<br>
+  /// functions. These are subroutine entries that contain a DW_AT_inline<br>
+  /// attribute.<br>
+  DenseMap<const GlobalVariable *, DbgScope *> AbstractInstanceRootMap;<br>
+<br>
+  /// AbstractInstanceRootList - List of abstract instance roots of inlined<br>
+  /// functions. These are subroutine entries that contain a DW_AT_inline<br>
+  /// attribute.<br>
+  SmallVector<DbgScope *, 32> AbstractInstanceRootList;<br>
+<br>
+  /// LexicalScopeToConcreteInstMap - Map a concrete instance's DIE to the<br>
+  /// lexical scope it's in.<br>
+  DenseMap<DbgScope *, DIE *> LexicalScopeToConcreteInstMap;<br>
+<br>
+  /// LexicalScopeStack - A stack of lexical scopes. The top one is the current<br>
+  /// scope.<br>
+  SmallVector<DbgScope *, 16> LexicalScopeStack;<br>
+<br>
   /// DebugTimer - Timer for the Dwarf debug writer.<br>
   Timer *DebugTimer;<br>
<br>
@@ -1769,7 +1787,7 @@<br>
           if (Element.getTag() == dwarf::DW_TAG_subprogram)<br>
             ElemDie = CreateSubprogramDIE(DW_Unit,<br>
                                           DISubprogram(Element.getGV()));<br>
-          else if (Element.getTag() == dwarf::DW_TAG_variable) // ???<br>
+          else if (Element.getTag() == dwarf::DW_TAG_variable) // ??<br>
             ElemDie = CreateGlobalVariableDIE(DW_Unit,<br>
                                               DIGlobalVariable(Element.getGV()));<br>
           else<br>
@@ -1958,6 +1976,7 @@<br>
<br>
     if (!SP.isDefinition()) {<br>
       AddUInt(SPDie, DW_AT_declaration, DW_FORM_flag, 1);<br>
+<br>
       // Add arguments. Do not add arguments for subprogram definition. They<br>
       // will be handled through RecordVariable.<br>
       if (SPTag == DW_TAG_subroutine_type)<br>
@@ -2030,6 +2049,13 @@<br>
     DbgScope *&Slot = DbgScopeMap[V];<br>
     if (Slot) return Slot;<br>
<br>
+    // Don't create a new scope if we already created one for an inlined<br>
+    // function.<br>
+    DenseMap<const GlobalVariable *, DbgScope *>::iterator<br>
+      II = AbstractInstanceRootMap.find(V);<br>
+    if (II != AbstractInstanceRootMap.end())<br>
+      return LexicalScopeStack.back();<br>
+<br>
     DbgScope *Parent = NULL;<br>
     DIBlock Block(V);<br>
<br>
@@ -2050,31 +2076,19 @@<br>
     return Slot;<br>
   }<br>
<br>
-  /// createInlinedSubroutineScope - Returns the scope associated with the<br>
-  /// inlined subroutine.<br>
-  ///<br>
-  DbgScope *createInlinedSubroutineScope(DISubprogram SP, unsigned Src,<br>
-                                         unsigned Line, unsigned Col) {<br>
-    DbgScope *Scope =<br>
-      new DbgInlinedSubroutineScope(NULL, SP, Src, Line, Col);<br>
-<br>
-    // FIXME - Add inlined function scopes to the root so we can delete them<br>
-    // later.<br>
-    assert (FunctionDbgScope && "Function scope info missing!");<br>
-    FunctionDbgScope->AddScope(Scope);<br>
-    return Scope;<br>
-  }<br>
-<br>
   /// ConstructDbgScope - Construct the components of a scope.<br>
   ///<br>
   void ConstructDbgScope(DbgScope *ParentScope,<br>
                          unsigned ParentStartID, unsigned ParentEndID,<br>
                          DIE *ParentDie, CompileUnit *Unit) {<br>
-    // Add variables to scope.<br>
-    SmallVector<DbgVariable *, 8> &Variables = ParentScope->getVariables();<br>
-    for (unsigned i = 0, N = Variables.size(); i < N; ++i) {<br>
-      DIE *VariableDie = NewDbgScopeVariable(Variables[i], Unit);<br>
-      if (VariableDie) ParentDie->AddChild(VariableDie);<br>
+    if (LexicalScopeToConcreteInstMap.find(ParentScope) ==<br>
+        LexicalScopeToConcreteInstMap.end()) {<br>
+      // Add variables to scope.<br>
+      SmallVector<DbgVariable *, 8> &Variables = ParentScope->getVariables();<br>
+      for (unsigned i = 0, N = Variables.size(); i < N; ++i) {<br>
+        DIE *VariableDie = NewDbgScopeVariable(Variables[i], Unit);<br>
+        if (VariableDie) ParentDie->AddChild(VariableDie);<br>
+      }<br>
     }<br>
<br>
     // Add nested scopes.<br>
@@ -2099,17 +2113,14 @@<br>
         ConstructDbgScope(Scope, ParentStartID, ParentEndID, ParentDie, Unit);<br>
       } else {<br>
         DIE *ScopeDie = NULL;<br>
-        if (MainCU && TAI->doesDwarfUsesInlineInfoSection()<br>
-            && Scope->isInlinedSubroutine()) {<br>
-          ScopeDie = new DIE(DW_TAG_inlined_subroutine);<br>
-          DIE *Origin = MainCU->getDieMapSlotFor(Scope->getDesc().getGV());<br>
-          AddDIEntry(ScopeDie, DW_AT_abstract_origin, DW_FORM_ref4, Origin);<br>
-          AddUInt(ScopeDie, DW_AT_call_file, 0, Scope->getFile());<br>
-          AddUInt(ScopeDie, DW_AT_call_line, 0, Scope->getLine());<br>
-          AddUInt(ScopeDie, DW_AT_call_column, 0, Scope->getColumn());<br>
-        } else {<br>
+<br>
+        DenseMap<DbgScope *, DIE *>::iterator I =<br>
+          LexicalScopeToConcreteInstMap.find(Scope);<br>
+<br>
+        if (I != LexicalScopeToConcreteInstMap.end())<br>
+          ScopeDie = I->second;<br>
+        else<br>
           ScopeDie = new DIE(DW_TAG_lexical_block);<br>
-        }<br>
<br>
         // Add the scope bounds.<br>
         if (StartID)<br>
@@ -2165,6 +2176,29 @@<br>
     ConstructDbgScope(RootScope, 0, 0, SPDie, Unit);<br>
   }<br>
<br>
+  void ConstructAbstractDbgScope(DbgScope *AbsScope) {<br>
+    // Exit if there is no root scope.<br>
+    if (!AbsScope) return;<br>
+<br>
+    DIDescriptor Desc = AbsScope->getDesc();<br>
+    if (Desc.isNull())<br>
+      return;<br>
+<br>
+    // Get the subprogram debug information entry.<br>
+    DISubprogram SPD(Desc.getGV());<br>
+<br>
+    // Get the compile unit context.<br>
+    CompileUnit *Unit = MainCU;<br>
+    if (!Unit)<br>
+      Unit = &FindCompileUnit(SPD.getCompileUnit());<br>
+<br>
+    // Get the subprogram die.<br>
+    DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV());<br>
+    assert(SPDie && "Missing subprogram descriptor");<br>
+<br>
+    ConstructDbgScope(AbsScope, 0, 0, SPDie, Unit);<br>
+  }<br>
+<br>
   /// ConstructDefaultDbgScope - Construct a default scope for the subprogram.<br>
   ///<br>
   void ConstructDefaultDbgScope(MachineFunction *MF) {<br>
@@ -2891,7 +2925,6 @@<br>
       DISubprogram SP(GV);<br>
       std::string Name;<br>
       std::string LName;<br>
-<br>
       SP.getLinkageName(LName);<br>
       SP.getName(Name);<br>
<br>
@@ -3087,8 +3120,10 @@<br>
<br>
     // Add to map.<br>
     Slot = SubprogramDie;<br>
+<br>
     // Add to context owner.<br>
     Unit->getDie()->AddChild(SubprogramDie);<br>
+<br>
     // Expose as global.<br>
     std::string Name;<br>
     Unit->AddGlobal(SP.getName(Name), SubprogramDie);<br>
@@ -3136,6 +3171,11 @@<br>
     for (unsigned j = 0, M = Values.size(); j < M; ++j)<br>
       delete Values[j];<br>
<br>
+    for (DenseMap<const GlobalVariable *, DbgScope *>::iterator<br>
+           I = AbstractInstanceRootMap.begin(),<br>
+           E = AbstractInstanceRootMap.end(); I != E;++I)<br>
+      delete I->second;<br>
+<br>
     delete DebugTimer;<br>
   }<br>
<br>
@@ -3342,6 +3382,12 @@<br>
       // information) needs to be explored.<br>
       ConstructDefaultDbgScope(MF);<br>
<br>
+    // Construct the DbgScope for abstract instances.<br>
+    for (SmallVector<DbgScope *, 32>::iterator<br>
+           I = AbstractInstanceRootList.begin(),<br>
+           E = AbstractInstanceRootList.end(); I != E; ++I)<br>
+      ConstructAbstractDbgScope(*I);<br>
+<br>
     DebugFrames.push_back(FunctionDebugFrameInfo(SubprogramCount,<br>
                                                  MMI->getFrameMoves()));<br>
<br>
@@ -3352,6 +3398,9 @@<br>
       DbgInlinedScopeMap.clear();<br>
       InlinedVariableScopes.clear();<br>
       FunctionDbgScope = NULL;<br>
+      LexicalScopeStack.clear();<br>
+      AbstractInstanceRootList.clear();<br>
+      LexicalScopeToConcreteInstMap.clear();<br>
     }<br>
<br>
     Lines.clear();<br>
@@ -3429,6 +3478,7 @@<br>
     DbgScope *Scope = getOrCreateScope(V);<br>
     unsigned ID = MMI->NextLabelID();<br>
     if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);<br>
+    LexicalScopeStack.push_back(Scope);<br>
<br>
     if (TimePassesIsEnabled)<br>
       DebugTimer->stopTimer();<br>
@@ -3437,13 +3487,14 @@<br>
   }<br>
<br>
   /// RecordRegionEnd - Indicate the end of a region.<br>
-  unsigned RecordRegionEnd(GlobalVariable *V) {<br>
+  unsigned RecordRegionEnd(GlobalVariable *V, DISubprogram &SP) {<br>
     if (TimePassesIsEnabled)<br>
       DebugTimer->startTimer();<br>
<br>
-    DbgScope *Scope = getOrCreateScope(V);<br>
     unsigned ID = MMI->NextLabelID();<br>
+    DbgScope *Scope = getOrCreateScope(V);<br>
     Scope->setEndLabelID(ID);<br>
+    LexicalScopeStack.pop_back();<br>
<br>
     if (TimePassesIsEnabled)<br>
       DebugTimer->stopTimer();<br>
@@ -3497,28 +3548,59 @@<br>
     if (TimePassesIsEnabled)<br>
       DebugTimer->startTimer();<br>
<br>
-    std::string Dir, Fn;<br>
-    unsigned Src = GetOrCreateSourceID(CU.getDirectory(Dir),<br>
-                                       CU.getFilename(Fn));<br>
-    DbgScope *Scope = createInlinedSubroutineScope(SP, Src, Line, Col);<br>
-    Scope->setStartLabelID(LabelID);<br>
-    MMI->RecordUsedDbgLabel(LabelID);<br>
     GlobalVariable *GV = SP.getGV();<br>
+    DenseMap<const GlobalVariable *, DbgScope *>::iterator<br>
+      II = AbstractInstanceRootMap.find(GV);<br>
<br>
-    DenseMap<GlobalVariable *, SmallVector<DbgScope *, 2> >::iterator<br>
-      SI = DbgInlinedScopeMap.find(GV);<br>
+    if (II == AbstractInstanceRootMap.end()) {<br>
+      // Create an abstract instance entry for this inlined function if it<br>
+      // doesn't already exist.<br>
+      DbgScope *Scope = new DbgScope(NULL, DIDescriptor(GV));<br>
+<br>
+      // Get the compile unit context.<br>
+      CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit());<br>
+      DIE *SPDie = Unit->getDieMapSlotFor(GV);<br>
+      assert(SPDie && "Missing subprogram descriptor!");<br>
+<br>
+      // Mark as being inlined. This makes this subprogram entry an abstract<br>
+      // instance root.<br>
+      // FIXME: Our debugger doesn't care about the value of DW_AT_inline, only<br>
+      // that it's defined. It probably won't change in the future, but this<br>
+      // could be more elegant.<br>
+      AddUInt(SPDie, DW_AT_inline, 0, DW_INL_declared_not_inlined);<br>
+<br>
+      // Keep track of the scope that's inlined into this function.<br>
+      DenseMap<GlobalVariable *, SmallVector<DbgScope *, 2> >::iterator<br>
+        SI = DbgInlinedScopeMap.find(GV);<br>
<br>
-    if (SI == DbgInlinedScopeMap.end())<br>
-      DbgInlinedScopeMap[GV].push_back(Scope);<br>
-    else<br>
-      SI->second.push_back(Scope);<br>
+      if (SI == DbgInlinedScopeMap.end())<br>
+        DbgInlinedScopeMap[GV].push_back(Scope);<br>
+      else<br>
+        SI->second.push_back(Scope);<br>
+<br>
+      // Track the start label for this inlined function.<br>
+      DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator<br>
+        I = InlineInfo.find(GV);<br>
<br>
-    DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator<br>
-      I = InlineInfo.find(GV);<br>
-    if (I == InlineInfo.end())<br>
-      InlineInfo[GV].push_back(LabelID);<br>
-    else<br>
-      I->second.push_back(LabelID);<br>
+      if (I == InlineInfo.end())<br>
+        InlineInfo[GV].push_back(LabelID);<br>
+      else<br>
+        I->second.push_back(LabelID);<br>
+<br>
+      AbstractInstanceRootMap[GV] = Scope;<br>
+      AbstractInstanceRootList.push_back(Scope);<br>
+    }<br>
+<br>
+    // Create a concrete inlined instance for this inlined function.<br>
+    DIE *ScopeDie = new DIE(DW_TAG_inlined_subroutine);<br>
+    CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit());<br>
+    DIE *Origin = Unit->getDieMapSlotFor(GV);<br>
+    AddDIEntry(ScopeDie, DW_AT_abstract_origin, DW_FORM_ref4, Origin);<br>
+    AddUInt(ScopeDie, DW_AT_call_file, 0, Unit->getID());<br>
+    AddUInt(ScopeDie, DW_AT_call_line, 0, Line);<br>
+    AddUInt(ScopeDie, DW_AT_call_column, 0, Col);<br>
+<br>
+    LexicalScopeToConcreteInstMap[LexicalScopeStack.back()] = ScopeDie;<br>
<br>
     if (TimePassesIsEnabled)<br>
       DebugTimer->stopTimer();<br>
@@ -3528,6 +3610,7 @@<br>
<br>
   /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.<br>
   unsigned RecordInlinedFnEnd(DISubprogram &SP) {<br>
+    // FIXME: This function never seems to be called!!<br>
     if (!TAI->doesDwarfUsesInlineInfoSection())<br>
       return 0;<br>
<br>
@@ -4729,8 +4812,8 @@<br>
 }<br>
<br>
 /// RecordRegionEnd - Indicate the end of a region.<br>
-unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V) {<br>
-  return DD->RecordRegionEnd(V);<br>
+unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V, DISubprogram &SP) {<br>
+  return DD->RecordRegionEnd(V, SP);<br>
 }<br>
<br>
 /// getRecordSourceLineCount - Count source lines.<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=71165&r1=71164&r2=71165&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=71165&r1=71164&r2=71165&view=diff</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Thu May  7 12:26:14 2009<br>
@@ -365,7 +365,8 @@<br>
           BuildMI(MBB, DL, II).addImm(ID);<br>
       } else {<br>
         const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);<br>
-        ID =  DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext()));<br>
+        ID =  DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext()),<br>
+                                  Subprogram);<br>
         BuildMI(MBB, DL, II).addImm(ID);<br>
       }<br>
     }<br>
@@ -391,6 +392,7 @@<br>
       // FIXME : Why DebugLoc is reset at the beginning of each block ?<br>
       if (PrevLoc.isUnknown())<br>
         return true;<br>
+<br>
       // Record the source line.<br>
       unsigned Line = Subprogram.getLineNumber();<br>
       setCurDebugLoc(DebugLoc::get(MF.getOrCreateDebugLocID(<br>
@@ -410,10 +412,10 @@<br>
       unsigned Line = Subprogram.getLineNumber();<br>
       MF.setDefaultDebugLoc(DebugLoc::get(MF.getOrCreateDebugLocID(<br>
                                               CompileUnit.getGV(), Line, 0)));<br>
-      if (DW && DW->ShouldEmitDwarfDebug()) {<br>
+<br>
+      if (DW && DW->ShouldEmitDwarfDebug())<br>
         // llvm.dbg.func_start also defines beginning of function scope.<br>
         DW->RecordRegionStart(cast<GlobalVariable>(FSI->getSubprogram()));<br>
-      }<br>
     }<br>
<br>
     return true;<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=71165&r1=71164&r2=71165&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=71165&r1=71164&r2=71165&view=diff</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Thu May  7 12:26:14 2009<br>
@@ -3944,7 +3944,8 @@<br>
       }<br>
<br>
       unsigned LabelID =<br>
-        DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()));<br>
+        DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext()),<br>
+                            Subprogram);<br>
       DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),<br>
                                getRoot(), LabelID));<br>
     }<br>
<br>
Removed: llvm/trunk/test/Transforms/InstCombine/constant-fold-ptr-casts.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/constant-fold-ptr-casts.ll?rev=71164&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/constant-fold-ptr-casts.ll?rev=71164&view=auto</a><br>

<br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/InstCombine/constant-fold-ptr-casts.ll (original)<br>
+++ llvm/trunk/test/Transforms/InstCombine/constant-fold-ptr-casts.ll (removed)<br>
@@ -1,18 +0,0 @@<br>
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i32 2143034560}<br>
-<br>
-; Instcombine should be able to completely fold this code.<br>
-<br>
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"<br>
-target triple = "i686-apple-darwin8"<br>
-<br>
-@bar = constant [3 x i64] [i64 9220983451228067448, i64 9220983451228067449, i64 9220983450959631991], align 8<br>
-<br>
-define i32 @foo() nounwind {<br>
-entry:<br>
-       %tmp87.2 = load i64* inttoptr (i32 add (i32 16, i32 ptrtoint ([3 x i64]* @bar to i32)) to i64*), align 8<br>
-       %t0 = bitcast i64 %tmp87.2 to double<br>
-       %tmp9192.2 = fptrunc double %t0 to float<br>
-       %t1 = bitcast float %tmp9192.2 to i32<br>
-       ret i32 %t1<br>
-}<br>
-<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>