diff --git a/cranelift/codegen/src/binemit/memorysink.rs b/cranelift/codegen/src/binemit/memorysink.rs index fe473c4c2c..dc86530b7c 100644 --- a/cranelift/codegen/src/binemit/memorysink.rs +++ b/cranelift/codegen/src/binemit/memorysink.rs @@ -15,7 +15,7 @@ //! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe. use super::{Addend, CodeInfo, CodeOffset, CodeSink, Reloc}; use crate::binemit::stack_map::StackMap; -use crate::ir::{ConstantOffset, ExternalName, Opcode, SourceLoc, TrapCode}; +use crate::ir::{ExternalName, Opcode, SourceLoc, TrapCode}; use core::ptr::write_unaligned; /// A `CodeSink` that writes binary machine code directly into memory. @@ -79,9 +79,6 @@ pub trait RelocSink { _: Addend, ); - /// Add a relocation referencing a constant. - fn reloc_constant(&mut self, _: CodeOffset, _: Reloc, _: ConstantOffset); - /// Track a call site whose return address is the given CodeOffset, for the given opcode. Does /// nothing in general, only useful for certain embedders (SpiderMonkey). fn add_call_site(&mut self, _: Opcode, _: CodeOffset, _: SourceLoc) {} @@ -138,11 +135,6 @@ impl<'a> CodeSink for MemoryCodeSink<'a> { self.relocs.reloc_external(ofs, srcloc, rel, name, addend); } - fn reloc_constant(&mut self, rel: Reloc, constant_offset: ConstantOffset) { - let ofs = self.offset(); - self.relocs.reloc_constant(ofs, rel, constant_offset); - } - fn trap(&mut self, code: TrapCode, srcloc: SourceLoc) { let ofs = self.offset(); self.traps.trap(ofs, srcloc, code); @@ -186,7 +178,6 @@ impl RelocSink for NullRelocSink { _: Addend, ) { } - fn reloc_constant(&mut self, _: CodeOffset, _: Reloc, _: ConstantOffset) {} } /// A `TrapSink` implementation that does nothing, which is convenient when diff --git a/cranelift/codegen/src/binemit/mod.rs b/cranelift/codegen/src/binemit/mod.rs index afd5ed558e..9532e34538 100644 --- a/cranelift/codegen/src/binemit/mod.rs +++ b/cranelift/codegen/src/binemit/mod.rs @@ -11,7 +11,7 @@ pub use self::memorysink::{ TrapSink, }; pub use self::stack_map::StackMap; -use crate::ir::{ConstantOffset, ExternalName, Opcode, SourceLoc, TrapCode}; +use crate::ir::{ExternalName, Opcode, SourceLoc, TrapCode}; use core::fmt; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; @@ -35,8 +35,6 @@ pub enum Reloc { Abs8, /// x86 PC-relative 4-byte X86PCRel4, - /// x86 PC-relative 4-byte offset to trailing rodata - X86PCRelRodata4, /// x86 call to PC-relative 4-byte X86CallPCRel4, /// x86 call to PLT-relative 4-byte @@ -78,7 +76,6 @@ impl fmt::Display for Reloc { Self::Abs8 => write!(f, "Abs8"), Self::S390xPCRel32Dbl => write!(f, "PCRel32Dbl"), Self::X86PCRel4 => write!(f, "PCRel4"), - Self::X86PCRelRodata4 => write!(f, "PCRelRodata4"), Self::X86CallPCRel4 => write!(f, "CallPCRel4"), Self::X86CallPLTRel4 => write!(f, "CallPLTRel4"), Self::X86GOTPCRel4 => write!(f, "GOTPCRel4"), @@ -147,9 +144,6 @@ pub trait CodeSink { /// Add a relocation referencing an external symbol plus the addend at the current offset. fn reloc_external(&mut self, _: SourceLoc, _: Reloc, _: &ExternalName, _: Addend); - /// Add a relocation referencing a constant. - fn reloc_constant(&mut self, _: Reloc, _: ConstantOffset); - /// Add trap information for the current offset. fn trap(&mut self, _: TrapCode, _: SourceLoc); diff --git a/cranelift/codegen/src/isa/test_utils.rs b/cranelift/codegen/src/isa/test_utils.rs index 668c481ec9..a9863ddf5b 100644 --- a/cranelift/codegen/src/isa/test_utils.rs +++ b/cranelift/codegen/src/isa/test_utils.rs @@ -66,8 +66,6 @@ impl CodeSink for TestCodeSink { ) { } - fn reloc_constant(&mut self, _rel: Reloc, _constant_offset: ConstantOffset) {} - fn trap(&mut self, _code: TrapCode, _srcloc: SourceLoc) {} fn begin_jumptables(&mut self) {} diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 8101a6ce84..f584382d82 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -2067,7 +2067,6 @@ mod test { fn reloc_external(&mut self, _: SourceLoc, r: Reloc, _: &ExternalName, _: Addend) { self.relocs.push((self.offset, r)); } - fn reloc_constant(&mut self, _: Reloc, _: ConstantOffset) {} fn trap(&mut self, t: TrapCode, _: SourceLoc) { self.traps.push((self.offset, t)); } diff --git a/cranelift/filetests/src/test_compile.rs b/cranelift/filetests/src/test_compile.rs index a73b97683c..c0115f3d47 100644 --- a/cranelift/filetests/src/test_compile.rs +++ b/cranelift/filetests/src/test_compile.rs @@ -95,7 +95,6 @@ impl binemit::CodeSink for SizeSink { _addend: binemit::Addend, ) { } - fn reloc_constant(&mut self, _: binemit::Reloc, _: ir::ConstantOffset) {} fn trap(&mut self, _code: ir::TrapCode, _srcloc: ir::SourceLoc) {} fn begin_jumptables(&mut self) {} fn begin_rodata(&mut self) {} diff --git a/cranelift/jit/src/backend.rs b/cranelift/jit/src/backend.rs index 925a653b0b..d7d092d258 100644 --- a/cranelift/jit/src/backend.rs +++ b/cranelift/jit/src/backend.rs @@ -893,16 +893,4 @@ impl RelocSink for JITRelocSink { addend, }); } - - fn reloc_constant(&mut self, _offset: CodeOffset, reloc: Reloc, _constant: ir::ConstantOffset) { - match reloc { - Reloc::X86PCRelRodata4 => { - // Not necessary to record this unless we are going to split apart code and its - // jumptbl/rodata. - } - _ => { - panic!("Unhandled reloc"); - } - } - } } diff --git a/cranelift/object/src/backend.rs b/cranelift/object/src/backend.rs index 6990d2200d..0f710d9f0e 100644 --- a/cranelift/object/src/backend.rs +++ b/cranelift/object/src/backend.rs @@ -734,16 +734,4 @@ impl RelocSink for ObjectRelocSink { name: name.clone(), }) } - - fn reloc_constant(&mut self, _offset: CodeOffset, reloc: Reloc, _jt: ir::ConstantOffset) { - match reloc { - Reloc::X86PCRelRodata4 => { - // Not necessary to record this unless we are going to split apart code and its - // jumptbl/rodata. - } - _ => { - panic!("Unhandled reloc"); - } - } - } } diff --git a/cranelift/src/disasm.rs b/cranelift/src/disasm.rs index 581a44c13f..96972c6bc5 100644 --- a/cranelift/src/disasm.rs +++ b/cranelift/src/disasm.rs @@ -36,22 +36,6 @@ impl binemit::RelocSink for PrintRelocs { .unwrap(); } } - - fn reloc_constant( - &mut self, - code_offset: binemit::CodeOffset, - reloc: binemit::Reloc, - constant: ir::ConstantOffset, - ) { - if self.flag_print { - writeln!( - &mut self.text, - "reloc_constant: {} {} at {}", - reloc, constant, code_offset - ) - .unwrap(); - } - } } pub struct PrintTraps { diff --git a/crates/cranelift/src/compiler.rs b/crates/cranelift/src/compiler.rs index 5e20adda33..6983945461 100644 --- a/crates/cranelift/src/compiler.rs +++ b/crates/cranelift/src/compiler.rs @@ -643,16 +643,6 @@ impl binemit::RelocSink for RelocSink { addend, }); } - - fn reloc_constant( - &mut self, - _code_offset: binemit::CodeOffset, - _reloc: binemit::Reloc, - _constant_offset: ir::ConstantOffset, - ) { - // Do nothing for now: cranelift emits constant data after the function code and also emits - // function code with correct relative offsets to the constant data. - } } impl RelocSink { @@ -764,12 +754,4 @@ impl binemit::RelocSink for TrampolineRelocSink { addend, }); } - fn reloc_constant( - &mut self, - _code_offset: binemit::CodeOffset, - _reloc: binemit::Reloc, - _constant_offset: ir::ConstantOffset, - ) { - panic!("trampoline compilation should not produce constant relocs"); - } } diff --git a/crates/cranelift/src/obj.rs b/crates/cranelift/src/obj.rs index b5d4510e5d..a5bed41d89 100644 --- a/crates/cranelift/src/obj.rs +++ b/crates/cranelift/src/obj.rs @@ -310,16 +310,6 @@ impl<'a> ObjectBuilder<'a> { Reloc::Abs4 => (RelocationKind::Absolute, RelocationEncoding::Generic, 32), Reloc::Abs8 => (RelocationKind::Absolute, RelocationEncoding::Generic, 64), - // This is emitted by the old x86 backend and is only present - // for when the constant rodata is separated from the code - // itself. We don't do that, though, so we ignore these - // relocations since the offsets already listed here are already - // correct. - // - // FIXME(#3009): when the old backend is removed delete this - // case. - Reloc::X86PCRelRodata4 => continue, - other => unimplemented!("Unimplemented relocation {:?}", other), }; self.obj