Skip to content

Commit

Permalink
Make assert_instr stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
sayantn committed Dec 21, 2024
1 parent cbbab56 commit b9fc7ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions crates/stdarch-test/src/disassembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn parse(output: &str) -> HashSet<Function> {
.filter(|&x| !x.is_empty())
.skip(1)
.map(str::to_lowercase)
.skip_while(|s| *s == "lock") // skip x86-specific prefix
.skip_while(|s| matches!(&**s, "lock" | "vex")) // skip x86-specific prefix
.collect::<Vec<String>>()
} else {
// objdump with --no-show-raw-insn
Expand All @@ -150,8 +150,8 @@ fn parse(output: &str) -> HashSet<Function> {
instruction
.split_whitespace()
.skip(1)
.skip_while(|s| *s == "lock" || *s == "{evex}") // skip x86-specific prefix
.map(std::string::ToString::to_string)
.skip_while(|s| matches!(*s, "lock" | "{evex}" | "{vex}")) // skip x86-specific prefix
.map(ToString::to_string)
.collect::<Vec<String>>()
};

Expand Down
9 changes: 7 additions & 2 deletions crates/stdarch-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cfg_if! {
use wasm::disassemble_myself;
} else {
mod disassembly;
use crate::disassembly::disassemble_myself;
use disassembly::disassemble_myself;
}
}

Expand Down Expand Up @@ -84,7 +84,12 @@ 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 expected = if expected == "unknown" {
"<unknown>" // Workaround for rust-lang/stdarch#1674, todo: remove when the issue is fixed
} else {
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
Expand Down

0 comments on commit b9fc7ca

Please sign in to comment.