The third argument of the OpenMP runtime call __kmpc_fork_call is the outlined function resulting from omp parallel directive; this is of type kmpc_micro. I can get this argument as an LLVM value by using (callInst->getArgOperand…), but once I get this value, i am stuck in knowing its class type. An example of this value can be:
void (i32*, i32*, …)* bitcast (void (i32*, i32*, double**, double**, double**, double**, double**, double*, i32*, double*, double*, i32**, double**, i32**, double*)* @.omp_outlined…45 to void (i32*, i32*, …)*)
I tried bitcast instruction, instruction, function call and did not work.
Is there a clean way (other than manipulating strings) to get the defintion of the outlined function from the call __kmpc_fork_call? By clean I mean where I can manipulate IR and LLVM methods (and not compare strings).
Thanks in advance for any help,
Adding openmp-dev list.
30 июля 2016 г., в 5:09, Dounia Khaldi via llvm-dev <email@example.com> написал(а):
I work on the NVPTX OpenMP codegen support and we don’t use fork() but I can point you to where you may be able to find this information.
In the clang sources, have a look at: lib/CodeGen/CGOpenMPRuntime.cpp and the function createRuntimeFunction where the call to __kmpc_fork_call() is created. The type of the outlined function can be had through the function: getKmpc_MicroPointerTy(). Is this what you are looking for?
Thanks Arpith for this pointer but it did not contain what I was looking for.
However, I solved my issue by finding that the BitCastInst used when outlining OpenMP parallel region offers a method for retrieving the original value within the bitcast via stripPointerCasts().
So what I did to retrieve omp_outlined…45 is:
//bitcast is the third argument of __kmpc_fork_call
Value *vcall = callInst->getArgOperand(2);
//This will return the outlined function in __kmpc_fork_call
Function *f = dyn_cast(vcall->stripPointerCasts());
f->getName returns “.omp_outlined…45” So this worked.