Respond to Chris' review:
authorVictor Hernandez <vhernandez@apple.com>
Mon, 11 Jan 2010 07:45:19 +0000 (07:45 +0000)
committerVictor Hernandez <vhernandez@apple.com>
Mon, 11 Jan 2010 07:45:19 +0000 (07:45 +0000)
Make InsertDbgValueIntrinsic() and get Offset take and recieve a uint64_t.
Get constness correct for getVariable() and getValue().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93149 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DebugInfo.h
include/llvm/IntrinsicInst.h
lib/Analysis/DebugInfo.cpp
lib/VMCore/IntrinsicInst.cpp

index 1e41c5966016472e8d03bc5d395e8c6089129510..c626b126b74f8416674f89cf302f585276c1a124 100644 (file)
@@ -647,11 +647,11 @@ namespace llvm {
                                Instruction *InsertBefore);
 
     /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
-    Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
+    Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
                                          DIVariable D, BasicBlock *InsertAtEnd);
 
     /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
-    Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
+    Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
                                        DIVariable D, Instruction *InsertBefore);
   private:
     Constant *GetTagConstant(unsigned TAG);
index 5808938400c22244ef6c496c27dcefc7b44cf477..151e4344f3b8319cf8e93e70705bb239d6117459 100644 (file)
@@ -99,9 +99,14 @@ namespace llvm {
   ///
   class DbgValueInst : public DbgInfoIntrinsic {
   public:
-    Value *getValue() const;
-    Value *getOffset() const { return getOperand(2); }
-    MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); }
+    const Value *getValue() const;
+    Value *getValue();
+    uint64_t getOffset() const {
+      return cast<ConstantInt>(
+                             const_cast<Value*>(getOperand(2)))->getZExtValue();
+    }
+    const MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); }
+    MDNode *getVariable() { return cast<MDNode>(getOperand(3)); }
 
     // Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const DbgValueInst *) { return true; }
index 731b57ac17aa9efb217521ae73d7e77afa72f6ba..15ca1fae085bc333da4d02dca70785afa2cca6d5 100644 (file)
@@ -1033,7 +1033,7 @@ DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo,
 
 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
 Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
-                              Instruction *InsertBefore) {
+                                      Instruction *InsertBefore) {
   // Cast the storage to a {}* for the call to llvm.dbg.declare.
   Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore);
 
@@ -1046,7 +1046,7 @@ Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
 
 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
 Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
-                              BasicBlock *InsertAtEnd) {
+                                      BasicBlock *InsertAtEnd) {
   // Cast the storage to a {}* for the call to llvm.dbg.declare.
   Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd);
 
@@ -1058,31 +1058,31 @@ Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
 }
 
 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
-Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, Value *Offset,
+Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
                                                 DIVariable D,
                                                 Instruction *InsertBefore) {
   assert(V && "no value passed to dbg.value");
-  assert(Offset->getType()->isInteger(64) && "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,
+  Value *Args[] = { MDNode::get(V->getContext(), Elts, 1),
+                    ConstantInt::get(Type::getInt64Ty(V->getContext()), 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,
+Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
                                                 DIVariable D,
                                                 BasicBlock *InsertAtEnd) {
   assert(V && "no value passed to dbg.value");
-  assert(Offset->getType()->isInteger(64) && "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,
+  Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), 
+                    ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
                     D.getNode() };
   return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
 }
index daa768c0cfe598b9e55bb44d6235171b0c2a12ea..cb9252efdf5881bab570f120c1f9573ca849d159 100644 (file)
@@ -54,6 +54,10 @@ Value *DbgInfoIntrinsic::StripCast(Value *C) {
 /// DbgValueInst - This represents the llvm.dbg.value instruction.
 ///
 
-Value *DbgValueInst::getValue() const {
+const Value *DbgValueInst::getValue() const {
+  return cast<MDNode>(getOperand(1))->getOperand(0);
+}
+
+Value *DbgValueInst::getValue() {
   return cast<MDNode>(getOperand(1))->getOperand(0);
 }