llvm.org GIT mirror llvm / 0c31641
Write function-local metadata as a metadata subblock of a funciton block git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93339 91177308-0d34-0410-b5e6-96231b3b80d8 Victor Hernandez 10 years ago
1 changed file(s) with 37 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
498498 for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
499499
500500 if (const MDNode *N = dyn_cast(Vals[i].first)) {
501 if (!StartedMetadataBlock) {
502 Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
503 StartedMetadataBlock = true;
504 }
505 WriteMDNode(N, VE, Stream, Record);
501 if (!N->isFunctionLocal()) {
502 if (!StartedMetadataBlock) {
503 Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
504 StartedMetadataBlock = true;
505 }
506 WriteMDNode(N, VE, Stream, Record);
507 }
506508 } else if (const MDString *MDS = dyn_cast(Vals[i].first)) {
507509 if (!StartedMetadataBlock) {
508510 Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
545547 Stream.EmitRecord(bitc::METADATA_NAMED_NODE, Record, 0);
546548 Record.clear();
547549 }
550 }
551
552 if (StartedMetadataBlock)
553 Stream.ExitBlock();
554 }
555
556 static void WriteFunctionLocalMetadata(const ValueEnumerator &VE,
557 BitstreamWriter &Stream) {
558 bool StartedMetadataBlock = false;
559 SmallVector Record;
560 ValueEnumerator::ValueList Vals = VE.getMDValues();
561 ValueEnumerator::ValueList::iterator it = Vals.begin();
562 ValueEnumerator::ValueList::iterator end = Vals.end();
563
564 while (it != end) {
565 if (const MDNode *N = dyn_cast((*it).first)) {
566 if (N->isFunctionLocal()) {
567 if (!StartedMetadataBlock) {
568 Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
569 StartedMetadataBlock = true;
570 }
571 WriteMDNode(N, VE, Stream, Record);
572 // Remove function-local MD, since it is used outside of function.
573 it = Vals.erase(it);
574 end = Vals.end();
575 continue;
576 }
577 }
578 ++it;
548579 }
549580
550581 if (StartedMetadataBlock)
12091240 // Emit names for all the instructions etc.
12101241 WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream);
12111242
1243 WriteFunctionLocalMetadata(VE, Stream);
12121244 WriteMetadataAttachment(F, VE, Stream);
12131245 VE.purgeFunction();
12141246 Stream.ExitBlock();