Browse Source

Mark return value as define instead of clobber for TLS pseudoinstructions (#4357)

pull/4359/head
bjorn3 2 years ago
committed by GitHub
parent
commit
d1446f767d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      cranelift/codegen/src/isa/aarch64/inst/mod.rs
  2. 4
      cranelift/codegen/src/isa/x64/inst/emit_tests.rs
  3. 11
      cranelift/codegen/src/isa/x64/inst/mod.rs
  4. 2
      cranelift/filetests/filetests/isa/aarch64/tls-elf-gd.clif
  5. 2
      cranelift/filetests/filetests/isa/x64/tls_elf.clif

9
cranelift/codegen/src/isa/aarch64/inst/mod.rs

@ -1032,9 +1032,10 @@ fn aarch64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut Operan
&Inst::VirtualSPOffsetAdj { .. } => {}
&Inst::ElfTlsGetAddr { .. } => {
collector.reg_clobbers(AArch64MachineDeps::get_regs_clobbered_by_call(
CallConv::SystemV,
));
collector.reg_def(Writable::from_reg(regs::xreg(0)));
let mut clobbers = AArch64MachineDeps::get_regs_clobbered_by_call(CallConv::SystemV);
clobbers.remove(regs::xreg_preg(0));
collector.reg_clobbers(clobbers);
}
&Inst::Unwind { .. } => {}
&Inst::EmitIsland { .. } => {}
@ -2723,7 +2724,7 @@ impl Inst {
&Inst::EmitIsland { needed_space } => format!("emit_island {}", needed_space),
&Inst::ElfTlsGetAddr { ref symbol } => {
format!("elf_tls_get_addr {}", symbol)
format!("x0 = elf_tls_get_addr {}", symbol)
}
&Inst::Unwind { ref inst } => {
format!("unwind {:?}", inst)

4
cranelift/codegen/src/isa/x64/inst/emit_tests.rs

@ -4840,7 +4840,7 @@ fn test_x64_emit() {
},
},
"66488D3D00000000666648E800000000",
"elf_tls_get_addr User { namespace: 0, index: 0 }",
"%rax = elf_tls_get_addr User { namespace: 0, index: 0 }",
));
insns.push((
@ -4851,7 +4851,7 @@ fn test_x64_emit() {
},
},
"488B3D00000000FF17",
"macho_tls_get_addr User { namespace: 0, index: 0 }",
"%rax = macho_tls_get_addr User { namespace: 0, index: 0 }",
));
// ========================================================

11
cranelift/codegen/src/isa/x64/inst/mod.rs

@ -1672,11 +1672,11 @@ impl PrettyPrint for Inst {
Inst::Ud2 { trap_code } => format!("ud2 {}", trap_code),
Inst::ElfTlsGetAddr { ref symbol } => {
format!("elf_tls_get_addr {:?}", symbol)
format!("%rax = elf_tls_get_addr {:?}", symbol)
}
Inst::MachOTlsGetAddr { ref symbol } => {
format!("macho_tls_get_addr {:?}", symbol)
format!("%rax = macho_tls_get_addr {:?}", symbol)
}
Inst::Unwind { inst } => {
@ -2083,15 +2083,16 @@ fn x64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut OperandCol
}
Inst::ElfTlsGetAddr { .. } | Inst::MachOTlsGetAddr { .. } => {
collector.reg_def(Writable::from_reg(regs::rax()));
// All caller-saves are clobbered.
//
// We use the SysV calling convention here because the
// pseudoinstruction (and relocation that it emits) is specific to
// ELF systems; other x86-64 targets with other conventions (i.e.,
// Windows) use different TLS strategies.
collector.reg_clobbers(X64ABIMachineSpec::get_regs_clobbered_by_call(
CallConv::SystemV,
));
let mut clobbers = X64ABIMachineSpec::get_regs_clobbered_by_call(CallConv::SystemV);
clobbers.remove(regs::gpr_preg(regs::ENC_RAX));
collector.reg_clobbers(clobbers);
}
Inst::Unwind { .. } => {}

2
cranelift/filetests/filetests/isa/aarch64/tls-elf-gd.clif

@ -19,7 +19,7 @@ block0(v0: i32):
; stp d8, d9, [sp, #-16]!
; block0:
; mov x25, x0
; elf_tls_get_addr u1:0
; x0 = elf_tls_get_addr u1:0
; mov x1, x0
; mov x0, x25
; ldp d8, d9, [sp], #16

2
cranelift/filetests/filetests/isa/x64/tls_elf.clif

@ -13,7 +13,7 @@ block0(v0: i32):
; pushq %rbp
; movq %rsp, %rbp
; block0:
; elf_tls_get_addr User { namespace: 1, index: 0 }
; %rax = elf_tls_get_addr User { namespace: 1, index: 0 }
; movq %rbp, %rsp
; popq %rbp
; ret

Loading…
Cancel
Save