diff options
-rw-r--r-- | llvm/include/llvm/Transforms/Scalar/GVN.h | 16 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 22 |
2 files changed, 20 insertions, 18 deletions
diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h index 849e1db7246..90425ed223d 100644 --- a/llvm/include/llvm/Transforms/Scalar/GVN.h +++ b/llvm/include/llvm/Transforms/Scalar/GVN.h @@ -34,7 +34,6 @@ namespace llvm { namespace gvn LLVM_LIBRARY_VISIBILITY { struct AvailableValue; struct AvailableValueInBlock; -struct Expression; class GVNLegacyPass; } @@ -62,23 +61,26 @@ public: private: friend class gvn::GVNLegacyPass; + struct Expression; + friend struct DenseMapInfo<Expression>; + /// This class holds the mapping between values and value numbers. It is used /// as an efficient mechanism to determine the expression-wise equivalence of /// two values. class ValueTable { DenseMap<Value *, uint32_t> valueNumbering; - DenseMap<gvn::Expression, uint32_t> expressionNumbering; + DenseMap<Expression, uint32_t> expressionNumbering; AliasAnalysis *AA; MemoryDependenceResults *MD; DominatorTree *DT; uint32_t nextValueNumber; - gvn::Expression create_expression(Instruction *I); - gvn::Expression create_cmp_expression(unsigned Opcode, - CmpInst::Predicate Predicate, - Value *LHS, Value *RHS); - gvn::Expression create_extractvalue_expression(ExtractValueInst *EI); + Expression create_expression(Instruction *I); + Expression create_cmp_expression(unsigned Opcode, + CmpInst::Predicate Predicate, Value *LHS, + Value *RHS); + Expression create_extractvalue_expression(ExtractValueInst *EI); uint32_t lookup_or_add_call(CallInst *C); public: diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 49037aed56b..f286eb209cb 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -75,7 +75,7 @@ static cl::opt<uint32_t> MaxRecurseDepth("max-recurse-depth", cl::Hidden, cl::init(1000), cl::ZeroOrMore, cl::desc("Max recurse depth (default = 1000)")); -struct llvm::gvn::Expression { +struct llvm::GVN::Expression { uint32_t opcode; Type *type; SmallVector<uint32_t, 4> varargs; @@ -102,16 +102,16 @@ struct llvm::gvn::Expression { }; namespace llvm { -template <> struct DenseMapInfo<Expression> { - static inline Expression getEmptyKey() { return ~0U; } +template <> struct DenseMapInfo<GVN::Expression> { + static inline GVN::Expression getEmptyKey() { return ~0U; } - static inline Expression getTombstoneKey() { return ~1U; } + static inline GVN::Expression getTombstoneKey() { return ~1U; } - static unsigned getHashValue(const Expression e) { + static unsigned getHashValue(const GVN::Expression e) { using llvm::hash_value; return static_cast<unsigned>(hash_value(e)); } - static bool isEqual(const Expression &LHS, const Expression &RHS) { + static bool isEqual(const GVN::Expression &LHS, const GVN::Expression &RHS) { return LHS == RHS; } }; @@ -229,7 +229,7 @@ struct llvm::gvn::AvailableValueInBlock { // ValueTable Internal Functions //===----------------------------------------------------------------------===// -Expression GVN::ValueTable::create_expression(Instruction *I) { +GVN::Expression GVN::ValueTable::create_expression(Instruction *I) { Expression e; e.type = I->getType(); e.opcode = I->getOpcode(); @@ -263,9 +263,8 @@ Expression GVN::ValueTable::create_expression(Instruction *I) { return e; } -Expression GVN::ValueTable::create_cmp_expression(unsigned Opcode, - CmpInst::Predicate Predicate, - Value *LHS, Value *RHS) { +GVN::Expression GVN::ValueTable::create_cmp_expression( + unsigned Opcode, CmpInst::Predicate Predicate, Value *LHS, Value *RHS) { assert((Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) && "Not a comparison!"); Expression e; @@ -282,7 +281,8 @@ Expression GVN::ValueTable::create_cmp_expression(unsigned Opcode, return e; } -Expression GVN::ValueTable::create_extractvalue_expression(ExtractValueInst *EI) { +GVN::Expression +GVN::ValueTable::create_extractvalue_expression(ExtractValueInst *EI) { assert(EI && "Not an ExtractValueInst?"); Expression e; e.type = EI->getType(); |