Skip to content

Commit ec37393

Browse files
committed
Auto merge of #147074 - matthiaskrgr:rollup-sm3owsd, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #145113 (resolve: Do not finalize shadowed bindings) - #146523 (Demote both armebv7r-none-* targets.) - #146704 (port `#[debugger_visualizer]` to the new attribute system) - #146758 (Stop linking rs{begin,end} objects on x86_64-*-windows-gnu) - #146778 (Use standard attribute logic for allocator shim) - #146849 (Reduce some uses of `LegacyBang`) - #147016 (fix doc comments to be more standard) - #147027 (Add new `tyalias` intra-doc link disambiguator) - #147031 (mbe: Simplify check_redundant_vis_repetition) - #147058 (Ignore more failing ui tests for GCC backend) Failed merges: - #147046 (Rename `rust.use-lld` to `rust.bootstrap-override-lld`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 54a8a1d + a91918f commit ec37393

File tree

242 files changed

+946
-644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+946
-644
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
use rustc_hir::attrs::{DebugVisualizer, DebuggerVisualizerType};
2+
3+
use super::prelude::*;
4+
5+
pub(crate) struct DebuggerViualizerParser;
6+
7+
impl<S: Stage> CombineAttributeParser<S> for DebuggerViualizerParser {
8+
const PATH: &[Symbol] = &[sym::debugger_visualizer];
9+
const ALLOWED_TARGETS: AllowedTargets =
10+
AllowedTargets::AllowList(&[Allow(Target::Mod), Allow(Target::Crate)]);
11+
const TEMPLATE: AttributeTemplate = template!(
12+
List: &[r#"natvis_file = "...", gdb_script_file = "...""#],
13+
"https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute"
14+
);
15+
16+
type Item = DebugVisualizer;
17+
const CONVERT: ConvertFn<Self::Item> = |v, _| AttributeKind::DebuggerVisualizer(v);
18+
19+
fn extend<'c>(
20+
cx: &'c mut AcceptContext<'_, '_, S>,
21+
args: &'c ArgParser<'_>,
22+
) -> impl IntoIterator<Item = Self::Item> + 'c {
23+
let Some(l) = args.list() else {
24+
cx.expected_list(args.span().unwrap_or(cx.attr_span));
25+
return None;
26+
};
27+
let Some(single) = l.single() else {
28+
cx.expected_single_argument(l.span);
29+
return None;
30+
};
31+
let Some(mi) = single.meta_item() else {
32+
cx.expected_name_value(single.span(), None);
33+
return None;
34+
};
35+
let path = mi.path().word_sym();
36+
let visualizer_type = match path {
37+
Some(sym::natvis_file) => DebuggerVisualizerType::Natvis,
38+
Some(sym::gdb_script_file) => DebuggerVisualizerType::GdbPrettyPrinter,
39+
_ => {
40+
cx.expected_specific_argument(
41+
mi.path().span(),
42+
&[sym::natvis_file, sym::gdb_script_file],
43+
);
44+
return None;
45+
}
46+
};
47+
48+
let Some(path) = mi.args().name_value() else {
49+
cx.expected_name_value(single.span(), path);
50+
return None;
51+
};
52+
53+
let Some(path) = path.value_as_str() else {
54+
cx.expected_string_literal(path.value_span, Some(path.value_as_lit()));
55+
return None;
56+
};
57+
58+
Some(DebugVisualizer { span: mi.span(), visualizer_type, path })
59+
}
60+
}

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub(crate) mod cfg_old;
3636
pub(crate) mod codegen_attrs;
3737
pub(crate) mod confusables;
3838
pub(crate) mod crate_level;
39+
pub(crate) mod debugger;
3940
pub(crate) mod deprecation;
4041
pub(crate) mod dummy;
4142
pub(crate) mod inline;

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::attributes::crate_level::{
2828
CrateNameParser, MoveSizeLimitParser, NoCoreParser, NoStdParser, PatternComplexityLimitParser,
2929
RecursionLimitParser, RustcCoherenceIsCoreParser, TypeLengthLimitParser,
3030
};
31+
use crate::attributes::debugger::DebuggerViualizerParser;
3132
use crate::attributes::deprecation::DeprecationParser;
3233
use crate::attributes::dummy::DummyParser;
3334
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
@@ -163,6 +164,7 @@ attribute_parsers!(
163164
// tidy-alphabetical-start
164165
Combine<AllowConstFnUnstableParser>,
165166
Combine<AllowInternalUnstableParser>,
167+
Combine<DebuggerViualizerParser>,
166168
Combine<ForceTargetFeatureParser>,
167169
Combine<LinkParser>,
168170
Combine<ReprParser>,

compiler/rustc_codegen_llvm/src/abi.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,13 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
538538

539539
// If the declaration has an associated instance, compute extra attributes based on that.
540540
if let Some(instance) = instance {
541-
llfn_attrs_from_instance(cx, llfn, instance);
541+
llfn_attrs_from_instance(
542+
cx,
543+
cx.tcx,
544+
llfn,
545+
&cx.tcx.codegen_instance_attrs(instance.def),
546+
Some(instance),
547+
);
542548
}
543549
}
544550

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ use rustc_ast::expand::allocator::{
55
};
66
use rustc_codegen_ssa::traits::BaseTypeCodegenMethods as _;
77
use rustc_middle::bug;
8+
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
89
use rustc_middle::ty::TyCtxt;
910
use rustc_session::config::{DebugInfo, OomStrategy};
1011
use rustc_symbol_mangling::mangle_internal_symbol;
11-
use smallvec::SmallVec;
1212

13+
use crate::attributes::llfn_attrs_from_instance;
1314
use crate::builder::SBuilder;
1415
use crate::declare::declare_simple_fn;
1516
use crate::llvm::{self, FALSE, TRUE, Type, Value};
16-
use crate::{SimpleCx, attributes, debuginfo, llvm_util};
17+
use crate::{SimpleCx, attributes, debuginfo};
1718

1819
pub(crate) unsafe fn codegen(
1920
tcx: TyCtxt<'_>,
@@ -149,18 +150,8 @@ fn create_wrapper_function(
149150
ty,
150151
);
151152

152-
let mut attrs = SmallVec::<[_; 2]>::new();
153-
154-
let target_cpu = llvm_util::target_cpu(tcx.sess);
155-
let target_cpu_attr = llvm::CreateAttrStringValue(cx.llcx, "target-cpu", target_cpu);
156-
157-
let tune_cpu_attr = llvm_util::tune_cpu(tcx.sess)
158-
.map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu));
159-
160-
attrs.push(target_cpu_attr);
161-
attrs.extend(tune_cpu_attr);
162-
163-
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &attrs);
153+
let attrs = CodegenFnAttrs::new();
154+
llfn_attrs_from_instance(cx, tcx, llfn, &attrs, None);
164155

165156
let no_return = if no_return {
166157
// -> ! DIFlagNoReturn
@@ -171,12 +162,6 @@ fn create_wrapper_function(
171162
None
172163
};
173164

174-
if tcx.sess.must_emit_unwind_tables() {
175-
let uwtable =
176-
attributes::uwtable_attr(cx.llcx, tcx.sess.opts.unstable_opts.use_sync_unwind);
177-
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &[uwtable]);
178-
}
179-
180165
let llbb = unsafe { llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, c"entry".as_ptr()) };
181166
let mut bx = SBuilder::build(&cx, llbb);
182167

0 commit comments

Comments
 (0)