mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-01 07:30:31 +00:00
[CFLAA] Fix a use-of-invalid-pointer bug.
As shown in the diff, we used to add to CFLAA's cache by doing `Cache[Fn] = buildSetsFrom(Fn)`. `buildSetsFrom(Fn)` may cause `Cache` to reallocate its underlying storage, if this happens and `Cache[Fn]` was evaluated prior to `buildSetsFrom(Fn)`, then we'll store the result to a bad address. Patch by Jia Chen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268269 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0e6ef97ce0
commit
c3791a9351
@ -994,7 +994,12 @@ void CFLAAResult::scan(Function *Fn) {
|
||||
assert(InsertPair.second &&
|
||||
"Trying to scan a function that has already been cached");
|
||||
|
||||
Cache[Fn] = buildSetsFrom(Fn);
|
||||
// Note that we can't do Cache[Fn] = buildSetsFrom(Fn) here: the function call
|
||||
// may get evaluated after operator[], potentially triggering a DenseMap
|
||||
// resize and invalidating the reference returned by operator[]
|
||||
auto FunInfo = buildSetsFrom(Fn);
|
||||
Cache[Fn] = std::move(FunInfo);
|
||||
|
||||
Handles.push_front(FunctionHandle(Fn, this));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user