[K/N] Don't pass -target-cpu to clang
It is not supported by bitcode embedding on Apple platforms. Instead, we set it in function attributes directly as Clang does.
This commit is contained in:
+13
@@ -22,6 +22,7 @@ internal fun addLlvmFunctionWithDefaultAttributes(
|
||||
type: LLVMTypeRef
|
||||
): LLVMValueRef = LLVMAddFunction(module, name, type)!!.also {
|
||||
addDefaultLlvmFunctionAttributes(context, it)
|
||||
addTargetCpuAndFeaturesAttributes(context, it)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,18 @@ private fun addDefaultLlvmFunctionAttributes(context: Context, llvmFunction: LLV
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set target cpu and its features to make LLVM generate correct machine code.
|
||||
*/
|
||||
private fun addTargetCpuAndFeaturesAttributes(context: Context, llvmFunction: LLVMValueRef) {
|
||||
context.config.platform.targetCpu?.let {
|
||||
LLVMAddTargetDependentFunctionAttr(llvmFunction, "target-cpu", it)
|
||||
}
|
||||
context.config.platform.targetCpuFeatures?.let {
|
||||
LLVMAddTargetDependentFunctionAttr(llvmFunction, "target-features", it)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun addLlvmAttributesForKotlinFunction(context: Context, irFunction: IrFunction, llvmFunction: LLVMValueRef) {
|
||||
if (irFunction.returnType.isNothing()) {
|
||||
setFunctionNoReturn(llvmFunction)
|
||||
|
||||
Reference in New Issue
Block a user