Skip to content

Commit

Permalink
assert_instr check for failed inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Jan 3, 2018
1 parent c5b3483 commit 5640258
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion stdsimd-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,25 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
}
}

// Look for `call` instructions in the disassembly to detect whether
// inlining failed: all intrinsics are `#[inline(always)]`, so
// calling one intrinsic from another should not generate `call`
// instructions.
let mut inlining_failed = false;
for instr in &function.instrs {
if let Some(part) = instr.parts.get(0) {
if part.contains("call") {
inlining_failed = true;
break;
}
}
}

let instruction_limit = 30;
let probably_only_one_instruction =
function.instrs.len() < instruction_limit;

if found && probably_only_one_instruction {
if found && probably_only_one_instruction && !inlining_failed {
return;
}

Expand All @@ -323,6 +337,8 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
} else if !probably_only_one_instruction {
panic!("instruction found, but the disassembly contains too many instructions: #instructions = {} !< {} (limit)",
function.instrs.len(), instruction_limit);
} else if inlining_failed {
panic!("instruction found, but the disassembly contains `call` instructions, which hint that inlining failed");
}
}

Expand Down

0 comments on commit 5640258

Please sign in to comment.