Name mangling and getOrInsertFunction

Hello,

I am trying to handle some overloaded functions in the LLVM IR.

I have a number of functions named “task” in the source code, differing in the number of parameters. And there is a call, let’s say:
task (a, b).

I get the file.ll equivalent and I want to replace the original call task (a,b) with a call to one of the other functions, task(a,b,c).

The problem is that due to name mangling I cannot find the second function, accepting 3 parameters. I can build the correct FuntionType, but I cannot use the M->getOrInsertFunction, since I cannot get the correct name of the function.

Do you have any suggestions on how can I:
(i) either retrieve the function name
(ii) directly retrieve the function I need, based on its FunctionTy and knowing that the name has a common substring with the other function (or based on the original name it has in the source code). To be more precise, originally, the function is called task and it is overloaded. Therefore, in the LLVM IR one of them becomes @Z6_task_PFvPvS_S_S_ES1_S_S_S_S and the other one @Z6_task_PFvPvS_S_S_ES_S_S_S .

And I want to replace call @Z6_task_PFvPvS_S_S_ES1_S_S_S_S (%a, %b)

with

call @Z6_task_PFvPvS_S_S_ES_S_S_S(%a, %b, %c)

Thank you,
Alexandra