@@ -1083,6 +1083,14 @@ impl Insn {
10831083 }
10841084 }
10851085
1086+ /// Return true if the instruction is a jump (has successor blocks in the CFG).
1087+ pub fn is_jump ( & self ) -> bool {
1088+ match self {
1089+ Insn :: IfTrue { .. } | Insn :: IfFalse { .. } | Insn :: Jump ( _) | Insn :: Entries { .. } => true ,
1090+ _ => false ,
1091+ }
1092+ }
1093+
10861094 pub fn print < ' a > ( & self , ptr_map : & ' a PtrPrintMap , iseq : Option < IseqPtr > ) -> InsnPrinter < ' a > {
10871095 InsnPrinter { inner : self . clone ( ) , ptr_map, iseq }
10881096 }
@@ -5031,17 +5039,20 @@ impl Function {
50315039 if !seen. insert ( block) { continue ; }
50325040 stack. push ( ( block, Action :: VisitSelf ) ) ;
50335041 for insn_id in & self . blocks [ block. 0 ] . insns {
5034- let insn = self . find ( * insn_id) ;
5035- match insn {
5042+ // Instructions without output, including branch instructions, can't be targets of
5043+ // make_equal_to, so we don't need find() here.
5044+ match & self . insns [ insn_id. 0 ] {
50365045 Insn :: IfTrue { target, .. } | Insn :: IfFalse { target, .. } | Insn :: Jump ( target) => {
50375046 stack. push ( ( target. target , Action :: VisitEdges ) ) ;
50385047 }
5039- Insn :: Entries { ref targets } => {
5048+ Insn :: Entries { targets } => {
50405049 for target in targets {
50415050 stack. push ( ( * target, Action :: VisitEdges ) ) ;
50425051 }
50435052 }
5044- _ => { }
5053+ _ => {
5054+ debug_assert ! ( !self . find( * insn_id) . is_jump( ) , "Instruction {:?} should not be in union-find; it has no output" , insn_id) ;
5055+ }
50455056 }
50465057 }
50475058 }
0 commit comments