From 936cb99d37acd294b92c2bf67ae26c6a52a8ff89 Mon Sep 17 00:00:00 2001 From: Ivan Radanov Ivanov Date: Thu, 25 Jan 2024 08:33:57 +0900 Subject: [PATCH] assert doesnt run on release builds --- tools/polymer/lib/Support/OslScop.cc | 3 ++- tools/polymer/lib/Support/ScopStmt.cc | 7 ++++--- .../Target/OpenScop/ConvertFromOpenScop.cc | 19 +++++++++++++------ .../lib/Target/OpenScop/ConvertToOpenScop.cc | 8 +++++--- tools/polymer/lib/Transforms/Reg2Mem.cc | 7 ++++--- tools/polymer/lib/Transforms/ScopStmtOpt.cc | 11 ++++++----- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/tools/polymer/lib/Support/OslScop.cc b/tools/polymer/lib/Support/OslScop.cc index 42565165ce78..66b3558efa7d 100644 --- a/tools/polymer/lib/Support/OslScop.cc +++ b/tools/polymer/lib/Support/OslScop.cc @@ -610,7 +610,8 @@ void OslScop::createAccessRelationConstraints( // The results of the affine value map, which are the access addresses, will // be placed to the leftmost of all columns. - assert(cst.composeMap(&vMap).succeeded()); + auto ret = cst.composeMap(&vMap).succeeded(); + assert(ret); } OslScop::SymbolTable *OslScop::getSymbolTable() { return &symbolTable; } diff --git a/tools/polymer/lib/Support/ScopStmt.cc b/tools/polymer/lib/Support/ScopStmt.cc index bbed25a411f0..6bf200e568a5 100644 --- a/tools/polymer/lib/Support/ScopStmt.cc +++ b/tools/polymer/lib/Support/ScopStmt.cc @@ -104,8 +104,8 @@ promoteSymbolToTopLevel(mlir::Value val, // "Found top-level argument should be a valid symbol."); unsigned int pos; - assert(domain.findVar(val, &pos) && - "Provided value should be in the given domain"); + auto res = domain.findVar(val, &pos); + assert(res && "Provided value should be in the given domain"); domain.setValue(pos, arg); symMap[val] = arg; @@ -128,7 +128,8 @@ void ScopStmtImpl::initializeDomainAndEnclosingOps() { affine::getEnclosingAffineOps(*caller, &enclosingOps); // The domain constraints can then be collected from the enclosing ops. - assert(succeeded(getIndexSet(enclosingOps, &domain))); + auto res = succeeded(getIndexSet(enclosingOps, &domain)); + assert(res); // Add additional indices that are in the top level block arguments. for (Value arg : caller->getOperands()) { diff --git a/tools/polymer/lib/Target/OpenScop/ConvertFromOpenScop.cc b/tools/polymer/lib/Target/OpenScop/ConvertFromOpenScop.cc index 6a531eb74125..f360064c42cd 100644 --- a/tools/polymer/lib/Target/OpenScop/ConvertFromOpenScop.cc +++ b/tools/polymer/lib/Target/OpenScop/ConvertFromOpenScop.cc @@ -867,7 +867,8 @@ void Importer::getAffineExprForLoopIterator( AffineExprBuilder builder(context, symTable, &symbolTable, scop, options); SmallVector affExprs; - assert(succeeded(builder.process(substAss->RHS, affExprs))); + auto res = succeeded(builder.process(substAss->RHS, affExprs)); + assert(res); // Insert dim operands. for (llvm::StringRef dimName : builder.dimNames.keys()) { @@ -955,7 +956,9 @@ LogicalResult Importer::processStmt(clast_user_stmt *userStmt) { OslScop::ValueTable *valueTable = scop->getValueTable(); osl_statement_p stmt; - assert(succeeded(scop->getStatement(userStmt->statement->number - 1, &stmt))); + auto res = + succeeded(scop->getStatement(userStmt->statement->number - 1, &stmt)); + assert(res); osl_body_p body = osl_statement_get_body(stmt); assert(body != NULL && "The body of the statement should not be NULL."); @@ -1106,8 +1109,10 @@ LogicalResult Importer::processStmt(clast_guard *guardStmt) { } } - assert(succeeded(builder.process(lhs, lhsExprs))); - assert(succeeded(builder.process(eq.RHS, rhsExprs))); + auto res = succeeded(builder.process(lhs, lhsExprs)); + assert(res); + res = succeeded(builder.process(eq.RHS, rhsExprs)); + assert(res); for (AffineExpr rhsExpr : rhsExprs) { AffineExpr eqExpr; @@ -1144,7 +1149,8 @@ LogicalResult Importer::processStmt(clast_guard *guardStmt) { Block *entryBlock = ifOp.getThenBlock(); b.setInsertionPointToStart(entryBlock); - assert(processStmtList(guardStmt->then).succeeded()); + auto res = processStmtList(guardStmt->then).succeeded(); + assert(res); b.setInsertionPointAfter(ifOp); return success(); @@ -1275,7 +1281,8 @@ LogicalResult Importer::processStmt(clast_for *forStmt) { b.setInsertionPointToStart(&entryBlock); entryBlock.walk( [&](mlir::affine::AffineYieldOp op) { b.setInsertionPoint(op); }); - assert(processStmtList(forStmt->body).succeeded()); + auto res = processStmtList(forStmt->body).succeeded(); + assert(res); b.setInsertionPointAfter(forOp); // Restore the symbol value. diff --git a/tools/polymer/lib/Target/OpenScop/ConvertToOpenScop.cc b/tools/polymer/lib/Target/OpenScop/ConvertToOpenScop.cc index e6cfc2964a6e..70d8e3def4e6 100644 --- a/tools/polymer/lib/Target/OpenScop/ConvertToOpenScop.cc +++ b/tools/polymer/lib/Target/OpenScop/ConvertToOpenScop.cc @@ -164,13 +164,15 @@ std::unique_ptr OslScopBuilder::build(mlir::func::FuncOp f) { const ScopStmt &stmt = scopStmtMap->find(scopStmtNames->at(stmtId))->second; scop->addBodyExtension(stmtId, stmt); } - assert(scop->validate() && "The scop object created cannot be validated."); + auto res = scop->validate(); + assert(res && "The scop object created cannot be validated."); // Additionally, setup the name of the function in the comment. std::string funcName(f.getName()); scop->addExtensionGeneric("comment", funcName); - assert(scop->validate() && "The scop object created cannot be validated."); + res = scop->validate(); + assert(res && "The scop object created cannot be validated."); return scop; } @@ -295,7 +297,7 @@ void OslScopBuilder::buildScopContext( for (unsigned i = 0; i < ctx.getNumSymbolVars(); i++) { mlir::Value sym = symValues[i]; unsigned pos; - assert(domain->findVar(sym, &pos)); + domain->findVar(sym, &pos); unsigned posAsCtx = i + domain->getNumDimVars(); LLVM_DEBUG(dbgs() << "Swapping " << posAsCtx << " " << pos << "\n"); diff --git a/tools/polymer/lib/Transforms/Reg2Mem.cc b/tools/polymer/lib/Transforms/Reg2Mem.cc index e7bc644381ad..fdf72c1976aa 100644 --- a/tools/polymer/lib/Transforms/Reg2Mem.cc +++ b/tools/polymer/lib/Transforms/Reg2Mem.cc @@ -600,8 +600,8 @@ static void getScratchpadIterDomains( forOps); affine::FlatAffineValueConstraints domain; - assert(succeeded(getIndexSet(forOps, &domain)) && - "Cannot get the iteration domain of the given forOps"); + auto res = succeeded(getIndexSet(forOps, &domain)); + assert(res && "Cannot get the iteration domain of the given forOps"); indexSets.push_back(domain); } @@ -669,7 +669,8 @@ static affine::FlatAffineValueConstraints unionScratchpadIterDomains( for (unsigned int j = 0; j < domain.getNumSymbolVars(); j++) { mlir::Value symbol = domain.getValue(j + domain.getNumDimVars()); unsigned int pos = 0; - assert(unionDomain.findVar(symbol, &pos)); + auto res = unionDomain.findVar(symbol, &pos); + assert(res); newInEq[pos] = inEq[j + domain.getNumDimVars()]; } // Merge constant diff --git a/tools/polymer/lib/Transforms/ScopStmtOpt.cc b/tools/polymer/lib/Transforms/ScopStmtOpt.cc index fc85587634fc..3a62ea9dccaf 100644 --- a/tools/polymer/lib/Transforms/ScopStmtOpt.cc +++ b/tools/polymer/lib/Transforms/ScopStmtOpt.cc @@ -138,7 +138,8 @@ static void getMemRefSize(MutableArrayRef forOps, // Get the constraints imposed by the whole set of nested loops. affine::FlatAffineValueConstraints cst; SmallVector enclosingOps{forOps.begin(), forOps.end()}; - assert(succeeded(getIndexSet(enclosingOps, &cst))); + auto res = succeeded(getIndexSet(enclosingOps, &cst)); + assert(res); // Project out indices other than the innermost. projectAllOutExcept(cst, indices); @@ -303,10 +304,10 @@ static void scopStmtSplit(ModuleOp m, OpBuilder &b, int toSplit) { mlir::func::CallOp call; // the corresponding call to `func`. Operation *opToSplit; - assert((opToSplit = findToSplitStmt(m, func, toSplit)) && - "Given split ID cannot be found"); - assert((call = findCallOpForFunc(m, func)) && - "The call op for the target function should be found."); + auto res = (opToSplit = findToSplitStmt(m, func, toSplit)); + assert(res && "Given split ID cannot be found"); + res = (call = findCallOpForFunc(m, func)); + assert(res && "The call op for the target function should be found."); scopStmtSplit(m, b, func, call, opToSplit); }