Skip to content

Re-enable extension of bool return values on x86_64 - #163917

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
saethlin:bool-return-extend
Oct 10, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
saethlin:bool-return-extend

Conversation

@saethlin

@saethlin saethlin commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

View all comments

I think this fixes #163911

Though the test here is a bit hard to figure out, I'm not sure under what conditions expectation goes in the left or the right column. Do I decide that per-target or per-instance? Because x86_64 seems obligated to extend bool returns, so whether it is a "target that extends" or not depends on the type we're dealing with.

I also noticed that because of how the test is written, if codegen starts adding a zeroext on a return type where it is wrong to do so, the test will pass anyway.

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

rustbot commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

workingjubilee is currently at their maximum review capacity.
They may take a while to respond.

@BoxyUwU

BoxyUwU commented Oct 7, 2026

Copy link
Copy Markdown
Member

is this worth a stable/beta backport?

@jieyouxu

jieyouxu commented Oct 7, 2026

Copy link
Copy Markdown
Member

is this worth a stable/beta backport?

Nominating just in case.
@rustbot label: +stable-nominated +beta-nominated

@rustbot rustbot added beta-nominated Nominated for backporting to the compiler in the beta channel. stable-nominated Nominated for backporting to the compiler in the stable channel. labels Oct 7, 2026
@jieyouxu jieyouxu added the O-x86_64 Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64) label Oct 7, 2026

@asquared31415 asquared31415 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.

This PR should fix the issue, the emitted LLVM IR returns to what was emitted in 1.98. A small nit on the conditions to clean it up a bit though.

View changes since this review

Comment thread compiler/rustc_target/src/callconv/x86_64.rs Outdated
@saethlin
saethlin force-pushed the bool-return-extend branch from 39167e7 to 61f40b0 Compare October 7, 2026 22:56
@rustbot

rustbot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

beta backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them.

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Oct 8, 2026
@rustbot

rustbot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

stable backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them.

@rustbot rustbot added the stable-accepted Accepted for backporting to the compiler in the stable channel. label Oct 8, 2026
@apiraino

apiraino commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

I have approved the backports without this PR being yet properly reviewed and merged (sorryu about that)

r? compiler

@rustbot rustbot assigned JohnTitor and unassigned workingjubilee Oct 8, 2026
@jieyouxu

jieyouxu commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

A random reroll here is likely unhelpful, ABI handling experts are scarce. I'll ask in the private channel. I'll do a review pass as well.

@jieyouxu jieyouxu left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Change itself looks right to me, at least from what I can gather. Some non-blocking nits.
@rustbot author

View changes since this review

Comment thread compiler/rustc_target/src/callconv/x86_64.rs Outdated
Comment thread compiler/rustc_target/src/callconv/x86_64.rs Outdated
Comment on lines 34 to -36
// ZERO/SIGN-EXTENDING TO 32 BITS NON-EXTENDING
// ============================== =======================
// x86_64: void @c_arg_bool(i1 zeroext %_a)

@jieyouxu jieyouxu Oct 9, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also noticed that because of how the test is written, if codegen starts adding a zeroext on a return type where it is wrong to do so, the test will pass anyway.

Yeah, that seems a bit awkward since it defeats the purpose of the return checks...

For the non-extending return check cases, can we instead match via patterns such as

// x86_64-linux:                                    define {{(dso_local )?}}i1 @c_ret_bool()

That way if the return type gets a zeroext this check should fail. Using this pattern against the uefi one (where it does zeroext) indeed fails to match.

(This is not blocking; I think we can also do this as a follow-up, since this is pre-existing.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Follow-up: #164016

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.

Assuming we have the option to pass FileCheck arguments, you could also use something like --implicit-check-not=zeroext --implicit-check-not=signext.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm yeah. I'm not sure using the implicit flags is much better though, that also seems not very straightforward when looking at the actual diff right?

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 9, 2026
@jieyouxu jieyouxu added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 9, 2026
@jieyouxu jieyouxu assigned jieyouxu and unassigned JohnTitor Oct 9, 2026
@saethlin
saethlin force-pushed the bool-return-extend branch from 61f40b0 to 3d42c2c Compare October 9, 2026 03:27
@RalfJung

RalfJung commented Oct 9, 2026

Copy link
Copy Markdown
Member

r? @nikic

@rustbot rustbot assigned nikic and unassigned jieyouxu Oct 9, 2026
@nikic

nikic commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a0f1885 has been approved by nikic

It is now in the queue for this repository.

@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 10, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 10, 2026
Rollup of 4 pull requests

Successful merges:

 - #163434 (Add documentation for the `crate_name` attribute)
 - #163917 (Re-enable extension of bool return values on x86_64)
 - #163242 (Expose regular argument attributes in rustc_public)
 - #164071 (cg_llvm: Avoid all remaining uses of `as_c_char_ptr`)
@rust-bors
rust-bors Bot merged commit 7ccd431 into rust-lang:main Oct 10, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 10, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 10, 2026
Rollup merge of #163917 - saethlin:bool-return-extend, r=nikic

Re-enable extension of bool return values on x86_64

I think this fixes #163911

Though the test here is a bit hard to figure out, I'm not sure under what conditions expectation goes in the left or the right column. Do I decide that per-target or per-instance? Because x86_64 seems obligated to extend bool returns, so whether it is a "target that extends" or not depends on the type we're dealing with.

I also noticed that because of how the test is written, if codegen starts adding a `zeroext` on a return type where it is wrong to do so, the test will pass anyway.
@cuviper cuviper removed the stable-nominated Nominated for backporting to the compiler in the stable channel. label Oct 12, 2026
@cuviper cuviper mentioned this pull request Oct 13, 2026
@cuviper cuviper modified the milestones: 1.101.0, 1.100.0 Oct 13, 2026
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 13, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 13, 2026
[stable] prepare Rust 1.99.1

- (partial) compiler-builtins subtree update #162816, fixing #163614
- Re-enable extension of bool return values on x86_64 #163917, fixing #163911
- fix(bootstrap/darwin): fix rpath for distributed LLD #163954, fixing #163947

r? me
cc @rust-lang/release
rust-bors Bot pushed a commit that referenced this pull request Oct 13, 2026
[beta] backports

- Fix ICE for ambiguous candidates on method probing #162904
- Don't imply incorrect things about `Global` in the docs of `System` #163342
- make semicolon_in_expressions_from_non_local_macros not report-in-deps #163364
- Force the correct type variable to never for method resolution on an adjusted never type #163450
- Update LLVM submodule to latest release/23.x branch #163615
- Switch TLS implementation for wasi and bump SDK version to 34 #163809
- use the type name instead of `Self` in constructor paths again #163863
- Re-enable extension of bool return values on x86_64 #163917
- Add `synchronization` import lib to windows-gnullvm dist #163933
- fix(bootstrap/darwin): fix rpath for distributed LLD #163954

r? me
@cuviper cuviper modified the milestones: 1.100.0, 1.99.1 Oct 13, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 17, 2026
…saethlin

Tighten (absence of) return attribute checks in `some-abis-do-extend-params-to-32-bits.rs`

Follow-up to rust-lang#163917.

* Fix some misplaced patterns in extending vs non-extending columns.
* Tighten return attribute patterns to actually reject unexpected `zeroext`/`signext` attributes.
  * See rust-lang#163917 (comment)

r? @saethlin (or compiler)
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 17, 2026
…saethlin

Tighten (absence of) return attribute checks in `some-abis-do-extend-params-to-32-bits.rs`

Follow-up to rust-lang#163917.

* Fix some misplaced patterns in extending vs non-extending columns.
* Tighten return attribute patterns to actually reject unexpected `zeroext`/`signext` attributes.
  * See rust-lang#163917 (comment)

r? @saethlin (or compiler)
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 17, 2026
…saethlin

Tighten (absence of) return attribute checks in `some-abis-do-extend-params-to-32-bits.rs`

Follow-up to rust-lang#163917.

* Fix some misplaced patterns in extending vs non-extending columns.
* Tighten return attribute patterns to actually reject unexpected `zeroext`/`signext` attributes.
  * See rust-lang#163917 (comment)

r? @saethlin (or compiler)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 17, 2026
…saethlin

Tighten (absence of) return attribute checks in `some-abis-do-extend-params-to-32-bits.rs`

Follow-up to rust-lang#163917.

* Fix some misplaced patterns in extending vs non-extending columns.
* Tighten return attribute patterns to actually reject unexpected `zeroext`/`signext` attributes.
  * See rust-lang#163917 (comment)

r? @saethlin (or compiler)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 17, 2026
…saethlin

Tighten (absence of) return attribute checks in `some-abis-do-extend-params-to-32-bits.rs`

Follow-up to rust-lang#163917.

* Fix some misplaced patterns in extending vs non-extending columns.
* Tighten return attribute patterns to actually reject unexpected `zeroext`/`signext` attributes.
  * See rust-lang#163917 (comment)

r? @saethlin (or compiler)
rust-bors Bot pushed a commit that referenced this pull request Oct 17, 2026
Rollup merge of #164016 - jieyouxu:jieyouxu/tighten-test, r=saethlin

Tighten (absence of) return attribute checks in `some-abis-do-extend-params-to-32-bits.rs`

Follow-up to #163917.

* Fix some misplaced patterns in extending vs non-extending columns.
* Tighten return attribute patterns to actually reject unexpected `zeroext`/`signext` attributes.
  * See #163917 (comment)

r? @saethlin (or compiler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-accepted Accepted for backporting to the compiler in the beta channel. O-x86_64 Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. stable-accepted Accepted for backporting to the compiler in the stable channel. 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.

Miscompilation with FFI bool return type on x86_64