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: unassignedb...@nondot.org Reporter: d...@codeplay.com CC: llvm-bugs@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs