<div dir="ltr">Hi All,<br><br><span class="gmail-socmaildefaultfont" style="font-size:10pt">We are encountering an issue where "</span><span style="color:rgb(51,51,51);font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace,serif;font-size:12px">bool llvm::isInTailCallPosition()" </span><span class="gmail-socmaildefaultfont" style="font-size:10pt">returns true for a callee not in a tail call position.<br><br><span class="gmail-socmaildefaultfont" style="font-size:10pt">The function "bool llvm::isInTailCallPosition()" (<a href="https://pastebin.com/fMxAsh95">https://pastebin.com/fMxAsh95</a>) only checks whether a </span><span class="gmail-socmaildefaultfont" style="font-size:10pt">call is in a tail call position if the call has side effects, accesses memory or is not safe to speculatively execute. Therefore, a “speculatable” function will always be considered in a tail-call position - regardless of whether it actually is. A small example as below:</span><br> <br>IR reproducer </span><a href="https://pastebin.com/eZwVxr2K">https://pastebin.com/eZwVxr2K</a> produces a tail call in caller without storing the result, which can be seen in the initial SDAG shared below:<br><a href="https://pastebin.com/SnyKHeZT">https://pastebin.com/SnyKHeZT</a> <span style="display:none"> </span><br><div><span style="font-size:10pt"><br>Any ideas or suggestions?</span><br></div><div><span class="gmail-socmaildefaultfont" style="font-size:10pt"><br>Thanks,<br>Victor</span></div></div>