1use rustc_abi as abi;
5use rustc_data_structures::graph::dominators::Dominators;
6use rustc_index::bit_set::DenseBitSet;
7use rustc_index::{IndexSlice, IndexVec};
8use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
9use rustc_middle::mir::{self, DefLocation, Location, TerminatorKind, traversal};
10use rustc_middle::ty;
11use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
12use rustc_span::{bug, span_bug};
13use tracing::debug;
14
15use super::FunctionCx;
16use crate::traits::*;
17
18pub(crate) fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
19 fx: &FunctionCx<'a, 'tcx, Bx>,
20 traversal_order: &[mir::BasicBlock],
21) -> DenseBitSet<mir::Local> {
22 let mir = fx.mir;
23 let dominators = mir.basic_blocks.dominators();
24 let locals = mir
25 .local_decls
26 .iter()
27 .map(|decl| {
28 let ty = fx.monomorphize(decl.ty);
29 let layout = fx.cx.spanned_layout_of(ty, decl.source_info.span);
30 if layout.is_zst() { LocalKind::ZST } else { LocalKind::Unused }
31 })
32 .collect();
33
34 let mut analyzer = LocalAnalyzer { fx, dominators, locals };
35
36 for arg in mir.args_iter() {
38 analyzer.define(arg, DefLocation::Argument);
39 }
40
41 for bb in traversal_order.iter().copied() {
45 let data = &mir.basic_blocks[bb];
46 analyzer.visit_basic_block_data(bb, data);
47 }
48
49 let mut non_ssa_locals = DenseBitSet::new_empty(analyzer.locals.len());
50 for (local, kind) in analyzer.locals.iter_enumerated() {
51 if #[allow(non_exhaustive_omitted_patterns)] match kind {
LocalKind::Memory => true,
_ => false,
}matches!(kind, LocalKind::Memory) {
52 non_ssa_locals.insert(local);
53 }
54 }
55
56 non_ssa_locals
57}
58
59#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LocalKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LocalKind::ZST => ::core::fmt::Formatter::write_str(f, "ZST"),
LocalKind::Memory =>
::core::fmt::Formatter::write_str(f, "Memory"),
LocalKind::Unused =>
::core::fmt::Formatter::write_str(f, "Unused"),
LocalKind::SSA(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "SSA",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LocalKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for LocalKind { }
#[automatically_derived]
impl ::core::clone::Clone for LocalKind {
#[inline]
fn clone(&self) -> LocalKind {
let _: ::core::clone::AssertParamIsClone<DefLocation>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for LocalKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for LocalKind {
#[inline]
fn eq(&self, other: &LocalKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(LocalKind::SSA(__self_0), LocalKind::SSA(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LocalKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<DefLocation>;
}
}Eq)]
60enum LocalKind {
61 ZST,
62 Memory,
64 Unused,
66 SSA(DefLocation),
68}
69
70struct LocalAnalyzer<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> {
71 fx: &'a FunctionCx<'b, 'tcx, Bx>,
72 dominators: &'a Dominators<mir::BasicBlock>,
73 locals: IndexVec<mir::Local, LocalKind>,
74}
75
76impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> LocalAnalyzer<'a, 'b, 'tcx, Bx> {
77 fn define(&mut self, local: mir::Local, location: DefLocation) {
78 let fx = self.fx;
79 let kind = &mut self.locals[local];
80 let decl = &fx.mir.local_decls[local];
81 match *kind {
82 LocalKind::ZST => {}
83 LocalKind::Memory => {}
84 LocalKind::Unused => {
85 let ty = fx.monomorphize(decl.ty);
86 let layout = fx.cx.spanned_layout_of(ty, decl.source_info.span);
87 *kind = if let abi::BackendRepr::Memory { .. } = layout.backend_repr {
88 LocalKind::Memory
89 } else {
90 LocalKind::SSA(location)
91 };
92 }
93 LocalKind::SSA(_) => *kind = LocalKind::Memory,
94 }
95 }
96
97 fn process_place(
98 &mut self,
99 place_ref: &mir::PlaceRef<'tcx>,
100 context: PlaceContext,
101 location: Location,
102 ) {
103 if !place_ref.projection.is_empty() {
104 const COPY_CONTEXT: PlaceContext =
105 PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy);
106
107 for elem in place_ref.projection {
110 if let mir::PlaceElem::Index(index_local) = *elem {
111 self.visit_local(index_local, COPY_CONTEXT, location);
112 }
113 }
114
115 if self.locals[place_ref.local] == LocalKind::Memory {
118 return;
119 }
120
121 if place_ref.is_indirect_first_projection() {
122 self.visit_local(place_ref.local, COPY_CONTEXT, location);
127 return;
128 }
129
130 if context.is_mutating_use() {
131 let mut_projection = PlaceContext::MutatingUse(MutatingUseContext::Projection);
135 self.visit_local(place_ref.local, mut_projection, location);
136 return;
137 }
138
139 let base_ty = self.fx.monomorphized_place_ty(mir::PlaceRef::from(place_ref.local));
142 let mut layout = self.fx.cx.layout_of(base_ty);
143 for elem in place_ref.projection {
144 layout = match *elem {
145 mir::PlaceElem::Field(fidx, ..) => layout.field(self.fx.cx, fidx.as_usize()),
146 mir::PlaceElem::Downcast(_, vidx)
147 if let abi::Variants::Single { index: single_variant } =
148 layout.variants
149 && vidx == single_variant =>
150 {
151 layout.for_variant(self.fx.cx, vidx)
152 }
153 _ => {
154 self.locals[place_ref.local] = LocalKind::Memory;
155 return;
156 }
157 }
158 }
159 if true {
if !layout.is_ssa_standalone() {
{
::core::panicking::panic_fmt(format_args!("Post-projection {0:?} layout should be non-Ref, but it\'s {1:?}",
place_ref, layout));
}
};
};debug_assert!(
160 layout.is_ssa_standalone(),
161 "Post-projection {place_ref:?} layout should be non-Ref, but it's {layout:?}",
162 );
163 }
164
165 self.visit_local(place_ref.local, context, location);
168 }
169}
170
171impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> Visitor<'tcx> for LocalAnalyzer<'a, 'b, 'tcx, Bx> {
172 fn visit_assign(
173 &mut self,
174 place: &mir::Place<'tcx>,
175 rvalue: &mir::Rvalue<'tcx>,
176 location: Location,
177 ) {
178 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:178",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(178u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("visit_assign(place={0:?}, rvalue={1:?})",
place, rvalue) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
179
180 if let Some(local) = place.as_local() {
181 self.define(local, DefLocation::Assignment(location));
182 } else {
183 self.visit_place(place, PlaceContext::MutatingUse(MutatingUseContext::Store), location);
184 }
185
186 self.visit_rvalue(rvalue, location);
187 }
188
189 fn visit_place(&mut self, place: &mir::Place<'tcx>, context: PlaceContext, location: Location) {
190 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:190",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(190u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("visit_place(place={0:?}, context={1:?})",
place, context) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("visit_place(place={:?}, context={:?})", place, context);
191 self.process_place(&place.as_ref(), context, location);
192 }
193
194 fn visit_local(&mut self, local: mir::Local, context: PlaceContext, location: Location) {
195 match context {
196 PlaceContext::MutatingUse(MutatingUseContext::Call) => {
197 let call = location.block;
198 let TerminatorKind::Call { target, func, .. } =
199 &self.fx.mir.basic_blocks[call].terminator().kind
200 else {
201 bug_impl(None, format_args!("impossible case reached"), Location::caller())bug!()
202 };
203 let tcx = self.fx.cx.tcx();
204 let func_ty = func.ty(&self.fx.mir.local_decls, tcx);
205 if let ty::FnDef(def_id, _args) = *func_ty.kind()
206 && let Some(intrinsic) = tcx.intrinsic(def_id)
207 && self.fx.cx.intrinsic_call_expects_place_always(intrinsic.name)
208 {
209 self.locals[local] = LocalKind::Memory;
210 }
211 self.define(local, DefLocation::CallReturn { call, target: *target });
212 }
213
214 PlaceContext::NonUse(_)
215 | PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention) => {}
216
217 PlaceContext::NonMutatingUse(
218 NonMutatingUseContext::Copy
219 | NonMutatingUseContext::Move
220 | NonMutatingUseContext::Inspect,
224 ) => match &mut self.locals[local] {
225 LocalKind::ZST => {}
226 LocalKind::Memory => {}
227 LocalKind::SSA(def) if def.dominates(location, self.dominators) => {}
228 kind @ (LocalKind::Unused | LocalKind::SSA(_)) => {
233 *kind = LocalKind::Memory;
234 }
235 },
236
237 PlaceContext::MutatingUse(
238 MutatingUseContext::Store
239 | MutatingUseContext::SetDiscriminant
240 | MutatingUseContext::AsmOutput
241 | MutatingUseContext::Borrow
242 | MutatingUseContext::RawBorrow
243 | MutatingUseContext::Projection,
244 )
245 | PlaceContext::NonMutatingUse(
246 NonMutatingUseContext::SharedBorrow
247 | NonMutatingUseContext::FakeBorrow
248 | NonMutatingUseContext::RawBorrow
249 | NonMutatingUseContext::Projection,
250 ) => {
251 self.locals[local] = LocalKind::Memory;
252 }
253
254 PlaceContext::MutatingUse(MutatingUseContext::Drop) => {
255 let kind = &mut self.locals[local];
256 if *kind != LocalKind::Memory {
257 let ty = self.fx.mir.local_decls[local].ty;
258 let ty = self.fx.monomorphize(ty);
259 if self.fx.cx.type_needs_drop(ty) {
260 *kind = LocalKind::Memory;
262 }
263 }
264 }
265
266 PlaceContext::MutatingUse(MutatingUseContext::Yield) => bug_impl(None, format_args!("impossible case reached"), Location::caller())bug!(),
267 }
268 }
269
270 fn visit_statement_debuginfo(&mut self, _: &mir::StmtDebugInfo<'tcx>, _: Location) {
271 }
273}
274
275#[derive(#[automatically_derived]
impl ::core::marker::Copy for CleanupKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for CleanupKind { }
#[automatically_derived]
impl ::core::clone::Clone for CleanupKind {
#[inline]
fn clone(&self) -> CleanupKind {
let _: ::core::clone::AssertParamIsClone<mir::BasicBlock>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CleanupKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
CleanupKind::NotCleanup =>
::core::fmt::Formatter::write_str(f, "NotCleanup"),
CleanupKind::Funclet =>
::core::fmt::Formatter::write_str(f, "Funclet"),
CleanupKind::Internal { funclet: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Internal", "funclet", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for CleanupKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for CleanupKind {
#[inline]
fn eq(&self, other: &CleanupKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(CleanupKind::Internal { funclet: __self_0 },
CleanupKind::Internal { funclet: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CleanupKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<mir::BasicBlock>;
}
}Eq)]
276pub(crate) enum CleanupKind {
277 NotCleanup,
278 Funclet,
279 Internal { funclet: mir::BasicBlock },
280}
281
282impl CleanupKind {
283 pub(crate) fn funclet_bb(self, for_bb: mir::BasicBlock) -> Option<mir::BasicBlock> {
284 match self {
285 CleanupKind::NotCleanup => None,
286 CleanupKind::Funclet => Some(for_bb),
287 CleanupKind::Internal { funclet } => Some(funclet),
288 }
289 }
290}
291
292pub(crate) fn cleanup_kinds(
296 mir: &mir::Body<'_>,
297 nop_landing_pads: &DenseBitSet<mir::BasicBlock>,
298) -> IndexVec<mir::BasicBlock, CleanupKind> {
299 fn discover_masters<'tcx>(
300 result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
301 mir: &mir::Body<'tcx>,
302 nop_landing_pads: &DenseBitSet<mir::BasicBlock>,
303 ) {
304 for (bb, data) in mir.basic_blocks.iter_enumerated() {
305 match data.terminator().kind {
306 TerminatorKind::Goto { .. }
307 | TerminatorKind::UnwindResume
308 | TerminatorKind::UnwindTerminate(_)
309 | TerminatorKind::Return
310 | TerminatorKind::TailCall { .. }
311 | TerminatorKind::CoroutineDrop
312 | TerminatorKind::Unreachable
313 | TerminatorKind::SwitchInt { .. }
314 | TerminatorKind::Yield { .. }
315 | TerminatorKind::FalseEdge { .. }
316 | TerminatorKind::FalseUnwind { .. } => { }
317 TerminatorKind::Call { unwind, .. }
318 | TerminatorKind::InlineAsm { unwind, .. }
319 | TerminatorKind::Assert { unwind, .. }
320 | TerminatorKind::Drop { unwind, .. } => {
321 if let mir::UnwindAction::Cleanup(unwind) = unwind
322 && !nop_landing_pads.contains(unwind)
323 {
324 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:324",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(324u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: {0:?}/{1:?} registering {2:?} as funclet",
bb, data, unwind) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
325 "cleanup_kinds: {:?}/{:?} registering {:?} as funclet",
326 bb, data, unwind
327 );
328 result[unwind] = CleanupKind::Funclet;
329 }
330 }
331 }
332 }
333 }
334
335 fn propagate<'tcx>(
336 result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
337 mir: &mir::Body<'tcx>,
338 ) {
339 let mut funclet_succs = IndexVec::from_elem(None, &mir.basic_blocks);
340
341 let mut set_successor = |funclet: mir::BasicBlock, succ| match funclet_succs[funclet] {
342 ref mut s @ None => {
343 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:343",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(343u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("set_successor: updating successor of {0:?} to {1:?}",
funclet, succ) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("set_successor: updating successor of {:?} to {:?}", funclet, succ);
344 *s = Some(succ);
345 }
346 Some(s) => {
347 if s != succ {
348 bug_impl(Some(mir.span),
format_args!("funclet {0:?} has 2 parents - {1:?} and {2:?}", funclet, s,
succ), Location::caller());span_bug!(
349 mir.span,
350 "funclet {:?} has 2 parents - {:?} and {:?}",
351 funclet,
352 s,
353 succ
354 );
355 }
356 }
357 };
358
359 for (bb, data) in traversal::reverse_postorder(mir) {
360 let funclet = match result[bb] {
361 CleanupKind::NotCleanup => continue,
362 CleanupKind::Funclet => bb,
363 CleanupKind::Internal { funclet } => funclet,
364 };
365
366 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:366",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(366u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: {0:?}/{1:?}/{2:?} propagating funclet {3:?}",
bb, data, result[bb], funclet) as
&dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
367 "cleanup_kinds: {:?}/{:?}/{:?} propagating funclet {:?}",
368 bb, data, result[bb], funclet
369 );
370
371 for succ in data.terminator().successors() {
372 let kind = result[succ];
373 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:373",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(373u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: propagating {0:?} to {1:?}/{2:?}",
funclet, succ, kind) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("cleanup_kinds: propagating {:?} to {:?}/{:?}", funclet, succ, kind);
374 match kind {
375 CleanupKind::NotCleanup => {
376 result[succ] = CleanupKind::Internal { funclet };
377 }
378 CleanupKind::Funclet => {
379 if funclet != succ {
380 set_successor(funclet, succ);
381 }
382 }
383 CleanupKind::Internal { funclet: succ_funclet } => {
384 if funclet != succ_funclet {
385 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:388",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(388u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("promoting {0:?} to a funclet and updating {1:?}",
succ, succ_funclet) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!(
389 "promoting {:?} to a funclet and updating {:?}",
390 succ, succ_funclet
391 );
392 result[succ] = CleanupKind::Funclet;
393 set_successor(succ_funclet, succ);
394 set_successor(funclet, succ);
395 }
396 }
397 }
398 }
399 }
400 }
401
402 let mut result = IndexVec::from_elem(CleanupKind::NotCleanup, &mir.basic_blocks);
403
404 discover_masters(&mut result, mir, &nop_landing_pads);
405 propagate(&mut result, mir);
406 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs:406",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(406u32),
::tracing_core::__macro_support::Option::Some("rustc_codegen_ssa::mir::analyze"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: result={0:?}",
result) as &dyn ::tracing::field::Value))])
});
} else { ; }
};debug!("cleanup_kinds: result={:?}", result);
407 result
408}