diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /lib/IR/LLVMContextImpl.h | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'lib/IR/LLVMContextImpl.h')
-rw-r--r-- | lib/IR/LLVMContextImpl.h | 89 |
1 files changed, 59 insertions, 30 deletions
diff --git a/lib/IR/LLVMContextImpl.h b/lib/IR/LLVMContextImpl.h index 808c239..e743ec3 100644 --- a/lib/IR/LLVMContextImpl.h +++ b/lib/IR/LLVMContextImpl.h @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LLVMCONTEXT_IMPL_H -#define LLVM_LLVMCONTEXT_IMPL_H +#ifndef LLVM_LIB_IR_LLVMCONTEXTIMPL_H +#define LLVM_LIB_IR_LLVMCONTEXTIMPL_H #include "AttributeImpl.h" #include "ConstantsContext.h" @@ -22,6 +22,7 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/SmallPtrSet.h" @@ -150,7 +151,7 @@ struct FunctionTypeKeyInfo { ReturnType(R), Params(P), isVarArg(V) {} KeyTy(const FunctionType* FT) : ReturnType(FT->getReturnType()), - Params(ArrayRef<Type*>(FT->param_begin(), FT->param_end())), + Params(makeArrayRef(FT->param_begin(), FT->param_end())), isVarArg(FT->isVarArg()) {} bool operator==(const KeyTy& that) const { if (ReturnType != that.ReturnType) @@ -190,23 +191,52 @@ struct FunctionTypeKeyInfo { } }; -// Provide a FoldingSetTrait::Equals specialization for MDNode that can use a -// shortcut to avoid comparing all operands. -template<> struct FoldingSetTrait<MDNode> : DefaultFoldingSetTrait<MDNode> { - static bool Equals(const MDNode &X, const FoldingSetNodeID &ID, - unsigned IDHash, FoldingSetNodeID &TempID) { - assert(!X.isNotUniqued() && "Non-uniqued MDNode in FoldingSet?"); - // First, check if the cached hashes match. If they don't we can skip the - // expensive operand walk. - if (X.Hash != IDHash) - return false; +/// \brief DenseMapInfo for GenericMDNode. +/// +/// Note that we don't need the is-function-local bit, since that's implicit in +/// the operands. +struct GenericMDNodeInfo { + struct KeyTy { + ArrayRef<Value *> Ops; + unsigned Hash; + + KeyTy(ArrayRef<Value *> Ops) + : Ops(Ops), Hash(hash_combine_range(Ops.begin(), Ops.end())) {} + + KeyTy(GenericMDNode *N, SmallVectorImpl<Value *> &Storage) { + Storage.resize(N->getNumOperands()); + for (unsigned I = 0, E = N->getNumOperands(); I != E; ++I) + Storage[I] = N->getOperand(I); + Ops = Storage; + Hash = hash_combine_range(Ops.begin(), Ops.end()); + } - // If they match we have to compare the operands. - X.Profile(TempID); - return TempID == ID; + bool operator==(const GenericMDNode *RHS) const { + if (RHS == getEmptyKey() || RHS == getTombstoneKey()) + return false; + if (Hash != RHS->getHash() || Ops.size() != RHS->getNumOperands()) + return false; + for (unsigned I = 0, E = Ops.size(); I != E; ++I) + if (Ops[I] != RHS->getOperand(I)) + return false; + return true; + } + }; + static inline GenericMDNode *getEmptyKey() { + return DenseMapInfo<GenericMDNode *>::getEmptyKey(); + } + static inline GenericMDNode *getTombstoneKey() { + return DenseMapInfo<GenericMDNode *>::getTombstoneKey(); } - static unsigned ComputeHash(const MDNode &X, FoldingSetNodeID &) { - return X.Hash; // Return cached hash. + static unsigned getHashValue(const KeyTy &Key) { return Key.Hash; } + static unsigned getHashValue(const GenericMDNode *U) { + return U->getHash(); + } + static bool isEqual(const KeyTy &LHS, const GenericMDNode *RHS) { + return LHS == RHS; + } + static bool isEqual(const GenericMDNode *LHS, const GenericMDNode *RHS) { + return LHS == RHS; } }; @@ -244,6 +274,7 @@ public: LLVMContext::DiagnosticHandlerTy DiagnosticHandler; void *DiagnosticContext; + bool RespectDiagnosticFilters; LLVMContext::YieldCallbackTy YieldCallback; void *YieldOpaqueHandle; @@ -260,25 +291,25 @@ public: FoldingSet<AttributeSetImpl> AttrsLists; FoldingSet<AttributeSetNode> AttrsSetNodes; - StringMap<Value*> MDStringCache; + StringMap<MDString> MDStringCache; - FoldingSet<MDNode> MDNodeSet; + DenseSet<GenericMDNode *, GenericMDNodeInfo> MDNodeSet; // MDNodes may be uniqued or not uniqued. When they're not uniqued, they // aren't in the MDNodeSet, but they're still shared between objects, so no // one object can destroy them. This set allows us to at least destroy them // on Context destruction. - SmallPtrSet<MDNode*, 1> NonUniquedMDNodes; - + SmallPtrSet<GenericMDNode *, 1> NonUniquedMDNodes; + DenseMap<Type*, ConstantAggregateZero*> CAZConstants; - typedef ConstantAggrUniqueMap<ArrayType, ConstantArray> ArrayConstantsTy; + typedef ConstantUniqueMap<ConstantArray> ArrayConstantsTy; ArrayConstantsTy ArrayConstants; - typedef ConstantAggrUniqueMap<StructType, ConstantStruct> StructConstantsTy; + typedef ConstantUniqueMap<ConstantStruct> StructConstantsTy; StructConstantsTy StructConstants; - typedef ConstantAggrUniqueMap<VectorType, ConstantVector> VectorConstantsTy; + typedef ConstantUniqueMap<ConstantVector> VectorConstantsTy; VectorConstantsTy VectorConstants; DenseMap<PointerType*, ConstantPointerNull*> CPNConstants; @@ -289,12 +320,10 @@ public: DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *> BlockAddresses; - ConstantUniqueMap<ExprMapKeyType, const ExprMapKeyType&, Type, ConstantExpr> - ExprConstants; + ConstantUniqueMap<ConstantExpr> ExprConstants; + + ConstantUniqueMap<InlineAsm> InlineAsms; - ConstantUniqueMap<InlineAsmKeyType, const InlineAsmKeyType&, PointerType, - InlineAsm> InlineAsms; - ConstantInt *TheTrueVal; ConstantInt *TheFalseVal; |