From a30b342b77594b6a997bd9c0b585dc7b5f66cbcf Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 9 Feb 2015 22:13:27 +0000 Subject: [PATCH] IR: Take uint64_t in DIBuilder::createExpression() `DIExpression` deals with `uint64_t`, so it doesn't make sense that `createExpression()` is created from `int64_t`. Switch to `uint64_t` to unify them. I've temporarily left in the `int64_t` version, which forwards to the `uint64_t` version. I'll delete it once I've updated the callers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228619 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DIBuilder.h | 3 ++- lib/IR/DIBuilder.cpp | 12 +++++++++--- lib/Transforms/Utils/Local.cpp | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h index b0eec7e576b..06753e7fce5 100644 --- a/include/llvm/IR/DIBuilder.h +++ b/include/llvm/IR/DIBuilder.h @@ -514,7 +514,8 @@ 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); + DIExpression createExpression(ArrayRef Addr); /// 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 4c8dbb72514..a1af40546b7 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -947,17 +947,23 @@ DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope, return RetVar; } -DIExpression DIBuilder::createExpression(ArrayRef Addr) { +DIExpression DIBuilder::createExpression(ArrayRef Addr) { auto Header = HeaderBuilder::get(DW_TAG_expression); - for (int64_t I : Addr) + for (uint64_t I : Addr) Header.concat(I); Metadata *Elts[] = {Header.get(VMContext)}; return DIExpression(MDNode::get(VMContext, Elts)); } +DIExpression DIBuilder::createExpression(ArrayRef Signed) { + // TODO: Remove the callers of this signed version and delete. + SmallVector Addr(Signed.begin(), Signed.end()); + return createExpression(Addr); +} + DIExpression DIBuilder::createPieceExpression(unsigned OffsetInBytes, unsigned SizeInBytes) { - int64_t Addr[] = {dwarf::DW_OP_piece, OffsetInBytes, SizeInBytes}; + uint64_t Addr[] = {dwarf::DW_OP_piece, OffsetInBytes, SizeInBytes}; return createExpression(Addr); } diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index c2dfaf52746..b8c0a7e47b5 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -1123,7 +1123,7 @@ 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. - SmallVector NewDIExpr; + SmallVector NewDIExpr; NewDIExpr.push_back(dwarf::DW_OP_deref); if (DIExpr) for (unsigned i = 0, n = DIExpr.getNumElements(); i < n; ++i)