mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-05 01:56:16 +00:00
[ObjCArc] Do not dereference an invalidated iterator.
Fix a bug in ARC contract pass where an iterator that pointed to a deleted instruction was dereferenced. It appears that tryToContractReleaseIntoStoreStrong was incorrectly assuming that a call to objc_retain would not immediately follow a call to objc_release. rdar://problem/25276306 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299507 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9be01ddb13
commit
1115fbdce4
@ -394,6 +394,7 @@ void ObjCARCContract::tryToContractReleaseIntoStoreStrong(Instruction *Release,
|
|||||||
|
|
||||||
DEBUG(llvm::dbgs() << " New Store Strong: " << *StoreStrong << "\n");
|
DEBUG(llvm::dbgs() << " New Store Strong: " << *StoreStrong << "\n");
|
||||||
|
|
||||||
|
if (&*Iter == Retain) ++Iter;
|
||||||
if (&*Iter == Store) ++Iter;
|
if (&*Iter == Store) ++Iter;
|
||||||
Store->eraseFromParent();
|
Store->eraseFromParent();
|
||||||
Release->eraseFromParent();
|
Release->eraseFromParent();
|
||||||
|
@ -243,6 +243,19 @@ entry:
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; This used to crash.
|
||||||
|
; CHECK-LABEL: define i8* @test13(
|
||||||
|
; CHECK: tail call void @objc_storeStrong(i8** %{{.*}}, i8* %[[NEW:.*]])
|
||||||
|
; CHECK-NEXT: ret i8* %[[NEW]]
|
||||||
|
|
||||||
|
define i8* @test13(i8* %a0, i8* %a1, i8** %addr, i8* %new) {
|
||||||
|
%old = load i8*, i8** %addr, align 8
|
||||||
|
call void @objc_release(i8* %old)
|
||||||
|
%retained = call i8* @objc_retain(i8* %new)
|
||||||
|
store i8* %retained, i8** %addr, align 8
|
||||||
|
ret i8* %retained
|
||||||
|
}
|
||||||
|
|
||||||
!0 = !{}
|
!0 = !{}
|
||||||
|
|
||||||
; CHECK: attributes [[NUW]] = { nounwind }
|
; CHECK: attributes [[NUW]] = { nounwind }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user