1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[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
This commit is contained in:
James Molloy 2015-10-19 08:54:59 +00:00
parent 2e0208e770
commit 570047b4e8

View File

@ -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;
}
}