<div dir="ltr"><div>Several users have been asking for this function attribute to prevent losing the calling functions's information in the backtrace. If we attach the attribute to a function, ideally we would want to prevent tail call optimization on all call sites that call the function. However, the compiler cannot always tell which function is called from a call site if it's an indirect call, so it's fine if an indirect call to the marked function ends up being tail-call optimized. For direct calls, we want the function attribute to prevent tail call 100% of the time.</div><div><br></div><div>We can also use a "notail" marker on the call instruction instead of using a function attribute. The only downside of using a marker is that we probably will never be able to prevent tail call optimization on indirect calls even when the compiler can turn it into a direct call (for example, via inlining). I'm not sure at the moment how important this is.</div><div><br></div><div><div><div><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 17, 2015 at 9:47 AM, Philip Reames via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>+llvm-dev<br>
      <br>
      Can you give a bit of background on what you're trying to address
      here?  After reading through the discussion and seeing that this
      is a best effort flag, I'm not sure that a function attribute is
      the best way to describe this.  I'm open to being convinced it is,
      but I'd like to hear a bit more about the use case and get broader
      visibility on the proposal first.<br>
      <br>
      Philip<div><div><br>
      <br>
      On 09/16/2015 07:27 PM, Akira Hatanaka via llvm-commits wrote:<br>
    </div></div></div>
    <blockquote type="cite"><div><div>
      <pre>ahatanak created this revision.
ahatanak added a subscriber: llvm-commits.

This patch adds support for a new IR function attribute "notail". The attribute is used to disable tail call optimization on calls to functions marked with the attribute.

This attribute is different from the existing attribute "disable-tail-calls", which disables tail call optimizations on all call sites within the marked function.

The patch to add support for the corresponding source-level function attribute is here:
<a href="http://reviews.llvm.org/D12922" target="_blank">http://reviews.llvm.org/D12922</a>

<a href="http://reviews.llvm.org/D12923" target="_blank">http://reviews.llvm.org/D12923</a>

Files:
  docs/LangRef.rst
  include/llvm/Bitcode/LLVMBitCodes.h
  include/llvm/IR/Attributes.h
  include/llvm/IR/Instructions.h
  lib/AsmParser/LLLexer.cpp
  lib/AsmParser/LLParser.cpp
  lib/AsmParser/LLToken.h
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/IR/Attributes.cpp
  lib/IR/Verifier.cpp
  lib/Transforms/Scalar/TailRecursionElimination.cpp
  test/Bindings/llvm-c/Inputs/invalid.ll.bc
  test/Bindings/llvm-c/invalid-bitcode.test
  test/Bitcode/attributes.ll
  test/Bitcode/invalid.ll
  test/Bitcode/invalid.ll.bc
  test/CodeGen/X86/attr-notail.ll
  test/Transforms/TailCallElim/notail.ll

</pre>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
llvm-commits mailing list
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<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/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div></div></div></div>