[Dwarf-Discuss] compilers generating ABI non-compliant function calls?

Jakub Jelinek jakub@redhat.com
Tue Mar 9 19:52:23 GMT 2021


On Tue, Mar 09, 2021 at 11:43:54AM -0800, David Blaikie wrote:
> Thanks for the details! So in this case GCC changes the ABI of foo(int x,
> int y) to be equivalent to foo(int y) and the parameter description of 'y'

No, it is actually equivalent to foo(void) but DW_TAG_call_site_parameter
in those cases holds the value the optimized away parameter would have if it
would be passed.
So, when the consumer evaluates DW_OP_GNU_parameter_ref, it handles it
similarly to DW_OP_entry_value, unwinds to caller if it can identify it,
and just looks up if some value is specified for it in that particular
caller.

> Does GCC do anything like the LLVM optimization when the function is
> externally visible, but some callers are visible to the optimizer - and the
> compiler concludes that since the parameter is unused inside the function
> implementation those callers can be modified to pass effectively garbage in
> that parameter? And what sort of DWARF does GCC use to describe that?

I think GCC doesn't do that, instead it would if considered beneficial
copy the function to a non-exported one and optimize away the parameters in
there (etc.).  Also note that the callee is exported, there is the question
if it can be semantically interposed (for GCC yes by default with
-fpic/-fPIC unless playing e.g. with visibility attributes) and in that case
you don't know if the parameter will be unused there.

	Jakub




More information about the Dwarf-discuss mailing list