Skip to content

Commit

Permalink
Reapply r215966, r215965, r215964, r215963, r215960, r215959, r215958…
Browse files Browse the repository at this point in the history
…, and r215957

This reverts commit r215981, which reverted the above commits because
MSVC std::equal asserts on nullptr iterators, and thes commits
introduced an `ArrayRef::equals()` on empty ArrayRefs.

ArrayRef was changed not to use std::equal in r215986.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215987 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dexonsmith committed Aug 19, 2014
1 parent 8c20a93 commit 7116af6
Show file tree
Hide file tree
Showing 8 changed files with 438 additions and 502 deletions.
2 changes: 2 additions & 0 deletions include/llvm/IR/Constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Constant : public User {
: User(ty, vty, Ops, NumOps) {}

void destroyConstantImpl();
void replaceUsesOfWithOnConstantImpl(Constant *Replacement);

public:
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue.
Expand Down
32 changes: 20 additions & 12 deletions include/llvm/IR/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ class PointerType;
class VectorType;
class SequentialType;

template<class ConstantClass, class TypeClass, class ValType>
struct ConstantCreator;
template<class ConstantClass, class TypeClass>
struct ConstantArrayCreator;
template<class ConstantClass, class TypeClass>
struct ConvertConstantType;
struct ConstantExprKeyType;
template <class ConstantClass> struct ConstantAggrKeyType;

//===----------------------------------------------------------------------===//
/// This is the shared class of boolean and integer constants. This class
Expand Down Expand Up @@ -338,14 +334,18 @@ class ConstantAggregateZero : public Constant {
/// ConstantArray - Constant Array Declarations
///
class ConstantArray : public Constant {
friend struct ConstantArrayCreator<ConstantArray, ArrayType>;
friend struct ConstantAggrKeyType<ConstantArray>;
ConstantArray(const ConstantArray &) LLVM_DELETED_FUNCTION;
protected:
ConstantArray(ArrayType *T, ArrayRef<Constant *> Val);
public:
// ConstantArray accessors
static Constant *get(ArrayType *T, ArrayRef<Constant*> V);

private:
static Constant *getImpl(ArrayType *T, ArrayRef<Constant *> V);

public:
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);

Expand Down Expand Up @@ -376,7 +376,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantArray, Constant)
// ConstantStruct - Constant Struct Declarations
//
class ConstantStruct : public Constant {
friend struct ConstantArrayCreator<ConstantStruct, StructType>;
friend struct ConstantAggrKeyType<ConstantStruct>;
ConstantStruct(const ConstantStruct &) LLVM_DELETED_FUNCTION;
protected:
ConstantStruct(StructType *T, ArrayRef<Constant *> Val);
Expand Down Expand Up @@ -435,14 +435,18 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantStruct, Constant)
/// ConstantVector - Constant Vector Declarations
///
class ConstantVector : public Constant {
friend struct ConstantArrayCreator<ConstantVector, VectorType>;
friend struct ConstantAggrKeyType<ConstantVector>;
ConstantVector(const ConstantVector &) LLVM_DELETED_FUNCTION;
protected:
ConstantVector(VectorType *T, ArrayRef<Constant *> Val);
public:
// ConstantVector accessors
static Constant *get(ArrayRef<Constant*> V);

private:
static Constant *getImpl(ArrayRef<Constant *> V);

public:
/// getSplat - Return a ConstantVector with the specified constant in each
/// element.
static Constant *getSplat(unsigned NumElts, Constant *Elt);
Expand Down Expand Up @@ -794,9 +798,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value)
/// constant expressions. The Opcode field for the ConstantExpr class is
/// maintained in the Value::SubclassData field.
class ConstantExpr : public Constant {
friend struct ConstantCreator<ConstantExpr,Type,
std::pair<unsigned, std::vector<Constant*> > >;
friend struct ConvertConstantType<ConstantExpr, Type>;
friend struct ConstantExprKeyType;

protected:
ConstantExpr(Type *ty, unsigned Opcode, Use *Ops, unsigned NumOps)
Expand Down Expand Up @@ -1113,6 +1115,12 @@ class ConstantExpr : public Constant {
void setValueSubclassData(unsigned short D) {
Value::setValueSubclassData(D);
}

/// \brief Check whether this can become its replacement.
///
/// For use during \a replaceUsesOfWithOnConstant(), check whether we know
/// how to turn this into \a Replacement, thereby reducing RAUW traffic.
bool canBecomeReplacement(const Constant *Replacement) const;
};

template <>
Expand Down
12 changes: 4 additions & 8 deletions include/llvm/IR/InlineAsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ namespace llvm {
class PointerType;
class FunctionType;
class Module;

struct InlineAsmKeyType;
template<class ValType, class ValRefType, class TypeClass, class ConstantClass,
bool HasLargeKey>
class ConstantUniqueMap;
template<class ConstantClass, class TypeClass, class ValType>
struct ConstantCreator;
template <class ConstantClass> class ConstantUniqueMap;

class InlineAsm : public Value {
public:
Expand All @@ -40,9 +37,8 @@ class InlineAsm : public Value {
};

private:
friend struct ConstantCreator<InlineAsm, PointerType, InlineAsmKeyType>;
friend class ConstantUniqueMap<InlineAsmKeyType, const InlineAsmKeyType&,
PointerType, InlineAsm, false>;
friend struct InlineAsmKeyType;
friend class ConstantUniqueMap<InlineAsm>;

InlineAsm(const InlineAsm &) LLVM_DELETED_FUNCTION;
void operator=(const InlineAsm&) LLVM_DELETED_FUNCTION;
Expand Down
Loading

0 comments on commit 7116af6

Please sign in to comment.