[llvm-commits] [llvm] r90512 - /llvm/trunk/lib/VMCore/AsmWriter.cpp
Victor Hernandez
vhernandez at apple.com
Thu Dec 3 17:35:02 PST 2009
Author: hernande
Date: Thu Dec 3 19:35:02 2009
New Revision: 90512
URL: http://llvm.org/viewvc/llvm-project?rev=90512&view=rev
Log:
Teach AsmWriter to write inline (not via a global metadata slot) metadata that contains an instruction
Modified:
llvm/trunk/lib/VMCore/AsmWriter.cpp
Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90512&r1=90511&r2=90512&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Dec 3 19:35:02 2009
@@ -695,8 +695,13 @@
!I->hasName())
CreateFunctionSlot(I);
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (MDNode *N = dyn_cast_or_null<MDNode>(I->getOperand(i)))
+ if (MDNode *N = dyn_cast_or_null<MDNode>(I->getOperand(i))) {
+ // Create a metadata slot only if N contains no instructions.
+ for (unsigned n = 0, e = N->getNumElements(); n != e; ++n)
+ if (isa<Instruction>(N->getElement(n)))
+ continue;
CreateMetadataSlot(N);
+ }
// Process metadata attached with this instruction.
MDs.clear();
@@ -1227,6 +1232,25 @@
}
if (const MDNode *N = dyn_cast<MDNode>(V)) {
+ if (Machine->getMetadataSlot(N) == -1) {
+ // Print metadata inline, not via slot reference number.
+ Out << "!{";
+ for (unsigned mi = 0, me = N->getNumElements(); mi != me; ++mi) {
+ const Value *Val = N->getElement(mi);
+ if (!Val)
+ Out << "null";
+ else {
+ TypePrinter->print(N->getElement(0)->getType(), Out);
+ Out << ' ';
+ WriteAsOperandInternal(Out, N->getElement(0), TypePrinter, Machine);
+ }
+ if (mi + 1 != me)
+ Out << ", ";
+ }
+ Out << '}';
+ return;
+ }
+
Out << '!' << Machine->getMetadataSlot(N);
return;
}
More information about the llvm-commits
mailing list