[llvm-commits] [llvm] r93339 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp

Victor Hernandez vhernandez at apple.com
Wed Jan 13 13:07:20 PST 2010


On Jan 13, 2010, at 1:05 PM, Devang Patel wrote:

> On Wed, Jan 13, 2010 at 11:37 AM, Victor Hernandez <vhernandez at apple.com> wrote:
> 
>> 
>> +static void WriteFunctionLocalMetadata(const ValueEnumerator &VE,
>> +                                       BitstreamWriter &Stream) {
>> +  bool StartedMetadataBlock = false;
>> +  SmallVector<uint64_t, 64> Record;
>> +  ValueEnumerator::ValueList Vals = VE.getMDValues();
>> +  ValueEnumerator::ValueList::iterator it = Vals.begin();
>> +  ValueEnumerator::ValueList::iterator end = Vals.end();
>> +
>> +  while (it != end) {
>> +    if (const MDNode *N = dyn_cast<MDNode>((*it).first)) {
>> +      if (N->isFunctionLocal()) {
>> +        if (!StartedMetadataBlock) {
>> +          Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
>> +          StartedMetadataBlock = true;
>> +        }
>> +        WriteMDNode(N, VE, Stream, Record);
>> +        // Remove function-local MD, since it is used outside of function.
> 
> how ?

Sorry that is a typo.  Meant to say "is not used".

> 
>> +        it = Vals.erase(it);
>> +        end = Vals.end();
>> +        continue;
>> +      }
>> +    }
>> +    ++it;
>> +  }
>> +
>> +  if (StartedMetadataBlock)
>> +    Stream.ExitBlock();
>> +}
>> +
>>  static void WriteMetadataAttachment(const Function &F,
>>                                     const ValueEnumerator &VE,
>>                                     BitstreamWriter &Stream) {
>> @@ -1210,6 +1241,7 @@
>>   // Emit names for all the instructions etc.
>>   WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream);
>> 
>> +  WriteFunctionLocalMetadata(VE, Stream);
> 
> This does not check function so will it write function local metadata
> from one function into another function's block ?

That check is done by the Verifier.  Do you think I need to do it here also?

> 
>>   WriteMetadataAttachment(F, VE, Stream);
>>   VE.purgeFunction();
>>   Stream.ExitBlock();
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> 
> 
> 
> -
> Devang





More information about the llvm-commits mailing list