mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
[assert-instr] compare only the instruction prefix
When comparing the assembly instructions against the expected instruction, depending on the platform, we might end up with `tzcntl != tzcnt`. This commit truncates the instructions to the length of the expected instruction, such that `tzcntl => tzcnt` and the comparison succeeds.
This commit is contained in:
@@ -242,9 +242,14 @@ pub fn assert(fnptr: usize, expected: &str) {
|
||||
// Look for `expected` as the first part of any instruction in this
|
||||
// function, returning if we do indeed find it.
|
||||
for instr in function.instrs.iter() {
|
||||
// Gets the first instruction, e.g. tzcntl in tzcntl %rax,%rax
|
||||
if let Some(part) = instr.parts.get(0) {
|
||||
if part == expected {
|
||||
return
|
||||
// Truncates the instruction with the length of the expected
|
||||
// instruction: tzcntl => tzcnt and compares that.
|
||||
if let Some(part) = part.get(0..expected.len()) {
|
||||
if part == expected {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user