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

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++.

Chip

Charles Davis wrote: