<div dir="ltr"><div>Hello LLVM!</div><div><br></div><div>I have recently noticed an issue which makes LLVM incorrectly recognize a function as a 'leaf' function when it isn't, and I have filed PR20243 (<a href="http://llvm.org/bugs/show_bug.cgi?id=20243">http://llvm.org/bugs/show_bug.cgi?id=20243</a>).</div>
<div>The bug I have reported is specific to one particular case where this happens, but I worry that the problem might be more general.</div><div><br></div><div>Essentially, the issue is that some backends expand instructions to calls to runtime library functions not only at instruction selection stage, but also in their AsmPrinter's (i.e. very late). In the PR I referenced, this happens with the creation of a call to __tls_get_addr in the X86 backend. Because of this, the call is invisible to any analysis or inspection running before the AsmPrinter.</div>
<div><br></div><div>Therefore, code that performs decisions based on whether the function is a leaf (in the PR, the issue is with -momit-leaf-frame-pointer) is going to make the wrong decision.</div><div><br></div><div>From a quick grep I can see that the PPC backend and the Sparc backend also do some handling of __tls_get_addr, but I haven't checked in detail.</div>
<div>Also, there may be more instances of other function calls being generated too late.</div><div><br></div><div>So I wanted to point this out to the community as a possible general issue to look into. I found one case, but there may be others.</div>
<div><br></div><div>Cheers,</div><div>    Dario Domizioli</div><div>    SN Systems - Sony Computer Entertainment Group</div><div><br></div><div><br></div></div>