Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -962,7 +962,9 @@ else dstAdj = llvm::ConstantExpr::getNSWAdd(srcAdj, adj); - return llvm::ConstantExpr::getInsertValue(src, dstAdj, 1); + llvm::Constant *res = ConstantFoldInsertValueInstruction(src, dstAdj, 1); + assert(res != nullptr && "Folding must succeed"); + return res; } llvm::Constant * Index: llvm/bindings/go/llvm/ir.go =================================================================== --- llvm/bindings/go/llvm/ir.go +++ llvm/bindings/go/llvm/ir.go @@ -993,16 +993,6 @@ 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 Index: llvm/bindings/ocaml/llvm/llvm.ml =================================================================== --- llvm/bindings/ocaml/llvm/llvm.ml +++ llvm/bindings/ocaml/llvm/llvm.ml @@ -704,8 +704,6 @@ = "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" Index: llvm/bindings/ocaml/llvm/llvm.mli =================================================================== --- llvm/bindings/ocaml/llvm/llvm.mli +++ llvm/bindings/ocaml/llvm/llvm.mli @@ -1347,11 +1347,6 @@ 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 Index: llvm/bindings/ocaml/llvm/llvm_ocaml.c =================================================================== --- llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -1013,23 +1013,6 @@ 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) { Index: llvm/docs/ReleaseNotes.rst =================================================================== --- llvm/docs/ReleaseNotes.rst +++ llvm/docs/ReleaseNotes.rst @@ -71,6 +71,7 @@ * The constant expression variants of the following instructions have been removed: * ``extractvalue`` + * ``insertvalue`` Changes to building LLVM ------------------------ @@ -179,6 +180,7 @@ 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 -------------------------- Index: llvm/include/llvm-c/Core.h =================================================================== --- llvm/include/llvm-c/Core.h +++ llvm/include/llvm-c/Core.h @@ -2238,9 +2238,6 @@ 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. */ Index: llvm/include/llvm/Analysis/TargetFolder.h =================================================================== --- llvm/include/llvm/Analysis/TargetFolder.h +++ llvm/include/llvm/Analysis/TargetFolder.h @@ -118,7 +118,7 @@ auto *CAgg = dyn_cast(Agg); auto *CVal = dyn_cast(Val); if (CAgg && CVal) - return Fold(ConstantExpr::getInsertValue(CAgg, CVal, IdxList)); + return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList); return nullptr; } Index: llvm/include/llvm/IR/ConstantFolder.h =================================================================== --- llvm/include/llvm/IR/ConstantFolder.h +++ llvm/include/llvm/IR/ConstantFolder.h @@ -107,7 +107,7 @@ auto *CAgg = dyn_cast(Agg); auto *CVal = dyn_cast(Val); if (CAgg && CVal) - return ConstantExpr::getInsertValue(CAgg, CVal, IdxList); + return ConstantFoldInsertValueInstruction(CAgg, CVal, IdxList); return nullptr; } Index: llvm/include/llvm/IR/Constants.h =================================================================== --- llvm/include/llvm/IR/Constants.h +++ llvm/include/llvm/IR/Constants.h @@ -1201,10 +1201,6 @@ /// 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 @@ static Constant *getShuffleVector(Constant *V1, Constant *V2, ArrayRef Mask, Type *OnlyIfReducedTy = nullptr); - static Constant *getInsertValue(Constant *Agg, Constant *Val, - ArrayRef Idxs, - Type *OnlyIfReducedTy = nullptr); /// Return the opcode at the root of this constant expression unsigned getOpcode() const { return getSubclassDataFromValue(); } @@ -1305,10 +1298,6 @@ /// FCMP constant expression. unsigned getPredicate() const; - /// Assert that this is an insertvalue or exactvalue - /// expression and return the list of indices. - ArrayRef getIndices() const; - /// Assert that this is a shufflevector and return the mask. See class /// ShuffleVectorInst for a description of the mask representation. ArrayRef getShuffleMask() const; Index: llvm/lib/Analysis/ConstantFolding.cpp =================================================================== --- llvm/lib/Analysis/ConstantFolding.cpp +++ llvm/lib/Analysis/ConstantFolding.cpp @@ -1195,7 +1195,8 @@ } if (auto *IVI = dyn_cast(I)) - return ConstantExpr::getInsertValue(Ops[0], Ops[1], IVI->getIndices()); + return ConstantFoldInsertValueInstruction(Ops[0], Ops[1], + IVI->getIndices()); if (auto *EVI = dyn_cast(I)) return ConstantFoldExtractValueInstruction(Ops[0], EVI->getIndices()); Index: llvm/lib/Analysis/InlineCost.cpp =================================================================== --- llvm/lib/Analysis/InlineCost.cpp +++ llvm/lib/Analysis/InlineCost.cpp @@ -2089,9 +2089,9 @@ bool CallAnalyzer::visitInsertValue(InsertValueInst &I) { // Constant folding for insert value is trivial. if (simplifyInstruction(I, [&](SmallVectorImpl &COps) { - return ConstantExpr::getInsertValue(/*AggregateOperand*/ COps[0], - /*InsertedValueOperand*/ COps[1], - I.getIndices()); + return ConstantFoldInsertValueInstruction( + /*AggregateOperand*/ COps[0], /*InsertedValueOperand*/ COps[1], + I.getIndices()); })) return true; Index: llvm/lib/Analysis/Lint.cpp =================================================================== --- llvm/lib/Analysis/Lint.cpp +++ llvm/lib/Analysis/Lint.cpp @@ -686,11 +686,6 @@ CE->getOperand(0)->getType(), CE->getType(), *DL)) return findValueImpl(CE->getOperand(0), OffsetOk, Visited); - } else if (CE->getOpcode() == Instruction::ExtractValue) { - ArrayRef Indices = CE->getIndices(); - if (Value *W = FindInsertedValue(CE->getOperand(0), Indices)) - if (W != V) - return findValueImpl(W, OffsetOk, Visited); } } Index: llvm/lib/AsmParser/LLParser.cpp =================================================================== --- llvm/lib/AsmParser/LLParser.cpp +++ llvm/lib/AsmParser/LLParser.cpp @@ -3474,32 +3474,8 @@ } case lltok::kw_extractvalue: return error(ID.Loc, "extractvalue constexprs are no longer supported"); - case lltok::kw_insertvalue: { - Lex.Lex(); - Constant *Val0, *Val1; - SmallVector 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(); Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -528,8 +528,8 @@ void visitInsertElement(const User &I); void visitShuffleVector(const User &I); - void visitExtractValue(const User &I); - void visitInsertValue(const User &I); + void visitExtractValue(const ExtractValueInst &I); + void visitInsertValue(const InsertValueInst &I); void visitLandingPad(const LandingPadInst &LP); void visitGetElementPtr(const User &I); Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -3747,13 +3747,8 @@ setValue(&I, DAG.getBuildVector(VT, DL, Ops)); } -void SelectionDAGBuilder::visitInsertValue(const User &I) { - ArrayRef Indices; - if (const InsertValueInst *IV = dyn_cast(&I)) - Indices = IV->getIndices(); - else - Indices = cast(&I)->getIndices(); - +void SelectionDAGBuilder::visitInsertValue(const InsertValueInst &I) { + ArrayRef Indices = I.getIndices(); const Value *Op0 = I.getOperand(0); const Value *Op1 = I.getOperand(1); Type *AggTy = I.getType(); @@ -3801,13 +3796,8 @@ DAG.getVTList(AggValueVTs), Values)); } -void SelectionDAGBuilder::visitExtractValue(const User &I) { - ArrayRef Indices; - if (const ExtractValueInst *EV = dyn_cast(&I)) - Indices = EV->getIndices(); - else - Indices = cast(&I)->getIndices(); - +void SelectionDAGBuilder::visitExtractValue(const ExtractValueInst &I) { + ArrayRef Indices = I.getIndices(); const Value *Op0 = I.getOperand(0); Type *AggTy = Op0->getType(); Type *ValTy = I.getType(); Index: llvm/lib/IR/AsmWriter.cpp =================================================================== --- llvm/lib/IR/AsmWriter.cpp +++ llvm/lib/IR/AsmWriter.cpp @@ -1590,10 +1590,6 @@ Out << ", "; } - if (CE->hasIndices()) - for (unsigned I : CE->getIndices()) - Out << ", " << I; - if (CE->isCast()) { Out << " to "; WriterCtx.TypePrinter->print(CE->getType(), Out); Index: llvm/lib/IR/Constants.cpp =================================================================== --- llvm/lib/IR/Constants.cpp +++ llvm/lib/IR/Constants.cpp @@ -547,8 +547,6 @@ delete static_cast(C); else if (isa(C)) delete static_cast(C); - else if (isa(C)) - delete static_cast(C); else if (isa(C)) delete static_cast(C); else if (isa(C)) @@ -1488,14 +1486,6 @@ return getOpcode() == Instruction::ICmp || getOpcode() == Instruction::FCmp; } -bool ConstantExpr::hasIndices() const { - return getOpcode() == Instruction::InsertValue; -} - -ArrayRef ConstantExpr::getIndices() const { - return cast(this)->Indices; -} - unsigned ConstantExpr::getPredicate() const { return cast(this)->predicate; } @@ -1539,9 +1529,6 @@ 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 @@ 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 @@ // 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 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 @@ 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); Index: llvm/lib/IR/ConstantsContext.h =================================================================== --- llvm/lib/IR/ConstantsContext.h +++ llvm/lib/IR/ConstantsContext.h @@ -209,37 +209,6 @@ } }; -/// 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 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 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(V) && classof(cast(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 @@ : public FixedNumOperandTraits {}; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) -template <> -struct OperandTraits - : public FixedNumOperandTraits {}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value) - template <> struct OperandTraits : public VariadicOperandTraits {}; @@ -472,7 +436,6 @@ uint8_t SubclassOptionalData; uint16_t SubclassData; ArrayRef Ops; - ArrayRef Indexes; ArrayRef ShuffleMask; Type *ExplicitTy; @@ -482,12 +445,6 @@ return None; } - static ArrayRef getIndicesIfValid(const ConstantExpr *CE) { - if (CE->hasIndices()) - return CE->getIndices(); - return None; - } - static Type *getSourceElementTypeIfValid(const ConstantExpr *CE) { if (auto *GEPCE = dyn_cast(CE)) return GEPCE->getSourceElementType(); @@ -498,18 +455,17 @@ ConstantExprKeyType(unsigned Opcode, ArrayRef Ops, unsigned short SubclassData = 0, unsigned short SubclassOptionalData = 0, - ArrayRef Indexes = None, ArrayRef 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 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 @@ : 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 @@ 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 @@ 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 @@ 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 @@ 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); Index: llvm/lib/IR/Core.cpp =================================================================== --- llvm/lib/IR/Core.cpp +++ llvm/lib/IR/Core.cpp @@ -1875,14 +1875,6 @@ IntMask)); } -LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, - LLVMValueRef ElementValueConstant, - unsigned *IdxList, unsigned NumIdx) { - return wrap(ConstantExpr::getInsertValue(unwrap(AggConstant), - unwrap(ElementValueConstant), - makeArrayRef(IdxList, NumIdx))); -} - LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, @@ -3079,8 +3071,6 @@ return EV->getNumIndices(); if (auto *IV = dyn_cast(I)) return IV->getNumIndices(); - if (auto *CE = dyn_cast(I)) - return CE->getIndices().size(); llvm_unreachable( "LLVMGetNumIndices applies only to extractvalue and insertvalue!"); } @@ -3091,8 +3081,6 @@ return EV->getIndices().data(); if (auto *IV = dyn_cast(I)) return IV->getIndices().data(); - if (auto *CE = dyn_cast(I)) - return CE->getIndices().data(); llvm_unreachable( "LLVMGetIndices applies only to extractvalue and insertvalue!"); } Index: llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp =================================================================== --- llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp +++ llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp @@ -270,13 +270,6 @@ // ShuffleVector return Builder.CreateShuffleVector(NewOperands[0], NewOperands[1], NewOperands[2]); - case Instruction::ExtractValue: - // ExtractValueConstantExpr - return Builder.CreateExtractValue(NewOperands[0], C->getIndices()); - case Instruction::InsertValue: - // InsertValueConstantExpr - return Builder.CreateInsertValue(NewOperands[0], NewOperands[1], - C->getIndices()); case Instruction::GetElementPtr: // GetElementPtrConstantExpr return Builder.CreateGEP(cast(C)->getSourceElementType(), Index: llvm/lib/Transforms/Utils/Evaluator.cpp =================================================================== --- llvm/lib/Transforms/Utils/Evaluator.cpp +++ llvm/lib/Transforms/Utils/Evaluator.cpp @@ -368,9 +368,11 @@ LLVM_DEBUG(dbgs() << "Found an ExtractValueInst! Simplifying: " << *InstResult << "\n"); } else if (auto *IVI = dyn_cast(CurInst)) { - InstResult = ConstantExpr::getInsertValue( + InstResult = ConstantFoldInsertValueInstruction( getVal(IVI->getAggregateOperand()), getVal(IVI->getInsertedValueOperand()), IVI->getIndices()); + if (!InstResult) + return false; LLVM_DEBUG(dbgs() << "Found an InsertValueInst! Simplifying: " << *InstResult << "\n"); } else if (GetElementPtrInst *GEP = dyn_cast(CurInst)) { Index: llvm/test/Assembler/insertextractvalue.ll =================================================================== --- llvm/test/Assembler/insertextractvalue.ll +++ llvm/test/Assembler/insertextractvalue.ll @@ -14,31 +14,3 @@ 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) -} Index: llvm/test/Assembler/insertvalue-invalid-type-1.ll =================================================================== --- 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) -} Index: llvm/test/Assembler/unsupported-constexprs.ll =================================================================== --- llvm/test/Assembler/unsupported-constexprs.ll +++ 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) } Index: llvm/test/CodeGen/X86/nonconst-static-iv.ll =================================================================== --- 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 - -@0 = global i8 insertvalue( { i8 } select (i1 ptrtoint (ptr @1 to i1), { i8 } { i8 1 }, { i8 } { i8 2 }), i8 0, 0) -@1 = external global i32 - -; CHECK-ERRORS: Unsupported expression in static initializer: insertvalue -