mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
Allow null to be an element of NamedMDNode. e.g. !llvm.stuff = !{!0, !1, null}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92783 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6ae68a28b9
commit
69d02e0a17
@ -512,6 +512,12 @@ bool LLParser::ParseNamedMetadata() {
|
||||
|
||||
SmallVector<MDNode *, 8> Elts;
|
||||
do {
|
||||
// Null is a special case since it is typeless.
|
||||
if (EatIfPresent(lltok::kw_null)) {
|
||||
Elts.push_back(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ParseToken(lltok::exclaim, "Expected '!' here"))
|
||||
return true;
|
||||
|
||||
|
@ -789,9 +789,13 @@ bool BitcodeReader::ParseMetadata() {
|
||||
unsigned Size = Record.size();
|
||||
SmallVector<MDNode *, 8> Elts;
|
||||
for (unsigned i = 0; i != Size; ++i) {
|
||||
Value *MD = MDValueList.getValueFwdRef(Record[i]);
|
||||
if (MDNode *B = dyn_cast_or_null<MDNode>(MD))
|
||||
Elts.push_back(B);
|
||||
if (Record[i] == ~0U)
|
||||
Elts.push_back(NULL);
|
||||
else {
|
||||
Value *MD = MDValueList.getValueFwdRef(Record[i]);
|
||||
if (MDNode *B = dyn_cast_or_null<MDNode>(MD))
|
||||
Elts.push_back(B);
|
||||
}
|
||||
}
|
||||
Value *V = NamedMDNode::Create(Context, Name.str(), Elts.data(),
|
||||
Elts.size(), TheModule);
|
||||
|
@ -540,7 +540,7 @@ static void WriteModuleMetadata(const ValueEnumerator &VE,
|
||||
if (NMD->getOperand(i))
|
||||
Record.push_back(VE.getValueID(NMD->getOperand(i)));
|
||||
else
|
||||
Record.push_back(0);
|
||||
Record.push_back(~0U);
|
||||
}
|
||||
Stream.EmitRecord(bitc::METADATA_NAMED_NODE, Record, 0);
|
||||
Record.clear();
|
||||
|
@ -223,7 +223,8 @@ void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) {
|
||||
|
||||
if (const NamedMDNode *N = dyn_cast<NamedMDNode>(MD)) {
|
||||
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
|
||||
EnumerateValue(N->getOperand(i));
|
||||
if (MDNode *E = N->getOperand(i))
|
||||
EnumerateValue(E);
|
||||
MDValues.push_back(std::make_pair(MD, 1U));
|
||||
MDValueMap[MD] = Values.size();
|
||||
return;
|
||||
|
@ -615,8 +615,7 @@ void SlotTracker::processModule() {
|
||||
E = TheModule->named_metadata_end(); I != E; ++I) {
|
||||
const NamedMDNode *NMD = I;
|
||||
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
||||
// FIXME: Change accessor to be type safe.
|
||||
if (MDNode *MD = cast_or_null<MDNode>(NMD->getOperand(i)))
|
||||
if (MDNode *MD = NMD->getOperand(i))
|
||||
CreateMetadataSlot(MD);
|
||||
}
|
||||
}
|
||||
@ -1370,10 +1369,10 @@ void AssemblyWriter::printNamedMDNode(const NamedMDNode *NMD) {
|
||||
Out << "!" << NMD->getName() << " = !{";
|
||||
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
||||
if (i) Out << ", ";
|
||||
// FIXME: Change accessor to be typesafe.
|
||||
// FIXME: This doesn't handle null??
|
||||
MDNode *MD = cast_or_null<MDNode>(NMD->getOperand(i));
|
||||
Out << '!' << Machine.getMetadataSlot(MD);
|
||||
if (MDNode *MD = NMD->getOperand(i))
|
||||
Out << '!' << Machine.getMetadataSlot(MD);
|
||||
else
|
||||
Out << "null";
|
||||
}
|
||||
Out << "}\n";
|
||||
}
|
||||
|
@ -3,4 +3,4 @@
|
||||
;; Simple NamedMDNode
|
||||
!0 = metadata !{i32 42}
|
||||
!1 = metadata !{metadata !"foo"}
|
||||
!llvm.stuff = !{!0, !1}
|
||||
!llvm.stuff = !{!0, !1, null}
|
||||
|
Loading…
Reference in New Issue
Block a user