[LLVMdev] clang change function name

John Criswell jtcriswel at gmail.com
Sun Mar 1 20:44:29 PST 2015


On 3/1/15 11:38 PM, Haopeng Liu wrote:
> Hi,
>
> I compile a .cpp with cmd:
> clang++ -emit-llvm -c -g -O0 -w pbzip2.cpp -o pbzip2.bc -lbz2
> llvm-dis pbzip2.bc
>
> One function in .cpp is consumer_decompress. However, I look inside 
> pbzip2.ll. The function name is changed to "define i8* 
> @_Z19consumer_decompressPv(i8* %q) #0 {"
>
> Why clang adds a "_Z19" prefix and "Pv" suffix?

Clang mangles the name so that the function's name encodes the name and 
the function's type; this helps the linker link C++ object files 
together correctly.  See 
http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B for 
more details.

Regards,

John Criswell

>
> Thanks,
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell




More information about the llvm-dev mailing list