[llvm-branch-commits] [llvm-branch] r90811 - in /llvm/branches/Apple/Zoidberg: include/llvm/Analysis/DebugInfo.h include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/Analysis/DebugInfo.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLParser.h lib/VMCore/AsmWriter.cpp

Victor Hernandez vhernandez at apple.com
Mon Dec 7 14:24:23 PST 2009


Author: hernande
Date: Mon Dec  7 16:24:23 2009
New Revision: 90811

URL: http://llvm.org/viewvc/llvm-project?rev=90811&view=rev
Log:
$ svn merge -c 90497 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r90497 into '.':
U    lib/AsmParser/LLParser.cpp
U    lib/AsmParser/LLParser.h
$ svn merge -c 90512 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r90512 into '.':
U    lib/VMCore/AsmWriter.cpp
$ svn merge -c 90572 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r90572 into '.':
G    lib/VMCore/AsmWriter.cpp
$ svn merge -c 90581 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r90581 into '.':
G    lib/VMCore/AsmWriter.cpp
$ svn merge -c 90788 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r90788 into '.':
U    include/llvm/Analysis/DebugInfo.h
U    include/llvm/IntrinsicInst.h
U    include/llvm/Intrinsics.td
U    lib/Analysis/DebugInfo.cpp
$ svn merge -c 90807 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r90807 into '.':
G    include/llvm/Analysis/DebugInfo.h
G    lib/Analysis/DebugInfo.cpp


Modified:
    llvm/branches/Apple/Zoidberg/include/llvm/Analysis/DebugInfo.h
    llvm/branches/Apple/Zoidberg/include/llvm/IntrinsicInst.h
    llvm/branches/Apple/Zoidberg/include/llvm/Intrinsics.td
    llvm/branches/Apple/Zoidberg/lib/Analysis/DebugInfo.cpp
    llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.cpp
    llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.h
    llvm/branches/Apple/Zoidberg/lib/VMCore/AsmWriter.cpp

Modified: llvm/branches/Apple/Zoidberg/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/Analysis/DebugInfo.h?rev=90811&r1=90810&r2=90811&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/Analysis/DebugInfo.h Mon Dec  7 16:24:23 2009
@@ -492,6 +492,7 @@
 
     const Type *EmptyStructPtr; // "{}*".
     Function *DeclareFn;     // llvm.dbg.declare
+    Function *ValueFn;       // llvm.dbg.value
 
     DIFactory(const DIFactory &);     // DO NOT IMPLEMENT
     void operator=(const DIFactory&); // DO NOT IMPLEMENT
@@ -639,6 +640,13 @@
     Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
                                Instruction *InsertBefore);
 
+    /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
+    Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
+                                         DIVariable D, BasicBlock *InsertAtEnd);
+
+    /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
+    Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
+                                       DIVariable D, Instruction *InsertBefore);
   private:
     Constant *GetTagConstant(unsigned TAG);
   };

Modified: llvm/branches/Apple/Zoidberg/include/llvm/IntrinsicInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/IntrinsicInst.h?rev=90811&r1=90810&r2=90811&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/IntrinsicInst.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/IntrinsicInst.h Mon Dec  7 16:24:23 2009
@@ -70,6 +70,7 @@
       case Intrinsic::dbg_region_start:
       case Intrinsic::dbg_region_end:
       case Intrinsic::dbg_declare:
+      case Intrinsic::dbg_value:
         return true;
       default: return false;
       }
@@ -171,6 +172,25 @@
     }
   };
 
+  /// DbgValueInst - This represents the llvm.dbg.value instruction.
+  ///
+  struct DbgValueInst : public DbgInfoIntrinsic {
+    Value *getValue()  const {
+      return cast<MDNode>(getOperand(1))->getElement(0);
+    }
+    Value *getOffset() const { return getOperand(2); }
+    MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); }
+
+    // Methods for support type inquiry through isa, cast, and dyn_cast:
+    static inline bool classof(const DbgValueInst *) { return true; }
+    static inline bool classof(const IntrinsicInst *I) {
+      return I->getIntrinsicID() == Intrinsic::dbg_value;
+    }
+    static inline bool classof(const Value *V) {
+      return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
+    }
+  };
+
   /// MemIntrinsic - This is the common base class for memset/memcpy/memmove.
   ///
   struct MemIntrinsic : public IntrinsicInst {

Modified: llvm/branches/Apple/Zoidberg/include/llvm/Intrinsics.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/Intrinsics.td?rev=90811&r1=90810&r2=90811&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/Intrinsics.td (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/Intrinsics.td Mon Dec  7 16:24:23 2009
@@ -290,6 +290,9 @@
   def int_dbg_func_start   : Intrinsic<[llvm_void_ty], [llvm_metadata_ty]>;
   def int_dbg_declare      : Intrinsic<[llvm_void_ty],
                                        [llvm_descriptor_ty, llvm_metadata_ty]>;
+  def int_dbg_value  	   : Intrinsic<[llvm_void_ty],
+                                       [llvm_metadata_ty, llvm_i64_ty,
+                                        llvm_metadata_ty]>;
 }
 
 //===------------------ Exception Handling Intrinsics----------------------===//

Modified: llvm/branches/Apple/Zoidberg/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Analysis/DebugInfo.cpp?rev=90811&r1=90810&r2=90811&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Analysis/DebugInfo.cpp Mon Dec  7 16:24:23 2009
@@ -1050,6 +1050,37 @@
   return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);
 }
 
+/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
+Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, Value *Offset,
+                                                DIVariable D,
+                                                Instruction *InsertBefore) {
+  assert(V && "no value passed to dbg.value");
+  assert(Offset->getType() == Type::getInt64Ty(V->getContext()) &&
+         "offset must be i64");
+  if (!ValueFn)
+    ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
+
+  Value *Elts[] = { V };
+  Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), Offset,
+                    D.getNode() };
+  return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
+}
+
+/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
+Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, Value *Offset,
+                                                DIVariable D,
+                                                BasicBlock *InsertAtEnd) {
+  assert(V && "no value passed to dbg.value");
+  assert(Offset->getType() == Type::getInt64Ty(V->getContext()) &&
+         "offset must be i64");
+  if (!ValueFn)
+    ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
+
+  Value *Elts[] = { V };
+  Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), Offset,
+                    D.getNode() };
+  return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
+}
 
 //===----------------------------------------------------------------------===//
 // DebugInfoFinder implementations.

Modified: llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.cpp?rev=90811&r1=90810&r2=90811&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.cpp Mon Dec  7 16:24:23 2009
@@ -581,6 +581,37 @@
   return false;
 }
 
+/// ParseInlineMetadata:
+///   !{type %instr}
+///   !{...} MDNode
+///   !"foo" MDString
+bool LLParser::ParseInlineMetadata(Value *&V, PerFunctionState &PFS) {
+  assert(Lex.getKind() == lltok::Metadata && "Only for Metadata");
+  V = 0;
+
+  Lex.Lex();
+  if (Lex.getKind() == lltok::lbrace) {
+    Lex.Lex();
+    if (ParseTypeAndValue(V, PFS) ||
+        ParseToken(lltok::rbrace, "expected end of metadata node"))
+      return true;
+
+    Value *Vals[] = { V };
+    V = MDNode::get(Context, Vals, 1);
+    return false;
+  }
+
+  // Standalone metadata reference
+  // !{ ..., !42, ... }
+  if (!ParseMDNode((MetadataBase *&)V))
+    return false;
+
+  // MDString:
+  // '!' STRINGCONSTANT
+  if (ParseMDString((MetadataBase *&)V)) return true;
+  return false;
+}
+
 /// ParseAlias:
 ///   ::= GlobalVar '=' OptionalVisibility 'alias' OptionalLinkage Aliasee
 /// Aliasee
@@ -1377,15 +1408,23 @@
     // Parse the argument.
     LocTy ArgLoc;
     PATypeHolder ArgTy(Type::getVoidTy(Context));
-    unsigned ArgAttrs1, ArgAttrs2;
+    unsigned ArgAttrs1 = Attribute::None;
+    unsigned ArgAttrs2 = Attribute::None;
     Value *V;
-    if (ParseType(ArgTy, ArgLoc) ||
-        ParseOptionalAttrs(ArgAttrs1, 0) ||
-        ParseValue(ArgTy, V, PFS) ||
-        // FIXME: Should not allow attributes after the argument, remove this in
-        // LLVM 3.0.
-        ParseOptionalAttrs(ArgAttrs2, 3))
+    if (ParseType(ArgTy, ArgLoc))
       return true;
+
+    if (Lex.getKind() == lltok::Metadata) {
+      if (ParseInlineMetadata(V, PFS))
+        return true;
+    } else {
+      if (ParseOptionalAttrs(ArgAttrs1, 0) ||
+          ParseValue(ArgTy, V, PFS) ||
+          // FIXME: Should not allow attributes after the argument, remove this
+          // in LLVM 3.0.
+          ParseOptionalAttrs(ArgAttrs2, 3))
+        return true;
+    }
     ArgList.push_back(ParamInfo(ArgLoc, V, ArgAttrs1|ArgAttrs2));
   }
 

Modified: llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.h?rev=90811&r1=90810&r2=90811&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.h (original)
+++ llvm/branches/Apple/Zoidberg/lib/AsmParser/LLParser.h Mon Dec  7 16:24:23 2009
@@ -279,7 +279,9 @@
       LocTy Loc;
       return ParseTypeAndBasicBlock(BB, Loc, PFS);
     }
-  
+
+    bool ParseInlineMetadata(Value *&V, PerFunctionState &PFS);
+
     struct ParamInfo {
       LocTy Loc;
       Value *V;

Modified: llvm/branches/Apple/Zoidberg/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/VMCore/AsmWriter.cpp?rev=90811&r1=90810&r2=90811&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/VMCore/AsmWriter.cpp Mon Dec  7 16:24:23 2009
@@ -813,6 +813,11 @@
 void SlotTracker::CreateMetadataSlot(const MDNode *N) {
   assert(N && "Can't insert a null Value into SlotTracker!");
 
+  // Don't insert if N contains an instruction.
+  for (unsigned i = 0, e = N->getNumElements(); i != e; ++i)
+    if (N->getElement(i) && isa<Instruction>(N->getElement(i)))
+      return;
+
   ValueMap::iterator I = mdnMap.find(N);
   if (I != mdnMap.end())
     return;
@@ -1227,6 +1232,25 @@
   }
 
   if (const MDNode *N = dyn_cast<MDNode>(V)) {
+    if (Machine->getMetadataSlot(N) == -1) {
+      // Print metadata inline, not via slot reference number.
+      Out << "!{";
+      for (unsigned mi = 0, me = N->getNumElements(); mi != me; ++mi) {
+        const Value *Val = N->getElement(mi);
+        if (!Val)
+          Out << "null";
+        else {
+          TypePrinter->print(N->getElement(0)->getType(), Out);
+          Out << ' ';
+          WriteAsOperandInternal(Out, N->getElement(0), TypePrinter, Machine);
+        }
+        if (mi + 1 != me)
+          Out << ", ";
+      }
+      Out << '}';
+      return;
+    }
+  
     Out << '!' << Machine->getMetadataSlot(N);
     return;
   }





More information about the llvm-branch-commits mailing list