GPIO using StellarisWare with LM4F120H5QR LaunchPad. SW2 not working as expected
On most of the GPIO pins, there are more than one functions associated. On the pin having SW2, there is also an NMI (non-maskable interrupt) attached. This renders the pin to be unlocked first and then it can be used as a GPIO input. 

As the comment suggests at line 6, you're basically unlocking SW2 pin to be used as a GPIO. All the pins having an alternate function of NMI are required to be unlocked first in order to be used.

For further details on NMI, you can refer to 
https://en.wikipedia.org/wiki/Non-maskable_interrupt