[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)
|
LLVMInitializeIPA(passRegistry)
|
||||||
LLVMInitializeCodeGen(passRegistry)
|
LLVMInitializeCodeGen(passRegistry)
|
||||||
LLVMInitializeTarget(passRegistry)
|
LLVMInitializeTarget(passRegistry)
|
||||||
|
LLVMInitializeObjCARCOpts(passRegistry)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun shouldRunLateBitcodePasses(context: Context): Boolean {
|
internal fun shouldRunLateBitcodePasses(context: Context): Boolean {
|
||||||
@@ -166,10 +167,16 @@ internal fun runLlvmOptimizationPipeline(context: Context) {
|
|||||||
config.customInlineThreshold?.let { threshold ->
|
config.customInlineThreshold?.let { threshold ->
|
||||||
LLVMPassManagerBuilderUseInlinerWithThreshold(passBuilder, threshold)
|
LLVMPassManagerBuilderUseInlinerWithThreshold(passBuilder, threshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pipeline that is similar to `llvm-lto`.
|
// Pipeline that is similar to `llvm-lto`.
|
||||||
// TODO: Add ObjC optimization passes.
|
|
||||||
LLVMPassManagerBuilderPopulateLTOPassManager(passBuilder, modulePasses, Internalize = 0, RunInliner = 1)
|
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)
|
LLVMRunPassManager(modulePasses, llvmModule)
|
||||||
|
|
||||||
LLVMPassManagerBuilderDispose(passBuilder)
|
LLVMPassManagerBuilderDispose(passBuilder)
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
#include <llvm/IR/LegacyPassManager.h>
|
#include <llvm/IR/LegacyPassManager.h>
|
||||||
#include <llvm/Analysis/TargetLibraryInfo.h>
|
#include <llvm/Analysis/TargetLibraryInfo.h>
|
||||||
#include <llvm/Transforms/Instrumentation.h>
|
#include <llvm/Transforms/Instrumentation.h>
|
||||||
|
#include <llvm/Transforms/ObjCARC.h>
|
||||||
#include <llvm/Support/FileSystem.h>
|
#include <llvm/Support/FileSystem.h>
|
||||||
#include <llvm/Support/Path.h>
|
#include <llvm/Support/Path.h>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -230,6 +232,11 @@ void LLVMKotlinAddTargetLibraryInfoWrapperPass(LLVMPassManagerRef passManagerRef
|
|||||||
passManager->add(new TargetLibraryInfoWrapperPass(Triple(targetTriple)));
|
passManager->add(new TargetLibraryInfoWrapperPass(Triple(targetTriple)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LLVMAddObjCARCContractPass(LLVMPassManagerRef passManagerRef) {
|
||||||
|
legacy::PassManagerBase *passManager = unwrap(passManagerRef);
|
||||||
|
passManager->add(createObjCARCContractPass());
|
||||||
|
}
|
||||||
|
|
||||||
void LLVMKotlinInitializeTargets() {
|
void LLVMKotlinInitializeTargets() {
|
||||||
#define INIT_LLVM_TARGET(TargetName) \
|
#define INIT_LLVM_TARGET(TargetName) \
|
||||||
LLVMInitialize##TargetName##TargetInfo();\
|
LLVMInitialize##TargetName##TargetInfo();\
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ void LLVMAddInstrProfPass(LLVMPassManagerRef passManagerRef, const char* outputF
|
|||||||
|
|
||||||
void LLVMKotlinAddTargetLibraryInfoWrapperPass(LLVMPassManagerRef passManagerRef, const char* targetTriple);
|
void LLVMKotlinAddTargetLibraryInfoWrapperPass(LLVMPassManagerRef passManagerRef, const char* targetTriple);
|
||||||
|
|
||||||
|
void LLVMAddObjCARCContractPass(LLVMPassManagerRef passManagerRef);
|
||||||
|
|
||||||
void LLVMKotlinInitializeTargets();
|
void LLVMKotlinInitializeTargets();
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user