aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/GlobalsModRef.cpp
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2015-10-19 08:54:59 +0000
committerJames Molloy <james.molloy@arm.com>2015-10-19 08:54:59 +0000
commit17379c4ea17a11af1f1e39a73db48dca6b5d5715 (patch)
treef21287766b55541cd935d94d1b2a6c04cb5dfbe9 /llvm/lib/Analysis/GlobalsModRef.cpp
parentab2e28ebafa3f995bcad3f0bf061b622e1d494b5 (diff)
downloadllvm-17379c4ea17a11af1f1e39a73db48dca6b5d5715.zip
llvm-17379c4ea17a11af1f1e39a73db48dca6b5d5715.tar.gz
llvm-17379c4ea17a11af1f1e39a73db48dca6b5d5715.tar.bz2
[GlobalsAA] Fix a really horrible iterator invalidation bug
We were keeping a reference to an object in a DenseMap then mutating it. At the end of the function we were attempting to clone that reference into other keys in the DenseMap, but DenseMap may well decide to resize its hashtable which would invalidate the reference! It took an extremely complex testcase to catch this - many thanks to Zhendong Su for catching it in PR25225. This fixes PR25225. llvm-svn: 250692
Diffstat (limited to 'llvm/lib/Analysis/GlobalsModRef.cpp')
-rw-r--r--llvm/lib/Analysis/GlobalsModRef.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp
index be5d384..979e2de 100644
--- a/llvm/lib/Analysis/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/GlobalsModRef.cpp
@@ -587,8 +587,11 @@ void GlobalsAAResult::AnalyzeCallGraph(CallGraph &CG, Module &M) {
// Finally, now that we know the full effect on this SCC, clone the
// information to each function in the SCC.
+ // FI is a reference into FunctionInfos, so copy it now so that it doesn't
+ // get invalidated if DenseMap decides to re-hash.
+ FunctionInfo CachedFI = FI;
for (unsigned i = 1, e = SCC.size(); i != e; ++i)
- FunctionInfos[SCC[i]->getFunction()] = FI;
+ FunctionInfos[SCC[i]->getFunction()] = CachedFI;
}
}