Prepare struct_gep for opaque pointers
Imlement struct_gep using LLVMBuildStructGEP2 which takes an explicit type argument instead of deriving it from a pointer type.
This commit is contained in:
@@ -98,6 +98,7 @@ fn emit_aapcs_va_arg(
|
||||
// Implementation of the AAPCS64 calling convention for va_args see
|
||||
// https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst
|
||||
let va_list_addr = list.immediate();
|
||||
let va_list_ty = list.deref(bx.cx).layout.llvm_type(bx);
|
||||
let layout = bx.cx.layout_of(target_ty);
|
||||
|
||||
let mut maybe_reg = bx.build_sibling_block("va_arg.maybe_reg");
|
||||
@@ -109,11 +110,11 @@ fn emit_aapcs_va_arg(
|
||||
|
||||
let gr_type = target_ty.is_any_ptr() || target_ty.is_integral();
|
||||
let (reg_off, reg_top_index, slot_size) = if gr_type {
|
||||
let gr_offs = bx.struct_gep(va_list_addr, 7);
|
||||
let gr_offs = bx.struct_gep(va_list_ty, va_list_addr, 7);
|
||||
let nreg = (layout.size.bytes() + 7) / 8;
|
||||
(gr_offs, 3, nreg * 8)
|
||||
} else {
|
||||
let vr_off = bx.struct_gep(va_list_addr, 9);
|
||||
let vr_off = bx.struct_gep(va_list_ty, va_list_addr, 9);
|
||||
let nreg = (layout.size.bytes() + 15) / 16;
|
||||
(vr_off, 5, nreg * 16)
|
||||
};
|
||||
@@ -141,7 +142,7 @@ fn emit_aapcs_va_arg(
|
||||
maybe_reg.cond_br(use_stack, &on_stack.llbb(), &in_reg.llbb());
|
||||
|
||||
let top_type = bx.type_i8p();
|
||||
let top = in_reg.struct_gep(va_list_addr, reg_top_index);
|
||||
let top = in_reg.struct_gep(va_list_ty, va_list_addr, reg_top_index);
|
||||
let top = in_reg.load(top_type, top, bx.tcx().data_layout.pointer_align.abi);
|
||||
|
||||
// reg_value = *(@top + reg_off_v);
|
||||
|
||||
Reference in New Issue
Block a user