diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -1053,7 +1053,7 @@ isa(CE1->getOperand(0))) { GlobalValue *GV = cast(CE1->getOperand(0)); - MaybeAlign GVAlign; + Align GVAlign; // defaults to 1 if (Module *TheModule = GV->getParent()) { const DataLayout &DL = TheModule->getDataLayout(); @@ -1073,14 +1073,14 @@ } else if (isa(GV)) { // Without a datalayout we have to assume the worst case: that the // function pointer isn't aligned at all. - GVAlign = std::nullopt; + GVAlign = Align(1); } else if (isa(GV)) { - GVAlign = cast(GV)->getAlign(); + GVAlign = cast(GV)->getAlign().valueOrOne(); } - if (GVAlign && *GVAlign > 1) { + if (GVAlign > 1) { unsigned DstWidth = CI2->getType()->getBitWidth(); - unsigned SrcWidth = std::min(DstWidth, Log2(*GVAlign)); + unsigned SrcWidth = std::min(DstWidth, Log2(GVAlign)); APInt BitsNotSet(APInt::getLowBitsSet(DstWidth, SrcWidth)); // If checking bits we know are clear, return zero.