From 643b3b70501f7e785c8d016743855e72756b001d Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 21 Dec 2024 02:35:41 +0530 Subject: [PATCH] Make `assert_instr` stricter --- crates/stdarch-test/src/disassembly.rs | 2 +- crates/stdarch-test/src/lib.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/stdarch-test/src/disassembly.rs b/crates/stdarch-test/src/disassembly.rs index a7b46a73fc..8c724b8d42 100644 --- a/crates/stdarch-test/src/disassembly.rs +++ b/crates/stdarch-test/src/disassembly.rs @@ -150,7 +150,7 @@ fn parse(output: &str) -> HashSet { instruction .split_whitespace() .skip(1) - .skip_while(|s| *s == "lock" || *s == "{evex}") // skip x86-specific prefix + .skip_while(|s| *s == "lock" || *s == "{evex}" || *s == "{vex}") // skip x86-specific prefix .map(std::string::ToString::to_string) .collect::>() }; diff --git a/crates/stdarch-test/src/lib.rs b/crates/stdarch-test/src/lib.rs index 3248de8f3a..b2a14b15fb 100644 --- a/crates/stdarch-test/src/lib.rs +++ b/crates/stdarch-test/src/lib.rs @@ -84,7 +84,9 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { // 2. It is a mark, indicating that the instruction will be // compiled into other instructions - mainly because of llvm // optimization. - let found = expected == "nop" || instrs.iter().any(|s| s.contains(expected)); + let found = expected == "nop" + || instrs.iter().any(|s| s.starts_with(expected)) + || (expected == "unknown" && instrs.iter().any(|s| s.starts_with(""))); // Workaround for rust-lang/stdarch#1674 // Look for subroutine call instructions in the disassembly to detect whether // inlining failed: all intrinsics are `#[inline(always)]`, so calling one