[LLVMdev] PROPOSAL: IR representation of detailed struct assignment information

Krzysztof Parzyszek kparzysz at codeaurora.org
Thu Aug 30 13:34:34 PDT 2012


On 8/22/2012 3:15 PM, Dan Gohman wrote:
> Here's an example showing the basic problem:
>
> struct bar {
>    char x;
>    float y;
>    double z;
> };
> void copy_bar(struct bar *a, struct bar *b) {
>    *a = *b;
> }
>
> We get this IR:
>
>    call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* %1, i64 16, i32 8, i1 false)
>
> This works, but it doesn't retain the information that the bytes between fields
> x and y don't really need to be copied, and it doesn't inform the optimizer
> that there are three fields with TBAA-relevant types being copied.
>
> The solution I propose here is to have front-ends describe the copy using
> metadata. For example:

Why not simply have something like this?

%1 = load bar* %b
store %1, bar* %a

-K


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation




More information about the llvm-dev mailing list