<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 31, 2017, at 12:00 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" class="">pichet2000@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Mon, Oct 30, 2017 at 5:39 PM, Adrian Prantl<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><div class=""><div class="gmail-h5"><br class=""><blockquote type="cite" class=""><div class="">On Oct 30, 2017, at 2:25 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" target="_blank" class="">pichet2000@gmail.com</a>> wrote:</div><br class="gmail-m_-3995178823218292809Apple-interchange-newline"><div class=""><br class="gmail-m_-3995178823218292809Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">On Mon, Oct 30, 2017 at 5:15 PM, Adrian Prantl<span class="gmail-m_-3995178823218292809Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span><span class="gmail-m_-3995178823218292809Apple-converted-space"> </span>wro<wbr class="">te:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="gmail-m_-3995178823218292809m_3515076279766131425gmail-h5"><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Oct 30, 2017, at 2:12 PM, Francois Pichet <<a href="mailto:pichet2000@gmail.com" target="_blank" class="">pichet2000@gmail.com</a>> wrote:</div><br class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-interchange-newline"><div class=""><br class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">On Wed, Aug 30, 2017 at 4:04 PM, Adrian Prantl via llvm-commits<span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lis<wbr class="">ts.llvm.org</a>></span><span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Author: adrian<br class="">Date: Wed Aug 30 13:04:17 2017<br class="">New Revision: 312165<br class=""><br class="">URL:<span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=312165&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/ll<wbr class="">vm-project?rev=312165&view=rev</a><br class="">Log:<br class="">Refactor DIBuilder::createFragmentExpre<wbr class="">ssion into a static DIExpression member<br class=""><br class="">NFC<br class=""><br class="">Modified:<br class="">   <span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>llvm/trunk/include/llvm/IR/D<wbr class="">IBuilder.h<br class="">   <span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>llvm/trunk/include/llvm/IR/D<wbr class="">ebugInfoMetadata.h<br class="">   <span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/Selec<wbr class="">tionDAG/LegalizeTypes.cpp<br class="">   <span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>llvm/trunk/lib/IR/DIBuilder.<wbr class="">cpp<br class="">   <span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>llvm/trunk/lib/IR/DebugInfoM<wbr class="">etadata.cpp<br class="">   <span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>llvm/trunk/lib/Transforms/IP<wbr class="">O/GlobalOpt.cpp<br class="">   <span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span>llvm/trunk/lib/Transforms/Sc<wbr class="">alar/SROA.cpp<br class=""><br class=""><br class=""><br class="">Modified: llvm/trunk/lib/IR/DebugInfoMet<wbr class="">adata.cpp<br class="">URL:<span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-m_-7207667922643354705Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=312165&r1=312164&r2=312165&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/ll<wbr class="">vm-project/llvm/trunk/lib/IR/D<wbr class="">ebugInfoMetadata.cpp?rev=31216<wbr class="">5&r1=312164&r2=312165&view=dif<wbr class="">f</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- llvm/trunk/lib/IR/DebugInfoMet<wbr class="">adata.cpp (original)<br class="">+++ llvm/trunk/lib/IR/DebugInfoMet<wbr class="">adata.cpp Wed Aug 30 13:04:17 2017<br class="">@@ -724,6 +724,34 @@ DIExpression *DIExpression::prepend(cons<br class="">   return DIExpression::get(Expr->getCon<wbr class="">text(), Ops);<br class=""> }<br class=""><br class="">+DIExpression *DIExpression::createFragmentE<wbr class="">xpression(const DIExpression *Expr,<br class="">+                                                     unsigned OffsetInBits,<br class="">+                                                     unsigned SizeInBits) {<br class="">+  SmallVector<uint64_t, 8> Ops;<br class="">+  // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.<br class="">+  if (Expr) {<br class="">+    for (auto Op : Expr->expr_ops()) {<br class="">+      if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {<br class="">+        // Make the new offset point into the existing fragment.<br class="">+        uint64_t FragmentOffsetInBits = Op.getArg(0);<br class="">+        // Op.getArg(0) is FragmentOffsetInBits.<br class="">+        // Op.getArg(1) is FragmentSizeInBits.<br class="">+        assert((OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) &&<br class="">+               "new fragment outside of original fragment");<br class=""></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> Hi, </div><div class=""><br class=""></div><div class="">I am getting an assert here on an (out of tree) big-endian target where 64-bit variables are splitted on 2 32-bit variables.</div><div class="">assert where: OffsetInBits=32, SizeInBits=32 and Expr: !DIExpression(DW_OP_LLVM<wbr class="">_fragment, 0, 32)</div><div class="">so 32 + 32 <= 32 is not true.</div><div class=""><br class=""></div><div class="">I might be wrong but I think the assert is only valid on little endian target?</div></div></div></blockquote><br class=""></div></div></div><div class="">I'm not sure I understand your example. Are you saying that you are calling createFragmentExpression on something that is already 32-bit fragment? Which pass is calling it? It seems more likely that there is something wrong with the call site.</div><span class="gmail-m_-3995178823218292809m_3515076279766131425gmail-HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- adrian</div><div class=""><br class=""></div><br class=""></font></span></div></blockquote><div class="">DAGTypeLegalizer::SetExpandedI<wbr class="">nteger is the call site:</div><div class=""><br class=""></div></div></div></blockquote></div></div><div class="">createFragmentExpression creates a fragment of and existing value at a given offset, and with a given size. If the existing value already is a fragment the offset and size are *within* the existing fragment. The assert verifies this. It should be endianness-neutral. Can you explain why you believe the assertion is wrong for big-endian targets?</div><span class="gmail-"><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="gmail_extra"> <span class="Apple-converted-space"> </span>if (DAG.getDataLayout().isBigEndi<wbr class="">an()) {</div><div class="gmail_extra">   <span class="Apple-converted-space"> </span>transferDbgValues(DAG, Op, Hi, 0);</div><div class="gmail_extra">   <span class="Apple-converted-space"> </span>transferDbgValues(DAG, Op, Lo, Hi.getValueSizeInBits());  // <--- assert </div></div></div></blockquote><div class=""><br class=""></div></span><div class="">This code was added in <a href="https://reviews.llvm.org/D38172" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D38172</a>. This is splitting the debug info into one part describing the Hi bits (at offset 0) and the Lo bits (at sizeof(Hi)). Since you are seeing the assertion I assume that you have a value that is split twice, is that correct? Can you explain why createFragmentExpression is called with a !DIExpression(DW_OP_LLVM_<wbr class="">fragment, 0, 32)?</div><div class=""><br class=""></div><div class="">thanks,</div><div class=""><br class=""></div></div></div></blockquote><div class=""><br class=""></div><div class="">Hi,</div><div class=""><br class=""></div><div class="">The problem happen when Op = ISD::build_pair and Lo and Hi already have fragment created by SROA.cpp.</div><div class=""><br class=""></div><div class="">More detail here:<span class="Apple-converted-space"> </span><a href="https://gist.github.com/anonymous/5d72495c77f28269fe3c01715e770e19" class="">https://gist.github.com/anonymous/5d72495c77f28269fe3c01715e770e19</a></div><div class=""><br class=""></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Not sure what the solution is.</span></div></blockquote><br class=""></div><div>My best guess is that SROA splits up the variable into Lo (offs=0) and Hi (offs=32) part and then the type legalizer wants to reorder that to Hi (offs=32) and Lo (offs=0) which fails because it violates the assertion that the new fragment is within the old one. So either we need to to make SROA also endianness-aware, or perhaps we need to revisit <a href="https://reviews.llvm.org/D38172" target="_blank" class="">D38172</a> to see if this was really the correct resolution. To do the latter we should start by reading the DWARF specification to see whether <a href="https://reviews.llvm.org/D38172" target="_blank" class="">D38172</a> assumptions on how DW_OP_piece operations for big-endian targets are supposed to be encoded match what the DWARF specification says. Perhaps it is the DWARF consumer (=the debugger) that needs to be endianness-aware when interpreting DW_OP_piece operators instead of reordering them in the compiler, but this is just speculation.</div><div><br class=""></div><div>-- adrian</div><br class=""></body></html>