From f401069962f9c65b23467eda3ba990b2afbaad27 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 17 Oct 2024 20:17:56 +0200 Subject: [PATCH] s390x: Hard code the link register for ElfTlsGetOffset (#9361) * s390x: Hard code the link register for ElfTlsGetOffset The ElfTlsGetOffset pseudo-instruction already hard codes the rest of the abi anyway and if another abi is ever needed, adding another pseudo-instruction or an enum field to the existing one would likely be necessary anyway. * Remove a couple of dead_code allows --- cranelift/bforest/src/node.rs | 1 - cranelift/codegen/src/isa/riscv64/inst/imms.rs | 1 - cranelift/codegen/src/isa/s390x/inst.isle | 1 - cranelift/codegen/src/isa/s390x/inst/emit.rs | 6 ++---- cranelift/codegen/src/isa/s390x/inst/mod.rs | 12 +++--------- cranelift/codegen/src/isa/s390x/lower.isle | 2 +- 6 files changed, 6 insertions(+), 17 deletions(-) diff --git a/cranelift/bforest/src/node.rs b/cranelift/bforest/src/node.rs index 443c112ed888..848c657e82c8 100644 --- a/cranelift/bforest/src/node.rs +++ b/cranelift/bforest/src/node.rs @@ -13,7 +13,6 @@ use core::fmt; /// /// An inner node contains at least M/2 node references unless it is the right-most node at its /// level. A leaf node contains at least N/2 keys unless it is the right-most leaf. -#[allow(dead_code)] // workaround for https://github.com/rust-lang/rust/issues/64362 pub(super) enum NodeData { Inner { /// The number of keys in this node. diff --git a/cranelift/codegen/src/isa/riscv64/inst/imms.rs b/cranelift/codegen/src/isa/riscv64/inst/imms.rs index 28f279154eaa..8f53506ce049 100644 --- a/cranelift/codegen/src/isa/riscv64/inst/imms.rs +++ b/cranelift/codegen/src/isa/riscv64/inst/imms.rs @@ -2,7 +2,6 @@ // Some variants are never constructed, but we still want them as options in the future. use super::Inst; -#[allow(dead_code)] use std::fmt::{Debug, Display, Formatter, Result}; #[derive(Copy, Clone, Debug, Default)] diff --git a/cranelift/codegen/src/isa/s390x/inst.isle b/cranelift/codegen/src/isa/s390x/inst.isle index 342f5846fddb..173cb7bd28a5 100644 --- a/cranelift/codegen/src/isa/s390x/inst.isle +++ b/cranelift/codegen/src/isa/s390x/inst.isle @@ -1020,7 +1020,6 @@ (tls_offset WritableReg) (got Reg) (got_offset Reg) - (link WritableReg) (symbol BoxSymbolReloc)) )) diff --git a/cranelift/codegen/src/isa/s390x/inst/emit.rs b/cranelift/codegen/src/isa/s390x/inst/emit.rs index eb42cc15a9ab..24bd4cb0fcfc 100644 --- a/cranelift/codegen/src/isa/s390x/inst/emit.rs +++ b/cranelift/codegen/src/isa/s390x/inst/emit.rs @@ -3250,9 +3250,7 @@ impl Inst { put(sink, &enc_rr(opcode, gpr(15), rn)); sink.add_call_site(); } - &Inst::ElfTlsGetOffset { - ref symbol, link, .. - } => { + &Inst::ElfTlsGetOffset { ref symbol, .. } => { let opcode = 0xc05; // BRASL // Add relocation for target function. This has to be done @@ -3265,7 +3263,7 @@ impl Inst { _ => unreachable!(), } - put(sink, &enc_ril_b(opcode, link.to_reg(), 0)); + put(sink, &enc_ril_b(opcode, gpr(14), 0)); sink.add_call_site(); } &Inst::Args { .. } => {} diff --git a/cranelift/codegen/src/isa/s390x/inst/mod.rs b/cranelift/codegen/src/isa/s390x/inst/mod.rs index 65c5d52ec044..75e7daab707f 100644 --- a/cranelift/codegen/src/isa/s390x/inst/mod.rs +++ b/cranelift/codegen/src/isa/s390x/inst/mod.rs @@ -923,7 +923,6 @@ fn s390x_get_operands(inst: &mut Inst, collector: &mut DenyReuseVisitor { collector.reg_fixed_use(got, gpr(12)); @@ -931,7 +930,7 @@ fn s390x_get_operands(inst: &mut Inst, collector: &mut DenyReuseVisitor { - let link = link.to_reg(); + &Inst::ElfTlsGetOffset { ref symbol, .. } => { let dest = match &**symbol { SymbolReloc::TlsGd { name } => { format!("tls_gdcall:{}", name.display(None)) } _ => unreachable!(), }; - format!("brasl {}, {}", show_reg(link), dest) + format!("brasl {}, {}", show_reg(gpr(14)), dest) } &Inst::Args { ref args } => { let mut s = "args".to_string(); diff --git a/cranelift/codegen/src/isa/s390x/lower.isle b/cranelift/codegen/src/isa/s390x/lower.isle index 225918a22bac..1b21021f0ff2 100644 --- a/cranelift/codegen/src/isa/s390x/lower.isle +++ b/cranelift/codegen/src/isa/s390x/lower.isle @@ -2279,7 +2279,7 @@ (rule (lib_call_tls_get_offset got got_offset symbol) (let ((tls_offset WritableReg (temp_writable_reg $I64)) (_ Unit (abi_for_elf_tls_get_offset)) - (_ Unit (emit (MInst.ElfTlsGetOffset tls_offset got got_offset (writable_link_reg) symbol)))) + (_ Unit (emit (MInst.ElfTlsGetOffset tls_offset got got_offset symbol)))) tls_offset)) (decl abi_for_elf_tls_get_offset () Unit)