Skip to content

Commit

Permalink
Refactored function call libfuncs to use the BlockExt trait (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Jun 5, 2024
1 parent c9b5ecd commit eacacf7
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/libfuncs/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,10 @@ pub fn build<'ctx, 'this>(
let type_info = registry.get_type(&var_info.ty)?;

if type_info.is_builtin() && type_info.is_zst(registry) {
results.push(
cont_block
.append_operation(llvm::undef(
type_info.build(context, helper, registry, metadata, &var_info.ty)?,
location,
))
.result(0)?
.into(),
);
results.push(cont_block.append_op_result(llvm::undef(
type_info.build(context, helper, registry, metadata, &var_info.ty)?,
location,
))?);
} else {
let val = cont_block.argument(count)?.into();
count += 1;
Expand Down Expand Up @@ -224,17 +219,14 @@ pub fn build<'ctx, 'this>(
let ret_layout = type_info.layout(registry)?;
(layout, offset) = layout.extend(ret_layout)?;

let pointer_val = entry
.append_operation(llvm::get_element_ptr(
context,
val,
DenseI32ArrayAttribute::new(context, &[offset as i32]),
IntegerType::new(context, 8).into(),
llvm::r#type::pointer(context, 0),
location,
))
.result(0)?
.into();
let pointer_val = entry.append_op_result(llvm::get_element_ptr(
context,
val,
DenseI32ArrayAttribute::new(context, &[offset as i32]),
IntegerType::new(context, 8).into(),
llvm::r#type::pointer(context, 0),
location,
))?;

results.push(entry.load(
context,
Expand Down

0 comments on commit eacacf7

Please sign in to comment.