diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index ffa77bb2fd65..d72133287f56 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -641,7 +641,7 @@ public: private: Status status; - Value *base; // non null only if status == base + AssertingVH base; // non null only if status == base }; } @@ -1098,10 +1098,10 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) { NewInsts.erase(BaseI); ReverseMap.erase(BaseI); BaseI->replaceAllUsesWith(Replacement); - BaseI->eraseFromParent(); assert(States.count(BDV)); assert(States[BDV].isConflict() && States[BDV].getBase() == BaseI); States[BDV] = BDVState(BDVState::Conflict, Replacement); + BaseI->eraseFromParent(); }; const DataLayout &DL = cast(def)->getModule()->getDataLayout(); while (!Worklist.empty()) {