Skip to content

Commit 5944b12

Browse files
committed
Auto merge of #151533 - JonathanBrouwer:rollup-P3oXrte, r=JonathanBrouwer
Rollup of 5 pull requests Successful merges: - #149639 (inline constant localized typeck constraint computation) - #150780 (Add -Z large-data-threshold) - #151520 (Rename `HandleCycleError` to `CycleErrorHandling`) - #151525 (update enzyme, includes an extra patch to fix MacOS builds in CI) - #151527 (Clean up or resolve cfg-related instances of `FIXME(f16_f128)`) r? @ghost
2 parents 9283d59 + 48b9a6c commit 5944b12

34 files changed

Lines changed: 228 additions & 170 deletions

File tree

compiler/rustc_borrowck/src/polonius/typeck_constraints.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub(super) fn convert_typeck_constraints<'tcx>(
4545
{
4646
localize_statement_constraint(
4747
tcx,
48-
body,
4948
stmt,
5049
&outlives_constraint,
5150
point,
@@ -74,7 +73,6 @@ pub(super) fn convert_typeck_constraints<'tcx>(
7473
/// needed CFG `from`-`to` intra-block nodes.
7574
fn localize_statement_constraint<'tcx>(
7675
tcx: TyCtxt<'tcx>,
77-
body: &Body<'tcx>,
7876
stmt: &Statement<'tcx>,
7977
outlives_constraint: &OutlivesConstraint<'tcx>,
8078
current_point: PointIndex,
@@ -114,28 +112,22 @@ fn localize_statement_constraint<'tcx>(
114112
},
115113
"there should be no common regions between the LHS and RHS of an assignment"
116114
);
117-
118-
let lhs_ty = body.local_decls[lhs.local].ty;
119-
let successor_point = current_point;
120-
compute_constraint_direction(
121-
tcx,
122-
outlives_constraint,
123-
&lhs_ty,
124-
current_point,
125-
successor_point,
126-
universal_regions,
127-
)
128115
}
129116
_ => {
130-
// For the other cases, we localize an outlives constraint to where it arises.
131-
LocalizedOutlivesConstraint {
132-
source: outlives_constraint.sup,
133-
from: current_point,
134-
target: outlives_constraint.sub,
135-
to: current_point,
136-
}
117+
// Assignments should be the only statement that can both generate constraints that
118+
// apply on entry (specific to the RHS place) *and* others that only apply on exit (the
119+
// subset of RHS regions that actually flow into the LHS): i.e., where midpoints would
120+
// be used to ensure the former happen before the latter, within the same MIR Location.
137121
}
138122
}
123+
124+
// We generally localize an outlives constraint to where it arises.
125+
LocalizedOutlivesConstraint {
126+
source: outlives_constraint.sup,
127+
from: current_point,
128+
target: outlives_constraint.sub,
129+
to: current_point,
130+
}
139131
}
140132

141133
/// For a given outlives constraint arising from a MIR terminator, localize the constraint with the
@@ -150,14 +142,12 @@ fn localize_terminator_constraint<'tcx>(
150142
universal_regions: &UniversalRegions<'tcx>,
151143
) -> LocalizedOutlivesConstraint {
152144
// FIXME: check if other terminators need the same handling as `Call`s, in particular
153-
// Assert/Yield/Drop. A handful of tests are failing with Drop related issues, as well as some
154-
// coroutine tests, and that may be why.
145+
// Assert/Yield/Drop.
155146
match &terminator.kind {
156147
// FIXME: also handle diverging calls.
157148
TerminatorKind::Call { destination, target: Some(target), .. } => {
158-
// Calls are similar to assignments, and thus follow the same pattern. If there is a
159-
// target for the call we also relate what flows into the destination here to entry to
160-
// that successor.
149+
// If there is a target for the call we also relate what flows into the destination here
150+
// to entry to that successor.
161151
let destination_ty = destination.ty(&body.local_decls, tcx);
162152
let successor_location = Location { block: *target, statement_index: 0 };
163153
let successor_point = liveness.point_from_location(successor_location);

compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl OwnedTargetMachine {
3939
debug_info_compression: llvm::CompressionKind,
4040
use_emulated_tls: bool,
4141
use_wasm_eh: bool,
42+
large_data_threshold: u64,
4243
) -> Result<Self, LlvmError<'static>> {
4344
// SAFETY: llvm::LLVMRustCreateTargetMachine copies pointed to data
4445
let tm_ptr = unsafe {
@@ -65,6 +66,7 @@ impl OwnedTargetMachine {
6566
debug_info_compression,
6667
use_emulated_tls,
6768
use_wasm_eh,
69+
large_data_threshold,
6870
)
6971
};
7072

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ pub(crate) fn target_machine_factory(
275275

276276
let use_wasm_eh = wants_wasm_eh(sess);
277277

278+
let large_data_threshold = sess.opts.unstable_opts.large_data_threshold.unwrap_or(0);
279+
278280
let prof = SelfProfilerRef::clone(&sess.prof);
279281
Arc::new(move |config: TargetMachineFactoryConfig| {
280282
// Self-profile timer for invoking a factory to create a target machine.
@@ -316,6 +318,7 @@ pub(crate) fn target_machine_factory(
316318
debuginfo_compression,
317319
use_emulated_tls,
318320
use_wasm_eh,
321+
large_data_threshold,
319322
)
320323
})
321324
}

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@ impl MsvcBasicName for ty::UintTy {
665665

666666
impl MsvcBasicName for ty::FloatTy {
667667
fn msvc_basic_name(self) -> &'static str {
668-
// FIXME(f16_f128): `f16` and `f128` have no MSVC representation. We could improve the
669-
// debuginfo. See: <https://github.com/rust-lang/rust/issues/121837>
668+
// FIXME(f128): `f128` has no MSVC representation. We could improve the debuginfo.
669+
// See: <https://github.com/rust-lang/rust/issues/121837>
670670
match self {
671671
ty::FloatTy::F16 => {
672672
bug!("`f16` should have been handled in `build_basic_type_di_node`")

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,7 @@ unsafe extern "C" {
23472347
DebugInfoCompression: CompressionKind,
23482348
UseEmulatedTls: bool,
23492349
UseWasmEH: bool,
2350+
LargeDataThreshold: u64,
23502351
) -> *mut TargetMachine;
23512352

23522353
pub(crate) fn LLVMRustAddLibraryInfo<'a>(

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
305305
bool EmitStackSizeSection, bool RelaxELFRelocations, bool UseInitArray,
306306
const char *SplitDwarfFile, const char *OutputObjFile,
307307
LLVMRustCompressionKind DebugInfoCompression, bool UseEmulatedTls,
308-
bool UseWasmEH) {
308+
bool UseWasmEH, uint64_t LargeDataThreshold) {
309309

310310
auto OptLevel = fromRust(RustOptLevel);
311311
auto RM = fromRust(RustReloc);
@@ -381,6 +381,11 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
381381
TargetMachine *TM = TheTarget->createTargetMachine(
382382
Trip.getTriple(), CPU, Feature, Options, RM, CM, OptLevel);
383383
#endif
384+
385+
if (LargeDataThreshold != 0) {
386+
TM->setLargeDataThreshold(LargeDataThreshold);
387+
}
388+
384389
return wrap(TM);
385390
}
386391

compiler/rustc_middle/src/query/plumbing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ use rustc_data_structures::sync::{AtomicU64, WorkerLocal};
44
use rustc_hir::def_id::{DefId, LocalDefId};
55
use rustc_hir::hir_id::OwnerId;
66
use rustc_macros::HashStable;
7-
use rustc_query_system::HandleCycleError;
87
use rustc_query_system::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
98
pub(crate) use rustc_query_system::query::QueryJobId;
10-
use rustc_query_system::query::*;
9+
use rustc_query_system::query::{CycleError, CycleErrorHandling, HashResult, QueryCache};
1110
use rustc_span::{ErrorGuaranteed, Span};
1211
pub use sealed::IntoQueryParam;
1312

@@ -23,7 +22,8 @@ pub struct DynamicQuery<'tcx, C: QueryCache> {
2322
pub name: &'static str,
2423
pub eval_always: bool,
2524
pub dep_kind: DepKind,
26-
pub handle_cycle_error: HandleCycleError,
25+
/// How this query deals with query cycle errors.
26+
pub cycle_error_handling: CycleErrorHandling,
2727
// Offset of this query's state field in the QueryStates struct
2828
pub query_state: usize,
2929
// Offset of this query's cache field in the QueryCaches struct

compiler/rustc_query_impl/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ use rustc_middle::query::{
1818
queries,
1919
};
2020
use rustc_middle::ty::TyCtxt;
21+
use rustc_query_system::Value;
2122
use rustc_query_system::dep_graph::SerializedDepNodeIndex;
2223
use rustc_query_system::ich::StableHashingContext;
2324
use rustc_query_system::query::{
24-
CycleError, HashResult, QueryCache, QueryConfig, QueryMap, QueryMode, QueryState,
25-
get_query_incr, get_query_non_incr,
25+
CycleError, CycleErrorHandling, HashResult, QueryCache, QueryConfig, QueryMap, QueryMode,
26+
QueryState, get_query_incr, get_query_non_incr,
2627
};
27-
use rustc_query_system::{HandleCycleError, Value};
2828
use rustc_span::{ErrorGuaranteed, Span};
2929

3030
use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green};
@@ -181,8 +181,8 @@ where
181181
}
182182

183183
#[inline(always)]
184-
fn handle_cycle_error(self) -> HandleCycleError {
185-
self.dynamic.handle_cycle_error
184+
fn cycle_error_handling(self) -> CycleErrorHandling {
185+
self.dynamic.cycle_error_handling
186186
}
187187

188188
#[inline(always)]

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,21 @@ pub fn query_key_hash_verify_all<'tcx>(tcx: TyCtxt<'tcx>) {
199199
}
200200
}
201201

202-
macro_rules! handle_cycle_error {
202+
macro_rules! cycle_error_handling {
203203
([]) => {{
204-
rustc_query_system::HandleCycleError::Error
204+
rustc_query_system::query::CycleErrorHandling::Error
205205
}};
206206
([(cycle_fatal) $($rest:tt)*]) => {{
207-
rustc_query_system::HandleCycleError::Fatal
207+
rustc_query_system::query::CycleErrorHandling::Fatal
208208
}};
209209
([(cycle_stash) $($rest:tt)*]) => {{
210-
rustc_query_system::HandleCycleError::Stash
210+
rustc_query_system::query::CycleErrorHandling::Stash
211211
}};
212212
([(cycle_delay_bug) $($rest:tt)*]) => {{
213-
rustc_query_system::HandleCycleError::DelayBug
213+
rustc_query_system::query::CycleErrorHandling::DelayBug
214214
}};
215215
([$other:tt $($modifiers:tt)*]) => {
216-
handle_cycle_error!([$($modifiers)*])
216+
cycle_error_handling!([$($modifiers)*])
217217
};
218218
}
219219

@@ -618,7 +618,7 @@ macro_rules! define_queries {
618618
name: stringify!($name),
619619
eval_always: is_eval_always!([$($modifiers)*]),
620620
dep_kind: dep_graph::dep_kinds::$name,
621-
handle_cycle_error: handle_cycle_error!([$($modifiers)*]),
621+
cycle_error_handling: cycle_error_handling!([$($modifiers)*]),
622622
query_state: std::mem::offset_of!(QueryStates<'tcx>, $name),
623623
query_cache: std::mem::offset_of!(QueryCaches<'tcx>, $name),
624624
cache_on_disk: |tcx, key| ::rustc_middle::query::cached::$name(tcx, key),

compiler/rustc_query_system/src/error.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ pub(crate) struct CycleStack {
1111
pub desc: String,
1212
}
1313

14-
#[derive(Copy, Clone)]
15-
pub enum HandleCycleError {
16-
Error,
17-
Fatal,
18-
DelayBug,
19-
Stash,
20-
}
21-
2214
#[derive(Subdiagnostic)]
2315
pub(crate) enum StackCount {
2416
#[note(query_system_cycle_stack_single)]

0 commit comments

Comments
 (0)