[llvm] r218797 - DIBuilder: Encapsulate DIExpression's element type
Duncan P. N. Exon Smith
dexonsmith at apple.com
Wed Oct 1 13:26:08 PDT 2014
Author: dexonsmith
Date: Wed Oct 1 15:26:08 2014
New Revision: 218797
URL: http://llvm.org/viewvc/llvm-project?rev=218797&view=rev
Log:
DIBuilder: Encapsulate DIExpression's element type
`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.
Modified:
llvm/trunk/include/llvm/IR/DIBuilder.h
llvm/trunk/lib/IR/DIBuilder.cpp
llvm/trunk/lib/Transforms/Utils/Local.cpp
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=218797&r1=218796&r2=218797&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Wed Oct 1 15:26:08 2014
@@ -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.
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=218797&r1=218796&r2=218797&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Wed Oct 1 15:26:08 2014
@@ -1045,10 +1045,14 @@ DIVariable DIBuilder::createLocalVariabl
/// 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));
}
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=218797&r1=218796&r2=218797&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Oct 1 15:26:08 2014
@@ -1115,14 +1115,13 @@ bool llvm::replaceDbgDeclareForAlloca(Al
// "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.
More information about the llvm-commits
mailing list