[PATCH] D60748: Fix i386 struct and union parameter alignment
Wei Xiao via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 15 19:35:45 PDT 2019
wxiao3 created this revision.
wxiao3 added reviewers: annita.zhang, LuoYuanke, smaslov, hjl.tools, RKSimon, rnk, andreadb.
wxiao3 added a project: clang.
Herald added a subscriber: cfe-commits.
According to i386 System V ABI 2.1: Structures and unions assume the alignment
of their most strictly aligned component. But current implementation always
takes them as 4-byte aligned which will result in incorrect code, e.g:
1 #include <immintrin.h>
2 typedef union {
3 int d[4];
4 __m128 m;
5 } M128;
6 extern void foo(int, ...);
7 void test(void)
8 {
9 M128 a;
10 foo(1, a);
11 foo(1, a.m);
12 }
The first call (line 10) takes the second arg as 4-byte aligned while the
second call (line 11) takes the second arg as 16-byte aligned. There is
oxymoron for the alignment of the 2 calls because they should be the same.
This patch fixes the bug by following i386 System V ABI.
Repository:
rC Clang
https://reviews.llvm.org/D60748
Files:
lib/CodeGen/TargetInfo.cpp
test/CodeGen/x86_32-align-linux.c
test/CodeGen/x86_32-arguments-linux.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60748.195292.patch
Type: text/x-patch
Size: 4092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190416/355c6312/attachment-0001.bin>
More information about the cfe-commits
mailing list