[NFC] Switch a few uses of undef to poison as placeholders for unreachable code

This commit is contained in:
Nuno Lopes 2022-07-30 13:55:56 +01:00
parent 6b4c386b1e
commit fffabd5348
6 changed files with 9 additions and 9 deletions

View File

@ -218,9 +218,9 @@ void DomTreeUpdater::validateDeleteBB(BasicBlock *DelBB) {
// DelBB is unreachable and all its instructions are dead.
while (!DelBB->empty()) {
Instruction &I = DelBB->back();
// Replace used instructions with an arbitrary value (undef).
// Replace used instructions with an arbitrary value (poison).
if (!I.use_empty())
I.replaceAllUsesWith(llvm::UndefValue::get(I.getType()));
I.replaceAllUsesWith(PoisonValue::get(I.getType()));
DelBB->getInstList().pop_back();
}
// Make sure DelBB has a valid terminator instruction. As long as DelBB is a

View File

@ -6337,7 +6337,7 @@ OutOfRecordLoop:
// We found at least one unresolved value. Nuke them all to avoid leaks.
for (unsigned i = ModuleValueListSize, e = ValueList.size(); i != e; ++i){
if ((A = dyn_cast_or_null<Argument>(ValueList[i])) && !A->getParent()) {
A->replaceAllUsesWith(UndefValue::get(A->getType()));
A->replaceAllUsesWith(PoisonValue::get(A->getType()));
delete A;
}
}

View File

@ -1227,8 +1227,8 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) {
// Create a call to __cxa_find_matching_catch_N function
Function *FMCF = getFindMatchingCatch(M, FMCArgs.size());
CallInst *FMCI = IRB.CreateCall(FMCF, FMCArgs, "fmc");
Value *Undef = UndefValue::get(LPI->getType());
Value *Pair0 = IRB.CreateInsertValue(Undef, FMCI, 0, "pair0");
Value *Poison = PoisonValue::get(LPI->getType());
Value *Pair0 = IRB.CreateInsertValue(Poison, FMCI, 0, "pair0");
Value *TempRet0 = IRB.CreateCall(GetTempRet0F, None, "tempret0");
Value *Pair1 = IRB.CreateInsertValue(Pair0, TempRet0, 1, "pair1");

View File

@ -634,7 +634,7 @@ private:
if (PN->getIncomingValue(0) != PN)
PN->replaceAllUsesWith(PN->getIncomingValue(0));
else
PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
PN->replaceAllUsesWith(PoisonValue::get(PN->getType()));
PN->eraseFromParent();
}
}

View File

@ -434,7 +434,7 @@ void LoadAndStorePromoter::run(const SmallVectorImpl<Instruction *> &Insts) {
replaceLoadWithValue(ALoad, NewVal);
// Avoid assertions in unreachable code.
if (NewVal == ALoad) NewVal = UndefValue::get(NewVal->getType());
if (NewVal == ALoad) NewVal = PoisonValue::get(NewVal->getType());
ALoad->replaceAllUsesWith(NewVal);
ReplacedLoads[ALoad] = NewVal;
}

View File

@ -37,7 +37,7 @@ lpad: ; preds = %entry
br label %catch.dispatch
; CHECK: lpad:
; CHECK-NEXT: %[[FMC:.*]] = call i8* @__cxa_find_matching_catch_4(i8* bitcast (i8** @_ZTIi to i8*), i8* null)
; CHECK-NEXT: %[[IVI1:.*]] = insertvalue { i8*, i32 } undef, i8* %[[FMC]], 0
; CHECK-NEXT: %[[IVI1:.*]] = insertvalue { i8*, i32 } poison, i8* %[[FMC]], 0
; CHECK-NEXT: %[[TEMPRET0_VAL:.*]] = call i32 @getTempRet0()
; CHECK-NEXT: %[[IVI2:.*]] = insertvalue { i8*, i32 } %[[IVI1]], i32 %[[TEMPRET0_VAL]], 1
; CHECK-NEXT: extractvalue { i8*, i32 } %[[IVI2]], 0
@ -107,7 +107,7 @@ ehspec.unexpected: ; preds = %filter.dispatch
unreachable
eh.resume: ; preds = %filter.dispatch
%lpad.val = insertvalue { i8*, i32 } undef, i8* %1, 0
%lpad.val = insertvalue { i8*, i32 } poison, i8* %1, 0
%lpad.val3 = insertvalue { i8*, i32 } %lpad.val, i32 %2, 1
resume { i8*, i32 } %lpad.val3
; CHECK: eh.resume: