[llvm-commits] [llvm] r94763 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Victor Hernandez vhernandez at apple.com
Fri Jan 29 11:36:19 PST 2010


On Jan 29, 2010, at 11:33 AM, Devang Patel wrote:

> Hi Victor,
> 
> On Fri, Jan 29, 2010 at 12:01 AM, Victor Hernandez <vhernandez at apple.com> wrote:
>> Author: hernande
>> Date: Thu Jan 28 18:01:35 2010
>> New Revision: 94763
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=94763&view=rev
>> Log:
>> mem2reg erases the dbg.declare intrinsics that it converts to dbg.val intrinsics
>> 
>> Modified:
>>    llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
>> 
>> Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=94763&r1=94762&r2=94763&view=diff
>> 
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Thu Jan 28 18:01:35 2010
>> @@ -373,9 +373,11 @@
>> 
>>       // Finally, after the scan, check to see if the store is all that is left.
>>       if (Info.UsingBlocks.empty()) {
>> -        // Record debuginfo for the store before removing it.
>> -        if (DbgDeclareInst *DDI = Info.DbgDeclare)
>> +        // Record debuginfo for the store and remove the declaration's debuginfo.
>> +        if (DbgDeclareInst *DDI = Info.DbgDeclare) {
>>           ConvertDebugDeclareToDebugValue(DDI, Info.OnlyStore);
>> +          DDI->eraseFromParent();
>> +        }
> 
> Why not erase DDI in ConvertDebugDeclareToDebugValue() itself ?

Because there can multiple stores to a single alloc/DbgDeclareInst (well not in that case, but yes in the other 2 uses of ConvertDebugDeclareToDebugValue().  So I can't delete the DDI until I have finished handling all of the stores, which is better done outside of ConvertDebugDeclareToDebugValue().

Victor


> -
> Devang
> 
>>         // Remove the (now dead) store and alloca.
>>         Info.OnlyStore->eraseFromParent();
>>         LBI.deleteValue(Info.OnlyStore);
>> @@ -418,6 +420,10 @@
>>         // The alloca has been processed, move on.
>>         RemoveFromAllocasList(AllocaNum);
>> 
>> +        // The alloca's debuginfo can be removed as well.
>> +        if (DbgDeclareInst *DDI = Info.DbgDeclare)
>> +          DDI->eraseFromParent();
>> +
>>         ++NumLocalPromoted;
>>         continue;
>>       }
>> @@ -493,7 +499,11 @@
>>     A->eraseFromParent();
>>   }
>> 
>> -
>> +  // Remove alloca's dbg.declare instrinsics from the function.
>> +  for (unsigned i = 0, e = AllocaDbgDeclares.size(); i != e; ++i)
>> +    if (DbgDeclareInst *DDI = AllocaDbgDeclares[i])
>> +      DDI->eraseFromParent();
>> +
>>   // Loop over all of the PHI nodes and see if there are any that we can get
>>   // rid of because they merge all of the same incoming values.  This can
>>   // happen due to undef values coming into the PHI nodes.  This process is
>> 
>> 
>> _______________________________________________
>> 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