DIBuilder: Encapsulate DIExpression's element type
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 1 Oct 2014 20:26:08 +0000 (20:26 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 1 Oct 2014 20:26:08 +0000 (20:26 +0000)
`DIExpression`'s elements are 64-bit integers that are stored as
`ConstantInt`.  The accessors already encapsulate the storage.  This
commit updates the `DIBuilder` API to also encapsulate that.

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

include/llvm/IR/DIBuilder.h
lib/IR/DIBuilder.cpp
lib/Transforms/Utils/Local.cpp

index c6e9f021a6470d6649f9bf6ca9739b07e681ece0..d12a0c609db40b64056225385a89efe9f46f7cb6 100644 (file)
@@ -503,7 +503,7 @@ namespace llvm {
     /// createExpression - Create a new descriptor for the specified
     /// variable which has a complex address expression for its address.
     /// @param Addr        An array of complex address operations.
-    DIExpression createExpression(ArrayRef<Value *> Addr = None);
+    DIExpression createExpression(ArrayRef<int64_t> Addr = None);
 
     /// createPieceExpression - Create a descriptor to describe one part
     /// of aggregate variable that is fragmented across multiple Values.
index 1ab52523d73dfca14d6330a1d3b8ad5089dd8232..f1d4a21bb73ba640bdc9583bedb4c84902960a9d 100644 (file)
@@ -1045,10 +1045,14 @@ DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
 /// createExpression - Create a new descriptor for the specified
 /// variable which has a complex address expression for its address.
 /// @param Addr        An array of complex address operations.
-DIExpression DIBuilder::createExpression(ArrayRef<Value *> Addr) {
+DIExpression DIBuilder::createExpression(ArrayRef<int64_t> Addr) {
   SmallVector<llvm::Value *, 16> Elts;
   Elts.push_back(GetTagConstant(VMContext, DW_TAG_expression));
-  Elts.insert(Elts.end(), Addr.begin(), Addr.end());
+
+  llvm::Type *Int64Ty = Type::getInt64Ty(VMContext);
+  for (int64_t I : Addr)
+    Elts.push_back(ConstantInt::get(Int64Ty, I));
+
   return DIExpression(MDNode::get(VMContext, Elts));
 }
 
index 69c9346c0277e0811c687440d014031773213e14..ecbe94a7e39a8e29177a7b6062d3b7497e4037ca 100644 (file)
@@ -1115,14 +1115,13 @@ bool llvm::replaceDbgDeclareForAlloca(AllocaInst *AI, Value *NewAllocaAddress,
   // "deref" operation to a list of address elements, as new llvm.dbg.declare
   // will take a value storing address of the memory for variable, not
   // alloca itself.
-  Type *Int64Ty = Type::getInt64Ty(AI->getContext());
-  SmallVector<Value *, 4> NewDIExpr;
+  SmallVector<int64_t, 4> NewDIExpr;
   if (DIExpr) {
     for (unsigned i = 0, n = DIExpr.getNumElements(); i < n; ++i) {
-      NewDIExpr.push_back(ConstantInt::get(Int64Ty, DIExpr.getElement(i)));
+      NewDIExpr.push_back(DIExpr.getElement(i));
     }
   }
-  NewDIExpr.push_back(ConstantInt::get(Int64Ty, dwarf::DW_OP_deref));
+  NewDIExpr.push_back(dwarf::DW_OP_deref);
 
   // Insert llvm.dbg.declare in the same basic block as the original alloca,
   // and remove old llvm.dbg.declare.