From 4f8ed0335c50fbe6ddedc4fa535f7a454c5e413c Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Sat, 18 Sep 2021 02:53:32 +0200 Subject: [PATCH] Check inlining and instruction count for assert_instr(nop) as well (#1218) --- library/stdarch/crates/stdarch-test/src/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/library/stdarch/crates/stdarch-test/src/lib.rs b/library/stdarch/crates/stdarch-test/src/lib.rs index ab7ed4b5e58f..15ff9595af0f 100644 --- a/library/stdarch/crates/stdarch-test/src/lib.rs +++ b/library/stdarch/crates/stdarch-test/src/lib.rs @@ -76,19 +76,16 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { 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: // 1. The expected intrinsic is compiled away so we can't // check for it - aka the intrinsic is not generating any code. // 2. It is a mark, indicating that the instruction will be // compiled into other instructions - mainly because of llvm // optimization. - if expected == "nop" { - 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)); + let found = expected == "nop" || instrs.iter().any(|s| s.starts_with(expected)); // Look for subroutine call instructions in the disassembly to detect whether // inlining failed: all intrinsics are `#[inline(always)]`, so calling one