0

I'm modifying GCC frontend now.
And I want to check GIMPLE file with FOR_EACH_BB_FN and to detect 'free' operation, which is used to release memory allocation in C.
Here is my code:

basic_block bb;
gimple_stmt_iterator gsi;
FOR_EACH_BB_FN(bb,cfun)
{
    for (gsi = gsi_start_bb(bb); ! gsi_end_p(gsi); gsi_next(&gsi))
    {
    gimple *stmt = gsi_stmt (gsi);
    stmt = gsi_stmt (gsi);
    ...

And then how can I check stmt is 'free' operation or not?

李宗霖
  • 11
  • 1
  • Welcome to Stack Overflow. Please review the [About] and [Ask] pages soon. It isn't clear to me what you're asking. The leading `>` aren't a remnant of a 'quote', so are they part of the source code or not? If so, what language? If not, why are they present? Are you looking for the free operation that corresponds to each `gsi_stmt()` call? If the first call allocates memory, the second surely leaks it, so you need to do something to release the data identified by `stmt`. If the `gsi_stmt()` call merely extracts a pointer to data in the `gsi` structure, the consecutive calls may be harmless. – Jonathan Leffler Oct 30 '18 at 02:38
  • @JonathanLeffler Thanks for your advice. I do look for the free operation that corresponds to each gsi_stmt() call, but I just don't know how should I write in the statement to determine it. – 李宗霖 Oct 30 '18 at 03:08
  • I don't know enough about Gimple to be able to help more than I have already. – Jonathan Leffler Oct 30 '18 at 03:14
  • Thank you for your advice. This is my first time to ask a question, and I apparently not know how to ask properly. Thank you for replying me so soon. – 李宗霖 Oct 30 '18 at 03:24

0 Answers0