[PATCH] D105760: [AMDGPU] Handle s_branch to another section.
Hafiz Abid Qadeer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 13 03:10:06 PDT 2021
abidh updated this revision to Diff 358213.
abidh added a comment.
Herald added subscribers: rupprecht, MaskRay, emaste.
Herald added a reviewer: jhenderson.
Rebase. One of the test file has moved in the repo so updated the patch accordingly.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105760/new/
https://reviews.llvm.org/D105760
Files:
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
llvm/test/MC/AMDGPU/reloc.s
llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-amdgpu.test
Index: llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-amdgpu.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-amdgpu.test
+++ llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-amdgpu.test
@@ -18,6 +18,7 @@
# CHECK-NEXT: 0x0 R_AMDGPU_REL32_LO - 0x0
# CHECK-NEXT: 0x0 R_AMDGPU_REL32_HI - 0x0
# CHECK-NEXT: 0x0 R_AMDGPU_RELATIVE64 - 0x0
+# CHECK-NEXT: 0x0 R_AMDGPU_REL16 - 0x0
# CHECK-NEXT: }
!ELF
@@ -43,3 +44,4 @@
- Type: R_AMDGPU_REL32_LO
- Type: R_AMDGPU_REL32_HI
- Type: R_AMDGPU_RELATIVE64
+ - Type: R_AMDGPU_REL16
Index: llvm/test/MC/AMDGPU/reloc.s
===================================================================
--- llvm/test/MC/AMDGPU/reloc.s
+++ llvm/test/MC/AMDGPU/reloc.s
@@ -9,6 +9,7 @@
// CHECK: R_AMDGPU_GOTPCREL32_HI global_var2
// CHECK: R_AMDGPU_REL32_LO global_var3
// CHECK: R_AMDGPU_REL32_HI global_var4
+// CHECK: R_AMDGPU_REL16 .text.unlikely
// CHECK: R_AMDGPU_ABS32 var
// CHECK: }
// CHECK: .rel.data {
@@ -25,6 +26,11 @@
s_mov_b32 s4, global_var2 at gotpcrel32@hi
s_mov_b32 s5, global_var3 at rel32@lo
s_mov_b32 s6, global_var4 at rel32@hi
+ s_branch cold
+
+ .section .text.unlikely
+cold:
+ s_add_i32 s15, s15, 1
.globl global_var0
.globl global_var1
Index: llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
+++ llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
@@ -80,9 +80,12 @@
const auto *SymA = Target.getSymA();
assert(SymA);
- Ctx.reportError(Fixup.getLoc(),
- Twine("undefined label '") + SymA->getSymbol().getName() + "'");
- return ELF::R_AMDGPU_NONE;
+ if (SymA->getSymbol().isUndefined()) {
+ Ctx.reportError(Fixup.getLoc(), Twine("undefined label '") +
+ SymA->getSymbol().getName() + "'");
+ return ELF::R_AMDGPU_NONE;
+ }
+ return ELF::R_AMDGPU_REL16;
}
llvm_unreachable("unhandled relocation type");
Index: llvm/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
===================================================================
--- llvm/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
+++ llvm/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
@@ -15,3 +15,4 @@
ELF_RELOC(R_AMDGPU_REL32_LO, 10)
ELF_RELOC(R_AMDGPU_REL32_HI, 11)
ELF_RELOC(R_AMDGPU_RELATIVE64, 13)
+ELF_RELOC(R_AMDGPU_REL16, 14)
Index: llvm/docs/AMDGPUUsage.rst
===================================================================
--- llvm/docs/AMDGPUUsage.rst
+++ llvm/docs/AMDGPUUsage.rst
@@ -1574,6 +1574,7 @@
``R_AMDGPU_REL32_HI`` Static 11 ``word32`` (S + A - P) >> 32
*reserved* 12
``R_AMDGPU_RELATIVE64`` Dynamic 13 ``word64`` B + A
+ ``R_AMDGPU_REL16`` Static 14 ``word16`` ((S + A - P) - 4) / 4
========================== ======= ===== ========== ==============================
``R_AMDGPU_ABS32_LO`` and ``R_AMDGPU_ABS32_HI`` are only supported by
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105760.358213.patch
Type: text/x-patch
Size: 3196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210713/93e92ff4/attachment.bin>
More information about the llvm-commits
mailing list