<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 8, 2016 at 9:55 AM, Hans Wennborg <span dir="ltr"><<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can a regular user run into this? The PR talks about the new pass<br>
manager. I haven't followed along very well, is that (partially)<br>
enabled by default these days?<br></blockquote><div><br></div><div>No; it is not on by default in production in any way at the moment (e.g. the linker would garbage collect the code when linking clang).</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
>From the PR it also sounds like the original test case still fails?<br>
<br>
Thanks,<br>
Hans<br>
<br>
On Fri, Aug 5, 2016 at 3:12 PM, Michael Zolotukhin<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:mzolotukhin@apple.com">mzolotukhin@apple.com</a>> wrote:<br>
> Hi Hans,<br>
><br>
> I think this fix is worth merging to the branch.<br>
><br>
> Thanks,<br>
> Michael<br>
><br>
>> On Aug 5, 2016, at 3:00 PM, Michael Zolotukhin <<a href="mailto:mzolotukhin@apple.com">mzolotukhin@apple.com</a>> wrote:<br>
>><br>
>> mzolotukhin committed rL277877: [LoopSimplify] Fix updating LCSSA after separating nested loops..<br>
>><br>
>> [LoopSimplify] Fix updating LCSSA after separating nested loops.<br>
>><br>
>> This fixes PR28825. The problem was that we only checked if a value from<br>
>> a created inner loop is used in the outer loop, and fixed LCSSA for<br>
>> them. But we missed to fixup LCSSA for values used in exits of the outer<br>
>> loop.<br>
>><br>
>><br>
>> Files:<br>
>>  /llvm/trunk/lib/Transforms/<wbr>Utils/LoopSimplify.cpp<br>
>>  /llvm/trunk/test/Transforms/<wbr>LoopSimplify/pr28272.ll<br>
>><br>
>> PATCH<br>
>><br>
>> Index: llvm/trunk/lib/Transforms/<wbr>Utils/LoopSimplify.cpp<br>
>> ==============================<wbr>==============================<wbr>=======<br>
>> --- llvm/trunk/lib/Transforms/<wbr>Utils/LoopSimplify.cpp  (revision 277876)<br>
>> +++ llvm/trunk/lib/Transforms/<wbr>Utils/LoopSimplify.cpp  (revision 277877)<br>
>> @@ -376,6 +376,21 @@<br>
>>         }<br>
>>       }<br>
>>     }<br>
>> +    // We also need to check exit blocks of the outer loop - it might be using<br>
>> +    // values from what now became an inner loop.<br>
>> +    SmallVector<BasicBlock*, 8> ExitBlocks;<br>
>> +    NewOuter->getExitBlocks(<wbr>ExitBlocks);<br>
>> +    for (BasicBlock *ExitBB: ExitBlocks) {<br>
>> +      for (Instruction &I : *ExitBB) {<br>
>> +        for (Value *Op : I.operands()) {<br>
>> +          Instruction *OpI = dyn_cast<Instruction>(Op);<br>
>> +          if (!OpI || !L->contains(OpI))<br>
>> +            continue;<br>
>> +          WorklistSet.insert(OpI);<br>
>> +        }<br>
>> +      }<br>
>> +    }<br>
>> +<br>
>>     SmallVector<Instruction *, 8> Worklist(WorklistSet.begin(),<br>
>>                                            WorklistSet.end());<br>
>>     formLCSSAForInstructions(<wbr>Worklist, *DT, *LI);<br>
>> Index: llvm/trunk/test/Transforms/<wbr>LoopSimplify/pr28272.ll<br>
>> ==============================<wbr>==============================<wbr>=======<br>
>> --- llvm/trunk/test/Transforms/<wbr>LoopSimplify/pr28272.ll        (revision 277876)<br>
>> +++ llvm/trunk/test/Transforms/<wbr>LoopSimplify/pr28272.ll        (revision 277877)<br>
>> @@ -1,7 +1,7 @@<br>
>> ; RUN: opt < %s -lcssa -loop-unroll -S | FileCheck %s<br>
>> target triple = "x86_64-unknown-linux-gnu"<br>
>><br>
>> -; PR28272<br>
>> +; PR28272, PR28825<br>
>> ; When LoopSimplify separates nested loops, it might break LCSSA form: values<br>
>> ; from the original loop might be used in the outer loop. This test invokes<br>
>> ; loop-unroll, which calls loop-simplify before itself. If LCSSA is broken<br>
>> @@ -74,3 +74,35 @@<br>
>> bb:<br>
>>   br label %loop2<br>
>> }<br>
>> +<br>
>> +; When LoopSimplify separates nested loops, it might break LCSSA form: values<br>
>> +; from the original loop might be used in exit blocks of the outer loop.<br>
>> +; CHECK-LABEL: @foo3<br>
>> +define void @foo3() {<br>
>> +entry:<br>
>> +  br label %bb1<br>
>> +<br>
>> +bb1:<br>
>> +  br i1 undef, label %bb2, label %bb1<br>
>> +<br>
>> +bb2:<br>
>> +  %a = phi i32 [ undef, %bb1 ], [ %a, %bb3 ], [ undef, %bb5 ]<br>
>> +  br i1 undef, label %bb3, label %bb1<br>
>> +<br>
>> +bb3:<br>
>> +  %b = load i32*, i32** undef<br>
>> +  br i1 undef, label %bb2, label %bb4<br>
>> +<br>
>> +bb4:<br>
>> +  br i1 undef, label %bb5, label %bb6<br>
>> +<br>
>> +bb5:<br>
>> +  br i1 undef, label %bb2, label %bb4<br>
>> +<br>
>> +bb6:<br>
>> +  br i1 undef, label %bb_end, label %bb1<br>
>> +<br>
>> +bb_end:<br>
>> +  %x = getelementptr i32, i32* %b<br>
>> +  br label %bb_end<br>
>> +}<br>
>><br>
>> Users:<br>
>>  mzolotukhin (Author)<br>
>><br>
>> <a href="https://reviews.llvm.org/rL277877" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>rL277877</a><br>
>><br>
>><br>
>><br>
><br>
</div></div></blockquote></div><br></div></div>