[llvm-bugs] [Bug 43812] New: pass names > with break llvm::PrintStatisticsJSON()

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 25 19:31:13 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43812

            Bug ID: 43812
           Summary: pass names > with  break llvm::PrintStatisticsJSON()
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: andres at anarazel.de
                CC: francisvm at yahoo.com, llvm-bugs at lists.llvm.org,
                    matze at braunis.de

Hi,

https://reviews.llvm.org/D41290 / r320996 / b213b27ee3cb changed
llvm::PrintStatisticsJSON() to assert yaml::QuotingType::None while making
needsQuotes() considerably more strict than before.

It was clearly too lenient in general before, but now the check fires in a lot
of cases where it's not necessary:

    void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R,
                                    const char *suffix, double Value) {
      assert(yaml::needsQuotes(Name) == yaml::QuotingType::None &&
             "TimerGroup name should not need quotes");
      assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None &&
             "Timer name should not need quotes");
      constexpr auto max_digits10 = std::numeric_limits<double>::max_digits10;
      OS << "\t\"time." << Name << '.' << R.Name << suffix
         << "\": " << format("%.*e", max_digits10 - 1, Value);
    }

now asserts out for pass names like "X86 DAG->DAG Instruction Selection", as
yaml::needsQuotes treats the > thatin  as a quote needing character. In this
context that's clearly not necessary, as R.Name is printed within double
quotes.

Before https://reviews.llvm.org/D25588 / r287370 / db39fd6c53f8 the code
basically only checked whether the string contained a quote or non-printable
character. The change to yaml::needsQuotes may have worked at the time, but is
clearly not semantically the right thing.

This is obviously pretty easy to fix, I'm just not quite sure which possible
fix is the right one. Among the possibilities:
1) just remove the asserts
2) go back to an open coded assertion
3) Use JSON.h to add the quotes, rather than doing so manually.

- Andres

- Andres

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191026/795b2fff/attachment.html>


More information about the llvm-bugs mailing list