diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/SROA.cpp | 7 |
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. |

