mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
Fix the objc_storeStrong recognizer to stop before walking off the
end of a basic block if there's no store. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156520 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ca313e1efa
commit
95b8cf1f11
@ -3902,12 +3902,15 @@ void ObjCARCContract::ContractRelease(Instruction *Release,
|
|||||||
if (Load->getParent() != BB) return;
|
if (Load->getParent() != BB) return;
|
||||||
|
|
||||||
// Walk down to find the store and the release, which may be in either order.
|
// Walk down to find the store and the release, which may be in either order.
|
||||||
BasicBlock::iterator I = Load;
|
BasicBlock::iterator I = Load, End = BB->end();
|
||||||
++I;
|
++I;
|
||||||
AliasAnalysis::Location Loc = AA->getLocation(Load);
|
AliasAnalysis::Location Loc = AA->getLocation(Load);
|
||||||
StoreInst *Store = 0;
|
StoreInst *Store = 0;
|
||||||
bool SawRelease = false;
|
bool SawRelease = false;
|
||||||
for (; !Store || !SawRelease; ++I) {
|
for (; !Store || !SawRelease; ++I) {
|
||||||
|
if (I == End)
|
||||||
|
return;
|
||||||
|
|
||||||
Instruction *Inst = I;
|
Instruction *Inst = I;
|
||||||
if (Inst == Release) {
|
if (Inst == Release) {
|
||||||
SawRelease = true;
|
SawRelease = true;
|
||||||
|
@ -132,4 +132,38 @@ entry:
|
|||||||
ret i1 %t
|
ret i1 %t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Like test0, but there's no store, so don't form an objc_storeStrong.
|
||||||
|
|
||||||
|
; CHECK: define void @test7(
|
||||||
|
; CHECK-NEXT: entry:
|
||||||
|
; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %p) nounwind
|
||||||
|
; CHECK-NEXT: %tmp = load i8** @x, align 8
|
||||||
|
; CHECK-NEXT: tail call void @objc_release(i8* %tmp) nounwind
|
||||||
|
; CHECK-NEXT: ret void
|
||||||
|
; CHECK-NEXT: }
|
||||||
|
define void @test7(i8* %p) {
|
||||||
|
entry:
|
||||||
|
%0 = tail call i8* @objc_retain(i8* %p) nounwind
|
||||||
|
%tmp = load i8** @x, align 8
|
||||||
|
tail call void @objc_release(i8* %tmp) nounwind
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; Like test0, but there's no retain, so don't form an objc_storeStrong.
|
||||||
|
|
||||||
|
; CHECK: define void @test8(
|
||||||
|
; CHECK-NEXT: entry:
|
||||||
|
; CHECK-NEXT: %tmp = load i8** @x, align 8
|
||||||
|
; CHECK-NEXT: store i8* %p, i8** @x, align 8
|
||||||
|
; CHECK-NEXT: tail call void @objc_release(i8* %tmp) nounwind
|
||||||
|
; CHECK-NEXT: ret void
|
||||||
|
; CHECK-NEXT: }
|
||||||
|
define void @test8(i8* %p) {
|
||||||
|
entry:
|
||||||
|
%tmp = load i8** @x, align 8
|
||||||
|
store i8* %p, i8** @x, align 8
|
||||||
|
tail call void @objc_release(i8* %tmp) nounwind
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
!0 = metadata !{}
|
!0 = metadata !{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user