[LLVMbugs] [Bug 5598] New: Clang generate wrong alignement on packed structure
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Mon Nov 23 08:45:29 PST 2009
http://llvm.org/bugs/show_bug.cgi?id=5598
Summary: Clang generate wrong alignement on packed structure
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: quickslyver at free.fr
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=3854)
--> (http://llvm.org/bugs/attachment.cgi?id=3854)
testcase
this code generate unaligned access with clang:
struct __attribute__((__packed__)) s { char c; unsigned long x; };
void foo (struct s *s) { s->x = 0; }
for example with arm:
clang outputs:
foo:
mov r1, #0
str r1, [r0, #+1]
bx lr
this generate an unaligned access exception.
gcc outputs:
foo:
mov r3, #0
strb r3, [r0, #4]
strb r3, [r0, #1]
strb r3, [r0, #2]
strb r3, [r0, #3]
bx lr
the llvm IR with clang without optimizations:
$ clang-cc -emit-llvm -o - -disable-llvm-optzns test.c
-triple=arm-unknown-unknown
; ModuleID = 'test.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32"
target triple = "arm-unknown-unknown"
%struct.s = type <{ i8, i32 }>
define arm_aapcscc void @foo(%struct.s* %s) nounwind {
entry:
%s.addr = alloca %struct.s* ; <%struct.s**> [#uses=2]
store %struct.s* %s, %struct.s** %s.addr
%tmp = load %struct.s** %s.addr ; <%struct.s*> [#uses=1]
%tmp1 = getelementptr inbounds %struct.s* %tmp, i32 0, i32 1 ; <i32*>
[#uses=1]
store i32 0, i32* %tmp1
ret void
}
According to baldrick the last store should be:
store i32 0, i32* %tmp1, align 1
instead of
store i32 0, i32* %tmp1
--
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