diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-02-01 00:58:04 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-02-01 00:58:04 +0000 |
commit | 152ac396db5b6c156816979b1590702088f22518 (patch) | |
tree | ca57baabb23ae9c02f5eb8d353a461534500a53a /llvm/lib/Transforms/Scalar/SROA.cpp | |
parent | 02d6f22c939cfd6e3b601f1fd14695187089e4c1 (diff) | |
download | bcm5719-llvm-152ac396db5b6c156816979b1590702088f22518.tar.gz bcm5719-llvm-152ac396db5b6c156816979b1590702088f22518.zip |
Fix PR22393. When recursively replacing an aggregate with a smaller
aggregate or scalar, the debug info needs to refer to the absolute offset
(relative to the entire variable) instead of storing the offset inside
the smaller aggregate.
llvm-svn: 227702
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SROA.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SROA.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index 8d818c673f6..6faf905f9b3 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -4174,14 +4174,23 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) { for (auto Piece : Pieces) { // Create a piece expression describing the new partition or reuse AI's // expression if there is only one partition. - if (IsSplit) - Expr = DIB.createPieceExpression(Piece.Offset, Piece.Size); + DIExpression PieceExpr = Expr; + if (IsSplit || Expr.isVariablePiece()) { + // If this alloca is already a scalar replacement of a larger aggregate, + // Piece.Offset describes the offset inside the scalar. + unsigned Offset = Expr.isVariablePiece() ? Expr.getPieceOffset() : 0; + assert((Offset == 0 || + Offset+Piece.Offset+Piece.Size <= + Expr.getPieceOffset()+Expr.getPieceSize()) && + "inner piece is not inside original alloca"); + PieceExpr = DIB.createPieceExpression(Offset+Piece.Offset, Piece.Size); + } // Remove any existing dbg.declare intrinsic describing the same alloca. if (DbgDeclareInst *OldDDI = FindAllocaDbgDeclare(Piece.Alloca)) OldDDI->eraseFromParent(); - Instruction *NewDDI = DIB.insertDeclare(Piece.Alloca, Var, Expr, &AI); + auto *NewDDI = DIB.insertDeclare(Piece.Alloca, Var, PieceExpr, &AI); NewDDI->setDebugLoc(DbgDecl->getDebugLoc()); } } |