[gem5] Calculate number of cache flushes. Avoid function call on null controller.