[PATCH] D145599: [CodeGen] Prevent nullptr deref in genAlternativeCodeSequence
Felipe de Azevedo Piovezan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 10:07:35 PST 2023
fdeazeve created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
A pointer dereference was added 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145599
Files:
llvm/lib/CodeGen/TargetInstrInfo.cpp
Index: llvm/lib/CodeGen/TargetInstrInfo.cpp
===================================================================
--- llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -1038,15 +1038,13 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145599.503429.patch
Type: text/x-patch
Size: 662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230308/34e3e909/attachment.bin>
More information about the llvm-commits
mailing list