Copy Elision code produces incorrect code
Calling conventions never cease to surprise me. Why would one violate such an assumption. =P Patches welcome, I do not have time to work on this in the near future.
Copy Elision code produces incorrect code in some cases.
For example
llc -mtriple=i386-unknown < tmp.ll
define <4 x i8> @test1(<4 x i8> %b) { %b.addr = alloca <4 x i8>, align 4 store <4 x i8> %b, <4 x i8>* %b.addr, align 4 %b.val = load <4 x i8>, <4 x i8>* %b.addr, align 4 ret <4 x i8> %b.val }
Generated code assume (incorrect) that the argument is packed in memory. movl 4(%esp), %eax movl 8(%esp), %ecx movl %ecx, (%eax) retl $4
For the reference
define <4 x i8> @test2(<4 x i8> %b) { ret <4 x i8> %b }
movl 4(%esp), %eax movb 8(%esp), %cl movb 12(%esp), %dl movb 16(%esp), %ch movb 20(%esp), %dh movb %dh, 3(%eax) movb %ch, 2(%eax) movb %dl, 1(%eax) movb %cl, (%eax) retl $4