[LLVMdev] Why are functions renamed for .cpp files with llvm-gcc?

Fabian Scheler fabian.scheler at gmail.com
Wed Jun 17 01:39:56 PDT 2009


Hi Arto,

> I wonder why there is a difference in how
> llvm-gcc compiles .c and .cpp files.
>
> Example:
>
> ---bar.cpp----
> int bar() {
>    return 42;
> }
> --------------
>
> $ llvm-gcc -emit-llvm -c bar.cpp
>
> Now running bar.o through llvm-dis gives:
> --------------------------------
> define i32 @_Z3barv() nounwind {
>  < clip >
> }
> --------------------------------
>
> Above, function 'bar' has been renamed to '_Z3barv'.
>
> If, however, 'bar.cpp' is renamed 'bar.c',
> we get 'define i32 @bar()' as expected.

The answer is: C++ name mangling

Ciao, Fabian



More information about the llvm-dev mailing list