[llvm] r247534 - GlobalsAAResult: Try to fix crash.
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 00:51:55 PDT 2015
Hi Takumi,
Thanks for fixing this! Does this fix your windows regressions due to
GlobalsAA, or are there still more to investigate?
Cheers,
James
On Mon, 14 Sep 2015 at 07:18 NAKAMURA Takumi via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: chapuni
> Date: Mon Sep 14 01:16:44 2015
> New Revision: 247534
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247534&view=rev
> Log:
> 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(&&).
>
> Modified:
> llvm/trunk/include/llvm/Analysis/GlobalsModRef.h
> llvm/trunk/lib/Analysis/GlobalsModRef.cpp
>
> Modified: llvm/trunk/include/llvm/Analysis/GlobalsModRef.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/GlobalsModRef.h?rev=247534&r1=247533&r2=247534&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Analysis/GlobalsModRef.h (original)
> +++ llvm/trunk/include/llvm/Analysis/GlobalsModRef.h Mon Sep 14 01:16:44
> 2015
> @@ -52,11 +52,11 @@ class GlobalsAAResult : public AAResultB
>
> /// 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;
> };
>
> Modified: llvm/trunk/lib/Analysis/GlobalsModRef.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/GlobalsModRef.cpp?rev=247534&r1=247533&r2=247534&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Analysis/GlobalsModRef.cpp (original)
> +++ llvm/trunk/lib/Analysis/GlobalsModRef.cpp Mon Sep 14 01:16:44 2015
> @@ -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(Globals
> 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,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150914/5ba2ea7b/attachment.html>
More information about the llvm-commits
mailing list