From e3b557809604d036af6e00c60f012c2025b59a5e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 11 Feb 2023 13:38:04 +0100 Subject: Vendor import of llvm-project main llvmorg-16-init-18548-gb0daacf58f41, the last commit before the upstream release/17.x branch was created. --- llvm/lib/IR/Operator.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'llvm/lib/IR/Operator.cpp') diff --git a/llvm/lib/IR/Operator.cpp b/llvm/lib/IR/Operator.cpp index c2a4a7c29915..b57f3e3b2967 100644 --- a/llvm/lib/IR/Operator.cpp +++ b/llvm/lib/IR/Operator.cpp @@ -35,7 +35,7 @@ bool Operator::hasPoisonGeneratingFlags() const { case Instruction::GetElementPtr: { auto *GEP = cast(this); // Note: inrange exists on constexpr only - return GEP->isInBounds() || GEP->getInRangeIndex() != None; + return GEP->isInBounds() || GEP->getInRangeIndex() != std::nullopt; } default: if (const auto *FP = dyn_cast(this)) @@ -44,6 +44,13 @@ bool Operator::hasPoisonGeneratingFlags() const { } } +bool Operator::hasPoisonGeneratingFlagsOrMetadata() const { + if (hasPoisonGeneratingFlags()) + return true; + auto *I = dyn_cast(this); + return I && I->hasPoisonGeneratingMetadata(); +} + Type *GEPOperator::getSourceElementType() const { if (auto *I = dyn_cast(this)) return I->getSourceElementType(); @@ -63,7 +70,7 @@ Align GEPOperator::getMaxPreservedAlignment(const DataLayout &DL) const { Align Result = Align(llvm::Value::MaximumAlignment); for (gep_type_iterator GTI = gep_type_begin(this), GTE = gep_type_end(this); GTI != GTE; ++GTI) { - int64_t Offset = 1; + uint64_t Offset; ConstantInt *OpC = dyn_cast(GTI.getOperand()); if (StructType *STy = GTI.getStructTypeOrNull()) { @@ -71,11 +78,9 @@ Align GEPOperator::getMaxPreservedAlignment(const DataLayout &DL) const { Offset = SL->getElementOffset(OpC->getZExtValue()); } else { assert(GTI.isSequential() && "should be sequencial"); - /// If the index isn't know we take 1 because it is the index that will + /// If the index isn't known, we take 1 because it is the index that will /// give the worse alignment of the offset. - int64_t ElemCount = 1; - if (OpC) - ElemCount = OpC->getZExtValue(); + const uint64_t ElemCount = OpC ? OpC->getZExtValue() : 1; Offset = DL.getTypeAllocSize(GTI.getIndexedType()) * ElemCount; } Result = Align(MinAlign(Offset, Result.value())); -- cgit v1.2.3