diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h index c6e9f021a64..d12a0c609db 100644 --- a/include/llvm/IR/DIBuilder.h +++ b/include/llvm/IR/DIBuilder.h @@ -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 Addr = None); + DIExpression createExpression(ArrayRef Addr = None); /// createPieceExpression - Create a descriptor to describe one part /// of aggregate variable that is fragmented across multiple Values. diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 1ab52523d73..f1d4a21bb73 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -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 Addr) { +DIExpression DIBuilder::createExpression(ArrayRef Addr) { SmallVector 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)); } diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 69c9346c027..ecbe94a7e39 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -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 NewDIExpr; + SmallVector 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.