Commit fc9246e7 authored by Ballabriga Clément's avatar Ballabriga Clément
Browse files

hack degueu pour contourner le probleme de filtering

parent 09f0a077
......@@ -378,6 +378,12 @@ class WPoly {
inline void intersection_assign(const WPoly &src) {
WPoly copie = src;
combine(copie, true);
elm::cout << "raw inter: ";
fflush(stdout); poly.minimized_constraints().print(); fflush(stdout);
elm::cout << "\n";
elm::cout << "raw inter: ";
fflush(stdout); copie.poly.minimized_constraints().print(); fflush(stdout);
elm::cout << "\n";
poly.intersection_assign(copie.poly);
}
......
......@@ -226,26 +226,32 @@ bool PPLDomain::equals(const PPLDomain &b) const {
* First, attempt to show that the states are different using quick checks.
*/
if (poly.variable_count() != b.poly.variable_count()) {
cout << "c est pas egal pcq: pas le meme nombre de variables" << endl;
return false;
}
if (compare_reg != b.compare_reg) {
cout << "c est pas egal pcq: pas le meme compare reg" << endl;
return false;
}
if (compare_op != b.compare_op) {
cout << "c est pas egal pcq: pas le meme compare op" << endl;
return false;
}
if (idmap.count() != b.idmap.count()) {
cout << "c est pas egal pcq: pas le meme idmap count" << endl;
return false;
}
if (victims != b.victims) {
cout << "c est pas egal pcq: pas le meme victim map" << endl;
return false;
}
if (bounds != b.bounds) {
cout << "c est pas egal pcq: pas le meme bounds" << endl;
return false;
}
......@@ -261,21 +267,24 @@ bool PPLDomain::equals(const PPLDomain &b) const {
if ((p.fst.getType() == Ident::ID_MEM_VAL) || (p.fst.getType() == Ident::ID_MEM_ADDR) || (p.fst.getType() == Ident::ID_MEM_VAL_INPUT)) {
continue;
}
cout << "expect: " << p.fst << endl;
expectedVarCount++;
}
_doUnify(l, r, true);
if ((l.idmap.count() != expectedVarCount) || (r.idmap.count() != expectedVarCount)) {
if ((l.idmap.count() != expectedVarCount)) {
/* There was some unmatched registers */
cout << "c est pas egal pcq: different ensemble de registres" << endl;
return false;
}
/* TODO
if (l.poly != r.poly) {
cout << "c est pas egal pcq: poly pas egal (reg)" << endl;
return false;
}
*/
/*
* At this point we are almost sure that the states are equal. We do a full unification (costly) to detect if the states are equal.
*/
......@@ -285,10 +294,12 @@ bool PPLDomain::equals(const PPLDomain &b) const {
if ((l.idmap.count() != idmap.count()) || (r.idmap.count() != b.idmap.count())) {
/* There was some unmatched memory locations */
cout << "c est pas egal pcq: different ensemble de memory locations" << endl;
return false;
}
if (l.poly != r.poly) {
cout << "c est pas egal pcq: poly pas egal (mem)" << endl;
return false;
}
......@@ -515,6 +526,8 @@ bound_t PPLDomain::getLoopBound(int loopId) const {
PPLDomain PPLDomain::onLoopExitLinear(int loop, const PPLDomain &bound) const {
PPLManager::t s_out = *this;
cout << "before onLoopExitLinear: " << s_out << endl;
cout << "bound: " << bound << endl;
Ident id(loop, Ident::ID_LOOP);
ASSERT(s_out.hasIdent(id)); /* You are supposed to be already inside the loop when you call onLoopExit() */
WVar v = s_out.getVar(id);
......@@ -541,6 +554,7 @@ PPLDomain PPLDomain::onLoopExitLinear(int loop, const PPLDomain &bound) const {
s_out.poly.intersection_assign(copy.poly);
s_out.varKill(v);
cout << "after onLoopExitLinear: " << s_out << endl;
return s_out;
}
......@@ -593,6 +607,8 @@ PPLDomain PPLDomain::onBranch(bool taken) const {
cout << "Filtering, compare_reg is: " << compare_reg << ", compare_op is: " << compare_op << ", taken=" << taken
<< endl;
#endif
switch (this_op) {
case sem::NE: {
WPoly poly2 = res.poly;
......@@ -1125,9 +1141,15 @@ PPLDomain PPLDomain::onMerge(const PPLDomain &r, bool widen) const {
PPLDomain r1 = r;
_doUnify(l1, r1);
for (int i = 0; i < r1.bounds.length(); i++)
l1.setBound(i, r1.getBound(i));
l1.poly.poly_hull_assign(r1.poly);
if (widen)
l1.poly.bounded_H79_extrapolation_assign(r1.poly);
l1.doFinalizeUpdate();
for (int i = 0; i < r1.bounds.length(); i++)
l1.setBound(i, r1.getBound(i));
return l1;
#ifdef POLY_DEBUG
cout << "Joined state:" << endl;
......@@ -1137,8 +1159,6 @@ PPLDomain PPLDomain::onMerge(const PPLDomain &r, bool widen) const {
exit(0);
#ifdef TODO
// cout << "before " << (widen ? "widening" : "join") << ", l= " << l1.getConsCount() << " r=" << r1.getConsCount() << endl;
for (int i = 0; i < r1.bounds.length(); i++)
l1.setBound(i, r1.getBound(i));
l1.poly.poly_hull_assign(r1.poly);
if (widen) {
......@@ -2185,32 +2205,41 @@ void PPLDomain::_doUnify(PPLDomain &l1, PPLDomain &r1, bool noPtr) const {
cout << r1;
#endif
WPoly inter = l1.poly;
inter.intersection_assign(r1.poly);
Ident cmp(16, Ident::ID_REG);
if (!noPtr) {
inter.intersection_assign(r1.poly);
}
MyHTable<guid_t,guid_t> rename;
/*
cout << "Inter: " << inter << endl;
if (!noPtr) {
ASSERT(!inter.is_empty());
}
*/
for (MyHTable<Ident, guid_t, HashIdent>::PairIterator it = l1.idmap.getPairIter(); it; it++) {
for (MyHTable<Ident, guid_t, HashIdent>::PairIterator it2 = r1.idmap.getPairIter(); it2; it2++) {
// Memory variables substitution
if (((*it).fst.getType() == Ident::ID_MEM_ADDR) && ((*it2).fst.getType() == Ident::ID_MEM_ADDR)) {
WVar x1((*it).snd);
WVar x2((*it2).snd);
if ((x1.guid() == x2.guid()) ||
inter.relation_with(x1 == x2).implies(PPL::Poly_Con_Relation::is_included())) {
// cout << "Identified " << x1 << " with " << x2 << endl;
WVar x1v = l1.getVar(Ident((*it).fst.getId(), Ident::ID_MEM_VAL));
WVar x2v = r1.getVar(Ident((*it2).fst.getId(), Ident::ID_MEM_VAL));
rename.add(x1.guid(), x2.guid());
rename.add(x1v.guid(), x2v.guid());
//cout << "[A] mapping " << x1.guid() << " to " << x2.guid() << endl;
//cout << "[V] mapping " << x1v.guid() << " to " << x2v.guid() << endl;
}
}
}
if (!noPtr)
for (MyHTable<Ident, guid_t, HashIdent>::PairIterator it2 = r1.idmap.getPairIter(); it2; it2++) {
// Memory variables substitution
if (((*it).fst.getType() == Ident::ID_MEM_ADDR) && ((*it2).fst.getType() == Ident::ID_MEM_ADDR)) {
WVar x1((*it).snd);
WVar x2((*it2).snd);
if ((x1.guid() == x2.guid()) ||
(!inter.is_empty() && inter.relation_with(x1 == x2).implies(PPL::Poly_Con_Relation::is_included()))) {
cout << "Identified " << x1 << " with " << x2 << endl;
WVar x1v = l1.getVar(Ident((*it).fst.getId(), Ident::ID_MEM_VAL));
WVar x2v = r1.getVar(Ident((*it2).fst.getId(), Ident::ID_MEM_VAL));
rename.add(x1.guid(), x2.guid());
rename.add(x1v.guid(), x2v.guid());
//cout << "[A] mapping " << x1.guid() << " to " << x2.guid() << endl;
//cout << "[V] mapping " << x1v.guid() << " to " << x2v.guid() << endl;
}
}
}
if (((*it).fst.getType() != Ident::ID_MEM_ADDR) && ((*it).fst.getType() != Ident::ID_MEM_VAL))
if (r1.idmap.has1((*it).fst)) {
rename.add((*it).snd, r1.idmap.find1((*it).fst));
//cout << "[R] mapping " << (*it).snd << " to " << r1.idmap.find1((*it).fst) << endl;
// cout << "[R] mapping " << (*it).snd << " to " << r1.idmap.find1((*it).fst) << endl;
}
}
......
......@@ -65,28 +65,34 @@ PolyAnalysis::state_t PolyAnalysis::processHeader(ai::CFGGraph &graph, MyHTable<
#endif
//state_t oldState = headerState[header->id()];
#ifndef LINBOUND
bound_t bound = backState.getLoopBound(header->id());
backState.setBound(header->id(), bound);
#endif
#ifdef LINBOUND
PPLDomain linearBound = backState.getLinearExpr(Ident(header->id(), Ident::ID_LOOP));
backState.setLinBound(header->id(), linearBound);
#endif
#ifdef POLY_DEBUG
cout << "ITERATION: " << int(bound) << endl;
#endif
/*
#ifndef LINBOUND
if ((MAX_ITERATION(header) != bound_t::UNBOUNDED) &&
((MAX_ITERATION(header) < bound) || (bound == bound_t::UNBOUNDED)))
MAX_ITERATION(header) = bound;
*/
#endif
if (!lb.hasKey(header->id()))
lb[header->id()] = PPLDomain();
#ifdef LINBOUND
const PPLDomain &oldBound = lb[header->id()];
lb[header->id()] = oldBound.onMerge(linearBound, false);
#endif
headerState[header->id()] = man.widening(backState, headerState[header->id()]);
#ifdef POLY_DEBUG
......@@ -331,10 +337,13 @@ void PolyAnalysis::processBB(PPLManager *man, ai::CFGGraph &graph, MyHTable<int,
* FIXME: should be bound = s.getLoopBound(bb->id()) but we need to fix the widening to make it work
*/
int bound = edgeState.getBound(bb->id());
#ifdef LINBOUND
PPLDomain linBound = edgeState.getLinBound(bb->id());
#ifdef POLY_DEBUG
#endif
cout << "Bound on loop exit: " << bound << endl;
#ifdef POLY_DEBUG
#endif
#ifdef LINBOUND
if (!linBound.isBottom()) {
edgeState = edgeState.onLoopExitLinear(bb->id(), linBound);
if (edgeState.isBottom())
......@@ -343,14 +352,16 @@ void PolyAnalysis::processBB(PPLManager *man, ai::CFGGraph &graph, MyHTable<int,
#ifdef POLY_DEBUG
cout << "linbound for " << bb->id() << " is " << linBound << endl;
#endif
/*
#endif
#ifndef LINBOUND
if (bound >= 0) {
edgeState = edgeState.onLoopExit(bb->id(), bound);
if (edgeState.isBottom()) {
continue;
}
}
*/
#endif
}
edgeState.doFinalizeUpdate();
ana.check(*e, edgeState);
......@@ -503,6 +514,7 @@ void PolyAnalysis::processWorkSpace(WorkSpace *ws) {
MyHTable<int, PPLDomain> bounds;
MyHTable<int, int> static_bounds;
processCFG(*entry, dummy, bounds, true /* is entry */, false /* summarize */);
#ifdef LINBOUND
cout << "PARAMETRIC LOOP BOUNDS: " << endl;
for (MyHTable<int, PPLDomain>::PairIterator it(bounds); it; it++) {
cout << "linear bound expr for (" << (*it).fst << "): " << (*it).snd << endl;
......@@ -538,6 +550,23 @@ void PolyAnalysis::processWorkSpace(WorkSpace *ws) {
}
delete _orders[(*iter2)->index()];
}
#else
cout << "LOOP BOUNDS: " << endl;
for (CFGCollection::Iter iter2(coll); iter2; iter2++) {
for (CFG::BlockIter iter((*iter2)->blocks()); iter; iter++) {
Block *bb = (*iter);
if (LOOP_HEADER(bb)) {
cout << "[" << (*iter2)->name() << "]"
<< "MAX_ITERATION(" << bb->id() << ") = " << MAX_ITERATION(bb) << endl;
/*
cout << "[" << (*iter2)->name() << "]"
<< "TOTAL_ITERATION(" << bb->id() << ") = " << TOTAL_ITERATION(bb) << endl;
*/
}
}
delete _orders[(*iter2)->index()];
}
#endif
}
} // namespace poly
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment