[llvm] r263084 - [gvn] Fix more indenting and formatting in regions of code that will

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 16:58:20 PST 2016


Author: chandlerc
Date: Wed Mar  9 18:58:20 2016
New Revision: 263084

URL: http://llvm.org/viewvc/llvm-project?rev=263084&view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=263084&r1=263083&r2=263084&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Mar  9 18:58:20 2016
@@ -78,79 +78,78 @@ MaxRecurseDepth("max-recurse-depth", cl:
 //                         ValueTable Class
 //===----------------------------------------------------------------------===//
 
+namespace {
+
+struct Expression {
+  uint32_t opcode;
+  Type *type;
+  SmallVector<uint32_t, 4> varargs;
+
+  Expression(uint32_t o = ~2U) : opcode(o) {}
+
+  bool operator==(const Expression &other) const {
+    if (opcode != other.opcode)
+      return false;
+    if (opcode == ~0U || opcode == ~1U)
+      return true;
+    if (type != other.type)
+      return false;
+    if (varargs != other.varargs)
+      return false;
+    return true;
+  }
+
+  friend hash_code hash_value(const Expression &Value) {
+    return hash_combine(
+        Value.opcode, Value.type,
+        hash_combine_range(Value.varargs.begin(), Value.varargs.end()));
+  }
+};
+
 /// 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.
-namespace {
-  struct Expression {
-    uint32_t opcode;
-    Type *type;
-    SmallVector<uint32_t, 4> varargs;
-
-    Expression(uint32_t o = ~2U) : opcode(o) { }
-
-    bool operator==(const Expression &other) const {
-      if (opcode != other.opcode)
-        return false;
-      if (opcode == ~0U || opcode == ~1U)
-        return true;
-      if (type != other.type)
-        return false;
-      if (varargs != other.varargs)
-        return false;
-      return true;
-    }
+class ValueTable {
+  DenseMap<Value *, uint32_t> valueNumbering;
+  DenseMap<Expression, uint32_t> expressionNumbering;
+  AliasAnalysis *AA;
+  MemoryDependenceResults *MD;
+  DominatorTree *DT;
+
+  uint32_t nextValueNumber;
+
+  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:
+  ValueTable() : nextValueNumber(1) {}
+  uint32_t lookup_or_add(Value *V);
+  uint32_t lookup(Value *V) const;
+  uint32_t lookup_or_add_cmp(unsigned Opcode, CmpInst::Predicate Pred,
+                             Value *LHS, Value *RHS);
+  bool exists(Value *V) const;
+  void add(Value *V, uint32_t num);
+  void clear();
+  void erase(Value *v);
+  void setAliasAnalysis(AliasAnalysis *A) { AA = A; }
+  AliasAnalysis *getAliasAnalysis() const { return AA; }
+  void setMemDep(MemoryDependenceResults *M) { MD = M; }
+  void setDomTree(DominatorTree *D) { DT = D; }
+  uint32_t getNextUnusedValueNumber() { return nextValueNumber; }
+  void verifyRemoved(const Value *) const;
+};
 
-    friend hash_code hash_value(const Expression &Value) {
-      return hash_combine(Value.opcode, Value.type,
-                          hash_combine_range(Value.varargs.begin(),
-                                             Value.varargs.end()));
-    }
-  };
-
-  class ValueTable {
-    DenseMap<Value*, uint32_t> valueNumbering;
-    DenseMap<Expression, uint32_t> expressionNumbering;
-    AliasAnalysis *AA;
-    MemoryDependenceResults *MD;
-    DominatorTree *DT;
-
-    uint32_t nextValueNumber;
-
-    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:
-    ValueTable() : nextValueNumber(1) { }
-    uint32_t lookup_or_add(Value *V);
-    uint32_t lookup(Value *V) const;
-    uint32_t lookup_or_add_cmp(unsigned Opcode, CmpInst::Predicate Pred,
-                               Value *LHS, Value *RHS);
-    bool exists(Value *V) const;
-    void add(Value *V, uint32_t num);
-    void clear();
-    void erase(Value *v);
-    void setAliasAnalysis(AliasAnalysis* A) { AA = A; }
-    AliasAnalysis *getAliasAnalysis() const { return AA; }
-    void setMemDep(MemoryDependenceResults* M) { MD = M; }
-    void setDomTree(DominatorTree* D) { DT = D; }
-    uint32_t getNextUnusedValueNumber() { return nextValueNumber; }
-    void verifyRemoved(const Value *) const;
-  };
-}
+} // End anonymous namespace.
 
 namespace llvm {
 template <> struct DenseMapInfo<Expression> {
-  static inline Expression getEmptyKey() {
-    return ~0U;
-  }
+  static inline Expression getEmptyKey() { return ~0U; }
 
-  static inline Expression getTombstoneKey() {
-    return ~1U;
-  }
+  static inline Expression getTombstoneKey() { return ~1U; }
 
   static unsigned getHashValue(const Expression e) {
     using llvm::hash_value;
@@ -160,8 +159,7 @@ template <> struct DenseMapInfo<Expressi
     return LHS == RHS;
   }
 };
-
-}
+} // End llvm namespace.
 
 //===----------------------------------------------------------------------===//
 //                     ValueTable Internal Functions




More information about the llvm-commits mailing list