Add elementtype attributes for llvm.arm.ldrex/strex intrinsics
These intrinsics (and a few more, but there are the only ones exposed by stdarch) require an elementtype attribute in LLVM 15.
This commit is contained in:
parent
ff693dc7b8
commit
f653d3ab30
3 changed files with 41 additions and 0 deletions
|
@ -569,6 +569,22 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
&[cmse_nonsecure_call],
|
||||
);
|
||||
}
|
||||
|
||||
// Some intrinsics require that an elementtype attribute (with the pointee type of a
|
||||
// pointer argument) is added to the callsite.
|
||||
let element_type_index = unsafe { llvm::LLVMRustGetElementTypeArgIndex(callsite) };
|
||||
if element_type_index >= 0 {
|
||||
let arg_ty = self.args[element_type_index as usize].layout.ty;
|
||||
let pointee_ty = arg_ty.builtin_deref(true).expect("Must be pointer argument").ty;
|
||||
let element_type_attr = unsafe {
|
||||
llvm::LLVMRustCreateElementTypeAttr(bx.llcx, bx.layout_of(pointee_ty).llvm_type(bx))
|
||||
};
|
||||
attributes::apply_to_callsite(
|
||||
callsite,
|
||||
llvm::AttributePlace::Argument(element_type_index as u32),
|
||||
&[element_type_attr],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue