File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use crate::{
66} ;
77
88pub fn canonicalize ( stmt : ir:: Statement ) -> Vec < Block > {
9- basic_block ( linearize ( stmt) )
9+ basic_block ( linearize ( stmt) ) . 0
1010}
1111
1212// The result will fit two properties:
@@ -186,7 +186,8 @@ impl Block {
186186 }
187187}
188188
189- fn basic_block ( stmts : Vec < ir:: Statement > ) -> Vec < Block > {
189+ fn basic_block ( stmts : Vec < ir:: Statement > ) -> ( Vec < Block > , Label ) {
190+ let done_label = Label :: new ( ) ;
190191 let mut blocks = vec ! [ ] ;
191192 let mut block: Option < Block > = None ;
192193 for stmt in stmts {
@@ -223,5 +224,10 @@ fn basic_block(stmts: Vec<ir::Statement>) -> Vec<Block> {
223224 }
224225 }
225226 }
226- blocks
227+ if block. is_some ( ) {
228+ blocks. push ( block. take ( ) . unwrap ( ) ) ;
229+ }
230+ // jump to end of function, avoid later reorder violate this
231+ blocks. last_mut ( ) . unwrap ( ) . push ( ir:: Statement :: Jump { exp : ir:: Exp :: Name ( done_label) , labels : vec ! [ done_label] } ) ;
232+ ( blocks, done_label)
227233}
You can’t perform that action at this time.
0 commit comments