I'm a bit confused as to why you would want to. Normally you want to debug your code whilst in debug mode, so you want the least amount of optimisation possible. Only when your code works would you want to increase optimisation to increase speed.

Adding -O2 to debug build will cause all sorts of problem for debugging. Are you sure sure this is what you want?