[LLVMdev] Broke my tail (call)

Jon Harrop jon at ffconsultancy.com
Tue Feb 24 02:50:39 PST 2009


On Monday 23 February 2009 16:14:57 Arnold Schwaighofer wrote:
> The problem has to do with how struct returns are represented
> internally by llvm (in the SelectionDAG) and how the tail call
> optimization implementation checks if it may perform the tail call.
> The implementation checks that the <call> node is immediately followed
> by a <ret> node. A struct return causes the insertion of a
> <merge_values> node between the tail call instruction and the return
> instruction node. Because of the intermediate node the backend
> believes it must not optimize the tail call.
>
> [result1, result2] = <call ... >
> [merged] = <merge_values [result1, result2]>
> <ret [merged]>
>
> So the current situation is that tail calls on functions that return a
> struct are not optimized (as you correctly observed ;). Sorry.

Thanks for the clarification. That makes a lot more sense!

LLVM's support for structs is wonderful but I don't think they can be 
called "first-class structs" until all such arbitrary restrictions have been 
removed, even though the workaround (using sret form) is trivial in this 
case.

Shall I file this as a bug against LLVM?

Assuming this gets fixed, will it be more efficient that the sret form?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list