Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/IR/Constants.h b/linux-x64/clang/include/llvm/IR/Constants.h
index ca56e8b..ac80223 100644
--- a/linux-x64/clang/include/llvm/IR/Constants.h
+++ b/linux-x64/clang/include/llvm/IR/Constants.h
@@ -41,12 +41,6 @@
namespace llvm {
-class ArrayType;
-class IntegerType;
-class PointerType;
-class SequentialType;
-class StructType;
-class VectorType;
template <class ConstantClass> struct ConstantAggrKeyType;
/// Base class for constants with no operands.
@@ -94,8 +88,10 @@
static ConstantInt *getTrue(LLVMContext &Context);
static ConstantInt *getFalse(LLVMContext &Context);
+ static ConstantInt *getBool(LLVMContext &Context, bool V);
static Constant *getTrue(Type *Ty);
static Constant *getFalse(Type *Ty);
+ static Constant *getBool(Type *Ty, bool V);
/// If Ty is a vector type, return a Constant with a splat of the given
/// value. Otherwise return a ConstantInt for the given value.
@@ -157,6 +153,20 @@
return Val.getSExtValue();
}
+ /// Return the constant as an llvm::MaybeAlign.
+ /// Note that this method can assert if the value does not fit in 64 bits or
+ /// is not a power of two.
+ inline MaybeAlign getMaybeAlignValue() const {
+ return MaybeAlign(getZExtValue());
+ }
+
+ /// Return the constant as an llvm::Align, interpreting `0` as `Align(1)`.
+ /// Note that this method can assert if the value does not fit in 64 bits or
+ /// is not a power of two.
+ inline Align getAlignValue() const {
+ return getMaybeAlignValue().valueOrOne();
+ }
+
/// A helper method that can be used to determine if the constant contained
/// within is equal to a constant. This only works for very small values,
/// because this is all that can be represented with all types.
@@ -300,6 +310,7 @@
/// Return true if Ty is big enough to represent V.
static bool isValueValidForType(Type *Ty, const APFloat &V);
inline const APFloat &getValueAPF() const { return Val; }
+ inline const APFloat &getValue() const { return Val; }
/// Return true if the value is positive or negative zero.
bool isZero() const { return Val.isZero(); }
@@ -388,7 +399,7 @@
/// use operands.
class ConstantAggregate : public Constant {
protected:
- ConstantAggregate(CompositeType *T, ValueTy VT, ArrayRef<Constant *> V);
+ ConstantAggregate(Type *T, ValueTy VT, ArrayRef<Constant *> V);
public:
/// Transparently provide more efficient getOperand methods.
@@ -456,8 +467,7 @@
static Constant *get(StructType *T, ArrayRef<Constant*> V);
template <typename... Csts>
- static typename std::enable_if<are_base_of<Constant, Csts...>::value,
- Constant *>::type
+ static std::enable_if_t<are_base_of<Constant, Csts...>::value, Constant *>
get(StructType *T, Csts *... Vs) {
SmallVector<Constant *, 8> Values({Vs...});
return get(T, Values);
@@ -514,17 +524,19 @@
public:
/// Return a ConstantVector with the specified constant in each element.
- static Constant *getSplat(unsigned NumElts, Constant *Elt);
+ /// Note that this might not return an instance of ConstantVector
+ static Constant *getSplat(ElementCount EC, Constant *Elt);
- /// Specialize the getType() method to always return a VectorType,
+ /// Specialize the getType() method to always return a FixedVectorType,
/// which reduces the amount of casting needed in parts of the compiler.
- inline VectorType *getType() const {
- return cast<VectorType>(Value::getType());
+ inline FixedVectorType *getType() const {
+ return cast<FixedVectorType>(Value::getType());
}
- /// If this is a splat constant, meaning that all of the elements have the
- /// same value, return that value. Otherwise return NULL.
- Constant *getSplatValue() const;
+ /// If all elements of the vector constant have the same value, return that
+ /// value. Otherwise, return nullptr. Ignore undefined elements by setting
+ /// AllowUndefs to true.
+ Constant *getSplatValue(bool AllowUndefs = false) const;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V) {
@@ -582,14 +594,13 @@
/// the same value but different type. For example, 0,0,0,1 could be a 4
/// element array of i8, or a 1-element array of i32. They'll both end up in
/// the same StringMap bucket, linked up.
- ConstantDataSequential *Next;
+ std::unique_ptr<ConstantDataSequential> Next;
void destroyConstantImpl();
protected:
explicit ConstantDataSequential(Type *ty, ValueTy VT, const char *Data)
- : ConstantData(ty, VT), DataElements(Data), Next(nullptr) {}
- ~ConstantDataSequential() { delete Next; }
+ : ConstantData(ty, VT), DataElements(Data) {}
static Constant *getImpl(StringRef Bytes, Type *Ty);
@@ -627,12 +638,6 @@
/// efficient as getElementAsInteger/Float/Double.
Constant *getElementAsConstant(unsigned i) const;
- /// Specialize the getType() method to always return a SequentialType, which
- /// reduces the amount of casting needed in parts of the compiler.
- inline SequentialType *getType() const {
- return cast<SequentialType>(Value::getType());
- }
-
/// Return the element type of the array/vector.
Type *getElementType() const;
@@ -723,14 +728,15 @@
return getImpl(Data, Ty);
}
- /// getFP() constructors - Return a constant with array type with an element
- /// count and element type of float with precision matching the number of
- /// bits in the ArrayRef passed in. (i.e. half for 16bits, float for 32bits,
- /// double for 64bits) Note that this can return a ConstantAggregateZero
- /// object.
- static Constant *getFP(LLVMContext &Context, ArrayRef<uint16_t> Elts);
- static Constant *getFP(LLVMContext &Context, ArrayRef<uint32_t> Elts);
- static Constant *getFP(LLVMContext &Context, ArrayRef<uint64_t> Elts);
+ /// getFP() constructors - Return a constant of array type with a float
+ /// element type taken from argument `ElementType', and count taken from
+ /// argument `Elts'. The amount of bits of the contained type must match the
+ /// number of bits of the type contained in the passed in ArrayRef.
+ /// (i.e. half or bfloat for 16bits, float for 32bits, double for 64bits) Note
+ /// that this can return a ConstantAggregateZero object.
+ static Constant *getFP(Type *ElementType, ArrayRef<uint16_t> Elts);
+ static Constant *getFP(Type *ElementType, ArrayRef<uint32_t> Elts);
+ static Constant *getFP(Type *ElementType, ArrayRef<uint64_t> Elts);
/// This method constructs a CDS and initializes it with a text string.
/// The default behavior (AddNull==true) causes a null terminator to
@@ -762,7 +768,12 @@
friend class ConstantDataSequential;
explicit ConstantDataVector(Type *ty, const char *Data)
- : ConstantDataSequential(ty, ConstantDataVectorVal, Data) {}
+ : ConstantDataSequential(ty, ConstantDataVectorVal, Data),
+ IsSplatSet(false) {}
+ // Cache whether or not the constant is a splat.
+ mutable bool IsSplatSet : 1;
+ mutable bool IsSplat : 1;
+ bool isSplatData() const;
public:
ConstantDataVector(const ConstantDataVector &) = delete;
@@ -777,14 +788,15 @@
static Constant *get(LLVMContext &Context, ArrayRef<float> Elts);
static Constant *get(LLVMContext &Context, ArrayRef<double> Elts);
- /// getFP() constructors - Return a constant with vector type with an element
- /// count and element type of float with the precision matching the number of
- /// bits in the ArrayRef passed in. (i.e. half for 16bits, float for 32bits,
- /// double for 64bits) Note that this can return a ConstantAggregateZero
- /// object.
- static Constant *getFP(LLVMContext &Context, ArrayRef<uint16_t> Elts);
- static Constant *getFP(LLVMContext &Context, ArrayRef<uint32_t> Elts);
- static Constant *getFP(LLVMContext &Context, ArrayRef<uint64_t> Elts);
+ /// getFP() constructors - Return a constant of vector type with a float
+ /// element type taken from argument `ElementType', and count taken from
+ /// argument `Elts'. The amount of bits of the contained type must match the
+ /// number of bits of the type contained in the passed in ArrayRef.
+ /// (i.e. half or bfloat for 16bits, float for 32bits, double for 64bits) Note
+ /// that this can return a ConstantAggregateZero object.
+ static Constant *getFP(Type *ElementType, ArrayRef<uint16_t> Elts);
+ static Constant *getFP(Type *ElementType, ArrayRef<uint32_t> Elts);
+ static Constant *getFP(Type *ElementType, ArrayRef<uint64_t> Elts);
/// Return a ConstantVector with the specified constant in each element.
/// The specified constant has to be a of a compatible type (i8/i16/
@@ -799,10 +811,10 @@
/// same value, return that value. Otherwise return NULL.
Constant *getSplatValue() const;
- /// Specialize the getType() method to always return a VectorType,
+ /// Specialize the getType() method to always return a FixedVectorType,
/// which reduces the amount of casting needed in parts of the compiler.
- inline VectorType *getType() const {
- return cast<VectorType>(Value::getType());
+ inline FixedVectorType *getType() const {
+ return cast<FixedVectorType>(Value::getType());
}
/// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -878,6 +890,42 @@
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value)
+/// Wrapper for a function that represents a value that
+/// functionally represents the original function. This can be a function,
+/// global alias to a function, or an ifunc.
+class DSOLocalEquivalent final : public Constant {
+ friend class Constant;
+
+ DSOLocalEquivalent(GlobalValue *GV);
+
+ void *operator new(size_t s) { return User::operator new(s, 1); }
+
+ void destroyConstantImpl();
+ Value *handleOperandChangeImpl(Value *From, Value *To);
+
+public:
+ /// Return a DSOLocalEquivalent for the specified global value.
+ static DSOLocalEquivalent *get(GlobalValue *GV);
+
+ /// Transparently provide more efficient getOperand methods.
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ GlobalValue *getGlobalValue() const {
+ return cast<GlobalValue>(Op<0>().get());
+ }
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static bool classof(const Value *V) {
+ return V->getValueID() == DSOLocalEquivalentVal;
+ }
+};
+
+template <>
+struct OperandTraits<DSOLocalEquivalent>
+ : public FixedNumOperandTraits<DSOLocalEquivalent, 1> {};
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(DSOLocalEquivalent, Value)
+
//===----------------------------------------------------------------------===//
/// A constant value that is initialized with an expression using
/// other constant values.
@@ -899,6 +947,8 @@
setValueSubclassData(Opcode);
}
+ ~ConstantExpr() = default;
+
public:
// Static methods to construct a ConstantExpr of different kinds. Note that
// these methods may return a object that is not an instance of the
@@ -946,6 +996,7 @@
static Constant *getAnd(Constant *C1, Constant *C2);
static Constant *getOr(Constant *C1, Constant *C2);
static Constant *getXor(Constant *C1, Constant *C2);
+ static Constant *getUMin(Constant *C1, Constant *C2);
static Constant *getShl(Constant *C1, Constant *C2,
bool HasNUW = false, bool HasNSW = false);
static Constant *getLShr(Constant *C1, Constant *C2, bool isExact = false);
@@ -1021,6 +1072,12 @@
return getLShr(C1, C2, true);
}
+ /// If C is a scalar/fixed width vector of known powers of 2, then this
+ /// function returns a new scalar/fixed width vector obtained from logBase2
+ /// of C. Undef vector elements are set to zero.
+ /// Return a null pointer otherwise.
+ static Constant *getExactLogBase2(Constant *C);
+
/// Return the identity constant for a binary opcode.
/// The identity constant C is defined as X op C = X and C op X = X for every
/// X when the binary operation is commutative. If the binop is not
@@ -1197,7 +1254,8 @@
Type *OnlyIfReducedTy = nullptr);
static Constant *getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx,
Type *OnlyIfReducedTy = nullptr);
- static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask,
+ static Constant *getShuffleVector(Constant *V1, Constant *V2,
+ ArrayRef<int> Mask,
Type *OnlyIfReducedTy = nullptr);
static Constant *getExtractValue(Constant *Agg, ArrayRef<unsigned> Idxs,
Type *OnlyIfReducedTy = nullptr);
@@ -1216,6 +1274,16 @@
/// expression and return the list of indices.
ArrayRef<unsigned> getIndices() const;
+ /// Assert that this is a shufflevector and return the mask. See class
+ /// ShuffleVectorInst for a description of the mask representation.
+ ArrayRef<int> getShuffleMask() const;
+
+ /// Assert that this is a shufflevector and return the mask.
+ ///
+ /// TODO: This is a temporary hack until we update the bitcode format for
+ /// shufflevector.
+ Constant *getShuffleMaskForBitcode() const;
+
/// Return a string representation for an opcode.
const char *getOpcodeName() const;
@@ -1250,7 +1318,7 @@
/// which would take a ConstantExpr parameter, but that would have spread
/// implementation details of ConstantExpr outside of Constants.cpp, which
/// would make it harder to remove ConstantExprs altogether.
- Instruction *getAsInstruction();
+ Instruction *getAsInstruction() const;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V) {
@@ -1282,13 +1350,16 @@
/// can appear to have different bit patterns at each use. See
/// LangRef.html#undefvalues for details.
///
-class UndefValue final : public ConstantData {
+class UndefValue : public ConstantData {
friend class Constant;
explicit UndefValue(Type *T) : ConstantData(T, UndefValueVal) {}
void destroyConstantImpl();
+protected:
+ explicit UndefValue(Type *T, ValueTy vty) : ConstantData(T, vty) {}
+
public:
UndefValue(const UndefValue &) = delete;
@@ -1315,7 +1386,49 @@
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V) {
- return V->getValueID() == UndefValueVal;
+ return V->getValueID() == UndefValueVal ||
+ V->getValueID() == PoisonValueVal;
+ }
+};
+
+//===----------------------------------------------------------------------===//
+/// In order to facilitate speculative execution, many instructions do not
+/// invoke immediate undefined behavior when provided with illegal operands,
+/// and return a poison value instead.
+///
+/// see LangRef.html#poisonvalues for details.
+///
+class PoisonValue final : public UndefValue {
+ friend class Constant;
+
+ explicit PoisonValue(Type *T) : UndefValue(T, PoisonValueVal) {}
+
+ void destroyConstantImpl();
+
+public:
+ PoisonValue(const PoisonValue &) = delete;
+
+ /// Static factory methods - Return an 'poison' object of the specified type.
+ static PoisonValue *get(Type *T);
+
+ /// If this poison has array or vector type, return a poison with the right
+ /// element type.
+ PoisonValue *getSequentialElement() const;
+
+ /// If this poison has struct type, return a poison with the right element
+ /// type for the specified element.
+ PoisonValue *getStructElement(unsigned Elt) const;
+
+ /// Return an poison of the right value for the specified GEP index if we can,
+ /// otherwise return null (e.g. if C is a ConstantExpr).
+ PoisonValue *getElementValue(Constant *C) const;
+
+ /// Return an poison of the right value for the specified GEP index.
+ PoisonValue *getElementValue(unsigned Idx) const;
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static bool classof(const Value *V) {
+ return V->getValueID() == PoisonValueVal;
}
};