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::layout::{HasTyCtxt, LayoutOf};
11use rustc_middle::{bug, span_bug, ty};
12use tracing::debug;
13
14use super::FunctionCx;
15use crate::traits::*;
16
17pub(crate) fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
18 fx: &FunctionCx<'a, 'tcx, Bx>,
19 traversal_order: &[mir::BasicBlock],
20) -> DenseBitSet<mir::Local> {
21 let mir = fx.mir;
22 let dominators = mir.basic_blocks.dominators();
23 let locals = mir
24 .local_decls
25 .iter()
26 .map(|decl| {
27 let ty = fx.monomorphize(decl.ty);
28 let layout = fx.cx.spanned_layout_of(ty, decl.source_info.span);
29 if layout.is_zst() { LocalKind::ZST } else { LocalKind::Unused }
30 })
31 .collect();
32
33 let mut analyzer = LocalAnalyzer { fx, dominators, locals };
34
35 for arg in mir.args_iter() {
37 analyzer.define(arg, DefLocation::Argument);
38 }
39
40 for bb in traversal_order.iter().copied() {
44 let data = &mir.basic_blocks[bb];
45 analyzer.visit_basic_block_data(bb, data);
46 }
47
48 let mut non_ssa_locals = DenseBitSet::new_empty(analyzer.locals.len());
49 for (local, kind) in analyzer.locals.iter_enumerated() {
50 if #[allow(non_exhaustive_omitted_patterns)] match kind {
LocalKind::Memory => true,
_ => false,
}matches!(kind, LocalKind::Memory) {
51 non_ssa_locals.insert(local);
52 }
53 }
54
55 non_ssa_locals
56}
57
58#[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]
impl ::core::clone::Clone for LocalKind {
#[inline]
fn clone(&self) -> LocalKind {
let _: ::core::clone::AssertParamIsClone<DefLocation>;
*self
}
}Clone, #[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)]
59enum LocalKind {
60 ZST,
61 Memory,
63 Unused,
65 SSA(DefLocation),
67}
68
69struct LocalAnalyzer<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> {
70 fx: &'a FunctionCx<'b, 'tcx, Bx>,
71 dominators: &'a Dominators<mir::BasicBlock>,
72 locals: IndexVec<mir::Local, LocalKind>,
73}
74
75impl<'a, 'b, 'tcx, Bx: BuilderMethods<'b, 'tcx>> LocalAnalyzer<'a, 'b, 'tcx, Bx> {
76 fn define(&mut self, local: mir::Local, location: DefLocation) {
77 let fx = self.fx;
78 let kind = &mut self.locals[local];
79 let decl = &fx.mir.local_decls[local];
80 match *kind {
81 LocalKind::ZST => {}
82 LocalKind::Memory => {}
83 LocalKind::Unused => {
84 let ty = fx.monomorphize(decl.ty);
85 let layout = fx.cx.spanned_layout_of(ty, decl.source_info.span);
86 *kind =
87 if fx.cx.is_backend_immediate(layout) || fx.cx.is_backend_scalar_pair(layout) {
88 LocalKind::SSA(location)
89 } else {
90 LocalKind::Memory
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 !!self.fx.cx.is_backend_ref(layout) {
{
::core::panicking::panic_fmt(format_args!("Post-projection {0:?} layout should be non-Ref, but it\'s {1:?}",
place_ref, layout));
}
};
};debug_assert!(
160 !self.fx.cx.is_backend_ref(layout),
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 compiler/rustc_codegen_ssa/src/mir/analyze.rs:178",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("visit_assign(place={0:?}, rvalue={1:?})",
place, rvalue) as &dyn 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 compiler/rustc_codegen_ssa/src/mir/analyze.rs:190",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("visit_place(place={0:?}, context={1:?})",
place, context) as &dyn 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 ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))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 | PlaceContext::MutatingUse(MutatingUseContext::Retag) => {}
217
218 PlaceContext::NonMutatingUse(
219 NonMutatingUseContext::Copy
220 | NonMutatingUseContext::Move
221 | NonMutatingUseContext::Inspect,
225 ) => match &mut self.locals[local] {
226 LocalKind::ZST => {}
227 LocalKind::Memory => {}
228 LocalKind::SSA(def) if def.dominates(location, self.dominators) => {}
229 kind @ (LocalKind::Unused | LocalKind::SSA(_)) => {
234 *kind = LocalKind::Memory;
235 }
236 },
237
238 PlaceContext::MutatingUse(
239 MutatingUseContext::Store
240 | MutatingUseContext::SetDiscriminant
241 | MutatingUseContext::AsmOutput
242 | MutatingUseContext::Borrow
243 | MutatingUseContext::RawBorrow
244 | MutatingUseContext::Projection,
245 )
246 | PlaceContext::NonMutatingUse(
247 NonMutatingUseContext::SharedBorrow
248 | NonMutatingUseContext::FakeBorrow
249 | NonMutatingUseContext::RawBorrow
250 | NonMutatingUseContext::Projection,
251 ) => {
252 self.locals[local] = LocalKind::Memory;
253 }
254
255 PlaceContext::MutatingUse(MutatingUseContext::Drop) => {
256 let kind = &mut self.locals[local];
257 if *kind != LocalKind::Memory {
258 let ty = self.fx.mir.local_decls[local].ty;
259 let ty = self.fx.monomorphize(ty);
260 if self.fx.cx.type_needs_drop(ty) {
261 *kind = LocalKind::Memory;
263 }
264 }
265 }
266
267 PlaceContext::MutatingUse(MutatingUseContext::Yield) => ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))bug!(),
268 }
269 }
270
271 fn visit_statement_debuginfo(&mut self, _: &mir::StmtDebugInfo<'tcx>, _: Location) {
272 }
274}
275
276#[derive(#[automatically_derived]
impl ::core::marker::Copy for CleanupKind { }Copy, #[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::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)]
277pub(crate) enum CleanupKind {
278 NotCleanup,
279 Funclet,
280 Internal { funclet: mir::BasicBlock },
281}
282
283impl CleanupKind {
284 pub(crate) fn funclet_bb(self, for_bb: mir::BasicBlock) -> Option<mir::BasicBlock> {
285 match self {
286 CleanupKind::NotCleanup => None,
287 CleanupKind::Funclet => Some(for_bb),
288 CleanupKind::Internal { funclet } => Some(funclet),
289 }
290 }
291}
292
293pub(crate) fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
297 fn discover_masters<'tcx>(
298 result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
299 mir: &mir::Body<'tcx>,
300 ) {
301 for (bb, data) in mir.basic_blocks.iter_enumerated() {
302 match data.terminator().kind {
303 TerminatorKind::Goto { .. }
304 | TerminatorKind::UnwindResume
305 | TerminatorKind::UnwindTerminate(_)
306 | TerminatorKind::Return
307 | TerminatorKind::TailCall { .. }
308 | TerminatorKind::CoroutineDrop
309 | TerminatorKind::Unreachable
310 | TerminatorKind::SwitchInt { .. }
311 | TerminatorKind::Yield { .. }
312 | TerminatorKind::FalseEdge { .. }
313 | TerminatorKind::FalseUnwind { .. } => { }
314 TerminatorKind::Call { unwind, .. }
315 | TerminatorKind::InlineAsm { unwind, .. }
316 | TerminatorKind::Assert { unwind, .. }
317 | TerminatorKind::Drop { unwind, .. } => {
318 if let mir::UnwindAction::Cleanup(unwind) = unwind {
319 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_codegen_ssa/src/mir/analyze.rs:319",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(319u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: {0:?}/{1:?} registering {2:?} as funclet",
bb, data, unwind) as &dyn Value))])
});
} else { ; }
};debug!(
320 "cleanup_kinds: {:?}/{:?} registering {:?} as funclet",
321 bb, data, unwind
322 );
323 result[unwind] = CleanupKind::Funclet;
324 }
325 }
326 }
327 }
328 }
329
330 fn propagate<'tcx>(
331 result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
332 mir: &mir::Body<'tcx>,
333 ) {
334 let mut funclet_succs = IndexVec::from_elem(None, &mir.basic_blocks);
335
336 let mut set_successor = |funclet: mir::BasicBlock, succ| match funclet_succs[funclet] {
337 ref mut s @ None => {
338 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_codegen_ssa/src/mir/analyze.rs:338",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(338u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("set_successor: updating successor of {0:?} to {1:?}",
funclet, succ) as &dyn Value))])
});
} else { ; }
};debug!("set_successor: updating successor of {:?} to {:?}", funclet, succ);
339 *s = Some(succ);
340 }
341 Some(s) => {
342 if s != succ {
343 ::rustc_middle::util::bug::span_bug_fmt(mir.span,
format_args!("funclet {0:?} has 2 parents - {1:?} and {2:?}", funclet, s,
succ));span_bug!(
344 mir.span,
345 "funclet {:?} has 2 parents - {:?} and {:?}",
346 funclet,
347 s,
348 succ
349 );
350 }
351 }
352 };
353
354 for (bb, data) in traversal::reverse_postorder(mir) {
355 let funclet = match result[bb] {
356 CleanupKind::NotCleanup => continue,
357 CleanupKind::Funclet => bb,
358 CleanupKind::Internal { funclet } => funclet,
359 };
360
361 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_codegen_ssa/src/mir/analyze.rs:361",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(361u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: {0:?}/{1:?}/{2:?} propagating funclet {3:?}",
bb, data, result[bb], funclet) as &dyn Value))])
});
} else { ; }
};debug!(
362 "cleanup_kinds: {:?}/{:?}/{:?} propagating funclet {:?}",
363 bb, data, result[bb], funclet
364 );
365
366 for succ in data.terminator().successors() {
367 let kind = result[succ];
368 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_codegen_ssa/src/mir/analyze.rs:368",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(368u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: propagating {0:?} to {1:?}/{2:?}",
funclet, succ, kind) as &dyn Value))])
});
} else { ; }
};debug!("cleanup_kinds: propagating {:?} to {:?}/{:?}", funclet, succ, kind);
369 match kind {
370 CleanupKind::NotCleanup => {
371 result[succ] = CleanupKind::Internal { funclet };
372 }
373 CleanupKind::Funclet => {
374 if funclet != succ {
375 set_successor(funclet, succ);
376 }
377 }
378 CleanupKind::Internal { funclet: succ_funclet } => {
379 if funclet != succ_funclet {
380 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_codegen_ssa/src/mir/analyze.rs:383",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(383u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("promoting {0:?} to a funclet and updating {1:?}",
succ, succ_funclet) as &dyn Value))])
});
} else { ; }
};debug!(
384 "promoting {:?} to a funclet and updating {:?}",
385 succ, succ_funclet
386 );
387 result[succ] = CleanupKind::Funclet;
388 set_successor(succ_funclet, succ);
389 set_successor(funclet, succ);
390 }
391 }
392 }
393 }
394 }
395 }
396
397 let mut result = IndexVec::from_elem(CleanupKind::NotCleanup, &mir.basic_blocks);
398
399 discover_masters(&mut result, mir);
400 propagate(&mut result, mir);
401 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_codegen_ssa/src/mir/analyze.rs:401",
"rustc_codegen_ssa::mir::analyze", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_codegen_ssa/src/mir/analyze.rs"),
::tracing_core::__macro_support::Option::Some(401u32),
::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};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("cleanup_kinds: result={0:?}",
result) as &dyn Value))])
});
} else { ; }
};debug!("cleanup_kinds: result={:?}", result);
402 result
403}