From 6af407144c6441720b2953d080455e565ee81b0e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 28 Aug 2018 12:36:21 -0700 Subject: [PATCH] Remove `Signature`'s `argument_bytes` field. It's not currently used. If we do need such information, it would be better to compute it on demand. --- cranelift/tests/moduletests.rs | 2 -- lib/codegen/src/ir/extfunc.rs | 37 +-------------------------- lib/codegen/src/legalizer/boundary.rs | 1 - lib/codegen/src/verifier/mod.rs | 5 ---- lib/reader/src/parser.rs | 4 --- 5 files changed, 1 insertion(+), 48 deletions(-) diff --git a/cranelift/tests/moduletests.rs b/cranelift/tests/moduletests.rs index c2312fe4f2..a4aea4b389 100644 --- a/cranelift/tests/moduletests.rs +++ b/cranelift/tests/moduletests.rs @@ -19,7 +19,6 @@ fn error_on_incompatible_sig_in_declare_function() { params: vec![AbiParam::new(types::I64)], returns: vec![], call_conv: CallConv::SystemV, - argument_bytes: None, }; module .declare_function("abc", Linkage::Local, &sig) @@ -36,7 +35,6 @@ fn define_simple_function(module: &mut Module) -> FuncId { params: vec![], returns: vec![], call_conv: CallConv::SystemV, - argument_bytes: None, }; let func_id = module diff --git a/lib/codegen/src/ir/extfunc.rs b/lib/codegen/src/ir/extfunc.rs index 30f0eaab74..451a90a7f9 100644 --- a/lib/codegen/src/ir/extfunc.rs +++ b/lib/codegen/src/ir/extfunc.rs @@ -8,7 +8,6 @@ use ir::{ArgumentLoc, ExternalName, SigRef, Type}; use isa::{RegInfo, RegUnit}; use settings::CallConv; -use std::cmp; use std::fmt; use std::str::FromStr; use std::vec::Vec; @@ -29,13 +28,6 @@ pub struct Signature { /// Calling convention. pub call_conv: CallConv, - - /// When the signature has been legalized to a specific ISA, this holds the size of the - /// argument array on the stack. Before legalization, this is `None`. - /// - /// This can be computed from the legalized `params` array as the maximum (offset plus - /// byte size) of the `ArgumentLoc::Stack(offset)` argument. - pub argument_bytes: Option, } impl Signature { @@ -45,7 +37,6 @@ impl Signature { params: Vec::new(), returns: Vec::new(), call_conv, - argument_bytes: None, } } @@ -54,25 +45,6 @@ impl Signature { self.params.clear(); self.returns.clear(); self.call_conv = call_conv; - self.argument_bytes = None; - } - - /// Compute the size of the stack arguments and mark signature as legalized. - /// - /// Even if there are no stack arguments, this will set `params` to `Some(0)` instead - /// of `None`. This indicates that the signature has been legalized. - pub fn compute_argument_bytes(&mut self) { - let bytes = self - .params - .iter() - .filter_map(|arg| match arg.location { - ArgumentLoc::Stack(offset) if offset >= 0 => { - Some(offset as u32 + arg.value_type.bytes()) - } - _ => None, - }) - .fold(0, cmp::max); - self.argument_bytes = Some(bytes); } /// Return an object that can display `self` with correct register names. @@ -421,16 +393,9 @@ mod tests { sig.returns.push(AbiParam::new(B8)); assert_eq!(sig.to_string(), "(i32, i32x4) -> f32, b8 baldrdash"); - // Test the offset computation algorithm. - assert_eq!(sig.argument_bytes, None); - sig.params[1].location = ArgumentLoc::Stack(8); - sig.compute_argument_bytes(); - // An `i32x4` at offset 8 requires a 24-byte argument array. - assert_eq!(sig.argument_bytes, Some(24)); // Order does not matter. sig.params[0].location = ArgumentLoc::Stack(24); - sig.compute_argument_bytes(); - assert_eq!(sig.argument_bytes, Some(28)); + sig.params[1].location = ArgumentLoc::Stack(8); // Writing ABI-annotated signatures. assert_eq!( diff --git a/lib/codegen/src/legalizer/boundary.rs b/lib/codegen/src/legalizer/boundary.rs index 6f3143028b..e052e63be6 100644 --- a/lib/codegen/src/legalizer/boundary.rs +++ b/lib/codegen/src/legalizer/boundary.rs @@ -57,7 +57,6 @@ pub fn legalize_libcall_signature(signature: &mut Signature, isa: &TargetIsa) { /// `current` is true if this is the signature for the current function. fn legalize_signature(signature: &mut Signature, current: bool, isa: &TargetIsa) { isa.legalize_signature(signature, current); - signature.compute_argument_bytes(); } /// Legalize the entry block parameters after `func`'s signature has been legalized. diff --git a/lib/codegen/src/verifier/mod.rs b/lib/codegen/src/verifier/mod.rs index bce49501e3..2f9c1dbcb4 100644 --- a/lib/codegen/src/verifier/mod.rs +++ b/lib/codegen/src/verifier/mod.rs @@ -1160,11 +1160,6 @@ impl<'a> Verifier<'a> { ) -> VerifierStepResult<()> { let sig = &self.func.dfg.signatures[sig_ref]; - // Before legalization, there's nothing to check. - if sig.argument_bytes.is_none() { - return Ok(()); - } - let args = self.func.dfg.inst_variable_args(inst); let expected_args = &sig.params[..]; diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index ff155fc195..c5bbe47f8f 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -919,10 +919,6 @@ impl<'a> Parser<'a> { } } - if sig.params.iter().all(|a| a.location.is_assigned()) { - sig.compute_argument_bytes(); - } - Ok(sig) }