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

Prevent using #[target_feature] on lang item functions #115910

Merged
merged 1 commit into from
Sep 22, 2023
Merged

Prevent using #[target_feature] on lang item functions #115910

merged 1 commit into from
Sep 22, 2023

Conversation

eduardosm
Copy link
Contributor

Fixes #109411 and also prevents from using #[target_feature] on other fn lang items to mitigate the concerns from #109411 (comment).

@rustbot
Copy link
Collaborator

rustbot commented Sep 17, 2023

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 17, 2023
@cjgillot
Copy link
Contributor

This check should probably happen in rustc_passes::check_attr, which is meant to verify that attributes are well-formed.

@eduardosm
Copy link
Contributor Author

This check should probably happen in rustc_passes::check_attr, which is meant to verify that attributes are well-formed.

I'm not so sure. Moving the check to check_attr would require figuring there both if the item is a lang item and if it is has target features. In collect_item_extended we already know we are visiting a lang item (and which one in particular), so it only needs to check for the target_feature attribute. Maybe it could be improved by using codegen_fn_attrs to avoid looping over the attributes.

In general, I've seen that check_attr are more like syntactic checks, e.g. that attributes are used on the correct target kind.

@cjgillot
Copy link
Contributor

What about just check for a lang attribute?

@eduardosm
Copy link
Contributor Author

What about just check for a lang attribute?

I'll try that with hir::lang_items::extract, which will also take care of #[panic_handler].

@cjgillot
Copy link
Contributor

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Sep 21, 2023

📌 Commit 9102816 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 21, 2023
@bors
Copy link
Contributor

bors commented Sep 22, 2023

⌛ Testing commit 9102816 with merge aace2df...

@bors
Copy link
Contributor

bors commented Sep 22, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing aace2df to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 22, 2023
@bors bors merged commit aace2df into rust-lang:master Sep 22, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 22, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (aace2df): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.4% [0.8%, 2.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 631.519s -> 632.249s (0.12%)
Artifact size: 317.47 MiB -> 317.50 MiB (0.01%)

@eduardosm eduardosm deleted the lang-fns-target-features branch July 18, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[target_feature] is allowed on #[panic_handler] with target_feature 1.1
6 participants