mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-15 06:25:53 +00:00
PR9214: Convert Metadata API to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129932 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -111,30 +111,25 @@ class MDNode : public Value, public FoldingSetNode {
|
|||||||
void replaceOperand(MDNodeOperand *Op, Value *NewVal);
|
void replaceOperand(MDNodeOperand *Op, Value *NewVal);
|
||||||
~MDNode();
|
~MDNode();
|
||||||
|
|
||||||
MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
|
MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal);
|
||||||
bool isFunctionLocal);
|
|
||||||
|
|
||||||
static MDNode *getMDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
|
static MDNode *getMDNode(LLVMContext &C, ArrayRef<Value*> Vals,
|
||||||
FunctionLocalness FL, bool Insert = true);
|
FunctionLocalness FL, bool Insert = true);
|
||||||
public:
|
public:
|
||||||
// Constructors and destructors.
|
// Constructors and destructors.
|
||||||
static MDNode *get(LLVMContext &Context, ArrayRef<Value*> V);
|
static MDNode *get(LLVMContext &Context, ArrayRef<Value*> Vals);
|
||||||
// FIXME: Eliminate this constructor form.
|
|
||||||
static MDNode *get(LLVMContext &Context, Value *const *Vals,
|
|
||||||
unsigned NumVals);
|
|
||||||
// getWhenValsUnresolved - Construct MDNode determining function-localness
|
// getWhenValsUnresolved - Construct MDNode determining function-localness
|
||||||
// from isFunctionLocal argument, not by analyzing Vals.
|
// from isFunctionLocal argument, not by analyzing Vals.
|
||||||
static MDNode *getWhenValsUnresolved(LLVMContext &Context, Value *const *Vals,
|
static MDNode *getWhenValsUnresolved(LLVMContext &Context,
|
||||||
unsigned NumVals, bool isFunctionLocal);
|
ArrayRef<Value*> Vals,
|
||||||
|
bool isFunctionLocal);
|
||||||
|
|
||||||
static MDNode *getIfExists(LLVMContext &Context, Value *const *Vals,
|
static MDNode *getIfExists(LLVMContext &Context, ArrayRef<Value*> Vals);
|
||||||
unsigned NumVals);
|
|
||||||
|
|
||||||
/// getTemporary - Return a temporary MDNode, for use in constructing
|
/// getTemporary - Return a temporary MDNode, for use in constructing
|
||||||
/// cyclic MDNode structures. A temporary MDNode is not uniqued,
|
/// cyclic MDNode structures. A temporary MDNode is not uniqued,
|
||||||
/// may be RAUW'd, and must be manually deleted with deleteTemporary.
|
/// may be RAUW'd, and must be manually deleted with deleteTemporary.
|
||||||
static MDNode *getTemporary(LLVMContext &Context, Value *const *Vals,
|
static MDNode *getTemporary(LLVMContext &Context, ArrayRef<Value*> Vals);
|
||||||
unsigned NumVals);
|
|
||||||
|
|
||||||
/// deleteTemporary - Deallocate a node created by getTemporary. The
|
/// deleteTemporary - Deallocate a node created by getTemporary. The
|
||||||
/// node must not have any users.
|
/// node must not have any users.
|
||||||
|
@@ -518,7 +518,7 @@ DIType DIBuilder::createTemporaryType() {
|
|||||||
// Give the temporary MDNode a tag. It doesn't matter what tag we
|
// Give the temporary MDNode a tag. It doesn't matter what tag we
|
||||||
// use here as long as DIType accepts it.
|
// use here as long as DIType accepts it.
|
||||||
Value *Elts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
Value *Elts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
||||||
MDNode *Node = MDNode::getTemporary(VMContext, Elts, 1);
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
||||||
return DIType(Node);
|
return DIType(Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,17 +532,19 @@ DIType DIBuilder::createTemporaryType(DIFile F) {
|
|||||||
NULL,
|
NULL,
|
||||||
F
|
F
|
||||||
};
|
};
|
||||||
MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts));
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
||||||
return DIType(Node);
|
return DIType(Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getOrCreateArray - Get a DIArray, create one if required.
|
/// getOrCreateArray - Get a DIArray, create one if required.
|
||||||
DIArray DIBuilder::getOrCreateArray(Value *const *Elements, unsigned NumElements) {
|
DIArray DIBuilder::getOrCreateArray(Value *const *Elements,
|
||||||
|
unsigned NumElements) {
|
||||||
if (NumElements == 0) {
|
if (NumElements == 0) {
|
||||||
Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext));
|
Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext));
|
||||||
return DIArray(MDNode::get(VMContext, &Null, 1));
|
return DIArray(MDNode::get(VMContext, Null));
|
||||||
}
|
}
|
||||||
return DIArray(MDNode::get(VMContext, Elements, NumElements));
|
return DIArray(MDNode::get(VMContext,
|
||||||
|
ArrayRef<Value*>(Elements, NumElements)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getOrCreateSubrange - Create a descriptor for a value range. This
|
/// getOrCreateSubrange - Create a descriptor for a value range. This
|
||||||
@@ -778,7 +780,7 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
|||||||
if (!DeclareFn)
|
if (!DeclareFn)
|
||||||
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
||||||
|
|
||||||
Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), VarInfo };
|
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
||||||
return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore);
|
return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -790,7 +792,7 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
|||||||
if (!DeclareFn)
|
if (!DeclareFn)
|
||||||
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
||||||
|
|
||||||
Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), VarInfo };
|
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
||||||
|
|
||||||
// If this block already has a terminator then insert this intrinsic
|
// If this block already has a terminator then insert this intrinsic
|
||||||
// before the terminator.
|
// before the terminator.
|
||||||
@@ -809,7 +811,7 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
|||||||
if (!ValueFn)
|
if (!ValueFn)
|
||||||
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
||||||
|
|
||||||
Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
||||||
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
||||||
VarInfo };
|
VarInfo };
|
||||||
return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
|
return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
|
||||||
@@ -824,7 +826,7 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
|||||||
if (!ValueFn)
|
if (!ValueFn)
|
||||||
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
||||||
|
|
||||||
Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
||||||
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
||||||
VarInfo };
|
VarInfo };
|
||||||
return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
|
return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
|
||||||
|
@@ -514,7 +514,7 @@ bool LLParser::ParseMDNodeID(MDNode *&Result) {
|
|||||||
if (Result) return false;
|
if (Result) return false;
|
||||||
|
|
||||||
// Otherwise, create MDNode forward reference.
|
// Otherwise, create MDNode forward reference.
|
||||||
MDNode *FwdNode = MDNode::getTemporary(Context, 0, 0);
|
MDNode *FwdNode = MDNode::getTemporary(Context, ArrayRef<Value*>());
|
||||||
ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
|
ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
|
||||||
|
|
||||||
if (NumberedMetadata.size() <= MID)
|
if (NumberedMetadata.size() <= MID)
|
||||||
@@ -572,7 +572,7 @@ bool LLParser::ParseStandaloneMetadata() {
|
|||||||
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
MDNode *Init = MDNode::get(Context, Elts.data(), Elts.size());
|
MDNode *Init = MDNode::get(Context, Elts);
|
||||||
|
|
||||||
// See if this was forward referenced, if so, handle it.
|
// See if this was forward referenced, if so, handle it.
|
||||||
std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> >::iterator
|
std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> >::iterator
|
||||||
@@ -2498,7 +2498,7 @@ bool LLParser::ParseMetadataListValue(ValID &ID, PerFunctionState *PFS) {
|
|||||||
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ID.MDNodeVal = MDNode::get(Context, Elts.data(), Elts.size());
|
ID.MDNodeVal = MDNode::get(Context, Elts);
|
||||||
ID.Kind = ValID::t_MDNode;
|
ID.Kind = ValID::t_MDNode;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -349,7 +349,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create and return a placeholder, which will later be RAUW'd.
|
// Create and return a placeholder, which will later be RAUW'd.
|
||||||
Value *V = MDNode::getTemporary(Context, 0, 0);
|
Value *V = MDNode::getTemporary(Context, ArrayRef<Value*>());
|
||||||
MDValuePtrs[Idx] = V;
|
MDValuePtrs[Idx] = V;
|
||||||
return V;
|
return V;
|
||||||
}
|
}
|
||||||
@@ -843,9 +843,7 @@ bool BitcodeReader::ParseMetadata() {
|
|||||||
else
|
else
|
||||||
Elts.push_back(NULL);
|
Elts.push_back(NULL);
|
||||||
}
|
}
|
||||||
Value *V = MDNode::getWhenValsUnresolved(Context,
|
Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal);
|
||||||
Elts.data(), Elts.size(),
|
|
||||||
IsFunctionLocal);
|
|
||||||
IsFunctionLocal = false;
|
IsFunctionLocal = false;
|
||||||
MDValueList.AssignValue(V, NextMDValueNo++);
|
MDValueList.AssignValue(V, NextMDValueNo++);
|
||||||
break;
|
break;
|
||||||
|
@@ -104,7 +104,7 @@ bool llvm::isAllocaPromotable(const AllocaInst *AI) {
|
|||||||
/// FindAllocaDbgDeclare - Finds the llvm.dbg.declare intrinsic describing the
|
/// FindAllocaDbgDeclare - Finds the llvm.dbg.declare intrinsic describing the
|
||||||
/// alloca 'V', if any.
|
/// alloca 'V', if any.
|
||||||
static DbgDeclareInst *FindAllocaDbgDeclare(Value *V) {
|
static DbgDeclareInst *FindAllocaDbgDeclare(Value *V) {
|
||||||
if (MDNode *DebugNode = MDNode::getIfExists(V->getContext(), &V, 1))
|
if (MDNode *DebugNode = MDNode::getIfExists(V->getContext(), V))
|
||||||
for (Value::use_iterator UI = DebugNode->use_begin(),
|
for (Value::use_iterator UI = DebugNode->use_begin(),
|
||||||
E = DebugNode->use_end(); UI != E; ++UI)
|
E = DebugNode->use_end(); UI != E; ++UI)
|
||||||
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(*UI))
|
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(*UI))
|
||||||
|
@@ -39,7 +39,7 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM,
|
|||||||
return VM[V] = const_cast<Value*>(V);
|
return VM[V] = const_cast<Value*>(V);
|
||||||
|
|
||||||
// Create a dummy node in case we have a metadata cycle.
|
// Create a dummy node in case we have a metadata cycle.
|
||||||
MDNode *Dummy = MDNode::getTemporary(V->getContext(), 0, 0);
|
MDNode *Dummy = MDNode::getTemporary(V->getContext(), ArrayRef<Value*>());
|
||||||
VM[V] = Dummy;
|
VM[V] = Dummy;
|
||||||
|
|
||||||
// Check all operands to see if any need to be remapped.
|
// Check all operands to see if any need to be remapped.
|
||||||
@@ -54,7 +54,7 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM,
|
|||||||
Value *Op = MD->getOperand(i);
|
Value *Op = MD->getOperand(i);
|
||||||
Elts.push_back(Op ? MapValue(Op, VM, Flags) : 0);
|
Elts.push_back(Op ? MapValue(Op, VM, Flags) : 0);
|
||||||
}
|
}
|
||||||
MDNode *NewMD = MDNode::get(V->getContext(), Elts.data(), Elts.size());
|
MDNode *NewMD = MDNode::get(V->getContext(), Elts);
|
||||||
Dummy->replaceAllUsesWith(NewMD);
|
Dummy->replaceAllUsesWith(NewMD);
|
||||||
VM[V] = NewMD;
|
VM[V] = NewMD;
|
||||||
MDNode::deleteTemporary(Dummy);
|
MDNode::deleteTemporary(Dummy);
|
||||||
|
@@ -543,7 +543,8 @@ LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
|
|||||||
|
|
||||||
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
|
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
|
||||||
unsigned Count) {
|
unsigned Count) {
|
||||||
return wrap(MDNode::get(*unwrap(C), unwrap<Value>(Vals, Count), Count));
|
return wrap(MDNode::get(*unwrap(C),
|
||||||
|
ArrayRef<Value*>(unwrap<Value>(Vals, Count), Count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
|
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
|
||||||
|
@@ -109,7 +109,7 @@ MDNode *DebugLoc::getAsMDNode(const LLVMContext &Ctx) const {
|
|||||||
ConstantInt::get(Int32, getLine()), ConstantInt::get(Int32, getCol()),
|
ConstantInt::get(Int32, getLine()), ConstantInt::get(Int32, getCol()),
|
||||||
Scope, IA
|
Scope, IA
|
||||||
};
|
};
|
||||||
return MDNode::get(Ctx2, &Elts[0], 4);
|
return MDNode::get(Ctx2, Elts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getFromDILocation - Translate the DILocation quad into a DebugLoc.
|
/// getFromDILocation - Translate the DILocation quad into a DebugLoc.
|
||||||
|
@@ -84,18 +84,18 @@ static MDNodeOperand *getOperandPtr(MDNode *N, unsigned Op) {
|
|||||||
return reinterpret_cast<MDNodeOperand*>(N+1)+Op;
|
return reinterpret_cast<MDNodeOperand*>(N+1)+Op;
|
||||||
}
|
}
|
||||||
|
|
||||||
MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
|
MDNode::MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal)
|
||||||
bool isFunctionLocal)
|
|
||||||
: Value(Type::getMetadataTy(C), Value::MDNodeVal) {
|
: Value(Type::getMetadataTy(C), Value::MDNodeVal) {
|
||||||
NumOperands = NumVals;
|
NumOperands = Vals.size();
|
||||||
|
|
||||||
if (isFunctionLocal)
|
if (isFunctionLocal)
|
||||||
setValueSubclassData(getSubclassDataFromValue() | FunctionLocalBit);
|
setValueSubclassData(getSubclassDataFromValue() | FunctionLocalBit);
|
||||||
|
|
||||||
// Initialize the operand list, which is co-allocated on the end of the node.
|
// Initialize the operand list, which is co-allocated on the end of the node.
|
||||||
|
unsigned i = 0;
|
||||||
for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
|
for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
|
||||||
Op != E; ++Op, ++Vals)
|
Op != E; ++Op, ++i)
|
||||||
new (Op) MDNodeOperand(*Vals, this);
|
new (Op) MDNodeOperand(Vals[i], this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,9 +183,8 @@ static bool isFunctionLocalValue(Value *V) {
|
|||||||
(isa<MDNode>(V) && cast<MDNode>(V)->isFunctionLocal());
|
(isa<MDNode>(V) && cast<MDNode>(V)->isFunctionLocal());
|
||||||
}
|
}
|
||||||
|
|
||||||
MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals,
|
MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef<Value*> Vals,
|
||||||
unsigned NumVals, FunctionLocalness FL,
|
FunctionLocalness FL, bool Insert) {
|
||||||
bool Insert) {
|
|
||||||
LLVMContextImpl *pImpl = Context.pImpl;
|
LLVMContextImpl *pImpl = Context.pImpl;
|
||||||
|
|
||||||
// Add all the operand pointers. Note that we don't have to add the
|
// Add all the operand pointers. Note that we don't have to add the
|
||||||
@@ -193,7 +192,7 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals,
|
|||||||
// Note that if the operands are later nulled out, the node will be
|
// Note that if the operands are later nulled out, the node will be
|
||||||
// removed from the uniquing map.
|
// removed from the uniquing map.
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
for (unsigned i = 0; i != NumVals; ++i)
|
for (unsigned i = 0; i != Vals.size(); ++i)
|
||||||
ID.AddPointer(Vals[i]);
|
ID.AddPointer(Vals[i]);
|
||||||
|
|
||||||
void *InsertPoint;
|
void *InsertPoint;
|
||||||
@@ -205,7 +204,7 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals,
|
|||||||
bool isFunctionLocal = false;
|
bool isFunctionLocal = false;
|
||||||
switch (FL) {
|
switch (FL) {
|
||||||
case FL_Unknown:
|
case FL_Unknown:
|
||||||
for (unsigned i = 0; i != NumVals; ++i) {
|
for (unsigned i = 0; i != Vals.size(); ++i) {
|
||||||
Value *V = Vals[i];
|
Value *V = Vals[i];
|
||||||
if (!V) continue;
|
if (!V) continue;
|
||||||
if (isFunctionLocalValue(V)) {
|
if (isFunctionLocalValue(V)) {
|
||||||
@@ -223,8 +222,8 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Coallocate space for the node and Operands together, then placement new.
|
// Coallocate space for the node and Operands together, then placement new.
|
||||||
void *Ptr = malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeOperand));
|
void *Ptr = malloc(sizeof(MDNode)+Vals.size()*sizeof(MDNodeOperand));
|
||||||
N = new (Ptr) MDNode(Context, Vals, NumVals, isFunctionLocal);
|
N = new (Ptr) MDNode(Context, Vals, isFunctionLocal);
|
||||||
|
|
||||||
// InsertPoint will have been set by the FindNodeOrInsertPos call.
|
// InsertPoint will have been set by the FindNodeOrInsertPos call.
|
||||||
pImpl->MDNodeSet.InsertNode(N, InsertPoint);
|
pImpl->MDNodeSet.InsertNode(N, InsertPoint);
|
||||||
@@ -233,26 +232,23 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, Value *const *Vals,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MDNode *MDNode::get(LLVMContext &Context, ArrayRef<Value*> Vals) {
|
MDNode *MDNode::get(LLVMContext &Context, ArrayRef<Value*> Vals) {
|
||||||
return getMDNode(Context, Vals.data(), Vals.size(), FL_Unknown);
|
return getMDNode(Context, Vals, FL_Unknown);
|
||||||
}
|
|
||||||
MDNode *MDNode::get(LLVMContext &Context, Value*const* Vals, unsigned NumVals) {
|
|
||||||
return getMDNode(Context, Vals, NumVals, FL_Unknown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MDNode *MDNode::getWhenValsUnresolved(LLVMContext &Context, Value *const *Vals,
|
MDNode *MDNode::getWhenValsUnresolved(LLVMContext &Context,
|
||||||
unsigned NumVals, bool isFunctionLocal) {
|
ArrayRef<Value*> Vals,
|
||||||
return getMDNode(Context, Vals, NumVals, isFunctionLocal ? FL_Yes : FL_No);
|
bool isFunctionLocal) {
|
||||||
|
return getMDNode(Context, Vals, isFunctionLocal ? FL_Yes : FL_No);
|
||||||
}
|
}
|
||||||
|
|
||||||
MDNode *MDNode::getIfExists(LLVMContext &Context, Value *const *Vals,
|
MDNode *MDNode::getIfExists(LLVMContext &Context, ArrayRef<Value*> Vals) {
|
||||||
unsigned NumVals) {
|
return getMDNode(Context, Vals, FL_Unknown, false);
|
||||||
return getMDNode(Context, Vals, NumVals, FL_Unknown, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MDNode *MDNode::getTemporary(LLVMContext &Context, Value *const *Vals,
|
MDNode *MDNode::getTemporary(LLVMContext &Context, ArrayRef<Value*> Vals) {
|
||||||
unsigned NumVals) {
|
MDNode *N =
|
||||||
MDNode *N = (MDNode *)malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeOperand));
|
(MDNode *)malloc(sizeof(MDNode)+Vals.size()*sizeof(MDNodeOperand));
|
||||||
N = new (N) MDNode(Context, Vals, NumVals, FL_No);
|
N = new (N) MDNode(Context, Vals, FL_No);
|
||||||
N->setValueSubclassData(N->getSubclassDataFromValue() |
|
N->setValueSubclassData(N->getSubclassDataFromValue() |
|
||||||
NotUniquedBit);
|
NotUniquedBit);
|
||||||
LeakDetector::addGarbageObject(N);
|
LeakDetector::addGarbageObject(N);
|
||||||
|
@@ -87,10 +87,10 @@ TEST_F(MDNodeTest, Simple) {
|
|||||||
V.push_back(CI);
|
V.push_back(CI);
|
||||||
V.push_back(s2);
|
V.push_back(s2);
|
||||||
|
|
||||||
MDNode *n1 = MDNode::get(Context, &V[0], 3);
|
MDNode *n1 = MDNode::get(Context, V);
|
||||||
Value *const c1 = n1;
|
Value *const c1 = n1;
|
||||||
MDNode *n2 = MDNode::get(Context, &c1, 1);
|
MDNode *n2 = MDNode::get(Context, c1);
|
||||||
MDNode *n3 = MDNode::get(Context, &V[0], 3);
|
MDNode *n3 = MDNode::get(Context, V);
|
||||||
EXPECT_NE(n1, n2);
|
EXPECT_NE(n1, n2);
|
||||||
#ifdef ENABLE_MDNODE_UNIQUING
|
#ifdef ENABLE_MDNODE_UNIQUING
|
||||||
EXPECT_EQ(n1, n3);
|
EXPECT_EQ(n1, n3);
|
||||||
@@ -112,7 +112,7 @@ TEST_F(MDNodeTest, Delete) {
|
|||||||
Instruction *I = new BitCastInst(C, Type::getInt32Ty(getGlobalContext()));
|
Instruction *I = new BitCastInst(C, Type::getInt32Ty(getGlobalContext()));
|
||||||
|
|
||||||
Value *const V = I;
|
Value *const V = I;
|
||||||
MDNode *n = MDNode::get(Context, &V, 1);
|
MDNode *n = MDNode::get(Context, V);
|
||||||
WeakVH wvh = n;
|
WeakVH wvh = n;
|
||||||
|
|
||||||
EXPECT_EQ(n, wvh);
|
EXPECT_EQ(n, wvh);
|
||||||
@@ -127,8 +127,8 @@ TEST(NamedMDNodeTest, Search) {
|
|||||||
|
|
||||||
Value *const V = C;
|
Value *const V = C;
|
||||||
Value *const V2 = C2;
|
Value *const V2 = C2;
|
||||||
MDNode *n = MDNode::get(Context, &V, 1);
|
MDNode *n = MDNode::get(Context, V);
|
||||||
MDNode *n2 = MDNode::get(Context, &V2, 1);
|
MDNode *n2 = MDNode::get(Context, V2);
|
||||||
|
|
||||||
Module M("MyModule", Context);
|
Module M("MyModule", Context);
|
||||||
const char *Name = "llvm.NMD1";
|
const char *Name = "llvm.NMD1";
|
||||||
|
Reference in New Issue
Block a user