Modify code during a pass

29 views
Skip to first unread message

Floris van Nee

unread,
Jan 30, 2015, 10:42:44 AM1/30/15
to gcc-...@googlegroups.com
While looking at some of the examples and documentation on the website, I noticed that most of them are aimed at recognizing certain patterns. However, I was wondering if it is also possible to modify code during a pass. For example: can I make all functions which match a certain name empty?

For example, transform:
void f() { printf("hi"); int x = 2 + 3; } 
Into:
void f() { }

-Floris

Basile Starynkevitch

unread,
Feb 1, 2015, 3:56:28 AM2/1/15
to gcc-...@googlegroups.com
This is certainly possible: MELT gives you a lot of Gimple and Basic Block building routines.

And most GCC optimization passes are of course modifying the GIMPLE.

I guess that you have to replace the ENTER and EXIT block of your f with a single empty basic block.

Regards.

--
Basile Starynkevitch
Reply all
Reply to author
Forward
0 new messages