This is the mail archive of the
mailing list for the GCC project.
Re: Inefficient code generation with -fPIC.
>If a function specifies throw() and calls other functions, it has to
>add a handler to catch throws from these other functions, so perhaps
>this is the source of the extra code. But in this case f() does not
>call any other functions, so I don't understand why it has an effect here.
The code that adds the handler is at the end of store_parm_decls, and in
finish_function, both in cp/decl.c. [Always adding it at this stage seems
reasonable - definitive information as to whether or not it is needed
presumably won't be available at this stage.]
Putting some printfs in the appropriate places, I see
current_function_uses_pic_offset_table being set to 1 in three places:
1. i386.c, ligitimize_pic_address(), line 2676, the symbol name starts .LRTH.
2. insn_emit.c, gen_call().
3. insn_emit.c, gen_call_value().
From what I understand of gcc's guts (which isn't that much), this is
during the conversion of the tree representation to RTL, before much
optimisation is done. The code that eventually decides to remove the
redundant handler seems be flow.c, flow_delete_block().