staticafi/llvm2c

stack overflow in createConstantsForOperands

mchalupa opened this issue · 0 comments

createConstantsForOperands can get stuck in a cycle and eventually cause stack overflow if the operands are used in a cycle, e.g. for these instructions:

%.01012 = phi i8 [ %11, %.lr.ph ], [ %.11, %.lr.ph.preheader ]
%11 = trunc i32 %10 to i8, !dbg !31
%10 = srem i32 %9, %8, !dbg !33
%9 = sext i8 %.113 to i32, !dbg !31
%.113 = phi i8 [ %.01012, %.lr.ph ], [ %., %.lr.ph.preheader ]

The %.01012 uses %11, which uses...., which uses %.113that uses%.01012`. We must detect such a cycle and bail out once we processed all that we need.