IR: cleanup Module::dropReferences

This replaces some old-style loops with range-based for.