[llvm-branch-commits] [llvm-branch] r84680 - in /llvm/branches/Apple/Leela: include/llvm/Metadata.h include/llvm/Support/DebugLoc.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/CodeGen/MachineInstr.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/ExecutionEngine/JIT/JITEmitter.cpp lib/Target/PIC16/PIC16DebugInfo.cpp lib/VMCore/Metadata.cpp test/DebugInfo/2009-11-16-Phi.ll

Bill Wendling isanbard at gmail.com
Tue Oct 20 14:16:06 PDT 2009


Author: void
Date: Tue Oct 20 16:16:05 2009
New Revision: 84680

URL: http://llvm.org/viewvc/llvm-project?rev=84680&view=rev
Log:
$ svn merge -c 84054 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84054 into '.':
U    include/llvm/Support/DebugLoc.h
U    lib/CodeGen/AsmPrinter/AsmPrinter.cpp
U    lib/CodeGen/AsmPrinter/DwarfDebug.cpp
U    lib/CodeGen/MachineInstr.cpp
U    lib/CodeGen/SelectionDAG/FastISel.cpp
U    lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
U    lib/Target/PIC16/PIC16DebugInfo.cpp
U    lib/ExecutionEngine/JIT/JITEmitter.cpp
$ svn merge -c 84113 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84113 into '.':
U    include/llvm/Metadata.h
U    lib/VMCore/Metadata.cpp
$ svn merge -c 84134 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84134 into '.':
U    lib/CodeGen/AsmPrinter/DwarfDebug.h
G    lib/CodeGen/AsmPrinter/DwarfDebug.cpp
$ svn merge -c 84262 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84262 into '.':
G    lib/CodeGen/AsmPrinter/DwarfDebug.cpp
$ svn merge -c 84264 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84264 into '.':
U    test/DebugInfo/2009-11-16-Phi.ll


Modified:
    llvm/branches/Apple/Leela/include/llvm/Metadata.h
    llvm/branches/Apple/Leela/include/llvm/Support/DebugLoc.h
    llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/branches/Apple/Leela/lib/CodeGen/MachineInstr.cpp
    llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
    llvm/branches/Apple/Leela/lib/ExecutionEngine/JIT/JITEmitter.cpp
    llvm/branches/Apple/Leela/lib/Target/PIC16/PIC16DebugInfo.cpp
    llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp
    llvm/branches/Apple/Leela/test/DebugInfo/2009-11-16-Phi.ll

Modified: llvm/branches/Apple/Leela/include/llvm/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/include/llvm/Metadata.h?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/include/llvm/Metadata.h (original)
+++ llvm/branches/Apple/Leela/include/llvm/Metadata.h Tue Oct 20 16:16:05 2009
@@ -351,6 +351,10 @@
   /// removeMDs - Remove all metadata attached with an instruction.
   void removeMDs(const Instruction *Inst);
 
+  /// copyMD - If metadata is attached with Instruction In1 then attach
+  /// the same metadata to In2.
+  void copyMD(Instruction *In1, Instruction *In2);
+
   /// getHandlerNames - Get handler names. This is used by bitcode
   /// writer.
   const StringMap<unsigned> *getHandlerNames();

Modified: llvm/branches/Apple/Leela/include/llvm/Support/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/include/llvm/Support/DebugLoc.h?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/include/llvm/Support/DebugLoc.h (original)
+++ llvm/branches/Apple/Leela/include/llvm/Support/DebugLoc.h Tue Oct 20 16:16:05 2009
@@ -24,19 +24,19 @@
   /// DebugLocTuple - Debug location tuple of filename id, line and column.
   ///
   struct DebugLocTuple {
-    MDNode *CompileUnit;
-    MDNode *InlinedLoc;
+    MDNode *Scope;
+    MDNode *InlinedAtLoc;
     unsigned Line, Col;
 
     DebugLocTuple()
-      : CompileUnit(0), InlinedLoc(0), Line(~0U), Col(~0U) {};
+      : Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {};
 
     DebugLocTuple(MDNode *n, MDNode *i, unsigned l, unsigned c)
-      : CompileUnit(n), InlinedLoc(i), Line(l), Col(c) {};
+      : Scope(n), InlinedAtLoc(i), Line(l), Col(c) {};
 
     bool operator==(const DebugLocTuple &DLT) const {
-      return CompileUnit == DLT.CompileUnit &&
-        InlinedLoc == DLT.InlinedLoc &&
+      return Scope == DLT.Scope &&
+        InlinedAtLoc == DLT.InlinedAtLoc &&
         Line == DLT.Line && Col == DLT.Col;
     }
     bool operator!=(const DebugLocTuple &DLT) const {
@@ -74,16 +74,16 @@
       return DebugLocTuple((MDNode*)~1U, (MDNode*)~1U, ~1U, ~1U);
     }
     static unsigned getHashValue(const DebugLocTuple &Val) {
-      return DenseMapInfo<MDNode*>::getHashValue(Val.CompileUnit) ^
-             DenseMapInfo<MDNode*>::getHashValue(Val.InlinedLoc) ^
+      return DenseMapInfo<MDNode*>::getHashValue(Val.Scope) ^
+             DenseMapInfo<MDNode*>::getHashValue(Val.InlinedAtLoc) ^
              DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
              DenseMapInfo<unsigned>::getHashValue(Val.Col);
     }
     static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
-      return LHS.CompileUnit == RHS.CompileUnit &&
-             LHS.InlinedLoc  == RHS.InlinedLoc &&
-             LHS.Line        == RHS.Line &&
-             LHS.Col         == RHS.Col;
+      return LHS.Scope        == RHS.Scope &&
+             LHS.InlinedAtLoc == RHS.InlinedAtLoc &&
+             LHS.Line         == RHS.Line &&
+             LHS.Col          == RHS.Col;
     }
 
     static bool isPod() { return true; }

Modified: llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Oct 20 16:16:05 2009
@@ -1362,9 +1362,9 @@
     if (!DL.isUnknown()) {
       DebugLocTuple CurDLT = MF->getDebugLocTuple(DL);
       if (BeforePrintingInsn) {
-        if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) {
+        if (CurDLT.Scope != 0 && PrevDLT != CurDLT) {
 	  unsigned L = DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,
-	  				    CurDLT.CompileUnit);
+	  				    CurDLT.Scope);
           printLabel(L);
 #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
           DW->SetDbgScopeBeginLabels(MI, L);
@@ -1773,9 +1773,10 @@
   // Print source line info.
   O.PadToColumn(MAI->getCommentColumn());
   O << MAI->getCommentString() << " SrcLine ";
-  if (DLT.CompileUnit) {
-    DICompileUnit CU(DLT.CompileUnit);
-    O << CU.getFilename() << " ";
+  if (DLT.Scope) {
+    DICompileUnit CU(DLT.Scope);
+    if (!CU.isNull())
+      O << CU.getFilename() << " ";
   }
   O << DLT.Line;
   if (DLT.Col != 0) 

Modified: llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Oct 20 16:16:05 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,18 @@
     DIVariable DV (Var);
     if (DV.isNull()) continue;
     unsigned VSlot = VI->second;
-    DbgScope *Scope = getDbgScope(DV.getContext().getNode(),  NULL);
+    DbgScope *Scope = NULL;
+    DenseMap<MDNode *, DbgScope *>::iterator DSI = 
+      DbgScopeMap.find(DV.getContext().getNode());
+    if (DSI != DbgScopeMap.end()) 
+      Scope = DSI->second;
+    else 
+      // There is not any instruction assocated with this scope, so get
+      // a new scope.
+      Scope = getDbgScope(DV.getContext().getNode(), 
+                          NULL /* Not an instruction */,
+                          NULL /* Not inlined */);
+    assert (Scope && "Unable to find variable scope!");
     Scope->AddVariable(new DbgVariable(DV, VSlot, false));
   }
 }
@@ -1842,14 +1869,14 @@
       if (DL.isUnknown())
         continue;
       DebugLocTuple DLT = MF->getDebugLocTuple(DL);
-      if (!DLT.CompileUnit)
+      if (!DLT.Scope)
         continue;
       // There is no need to create another DIE for compile unit. For all
       // other scopes, create one DbgScope now. This will be translated 
       // into a scope DIE at the end.
-      DIDescriptor D(DLT.CompileUnit);
+      DIDescriptor D(DLT.Scope);
       if (!D.isCompileUnit()) {
-        DbgScope *Scope = getDbgScope(DLT.CompileUnit, MInsn);
+        DbgScope *Scope = getDbgScope(DLT.Scope, MInsn, DLT.InlinedAtLoc);
         Scope->setLastInsn(MInsn);
       }
     }
@@ -1942,11 +1969,11 @@
   if (!FDL.isUnknown()) {
     DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
     unsigned LabelID = 0;
-    DISubprogram SP = getDISubprogram(DLT.CompileUnit);
+    DISubprogram SP = getDISubprogram(DLT.Scope);
     if (!SP.isNull())
-      LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.CompileUnit);
+      LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.Scope);
     else
-      LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.CompileUnit);
+      LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.Scope);
     Asm->printLabel(LabelID);
     O << '\n';
   }
@@ -1954,7 +1981,7 @@
   DebugLoc FDL = MF->getDefaultDebugLoc();
   if (!FDL.isUnknown()) {
     DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
-    unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.CompileUnit);
+    unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.Scope);
     Asm->printLabel(LabelID);
     O << '\n';
   }

Modified: llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Oct 20 16:16:05 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.
   ///

Modified: llvm/branches/Apple/Leela/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/MachineInstr.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/MachineInstr.cpp Tue Oct 20 16:16:05 2009
@@ -1082,11 +1082,12 @@
   if (!debugLoc.isUnknown()) {
     const MachineFunction *MF = getParent()->getParent();
     DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc);
-    DICompileUnit CU(DLT.CompileUnit);
-    OS << " [dbg: "
-       << CU.getDirectory() << '/' << CU.getFilename() << ","
-       << DLT.Line << ","
-       << DLT.Col  << "]";
+    DICompileUnit CU(DLT.Scope);
+    if (!CU.isNull())
+      OS << " [dbg: "
+         << CU.getDirectory() << '/' << CU.getFilename() << ","
+         << DLT.Line << ","
+         << DLT.Col  << "]";
   }
 
   OS << "\n";

Modified: llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Oct 20 16:16:05 2009
@@ -385,10 +385,9 @@
       
       DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc);
       DISubprogram SP(FSI->getSubprogram());
-      unsigned LabelID = DW->RecordInlinedFnStart(SP,
-                                                  DICompileUnit(PrevLocTpl.CompileUnit),
-                                                  PrevLocTpl.Line,
-                                                  PrevLocTpl.Col);
+      unsigned LabelID = 
+        DW->RecordInlinedFnStart(SP,DICompileUnit(PrevLocTpl.Scope),
+                                 PrevLocTpl.Line, PrevLocTpl.Col);
       const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
       BuildMI(MBB, DL, II).addImm(LabelID);
       return true;

Modified: llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Oct 20 16:16:05 2009
@@ -3941,7 +3941,7 @@
         return 0;
       DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc);
       DISubprogram SP(FSI.getSubprogram());
-      DICompileUnit CU(PrevLocTpl.CompileUnit);
+      DICompileUnit CU(PrevLocTpl.Scope);
       unsigned LabelID = DW->RecordInlinedFnStart(SP, CU,
                                                   PrevLocTpl.Line,
                                                   PrevLocTpl.Col);

Modified: llvm/branches/Apple/Leela/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/branches/Apple/Leela/lib/ExecutionEngine/JIT/JITEmitter.cpp Tue Oct 20 16:16:05 2009
@@ -713,7 +713,7 @@
     DebugLocTuple CurDLT = EmissionDetails.MF->getDebugLocTuple(DL);
 
     if (BeforePrintingInsn) {
-      if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) {
+      if (CurDLT.Scope != 0 && PrevDLT != CurDLT) {
         JITEvent_EmittedFunctionDetails::LineStart NextLine;
         NextLine.Address = getCurrentPCValue();
         NextLine.Loc = DL;

Modified: llvm/branches/Apple/Leela/lib/Target/PIC16/PIC16DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Target/PIC16/PIC16DebugInfo.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Target/PIC16/PIC16DebugInfo.cpp Tue Oct 20 16:16:05 2009
@@ -258,7 +258,7 @@
   if (! EmitDebugDirectives) return;
   assert (! DL.isUnknown()  && "can't change to invalid debug loc");
 
-  MDNode *CU = MF.getDebugLocTuple(DL).CompileUnit;
+  MDNode *CU = MF.getDebugLocTuple(DL).Scope;
   unsigned line = MF.getDebugLocTuple(DL).Line;
 
   SwitchToCU(CU);

Modified: llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp (original)
+++ llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp Tue Oct 20 16:16:05 2009
@@ -359,6 +359,20 @@
   MetadataStore.erase(I);
 }
 
+/// copyMD - If metadata is attached with Instruction In1 then attach
+/// the same metadata to In2.
+void MetadataContext::copyMD(Instruction *In1, Instruction *In2) {
+  assert (In1 && In2 && "Invalid instruction!");
+   MDStoreTy::iterator I = MetadataStore.find(In1);
+  if (I == MetadataStore.end())
+    return;
+
+  MDMapTy &In1Info = I->second;
+  MDMapTy In2Info;
+  for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end(); I != E; ++I)
+    if (MDNode *MD = dyn_cast_or_null<MDNode>(I->second))
+      addMD(I->first, MD, In2);
+}
 
 /// getMD - Get the metadata of given kind attached with an Instruction.
 /// If the metadata is not found then return 0.
@@ -416,3 +430,4 @@
   // FIXME : Give custom handlers a chance to override this.
   ValueIsCloned(I1, I2);
 }
+

Modified: llvm/branches/Apple/Leela/test/DebugInfo/2009-11-16-Phi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/test/DebugInfo/2009-11-16-Phi.ll?rev=84680&r1=84679&r2=84680&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/test/DebugInfo/2009-11-16-Phi.ll (original)
+++ llvm/branches/Apple/Leela/test/DebugInfo/2009-11-16-Phi.ll Tue Oct 20 16:16:05 2009
@@ -10,4 +10,4 @@
    ret i32 %0
 }
 
-!0 = metadata !{i32 42}
\ No newline at end of file
+!0 = metadata !{i32 42}





More information about the llvm-branch-commits mailing list