mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Kill every call to @clang.arc.use in the ARC contract phase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177769 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
46125e1a8b
commit
1f9c4407c0
@ -38,6 +38,7 @@ llvm::objcarc::CanAlterRefCount(const Instruction *Inst, const Value *Ptr,
|
|||||||
switch (Class) {
|
switch (Class) {
|
||||||
case IC_Autorelease:
|
case IC_Autorelease:
|
||||||
case IC_AutoreleaseRV:
|
case IC_AutoreleaseRV:
|
||||||
|
case IC_IntrinsicUser:
|
||||||
case IC_User:
|
case IC_User:
|
||||||
// These operations never directly modify a reference count.
|
// These operations never directly modify a reference count.
|
||||||
return false;
|
return false;
|
||||||
|
@ -89,6 +89,7 @@ enum InstructionClass {
|
|||||||
IC_CopyWeak, ///< objc_copyWeak (derived)
|
IC_CopyWeak, ///< objc_copyWeak (derived)
|
||||||
IC_DestroyWeak, ///< objc_destroyWeak (derived)
|
IC_DestroyWeak, ///< objc_destroyWeak (derived)
|
||||||
IC_StoreStrong, ///< objc_storeStrong (derived)
|
IC_StoreStrong, ///< objc_storeStrong (derived)
|
||||||
|
IC_IntrinsicUser, ///< clang.arc.use
|
||||||
IC_CallOrUser, ///< could call objc_release and/or "use" pointers
|
IC_CallOrUser, ///< could call objc_release and/or "use" pointers
|
||||||
IC_Call, ///< could call objc_release
|
IC_Call, ///< could call objc_release
|
||||||
IC_User, ///< could "use" a pointer
|
IC_User, ///< could "use" a pointer
|
||||||
@ -97,6 +98,13 @@ enum InstructionClass {
|
|||||||
|
|
||||||
raw_ostream &operator<<(raw_ostream &OS, const InstructionClass Class);
|
raw_ostream &operator<<(raw_ostream &OS, const InstructionClass Class);
|
||||||
|
|
||||||
|
/// \brief Test if the given class is a kind of user.
|
||||||
|
inline static bool IsUser(InstructionClass Class) {
|
||||||
|
return Class == IC_User ||
|
||||||
|
Class == IC_CallOrUser ||
|
||||||
|
Class == IC_IntrinsicUser;
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Test if the given class is objc_retain or equivalent.
|
/// \brief Test if the given class is objc_retain or equivalent.
|
||||||
static inline bool IsRetain(InstructionClass Class) {
|
static inline bool IsRetain(InstructionClass Class) {
|
||||||
return Class == IC_Retain ||
|
return Class == IC_Retain ||
|
||||||
|
@ -453,6 +453,10 @@ bool ObjCARCContract::runOnFunction(Function &F) {
|
|||||||
if (isa<AllocaInst>(Inst))
|
if (isa<AllocaInst>(Inst))
|
||||||
TailOkForStoreStrongs = false;
|
TailOkForStoreStrongs = false;
|
||||||
continue;
|
continue;
|
||||||
|
case IC_IntrinsicUser:
|
||||||
|
// Remove calls to @clang.arc.use(...).
|
||||||
|
Inst->eraseFromParent();
|
||||||
|
continue;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -211,6 +211,9 @@ static bool DoesRetainableObjPtrEscape(const User *Ptr) {
|
|||||||
// These special functions make copies of their pointer arguments.
|
// These special functions make copies of their pointer arguments.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case IC_IntrinsicUser:
|
||||||
|
// Use by the use intrinsic is not an escape.
|
||||||
|
continue;
|
||||||
case IC_User:
|
case IC_User:
|
||||||
case IC_None:
|
case IC_None:
|
||||||
// Use by an instruction which copies the value is an escape if the
|
// Use by an instruction which copies the value is an escape if the
|
||||||
@ -1601,8 +1604,7 @@ ObjCARCOpt::VisitInstructionBottomUp(Instruction *Inst,
|
|||||||
else
|
else
|
||||||
S.RRI.ReverseInsertPts.insert(llvm::next(BasicBlock::iterator(Inst)));
|
S.RRI.ReverseInsertPts.insert(llvm::next(BasicBlock::iterator(Inst)));
|
||||||
S.SetSeq(S_Use);
|
S.SetSeq(S_Use);
|
||||||
} else if (Seq == S_Release &&
|
} else if (Seq == S_Release && IsUser(Class)) {
|
||||||
(Class == IC_User || Class == IC_CallOrUser)) {
|
|
||||||
// Non-movable releases depend on any possible objc pointer use.
|
// Non-movable releases depend on any possible objc pointer use.
|
||||||
S.SetSeq(S_Stop);
|
S.SetSeq(S_Stop);
|
||||||
assert(S.RRI.ReverseInsertPts.empty());
|
assert(S.RRI.ReverseInsertPts.empty());
|
||||||
@ -2392,6 +2394,7 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
|
|||||||
goto clobbered;
|
goto clobbered;
|
||||||
case IC_AutoreleasepoolPush:
|
case IC_AutoreleasepoolPush:
|
||||||
case IC_None:
|
case IC_None:
|
||||||
|
case IC_IntrinsicUser:
|
||||||
case IC_User:
|
case IC_User:
|
||||||
// Weak pointers are only modified through the weak entry points
|
// Weak pointers are only modified through the weak entry points
|
||||||
// (and arbitrary calls, which could call the weak entry points).
|
// (and arbitrary calls, which could call the weak entry points).
|
||||||
|
@ -72,6 +72,8 @@ raw_ostream &llvm::objcarc::operator<<(raw_ostream &OS,
|
|||||||
return OS << "IC_Call";
|
return OS << "IC_Call";
|
||||||
case IC_User:
|
case IC_User:
|
||||||
return OS << "IC_User";
|
return OS << "IC_User";
|
||||||
|
case IC_IntrinsicUser:
|
||||||
|
return OS << "IC_IntrinsicUser";
|
||||||
case IC_None:
|
case IC_None:
|
||||||
return OS << "IC_None";
|
return OS << "IC_None";
|
||||||
}
|
}
|
||||||
@ -81,10 +83,11 @@ raw_ostream &llvm::objcarc::operator<<(raw_ostream &OS,
|
|||||||
InstructionClass llvm::objcarc::GetFunctionClass(const Function *F) {
|
InstructionClass llvm::objcarc::GetFunctionClass(const Function *F) {
|
||||||
Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
|
Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
|
||||||
|
|
||||||
// No arguments.
|
// No (mandatory) arguments.
|
||||||
if (AI == AE)
|
if (AI == AE)
|
||||||
return StringSwitch<InstructionClass>(F->getName())
|
return StringSwitch<InstructionClass>(F->getName())
|
||||||
.Case("objc_autoreleasePoolPush", IC_AutoreleasepoolPush)
|
.Case("objc_autoreleasePoolPush", IC_AutoreleasepoolPush)
|
||||||
|
.Case("clang.arc.use", IC_IntrinsicUser)
|
||||||
.Default(IC_CallOrUser);
|
.Default(IC_CallOrUser);
|
||||||
|
|
||||||
// One argument.
|
// One argument.
|
||||||
|
@ -162,4 +162,15 @@ return: ; preds = %if.then, %entry
|
|||||||
ret i8* %retval
|
ret i8* %retval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Kill calls to @clang.arc.use(...)
|
||||||
|
; CHECK: define void @test9(
|
||||||
|
; CHECK-NOT: clang.arc.use
|
||||||
|
; CHECK: }
|
||||||
|
define void @test9(i8* %a, i8* %b) {
|
||||||
|
call void (...)* @clang.arc.use(i8* %a, i8* %b) nounwind
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @clang.arc.use(...) nounwind
|
||||||
|
|
||||||
; CHECK: attributes [[NUW]] = { nounwind }
|
; CHECK: attributes [[NUW]] = { nounwind }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user