Skip to content

Commit 87eb93f

Browse files
committed
stdarch-test: error if only part of an instruction matched
1 parent eff520b commit 87eb93f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/stdarch-test/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
9292
};
9393

9494
// Check whether the given instruction is part of the disassemblied body.
95-
let found = expected == "nop" || instrs.iter().any(|s| s.starts_with(expected));
95+
let found = expected == "nop"
96+
|| instrs.iter().any(|instruction| {
97+
// Check that the next character is non-alphabetic. This prevents false negatives
98+
// when e.g. `fminnm` was used but `fmin` was expected.
99+
instruction.starts_with(expected)
100+
&& !instruction[expected.len()..].starts_with(|c: char| c.is_ascii_alphabetic())
101+
});
96102

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

0 commit comments

Comments
 (0)