[LLVMbugs] [Bug 2920] New: JIT uses rip-relative addressing for absolute addresses.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Oct 18 21:28:50 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2920

           Summary: JIT uses rip-relative addressing for absolute addresses.
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: ofv at wanadoo.es
                CC: llvmbugs at cs.uiuc.edu, ofv at wanadoo.es


This is for x86-64. The problem is not present on x86.

This llvm code uses intttoptr for reading and writing some memory addresses:

define i32 @main() {
        %1 = alloca i1          ; <i1*> [#uses=2]
        %2 = alloca i32         ; <i32*> [#uses=2]
        %3 = inttoptr i64 17349872 to i1*               ; <i1*> [#uses=1]
        %4 = load i1* %3                ; <i1> [#uses=1]
        br i1 %4, label %9, label %5

; <label>:5             ; preds = %0
        %6 = inttoptr i64 17349872 to i1*               ; <i1*> [#uses=1]
        store i1 true, i1* %1
        %7 = load i1* %1                ; <i1> [#uses=1]
        store i1 %7, i1* %6
        %8 = inttoptr i64 17349876 to i32*              ; <i32*> [#uses=1]
        store i32 10, i32* %8
        br label %9

; <label>:9             ; preds = %5, %0
        %10 = inttoptr i64 17349876 to i32*             ; <i32*> [#uses=1]
        %11 = load i32* %10             ; <i32> [#uses=1]
        store i32 %11, i32* %2
        %12 = load i32* %2              ; <i32> [#uses=1]
        ret i32 %12
}

the JIT generates this machine code (taken from a gdb session):

0x00007f15bb92e010:     sub    $0x8,%rsp                     
0x00007f15bb92e014:     mov    0x108bcf0(%rip),%al        # 0x7f15bc9b9d0a
0x00007f15bb92e01a:     test   %al,%al
0x00007f15bb92e01c:     jne    0x7f15bb92e038
0x00007f15bb92e022:     movb   $0x1,0x7(%rsp)
0x00007f15bb92e027:     movb   $0x1,0x108bcf0(%rip)        # 0x7f15bc9b9d1e
0x00007f15bb92e02e:     movl   $0xa,0x108bcf4(%rip)        # 0x7f15bc9b9d2c
<getutline_r+12>
0x00007f15bb92e038:     mov    0x108bcf4(%rip),%eax        # 0x7f15bc9b9d32
<getutline_r+18>
0x00007f15bb92e03e:     mov    %eax,(%rsp)
0x00007f15bb92e041:     add    $0x8,%rsp
0x00007f15bb92e045:     retq

As you can see, rip-relative addressing is used combined with the absolute
addresses.

No optimizations applied. I can't reproduce the problem with llc. The code it
generates uses absolute addresses.


-- 
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