Remove unsound target_feature_inline_always feature#156242
Remove unsound target_feature_inline_always feature#156242Jamesbarford wants to merge 6 commits into
target_feature_inline_always feature#156242Conversation
|
cc @Amanieu, @folkertdev, @sayantn Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
|
|
That's unfortunate, but makes sense. One thing I'm worried about here is terrible merge conflicts with |
We already do error for that, so what are you changing here? So this amounts to "just" removing the Also Cc @davidtwco |
|
No that's what happens when you update the generators and the inline annotation on most generated functions changes. Those changes are uninteresting but really inflate the line count. |
Yes 👍, I'll remove that from the description |
target_feature_inline_always feature
|
I had suggested to @Jamesbarford that we remove the uses in stdarch in this PR just to avoid the hassle of having to wait for syncs to happen before being able to make the change in rustc, but I don't feel too strongly, if we'd prefer to land the change in stdarch first and then land this after a sync, happy to do it that way too. |
|
We're not in a rush here I think, and the sync with |
This comment has been minimized.
This comment has been minimized.
…pport, reinstating error message and providing a link to the tracking issue for the full rationale.
a0d1b36 to
311cda6
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
There was a problem hiding this comment.
So the stdarch changes have landed and synced, and just the rustc changes remain? Sorry, I didn't realize this was waiting for me.
@rustbot author
| /// Get LLVM attribute for the provided inline heuristic. | ||
| pub(crate) fn inline_attr<'ll, 'tcx>( | ||
| #[inline] | ||
| fn inline_attr<'ll, 'tcx>( |
There was a problem hiding this comment.
There was a problem hiding this comment.
Happy to revert if you feel it best.
However fn inline_attr(...) as it stands in this PR cleans up the body of fn llfn_attrs_from_instance(...) to be as follows for adding the inline attribute;
if let Some(instance) = instance
&& let Some(inline_attr) = inline_attr(cx, tcx, instance)
{
to_add.push(inline_attr);
}It's quite nice the logic is self contained in the fn inline_attr(...) function, this also seems to follow the pattern for the other attributes being added.
There was a problem hiding this comment.
405214d I've reverted as best I can. Due to other code changes unrelated to #[inline(always)] + #[target_feature(enable = "...")] it has rendered a 1:1 reversal implausible.
There was a problem hiding this comment.
Okay, so someone will have to actually understand the change to this function then to tell whether this is a clean revert. Without digging into this code (which would take some time as I have no context for it) I can't tell why these lines of code got moved around. I hope one of the people I pinged above can take a look as they might already have this context. (Or maybe @saethlin does.)
|
Reminder, once the PR becomes ready for a review, use |
…`register_removed(...)` call
This comment has been minimized.
This comment has been minimized.
…inealways + target feature changes, factoring in subsequent codebase changes
View all comments
Summary
target_feature_inline_always#[inline]& regenerate stdarch.Why?
Succinctly; the feature relies on LLVMs
AlwaysInlinerPass()running before LLVMs heuristic based inliner pass. Which is not a basis for sound code.This has been discussed in the tracking issue.
If the ordering of the passes were to change, of which they have in the past, it is very possible we could inline functions across callsites with mismatching target features leading to unsound code. Checks proposed in; #155426 would only take into account caller -> callee which is not enough to guard against possibly of generating unsound code if the pass ordering were to change.
There doesn't seem to be a way, presently, this this mechanism to provide soundness guarantees nor does it seem like
AlwaysInlinerPass()is a desired feature of LLVM, which this feature relies on.r? @RalfJung