diff --git a/cranelift/codegen/src/ir/function.rs b/cranelift/codegen/src/ir/function.rs index 77c06964bf..1e72d2bc48 100644 --- a/cranelift/codegen/src/ir/function.rs +++ b/cranelift/codegen/src/ir/function.rs @@ -295,8 +295,8 @@ impl Function { /// to be confused with a "leaf function" in Windows terminology. pub fn is_leaf(&self) -> bool { // Conservative result: if there's at least one function signature referenced in this - // function, assume it may call. - !self.dfg.signatures.is_empty() + // function, assume it is not a leaf. + self.dfg.signatures.is_empty() } } diff --git a/cranelift/codegen/src/stack_layout.rs b/cranelift/codegen/src/stack_layout.rs index d04137ff10..55f3eb864f 100644 --- a/cranelift/codegen/src/stack_layout.rs +++ b/cranelift/codegen/src/stack_layout.rs @@ -47,7 +47,7 @@ pub fn layout_stack( let mut incoming_max = 0; let mut outgoing_max = 0; let mut min_align = alignment; - let mut must_align = is_leaf; + let mut must_align = !is_leaf; for slot in frame.values() { if slot.size > max_size { @@ -145,7 +145,7 @@ mod tests { let sss = &mut StackSlots::new(); // For all these test cases, assume it will call. - let is_leaf = true; + let is_leaf = false; // An empty layout should have 0-sized stack frame. assert_eq!(layout_stack(sss, is_leaf, 1), Ok(0));