Skip to content

Commit

Permalink
Fixed an infinite looping
Browse files Browse the repository at this point in the history
Symbolic expression add operation has a bug that causes an infinite looping.

This change fixes it.
Also, improve debugging functions by adding 'const' qualifier for their arguments.
  • Loading branch information
jgu222 authored and igcbot committed Sep 12, 2023
1 parent be078e2 commit d386d8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
22 changes: 11 additions & 11 deletions IGC/Compiler/CISACodeGen/SLMConstProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void SymbolicEvaluation::dump_symbols()
dbgs() << "\n\n";
}

void SymbolicEvaluation::print(raw_ostream& OS, SymProd* P)
void SymbolicEvaluation::print(raw_ostream& OS, const SymProd* P)
{
bool hasError = false;
for (int i = 0; i < (int)P->Prod.size(); ++i) {
Expand All @@ -178,7 +178,7 @@ void SymbolicEvaluation::print(raw_ostream& OS, SymProd* P)
}
}

void SymbolicEvaluation::print_varMapping(raw_ostream& OS, SymProd* P)
void SymbolicEvaluation::print_varMapping(raw_ostream& OS, const SymProd* P)
{
std::map<const Value*, int> varMap;
const int psz = (int)P->Prod.size();
Expand All @@ -202,7 +202,7 @@ void SymbolicEvaluation::print_varMapping(raw_ostream& OS, SymProd* P)
}
}

void SymbolicEvaluation::print(raw_ostream& OS, SymTerm* T)
void SymbolicEvaluation::print(raw_ostream& OS, const SymTerm* T)
{
if (T->Term->Prod.size() > 0) {
if (T->Coeff != 1) {
Expand All @@ -216,12 +216,12 @@ void SymbolicEvaluation::print(raw_ostream& OS, SymTerm* T)
}
}

void SymbolicEvaluation::print_varMapping(raw_ostream& OS, SymTerm* T)
void SymbolicEvaluation::print_varMapping(raw_ostream& OS, const SymTerm* T)
{
print_varMapping(OS, T->Term);
}

void SymbolicEvaluation::print(raw_ostream& OS, SymExpr* SE)
void SymbolicEvaluation::print(raw_ostream& OS, const SymExpr* SE)
{
int e = (int)SE->SymTerms.size();
for (int i = 0; i < e; ++i) {
Expand All @@ -239,7 +239,7 @@ void SymbolicEvaluation::print(raw_ostream& OS, SymExpr* SE)
}
}

void SymbolicEvaluation::print_varMapping(raw_ostream& OS, SymExpr* SE)
void SymbolicEvaluation::print_varMapping(raw_ostream& OS, const SymExpr* SE)
{
std::map<const Value*, int> varMap;
const int e = (int)SE->SymTerms.size();
Expand Down Expand Up @@ -291,23 +291,23 @@ void SymbolicEvaluation::print_varMapping(raw_ostream& OS, const Value* V)
}
}

void SymbolicEvaluation::dump(SymProd* P)
void SymbolicEvaluation::dump(const SymProd* P)
{
dbgs() << "\n";
print(dbgs(), P);
print_varMapping(dbgs(), P);
dbgs() << "\n";
}

void SymbolicEvaluation::dump(SymTerm* T)
void SymbolicEvaluation::dump(const SymTerm* T)
{
dbgs() << "\n";
print(dbgs(), T);
print_varMapping(dbgs(), T);
dbgs() << "\n";
}

void SymbolicEvaluation::dump(SymExpr* SE)
void SymbolicEvaluation::dump(const SymExpr* SE)
{
dbgs() << "\n";
print(dbgs(), SE);
Expand Down Expand Up @@ -643,9 +643,9 @@ SymExpr* SymbolicEvaluation::add(
if (Coeff != 0)
{
T = T0;
++i0;
++i1;
}
++i0;
++i1;
}

if (T != nullptr) {
Expand Down
18 changes: 9 additions & 9 deletions IGC/Compiler/CISACodeGen/SLMConstProp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,19 @@ namespace IGC
}

#if defined(_DEBUG)
void print(llvm::raw_ostream& OS, SymProd* P);
void print(llvm::raw_ostream& OS, SymTerm* T);
void print(llvm::raw_ostream& OS, SymExpr* SE);
void print(llvm::raw_ostream& OS, const SymProd* P);
void print(llvm::raw_ostream& OS, const SymTerm* T);
void print(llvm::raw_ostream& OS, const SymExpr* SE);
void print(llvm::raw_ostream& OS, const llvm::Value* V);
void print_varMapping(llvm::raw_ostream& OS, SymProd* P);
void print_varMapping(llvm::raw_ostream& OS, SymTerm* T);
void print_varMapping(llvm::raw_ostream& OS, SymExpr* SE);
void print_varMapping(llvm::raw_ostream& OS, const SymProd* P);
void print_varMapping(llvm::raw_ostream& OS, const SymTerm* T);
void print_varMapping(llvm::raw_ostream& OS, const SymExpr* SE);
void print_varMapping(llvm::raw_ostream& OS, const llvm::Value* V);

void dump_symbols();
void dump(SymProd* P);
void dump(SymTerm* T);
void dump(SymExpr* SE);
void dump(const SymProd* P);
void dump(const SymTerm* T);
void dump(const SymExpr* SE);
void dump(const llvm::Value* V);
#endif

Expand Down

0 comments on commit d386d8e

Please sign in to comment.