]> git.lizzy.rs Git - rust.git/commitdiff
Don't always run `add_call_guards` pass
authorJonas Schievink <jonasschievink@gmail.com>
Mon, 13 Apr 2020 18:22:45 +0000 (20:22 +0200)
committerJonas Schievink <jonasschievink@gmail.com>
Mon, 13 Apr 2020 18:22:45 +0000 (20:22 +0200)
src/librustc_mir/transform/add_retag.rs
src/librustc_mir/transform/mod.rs

index 5c016b0c515af751468c01cf22b386b38b11360c..d0de0a09873b220c672ebdd2e1a1131c1d88b79a 100644 (file)
@@ -58,10 +58,14 @@ fn may_be_reference(ty: Ty<'tcx>) -> bool {
 }
 
 impl<'tcx> MirPass<'tcx> for AddRetag {
-    fn run_pass(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
+    fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
         if !tcx.sess.opts.debugging_opts.mir_emit_retag {
             return;
         }
+
+        // We need an `AllCallEdges` pass before we can do any work.
+        super::add_call_guards::AllCallEdges.run_pass(tcx, src, body);
+
         let (span, arg_count) = (body.span, body.arg_count);
         let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
         let needs_retag = |place: &Place<'tcx>| {
index 81ea57e4c004c28d0671ae9e8277c4f9f0fa6f95..8db0b39a497a9918144af42fa39e86e4373afe08 100644 (file)
@@ -287,10 +287,8 @@ fn run_optimization_passes<'tcx>(
             // AddMovesForPackedDrops needs to run after drop
             // elaboration.
             &add_moves_for_packed_drops::AddMovesForPackedDrops,
-            // AddRetag needs to run after ElaborateDrops, and it needs
-            // an AllCallEdges pass right before it.  Otherwise it should
-            // run fairly late, but before optimizations begin.
-            &add_call_guards::AllCallEdges,
+            // `AddRetag` needs to run after `ElaborateDrops`. Otherwise it should run fairly late,
+            // but before optimizations begin.
             &add_retag::AddRetag,
             &simplify::SimplifyCfg::new("elaborate-drops"),
             // No lifetime analysis based on borrowing can be done from here on out.