[K/N] Add ObjCARCContract LLVM pass.
This commit is contained in:
committed by
TeamCityServer
parent
1eb960783a
commit
690d0689a1
+8
-1
@@ -22,6 +22,7 @@ private fun initializeLlvmGlobalPassRegistry() {
|
||||
LLVMInitializeIPA(passRegistry)
|
||||
LLVMInitializeCodeGen(passRegistry)
|
||||
LLVMInitializeTarget(passRegistry)
|
||||
LLVMInitializeObjCARCOpts(passRegistry)
|
||||
}
|
||||
|
||||
internal fun shouldRunLateBitcodePasses(context: Context): Boolean {
|
||||
@@ -166,10 +167,16 @@ internal fun runLlvmOptimizationPipeline(context: Context) {
|
||||
config.customInlineThreshold?.let { threshold ->
|
||||
LLVMPassManagerBuilderUseInlinerWithThreshold(passBuilder, threshold)
|
||||
}
|
||||
|
||||
// Pipeline that is similar to `llvm-lto`.
|
||||
// TODO: Add ObjC optimization passes.
|
||||
LLVMPassManagerBuilderPopulateLTOPassManager(passBuilder, modulePasses, Internalize = 0, RunInliner = 1)
|
||||
|
||||
// Lower ObjC ARC intrinsics (e.g. `@llvm.objc.clang.arc.use(...)`).
|
||||
// While Kotlin/Native codegen itself doesn't produce these intrinsics, they might come
|
||||
// from cinterop "glue" bitcode.
|
||||
// TODO: Consider adding other ObjC passes.
|
||||
LLVMAddObjCARCContractPass(modulePasses)
|
||||
|
||||
LLVMRunPassManager(modulePasses, llvmModule)
|
||||
|
||||
LLVMPassManagerBuilderDispose(passBuilder)
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#include <llvm/IR/LegacyPassManager.h>
|
||||
#include <llvm/Analysis/TargetLibraryInfo.h>
|
||||
#include <llvm/Transforms/Instrumentation.h>
|
||||
#include <llvm/Transforms/ObjCARC.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/Path.h>
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -230,6 +232,11 @@ void LLVMKotlinAddTargetLibraryInfoWrapperPass(LLVMPassManagerRef passManagerRef
|
||||
passManager->add(new TargetLibraryInfoWrapperPass(Triple(targetTriple)));
|
||||
}
|
||||
|
||||
void LLVMAddObjCARCContractPass(LLVMPassManagerRef passManagerRef) {
|
||||
legacy::PassManagerBase *passManager = unwrap(passManagerRef);
|
||||
passManager->add(createObjCARCContractPass());
|
||||
}
|
||||
|
||||
void LLVMKotlinInitializeTargets() {
|
||||
#define INIT_LLVM_TARGET(TargetName) \
|
||||
LLVMInitialize##TargetName##TargetInfo();\
|
||||
|
||||
@@ -74,6 +74,8 @@ void LLVMAddInstrProfPass(LLVMPassManagerRef passManagerRef, const char* outputF
|
||||
|
||||
void LLVMKotlinAddTargetLibraryInfoWrapperPass(LLVMPassManagerRef passManagerRef, const char* targetTriple);
|
||||
|
||||
void LLVMAddObjCARCContractPass(LLVMPassManagerRef passManagerRef);
|
||||
|
||||
void LLVMKotlinInitializeTargets();
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user