[LLVMdev] missed optimizations

Matthijs Kooijman matthijs at stdin.nl
Fri Sep 5 01:03:25 PDT 2008


Hi Eli,

> That said, clang really should be turning int x2() { return x(0); }
> into "define i32 @x2()" rather than "define i32 @x2(...)"; the
> function isn't varargs, and marking it as such could lead to wrong
> code for exotic calling conventions.
I always understood that this is correct per C language specification. For
functions that are internal (static), the DeadArgElim pass removes the vararg
spec if it's unused, but that's not applicable in this case.

Any particular reason the inliner doesn't touch varargs? I think that when you
call a varargs function without any varargs, it should be able to inline it
just fine? Or at least when the function in question also doesn't call the
va_* functions.

> > Also, shouldn't the function g() get inlined in the h() function? It is
> > inlined only if I change the g() function to be static. So isn't llvm being
> > too conservative when inlining global functions?
> 
> The inliner doesn't like varargs; see above.

And the fact that it is inlined when it's static, is probably due to the
DeadArgElim I mentioned above.

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080905/f0ce343d/attachment.sig>


More information about the llvm-dev mailing list