Skip to content

Skip redundant monomorphization checks - #164330

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
charliermarsh:charlie/skip-redundant-abi-checks
Oct 21, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
charliermarsh:charlie/skip-redundant-abi-checks

Conversation

@charliermarsh

Copy link
Copy Markdown
Contributor

Summary

This PR attempts to avoid unnecessary work during call-site ABI checks. On main, we instantiate generic arguments and normalize the callee type, but then immediately return for Rust ABIs and LLVM intrinsics.

Since the ABI doesn't depend on generic arguments, we can instead check it first and skip that preparation if the subsequent checks would be a no-op.

@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 Oct 14, 2026
@rustbot

rustbot commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

r? @adwinwhite

rustbot has assigned @adwinwhite.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 18 candidates

@rust-log-analyzer

This comment has been minimized.

@Kobzol

Kobzol commented Oct 14, 2026

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 14, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 14, 2026
…ks, r=<try>

Skip redundant monomorphization checks
@rust-bors

rust-bors Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: dea04eb (dea04eb7af15ea77b8bdb45a3a68294aa5361af4)
Base parent: 7df8138 (7df81381d027710708209f36b98d11b1c88f8d2e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (dea04eb): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@bors rollup=iffy rustc-perf
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.8%, -0.2%] 2
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.2%] 6
All ❌✅ (primary) -0.5% [-0.8%, -0.2%] 2

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (secondary 1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.902s -> 489.636s (-0.05%)
Artifact size: 407.05 MiB -> 407.13 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 15, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member

CI failure is sus. Re-triggering it.

@adwinwhite

Copy link
Copy Markdown
Contributor

Given that this fast path has a soundness hole (see check_call_site_abi), I don't think we should duplicate it outside.
Perhaps we can move the instantiate_mir_and_normalize_erasing_regions into check_call_site_abi and skip in check_call_site_abi?

@adwinwhite adwinwhite left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 213 to 214
instance: Instance<'tcx>,
caller: InstanceKind<'tcx>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace caller: InstanceKind with caller: Instance and avoid the redundant arguments?

Comment on lines +216 to +221
let extern_abi = callee.fn_sig(tcx).abi();
// The ABI does not depend on generic arguments.
let extern_abi = match *callee.kind() {
ty::FnDef(def_id, _) => tcx.fn_sig(def_id).skip_binder().abi(),
_ => callee.fn_sig(tcx).abi(),
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can call .fn_sig(tcx).abi() as before?

@adwinwhite

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a498a55 has been approved by adwinwhite

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@rust-bors rust-bors Bot 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 Oct 21, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 21, 2026
…nt-abi-checks, r=adwinwhite

Skip redundant monomorphization checks

## Summary

This PR attempts to avoid unnecessary work during call-site ABI checks. On main, we instantiate generic arguments and normalize the callee type, but then immediately return for Rust ABIs and LLVM intrinsics.

Since the ABI doesn't depend on generic arguments, we can instead check it first and skip that preparation if the subsequent checks would be a no-op.
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #162460 (Feat - `#[inline(always)] + #[target_feature(enable = "....")]` #2)
 - #163485 (`rustc_builtin_macros` cleanup, part 8)
 - #164578 (Don't ignore unknown LLVM diagnostics)
 - #162369 (Document the `recursion_limit` built-in attribute)
 - #162840 (tier 3 target policy: target CPU and features must be supported by upstream backend)
 - #164330 (Skip redundant monomorphization checks)
 - #164656 (stabilize ExitCodeExt for Windows)
 - #164660 (Touch up attribute docs)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 21, 2026
…nt-abi-checks, r=adwinwhite

Skip redundant monomorphization checks

## Summary

This PR attempts to avoid unnecessary work during call-site ABI checks. On main, we instantiate generic arguments and normalize the callee type, but then immediately return for Rust ABIs and LLVM intrinsics.

Since the ABI doesn't depend on generic arguments, we can instead check it first and skip that preparation if the subsequent checks would be a no-op.
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #162460 (Feat - `#[inline(always)] + #[target_feature(enable = "....")]` #2)
 - #163485 (`rustc_builtin_macros` cleanup, part 8)
 - #164457 (Add `vec_visualizer` lldb test)
 - #161253 (Implement `AsMut<T>` and `AsRef<T>` for `!`.)
 - #162369 (Document the `recursion_limit` built-in attribute)
 - #162840 (tier 3 target policy: target CPU and features must be supported by upstream backend)
 - #164329 (use default_field_values in declare_lint)
 - #164330 (Skip redundant monomorphization checks)
 - #164527 (doc: added addtional docs for Write)
 - #164656 (stabilize ExitCodeExt for Windows)
 - #164660 (Touch up attribute docs)
 - #164681 (tidy: use repository-relative path for style checks)
 - #164688 (re-enable test_dir_remove_dir test on QNX)
@rust-bors
rust-bors Bot merged commit 7658469 into rust-lang:main Oct 21, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
Rollup merge of #164330 - charliermarsh:charlie/skip-redundant-abi-checks, r=adwinwhite

Skip redundant monomorphization checks

## Summary

This PR attempts to avoid unnecessary work during call-site ABI checks. On main, we instantiate generic arguments and normalize the callee type, but then immediately return for Rust ABIs and LLVM intrinsics.

Since the ABI doesn't depend on generic arguments, we can instead check it first and skip that preparation if the subsequent checks would be a no-op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

7 participants