-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[GVN][NFC] Match coding standards #128683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As per LLVM coding standards "Variable names should be nouns (as they represent state). The name should be camel case, and start with an upper case letter (e.g. Leader or Boats)."
@llvm/pr-subscribers-llvm-transforms Author: Madhur Amilkanthwar (madhur13490) ChangesAs per LLVM coding standards Full diff: https://github.com/llvm/llvm-project/pull/128683.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 3f306bb52c12a..c3aea6052c178 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -332,19 +332,19 @@ struct llvm::gvn::AvailableValueInBlock {
//===----------------------------------------------------------------------===//
GVNPass::Expression GVNPass::ValueTable::createExpr(Instruction *I) {
- Expression e;
- e.type = I->getType();
- e.opcode = I->getOpcode();
+ Expression E;
+ E.type = I->getType();
+ E.opcode = I->getOpcode();
if (const GCRelocateInst *GCR = dyn_cast<GCRelocateInst>(I)) {
// gc.relocate is 'special' call: its second and third operands are
// not real values, but indices into statepoint's argument list.
// Use the refered to values for purposes of identity.
- e.varargs.push_back(lookupOrAdd(GCR->getOperand(0)));
- e.varargs.push_back(lookupOrAdd(GCR->getBasePtr()));
- e.varargs.push_back(lookupOrAdd(GCR->getDerivedPtr()));
+ E.varargs.push_back(lookupOrAdd(GCR->getOperand(0)));
+ E.varargs.push_back(lookupOrAdd(GCR->getBasePtr()));
+ E.varargs.push_back(lookupOrAdd(GCR->getDerivedPtr()));
} else {
for (Use &Op : I->operands())
- e.varargs.push_back(lookupOrAdd(Op));
+ E.varargs.push_back(lookupOrAdd(Op));
}
if (I->isCommutative()) {
// Ensure that commutative instructions that only differ by a permutation
@@ -352,78 +352,78 @@ GVNPass::Expression GVNPass::ValueTable::createExpr(Instruction *I) {
// numbers. Since commutative operands are the 1st two operands it is more
// efficient to sort by hand rather than using, say, std::sort.
assert(I->getNumOperands() >= 2 && "Unsupported commutative instruction!");
- if (e.varargs[0] > e.varargs[1])
- std::swap(e.varargs[0], e.varargs[1]);
- e.commutative = true;
+ if (E.varargs[0] > E.varargs[1])
+ std::swap(E.varargs[0], E.varargs[1]);
+ E.commutative = true;
}
if (auto *C = dyn_cast<CmpInst>(I)) {
// Sort the operand value numbers so x<y and y>x get the same value number.
CmpInst::Predicate Predicate = C->getPredicate();
- if (e.varargs[0] > e.varargs[1]) {
- std::swap(e.varargs[0], e.varargs[1]);
+ if (E.varargs[0] > E.varargs[1]) {
+ std::swap(E.varargs[0], E.varargs[1]);
Predicate = CmpInst::getSwappedPredicate(Predicate);
}
- e.opcode = (C->getOpcode() << 8) | Predicate;
- e.commutative = true;
- } else if (auto *E = dyn_cast<InsertValueInst>(I)) {
- e.varargs.append(E->idx_begin(), E->idx_end());
+ E.opcode = (C->getOpcode() << 8) | Predicate;
+ E.commutative = true;
+ } else if (auto *IVI = dyn_cast<InsertValueInst>(I)) {
+ E.varargs.append(IVI->idx_begin(), IVI->idx_end());
} else if (auto *SVI = dyn_cast<ShuffleVectorInst>(I)) {
ArrayRef<int> ShuffleMask = SVI->getShuffleMask();
- e.varargs.append(ShuffleMask.begin(), ShuffleMask.end());
+ E.varargs.append(ShuffleMask.begin(), ShuffleMask.end());
} else if (auto *CB = dyn_cast<CallBase>(I)) {
- e.attrs = CB->getAttributes();
+ E.attrs = CB->getAttributes();
}
- return e;
+ return E;
}
GVNPass::Expression GVNPass::ValueTable::createCmpExpr(
unsigned Opcode, CmpInst::Predicate Predicate, Value *LHS, Value *RHS) {
assert((Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) &&
"Not a comparison!");
- Expression e;
- e.type = CmpInst::makeCmpResultType(LHS->getType());
- e.varargs.push_back(lookupOrAdd(LHS));
- e.varargs.push_back(lookupOrAdd(RHS));
+ Expression E;
+ E.type = CmpInst::makeCmpResultType(LHS->getType());
+ E.varargs.push_back(lookupOrAdd(LHS));
+ E.varargs.push_back(lookupOrAdd(RHS));
// Sort the operand value numbers so x<y and y>x get the same value number.
- if (e.varargs[0] > e.varargs[1]) {
- std::swap(e.varargs[0], e.varargs[1]);
+ if (E.varargs[0] > E.varargs[1]) {
+ std::swap(E.varargs[0], E.varargs[1]);
Predicate = CmpInst::getSwappedPredicate(Predicate);
}
- e.opcode = (Opcode << 8) | Predicate;
- e.commutative = true;
- return e;
+ E.opcode = (Opcode << 8) | Predicate;
+ E.commutative = true;
+ return E;
}
GVNPass::Expression
GVNPass::ValueTable::createExtractvalueExpr(ExtractValueInst *EI) {
assert(EI && "Not an ExtractValueInst?");
- Expression e;
- e.type = EI->getType();
- e.opcode = 0;
+ Expression E;
+ E.type = EI->getType();
+ E.opcode = 0;
WithOverflowInst *WO = dyn_cast<WithOverflowInst>(EI->getAggregateOperand());
if (WO != nullptr && EI->getNumIndices() == 1 && *EI->idx_begin() == 0) {
// EI is an extract from one of our with.overflow intrinsics. Synthesize
// a semantically equivalent expression instead of an extract value
// expression.
- e.opcode = WO->getBinaryOp();
- e.varargs.push_back(lookupOrAdd(WO->getLHS()));
- e.varargs.push_back(lookupOrAdd(WO->getRHS()));
- return e;
+ E.opcode = WO->getBinaryOp();
+ E.varargs.push_back(lookupOrAdd(WO->getLHS()));
+ E.varargs.push_back(lookupOrAdd(WO->getRHS()));
+ return E;
}
// Not a recognised intrinsic. Fall back to producing an extract value
// expression.
- e.opcode = EI->getOpcode();
+ E.opcode = EI->getOpcode();
for (Use &Op : EI->operands())
- e.varargs.push_back(lookupOrAdd(Op));
+ E.varargs.push_back(lookupOrAdd(Op));
- append_range(e.varargs, EI->indices());
+ append_range(E.varargs, EI->indices());
- return e;
+ return E;
}
GVNPass::Expression GVNPass::ValueTable::createGEPExpr(GetElementPtrInst *GEP) {
|
nikic
approved these changes
Feb 25, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per LLVM coding standards
"Variable names should be nouns (as they represent state).
The name should be camel case, and start with an upper
case letter (e.g. Leader or Boats)."