From: Quentin Colombet Date: Fri, 13 Oct 2017 21:16:05 +0000 (+0000) Subject: [Legalizer] Only allocate the SetVectors once per function. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35a6ebd9c8138e7c12134afacc19b622ffc52133;p=llvm [Legalizer] Only allocate the SetVectors once per function. Prior to this patch we used to create SetVectors in temporaries that were created and destroyed for each instruction. Now, instead we create and destroyed them only once, but clear the content for each instruction. This speeds up the pass by ~25%. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315756 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/GlobalISel/Legalizer.cpp b/lib/CodeGen/GlobalISel/Legalizer.cpp index 1c474b99846..a9847dea3ce 100644 --- a/lib/CodeGen/GlobalISel/Legalizer.cpp +++ b/lib/CodeGen/GlobalISel/Legalizer.cpp @@ -70,6 +70,9 @@ bool Legalizer::runOnMachineFunction(MachineFunction &MF) { // convergence for performance reasons. bool Changed = false; MachineBasicBlock::iterator NextMI; + using VecType = SetVector>; + VecType WorkList; + VecType CombineList; for (auto &MBB : MF) { for (auto MI = MBB.begin(); MI != MBB.end(); MI = NextMI) { // Get the next Instruction before we try to legalize, because there's a @@ -81,9 +84,8 @@ bool Legalizer::runOnMachineFunction(MachineFunction &MF) { if (!isPreISelGenericOpcode(MI->getOpcode())) continue; unsigned NumNewInsns = 0; - using VecType = SetVector>; - VecType WorkList; - VecType CombineList; + WorkList.clear(); + CombineList.clear(); Helper.MIRBuilder.recordInsertions([&](MachineInstr *MI) { // Only legalize pre-isel generic instructions. // Legalization process could generate Target specific pseudo