Skip to content

Commit cf4ac03

Browse files
committed
Make assert_instr stricter
1 parent a514252 commit cf4ac03

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

crates/stdarch-test/src/disassembly.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn parse(output: &str) -> HashSet<Function> {
140140
.filter(|&x| !x.is_empty())
141141
.skip(1)
142142
.map(str::to_lowercase)
143-
.skip_while(|s| *s == "lock") // skip x86-specific prefix
143+
.skip_while(|s| matches!(&**s, "lock" | "vex")) // skip x86-specific prefix
144144
.collect::<Vec<String>>()
145145
} else {
146146
// objdump with --no-show-raw-insn
@@ -150,8 +150,8 @@ fn parse(output: &str) -> HashSet<Function> {
150150
instruction
151151
.split_whitespace()
152152
.skip(1)
153-
.skip_while(|s| *s == "lock" || *s == "{evex}") // skip x86-specific prefix
154-
.map(std::string::ToString::to_string)
153+
.skip_while(|s| matches!(*s, "lock" | "{evex}" | "{vex}")) // skip x86-specific prefix
154+
.map(ToString::to_string)
155155
.collect::<Vec<String>>()
156156
};
157157

crates/stdarch-test/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
8484
// 2. It is a mark, indicating that the instruction will be
8585
// compiled into other instructions - mainly because of llvm
8686
// optimization.
87-
let found = expected == "nop" || instrs.iter().any(|s| s.contains(expected));
87+
let found = expected == "nop"
88+
|| instrs.iter().any(|s| s.starts_with(expected))
89+
|| (expected == "unknown" && instrs.iter().any(|s| s.starts_with("<unknown>"))); // Workaround for rust-lang/stdarch#1674
8890

8991
// Look for subroutine call instructions in the disassembly to detect whether
9092
// inlining failed: all intrinsics are `#[inline(always)]`, so calling one

0 commit comments

Comments
 (0)