Split the checking of StableModules in upsweep_mod
This is the first step in the implementation plan described here #14095
This is similar in spirit to the changes done in !5555 (closed). But I have intentionally kept this in a separate MR since this one is completely independent.
And I have tried to not change the code too much, to keep this a simple refactor.
The reason I want to get this merged before the actual fine-grained driver implementation is because this in itself improves the readability of the code.