@@ -167,31 +167,20 @@ impl JIT {
167167 // Create the entry block, to start emitting code in.
168168 let entry_block = builder. create_block ( ) ;
169169
170- // Add block parameters for function parameters.
171- builder. append_block_params_for_function_params ( entry_block) ;
172-
173170 builder. switch_to_block ( entry_block) ;
174171 builder. seal_block ( entry_block) ;
175172
176173 let mut trans = FunctionTranslator :: new ( builder, & mut self . module ) ;
177174
178- // Add variables for the function parameters and define them from block params.
179- let block_params: Vec < _ > = trans. builder . block_params ( entry_block) . to_vec ( ) ;
180- for ( i, param) in decl. params . iter ( ) . enumerate ( ) {
181- let ty = param. ty . expect ( "expected type" ) . cranelift_type ( ) ;
182- trans. declare_variable ( & param. name , ty) ;
183- let var = * trans. variables . get ( & * param. name ) . unwrap ( ) ;
184- trans. builder . def_var ( var, block_params[ i] ) ;
175+ // Add variables for the function parameters.
176+ for param in & decl. params {
177+ trans. declare_variable ( & param. name , param. ty . expect ( "expected type" ) . cranelift_type ( ) ) ;
185178 }
186179
187- let result = trans. translate_fn ( decl, decls) ;
180+ trans. translate_fn ( decl, decls) ;
188181
189182 // Need a return instruction at the end of the function's block.
190- if matches ! ( * decl. ret, crate :: Type :: Void ) {
191- trans. builder . ins ( ) . return_ ( & [ ] ) ;
192- } else {
193- trans. builder . ins ( ) . return_ ( & [ result] ) ;
194- }
183+ trans. builder . ins ( ) . return_ ( & [ ] ) ;
195184
196185 // Indicate we're finished with the function.
197186 trans. builder . finalize ( ) ;
@@ -292,8 +281,8 @@ impl<'a> FunctionTranslator<'a> {
292281 }
293282 }
294283
295- fn translate_fn ( & mut self , decl : & FuncDecl , decls : & DeclTable ) -> Value {
296- self . translate_expr ( decl. body . unwrap ( ) , decl, decls)
284+ fn translate_fn ( & mut self , decl : & FuncDecl , decls : & DeclTable ) {
285+ self . translate_expr ( decl. body . unwrap ( ) , decl, decls) ;
297286 }
298287
299288 fn translate_lvalue ( & mut self , expr : ExprID , decl : & FuncDecl , decls : & DeclTable ) -> Value {
0 commit comments