Skip to content

Commit f78dde6

Browse files
authored
Unrolled build for #151336
Rollup merge of #151336 - port_rustc_codegen_attrs, r=JonathanBrouwer Port rustc codegen attrs Tracking issue: #131229 two more quick ones r? @JonathanBrouwer
2 parents 158ae9e + 3e731f7 commit f78dde6

6 files changed

Lines changed: 44 additions & 7 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,27 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcHasIncoherentInherentImplsParse
320320
]);
321321
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHasIncoherentInherentImpls;
322322
}
323+
324+
pub(crate) struct RustcNounwindParser;
325+
326+
impl<S: Stage> NoArgsAttributeParser<S> for RustcNounwindParser {
327+
const PATH: &[Symbol] = &[sym::rustc_nounwind];
328+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
329+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
330+
Allow(Target::Fn),
331+
Allow(Target::ForeignFn),
332+
Allow(Target::Method(MethodKind::Inherent)),
333+
Allow(Target::Method(MethodKind::TraitImpl)),
334+
Allow(Target::Method(MethodKind::Trait { body: true })),
335+
]);
336+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNounwind;
337+
}
338+
339+
pub(crate) struct RustcOffloadKernelParser;
340+
341+
impl<S: Stage> NoArgsAttributeParser<S> for RustcOffloadKernelParser {
342+
const PATH: &[Symbol] = &[sym::rustc_offload_kernel];
343+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
344+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
345+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcOffloadKernel;
346+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ use crate::attributes::rustc_internal::{
7878
RustcLintDiagnosticsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser,
7979
RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser,
8080
RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser,
81-
RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser,
82-
RustcSimdMonomorphizeLaneLimitParser,
81+
RustcNoImplicitAutorefsParser, RustcNounwindParser, RustcObjectLifetimeDefaultParser,
82+
RustcOffloadKernelParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser,
8383
};
8484
use crate::attributes::semantics::MayDangleParser;
8585
use crate::attributes::stability::{
@@ -296,6 +296,8 @@ attribute_parsers!(
296296
Single<WithoutArgs<RustcMainParser>>,
297297
Single<WithoutArgs<RustcNeverReturnsNullPointerParser>>,
298298
Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
299+
Single<WithoutArgs<RustcNounwindParser>>,
300+
Single<WithoutArgs<RustcOffloadKernelParser>>,
299301
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
300302
Single<WithoutArgs<RustcReallocatorParser>>,
301303
Single<WithoutArgs<RustcShouldNotBeCalledOnConstItems>>,

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,12 @@ fn process_builtin_attrs(
347347
AttributeKind::RustcAllocatorZeroed => {
348348
codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR_ZEROED
349349
}
350+
AttributeKind::RustcNounwind => {
351+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND
352+
}
353+
AttributeKind::RustcOffloadKernel => {
354+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::OFFLOAD_KERNEL
355+
}
350356
_ => {}
351357
}
352358
}
@@ -356,14 +362,10 @@ fn process_builtin_attrs(
356362
};
357363

358364
match name {
359-
sym::rustc_nounwind => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND,
360365
sym::patchable_function_entry => {
361366
codegen_fn_attrs.patchable_function_entry =
362367
parse_patchable_function_entry(tcx, attr);
363368
}
364-
sym::rustc_offload_kernel => {
365-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::OFFLOAD_KERNEL
366-
}
367369
_ => {}
368370
}
369371
}

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,15 @@ pub enum AttributeKind {
981981
/// Represents `#[rustc_no_implicit_autorefs]`
982982
RustcNoImplicitAutorefs,
983983

984+
/// Represents `#[rustc_nounwind]`
985+
RustcNounwind,
986+
984987
/// Represents `#[rustc_object_lifetime_default]`.
985988
RustcObjectLifetimeDefault,
986989

990+
/// Represents `#[rustc_offload_kernel]`
991+
RustcOffloadKernel,
992+
987993
/// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]`
988994
RustcPassIndirectlyInNonRusticAbis(Span),
989995

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ impl AttributeKind {
122122
RustcMustImplementOneOf { .. } => No,
123123
RustcNeverReturnsNullPointer => Yes,
124124
RustcNoImplicitAutorefs => Yes,
125+
RustcNounwind => No,
125126
RustcObjectLifetimeDefault => No,
127+
RustcOffloadKernel => Yes,
126128
RustcPassIndirectlyInNonRusticAbis(..) => No,
127129
RustcReallocator => No,
128130
RustcScalableVector { .. } => Yes,

compiler/rustc_passes/src/check_attr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
322322
| AttributeKind::RustcAllocatorZeroedVariant { .. }
323323
| AttributeKind::RustcDeallocator
324324
| AttributeKind::RustcReallocator
325+
| AttributeKind::RustcNounwind
326+
| AttributeKind::RustcOffloadKernel
325327
) => { /* do nothing */ }
326328
Attribute::Unparsed(attr_item) => {
327329
style = Some(attr_item.style);
@@ -390,7 +392,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
390392
| sym::rustc_partition_reused
391393
| sym::rustc_partition_codegened
392394
| sym::rustc_expected_cgu_reuse
393-
| sym::rustc_nounwind
394395
// crate-level attrs, are checked below
395396
| sym::feature
396397
| sym::register_tool

0 commit comments

Comments
 (0)