Skip to content

Commit

Permalink
inlining check: use starts_with() instead of contains() while checkin…
Browse files Browse the repository at this point in the history
…g for subroutine call instruction
  • Loading branch information
hkratz committed Sep 8, 2021
1 parent 5508b2e commit 655fa1e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/stdarch-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
// inlining failed: all intrinsics are `#[inline(always)]`, so calling one
// intrinsic from another should not generate subroutine call instructions.
let inlining_failed = if cfg!(target_arch = "x86_64") || cfg!(target_arch = "wasm32") {
instrs.iter().any(|s| s.contains("call "))
instrs.iter().any(|s| s.starts_with("call "))
} else if cfg!(target_arch = "x86") {
instrs.windows(2).any(|s| {
// On 32-bit x86 position independent code will call itself and be
// immediately followed by a `pop` to learn about the current address.
// Let's not take that into account when considering whether a function
// failed inlining something.
s[0].contains("call ") && s[1].contains("pop") // FIXME: original logic but does not match comment
s[0].starts_with("call ") && s[1].starts_with("pop") // FIXME: original logic but does not match comment
})
} else if cfg!(target_arch = "aarch64") {
instrs.iter().any(|s| s.contains("bl "))
instrs.iter().any(|s| s.starts_with("bl "))
} else {
// FIXME: Add detection for other archs
false
Expand Down

0 comments on commit 655fa1e

Please sign in to comment.