[LLVMbugs] [Bug 603] NEW: [llvm-gcc] CFE does not lay out structures correctly when funny darwin rules apply
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Thu Jul 21 16:30:51 PDT 2005
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=603
Summary: [llvm-gcc] CFE does not lay out structures correctly
when funny darwin rules apply
Product: tools
Version: 1.0
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P2
Component: llvm-gcc
AssignedTo: sabre at nondot.org
ReportedBy: sabre at nondot.org
CC: natebegeman at mac.com
llvm-gcc is currently miscompiling the following code:
----
typedef union {
int A; long long L;
} X;
typedef struct {
X x;
int B;
} Y;
Y* foo(Y *l) { return l+1; }
---
In this case, the X union should have 8-byte alignment due to funny darwin rules (even though long
long's are normally only 4-byte aligned). When X is the first element of a struct, that increases its
alignment requirements to 8-bytes, which increases the size of Y from 12 to 16 bytes.
llvm-gcc currently compiles this to:
---
%struct.Y = type { %union.X, int }
%union.X = type { long }
%struct.Y* %_Z3fooP1Y(%struct.Y* %l) {
%tmp.2 = getelementptr %struct.Y* %l, int 1 ; <%struct.Y*> [#uses=1]
ret %struct.Y* %tmp.2
}
---
... which is incorrect: Y is only 12 bytes in size. This causes us to emit the following PPC code:
__Z3fooP1Y:
addi r3, r3, 12
blr
... instead of the correct code:
__Z3fooP1Y:
addi r3, r3, 16
blr
This problem was reduced from Bug 449.
-Chris
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list