fixed code style
This commit is contained in:
@@ -124,7 +124,7 @@ static vector<T>* getCommonElements(const vector<vector<T>>* vectors)
|
||||
}
|
||||
|
||||
|
||||
static map<BBlock*, vector<BBlock*>> findDominators(vector<BBlock*> blocks)
|
||||
static map<BBlock*, vector<BBlock*>> findDominators(const vector<BBlock*>& blocks)
|
||||
{
|
||||
map<BBlock*, vector<BBlock*>> result;
|
||||
|
||||
@@ -133,7 +133,7 @@ static map<BBlock*, vector<BBlock*>> findDominators(vector<BBlock*> blocks)
|
||||
{
|
||||
changed = false;
|
||||
|
||||
for (auto currentBlock : blocks)
|
||||
for (auto& currentBlock : blocks)
|
||||
{
|
||||
auto pred = currentBlock->getPrev();
|
||||
auto prevDominators = new vector<vector<BBlock*>>();
|
||||
@@ -166,7 +166,7 @@ static void renumberBlocks(BBlock* current, int* n, map<int, int>* res, set<BBlo
|
||||
return a->getInstructions()[0]->getInstruction()->getOperator()->lineNumber() > b->getInstructions()[0]->getInstruction()->getOperator()->lineNumber();
|
||||
});
|
||||
|
||||
for (auto i : nextBlocks)
|
||||
for (auto& i : nextBlocks)
|
||||
renumberBlocks(i, n, res, visited);
|
||||
|
||||
(*res)[current->getNumber()] = *n;
|
||||
@@ -214,7 +214,7 @@ static BBlock* findImmediateDominatorsDfsHelper(BBlock* block, BBlock* currentBl
|
||||
if (find(dominators[block].begin(), dominators[block].end(), currentBlock) != dominators[block].end())
|
||||
currentImmediateDominator = currentBlock;
|
||||
|
||||
for (auto nextBlock : currentBlock->getNext())
|
||||
for (auto& nextBlock : currentBlock->getNext())
|
||||
{
|
||||
auto result = findImmediateDominatorsDfsHelper(block, nextBlock, currentImmediateDominator, visited, dominators);
|
||||
|
||||
@@ -239,13 +239,13 @@ static map<BBlock*, BBlock*> findImmediateDominators1(const map<BBlock*, vector<
|
||||
const auto& doms = pair.second;
|
||||
|
||||
BBlock* candidate = NULL;
|
||||
for (auto d : doms)
|
||||
for (auto& d : doms)
|
||||
{
|
||||
if (d == b)
|
||||
continue;
|
||||
|
||||
bool isImmediate = true;
|
||||
for (auto other : doms)
|
||||
for (auto& other : doms)
|
||||
{
|
||||
if (other == b || other == d)
|
||||
continue;
|
||||
@@ -370,7 +370,7 @@ static void getBlocksWithFiFunctions(const vector<BBlock*> blocks, set<BArgument
|
||||
auto block = *worklist.begin();
|
||||
worklist.erase(block);
|
||||
|
||||
for (auto dfBlock : dominatorBorders[block])
|
||||
for (auto& dfBlock : dominatorBorders[block])
|
||||
{
|
||||
if (hasFiFunction.find(dfBlock) == hasFiFunction.end())
|
||||
{
|
||||
@@ -450,7 +450,7 @@ static BArgument* newName(BArgument* var, map<string, int>& counter, map<string,
|
||||
}
|
||||
|
||||
static void renameFiFunctionResultVar(BBlock* block, map<string, int>& counter, map<string, stack<BArgument*>>& stack) {
|
||||
for (auto irBlock : block->getInstructions())
|
||||
for (auto& irBlock : block->getInstructions())
|
||||
{
|
||||
auto instruction = irBlock->getInstruction();
|
||||
if (instruction->getOperation() == CFG_OP::F_CALL && instruction->getArg1() != NULL &&
|
||||
@@ -463,7 +463,7 @@ static void renameFiFunctionResultVar(BBlock* block, map<string, int>& counter,
|
||||
|
||||
static void renameInstructionVars(BBlock* block, map<string, int>& counter, map<string, stack<BArgument*>>& stack)
|
||||
{
|
||||
for (auto irBlock : block->getInstructions())
|
||||
for (auto& irBlock : block->getInstructions())
|
||||
{
|
||||
auto instruction = irBlock->getInstruction();
|
||||
|
||||
@@ -483,7 +483,7 @@ static void renameFiFunctionArgsVar(BBlock* block, map<string, stack<BArgument*>
|
||||
auto size = block->getInstructions().size();
|
||||
auto& instructions = block->getInstructions();
|
||||
|
||||
for (auto i = 0; i < size; i++)
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
auto irBlock = instructions[i];
|
||||
auto instruction = irBlock->getInstruction();
|
||||
@@ -518,9 +518,8 @@ static vector<BBlock*> findBlocksWithValue(map<BBlock*, BBlock*>& iDominators, B
|
||||
vector<BBlock*> result;
|
||||
|
||||
// Проходим по всем элементам map
|
||||
for (auto& pair : iDominators)
|
||||
// Если значение равно x, добавляем ключ в результат
|
||||
if (pair.second == x)
|
||||
for (auto& pair : iDominators)
|
||||
if (pair.second == x) // Если значение равно x, добавляем ключ в результат
|
||||
result.push_back(pair.first);
|
||||
|
||||
return result;
|
||||
@@ -531,10 +530,10 @@ static void renameIR(BBlock* block, map<BBlock*, BBlock*>& iDominators, map<stri
|
||||
renameFiFunctionResultVar(block, counter, stack);
|
||||
renameInstructionVars(block, counter, stack);
|
||||
|
||||
for (auto* successor : block->getNext())
|
||||
for (auto& successor : block->getNext())
|
||||
renameFiFunctionArgsVar(successor, stack);
|
||||
|
||||
for (auto* child : findBlocksWithValue(iDominators, block))
|
||||
for (auto& child : findBlocksWithValue(iDominators, block))
|
||||
renameIR(child, iDominators, counter, stack);
|
||||
|
||||
for (auto& irBlock : block->getInstructions())
|
||||
@@ -567,12 +566,12 @@ void buildIRSSAForm(const map<FuncInfo*, vector<BBlock*>>& fullIR,
|
||||
|
||||
vector<BBlock*> funcIR;
|
||||
|
||||
for (auto i : funcIRConst)
|
||||
for (auto& i : funcIRConst)
|
||||
funcIR.push_back(new BBlock(*i));
|
||||
|
||||
restoreConnections(funcIRConst, funcIR);
|
||||
|
||||
for (auto i : funcIR) {
|
||||
for (auto& i : funcIR) {
|
||||
//printBlock(i);
|
||||
}
|
||||
auto dominators = findDominators(funcIR);
|
||||
@@ -631,7 +630,7 @@ void buildIRSSAForm(const map<FuncInfo*, vector<BBlock*>>& fullIR,
|
||||
map<string, int> count;
|
||||
map<string, stack<BArgument*>> varStack;
|
||||
|
||||
for (auto var : globals)
|
||||
for (auto& var : globals)
|
||||
{
|
||||
count[var->getValue()] = 0;
|
||||
|
||||
@@ -643,7 +642,7 @@ void buildIRSSAForm(const map<FuncInfo*, vector<BBlock*>>& fullIR,
|
||||
|
||||
renameIR(funcIR[0], iDominators, count, varStack);
|
||||
|
||||
for (auto i : funcIR) {
|
||||
for (auto& i : funcIR) {
|
||||
//printBlock(i);
|
||||
}
|
||||
//cout << endl << endl << endl << endl << endl;
|
||||
|
||||
Reference in New Issue
Block a user