@@ -61,11 +61,12 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
61
61
black_box ( shim_addr) ;
62
62
63
63
//eprintln!("shim name: {fnname}");
64
- let function = & DISASSEMBLY
65
- . get ( & Function :: new ( fnname) )
66
- . unwrap_or_else ( || panic ! ( "function \" {fnname} \" not found in the disassembly" ) ) ;
64
+ let Some ( function) = & DISASSEMBLY . get ( & Function :: new ( fnname ) ) else {
65
+ panic ! ( "function `{ fnname}` not found in the disassembly" )
66
+ } ;
67
67
//eprintln!(" function: {:?}", function);
68
68
69
+ // Trim any filler instructions.
69
70
let mut instrs = & function. instrs [ ..] ;
70
71
while instrs. last ( ) . is_some_and ( |s| s == "nop" || s == "int3" ) {
71
72
instrs = & instrs[ ..instrs. len ( ) - 1 ] ;
@@ -80,11 +81,17 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
80
81
// 2. It is a mark, indicating that the instruction will be
81
82
// compiled into other instructions - mainly because of llvm
82
83
// optimization.
83
- let expected = if expected == "unknown" {
84
- "<unknown>" // Workaround for rust-lang/stdarch#1674, todo: remove when the issue is fixed
85
- } else {
86
- expected
84
+ let expected = match expected {
85
+ // `<unknown>` is what LLVM will generate for unknown instructions. We use this to fail
86
+ // loudly when LLVM does start supporting these instructions.
87
+ //
88
+ // This was introduced in https://github.com/rust-lang/stdarch/pull/1674 to work around the
89
+ // RISC-V P extension not yet being supported.
90
+ "unknown" => "<unknown>" ,
91
+ _ => expected,
87
92
} ;
93
+
94
+ // Check whether the given instruction is part of the disassemblied body.
88
95
let found = expected == "nop" || instrs. iter ( ) . any ( |s| s. starts_with ( expected) ) ;
89
96
90
97
// Look for subroutine call instructions in the disassembly to detect whether
0 commit comments