[llvm] [LoongArch][NFC] More tests to ensure branch relocs reserved when relax enabled (PR #153768)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 02:51:01 PDT 2025
https://github.com/zhaoqi5 created https://github.com/llvm/llvm-project/pull/153768
None
>From 3cd34e610639c7507179f661fb0221cc2f295ee0 Mon Sep 17 00:00:00 2001
From: Qi Zhao <zhaoqi01 at loongson.cn>
Date: Fri, 15 Aug 2025 16:19:13 +0800
Subject: [PATCH] [LoongArch][NFC] More tests to ensure branch relocs reserved
when relax enabled
---
.../MC/LoongArch/Relocations/relax-attr.s | 31 ++++++++++++++-----
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/llvm/test/MC/LoongArch/Relocations/relax-attr.s b/llvm/test/MC/LoongArch/Relocations/relax-attr.s
index b1e648d850bb9..e3e9038b755d3 100644
--- a/llvm/test/MC/LoongArch/Relocations/relax-attr.s
+++ b/llvm/test/MC/LoongArch/Relocations/relax-attr.s
@@ -1,19 +1,27 @@
-# RUN: llvm-mc --filetype=obj --triple=loongarch64 %s -o %t
-# RUN: llvm-readobj -r %t | FileCheck %s
-# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax %s -o %t
-# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=CHECKR
+# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=-relax %s -o %t.n
+# RUN: llvm-readobj -r %t.n | FileCheck %s
+# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax %s -o %t.r
+# RUN: llvm-readobj -r %t.r | FileCheck %s --check-prefix=CHECKR
# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.text {
+# CHECK-NEXT: 0x4 R_LARCH_CALL36 foo 0x0
+# CHECK-NEXT: }
# CHECK-NEXT: Section ({{.*}}) .rela.data {
-# CHECK-NEXT: 0x0 R_LARCH_64 .text 0x4
+# CHECK-NEXT: 0x0 R_LARCH_64 .text 0xC
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECKR: Relocations [
# CHECKR-NEXT: Section ({{.*}}) .rela.text {
-# CHECKR-NEXT: 0x8 R_LARCH_B21 .L1 0x0
-# CHECKR-NEXT: 0xC R_LARCH_B16 .L1 0x0
-# CHECKR-NEXT: 0x10 R_LARCH_B26 .L1 0x0
+# CHECKR-NEXT: 0x4 R_LARCH_CALL36 foo 0x0
+# CHECKR-NEXT: 0x4 R_LARCH_RELAX - 0x0
+# CHECKR-NEXT: 0x10 R_LARCH_B21 .L0 0x0
+# CHECKR-NEXT: 0x14 R_LARCH_B21 .L1 0x0
+# CHECKR-NEXT: 0x18 R_LARCH_B16 .L0 0x0
+# CHECKR-NEXT: 0x1C R_LARCH_B16 .L1 0x0
+# CHECKR-NEXT: 0x20 R_LARCH_B26 .L0 0x0
+# CHECKR-NEXT: 0x24 R_LARCH_B26 .L1 0x0
# CHECKR-NEXT: }
# CHECKR-NEXT: Section ({{.*}}) .rela.data {
# CHECKR-NEXT: 0x0 R_LARCH_64 .L1 0x0
@@ -22,10 +30,17 @@
.text
nop
+
+.L0:
+ call36 foo
+
.L1:
nop
+ bnez $a0, .L0
beqz $a0, .L1
+ beq $a0, $a1, .L0
blt $a0, $a1, .L1
+ bl .L0
b .L1
.data
More information about the llvm-commits
mailing list