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.

llvm-svn: 111681
This commit is contained in:
Dan Gohman
2010-08-20 22:02:26 +00:00
parent 662f05a035
commit 16a5d98c3a
6 changed files with 62 additions and 14 deletions

View File

@@ -333,9 +333,9 @@ void BitcodeReaderMDValueList::AssignValue(Value *V, unsigned Idx) {
}
// If there was a forward reference to this value, replace it.
Value *PrevVal = OldV;
MDNode *PrevVal = cast<MDNode>(OldV);
OldV->replaceAllUsesWith(V);
delete PrevVal;
MDNode::deleteTemporary(PrevVal);
// Deleting PrevVal sets Idx value in MDValuePtrs to null. Set new
// value for Idx.
MDValuePtrs[Idx] = V;
@@ -351,7 +351,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) {
}
// Create and return a placeholder, which will later be RAUW'd.
Value *V = new Argument(Type::getMetadataTy(Context));
Value *V = MDNode::getTemporary(Context, 0, 0);
MDValuePtrs[Idx] = V;
return V;
}