[ I wasn't going to answer this, because you've left out all the details that would be required for me to answer it well, but since you've asked me specifically to answer, I'll try. ]

On May 29, 2006, at 9:09 PM, sean yang wrote:
The first question is: If I want to find a BB that containing a specific function call (say 'foo'), is there an easy way in the RTX level?

Yes or no, depending on what you consider easy and how you define the problem. Anyway, if you look at the rtl:

(call_insn 8 28 9 0 (parallel [
(call (mem:SI (symbol_ref:SI ("&L_foo$stub") <function_decl 0x41687b00 foo>) [0 S4 A8])
                (const_int 32 [0x20]))
            (use (const_int 0 [0x0]))
            (clobber (reg:SI 65 lr))
        ]) 368 {*call_nonlocal_sysv} (nil)
    (nil)
    (nil))

all you have to do it wonder the insns looking for a call_insn and then check to see if the form is (mem (symbol_ref X)), and then check to see if the X mentioned is the one your interested in. The above is a nice example, because it shows that the spelling of X need not be very portable, so doing this reliably can be `hard'.

Further, the compiler can use a register and an indirect call, thus making strcmp for the function name non-trivial. If you want to wave your hands and not solve that problem, it is then easier, if not, then it can be impossible to solve. As impossible as:

main() {
        extern (*bar)():
        (*bar)();
}

is to figure out. However, it need not be that hard, could only be as hard as checking the NOTEs structure and doing a strcmp on them. That is easy to do.

Hint, if pr can show you the information you're interested in, then, trivially, the answer is yes. Just follow the rtl dumper to the info you want.

The second one is: how can i get the order of different call foo in the final assembly code.

The language gap causes this question to be hard for us to understand. If you told us what you're trying to do and why in 20 pages or more it would be easier to answer.

Can I get it by dumping some information, say the order of the instruction link list, in RTL representation?

First, you never defined what ordering you want. Do you want order as defined by the address of the instruction? Do you want source code order? Do you want order in the rtl for the function?

For rtl order, yes, just walk the rtl in order, and the first call to foo is the first, and the second call to foo is the second...

For source code order, you can approximate it by checking the debug line information associated with call in question. Just collect all that info, sort increasing by line, the first one is first, the second one is second and so on. This, as you can tell can't help with multiple calls to foo on the same line nor with compiles that lack debug information. Though, if one throws the column numbers into the debug information, then one can solve for multiple calls on one line as well. EXPR_LOCATION and EXPR_LINENO might have some of the data you're interested in.

For address ordering, well, generally that is the same as rtl order, but hot/cold partitioning can alter that. I'll not answer this, as I'm hoping you don't care about the details.

Reply via email to