[LLVMbugs] [Bug 10048] New: llc 2.9 doesn't care of packed attribute to generate code for x86 target
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon May 30 00:46:47 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10048
Summary: llc 2.9 doesn't care of packed attribute to generate
code for x86 target
Product: new-bugs
Version: 2.9
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: babslachem at gmail.com
CC: llvmbugs at cs.uiuc.edu
Hi all,
It seems that there is a regression in LLVM 2.9 vs LLVM 2.8 with respect of
handling packed structure and mis-aligned memory accesses. Here is an example
that illustrate the problem.
Command line used is llc -march=x86 foo.ll -o foo.s
Here is LLVM code sample:
%struct.sType = type < { < 4 x float >, < 4 x float >, < 4 x float > } >
@A = common global < 4 x float > zeroinitializer
@B = common global < 4 x float > zeroinitializer
@C = common global < 4 x float > zeroinitializer
define void @bar(%struct.sType* byval %s) {
L.entry:
%0 = bitcast %struct.sType* %s to < 4 x float >*
%1 = load < 4 x float >* %0, align 1
store < 4 x float > %1, < 4 x float >* @A, align 1
%2 = bitcast %struct.sType* %s to < 4 x float >*
%3 = load < 4 x float >* %2, align 1
store < 4 x float > %3, < 4 x float >* @B, align 1
%4 = bitcast %struct.sType* %s to < 4 x float >*
%5 = load < 4 x float >* %4, align 1
store < 4 x float > %5, < 4 x float >* @C, align 1
ret void
}
define void @foo(%struct.sType* byval %x) {
L.entry:
call void @bar (%struct.sType* byval %x)
ret void
}
struct.sType is declared as a packed structure so it is considered as one byte
aligned. Using LLVM 2.9, I've got following assembly:
...
bar: # @bar
.Leh_func_begin0:
# BB#0: # %L.entry
movaps 4(%esp), %xmm0
movaps %xmm0, A
movaps 4(%esp), %xmm0
movaps %xmm0, B
movaps 4(%esp), %xmm0
movaps %xmm0, C
ret
...
foo: # @foo
.Leh_func_begin1:
# BB#0: # %L.entry
subl $60, %esp
.Ltmp1:
movaps 96(%esp), %xmm0
movaps %xmm0, 32(%esp)
movaps 64(%esp), %xmm0
movaps 80(%esp), %xmm1
movaps %xmm1, 16(%esp)
movaps %xmm0, (%esp)
calll bar
addl $60, %esp
ret
...
As you can see movaps is used in bar to access structure member however
accesses are performed with align 1 attribute. Moreover, in foo a copy is
performed using movaps.
Now if I compile using LLC 2.8, I've got following assembly:
...
bar: # @bar
.Leh_func_begin0:
# BB#0: # %L.entry
movups 4(%esp), %xmm0
movaps %xmm0, A
movups 4(%esp), %xmm0
movaps %xmm0, B
movups 4(%esp), %xmm0
movaps %xmm0, C
ret
...
foo: # @foo
.Leh_func_begin1:
# BB#0: # %L.entry
subl $52, %esp
.Ltmp1:
movsd 96(%esp), %xmm0
movsd %xmm0, 40(%esp)
movsd 88(%esp), %xmm0
movsd %xmm0, 32(%esp)
movsd 80(%esp), %xmm0
movsd %xmm0, 24(%esp)
movsd 72(%esp), %xmm0
movsd %xmm0, 16(%esp)
movsd 56(%esp), %xmm0
movsd 64(%esp), %xmm1
movsd %xmm1, 8(%esp)
movsd %xmm0, (%esp)
call bar
addl $52, %esp
ret
...
Which seems to be correct, since structure accesses in bar are performed using
movups instead of moveaps and struct copy in foo is done use movsd.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list