From ac5148ef41f0bd9ae6d1f18d0f82398162086378 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Mon, 29 Aug 2016 19:27:20 +0000 Subject: [PATCH] GlobalISel: switch to SmallVector for pending legalizations. std::queue was doing far to many heap allocations to be healthy. llvm-svn: 279992 --- llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp b/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp index afc8289..9787227 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineLegalizeHelper.cpp @@ -58,21 +58,23 @@ MachineLegalizeHelper::legalizeInstrStep(MachineInstr &MI, MachineLegalizeHelper::LegalizeResult MachineLegalizeHelper::legalizeInstr(MachineInstr &MI, const MachineLegalizer &Legalizer) { - std::queue WorkList; - MIRBuilder.recordInsertions([&](MachineInstr *MI) { WorkList.push(MI); }); - WorkList.push(&MI); + SmallVector WorkList; + MIRBuilder.recordInsertions( + [&](MachineInstr *MI) { WorkList.push_back(MI); }); + WorkList.push_back(&MI); bool Changed = false; LegalizeResult Res; + unsigned Idx = 0; do { - Res = legalizeInstrStep(*WorkList.front(), Legalizer); + Res = legalizeInstrStep(*WorkList[Idx], Legalizer); if (Res == UnableToLegalize) { MIRBuilder.stopRecordingInsertions(); return UnableToLegalize; } Changed |= Res == Legalized; - WorkList.pop(); - } while (!WorkList.empty()); + ++Idx; + } while (Idx < WorkList.size()); MIRBuilder.stopRecordingInsertions(); -- 2.7.4