1919//! `.constprop`, `.part`) remove parameters, reorder them, or replace one with a piece of it that has
2020//! no DIE of its own. The declaration's parameter list then misdescribes the code at that address.
2121//!
22+ //! Reconstruction only runs when GCC marks at least one parameter as removed
23+ //! (`DW_OP_GNU_parameter_ref`), the evidence that the signature changed. Any other concrete instance,
24+ //! such as clang's out-of-line copy of a function it also inlined, takes the declared arguments, and
25+ //! its entry locations are not trusted over the declaration: clang can describe a parameter at the
26+ //! entry PC by the register it is copied to a few instructions later.
27+ //!
2228//! This module rebuilds the signature from evidence instead of from the declaration: each parameter's
2329//! location at the function's entry PC is mapped through the architecture's DWARF register numbering
2430//! and the platform's calling convention to an argument slot. A register-sized scalar on the stack
@@ -567,7 +573,9 @@ pub(crate) fn reconstruct_concrete_parameters<R: ReaderType>(
567573 _ => ( ) ,
568574 }
569575 }
570- if parameter_count == 0 {
576+ // Without a removed parameter there is no evidence the instance's signature differs from the
577+ // declaration, so keep the declaration (see the module docs).
578+ if parameter_count == 0 || removed_count == 0 {
571579 return None ;
572580 }
573581
@@ -580,10 +588,8 @@ pub(crate) fn reconstruct_concrete_parameters<R: ReaderType>(
580588 } )
581589 . collect ( ) ;
582590 // With a removed parameter, the located slots are only a lower bound (see Placeholder).
583- if removed_count > 0 {
584- while result. len ( ) < parameter_count {
585- result. push ( ConcreteParameter :: Placeholder { size } ) ;
586- }
591+ while result. len ( ) < parameter_count {
592+ result. push ( ConcreteParameter :: Placeholder { size } ) ;
587593 }
588594 Some ( result)
589595}
0 commit comments