Analysis: add info to delete useless data 22/17222/2
Calixte DENIZET [Fri, 18 Sep 2015 15:34:15 +0000 (17:34 +0200)]
Change-Id: Ie7027bb1b65ec6cb3ee3387dac51826346914698

18 files changed:
scilab/modules/ast/includes/analysis/AnalysisVisitor.hxx
scilab/modules/ast/includes/analysis/data/Block.hxx
scilab/modules/ast/includes/analysis/data/DataManager.hxx
scilab/modules/ast/includes/analysis/data/FunctionBlock.hxx
scilab/modules/ast/includes/ast/debugvisitor.hxx
scilab/modules/ast/src/cpp/analysis/AnalysisVisitor.cpp
scilab/modules/ast/src/cpp/analysis/Block.cpp
scilab/modules/ast/src/cpp/analysis/CeilAnalyzer.cpp
scilab/modules/ast/src/cpp/analysis/CompleteMacroSignature.cpp
scilab/modules/ast/src/cpp/analysis/DataManager.cpp
scilab/modules/ast/src/cpp/analysis/FunctionBlock.cpp
scilab/modules/ast/src/cpp/analysis/MemInitAnalyzer.cpp
scilab/modules/ast/src/cpp/analysis/SizeAnalyzer.cpp
scilab/modules/ast/src/cpp/analysis/TypeofAnalyzer.cpp
scilab/modules/ast/src/cpp/analysis/VisitAssignExp.cpp
scilab/modules/ast/src/cpp/analysis/VisitIfExp.cpp
scilab/modules/ast/src/cpp/analysis/VisitOpExp.cpp
scilab/modules/ast/src/cpp/ast/debugvisitor.cpp

index cfef88d..d7b248f 100644 (file)
@@ -307,7 +307,7 @@ private:
     }
 
     template<TIType (F)(GVN &, const TIType &, const TIType &)>
-    inline TIType checkEWBinOp(TIType & LT, TIType & RT, const Result & LR, const Result & RR, bool & safe, int & tempId)
+    inline TIType checkEWBinOp(TIType & LT, TIType & RT, const Result & LR, const Result & RR, bool & safe, int & tempId, ast::Exp * Lexp, ast::Exp * Rexp)
     {
         TIType resT = F(getGVN(), LT, RT);
         if (resT.hasInvalidDims())
@@ -329,7 +329,7 @@ private:
             safe = true;
         }
 
-        tempId = getTmpIdForEWOp(resT, LR, RR);
+        tempId = getTmpIdForEWOp(resT, LR, RR, Lexp, Rexp);
 
         if (resT.isscalar())
         {
@@ -343,7 +343,7 @@ private:
 
     // get temp id for an element-wise operation
     // A + (B + 1) => B+1 is a temp, A is not and we can reuse the temp to put the result of A + (B+1)
-    int getTmpIdForEWOp(const TIType & resT, const Result & LR, const Result & RR);
+    int getTmpIdForEWOp(const TIType & resT, const Result & LR, const Result & RR, ast::Exp * Lexp, ast::Exp * Rexp);
     void visitArguments(const std::wstring & name, const unsigned int lhs, const TIType & calltype, ast::CallExp & e, const ast::exps_t & args);
 
     void visit(ast::SelectExp & e);
@@ -406,7 +406,7 @@ private:
         logger.log(L"WhileExp", e.getLocation());
         loops.push(&e);
         e.getTest().accept(*this);
-        dm.releaseTmp(getResult().getTempId());
+        dm.releaseTmp(getResult().getTempId(), &e.getTest());
         e.getBody().accept(*this);
         loops.pop();
     }
index a553b97..c157f7d 100644 (file)
@@ -14,7 +14,6 @@
 #define __BLOCK_HXX__
 
 #include <iostream>
-#include <map>
 #include <vector>
 
 #include "allexp.hxx"
@@ -114,7 +113,7 @@ public:
 
     virtual void addLocal(const symbol::Symbol & sym, const TIType & type, const bool isIntIterator);
     virtual int getTmpId(const TIType & type, const bool isIntIterator);
-    virtual void releaseTmp(const int id);
+    virtual void releaseTmp(const int id, ast::Exp * exp);
     virtual Info & addRead(const symbol::Symbol & sym, ast::Exp * exp);
     virtual Info & addWrite(const symbol::Symbol & sym, const TIType & Rtype, ast::Exp * exp);
     virtual Info & addDefine(const symbol::Symbol & sym, const TIType & Rtype, const bool isAnInt, ast::Exp * exp);
index a712384..78028a7 100644 (file)
@@ -64,7 +64,7 @@ public:
     void addGlobal(const symbol::Symbol & sym);
     void registerData(Data * _data, int line = 0, char * file = nullptr);
     int getTmpId(const TIType & type, const bool isAnInt);
-    void releaseTmp(const int id);
+    void releaseTmp(const int id, ast::Exp * exp);
     Info & read(const symbol::Symbol & sym, ast::Exp * exp);
     Info & write(const symbol::Symbol & sym, const TIType & Rtype, ast::Exp * exp);
     Info & define(const symbol::Symbol & sym, const TIType & Rtype, const bool isAnInt, ast::Exp * exp);
index d34bbbc..a932761 100644 (file)
@@ -148,7 +148,7 @@ public:
     Block * getDefBlock(const symbol::Symbol & sym, tools::SymbolMap<Info>::iterator & it, const bool global) override;
     void addLocal(const symbol::Symbol & sym, const TIType & type, const bool isAnInt) override;
     int getTmpId(const TIType & type, const bool isAnInt) override;
-    void releaseTmp(const int id) override;
+    void releaseTmp(const int id, ast::Exp * exp) override;
 
     bool addIn(const TITypeSignatureTuple & tuple, const std::vector<GVN::Value *> & values);
     void setGlobals(const tools::SymbolOrdSet & v);
index dd594be..62dda71 100644 (file)
@@ -27,7 +27,7 @@ namespace ast
 class EXTERN_AST DebugVisitor : public GenVisitor<const_kind>
 {
 public:
-    DebugVisitor(std::wostream & my_ostr = std::wcerr) : ostr(&my_ostr) { }
+    DebugVisitor(std::wostream & my_ostr = std::wcerr, const bool _printDecoration = false) : ostr(&my_ostr), printDecoration(_printDecoration) { }
 
     /** \name Visit Matrix Expressions nodes.
      ** \{ */
@@ -145,10 +145,12 @@ public:
     }
 
 protected:
+
     std::wostream * ostr;
+    const bool printDecoration;
 
 private:
-    
+
     void DEBUG_START_NODE(const ast::Ast & e);
     void DEBUG_END_NODE(void);
     void DEBUG(const std::wstring& str);
index 0ef36d2..8da7348 100644 (file)
@@ -277,9 +277,11 @@ void AnalysisVisitor::visitArguments(const std::wstring & name, const unsigned i
             multipleLHS.emplace_back(type, tempId);
         }
 
+        auto i = args.begin();
         for (const auto & resarg : resargs)
         {
-            getDM().releaseTmp(resarg.getTempId());
+            getDM().releaseTmp(resarg.getTempId(), *i);
+            ++i;
         }
     }
     else if (lhs == 1)
@@ -296,9 +298,11 @@ void AnalysisVisitor::visitArguments(const std::wstring & name, const unsigned i
         if (tempId == -1)
         {
             tempId = getDM().getTmpId(out[0], false);
+            auto i = args.begin();
             for (const auto & resarg : resargs)
             {
-                getDM().releaseTmp(resarg.getTempId());
+                getDM().releaseTmp(resarg.getTempId(), *i);
+                ++i;
             }
         }
 
@@ -308,7 +312,7 @@ void AnalysisVisitor::visitArguments(const std::wstring & name, const unsigned i
     }
 }
 
-int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, const Result & RR)
+int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, const Result & RR, ast::Exp * Lexp, ast::Exp * Rexp)
 {
     int tempId = -1;
     if (resT.isknown() && resT.ismatrix())
@@ -333,7 +337,7 @@ int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, con
                         else
                         {
                             tempId = getDM().getTmpId(resT, false);
-                            getDM().releaseTmp(Rid);
+                            getDM().releaseTmp(Rid, Rexp);
                         }
                     }
                     else
@@ -341,17 +345,17 @@ int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, con
                         if (resT == LT)
                         {
                             tempId = Lid;
-                            getDM().releaseTmp(Rid);
+                            getDM().releaseTmp(Rid, Rexp);
                         }
                         else if (Rid != -1 && resT == RT)
                         {
                             tempId = Rid;
-                            getDM().releaseTmp(Lid);
+                            getDM().releaseTmp(Lid, Lexp);
                         }
                         else
                         {
                             tempId = getDM().getTmpId(resT, false);
-                            getDM().releaseTmp(Lid);
+                            getDM().releaseTmp(Lid, Lexp);
                         }
                     }
                 }
@@ -370,15 +374,15 @@ int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, con
                         else if (Lid != -1 && resT == LT)
                         {
                             tempId = Lid;
-                            getDM().releaseTmp(Rid);
+                            getDM().releaseTmp(Rid, Rexp);
                         }
                         else
                         {
                             tempId = getDM().getTmpId(resT, false);
-                            getDM().releaseTmp(Rid);
+                            getDM().releaseTmp(Rid, Rexp);
                         }
                     }
-                    getDM().releaseTmp(Lid);
+                    getDM().releaseTmp(Lid, Lexp);
                 }
             }
             else
@@ -398,15 +402,15 @@ int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, con
                         else if (Rid != -1 && resT == RT)
                         {
                             tempId = Rid;
-                            getDM().releaseTmp(Lid);
+                            getDM().releaseTmp(Lid, Lexp);
                         }
                         else
                         {
                             tempId = getDM().getTmpId(resT, false);
-                            getDM().releaseTmp(Lid);
+                            getDM().releaseTmp(Lid, Lexp);
                         }
                     }
-                    getDM().releaseTmp(Rid);
+                    getDM().releaseTmp(Rid, Rexp);
                 }
                 else
                 {
@@ -419,7 +423,7 @@ int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, con
                         else
                         {
                             tempId = getDM().getTmpId(resT, false);
-                            getDM().releaseTmp(Lid);
+                            getDM().releaseTmp(Lid, Lexp);
                         }
                     }
                     else
@@ -431,14 +435,14 @@ int AnalysisVisitor::getTmpIdForEWOp(const TIType & resT, const Result & LR, con
                         else if (Lid != -1 && resT == LT)
                         {
                             tempId = Lid;
-                            getDM().releaseTmp(Rid);
+                            getDM().releaseTmp(Rid, Rexp);
                         }
                         else
                         {
                             tempId = getDM().getTmpId(resT, false);
-                            getDM().releaseTmp(Rid);
+                            getDM().releaseTmp(Rid, Rexp);
                         }
-                        getDM().releaseTmp(Lid);
+                        getDM().releaseTmp(Lid, Lexp);
                     }
                 }
             }
index a80bf2d..a40f509 100644 (file)
@@ -61,7 +61,6 @@ void Block::clone(Info & info, const symbol::Symbol & sym, ast::Exp * exp)
         info.data = new Data(info.isknown(), sym);
         dm->registerData(info.data);//, __LINE__, __FILE__);
         clone(sym, exp);
-        exp->getDecorator().cloneData = true;
     }
 }
 
@@ -204,7 +203,10 @@ Info & Block::addWrite(const symbol::Symbol & sym, const TIType & Rtype, ast::Ex
         info.exists = true;
     }
 
-    clone(info, sym, exp);
+    if (!info.type.isscalar())
+    {
+        clone(info, sym, exp);
+    }
     info.W = true;
 
     return info;
@@ -228,11 +230,11 @@ int Block::getTmpId(const TIType & type, const bool isAnInt)
     return -1;
 }
 
-void Block::releaseTmp(const int id)
+void Block::releaseTmp(const int id, ast::Exp * exp)
 {
     if (parent)
     {
-        parent->releaseTmp(id);
+        parent->releaseTmp(id, exp);
     }
 }
 
@@ -363,6 +365,7 @@ Info & Block::putAndClear(const symbol::Symbol & sym, ast::Exp * exp)
             if (info.data->hasOneOwner())
             {
                 info.cleared = true;
+                exp->getDecorator().deleteData = true;
                 info.local = Info::Local::INFO_TRUE;
                 return info;
             }
@@ -384,6 +387,7 @@ Info & Block::putAndClear(const symbol::Symbol & sym, ast::Exp * exp)
                 Info & i = addSym(sym, info);
                 info.data = old;
                 i.cleared = true;
+                exp->getDecorator().deleteData = true;
                 i.local = Info::Local::INFO_TRUE;
                 return i;
             }
index aba94ce..e2cee64 100644 (file)
@@ -52,7 +52,7 @@ bool CeilAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, as
             }
             else
             {
-                visitor.getDM().releaseTmp(R.getTempId());
+                visitor.getDM().releaseTmp(R.getTempId(), *first);
             }
         }
     }
index 7d8a9c9..1cb817d 100644 (file)
@@ -50,7 +50,7 @@ const MacroOut * CompleteMacroSignature::analyze(AnalysisVisitor & visitor, cons
 
         fblock.getExp()->accept(visitor);
         dm.finalizeBlock();
-        //std::wcerr << fblock << std::endl;
+        std::wcerr << fblock << std::endl;
         visitor.emitFunctionBlock(fblock);
         outMap.emplace_back(fblock.getConstraints(), fblock.getGlobalConstants(), fblock.getOuts());
 
index c7cda6f..0352c93 100644 (file)
@@ -88,9 +88,9 @@ int DataManager::getTmpId(const TIType & type, const bool isAnInt)
     return current->getTmpId(type, isAnInt);
 }
 
-void DataManager::releaseTmp(const int id)
+void DataManager::releaseTmp(const int id, ast::Exp * exp)
 {
-    current->releaseTmp(id);
+    current->releaseTmp(id, exp);
 }
 
 Info & DataManager::read(const symbol::Symbol & sym, ast::Exp * exp)
index 1b47f3e..9f74e8e 100644 (file)
@@ -177,9 +177,18 @@ int FunctionBlock::getTmpId(const TIType & type, const bool isAnInt)
     return tempManager.getTmp(type, isAnInt);
 }
 
-void FunctionBlock::releaseTmp(const int id)
+void FunctionBlock::releaseTmp(const int id, ast::Exp * exp)
 {
     tempManager.releaseTmp(id);
+    if (id != -1 && exp)
+    {
+        const TIType & ty = exp->getDecorator().getResult().getType();
+        // TODO: handle other complex types like mlist, struct, ...
+        if (!ty.isscalar() || ty.type == TIType::STRING || ty.type == TIType::POLYNOMIAL)
+        {
+            exp->getDecorator().deleteData = true;
+        }
+    }
 }
 
 void FunctionBlock::setInOut(MacroDef * macrodef, const unsigned int rhs, const std::vector<TIType> & _in)
@@ -274,7 +283,7 @@ std::wostream & operator<<(std::wostream & out, const FunctionBlock & fblock)
     //ast::PrintVisitor pv(out, true, false);
     //fblock.exp->accept(pv);
 
-    ast::DebugVisitor dv(out);
+    ast::DebugVisitor dv(out, true);
     fblock.exp->accept(dv);
 
     return out;
index 30e08e0..f58a4b4 100644 (file)
@@ -26,10 +26,10 @@ bool MemInitAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs,
 
         first->accept(visitor);
         Result R1 = visitor.getResult();
-        visitor.getDM().releaseTmp(R1.getTempId());
+        visitor.getDM().releaseTmp(R1.getTempId(), first);
         second->accept(visitor);
         Result & R2 = visitor.getResult();
-        visitor.getDM().releaseTmp(R2.getTempId());
+        visitor.getDM().releaseTmp(R2.getTempId(), second);
         double val;
         SymbolicDimension rows, cols;
         bool empty = false;
index 2440cd1..b0c5680 100644 (file)
@@ -45,7 +45,7 @@ bool SizeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, as
     Result & res = visitor.getResult();
     if (!res.getType().ismatrix())
     {
-        visitor.getDM().releaseTmp(res.getTempId());
+        visitor.getDM().releaseTmp(res.getTempId(), first);
         return false;
     }
 
@@ -83,7 +83,7 @@ bool SizeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, as
                     }
                     else
                     {
-                        visitor.getDM().releaseTmp(res.getTempId());
+                        visitor.getDM().releaseTmp(res.getTempId(), first);
                         return false;
                     }
                 }
@@ -105,20 +105,20 @@ bool SizeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, as
                     }
                     else
                     {
-                        visitor.getDM().releaseTmp(res.getTempId());
+                        visitor.getDM().releaseTmp(res.getTempId(), first);
                         return false;
                     }
                 }
             }
             else
             {
-                visitor.getDM().releaseTmp(res.getTempId());
+                visitor.getDM().releaseTmp(res.getTempId(), first);
                 return false;
             }
             break;
         }
         default:
-            visitor.getDM().releaseTmp(res.getTempId());
+            visitor.getDM().releaseTmp(res.getTempId(), first);
             return false;
     }
 
index baa4d92..6bb196d 100644 (file)
@@ -45,7 +45,7 @@ bool TypeofAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs,
     }
     else
     {
-        visitor.getDM().releaseTmp(visitor.getResult().getTempId());
+        visitor.getDM().releaseTmp(visitor.getResult().getTempId(), arg);
         return false;
     }
 }
index 7e6cb22..8d5cdd3 100644 (file)
@@ -61,7 +61,7 @@ void AnalysisVisitor::visit(ast::AssignExp & e)
             Info & info = getDM().define(sym, RR.getType(), RR.isAnInt(), &e);
             info.getConstant() = RR.getConstant();
             e.getDecorator().safe = true;
-            getDM().releaseTmp(RR.getTempId());
+            getDM().releaseTmp(RR.getTempId(), &e.getRightExp());
         }
     }
     else if (e.getLeftExp().isCallExp()) // A(12) = ...
@@ -79,7 +79,7 @@ void AnalysisVisitor::visit(ast::AssignExp & e)
             {
                 e.getDecorator().safe = (RR.getType() == getResult().getType());
             }
-            getDM().releaseTmp(RR.getTempId());
+            getDM().releaseTmp(RR.getTempId(), &e.getRightExp());
         }
     }
     else if (e.getLeftExp().isAssignListExp()) // [A, B] = ...
index 86595bf..6335044 100644 (file)
@@ -157,7 +157,7 @@ void AnalysisVisitor::visit(ast::IfExp & e)
     {
         dm.addBlock(Block::EXCLUSIVE, &e);
         e.getTest().accept(*this);
-        dm.releaseTmp(getResult().getTempId());
+        dm.releaseTmp(getResult().getTempId(), &e.getTest());
         dm.addBlock(Block::NORMAL, &e.getThen());
         e.getThen().accept(*this);
         dm.finalizeBlock();
index af365c2..9ce29ae 100644 (file)
@@ -25,10 +25,12 @@ void AnalysisVisitor::visit(ast::OpExp & e)
     TIType resT(getGVN());
     int tempId = -1;
     bool safe = false;
+    ast::Exp & Lexp = e.getLeft();
+    ast::Exp & Rexp = e.getRight();
 
-    e.getLeft().accept(*this);
+    Lexp.accept(*this);
     Result LR = getResult();
-    e.getRight().accept(*this);
+    Rexp.accept(*this);
     Result & RR = getResult();
     if (LR.getType().isknown() && RR.getType().isknown())
     {
@@ -41,12 +43,12 @@ void AnalysisVisitor::visit(ast::OpExp & e)
             {
                 case ast::OpExp::plus :
                 {
-                    resT = checkEWBinOp<_check_plus>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_plus>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::minus:
                 {
-                    resT = checkEWBinOp<_check_minus>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_minus>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::times:
@@ -71,8 +73,8 @@ void AnalysisVisitor::visit(ast::OpExp & e)
                     }
 
                     tempId = dm.getTmpId(resT, false);
-                    dm.releaseTmp(LR.getTempId());
-                    dm.releaseTmp(RR.getTempId());
+                    dm.releaseTmp(LR.getTempId(), &e);
+                    dm.releaseTmp(RR.getTempId(), &e);
 
                     break;
                 }
@@ -98,8 +100,8 @@ void AnalysisVisitor::visit(ast::OpExp & e)
                     }
 
                     tempId = dm.getTmpId(resT, false);
-                    dm.releaseTmp(LR.getTempId());
-                    dm.releaseTmp(RR.getTempId());
+                    dm.releaseTmp(LR.getTempId(), &e);
+                    dm.releaseTmp(RR.getTempId(), &e);
                     break;
                 }
                 case ast::OpExp::ldivide:
@@ -124,8 +126,8 @@ void AnalysisVisitor::visit(ast::OpExp & e)
                     }
 
                     tempId = dm.getTmpId(resT, false);
-                    dm.releaseTmp(LR.getTempId());
-                    dm.releaseTmp(RR.getTempId());
+                    dm.releaseTmp(LR.getTempId(), &e);
+                    dm.releaseTmp(RR.getTempId(), &e);
                     break;
                 }
                 case ast::OpExp::power:
@@ -150,23 +152,23 @@ void AnalysisVisitor::visit(ast::OpExp & e)
                     }
 
                     tempId = dm.getTmpId(resT, false);
-                    dm.releaseTmp(LR.getTempId());
-                    dm.releaseTmp(RR.getTempId());
+                    dm.releaseTmp(LR.getTempId(), &e);
+                    dm.releaseTmp(RR.getTempId(), &e);
                     break;
                 }
                 case ast::OpExp::dottimes :
                 {
-                    resT = checkEWBinOp<_check_dottimes>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_dottimes>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::dotrdivide:
                 {
-                    resT = checkEWBinOp<_check_dotrdiv>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_dotrdiv>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::dotpower:
                 {
-                    resT = checkEWBinOp<_check_dotpower>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_dotpower>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::unaryMinus :
@@ -187,58 +189,58 @@ void AnalysisVisitor::visit(ast::OpExp & e)
                         safe = true;
                     }
                     tempId = dm.getTmpId(resT, false);
-                    dm.releaseTmp(LR.getTempId());
-                    dm.releaseTmp(RR.getTempId());
+                    dm.releaseTmp(LR.getTempId(), &e);
+                    dm.releaseTmp(RR.getTempId(), &e);
                     break;
                 }
                 case ast::OpExp::eq:
                 {
-                    resT = checkEWBinOp<_check_eq>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_eq>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::ne:
                 {
-                    resT = checkEWBinOp<_check_neq>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_neq>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::lt:
                 {
-                    resT = checkEWBinOp<_check_lt>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_lt>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::le:
                 {
-                    resT = checkEWBinOp<_check_le>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_le>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::gt:
                 {
-                    resT = checkEWBinOp<_check_gt>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_gt>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::ge:
                 {
-                    resT = checkEWBinOp<_check_ge>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_ge>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::logicalAnd:
                 {
-                    resT = checkEWBinOp<_check_and>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_and>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::logicalOr:
                 {
-                    resT = checkEWBinOp<_check_or>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_or>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::logicalShortCutAnd:
                 {
-                    resT = checkEWBinOp<_check_andand>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_andand>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
                 case ast::OpExp::logicalShortCutOr:
                 {
-                    resT = checkEWBinOp<_check_oror>(LT, RT, LR, RR, safe, tempId);
+                    resT = checkEWBinOp<_check_oror>(LT, RT, LR, RR, safe, tempId, &Lexp, &Rexp);
                     break;
                 }
             }
@@ -287,7 +289,7 @@ void AnalysisVisitor::visit(ast::TransposeExp & e)
     TIType resType(dm.getGVN(), type.type, type.cols, type.rows);
     e.getDecorator().res = Result(resType, dm.getTmpId(resType, false));
     e.getDecorator().safe = true;
-    dm.releaseTmp(res.getTempId());
+    dm.releaseTmp(res.getTempId(), &e);
 
     setResult(e.getDecorator().res);
 }
index a195d16..e36eb59 100644 (file)
@@ -56,7 +56,11 @@ void DebugVisitor::DEBUG(const std::wstring& str, const Exp &e)
     Location loc = e.getLocation();
     *ostr << L" @(" << loc.first_line << L"." << loc.first_column << L" -> ";
     *ostr << loc.last_line << L"." << loc.last_column << L")";
-    //*ostr << L" Deco(" << e.getDecorator() << L")" << endl;
+    if (printDecoration)
+    {
+        *ostr << L" Deco(" << e.getDecorator() << L")";
+    }
+    *ostr << std::endl;
 }