Do not fail in case we do not have valid dependences

In case we do not have valid dependences, we do not run dead code elimination or
the schedule optimizer. This fixes an infinite loop in the dead code
elimination (PR12110).
Use static instead of an anonymous namespace.