Skip to content

Conversation

jssandh2
Copy link

@jssandh2 jssandh2 commented Oct 29, 2017

  • Certain fixes in logic in the CFG logic.
  • Reconstruction of code for Liquid Type generation and verification for Immutable Environments.
  • New files :
    • VariablesEnvironmentImmutable.h
    • VariablesEnvironmentImmutable.cpp
    • VariablesEnvLibEImmutable.cpp
  • NOTES :
    • Compilation works. Verified.
  • TODO ( @jssandh2 ) :
    • Verify logic for startBlock, getCommonVariables, validateFinishedAndUnfinishedBlocks, Phi Node Logic is correct
      cc : @shravanrn
  • UPDATES : i) Example added. We should go through the PR and verify the logic.

namespace liquid
{

class PhiNodeObligation
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PhiNodeObligation is a DS used to automatically infer phi nodes for mutable code - not needed here


std::map<std::string, std::set<std::string>> variablesValuesPerBlock;
std::set<std::string> finishedBlocks;
std::map<std::string, std::vector<PhiNodeObligation>> phiNodeObligations;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@jssandh2
Copy link
Author

@shravanrn : PhiNodeObligation removed. A git grep -e phiNodeObligations shows they aren't being used anywhere else. Good catch, because it was only being called for removing a block, which means we would've had a segfault at some point.


// Ensure that :
// 1) forall blocks in PreviousFinishedBlocks, dominate(blocks, block), forall block in PreviousUnfinishedblocks
for (const auto& previousUnfinishedBlock : previousFinishedBlocks)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previousUnfinishedBlock : previousFinishedBlocks is definitely wrong

bool first = true;

for (auto& previousBlock : previousBlocks)
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly dominates

}

ResultType VariablesEnvironmentImmutable::validateFinishedAndUnfinishedBlockStates(
const std::vector<std::string>& previousFinishedBlocks,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably remove this function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upcoming commit may not immediately remove this function. I am first removing redundant variables, and making sure the new logic is not broken because of removals. This will come up next.


bool first = true;

for (auto& previousBlock : previousBlocks)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impose the linear order by checking ancestors - Juspreet


for (auto& previousBlock : previousBlocks)
{
if (first)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before accessing variablesMappingsPerBlock[previousBlock] there should be a check to make sure variablesMappingsPerBlock[previousBlock] is actually filled in... else the order of iteration is broken

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See finishedBlocks

@jssandh2 jssandh2 changed the title Juspreet - New Fixpoint Constraint Builder - Immutable Only Juspreet - New Fixpoint Graph Builder - Immutable Only Nov 27, 2017
return ResultType::Success();
}

ResultType VariablesEnvironmentImmutable::createPhiNodeWithoutCreatedBinders(const std::string& variable, const std::string& mappedVariableName, const FixpointType& type, const std::vector<std::string>& sourceVariableNames, const std::vector<std::string>& previousBlocks)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createPhiNodeAssumingNoFutureBinders

Copy link
Author

@jssandh2 jssandh2 Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reversed this, as this was wrong. We were not using createPhiNodeAssumingNoFutureBinders and were actually using createPhiNodeWithoutCreatedBinders. The functionality wasn't different, as there is a statement check for undeclared variables that we will never go into (save for the sake of for loops).


predecessorTransitionGuards.emplace_back("("s + predecessorEntryGuard + " && "s + transitionGuardName + ")"s);
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw error if more than 2 predecessors

if (!getPredRes.Succeeded) { return getPredRes; }
}

std::vector<std::string> predecessorTransitionGuards;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

predecessors.size() > 2 => Not good.

}

//@TODO:: (juspreet) - The recursive call here isn't clear. Verify.
ResultType VariablesEnvironmentImmutable::getBlockGuard(const std::string& blockName, std::string& blockGuard)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with fixpoint algorithm

}
}

for (const auto& blockName : blockNames)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of block guards

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on the next part of the TODO list - Replacing blockGuards with a purely Fixpoint approach.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on the next part of the TODO list - Replacing blockGuards with a purely Fixpoint approach.

const FunctionBlockGraph& functionBlockGraph;

std::map<std::string, FixpointType> variableTypes;
std::map<std::string, std::map<std::string, std::string>> variablesMappingsPerBlock;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

std::map<std::string, FixpointType> variableTypes;
std::map<std::string, std::map<std::string, std::string>> variablesMappingsPerBlock;

std::map<std::string, std::set<std::string>> variablesValuesPerBlock;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to vector

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to a vector, and added a RefinementUtils function to get a set from a vector. As a result, I'm wondering if this should be changed in the first place ?

}

// Get the name of the variable
std::string VariablesEnvironmentImmutable::GetVariableName(const std::string variableName)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

std::map<std::string, std::set<std::string>> variablesValuesPerBlock;
std::set<std::string> finishedBlocks;

std::set<std::string> outputVariables;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove


std::set<std::string> outputVariables;

std::map<std::string, std::string> cachedBlockGuards;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

ResultType endBlock(const std::string& blockName);

public:
Counter FreshState;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@jssandh2
Copy link
Author

jssandh2 commented Dec 26, 2017

  • i) There is one more part with changes - Part 3 that is WIP and will come as the next commit.
  • ii) The WIP part includes :
    • a) Removal of cachedBlockGuards
    • b) Introduction of Fixpoint Algorithm instead of BlockGuards
    • c) Sanitization of code after Line 391

@jssandh2
Copy link
Author

jssandh2 commented Feb 5, 2018

There are still ~3 things to discuss (though, for the sake of practicality and incremental work, this PR can be merged as it is verified to work):

  • The concept of StrictlyDominates and its future.
    • How will we use it when we use a Fixpoint approach for BlockGuards.
    • What exactly will be its running definition when cycles are possible in the Graph.
  • The strategy for the introduction of the Fixpoint approach.
  • The necessity (or lack thereof) of __block__ + blockName as a blockBinder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants