diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/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())