diff options
author | Nikita Popov <npopov@redhat.com> | 2022-06-28 11:25:54 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-07-04 09:27:22 +0200 |
commit | 7283f48a05de46fe8721ee6c29b1b6427e7d1a33 (patch) | |
tree | dfbc5f67695199cffdfdda80e4f088f1025c1fbf /llvm/lib/IR/Constants.cpp | |
parent | 1063dfc0285362918aa6bce482a532cb911f64fb (diff) | |
download | llvm-7283f48a05de46fe8721ee6c29b1b6427e7d1a33.zip llvm-7283f48a05de46fe8721ee6c29b1b6427e7d1a33.tar.gz llvm-7283f48a05de46fe8721ee6c29b1b6427e7d1a33.tar.bz2 |
[IR] Remove support for insertvalue constant expression
This removes the insertvalue constant expression, as part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
This is very similar to the extractvalue removal from D125795.
insertvalue is also not supported in bitcode, so no auto-ugprade
is necessary.
ConstantExpr::getInsertValue() can be replaced with
IRBuilder::CreateInsertValue() or ConstantFoldInsertValueInstruction(),
depending on whether a constant result is required (with the latter
being fallible).
The ConstantExpr::hasIndices() and ConstantExpr::getIndices()
methods also go away here, because there are no longer any constant
expressions with indices.
Differential Revision: https://reviews.llvm.org/D128719
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 0bf5e09..961e528 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -547,8 +547,6 @@ void llvm::deleteConstant(Constant *C) { delete static_cast<InsertElementConstantExpr *>(C); else if (isa<ShuffleVectorConstantExpr>(C)) delete static_cast<ShuffleVectorConstantExpr *>(C); - else if (isa<InsertValueConstantExpr>(C)) - delete static_cast<InsertValueConstantExpr *>(C); else if (isa<GetElementPtrConstantExpr>(C)) delete static_cast<GetElementPtrConstantExpr *>(C); else if (isa<CompareConstantExpr>(C)) @@ -1488,14 +1486,6 @@ bool ConstantExpr::isCompare() const { return getOpcode() == Instruction::ICmp || getOpcode() == Instruction::FCmp; } -bool ConstantExpr::hasIndices() const { - return getOpcode() == Instruction::InsertValue; -} - -ArrayRef<unsigned> ConstantExpr::getIndices() const { - return cast<InsertValueConstantExpr>(this)->Indices; -} - unsigned ConstantExpr::getPredicate() const { return cast<CompareConstantExpr>(this)->predicate; } @@ -1539,9 +1529,6 @@ Constant *ConstantExpr::getWithOperands(ArrayRef<Constant *> Ops, Type *Ty, OnlyIfReducedTy); case Instruction::ExtractElement: return ConstantExpr::getExtractElement(Ops[0], Ops[1], OnlyIfReducedTy); - case Instruction::InsertValue: - return ConstantExpr::getInsertValue(Ops[0], Ops[1], getIndices(), - OnlyIfReducedTy); case Instruction::FNeg: return ConstantExpr::getFNeg(Ops[0]); case Instruction::ShuffleVector: @@ -2517,7 +2504,7 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C, if (InRangeIndex && *InRangeIndex < 63) SubClassOptionalData |= (*InRangeIndex + 1) << 1; const ConstantExprKeyType Key(Instruction::GetElementPtr, ArgVec, 0, - SubClassOptionalData, None, None, Ty); + SubClassOptionalData, None, Ty); LLVMContextImpl *pImpl = C->getContext().pImpl; return pImpl->ExprConstants.getOrCreate(ReqTy, Key); @@ -2638,36 +2625,12 @@ Constant *ConstantExpr::getShuffleVector(Constant *V1, Constant *V2, // Look up the constant in the table first to ensure uniqueness Constant *ArgVec[] = {V1, V2}; - ConstantExprKeyType Key(Instruction::ShuffleVector, ArgVec, 0, 0, None, Mask); + ConstantExprKeyType Key(Instruction::ShuffleVector, ArgVec, 0, 0, Mask); LLVMContextImpl *pImpl = ShufTy->getContext().pImpl; return pImpl->ExprConstants.getOrCreate(ShufTy, Key); } -Constant *ConstantExpr::getInsertValue(Constant *Agg, Constant *Val, - ArrayRef<unsigned> Idxs, - Type *OnlyIfReducedTy) { - assert(Agg->getType()->isFirstClassType() && - "Non-first-class type for constant insertvalue expression"); - - assert(ExtractValueInst::getIndexedType(Agg->getType(), - Idxs) == Val->getType() && - "insertvalue indices invalid!"); - Type *ReqTy = Val->getType(); - - if (Constant *FC = ConstantFoldInsertValueInstruction(Agg, Val, Idxs)) - return FC; - - if (OnlyIfReducedTy == ReqTy) - return nullptr; - - Constant *ArgVec[] = { Agg, Val }; - const ConstantExprKeyType Key(Instruction::InsertValue, ArgVec, 0, 0, Idxs); - - LLVMContextImpl *pImpl = Agg->getContext().pImpl; - return pImpl->ExprConstants.getOrCreate(ReqTy, Key); -} - Constant *ConstantExpr::getNeg(Constant *C, bool HasNUW, bool HasNSW) { assert(C->getType()->isIntOrIntVectorTy() && "Cannot NEG a nonintegral value!"); @@ -3517,9 +3480,6 @@ Instruction *ConstantExpr::getAsInstruction(Instruction *InsertBefore) const { return InsertElementInst::Create(Ops[0], Ops[1], Ops[2], "", InsertBefore); case Instruction::ExtractElement: return ExtractElementInst::Create(Ops[0], Ops[1], "", InsertBefore); - case Instruction::InsertValue: - return InsertValueInst::Create(Ops[0], Ops[1], getIndices(), "", - InsertBefore); case Instruction::ShuffleVector: return new ShuffleVectorInst(Ops[0], Ops[1], getShuffleMask(), "", InsertBefore); |