This is the mail archive of the gcc-help@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: [BE] How to query attributes of a function being called?


Ian Lance Taylor schrieb:
Georg-Johann Lay <avr@gjlay.de> writes:

Hi, suppose this test case of C code:

typedef void (*cb_t)(void) __attribute__((callback));

void caller (cb_t cb)
{
    cb();
}

What I need in the backend is a way to query for the attributs that
are attaches to callees like 'cb'.

./config/i386/winnt.c uses TARGET_MANGLE_DECL_ASSEMBLER_NAME in order
to encode some information in the callee's name, but in my case the
call may be indirect as indicated above.

It may work to look at the MEM_EXPR of the call operand and look at DECL_ATTRIBUTES of that.

Hi, proplems arise here:


struct S
{
    void (*foo)(void);
    void (*cb)(void) __attribute__((callback));
};

void caller (struct S s, struct S *ps)
{
    s.cb();    // #1
    ps->cb();  // #2
}

Call #2 seems to work, REG_EXPR yiels a COMPONENT_REF.

But for call #1 REG_EXP is NULL_TREE in final, and so is the corresponding MEM_EXPR of the enclosing MEM.

So the middle-end nullifies all informations about the callee or never makes an effort to get it.

The middleend is an ocean of information, but hardly a drop of water reaches the desert of the backend... :-(

In some cases, call #1 gives a non-NULL_TREE REG_EXPR, but it then is a PARM_DECL and you do knot know which component is the one that is being called.

Georg-Johann


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