Skip to content

Commit 351eefe

Browse files
committed
Auto merge of #71106 - jonas-schievink:remove-call-guard-pass, r=ecstatic-morse,RalfJung
Don't always run `add_call_guards` pass It is only needed when `add_retag` runs. (the pass is run again to split critical edges before codegen, that one is required)
2 parents 76cbf00 + 8c50006 commit 351eefe

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/librustc_mir/transform/add_retag.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ fn may_be_reference(ty: Ty<'tcx>) -> bool {
5858
}
5959

6060
impl<'tcx> MirPass<'tcx> for AddRetag {
61-
fn run_pass(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
61+
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
6262
if !tcx.sess.opts.debugging_opts.mir_emit_retag {
6363
return;
6464
}
65+
66+
// We need an `AllCallEdges` pass before we can do any work.
67+
super::add_call_guards::AllCallEdges.run_pass(tcx, src, body);
68+
6569
let (span, arg_count) = (body.span, body.arg_count);
6670
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
6771
let needs_retag = |place: &Place<'tcx>| {

src/librustc_mir/transform/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,8 @@ fn run_optimization_passes<'tcx>(
287287
// AddMovesForPackedDrops needs to run after drop
288288
// elaboration.
289289
&add_moves_for_packed_drops::AddMovesForPackedDrops,
290-
// AddRetag needs to run after ElaborateDrops, and it needs
291-
// an AllCallEdges pass right before it. Otherwise it should
292-
// run fairly late, but before optimizations begin.
293-
&add_call_guards::AllCallEdges,
290+
// `AddRetag` needs to run after `ElaborateDrops`. Otherwise it should run fairly late,
291+
// but before optimizations begin.
294292
&add_retag::AddRetag,
295293
&simplify::SimplifyCfg::new("elaborate-drops"),
296294
// No lifetime analysis based on borrowing can be done from here on out.

0 commit comments

Comments
 (0)