Auto merge of #132631 - workingjubilee:rollup-dx0krqp, r=workingjubilee

Rollup of 4 pull requests

Successful merges:

 - #132153 (Stabilise `const_char_encode_utf16`.)
 - #132473 ([core/fmt] Replace checked slice indexing by unchecked to support panic-free code)
 - #132600 (PassWrapper: adapt for new parameter in LLVM)
 - #132630 (triagebot: ping wg-const-eval when relevant files change)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-11-05 18:58:59 +00:00
commit bc5cf994db
5 changed files with 56 additions and 11 deletions

View File

@ -784,8 +784,14 @@ extern "C" LLVMRustResult LLVMRustOptimize(
// the PassBuilder does not create a pipeline.
std::vector<std::function<void(ModulePassManager &, OptimizationLevel)>>
PipelineStartEPCallbacks;
#if LLVM_VERSION_GE(20, 0)
std::vector<std::function<void(ModulePassManager &, OptimizationLevel,
ThinOrFullLTOPhase)>>
OptimizerLastEPCallbacks;
#else
std::vector<std::function<void(ModulePassManager &, OptimizationLevel)>>
OptimizerLastEPCallbacks;
#endif
if (!IsLinkerPluginLTO && SanitizerOptions && SanitizerOptions->SanitizeCFI &&
!NoPrepopulatePasses) {
@ -832,7 +838,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
SanitizerOptions->SanitizeDataFlowABIList +
SanitizerOptions->SanitizeDataFlowABIListLen);
OptimizerLastEPCallbacks.push_back(
#if LLVM_VERSION_GE(20, 0)
[ABIListFiles](ModulePassManager &MPM, OptimizationLevel Level,
ThinOrFullLTOPhase phase) {
#else
[ABIListFiles](ModulePassManager &MPM, OptimizationLevel Level) {
#endif
MPM.addPass(DataFlowSanitizerPass(ABIListFiles));
});
}
@ -844,23 +855,39 @@ extern "C" LLVMRustResult LLVMRustOptimize(
/*CompileKernel=*/false,
/*EagerChecks=*/true);
OptimizerLastEPCallbacks.push_back(
#if LLVM_VERSION_GE(20, 0)
[Options](ModulePassManager &MPM, OptimizationLevel Level,
ThinOrFullLTOPhase phase) {
#else
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
#endif
MPM.addPass(MemorySanitizerPass(Options));
});
}
if (SanitizerOptions->SanitizeThread) {
OptimizerLastEPCallbacks.push_back([](ModulePassManager &MPM,
OptimizationLevel Level) {
OptimizerLastEPCallbacks.push_back(
#if LLVM_VERSION_GE(20, 0)
[](ModulePassManager &MPM, OptimizationLevel Level,
ThinOrFullLTOPhase phase) {
#else
[](ModulePassManager &MPM, OptimizationLevel Level) {
#endif
MPM.addPass(ModuleThreadSanitizerPass());
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
MPM.addPass(
createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
});
}
if (SanitizerOptions->SanitizeAddress ||
SanitizerOptions->SanitizeKernelAddress) {
OptimizerLastEPCallbacks.push_back(
#if LLVM_VERSION_GE(20, 0)
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level,
ThinOrFullLTOPhase phase) {
#else
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
#endif
auto CompileKernel = SanitizerOptions->SanitizeKernelAddress;
AddressSanitizerOptions opts = AddressSanitizerOptions{
CompileKernel,
@ -874,7 +901,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
}
if (SanitizerOptions->SanitizeHWAddress) {
OptimizerLastEPCallbacks.push_back(
#if LLVM_VERSION_GE(20, 0)
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level,
ThinOrFullLTOPhase phase) {
#else
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
#endif
HWAddressSanitizerOptions opts(
/*CompileKernel=*/false,
SanitizerOptions->SanitizeHWAddressRecover,
@ -935,7 +967,11 @@ extern "C" LLVMRustResult LLVMRustOptimize(
for (const auto &C : PipelineStartEPCallbacks)
C(MPM, OptLevel);
for (const auto &C : OptimizerLastEPCallbacks)
#if LLVM_VERSION_GE(20, 0)
C(MPM, OptLevel, ThinOrFullLTOPhase::None);
#else
C(MPM, OptLevel);
#endif
}
if (ExtraPassesLen) {

View File

@ -711,7 +711,7 @@ pub const fn encode_utf8(self, dst: &mut [u8]) -> &mut str {
/// '𝕊'.encode_utf16(&mut b);
/// ```
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
#[rustc_const_unstable(feature = "const_char_encode_utf16", issue = "130660")]
#[rustc_const_stable(feature = "const_char_encode_utf16", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] {
encode_utf16_raw(self as u32, dst)
@ -1819,7 +1819,10 @@ pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
/// Panics if the buffer is not large enough.
/// A buffer of length 2 is large enough to encode any `char`.
#[unstable(feature = "char_internals", reason = "exposed only for libstd", issue = "none")]
#[rustc_const_unstable(feature = "const_char_encode_utf16", issue = "130660")]
#[cfg_attr(
bootstrap,
rustc_const_stable(feature = "const_char_encode_utf16", since = "CURRENT_RUSTC_VERSION")
)]
#[doc(hidden)]
#[inline]
pub const fn encode_utf16_raw(mut code: u32, dst: &mut [u16]) -> &mut [u16] {

View File

@ -88,7 +88,10 @@ fn fmt_int<T: DisplayInt>(&self, mut x: T, f: &mut fmt::Formatter<'_>) -> fmt::R
};
}
}
let buf = &buf[curr..];
// SAFETY: `curr` is initialized to `buf.len()` and is only decremented, so it can't overflow. It is
// decremented exactly once for each digit. Since u128 is the widest fixed width integer format supported,
// the maximum number of digits (bits) is 128 for base-2, so `curr` won't underflow as well.
let buf = unsafe { buf.get_unchecked(curr..) };
// SAFETY: The only chars in `buf` are created by `Self::digit` which are assumed to be
// valid UTF-8
let buf = unsafe {

View File

@ -115,7 +115,6 @@
#![feature(const_align_of_val_raw)]
#![feature(const_alloc_layout)]
#![feature(const_black_box)]
#![feature(const_char_encode_utf16)]
#![feature(const_eval_select)]
#![feature(const_float_methods)]
#![feature(const_heap)]

View File

@ -611,6 +611,10 @@ cc = ["@bjorn3"]
[mentions."compiler/rustc_codegen_gcc"]
cc = ["@antoyo", "@GuillaumeGomez"]
[mentions."compiler/rustc_const_eval/src/"]
message = "Some changes occurred to the CTFE machinery"
cc = ["@rust-lang/wg-const-eval"]
[mentions."compiler/rustc_const_eval/src/interpret"]
message = "Some changes occurred to the CTFE / Miri interpreter"
cc = ["@rust-lang/miri"]
@ -633,7 +637,7 @@ cc = ["@compiler-errors", "@lcnr"]
[mentions."compiler/rustc_middle/src/mir/interpret"]
message = "Some changes occurred to the CTFE / Miri interpreter"
cc = ["@rust-lang/miri"]
cc = ["@rust-lang/miri", "@rust-lang/wg-const-eval"]
[mentions."compiler/rustc_mir_transform/src/"]
message = "Some changes occurred to MIR optimizations"
@ -706,7 +710,7 @@ message = """
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.
"""
cc = ["@rust-lang/miri"]
cc = ["@rust-lang/miri", "@rust-lang/wg-const-eval"]
[mentions."library/portable-simd"]
message = """