Malveeka Tewari
2011-Jun-04 03:55 UTC
[LLVMdev] Function name changes in .bc on running llvm-g++
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 and is there a way to avoid so that the function name remains unchanged. This is how I am invoking llvm-g++ llvm-g++ -emit-llvm -c -O0 streamcluster.cpp -o streamcluster.bc Thanks! Malveeka -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110603/c36224d8/attachment.html>
Charles Davis
2011-Jun-04 04:01 UTC
[LLVMdev] Function name changes in .bc on running llvm-g++
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 renamingYou 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++. Chip
Nick Lewycky
2011-Jun-04 04:09 UTC
[LLVMdev] Function name changes in .bc on running llvm-g++
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