[llvm] f3bd1b9 - [SystemZ][z/OS] Use the text section for jump tables (#179793)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 5 05:18:21 PST 2026
Author: Kai Nacke
Date: 2026-02-05T08:18:17-05:00
New Revision: f3bd1b9526c29dbd17186836e6161a88589dcbb7
URL: https://github.com/llvm/llvm-project/commit/f3bd1b9526c29dbd17186836e6161a88589dcbb7
DIFF: https://github.com/llvm/llvm-project/commit/f3bd1b9526c29dbd17186836e6161a88589dcbb7.diff
LOG: [SystemZ][z/OS] Use the text section for jump tables (#179793)
Jump tables are read only data, and the text section is the best choice
for them.
Added:
llvm/test/CodeGen/SystemZ/zos-jumptable.ll
Modified:
llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index f5f5f09e5a4b0..8cb1609153045 100644
--- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -325,6 +325,8 @@ class TargetLoweringObjectFileGOFF : public TargetLoweringObjectFile {
void getModuleMetadata(Module &M) override;
+ bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
+ const Function &F) const override;
MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
const TargetMachine &TM) const override;
MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index f8f549f25f5a7..47ee485a2cca9 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2810,6 +2810,11 @@ void TargetLoweringObjectFileGOFF::getModuleMetadata(Module &M) {
ADAPR->setBeginSymbol(ADASym);
}
+bool TargetLoweringObjectFileGOFF::shouldPutJumpTableInFunctionSection(
+ bool UsesLabelDifference, const Function &F) const {
+ return true;
+}
+
MCSection *TargetLoweringObjectFileGOFF::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
return SelectSectionForGlobal(GO, Kind, TM);
diff --git a/llvm/test/CodeGen/SystemZ/zos-jumptable.ll b/llvm/test/CodeGen/SystemZ/zos-jumptable.ll
new file mode 100644
index 0000000000000..4b11759874088
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/zos-jumptable.ll
@@ -0,0 +1,34 @@
+; RUN: llc -mtriple s390x-zos -emit-gnuas-syntax-on-zos=0 < %s | FileCheck %s
+
+define void @jumptable(i32 signext %in, ptr %out) {
+; CHECK-LABEL: jumptable DS 0H
+; CHECK: larl 3,L#JTI0_0
+; CHECK: L#func_end1 DS 0H
+; CHECK: L#JTI0_0 DS 0H
+; CHECK: DC AD(L#BB0_2)
+; CHECK: DC AD(L#BB0_5)
+; CHECK: DC AD(L#BB0_3)
+; CHECK: DC AD(L#BB0_4)
+
+entry:
+ switch i32 %in, label %exit [
+ i32 1, label %bb1
+ i32 2, label %bb2
+ i32 3, label %bb3
+ i32 4, label %bb4
+ ]
+bb1:
+ store i32 4, ptr %out
+ br label %exit
+bb2:
+ store i32 3, ptr %out
+ br label %exit
+bb3:
+ store i32 2, ptr %out
+ br label %exit
+bb4:
+ store i32 1, ptr %out
+ br label %exit
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list