I generated the llvm code for the following simple function (based on clang/llvm 2.8) using:<br>clang -S -O2 -emit-llvm memory_unalignedint.c<br><br>int f(char *ptr)<br>{<br> int r = *((int*)(ptr+2));<br> return r;<br>}<br>
<br>And I was wondering why the alignment for the load is set to 4 although the load is not aligned ? (%tmp1 = load i32* %0, align 4)<br>Thank you,<br><br>Damien<br><br><br>target datalayout = "e-p:64:64:64-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-s0:64:64-f80:128:128-n8:16:32:64"<br>
target triple = "x86_64-unknown-linux-gnu"<br><br>define i32 @f(i8* nocapture %ptr) nounwind readonly {<br>entry:<br> %add.ptr = getelementptr inbounds i8* %ptr, i64 2<br> %0 = bitcast i8* %add.ptr to i32*<br>
%tmp1 = load i32* %0, align 4<br> ret i32 %tmp1<br>}<br><br>