Check inlining and instruction count for assert_instr(nop) as well (#1218)

This commit is contained in:
Hans Kratz
2021-09-18 02:53:32 +02:00
committed by GitHub
parent bd0e352338
commit 4f8ed0335c

View File

@@ -76,19 +76,16 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
instrs = &instrs[..instrs.len() - 1]; instrs = &instrs[..instrs.len() - 1];
} }
// Look for `expected` as the first part of any instruction in this
// function, e.g., tzcntl in tzcntl %rax,%rax.
//
// There are two cases when the expected instruction is nop: // There are two cases when the expected instruction is nop:
// 1. The expected intrinsic is compiled away so we can't // 1. The expected intrinsic is compiled away so we can't
// check for it - aka the intrinsic is not generating any code. // check for it - aka the intrinsic is not generating any code.
// 2. It is a mark, indicating that the instruction will be // 2. It is a mark, indicating that the instruction will be
// compiled into other instructions - mainly because of llvm // compiled into other instructions - mainly because of llvm
// optimization. // optimization.
if expected == "nop" { let found = expected == "nop" || instrs.iter().any(|s| s.starts_with(expected));
return;
}
// Look for `expected` as the first part of any instruction in this
// function, e.g., tzcntl in tzcntl %rax,%rax.
let found = instrs.iter().any(|s| s.starts_with(expected));
// Look for subroutine call instructions in the disassembly to detect whether // Look for subroutine call instructions in the disassembly to detect whether
// inlining failed: all intrinsics are `#[inline(always)]`, so calling one // inlining failed: all intrinsics are `#[inline(always)]`, so calling one