[LLVMdev] Name mangling and getOrInsertFunction

Jimborean Alexandra xinfinity_a at yahoo.com
Tue Apr 16 11:35:08 PDT 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130416/4d858474/attachment.html>


More information about the llvm-dev mailing list