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

A. Vuori avuori at cs.Helsinki.FI
Wed Jun 17 01:16:48 PDT 2009


Hello,

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.

I'm currently running precompiled llvm-gcc binaries (being 
unable to compile fresh llvm-gcc at the moment):
llvm-gcc (GCC) 4.2.1 (Based on Apple Inc. build 5623) (LLVM build 2.4).

I apologize if the issue is due to my old llvm-gcc version.

-- 
Arto Vuori



More information about the llvm-dev mailing list