Lib/Liveness/RegUsage.cpp
/**
 * Check internal consistency of used variables
 *
 * If anything is detected here, it is a compile error.
 */
Check internal consistency of used variables
If anything is detected here, it is a compile error.
Check internal consistency of used variables If anything is detected here it is a compile error .
void RegUsage::check() const {
  std::string ret;
   Does not need to be tested.
  {
    std::string tmp = get_never_assigned_list(*this);
    if (!tmp.empty()) {
      std::string msg;
      msg << "  There are internal instruction variables which are used but never assigned.\n"
          << "  Variables: " << tmp << "\n";
      ret << msg;
    }
  }
  {
    std::string tmp;
    for (int i = 0; i < (int) size(); i++) {
      auto const &item = (*this)[i];
      if (!item.regular_use())   continue;
      if (item.never_assigned()) continue;   Tested in previous block
      if (item.first_live() <= item.first_dst()) {
        tmp << "  Variable " << i << " is live before first assignment" << "\n";
      }
    }
    if (!tmp.empty()) {
      tmp << "\n  This can happen if the first assignment is in a conditional block (If, When, For etc).\n";
      ret << tmp;
      debug(dump(true));
      breakpoint
    }
  }
  if (!ret.empty()) {
    std::string prefix = "RegUsage internal error(s) ";
    if (Platform::compiling_for_vc4()) {
      prefix << "vc4";
    } else {
      prefix << "v3d";
    }
    prefix << ":\n";
    error(prefix + ret, true);
  } 
}
void RegUsage :: check ( ) const { std :: string ret ; { std :: string tmp = get_never_assigned_list ( * this ) ; if ( ! tmp . empty ( ) ) { std :: string msg ; msg << " \n " << " " << tmp << " \n " ; ret << msg ; } } { std :: string tmp ; for ( int i = 0 ; i < ( int ) size ( ) ; i ++ ) { auto const & item = ( * this ) [ i ] ; if ( ! item . regular_use ( ) ) continue ; if ( item . never_assigned ( ) ) continue ; if ( item . first_live ( ) <= item . first_dst ( ) ) { tmp << " " << i << " " << " \n " ; } } if ( ! tmp . empty ( ) ) { tmp << " \n \n " ; ret << tmp ; } } if ( ! ret . empty ( ) ) { std :: string prefix = " " ; if ( Platform :: compiling_for_vc4 ( ) ) { prefix << " " ; } else { prefix << " " ; } prefix << " \n " ; error ( prefix + ret , true ) ; } }
Check internal consistency of used variables
 If anything is detected here, it is a compile error.
Check internal consistency of used variables If anything is detected here it is a compile error .
// Case 'instruction variables which are assigned but never used' // is pretty common and not much of an issue (any more). // E.g. It occurs if condition flags need to be set and the result of the  // operation is discarded. // // Does not need to be tested. // Tested in previous block //debug(dump(true)); //breakpoint