http://llvm.org/bugs/show_bug.cgi?id=4589
Bill Wendling <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] Status|NEW |RESOLVED Resolution| |WORKSFORME --- Comment #1 from Bill Wendling <[email protected]> 2009-07-19 22:05:45 --- I'm assuming that the original code is this: $ cat t.c #include <inttypes.h> struct dt { int32_t f1; int32_t *f2; }; int32_t **get_el(char *arg) { struct dt *ptr = (struct dt*)arg; return &ptr->f2; } On a 32-bit machine, we get: $ llvm-gcc -o - t.c -S -emit-llvm -Os ; ModuleID = 't.c' target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin9.8" define i32** @get_el(i8* %arg) nounwind readnone optsize { entry: %0 = getelementptr i8* %arg, i32 4 ; <i8*> [#uses=1] %1 = bitcast i8* %0 to i32** ; <i32**> [#uses=1] ret i32** %1 } On a 64-bit machine, we get: $ llvm-gcc -o - t.c -S -emit-llvm -Os -m64 ; ModuleID = 't.c' 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" target triple = "x86_64-apple-darwin9.8" define i32** @get_el(i8* %arg) nounwind readnone optsize { entry: %0 = getelementptr i8* %arg, i64 8 ; <i8*> [#uses=1] %1 = bitcast i8* %0 to i32** ; <i32**> [#uses=1] ret i32** %1 } Both of which are correct. Note, that LLVM code is not 100% platform independent. Because of specifics of languages, the LLVM IR that's generated is much different for, say, 32-bit machines as opposed to 64-bit machines. -- 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. _______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
