[LLVMdev] Inlining bitcast functions...

Relph, Richard Richard.Relph at amd.com
Fri Nov 9 15:25:38 PST 2012


I've got a call instruction:
  call void bitcast (void (%4 addrspace(1)*, <2 x i32>, <4 x float>)* @_Z12write_imagefPU3AS110_image2d_tDv2_iDv4_f to void (%9 addrspace(1)*, <2 x i32>, <4 x float>)*)(%9 addrspace(1)* %dstimg, <2 x i32> %28, <4 x float> %26) nounwind

%4 and %9 are both (stripped) opaque structs.

InlineFunction() does not inline this because call->getCalledFunction() returns 0. call->getCalledValue() returns a cast ConstantExpr. The called Function * is available at (leaving out necessary casts and checks) call->getCalledValue()->getOperand(0). I've tried using call->setCalledFunction(), but that isn't successful either, I'm guessing because the types don't match.

If I don't strip the module, the linker produces an ordinary call to the target function, with no bitcast because both formal arg and passed arg have the same opaque struct name, and InlineFunction() works great.

Is this a "bug" in InlineFunction? Or is there something I am expected to do to the call before calling InlineFunction()? (If yes, what? ;-) It feels like replacing the call, bitcasting the types of the arguments to match the types expected by the callee, is 'unreasonable'.

Note that InlineFunction() also doesn't work if the callee is an alias… and I sure wish that "just worked" as well. ;-) But in that case, calling call->setCalledFunction() is straight forward enough and does work.

Thanks,
Richard




More information about the llvm-dev mailing list