mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Introduce a new temporary MDNode concept. Temporary MDNodes are
not part of the IR, are not uniqued, and may be safely RAUW'd. This replaces a variety of alternate mechanisms for achieving the same effect. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111681 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "SymbolTableListTraitsImpl.h"
|
||||
#include "llvm/Support/LeakDetector.h"
|
||||
#include "llvm/Support/ValueHandle.h"
|
||||
using namespace llvm;
|
||||
|
||||
@@ -244,6 +245,28 @@ MDNode *MDNode::getIfExists(LLVMContext &Context, Value *const *Vals,
|
||||
return getMDNode(Context, Vals, NumVals, FL_Unknown, false);
|
||||
}
|
||||
|
||||
MDNode *MDNode::getTemporary(LLVMContext &Context, Value *const *Vals,
|
||||
unsigned NumVals) {
|
||||
MDNode *N = (MDNode *)malloc(sizeof(MDNode)+NumVals*sizeof(MDNodeOperand));
|
||||
N = new (N) MDNode(Context, Vals, NumVals, FL_No);
|
||||
N->setValueSubclassData(N->getSubclassDataFromValue() |
|
||||
NotUniquedBit);
|
||||
LeakDetector::addGarbageObject(N);
|
||||
return N;
|
||||
}
|
||||
|
||||
void MDNode::deleteTemporary(MDNode *N) {
|
||||
assert(N->use_empty() && "Temporary MDNode has uses!");
|
||||
assert((N->getSubclassDataFromValue() & NotUniquedBit) &&
|
||||
"Temporary MDNode does not have NotUniquedBit set!");
|
||||
assert((N->getSubclassDataFromValue() & DestroyFlag) == 0 &&
|
||||
"Temporary MDNode does has DestroyFlag set!");
|
||||
N->setValueSubclassData(N->getSubclassDataFromValue() |
|
||||
DestroyFlag);
|
||||
LeakDetector::removeGarbageObject(N);
|
||||
delete N;
|
||||
}
|
||||
|
||||
/// getOperand - Return specified operand.
|
||||
Value *MDNode::getOperand(unsigned i) const {
|
||||
return *getOperandPtr(const_cast<MDNode*>(this), i);
|
||||
|
||||
Reference in New Issue
Block a user