[llvm] 7283f48 - [IR] Remove support for insertvalue constant expression
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 4 00:27:31 PDT 2022
Author: Nikita Popov
Date: 2022-07-04T09:27:22+02:00
New Revision: 7283f48a05de46fe8721ee6c29b1b6427e7d1a33
URL: https://github.com/llvm/llvm-project/commit/7283f48a05de46fe8721ee6c29b1b6427e7d1a33
DIFF: https://github.com/llvm/llvm-project/commit/7283f48a05de46fe8721ee6c29b1b6427e7d1a33.diff
LOG: [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
Added:
Modified:
llvm/bindings/go/llvm/ir.go
llvm/bindings/ocaml/llvm/llvm.ml
llvm/bindings/ocaml/llvm/llvm.mli
llvm/bindings/ocaml/llvm/llvm_ocaml.c
llvm/docs/ReleaseNotes.rst
llvm/include/llvm-c/Core.h
llvm/include/llvm/IR/Constants.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/ConstantsContext.h
llvm/lib/IR/Core.cpp
llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
llvm/test/Assembler/insertextractvalue.ll
llvm/test/Assembler/unsupported-constexprs.ll
Removed:
llvm/test/Assembler/insertvalue-invalid-type-1.ll
llvm/test/CodeGen/X86/nonconst-static-iv.ll
################################################################################
diff --git a/llvm/bindings/go/llvm/ir.go b/llvm/bindings/go/llvm/ir.go
index 14cad0cb7ed3..2ac1f15648f0 100644
--- a/llvm/bindings/go/llvm/ir.go
+++ b/llvm/bindings/go/llvm/ir.go
@@ -993,16 +993,6 @@ func ConstShuffleVector(veca, vecb, mask Value) (rv Value) {
return
}
-func ConstInsertValue(agg, val Value, indices []uint32) (rv Value) {
- n := len(indices)
- if n == 0 {
- panic("one or more indices are required")
- }
- ptr := (*C.unsigned)(&indices[0])
- rv.C = C.LLVMConstInsertValue(agg.C, val.C, ptr, C.unsigned(n))
- return
-}
-
func BlockAddress(f Value, bb BasicBlock) (v Value) {
v.C = C.LLVMBlockAddress(f.C, bb.C)
return
diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml
index bf8b96959f81..3c50e95cd4b1 100644
--- a/llvm/bindings/ocaml/llvm/llvm.ml
+++ b/llvm/bindings/ocaml/llvm/llvm.ml
@@ -704,8 +704,6 @@ external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
= "LLVMConstInsertElement"
external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
= "LLVMConstShuffleVector"
-external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
- = "llvm_const_insertvalue"
external const_inline_asm : lltype -> string -> string -> bool -> bool ->
llvalue
= "llvm_const_inline_asm"
diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli
index 385c3cc272d1..584545c74f42 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -1347,11 +1347,6 @@ val const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
See the method [llvm::ConstantExpr::getShuffleVector]. *)
val const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
-(** [const_insertvalue agg val idxs] inserts the value [val] in the specified
- indexs [idxs] in the aggregate [agg]. Each [idxs] must be less than the size
- of the aggregate. See the method [llvm::ConstantExpr::getInsertValue]. *)
-val const_insertvalue : llvalue -> llvalue -> int array -> llvalue
-
(** [const_inline_asm ty asm con side align] inserts a inline assembly string.
See the method [llvm::InlineAsm::get]. *)
val const_inline_asm : lltype -> string -> string -> bool -> bool -> llvalue
diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
index b10b1a3ed84a..e950972fc02f 100644
--- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -1013,23 +1013,6 @@ LLVMValueRef llvm_const_intcast(LLVMValueRef CV, LLVMTypeRef T,
return LLVMConstIntCast(CV, T, Bool_val(IsSigned));
}
-/* llvalue -> llvalue -> int array -> llvalue */
-LLVMValueRef llvm_const_insertvalue(LLVMValueRef Aggregate, LLVMValueRef Val,
- value Indices) {
- int size = Wosize_val(Indices);
- int i;
- LLVMValueRef result;
-
- unsigned *idxs = (unsigned *)malloc(size * sizeof(unsigned));
- for (i = 0; i < size; i++) {
- idxs[i] = Int_val(Field(Indices, i));
- }
-
- result = LLVMConstInsertValue(Aggregate, Val, idxs, size);
- free(idxs);
- return result;
-}
-
/* lltype -> string -> string -> bool -> bool -> llvalue */
LLVMValueRef llvm_const_inline_asm(LLVMTypeRef Ty, value Asm, value Constraints,
value HasSideEffects, value IsAlignStack) {
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 3b3345ed71e7..10e3d451e797 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -71,6 +71,7 @@ Changes to the LLVM IR
* The constant expression variants of the following instructions have been
removed:
* ``extractvalue``
+ * ``insertvalue``
Changes to building LLVM
------------------------
@@ -179,6 +180,7 @@ Changes to the C API
an instruction should be created using the ``LLVMBuildXYZ`` APIs, which will
constant fold the operands if possible and create an instruction otherwise:
* ``LLVMConstExtractValue``
+ * ``LLVMConstInsertValue``
Changes to the Go bindings
--------------------------
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 2abc29851cd9..c913cc6d0fad 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -2238,9 +2238,6 @@ LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
LLVMValueRef VectorBConstant,
LLVMValueRef MaskConstant);
-LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
- LLVMValueRef ElementValueConstant,
- unsigned *IdxList, unsigned NumIdx);
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
/** Deprecated: Use LLVMGetInlineAsm instead. */
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index b5445ff71b74..893ecb05703c 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1201,10 +1201,6 @@ class ConstantExpr : public Constant {
/// Return true if this is a compare constant expression
bool isCompare() const;
- /// Return true if this is an insertvalue or extractvalue expression,
- /// and the getIndices() method may be used.
- bool hasIndices() const;
-
/// Select constant expr
///
/// \param OnlyIfReducedTy see \a getWithOperands() docs.
@@ -1294,9 +1290,6 @@ class ConstantExpr : public Constant {
static Constant *getShuffleVector(Constant *V1, Constant *V2,
ArrayRef<int> Mask,
Type *OnlyIfReducedTy = nullptr);
- static Constant *getInsertValue(Constant *Agg, Constant *Val,
- ArrayRef<unsigned> Idxs,
- Type *OnlyIfReducedTy = nullptr);
/// Return the opcode at the root of this constant expression
unsigned getOpcode() const { return getSubclassDataFromValue(); }
@@ -1305,10 +1298,6 @@ class ConstantExpr : public Constant {
/// FCMP constant expression.
unsigned getPredicate() const;
- /// Assert that this is an insertvalue or exactvalue
- /// expression and return the list of indices.
- ArrayRef<unsigned> getIndices() const;
-
/// Assert that this is a shufflevector and return the mask. See class
/// ShuffleVectorInst for a description of the mask representation.
ArrayRef<int> getShuffleMask() const;
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index a1cdeac2b47f..fd11511c05d0 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3474,32 +3474,8 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
}
case lltok::kw_extractvalue:
return error(ID.Loc, "extractvalue constexprs are no longer supported");
- case lltok::kw_insertvalue: {
- Lex.Lex();
- Constant *Val0, *Val1;
- SmallVector<unsigned, 4> Indices;
- if (parseToken(lltok::lparen, "expected '(' in insertvalue constantexpr") ||
- parseGlobalTypeAndValue(Val0) ||
- parseToken(lltok::comma,
- "expected comma in insertvalue constantexpr") ||
- parseGlobalTypeAndValue(Val1) || parseIndexList(Indices) ||
- parseToken(lltok::rparen, "expected ')' in insertvalue constantexpr"))
- return true;
- if (!Val0->getType()->isAggregateType())
- return error(ID.Loc, "insertvalue operand must be aggregate type");
- Type *IndexedType =
- ExtractValueInst::getIndexedType(Val0->getType(), Indices);
- if (!IndexedType)
- return error(ID.Loc, "invalid indices for insertvalue");
- if (IndexedType != Val1->getType())
- return error(ID.Loc, "insertvalue operand and field disagree in type: '" +
- getTypeString(Val1->getType()) +
- "' instead of '" + getTypeString(IndexedType) +
- "'");
- ID.ConstantVal = ConstantExpr::getInsertValue(Val0, Val1, Indices);
- ID.Kind = ValID::t_Constant;
- return false;
- }
+ case lltok::kw_insertvalue:
+ return error(ID.Loc, "insertvalue constexprs are no longer supported");
case lltok::kw_icmp:
case lltok::kw_fcmp: {
unsigned PredVal, Opc = Lex.getUIntVal();
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 941ed808bab1..fa798a4b341e 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2674,9 +2674,6 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
Record.push_back(VE.getValueID(C->getOperand(1)));
Record.push_back(CE->getPredicate());
break;
- case Instruction::InsertValue:
- report_fatal_error("insertvalue constexprs not supported");
- break;
}
} else if (const BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
Code = bitc::CST_CODE_BLOCKADDRESS;
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 37d05cdba76d..b3e8f30725bf 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3747,13 +3747,8 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
setValue(&I, DAG.getBuildVector(VT, DL, Ops));
}
-void SelectionDAGBuilder::visitInsertValue(const User &I) {
- ArrayRef<unsigned> Indices;
- if (const InsertValueInst *IV = dyn_cast<InsertValueInst>(&I))
- Indices = IV->getIndices();
- else
- Indices = cast<ConstantExpr>(&I)->getIndices();
-
+void SelectionDAGBuilder::visitInsertValue(const InsertValueInst &I) {
+ ArrayRef<unsigned> Indices = I.getIndices();
const Value *Op0 = I.getOperand(0);
const Value *Op1 = I.getOperand(1);
Type *AggTy = I.getType();
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index 72cca3d9b001..4a3ab00614b3 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -529,7 +529,7 @@ class SelectionDAGBuilder {
void visitShuffleVector(const User &I);
void visitExtractValue(const ExtractValueInst &I);
- void visitInsertValue(const User &I);
+ void visitInsertValue(const InsertValueInst &I);
void visitLandingPad(const LandingPadInst &LP);
void visitGetElementPtr(const User &I);
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 596348ddb462..b558a5b9fa29 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1590,10 +1590,6 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
Out << ", ";
}
- if (CE->hasIndices())
- for (unsigned I : CE->getIndices())
- Out << ", " << I;
-
if (CE->isCast()) {
Out << " to ";
WriterCtx.TypePrinter->print(CE->getType(), Out);
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 0bf5e09d6647..961e52810b98 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);
diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h
index 21ef1c0d9f64..1d74e2d49f35 100644
--- a/llvm/lib/IR/ConstantsContext.h
+++ b/llvm/lib/IR/ConstantsContext.h
@@ -209,37 +209,6 @@ class ShuffleVectorConstantExpr final : public ConstantExpr {
}
};
-/// InsertValueConstantExpr - This class is private to
-/// Constants.cpp, and is used behind the scenes to implement
-/// insertvalue constant exprs.
-class InsertValueConstantExpr final : public ConstantExpr {
-public:
- InsertValueConstantExpr(Constant *Agg, Constant *Val,
- ArrayRef<unsigned> IdxList, Type *DestTy)
- : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2),
- Indices(IdxList.begin(), IdxList.end()) {
- Op<0>() = Agg;
- Op<1>() = Val;
- }
-
- // allocate space for exactly one operand
- void *operator new(size_t S) { return User::operator new(S, 2); }
- void operator delete(void *Ptr) { User::operator delete(Ptr); }
-
- /// Indices - These identify the position for the insertion.
- const SmallVector<unsigned, 4> Indices;
-
- /// Transparently provide more efficient getOperand methods.
- DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
-
- static bool classof(const ConstantExpr *CE) {
- return CE->getOpcode() == Instruction::InsertValue;
- }
- static bool classof(const Value *V) {
- return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
- }
-};
-
/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
/// used behind the scenes to implement getelementpr constant exprs.
class GetElementPtrConstantExpr final : public ConstantExpr {
@@ -332,11 +301,6 @@ struct OperandTraits<ShuffleVectorConstantExpr>
: public FixedNumOperandTraits<ShuffleVectorConstantExpr, 2> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value)
-template <>
-struct OperandTraits<InsertValueConstantExpr>
- : public FixedNumOperandTraits<InsertValueConstantExpr, 2> {};
-DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value)
-
template <>
struct OperandTraits<GetElementPtrConstantExpr>
: public VariadicOperandTraits<GetElementPtrConstantExpr, 1> {};
@@ -472,7 +436,6 @@ struct ConstantExprKeyType {
uint8_t SubclassOptionalData;
uint16_t SubclassData;
ArrayRef<Constant *> Ops;
- ArrayRef<unsigned> Indexes;
ArrayRef<int> ShuffleMask;
Type *ExplicitTy;
@@ -482,12 +445,6 @@ struct ConstantExprKeyType {
return None;
}
- static ArrayRef<unsigned> getIndicesIfValid(const ConstantExpr *CE) {
- if (CE->hasIndices())
- return CE->getIndices();
- return None;
- }
-
static Type *getSourceElementTypeIfValid(const ConstantExpr *CE) {
if (auto *GEPCE = dyn_cast<GetElementPtrConstantExpr>(CE))
return GEPCE->getSourceElementType();
@@ -498,18 +455,17 @@ struct ConstantExprKeyType {
ConstantExprKeyType(unsigned Opcode, ArrayRef<Constant *> Ops,
unsigned short SubclassData = 0,
unsigned short SubclassOptionalData = 0,
- ArrayRef<unsigned> Indexes = None,
ArrayRef<int> ShuffleMask = None,
Type *ExplicitTy = nullptr)
: Opcode(Opcode), SubclassOptionalData(SubclassOptionalData),
- SubclassData(SubclassData), Ops(Ops), Indexes(Indexes),
- ShuffleMask(ShuffleMask), ExplicitTy(ExplicitTy) {}
+ SubclassData(SubclassData), Ops(Ops), ShuffleMask(ShuffleMask),
+ ExplicitTy(ExplicitTy) {}
ConstantExprKeyType(ArrayRef<Constant *> Operands, const ConstantExpr *CE)
: Opcode(CE->getOpcode()),
SubclassOptionalData(CE->getRawSubclassOptionalData()),
SubclassData(CE->isCompare() ? CE->getPredicate() : 0), Ops(Operands),
- Indexes(getIndicesIfValid(CE)), ShuffleMask(getShuffleMaskIfValid(CE)),
+ ShuffleMask(getShuffleMaskIfValid(CE)),
ExplicitTy(getSourceElementTypeIfValid(CE)) {}
ConstantExprKeyType(const ConstantExpr *CE,
@@ -517,7 +473,7 @@ struct ConstantExprKeyType {
: Opcode(CE->getOpcode()),
SubclassOptionalData(CE->getRawSubclassOptionalData()),
SubclassData(CE->isCompare() ? CE->getPredicate() : 0),
- Indexes(getIndicesIfValid(CE)), ShuffleMask(getShuffleMaskIfValid(CE)),
+ ShuffleMask(getShuffleMaskIfValid(CE)),
ExplicitTy(getSourceElementTypeIfValid(CE)) {
assert(Storage.empty() && "Expected empty storage");
for (unsigned I = 0, E = CE->getNumOperands(); I != E; ++I)
@@ -528,8 +484,7 @@ struct ConstantExprKeyType {
bool operator==(const ConstantExprKeyType &X) const {
return Opcode == X.Opcode && SubclassData == X.SubclassData &&
SubclassOptionalData == X.SubclassOptionalData && Ops == X.Ops &&
- Indexes == X.Indexes && ShuffleMask == X.ShuffleMask &&
- ExplicitTy == X.ExplicitTy;
+ ShuffleMask == X.ShuffleMask && ExplicitTy == X.ExplicitTy;
}
bool operator==(const ConstantExpr *CE) const {
@@ -544,8 +499,6 @@ struct ConstantExprKeyType {
for (unsigned I = 0, E = Ops.size(); I != E; ++I)
if (Ops[I] != CE->getOperand(I))
return false;
- if (Indexes != getIndicesIfValid(CE))
- return false;
if (ShuffleMask != getShuffleMaskIfValid(CE))
return false;
if (ExplicitTy != getSourceElementTypeIfValid(CE))
@@ -557,7 +510,6 @@ struct ConstantExprKeyType {
return hash_combine(
Opcode, SubclassOptionalData, SubclassData,
hash_combine_range(Ops.begin(), Ops.end()),
- hash_combine_range(Indexes.begin(), Indexes.end()),
hash_combine_range(ShuffleMask.begin(), ShuffleMask.end()), ExplicitTy);
}
@@ -583,8 +535,6 @@ struct ConstantExprKeyType {
return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
case Instruction::ShuffleVector:
return new ShuffleVectorConstantExpr(Ops[0], Ops[1], ShuffleMask);
- case Instruction::InsertValue:
- return new InsertValueConstantExpr(Ops[0], Ops[1], Indexes, Ty);
case Instruction::GetElementPtr:
return GetElementPtrConstantExpr::Create(ExplicitTy, Ops[0], Ops.slice(1),
Ty, SubclassOptionalData);
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 4b9189ca5baa..e2473ab99091 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -1875,14 +1875,6 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
IntMask));
}
-LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
- LLVMValueRef ElementValueConstant,
- unsigned *IdxList, unsigned NumIdx) {
- return wrap(ConstantExpr::getInsertValue(unwrap<Constant>(AggConstant),
- unwrap<Constant>(ElementValueConstant),
- makeArrayRef(IdxList, NumIdx)));
-}
-
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
const char *Constraints,
LLVMBool HasSideEffects,
@@ -3079,8 +3071,6 @@ unsigned LLVMGetNumIndices(LLVMValueRef Inst) {
return EV->getNumIndices();
if (auto *IV = dyn_cast<InsertValueInst>(I))
return IV->getNumIndices();
- if (auto *CE = dyn_cast<ConstantExpr>(I))
- return CE->getIndices().size();
llvm_unreachable(
"LLVMGetNumIndices applies only to extractvalue and insertvalue!");
}
@@ -3091,8 +3081,6 @@ const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
return EV->getIndices().data();
if (auto *IV = dyn_cast<InsertValueInst>(I))
return IV->getIndices().data();
- if (auto *CE = dyn_cast<ConstantExpr>(I))
- return CE->getIndices().data();
llvm_unreachable(
"LLVMGetIndices applies only to extractvalue and insertvalue!");
}
diff --git a/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp b/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
index 2201eb19c80f..b4f7a64f144a 100644
--- a/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
@@ -270,10 +270,6 @@ Value *GenericToNVVM::remapConstantExpr(Module *M, Function *F, ConstantExpr *C,
// ShuffleVector
return Builder.CreateShuffleVector(NewOperands[0], NewOperands[1],
NewOperands[2]);
- case Instruction::InsertValue:
- // InsertValueConstantExpr
- return Builder.CreateInsertValue(NewOperands[0], NewOperands[1],
- C->getIndices());
case Instruction::GetElementPtr:
// GetElementPtrConstantExpr
return Builder.CreateGEP(cast<GEPOperator>(C)->getSourceElementType(),
diff --git a/llvm/test/Assembler/insertextractvalue.ll b/llvm/test/Assembler/insertextractvalue.ll
index 6621330cbcf8..d205e46e7f92 100644
--- a/llvm/test/Assembler/insertextractvalue.ll
+++ b/llvm/test/Assembler/insertextractvalue.ll
@@ -14,31 +14,3 @@ define float @foo({{i32},{float, double}}* %p) nounwind {
store {{i32},{float, double}} %r, {{i32},{float, double}}* %p
ret float %s
}
-
-; CHECK-LABEL: @bar
-; CHECK-NEXT: store { { i32 }, { float, double } } { { i32 } { i32 4 }, { float, double } { float 4.000000e+00, double 2.000000e+01 } }, { { i32 }, { float, double } }* %p
-define void @bar({{i32},{float, double}}* %p) nounwind {
- store {{i32},{float, double}} insertvalue ({{i32},{float, double}}{{i32}{i32 4},{float, double}{float 4.0, double 5.0}}, double 20.0, 1, 1), {{i32},{float, double}}* %p
- ret void
-}
-
-; CHECK-LABEL: @car
-; CHECK-NEXT: store { { i32 }, { float, double } } { { i32 } undef, { float, double } { float undef, double 2.000000e+01 } }, { { i32 }, { float, double } }* %p
-define void @car({{i32},{float, double}}* %p) nounwind {
- store {{i32},{float, double}} insertvalue ({{i32},{float, double}} undef, double 20.0, 1, 1), {{i32},{float, double}}* %p
- ret void
-}
-
-; CHECK-LABEL: @dar
-; CHECK-NEXT: store { { i32 }, { float, double } } { { i32 } zeroinitializer, { float, double } { float 0.000000e+00, double 2.000000e+01 } }, { { i32 }, { float, double } }* %p
-define void @dar({{i32},{float, double}}* %p) nounwind {
- store {{i32},{float, double}} insertvalue ({{i32},{float, double}} zeroinitializer, double 20.0, 1, 1), {{i32},{float, double}}* %p
- ret void
-}
-
-; PR4963
-; CHECK: @test57
-; CHECK-NEXT: ret <{ i32, i32 }> <{ i32 0, i32 4 }>
-define <{ i32, i32 }> @test57() {
- ret <{ i32, i32 }> insertvalue (<{ i32, i32 }> zeroinitializer, i32 4, 1)
-}
diff --git a/llvm/test/Assembler/insertvalue-invalid-type-1.ll b/llvm/test/Assembler/insertvalue-invalid-type-1.ll
deleted file mode 100644
index de9b782874be..000000000000
--- a/llvm/test/Assembler/insertvalue-invalid-type-1.ll
+++ /dev/null
@@ -1,7 +0,0 @@
-; RUN: not llvm-as < %s 2>&1 | FileCheck %s
-
-; CHECK: insertvalue operand and field disagree in type: 'i32' instead of 'i64'
-
-define <{ i32 }> @test() {
- ret <{ i32 }> insertvalue (<{ i64 }> zeroinitializer, i32 4, 0)
-}
diff --git a/llvm/test/Assembler/unsupported-constexprs.ll b/llvm/test/Assembler/unsupported-constexprs.ll
index 77c0af7bab83..955aed64bc7d 100644
--- a/llvm/test/Assembler/unsupported-constexprs.ll
+++ b/llvm/test/Assembler/unsupported-constexprs.ll
@@ -1,6 +1,15 @@
-; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+; RUN: split-file %s %t
+; RUN: not llvm-as < %t/extractvalue.ll 2>&1 | FileCheck %s --check-prefix=EXTRACTVALUE
+; RUN: not llvm-as < %t/insertvalue.ll 2>&1 | FileCheck %s --check-prefix=INSERTVALUE
-define float @extractvalue() {
-; CHECK: [[@LINE+1]]:13: error: extractvalue constexprs are no longer supported
- ret float extractvalue ({i32} {i32 3}, 0)
+;--- extractvalue.ll
+define i32 @extractvalue() {
+; EXTRACTVALUE: error: extractvalue constexprs are no longer supported
+ ret i32 extractvalue ({i32} {i32 3}, 0)
+}
+
+;--- insertvalue.ll
+define {i32} @insertvalue() {
+; INSERTVALUE: error: insertvalue constexprs are no longer supported
+ ret {i32} insertvalue ({i32} poison, i32 3, 0)
}
diff --git a/llvm/test/CodeGen/X86/nonconst-static-iv.ll b/llvm/test/CodeGen/X86/nonconst-static-iv.ll
deleted file mode 100644
index d77a09c7f44c..000000000000
--- a/llvm/test/CodeGen/X86/nonconst-static-iv.ll
+++ /dev/null
@@ -1,8 +0,0 @@
-; RUN: not --crash llc -mtriple=i686-linux-gnu < %s 2> %t
-; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s
-
- at 0 = global i8 insertvalue( { i8 } select (i1 ptrtoint (ptr @1 to i1), { i8 } { i8 1 }, { i8 } { i8 2 }), i8 0, 0)
- at 1 = external global i32
-
-; CHECK-ERRORS: Unsupported expression in static initializer: insertvalue
-
More information about the llvm-commits
mailing list