On Thu, Dec 08, 2022 at 02:02:36PM +0100, Jose E. Marchesi wrote: > So, I guess the right fix would be to call assemble_external_libcall > during final? The `.global FOO' directive would be generated > immediately before the call sequence, but I guess that would be ok.
During final only if all the targets can deal with the effects of assemble_external_libcall being done in the middle of emitting assembly for the function. Otherwise, it could be e.g. done in the first loop of shorten_branches. Note, in calls.cc it is done only for emit_library_call_value_1 and not for emit_call_1, so if we do it late, we need to be able to find out what call is to a libcall and what is to a normal call. If there is no way to differentiate it right now, perhaps we need some flag somewhere, say on a SYMBOL_REF. And then assemble_external_libcall either only if such a SYMBOL_REF appears in CALL_INSN or sibcall JUMP_INSN, or perhaps anywhere in the function and its constant pool. Jakub