Fix inverted result of is_leaf method

This commit is contained in:
Y-Nak
2020-02-13 16:56:08 +09:00
committed by Benjamin Bouvier
parent 51229c3f58
commit 58e5a62cde
2 changed files with 4 additions and 4 deletions

View File

@@ -295,8 +295,8 @@ impl Function {
/// to be confused with a "leaf function" in Windows terminology. /// to be confused with a "leaf function" in Windows terminology.
pub fn is_leaf(&self) -> bool { pub fn is_leaf(&self) -> bool {
// Conservative result: if there's at least one function signature referenced in this // Conservative result: if there's at least one function signature referenced in this
// function, assume it may call. // function, assume it is not a leaf.
!self.dfg.signatures.is_empty() self.dfg.signatures.is_empty()
} }
} }

View File

@@ -47,7 +47,7 @@ pub fn layout_stack(
let mut incoming_max = 0; let mut incoming_max = 0;
let mut outgoing_max = 0; let mut outgoing_max = 0;
let mut min_align = alignment; let mut min_align = alignment;
let mut must_align = is_leaf; let mut must_align = !is_leaf;
for slot in frame.values() { for slot in frame.values() {
if slot.size > max_size { if slot.size > max_size {
@@ -145,7 +145,7 @@ mod tests {
let sss = &mut StackSlots::new(); let sss = &mut StackSlots::new();
// For all these test cases, assume it will call. // 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. // An empty layout should have 0-sized stack frame.
assert_eq!(layout_stack(sss, is_leaf, 1), Ok(0)); assert_eq!(layout_stack(sss, is_leaf, 1), Ok(0));