<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 30, 2015, at 11:14 AM, Quentin Colombet via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Hi Tim and Jon,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">On Nov 30, 2015, at 10:51 AM, Jonathan Roelofs <<a href="mailto:jonathan@codesourcery.com" class="">jonathan@codesourcery.com</a>> wrote:<br class=""><br class=""><br class=""><br class="">On 11/30/15 10:42 AM, Quentin Colombet wrote:<br class=""><blockquote type="cite" class="">Hi Jon,<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Nov 25, 2015, at 11:25 AM, Jonathan Roelofs<br class=""><<a href="mailto:jonathan@codesourcery.com" class="">jonathan@codesourcery.com</a> <<a href="mailto:jonathan@codesourcery.com" class="">mailto:jonathan@codesourcery.com</a>>> wrote:<br class=""><br class=""><br class=""><br class="">On 7/20/15 3:42 PM, Quentin Colombet wrote:<br class=""><blockquote type="cite" class="">Author: qcolombet<br class="">Date: Mon Jul 20 16:42:14 2015<br class="">New Revision: 242714<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=242714&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=242714&view=rev</a><br class="">Log:<br class="">[ARM] Refactor the prologue/epilogue emission to be more robust.<br class=""><br class="">This is the first step toward supporting shrink-wrapping for this target.<br class=""><br class="">The changes could be summarized by these items:<br class="">- Expand the tail-call return as part of the expand pseudo pass.<br class="">- Get rid of the assumptions that the epilogue is the exit block:<br class="">* Do not assume which registers are free in the epilogue. (This<br class="">indirectly<br class="">  improve the lowering of the code for the segmented stacks, see<br class="">the test<br class="">  cases.)<br class="">* Take into account that the basic block can be empty.<br class=""><br class="">Related to <<a href="rdar://problem/20821730" class="">rdar://problem/20821730</a>><br class=""><br class=""></blockquote><br class="">snip<br class=""><br class=""><blockquote type="cite" class="">Modified: llvm/trunk/test/CodeGen/ARM/thumb1_return_sequence.ll<br class="">URL:http://<a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb1_return_sequence.ll?rev=242714&r1=242713&r2=242714&view=diff" class="">llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb1_return_sequence.ll?rev=242714&r1=242713&r2=242714&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/CodeGen/ARM/thumb1_return_sequence.ll (original)<br class="">+++ llvm/trunk/test/CodeGen/ARM/thumb1_return_sequence.ll Mon Jul 20<br class="">16:42:14 2015<br class="">@@ -23,11 +23,9 @@ entry:<br class="">; --------<br class="">; CHECK-V4T:         add sp,<br class="">; CHECK-V4T-NEXT:    pop {[[SAVED]]}<br class="">-; CHECK-V4T-NEXT:    mov r12, r3<br class="">-; CHECK-V4T-NEXT:    pop {r3}<br class="">-; CHECK-V4T-NEXT:    mov lr, r3<br class="">-; CHECK-V4T-NEXT:    mov r3, r12<br class="">-; CHECK-V4T:         bx  lr<br class="">+; We do not have any SP update to insert so we can just optimize<br class="">+; the pop sequence.<br class="">+; CHECK-V4T-NEXT:    pop {pc}<br class=""></blockquote><br class="">This ^ is an invalid optimization. The awkward sequence there is<br class="">necessary because:<br class=""><br class="">Arch constraints:<br class="">* v4t can't change the thumb bit via a `pop { pc }` insruction<br class="">* v4t can only pop into lo registers and the pc<br class="">    (and bit[0] of the value popped into pc must be 0 if pc is in<br class="">     the list)<br class="">* v4t can't move from a lo register to a lo register<br class=""><br class="">AAPCS constraints:<br class="">* r3 needs to be saved off in case it is used as part of the return<br class="">    value.<br class="">* r12 is the only register we're allowed to clobber.<br class=""></blockquote><br class="">Maybe the test or check line is just poorly written because the code<br class="">that does this optimization is guarded under  STI.hasV5TOps(), i.e.,<br class="">this should not happen for v4t only arch.<br class=""></blockquote><br class="">The problem is in the changes under the `if (ArgRegsSaveSize || IsV4PopReturn)` guard:<br class=""><br class=""><a href="https://github.com/llvm-mirror/llvm/commit/b2dab382ce01d602a757906160fccd9129c768f7#diff-5daa733fad8e67c69c0c5291dbb05ebbR392" class="">https://github.com/llvm-mirror/llvm/commit/b2dab382ce01d602a757906160fccd9129c768f7#diff-5daa733fad8e67c69c0c5291dbb05ebbR392</a><br class=""><br class="">which did have `STI.hasV4TOps() && !STI.hasV5TOps()` as part of its condition.  This was conservatively correct, but sub-optimal for v5t+.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Thanks for pointing that out.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I see the problem now.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I’ll push a patch shortly.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>Should be fixed by <span style="font-family: Menlo; font-size: 11px;" class="">Committed revision 254325.</span></div><div><span style="font-family: Menlo; font-size: 11px;" class=""><br class=""></span></div><div><span style="font-family: Menlo; font-size: 11px;" class="">Q.</span></div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Cheers,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">-Quentin</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class=""><br class="">Do you have an actual test case where this fails?<br class=""></blockquote><br class="">No, I don't. I can't find the original testcases that motivated r214928 either (other than the ones in the commit).<br class=""><br class=""><br class="">Jon<br class=""><br class=""><blockquote type="cite" class=""><br class="">Thanks,<br class="">-Quentin<br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">; CHECK-V5T:         pop {[[SAVED]], pc}<br class="">}<br class=""><br class="">@@ -53,19 +51,19 @@ entry:<br class="">; Epilogue<br class="">; --------<br class="">; CHECK-V4T:         pop {[[SAVED]]}<br class="">-; CHECK-V4T-NEXT:    mov r12, r3<br class="">-; CHECK-V4T-NEXT:    pop {r3}<br class="">+; CHECK-V4T-NEXT:    mov r12, [[POP_REG:r[0-7]]]<br class="">+; CHECK-V4T-NEXT:    pop {[[POP_REG]]}<br class="">; CHECK-V4T-NEXT:    add sp,<br class="">-; CHECK-V4T-NEXT:    mov lr, r3<br class="">-; CHECK-V4T-NEXT:    mov r3, r12<br class="">+; CHECK-V4T-NEXT:    mov lr, [[POP_REG]]<br class="">+; CHECK-V4T-NEXT:    mov [[POP_REG]], r12<br class="">; CHECK-V4T:         bx  lr<br class="">; CHECK-V5T:         add sp,<br class="">; CHECK-V5T-NEXT:    pop {[[SAVED]]}<br class="">-; CHECK-V5T-NEXT:    mov r12, r3<br class="">-; CHECK-V5T-NEXT:    pop {r3}<br class="">+; CHECK-V5T-NEXT:    mov r12, [[POP_REG:r[0-7]]]<br class="">+; CHECK-V5T-NEXT:    pop {[[POP_REG]]}<br class="">; CHECK-V5T-NEXT:    add sp,<br class="">-; CHECK-V5T-NEXT:    mov lr, r3<br class="">-; CHECK-V5T-NEXT:    mov r3, r12<br class="">+; CHECK-V5T-NEXT:    mov lr, [[POP_REG]]<br class="">+; CHECK-V5T-NEXT:    mov [[POP_REG]], r12<br class="">; CHECK-V5T-NEXT:    bx lr<br class="">}<br class=""><br class="">@@ -95,8 +93,7 @@ entry:<br class="">; Epilogue<br class="">; --------<br class="">; CHECK-V4T:    pop {[[SAVED]]}<br class="">-; CHECK-V4T:    pop {r3}<br class="">-; CHECK-V4T:    bx r3<br class="">+; CHECK-V4T:    pop {pc}<br class=""></blockquote><br class="">This ^ is also invalid for the same reason.<br class=""><br class=""><blockquote type="cite" class="">; CHECK-V5T:    pop {[[SAVED]], pc}<br class="">}<br class=""><br class="">@@ -148,14 +145,18 @@ entry:<br class="">; --------<br class="">; CHECK-V4T:         add sp,<br class="">; CHECK-V4T-NEXT:    pop {[[SAVED]]}<br class="">-; CHECK-V4T-NEXT:    pop {r3}<br class="">+; Only r1 to r3 are available to pop LR.<br class="">+; r0 is used for the return value.<br class="">+; CHECK-V4T-NEXT:    pop {[[POP_REG:r[1-3]]]}<br class="">; CHECK-V4T-NEXT:    add sp,<br class="">-; CHECK-V4T-NEXT:    bx r3<br class="">+; CHECK-V4T-NEXT:    bx [[POP_REG]]<br class="">; CHECK-V5T:         add sp,<br class="">; CHECK-V5T-NEXT:    pop {[[SAVED]]}<br class="">-; CHECK-V5T-NEXT:    pop {r3}<br class="">+; Only r1 to r3 are available to pop LR.<br class="">+; r0 is used for the return value.<br class="">+; CHECK-V5T-NEXT:    pop {[[POP_REG:r[1-3]]]}<br class="">; CHECK-V5T-NEXT:    add sp,<br class="">-; CHECK-V5T-NEXT:    bx r3<br class="">+; CHECK-V5T-NEXT:    bx [[POP_REG]]<br class="">}<br class=""><br class="">; CHECK-V4T-LABEL: noframe<br class="">@@ -191,13 +192,17 @@ entry:<br class="">; Epilogue<br class="">; --------<br class="">; CHECK-V4T:         pop {[[SAVED]]}<br class="">-; CHECK-V4T-NEXT:    pop {r3}<br class="">+; Only r1 to r3 are available to pop LR.<br class="">+; r0 is used for the return value.<br class="">+; CHECK-V4T-NEXT:    pop {[[POP_REG:r[1-3]]]}<br class="">; CHECK-V4T-NEXT:    add sp,<br class="">-; CHECK-V4T-NEXT:    bx r3<br class="">+; CHECK-V4T-NEXT:    bx [[POP_REG]]<br class="">; CHECK-V5T:         pop {[[SAVED]]}<br class="">-; CHECK-V5T-NEXT:    pop {r3}<br class="">+; Only r1 to r3 are available to pop LR.<br class="">+; r0 is used for the return value.<br class="">+; CHECK-V5T-NEXT:    pop {[[POP_REG:r[1-3]]]}<br class="">; CHECK-V5T-NEXT:    add sp,<br class="">-; CHECK-V5T-NEXT:    bx r3<br class="">+; CHECK-V5T-NEXT:    bx [[POP_REG]]<br class="">}<br class=""><br class="">declare void @llvm.va_start(i8*) nounwind<br class=""><br class=""></blockquote><br class="">snip<br class=""><br class=""><blockquote type="cite" class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a> <<a href="mailto:llvm-commits@cs.uiuc.edu" class="">mailto:llvm-commits@cs.uiuc.edu</a>><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class=""><br class=""></blockquote><br class="">--<br class="">Jon Roelofs<br class=""><a href="mailto:jonathan@codesourcery.com" class="">jonathan@codesourcery.com</a> <<a href="mailto:jonathan@codesourcery.com" class="">mailto:jonathan@codesourcery.com</a>><br class="">CodeSourcery / Mentor Embedded<br class=""></blockquote><br class=""></blockquote><br class="">--<span class="Apple-converted-space"> </span><br class="">Jon Roelofs<br class=""><a href="mailto:jonathan@codesourcery.com" class="">jonathan@codesourcery.com</a><br class="">CodeSourcery / Mentor Embedded<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">llvm-commits mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:llvm-commits@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">llvm-commits@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></div></blockquote></div><br class=""></body></html>