mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 22:06:06 +00:00
[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
This commit is contained in:
parent
1063dfc028
commit
7283f48a05
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
--------------------------
|
||||
|
@ -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. */
|
||||
|
@ -1201,10 +1201,6 @@ public:
|
||||
/// 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 @@ public:
|
||||
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 @@ public:
|
||||
/// 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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -529,7 +529,7 @@ private:
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -209,37 +209,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// 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 @@ private:
|
||||
uint8_t SubclassOptionalData;
|
||||
uint16_t SubclassData;
|
||||
ArrayRef<Constant *> Ops;
|
||||
ArrayRef<unsigned> Indexes;
|
||||
ArrayRef<int> ShuffleMask;
|
||||
Type *ExplicitTy;
|
||||
|
||||
@ -482,12 +445,6 @@ private:
|
||||
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 @@ public:
|
||||
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 @@ public:
|
||||
: 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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ public:
|
||||
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);
|
||||
|
@ -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!");
|
||||
}
|
||||
|
@ -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(),
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user