summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorKeno Fischer <kfischer@college.harvard.edu>2016-01-14 20:06:34 +0000
committerKeno Fischer <kfischer@college.harvard.edu>2016-01-14 20:06:34 +0000
commitd5354fdddb3f02beb33ea3d3b06dbe50687bc81c (patch)
tree8d3604f1ce4e5ae868e022229216946b2031b414 /llvm/lib
parent60b201b662789fb96f63170afe0131d7d0bd08dd (diff)
downloadbcm5719-llvm-d5354fdddb3f02beb33ea3d3b06dbe50687bc81c.tar.gz
bcm5719-llvm-d5354fdddb3f02beb33ea3d3b06dbe50687bc81c.zip
[SROA] Also insert a bit piece expression if only one piece is needed
Summary: If SROA creates only one piece (e.g. because the other is not needed), it still needs to create a bit_piece expression if that bit piece is smaller than the original size of the alloca. Reviewers: aprantl Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16187 llvm-svn: 257795
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index a7361b5fe08..4fa7a9fcfba 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -4024,12 +4024,12 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
auto *Var = DbgDecl->getVariable();
auto *Expr = DbgDecl->getExpression();
DIBuilder DIB(*AI.getModule(), /*AllowUnresolved*/ false);
- bool IsSplit = Pieces.size() > 1;
+ uint64_t AllocaSize = DL.getTypeSizeInBits(AI.getAllocatedType());
for (auto Piece : Pieces) {
// Create a piece expression describing the new partition or reuse AI's
// expression if there is only one partition.
auto *PieceExpr = Expr;
- if (IsSplit || Expr->isBitPiece()) {
+ if (Piece.Size < AllocaSize || Expr->isBitPiece()) {
// If this alloca is already a scalar replacement of a larger aggregate,
// Piece.Offset describes the offset inside the scalar.
uint64_t Offset = Expr->isBitPiece() ? Expr->getBitPieceOffset() : 0;
@@ -4043,6 +4043,9 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
Size = std::min(Size, AbsEnd - Start);
}
PieceExpr = DIB.createBitPieceExpression(Start, Size);
+ } else {
+ assert(Pieces.size() == 1 &&
+ "partition is as large as original alloca");
}
// Remove any existing dbg.declare intrinsic describing the same alloca.
OpenPOWER on IntegriCloud