[llvm] fffabd5 - [NFC] Switch a few uses of undef to poison as placeholders for unreachable code
Nuno Lopes via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 30 05:56:07 PDT 2022
Author: Nuno Lopes
Date: 2022-07-30T13:55:56+01:00
New Revision: fffabd53482f34f96ab9273486538f587e3d91fc
URL: https://github.com/llvm/llvm-project/commit/fffabd53482f34f96ab9273486538f587e3d91fc
DIFF: https://github.com/llvm/llvm-project/commit/fffabd53482f34f96ab9273486538f587e3d91fc.diff
LOG: [NFC] Switch a few uses of undef to poison as placeholders for unreachable code
Added:
Modified:
llvm/lib/Analysis/DomTreeUpdater.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/lib/Transforms/Scalar/GVNSink.cpp
llvm/lib/Transforms/Utils/SSAUpdater.cpp
llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/DomTreeUpdater.cpp b/llvm/lib/Analysis/DomTreeUpdater.cpp
index 888c167232089..f878774d5d64d 100644
--- a/llvm/lib/Analysis/DomTreeUpdater.cpp
+++ b/llvm/lib/Analysis/DomTreeUpdater.cpp
@@ -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
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 1943b5db94c3e..343d49b4be9f4 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -6337,7 +6337,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
// 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;
}
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 7a1a769c6b16c..7417534540275 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -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");
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 720b8e71fd567..6fc6a931a861c 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -634,7 +634,7 @@ class GVNSink {
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();
}
}
diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp
index 37019e3bf95be..2520aa5d9db00 100644
--- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp
+++ b/llvm/lib/Transforms/Utils/SSAUpdater.cpp
@@ -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;
}
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll b/llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
index b72984b7b59f6..f7b9bbb3782dc 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
@@ -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:
More information about the llvm-commits
mailing list