Update prebuilt Clang to match Android kernel.
Bug: 132428451
Change-Id: I8f6e2cb23f381fc0c02ddea99b867e58e925e5be
diff --git a/linux-x64/clang/include/llvm/IR/PatternMatch.h b/linux-x64/clang/include/llvm/IR/PatternMatch.h
index 7c05834..6c51d48 100644
--- a/linux-x64/clang/include/llvm/IR/PatternMatch.h
+++ b/linux-x64/clang/include/llvm/IR/PatternMatch.h
@@ -1,9 +1,8 @@
//===- PatternMatch.h - Match on the LLVM IR --------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -31,7 +30,6 @@
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
-#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
@@ -215,6 +213,7 @@
// Non-splat vector constant: check each element for a match.
unsigned NumElts = V->getType()->getVectorNumElements();
assert(NumElts != 0 && "Constant vector with no elements?");
+ bool HasNonUndefElements = false;
for (unsigned i = 0; i != NumElts; ++i) {
Constant *Elt = C->getAggregateElement(i);
if (!Elt)
@@ -224,8 +223,9 @@
auto *CI = dyn_cast<ConstantInt>(Elt);
if (!CI || !this->isValue(CI->getValue()))
return false;
+ HasNonUndefElements = true;
}
- return true;
+ return HasNonUndefElements;
}
}
return false;
@@ -272,6 +272,7 @@
// Non-splat vector constant: check each element for a match.
unsigned NumElts = V->getType()->getVectorNumElements();
assert(NumElts != 0 && "Constant vector with no elements?");
+ bool HasNonUndefElements = false;
for (unsigned i = 0; i != NumElts; ++i) {
Constant *Elt = C->getAggregateElement(i);
if (!Elt)
@@ -281,8 +282,9 @@
auto *CF = dyn_cast<ConstantFP>(Elt);
if (!CF || !this->isValue(CF->getValueAPF()))
return false;
+ HasNonUndefElements = true;
}
- return true;
+ return HasNonUndefElements;
}
}
return false;
@@ -659,11 +661,32 @@
return BinaryOp_match<LHS, RHS, Instruction::FSub>(L, R);
}
+template <typename Op_t> struct FNeg_match {
+ Op_t X;
+
+ FNeg_match(const Op_t &Op) : X(Op) {}
+ template <typename OpTy> bool match(OpTy *V) {
+ auto *FPMO = dyn_cast<FPMathOperator>(V);
+ if (!FPMO || FPMO->getOpcode() != Instruction::FSub)
+ return false;
+ if (FPMO->hasNoSignedZeros()) {
+ // With 'nsz', any zero goes.
+ if (!cstfp_pred_ty<is_any_zero_fp>().match(FPMO->getOperand(0)))
+ return false;
+ } else {
+ // Without 'nsz', we need fsub -0.0, X exactly.
+ if (!cstfp_pred_ty<is_neg_zero_fp>().match(FPMO->getOperand(0)))
+ return false;
+ }
+ return X.match(FPMO->getOperand(1));
+ }
+};
+
/// Match 'fneg X' as 'fsub -0.0, X'.
-template <typename RHS>
-inline BinaryOp_match<cstfp_pred_ty<is_neg_zero_fp>, RHS, Instruction::FSub>
-m_FNeg(const RHS &X) {
- return m_FSub(m_NegZeroFP(), X);
+template <typename OpTy>
+inline FNeg_match<OpTy>
+m_FNeg(const OpTy &X) {
+ return FNeg_match<OpTy>(X);
}
/// Match 'fneg X' as 'fsub +-0.0, X'.
@@ -1440,6 +1463,20 @@
if (AddExpr.match(ICmpRHS) && (ICmpLHS == AddLHS || ICmpLHS == AddRHS))
return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpRHS);
+ // Match special-case for increment-by-1.
+ if (Pred == ICmpInst::ICMP_EQ) {
+ // (a + 1) == 0
+ // (1 + a) == 0
+ if (AddExpr.match(ICmpLHS) && m_ZeroInt().match(ICmpRHS) &&
+ (m_One().match(AddLHS) || m_One().match(AddRHS)))
+ return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpLHS);
+ // 0 == (a + 1)
+ // 0 == (1 + a)
+ if (m_ZeroInt().match(ICmpLHS) && AddExpr.match(ICmpRHS) &&
+ (m_One().match(AddLHS) || m_One().match(AddRHS)))
+ return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpRHS);
+ }
+
return false;
}
};
@@ -1461,8 +1498,10 @@
Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
template <typename OpTy> bool match(OpTy *V) {
- CallSite CS(V);
- return CS.isCall() && Val.match(CS.getArgument(OpI));
+ // FIXME: Should likely be switched to use `CallBase`.
+ if (const auto *CI = dyn_cast<CallInst>(V))
+ return Val.match(CI->getArgOperand(OpI));
+ return false;
}
};