[llvm-commits] [llvm] r84113 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp

Devang Patel dpatel at apple.com
Wed Oct 14 11:53:25 PDT 2009


On Oct 14, 2009, at 11:48 AM, Nick Lewycky wrote:

> Devang Patel wrote:
>> Author: dpatel
>> Date: Wed Oct 14 12:02:49 2009
>> New Revision: 84113
>> URL: http://llvm.org/viewvc/llvm-project?rev=84113&view=rev
>> Log:
>> Add copyMD to copy metadata from one instruction to another  
>> instruction.
>> Modified:
>>    llvm/trunk/include/llvm/Metadata.h
>>    llvm/trunk/lib/VMCore/Metadata.cpp
>> Modified: llvm/trunk/include/llvm/Metadata.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=84113&r1=84112&r2=84113&view=diff
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/include/llvm/Metadata.h (original)
>> +++ llvm/trunk/include/llvm/Metadata.h Wed Oct 14 12:02:49 2009
>> @@ -351,6 +351,10 @@
>>   /// removeMDs - Remove all metadata attached with an instruction.
>>   void removeMDs(const Instruction *Inst);
>> +  /// copyMD - If metadata is attached with Instruction In1 then  
>> attach
>> +  /// the same metadata to In2.
>> +  void copyMD(Instruction *In1, Instruction *In2);
>> +
>>   /// getHandlerNames - Get handler names. This is used by bitcode
>>   /// writer.
>>   const StringMap<unsigned> *getHandlerNames();
>> Modified: llvm/trunk/lib/VMCore/Metadata.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=84113&r1=84112&r2=84113&view=diff
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/lib/VMCore/Metadata.cpp (original)
>> +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Oct 14 12:02:49 2009
>> @@ -359,6 +359,20 @@
>>   MetadataStore.erase(I);
>> }
>> +/// copyMD - If metadata is attached with Instruction In1 then  
>> attach
>> +/// the same metadata to In2.
>> +void MetadataContext::copyMD(Instruction *In1, Instruction *In2) {
>> +  assert (In1 && In2 && "Invalid instruction!");
>> +   MDStoreTy::iterator I = MetadataStore.find(In1);
>> +  if (I == MetadataStore.end())
>> +    return;
>> +
>> +  MDMapTy &In1Info = I->second;
>> +  MDMapTy In2Info;
>> +  for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end();  
>> I != E; ++I)
>> +    if (MDNode *MD = dyn_cast_or_null<MDNode>(I->second))
>
> When would this be null?

If it was replaced or deleted.

> If it's "!metadata null" we want to push a null metadata onto the  
> target instruction, right?

I am not sure.
-
Devang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20091014/b5983e2d/attachment.html>


More information about the llvm-commits mailing list