diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e199c87d..ede32f093 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: usesh: true copyback: false prepare: | - pkg install -y gmake git bash python3 libxml2 llvm17 + pkg install -y gmake git bash python3 libxml2 llvm18 run: | # `set -e` is needed for test failures to register. https://github.com/vmactions/freebsd-vm/issues/72 set -e -x @@ -87,20 +87,20 @@ jobs: run: | wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 17 - echo "/usr/lib/llvm-17/bin" >> $GITHUB_PATH + sudo ./llvm.sh 20 + echo "/usr/lib/llvm-20/bin" >> $GITHUB_PATH - name: Download LLVM (MacOS Intel) if: matrix.os == 'macos-13' run: | - brew install llvm@17 lua@5.4 - echo "/usr/local/opt/llvm@17/bin" >> $GITHUB_PATH + brew install llvm@18 lua@5.4 + echo "/usr/local/opt/llvm@18/bin" >> $GITHUB_PATH - name: Download LLVM (MacOS ARM) if: matrix.os == 'macos-14' run: | - brew install llvm@17 wasmtime lua@5.4 - echo "/opt/homebrew/opt/llvm@17/bin" >> $GITHUB_PATH + brew install llvm@18 wasmtime lua@5.4 + echo "/opt/homebrew/opt/llvm@18/bin" >> $GITHUB_PATH - name: Build Odin run: ./build_odin.sh release diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 314711efb..80b2a72af 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -53,8 +53,8 @@ jobs: - name: (Linux) Download LLVM run: | apk add --no-cache \ - musl-dev llvm18-dev clang18 git mold lz4 \ - libxml2-static llvm18-static zlib-static zstd-static \ + musl-dev llvm20-dev clang20 git mold lz4 \ + libxml2-static llvm20-static zlib-static zstd-static \ make shell: alpine.sh --root {0} - name: build odin diff --git a/LLVM-C.dll b/LLVM-C.dll index ee03a2acd..b2f22ba8e 100644 Binary files a/LLVM-C.dll and b/LLVM-C.dll differ diff --git a/bin/lld-link.exe b/bin/lld-link.exe index da6527264..ec739e0fd 100644 Binary files a/bin/lld-link.exe and b/bin/lld-link.exe differ diff --git a/bin/llvm/windows/LLVM-C.lib b/bin/llvm/windows/LLVM-C.lib index 0e5b6c624..6230de057 100644 Binary files a/bin/llvm/windows/LLVM-C.lib and b/bin/llvm/windows/LLVM-C.lib differ diff --git a/bin/llvm/windows/clang_rt.asan-x86_64.lib b/bin/llvm/windows/clang_rt.asan-x86_64.lib index 0b209dc8d..d7dfcbb1c 100644 Binary files a/bin/llvm/windows/clang_rt.asan-x86_64.lib and b/bin/llvm/windows/clang_rt.asan-x86_64.lib differ diff --git a/bin/wasm-ld.exe b/bin/wasm-ld.exe index da6527264..ec739e0fd 100644 Binary files a/bin/wasm-ld.exe and b/bin/wasm-ld.exe differ diff --git a/src/llvm-c/Analysis.h b/src/llvm-c/Analysis.h index 6b93b5c3d..270b145a4 100644 --- a/src/llvm-c/Analysis.h +++ b/src/llvm-c/Analysis.h @@ -19,8 +19,8 @@ #ifndef LLVM_C_ANALYSIS_H #define LLVM_C_ANALYSIS_H -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/BitReader.h b/src/llvm-c/BitReader.h index 725f3fa84..088107468 100644 --- a/src/llvm-c/BitReader.h +++ b/src/llvm-c/BitReader.h @@ -19,8 +19,8 @@ #ifndef LLVM_C_BITREADER_H #define LLVM_C_BITREADER_H -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/BitWriter.h b/src/llvm-c/BitWriter.h index ba4a61afc..ea84b6593 100644 --- a/src/llvm-c/BitWriter.h +++ b/src/llvm-c/BitWriter.h @@ -19,8 +19,8 @@ #ifndef LLVM_C_BITWRITER_H #define LLVM_C_BITWRITER_H -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Comdat.h b/src/llvm-c/Comdat.h index 30df20799..8002bc058 100644 --- a/src/llvm-c/Comdat.h +++ b/src/llvm-c/Comdat.h @@ -14,8 +14,8 @@ #ifndef LLVM_C_COMDAT_H #define LLVM_C_COMDAT_H -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Config/llvm-config.h b/src/llvm-c/Config/llvm-config.h index e4edb83c5..8b77597c9 100644 --- a/src/llvm-c/Config/llvm-config.h +++ b/src/llvm-c/Config/llvm-config.h @@ -142,16 +142,16 @@ #define LLVM_USE_PERF 0 /* Major version of the LLVM API */ -#define LLVM_VERSION_MAJOR 18 +#define LLVM_VERSION_MAJOR 20 /* Minor version of the LLVM API */ #define LLVM_VERSION_MINOR 1 /* Patch version of the LLVM API */ -#define LLVM_VERSION_PATCH 8 +#define LLVM_VERSION_PATCH 0 /* LLVM version string */ -#define LLVM_VERSION_STRING "18.1.8" +#define LLVM_VERSION_STRING "20.1.0" /* Whether LLVM records statistics for use with GetStatistics(), * PrintStatistics() or PrintStatisticsJSON() diff --git a/src/llvm-c/Core.h b/src/llvm-c/Core.h index 25b8248fd..dc8ecf4fb 100644 --- a/src/llvm-c/Core.h +++ b/src/llvm-c/Core.h @@ -15,11 +15,11 @@ #ifndef LLVM_C_CORE_H #define LLVM_C_CORE_H -#include "Deprecated.h" -#include "ErrorHandling.h" -#include "ExternC.h" +#include "llvm-c/Deprecated.h" +#include "llvm-c/ErrorHandling.h" +#include "llvm-c/ExternC.h" -#include "Types.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN @@ -146,27 +146,27 @@ typedef enum { } LLVMOpcode; typedef enum { - LLVMVoidTypeKind, /**< type with no size */ - LLVMHalfTypeKind, /**< 16 bit floating point type */ - LLVMFloatTypeKind, /**< 32 bit floating point type */ - LLVMDoubleTypeKind, /**< 64 bit floating point type */ - LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ - LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ - LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ - LLVMLabelTypeKind, /**< Labels */ - LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ - LLVMFunctionTypeKind, /**< Functions */ - LLVMStructTypeKind, /**< Structures */ - LLVMArrayTypeKind, /**< Arrays */ - LLVMPointerTypeKind, /**< Pointers */ - LLVMVectorTypeKind, /**< Fixed width SIMD vector type */ - LLVMMetadataTypeKind, /**< Metadata */ - LLVMX86_MMXTypeKind, /**< X86 MMX */ - LLVMTokenTypeKind, /**< Tokens */ - LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */ - LLVMBFloatTypeKind, /**< 16 bit brain floating point type */ - LLVMX86_AMXTypeKind, /**< X86 AMX */ - LLVMTargetExtTypeKind, /**< Target extension type */ + LLVMVoidTypeKind = 0, /**< type with no size */ + LLVMHalfTypeKind = 1, /**< 16 bit floating point type */ + LLVMFloatTypeKind = 2, /**< 32 bit floating point type */ + LLVMDoubleTypeKind = 3, /**< 64 bit floating point type */ + LLVMX86_FP80TypeKind = 4, /**< 80 bit floating point type (X87) */ + LLVMFP128TypeKind = 5, /**< 128 bit floating point type (112-bit mantissa)*/ + LLVMPPC_FP128TypeKind = 6, /**< 128 bit floating point type (two 64-bits) */ + LLVMLabelTypeKind = 7, /**< Labels */ + LLVMIntegerTypeKind = 8, /**< Arbitrary bit width integers */ + LLVMFunctionTypeKind = 9, /**< Functions */ + LLVMStructTypeKind = 10, /**< Structures */ + LLVMArrayTypeKind = 11, /**< Arrays */ + LLVMPointerTypeKind = 12, /**< Pointers */ + LLVMVectorTypeKind = 13, /**< Fixed width SIMD vector type */ + LLVMMetadataTypeKind = 14, /**< Metadata */ + /* 15 previously used by LLVMX86_MMXTypeKind */ + LLVMTokenTypeKind = 16, /**< Tokens */ + LLVMScalableVectorTypeKind = 17, /**< Scalable SIMD vector type */ + LLVMBFloatTypeKind = 18, /**< 16 bit brain floating point type */ + LLVMX86_AMXTypeKind = 19, /**< X86 AMX */ + LLVMTargetExtTypeKind = 20, /**< Target extension type */ } LLVMTypeKind; typedef enum { @@ -286,6 +286,7 @@ typedef enum { LLVMInstructionValueKind, LLVMPoisonValueValueKind, LLVMConstantTargetNoneValueKind, + LLVMConstantPtrAuthValueKind, } LLVMValueKind; typedef enum { @@ -361,35 +362,42 @@ typedef enum { } LLVMAtomicOrdering; typedef enum { - LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */ - LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */ - LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */ - LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */ - LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */ - LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */ - LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */ - LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the - original using a signed comparison and return - the old one */ - LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the - original using a signed comparison and return - the old one */ - LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the - original using an unsigned comparison and return - the old one */ - LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the - original using an unsigned comparison and return - the old one */ - LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the - old one */ - LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the + LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */ + LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */ + LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */ + LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */ + LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */ + LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */ + LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */ + LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the + original using a signed comparison and return + the old one */ + LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the + original using a signed comparison and return + the old one */ + LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the + original using an unsigned comparison and return + the old one */ + LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the + original using an unsigned comparison and return + the old one */ + LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the old one */ - LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the - original using an floating point comparison and - return the old one */ - LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the - original using an floating point comparison and - return the old one */ + LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the + old one */ + LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the + original using an floating point comparison and + return the old one */ + LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the + original using an floating point comparison and + return the old one */ + LLVMAtomicRMWBinOpUIncWrap, /**< Increments the value, wrapping back to zero + when incremented above input value */ + LLVMAtomicRMWBinOpUDecWrap, /**< Decrements the value, wrapping back to + the input value when decremented below zero */ + LLVMAtomicRMWBinOpUSubCond, /** #else diff --git a/src/llvm-c/Error.h b/src/llvm-c/Error.h index 00746c701..874bbcfe8 100644 --- a/src/llvm-c/Error.h +++ b/src/llvm-c/Error.h @@ -14,7 +14,7 @@ #ifndef LLVM_C_ERROR_H #define LLVM_C_ERROR_H -#include "ExternC.h" +#include "llvm-c/ExternC.h" LLVM_C_EXTERN_C_BEGIN @@ -51,6 +51,14 @@ LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err); */ void LLVMConsumeError(LLVMErrorRef Err); +/** + * Report a fatal error if Err is a failure value. + * + * This function can be used to wrap calls to fallible functions ONLY when it is + * known that the Error will always be a success value. + */ +void LLVMCantFail(LLVMErrorRef Err); + /** * Returns the given string's error message. This operation consumes the error, * and the given LLVMErrorRef value is not usable once this call returns. diff --git a/src/llvm-c/ErrorHandling.h b/src/llvm-c/ErrorHandling.h index 7f9b50a95..d9b9f2275 100644 --- a/src/llvm-c/ErrorHandling.h +++ b/src/llvm-c/ErrorHandling.h @@ -14,7 +14,7 @@ #ifndef LLVM_C_ERRORHANDLING_H #define LLVM_C_ERRORHANDLING_H -#include "ExternC.h" +#include "llvm-c/ExternC.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/ExecutionEngine.h b/src/llvm-c/ExecutionEngine.h index 8e72faefd..c5fc9bdb4 100644 --- a/src/llvm-c/ExecutionEngine.h +++ b/src/llvm-c/ExecutionEngine.h @@ -19,10 +19,10 @@ #ifndef LLVM_C_EXECUTIONENGINE_H #define LLVM_C_EXECUTIONENGINE_H -#include "ExternC.h" -#include "Target.h" -#include "TargetMachine.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Target.h" +#include "llvm-c/TargetMachine.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/IRReader.h b/src/llvm-c/IRReader.h index ec1110c7a..905b84fa5 100644 --- a/src/llvm-c/IRReader.h +++ b/src/llvm-c/IRReader.h @@ -14,8 +14,8 @@ #ifndef LLVM_C_IRREADER_H #define LLVM_C_IRREADER_H -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/LLJIT.h b/src/llvm-c/LLJIT.h index ee207e10e..a58c3b8bb 100644 --- a/src/llvm-c/LLJIT.h +++ b/src/llvm-c/LLJIT.h @@ -24,10 +24,10 @@ #ifndef LLVM_C_LLJIT_H #define LLVM_C_LLJIT_H -#include "Error.h" -#include "Orc.h" -#include "TargetMachine.h" -#include "Types.h" +#include "llvm-c/Error.h" +#include "llvm-c/Orc.h" +#include "llvm-c/TargetMachine.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/LLJITUtils.h b/src/llvm-c/LLJITUtils.h index 57ffedff8..940097432 100644 --- a/src/llvm-c/LLJITUtils.h +++ b/src/llvm-c/LLJITUtils.h @@ -26,7 +26,7 @@ #ifndef LLVM_C_LLJITUTILS_H #define LLVM_C_LLJITUTILS_H -#include "LLJIT.h" +#include "llvm-c/LLJIT.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Linker.h b/src/llvm-c/Linker.h index 463a2cff9..acff5d5e2 100644 --- a/src/llvm-c/Linker.h +++ b/src/llvm-c/Linker.h @@ -14,8 +14,8 @@ #ifndef LLVM_C_LINKER_H #define LLVM_C_LINKER_H -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Object.h b/src/llvm-c/Object.h index 1948c3c34..2f39179c1 100644 --- a/src/llvm-c/Object.h +++ b/src/llvm-c/Object.h @@ -19,9 +19,9 @@ #ifndef LLVM_C_OBJECT_H #define LLVM_C_OBJECT_H -#include "ExternC.h" -#include "Types.h" -#include "Config/llvm-config.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" +#include "llvm-c/Config/llvm-config.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Orc.h b/src/llvm-c/Orc.h index ecd110b4d..8609a8a6d 100644 --- a/src/llvm-c/Orc.h +++ b/src/llvm-c/Orc.h @@ -27,9 +27,9 @@ #ifndef LLVM_C_ORC_H #define LLVM_C_ORC_H -#include "Error.h" -#include "TargetMachine.h" -#include "Types.h" +#include "llvm-c/Error.h" +#include "llvm-c/TargetMachine.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN @@ -181,6 +181,15 @@ typedef struct { */ typedef LLVMOrcCDependenceMapPair *LLVMOrcCDependenceMapPairs; +/** + * A set of symbols that share dependencies. + */ +typedef struct { + LLVMOrcCSymbolsList Symbols; + LLVMOrcCDependenceMapPairs Dependencies; + size_t NumDependencies; +} LLVMOrcCSymbolDependenceGroup; + /** * Lookup kind. This can be used by definition generators when deciding whether * to produce a definition for a requested symbol. @@ -808,6 +817,19 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved( * that all symbols covered by this MaterializationResponsibility instance * have been emitted. * + * This function takes ownership of the symbols in the Dependencies struct. + * This allows the following pattern... + * + * LLVMOrcSymbolStringPoolEntryRef Names[] = {...}; + * LLVMOrcCDependenceMapPair Dependence = {JD, {Names, sizeof(Names)}} + * LLVMOrcMaterializationResponsibilityAddDependencies(JD, Name, &Dependence, + * 1); + * + * ... without requiring cleanup of the elements of the Names array afterwards. + * + * The client is still responsible for deleting the Dependencies.Names arrays, + * and the Dependencies array itself. + * * This method will return an error if any symbols being resolved have been * moved to the error state due to the failure of a dependency. If this * method returns an error then clients should log it and call @@ -817,7 +839,8 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved( * LLVMErrorSuccess. */ LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyEmitted( - LLVMOrcMaterializationResponsibilityRef MR); + LLVMOrcMaterializationResponsibilityRef MR, + LLVMOrcCSymbolDependenceGroup *SymbolDepGroups, size_t NumSymbolDepGroups); /** * Attempt to claim responsibility for new definitions. This method can be @@ -870,38 +893,6 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityDelegate( LLVMOrcSymbolStringPoolEntryRef *Symbols, size_t NumSymbols, LLVMOrcMaterializationResponsibilityRef *Result); -/** - * Adds dependencies to a symbol that the MaterializationResponsibility is - * responsible for. - * - * This function takes ownership of Dependencies struct. The Names - * array have been retained for this function. This allows the following - * pattern... - * - * LLVMOrcSymbolStringPoolEntryRef Names[] = {...}; - * LLVMOrcCDependenceMapPair Dependence = {JD, {Names, sizeof(Names)}} - * LLVMOrcMaterializationResponsibilityAddDependencies(JD, Name, &Dependence, - * 1); - * - * ... without requiring cleanup of the elements of the Names array afterwards. - * - * The client is still responsible for deleting the Dependencies.Names array - * itself. - */ -void LLVMOrcMaterializationResponsibilityAddDependencies( - LLVMOrcMaterializationResponsibilityRef MR, - LLVMOrcSymbolStringPoolEntryRef Name, - LLVMOrcCDependenceMapPairs Dependencies, size_t NumPairs); - -/** - * Adds dependencies to all symbols that the MaterializationResponsibility is - * responsible for. See LLVMOrcMaterializationResponsibilityAddDependencies for - * notes about memory responsibility. - */ -void LLVMOrcMaterializationResponsibilityAddDependenciesForAll( - LLVMOrcMaterializationResponsibilityRef MR, - LLVMOrcCDependenceMapPairs Dependencies, size_t NumPairs); - /** * Create a "bare" JITDylib. * diff --git a/src/llvm-c/OrcEE.h b/src/llvm-c/OrcEE.h index aef24c7aa..d451187aa 100644 --- a/src/llvm-c/OrcEE.h +++ b/src/llvm-c/OrcEE.h @@ -24,11 +24,11 @@ #ifndef LLVM_C_ORCEE_H #define LLVM_C_ORCEE_H -#include "Error.h" -#include "ExecutionEngine.h" -#include "Orc.h" -#include "TargetMachine.h" -#include "Types.h" +#include "llvm-c/Error.h" +#include "llvm-c/ExecutionEngine.h" +#include "llvm-c/Orc.h" +#include "llvm-c/TargetMachine.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Remarks.h b/src/llvm-c/Remarks.h index 548a4041a..ffe647a65 100644 --- a/src/llvm-c/Remarks.h +++ b/src/llvm-c/Remarks.h @@ -15,8 +15,8 @@ #ifndef LLVM_C_REMARKS_H #define LLVM_C_REMARKS_H -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" #ifdef __cplusplus #include #else diff --git a/src/llvm-c/Support.h b/src/llvm-c/Support.h index 31a75354c..17657861b 100644 --- a/src/llvm-c/Support.h +++ b/src/llvm-c/Support.h @@ -14,9 +14,9 @@ #ifndef LLVM_C_SUPPORT_H #define LLVM_C_SUPPORT_H -#include "DataTypes.h" -#include "ExternC.h" -#include "Types.h" +#include "llvm-c/DataTypes.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Target.h b/src/llvm-c/Target.h index 4d03741c4..54367a41b 100644 --- a/src/llvm-c/Target.h +++ b/src/llvm-c/Target.h @@ -19,9 +19,9 @@ #ifndef LLVM_C_TARGET_H #define LLVM_C_TARGET_H -#include "ExternC.h" -#include "Types.h" -#include "Config/llvm-config.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" +#include "llvm-c/Config/llvm-config.h" LLVM_C_EXTERN_C_BEGIN @@ -40,34 +40,34 @@ typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef; /* Declare all of the target-initialization functions that are available. */ #define LLVM_TARGET(TargetName) \ void LLVMInitialize##TargetName##TargetInfo(void); -#include "Config/Targets.def" +#include "llvm-c/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void); -#include "Config/Targets.def" +#include "llvm-c/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ #define LLVM_TARGET(TargetName) \ void LLVMInitialize##TargetName##TargetMC(void); -#include "Config/Targets.def" +#include "llvm-c/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ /* Declare all of the available assembly printer initialization functions. */ #define LLVM_ASM_PRINTER(TargetName) \ void LLVMInitialize##TargetName##AsmPrinter(void); -#include "Config/AsmPrinters.def" +#include "llvm-c/Config/AsmPrinters.def" #undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */ /* Declare all of the available assembly parser initialization functions. */ #define LLVM_ASM_PARSER(TargetName) \ void LLVMInitialize##TargetName##AsmParser(void); -#include "Config/AsmParsers.def" +#include "llvm-c/Config/AsmParsers.def" #undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */ /* Declare all of the available disassembler initialization functions. */ #define LLVM_DISASSEMBLER(TargetName) \ void LLVMInitialize##TargetName##Disassembler(void); -#include "Config/Disassemblers.def" +#include "llvm-c/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ /** LLVMInitializeAllTargetInfos - The main program should call this function if @@ -75,7 +75,7 @@ typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef; support. */ static inline void LLVMInitializeAllTargetInfos(void) { #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo(); -#include "Config/Targets.def" +#include "llvm-c/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ } @@ -84,7 +84,7 @@ static inline void LLVMInitializeAllTargetInfos(void) { support. */ static inline void LLVMInitializeAllTargets(void) { #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target(); -#include "Config/Targets.def" +#include "llvm-c/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ } @@ -93,7 +93,7 @@ static inline void LLVMInitializeAllTargets(void) { support. */ static inline void LLVMInitializeAllTargetMCs(void) { #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC(); -#include "Config/Targets.def" +#include "llvm-c/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ } @@ -102,7 +102,7 @@ static inline void LLVMInitializeAllTargetMCs(void) { available via the TargetRegistry. */ static inline void LLVMInitializeAllAsmPrinters(void) { #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter(); -#include "Config/AsmPrinters.def" +#include "llvm-c/Config/AsmPrinters.def" #undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */ } @@ -111,7 +111,7 @@ static inline void LLVMInitializeAllAsmPrinters(void) { available via the TargetRegistry. */ static inline void LLVMInitializeAllAsmParsers(void) { #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser(); -#include "Config/AsmParsers.def" +#include "llvm-c/Config/AsmParsers.def" #undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */ } @@ -121,7 +121,7 @@ static inline void LLVMInitializeAllAsmParsers(void) { static inline void LLVMInitializeAllDisassemblers(void) { #define LLVM_DISASSEMBLER(TargetName) \ LLVMInitialize##TargetName##Disassembler(); -#include "Config/Disassemblers.def" +#include "llvm-c/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ } @@ -244,7 +244,7 @@ LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD); LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD, unsigned AS); -/** Computes the size of a type in bytes for a target. +/** Computes the size of a type in bits for a target. See the method llvm::DataLayout::getTypeSizeInBits. */ unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty); diff --git a/src/llvm-c/TargetMachine.h b/src/llvm-c/TargetMachine.h index aa628e216..cbe891380 100644 --- a/src/llvm-c/TargetMachine.h +++ b/src/llvm-c/TargetMachine.h @@ -19,9 +19,9 @@ #ifndef LLVM_C_TARGETMACHINE_H #define LLVM_C_TARGETMACHINE_H -#include "ExternC.h" -#include "Target.h" -#include "Types.h" +#include "llvm-c/ExternC.h" +#include "llvm-c/Target.h" +#include "llvm-c/Types.h" LLVM_C_EXTERN_C_BEGIN diff --git a/src/llvm-c/Transforms/PassBuilder.h b/src/llvm-c/Transforms/PassBuilder.h index 8ad2a9982..d297b57ca 100644 --- a/src/llvm-c/Transforms/PassBuilder.h +++ b/src/llvm-c/Transforms/PassBuilder.h @@ -14,9 +14,9 @@ #ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H #define LLVM_C_TRANSFORMS_PASSBUILDER_H -#include "../Error.h" -#include "../TargetMachine.h" -#include "../Types.h" +#include "llvm-c/Error.h" +#include "llvm-c/TargetMachine.h" +#include "llvm-c/Types.h" /** * @defgroup LLVMCCoreNewPM New Pass Manager @@ -50,6 +50,16 @@ LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes, LLVMTargetMachineRef TM, LLVMPassBuilderOptionsRef Options); +/** + * Construct and run a set of passes over a function. + * + * This function behaves the same as LLVMRunPasses, but operates on a single + * function instead of an entire module. + */ +LLVMErrorRef LLVMRunPassesOnFunction(LLVMValueRef F, const char *Passes, + LLVMTargetMachineRef TM, + LLVMPassBuilderOptionsRef Options); + /** * Create a new set of options for a PassBuilder * @@ -72,6 +82,14 @@ void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, LLVMBool DebugLogging); +/** + * Specify a custom alias analysis pipeline for the PassBuilder to be used + * instead of the default one. The string argument is not copied; the caller + * is responsible for ensuring it outlives the PassBuilderOptions instance. + */ +void LLVMPassBuilderOptionsSetAAPipeline(LLVMPassBuilderOptionsRef Options, + const char *AAPipeline); + void LLVMPassBuilderOptionsSetLoopInterleaving( LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving); diff --git a/src/llvm-c/Types.h b/src/llvm-c/Types.h index 77aa7c9b4..4681500ef 100644 --- a/src/llvm-c/Types.h +++ b/src/llvm-c/Types.h @@ -14,8 +14,8 @@ #ifndef LLVM_C_TYPES_H #define LLVM_C_TYPES_H -#include "DataTypes.h" -#include "ExternC.h" +#include "llvm-c/DataTypes.h" +#include "llvm-c/ExternC.h" LLVM_C_EXTERN_C_BEGIN @@ -169,6 +169,11 @@ typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef; */ typedef struct LLVMOpaqueBinary *LLVMBinaryRef; +/** + * @see llvm::DbgRecord + */ +typedef struct LLVMOpaqueDbgRecord *LLVMDbgRecordRef; + /** * @} */ diff --git a/src/llvm-c/lto.h b/src/llvm-c/lto.h index 89f76c695..5ceb02224 100644 --- a/src/llvm-c/lto.h +++ b/src/llvm-c/lto.h @@ -16,7 +16,7 @@ #ifndef LLVM_C_LTO_H #define LLVM_C_LTO_H -#include "ExternC.h" +#include "llvm-c/ExternC.h" #ifdef __cplusplus #include diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 0b2bb7956..6d9f6d958 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -256,8 +256,10 @@ gb_internal i64 lb_sizeof(LLVMTypeRef type) { } break; +#if LLVM_VERSION_MAJOR < 20 case LLVMX86_MMXTypeKind: return 8; +#endif case LLVMVectorTypeKind: { LLVMTypeRef elem = OdinLLVMGetVectorElementType(type); @@ -310,8 +312,10 @@ gb_internal i64 lb_alignof(LLVMTypeRef type) { case LLVMArrayTypeKind: return lb_alignof(OdinLLVMGetArrayElementType(type)); +#if LLVM_VERSION_MAJOR < 20 case LLVMX86_MMXTypeKind: return 8; +#endif case LLVMVectorTypeKind: { // TODO(bill): This appears to be correct but LLVM isn't necessarily "great" with regards to documentation diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index fefab6e67..c3afac115 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -1591,797 +1591,7 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) { LLVMPassBuilderOptionsRef pb_options = LLVMCreatePassBuilderOptions(); defer (LLVMDisposePassBuilderOptions(pb_options)); - switch (build_context.optimization_level) { - case -1: - array_add(&passes, "function(annotation-remarks)"); - break; - case 0: - array_add(&passes, "always-inline"); - array_add(&passes, "function(annotation-remarks)"); - break; - case 1: -// default -// Passes removed: coro, openmp, sroa -#if LLVM_VERSION_MAJOR == 17 - array_add(&passes, u8R"( -annotation2metadata, -forceattrs, -inferattrs, -function( - lower-expect, - simplifycfg, - early-cse<> -), -ipsccp, -called-value-propagation, -globalopt, -function( - mem2reg, - instcombine, - simplifycfg -), -require, -function( - invalidate -), -require, -cgscc( - devirt<4>( - inline, - inline, - function-attrs, - function( - early-cse, - speculative-execution, - jump-threading, - correlated-propagation, - simplifycfg, - instcombine, - aggressive-instcombine, - constraint-elimination, - tailcallelim, - simplifycfg, - reassociate, - loop-mssa( - loop-instsimplify, - loop-simplifycfg, - licm, - loop-rotate, - licm, - simple-loop-unswitch - ), - simplifycfg, - instcombine, - loop( - loop-idiom, - indvars, - loop-deletion, - loop-unroll-full - ), - vector-combine, - mldst-motion, - gvn<>, - sccp, - bdce, - instcombine, - jump-threading, - correlated-propagation, - adce, - memcpyopt, - dse, - move-auto-init, - loop-mssa( - licm - ), - simplifycfg, - instcombine - ), - function-attrs, - function( - require - ) - ) -), -deadargelim, -globalopt, -globaldce, -elim-avail-extern, -rpo-function-attrs, -recompute-globalsaa, -function( - float2int, - lower-constant-intrinsics, - loop( - loop-rotate, - loop-deletion - ), - loop-distribute, - inject-tli-mappings, - loop-vectorize, - loop-load-elim, - instcombine, - simplifycfg, - slp-vectorizer, - vector-combine, - instcombine, - loop-unroll, - transform-warning, - instcombine, - loop-mssa( - licm - ), - alignment-from-assumptions, - loop-sink, - instsimplify, - div-rem-pairs, - tailcallelim, - simplifycfg -), -globaldce, -constmerge, -cg-profile, -rel-lookup-table-converter, -function( - annotation-remarks -), -verify -)"); -#else - array_add(&passes, u8R"( -annotation2metadata, -forceattrs, -inferattrs, -function( - lower-expect, - simplifycfg, - sroa, - early-cse<> -), -ipsccp, -called-value-propagation, -globalopt, -function( - mem2reg, - instcombine, - simplifycfg -), -always-inline, -require, -function( - invalidate -), -require, -cgscc( - devirt<4>( - inline, - function-attrs, - function( - sroa, - early-cse, - speculative-execution, - jump-threading, - correlated-propagation, - simplifycfg, - instcombine, - aggressive-instcombine, - tailcallelim, - simplifycfg, - reassociate, - constraint-elimination, - loop-mssa( - loop-instsimplify, - loop-simplifycfg, - licm, - loop-rotate, - licm, - simple-loop-unswitch - ), - simplifycfg, - instcombine, - loop( - loop-idiom, - indvars, - loop-deletion, - loop-unroll-full - ), - sroa, - vector-combine, - mldst-motion, - gvn<>, - sccp, - bdce, - instcombine, - jump-threading, - correlated-propagation, - adce, - memcpyopt, - dse, - move-auto-init, - loop-mssa( - licm - ), - simplifycfg, - instcombine - ), - function-attrs, - function( - require - ) - ) -), -deadargelim, -globalopt, -globaldce, -elim-avail-extern, -rpo-function-attrs, -recompute-globalsaa, -function( - float2int, - lower-constant-intrinsics, - loop( - loop-rotate, - loop-deletion - ), - loop-distribute, - inject-tli-mappings, - loop-vectorize, - infer-alignment, - loop-load-elim, - instcombine, - simplifycfg, - slp-vectorizer, - vector-combine, - instcombine, - loop-unroll, - transform-warning, - sroa, - infer-alignment, - instcombine, - loop-mssa( - licm - ), - alignment-from-assumptions, - loop-sink, - instsimplify, - div-rem-pairs, - tailcallelim, - simplifycfg -), -globaldce, -constmerge, -cg-profile, -rel-lookup-table-converter, -function( - annotation-remarks -), -verify -)"); -#endif - break; -// default -// Passes removed: coro, openmp, sroa - case 2: -#if LLVM_VERSION_MAJOR == 17 - array_add(&passes, u8R"( -annotation2metadata, -forceattrs, -inferattrs, -function( - lower-expect, - simplifycfg, - early-cse<> -), -ipsccp, -called-value-propagation, -globalopt, -function( - mem2reg, - instcombine, - simplifycfg -), -require, -function( - invalidate -), -require, -cgscc( - devirt<4>( - inline, - inline, - function-attrs, - function( - early-cse, - speculative-execution, - jump-threading, - correlated-propagation, - simplifycfg, - instcombine, - aggressive-instcombine, - constraint-elimination, - libcalls-shrinkwrap, - tailcallelim, - simplifycfg, - reassociate, - loop-mssa( - loop-instsimplify, - loop-simplifycfg, - licm, - loop-rotate, - licm, - simple-loop-unswitch - ), - simplifycfg, - instcombine, - loop( - loop-idiom, - indvars, - loop-deletion, - loop-unroll-full - ), - vector-combine, - mldst-motion, - gvn<>, - sccp, - bdce, - instcombine, - jump-threading, - correlated-propagation, - adce, - memcpyopt, - dse, - move-auto-init, - loop-mssa( - licm - ), - simplifycfg, - instcombine - ), - function-attrs, - function( - require - ) - ) -), -deadargelim, -globalopt, -globaldce, -elim-avail-extern, -rpo-function-attrs, -recompute-globalsaa, -function( - float2int, - lower-constant-intrinsics, - loop( - loop-rotate, - loop-deletion - ), - loop-distribute, - inject-tli-mappings, - loop-vectorize, - loop-load-elim, - instcombine, - simplifycfg, - slp-vectorizer, - vector-combine, - instcombine, - loop-unroll, - transform-warning, - instcombine, - loop-mssa( - licm - ), - alignment-from-assumptions, - loop-sink, - instsimplify, - div-rem-pairs, - tailcallelim, - simplifycfg -), -globaldce, -constmerge, -cg-profile, -rel-lookup-table-converter, -function( - annotation-remarks -), -verify -)"); -#else - array_add(&passes, u8R"( -annotation2metadata, -forceattrs, -inferattrs, -function( - lower-expect, - simplifycfg, - sroa, - early-cse<> -), -ipsccp, -called-value-propagation, -globalopt, -function( - mem2reg, - instcombine, - simplifycfg -), -always-inline, -require, -function( - invalidate -), -require, -cgscc( - devirt<4>( - inline, - function-attrs, - function( - sroa, - early-cse, - speculative-execution, - jump-threading, - correlated-propagation, - simplifycfg, - instcombine, - aggressive-instcombine, - libcalls-shrinkwrap, - tailcallelim, - simplifycfg, - reassociate, - constraint-elimination, - loop-mssa( - loop-instsimplify, - loop-simplifycfg, - licm, - loop-rotate, - licm, - simple-loop-unswitch - ), - simplifycfg, - instcombine, - loop( - loop-idiom, - indvars, - loop-deletion, - loop-unroll-full - ), - sroa, - vector-combine, - mldst-motion, - gvn<>, - sccp, - bdce, - instcombine, - jump-threading, - correlated-propagation, - adce, - memcpyopt, - dse, - move-auto-init, - loop-mssa( - licm - ), - simplifycfg, - instcombine - ), - function-attrs, - function( - require - ) - ) -), -deadargelim, -globalopt, -globaldce, -elim-avail-extern, -rpo-function-attrs, -recompute-globalsaa, -function( - float2int, - lower-constant-intrinsics, - loop( - loop-rotate, - loop-deletion - ), - loop-distribute, - inject-tli-mappings, - loop-vectorize, - infer-alignment, - loop-load-elim, - instcombine, - simplifycfg, - slp-vectorizer, - vector-combine, - instcombine, - loop-unroll, - transform-warning, - sroa, - infer-alignment, - instcombine, - loop-mssa( - licm - ), - alignment-from-assumptions, - loop-sink, - instsimplify, - div-rem-pairs, - tailcallelim, - simplifycfg -), -globaldce, -constmerge, -cg-profile, -rel-lookup-table-converter, -function( - annotation-remarks -), -verify -)"); -#endif - break; - - case 3: -// default -// Passes removed: coro, openmp, sroa -#if LLVM_VERSION_MAJOR == 17 - array_add(&passes, u8R"( -annotation2metadata, -forceattrs, -inferattrs, -function( - lower-expect, - simplifycfg, - early-cse<>, - callsite-splitting -), -ipsccp, -called-value-propagation, -globalopt, -function( - mem2reg, - instcombine, - simplifycfg -), -require, -function( - invalidate -), -require, -cgscc( - devirt<4>( - inline, - inline, - function-attrs, - argpromotion, - function( - early-cse, - speculative-execution, - jump-threading, - correlated-propagation, - simplifycfg, - instcombine, - aggressive-instcombine, - constraint-elimination, - libcalls-shrinkwrap, - tailcallelim, - simplifycfg, - reassociate, - loop-mssa( - loop-instsimplify, - loop-simplifycfg, - licm, - loop-rotate, - licm, - simple-loop-unswitch - ), - simplifycfg, - instcombine, - loop( - loop-idiom, - indvars, - loop-deletion, - loop-unroll-full - ), - vector-combine, - mldst-motion, - gvn<>, - sccp, - bdce, - instcombine, - jump-threading, - correlated-propagation, - adce, - memcpyopt, - dse, - move-auto-init, - loop-mssa( - licm - ), - simplifycfg, - instcombine - ), - function-attrs, - function( - require - ) - ) -), -deadargelim, -globalopt, -globaldce, -elim-avail-extern, -rpo-function-attrs, -recompute-globalsaa, -function( - float2int, - lower-constant-intrinsics, - chr, - loop( - loop-rotate, - loop-deletion - ), - loop-distribute, - inject-tli-mappings, - loop-vectorize, - loop-load-elim, - instcombine, - simplifycfg, - slp-vectorizer, - vector-combine, - instcombine, - loop-unroll, - transform-warning, - instcombine, - loop-mssa( - licm - ), - alignment-from-assumptions, - loop-sink, - instsimplify, - div-rem-pairs, - tailcallelim, - simplifycfg -), -globaldce, -constmerge, -cg-profile, -rel-lookup-table-converter, -function( - annotation-remarks -), -verify -)"); -#else - array_add(&passes, u8R"( -annotation2metadata, -forceattrs, -inferattrs, -function( - lower-expect, - simplifycfg, - sroa, - early-cse<>, - callsite-splitting -), -ipsccp, -called-value-propagation, -globalopt, -function( - mem2reg, - instcombine, - simplifycfg -), -always-inline, -require, -function(invalidate), -require, -cgscc( - devirt<4>( - inline, - function-attrs, - argpromotion, - function( - sroa, - early-cse, - speculative-execution, - jump-threading, - correlated-propagation, - simplifycfg, - instcombine, - aggressive-instcombine, - libcalls-shrinkwrap, - tailcallelim, - simplifycfg, - reassociate, - constraint-elimination, - loop-mssa( - loop-instsimplify, - loop-simplifycfg, - licm, - loop-rotate, - licm, - simple-loop-unswitch - ), - simplifycfg, - instcombine, - loop( - loop-idiom, - indvars, - loop-deletion, - loop-unroll-full - ), - sroa, - vector-combine, - mldst-motion, - gvn<>, - sccp, - bdce, - instcombine, - jump-threading, - correlated-propagation, - adce, - memcpyopt, - dse, - move-auto-init, - loop-mssa(licm), - simplifycfg, - instcombine - ), - function-attrs, - function( - require - ) - ) -), -deadargelim, -globalopt, -globaldce, -elim-avail-extern, -rpo-function-attrs, -recompute-globalsaa, -function( - float2int, - lower-constant-intrinsics, - chr, - loop( - loop-rotate, - loop-deletion - ), - loop-distribute, - inject-tli-mappings, - loop-vectorize, - infer-alignment, - loop-load-elim, - instcombine, - simplifycfg, - slp-vectorizer, - vector-combine, - instcombine, - loop-unroll, - transform-warning, - sroa, - infer-alignment, - instcombine, - loop-mssa(licm), - alignment-from-assumptions, - loop-sink, - instsimplify, - div-rem-pairs, - tailcallelim, - simplifycfg -), -globaldce, -constmerge, -cg-profile, -rel-lookup-table-converter, -function( - annotation-remarks -), -verify -)"); -#endif - break; - } + #include "llvm_backend_passes.cpp" // asan - Linux, Darwin, Windows // msan - linux @@ -2958,13 +2168,16 @@ gb_internal bool lb_generate_code(lbGenerator *gen) { LLVMInitializeWebAssemblyAsmParser(); LLVMInitializeWebAssemblyDisassembler(); break; + case TargetArch_riscv64: + LLVMInitializeRISCVTargetInfo(); + LLVMInitializeRISCVTarget(); + LLVMInitializeRISCVTargetMC(); + LLVMInitializeRISCVAsmPrinter(); + LLVMInitializeRISCVAsmParser(); + LLVMInitializeRISCVDisassembler(); + break; default: - LLVMInitializeAllTargetInfos(); - LLVMInitializeAllTargets(); - LLVMInitializeAllTargetMCs(); - LLVMInitializeAllAsmPrinters(); - LLVMInitializeAllAsmParsers(); - LLVMInitializeAllDisassemblers(); + GB_PANIC("Unimplemented LLVM target initialization"); break; } diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index 067004bc1..926daaae4 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -1085,7 +1085,12 @@ gb_internal void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, T LLVMMetadataRef llvm_debug_loc = lb_debug_location_from_token_pos(p, token.pos); LLVMMetadataRef llvm_expr = LLVMDIBuilderCreateExpression(m->debug_builder, nullptr, 0); lb_set_llvm_metadata(m, ptr, llvm_expr); + +#if LLVM_VERSION_MAJOR <= 18 LLVMDIBuilderInsertDeclareAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block); +#else + LLVMDIBuilderInsertDbgValueRecordAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block); +#endif } gb_internal void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block) { diff --git a/src/llvm_backend_passes.cpp b/src/llvm_backend_passes.cpp new file mode 100644 index 000000000..bea95ce8e --- /dev/null +++ b/src/llvm_backend_passes.cpp @@ -0,0 +1,1195 @@ + switch (build_context.optimization_level) { + case -1: + array_add(&passes, "function(annotation-remarks)"); + break; + case 0: + array_add(&passes, "always-inline"); + array_add(&passes, "function(annotation-remarks)"); + break; + case 1: +// default +// Passes removed: coro, openmp, sroa +#if LLVM_VERSION_MAJOR == 17 + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + lower-expect, + simplifycfg, + early-cse<> +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + inline, + function-attrs, + function( + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + constraint-elimination, + tailcallelim, + simplifycfg, + reassociate, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + loop-deletion, + loop-unroll-full + ), + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); +#elif LLVM_VERSION_MAJOR < 20 + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + lower-expect, + simplifycfg, + sroa, + early-cse<> +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +always-inline, +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + function-attrs, + function( + sroa, + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + tailcallelim, + simplifycfg, + reassociate, + constraint-elimination, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + loop-deletion, + loop-unroll-full + ), + sroa, + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + infer-alignment, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + sroa, + infer-alignment, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); +#else + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + ee-instrument<>, + lower-expect, + simplifycfg, + sroa, + early-cse<> +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +always-inline, +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + function-attrs, + function( + sroa, + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + tailcallelim, + simplifycfg, + reassociate, + constraint-elimination, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + extra-simple-loop-unswitch-passes, + loop-deletion,loop-unroll-full + ), + sroa, + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + infer-alignment, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + sroa, + infer-alignment, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); + +#endif + break; +// default +// Passes removed: coro, openmp, sroa + case 2: +#if LLVM_VERSION_MAJOR == 17 + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + lower-expect, + simplifycfg, + early-cse<> +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + inline, + function-attrs, + function( + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + constraint-elimination, + libcalls-shrinkwrap, + tailcallelim, + simplifycfg, + reassociate, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + loop-deletion, + loop-unroll-full + ), + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); +#elif LLVM_VERSION_MAJOR < 20 + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + lower-expect, + simplifycfg, + sroa, + early-cse<> +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +always-inline, +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + function-attrs, + function( + sroa, + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + libcalls-shrinkwrap, + tailcallelim, + simplifycfg, + reassociate, + constraint-elimination, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + loop-deletion, + loop-unroll-full + ), + sroa, + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + infer-alignment, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + sroa, + infer-alignment, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); +#else + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + ee-instrument<>, + lower-expect, + simplifycfg, + sroa, + early-cse<> +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +always-inline, +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + function-attrs, + function( + sroa, + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + libcalls-shrinkwrap, + tailcallelim, + simplifycfg, + reassociate, + constraint-elimination, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + extra-simple-loop-unswitch-passes, + loop-deletion, + loop-unroll-full + ), + sroa, + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + infer-alignment, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + sroa, + infer-alignment, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); +#endif + break; + + case 3: +// default +// Passes removed: coro, openmp, sroa +#if LLVM_VERSION_MAJOR == 17 + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + lower-expect, + simplifycfg, + early-cse<>, + callsite-splitting +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + inline, + function-attrs, + argpromotion, + function( + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + constraint-elimination, + libcalls-shrinkwrap, + tailcallelim, + simplifycfg, + reassociate, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + loop-deletion, + loop-unroll-full + ), + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + chr, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); + +#elif LLVM_VERSION_MAJOR < 20 + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + lower-expect, + simplifycfg, + sroa, + early-cse<>, + callsite-splitting +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +always-inline, +require, +function(invalidate), +require, +cgscc( + devirt<4>( + inline, + function-attrs, + argpromotion, + function( + sroa, + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + libcalls-shrinkwrap, + tailcallelim, + simplifycfg, + reassociate, + constraint-elimination, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + loop-deletion, + loop-unroll-full + ), + sroa, + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa(licm), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + chr, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + infer-alignment, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + sroa, + infer-alignment, + instcombine, + loop-mssa(licm), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify +)"); +#else + array_add(&passes, u8R"( +annotation2metadata, +forceattrs, +inferattrs, +function( + ee-instrument<>, + lower-expect, + simplifycfg, + sroa, + early-cse<>, + callsite-splitting +), +ipsccp, +called-value-propagation, +globalopt, +function( + mem2reg, + instcombine, + simplifycfg +), +always-inline, +require, +function( + invalidate +), +require, +cgscc( + devirt<4>( + inline, + function-attrs, + argpromotion, + function( + sroa, + early-cse, + speculative-execution, + jump-threading, + correlated-propagation, + simplifycfg, + instcombine, + aggressive-instcombine, + libcalls-shrinkwrap, + tailcallelim, + simplifycfg, + reassociate, + constraint-elimination, + loop-mssa( + loop-instsimplify, + loop-simplifycfg, + licm, + loop-rotate, + licm, + simple-loop-unswitch + ), + simplifycfg, + instcombine, + loop( + loop-idiom, + indvars, + extra-simple-loop-unswitch-passes, + loop-deletion, + loop-unroll-full + ), + sroa, + vector-combine, + mldst-motion, + gvn<>, + sccp, + bdce, + instcombine, + jump-threading, + correlated-propagation, + adce, + memcpyopt, + dse, + move-auto-init, + loop-mssa( + licm + ), + simplifycfg, + instcombine + ), + function-attrs, + function( + require + ) + ) +), +deadargelim, +globalopt, +globaldce, +elim-avail-extern, +rpo-function-attrs, +recompute-globalsaa, +function( + float2int, + lower-constant-intrinsics, + chr, + loop( + loop-rotate, + loop-deletion + ), + loop-distribute, + inject-tli-mappings, + loop-vectorize, + infer-alignment, + loop-load-elim, + instcombine, + simplifycfg, + slp-vectorizer, + vector-combine, + instcombine, + loop-unroll, + transform-warning, + sroa, + infer-alignment, + instcombine, + loop-mssa( + licm + ), + alignment-from-assumptions, + loop-sink, + instsimplify, + div-rem-pairs, + tailcallelim, + simplifycfg +), +globaldce, +constmerge, +cg-profile, +rel-lookup-table-converter, +function( + annotation-remarks +), +verify + +)"); + +#endif + break; + } \ No newline at end of file