Skip to content

cg_llvm: Clean up some inline assembly bindings #140914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 12, 2025

Conversation

Zalathar
Copy link
Contributor

This PR combines a few loosely-related cleanups to LLVM bindings related to inline assembly. These include:

  • Replacing LLVMRustInlineAsm with LLVM-C's LLVMGetInlineAsm
  • Adjusting FFI declarations to avoid the need for explicit as_c_char_ptr conversions
  • Flattening control flow in inline_asm_call

There should be no functional changes.

Zalathar added 5 commits May 11, 2025 14:26
This module comment describes why it's OK for LLVM bindings to declare a
parameter type of `*const c_uchar` for pointer/length strings, even though the
corresponding parameter on the C/C++ side uses `const char *`.

Adding a searchable term to each such parameter should make it easier for
future maintainers to understand why `*const c_uchar` is being used instead of
`*const c_char`.
This LLVM-C binding replaces the existing `LLVMRustInlineAsm` function.
This patch also changes the Rust-side declaration to take `*const c_uchar`
instead of `*const c_char`, to avoid the need for `AsCCharPtr`.
This avoids the need for an explicit `as_c_char_ptr` conversion.
@Zalathar Zalathar added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label May 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 11, 2025

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
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

@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 May 11, 2025
@compiler-errors
Copy link
Member

r? compiler-errors @bors r+

@bors
Copy link
Collaborator

bors commented May 12, 2025

📌 Commit eccf064 has been approved by compiler-errors

It is now in the queue for this repository.

@rustbot rustbot assigned compiler-errors and unassigned BoxyUwU May 12, 2025
@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 May 12, 2025
@bors
Copy link
Collaborator

bors commented May 12, 2025

⌛ Testing commit eccf064 with merge 1a7f290...

@bors
Copy link
Collaborator

bors commented May 12, 2025

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 1a7f290 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 12, 2025
@bors bors merged commit 1a7f290 into rust-lang:master May 12, 2025
7 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 12, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 420ca71 (parent) -> 1a7f290 (this PR)

Test differences

Show 33150 test diffs

Stage 1

  • errors::verify_const_eval_non_const_fmt_macro_call_17: [missing] -> pass (J0)
  • errors::verify_expand_meta_var_expr_unrecognized_var_3: [missing] -> pass (J0)
  • errors::verify_mir_dataflow_peek_argument_untracked_9: [missing] -> pass (J0)
  • errors::verify_mir_dataflow_unknown_formatter_1: [missing] -> pass (J0)
  • errors::verify_monomorphize_couldnt_dump_mono_stats_4: [missing] -> pass (J0)
  • errors::verify_passes_attr_only_in_functions_137: [missing] -> pass (J0)
  • html::render::ordered_json::tests::escape_json_number: [missing] -> pass (J0)
  • parser::tests::different_note_spanned_8: [missing] -> pass (J0)
  • parser::tests::parse_exprs: [missing] -> pass (J0)
  • spec::tests::riscv32imac_unknown_none_elf: [missing] -> pass (J0)
  • spec::tests::x86_64_unknown_l4re_uclibc: [missing] -> pass (J0)
  • ascii::test_is_ascii: [missing] -> pass (J1)
  • collections::btree::set::tests::test_split_off_empty_right: [missing] -> pass (J1)
  • collections::vec_deque::tests::test_reserve_exact: [missing] -> pass (J1)
  • io::tests::read_to_end_error: [missing] -> pass (J1)
  • iter::adapters::flatten::test_flatten_try_folds: [missing] -> pass (J1)
  • misc_tests::test_show: [missing] -> pass (J1)
  • mpsc::issue_39364: [missing] -> pass (J1)
  • nonzero::test_match_option_empty_vec: [missing] -> pass (J1)
  • num::bignum::test_bit_length: [missing] -> pass (J1)
  • num::i128::test_is_negative: [missing] -> pass (J1)
  • num::i128::test_overflows: [missing] -> pass (J1)
  • num::i16::test_carrying_mul_add: [missing] -> pass (J1)
  • num::i64::test_abs: [missing] -> pass (J1)
  • option::test_option_as_deref: [missing] -> pass (J1)
  • slice::slice_index::rangefrom_len::pass: [missing] -> pass (J1)
  • slice::test_rchunks_count: [missing] -> pass (J1)
  • sort::tests::unstable::correct_i32_random_s95: [missing] -> pass (J1)
  • sort::tests::unstable::correct_i32_saw_mixed: [missing] -> pass (J1)
  • str::ceil_char_boundary: [missing] -> pass (J1)
  • str::test_as_bytes: [missing] -> pass (J1)
  • str::test_iterator_advance: [missing] -> pass (J1)
  • string::test_replace_range_empty: [missing] -> pass (J1)
  • vec_deque::test_binary_search_by: [missing] -> pass (J1)
  • btree::map::from_iter_seq_10_000: [missing] -> pass (J2)
  • btree::set::clone_10k_and_drain_half: [missing] -> pass (J2)
  • fs::tests::copy_file_returns_metadata_len: [missing] -> pass (J2)
  • iter::bench_skip_trusted_random_access: [missing] -> pass (J2)
  • num::flt2dec::strategy::grisu::bench_small_exact_inf: [missing] -> pass (J2)
  • os::unix::net::tests::test_connect_unix_datagram: [missing] -> pass (J2)
  • vec::bench_extend_0010_0010: [missing] -> pass (J2)
  • vec::bench_from_elem_0000: [missing] -> pass (J2)
  • sort::tests::stable::deterministic_i32_random_d2: [missing] -> ignore (J3)

Stage 2

  • config::externs::tests::test_split_extern_opt: pass -> [missing] (J0)
  • deriving::coerce_pointee::verify_builtin_macros_coerce_pointee_too_many_pointees_4: pass -> [missing] (J0)
  • doctest::tests::comment_in_attrs: pass -> [missing] (J0)
  • errors::verify_ast_passes_item_invalid_safety_16: pass -> [missing] (J0)
  • errors::verify_ast_passes_optional_trait_supertrait_47: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_compiler_builtins_cannot_call_135: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_extract_bundled_libs_mmap_file_69: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_stripping_debug_info_failed_58: pass -> [missing] (J0)
  • errors::verify_expand_module_file_not_found_31: pass -> [missing] (J0)
  • errors::verify_hir_typeck_union_pat_multiple_fields_15: pass -> [missing] (J0)
  • errors::verify_parse_incorrect_visibility_restriction_45: pass -> [missing] (J0)
  • errors::verify_parse_invalid_digit_literal_109: pass -> [missing] (J0)
  • errors::verify_parse_kw_bad_case_161: pass -> [missing] (J0)
  • errors::verify_parse_unexpected_token_after_struct_name_found_metavar_94: pass -> [missing] (J0)
  • errors::verify_passes_doc_alias_start_end_23: pass -> [missing] (J0)
  • errors::verify_passes_doc_test_unknown_include_48: pass -> [missing] (J0)
  • errors::verify_passes_has_incoherent_inherent_impl_52: pass -> [missing] (J0)
  • errors::verify_resolve_static_lifetime_is_reserved_48: pass -> [missing] (J0)
  • errors::verify_session_invalid_literal_suffix_32: pass -> [missing] (J0)
  • maybe_transmutable::tests::bool::should_permit_validity_expansion_and_reject_contraction: pass -> [missing] (J0)
  • spec::tests::aarch64_unknown_nuttx: pass -> [missing] (J0)
  • spec::tests::aarch64_unknown_uefi: pass -> [missing] (J0)
  • any::any_unsized: pass -> [missing] (J1)
  • f32::test_sqrt_domain: pass -> [missing] (J1)
  • io::cursor::tests::test_slice_reader_vectored: pass -> [missing] (J1)
  • io::tests::io_slice_into_slice: pass -> [missing] (J1)
  • iter::traits::iterator::test_collect_into_tuples: pass -> [missing] (J1)
  • mem::offset_of_addr: pass -> [missing] (J1)
  • mem::uninit_write_copy_of_slice_panic_lt: pass -> [missing] (J1)
  • mem::uninit_write_with_no_drop: pass -> [missing] (J1)
  • num::bignum::test_mul_small_overflow: pass -> [missing] (J1)
  • ops::deref_mut_on_ref: pass -> [missing] (J1)
  • os::unix::io::tests::test_raw_fd_layout: pass -> [missing] (J1)
  • slice::chunks_mut_are_send_and_sync: pass -> [missing] (J1)
  • slice::test_get_disjoint_mut_range_oob: pass -> [missing] (J1)
  • slice::test_iterator_advance_back_by: pass -> [missing] (J1)
  • slice::test_iterator_advance_by: pass -> [missing] (J1)
  • slice::test_show: pass -> [missing] (J1)
  • sys_common::wtf8::tests::wtf8_display: pass -> [missing] (J1)
  • sys_common::wtf8::tests::wtf8_slice_from_not_code_point_boundary: pass -> [missing] (J1)
  • thin_box::align2zst: pass -> [missing] (J1)
  • vec::test_extend_from_within_spec: pass -> [missing] (J1)
  • vec::vec_null_ptr_roundtrip: pass -> [missing] (J1)
  • btree::set::difference_random_100_vs_100: pass -> [missing] (J2)
  • char::methods::bench_non_ascii_char_to_uppercase: pass -> [missing] (J2)
  • num::dec2flt::bench_0: pass -> [missing] (J2)
  • slice::sort_unstable_large_strings: pass -> [missing] (J2)
  • sort::tests::stable::panic_retain_orig_set_cell_i32_random: pass -> [missing] (J2)
  • str::debug::ascii_escapes: pass -> [missing] (J2)
  • sort::tests::stable::deterministic_string_saw_mixed: ignore -> [missing] (J3)
  • sort::tests::stable::self_cmp_cell_i32_random: ignore -> [missing] (J3)
  • sort::tests::unstable::correct_f128_descending: ignore -> [missing] (J3)
  • sort::tests::unstable::deterministic_string_random_s95: ignore -> [missing] (J3)
  • sort::tests::unstable::panic_retain_orig_set_string_ascending: ignore -> [missing] (J3)
  • sort::tests::unstable::self_cmp_cell_i32_descending: ignore -> [missing] (J3)
  • sort::tests::unstable::stability_i32_random: ignore -> [missing] (J3)
  • sort::tests::unstable::stability_i32_saw_mixed: ignore -> [missing] (J3)

(and 16504 additional test diffs)

Additionally, 16546 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 1a7f290a9aedc138edf9c88a82019292019754d9 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-apple-2: 1579.4s -> 6768.4s (328.5%)
  2. test-various: 2420.2s -> 4161.5s (72.0%)
  3. dist-aarch64-linux: 5524.1s -> 7699.6s (39.4%)
  4. x86_64-gnu-aux: 4351.2s -> 5984.9s (37.5%)
  5. x86_64-apple-1: 6843.3s -> 9106.8s (33.1%)
  6. aarch64-apple: 3331.8s -> 4330.1s (30.0%)
  7. dist-x86_64-apple: 9860.6s -> 8742.1s (-11.3%)
  8. dist-various-1: 4466.7s -> 4883.2s (9.3%)
  9. dist-x86_64-mingw: 7655.9s -> 8170.0s (6.7%)
  10. dist-powerpc64-linux: 5546.1s -> 5224.3s (-5.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1a7f290): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -2.8%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 771.187s -> 772.98s (0.23%)
Artifact size: 365.44 MiB -> 365.34 MiB (-0.03%)

@Zalathar Zalathar deleted the asm-bindings branch May 12, 2025 22:23
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. merged-by-bors This PR was explicitly merged by bors. 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.

6 participants