<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 11, 2011, at 4:50 PMPST, Yuri wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>When I try running one llvm function in JIT without optimization I get <br>SEGV. Looking at assembly (below) I see that the local value <br>0xffffffffffffffe0(%rbp) is used without being ever initialized (see my <br>comment in asm).<br>Same code on i386 works fine, with and w/out optimization.<br><br>My guess is that this is a bug in LLVM.<br><br>Yuri<br></div></blockquote><div><br></div><div>The unitialized load is there in the llc version as well (16(%rsp)).  It looks like it's been erroneously moved ahead of the spill to that slot.  Please file a PR.  (I can see this on Darwin with llc -O0).</div><br><blockquote type="cite"><div>--- llvm ---<br>%struct.mystruct = type { i32, i8, i8, i8, i8 }<br><br>define i32 @xfunc(%struct.mystruct* %a1, %struct.mystruct* %a2) {<br>   br label %lbl1<br>lbl1:<br>   %v1 = call i32 @yfunc(i32 1, i32 0, i32 0)<br>   %v2 = bitcast %struct.mystruct* %a1 to i8*<br>   %v3 = getelementptr i8* %v2, i32 %v1<br>   %v4 = bitcast i8* %v3 to i32*<br>   %v5 = load i32* %v4<br>   %v6 = call i32 @yfunc(i32 1, i32 4, i32 0)<br>   %v7 = bitcast %struct.mystruct* %a2 to i8*<br>   %v8 = getelementptr i8* %v7, i32 %v6<br>   %v9 = bitcast i8* %v8 to i32*<br>   %v10 = load i32* %v9<br>   %op.dual.plus.uint32 = add i32 %v5, %v10<br>   br label %lbl2<br>lbl2:<br>   ret i32 %op.dual.plus.uint32<br>}<br><br>declare i32 @yfunc(i32, i32, i32)<br><br><br>--- assembly obtained in gdb for JITted code ---<br>     0x0000000800989bf0:     push   %rbp<br>     0x0000000800989bf1:     mov    %rsp,%rbp<br>     0x0000000800989bf4:     sub    $0x30,%rsp<br>     0x0000000800989bf8:     mov    %rdi,0xfffffffffffffff8(%rbp)<br>     0x0000000800989bfc:     mov    %rsi,0xfffffffffffffff0(%rbp)<br>     0x0000000800989c00:     mov    $0x1,%edi<br>     0x0000000800989c05:     xor    %eax,%eax<br>     0x0000000800989c07:     mov    $0x800a09060,%rcx<br>     0x0000000800989c11:     mov    %eax,%esi<br>     0x0000000800989c13:     mov    %eax,%edx<br>     0x0000000800989c15:     callq  *%ecx<br>     0x0000000800989c17:     movslq %eax,%rcx<br>     0x0000000800989c1a:     mov    0xfffffffffffffff8(%rbp),%r8<br>     0x0000000800989c1e:     mov    (%r8,%rcx,1),%eax<br>     0x0000000800989c22:     mov    $0x1,%edi<br>     0x0000000800989c27:     mov    $0x4,%esi<br>     0x0000000800989c2c:     xor    %edx,%edx<br>     0x0000000800989c2e:     mov    $0x800a09060,%rcx<br>     0x0000000800989c38:     mov    %eax,0xffffffffffffffec(%rbp)<br>     0x0000000800989c3b:     callq  *%ecx<br>     0x0000000800989c3d:     mov    0xffffffffffffffec(%rbp),%edx<br>     0x0000000800989c40:     mov    0xfffffffffffffff0(%rbp),%rcx<br>     0x0000000800989c44:     mov    0xffffffffffffffe0(%rbp),%r8  ; XXX <br>use of uninitialized value<br>     0x0000000800989c48:     add    (%rcx,%r8,1),%edx             ; SEGV<br>     0x0000000800989c4c:     movslq %eax,%r8<br>     0x0000000800989c4f:     mov    %edx,0xffffffffffffffdc(%rbp)<br>     0x0000000800989c52:     mov    %r8,0xffffffffffffffe0(%rbp)<br>     0x0000000800989c56:     mov    0xffffffffffffffdc(%rbp),%eax<br>     0x0000000800989c59:     add    $0x30,%rsp<br>     0x0000000800989c5d:     pop    %rbp<br>     0x0000000800989c5e:     retq<br><br>--- result after running llvm-as and llc on the same function ---<br>         subq    $56, %rsp<br>.Ltmp0:<br>         movq    %rdi, 48(%rsp)          # 8-byte Spill<br>         movq    %rsi, 40(%rsp)          # 8-byte Spill<br># BB#1:                                 # %lbl1<br>         movl    $1, %eax<br>         movl    $4, %esi<br>         movl    $0, %ecx<br>         movl    %eax, %edi<br>         movl    %esi, 36(%rsp)          # 4-byte Spill<br>         movl    %ecx, %esi<br>         movl    %ecx, %edx<br>         movl    %eax, 32(%rsp)          # 4-byte Spill<br>         movl    %ecx, 28(%rsp)          # 4-byte Spill<br>         callq   yfunc<br>         movslq  %eax, %r8<br>         movq    48(%rsp), %r9           # 8-byte Reload<br>         movl    (%r9,%r8), %eax<br>         movl    32(%rsp), %edi          # 4-byte Reload<br>         movl    36(%rsp), %esi          # 4-byte Reload<br>         movl    28(%rsp), %edx          # 4-byte Reload<br>         movl    %eax, 24(%rsp)          # 4-byte Spill<br>         callq   yfunc<br>         movl    24(%rsp), %ecx          # 4-byte Reload<br>         movq    40(%rsp), %r8           # 8-byte Reload<br>         movq    16(%rsp), %r9           # 8-byte Reload<br>         addl    (%r8,%r9), %ecx<br>         movslq  %eax, %r9<br>         movl    %ecx, 12(%rsp)          # 4-byte Spill<br>         movq    %r9, 16(%rsp)           # 8-byte Spill<br># BB#2:                                 # %lbl2<br>         movl    12(%rsp), %eax          # 4-byte Reload<br>         addq    $56, %rsp<br>         ret<br><br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></body></html>