From: Chandler Carruth Date: Wed, 22 Jul 2015 11:36:09 +0000 (+0000) Subject: [GMR] Switch to a DenseMap and clean up the iteration loop. NFC. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f28cb39e4ca07c387dd270ce123753f898a75d5c;p=oota-llvm.git [GMR] Switch to a DenseMap and clean up the iteration loop. NFC. Since we have to iterate this map not that infrequently, we should use a map that is efficient for iteration. It is also almost certainly much faster for lookups as well. There is more to do in terms of reducing the wasted overhead of GMR's runtime though. Not sure how much is worthwhile though. The loop improvements should hopefully address the code review that Duncan gave when he saw this code as I moved it around. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242891 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 720bef85798..7713a5b6476 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -97,7 +97,7 @@ class GlobalsModRef : public ModulePass, public AliasAnalysis { /// AllocsForIndirectGlobals - If an instruction allocates memory for an /// indirect global, this map indicates which one. - std::map AllocsForIndirectGlobals; + DenseMap AllocsForIndirectGlobals; /// FunctionInfo - For each function, keep track of what globals are /// modified or read. @@ -120,16 +120,11 @@ class GlobalsModRef : public ModulePass, public AliasAnalysis { // any AllocRelatedValues for it. if (GMR.IndirectGlobals.erase(GV)) { // Remove any entries in AllocsForIndirectGlobals for this global. - for (std::map::iterator - I = GMR.AllocsForIndirectGlobals.begin(), - E = GMR.AllocsForIndirectGlobals.end(); - I != E;) { - if (I->second == GV) { - GMR.AllocsForIndirectGlobals.erase(I++); - } else { - ++I; - } - } + for (auto I = GMR.AllocsForIndirectGlobals.begin(), + E = GMR.AllocsForIndirectGlobals.end(); + I != E; ++I) + if (I->second == GV) + GMR.AllocsForIndirectGlobals.erase(I); } } }