-
Notifications
You must be signed in to change notification settings - Fork 1
Juspreet - New Fixpoint Graph Builder - Immutable Only #3
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
base: RefinementTypes
Are you sure you want to change the base?
Juspreet - New Fixpoint Graph Builder - Immutable Only #3
Conversation
…ock Modification and exposed functions
…rrors. Compilation woks.
namespace liquid | ||
{ | ||
|
||
class PhiNodeObligation |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
@shravanrn : PhiNodeObligation removed. A |
|
||
// Ensure that : | ||
// 1) forall blocks in PreviousFinishedBlocks, dominate(blocks, block), forall block in PreviousUnfinishedblocks | ||
for (const auto& previousUnfinishedBlock : previousFinishedBlocks) |
There was a problem hiding this comment.
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) | ||
{ |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably remove this function
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See finishedBlocks
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createPhiNodeAssumingNoFutureBinders
There was a problem hiding this comment.
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); | ||
} | ||
|
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to vector
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
|
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):
|
VariablesEnvironmentImmutable.h
VariablesEnvironmentImmutable.cpp
VariablesEnvLibEImmutable.cpp
startBlock
,getCommonVariables
,validateFinishedAndUnfinishedBlocks
, Phi Node Logic is correctcc : @shravanrn