Skip to content

Commit fb20e4d

Browse files
committed
Auto merge of rust-lang#131573 - tgross35:rollup-r7l182a, r=tgross35
Rollup of 7 pull requests Successful merges: - rust-lang#130078 (rustdoc-json: change item ID's repr from a string to an int) - rust-lang#131065 (Port sort-research-rs test suite to Rust stdlib tests) - rust-lang#131109 (Stabilize `debug_more_non_exhaustive`) - rust-lang#131287 (stabilize const_result) - rust-lang#131463 (Stabilise `const_char_encode_utf8`.) - rust-lang#131543 (coverage: Remove code related to LLVM 17) - rust-lang#131552 (RustWrapper: adapt for rename of Intrinsic::getDeclaration) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1bc403d + 6f76d6e commit fb20e4d

File tree

23 files changed

+2325
-810
lines changed

23 files changed

+2325
-810
lines changed

Diff for: compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,20 @@ use crate::coverageinfo::ffi::CounterMappingRegion;
1414
use crate::coverageinfo::map_data::{FunctionCoverage, FunctionCoverageCollector};
1515
use crate::{coverageinfo, llvm};
1616

17-
/// Generates and exports the Coverage Map.
17+
/// Generates and exports the coverage map, which is embedded in special
18+
/// linker sections in the final binary.
1819
///
19-
/// Rust Coverage Map generation supports LLVM Coverage Mapping Format versions
20-
/// 6 and 7 (encoded as 5 and 6 respectively), as described at
21-
/// [LLVM Code Coverage Mapping Format](https://github.com/rust-lang/llvm-project/blob/rustc/18.0-2024-02-13/llvm/docs/CoverageMappingFormat.rst).
22-
/// These versions are supported by the LLVM coverage tools (`llvm-profdata` and `llvm-cov`)
23-
/// distributed in the `llvm-tools-preview` rustup component.
24-
///
25-
/// Consequently, Rust's bundled version of Clang also generates Coverage Maps compliant with
26-
/// the same version. Clang's implementation of Coverage Map generation was referenced when
27-
/// implementing this Rust version, and though the format documentation is very explicit and
28-
/// detailed, some undocumented details in Clang's implementation (that may or may not be important)
29-
/// were also replicated for Rust's Coverage Map.
20+
/// Those sections are then read and understood by LLVM's `llvm-cov` tool,
21+
/// which is distributed in the `llvm-tools` rustup component.
3022
pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) {
3123
let tcx = cx.tcx;
3224

3325
// Ensure that LLVM is using a version of the coverage mapping format that
3426
// agrees with our Rust-side code. Expected versions (encoded as n-1) are:
35-
// - `CovMapVersion::Version6` (5) used by LLVM 13-17
36-
// - `CovMapVersion::Version7` (6) used by LLVM 18
27+
// - `CovMapVersion::Version7` (6) used by LLVM 18-19
3728
let covmap_version = {
3829
let llvm_covmap_version = coverageinfo::mapping_version();
39-
let expected_versions = 5..=6;
30+
let expected_versions = 6..=6;
4031
assert!(
4132
expected_versions.contains(&llvm_covmap_version),
4233
"Coverage mapping version exposed by `llvm-wrapper` is out of sync; \

Diff for: compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
183183
RustMappingRegions, NumMappingRegions)) {
184184
MappingRegions.emplace_back(
185185
fromRust(Region.Count), fromRust(Region.FalseCount),
186-
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
186+
#if LLVM_VERSION_LT(19, 0)
187187
coverage::CounterMappingRegion::MCDCParameters{},
188188
#endif
189189
Region.FileID, Region.ExpandedFileID, // File IDs, then region info.

Diff for: compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -1533,27 +1533,40 @@ extern "C" LLVMValueRef LLVMRustBuildCall(LLVMBuilderRef B, LLVMTypeRef Ty,
15331533

15341534
extern "C" LLVMValueRef
15351535
LLVMRustGetInstrProfIncrementIntrinsic(LLVMModuleRef M) {
1536+
#if LLVM_VERSION_GE(20, 0)
1537+
return wrap(llvm::Intrinsic::getOrInsertDeclaration(
1538+
unwrap(M), llvm::Intrinsic::instrprof_increment));
1539+
#else
15361540
return wrap(llvm::Intrinsic::getDeclaration(
15371541
unwrap(M), llvm::Intrinsic::instrprof_increment));
1542+
#endif
15381543
}
15391544

15401545
extern "C" LLVMValueRef
15411546
LLVMRustGetInstrProfMCDCParametersIntrinsic(LLVMModuleRef M) {
1542-
#if LLVM_VERSION_GE(19, 0)
1543-
return wrap(llvm::Intrinsic::getDeclaration(
1547+
#if LLVM_VERSION_LT(19, 0)
1548+
report_fatal_error("LLVM 19.0 is required for mcdc intrinsic functions");
1549+
#endif
1550+
#if LLVM_VERSION_GE(20, 0)
1551+
return wrap(llvm::Intrinsic::getOrInsertDeclaration(
15441552
unwrap(M), llvm::Intrinsic::instrprof_mcdc_parameters));
15451553
#else
1546-
report_fatal_error("LLVM 19.0 is required for mcdc intrinsic functions");
1554+
return wrap(llvm::Intrinsic::getDeclaration(
1555+
unwrap(M), llvm::Intrinsic::instrprof_mcdc_parameters));
15471556
#endif
15481557
}
15491558

15501559
extern "C" LLVMValueRef
15511560
LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(LLVMModuleRef M) {
1552-
#if LLVM_VERSION_GE(19, 0)
1553-
return wrap(llvm::Intrinsic::getDeclaration(
1561+
#if LLVM_VERSION_LT(19, 0)
1562+
report_fatal_error("LLVM 19.0 is required for mcdc intrinsic functions");
1563+
#endif
1564+
#if LLVM_VERSION_GE(20, 0)
1565+
return wrap(llvm::Intrinsic::getOrInsertDeclaration(
15541566
unwrap(M), llvm::Intrinsic::instrprof_mcdc_tvbitmap_update));
15551567
#else
1556-
report_fatal_error("LLVM 19.0 is required for mcdc intrinsic functions");
1568+
return wrap(llvm::Intrinsic::getDeclaration(
1569+
unwrap(M), llvm::Intrinsic::instrprof_mcdc_tvbitmap_update));
15571570
#endif
15581571
}
15591572

Diff for: library/alloc/src/slice.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ use core::cmp::Ordering::{self, Less};
1919
use core::mem::{self, MaybeUninit};
2020
#[cfg(not(no_global_oom_handling))]
2121
use core::ptr;
22-
#[cfg(not(no_global_oom_handling))]
23-
use core::slice::sort;
24-
25-
use crate::alloc::Allocator;
26-
#[cfg(not(no_global_oom_handling))]
27-
use crate::alloc::Global;
28-
#[cfg(not(no_global_oom_handling))]
29-
use crate::borrow::ToOwned;
30-
use crate::boxed::Box;
31-
use crate::vec::Vec;
32-
33-
#[cfg(test)]
34-
mod tests;
35-
3622
#[unstable(feature = "array_chunks", issue = "74985")]
3723
pub use core::slice::ArrayChunks;
3824
#[unstable(feature = "array_chunks", issue = "74985")]
@@ -43,6 +29,8 @@ pub use core::slice::ArrayWindows;
4329
pub use core::slice::EscapeAscii;
4430
#[stable(feature = "slice_get_slice", since = "1.28.0")]
4531
pub use core::slice::SliceIndex;
32+
#[cfg(not(no_global_oom_handling))]
33+
use core::slice::sort;
4634
#[stable(feature = "slice_group_by", since = "1.77.0")]
4735
pub use core::slice::{ChunkBy, ChunkByMut};
4836
#[stable(feature = "rust1", since = "1.0.0")]
@@ -83,6 +71,14 @@ pub use hack::into_vec;
8371
#[cfg(test)]
8472
pub use hack::to_vec;
8573

74+
use crate::alloc::Allocator;
75+
#[cfg(not(no_global_oom_handling))]
76+
use crate::alloc::Global;
77+
#[cfg(not(no_global_oom_handling))]
78+
use crate::borrow::ToOwned;
79+
use crate::boxed::Box;
80+
use crate::vec::Vec;
81+
8682
// HACK(japaric): With cfg(test) `impl [T]` is not available, these three
8783
// functions are actually methods that are in `impl [T]` but not in
8884
// `core::slice::SliceExt` - we need to supply these functions for the

0 commit comments

Comments
 (0)