<div dir="ltr">I can look into this. The confusion of representing <span style="font-size:12.8px">x86_fp80 in the debug info is an issue which I have have brought up separately on the mailing list. I'm confused about this particular case though. What is happening? Is it splitting an array of </span><span style="font-size:12.8px">x86_fp80 and getting confused about the size? I think the proper fix is probably to adjust the size information for the piece. I'd recommend against reverting this patch, since you'll end up with crashes in the backend due to incorrect IR. If you would like, I think a possible course of action would be to temporarily remove the assert, which I think should only lead to incorrect debug info.</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 15, 2016 at 6:51 AM, James Molloy <span dir="ltr"><<a href="mailto:james@jamesmolloy.co.uk" target="_blank">james@jamesmolloy.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>Looking further at this, the issue stems from the type involved, which is x86_fp80. This type has a n AllocSize of 128 bits but an "actual" size of 80 bits. Part of SROA is using the alloc size and another part is using the non-alloc size which is why we get a size disparity.</div><div><br></div><div>I've put assertions in to this code that fire when DL.getTypeSizeInBits != DL.getTypeAllocSizeInBits, and those never fire in the test suite. </div><div><br></div><div>As this patch isn't sufficiently tested, I vote that we revert this patch.</div><div><br></div><div>Thoughts?</div><div><br></div><div>Cheers,</div><div><br></div><div>James</div><div><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Mon, 15 Aug 2016 at 10:52 James Molloy <<a href="mailto:james@jamesmolloy.co.uk" target="_blank">james@jamesmolloy.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br>Hi Keno, Adrian,<div><br></div><div>A recent change of mine to SimplifyCFG exposed a bug in this commit. This assert is firing:</div><div><br></div><div><div>       assert(Pieces.size() == 1 &&</div></div></div><div dir="ltr"><div><div>               "partition is as large as original alloca");</div></div></div><div dir="ltr"><div></div><div><br></div><div>From the phab review it looks like this assert was added in late in the review process and my testing shows that this assert is never tested at all in the regression tests (changing to assert(0) doesn't cause any failures!)</div><div><br></div><div>The error is shown here: <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/23920/steps/annotate/logs/stdio" target="_blank">http://lab.llvm.org:<wbr>8011/builders/sanitizer-x86_<wbr>64-linux-autoconf/builds/<wbr>23920/steps/annotate/logs/<wbr>stdio</a></div><div><br></div><div>It's easily reproducible with ToT clang simply compiling the file projects/compiler-rt/lib/<wbr>builtins/powixf2.c *with debug info enabled (-g)*.</div><div><br></div><div>I'd fix it myself but after staring for a while I can't work out if the the assert sense is wrong (the text "partition is as large as original alloca" seems like a failure mode to me, which would indicate that perhaps the test should have been "Pieces.size() != 1" ?) or if the assert is correct but there is a failure somewhere else.</div><div><br></div><div>Could you please take a look?</div><div><br></div><div>Cheers,</div><div><br></div><div>James</div></div><div dir="ltr"><div><br><div class="gmail_quote"><div dir="ltr">On Thu, 14 Jan 2016 at 20:10 Keno Fischer via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kfischer<br>
Date: Thu Jan 14 14:06:34 2016<br>
New Revision: 257795<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=257795&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=257795&view=rev</a><br>
Log:<br>
[SROA] Also insert a bit piece expression if only one piece is needed<br>
<br>
Summary: If SROA creates only one piece (e.g. because the other is not needed),<br>
it still needs to create a bit_piece expression if that bit piece is smaller<br>
than the original size of the alloca.<br>
<br>
Reviewers: aprantl<br>
<br>
Subscribers: llvm-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D16187" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16187</a><br>
<br>
Added:<br>
    llvm/trunk/test/Transforms/<wbr>SROA/dbg-single-piece.ll<br>
Modified:<br>
    llvm/trunk/lib/Transforms/<wbr>Scalar/SROA.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/<wbr>Scalar/SROA.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=257795&r1=257794&r2=257795&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/Scalar/SROA.cpp?<wbr>rev=257795&r1=257794&r2=<wbr>257795&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>Scalar/SROA.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>Scalar/SROA.cpp Thu Jan 14 14:06:34 2016<br>
@@ -4024,12 +4024,12 @@ bool SROA::splitAlloca(AllocaInst &AI, A<br>
     auto *Var = DbgDecl->getVariable();<br>
     auto *Expr = DbgDecl->getExpression();<br>
     DIBuilder DIB(*AI.getModule(), /*AllowUnresolved*/ false);<br>
-    bool IsSplit = Pieces.size() > 1;<br>
+    uint64_t AllocaSize = DL.getTypeSizeInBits(AI.<wbr>getAllocatedType());<br>
     for (auto Piece : Pieces) {<br>
       // Create a piece expression describing the new partition or reuse AI's<br>
       // expression if there is only one partition.<br>
       auto *PieceExpr = Expr;<br>
-      if (IsSplit || Expr->isBitPiece()) {<br>
+      if (Piece.Size < AllocaSize || Expr->isBitPiece()) {<br>
         // If this alloca is already a scalar replacement of a larger aggregate,<br>
         // Piece.Offset describes the offset inside the scalar.<br>
         uint64_t Offset = Expr->isBitPiece() ? Expr->getBitPieceOffset() : 0;<br>
@@ -4043,6 +4043,9 @@ bool SROA::splitAlloca(AllocaInst &AI, A<br>
           Size = std::min(Size, AbsEnd - Start);<br>
         }<br>
         PieceExpr = DIB.createBitPieceExpression(<wbr>Start, Size);<br>
+      } else {<br>
+        assert(Pieces.size() == 1 &&<br>
+               "partition is as large as original alloca");<br>
       }<br>
<br>
       // Remove any existing dbg.declare intrinsic describing the same alloca.<br>
<br>
Added: llvm/trunk/test/Transforms/<wbr>SROA/dbg-single-piece.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SROA/dbg-single-piece.ll?rev=257795&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>Transforms/SROA/dbg-single-<wbr>piece.ll?rev=257795&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/Transforms/<wbr>SROA/dbg-single-piece.ll (added)<br>
+++ llvm/trunk/test/Transforms/<wbr>SROA/dbg-single-piece.ll Thu Jan 14 14:06:34 2016<br>
@@ -0,0 +1,37 @@<br>
+; RUN: opt -sroa %s -S | FileCheck %s<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:<wbr>32:64-S128"<br>
+<br>
+%foo = type { [8 x i8], [8 x i8] }<br>
+<br>
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #0<br>
+define void @_<wbr>ZL18findInsertLocationPN4llvm1<wbr>7MachineBasicBlockENS_<wbr>9SlotIndexERNS_<wbr>13LiveIntervalsE() {<br>
+entry:<br>
+  %retval = alloca %foo, align 8<br>
+  call void @llvm.dbg.declare(metadata %foo* %retval, metadata !1, metadata !7), !dbg !8<br>
+; Checks that SROA still inserts a bit_piece expression, even if it produces only one piece<br>
+; (as long as that piece is smaller than the whole thing)<br>
+; CHECK-NOT: call void @llvm.dbg.value<br>
+; CHECK: call void @llvm.dbg.value(metadata %foo* undef, i64 0, metadata !1, metadata ![[BIT_PIECE:[0-9]+]]), !dbg<br>
+; CHECK-NOT: call void @llvm.dbg.value<br>
+; CHECK: ![[BIT_PIECE]] = !DIExpression(DW_OP_bit_piece, 64, 64)<br>
+  %0 = bitcast %foo* %retval to i8*<br>
+  %1 = getelementptr inbounds i8, i8* %0, i64 8<br>
+  %2 = bitcast i8* %1 to %foo**<br>
+  store %foo* undef, %foo** %2, align 8<br>
+  ret void<br>
+}<br>
+<br>
+attributes #0 = { nounwind readnone }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{}<br>
+!llvm.module.flags = !{!0}<br>
+<br>
+!0 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!1 = !DILocalVariable(name: "I", scope: !2, file: !3, line: 947, type: !4)<br>
+!2 = distinct !DISubprogram(name: "findInsertLocation", linkageName: "_<wbr>ZL18findInsertLocationPN4llvm1<wbr>7MachineBasicBlockENS_<wbr>9SlotIndexERNS_<wbr>13LiveIntervalsE", scope: !3, file: !3, line: 937, isLocal: true, isDefinition: true, scopeLine: 938, flags: DIFlagPrototyped, isOptimized: true)<br>
+!3 = !DIFile(filename: "none", directory: ".")<br>
+!4 = !DICompositeType(tag: DW_TAG_class_type, name: "bundle_iterator<llvm::<wbr>MachineInstr, llvm::ilist_iterator<llvm::<wbr>MachineInstr> >", scope: !5, file: !3, line: 163, size: 128, align: 64, elements: !6, templateParams: !6, identifier: "_<wbr>ZTSN4llvm17MachineBasicBlock15<wbr>bundle_iteratorINS_<wbr>12MachineInstrENS_14ilist_<wbr>iteratorIS2_EEEE")<br>
+!5 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "MachineBasicBlock", file: !3, line: 68, size: 1408, align: 64, identifier: "_<wbr>ZTSN4llvm17MachineBasicBlockE"<wbr>)<br>
+!6 = !{}<br>
+!7 = !DIExpression()<br>
+!8 = !DILocation(line: 947, column: 35, scope: !2)<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div></blockquote></div></div></div></div>
</blockquote></div><br></div>