[llvm] r290551 - clang-format NewGVN files
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 26 12:06:59 PST 2016
Author: dannyb
Date: Mon Dec 26 14:06:58 2016
New Revision: 290551
URL: http://llvm.org/viewvc/llvm-project?rev=290551&view=rev
Log:
clang-format NewGVN files
Modified:
llvm/trunk/include/llvm/Transforms/Scalar/GVNExpression.h
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
Modified: llvm/trunk/include/llvm/Transforms/Scalar/GVNExpression.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar/GVNExpression.h?rev=290551&r1=290550&r2=290551&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar/GVNExpression.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar/GVNExpression.h Mon Dec 26 14:06:58 2016
@@ -68,8 +68,7 @@ public:
// Compare the expression type for anything but load and store.
// For load and store we set the opcode to zero.
// This is needed for load coercion.
- if (getExpressionType() != ET_Load &&
- getExpressionType() != ET_Store &&
+ if (getExpressionType() != ET_Load && getExpressionType() != ET_Store &&
getExpressionType() != Other.getExpressionType())
return false;
@@ -190,7 +189,7 @@ public:
const auto &OE = cast<BasicExpression>(Other);
return getType() == OE.getType() && NumOperands == OE.NumOperands &&
- std::equal(op_begin(), op_end(), OE.op_begin());
+ std::equal(op_begin(), op_end(), OE.op_begin());
}
virtual hash_code getHashValue() const override {
@@ -220,6 +219,7 @@ class op_inserter
private:
typedef BasicExpression Container;
Container *BE;
+
public:
explicit op_inserter(BasicExpression &E) : BE(&E) {}
explicit op_inserter(BasicExpression *E) : BE(E) {}
@@ -233,7 +233,6 @@ public:
op_inserter &operator++(int) { return *this; }
};
-
class CallExpression final : public BasicExpression {
private:
CallInst *Call;
@@ -245,8 +244,7 @@ public:
}
CallExpression(unsigned NumOperands, CallInst *C, MemoryAccess *DA)
- : BasicExpression(NumOperands, ET_Call), Call(C),
- DefiningAccess(DA) {}
+ : BasicExpression(NumOperands, ET_Call), Call(C), DefiningAccess(DA) {}
void operator=(const CallExpression &) = delete;
CallExpression(const CallExpression &) = delete;
CallExpression() = delete;
@@ -287,8 +285,8 @@ public:
LoadExpression(unsigned NumOperands, LoadInst *L, MemoryAccess *DA)
: LoadExpression(ET_Load, NumOperands, L, DA) {}
- LoadExpression(enum ExpressionType EType, unsigned NumOperands,
- LoadInst *L, MemoryAccess *DA)
+ LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L,
+ MemoryAccess *DA)
: BasicExpression(NumOperands, EType), Load(L), DefiningAccess(DA) {
Alignment = L ? L->getAlignment() : 0;
}
@@ -335,8 +333,7 @@ public:
}
StoreExpression(unsigned NumOperands, StoreInst *S, MemoryAccess *DA)
- : BasicExpression(NumOperands, ET_Store), Store(S),
- DefiningAccess(DA) {}
+ : BasicExpression(NumOperands, ET_Store), Store(S), DefiningAccess(DA) {}
void operator=(const StoreExpression &) = delete;
StoreExpression(const StoreExpression &) = delete;
StoreExpression() = delete;
@@ -374,8 +371,7 @@ public:
return EB->getExpressionType() == ET_AggregateValue;
}
- AggregateValueExpression(unsigned NumOperands,
- unsigned NumIntOperands)
+ AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
: BasicExpression(NumOperands, ET_AggregateValue),
MaxIntOperands(NumIntOperands), NumIntOperands(0),
IntOperands(nullptr) {}
@@ -413,7 +409,7 @@ public:
return false;
const AggregateValueExpression &OE = cast<AggregateValueExpression>(Other);
return NumIntOperands == OE.NumIntOperands &&
- std::equal(int_op_begin(), int_op_end(), OE.int_op_begin());
+ std::equal(int_op_begin(), int_op_end(), OE.int_op_begin());
}
virtual hash_code getHashValue() const override {
@@ -453,7 +449,6 @@ public:
int_op_inserter &operator++(int) { return *this; }
};
-
class PHIExpression final : public BasicExpression {
private:
BasicBlock *BB;
@@ -501,8 +496,7 @@ public:
return EB->getExpressionType() == ET_Variable;
}
- VariableExpression(Value *V)
- : Expression(ET_Variable), VariableValue(V) {}
+ VariableExpression(Value *V) : Expression(ET_Variable), VariableValue(V) {}
void operator=(const VariableExpression &) = delete;
VariableExpression(const VariableExpression &) = delete;
VariableExpression() = delete;
@@ -539,8 +533,7 @@ public:
return EB->getExpressionType() == ET_Constant;
}
- ConstantExpression()
- : Expression(ET_Constant), ConstantValue(NULL) {}
+ ConstantExpression() : Expression(ET_Constant), ConstantValue(NULL) {}
ConstantExpression(Constant *constantValue)
: Expression(ET_Constant), ConstantValue(constantValue) {}
void operator=(const ConstantExpression &) = delete;
Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=290551&r1=290550&r2=290551&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Mon Dec 26 14:06:58 2016
@@ -87,13 +87,13 @@ STATISTIC(NumGVNPhisAllSame, "Number of
// Anchor methods.
namespace llvm {
namespace GVNExpression {
- Expression::~Expression() = default;
- BasicExpression::~BasicExpression() = default;
- CallExpression::~CallExpression() = default;
- LoadExpression::~LoadExpression() = default;
- StoreExpression::~StoreExpression() = default;
- AggregateValueExpression::~AggregateValueExpression() = default;
- PHIExpression::~PHIExpression() = default;
+Expression::~Expression() = default;
+BasicExpression::~BasicExpression() = default;
+CallExpression::~CallExpression() = default;
+LoadExpression::~LoadExpression() = default;
+StoreExpression::~StoreExpression() = default;
+AggregateValueExpression::~AggregateValueExpression() = default;
+PHIExpression::~PHIExpression() = default;
}
}
@@ -140,29 +140,29 @@ struct CongruenceClass {
};
namespace llvm {
- template <> struct DenseMapInfo<const Expression *> {
- static const Expression *getEmptyKey() {
- uintptr_t Val = static_cast<uintptr_t>(-1);
- Val <<= PointerLikeTypeTraits<const Expression *>::NumLowBitsAvailable;
- return reinterpret_cast<const Expression *>(Val);
- }
- static const Expression *getTombstoneKey() {
- uintptr_t Val = static_cast<uintptr_t>(~1U);
- Val <<= PointerLikeTypeTraits<const Expression *>::NumLowBitsAvailable;
- return reinterpret_cast<const Expression *>(Val);
- }
- static unsigned getHashValue(const Expression *V) {
- return static_cast<unsigned>(V->getHashValue());
- }
- static bool isEqual(const Expression *LHS, const Expression *RHS) {
- if (LHS == RHS)
- return true;
- if (LHS == getTombstoneKey() || RHS == getTombstoneKey() ||
- LHS == getEmptyKey() || RHS == getEmptyKey())
- return false;
- return *LHS == *RHS;
- }
- };
+template <> struct DenseMapInfo<const Expression *> {
+ static const Expression *getEmptyKey() {
+ uintptr_t Val = static_cast<uintptr_t>(-1);
+ Val <<= PointerLikeTypeTraits<const Expression *>::NumLowBitsAvailable;
+ return reinterpret_cast<const Expression *>(Val);
+ }
+ static const Expression *getTombstoneKey() {
+ uintptr_t Val = static_cast<uintptr_t>(~1U);
+ Val <<= PointerLikeTypeTraits<const Expression *>::NumLowBitsAvailable;
+ return reinterpret_cast<const Expression *>(Val);
+ }
+ static unsigned getHashValue(const Expression *V) {
+ return static_cast<unsigned>(V->getHashValue());
+ }
+ static bool isEqual(const Expression *LHS, const Expression *RHS) {
+ if (LHS == RHS)
+ return true;
+ if (LHS == getTombstoneKey() || RHS == getTombstoneKey() ||
+ LHS == getEmptyKey() || RHS == getEmptyKey())
+ return false;
+ return *LHS == *RHS;
+ }
+};
} // end namespace llvm
class NewGVN : public FunctionPass {
@@ -240,8 +240,7 @@ public:
bool runOnFunction(Function &F) override;
bool runGVN(Function &F, DominatorTree *DT, AssumptionCache *AC,
- TargetLibraryInfo *TLI, AliasAnalysis *AA,
- MemorySSA *MSSA);
+ TargetLibraryInfo *TLI, AliasAnalysis *AA, MemorySSA *MSSA);
private:
// This transformation requires dominator postdominator info.
@@ -632,8 +631,7 @@ NewGVN::createAggregateValueExpression(I
llvm_unreachable("Unhandled type of aggregate value operation");
}
-const VariableExpression *
-NewGVN::createVariableExpression(Value *V) {
+const VariableExpression *NewGVN::createVariableExpression(Value *V) {
VariableExpression *E = new (ExpressionAllocator) VariableExpression(V);
E->setOpcode(V->getValueID());
return E;
@@ -647,8 +645,7 @@ const Expression *NewGVN::createVariable
return createVariableExpression(Leader);
}
-const ConstantExpression *
-NewGVN::createConstantExpression(Constant *C) {
+const ConstantExpression *NewGVN::createConstantExpression(Constant *C) {
ConstantExpression *E = new (ExpressionAllocator) ConstantExpression(C);
E->setOpcode(C->getValueID());
return E;
@@ -667,8 +664,7 @@ const CallExpression *NewGVN::createCall
// See if we have a congruence class and leader for this operand, and if so,
// return it. Otherwise, return the operand itself.
template <class T>
-Value *NewGVN::lookupOperandLeader(Value *V, const User *U,
- const T &B) const {
+Value *NewGVN::lookupOperandLeader(Value *V, const User *U, const T &B) const {
CongruenceClass *CC = ValueToClass.lookup(V);
if (CC && (CC != InitialClass))
return CC->RepLeader;
@@ -747,8 +743,7 @@ const Expression *NewGVN::performSymboli
if (!LI->isSimple())
return nullptr;
- Value *LoadAddressLeader =
- lookupOperandLeader(LI->getPointerOperand(), I, B);
+ Value *LoadAddressLeader = lookupOperandLeader(LI->getPointerOperand(), I, B);
// Load of undef is undef.
if (isa<UndefValue>(LoadAddressLeader))
return createConstantExpression(UndefValue::get(LI->getType()));
@@ -778,10 +773,8 @@ const Expression *NewGVN::performSymboli
return createCallExpression(CI, nullptr, B);
else if (AA->onlyReadsMemory(CI)) {
MemoryAccess *DefiningAccess = MSSAWalker->getClobberingMemoryAccess(CI);
- return createCallExpression(CI, lookupMemoryAccessEquiv(DefiningAccess),
- B);
- }
- else
+ return createCallExpression(CI, lookupMemoryAccessEquiv(DefiningAccess), B);
+ } else
return nullptr;
}
@@ -1219,7 +1212,8 @@ void NewGVN::processOutgoingEdges(Termin
}
}
-// The algorithm initially places the values of the routine in the INITIAL congruence
+// The algorithm initially places the values of the routine in the INITIAL
+// congruence
// class. The leader of INITIAL is the undetermined value `TOP`.
// When the algorithm has finished, values still in INITIAL are unreachable.
void NewGVN::initializeCongruenceClasses(Function &F) {
@@ -1357,10 +1351,10 @@ void NewGVN::valueNumberInstruction(Inst
}
}
-// This is the main transformation entry point.
+// This is the main transformation entry point.
bool NewGVN::runGVN(Function &F, DominatorTree *_DT, AssumptionCache *_AC,
- TargetLibraryInfo *_TLI, AliasAnalysis *_AA,
- MemorySSA *_MSSA) {
+ TargetLibraryInfo *_TLI, AliasAnalysis *_AA,
+ MemorySSA *_MSSA) {
bool Changed = false;
DT = _DT;
AC = _AC;
@@ -1472,12 +1466,13 @@ bool NewGVN::runGVN(Function &F, Dominat
}
// Delete all unreachable blocks.
- auto UnreachableBlockPred =
- [&](const BasicBlock &BB) { return !ReachableBlocks.count(&BB); };
+ auto UnreachableBlockPred = [&](const BasicBlock &BB) {
+ return !ReachableBlocks.count(&BB);
+ };
for (auto &BB : make_filter_range(F, UnreachableBlockPred)) {
DEBUG(dbgs() << "We believe block " << getBlockName(&BB)
- << " is unreachable\n");
+ << " is unreachable\n");
deleteInstructionsInBlock(&BB);
Changed = true;
}
@@ -1496,8 +1491,7 @@ bool NewGVN::runOnFunction(Function &F)
&getAnalysis<MemorySSAWrapperPass>().getMSSA());
}
-PreservedAnalyses NewGVNPass::run(Function &F,
- AnalysisManager<Function> &AM) {
+PreservedAnalyses NewGVNPass::run(Function &F, AnalysisManager<Function> &AM) {
NewGVN Impl;
// Apparently the order in which we get these results matter for
@@ -1539,8 +1533,7 @@ struct NewGVN::ValueDFS {
// Only one of these will be set.
Value *Val;
Use *U;
- ValueDFS()
- : DFSIn(0), DFSOut(0), LocalNum(0), Val(nullptr), U(nullptr) {}
+ ValueDFS() : DFSIn(0), DFSOut(0), LocalNum(0), Val(nullptr), U(nullptr) {}
bool operator<(const ValueDFS &Other) const {
// It's not enough that any given field be less than - we have sets
@@ -1557,25 +1550,28 @@ struct NewGVN::ValueDFS {
// Each LLVM instruction only produces one value, and thus the lowest-level
// differentiator that really matters for the stack (and what we use as as a
// replacement) is the local dfs number.
- // Everything else in the structure is instruction level, and only affects the
- // order in which we will replace operands of a given instruction.
+ // Everything else in the structure is instruction level, and only affects
+ // the order in which we will replace operands of a given instruction.
//
// For a given instruction (IE things with equal dfsin, dfsout, localnum),
// the order of replacement of uses does not matter.
// IE given,
// a = 5
// b = a + a
- // When you hit b, you will have two valuedfs with the same dfsin, out, and localnum.
+ // When you hit b, you will have two valuedfs with the same dfsin, out, and
+ // localnum.
// The .val will be the same as well.
// The .u's will be different.
- // You will replace both, and it does not matter what order you replace them in
- // (IE whether you replace operand 2, then operand 1, or operand 1, then operand 2).
- // Similarly for the case of same dfsin, dfsout, localnum, but different .val's
+ // You will replace both, and it does not matter what order you replace them
+ // in (IE whether you replace operand 2, then operand 1, or operand 1, then
+ // operand 2).
+ // Similarly for the case of same dfsin, dfsout, localnum, but different
+ // .val's
// a = 5
// b = 6
// c = a + b
- // in c, we will a valuedfs for a, and one for b,with everything the same but
- // .val and .u.
+ // in c, we will a valuedfs for a, and one for b,with everything the same
+ // but .val and .u.
// It does not matter what order we replace these operands in.
// You will always end up with the same IR, and this is guaranteed.
return std::tie(DFSIn, DFSOut, LocalNum, Val, U) <
@@ -1768,7 +1764,6 @@ bool NewGVN::eliminateInstructions(Funct
// overlapping ranges while sorting, as we will never eliminate anything
// with those members, as they don't dominate anything else in our set.
-
bool AnythingReplaced = false;
// Since we are going to walk the domtree anyway, and we can't guarantee the
@@ -1924,8 +1919,7 @@ bool NewGVN::eliminateInstructions(Funct
// If we replaced something in an instruction, handle the patching of
// metadata.
- if (auto *ReplacedInst =
- dyn_cast<Instruction>(MemberUse->get()))
+ if (auto *ReplacedInst = dyn_cast<Instruction>(MemberUse->get()))
patchReplacementInstruction(ReplacedInst, Result);
assert(isa<Instruction>(MemberUse->getUser()));
@@ -1960,4 +1954,3 @@ bool NewGVN::eliminateInstructions(Funct
return AnythingReplaced;
}
-
More information about the llvm-commits
mailing list