AMDGPU ignores noinline
when it slaps alwaysinline
everywhere.
Allow target specs to disable that attribute.
This commit is contained in:
parent
1c0603e55f
commit
bfddedee37
3 changed files with 10 additions and 5 deletions
|
@ -16,6 +16,7 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use rustc::session::config::Sanitizer;
|
use rustc::session::config::Sanitizer;
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
|
use rustc::ty::layout::HasTyCtxt;
|
||||||
use rustc::ty::query::Providers;
|
use rustc::ty::query::Providers;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
|
@ -32,12 +33,16 @@ use value::Value;
|
||||||
|
|
||||||
/// Mark LLVM function to use provided inline heuristic.
|
/// Mark LLVM function to use provided inline heuristic.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inline(val: &'ll Value, inline: InlineAttr) {
|
pub fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
|
||||||
use self::InlineAttr::*;
|
use self::InlineAttr::*;
|
||||||
match inline {
|
match inline {
|
||||||
Hint => Attribute::InlineHint.apply_llfn(Function, val),
|
Hint => Attribute::InlineHint.apply_llfn(Function, val),
|
||||||
Always => Attribute::AlwaysInline.apply_llfn(Function, val),
|
Always => Attribute::AlwaysInline.apply_llfn(Function, val),
|
||||||
Never => Attribute::NoInline.apply_llfn(Function, val),
|
Never => {
|
||||||
|
if cx.tcx().sess.target.target.arch != "amdgpu" {
|
||||||
|
Attribute::NoInline.apply_llfn(Function, val);
|
||||||
|
}
|
||||||
|
},
|
||||||
None => {
|
None => {
|
||||||
Attribute::InlineHint.unapply_llfn(Function, val);
|
Attribute::InlineHint.unapply_llfn(Function, val);
|
||||||
Attribute::AlwaysInline.unapply_llfn(Function, val);
|
Attribute::AlwaysInline.unapply_llfn(Function, val);
|
||||||
|
@ -142,7 +147,7 @@ pub fn from_fn_attrs(
|
||||||
let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id))
|
let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id))
|
||||||
.unwrap_or(CodegenFnAttrs::new());
|
.unwrap_or(CodegenFnAttrs::new());
|
||||||
|
|
||||||
inline(llfn, codegen_fn_attrs.inline);
|
inline(cx, llfn, codegen_fn_attrs.inline);
|
||||||
|
|
||||||
// The `uwtable` attribute according to LLVM is:
|
// The `uwtable` attribute according to LLVM is:
|
||||||
//
|
//
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub fn get_fn(
|
||||||
debug!("get_fn: not casting pointer!");
|
debug!("get_fn: not casting pointer!");
|
||||||
|
|
||||||
if instance.def.is_inline(tcx) {
|
if instance.def.is_inline(tcx) {
|
||||||
attributes::inline(llfn, attributes::InlineAttr::Hint);
|
attributes::inline(cx, llfn, attributes::InlineAttr::Hint);
|
||||||
}
|
}
|
||||||
attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id()));
|
attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id()));
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||||
|
|
||||||
debug!("predefine_fn: mono_ty = {:?} instance = {:?}", mono_ty, instance);
|
debug!("predefine_fn: mono_ty = {:?} instance = {:?}", mono_ty, instance);
|
||||||
if instance.def.is_inline(cx.tcx) {
|
if instance.def.is_inline(cx.tcx) {
|
||||||
attributes::inline(lldecl, attributes::InlineAttr::Hint);
|
attributes::inline(cx, lldecl, attributes::InlineAttr::Hint);
|
||||||
}
|
}
|
||||||
attributes::from_fn_attrs(cx, lldecl, Some(instance.def.def_id()));
|
attributes::from_fn_attrs(cx, lldecl, Some(instance.def.def_id()));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue