[llvm-commits] [llvm] r157080 - in /llvm/trunk: lib/Transforms/Scalar/ObjCARC.cpp test/Transforms/ObjCARC/weak-dce.ll

Dan Gohman gohman at apple.com
Mon May 21 10:42:47 PDT 2012


On May 18, 2012, at 5:24 PM, Bob Wilson <bob.wilson at apple.com> wrote:

> 
> On May 18, 2012, at 3:17 PM, Dan Gohman <gohman at apple.com> wrote:
> 
>> Author: djg
>> Date: Fri May 18 17:17:29 2012
>> New Revision: 157080
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=157080&view=rev
>> Log:
>> Fix replacing all the users of objc weak runtime routines
>> when deleting them. rdar://11434915.
>> 
>> Added:
>>   llvm/trunk/test/Transforms/ObjCARC/weak-dce.ll
>> Modified:
>>   llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
>> 
>> Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=157080&r1=157079&r2=157080&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Fri May 18 17:17:29 2012
>> @@ -3486,8 +3486,18 @@
>>      for (Value::use_iterator UI = Alloca->use_begin(),
>>           UE = Alloca->use_end(); UI != UE; ) {
>>        CallInst *UserInst = cast<CallInst>(*UI++);
>> -        if (!UserInst->use_empty())
>> -          UserInst->replaceAllUsesWith(UserInst->getArgOperand(0));
>> +        switch (GetBasicInstructionClass(UserInst)) {
>> +        case IC_InitWeak:
>> +        case IC_StoreWeak:
>> +          // These functions return their second argument.
>> +          UserInst->replaceAllUsesWith(UserInst->getArgOperand(1));
>> +          break;
>> +        case IC_DestroyWeak:
>> +          // No return value.
>> +          break;
>> +        default:
>> +          break;
>> +        }
> 
> In the default case, the previous code did an RAUW with operand 0, but it now does nothing at all.  Is that really what you intended?

The default case is actually unreachable here. I've made it an
llvm_unreachable now.

Dan




More information about the llvm-commits mailing list