diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-11-17 17:26:11 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-11-17 17:31:09 -0500 |
commit | 5d67d81f484f935b709918ad99462e32efa3b17a (patch) | |
tree | ebe6a08ef339b88acb5748fdc7303ccff668e7e5 /llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | |
parent | 1b0efe2b1778e821aade88667b1cb82d1c93f7e9 (diff) | |
download | bcm5719-llvm-5d67d81f484f935b709918ad99462e32efa3b17a.tar.gz bcm5719-llvm-5d67d81f484f935b709918ad99462e32efa3b17a.zip |
[InstCombine] prevent crashing/assert on shift constant expression (PR44028)
The binary operator cast implies an instruction, but the matcher for shift does not:
https://bugs.llvm.org/show_bug.cgi?id=44028
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index f35a6ce2d93..fbff5dd4a8c 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -319,7 +319,8 @@ static Instruction *foldShiftOfShiftedLogic(BinaryOperator &I, // TODO: Remove the one-use check if the other logic operand (Y) is constant. Value *X, *Y; auto matchFirstShift = [&](Value *V) { - return match(V, m_OneUse(m_Shift(m_Value(X), m_APInt(C0)))) && + return !isa<ConstantExpr>(V) && + match(V, m_OneUse(m_Shift(m_Value(X), m_APInt(C0)))) && cast<BinaryOperator>(V)->getOpcode() == ShiftOpcode && (*C0 + *C1).ult(Ty->getScalarSizeInBits()); }; |