[PATCH] D138642: ConstantFolding: Guard use of getFunction
David Stuttard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 24 01:27:05 PST 2022
dstuttard created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dstuttard requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Add additional guards for a use of getFunction on an Instruction
In some cases constanfFoldCanonicalize can be called with a cloned instruction
that doesn't have a parent (or associated function), causing a seg fault.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138642
Files:
llvm/lib/Analysis/ConstantFolding.cpp
Index: llvm/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -1959,7 +1959,7 @@
if (Src.isNormal() || Src.isInfinity())
return ConstantFP::get(CI->getContext(), Src);
- if (Src.isDenormal()) {
+ if (Src.isDenormal() && CI->getParent() && CI->getFunction()) {
DenormalMode DenormMode =
CI->getFunction()->getDenormalMode(Src.getSemantics());
if (DenormMode == DenormalMode::getIEEE())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138642.477702.patch
Type: text/x-patch
Size: 554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221124/a33ffeb1/attachment.bin>
More information about the llvm-commits
mailing list