[LLVMdev] Broke my tail (call)

Arnold Schwaighofer arnold.schwaighofer at gmail.com
Sat Mar 28 01:50:20 PDT 2009


Hello Jon,

Yes you are right tail call optimization breaks for i1.

It breaks for the same reason it breaks when structs are returned.

Simple example

define fastcc i1 @i1test(i32, i32, i32, i32) {
  entry:
  %4 = tail call fastcc i1 @i1test( i32 %0, i32 %1, i32 %2, i32 %3)
  ret i1 %4
}

In the intermediate representation, the SelectionDAG, there is a node
that converts the result of i1test from a i8 to a i1. This should not
hinder tail call optimization. But since i don't detect this case
correctly tail calls are turned off.

A fix for this bug and the struct return bug is in svn (revision 67934).

regards
arnold
On Sat, Mar 28, 2009 at 6:16 AM, Jon Harrop <jon at ffconsultancy.com> wrote:
> I just noticed that altering my representation of the unit type also seems to
> break tail calls. Specifically, if I return the i1 or i8 types. Is that
> expected to break tail calls as well as returning structs? If so, when
> exactly can tail calls be relied upon?

Whenever i did not miss something ;). Sorry!



More information about the llvm-dev mailing list