[llvm][update][5.0.0] llvm 5.0.0

This commit is contained in:
Vasily Levchenko
2017-12-01 09:29:38 +03:00
committed by Vasily Levchenko
parent e2d2ed5237
commit 3a6cb76dc1
15 changed files with 127 additions and 63 deletions
+7 -3
View File
@@ -99,13 +99,17 @@ kotlinNativeInterop {
llvm {
dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary"
defFile 'llvm.def'
compilerOpts "-fPIC", "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include"
if (!project.parent.convention.plugins.platformInfo.isWindows())
compilerOpts "-fPIC"
compilerOpts "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include"
linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static"
}
hash { // TODO: copy-pasted from ':common:compileHash'
compilerOpts '-fPIC'
linkerOpts '-fPIC'
if (!project.parent.convention.plugins.platformInfo.isWindows()) {
compilerOpts '-fPIC'
linkerOpts '-fPIC'
}
linker 'clang++'
linkOutputs ":common:${hostName}Hash"
@@ -290,8 +290,8 @@ internal class FunctionGenerationContext(val function: LLVMValueRef,
private fun callRaw(llvmFunction: LLVMValueRef, args: List<LLVMValueRef>,
lazyLandingpad: () -> LLVMBasicBlockRef?): LLVMValueRef {
val rargs = args.toCValues()
if (LLVMIsAFunction(llvmFunction) != null /* the function declaration */ &&
(LLVMGetFunctionAttr(llvmFunction) and LLVMNoUnwindAttribute) != 0) {
if (LLVMIsAFunction(llvmFunction) != null /* the function declaration */ &&
isFunctionNoUnwind(llvmFunction)) {
return LLVMBuildCall(builder, llvmFunction, rargs, args.size, "")!!
} else {
@@ -280,11 +280,25 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
val functionType = getFunctionType(externalFunction)
val function = LLVMAddFunction(llvmModule, name, functionType)!!
val attributes = LLVMGetFunctionAttr(externalFunction)
LLVMAddFunctionAttr(function, attributes)
copyFunctionAttributes(externalFunction, function)
return function
}
private fun copyFunctionAttributes(source: LLVMValueRef, destination: LLVMValueRef) {
// TODO: consider parameter attributes
val attributeIndex = LLVMAttributeFunctionIndex
val count = LLVMGetAttributeCountAtIndex(source, attributeIndex)
memScoped {
val attributes = allocArray<LLVMAttributeRefVar>(count)
LLVMGetAttributesAtIndex(source, attributeIndex, attributes)
(0 until count).forEach {
LLVMAddAttributeAtIndex(destination, attributeIndex, attributes[it])
}
}
}
private fun importMemset() : LLVMValueRef {
val parameterTypes = cValuesOf(int8TypePtr, int8Type, int32Type, int32Type, int1Type)
val functionType = LLVMFunctionType(LLVMVoidType(), parameterTypes, 5, 0)
@@ -306,7 +320,7 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
private fun externalNounwindFunction(name: String, type: LLVMTypeRef, origin: LlvmSymbolOrigin): LLVMValueRef {
val function = externalFunction(name, type, origin)
LLVMAddFunctionAttr(function, LLVMNoUnwindAttribute)
setFunctionNoUnwind(function)
return function
}
@@ -281,6 +281,28 @@ fun parseBitcodeFile(path: String): LLVMModuleRef = memScoped {
}
}
private val nounwindAttrKindId: Int
get() = getAttributeKindId("nounwind")
fun isFunctionNoUnwind(function: LLVMValueRef): Boolean {
val attribute = LLVMGetEnumAttributeAtIndex(function, LLVMAttributeFunctionIndex, nounwindAttrKindId)
return attribute != null
}
private fun getAttributeKindId(attributeName: String): Int {
val nounwindAttrKindId = LLVMGetEnumAttributeKindForName(attributeName, attributeName.length.signExtend())
if (nounwindAttrKindId == 0) {
throw Error("Unable to find '$attributeName' attribute kind id")
}
return nounwindAttrKindId
}
fun setFunctionNoUnwind(function: LLVMValueRef) {
val attribute = LLVMCreateEnumAttribute(LLVMGetTypeContext(function.type), nounwindAttrKindId, 0)!!
LLVMAddAttributeAtIndex(function, LLVMAttributeFunctionIndex, attribute)
}
internal fun String.mdString() = LLVMMDString(this, this.length)!!
internal fun node(vararg it:LLVMValueRef) = LLVMMDNode(it.toList().toCValues(), it.size)
+29 -30
View File
@@ -28,9 +28,9 @@ homeDependencyCache = .konan/cache
llvmDebugOptFlags = -O0
# Mac OS X.
llvmVersion.osx = 3.9.0
llvmHome.osx = clang-llvm-3.9.0-darwin-macos
targetToolchain.osx = clang-llvm-3.9.0-darwin-macos
llvmVersion.osx = 5.0.0
llvmHome.osx = clang-llvm-5.0.0-darwin-macos
targetToolchain.osx = clang-llvm-5.0.0-darwin-macos
arch.osx = x86_64
targetSysRoot.osx = target-sysroot-1-darwin-macos
@@ -49,13 +49,13 @@ osVersionMin.osx = 10.11
entrySelector.osx = -alias _Konan_main _main
dependencies.osx = target-sysroot-1-darwin-macos \
libffi-3.2.1-2-darwin-macos \
clang-llvm-3.9.0-darwin-macos
clang-llvm-5.0.0-darwin-macos
# Apple iOS.
targetToolchain.osx-ios = clang-llvm-3.9.0-darwin-macos
targetToolchain.osx-ios = clang-llvm-5.0.0-darwin-macos
dependencies.osx-ios = target-sysroot-1-darwin-macos \
libffi-3.2.1-2-darwin-ios \
clang-llvm-3.9.0-darwin-macos \
clang-llvm-5.0.0-darwin-macos \
target-sysroot-2-darwin-ios
arch.ios = arm64
@@ -73,10 +73,10 @@ osVersionMinFlagClang.ios = -miphoneos-version-min
osVersionMin.ios = 8.0
# Apple iOS simulator.
targetToolchain.osx-ios_sim = clang-llvm-3.9.0-darwin-macos
targetToolchain.osx-ios_sim = clang-llvm-5.0.0-darwin-macos
dependencies.osx-ios_sim = target-sysroot-1-darwin-macos \
libffi-3.2.1-2-darwin-ios_sim \
clang-llvm-3.9.0-darwin-macos \
clang-llvm-5.0.0-darwin-macos \
target-sysroot-1-darwin-ios_sim
arch.ios_sim = x86_64
@@ -94,8 +94,8 @@ osVersionMinFlagClang.ios_sim = -mios-simulator-version-min
osVersionMin.ios_sim = 8.0
# Linux x86-64.
llvmVersion.linux = 3.9.0
llvmHome.linux = clang-llvm-3.9.0-linux-x86-64
llvmVersion.linux = 5.0.0
llvmHome.linux = clang-llvm-5.0.0-linux-x86-64
gccToolchain.linux = target-gcc-toolchain-3-linux-x86-64
targetToolchain.linux = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu
@@ -119,14 +119,14 @@ entrySelector.linux = --defsym main=Konan_main
# targetSysRoot relative
abiSpecificLibraries.linux = ../lib64 lib64 usr/lib64
dependencies.linux = \
clang-llvm-3.9.0-linux-x86-64 \
clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-3-linux-x86-64 \
libffi-3.2.1-2-linux-x86-64
# Raspberry Pi
targetToolchain.linux-raspberrypi = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu
dependencies.linux-raspberrypi = \
clang-llvm-3.9.0-linux-x86-64 \
clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-3-linux-x86-64 \
target-sysroot-1-raspberrypi \
libffi-3.2.1-2-linux-x86-64 \
@@ -155,7 +155,7 @@ abiSpecificLibraries.raspberrypi = \
# MIPS
targetToolchain.linux-linux_mips32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu
dependencies.linux-linux_mips32 = \
clang-llvm-3.9.0-linux-x86-64 \
clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-2-linux-mips \
target-sysroot-2-mips \
libffi-3.2.1-2-linux-x86-64 \
@@ -179,7 +179,7 @@ abiSpecificLibraries.linux_mips32 =
# MIPSel
targetToolchain.linux-linux_mipsel32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu
dependencies.linux-linux_mipsel32 = \
clang-llvm-3.9.0-linux-x86-64 \
clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-2-linux-mips \
target-sysroot-2-mipsel \
libffi-3.2.1-2-linux-x86-64 \
@@ -204,13 +204,13 @@ abiSpecificLibraries.linux_mipsel32 =
targetToolchain.osx-android_arm32 = target-toolchain-21-osx-android_arm32
# TODO: split dependencies to host-dependent and host-independent parts.
dependencies.osx-android_arm32 = \
clang-llvm-3.9.0-darwin-macos \
clang-llvm-5.0.0-darwin-macos \
target-sysroot-21-android_arm32 \
target-toolchain-21-osx-android_arm32 \
libffi-3.2.1-2-android_arm32
targetToolchain.linux-android_arm32 = target-toolchain-21-linux-android_arm32
dependencies.linux-android_arm32 = \
clang-llvm-3.9.0-linux-x86-64 \
clang-llvm-5.0.0-linux-x86-64 \
target-sysroot-21-android_arm32 \
target-toolchain-21-linux-android_arm32 \
libffi-3.2.1-2-android_arm32
@@ -229,13 +229,13 @@ linkerKonanFlags.android_arm32 = -lm -latomic -lstdc++ -landroid
targetToolchain.osx-android_arm64 = target-toolchain-21-osx-android_arm64
# TODO: split dependencies to host-dependent and host-independent parts.
dependencies.osx-android_arm64 = \
clang-llvm-3.9.0-darwin-macos \
clang-llvm-5.0.0-darwin-macos \
target-sysroot-21-android_arm64 \
target-toolchain-21-osx-android_arm64 \
libffi-3.2.1-2-android_arm64
targetToolchain.linux-android_arm64 = target-toolchain-21-linux-android_arm64
dependencies.linux-android_arm64 = \
clang-llvm-3.9.0-linux-x86-64 \
clang-llvm-5.0.0-linux-x86-64 \
target-sysroot-21-android_arm64 \
target-toolchain-21-linux-android_arm64 \
libffi-3.2.1-2-android_arm64
@@ -249,34 +249,33 @@ linkerKonanFlags.android_arm64 = -lm -latomic -lstdc++ -landroid
linkerDebugFlags.android_arm64 = -Wl,-S
# Windows x86-64, based on mingw-w64.
llvmVersion.mingw = 3.9.1
llvmHome.mingw = msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64
targetToolchain.mingw = msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64
llvmVersion.mingw = 5.0.0
llvmHome.mingw = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
targetToolchain.mingw = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
quadruple.mingw = x86_64-w64-mingw32
targetSysRoot.mingw = msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64
targetSysRoot.mingw = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
libffiDir.mingw = libffi-3.2.1-mingw-w64-x86-64
llvmLtoFlags.mingw =
llvmLtoOptFlags.mingw = -O3 -function-sections
llvmLtoNooptFlags.mingw = -O1
linkerDebugFlags.mingw = -Wl,-S
linkerKonanFlags.mingw = -static-libgcc -static-libstdc++ \
-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic
linkerKonanFlags.mingw =-static-libgcc -static-libstdc++ -Xclang -flto-visibility-public-std -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic
linkerOptimizationFlags.mingw = -Wl,--gc-sections
entrySelector.mingw = -Wl,--defsym,main=Konan_main
dependencies.mingw = \
msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64 \
msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64 \
libffi-3.2.1-mingw-w64-x86-64
# WebAssembly 32-bit.
targetToolchain.osx-wasm32 = target-toolchain-1-osx-wasm
targetToolchain.osx-wasm32 = target-toolchain-2-osx-wasm
dependencies.osx-wasm32 = \
clang-llvm-3.9.0-darwin-macos \
target-sysroot-1-wasm \
target-toolchain-1-osx-wasm
clang-llvm-5.0.0-darwin-macos \
target-sysroot-2-wasm \
target-toolchain-2-osx-wasm
quadruple.wasm32 = wasm32
llvmLtoFlags.wasm32 =
targetSysRoot.wasm32 = target-sysroot-1-wasm
targetSysRoot.wasm32 = target-sysroot-2-wasm
# The stack size is in bytes.
s2wasmFlags.wasm32 = --allocate-stack 1048576 --import-memory
+14 -6
View File
@@ -3,7 +3,7 @@ headers = llvm-c/Core.h llvm-c/Target.h llvm-c/Analysis.h llvm-c/BitWriter.h \
headerFilter = llvm-c/* DebugInfoC.h
compilerOpts = -std=c99 -fPIC \
compilerOpts = -std=c99 \
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers \
-pedantic -Wno-long-long -Wcovered-switch-default -Wdelete-non-virtual-dtor \
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
@@ -11,28 +11,36 @@ compilerOpts = -std=c99 -fPIC \
linker = clang++
linkerOpts = -fPIC -fvisibility-inlines-hidden \
linkerOpts = -fvisibility-inlines-hidden \
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers \
-pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor \
-std=c++11 \
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
-ldebugInfo -lLLVMTarget -lLLVMMC -lLLVMLinker -lLLVMTransformUtils -lLLVMBitWriter \
-lLLVMBitReader -lLLVMAnalysis -lLLVMProfileData -lLLVMCore -lLLVMSupport
-lLLVMBitReader -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC \
-lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle
# ./llvm-config --libs analysis bitreader bitwriter core linker target
linkerOpts.osx = \
linkerOpts.osx = -fPIC \
-Wl,-search_paths_first -Wl,-headerpad_max_install_names \
-lpthread -lz -lm -lcurses
-lpthread -lz -lm -lcurses -Wl,-U,_futimens -Wl,-U,_LLVMDumpType
linkerOpts.linux=\
linkerOpts.linux= -fPIC \
-Wl,-z,noexecstack \
-lrt -ldl -lpthread -lz -lm
linkerOpts.mingw = -lole32 -luuid -static-libgcc -static-libstdc++ \
-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic
# It looks like mingw port compiled without LLVM_ENABLE_DUMP
#Note: ld on mingw process -Wl,-U,_LLVMDumpType use different from other platform
# way, using this option cause linkage error:
# ld: -r and -shared may not be used together
excludedFunctions.mingw = LLVMDumpType
excludedFunctions = LLVMInitializeAllAsmParsers LLVMInitializeAllAsmPrinters LLVMInitializeAllDisassemblers \
LLVMInitializeAllTargetInfos LLVMInitializeAllTargetMCs LLVMInitializeAllTargets LLVMInitializeNativeTarget \
LLVMInitializeNativeAsmParser LLVMInitializeNativeAsmPrinter LLVMInitializeNativeDisassembler