]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #88629 - wesleywiser:fix_debuginfo_for_scalarpair_params, r=oli-obk
authorbors <bors@rust-lang.org>
Wed, 22 Sep 2021 01:13:49 +0000 (01:13 +0000)
committerbors <bors@rust-lang.org>
Wed, 22 Sep 2021 01:13:49 +0000 (01:13 +0000)
Fix debuginfo for parameters passed via the ScalarPair abi on Windows

Mark all of these as locals so the debugger does not try to interpret
them as being a pointer to the value. This extends the approach used
in #81898.

Fixes #88625

1  2 
compiler/rustc_codegen_ssa/src/mir/mod.rs

index 8e3982c72d7742408951922d31ad4da40b64755c,0877345938a92d5fc36b3530a6f4dbbc6518aed4..37f5de309baffe7bff940fc45faaf93bb6adf534
@@@ -2,7 -2,7 +2,7 @@@ use crate::traits::*
  use rustc_errors::ErrorReported;
  use rustc_middle::mir;
  use rustc_middle::mir::interpret::ErrorHandled;
 -use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt, TyAndLayout};
 +use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout};
  use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
  use rustc_target::abi::call::{FnAbi, PassMode};
  
@@@ -29,7 -29,7 +29,7 @@@ pub struct FunctionCx<'a, 'tcx, Bx: Bui
  
      cx: &'a Bx::CodegenCx,
  
 -    fn_abi: FnAbi<'tcx, Ty<'tcx>>,
 +    fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
  
      /// When unwinding is initiated, we have to store this personality
      /// value somewhere so that we can load it and re-use it in the
@@@ -129,6 -129,7 +129,7 @@@ impl<'a, 'tcx, V: CodegenObject> LocalR
  
  ///////////////////////////////////////////////////////////////////////////
  
+ #[instrument(level = "debug", skip(cx))]
  pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
      cx: &'a Bx::CodegenCx,
      instance: Instance<'tcx>,
  
      let mir = cx.tcx().instance_mir(instance.def);
  
 -    let fn_abi = FnAbi::of_instance(cx, instance, &[]);
 +    let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
      debug!("fn_abi: {:?}", fn_abi);
  
      let debug_context = cx.create_function_debug_context(instance, &fn_abi, llfn, &mir);
      }
  
      let cleanup_kinds = analyze::cleanup_kinds(&mir);
 -    // Allocate a `Block` for every basic block, except
 -    // the start block, if nothing loops back to it.
 -    let reentrant_start_block = !mir.predecessors()[mir::START_BLOCK].is_empty();
 -    let cached_llbbs: IndexVec<mir::BasicBlock, Option<Bx::BasicBlock>> =
 -        mir.basic_blocks()
 -            .indices()
 -            .map(|bb| {
 -                if bb == mir::START_BLOCK && !reentrant_start_block {
 -                    Some(start_llbb)
 -                } else {
 -                    None
 -                }
 -            })
 -            .collect();
 +    let cached_llbbs: IndexVec<mir::BasicBlock, Option<Bx::BasicBlock>> = mir
 +        .basic_blocks()
 +        .indices()
 +        .map(|bb| if bb == mir::START_BLOCK { Some(start_llbb) } else { None })
 +        .collect();
  
      let mut fx = FunctionCx {
          instance,
      // Apply debuginfo to the newly allocated locals.
      fx.debug_introduce_locals(&mut bx);
  
 -    // Branch to the START block, if it's not the entry block.
 -    if reentrant_start_block {
 -        bx.br(fx.llbb(mir::START_BLOCK));
 -    }
 -
      // Codegen the body of each block using reverse postorder
      // FIXME(eddyb) reuse RPO iterator between `analysis` and this.
      for (bb, _) in traversal::reverse_postorder(&mir) {