CrossModuleOptimization: fix a bug in cycle-detection
The check to avoid infinite recursion in case of call graph cycles didn't work correctly.
It didn't result in crashes, because the function also has an additional max-depth check, but it could lead to exponential complexity in some cases.
Unfortunately I don't have a test case for this fix.