summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-02-09 23:57:22 +0000
committerAdrian Prantl <aprantl@apple.com>2015-02-09 23:57:22 +0000
commit34e7590e0da85f7f0c570f9d94f8a6431b2f7ebe (patch)
tree6bcf3979ccc18f4c820b15d7a377ef2dea58bd4c /llvm/lib/Transforms
parent27bd01f71cbc9ef5c489e27980b21087232b229c (diff)
downloadbcm5719-llvm-34e7590e0da85f7f0c570f9d94f8a6431b2f7ebe.tar.gz
bcm5719-llvm-34e7590e0da85f7f0c570f9d94f8a6431b2f7ebe.zip
Debug info: When updating debug info during SROA, do not emit debug info
for any padding introduced by SROA. In particular, do not emit debug info for an alloca that represents only the padding introduced by a previous iteration. Fixes PR22495. llvm-svn: 228632
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index eaf73ee5e68..f69c750f3f9 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -4153,8 +4153,13 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
for (auto &P : AS.partitions()) {
if (AllocaInst *NewAI = rewritePartition(AI, AS, P)) {
Changed = true;
- if (NewAI != &AI)
- Pieces.push_back(Piece(NewAI, P.beginOffset(), P.size()));
+ if (NewAI != &AI) {
+ uint64_t SizeOfByte = 8;
+ uint64_t AllocaSize = DL->getTypeSizeInBits(NewAI->getAllocatedType());
+ // Don't include any padding.
+ uint64_t Size = std::min(AllocaSize, P.size() * SizeOfByte);
+ Pieces.push_back(Piece(NewAI, P.beginOffset() * SizeOfByte, Size));
+ }
}
++NumPartitions;
}
@@ -4178,12 +4183,17 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) {
if (IsSplit || Expr.isBitPiece()) {
// If this alloca is already a scalar replacement of a larger aggregate,
// Piece.Offset describes the offset inside the scalar.
- unsigned Offset = Expr.isBitPiece() ? Expr.getBitPieceOffset() : 0;
- assert((Offset == 0 ||
- Offset+Piece.Offset+Piece.Size*8 <=
- Expr.getBitPieceOffset()+Expr.getBitPieceSize()) &&
- "inner piece is not inside original alloca");
- PieceExpr = DIB.createBitPieceExpression(Offset+Piece.Offset*8, Piece.Size*8);
+ uint64_t Offset = Expr.isBitPiece() ? Expr.getBitPieceOffset() : 0;
+ uint64_t Start = Offset + Piece.Offset;
+ uint64_t Size = Piece.Size;
+ if (Expr.isBitPiece()) {
+ uint64_t AbsEnd = Expr.getBitPieceOffset() + Expr.getBitPieceSize();
+ if (Start >= AbsEnd)
+ // No need to describe a SROAed padding.
+ continue;
+ Size = std::min(Size, AbsEnd - Start);
+ }
+ PieceExpr = DIB.createBitPieceExpression(Start, Size);
}
// Remove any existing dbg.declare intrinsic describing the same alloca.
OpenPOWER on IntegriCloud