llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-elf

Author: None (llvmbot)

<details>
<summary>Changes</summary>

Backport 62d018b87a161bb2797c1ed03a482ffcdc8b162c

Requested by: @<!-- -->androm3da

---
Full diff: https://github.com/llvm/llvm-project/pull/180610.diff


2 Files Affected:

- (modified) lld/ELF/Arch/Hexagon.cpp (+2) 
- (modified) lld/test/ELF/hexagon-tls-ie.s (+35-1) 


``````````diff
diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp
index 9b33e78731c97..d6495e12668d7 100644
--- a/lld/ELF/Arch/Hexagon.cpp
+++ b/lld/ELF/Arch/Hexagon.cpp
@@ -225,6 +225,8 @@ static uint32_t findMaskR8(uint32_t insn) {
 }
 
 static uint32_t findMaskR11(uint32_t insn) {
+  if (isDuplex(insn))
+    return 0x03f00000;
   if ((0xff000000 & insn) == 0xa1000000)
     return 0x060020ff;
   return 0x06003fe0;
diff --git a/lld/test/ELF/hexagon-tls-ie.s b/lld/test/ELF/hexagon-tls-ie.s
index ea05279473116..158f4d2ca8981 100644
--- a/lld/test/ELF/hexagon-tls-ie.s
+++ b/lld/test/ELF/hexagon-tls-ie.s
@@ -1,5 +1,6 @@
 # REQUIRES: hexagon
-# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o
+# RUN: rm -rf %t.dir && split-file %s %t.dir
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %t.dir/main.s -o %t.o
 # RUN: llvm-readobj -r %t.o | FileCheck -check-prefix=RELOC %s
 # RUN: ld.lld %t.o -o %t
 ## shared needs -z notext because of the R_HEX_IE_16/32_X(R_GOT) static
@@ -11,6 +12,16 @@
 # RUN: FileCheck -check-prefix=SHARED %s
 # RUN: llvm-readobj -r  %t.so | FileCheck -check-prefix=RELA %s
 
+## Test R_HEX_TPREL_11_X on duplex instructions with large TLS offset.
+## TPREL relocations cannot be used with -shared, so test separately.
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf \
+# RUN:   %t.dir/tprel-duplex.s -o %t-duplex.o
+# RUN: llvm-readobj -r %t-duplex.o | FileCheck -check-prefix=RELOC-DUPLEX %s
+# RUN: ld.lld %t-duplex.o -o %t-duplex
+# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t-duplex | \
+# RUN:   FileCheck -check-prefix=CHECK-DUPLEX %s
+
+#--- main.s
        .globl  _start
        .type   _start, @function
 _start:
@@ -76,3 +87,26 @@ c:
 .globl  d
 d:
 .word 4
+
+#--- tprel-duplex.s
+## Test R_HEX_TPREL_11_X on duplex instructions with large TLS offset.
+## This exercises the isDuplex() path in findMaskR11().
+       .globl  _start
+       .type   _start, @function
+_start:
+# RELOC-DUPLEX:      0x0 R_HEX_TPREL_32_6_X e 0x0
+# RELOC-DUPLEX-NEXT: 0x4 R_HEX_TPREL_11_X e 0x0
+# CHECK-DUPLEX:      { immext(#0xfffbffc0)
+# CHECK-DUPLEX-NEXT:   r2 = add(r2,##-0x40003); memw(r3+#0x0) = #0 }
+    {
+        r2 = add(r2,##e@TPREL)
+        memw(r3+#0) = #0
+    }
+    jumpr r31
+
+.section .tbss,"awT",@nobits
+.p2align 2
+.space 0xd
+.globl e
+e:
+.space 0x40000

``````````

</details>


https://github.com/llvm/llvm-project/pull/180610
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to