I would start by removing the pinMode and digitalWrite lines. Those are setting up pin 13, however, the tft.begin() is coming along a few microseconds later and switching pin 13 to be the SPI clock signal. Perhaps at certain optimization levels the compiler is getting confused about what to do with the SPI clock line and the tft startup code is getting stuck in the startup routines because SPI transactions never finish.