[PATCH] D111682: [TableGen][PGO] Disable profile instrumentation for printInstruction function

Rong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 15:03:28 PDT 2021


xur created this revision.
xur added reviewers: davidxl, rnk.
Herald added subscribers: wenlei, tpr.
xur requested review of this revision.
Herald added a project: LLVM.

We are seeing extremely long time in building AMDGPUInstPrinter.cpp when profile instrumentation is enabled: It takes more than 5 minutes (compared to ~ 8 seconds in non-instrument build)

This caused by the huge statements in printInsruction functions. In profile instrumentation build, we need have extra
control flow to differentiate each case statement. This in turn adds significant compile time in block placement and branch folding.

Function printInstruction is not likely to benefit from PGO build as it's rarely executed in a typical compilation. 
So here I disable the profile instrumentation for this function.


https://reviews.llvm.org/D111682

Files:
  llvm/utils/TableGen/AsmWriterEmitter.cpp


Index: llvm/utils/TableGen/AsmWriterEmitter.cpp
===================================================================
--- llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -457,9 +457,14 @@
   StringRef ClassName = AsmWriter->getValueAsString("AsmWriterClassName");
   bool PassSubtarget = AsmWriter->getValueAsInt("PassSubtarget");
 
+  // This function has some huge switch statements that causing excessive
+  // compile time in LLVM profile instrumenation build. This print function
+  // usually is not frequently called in compilation. Here we disable the
+  // profile instrumenation for this function.
   O << "/// printInstruction - This method is automatically generated by "
        "tablegen\n"
        "/// from the instruction set description.\n"
+       "__attribute__((no_profile_instrument_function))\n"
        "void "
     << Target.getName() << ClassName
     << "::printInstruction(const MCInst *MI, uint64_t Address, "


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111682.379193.patch
Type: text/x-patch
Size: 978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211012/03bca7d1/attachment.bin>


More information about the llvm-commits mailing list