Skip to content

Commit

Permalink
Fix CUDA HTML code printing bug. (#8558)
Browse files Browse the repository at this point in the history
* Fix CUDA HTML code printing bug.
  • Loading branch information
mcourteaux authored Jan 27, 2025
1 parent bf65d52 commit 53afee7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/StmtToHTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,16 @@ class HTMLCodePrinter : public IRVisitor {
std::istringstream ss(str);

for (std::string line; std::getline(ss, line);) {
if (line.empty()) {
if (line.empty() || line == "\t") {
stream << "<span class='line'></span>\n";
continue;
}
bool indent = false;
if (line[0] == '\t') {
// Replace first tab with four spaces.
line = line.substr(1);
indent = true;
}
line = escape_html(line);

bool should_print_open_indent = false;
Expand Down Expand Up @@ -844,14 +850,6 @@ class HTMLCodePrinter : public IRVisitor {
scope.pop(current_kernel);
}

bool indent = false;

if (line[0] == '\t') {
// Replace first tab with four spaces.
line = line.substr(1);
indent = true;
}

line = replace_all(line, ".f32", ".<span class='OpF32'>f32</span>");
line = replace_all(line, ".f64", ".<span class='OpF64'>f64</span>");

Expand Down Expand Up @@ -883,7 +881,7 @@ class HTMLCodePrinter : public IRVisitor {
}

// Predicated instructions
if (line.front() == '@' && indent) {
if (!line.empty() && line.front() == '@' && indent) {
idx = line.find(' ');
std::string pred = line.substr(1, idx - 1);
line = "<span class='Pred'>@" + variable(pred, Bool()) + "</span>" + line.substr(idx);
Expand Down

0 comments on commit 53afee7

Please sign in to comment.