[PATCH] D16187: [SROA] Also insert a bit piece expression if only one piece is needed
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 14 09:09:49 PST 2016
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.
Thanks. LGTM with minor comments addressed.
================
Comment at: lib/Transforms/Scalar/SROA.cpp:4032
@@ -4031,3 +4031,3 @@
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,
----------------
Should we add an
} else assert(Pieces.size() == 1&& "partition is as large as original alloca")
?
================
Comment at: test/Transforms/SROA/dbg-single-piece.ll:12
@@ +11,3 @@
+ %retval = alloca %foo, align 8
+ call void @llvm.dbg.declare(metadata %foo* %retval, metadata !1, metadata !7), !dbg !8
+; CHECK: call void @llvm.dbg.value(metadata %foo* undef, i64 0, metadata !1, metadata ![[BIT_PIECE:[0-9]+]]), !dbg !8
----------------
I think we should also check for the sroa'd alloca and verify that its size matches the size of the OP_bit_piece.
================
Comment at: test/Transforms/SROA/dbg-single-piece.ll:13
@@ +12,3 @@
+ call void @llvm.dbg.declare(metadata %foo* %retval, metadata !1, metadata !7), !dbg !8
+; CHECK: call void @llvm.dbg.value(metadata %foo* undef, i64 0, metadata !1, metadata ![[BIT_PIECE:[0-9]+]]), !dbg !8
+; CHECK: ![[BIT_PIECE]] = !DIExpression(DW_OP_bit_piece, 64, 64)
----------------
checking for the hardcoded !dbg !8 is just asking for trouble :-)
================
Comment at: test/Transforms/SROA/dbg-single-piece.ll:14
@@ +13,3 @@
+; CHECK: call void @llvm.dbg.value(metadata %foo* undef, i64 0, metadata !1, metadata ![[BIT_PIECE:[0-9]+]]), !dbg !8
+; CHECK: ![[BIT_PIECE]] = !DIExpression(DW_OP_bit_piece, 64, 64)
+ %0 = bitcast %foo* %retval to i8*
----------------
Comment?
; 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.
Repository:
rL LLVM
http://reviews.llvm.org/D16187
More information about the llvm-commits
mailing list