mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 22:07:27 +00:00
[objc-arc] Change EntryPointType to an enum class outside of ARCRuntimeEntryPoints called ARCRuntimeEntryPointKind.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232347 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e4931b489
commit
5b69462b3a
@ -27,22 +27,22 @@
|
||||
namespace llvm {
|
||||
namespace objcarc {
|
||||
|
||||
enum class ARCRuntimeEntryPointKind {
|
||||
AutoreleaseRV,
|
||||
Release,
|
||||
Retain,
|
||||
RetainBlock,
|
||||
Autorelease,
|
||||
StoreStrong,
|
||||
RetainRV,
|
||||
RetainAutorelease,
|
||||
RetainAutoreleaseRV,
|
||||
};
|
||||
|
||||
/// Declarations for ObjC runtime functions and constants. These are initialized
|
||||
/// lazily to avoid cluttering up the Module with unused declarations.
|
||||
class ARCRuntimeEntryPoints {
|
||||
public:
|
||||
enum EntryPointType {
|
||||
EPT_AutoreleaseRV,
|
||||
EPT_Release,
|
||||
EPT_Retain,
|
||||
EPT_RetainBlock,
|
||||
EPT_Autorelease,
|
||||
EPT_StoreStrong,
|
||||
EPT_RetainRV,
|
||||
EPT_RetainAutorelease,
|
||||
EPT_RetainAutoreleaseRV
|
||||
};
|
||||
|
||||
ARCRuntimeEntryPoints() : TheModule(nullptr),
|
||||
AutoreleaseRV(nullptr),
|
||||
Release(nullptr),
|
||||
@ -69,30 +69,30 @@ public:
|
||||
RetainAutoreleaseRV = nullptr;
|
||||
}
|
||||
|
||||
Constant *get(const EntryPointType entry) {
|
||||
Constant *get(ARCRuntimeEntryPointKind kind) {
|
||||
assert(TheModule != nullptr && "Not initialized.");
|
||||
|
||||
switch (entry) {
|
||||
case EPT_AutoreleaseRV:
|
||||
switch (kind) {
|
||||
case ARCRuntimeEntryPointKind::AutoreleaseRV:
|
||||
return getI8XRetI8XEntryPoint(AutoreleaseRV,
|
||||
"objc_autoreleaseReturnValue", true);
|
||||
case EPT_Release:
|
||||
case ARCRuntimeEntryPointKind::Release:
|
||||
return getVoidRetI8XEntryPoint(Release, "objc_release");
|
||||
case EPT_Retain:
|
||||
case ARCRuntimeEntryPointKind::Retain:
|
||||
return getI8XRetI8XEntryPoint(Retain, "objc_retain", true);
|
||||
case EPT_RetainBlock:
|
||||
case ARCRuntimeEntryPointKind::RetainBlock:
|
||||
return getI8XRetI8XEntryPoint(RetainBlock, "objc_retainBlock", false);
|
||||
case EPT_Autorelease:
|
||||
case ARCRuntimeEntryPointKind::Autorelease:
|
||||
return getI8XRetI8XEntryPoint(Autorelease, "objc_autorelease", true);
|
||||
case EPT_StoreStrong:
|
||||
case ARCRuntimeEntryPointKind::StoreStrong:
|
||||
return getI8XRetI8XXI8XEntryPoint(StoreStrong, "objc_storeStrong");
|
||||
case EPT_RetainRV:
|
||||
case ARCRuntimeEntryPointKind::RetainRV:
|
||||
return getI8XRetI8XEntryPoint(RetainRV,
|
||||
"objc_retainAutoreleasedReturnValue", true);
|
||||
case EPT_RetainAutorelease:
|
||||
case ARCRuntimeEntryPointKind::RetainAutorelease:
|
||||
return getI8XRetI8XEntryPoint(RetainAutorelease, "objc_retainAutorelease",
|
||||
true);
|
||||
case EPT_RetainAutoreleaseRV:
|
||||
case ARCRuntimeEntryPointKind::RetainAutoreleaseRV:
|
||||
return getI8XRetI8XEntryPoint(RetainAutoreleaseRV,
|
||||
"objc_retainAutoreleaseReturnValue", true);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ bool ObjCARCContract::optimizeRetainCall(Function &F, Instruction *Retain) {
|
||||
|
||||
// We do not have to worry about tail calls/does not throw since
|
||||
// retain/retainRV have the same properties.
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_RetainRV);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPointKind::RetainRV);
|
||||
cast<CallInst>(Retain)->setCalledFunction(Decl);
|
||||
|
||||
DEBUG(dbgs() << "New: " << *Retain << "\n");
|
||||
@ -181,8 +181,8 @@ bool ObjCARCContract::contractAutorelease(
|
||||
" Retain: " << *Retain << "\n");
|
||||
|
||||
Constant *Decl = EP.get(Class == ARCInstKind::AutoreleaseRV
|
||||
? ARCRuntimeEntryPoints::EPT_RetainAutoreleaseRV
|
||||
: ARCRuntimeEntryPoints::EPT_RetainAutorelease);
|
||||
? ARCRuntimeEntryPointKind::RetainAutoreleaseRV
|
||||
: ARCRuntimeEntryPointKind::RetainAutorelease);
|
||||
Retain->setCalledFunction(Decl);
|
||||
|
||||
DEBUG(dbgs() << " New RetainAutorelease: " << *Retain << "\n");
|
||||
@ -380,7 +380,7 @@ void ObjCARCContract::tryToContractReleaseIntoStoreStrong(Instruction *Release,
|
||||
Args[0] = new BitCastInst(Args[0], I8XX, "", Store);
|
||||
if (Args[1]->getType() != I8X)
|
||||
Args[1] = new BitCastInst(Args[1], I8X, "", Store);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_StoreStrong);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPointKind::StoreStrong);
|
||||
CallInst *StoreStrong = CallInst::Create(Decl, Args, "", Store);
|
||||
StoreStrong->setDoesNotThrow();
|
||||
StoreStrong->setDebugLoc(Store->getDebugLoc());
|
||||
|
@ -567,7 +567,7 @@ ObjCARCOpt::OptimizeRetainRVCall(Function &F, Instruction *RetainRV) {
|
||||
"objc_retain since the operand is not a return value.\n"
|
||||
"Old = " << *RetainRV << "\n");
|
||||
|
||||
Constant *NewDecl = EP.get(ARCRuntimeEntryPoints::EPT_Retain);
|
||||
Constant *NewDecl = EP.get(ARCRuntimeEntryPointKind::Retain);
|
||||
cast<CallInst>(RetainRV)->setCalledFunction(NewDecl);
|
||||
|
||||
DEBUG(dbgs() << "New = " << *RetainRV << "\n");
|
||||
@ -603,7 +603,7 @@ void ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F,
|
||||
"Old = " << *AutoreleaseRV << "\n");
|
||||
|
||||
CallInst *AutoreleaseRVCI = cast<CallInst>(AutoreleaseRV);
|
||||
Constant *NewDecl = EP.get(ARCRuntimeEntryPoints::EPT_Autorelease);
|
||||
Constant *NewDecl = EP.get(ARCRuntimeEntryPointKind::Autorelease);
|
||||
AutoreleaseRVCI->setCalledFunction(NewDecl);
|
||||
AutoreleaseRVCI->setTailCall(false); // Never tail call objc_autorelease.
|
||||
Class = ARCInstKind::Autorelease;
|
||||
@ -709,7 +709,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
|
||||
// Create the declaration lazily.
|
||||
LLVMContext &C = Inst->getContext();
|
||||
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Release);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Release);
|
||||
CallInst *NewCall = CallInst::Create(Decl, Call->getArgOperand(0), "",
|
||||
Call);
|
||||
NewCall->setMetadata(MDKindCache.ImpreciseReleaseMDKind,
|
||||
@ -1414,7 +1414,7 @@ void ObjCARCOpt::MoveCalls(Value *Arg, RRInfo &RetainsToMove,
|
||||
for (Instruction *InsertPt : ReleasesToMove.ReverseInsertPts) {
|
||||
Value *MyArg = ArgTy == ParamTy ? Arg :
|
||||
new BitCastInst(Arg, ParamTy, "", InsertPt);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Retain);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
|
||||
CallInst *Call = CallInst::Create(Decl, MyArg, "", InsertPt);
|
||||
Call->setDoesNotThrow();
|
||||
Call->setTailCall();
|
||||
@ -1425,7 +1425,7 @@ void ObjCARCOpt::MoveCalls(Value *Arg, RRInfo &RetainsToMove,
|
||||
for (Instruction *InsertPt : RetainsToMove.ReverseInsertPts) {
|
||||
Value *MyArg = ArgTy == ParamTy ? Arg :
|
||||
new BitCastInst(Arg, ParamTy, "", InsertPt);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Release);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Release);
|
||||
CallInst *Call = CallInst::Create(Decl, MyArg, "", InsertPt);
|
||||
// Attach a clang.imprecise_release metadata tag, if appropriate.
|
||||
if (MDNode *M = ReleasesToMove.ReleaseMetadata)
|
||||
@ -1780,7 +1780,7 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
|
||||
Changed = true;
|
||||
// If the load has a builtin retain, insert a plain retain for it.
|
||||
if (Class == ARCInstKind::LoadWeakRetained) {
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Retain);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
|
||||
CallInst *CI = CallInst::Create(Decl, EarlierCall, "", Call);
|
||||
CI->setTailCall();
|
||||
}
|
||||
@ -1809,7 +1809,7 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
|
||||
Changed = true;
|
||||
// If the load has a builtin retain, insert a plain retain for it.
|
||||
if (Class == ARCInstKind::LoadWeakRetained) {
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPoints::EPT_Retain);
|
||||
Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
|
||||
CallInst *CI = CallInst::Create(Decl, EarlierCall, "", Call);
|
||||
CI->setTailCall();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user