going from a SYMBOL_REF to a decl node

Zack Weinberg zack@wolery.cumb.org
Mon Apr 3 19:32:00 GMT 2000


On Mon, Apr 03, 2000 at 07:14:34PM -0700, Mike Stump wrote:
> > From: Zack Weinberg <zack@wolery.cumb.org>
> > Date: Mon, 3 Apr 2000 19:04:24 -0700
> > To: gcc@gcc.gnu.org
> 
> > Is there any way to go from a SYMBOL_REF rtx to the declaration it
> > refers to?  For example, given this insn:
> 
> > (call_insn/j 10 18 11 (call (mem:QI (symbol_ref:SI ("abort")) 0)
> >         (const_int 0 [0x0])) -1 (nil)
> 
> > I want to be able to dig up the tree for <abort>.
> 
> Sure, just check out the symbol table?  :-) You didn't expect a harder
> answer did you?  No, I don't think there is an easier answer, either.

I tried that... it turns out you can't do it in the back end.  You can
get as far as the IDENTIFIER_NODE, but to get from the IDENTIFIER_NODE
to the FUNCTION_DECL requires that you know things only the front end
knows.  Like how to call lookup_name.

Maybe I should describe the real problem.  I was trying to fix a
bug provoked by the sibcall optimizer:

void x(void) { abort(); }
void y(void) { something(); }

gcc thinks neither x nor y can return.  This is because the RTL for
both functions looks like

(note 2 0 3 "" NOTE_INSN_DELETED)
(note 3 2 18 "" NOTE_INSN_FUNCTION_BEG)
(note 18 3 10 [bb 0] NOTE_INSN_BASIC_BLOCK)

(call_insn/j 10 18 11 (call (mem:QI (symbol_ref:SI ("...")) 0)
        (const_int 0 [0x0])) -1 (nil)
    (nil)
    (nil))

(barrier 11 10 14)
(note 14 11 0 "" NOTE_INSN_DELETED)

calculate_can_reach_end needs to know, given only that CALL_INSN,
whether or not it's calling a noreturn function.   The barrier doesn't
help; it's always there.

I'm going to try setting ->volatil on the CALL_INSN in expand_call, but
that may break something else...

zw


More information about the Gcc mailing list