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

This commit is contained in:
bjorn3
2022-06-30 19:44:51 +02:00
committed by GitHub
parent b4830ef1e7
commit d1446f767d
5 changed files with 15 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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