diff --git a/cranelift/codegen/src/ir/dfg.rs b/cranelift/codegen/src/ir/dfg.rs index 5784812cff..507881c770 100644 --- a/cranelift/codegen/src/ir/dfg.rs +++ b/cranelift/codegen/src/ir/dfg.rs @@ -138,10 +138,10 @@ pub struct DataFlowGraph { /// Saves Value labels. pub values_labels: Option>, - /// Constants used within the function + /// Constants used within the function. pub constants: ConstantPool, - /// Stores large immediates that otherwise will not fit on InstructionData + /// Stores large immediates that otherwise will not fit on InstructionData. pub immediates: PrimaryMap, /// Jump tables used in this function. @@ -275,12 +275,12 @@ fn resolve_aliases(values: &PrimaryMap, value: Value) -> } } -/// Iterator over all Values in a DFG +/// Iterator over all Values in a DFG. pub struct Values<'a> { inner: entity::Iter<'a, Value, ValueDataPacked>, } -/// Check for non-values +/// Check for non-values. fn valid_valuedata(data: ValueDataPacked) -> bool { let data = ValueData::from(data); if let ValueData::Alias { diff --git a/cranelift/codegen/src/ir/entities.rs b/cranelift/codegen/src/ir/entities.rs index 576268be1e..3917ff6586 100644 --- a/cranelift/codegen/src/ir/entities.rs +++ b/cranelift/codegen/src/ir/entities.rs @@ -336,7 +336,7 @@ entity_impl!(UserExternalNameRef, "userextname"); /// An opaque reference to a function [`Signature`](super::Signature). /// /// `SigRef`s are used to declare a function with -/// [`FunctionBuiler::import_function`](https://docs.rs/cranelift-frontend/*/cranelift_frontend/struct.FunctionBuilder.html#method.import_function) +/// [`FunctionBuilder::import_function`](https://docs.rs/cranelift-frontend/*/cranelift_frontend/struct.FunctionBuilder.html#method.import_function) /// as well as to make an [indirect function call](super::InstBuilder::call_indirect). /// /// `SigRef`s can be created with @@ -551,6 +551,14 @@ mod tests { ); } + #[test] + fn memory_option() { + use core::mem; + // PackedOption is used because Option is twice as large + // as EntityRef. If this ever fails to be the case, this test will fail. + assert_eq!(mem::size_of::() * 2, mem::size_of::>()); + } + #[test] fn constant_with_number() { assert_eq!(Constant::with_number(0).unwrap().to_string(), "const0"); diff --git a/cranelift/codegen/src/ir/function.rs b/cranelift/codegen/src/ir/function.rs index f9dd4b7d1e..74501f1fda 100644 --- a/cranelift/codegen/src/ir/function.rs +++ b/cranelift/codegen/src/ir/function.rs @@ -230,7 +230,7 @@ impl FunctionStencil { self.global_values.push(data) } - /// Find the global dyn_scale value associated with given DynamicType + /// Find the global dyn_scale value associated with given DynamicType. pub fn get_dyn_scale(&self, ty: DynamicType) -> GlobalValue { self.dfg.dynamic_types.get(ty).unwrap().dynamic_scale } diff --git a/cranelift/codegen/src/ir/jumptable.rs b/cranelift/codegen/src/ir/jumptable.rs index 85f37ad7da..0f02e3c127 100644 --- a/cranelift/codegen/src/ir/jumptable.rs +++ b/cranelift/codegen/src/ir/jumptable.rs @@ -28,7 +28,7 @@ pub struct JumpTableData { } impl JumpTableData { - /// Create a new jump table with the provided blocks + /// Create a new jump table with the provided blocks. pub fn new(def: BlockCall, table: &[BlockCall]) -> Self { Self { table: std::iter::once(def).chain(table.iter().copied()).collect(), diff --git a/cranelift/codegen/src/ir/layout.rs b/cranelift/codegen/src/ir/layout.rs index f04560e243..2f6788fbe7 100644 --- a/cranelift/codegen/src/ir/layout.rs +++ b/cranelift/codegen/src/ir/layout.rs @@ -375,7 +375,7 @@ impl Layout { } /// A single node in the linked-list of blocks. -// Whenever you add new fields here, don't forget to update the custom serializer for `Layout` too. +// **Note:** Whenever you add new fields here, don't forget to update the custom serializer for `Layout` too. #[derive(Clone, Debug, Default, PartialEq, Hash)] struct BlockNode { prev: PackedOption, diff --git a/cranelift/codegen/src/ir/mod.rs b/cranelift/codegen/src/ir/mod.rs index 3a5936fcb9..cd302c2397 100644 --- a/cranelift/codegen/src/ir/mod.rs +++ b/cranelift/codegen/src/ir/mod.rs @@ -89,7 +89,7 @@ pub struct ValueLabelStart { pub label: ValueLabel, } -/// Value label assignements: label starts or value aliases. +/// Value label assignments: label starts or value aliases. #[derive(Debug, Clone, PartialEq, Hash)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] pub enum ValueLabelAssignments {