summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h')
-rw-r--r--llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h74
1 files changed, 16 insertions, 58 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
index ba4924c9cb2..7f6b157304a 100644
--- a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
+++ b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
@@ -26,6 +26,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/ErrorHandling.h"
@@ -74,27 +75,27 @@ public:
switch (kind) {
case ARCRuntimeEntryPointKind::AutoreleaseRV:
- return getI8XRetI8XEntryPoint(AutoreleaseRV,
- "objc_autoreleaseReturnValue", true);
+ return getIntrinsicEntryPoint(AutoreleaseRV,
+ Intrinsic::objc_autoreleaseReturnValue);
case ARCRuntimeEntryPointKind::Release:
- return getVoidRetI8XEntryPoint(Release, "objc_release");
+ return getIntrinsicEntryPoint(Release, Intrinsic::objc_release);
case ARCRuntimeEntryPointKind::Retain:
- return getI8XRetI8XEntryPoint(Retain, "objc_retain", true);
+ return getIntrinsicEntryPoint(Retain, Intrinsic::objc_retain);
case ARCRuntimeEntryPointKind::RetainBlock:
- return getI8XRetI8XEntryPoint(RetainBlock, "objc_retainBlock", false);
+ return getIntrinsicEntryPoint(RetainBlock, Intrinsic::objc_retainBlock);
case ARCRuntimeEntryPointKind::Autorelease:
- return getI8XRetI8XEntryPoint(Autorelease, "objc_autorelease", true);
+ return getIntrinsicEntryPoint(Autorelease, Intrinsic::objc_autorelease);
case ARCRuntimeEntryPointKind::StoreStrong:
- return getI8XRetI8XXI8XEntryPoint(StoreStrong, "objc_storeStrong");
+ return getIntrinsicEntryPoint(StoreStrong, Intrinsic::objc_storeStrong);
case ARCRuntimeEntryPointKind::RetainRV:
- return getI8XRetI8XEntryPoint(RetainRV,
- "objc_retainAutoreleasedReturnValue", true);
+ return getIntrinsicEntryPoint(RetainRV,
+ Intrinsic::objc_retainAutoreleasedReturnValue);
case ARCRuntimeEntryPointKind::RetainAutorelease:
- return getI8XRetI8XEntryPoint(RetainAutorelease, "objc_retainAutorelease",
- true);
+ return getIntrinsicEntryPoint(RetainAutorelease,
+ Intrinsic::objc_retainAutorelease);
case ARCRuntimeEntryPointKind::RetainAutoreleaseRV:
- return getI8XRetI8XEntryPoint(RetainAutoreleaseRV,
- "objc_retainAutoreleaseReturnValue", true);
+ return getIntrinsicEntryPoint(RetainAutoreleaseRV,
+ Intrinsic::objc_retainAutoreleaseReturnValue);
}
llvm_unreachable("Switch should be a covered switch.");
@@ -131,54 +132,11 @@ private:
/// Declaration for objc_retainAutoreleaseReturnValue().
Constant *RetainAutoreleaseRV = nullptr;
- Constant *getVoidRetI8XEntryPoint(Constant *&Decl, StringRef Name) {
+ Constant *getIntrinsicEntryPoint(Constant *&Decl, Intrinsic::ID IntID) {
if (Decl)
return Decl;
- LLVMContext &C = TheModule->getContext();
- Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
- AttributeList Attr = AttributeList().addAttribute(
- C, AttributeList::FunctionIndex, Attribute::NoUnwind);
- FunctionType *Fty = FunctionType::get(Type::getVoidTy(C), Params,
- /*isVarArg=*/false);
- return Decl = TheModule->getOrInsertFunction(Name, Fty, Attr);
- }
-
- Constant *getI8XRetI8XEntryPoint(Constant *&Decl, StringRef Name,
- bool NoUnwind = false) {
- if (Decl)
- return Decl;
-
- LLVMContext &C = TheModule->getContext();
- Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
- Type *Params[] = { I8X };
- FunctionType *Fty = FunctionType::get(I8X, Params, /*isVarArg=*/false);
- AttributeList Attr = AttributeList();
-
- if (NoUnwind)
- Attr = Attr.addAttribute(C, AttributeList::FunctionIndex,
- Attribute::NoUnwind);
-
- return Decl = TheModule->getOrInsertFunction(Name, Fty, Attr);
- }
-
- Constant *getI8XRetI8XXI8XEntryPoint(Constant *&Decl, StringRef Name) {
- if (Decl)
- return Decl;
-
- LLVMContext &C = TheModule->getContext();
- Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
- Type *I8XX = PointerType::getUnqual(I8X);
- Type *Params[] = { I8XX, I8X };
-
- AttributeList Attr = AttributeList().addAttribute(
- C, AttributeList::FunctionIndex, Attribute::NoUnwind);
- Attr = Attr.addParamAttribute(C, 0, Attribute::NoCapture);
-
- FunctionType *Fty = FunctionType::get(Type::getVoidTy(C), Params,
- /*isVarArg=*/false);
-
- return Decl = TheModule->getOrInsertFunction(Name, Fty, Attr);
+ return Decl = Intrinsic::getDeclaration(TheModule, IntID);
}
};
OpenPOWER on IntegriCloud