llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-hexagon @llvm/pr-subscribers-lld Author: None (llvmbot) <details> <summary>Changes</summary> Backport 9105d9c24949d8cf9b740cb874027351e7230e70 Requested by: @<!-- -->androm3da --- Full diff: https://github.com/llvm/llvm-project/pull/184646.diff 2 Files Affected: - (modified) lld/ELF/Arch/Hexagon.cpp (+2) - (added) lld/test/ELF/hexagon-duplex-relocs.s (+40) ``````````diff diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp index d6495e12668d7..09dee664589b2 100644 --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -217,6 +217,8 @@ static uint32_t findMaskR6(Ctx &ctx, uint32_t insn) { } static uint32_t findMaskR8(uint32_t insn) { + if (isDuplex(insn)) + return 0x03f00000; if ((0xff000000 & insn) == 0xde000000) return 0x00e020e8; if ((0xff000000 & insn) == 0x3c000000) diff --git a/lld/test/ELF/hexagon-duplex-relocs.s b/lld/test/ELF/hexagon-duplex-relocs.s new file mode 100644 index 0000000000000..8d7705517cb34 --- /dev/null +++ b/lld/test/ELF/hexagon-duplex-relocs.s @@ -0,0 +1,40 @@ +# REQUIRES: hexagon +# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o +# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=RELOC %s +# RUN: ld.lld %t.o -o %t +# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck %s + +## Test R_HEX_8_X relocation on duplex instructions (SA1_addi). +## findMaskR8() must use the duplex mask 0x03f00000 when parse bits [15:14] +## are zero. Pair a non-duplex form with a duplex form using the same symbol +## and verify both resolve to the same address. +## +## Duplex paths for the other findMask functions are already covered: +## findMaskR6: hexagon.s (R_HEX_6_X duplex) +## findMaskR11: hexagon-tls-ie.s (R_HEX_TPREL_11_X duplex) +## findMaskR16: hexagon-shared.s (R_HEX_GOT_16_X duplex) + + .globl _start, target + .type _start, @function +_start: + +# Non-duplex reference (R_HEX_16_X, via findMaskR16) +# RELOC: R_HEX_32_6_X target 0x0 +# RELOC-NEXT: R_HEX_16_X target 0x0 +# CHECK: { immext(# +# CHECK-NEXT: r0 = add(r0,##[[ADDR:0x[0-9a-f]+]]) } + r0 = add(r0, ##target) + +# Duplex form (R_HEX_8_X, via findMaskR8) +# RELOC-NEXT: R_HEX_32_6_X target 0x0 +# RELOC-NEXT: R_HEX_8_X target 0x0 +# CHECK-NEXT: { immext(# +# CHECK-NEXT: r0 = add(r0,##[[ADDR]]); memw(r1+#0x0) = r2 } + { r0 = add(r0, ##target) + memw(r1+#0) = r2 } + + jumpr r31 + +target: + nop + jumpr r31 `````````` </details> https://github.com/llvm/llvm-project/pull/184646 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
