[LLVMdev] Inlining bitcast functions...

Eli Friedman eli.friedman at gmail.com
Fri Nov 9 15:33:05 PST 2012


On Fri, Nov 9, 2012 at 3:25 PM, Relph, Richard <Richard.Relph at amd.com> wrote:
> 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.

This sounds like a bug in the IR linker (which is normally pretty good
at unifying struct types).

> Is this a "bug" in InlineFunction? Or is there something I am expected to do to the call before calling InlineFunction()? (If yes, what? ;-)

instcombine knows how to fix this.

-Eli




More information about the llvm-dev mailing list