Ignore:
Timestamp:
Jan 21, 2016, 5:15:33 PM (3 years ago)
Author:
nmedfort
Message:

Work on lowering + some timing and papi information that will be cleaned up later.

File:
1 edited

Legend:

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

    r4899 r4919  
    169169    PabloPrinter::print(user, str);
    170170    if (count == 0) {
    171         str << " is not recorded in ";
     171        str << " is not considered a user of ";
    172172    } else if (count > 0) {
    173         str << " is recorded" << count << " times in ";
     173        str << " was recorded too many times (" << count << ") in the user list of ";
    174174    }
    175175    PabloPrinter::print(def, str);
    176     str << "'s user list.";
     176    throw std::runtime_error(str.str());
     177}
     178
     179/** ------------------------------------------------------------------------------------------------------------- *
     180 * @brief throwReportedScopeError
     181 ** ------------------------------------------------------------------------------------------------------------- */
     182static void throwReportedScopeError(const Statement * const stmt) {
     183    std::string tmp;
     184    raw_string_ostream str(tmp);
     185    str << "PabloVerifier: structure error: ";
     186    PabloPrinter::print(stmt, str);
     187    str << " is not contained in its reported scope block";
     188    throw std::runtime_error(str.str());
     189}
     190
     191/** ------------------------------------------------------------------------------------------------------------- *
     192 * @brief throwMisreportedBranchError
     193 ** ------------------------------------------------------------------------------------------------------------- */
     194static void throwMisreportedBranchError(const Statement * const stmt, const Statement * const branch) {
     195    std::string tmp;
     196    raw_string_ostream str(tmp);
     197    str << "PabloVerifier: structure error: ";
     198    PabloPrinter::print(stmt, str);
     199    str << " branches into a scope block that reports ";
     200    PabloPrinter::print(stmt, str);
     201    str << " as its branching statement.";
     202    throw std::runtime_error(str.str());
     203}
     204
     205/** ------------------------------------------------------------------------------------------------------------- *
     206 * @brief throwReflexiveIfConditionError
     207 ** ------------------------------------------------------------------------------------------------------------- */
     208static void throwReflexiveIfConditionError(const PabloAST * const ifNode) {
     209    std::string tmp;
     210    raw_string_ostream str(tmp);
     211    str << "PabloVerifier: structure error: the condition of ";
     212    PabloPrinter::print(ifNode, str);
     213    str << " cannot be defined by the If node itself.";
    177214    throw std::runtime_error(str.str());
    178215}
     
    206243        if (LLVM_UNLIKELY(isa<If>(stmt) || isa<While>(stmt))) {
    207244            const PabloBlock * nested = isa<If>(stmt) ? cast<If>(stmt)->getBody() : cast<While>(stmt)->getBody();
    208             if (LLVM_UNLIKELY(nested->getParent() != block)) {
    209                 std::string tmp;
    210                 raw_string_ostream str(tmp);
    211                 str << "PabloVerifier: structure error: body of ";
    212                 PabloPrinter::print(stmt, str);
    213                 str << " is not nested within the expected scope block";
    214                 throw std::runtime_error(str.str());
     245            if (LLVM_UNLIKELY(nested->getBranch() != stmt)) {
     246                throwMisreportedBranchError(stmt, nested->getBranch());
     247            } else if (LLVM_UNLIKELY(nested->getParent() != block)) {
     248                throwReportedScopeError(stmt);
    215249            }
    216250            if (isa<If>(stmt)) {
    217251                for (const Assign * def : cast<If>(stmt)->getDefined()) {
    218252                    if (LLVM_UNLIKELY(def == cast<If>(stmt)->getCondition())) {
    219                         std::string tmp;
    220                         raw_string_ostream str(tmp);
    221                         str << "PabloVerifier: structure error: the condition of ";
    222                         PabloPrinter::print(cast<PabloAST>(stmt), str);
    223                         str << " cannot be defined by the If node itself.";
    224                         throw std::runtime_error(str.str());
    225                     }
    226                 }
    227             }
    228             if (isa<If>(stmt)) {
    229                 for (const Assign * def : cast<If>(stmt)->getDefined()) {
    230                     if (LLVM_UNLIKELY(unreachable(def, nested))) {
     253                        throwReflexiveIfConditionError(stmt);
     254                    } else if (LLVM_UNLIKELY(unreachable(def, nested))) {
    231255                        throwUncontainedEscapedValueError(stmt, def);
    232256                    }
     
    250274                    }
    251275                    count = std::count(var->user_begin(), var->user_end(), stmt);
    252                     if (LLVM_UNLIKELY(count != 1)) {
     276                    if (LLVM_UNLIKELY(count != ((cast<While>(stmt)->getCondition() == var) ? 2 : 1))) {
    253277                        throwEscapedValueUsageError(stmt, var, var, stmt, count);
    254278                    }
Note: See TracChangeset for help on using the changeset viewer.