aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Constants.cpp36
-rw-r--r--llvm/lib/IR/ConstantsContext.h44
-rw-r--r--llvm/lib/IR/Function.cpp5
-rw-r--r--llvm/lib/IR/Globals.cpp11
-rw-r--r--llvm/lib/IR/Instruction.cpp4
-rw-r--r--llvm/lib/IR/Instructions.cpp235
-rw-r--r--llvm/lib/IR/User.cpp20
7 files changed, 182 insertions, 173 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index e32a54f..6d035d5 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -1267,9 +1267,9 @@ static Constant *getSequenceIfElementsMatch(Constant *C,
}
ConstantAggregate::ConstantAggregate(Type *T, ValueTy VT,
- ArrayRef<Constant *> V)
- : Constant(T, VT, OperandTraits<ConstantAggregate>::op_end(this) - V.size(),
- V.size()) {
+ ArrayRef<Constant *> V,
+ AllocInfo AllocInfo)
+ : Constant(T, VT, AllocInfo) {
llvm::copy(V, op_begin());
// Check that types match, unless this is an opaque struct.
@@ -1282,8 +1282,9 @@ ConstantAggregate::ConstantAggregate(Type *T, ValueTy VT,
}
}
-ConstantArray::ConstantArray(ArrayType *T, ArrayRef<Constant *> V)
- : ConstantAggregate(T, ConstantArrayVal, V) {
+ConstantArray::ConstantArray(ArrayType *T, ArrayRef<Constant *> V,
+ AllocInfo AllocInfo)
+ : ConstantAggregate(T, ConstantArrayVal, V, AllocInfo) {
assert(V.size() == T->getNumElements() &&
"Invalid initializer for constant array");
}
@@ -1346,8 +1347,9 @@ StructType *ConstantStruct::getTypeForElements(ArrayRef<Constant*> V,
return getTypeForElements(V[0]->getContext(), V, Packed);
}
-ConstantStruct::ConstantStruct(StructType *T, ArrayRef<Constant *> V)
- : ConstantAggregate(T, ConstantStructVal, V) {
+ConstantStruct::ConstantStruct(StructType *T, ArrayRef<Constant *> V,
+ AllocInfo AllocInfo)
+ : ConstantAggregate(T, ConstantStructVal, V, AllocInfo) {
assert((T->isOpaque() || V.size() == T->getNumElements()) &&
"Invalid initializer for constant struct");
}
@@ -1388,8 +1390,9 @@ Constant *ConstantStruct::get(StructType *ST, ArrayRef<Constant*> V) {
return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V);
}
-ConstantVector::ConstantVector(VectorType *T, ArrayRef<Constant *> V)
- : ConstantAggregate(T, ConstantVectorVal, V) {
+ConstantVector::ConstantVector(VectorType *T, ArrayRef<Constant *> V,
+ AllocInfo AllocInfo)
+ : ConstantAggregate(T, ConstantVectorVal, V, AllocInfo) {
assert(V.size() == cast<FixedVectorType>(T)->getNumElements() &&
"Invalid initializer for constant vector");
}
@@ -1879,7 +1882,7 @@ BlockAddress *BlockAddress::get(Function *F, BasicBlock *BB) {
BlockAddress::BlockAddress(Function *F, BasicBlock *BB)
: Constant(PointerType::get(F->getContext(), F->getAddressSpace()),
- Value::BlockAddressVal, &Op<0>(), 2) {
+ Value::BlockAddressVal, AllocMarker) {
setOperand(0, F);
setOperand(1, BB);
BB->AdjustBlockAddressRefCount(1);
@@ -1951,7 +1954,7 @@ DSOLocalEquivalent *DSOLocalEquivalent::get(GlobalValue *GV) {
}
DSOLocalEquivalent::DSOLocalEquivalent(GlobalValue *GV)
- : Constant(GV->getType(), Value::DSOLocalEquivalentVal, &Op<0>(), 1) {
+ : Constant(GV->getType(), Value::DSOLocalEquivalentVal, AllocMarker) {
setOperand(0, GV);
}
@@ -2009,7 +2012,7 @@ NoCFIValue *NoCFIValue::get(GlobalValue *GV) {
}
NoCFIValue::NoCFIValue(GlobalValue *GV)
- : Constant(GV->getType(), Value::NoCFIValueVal, &Op<0>(), 1) {
+ : Constant(GV->getType(), Value::NoCFIValueVal, AllocMarker) {
setOperand(0, GV);
}
@@ -2056,7 +2059,7 @@ ConstantPtrAuth *ConstantPtrAuth::getWithSameSchema(Constant *Pointer) const {
ConstantPtrAuth::ConstantPtrAuth(Constant *Ptr, ConstantInt *Key,
ConstantInt *Disc, Constant *AddrDisc)
- : Constant(Ptr->getType(), Value::ConstantPtrAuthVal, &Op<0>(), 4) {
+ : Constant(Ptr->getType(), Value::ConstantPtrAuthVal, AllocMarker) {
assert(Ptr->getType()->isPointerTy());
assert(Key->getBitWidth() == 32);
assert(Disc->getBitWidth() == 64);
@@ -2758,11 +2761,8 @@ const char *ConstantExpr::getOpcodeName() const {
GetElementPtrConstantExpr::GetElementPtrConstantExpr(
Type *SrcElementTy, Constant *C, ArrayRef<Constant *> IdxList, Type *DestTy,
- std::optional<ConstantRange> InRange)
- : ConstantExpr(DestTy, Instruction::GetElementPtr,
- OperandTraits<GetElementPtrConstantExpr>::op_end(this) -
- (IdxList.size() + 1),
- IdxList.size() + 1),
+ std::optional<ConstantRange> InRange, AllocInfo AllocInfo)
+ : ConstantExpr(DestTy, Instruction::GetElementPtr, AllocInfo),
SrcElementTy(SrcElementTy),
ResElementTy(GetElementPtrInst::getIndexedType(SrcElementTy, IdxList)),
InRange(std::move(InRange)) {
diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h
index bd19ec6..6afc86f 100644
--- a/llvm/lib/IR/ConstantsContext.h
+++ b/llvm/lib/IR/ConstantsContext.h
@@ -44,14 +44,16 @@ namespace llvm {
/// CastConstantExpr - This class is private to Constants.cpp, and is used
/// behind the scenes to implement cast constant exprs.
class CastConstantExpr final : public ConstantExpr {
+ constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
+
public:
CastConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
- : ConstantExpr(Ty, Opcode, &Op<0>(), 1) {
+ : ConstantExpr(Ty, Opcode, AllocMarker) {
Op<0>() = C;
}
// allocate space for exactly one operand
- void *operator new(size_t S) { return User::operator new(S, 1); }
+ void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
void operator delete(void *Ptr) { User::operator delete(Ptr); }
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -67,17 +69,19 @@ public:
/// BinaryConstantExpr - This class is private to Constants.cpp, and is used
/// behind the scenes to implement binary constant exprs.
class BinaryConstantExpr final : public ConstantExpr {
+ constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
+
public:
BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2,
unsigned Flags)
- : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) {
+ : ConstantExpr(C1->getType(), Opcode, AllocMarker) {
Op<0>() = C1;
Op<1>() = C2;
SubclassOptionalData = Flags;
}
// allocate space for exactly two operands
- void *operator new(size_t S) { return User::operator new(S, 2); }
+ void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
void operator delete(void *Ptr) { User::operator delete(Ptr); }
/// Transparently provide more efficient getOperand methods.
@@ -95,16 +99,18 @@ public:
/// Constants.cpp, and is used behind the scenes to implement
/// extractelement constant exprs.
class ExtractElementConstantExpr final : public ConstantExpr {
+ constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
+
public:
ExtractElementConstantExpr(Constant *C1, Constant *C2)
- : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
- Instruction::ExtractElement, &Op<0>(), 2) {
+ : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
+ Instruction::ExtractElement, AllocMarker) {
Op<0>() = C1;
Op<1>() = C2;
}
// allocate space for exactly two operands
- void *operator new(size_t S) { return User::operator new(S, 2); }
+ void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
void operator delete(void *Ptr) { User::operator delete(Ptr); }
/// Transparently provide more efficient getOperand methods.
@@ -122,17 +128,18 @@ public:
/// Constants.cpp, and is used behind the scenes to implement
/// insertelement constant exprs.
class InsertElementConstantExpr final : public ConstantExpr {
+ constexpr static IntrusiveOperandsAllocMarker AllocMarker{3};
+
public:
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
- : ConstantExpr(C1->getType(), Instruction::InsertElement,
- &Op<0>(), 3) {
+ : ConstantExpr(C1->getType(), Instruction::InsertElement, AllocMarker) {
Op<0>() = C1;
Op<1>() = C2;
Op<2>() = C3;
}
// allocate space for exactly three operands
- void *operator new(size_t S) { return User::operator new(S, 3); }
+ void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
void operator delete(void *Ptr) { User::operator delete(Ptr); }
/// Transparently provide more efficient getOperand methods.
@@ -150,12 +157,14 @@ public:
/// Constants.cpp, and is used behind the scenes to implement
/// shufflevector constant exprs.
class ShuffleVectorConstantExpr final : public ConstantExpr {
+ constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
+
public:
ShuffleVectorConstantExpr(Constant *C1, Constant *C2, ArrayRef<int> Mask)
: ConstantExpr(VectorType::get(
cast<VectorType>(C1->getType())->getElementType(),
Mask.size(), isa<ScalableVectorType>(C1->getType())),
- Instruction::ShuffleVector, &Op<0>(), 2) {
+ Instruction::ShuffleVector, AllocMarker) {
assert(ShuffleVectorInst::isValidOperands(C1, C2, Mask) &&
"Invalid shuffle vector instruction operands!");
Op<0>() = C1;
@@ -168,7 +177,7 @@ public:
SmallVector<int, 4> ShuffleMask;
Constant *ShuffleMaskForBitcode;
- void *operator new(size_t S) { return User::operator new(S, 2); }
+ void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
void operator delete(void *Ptr) { return User::operator delete(Ptr); }
/// Transparently provide more efficient getOperand methods.
@@ -191,15 +200,17 @@ class GetElementPtrConstantExpr : public ConstantExpr {
GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C,
ArrayRef<Constant *> IdxList, Type *DestTy,
- std::optional<ConstantRange> InRange);
+ std::optional<ConstantRange> InRange,
+ AllocInfo AllocInfo);
public:
static GetElementPtrConstantExpr *
Create(Type *SrcElementTy, Constant *C, ArrayRef<Constant *> IdxList,
Type *DestTy, unsigned Flags, std::optional<ConstantRange> InRange) {
- GetElementPtrConstantExpr *Result = new (IdxList.size() + 1)
+ IntrusiveOperandsAllocMarker AllocMarker{unsigned(IdxList.size() + 1)};
+ GetElementPtrConstantExpr *Result = new (AllocMarker)
GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy,
- std::move(InRange));
+ std::move(InRange), AllocMarker);
Result->SubclassOptionalData = Flags;
return Result;
}
@@ -318,7 +329,8 @@ template <class ConstantClass> struct ConstantAggrKeyType {
using TypeClass = typename ConstantInfo<ConstantClass>::TypeClass;
ConstantClass *create(TypeClass *Ty) const {
- return new (Operands.size()) ConstantClass(Ty, Operands);
+ User::IntrusiveOperandsAllocMarker AllocMarker{unsigned(Operands.size())};
+ return new (AllocMarker) ConstantClass(Ty, Operands, AllocMarker);
}
};
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index afef893..82ff4e1 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -402,7 +402,7 @@ Function *Function::createWithDefaultAttr(FunctionType *Ty,
LinkageTypes Linkage,
unsigned AddrSpace, const Twine &N,
Module *M) {
- auto *F = new Function(Ty, Linkage, AddrSpace, N, M);
+ auto *F = new (AllocMarker) Function(Ty, Linkage, AddrSpace, N, M);
AttrBuilder B(F->getContext());
UWTableKind UWTable = M->getUwtable();
if (UWTable != UWTableKind::None)
@@ -501,8 +501,7 @@ static unsigned computeAddrSpace(unsigned AddrSpace, Module *M) {
Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
const Twine &name, Module *ParentModule)
- : GlobalObject(Ty, Value::FunctionVal,
- OperandTraits<Function>::op_begin(this), 0, Linkage, name,
+ : GlobalObject(Ty, Value::FunctionVal, AllocMarker, Linkage, name,
computeAddrSpace(AddrSpace, ParentModule)),
NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
assert(FunctionType::isValidReturnType(getReturnType()) &&
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 2bc69cd..99f4fa5 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -442,9 +442,8 @@ GlobalVariable::GlobalVariable(Type *Ty, bool constant, LinkageTypes Link,
Constant *InitVal, const Twine &Name,
ThreadLocalMode TLMode, unsigned AddressSpace,
bool isExternallyInitialized)
- : GlobalObject(Ty, Value::GlobalVariableVal,
- OperandTraits<GlobalVariable>::op_begin(this),
- InitVal != nullptr, Link, Name, AddressSpace),
+ : GlobalObject(Ty, Value::GlobalVariableVal, AllocMarker, Link, Name,
+ AddressSpace),
isConstantGlobal(constant),
isExternallyInitializedConstant(isExternallyInitialized) {
assert(!Ty->isFunctionTy() && PointerType::isValidElementType(Ty) &&
@@ -454,6 +453,8 @@ GlobalVariable::GlobalVariable(Type *Ty, bool constant, LinkageTypes Link,
assert(InitVal->getType() == Ty &&
"Initializer should be the same type as the GlobalVariable!");
Op<0>() = InitVal;
+ } else {
+ setGlobalVariableNumOperands(0);
}
}
@@ -540,7 +541,7 @@ void GlobalVariable::setCodeModel(CodeModel::Model CM) {
GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
const Twine &Name, Constant *Aliasee,
Module *ParentModule)
- : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name,
+ : GlobalValue(Ty, Value::GlobalAliasVal, AllocMarker, Link, Name,
AddressSpace) {
setAliasee(Aliasee);
if (ParentModule)
@@ -597,7 +598,7 @@ const GlobalObject *GlobalAlias::getAliaseeObject() const {
GlobalIFunc::GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
const Twine &Name, Constant *Resolver,
Module *ParentModule)
- : GlobalObject(Ty, Value::GlobalIFuncVal, &Op<0>(), 1, Link, Name,
+ : GlobalObject(Ty, Value::GlobalIFuncVal, AllocMarker, Link, Name,
AddressSpace) {
setResolver(Resolver);
if (ParentModule)
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 62d88ce..b1c2b02 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -32,9 +32,9 @@ InsertPosition::InsertPosition(Instruction *InsertBefore)
InsertPosition::InsertPosition(BasicBlock *InsertAtEnd)
: InsertAt(InsertAtEnd ? InsertAtEnd->end() : InstListType::iterator()) {}
-Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
+Instruction::Instruction(Type *ty, unsigned it, AllocInfo AllocInfo,
InsertPosition InsertBefore)
- : User(ty, Value::InstructionVal + it, Ops, NumOps) {
+ : User(ty, Value::InstructionVal + it, AllocInfo) {
// When called with an iterator, there must be a block to insert into.
if (InstListType::iterator InsertIt = InsertBefore; InsertIt.isValid()) {
BasicBlock *BB = InsertIt.getNodeParent();
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 19da1f6..e95b98a 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -121,8 +121,9 @@ const char *SelectInst::areInvalidOperands(Value *Op0, Value *Op1, Value *Op2) {
//===----------------------------------------------------------------------===//
PHINode::PHINode(const PHINode &PN)
- : Instruction(PN.getType(), Instruction::PHI, nullptr, PN.getNumOperands()),
+ : Instruction(PN.getType(), Instruction::PHI, AllocMarker),
ReservedSpace(PN.getNumOperands()) {
+ NumUserOperands = PN.getNumOperands();
allocHungoffUses(PN.getNumOperands());
std::copy(PN.op_begin(), PN.op_end(), op_begin());
copyIncomingBlocks(make_range(PN.block_begin(), PN.block_end()));
@@ -243,14 +244,14 @@ bool PHINode::hasConstantOrUndefValue() const {
LandingPadInst::LandingPadInst(Type *RetTy, unsigned NumReservedValues,
const Twine &NameStr,
InsertPosition InsertBefore)
- : Instruction(RetTy, Instruction::LandingPad, nullptr, 0, InsertBefore) {
+ : Instruction(RetTy, Instruction::LandingPad, AllocMarker, InsertBefore) {
init(NumReservedValues, NameStr);
}
LandingPadInst::LandingPadInst(const LandingPadInst &LP)
- : Instruction(LP.getType(), Instruction::LandingPad, nullptr,
- LP.getNumOperands()),
+ : Instruction(LP.getType(), Instruction::LandingPad, AllocMarker),
ReservedSpace(LP.getNumOperands()) {
+ NumUserOperands = LP.getNumOperands();
allocHungoffUses(LP.getNumOperands());
Use *OL = getOperandList();
const Use *InOL = LP.getOperandList();
@@ -716,16 +717,16 @@ void CallInst::init(FunctionType *FTy, Value *Func, const Twine &NameStr) {
}
CallInst::CallInst(FunctionType *Ty, Value *Func, const Twine &Name,
- InsertPosition InsertBefore)
- : CallBase(Ty->getReturnType(), Instruction::Call,
- OperandTraits<CallBase>::op_end(this) - 1, 1, InsertBefore) {
+ AllocInfo AllocInfo, InsertPosition InsertBefore)
+ : CallBase(Ty->getReturnType(), Instruction::Call, AllocInfo,
+ InsertBefore) {
init(Ty, Func, Name);
}
-CallInst::CallInst(const CallInst &CI)
- : CallBase(CI.Attrs, CI.FTy, CI.getType(), Instruction::Call,
- OperandTraits<CallBase>::op_end(this) - CI.getNumOperands(),
- CI.getNumOperands()) {
+CallInst::CallInst(const CallInst &CI, AllocInfo AllocInfo)
+ : CallBase(CI.Attrs, CI.FTy, CI.getType(), Instruction::Call, AllocInfo) {
+ assert(getNumOperands() == CI.getNumOperands() &&
+ "Wrong number of operands allocated");
setTailCallKind(CI.getTailCallKind());
setCallingConv(CI.getCallingConv());
@@ -774,7 +775,7 @@ void InvokeInst::init(FunctionType *FTy, Value *Fn, BasicBlock *IfNormal,
const Twine &NameStr) {
this->FTy = FTy;
- assert((int)getNumOperands() ==
+ assert(getNumOperands() ==
ComputeNumOperands(Args.size(), CountBundleInputs(Bundles)) &&
"NumOperands not set up?");
@@ -803,10 +804,10 @@ void InvokeInst::init(FunctionType *FTy, Value *Fn, BasicBlock *IfNormal,
setName(NameStr);
}
-InvokeInst::InvokeInst(const InvokeInst &II)
- : CallBase(II.Attrs, II.FTy, II.getType(), Instruction::Invoke,
- OperandTraits<CallBase>::op_end(this) - II.getNumOperands(),
- II.getNumOperands()) {
+InvokeInst::InvokeInst(const InvokeInst &II, AllocInfo AllocInfo)
+ : CallBase(II.Attrs, II.FTy, II.getType(), Instruction::Invoke, AllocInfo) {
+ assert(getNumOperands() == II.getNumOperands() &&
+ "Wrong number of operands allocated");
setCallingConv(II.getCallingConv());
std::copy(II.op_begin(), II.op_end(), op_begin());
std::copy(II.bundle_op_info_begin(), II.bundle_op_info_end(),
@@ -855,9 +856,9 @@ void CallBrInst::init(FunctionType *FTy, Value *Fn, BasicBlock *Fallthrough,
const Twine &NameStr) {
this->FTy = FTy;
- assert((int)getNumOperands() ==
- ComputeNumOperands(Args.size(), IndirectDests.size(),
- CountBundleInputs(Bundles)) &&
+ assert(getNumOperands() == ComputeNumOperands(Args.size(),
+ IndirectDests.size(),
+ CountBundleInputs(Bundles)) &&
"NumOperands not set up?");
#ifndef NDEBUG
@@ -887,10 +888,11 @@ void CallBrInst::init(FunctionType *FTy, Value *Fn, BasicBlock *Fallthrough,
setName(NameStr);
}
-CallBrInst::CallBrInst(const CallBrInst &CBI)
+CallBrInst::CallBrInst(const CallBrInst &CBI, AllocInfo AllocInfo)
: CallBase(CBI.Attrs, CBI.FTy, CBI.getType(), Instruction::CallBr,
- OperandTraits<CallBase>::op_end(this) - CBI.getNumOperands(),
- CBI.getNumOperands()) {
+ AllocInfo) {
+ assert(getNumOperands() == CBI.getNumOperands() &&
+ "Wrong number of operands allocated");
setCallingConv(CBI.getCallingConv());
std::copy(CBI.op_begin(), CBI.op_end(), op_begin());
std::copy(CBI.bundle_op_info_begin(), CBI.bundle_op_info_end(),
@@ -918,19 +920,19 @@ CallBrInst *CallBrInst::Create(CallBrInst *CBI, ArrayRef<OperandBundleDef> OpB,
// ReturnInst Implementation
//===----------------------------------------------------------------------===//
-ReturnInst::ReturnInst(const ReturnInst &RI)
+ReturnInst::ReturnInst(const ReturnInst &RI, AllocInfo AllocInfo)
: Instruction(Type::getVoidTy(RI.getContext()), Instruction::Ret,
- OperandTraits<ReturnInst>::op_end(this) - RI.getNumOperands(),
- RI.getNumOperands()) {
+ AllocInfo) {
+ assert(getNumOperands() == RI.getNumOperands() &&
+ "Wrong number of operands allocated");
if (RI.getNumOperands())
Op<0>() = RI.Op<0>();
SubclassOptionalData = RI.SubclassOptionalData;
}
-ReturnInst::ReturnInst(LLVMContext &C, Value *retVal,
+ReturnInst::ReturnInst(LLVMContext &C, Value *retVal, AllocInfo AllocInfo,
InsertPosition InsertBefore)
- : Instruction(Type::getVoidTy(C), Instruction::Ret,
- OperandTraits<ReturnInst>::op_end(this) - !!retVal, !!retVal,
+ : Instruction(Type::getVoidTy(C), Instruction::Ret, AllocInfo,
InsertBefore) {
if (retVal)
Op<0>() = retVal;
@@ -942,13 +944,13 @@ ReturnInst::ReturnInst(LLVMContext &C, Value *retVal,
ResumeInst::ResumeInst(const ResumeInst &RI)
: Instruction(Type::getVoidTy(RI.getContext()), Instruction::Resume,
- OperandTraits<ResumeInst>::op_begin(this), 1) {
+ AllocMarker) {
Op<0>() = RI.Op<0>();
}
ResumeInst::ResumeInst(Value *Exn, InsertPosition InsertBefore)
: Instruction(Type::getVoidTy(Exn->getContext()), Instruction::Resume,
- OperandTraits<ResumeInst>::op_begin(this), 1, InsertBefore) {
+ AllocMarker, InsertBefore) {
Op<0>() = Exn;
}
@@ -956,11 +958,11 @@ ResumeInst::ResumeInst(Value *Exn, InsertPosition InsertBefore)
// CleanupReturnInst Implementation
//===----------------------------------------------------------------------===//
-CleanupReturnInst::CleanupReturnInst(const CleanupReturnInst &CRI)
- : Instruction(CRI.getType(), Instruction::CleanupRet,
- OperandTraits<CleanupReturnInst>::op_end(this) -
- CRI.getNumOperands(),
- CRI.getNumOperands()) {
+CleanupReturnInst::CleanupReturnInst(const CleanupReturnInst &CRI,
+ AllocInfo AllocInfo)
+ : Instruction(CRI.getType(), Instruction::CleanupRet, AllocInfo) {
+ assert(getNumOperands() == CRI.getNumOperands() &&
+ "Wrong number of operands allocated");
setSubclassData<Instruction::OpaqueField>(
CRI.getSubclassData<Instruction::OpaqueField>());
Op<0>() = CRI.Op<0>();
@@ -978,12 +980,10 @@ void CleanupReturnInst::init(Value *CleanupPad, BasicBlock *UnwindBB) {
}
CleanupReturnInst::CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB,
- unsigned Values,
+ AllocInfo AllocInfo,
InsertPosition InsertBefore)
: Instruction(Type::getVoidTy(CleanupPad->getContext()),
- Instruction::CleanupRet,
- OperandTraits<CleanupReturnInst>::op_end(this) - Values,
- Values, InsertBefore) {
+ Instruction::CleanupRet, AllocInfo, InsertBefore) {
init(CleanupPad, UnwindBB);
}
@@ -997,7 +997,7 @@ void CatchReturnInst::init(Value *CatchPad, BasicBlock *BB) {
CatchReturnInst::CatchReturnInst(const CatchReturnInst &CRI)
: Instruction(Type::getVoidTy(CRI.getContext()), Instruction::CatchRet,
- OperandTraits<CatchReturnInst>::op_begin(this), 2) {
+ AllocMarker) {
Op<0>() = CRI.Op<0>();
Op<1>() = CRI.Op<1>();
}
@@ -1005,8 +1005,7 @@ CatchReturnInst::CatchReturnInst(const CatchReturnInst &CRI)
CatchReturnInst::CatchReturnInst(Value *CatchPad, BasicBlock *BB,
InsertPosition InsertBefore)
: Instruction(Type::getVoidTy(BB->getContext()), Instruction::CatchRet,
- OperandTraits<CatchReturnInst>::op_begin(this), 2,
- InsertBefore) {
+ AllocMarker, InsertBefore) {
init(CatchPad, BB);
}
@@ -1018,7 +1017,7 @@ CatchSwitchInst::CatchSwitchInst(Value *ParentPad, BasicBlock *UnwindDest,
unsigned NumReservedValues,
const Twine &NameStr,
InsertPosition InsertBefore)
- : Instruction(ParentPad->getType(), Instruction::CatchSwitch, nullptr, 0,
+ : Instruction(ParentPad->getType(), Instruction::CatchSwitch, AllocMarker,
InsertBefore) {
if (UnwindDest)
++NumReservedValues;
@@ -1027,8 +1026,8 @@ CatchSwitchInst::CatchSwitchInst(Value *ParentPad, BasicBlock *UnwindDest,
}
CatchSwitchInst::CatchSwitchInst(const CatchSwitchInst &CSI)
- : Instruction(CSI.getType(), Instruction::CatchSwitch, nullptr,
- CSI.getNumOperands()) {
+ : Instruction(CSI.getType(), Instruction::CatchSwitch, AllocMarker) {
+ NumUserOperands = CSI.NumUserOperands;
init(CSI.getParentPad(), CSI.getUnwindDest(), CSI.getNumOperands());
setNumHungOffUseOperands(ReservedSpace);
Use *OL = getOperandList();
@@ -1093,22 +1092,19 @@ void FuncletPadInst::init(Value *ParentPad, ArrayRef<Value *> Args,
setName(NameStr);
}
-FuncletPadInst::FuncletPadInst(const FuncletPadInst &FPI)
- : Instruction(FPI.getType(), FPI.getOpcode(),
- OperandTraits<FuncletPadInst>::op_end(this) -
- FPI.getNumOperands(),
- FPI.getNumOperands()) {
+FuncletPadInst::FuncletPadInst(const FuncletPadInst &FPI, AllocInfo AllocInfo)
+ : Instruction(FPI.getType(), FPI.getOpcode(), AllocInfo) {
+ assert(getNumOperands() == FPI.getNumOperands() &&
+ "Wrong number of operands allocated");
std::copy(FPI.op_begin(), FPI.op_end(), op_begin());
setParentPad(FPI.getParentPad());
}
FuncletPadInst::FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
- ArrayRef<Value *> Args, unsigned Values,
+ ArrayRef<Value *> Args, AllocInfo AllocInfo,
const Twine &NameStr,
InsertPosition InsertBefore)
- : Instruction(ParentPad->getType(), Op,
- OperandTraits<FuncletPadInst>::op_end(this) - Values, Values,
- InsertBefore) {
+ : Instruction(ParentPad->getType(), Op, AllocInfo, InsertBefore) {
init(ParentPad, Args, NameStr);
}
@@ -1118,8 +1114,8 @@ FuncletPadInst::FuncletPadInst(Instruction::FuncletPadOps Op, Value *ParentPad,
UnreachableInst::UnreachableInst(LLVMContext &Context,
InsertPosition InsertBefore)
- : Instruction(Type::getVoidTy(Context), Instruction::Unreachable, nullptr,
- 0, InsertBefore) {}
+ : Instruction(Type::getVoidTy(Context), Instruction::Unreachable,
+ AllocMarker, InsertBefore) {}
//===----------------------------------------------------------------------===//
// BranchInst Implementation
@@ -1131,19 +1127,18 @@ void BranchInst::AssertOK() {
"May only branch on boolean predicates!");
}
-BranchInst::BranchInst(BasicBlock *IfTrue, InsertPosition InsertBefore)
+BranchInst::BranchInst(BasicBlock *IfTrue, AllocInfo AllocInfo,
+ InsertPosition InsertBefore)
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
- OperandTraits<BranchInst>::op_end(this) - 1, 1,
- InsertBefore) {
+ AllocInfo, InsertBefore) {
assert(IfTrue && "Branch destination may not be null!");
Op<-1>() = IfTrue;
}
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
- InsertPosition InsertBefore)
+ AllocInfo AllocInfo, InsertPosition InsertBefore)
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
- OperandTraits<BranchInst>::op_end(this) - 3, 3,
- InsertBefore) {
+ AllocInfo, InsertBefore) {
// Assign in order of operand index to make use-list order predictable.
Op<-3>() = Cond;
Op<-2>() = IfFalse;
@@ -1153,10 +1148,11 @@ BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
#endif
}
-BranchInst::BranchInst(const BranchInst &BI)
+BranchInst::BranchInst(const BranchInst &BI, AllocInfo AllocInfo)
: Instruction(Type::getVoidTy(BI.getContext()), Instruction::Br,
- OperandTraits<BranchInst>::op_end(this) - BI.getNumOperands(),
- BI.getNumOperands()) {
+ AllocInfo) {
+ assert(getNumOperands() == BI.getNumOperands() &&
+ "Wrong number of operands allocated");
// Assign in order of operand index to make use-list order predictable.
if (BI.getNumOperands() != 1) {
assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!");
@@ -1313,9 +1309,8 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Align Align,
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Align Align,
AtomicOrdering Order, SyncScope::ID SSID,
InsertPosition InsertBefore)
- : Instruction(Type::getVoidTy(val->getContext()), Store,
- OperandTraits<StoreInst>::op_begin(this),
- OperandTraits<StoreInst>::operands(this), InsertBefore) {
+ : Instruction(Type::getVoidTy(val->getContext()), Store, AllocMarker,
+ InsertBefore) {
Op<0>() = val;
Op<1>() = addr;
setVolatile(isVolatile);
@@ -1356,8 +1351,7 @@ AtomicCmpXchgInst::AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal,
InsertPosition InsertBefore)
: Instruction(
StructType::get(Cmp->getType(), Type::getInt1Ty(Cmp->getContext())),
- AtomicCmpXchg, OperandTraits<AtomicCmpXchgInst>::op_begin(this),
- OperandTraits<AtomicCmpXchgInst>::operands(this), InsertBefore) {
+ AtomicCmpXchg, AllocMarker, InsertBefore) {
Init(Ptr, Cmp, NewVal, Alignment, SuccessOrdering, FailureOrdering, SSID);
}
@@ -1389,9 +1383,7 @@ void AtomicRMWInst::Init(BinOp Operation, Value *Ptr, Value *Val,
AtomicRMWInst::AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val,
Align Alignment, AtomicOrdering Ordering,
SyncScope::ID SSID, InsertPosition InsertBefore)
- : Instruction(Val->getType(), AtomicRMW,
- OperandTraits<AtomicRMWInst>::op_begin(this),
- OperandTraits<AtomicRMWInst>::operands(this), InsertBefore) {
+ : Instruction(Val->getType(), AtomicRMW, AllocMarker, InsertBefore) {
Init(Operation, Ptr, Val, Alignment, Ordering, SSID);
}
@@ -1448,7 +1440,7 @@ StringRef AtomicRMWInst::getOperationName(BinOp Op) {
FenceInst::FenceInst(LLVMContext &C, AtomicOrdering Ordering,
SyncScope::ID SSID, InsertPosition InsertBefore)
- : Instruction(Type::getVoidTy(C), Fence, nullptr, 0, InsertBefore) {
+ : Instruction(Type::getVoidTy(C), Fence, AllocMarker, InsertBefore) {
setOrdering(Ordering);
setSyncScopeID(SSID);
}
@@ -1466,13 +1458,13 @@ void GetElementPtrInst::init(Value *Ptr, ArrayRef<Value *> IdxList,
setName(Name);
}
-GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
- : Instruction(GEPI.getType(), GetElementPtr,
- OperandTraits<GetElementPtrInst>::op_end(this) -
- GEPI.getNumOperands(),
- GEPI.getNumOperands()),
+GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI,
+ AllocInfo AllocInfo)
+ : Instruction(GEPI.getType(), GetElementPtr, AllocInfo),
SourceElementType(GEPI.SourceElementType),
ResultElementType(GEPI.ResultElementType) {
+ assert(getNumOperands() == GEPI.getNumOperands() &&
+ "Wrong number of operands allocated");
std::copy(GEPI.op_begin(), GEPI.op_end(), op_begin());
SubclassOptionalData = GEPI.SubclassOptionalData;
}
@@ -1606,9 +1598,8 @@ bool GetElementPtrInst::collectOffset(
ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
const Twine &Name,
InsertPosition InsertBef)
- : Instruction(
- cast<VectorType>(Val->getType())->getElementType(), ExtractElement,
- OperandTraits<ExtractElementInst>::op_begin(this), 2, InsertBef) {
+ : Instruction(cast<VectorType>(Val->getType())->getElementType(),
+ ExtractElement, AllocMarker, InsertBef) {
assert(isValidOperands(Val, Index) &&
"Invalid extractelement instruction operands!");
Op<0>() = Val;
@@ -1629,9 +1620,7 @@ bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
const Twine &Name,
InsertPosition InsertBef)
- : Instruction(Vec->getType(), InsertElement,
- OperandTraits<InsertElementInst>::op_begin(this), 3,
- InsertBef) {
+ : Instruction(Vec->getType(), InsertElement, AllocMarker, InsertBef) {
assert(isValidOperands(Vec, Elt, Index) &&
"Invalid insertelement instruction operands!");
Op<0>() = Vec;
@@ -1679,8 +1668,7 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
: Instruction(
VectorType::get(cast<VectorType>(V1->getType())->getElementType(),
cast<VectorType>(Mask->getType())->getElementCount()),
- ShuffleVector, OperandTraits<ShuffleVectorInst>::op_begin(this),
- OperandTraits<ShuffleVectorInst>::operands(this), InsertBefore) {
+ ShuffleVector, AllocMarker, InsertBefore) {
assert(isValidOperands(V1, V2, Mask) &&
"Invalid shuffle vector instruction operands!");
@@ -1698,8 +1686,7 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, ArrayRef<int> Mask,
: Instruction(
VectorType::get(cast<VectorType>(V1->getType())->getElementType(),
Mask.size(), isa<ScalableVectorType>(V1->getType())),
- ShuffleVector, OperandTraits<ShuffleVectorInst>::op_begin(this),
- OperandTraits<ShuffleVectorInst>::operands(this), InsertBefore) {
+ ShuffleVector, AllocMarker, InsertBefore) {
assert(isValidOperands(V1, V2, Mask) &&
"Invalid shuffle vector instruction operands!");
Op<0>() = V1;
@@ -2464,9 +2451,8 @@ void InsertValueInst::init(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs,
}
InsertValueInst::InsertValueInst(const InsertValueInst &IVI)
- : Instruction(IVI.getType(), InsertValue,
- OperandTraits<InsertValueInst>::op_begin(this), 2),
- Indices(IVI.Indices) {
+ : Instruction(IVI.getType(), InsertValue, AllocMarker),
+ Indices(IVI.Indices) {
Op<0>() = IVI.getOperand(0);
Op<1>() = IVI.getOperand(1);
SubclassOptionalData = IVI.SubclassOptionalData;
@@ -2565,8 +2551,7 @@ void UnaryOperator::AssertOK() {
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
const Twine &Name, InsertPosition InsertBefore)
- : Instruction(Ty, iType, OperandTraits<BinaryOperator>::op_begin(this),
- OperandTraits<BinaryOperator>::operands(this), InsertBefore) {
+ : Instruction(Ty, iType, AllocMarker, InsertBefore) {
Op<0>() = S1;
Op<1>() = S2;
setName(Name);
@@ -3427,8 +3412,7 @@ AddrSpaceCastInst::AddrSpaceCastInst(Value *S, Type *Ty, const Twine &Name,
CmpInst::CmpInst(Type *ty, OtherOps op, Predicate predicate, Value *LHS,
Value *RHS, const Twine &Name, InsertPosition InsertBefore,
Instruction *FlagsSource)
- : Instruction(ty, op, OperandTraits<CmpInst>::op_begin(this),
- OperandTraits<CmpInst>::operands(this), InsertBefore) {
+ : Instruction(ty, op, AllocMarker, InsertBefore) {
Op<0>() = LHS;
Op<1>() = RHS;
setPredicate((Predicate)predicate);
@@ -3918,12 +3902,12 @@ void SwitchInst::init(Value *Value, BasicBlock *Default, unsigned NumReserved) {
SwitchInst::SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
InsertPosition InsertBefore)
: Instruction(Type::getVoidTy(Value->getContext()), Instruction::Switch,
- nullptr, 0, InsertBefore) {
+ AllocMarker, InsertBefore) {
init(Value, Default, 2+NumCases*2);
}
SwitchInst::SwitchInst(const SwitchInst &SI)
- : Instruction(SI.getType(), Instruction::Switch, nullptr, 0) {
+ : Instruction(SI.getType(), Instruction::Switch, AllocMarker) {
init(SI.getCondition(), SI.getDefaultDest(), SI.getNumOperands());
setNumHungOffUseOperands(SI.getNumOperands());
Use *OL = getOperandList();
@@ -4125,13 +4109,14 @@ void IndirectBrInst::growOperands() {
IndirectBrInst::IndirectBrInst(Value *Address, unsigned NumCases,
InsertPosition InsertBefore)
: Instruction(Type::getVoidTy(Address->getContext()),
- Instruction::IndirectBr, nullptr, 0, InsertBefore) {
+ Instruction::IndirectBr, AllocMarker, InsertBefore) {
init(Address, NumCases);
}
IndirectBrInst::IndirectBrInst(const IndirectBrInst &IBI)
: Instruction(Type::getVoidTy(IBI.getContext()), Instruction::IndirectBr,
- nullptr, IBI.getNumOperands()) {
+ AllocMarker) {
+ NumUserOperands = IBI.NumUserOperands;
allocHungoffUses(IBI.getNumOperands());
Use *OL = getOperandList();
const Use *InOL = IBI.getOperandList();
@@ -4185,7 +4170,8 @@ FreezeInst::FreezeInst(Value *S, const Twine &Name, InsertPosition InsertBefore)
// unit that uses these classes.
GetElementPtrInst *GetElementPtrInst::cloneImpl() const {
- return new (getNumOperands()) GetElementPtrInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) GetElementPtrInst(*this, AllocMarker);
}
UnaryOperator *UnaryOperator::cloneImpl() const {
@@ -4305,10 +4291,13 @@ AddrSpaceCastInst *AddrSpaceCastInst::cloneImpl() const {
CallInst *CallInst::cloneImpl() const {
if (hasOperandBundles()) {
- unsigned DescriptorBytes = getNumOperandBundles() * sizeof(BundleOpInfo);
- return new(getNumOperands(), DescriptorBytes) CallInst(*this);
+ IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
+ getNumOperands(),
+ getNumOperandBundles() * unsigned(sizeof(BundleOpInfo))};
+ return new (AllocMarker) CallInst(*this, AllocMarker);
}
- return new(getNumOperands()) CallInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) CallInst(*this, AllocMarker);
}
SelectInst *SelectInst::cloneImpl() const {
@@ -4331,18 +4320,20 @@ ShuffleVectorInst *ShuffleVectorInst::cloneImpl() const {
return new ShuffleVectorInst(getOperand(0), getOperand(1), getShuffleMask());
}
-PHINode *PHINode::cloneImpl() const { return new PHINode(*this); }
+PHINode *PHINode::cloneImpl() const { return new (AllocMarker) PHINode(*this); }
LandingPadInst *LandingPadInst::cloneImpl() const {
return new LandingPadInst(*this);
}
ReturnInst *ReturnInst::cloneImpl() const {
- return new(getNumOperands()) ReturnInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) ReturnInst(*this, AllocMarker);
}
BranchInst *BranchInst::cloneImpl() const {
- return new(getNumOperands()) BranchInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) BranchInst(*this, AllocMarker);
}
SwitchInst *SwitchInst::cloneImpl() const { return new SwitchInst(*this); }
@@ -4353,28 +4344,37 @@ IndirectBrInst *IndirectBrInst::cloneImpl() const {
InvokeInst *InvokeInst::cloneImpl() const {
if (hasOperandBundles()) {
- unsigned DescriptorBytes = getNumOperandBundles() * sizeof(BundleOpInfo);
- return new(getNumOperands(), DescriptorBytes) InvokeInst(*this);
+ IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
+ getNumOperands(),
+ getNumOperandBundles() * unsigned(sizeof(BundleOpInfo))};
+ return new (AllocMarker) InvokeInst(*this, AllocMarker);
}
- return new(getNumOperands()) InvokeInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) InvokeInst(*this, AllocMarker);
}
CallBrInst *CallBrInst::cloneImpl() const {
if (hasOperandBundles()) {
- unsigned DescriptorBytes = getNumOperandBundles() * sizeof(BundleOpInfo);
- return new (getNumOperands(), DescriptorBytes) CallBrInst(*this);
+ IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
+ getNumOperands(),
+ getNumOperandBundles() * unsigned(sizeof(BundleOpInfo))};
+ return new (AllocMarker) CallBrInst(*this, AllocMarker);
}
- return new (getNumOperands()) CallBrInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) CallBrInst(*this, AllocMarker);
}
-ResumeInst *ResumeInst::cloneImpl() const { return new (1) ResumeInst(*this); }
+ResumeInst *ResumeInst::cloneImpl() const {
+ return new (AllocMarker) ResumeInst(*this);
+}
CleanupReturnInst *CleanupReturnInst::cloneImpl() const {
- return new (getNumOperands()) CleanupReturnInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) CleanupReturnInst(*this, AllocMarker);
}
CatchReturnInst *CatchReturnInst::cloneImpl() const {
- return new (getNumOperands()) CatchReturnInst(*this);
+ return new (AllocMarker) CatchReturnInst(*this);
}
CatchSwitchInst *CatchSwitchInst::cloneImpl() const {
@@ -4382,7 +4382,8 @@ CatchSwitchInst *CatchSwitchInst::cloneImpl() const {
}
FuncletPadInst *FuncletPadInst::cloneImpl() const {
- return new (getNumOperands()) FuncletPadInst(*this);
+ IntrusiveOperandsAllocMarker AllocMarker{getNumOperands()};
+ return new (AllocMarker) FuncletPadInst(*this, AllocMarker);
}
UnreachableInst *UnreachableInst::cloneImpl() const {
diff --git a/llvm/lib/IR/User.cpp b/llvm/lib/IR/User.cpp
index 00dd9c7..b0aa785 100644
--- a/llvm/lib/IR/User.cpp
+++ b/llvm/lib/IR/User.cpp
@@ -145,10 +145,7 @@ void *User::allocateFixedOperandUser(size_t Size, unsigned Us,
::operator new(Size + sizeof(Use) * Us + DescBytesToAllocate));
Use *Start = reinterpret_cast<Use *>(Storage + DescBytesToAllocate);
Use *End = Start + Us;
- User *Obj = reinterpret_cast<User*>(End);
- Obj->NumUserOperands = Us;
- Obj->HasHungOffUses = false;
- Obj->HasDescriptor = DescBytes != 0;
+ User *Obj = reinterpret_cast<User *>(End);
for (; Start != End; Start++)
new (Start) Use(Obj);
@@ -160,22 +157,21 @@ void *User::allocateFixedOperandUser(size_t Size, unsigned Us,
return Obj;
}
-void *User::operator new(size_t Size, unsigned Us) {
- return allocateFixedOperandUser(Size, Us, 0);
+void *User::operator new(size_t Size, IntrusiveOperandsAllocMarker allocTrait) {
+ return allocateFixedOperandUser(Size, allocTrait.NumOps, 0);
}
-void *User::operator new(size_t Size, unsigned Us, unsigned DescBytes) {
- return allocateFixedOperandUser(Size, Us, DescBytes);
+void *User::operator new(size_t Size,
+ IntrusiveOperandsAndDescriptorAllocMarker allocTrait) {
+ return allocateFixedOperandUser(Size, allocTrait.NumOps,
+ allocTrait.DescBytes);
}
-void *User::operator new(size_t Size) {
+void *User::operator new(size_t Size, HungOffOperandsAllocMarker) {
// Allocate space for a single Use*
void *Storage = ::operator new(Size + sizeof(Use *));
Use **HungOffOperandList = static_cast<Use **>(Storage);
User *Obj = reinterpret_cast<User *>(HungOffOperandList + 1);
- Obj->NumUserOperands = 0;
- Obj->HasHungOffUses = true;
- Obj->HasDescriptor = false;
*HungOffOperandList = nullptr;
return Obj;
}