Ignore:
Timestamp:
Oct 31, 2015, 12:20:31 PM (3 years ago)
Author:
nmedfort
Message:

Bug fix for use-def correctness regarding escaping values of If and While nodes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.cpp

    r4764 r4856  
    2323    for (PabloAST * def : mDefined) {
    2424        def->addUser(this);
    25         addUser(def);
     25        this->addUser(def);
    2626    }
    2727}
     
    3434    for (PabloAST * def : mDefined) {
    3535        def->addUser(this);
    36         addUser(def);
     36        this->addUser(def);
    3737    }
    3838}
    3939
    4040void If::addDefined(Assign * def) {
    41     if (LLVM_LIKELY(std::find(mDefined.begin(), mDefined.end(), def) != mDefined.end())) {
    42         const auto size = mDefined.size();
     41    if (LLVM_LIKELY(std::find(mDefined.begin(), mDefined.end(), def) == mDefined.end())) {
    4342        mDefined.push_back(def);
    44         assert (mDefined.size() == size + 1);
    45         assert (mDefined.back() == def);
    4643        def->addUser(this);
    47         addUser(def);
     44        this->addUser(def);
     45    }
     46}
     47
     48void If::removeDefined(Assign * def) {
     49    auto f = std::find(mDefined.begin(), mDefined.end(), def);
     50    if (LLVM_LIKELY(f != mDefined.end())) {
     51        mDefined.erase(f);
     52        def->removeUser(this);
     53        this->removeUser(def);
    4854    }
    4955}
Note: See TracChangeset for help on using the changeset viewer.