[PATCH] D70650: [MC] Rewrite tablegen for printInstrAlias to comiple faster, NFC

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 16:44:38 PST 2019


craig.topper added inline comments.


================
Comment at: llvm/lib/MC/MCInstPrinter.cpp:106
+                                              const AliasMatchingData &M) {
+  // FIXME: To expensive to do every call. Check ctor?
+  assert(std::is_sorted(
----------------
Nit: I think the first "To" was supposed to be "Too"


================
Comment at: llvm/utils/TableGen/AsmWriterEmitter.cpp:682
     StringRef ASM(AsmString);
-    SmallString<128> OutString;
-    raw_svector_ostream OS(OutString);
+    std::string OutString;
+    raw_string_ostream OS(OutString);
----------------
Was this changed from SmallString to std::string so we could just return it? Do we lose out on NRVO by going through OS.str() instead of OS.flush; return OutString;?


================
Comment at: llvm/utils/TableGen/AsmWriterEmitter.cpp:685
     for (StringRef::iterator I = ASM.begin(), E = ASM.end(); I != E;) {
       OS << *I;
+      ++UnescapedSize;
----------------
How efficient is putting 1 character at a time into a std::string with respect to heap allocations vs the large SmallString we had before. Though I'm not sure how long these strings are in practice. Do we stay under the small string size for std::string?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70650/new/

https://reviews.llvm.org/D70650





More information about the llvm-commits mailing list