eraseIfNoUse: check if WeakVH is dead

This commit is contained in:
Alessandro Di Federico
2023-01-03 11:37:49 +01:00
parent a4f4906ba7
commit 27dba19ddc
+4 -3
View File
@@ -217,9 +217,10 @@ protected:
};
static void eraseIfNoUse(const WeakVH &V) {
if (Instruction *I = dyn_cast_or_null<Instruction>(&*V))
if (I->use_begin() == I->use_end())
eraseFromParent(I);
if (V != nullptr)
if (Instruction *I = dyn_cast_or_null<Instruction>(&*V))
if (I->use_begin() == I->use_end())
eraseFromParent(I);
}
static SwitchInst *getNextSwitch(SwitchInst::CaseHandle Case) {