[llvm] e2537f6 - [ValueTracking] Replace dyn_cast with dyn_cast_or_null to account for getTerminator returning null
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 8 05:34:26 PST 2022
Author: Simon Pilgrim
Date: 2022-02-08T13:33:26Z
New Revision: e2537f6b1989213b68eabb662b6dd5b4425f43cd
URL: https://github.com/llvm/llvm-project/commit/e2537f6b1989213b68eabb662b6dd5b4425f43cd
DIFF: https://github.com/llvm/llvm-project/commit/e2537f6b1989213b68eabb662b6dd5b4425f43cd.diff
LOG: [ValueTracking] Replace dyn_cast with dyn_cast_or_null to account for getTerminator returning null
Noticed while running checks on D117995 - a hexagon regression test was managing to return a block without a terminator
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index c14bdb8bc262e..a93430cfbf53d 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -5125,10 +5125,10 @@ static bool isGuaranteedNotToBeUndefOrPoison(const Value *V,
auto *TI = Dominator->getBlock()->getTerminator();
Value *Cond = nullptr;
- if (auto BI = dyn_cast<BranchInst>(TI)) {
+ if (auto BI = dyn_cast_or_null<BranchInst>(TI)) {
if (BI->isConditional())
Cond = BI->getCondition();
- } else if (auto SI = dyn_cast<SwitchInst>(TI)) {
+ } else if (auto SI = dyn_cast_or_null<SwitchInst>(TI)) {
Cond = SI->getCondition();
}
More information about the llvm-commits
mailing list