[LLVMdev] Function name changes in .bc on running llvm-g++

Nick Lewycky nicholas at mxc.ca
Fri Jun 3 21:09:52 PDT 2011


Charles Davis wrote:
> On 6/3/11 9:55 PM, Malveeka Tewari wrote:
>> Hi
>>
>> I am running llvm-g++ on a .cpp file to generate the llvm bitcode.
>>
>> The function definition in the .cpp file is:
>>
>> float pFL(Points *points, int *feasible, int numfeasible, float z, long *k,
>>        double cost, long iter, float e, int pid, pthread_barrier_t*
>> barrier) {
>>
>> However, in the bit code I see that the function name has been modified
>> to the following
>>
>> define float
>> @_Z3pFLP6PointsPiifPldlfiP17pthread_barrier_t(%struct.Points* %points,
>> i32* %feasible, i32 %numfeasible, float %z, i32* %k, double %cost, i32
>> %iter, float %e, i32 %pid, %union.pthread_barrier_t* %barrier) nounwind {
>>
>> What is the reason for the function renaming
> You wrote it in C++, that's why! You see, C++ supports something called
> "function overloading", where you can define two or more functions with
> the same name but different sets of arguments. That name--which is said
> to be "mangled" for obvious reasons--is so overloaded functions don't
> conflict with each other.
>> and is there a way to avoid
>> so that the function name remains unchanged.
> Yeah... don't write it in C++.

Wrapping the function in an extern "C" { ... } block also works.

Nick



More information about the llvm-dev mailing list