[llvm] r259702 - [LoopStrengthReduce] Don't rewrite PHIs with incoming values from CatchSwitches

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 09:57:11 PST 2016


Yes, go ahead and merge with the script in utils/release/merge.sh.

Thanks,
Hans

On Wed, Feb 17, 2016 at 9:35 AM, David Majnemer
<david.majnemer at gmail.com> wrote:
> Could we get this merged into 3.8?
>
> On Wed, Feb 3, 2016 at 1:30 PM, David Majnemer via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: majnemer
>> Date: Wed Feb  3 15:30:34 2016
>> New Revision: 259702
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=259702&view=rev
>> Log:
>> [LoopStrengthReduce] Don't rewrite PHIs with incoming values from
>> CatchSwitches
>>
>> Bail out if we have a PHI on an EHPad that gets a value from a
>> CatchSwitchInst.  Because the CatchSwitchInst cannot be split, there is
>> no good place to stick any instructions.
>>
>> This fixes PR26373.
>>
>> Modified:
>>     llvm/trunk/include/llvm/IR/Instructions.h
>>     llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
>>     llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll
>>
>> Modified: llvm/trunk/include/llvm/IR/Instructions.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=259702&r1=259701&r2=259702&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/IR/Instructions.h (original)
>> +++ llvm/trunk/include/llvm/IR/Instructions.h Wed Feb  3 15:30:34 2016
>> @@ -2512,6 +2512,14 @@ public:
>>      return block_begin() + getNumOperands();
>>    }
>>
>> +  iterator_range<block_iterator> blocks() {
>> +    return make_range(block_begin(), block_end());
>> +  }
>> +
>> +  iterator_range<const_block_iterator> blocks() const {
>> +    return make_range(block_begin(), block_end());
>> +  }
>> +
>>    op_range incoming_values() { return operands(); }
>>
>>    const_op_range incoming_values() const { return operands(); }
>>
>> Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=259702&r1=259701&r2=259702&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Wed Feb  3
>> 15:30:34 2016
>> @@ -4799,6 +4799,17 @@ LSRInstance::LSRInstance(Loop *L, IVUser
>>        DEBUG(dbgs() << "LSR skipping loop, too many IV Users in " << U <<
>> "\n");
>>        return;
>>      }
>> +    // Bail out if we have a PHI on an EHPad that gets a value from a
>> +    // CatchSwitchInst.  Because the CatchSwitchInst cannot be split,
>> there is
>> +    // no good place to stick any instructions.
>> +    if (auto *PN = dyn_cast<PHINode>(U.getUser())) {
>> +       auto *FirstNonPHI = PN->getParent()->getFirstNonPHI();
>> +       if (isa<FuncletPadInst>(FirstNonPHI) ||
>> +           isa<CatchSwitchInst>(FirstNonPHI))
>> +         for (BasicBlock *PredBB : PN->blocks())
>> +           if (isa<CatchSwitchInst>(PredBB->getFirstNonPHI()))
>> +             return;
>> +    }
>>    }
>>
>>  #ifndef NDEBUG
>>
>> Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll?rev=259702&r1=259701&r2=259702&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll (original)
>> +++ llvm/trunk/test/Transforms/LoopStrengthReduce/funclet.ll Wed Feb  3
>> 15:30:34 2016
>> @@ -214,3 +214,32 @@ try.cont.7:
>>
>>  ; CHECK: catch.dispatch.2:
>>  ; CHECK: %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catch.dispatch ]
>> +
>> +define i32 @test2() personality i32 (...)* @_except_handler3 {
>> +entry:
>> +  br label %for.body
>> +
>> +for.body:                                         ; preds = %for.inc,
>> %entry
>> +  %phi = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
>> +  invoke void @reserve()
>> +          to label %for.inc unwind label %catch.dispatch
>> +
>> +catch.dispatch:                                   ; preds = %for.body
>> +  %tmp18 = catchswitch within none [label %catch.handler] unwind to
>> caller
>> +
>> +catch.handler:                                    ; preds =
>> %catch.dispatch
>> +  %phi.lcssa = phi i32 [ %phi, %catch.dispatch ]
>> +  %tmp19 = catchpad within %tmp18 [i8* null]
>> +  catchret from %tmp19 to label %done
>> +
>> +done:
>> +  ret i32 %phi.lcssa
>> +
>> +for.inc:                                          ; preds = %for.body
>> +  %inc = add i32 %phi, 1
>> +  br label %for.body
>> +}
>> +
>> +; CHECK-LABEL: define i32 @test2(
>> +; CHECK:      %phi.lcssa = phi i32 [ %phi, %catch.dispatch ]
>> +; CHECK-NEXT: catchpad within
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


More information about the llvm-commits mailing list