[llvm-dev] Legalized selection DAG differs for the same code and flags

Gleb Popov via llvm-dev llvm-dev at lists.llvm.org
Sun Mar 22 10:50:43 PDT 2020


Hello, LLVM Devs.

I'm compiling following code using my own backend:

int foo() {
    char arr[4];
    arr[0] = 0xAA;
    arr[1] = 0xBB;
    arr[2] = 0xCC;
    arr[3] = 0xDD;
    return *(int*)&arr[0];
}

The memory operation in "return" statement ends up transformed into 4-byte
load in the initial DAG:

load<(dereferenceable load 4 from %ir.7, align 1, addrspace 1)> t31,
FrameIndex:i32<0>, ...

However, at the "Legalized selection DAG" stage things go differently,
depending on the OS I'm running. On Windows this load stay in its previous
form, but on FreeBSD this load gets turned into 1-byte loads for some
reason:

load<(dereferenceable load 1 from %ir.7, addrspace 1)
load<(dereferenceable load 1 from %ir.7 + 1, addrspace 1)
...

Can anyone give me a hint why this happens? Optimization level is the same
and FastISel is used in both cases.

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200322/85b81f73/attachment.html>


More information about the llvm-dev mailing list