<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [Mips] backend emits JAL instructions truncating the jump address"
href="https://llvm.org/bugs/show_bug.cgi?id=26129">26129</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Mips] backend emits JAL instructions truncating the jump address
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dean@codeplay.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>