[llvm] r336142 - [llvm-mca] Clear the content of map VariantDescriptors in InstrBuilder before we start analyzing a new CodeBlock. NFCI.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 13:39:57 PDT 2018


Author: adibiagio
Date: Mon Jul  2 13:39:57 2018
New Revision: 336142

URL: http://llvm.org/viewvc/llvm-project?rev=336142&view=rev
Log:
[llvm-mca] Clear the content of map VariantDescriptors in InstrBuilder before we start analyzing a new CodeBlock. NFCI.

Different CodeBlocks don't overlap. The same MCInst cannot appear in more than
one code block because all blocks are instantiated before the simulation is run.

We should always clear the content of map VariantDescriptors before every
simulation, since VariantDescriptors cannot possibly store useful information
for the next blocks. It is also "safer" to clear its content because `MCInst*`
is used as the key type for map VariantDescriptors.

Modified:
    llvm/trunk/tools/llvm-mca/InstrBuilder.h
    llvm/trunk/tools/llvm-mca/llvm-mca.cpp

Modified: llvm/trunk/tools/llvm-mca/InstrBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/InstrBuilder.h?rev=336142&r1=336141&r2=336142&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/InstrBuilder.h (original)
+++ llvm/trunk/tools/llvm-mca/InstrBuilder.h Mon Jul  2 13:39:57 2018
@@ -69,6 +69,8 @@ public:
     return ProcResourceMasks;
   }
 
+  void clear() { VariantDescriptors.shrink_and_clear(); }
+
   std::unique_ptr<Instruction> createInstruction(const llvm::MCInst &MCI);
 };
 } // namespace mca

Modified: llvm/trunk/tools/llvm-mca/llvm-mca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/llvm-mca.cpp?rev=336142&r1=336141&r2=336142&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/llvm-mca.cpp (original)
+++ llvm/trunk/tools/llvm-mca/llvm-mca.cpp Mon Jul  2 13:39:57 2018
@@ -547,6 +547,9 @@ int main(int argc, char **argv) {
 
     P->run();
     Printer.printReport(TOF->os());
+
+    // Clear the InstrBuilder internal state in preparation for another round.
+    IB.clear();
   }
 
   TOF->keep();




More information about the llvm-commits mailing list