[LLVMdev] Why are functions renamed for .cpp files with llvm-gcc?
Frits van Bommel
fvbommel at wxs.nl
Wed Jun 17 02:12:39 PDT 2009
A. Vuori wrote:
> Above, function 'bar' has been renamed to '_Z3barv'.
>
> If, however, 'bar.cpp' is renamed 'bar.c',
> we get 'define i32 @bar()' as expected.
This is not llvm-gcc specific; it happens for regular gcc too. It's needed to
support overloading multiple functions called 'bar' with different parameters,
(which C++ supports but C does not). _Z3barv just means "bar()", i.e. a function
named 'bar' with no parameters (there's a program called c++filt to demangle
these names).
This is called name mangling. See also
http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B
More information about the llvm-dev
mailing list