[llvm-commits] [LLVM, loop-unswitch] Potential bug in RewriteLoopBodyWithConditionConstant

Stepan Dyatkovskiy stpworld at narod.ru
Tue Nov 22 03:01:16 PST 2011

Hi all.

It seems that the code inside the 
LoopUnswitch::RewriteLoopBodyWithConditionConstant contains potential bugs.
UseList is changed inside the loops that are goes through its items:

LoopUnswitch.cpp, string #905: for (Value::use_iterator UI = 
LIC->use_begin(), E = LIC->use_end(); UI != E; ++UI) {

...and then inside the loop body UseList is changed implicitly (
LoopUnswitch.cpp, string #910):
U->replaceUsesOfWith(LIC, Replacement);

It seems that after editing UseList loop may produce unpreditable 
results. But we are lucky by now though :-)

I propose to collect all to be changed and then do some changes?
If so, please find the patch attached for review.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-unswitch-uselist.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111122/fc49ed4e/attachment.bin>

More information about the llvm-commits mailing list