Skip to content

Commit 7776377

Browse files
committed
[gvn] Fix more indenting and formatting in regions of code that will
need to be changed for porting to the new pass manager. Also sink the comment on the ValueTable class back to that class instead of it dangling on an anonymous namespace. No functionality changed. llvm-svn: 263084
1 parent 169c84f commit 7776377

File tree

1 file changed

+62
-64
lines changed

1 file changed

+62
-64
lines changed

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 62 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -78,79 +78,78 @@ MaxRecurseDepth("max-recurse-depth", cl::Hidden, cl::init(1000), cl::ZeroOrMore,
7878
// ValueTable Class
7979
//===----------------------------------------------------------------------===//
8080

81+
namespace {
82+
83+
struct Expression {
84+
uint32_t opcode;
85+
Type *type;
86+
SmallVector<uint32_t, 4> varargs;
87+
88+
Expression(uint32_t o = ~2U) : opcode(o) {}
89+
90+
bool operator==(const Expression &other) const {
91+
if (opcode != other.opcode)
92+
return false;
93+
if (opcode == ~0U || opcode == ~1U)
94+
return true;
95+
if (type != other.type)
96+
return false;
97+
if (varargs != other.varargs)
98+
return false;
99+
return true;
100+
}
101+
102+
friend hash_code hash_value(const Expression &Value) {
103+
return hash_combine(
104+
Value.opcode, Value.type,
105+
hash_combine_range(Value.varargs.begin(), Value.varargs.end()));
106+
}
107+
};
108+
81109
/// This class holds the mapping between values and value numbers. It is used
82110
/// as an efficient mechanism to determine the expression-wise equivalence of
83111
/// two values.
84-
namespace {
85-
struct Expression {
86-
uint32_t opcode;
87-
Type *type;
88-
SmallVector<uint32_t, 4> varargs;
112+
class ValueTable {
113+
DenseMap<Value *, uint32_t> valueNumbering;
114+
DenseMap<Expression, uint32_t> expressionNumbering;
115+
AliasAnalysis *AA;
116+
MemoryDependenceResults *MD;
117+
DominatorTree *DT;
89118

90-
Expression(uint32_t o = ~2U) : opcode(o) { }
119+
uint32_t nextValueNumber;
91120

92-
bool operator==(const Expression &other) const {
93-
if (opcode != other.opcode)
94-
return false;
95-
if (opcode == ~0U || opcode == ~1U)
96-
return true;
97-
if (type != other.type)
98-
return false;
99-
if (varargs != other.varargs)
100-
return false;
101-
return true;
102-
}
121+
Expression create_expression(Instruction *I);
122+
Expression create_cmp_expression(unsigned Opcode,
123+
CmpInst::Predicate Predicate, Value *LHS,
124+
Value *RHS);
125+
Expression create_extractvalue_expression(ExtractValueInst *EI);
126+
uint32_t lookup_or_add_call(CallInst *C);
103127

104-
friend hash_code hash_value(const Expression &Value) {
105-
return hash_combine(Value.opcode, Value.type,
106-
hash_combine_range(Value.varargs.begin(),
107-
Value.varargs.end()));
108-
}
109-
};
128+
public:
129+
ValueTable() : nextValueNumber(1) {}
130+
uint32_t lookup_or_add(Value *V);
131+
uint32_t lookup(Value *V) const;
132+
uint32_t lookup_or_add_cmp(unsigned Opcode, CmpInst::Predicate Pred,
133+
Value *LHS, Value *RHS);
134+
bool exists(Value *V) const;
135+
void add(Value *V, uint32_t num);
136+
void clear();
137+
void erase(Value *v);
138+
void setAliasAnalysis(AliasAnalysis *A) { AA = A; }
139+
AliasAnalysis *getAliasAnalysis() const { return AA; }
140+
void setMemDep(MemoryDependenceResults *M) { MD = M; }
141+
void setDomTree(DominatorTree *D) { DT = D; }
142+
uint32_t getNextUnusedValueNumber() { return nextValueNumber; }
143+
void verifyRemoved(const Value *) const;
144+
};
110145

111-
class ValueTable {
112-
DenseMap<Value*, uint32_t> valueNumbering;
113-
DenseMap<Expression, uint32_t> expressionNumbering;
114-
AliasAnalysis *AA;
115-
MemoryDependenceResults *MD;
116-
DominatorTree *DT;
117-
118-
uint32_t nextValueNumber;
119-
120-
Expression create_expression(Instruction* I);
121-
Expression create_cmp_expression(unsigned Opcode,
122-
CmpInst::Predicate Predicate,
123-
Value *LHS, Value *RHS);
124-
Expression create_extractvalue_expression(ExtractValueInst* EI);
125-
uint32_t lookup_or_add_call(CallInst* C);
126-
public:
127-
ValueTable() : nextValueNumber(1) { }
128-
uint32_t lookup_or_add(Value *V);
129-
uint32_t lookup(Value *V) const;
130-
uint32_t lookup_or_add_cmp(unsigned Opcode, CmpInst::Predicate Pred,
131-
Value *LHS, Value *RHS);
132-
bool exists(Value *V) const;
133-
void add(Value *V, uint32_t num);
134-
void clear();
135-
void erase(Value *v);
136-
void setAliasAnalysis(AliasAnalysis* A) { AA = A; }
137-
AliasAnalysis *getAliasAnalysis() const { return AA; }
138-
void setMemDep(MemoryDependenceResults* M) { MD = M; }
139-
void setDomTree(DominatorTree* D) { DT = D; }
140-
uint32_t getNextUnusedValueNumber() { return nextValueNumber; }
141-
void verifyRemoved(const Value *) const;
142-
};
143-
}
146+
} // End anonymous namespace.
144147

145148
namespace llvm {
146149
template <> struct DenseMapInfo<Expression> {
147-
static inline Expression getEmptyKey() {
148-
return ~0U;
149-
}
150+
static inline Expression getEmptyKey() { return ~0U; }
150151

151-
static inline Expression getTombstoneKey() {
152-
return ~1U;
153-
}
152+
static inline Expression getTombstoneKey() { return ~1U; }
154153

155154
static unsigned getHashValue(const Expression e) {
156155
using llvm::hash_value;
@@ -160,8 +159,7 @@ template <> struct DenseMapInfo<Expression> {
160159
return LHS == RHS;
161160
}
162161
};
163-
164-
}
162+
} // End llvm namespace.
165163

166164
//===----------------------------------------------------------------------===//
167165
// ValueTable Internal Functions

0 commit comments

Comments
 (0)