Fix issue caused by dangling instruction.

- Come on inkwell, I thought you were better than this.
This commit is contained in:
Lachlan Sneff
2019-03-01 20:23:21 -08:00
parent f0ac76517a
commit 362e5aa160
2 changed files with 23 additions and 27 deletions

View File

@ -110,8 +110,6 @@ pub fn parse_function_bodies(
})?;
}
module.print_to_stderr();
generate_trampolines(info, &signatures, &module, &context, &builder, &intrinsics);
let pass_manager = PassManager::create_for_module();
@ -161,22 +159,6 @@ fn parse_function(
.map(|ty| builder.build_phi(ty, &state.var_name()))
.collect();
match phis.as_slice() {
// No returns.
&[] => {
builder.build_return(None);
}
&[one_value] => {
let value = one_value.as_basic_value();
builder.build_return(Some(&value));
}
returns @ _ => {
// let struct_ty = llvm_sig.get_return_type().as_struct_type();
// let ret_struct = struct_ty.const_zero();
unimplemented!("multi-value returns not yet implemented")
}
}
state.push_block(return_block, phis);
builder.position_at_end(&entry_block);
@ -504,6 +486,7 @@ fn parse_function(
if phi.count_incoming() != 0 {
state.push1(phi.as_basic_value());
} else {
println!("replacing");
let basic_ty = phi.as_basic_value().get_type();
let placeholder_value = match basic_ty {
BasicTypeEnum::IntType(int_ty) => {
@ -1881,6 +1864,22 @@ fn parse_function(
}
}
let results = state.popn_save(func_sig.returns().len())?;
match results.as_slice() {
[] => {
builder.build_return(None);
}
[one_value] => {
builder.build_return(Some(one_value));
}
returns @ _ => {
// let struct_ty = llvm_sig.get_return_type().as_struct_type();
// let ret_struct = struct_ty.const_zero();
unimplemented!("multi-value returns not yet implemented")
}
}
Ok(())
}