[llvm-commits] [llvm] r126088 - in /llvm/trunk: lib/Transforms/Utils/Local.cpp test/CodeGen/X86/codegen-dce.ll unittests/Transforms/Utils/Local.cpp

Nick Lewycky nicholas at mxc.ca
Sun Feb 20 11:24:55 PST 2011


On 02/20/2011 10:12 AM, Duncan Sands wrote:
> Hi Nick,
>
>> Make RecursivelyDeleteDeadPHINode delete a phi node that has no users and add a
>> test for that. With this change, test/CodeGen/X86/codegen-dce.ll no longer finds
>> any instructions to DCE, so delete the test.
>>
>> Also renamed J and JP to I and IP in RecursivelyDeleteDeadPHINode.
>>
>> Removed:
>>       llvm/trunk/test/CodeGen/X86/codegen-dce.ll
>> Modified:
>>       llvm/trunk/lib/Transforms/Utils/Local.cpp
>>       llvm/trunk/unittests/Transforms/Utils/Local.cpp
>>
>> Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=126088&r1=126087&r2=126088&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sun Feb 20 12:05:56 2011
>> @@ -283,6 +283,11 @@
>>    /// delete it.  If that makes any of its operands trivially dead, delete them
>>    /// too, recursively.  Return true if the PHI node is actually deleted.
>>    bool llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) {
>> +  if (PN->use_empty()) {
>> +    PN->eraseFromParent();
>> +    return true;
>> +  }
>> +
>
> rather than doing this, or as well as doing this, how about having
> AreAllUsesEqual return true when there are no uses (which would be
> more logical anyway)?

Because the very next thing the loop does is "I = 
cast<Instruction>(*I->use_begin())", so that would crash.

It's just trying to walk the use list,

Nick



More information about the llvm-commits mailing list