mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
IR: Add MDNode::getDistinct()
Allow distinct `MDNode`s to be explicitly created. There's no way (yet) of representing their distinctness in assembly/bitcode, however, so this still isn't first-class. Part of PR22111. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225406 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -411,8 +411,12 @@ static bool isOperandUnresolved(Metadata *Op) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GenericMDNode::GenericMDNode(LLVMContext &C, ArrayRef<Metadata *> Vals)
|
||||
GenericMDNode::GenericMDNode(LLVMContext &C, ArrayRef<Metadata *> Vals,
|
||||
bool AllowRAUW)
|
||||
: MDNode(C, GenericMDNodeKind, Vals) {
|
||||
if (!AllowRAUW)
|
||||
return;
|
||||
|
||||
// Check whether any operands are unresolved, requiring re-uniquing.
|
||||
for (const auto &Op : operands())
|
||||
if (isOperandUnresolved(Op))
|
||||
@@ -581,12 +585,18 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef<Metadata *> MDs,
|
||||
return nullptr;
|
||||
|
||||
// Coallocate space for the node and Operands together, then placement new.
|
||||
GenericMDNode *N = new (MDs.size()) GenericMDNode(Context, MDs);
|
||||
auto *N = new (MDs.size()) GenericMDNode(Context, MDs, /* AllowRAUW */ true);
|
||||
N->setHash(Key.Hash);
|
||||
Store.insert(N);
|
||||
return N;
|
||||
}
|
||||
|
||||
MDNode *MDNode::getDistinct(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
|
||||
auto *N = new (MDs.size()) GenericMDNode(Context, MDs, /* AllowRAUW */ false);
|
||||
N->storeDistinctInContext();
|
||||
return N;
|
||||
}
|
||||
|
||||
MDNodeFwdDecl *MDNode::getTemporary(LLVMContext &Context,
|
||||
ArrayRef<Metadata *> MDs) {
|
||||
MDNodeFwdDecl *N = new (MDs.size()) MDNodeFwdDecl(Context, MDs);
|
||||
|
Reference in New Issue
Block a user