diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2015-07-22 11:36:09 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2015-07-22 11:36:09 +0000 |
| commit | 6919267d0be8a854ef2397269f9fe6784377de64 (patch) | |
| tree | 9c728e81c681208e666e36fb71fd2987d12538f4 /llvm | |
| parent | 6fb9c087cbf69176c2fbbb1868d130d62d807d99 (diff) | |
| download | bcm5719-llvm-6919267d0be8a854ef2397269f9fe6784377de64.tar.gz bcm5719-llvm-6919267d0be8a854ef2397269f9fe6784377de64.zip | |
[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.
llvm-svn: 242891
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Analysis/IPA/GlobalsModRef.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp index 720bef85798..7713a5b6476 100644 --- a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/llvm/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<const Value *, const GlobalValue *> AllocsForIndirectGlobals; + DenseMap<const Value *, const GlobalValue *> 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<const Value *, const GlobalValue *>::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); } } } |

