[llvm-bugs] [Bug 26129] New: [Mips] backend emits JAL instructions truncating the jump address

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 13 06:17:01 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26129

            Bug ID: 26129
           Summary: [Mips] backend emits JAL instructions truncating the
                    jump address
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dean at codeplay.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Hi,

when invoking a function through an absolute address, the mips backend emits
the JAL instruction. This is fine only when the address happens to be in the
same "PC-region branch", as the most significant part of the address is based
on the PC. Otherwise truncation happens and the behaviour is incorrect.

Repro, consider this snippet:

define i32 @foo(i32 signext %a, i32 signext %b) #0 {
  %1 = tail call i32 inttoptr (i32 1073741824 to i32 (i32, i32)*)(i32 signext
%a, i32 signext %b) #1
  ret i32 0
}

obtained by clang --target=mipsel--linux-android -O2 -c -emit-llvm -o sample.bc
sample.c 

int foo(int a, int b){
    int (*f) (int, int) = (int (*) (int, int)) 0x40000000; // 1 Gb
    f(a, b); // Jumps to 0!
    return 0;
}

Compile with llc -filetype=obj -mtriple=mipsel--linux-android sample.bc -o
sample.o:
Disassembly of section .text:
foo:
       0:    e8 ff bd 27     addiu    $sp, $sp, -24
       4:    14 00 bf af     sw    $ra, 20($sp)
       8:    00 00 00 0c     jal    0 // boom
       c:    00 00 00 00     nop
      10:    00 00 02 24     addiu    $2, $zero, 0
      14:    14 00 bf 8f     lw    $ra, 20($sp)
      18:    08 00 e0 03     jr    $ra
      1c:    18 00 bd 27     addiu    $sp, $sp, 24

This is a bug being around for some time affecting the JIT capability of LLDB
for Mips.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160113/fd78ce66/attachment.html>


More information about the llvm-bugs mailing list