summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2015-09-14 06:16:44 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2015-09-14 06:16:44 +0000
commit98800d9c3ac013d13fefcf5260068839cbc8881e (patch)
tree7ba45174f84db7f29c05310df68138e60bd826d5
parentc0cc747ae847273c091f6d2ebf93172f8cbb7ea2 (diff)
downloadbcm5719-llvm-98800d9c3ac013d13fefcf5260068839cbc8881e.tar.gz
bcm5719-llvm-98800d9c3ac013d13fefcf5260068839cbc8881e.zip
GlobalsAAResult: Try to fix crash.
DeletionCallbackHandle holds GAR in its creation. It assumes; - It is registered as CallbackVH. It should not be moved in its life. - Its parent, GAR, may be moved. To move list<DeletionCallbackHandle> GlobalsAAResult::Handles, GAR must be updated with the destination in GlobalsAAResult(&&). llvm-svn: 247534
-rw-r--r--llvm/include/llvm/Analysis/GlobalsModRef.h4
-rw-r--r--llvm/lib/Analysis/GlobalsModRef.cpp26
2 files changed, 18 insertions, 12 deletions
diff --git a/llvm/include/llvm/Analysis/GlobalsModRef.h b/llvm/include/llvm/Analysis/GlobalsModRef.h
index c142ec22f12..9e0f36f86bc 100644
--- a/llvm/include/llvm/Analysis/GlobalsModRef.h
+++ b/llvm/include/llvm/Analysis/GlobalsModRef.h
@@ -52,11 +52,11 @@ class GlobalsAAResult : public AAResultBase<GlobalsAAResult> {
/// Handle to clear this analysis on deletion of values.
struct DeletionCallbackHandle final : CallbackVH {
- GlobalsAAResult &GAR;
+ GlobalsAAResult *GAR;
std::list<DeletionCallbackHandle>::iterator I;
DeletionCallbackHandle(GlobalsAAResult &GAR, Value *V)
- : CallbackVH(V), GAR(GAR) {}
+ : CallbackVH(V), GAR(&GAR) {}
void deleted() override;
};
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp
index 9dbda3aa422..a5820cd7a56 100644
--- a/llvm/lib/Analysis/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/GlobalsModRef.cpp
@@ -195,34 +195,34 @@ private:
void GlobalsAAResult::DeletionCallbackHandle::deleted() {
Value *V = getValPtr();
if (auto *F = dyn_cast<Function>(V))
- GAR.FunctionInfos.erase(F);
+ GAR->FunctionInfos.erase(F);
if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
- if (GAR.NonAddressTakenGlobals.erase(GV)) {
+ if (GAR->NonAddressTakenGlobals.erase(GV)) {
// This global might be an indirect global. If so, remove it and
// remove any AllocRelatedValues for it.
- if (GAR.IndirectGlobals.erase(GV)) {
+ if (GAR->IndirectGlobals.erase(GV)) {
// Remove any entries in AllocsForIndirectGlobals for this global.
- for (auto I = GAR.AllocsForIndirectGlobals.begin(),
- E = GAR.AllocsForIndirectGlobals.end();
+ for (auto I = GAR->AllocsForIndirectGlobals.begin(),
+ E = GAR->AllocsForIndirectGlobals.end();
I != E; ++I)
if (I->second == GV)
- GAR.AllocsForIndirectGlobals.erase(I);
+ GAR->AllocsForIndirectGlobals.erase(I);
}
// Scan the function info we have collected and remove this global
// from all of them.
- for (auto &FIPair : GAR.FunctionInfos)
+ for (auto &FIPair : GAR->FunctionInfos)
FIPair.second.eraseModRefInfoForGlobal(*GV);
}
}
// If this is an allocation related to an indirect global, remove it.
- GAR.AllocsForIndirectGlobals.erase(V);
+ GAR->AllocsForIndirectGlobals.erase(V);
// And clear out the handle.
setValPtr(nullptr);
- GAR.Handles.erase(I);
+ GAR->Handles.erase(I);
// This object is now destroyed!
}
@@ -794,7 +794,13 @@ GlobalsAAResult::GlobalsAAResult(GlobalsAAResult &&Arg)
IndirectGlobals(std::move(Arg.IndirectGlobals)),
AllocsForIndirectGlobals(std::move(Arg.AllocsForIndirectGlobals)),
FunctionInfos(std::move(Arg.FunctionInfos)),
- Handles(std::move(Arg.Handles)) {}
+ Handles(std::move(Arg.Handles)) {
+ // Update the parent for each DeletionCallbackHandle.
+ for (auto &H : Handles) {
+ assert(H.GAR == &Arg);
+ H.GAR = this;
+ }
+}
/*static*/ GlobalsAAResult
GlobalsAAResult::analyzeModule(Module &M, const TargetLibraryInfo &TLI,
OpenPOWER on IntegriCloud