[llvm] [LoongArch][test] Test 8- and 16-bit subtraction relocations. NFC (PR #222825)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 18:56:20 PDT 2026
https://github.com/wangleiat created https://github.com/llvm/llvm-project/pull/222825
Add MC tests for 1- and 2-byte subtraction relocations enabled by #211754.
>From c410bbf386c8bff3521da6c3b4c450aa0b24ce52 Mon Sep 17 00:00:00 2001
From: wanglei <wanglei at loongson.cn>
Date: Fri, 11 Sep 2026 09:52:09 +0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.7
---
llvm/test/MC/LoongArch/Relocations/sub-expr.s | 26 +++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/llvm/test/MC/LoongArch/Relocations/sub-expr.s b/llvm/test/MC/LoongArch/Relocations/sub-expr.s
index 78305852d1a50..bbc51d5e46714 100644
--- a/llvm/test/MC/LoongArch/Relocations/sub-expr.s
+++ b/llvm/test/MC/LoongArch/Relocations/sub-expr.s
@@ -5,8 +5,6 @@
## Check that subtraction expressions emit R_LARCH_32_PCREL and R_LARCH_64_PCREL relocations.
-## TODO: 1- or 2-byte data relocations are not supported for now.
-
# CHECK: Relocations [
# NORELAX-NEXT: Section ({{.*}}) .rela.sx {
# NORELAX-NEXT: 0x4 R_LARCH_PCALA_HI20 z 0x0
@@ -42,6 +40,22 @@
# CHECK-NEXT: 0x40 R_LARCH_64_PCREL - 0xBEEF
# CHECK-NEXT: 0x48 R_LARCH_32_PCREL extsym 0x8
# CHECK-NEXT: 0x4C R_LARCH_64_PCREL extsym 0xC
+# CHECK-NEXT: 0x54 R_LARCH_ADD16 x 0x0
+# CHECK-NEXT: 0x54 R_LARCH_SUB16 .L0 0x0
+# CHECK-NEXT: 0x56 R_LARCH_ADD16 y 0x0
+# CHECK-NEXT: 0x56 R_LARCH_SUB16 .L0 0x0
+# CHECK-NEXT: 0x58 R_LARCH_ADD8 x 0x0
+# CHECK-NEXT: 0x58 R_LARCH_SUB8 .L0 0x0
+# CHECK-NEXT: 0x59 R_LARCH_ADD8 y 0x0
+# CHECK-NEXT: 0x59 R_LARCH_SUB8 .L0 0x0
+# CHECK-NEXT: 0x5A R_LARCH_ADD16 x 0x0
+# CHECK-NEXT: 0x5A R_LARCH_SUB16 y 0x0
+# CHECK-NEXT: 0x5C R_LARCH_ADD16 y 0x0
+# CHECK-NEXT: 0x5C R_LARCH_SUB16 x 0x0
+# CHECK-NEXT: 0x5E R_LARCH_ADD8 x 0x0
+# CHECK-NEXT: 0x5E R_LARCH_SUB8 y 0x0
+# CHECK-NEXT: 0x5F R_LARCH_ADD8 y 0x0
+# CHECK-NEXT: 0x5F R_LARCH_SUB8 x 0x0
# CHECK-NEXT: }
# NORELAX-NEXT: Section ({{.*}}) .rela.sy {
@@ -80,6 +94,14 @@ la.pcrel $a0, z
.8byte 0xbeef-1b
.4byte extsym-1b
.8byte extsym-1b
+.2byte x-.
+.2byte y-.
+.byte x-.
+.byte y-.
+.2byte x-y
+.2byte y-x
+.byte x-y
+.byte y-x
.section .sy,"ax"
call36 foo
More information about the llvm-commits
mailing list