Skip to content

Commit f0b0d3f

Browse files
committed
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.
1 parent fc2d621 commit f0b0d3f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/SILOptimizer/IPO/CrossModuleOptimization.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ bool CrossModuleOptimization::canSerializeFunction(
185185
if (iter != canSerializeFlags.end())
186186
return iter->second;
187187

188+
// Temporarily set the flag to false (to avoid infinite recursion) until we set
189+
// it to true at the end of this function.
190+
canSerializeFlags[function] = false;
191+
188192
if (DeclContext *funcCtxt = function->getDeclContext()) {
189193
if (!canUseFromInline(funcCtxt))
190194
return false;

0 commit comments

Comments
 (0)