Repository navigation
Use emit_ptr_va_arg for va_arg on AVR - #165462
Conversation
| // CHECK-NEXT: ret | ||
| ap.next_arg() |
There was a problem hiding this comment.
Did you configure GCC in any particular way to make the checking easier?
https://godbolt.org/z/Ev8nMhd9P
The GCC output looks quite different, and also clang's output looks way shorter than what we asserted before.
There was a problem hiding this comment.
I mainly just compared the effects of the assembly, as GCC and Clang have differing opinions on instruction selection. Using -mmcu=atmega328p to match the test will allow GCC/Clang to use the movw, increasing the similarity. __tmp_reg__ is just r0. subi r18,-2, sbci r19,-1 is just GCC's way of adding 2 to r19:r18 (the subtraction effectively adds two by subtracting 254, and the carry will make sbci r19, -1 a no-op, unless their is no carry which means that the addition would have overflowed which means sbci needs to add 1 to r19 by subtracting 255). X+ increments X after the operation.
The LLVM va_arg instruction has a repeating pattern that it emits for every two bytes of the argument (that's why the assembly for read_i16 was the only assembly that didn't change). Trying a longer type like long long (8 bytes, instead of int's two bytes) results in Clang emitting assembly comparable to the old assembly in the test.
This comment has been minimized.
This comment has been minimized.
|
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. |
Rollup of 8 pull requests Successful merges: - #164720 (Expand E0271 on return type) - #165301 (Fix struct-literal suggestion spans in macros) - #165573 ([tiny] Tweak incorrect `#[default]` errors) - #164036 ([rustdoc] Allow `.` to be used the same as `::` in the search) - #165457 (tests: llvm 24 can merge addrspace declarations again) - #165462 (Use `emit_ptr_va_arg` for `va_arg` on AVR) - #165609 (OIDC artifact pushes) - #165620 (change return type of FloatErrorKind::kind)
Rollup of 8 pull requests Successful merges: - #164720 (Expand E0271 on return type) - #165301 (Fix struct-literal suggestion spans in macros) - #165573 ([tiny] Tweak incorrect `#[default]` errors) - #164036 ([rustdoc] Allow `.` to be used the same as `::` in the search) - #165457 (tests: llvm 24 can merge addrspace declarations again) - #165462 (Use `emit_ptr_va_arg` for `va_arg` on AVR) - #165609 (OIDC artifact pushes) - #165620 (change return type of FloatErrorKind::kind)
Rollup merge of #165462 - beetrees:va-arg-avr, r=folkertdev Use `emit_ptr_va_arg` for `va_arg` on AVR This avoids using LLVM's `va_arg` instruction and also gives much better codegen for types larger than two bytes. This matches GCC and LLVM (checked by comparing the assembly). Ping target maintainer @Patryk27 r? @folkertdev
This avoids using LLVM's
va_arginstruction and also gives much better codegen for types larger than two bytes. This matches GCC and LLVM (checked by comparing the assembly).Ping target maintainer @Patryk27
r? @folkertdev