-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Don't compute FnAbi for LLVM intrinsics in backends #150768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -646,10 +646,32 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { | |
| ) -> Self::Value { | ||
| let tcx = self.tcx(); | ||
|
|
||
| // FIXME remove usage of fn_abi | ||
| let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty()); | ||
| assert!(!fn_abi.ret.is_indirect()); | ||
| let fn_ty = fn_abi.llvm_type(self); | ||
| let fn_ty = instance.ty(tcx, self.typing_env()); | ||
| let fn_sig = match *fn_ty.kind() { | ||
| ty::FnDef(def_id, args) => { | ||
| tcx.instantiate_bound_regions_with_erased(tcx.fn_sig(def_id).instantiate(tcx, args)) | ||
| } | ||
| _ => unreachable!(), | ||
| }; | ||
| assert!(!fn_sig.c_variadic); | ||
wesleywiser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| let ret_layout = self.layout_of(fn_sig.output()); | ||
| let llreturn_ty = if ret_layout.is_zst() { | ||
| self.type_void() | ||
| } else { | ||
| ret_layout.immediate_llvm_type(self) | ||
| }; | ||
|
|
||
| let mut llargument_tys = Vec::with_capacity(fn_sig.inputs().len()); | ||
| for &arg in fn_sig.inputs() { | ||
| let arg_layout = self.layout_of(arg); | ||
| if arg_layout.is_zst() { | ||
| continue; | ||
| } | ||
| llargument_tys.push(arg_layout.immediate_llvm_type(self)); | ||
| } | ||
|
|
||
| let fn_ty = self.type_func(&llargument_tys, llreturn_ty); | ||
|
|
||
| let fn_ptr = if let Some(&llfn) = self.intrinsic_instances.borrow().get(&instance) { | ||
| llfn | ||
|
|
@@ -665,12 +687,11 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { | |
| let llfn = declare_raw_fn( | ||
| self, | ||
| sym, | ||
| fn_abi.llvm_cconv(self), | ||
| llvm::CCallConv, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this effectively just a lie? Or how does LLVM model the ABI for intrinsics? Is there a hidden assumption here that intrinsics only ever take ~integers/pointers that don't have any special handling in terms of ABI lowering of the arguments?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This matches what was effectively done previously. I don't know if LLVM actually cares about the calling convention for intrinsics. It recognizes intrinsics based on a builtin list of symbol names. (if you declare an |
||
| llvm::UnnamedAddr::Global, | ||
| llvm::Visibility::Default, | ||
| fn_ty, | ||
| ); | ||
| fn_abi.apply_attrs_llfn(self, llfn, Some(instance)); | ||
|
|
||
| llfn | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is the same ABI question as below - we're assuming there's no on-stack parameter passing since it's an intrinsic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extern "unadjusted"previously forcedPassMode::Directfor all arguments, which means that on-stack parameters would never occur.