Some compiler provide flags (such as /Ot, /O2, and /Ox) optimize code for performance. This technique is an easy way to reduce the execution time of a UEFI driver. For the most part, the EDK II balances size and speed optimizations. The flags can be customized to specify a preference for speed or size.
Note:
When optimization is turned on, each line of source code may not map to the same line when a debugger is active. This can make it more difficult to debug.
TIP:
Be careful when turning on compiler optimizations because C source that works fine with optimizations disabled may stop working with optimizations enabled. They usually stop working because of missing volatile
declarations on variables and data structures that are shared between normal contexts and raised TPL contexts.
TIP:
Because the UEFI driver is small, it may execute faster. If there are any speed paths in a UEFI driver that cause problems if the UEFI driver executes faster, then these switches may expose those speed paths. These same speed paths also show up as faster processors are used, so it is good to find these speed paths early.