diff options
author | Dan Gohman <gohman@apple.com> | 2012-05-18 22:17:29 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2012-05-18 22:17:29 +0000 |
commit | ce5d8b0d03b9c37727d08de4fa1bcc7be7ea8bb1 (patch) | |
tree | 6683dd50db2384891cd383a96157570ec14955a7 /lib/Transforms | |
parent | c696c8bd35a8ab293879e821142dd9136201f16e (diff) |
Fix replacing all the users of objc weak runtime routines
when deleting them. rdar://11434915.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157080 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/ObjCARC.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp index ce4a195d95..c4ab42d263 100644 --- a/lib/Transforms/Scalar/ObjCARC.cpp +++ b/lib/Transforms/Scalar/ObjCARC.cpp @@ -3486,8 +3486,18 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) { 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; + } UserInst->eraseFromParent(); } Alloca->eraseFromParent(); |