Skip to content
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

Rollup of 7 pull requests #81810

Merged
merged 21 commits into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
58307bc
stabilize `peekable_next_if`
Stupremee Dec 13, 2020
34cb4bc
bump rust version for peekable_next_if feature
Stupremee Dec 13, 2020
c351107
Document how `MaybeUninit<Struct>` can be initialized.
rodrimati1992 Jan 31, 2021
0974026
Removed trailing whitespace
rodrimati1992 Jan 31, 2021
aa83e2a
Update maybe_uninit.rs
rodrimati1992 Jan 31, 2021
21c2343
Update comment about leaking
rodrimati1992 Jan 31, 2021
1020784
BTreeMap: make Ord bound explicit, compile-test its absence
ssomers Jan 30, 2021
fbe109a
Avoid a hir access inside get_static
bjorn3 Feb 2, 2021
360f8f8
Make rustdoc respect `--error-format short`
poliorcetics Feb 2, 2021
da53655
Use is_local instead of as_local
bjorn3 Feb 4, 2021
716d2cd
Add a test for the shortness format in rustdoc
poliorcetics Feb 4, 2021
eb5e2d0
Never MIR inline functions with a different instruction set
tmiasko Feb 5, 2021
c89b9d9
Small refactor with Iterator::reduce
camsteffen Feb 4, 2021
ceda547
Bump peekable_next_if to rust 1.51.0
dtolnay Feb 5, 2021
cc882fc
Rollup merge of #80011 - Stupremee:stabilize-peekable-next-if, r=dtolnay
m-ou-se Feb 5, 2021
43b3adb
Rollup merge of #81580 - rodrimati1992:patch-2, r=dtolnay
m-ou-se Feb 5, 2021
78be1aa
Rollup merge of #81610 - ssomers:btree_emphasize_ord_bound, r=dtolnay
m-ou-se Feb 5, 2021
add80c9
Rollup merge of #81664 - bjorn3:no_codegen_hir, r=lcnr
m-ou-se Feb 5, 2021
e8aaa14
Rollup merge of #81675 - poliorcetics:respect-shortness, r=jyn514
m-ou-se Feb 5, 2021
728c955
Rollup merge of #81753 - tmiasko:inline-instruction-set, r=oli-obk
m-ou-se Feb 5, 2021
51c6803
Rollup merge of #81795 - camsteffen:diagnostics-reduce, r=oli-obk
m-ou-se Feb 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub enum InlineAttr {
Never,
}

#[derive(Clone, Encodable, Decodable, Debug)]
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
pub enum InstructionSetAttr {
ArmA32,
ArmT32,
Expand Down
80 changes: 24 additions & 56 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ use crate::value::Value;
use libc::c_uint;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::const_cstr;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::Node;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
read_target_uint, Allocation, ErrorHandled, GlobalAlloc, Pointer,
};
use rustc_middle::mir::mono::MonoItem;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::sym;
use rustc_target::abi::{AddressSpace, Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size};
use tracing::debug;

Expand Down Expand Up @@ -209,70 +206,42 @@ impl CodegenCx<'ll, 'tcx> {

let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all());
let sym = self.tcx.symbol_name(instance).name;
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);

debug!("get_static: sym={} instance={:?}", sym, instance);
debug!("get_static: sym={} instance={:?} fn_attrs={:?}", sym, instance, fn_attrs);

let g = if let Some(local_def_id) = def_id.as_local() {
let id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
let g = if def_id.is_local() && !self.tcx.is_foreign_item(def_id) {
let llty = self.layout_of(ty).llvm_type(self);
// FIXME: refactor this to work without accessing the HIR
let (g, attrs) = match self.tcx.hir().get(id) {
Node::Item(&hir::Item { attrs, kind: hir::ItemKind::Static(..), .. }) => {
if let Some(g) = self.get_declared_value(sym) {
if self.val_ty(g) != self.type_ptr_to(llty) {
span_bug!(self.tcx.def_span(def_id), "Conflicting types for static");
}
}

let g = self.declare_global(sym, llty);

if !self.tcx.is_reachable_non_generic(local_def_id) {
unsafe {
llvm::LLVMRustSetVisibility(g, llvm::Visibility::Hidden);
}
}

(g, attrs)
if let Some(g) = self.get_declared_value(sym) {
if self.val_ty(g) != self.type_ptr_to(llty) {
span_bug!(self.tcx.def_span(def_id), "Conflicting types for static");
}
}

Node::ForeignItem(&hir::ForeignItem {
ref attrs,
kind: hir::ForeignItemKind::Static(..),
..
}) => {
let fn_attrs = self.tcx.codegen_fn_attrs(local_def_id);
(check_and_apply_linkage(&self, &fn_attrs, ty, sym, def_id), &**attrs)
}

item => bug!("get_static: expected static, found {:?}", item),
};

debug!("get_static: sym={} attrs={:?}", sym, attrs);
let g = self.declare_global(sym, llty);

for attr in attrs {
if self.tcx.sess.check_name(attr, sym::thread_local) {
llvm::set_thread_local_mode(g, self.tls_model);
if !self.tcx.is_reachable_non_generic(def_id) {
unsafe {
llvm::LLVMRustSetVisibility(g, llvm::Visibility::Hidden);
}
}

g
} else {
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
debug!("get_static: sym={} item_attr={:?}", sym, self.tcx.item_attrs(def_id));
check_and_apply_linkage(&self, &fn_attrs, ty, sym, def_id)
};

let attrs = self.tcx.codegen_fn_attrs(def_id);
let g = check_and_apply_linkage(&self, &attrs, ty, sym, def_id);

// Thread-local statics in some other crate need to *always* be linked
// against in a thread-local fashion, so we need to be sure to apply the
// thread-local attribute locally if it was present remotely. If we
// don't do this then linker errors can be generated where the linker
// complains that one object files has a thread local version of the
// symbol and another one doesn't.
if attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) {
llvm::set_thread_local_mode(g, self.tls_model);
}
// Thread-local statics in some other crate need to *always* be linked
// against in a thread-local fashion, so we need to be sure to apply the
// thread-local attribute locally if it was present remotely. If we
// don't do this then linker errors can be generated where the linker
// complains that one object files has a thread local version of the
// symbol and another one doesn't.
if fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) {
llvm::set_thread_local_mode(g, self.tls_model);
}

if !def_id.is_local() {
let needs_dll_storage_attr = self.use_dll_storage_attrs && !self.tcx.is_foreign_item(def_id) &&
// ThinLTO can't handle this workaround in all cases, so we don't
// emit the attrs. Instead we make them unnecessary by disallowing
Expand Down Expand Up @@ -304,8 +273,7 @@ impl CodegenCx<'ll, 'tcx> {
}
}
}
g
};
}

if self.use_dll_storage_attrs && self.tcx.is_dllimport_foreign_item(def_id) {
// For foreign (native) libs we know the exact storage type to use.
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_mir/src/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ impl Inliner<'tcx> {
return false;
}

if self.codegen_fn_attrs.instruction_set != codegen_fn_attrs.instruction_set {
debug!("`callee has incompatible instruction set - not inlining");
return false;
}

let hinted = match codegen_fn_attrs.inline {
// Just treat inline(always) as a hint for now,
// there are cases that prevent inlining that we
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,9 @@ impl<'a> Resolver<'a> {
_,
) = binding.kind
{
let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor");
let def_id = self.parent(ctor_def_id).expect("no parent for a constructor");
let fields = self.field_names.get(&def_id)?;
let first_field = fields.first()?; // Handle `struct Foo()`
return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)));
return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()`
}
None
}
Expand Down
Loading