Skip to content

Rollup of 19 pull requests #145077

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 106 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
215d8ed
combine rust files into one compilation
folkertdev Jul 11, 2025
426091a
update `Cargo.lock`
folkertdev Jul 19, 2025
83804bf
split rust code into crates
folkertdev Jul 11, 2025
3051039
generate arrays of type-erased function pointers
folkertdev Jul 11, 2025
b658b3d
work around not being able to project out of SIMD values any more
folkertdev Jul 22, 2025
4b95bb7
Merge pull request #1881 from folkertdev/s390x-project-simd
sayantn Jul 22, 2025
aaa5d91
remove `lazy_static` dependency from `intrinsic-test`
folkertdev Jul 22, 2025
4bf2151
Merge pull request #1880 from folkertdev/remove-lazy-static-dep
folkertdev Jul 22, 2025
cb27ff0
remove unused deps
klensy Jul 23, 2025
d8bf6c4
bump serde_with. Weird that it works without std feature, but
klensy Jul 23, 2025
75fc5ce
Merge pull request #1882 from klensy/deps
folkertdev Jul 23, 2025
a343926
Prepare for merging from rust-lang/rust
Kobzol Jul 23, 2025
67f73c7
Merge ref '5a30e4307f05' from rust-lang/rust
Kobzol Jul 23, 2025
8f0ffa8
Reformat code
Kobzol Jul 23, 2025
0231fa9
Merge pull request #1883 from Kobzol/pull
folkertdev Jul 23, 2025
be947d4
Add non-temporal note for maskmoveu_si128
197g Jul 24, 2025
14febfa
Merge pull request #1885 from 197g/maskmove-is-non-temporal
sayantn Jul 24, 2025
49ea48d
loongarch: Use unified data types for SIMD intrinsics
heiher Jul 19, 2025
cc15f02
Merge pull request #1879 from heiher/loong-simd-unified-types
folkertdev Jul 25, 2025
f998575
Merge pull request #1863 from folkertdev/combine-rust-files
sayantn Jul 25, 2025
90d97f6
feat: updated Argument<T> type for functional compatibility with other
madhav-madhusoodanan Jul 27, 2025
213fd4e
Merge pull request #1887 from madhav-madhusoodanan/intrinsic-test-arg…
folkertdev Jul 27, 2025
c07f8bb
chore: handling the case where --generate-only flag is passed
madhav-madhusoodanan Jul 27, 2025
15373cc
Merge pull request #1888 from madhav-madhusoodanan/intrinsic-test-gen…
folkertdev Jul 27, 2025
e6c0136
Use GitHub app for authenticating sync workflows
Kobzol Jul 29, 2025
d6c33bf
Merge pull request #1891 from Kobzol/ci-gh-app
tgross35 Jul 29, 2025
8926d9c
Prepare for merging from rust-lang/rust
invalid-email-address Jul 31, 2025
49aa0ec
Merge ref '32e7a4b92b10' from rust-lang/rust
invalid-email-address Jul 31, 2025
f95edbe
move gcc config parsing to parse_inner
Shourya742 Jul 30, 2025
3f9bf57
move dist to parse_inner
Shourya742 Jul 30, 2025
924912c
move target parsing to parse_inner
Shourya742 Jul 30, 2025
89219ff
move install to parse_inner
Shourya742 Jul 30, 2025
3248ff1
move llvm parsing to parse_inner
Shourya742 Jul 30, 2025
ddd2a54
move rust config to parse_inner
Shourya742 Jul 30, 2025
ae05591
Force initializing ExecutionContext with verbosity and fail_fast mode
Shourya742 Jul 30, 2025
82756fd
Extract TOML config loading and src directory computation into separa…
Shourya742 Jul 30, 2025
f89ea08
Split TOML postprocessing into a separate function
Shourya742 Jul 30, 2025
cfc40de
Override some build TOML values by flags
Shourya742 Jul 30, 2025
8652d96
Fix logging of config skip values
Shourya742 Jul 30, 2025
58a38cd
Fix verbosity setting
Shourya742 Jul 30, 2025
222dfcc
add install default implementation
Shourya742 Aug 1, 2025
bbe7c08
add gcc and dist default implementation
Shourya742 Aug 1, 2025
38ddefa
add llvm default implementation
Shourya742 Aug 1, 2025
8b80cb0
add rust default implementation
Shourya742 Aug 1, 2025
d3d3b10
make llvm toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
c008a4b
make gcc toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
4d2a2c2
make dist toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
ad98550
make install toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
2c96132
make build toml fields follow a specific naming convention
Shourya742 Aug 1, 2025
a75326b
move build config to the top of parse method
Shourya742 Aug 1, 2025
39d9cf7
move install config to the top of parse method
Shourya742 Aug 1, 2025
120d93e
move rust config to the top of parse method
Shourya742 Aug 1, 2025
f74f1a0
move llvm config to the top of parse method
Shourya742 Aug 1, 2025
7f20ad8
move dist and gcc config to the top of parse method
Shourya742 Aug 1, 2025
c861fbd
use gcc 15 as the linker on loongarch
folkertdev Aug 2, 2025
56ba98c
Merge pull request #1893 from folkertdev/loongarch-gcc
sayantn Aug 3, 2025
3b216c3
feat: Added another variant of the Constraint enum
madhav-madhusoodanan Aug 2, 2025
daa742a
Merge pull request #1892 from madhav-madhusoodanan/intrinsic-test-con…
folkertdev Aug 3, 2025
c691374
Merge pull request #1889 from rust-lang/rustc-pull
folkertdev Aug 3, 2025
d857d54
Print CGU reuse statistics when `-Zprint-mono-items` is enabled
Kobzol Aug 4, 2025
75e20af
Add new `test::print_merged_doctests_times` used by rustdoc to displa…
GuillaumeGomez Aug 4, 2025
36383dd
[win][arm64ec] Fix msvc-wholearchive for Arm64EC
dpaoliello Aug 5, 2025
76dce27
feat: cleaned the IntrinsicType struct and associated functions.
madhav-madhusoodanan Aug 5, 2025
e84116d
chore: moved chunk_info to `common` and code cleanup
madhav-madhusoodanan Aug 5, 2025
841c8e4
Merge pull request #1895 from madhav-madhusoodanan/intrinsic-test-int…
folkertdev Aug 5, 2025
de01bd3
use `IntoIterator` for the `add_flags` methods
folkertdev Aug 5, 2025
92f195c
Merge pull request #1896 from folkertdev/add-flags-into-iter
sayantn Aug 5, 2025
62c92f3
moved 35 tests to organized locations
Kivooeo Jul 24, 2025
b6e13e3
comments
Kivooeo Jul 24, 2025
962836d
remove redundant _toml suffix and other misc changes
Shourya742 Aug 4, 2025
81ed042
coverage: Remove all unstable support for MC/DC instrumentation
Zalathar Aug 6, 2025
c396521
[codegen] assume the tag, not the relative discriminant
scottmcm Aug 1, 2025
4ff22dd
Move some TypeVisitable/TypeFoldable impls to rustc_type_ir
flodiebold Nov 10, 2024
025fbe8
Add support for shortening `Instance` and use it
estebank Jul 29, 2025
1c428ec
move `type_check` out of `compute_regions`
lcnr Aug 7, 2025
d6dc363
add multiple known-bugs for NLL problem case 3
lqd Aug 7, 2025
e3aae61
add filtering lending iterator known-bug
lqd Aug 7, 2025
202963f
add multiple known-bugs for the linked-list cursor-like pattern of 46…
lqd Aug 7, 2025
6c02653
Prevent name collisions with internal implementation details
bjorn3 Aug 7, 2025
487e5ce
Introduce, implement and use CmResolver.
LorrensP-2158466 Aug 4, 2025
186cef0
Move metadata symbol export from exported_non_generic_symbols to expo…
bjorn3 Aug 7, 2025
29799c2
Add a missing UpcastFrom impl in rustc_type_ir
flodiebold Nov 10, 2024
34e5820
Clean up some resolved test regressions of const trait removals in std
ShoyuVanilla Aug 7, 2025
7ea5e79
Readd myself to review queue
jackh726 Aug 7, 2025
1c41c3d
Add minimal `armv7a-vex-v5` support
lewisfm Aug 7, 2025
8a87857
Add test.
cjgillot Aug 7, 2025
ebd60b9
Do not flatten derefs with ProjectionElem::Index.
cjgillot Aug 7, 2025
cb271d0
Rollup merge of #144400 - Kivooeo:issue3, r=jieyouxu
Zalathar Aug 8, 2025
44ffe10
Rollup merge of #144764 - scottmcm:tweak-impossible-discriminant-assu…
Zalathar Aug 8, 2025
af33da3
Rollup merge of #144807 - Shourya742:2025-07-30-streamline-config, r=…
Zalathar Aug 8, 2025
2b7659c
Rollup merge of #144899 - Kobzol:cgu-reuse, r=saethlin
Zalathar Aug 8, 2025
3f94101
Rollup merge of #144909 - GuillaumeGomez:extend-libtest-for-merged-do…
Zalathar Aug 8, 2025
ecce94c
Rollup merge of #144912 - LorrensP-2158466:smart-resolver, r=petroche…
Zalathar Aug 8, 2025
bdb082b
Rollup merge of #144914 - estebank:short-paths-2, r=fee1-dead
Zalathar Aug 8, 2025
2edfd36
Rollup merge of #144931 - dpaoliello:msvc-wholearchive, r=jieyouxu
Zalathar Aug 8, 2025
562222b
Rollup merge of #144999 - Zalathar:remove-mcdc, r=oli-obk
Zalathar Aug 8, 2025
0d22b2e
Rollup merge of #145009 - jackh726:ra-next-solver-changes, r=compiler…
Zalathar Aug 8, 2025
162e2e4
Rollup merge of #145030 - cjgillot:gvn-no-flatten-index, r=saethlin
Zalathar Aug 8, 2025
6f2d55b
Rollup merge of #145042 - heiher:stdarch-push, r=folkertdev
Zalathar Aug 8, 2025
e4b2fad
Rollup merge of #145047 - lcnr:yeet-mir-typeck, r=lqd
Zalathar Aug 8, 2025
432a4f2
Rollup merge of #145051 - bjorn3:prevent_linkage_symbol_name_collisio…
Zalathar Aug 8, 2025
ab0b90f
Rollup merge of #145053 - lqd:known-bugs, r=jackh726
Zalathar Aug 8, 2025
18f5e9b
Rollup merge of #145055 - bjorn3:move_metadata_symbol_export, r=saethlin
Zalathar Aug 8, 2025
bd7af8a
Rollup merge of #145057 - ShoyuVanilla:const-trait-tests-cleanup, r=p…
Zalathar Aug 8, 2025
9f0a7fe
Rollup merge of #145068 - jackh726:add-review, r=jackh726
Zalathar Aug 8, 2025
f6283ae
Rollup merge of #145070 - vexide:minimal-armv7a-vex-v5, r=wesleywiser
Zalathar Aug 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::borrow::Cow;
use std::cell::{OnceCell, RefCell};
use std::marker::PhantomData;
use std::ops::{ControlFlow, Deref};
use std::rc::Rc;

use borrow_set::LocalsStateAtExit;
use root_cx::BorrowCheckRootCtxt;
Expand All @@ -44,6 +45,7 @@ use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces}
use rustc_mir_dataflow::move_paths::{
InitIndex, InitLocation, LookupResult, MoveData, MovePathIndex,
};
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::{Analysis, Results, ResultsVisitor, visit_results};
use rustc_session::lint::builtin::{TAIL_EXPR_DROP_ORDER, UNUSED_MUT};
use rustc_span::{ErrorGuaranteed, Span, Symbol};
Expand All @@ -60,11 +62,14 @@ use crate::path_utils::*;
use crate::place_ext::PlaceExt;
use crate::places_conflict::{PlaceConflictBias, places_conflict};
use crate::polonius::PoloniusDiagnosticsContext;
use crate::polonius::legacy::{PoloniusLocationTable, PoloniusOutput};
use crate::polonius::legacy::{
PoloniusFacts, PoloniusFactsExt, PoloniusLocationTable, PoloniusOutput,
};
use crate::prefixes::PrefixSet;
use crate::region_infer::RegionInferenceContext;
use crate::renumber::RegionCtxt;
use crate::session_diagnostics::VarNeedNotMut;
use crate::type_check::MirTypeckResults;

mod borrow_set;
mod borrowck_errors;
Expand Down Expand Up @@ -321,7 +326,34 @@ fn do_mir_borrowck<'tcx>(
let locals_are_invalidated_at_exit = tcx.hir_body_owner_kind(def).is_fn_or_closure();
let borrow_set = BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &move_data);

// Compute non-lexical lifetimes.
let location_map = Rc::new(DenseLocationMap::new(body));

let polonius_input = root_cx.consumer.as_ref().map_or(false, |c| c.polonius_input())
|| infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled();
let mut polonius_facts =
(polonius_input || PoloniusFacts::enabled(infcx.tcx)).then_some(PoloniusFacts::default());

// Run the MIR type-checker.
let MirTypeckResults {
constraints,
universal_region_relations,
opaque_type_values,
polonius_context,
} = type_check::type_check(
root_cx,
&infcx,
body,
&promoted,
universal_regions,
&location_table,
&borrow_set,
&mut polonius_facts,
&move_data,
Rc::clone(&location_map),
);

// Compute non-lexical lifetimes using the constraints computed
// by typechecking the MIR body.
let nll::NllOutput {
regioncx,
polonius_input,
Expand All @@ -332,14 +364,19 @@ fn do_mir_borrowck<'tcx>(
} = nll::compute_regions(
root_cx,
&infcx,
universal_regions,
body,
&promoted,
&location_table,
&move_data,
&borrow_set,
location_map,
universal_region_relations,
constraints,
polonius_facts,
polonius_context,
);

regioncx.infer_opaque_types(root_cx, &infcx, opaque_type_values);

// Dump MIR results into a file, if that is enabled. This lets us
// write unit-tests, as well as helping with debugging.
nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req, &borrow_set);
Expand Down
46 changes: 12 additions & 34 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use std::path::PathBuf;
use std::rc::Rc;
use std::str::FromStr;

use polonius_engine::{Algorithm, Output};
use polonius_engine::{Algorithm, AllFacts, Output};
use rustc_data_structures::frozen::Frozen;
use rustc_index::IndexSlice;
use rustc_middle::mir::pretty::{PrettyPrintMirOptions, dump_mir_with_options};
use rustc_middle::mir::{Body, PassWhere, Promoted, create_dump_file, dump_enabled, dump_mir};
Expand All @@ -18,14 +19,16 @@ use rustc_span::sym;
use tracing::{debug, instrument};

use crate::borrow_set::BorrowSet;
use crate::consumers::RustcFacts;
use crate::diagnostics::RegionErrors;
use crate::handle_placeholders::compute_sccs_applying_placeholder_outlives_constraints;
use crate::polonius::PoloniusDiagnosticsContext;
use crate::polonius::legacy::{
PoloniusFacts, PoloniusFactsExt, PoloniusLocationTable, PoloniusOutput,
};
use crate::polonius::{PoloniusContext, PoloniusDiagnosticsContext};
use crate::region_infer::RegionInferenceContext;
use crate::type_check::{self, MirTypeckResults};
use crate::type_check::MirTypeckRegionConstraints;
use crate::type_check::free_region_relations::UniversalRegionRelations;
use crate::universal_regions::UniversalRegions;
use crate::{
BorrowCheckRootCtxt, BorrowckInferCtxt, ClosureOutlivesSubject, ClosureRegionRequirements,
Expand Down Expand Up @@ -76,41 +79,18 @@ pub(crate) fn replace_regions_in_mir<'tcx>(
pub(crate) fn compute_regions<'tcx>(
root_cx: &mut BorrowCheckRootCtxt<'tcx>,
infcx: &BorrowckInferCtxt<'tcx>,
universal_regions: UniversalRegions<'tcx>,
body: &Body<'tcx>,
promoted: &IndexSlice<Promoted, Body<'tcx>>,
location_table: &PoloniusLocationTable,
move_data: &MoveData<'tcx>,
borrow_set: &BorrowSet<'tcx>,
location_map: Rc<DenseLocationMap>,
universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
constraints: MirTypeckRegionConstraints<'tcx>,
mut polonius_facts: Option<AllFacts<RustcFacts>>,
polonius_context: Option<PoloniusContext>,
) -> NllOutput<'tcx> {
let is_polonius_legacy_enabled = infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled();
let polonius_input = root_cx.consumer.as_ref().map_or(false, |c| c.polonius_input())
|| is_polonius_legacy_enabled;
let polonius_output = root_cx.consumer.as_ref().map_or(false, |c| c.polonius_output())
|| is_polonius_legacy_enabled;
let mut polonius_facts =
(polonius_input || PoloniusFacts::enabled(infcx.tcx)).then_some(PoloniusFacts::default());

let location_map = Rc::new(DenseLocationMap::new(body));

// Run the MIR type-checker.
let MirTypeckResults {
constraints,
universal_region_relations,
opaque_type_values,
polonius_context,
} = type_check::type_check(
root_cx,
infcx,
body,
promoted,
universal_regions,
location_table,
borrow_set,
&mut polonius_facts,
move_data,
Rc::clone(&location_map),
);
|| infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled();

let lowered_constraints = compute_sccs_applying_placeholder_outlives_constraints(
constraints,
Expand Down Expand Up @@ -173,8 +153,6 @@ pub(crate) fn compute_regions<'tcx>(
infcx.set_tainted_by_errors(guar);
}

regioncx.infer_opaque_types(root_cx, infcx, opaque_type_values);

NllOutput {
regioncx,
polonius_input: polonius_facts.map(Box::new),
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ fn data_id_for_static(
// `extern_with_linkage_foo` will instead be initialized to
// zero.

let ref_name = format!("_rust_extern_with_linkage_{}", symbol_name);
let ref_name = format!(
"_rust_extern_with_linkage_{:016x}_{symbol_name}",
tcx.stable_crate_id(LOCAL_CRATE)
);
let ref_data_id = module.declare_data(&ref_name, Linkage::Local, false, false).unwrap();
let mut data = DataDescription::new();
data.set_align(align);
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_gcc/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rustc_codegen_ssa::traits::{
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint,
Expand Down Expand Up @@ -384,8 +385,8 @@ fn check_and_apply_linkage<'gcc, 'tcx>(
// linkage and there are no definitions), then
// `extern_with_linkage_foo` will instead be initialized to
// zero.
let mut real_name = "_rust_extern_with_linkage_".to_string();
real_name.push_str(sym);
let real_name =
format!("_rust_extern_with_linkage_{:016x}_{sym}", cx.tcx.stable_crate_id(LOCAL_CRATE));
let global2 = cx.define_global(&real_name, gcc_type, is_tls, attrs.link_section);
// TODO(antoyo): set linkage.
let value = cx.const_ptrcast(global1.get_address(None), gcc_type);
Expand Down
44 changes: 0 additions & 44 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1886,48 +1886,4 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
) {
self.call_intrinsic("llvm.instrprof.increment", &[], &[fn_name, hash, num_counters, index]);
}

/// Emits a call to `llvm.instrprof.mcdc.parameters`.
///
/// This doesn't produce any code directly, but is used as input by
/// the LLVM pass that handles coverage instrumentation.
///
/// (See clang's [`CodeGenPGO::emitMCDCParameters`] for comparison.)
///
/// [`CodeGenPGO::emitMCDCParameters`]:
/// https://github.com/rust-lang/llvm-project/blob/5399a24/clang/lib/CodeGen/CodeGenPGO.cpp#L1124
#[instrument(level = "debug", skip(self))]
pub(crate) fn mcdc_parameters(
&mut self,
fn_name: &'ll Value,
hash: &'ll Value,
bitmap_bits: &'ll Value,
) {
self.call_intrinsic("llvm.instrprof.mcdc.parameters", &[], &[fn_name, hash, bitmap_bits]);
}

#[instrument(level = "debug", skip(self))]
pub(crate) fn mcdc_tvbitmap_update(
&mut self,
fn_name: &'ll Value,
hash: &'ll Value,
bitmap_index: &'ll Value,
mcdc_temp: &'ll Value,
) {
let args = &[fn_name, hash, bitmap_index, mcdc_temp];
self.call_intrinsic("llvm.instrprof.mcdc.tvbitmap.update", &[], args);
}

#[instrument(level = "debug", skip(self))]
pub(crate) fn mcdc_condbitmap_reset(&mut self, mcdc_temp: &'ll Value) {
self.store(self.const_i32(0), mcdc_temp, self.tcx.data_layout.i32_align.abi);
}

#[instrument(level = "debug", skip(self))]
pub(crate) fn mcdc_condbitmap_update(&mut self, cond_index: &'ll Value, mcdc_temp: &'ll Value) {
let align = self.tcx.data_layout.i32_align.abi;
let current_tv_index = self.load(self.cx.type_i32(), mcdc_temp, align);
let new_tv_index = self.add(current_tv_index, cond_index);
self.store(new_tv_index, mcdc_temp, align);
}
}
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_codegen_ssa::common;
use rustc_codegen_ssa::traits::*;
use rustc_hir::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
Allocation, ConstAllocation, ErrorHandled, InitChunk, Pointer, Scalar as InterpScalar,
Expand Down Expand Up @@ -191,8 +191,8 @@ fn check_and_apply_linkage<'ll, 'tcx>(
// linkage and there are no definitions), then
// `extern_with_linkage_foo` will instead be initialized to
// zero.
let mut real_name = "_rust_extern_with_linkage_".to_string();
real_name.push_str(sym);
let real_name =
format!("_rust_extern_with_linkage_{:016x}_{sym}", cx.tcx.stable_crate_id(LOCAL_CRATE));
let g2 = cx.define_global(&real_name, llty).unwrap_or_else(|| {
cx.sess().dcx().emit_fatal(SymbolAlreadyDefined {
span: cx.tcx.def_span(def_id),
Expand Down
78 changes: 3 additions & 75 deletions compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,48 +73,6 @@ pub(crate) struct CounterExpression {
pub(crate) rhs: Counter,
}

pub(crate) mod mcdc {
use rustc_middle::mir::coverage::{ConditionId, ConditionInfo, DecisionInfo};

/// Must match the layout of `LLVMRustMCDCDecisionParameters`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct DecisionParameters {
bitmap_idx: u32,
num_conditions: u16,
}

type LLVMConditionId = i16;

/// Must match the layout of `LLVMRustMCDCBranchParameters`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct BranchParameters {
condition_id: LLVMConditionId,
condition_ids: [LLVMConditionId; 2],
}

impl From<ConditionInfo> for BranchParameters {
fn from(value: ConditionInfo) -> Self {
let to_llvm_cond_id = |cond_id: Option<ConditionId>| {
cond_id.and_then(|id| LLVMConditionId::try_from(id.as_usize()).ok()).unwrap_or(-1)
};
let ConditionInfo { condition_id, true_next_id, false_next_id } = value;
Self {
condition_id: to_llvm_cond_id(Some(condition_id)),
condition_ids: [to_llvm_cond_id(false_next_id), to_llvm_cond_id(true_next_id)],
}
}
}

impl From<DecisionInfo> for DecisionParameters {
fn from(info: DecisionInfo) -> Self {
let DecisionInfo { bitmap_idx, num_conditions } = info;
Self { bitmap_idx, num_conditions }
}
}
}

/// A span of source code coordinates to be embedded in coverage metadata.
///
/// Must match the layout of `LLVMRustCoverageSpan`.
Expand Down Expand Up @@ -148,26 +106,14 @@ pub(crate) struct Regions {
pub(crate) code_regions: Vec<CodeRegion>,
pub(crate) expansion_regions: Vec<ExpansionRegion>,
pub(crate) branch_regions: Vec<BranchRegion>,
pub(crate) mcdc_branch_regions: Vec<MCDCBranchRegion>,
pub(crate) mcdc_decision_regions: Vec<MCDCDecisionRegion>,
}

impl Regions {
/// Returns true if none of this structure's tables contain any regions.
pub(crate) fn has_no_regions(&self) -> bool {
let Self {
code_regions,
expansion_regions,
branch_regions,
mcdc_branch_regions,
mcdc_decision_regions,
} = self;

code_regions.is_empty()
&& expansion_regions.is_empty()
&& branch_regions.is_empty()
&& mcdc_branch_regions.is_empty()
&& mcdc_decision_regions.is_empty()
let Self { code_regions, expansion_regions, branch_regions } = self;

code_regions.is_empty() && expansion_regions.is_empty() && branch_regions.is_empty()
}
}

Expand Down Expand Up @@ -195,21 +141,3 @@ pub(crate) struct BranchRegion {
pub(crate) true_counter: Counter,
pub(crate) false_counter: Counter,
}

/// Must match the layout of `LLVMRustCoverageMCDCBranchRegion`.
#[derive(Clone, Debug)]
#[repr(C)]
pub(crate) struct MCDCBranchRegion {
pub(crate) cov_span: CoverageSpan,
pub(crate) true_counter: Counter,
pub(crate) false_counter: Counter,
pub(crate) mcdc_branch_params: mcdc::BranchParameters,
}

/// Must match the layout of `LLVMRustCoverageMCDCDecisionRegion`.
#[derive(Clone, Debug)]
#[repr(C)]
pub(crate) struct MCDCDecisionRegion {
pub(crate) cov_span: CoverageSpan,
pub(crate) mcdc_decision_params: mcdc::DecisionParameters,
}
Loading
Loading