File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -406,13 +406,14 @@ impl Assembler {
406406 // case. If the values aren't heap objects then we'll treat them as
407407 // if they were just unsigned integer.
408408 let is_load = matches ! ( insn, Insn :: Load { .. } | Insn :: LoadInto { .. } ) ;
409+ let is_jump = insn. is_jump ( ) ;
409410 let mut opnd_iter = insn. opnd_iter_mut ( ) ;
410411
411412 while let Some ( opnd) = opnd_iter. next ( ) {
412413 if let Opnd :: Value ( value) = opnd {
413414 if value. special_const_p ( ) {
414415 * opnd = Opnd :: UImm ( value. as_u64 ( ) ) ;
415- } else if !is_load {
416+ } else if !is_load && !is_jump {
416417 * opnd = asm. load ( * opnd) ;
417418 }
418419 } ;
Original file line number Diff line number Diff line change @@ -1037,6 +1037,15 @@ impl Insn {
10371037
10381038 /// Returns true if this instruction is a terminator (ends a basic block).
10391039 pub fn is_terminator ( & self ) -> bool {
1040+ self . is_jump ( ) ||
1041+ match self {
1042+ Insn :: CRet ( _) => true ,
1043+ _ => false
1044+ }
1045+ }
1046+
1047+ /// Returns true if this instruction is a jump.
1048+ pub fn is_jump ( & self ) -> bool {
10401049 match self {
10411050 Insn :: Jbe ( _) |
10421051 Insn :: Jb ( _) |
@@ -1052,8 +1061,7 @@ impl Insn {
10521061 Insn :: JoMul ( _) |
10531062 Insn :: Jz ( _) |
10541063 Insn :: Joz ( ..) |
1055- Insn :: Jonz ( ..) |
1056- Insn :: CRet ( _) => true ,
1064+ Insn :: Jonz ( ..) => true ,
10571065 _ => false
10581066 }
10591067 }
@@ -2232,6 +2240,7 @@ impl Assembler
22322240 self . basic_blocks [ successor. 0 ] . insn_ids . insert ( 1 + i, None ) ;
22332241 }
22342242 } else {
2243+ assert_eq ! ( num_successors, 1 ) ;
22352244 // Single-succ: insert at end of predecessor before terminator
22362245 let len = self . basic_blocks [ pred_id. 0 ] . insns . len ( ) ;
22372246 for ( i, mov) in moves. into_iter ( ) . enumerate ( ) {
You can’t perform that action at this time.
0 commit comments