[llvm] [RISCV] Put Large Code Model Constant Pools in .text (PR #151393)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 30 16:48:46 PDT 2025
================
@@ -0,0 +1,102 @@
+; RUN: llc -mtriple=riscv64 -mattr=+f,+zfh -target-abi=lp64f -code-model=large -verify-machineinstrs < %s \
+; RUN: -filetype=obj -o - | llvm-objdump -htr - \
+; RUN: | FileCheck %s -check-prefix=RV64I
+; RUN: llc -mtriple=riscv64 -mattr=+zfinx,+zhinx -target-abi=lp64 -code-model=large -verify-machineinstrs < %s \
+; RUN: -filetype=obj -o - | llvm-objdump -htr - \
+; RUN: | FileCheck %s -check-prefix=RV64I
+
+
+;; This tests that we are lowering large code model constants into `.text`
+;; constant pools, so that accessing them is close to `.text`, rather than
+;; far away in `.data`. The other choices are `.rodata` and `.data.rel.ro`,
+;; both of which may not be close enough to `.text` to be referenced.
+
+; RV64I-LABEL: Sections:
+; RV64I: .text 000000b4
+; RV64I: .rela.text 00000060
+; RV64I: .bss 00000010
+; RV64I: .data 00000002
+
+; RV64I-LABEL: SYMBOL TABLE:
+; RV64I: g O .bss 0000000000000004 G
+; RV64I: g F .text {{[0-9a-f]+}} lower_global
+; RV64I: g O .bss 0000000000000008 addr
+; RV64I: g F .text {{[0-9a-f]+}} lower_blockaddress
+; RV64I: g F .text {{[0-9a-f]+}} lower_blockaddress_displ
+; RV64I: g F .text {{[0-9a-f]+}} lower_constantpool
+; RV64I: w *UND* 0000000000000000 W
+; RV64I: g F .text {{[0-9a-f]+}} lower_extern_weak
+; RV64I: g O .data 0000000000000002 X
+; RV64I: g F .text {{[0-9a-f]+}} lower_global_half
+
+; RV64I-LABEL: RELOCATION RECORDS FOR [.text]:
+; RV64I: R_RISCV_64 G
+; RV64I: R_RISCV_64 addr
+; RV64I: R_RISCV_64 W
+; RV64I: R_RISCV_64 X
----------------
lenary wrote:
These are the relocation records for the symbols, showing they're in the `.text` section.
Maybe these checks aren't resilient enough and I should be using `-NEXT:` to help that.
I can see that the Symbol and Section tables are a bit useless for this test.
That said, I think that we do want to check that the `float 1.000244140625` is also put into `.text`, which won't have a relocation, which is currently difficult.
https://github.com/llvm/llvm-project/pull/151393
More information about the llvm-commits
mailing list