This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: REG_CALL_DECL notes


On 12/01/16 17:10, Jakub Jelinek wrote:
Hi!

What is the reason for these notes?

From https://gcc.gnu.org/ml/gcc-patches/2013-03/msg01316.html:
...
Using the reg-note we are able to easily link call_insns to their corresponding declaration, even after the calls may have been split into an insn (set register to function address) and a call_insn (call register), which can happen for f.i. sh, and mips with -mabi-calls.
...

I mean, for indirect calls usually the argument is NULL, so at least for
that case I'd say
(expr_list:REG_CALL_DECL (nil)
is just a waste of RTL memory, because nothing will really make use of it:

static tree
get_call_fndecl (rtx_insn *insn)
{
   rtx note, datum;

   note = find_reg_note (insn, REG_CALL_DECL, NULL_RTX);
   if (note == NULL_RTX)
     return NULL_TREE;

   datum = XEXP (note, 0);
   if (datum != NULL_RTX)
     return SYMBOL_REF_DECL (datum);

   return NULL_TREE;
}

will return the same thing whether ther is REG_CALL_DECL (nil) or no note at
all.

Agreed.

But even for normal calls, on most targets the decl is often embedded
already somewhere else in the call instruction:
(call_insn 6 5 7 2 (call (mem:QI (symbol_ref:DI ("exit") [flags 0x41] <function_decl 0x7fc30b495e58 __builtin_exit>) [0 __builtin_exit S1 A8])
         (const_int 0 [0])) mnau.c:1 -1
      (expr_list:REG_CALL_DECL (symbol_ref:DI ("exit") [flags 0x41] <function_decl 0x7fc30b495e58 __builtin_exit>)
So, why doesn't say get_call_fndecl use REG_CALL_DECL if present, otherwise
if flag_ipa_ra look up the CALL rtx in the instruction and look up the symbol_ref in its
MEM?

AFAIU, the targets for which this regnote matters are sh, and mips with -mabi-calls. So we could drop the regnote for all other targets.

If we want to reduce the amount of regnotes also for those two targets, we can initially do without, but then once we split the call insn, we'll have to add the reg-note.

Thanks,
- Tom

Then, what call.c could do is instead of:
           last = last_call_insn ();
           add_reg_note (last, REG_CALL_DECL, datum);
first call get_call_fndecl (last) and if that returns datum, don't add any
note.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]