Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

matthiaskrgr
Copy link
Member

@matthiaskrgr matthiaskrgr commented Sep 8, 2025

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

folkertdev and others added 11 commits September 3, 2025 00:19
match clang's `va_arg` assembly on arm targets

tracking issue: rust-lang#44930

For this example

```rust
#![feature(c_variadic)]

#[unsafe(no_mangle)]
unsafe extern "C" fn variadic(a: f64, mut args: ...) -> f64 {
    let b = args.arg::<f64>();
    let c = args.arg::<f64>();

    a + b + c
}
```

We currently generate (via llvm):

```asm
variadic:
    sub     sp, sp, rust-lang#12
    stmib   sp, {r2, r3}
    vmov    d0, r0, r1
    add     r0, sp, rust-lang#4
    vldr    d1, [sp, rust-lang#4]
    add     r0, r0, rust-lang#15
    bic     r0, r0, rust-lang#7
    vadd.f64        d0, d0, d1
    add     r1, r0, rust-lang#8
    str     r1, [sp]
    vldr    d1, [r0]
    vadd.f64        d0, d0, d1
    vmov    r0, r1, d0
    add     sp, sp, rust-lang#12
    bx      lr
```

LLVM is not doing a good job. In fact, it's well-known that LLVM's implementation of `va_arg` is kind of bad, and we implement it ourselves (based on clang) for many targets already. For arm,  our own `emit_ptr_va_arg` saves 3 instructions.

Next, it turns out it's important for LLVM to explicitly start and end the lifetime of the `va_list`. In rust-lang#146059 I already end the lifetime, but when looking at this again, I noticed that it is important to also start it, see https://godbolt.org/z/EGqvKTTsK: failing to explicitly start the lifetime uses an extra register.

So, the combination of `emit_ptr_va_arg` with starting/ending the lifetime makes rustc emit exactly the instructions that clang generates::

```asm
variadic:
    sub     sp, sp, rust-lang#12
    stmib   sp, {r2, r3}
    vmov    d16, r0, r1
    vldr    d17, [sp, rust-lang#4]
    vadd.f64        d16, d16, d17
    vldr    d17, [sp, rust-lang#12]
    vadd.f64        d16, d16, d17
    vmov    r0, r1, d16
    add     sp, sp, rust-lang#12
    bx      lr
```

The arguments to `emit_ptr_va_arg` are based on [the clang implementation](https://github.com/llvm/llvm-project/blob/03dc2a41f3d9a500e47b513de5c5008c06860d65/clang/lib/CodeGen/Targets/ARM.cpp#L798-L844).

r? `@workingjubilee` (I can re-roll if your queue is too full, but you do seem like the right person here)
In the rustc_llvm build script, don't consider arm64* to be 32-bit

The build script for `rustc_llvm` needs to detect 32-bit targets so that it links against `libatomics`. To do this, it matches the target architecture against `arm`, unfortunately incorrectly matches Arm64EC, Arm64E, etc.

This change adds a check that the target arch doesn't match `arm64`.
GVN: Ensure indirect is first projection in try_as_place.

I haven't found any report for this bug on existing code, but managed to trigger it with rust-lang#143333
…lize-docs, r=jhpratt

docs(std): add error docs for path canonicalize

This PR adds the missing error documentation for both [Path.canonicalize](https://doc.rust-lang.org/std/path/struct.Path.html#method.canonicalize) and [PathBuf.canonicalize](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.canonicalize) methods. Since both methods are wappers around [fs::canonicalize](https://doc.rust-lang.org/std/fs/fn.canonicalize.html), the error doc is copied directly from that function.

This makes it faster to find what errors might arise when calling `path.canonicalize` or `path_buf.canonicalize` in the editor itself without needing to drill down to the  `fs::canonicalzie` docs.
…=jhpratt

Implement `Sum` and `Product` for `f16` and `f128`.

Tracking issue: rust-lang#116909.

This PR implements `core::iter::{Sum, Product}` for `f16` and `f128`.

I'm curious as to why these two traits aren't already implemented. I've been unable to find any information about it at all, so if there is anything that currently blocks them, I would appreciate if someone could fill me in.
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Sep 8, 2025
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Sep 8, 2025

📌 Commit 2c7abaa has been approved by matthiaskrgr

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 8, 2025
@bors
Copy link
Collaborator

bors commented Sep 8, 2025

⌛ Testing commit 2c7abaa with merge ef15265...

bors added a commit that referenced this pull request Sep 8, 2025
Rollup of 5 pull requests

Successful merges:

 - #144549 (match clang's `va_arg` assembly on arm targets)
 - #146184 (In the rustc_llvm build script, don't consider arm64* to be 32-bit)
 - #146298 (GVN: Ensure indirect is first projection in try_as_place.)
 - #146299 (docs(std): add error docs for path canonicalize)
 - #146300 (Implement `Sum` and `Product` for `f16` and `f128`.)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job arm-android failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [assembly] tests/assembly-llvm/c-variadic-arm.rs stdout ----
------FileCheck stdout------------------------------

------FileCheck stderr------------------------------
/checkout/tests/assembly-llvm/c-variadic-arm.rs:14:12: error: CHECK: expected string not found in input
 // CHECK: sub sp, sp, #12
           ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/assembly-llvm/c-variadic-arm/c-variadic-arm.s:17:19: note: scanning from here
 .file "c_variadic_arm.ccda00c1758a421a-cgu.0"
                  ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/assembly-llvm/c-variadic-arm/c-variadic-arm.s:26:2: note: possible intended match here
 sub sp, sp, #8
 ^

Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/assembly-llvm/c-variadic-arm/c-variadic-arm.s
Check file: /checkout/tests/assembly-llvm/c-variadic-arm.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1:  .syntax unified 
            2:  .eabi_attribute 67, "2.09" 
            3:  .eabi_attribute 6, 4 
            4:  .eabi_attribute 8, 1 
            5:  .eabi_attribute 9, 1 
            6:  .eabi_attribute 34, 0 
            7:  .eabi_attribute 15, 1 
            8:  .eabi_attribute 16, 1 
            9:  .eabi_attribute 17, 2 
           10:  .eabi_attribute 20, 1 
           11:  .eabi_attribute 21, 1 
           12:  .eabi_attribute 23, 3 
           13:  .eabi_attribute 24, 1 
           14:  .eabi_attribute 25, 1 
           15:  .eabi_attribute 38, 1 
           16:  .eabi_attribute 14, 0 
           17:  .file "c_variadic_arm.ccda00c1758a421a-cgu.0" 
check:14'0                       X~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
           18:  .section .text.variadic,"ax",%progbits 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           19:  .globl variadic 
check:14'0     ~~~~~~~~~~~~~~~~~
           20:  .p2align 2 
check:14'0     ~~~~~~~~~~~~
           21:  .type variadic,%function 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
           22:  .code 32 
check:14'0     ~~~~~~~~~~
           23: variadic: 
check:14'0     ~~~~~~~~~~
           24:  .fnstart 
check:14'0     ~~~~~~~~~~
           25:  .pad #8 
check:14'0     ~~~~~~~~~
           26:  sub sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
check:14'1      ?               possible intended match
           27:  .save {r11, lr} 
check:14'0     ~~~~~~~~~~~~~~~~~
           28:  push {r11, lr} 
check:14'0     ~~~~~~~~~~~~~~~~
           29:  .pad #8 
check:14'0     ~~~~~~~~~
           30:  sub sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
           31:  str r2, [sp, #16] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           32:  str r3, [sp, #20] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           33:  bl __aeabi_dadd 
check:14'0     ~~~~~~~~~~~~~~~~~
           34:  ldr r2, [sp, #24] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           35:  ldr r3, [sp, #28] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           36:  bl __aeabi_dadd 
check:14'0     ~~~~~~~~~~~~~~~~~
           37:  add sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
           38:  pop {r11, lr} 
check:14'0     ~~~~~~~~~~~~~~~
           39:  add sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
           40:  bx lr 
check:14'0     ~~~~~~~
           41: .Lfunc_end0: 
check:14'0     ~~~~~~~~~~~~~
           42:  .size variadic, .Lfunc_end0-variadic 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           43:  .fnend 
check:14'0     ~~~~~~~~
           44:  
check:14'0     ~
           45:  .ident "rustc version 1.91.0-nightly (ef152652e 2025-09-08)" 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           46:  .section ".note.GNU-stack","",%progbits 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>

------------------------------------------

error: verification with 'FileCheck' failed
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/assembly-llvm/c-variadic-arm/c-variadic-arm.s" "/checkout/tests/assembly-llvm/c-variadic-arm.rs" "--check-prefix=CHECK" "--allow-unused-prefixes" "--dump-input-context" "100"
stdout: none
--- stderr -------------------------------
/checkout/tests/assembly-llvm/c-variadic-arm.rs:14:12: error: CHECK: expected string not found in input
 // CHECK: sub sp, sp, #12
           ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/assembly-llvm/c-variadic-arm/c-variadic-arm.s:17:19: note: scanning from here
 .file "c_variadic_arm.ccda00c1758a421a-cgu.0"
                  ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/assembly-llvm/c-variadic-arm/c-variadic-arm.s:26:2: note: possible intended match here
 sub sp, sp, #8
 ^

Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/assembly-llvm/c-variadic-arm/c-variadic-arm.s
Check file: /checkout/tests/assembly-llvm/c-variadic-arm.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1:  .syntax unified 
            2:  .eabi_attribute 67, "2.09" 
            3:  .eabi_attribute 6, 4 
            4:  .eabi_attribute 8, 1 
            5:  .eabi_attribute 9, 1 
            6:  .eabi_attribute 34, 0 
            7:  .eabi_attribute 15, 1 
            8:  .eabi_attribute 16, 1 
            9:  .eabi_attribute 17, 2 
           10:  .eabi_attribute 20, 1 
           11:  .eabi_attribute 21, 1 
           12:  .eabi_attribute 23, 3 
           13:  .eabi_attribute 24, 1 
           14:  .eabi_attribute 25, 1 
           15:  .eabi_attribute 38, 1 
           16:  .eabi_attribute 14, 0 
           17:  .file "c_variadic_arm.ccda00c1758a421a-cgu.0" 
check:14'0                       X~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
           18:  .section .text.variadic,"ax",%progbits 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           19:  .globl variadic 
check:14'0     ~~~~~~~~~~~~~~~~~
           20:  .p2align 2 
check:14'0     ~~~~~~~~~~~~
           21:  .type variadic,%function 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
           22:  .code 32 
check:14'0     ~~~~~~~~~~
           23: variadic: 
check:14'0     ~~~~~~~~~~
           24:  .fnstart 
check:14'0     ~~~~~~~~~~
           25:  .pad #8 
check:14'0     ~~~~~~~~~
           26:  sub sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
check:14'1      ?               possible intended match
           27:  .save {r11, lr} 
check:14'0     ~~~~~~~~~~~~~~~~~
           28:  push {r11, lr} 
check:14'0     ~~~~~~~~~~~~~~~~
           29:  .pad #8 
check:14'0     ~~~~~~~~~
           30:  sub sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
           31:  str r2, [sp, #16] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           32:  str r3, [sp, #20] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           33:  bl __aeabi_dadd 
check:14'0     ~~~~~~~~~~~~~~~~~
           34:  ldr r2, [sp, #24] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           35:  ldr r3, [sp, #28] 
check:14'0     ~~~~~~~~~~~~~~~~~~~
           36:  bl __aeabi_dadd 
check:14'0     ~~~~~~~~~~~~~~~~~
           37:  add sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
           38:  pop {r11, lr} 
check:14'0     ~~~~~~~~~~~~~~~
           39:  add sp, sp, #8 
check:14'0     ~~~~~~~~~~~~~~~~
           40:  bx lr 
check:14'0     ~~~~~~~
           41: .Lfunc_end0: 
check:14'0     ~~~~~~~~~~~~~
           42:  .size variadic, .Lfunc_end0-variadic 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           43:  .fnend 
check:14'0     ~~~~~~~~
           44:  
check:14'0     ~
           45:  .ident "rustc version 1.91.0-nightly (ef152652e 2025-09-08)" 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           46:  .section ".note.GNU-stack","",%progbits 
check:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>
------------------------------------------

---- [assembly] tests/assembly-llvm/c-variadic-arm.rs stdout end ----

failures:
    [assembly] tests/assembly-llvm/c-variadic-arm.rs

test result: FAILED. 492 passed; 1 failed; 79 ignored; 0 measured; 0 filtered out; finished in 16.89s

@bors
Copy link
Collaborator

bors commented Sep 8, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 8, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. rollup A PR which is a rollup T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants