@@ -278,10 +278,15 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
278
278
assert_eq ! ( functions. len( ) , 1 ) ;
279
279
let function = & functions[ 0 ] ;
280
280
281
+ let mut instrs = & function. instrs [ ..] ;
282
+ while instrs. last ( ) . map ( |s| s. parts == [ "nop" ] ) . unwrap_or ( false ) {
283
+ instrs = & instrs[ ..instrs. len ( ) - 1 ] ;
284
+ }
285
+
281
286
// Look for `expected` as the first part of any instruction in this
282
287
// function, returning if we do indeed find it.
283
288
let mut found = false ;
284
- for instr in & function . instrs {
289
+ for instr in instrs {
285
290
// Gets the first instruction, e.g. tzcntl in tzcntl %rax,%rax
286
291
if let Some ( part) = instr. parts . get ( 0 ) {
287
292
// Truncates the instruction with the length of the expected
@@ -298,7 +303,7 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
298
303
// calling one intrinsic from another should not generate `call`
299
304
// instructions.
300
305
let mut inlining_failed = false ;
301
- for ( i, instr) in function . instrs . iter ( ) . enumerate ( ) {
306
+ for ( i, instr) in instrs. iter ( ) . enumerate ( ) {
302
307
let part = match instr. parts . get ( 0 ) {
303
308
Some ( part) => part,
304
309
None => continue ,
@@ -342,7 +347,7 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
342
347
_ => 20 ,
343
348
} ;
344
349
let probably_only_one_instruction =
345
- function . instrs . len ( ) < instruction_limit;
350
+ instrs. len ( ) < instruction_limit;
346
351
347
352
if found && probably_only_one_instruction && !inlining_failed {
348
353
return ;
@@ -354,7 +359,7 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
354
359
"disassembly for {}: " ,
355
360
sym. as_ref( ) . expect( "symbol not found" )
356
361
) ;
357
- for ( i, instr) in function . instrs . iter ( ) . enumerate ( ) {
362
+ for ( i, instr) in instrs. iter ( ) . enumerate ( ) {
358
363
print ! ( "\t {:2}: " , i) ;
359
364
for part in & instr. parts {
360
365
print ! ( "{} " , part) ;
@@ -371,7 +376,7 @@ pub fn assert(fnptr: usize, fnname: &str, expected: &str) {
371
376
panic ! (
372
377
"instruction found, but the disassembly contains too many \
373
378
instructions: #instructions = {} >= {} (limit)",
374
- function . instrs. len( ) ,
379
+ instrs. len( ) ,
375
380
instruction_limit
376
381
) ;
377
382
} else if inlining_failed {
0 commit comments