LLVM-8.0 | Requesting Help : Function->getName() returns empty string

Hello All,

I am creating a Module and getting Function pointer as below in some function.

Function *fn = module->getFunction(fnName);
printf("func Name: %s.\n", fn->getName().str().c_str()); 
.
.
return (intptr_t) fn;

This prints : “func Name: main.” I convert the ptr to int and return it.

Later I am receiving this as a Func Handler in other function

executeFunction(int funcHandle . .) {
.
.
    Function *fn = (Function *) funcHandle;
    printf("func Name: %s\n",fn->getName().str().c_str());

    gv = executionEngine->runFunction(fn, *args);
.
}

Here it prints an empty string and also the executionEngine->runFunction() gives error : Assertion failed! Expression: GV->hasName() && “Global must have name.”

I am using LLVM-8.0. Please let me know if I am missing out something OR if the procedure is wrong

Best regards,

Manoj

Hi Manoj,

Here it prints an empty string and also the executionEngine->runFunction() gives error : Assertion failed! Expression: GV->hasName() && "Global must have name."

Have you checked that it's definitely the same pointer? Obviously the
code you posted isn't real but it does show funcHandle being passed as
an int rather than an intptr, which could easily truncate the value.

Cheers.

Tim.

Yes, I did. I printed out the one I am returning and the one I am receiving. Both are same. This use to work on LLVM-3.3. Now I am trying to port it to 8.0.

Please let me know, I can provide you with more code prior to this, If that would help.

Regards,
Manoj