[cfe-dev] Emitted code for zero-arg functions

Arto Vuori vuoria at tcs.hut.fi
Thu Jun 11 05:01:11 PDT 2009


Hello!

Is this expected behaviour that clang emits a bitcast from
a function with no arguments to a vararg function in the
'call' instruction considering the following C program:

     void foo();
     void foo() { }
     int main(void) { foo(); return 0; }

Clang emits the following 'call' instruction:

     call void (...)* bitcast (void ()* @foo to void (...)*)()

In contrast llvm-gcc emits simply:

     call void @foo() nounwind

If we _explicitly_ declare that 'foo' is a function with no arguments
as follows, no bitcast is emitted with clang nor llvm-gcc.

     void foo(void);

The behaviour affects, for example, the usage of
CallInst::getCalledFunction.

The C code was compiled with -O0 for both compilers. My clang is
compiled from revision 72717. My llvm-gcc is an old build, but
that's not the point here.

--
Arto Vuori



More information about the cfe-dev mailing list