[llvm-dev] [MIPS64] Workaround fixup_Mips_32 for getExprOpValue

Leslie Zhai via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 16 03:19:13 PDT 2020


Hi,

Testcase:

$ cat llvm/test/MC/Mips/reloc-directive-bad-n64.s
# RUN: llvm-mc -triple mips64el-unknown-linux < %s -show-encoding \
# RUN: -target-abi=n64 2>&1 | FileCheck %s
.text
.global main
main:
nop
daddiu $t9, $ra, main - . # CHECK: :[[@LINE]]:25: warning: should use 
explicit constraints!
nop
.word main


GNU toolchain:

$ gcc -fPIC -c ./llvm/test/MC/Mips/reloc-directive-bad-n64.s -o t.gnu.o
$ objdump -r t.gnu.o

t.gnu.o: file format elf64-tradlittlemips

RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
000000000000000c R_MIPS_32 main
000000000000000c R_MIPS_NONE *ABS*
000000000000000c R_MIPS_NONE *ABS*


But LLVM toolchain:

$ clang -fPIC -c ./llvm/test/MC/Mips/reloc-directive-bad-n64.s -o t.llvm.o
$ objdump -r t.llvm.o

t.llvm.o: file format elf64-tradlittlemips

RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000000000004 R_MIPS_32 main
0000000000000004 R_MIPS_NONE *ABS*
0000000000000004 R_MIPS_NONE *ABS*
0000000000000004 R_MIPS_32 .text+0x0000000000000004
0000000000000004 R_MIPS_NONE *ABS*+0x0000000000000004
0000000000000004 R_MIPS_NONE *ABS*+0x0000000000000004
000000000000000c R_MIPS_32 main
000000000000000c R_MIPS_NONE *ABS*
000000000000000c R_MIPS_NONE *ABS*


Warning the user and behaviour the same as GNU toolchain after applied 
the workaround patch[1]:

$ ./build/bin/clang -fPIC -c 
./llvm/test/MC/Mips/reloc-directive-bad-n64.s -o t.llvm.o

./llvm/test/MC/Mips/reloc-directive-bad-n64.s:7:25: warning: should use 
explicit constraints!
daddiu $t9, $ra, main - . # CHECK: :[[@LINE]]:25: warning: should use 
explicit constraints!
^
<unknown>:0: warning: should use explicit constraints!

$ objdump -r t.llvm.o

t.llvm.o: file format elf64-tradlittlemips

RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
000000000000000c R_MIPS_32 main
000000000000000c R_MIPS_NONE *ABS*
000000000000000c R_MIPS_NONE *ABS*


Passed make check-llvm-mc-mips:

[100%] Running lit suite /home/loongson/zhaixiang/llvm-project-8.x/llvm/test/MC/Mips
Testing Time: 5.36s
   Expected Passes    : 415
   Expected Failures  : 19
[100%] Built target check-llvm-mc-mips


Please review the patch[1], and give me some advice!

[1] https://reviews.llvm.org/D81919

Thanks,
Leslie Zhai



More information about the llvm-dev mailing list