aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetInstrInfo.cpp
diff options
context:
space:
mode:
authorFelipe de Azevedo Piovezan <fpiovezan@apple.com>2023-03-08 13:04:29 -0500
committerFelipe de Azevedo Piovezan <fpiovezan@apple.com>2023-03-08 13:41:32 -0500
commitc0967995d254fd2dd24ba74afa46df5f559f11ba (patch)
treeabfec0e3e5f3515732ce7d67562de0f333508463 /llvm/lib/CodeGen/TargetInstrInfo.cpp
parent7fb0b1b8d7e75c442b4ae2f1564e1e703aca98b4 (diff)
downloadllvm-c0967995d254fd2dd24ba74afa46df5f559f11ba.zip
llvm-c0967995d254fd2dd24ba74afa46df5f559f11ba.tar.gz
llvm-c0967995d254fd2dd24ba74afa46df5f559f11ba.tar.bz2
[CodeGen] Prevent nullptr deref in genAlternativeCodeSequence
A pointer dereference was added (D141302) above an assert that checks whether the pointer is null. This commit moves the assert above the dereference and transforms it into an llvm_unreachable to better express the intent that certain switch cases should never be reached. Differential Revision: https://reviews.llvm.org/D145599
Diffstat (limited to 'llvm/lib/CodeGen/TargetInstrInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetInstrInfo.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index e86724a..1ea5c07 100644
--- a/llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -1038,15 +1038,13 @@ void TargetInstrInfo::genAlternativeCodeSequence(
Prev = MRI.getUniqueVRegDef(Root.getOperand(2).getReg());
break;
default:
- break;
+ llvm_unreachable("Unknown pattern for machine combiner");
}
// Don't reassociate if Prev and Root are in different blocks.
if (Prev->getParent() != Root.getParent())
return;
- assert(Prev && "Unknown pattern for machine combiner");
-
reassociateOps(Root, *Prev, Pattern, InsInstrs, DelInstrs, InstIdxForVirtReg);
}