Skip to content

Commit 4473315

Browse files
sayantnAmanieu
authored andcommitted
Make assert_instr stricter
1 parent 046ced7 commit 4473315

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Diff for: 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

Diff for: crates/stdarch-test/src/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ 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 expected = if expected == "unknown" {
88+
"<unknown>" // Workaround for rust-lang/stdarch#1674, todo: remove when the issue is fixed
89+
} else {
90+
expected
91+
};
92+
let found = expected == "nop" || instrs.iter().any(|s| s.starts_with(expected));
8893

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

0 commit comments

Comments
 (0)