2
0
Эх сурвалжийг харах

Merge pull request #4945 from odin-lang/llvm-20

Update to LLVM 20.1.0
gingerBill 5 сар өмнө
parent
commit
067442ee32

+ 7 - 7
.github/workflows/ci.yml

@@ -52,7 +52,7 @@ jobs:
         usesh: true
         usesh: true
         copyback: false
         copyback: false
         prepare: |
         prepare: |
-          pkg install -y gmake git bash python3 libxml2 llvm17
+          pkg install -y gmake git bash python3 libxml2 llvm18
         run: |
         run: |
           # `set -e` is needed for test failures to register. https://github.com/vmactions/freebsd-vm/issues/72
           # `set -e` is needed for test failures to register. https://github.com/vmactions/freebsd-vm/issues/72
           set -e -x
           set -e -x
@@ -87,20 +87,20 @@ jobs:
         run: |
         run: |
           wget https://apt.llvm.org/llvm.sh
           wget https://apt.llvm.org/llvm.sh
           chmod +x 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)
       - name: Download LLVM (MacOS Intel)
         if: matrix.os == 'macos-13'
         if: matrix.os == 'macos-13'
         run: |
         run: |
-          brew install llvm@17 [email protected]
-          echo "/usr/local/opt/llvm@17/bin" >> $GITHUB_PATH
+          brew install llvm@18 [email protected]
+          echo "/usr/local/opt/llvm@18/bin" >> $GITHUB_PATH
 
 
       - name: Download LLVM (MacOS ARM)
       - name: Download LLVM (MacOS ARM)
         if: matrix.os == 'macos-14'
         if: matrix.os == 'macos-14'
         run: |
         run: |
-          brew install llvm@17 wasmtime [email protected]
-          echo "/opt/homebrew/opt/llvm@17/bin" >> $GITHUB_PATH
+          brew install llvm@18 wasmtime [email protected]
+          echo "/opt/homebrew/opt/llvm@18/bin" >> $GITHUB_PATH
 
 
       - name: Build Odin
       - name: Build Odin
         run: ./build_odin.sh release
         run: ./build_odin.sh release

+ 2 - 2
.github/workflows/nightly.yml

@@ -53,8 +53,8 @@ jobs:
       - name: (Linux) Download LLVM
       - name: (Linux) Download LLVM
         run: |
         run: |
           apk add --no-cache \
           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
           make
         shell: alpine.sh --root {0}
         shell: alpine.sh --root {0}
       - name: build odin
       - name: build odin

BIN
LLVM-C.dll


BIN
bin/lld-link.exe


BIN
bin/llvm/windows/LLVM-C.lib


BIN
bin/llvm/windows/clang_rt.asan-x86_64.lib


BIN
bin/wasm-ld.exe


+ 2 - 2
src/llvm-c/Analysis.h

@@ -19,8 +19,8 @@
 #ifndef LLVM_C_ANALYSIS_H
 #ifndef LLVM_C_ANALYSIS_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 2 - 2
src/llvm-c/BitReader.h

@@ -19,8 +19,8 @@
 #ifndef LLVM_C_BITREADER_H
 #ifndef LLVM_C_BITREADER_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 2 - 2
src/llvm-c/BitWriter.h

@@ -19,8 +19,8 @@
 #ifndef LLVM_C_BITWRITER_H
 #ifndef LLVM_C_BITWRITER_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 2 - 2
src/llvm-c/Comdat.h

@@ -14,8 +14,8 @@
 #ifndef LLVM_C_COMDAT_H
 #ifndef LLVM_C_COMDAT_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 3 - 3
src/llvm-c/Config/llvm-config.h

@@ -142,16 +142,16 @@
 #define LLVM_USE_PERF 0
 #define LLVM_USE_PERF 0
 
 
 /* Major version of the LLVM API */
 /* Major version of the LLVM API */
-#define LLVM_VERSION_MAJOR 18
+#define LLVM_VERSION_MAJOR 20
 
 
 /* Minor version of the LLVM API */
 /* Minor version of the LLVM API */
 #define LLVM_VERSION_MINOR 1
 #define LLVM_VERSION_MINOR 1
 
 
 /* Patch version of the LLVM API */
 /* Patch version of the LLVM API */
-#define LLVM_VERSION_PATCH 8
+#define LLVM_VERSION_PATCH 0
 
 
 /* LLVM version string */
 /* 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(),
 /* Whether LLVM records statistics for use with GetStatistics(),
  * PrintStatistics() or PrintStatisticsJSON()
  * PrintStatistics() or PrintStatisticsJSON()

+ 452 - 84
src/llvm-c/Core.h

@@ -15,11 +15,11 @@
 #ifndef LLVM_C_CORE_H
 #ifndef LLVM_C_CORE_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 
@@ -146,27 +146,27 @@ typedef enum {
 } LLVMOpcode;
 } LLVMOpcode;
 
 
 typedef enum {
 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;
 } LLVMTypeKind;
 
 
 typedef enum {
 typedef enum {
@@ -286,6 +286,7 @@ typedef enum {
   LLVMInstructionValueKind,
   LLVMInstructionValueKind,
   LLVMPoisonValueValueKind,
   LLVMPoisonValueValueKind,
   LLVMConstantTargetNoneValueKind,
   LLVMConstantTargetNoneValueKind,
+  LLVMConstantPtrAuthValueKind,
 } LLVMValueKind;
 } LLVMValueKind;
 
 
 typedef enum {
 typedef enum {
@@ -361,35 +362,42 @@ typedef enum {
 } LLVMAtomicOrdering;
 } LLVMAtomicOrdering;
 
 
 typedef enum {
 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 */
                             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, /**<Subtracts the value only if no unsigned
+                                 overflow */
+  LLVMAtomicRMWBinOpUSubSat,  /**<Subtracts the value, clamping to zero */
 } LLVMAtomicRMWBinOp;
 } LLVMAtomicRMWBinOp;
 
 
 typedef enum {
 typedef enum {
@@ -467,6 +475,8 @@ enum {
   LLVMAttributeFunctionIndex = -1,
   LLVMAttributeFunctionIndex = -1,
 };
 };
 
 
+typedef unsigned LLVMAttributeIndex;
+
 /**
 /**
  * Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
  * Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
  *
  *
@@ -481,8 +491,6 @@ typedef enum {
   LLVMTailCallKindNoTail = 3,
   LLVMTailCallKindNoTail = 3,
 } LLVMTailCallKind;
 } LLVMTailCallKind;
 
 
-typedef unsigned LLVMAttributeIndex;
-
 enum {
 enum {
   LLVMFastMathAllowReassoc = (1 << 0),
   LLVMFastMathAllowReassoc = (1 << 0),
   LLVMFastMathNoNaNs = (1 << 1),
   LLVMFastMathNoNaNs = (1 << 1),
@@ -506,6 +514,20 @@ enum {
  */
  */
 typedef unsigned LLVMFastMathFlags;
 typedef unsigned LLVMFastMathFlags;
 
 
+enum {
+  LLVMGEPFlagInBounds = (1 << 0),
+  LLVMGEPFlagNUSW = (1 << 1),
+  LLVMGEPFlagNUW = (1 << 2),
+};
+
+/**
+ * Flags that constrain the allowed wrap semantics of a getelementptr
+ * instruction.
+ *
+ * See https://llvm.org/docs/LangRef.html#getelementptr-instruction
+ */
+typedef unsigned LLVMGEPNoWrapFlags;
+
 /**
 /**
  * @}
  * @}
  */
  */
@@ -627,6 +649,11 @@ unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
                                   unsigned SLen);
                                   unsigned SLen);
 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
 
 
+/**
+ * Maps a synchronization scope name to a ID unique within this context.
+ */
+unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen);
+
 /**
 /**
  * Return an unique id given the name of a enum attribute,
  * Return an unique id given the name of a enum attribute,
  * or 0 if no attribute by that name exists.
  * or 0 if no attribute by that name exists.
@@ -669,6 +696,18 @@ LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
  */
  */
 LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
 LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
 
 
+/**
+ * Create a ConstantRange attribute.
+ *
+ * LowerWords and UpperWords need to be NumBits divided by 64 rounded up
+ * elements long.
+ */
+LLVMAttributeRef LLVMCreateConstantRangeAttribute(LLVMContextRef C,
+                                                  unsigned KindID,
+                                                  unsigned NumBits,
+                                                  const uint64_t LowerWords[],
+                                                  const uint64_t UpperWords[]);
+
 /**
 /**
  * Create a string attribute.
  * Create a string attribute.
  */
  */
@@ -744,6 +783,24 @@ LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
  */
  */
 void LLVMDisposeModule(LLVMModuleRef M);
 void LLVMDisposeModule(LLVMModuleRef M);
 
 
+/**
+ * Soon to be deprecated.
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
+ * Returns true if the module is in the new debug info mode which uses
+ * non-instruction debug records instead of debug intrinsics for variable
+ * location tracking.
+ */
+LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M);
+
+/**
+ * Soon to be deprecated.
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
+ * Convert module into desired debug info format.
+ */
+void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat);
+
 /**
 /**
  * Obtain the identifier of a module.
  * Obtain the identifier of a module.
  *
  *
@@ -1130,6 +1187,16 @@ LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
  */
  */
 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
 
 
+/**
+ * Obtain a Function value from a Module by its name.
+ *
+ * The returned value corresponds to a llvm::Function value.
+ *
+ * @see llvm::Module::getFunction()
+ */
+LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M, const char *Name,
+                                            size_t Length);
+
 /**
 /**
  * Obtain an iterator to the first Function in a Module.
  * Obtain an iterator to the first Function in a Module.
  *
  *
@@ -1618,6 +1685,35 @@ LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
  */
  */
 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
 
 
+/**
+ * Get the pointer value for the associated ConstantPtrAuth constant.
+ *
+ * @see llvm::ConstantPtrAuth::getPointer
+ */
+LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth);
+
+/**
+ * Get the key value for the associated ConstantPtrAuth constant.
+ *
+ * @see llvm::ConstantPtrAuth::getKey
+ */
+LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth);
+
+/**
+ * Get the discriminator value for the associated ConstantPtrAuth constant.
+ *
+ * @see llvm::ConstantPtrAuth::getDiscriminator
+ */
+LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth);
+
+/**
+ * Get the address discriminator value for the associated ConstantPtrAuth
+ * constant.
+ *
+ * @see llvm::ConstantPtrAuth::getAddrDiscriminator
+ */
+LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth);
+
 /**
 /**
  * @}
  * @}
  */
  */
@@ -1638,11 +1734,6 @@ LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
  */
  */
 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
 
 
-/**
- * Create a X86 MMX type in a context.
- */
-LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
-
 /**
 /**
  * Create a X86 AMX type in a context.
  * Create a X86 AMX type in a context.
  */
  */
@@ -1664,7 +1755,6 @@ LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
  */
  */
 LLVMTypeRef LLVMVoidType(void);
 LLVMTypeRef LLVMVoidType(void);
 LLVMTypeRef LLVMLabelType(void);
 LLVMTypeRef LLVMLabelType(void);
-LLVMTypeRef LLVMX86MMXType(void);
 LLVMTypeRef LLVMX86AMXType(void);
 LLVMTypeRef LLVMX86AMXType(void);
 
 
 /**
 /**
@@ -1676,6 +1766,42 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
                                        unsigned *IntParams,
                                        unsigned *IntParams,
                                        unsigned IntParamCount);
                                        unsigned IntParamCount);
 
 
+/**
+ * Obtain the name for this target extension type.
+ *
+ * @see llvm::TargetExtType::getName()
+ */
+const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy);
+
+/**
+ * Obtain the number of type parameters for this target extension type.
+ *
+ * @see llvm::TargetExtType::getNumTypeParameters()
+ */
+unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy);
+
+/**
+ * Get the type parameter at the given index for the target extension type.
+ *
+ * @see llvm::TargetExtType::getTypeParameter()
+ */
+LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy,
+                                          unsigned Idx);
+
+/**
+ * Obtain the number of int parameters for this target extension type.
+ *
+ * @see llvm::TargetExtType::getNumIntParameters()
+ */
+unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy);
+
+/**
+ * Get the int parameter at the given index for the target extension type.
+ *
+ * @see llvm::TargetExtType::getIntParameter()
+ */
+unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx);
+
 /**
 /**
  * @}
  * @}
  */
  */
@@ -1705,6 +1831,10 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
  * @{
  * @{
  */
  */
 
 
+// Currently, clang-format tries to format the LLVM_FOR_EACH_VALUE_SUBCLASS
+// macro in a progressively-indented fashion, which is not desired
+// clang-format off
+
 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
   macro(Argument)                           \
   macro(Argument)                           \
   macro(BasicBlock)                         \
   macro(BasicBlock)                         \
@@ -1724,6 +1854,7 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
       macro(ConstantStruct)                 \
       macro(ConstantStruct)                 \
       macro(ConstantTokenNone)              \
       macro(ConstantTokenNone)              \
       macro(ConstantVector)                 \
       macro(ConstantVector)                 \
+      macro(ConstantPtrAuth)                \
       macro(GlobalValue)                    \
       macro(GlobalValue)                    \
         macro(GlobalAlias)                  \
         macro(GlobalAlias)                  \
         macro(GlobalObject)                 \
         macro(GlobalObject)                 \
@@ -1795,6 +1926,8 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
       macro(AtomicRMWInst)                  \
       macro(AtomicRMWInst)                  \
       macro(FenceInst)
       macro(FenceInst)
 
 
+// clang-format on
+
 /**
 /**
  * @defgroup LLVMCCoreValueGeneral General APIs
  * @defgroup LLVMCCoreValueGeneral General APIs
  *
  *
@@ -1848,6 +1981,21 @@ void LLVMDumpValue(LLVMValueRef Val);
  */
  */
 char *LLVMPrintValueToString(LLVMValueRef Val);
 char *LLVMPrintValueToString(LLVMValueRef Val);
 
 
+/**
+ * Obtain the context to which this value is associated.
+ *
+ * @see llvm::Value::getContext()
+ */
+LLVMContextRef LLVMGetValueContext(LLVMValueRef Val);
+
+/**
+ * Return a string representation of the DbgRecord. Use
+ * LLVMDisposeMessage to free the string.
+ *
+ * @see llvm::DbgRecord::print()
+ */
+char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record);
+
 /**
 /**
  * Replace all uses of a value with another one.
  * Replace all uses of a value with another one.
  *
  *
@@ -2165,11 +2313,22 @@ double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
 /**
 /**
  * Create a ConstantDataSequential and initialize it with a string.
  * Create a ConstantDataSequential and initialize it with a string.
  *
  *
+ * @deprecated LLVMConstStringInContext is deprecated in favor of the API
+ * accurate LLVMConstStringInContext2
  * @see llvm::ConstantDataArray::getString()
  * @see llvm::ConstantDataArray::getString()
  */
  */
 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
                                       unsigned Length, LLVMBool DontNullTerminate);
                                       unsigned Length, LLVMBool DontNullTerminate);
 
 
+/**
+ * Create a ConstantDataSequential and initialize it with a string.
+ *
+ * @see llvm::ConstantDataArray::getString()
+ */
+LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str,
+                                       size_t Length,
+                                       LLVMBool DontNullTerminate);
+
 /**
 /**
  * Create a ConstantDataSequential with string content in the global context.
  * Create a ConstantDataSequential with string content in the global context.
  *
  *
@@ -2269,6 +2428,14 @@ LLVM_ATTRIBUTE_C_DEPRECATED(
  */
  */
 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
 
 
+/**
+ * Create a ConstantPtrAuth constant with the given values.
+ *
+ * @see llvm::ConstantPtrAuth::get()
+ */
+LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key,
+                                 LLVMValueRef Disc, LLVMValueRef AddrDisc);
+
 /**
 /**
  * @}
  * @}
  */
  */
@@ -2287,7 +2454,9 @@ LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
-LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
+LLVM_ATTRIBUTE_C_DEPRECATED(
+    LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal),
+    "Use LLVMConstNull instead.");
 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
@@ -2299,16 +2468,22 @@ LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
-                           LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
-                           LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
 LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
 LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
                            LLVMValueRef *ConstantIndices, unsigned NumIndices);
                            LLVMValueRef *ConstantIndices, unsigned NumIndices);
 LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
 LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
                                    LLVMValueRef *ConstantIndices,
                                    LLVMValueRef *ConstantIndices,
                                    unsigned NumIndices);
                                    unsigned NumIndices);
+/**
+ * Creates a constant GetElementPtr expression. Similar to LLVMConstGEP2, but
+ * allows specifying the no-wrap flags.
+ *
+ * @see llvm::ConstantExpr::getGetElementPtr()
+ */
+LLVMValueRef LLVMConstGEPWithNoWrapFlags(LLVMTypeRef Ty,
+                                         LLVMValueRef ConstantVal,
+                                         LLVMValueRef *ConstantIndices,
+                                         unsigned NumIndices,
+                                         LLVMGEPNoWrapFlags NoWrapFlags);
 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
@@ -2328,6 +2503,16 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
                                     LLVMValueRef MaskConstant);
                                     LLVMValueRef MaskConstant);
 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
 
 
+/**
+ * Gets the function associated with a given BlockAddress constant value.
+ */
+LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr);
+
+/**
+ * Gets the basic block associated with a given BlockAddress constant value.
+ */
+LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr);
+
 /** Deprecated: Use LLVMGetInlineAsm instead. */
 /** Deprecated: Use LLVMGetInlineAsm instead. */
 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
                                 const char *AsmString, const char *Constraints,
                                 const char *AsmString, const char *Constraints,
@@ -2473,6 +2658,8 @@ LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
                                          const char *Name,
                                          const char *Name,
                                          unsigned AddressSpace);
                                          unsigned AddressSpace);
 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
+LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M, const char *Name,
+                                          size_t Length);
 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
@@ -2608,7 +2795,7 @@ void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
 /**
 /**
  * Obtain the intrinsic ID number which matches the given function name.
  * Obtain the intrinsic ID number which matches the given function name.
  *
  *
- * @see llvm::Function::lookupIntrinsicID()
+ * @see llvm::Intrinsic::lookupIntrinsicID()
  */
  */
 unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
 unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
 
 
@@ -2620,10 +2807,10 @@ unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
 
 
 /**
 /**
- * Create or insert the declaration of an intrinsic.  For overloaded intrinsics,
+ * Get or insert the declaration of an intrinsic.  For overloaded intrinsics,
  * parameter types must be provided to uniquely identify an overload.
  * parameter types must be provided to uniquely identify an overload.
  *
  *
- * @see llvm::Intrinsic::getDeclaration()
+ * @see llvm::Intrinsic::getOrInsertDeclaration()
  */
  */
 LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
 LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
                                          unsigned ID,
                                          unsigned ID,
@@ -2647,10 +2834,8 @@ LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
 const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
 const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
 
 
 /** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
 /** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
-const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
-                                            LLVMTypeRef *ParamTypes,
-                                            size_t ParamCount,
-                                            size_t *NameLength);
+char *LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes,
+                                      size_t ParamCount, size_t *NameLength);
 
 
 /**
 /**
  * Copies the name of an overloaded intrinsic identified by a given list of
  * Copies the name of an overloaded intrinsic identified by a given list of
@@ -2663,10 +2848,9 @@ const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
  *
  *
  * @see llvm::Intrinsic::getName()
  * @see llvm::Intrinsic::getName()
  */
  */
-const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
-                                             LLVMTypeRef *ParamTypes,
-                                             size_t ParamCount,
-                                             size_t *NameLength);
+char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
+                                       LLVMTypeRef *ParamTypes,
+                                       size_t ParamCount, size_t *NameLength);
 
 
 /**
 /**
  * Obtain if the intrinsic identified by the given ID is overloaded.
  * Obtain if the intrinsic identified by the given ID is overloaded.
@@ -2709,6 +2893,44 @@ const char *LLVMGetGC(LLVMValueRef Fn);
  */
  */
 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
 
 
+/**
+ * Gets the prefix data associated with a function. Only valid on functions, and
+ * only if LLVMHasPrefixData returns true.
+ * See https://llvm.org/docs/LangRef.html#prefix-data
+ */
+LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn);
+
+/**
+ * Check if a given function has prefix data. Only valid on functions.
+ * See https://llvm.org/docs/LangRef.html#prefix-data
+ */
+LLVMBool LLVMHasPrefixData(LLVMValueRef Fn);
+
+/**
+ * Sets the prefix data for the function. Only valid on functions.
+ * See https://llvm.org/docs/LangRef.html#prefix-data
+ */
+void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData);
+
+/**
+ * Gets the prologue data associated with a function. Only valid on functions,
+ * and only if LLVMHasPrologueData returns true.
+ * See https://llvm.org/docs/LangRef.html#prologue-data
+ */
+LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn);
+
+/**
+ * Check if a given function has prologue data. Only valid on functions.
+ * See https://llvm.org/docs/LangRef.html#prologue-data
+ */
+LLVMBool LLVMHasPrologueData(LLVMValueRef Fn);
+
+/**
+ * Sets the prologue data for the function. Only valid on functions.
+ * See https://llvm.org/docs/LangRef.html#prologue-data
+ */
+void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData);
+
 /**
 /**
  * Add an attribute to a function.
  * Add an attribute to a function.
  *
  *
@@ -3426,8 +3648,7 @@ LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
 /**
 /**
  * Obtain the predicate of an instruction.
  * Obtain the predicate of an instruction.
  *
  *
- * This is only valid for instructions that correspond to llvm::ICmpInst
- * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
+ * This is only valid for instructions that correspond to llvm::ICmpInst.
  *
  *
  * @see llvm::ICmpInst::getPredicate()
  * @see llvm::ICmpInst::getPredicate()
  */
  */
@@ -3436,8 +3657,7 @@ LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
 /**
 /**
  * Obtain the float predicate of an instruction.
  * Obtain the float predicate of an instruction.
  *
  *
- * This is only valid for instructions that correspond to llvm::FCmpInst
- * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
+ * This is only valid for instructions that correspond to llvm::FCmpInst.
  *
  *
  * @see llvm::FCmpInst::getPredicate()
  * @see llvm::FCmpInst::getPredicate()
  */
  */
@@ -3462,6 +3682,41 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
  */
  */
 LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
 LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
 
 
+/**
+ * Obtain the first debug record attached to an instruction.
+ *
+ * Use LLVMGetNextDbgRecord() and LLVMGetPreviousDbgRecord() to traverse the
+ * sequence of DbgRecords.
+ *
+ * Return the first DbgRecord attached to Inst or NULL if there are none.
+ *
+ * @see llvm::Instruction::getDbgRecordRange()
+ */
+LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst);
+
+/**
+ * Obtain the last debug record attached to an instruction.
+ *
+ * Return the last DbgRecord attached to Inst or NULL if there are none.
+ *
+ * @see llvm::Instruction::getDbgRecordRange()
+ */
+LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst);
+
+/**
+ * Obtain the next DbgRecord in the sequence or NULL if there are no more.
+ *
+ * @see llvm::Instruction::getDbgRecordRange()
+ */
+LLVMDbgRecordRef LLVMGetNextDbgRecord(LLVMDbgRecordRef DbgRecord);
+
+/**
+ * Obtain the previous DbgRecord in the sequence or NULL if there are no more.
+ *
+ * @see llvm::Instruction::getDbgRecordRange()
+ */
+LLVMDbgRecordRef LLVMGetPreviousDbgRecord(LLVMDbgRecordRef DbgRecord);
+
 /**
 /**
  * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
  * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
  *
  *
@@ -3634,6 +3889,28 @@ void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
  */
  */
 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
 
 
+/**
+ * Get the default destination of a CallBr instruction.
+ *
+ * @see llvm::CallBrInst::getDefaultDest()
+ */
+LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr);
+
+/**
+ * Get the number of indirect destinations of a CallBr instruction.
+ *
+ * @see llvm::CallBrInst::getNumIndirectDests()
+
+ */
+unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr);
+
+/**
+ * Get the indirect destination of a CallBr instruction at the given index.
+ *
+ * @see llvm::CallBrInst::getIndirectDest()
+ */
+LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, unsigned Idx);
+
 /**
 /**
  * @}
  * @}
  */
  */
@@ -3750,6 +4027,20 @@ void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
  */
  */
 LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
 LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
 
 
+/**
+ * Get the no-wrap related flags for the given GEP instruction.
+ *
+ * @see llvm::GetElementPtrInst::getNoWrapFlags
+ */
+LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP);
+
+/**
+ * Set the no-wrap related flags for the given GEP instruction.
+ *
+ * @see llvm::GetElementPtrInst::setNoWrapFlags
+ */
+void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP, LLVMGEPNoWrapFlags NoWrapFlags);
+
 /**
 /**
  * @}
  * @}
  */
  */
@@ -3832,9 +4123,28 @@ const unsigned *LLVMGetIndices(LLVMValueRef Inst);
 
 
 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
 LLVMBuilderRef LLVMCreateBuilder(void);
 LLVMBuilderRef LLVMCreateBuilder(void);
+/**
+ * Set the builder position before Instr but after any attached debug records,
+ * or if Instr is null set the position to the end of Block.
+ */
 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
                          LLVMValueRef Instr);
                          LLVMValueRef Instr);
+/**
+ * Set the builder position before Instr and any attached debug records,
+ * or if Instr is null set the position to the end of Block.
+ */
+void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder,
+                                         LLVMBasicBlockRef Block,
+                                         LLVMValueRef Inst);
+/**
+ * Set the builder position before Instr but after any attached debug records.
+ */
 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
+/**
+ * Set the builder position before Instr and any attached debug records.
+ */
+void LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder,
+                                                 LLVMValueRef Instr);
 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
@@ -3897,6 +4207,13 @@ LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
                                     LLVMMetadataRef FPMathTag);
                                     LLVMMetadataRef FPMathTag);
 
 
+/**
+ * Obtain the context to which this builder is associated.
+ *
+ * @see llvm::IRBuilder::getContext()
+ */
+LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder);
+
 /**
 /**
  * Deprecated: Passing the NULL location will crash.
  * Deprecated: Passing the NULL location will crash.
  * Use LLVMGetCurrentDebugLocation2 instead.
  * Use LLVMGetCurrentDebugLocation2 instead.
@@ -3920,6 +4237,12 @@ LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
                              LLVMBasicBlockRef Else, unsigned NumCases);
                              LLVMBasicBlockRef Else, unsigned NumCases);
 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
                                  unsigned NumDests);
                                  unsigned NumDests);
+LLVMValueRef LLVMBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
+                             LLVMBasicBlockRef DefaultDest,
+                             LLVMBasicBlockRef *IndirectDests,
+                             unsigned NumIndirectDests, LLVMValueRef *Args,
+                             unsigned NumArgs, LLVMOperandBundleRef *Bundles,
+                             unsigned NumBundles, const char *Name);
 LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
 LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
                               LLVMValueRef *Args, unsigned NumArgs,
                               LLVMValueRef *Args, unsigned NumArgs,
                               LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
                               LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
@@ -4075,8 +4398,10 @@ LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
                              const char *Name);
                              const char *Name);
-LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
-                             const char *Name);
+LLVM_ATTRIBUTE_C_DEPRECATED(LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B,
+                                                         LLVMValueRef V,
+                                                         const char *Name),
+                            "Use LLVMBuildNeg + LLVMSetNUW instead.");
 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
 
 
@@ -4182,11 +4507,25 @@ LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
 LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
 LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
                                    LLVMValueRef Pointer, LLVMValueRef *Indices,
                                    LLVMValueRef Pointer, LLVMValueRef *Indices,
                                    unsigned NumIndices, const char *Name);
                                    unsigned NumIndices, const char *Name);
+/**
+ * Creates a GetElementPtr instruction. Similar to LLVMBuildGEP2, but allows
+ * specifying the no-wrap flags.
+ *
+ * @see llvm::IRBuilder::CreateGEP()
+ */
+LLVMValueRef LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty,
+                                         LLVMValueRef Pointer,
+                                         LLVMValueRef *Indices,
+                                         unsigned NumIndices, const char *Name,
+                                         LLVMGEPNoWrapFlags NoWrapFlags);
 LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
 LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
                                  LLVMValueRef Pointer, unsigned Idx,
                                  LLVMValueRef Pointer, unsigned Idx,
                                  const char *Name);
                                  const char *Name);
 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
                                    const char *Name);
                                    const char *Name);
+/**
+ * Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.
+ */
 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
                                       const char *Name);
                                       const char *Name);
 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
@@ -4296,15 +4635,28 @@ LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,
                                const char *Name);
                                const char *Name);
 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
                             LLVMBool singleThread, const char *Name);
                             LLVMBool singleThread, const char *Name);
+LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B,
+                                     LLVMAtomicOrdering ordering, unsigned SSID,
+                                     const char *Name);
 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
                                 LLVMValueRef PTR, LLVMValueRef Val,
                                 LLVMValueRef PTR, LLVMValueRef Val,
                                 LLVMAtomicOrdering ordering,
                                 LLVMAtomicOrdering ordering,
                                 LLVMBool singleThread);
                                 LLVMBool singleThread);
+LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B,
+                                         LLVMAtomicRMWBinOp op,
+                                         LLVMValueRef PTR, LLVMValueRef Val,
+                                         LLVMAtomicOrdering ordering,
+                                         unsigned SSID);
 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
                                     LLVMValueRef Cmp, LLVMValueRef New,
                                     LLVMValueRef Cmp, LLVMValueRef New,
                                     LLVMAtomicOrdering SuccessOrdering,
                                     LLVMAtomicOrdering SuccessOrdering,
                                     LLVMAtomicOrdering FailureOrdering,
                                     LLVMAtomicOrdering FailureOrdering,
                                     LLVMBool SingleThread);
                                     LLVMBool SingleThread);
+LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(LLVMBuilderRef B, LLVMValueRef Ptr,
+                                             LLVMValueRef Cmp, LLVMValueRef New,
+                                             LLVMAtomicOrdering SuccessOrdering,
+                                             LLVMAtomicOrdering FailureOrdering,
+                                             unsigned SSID);
 
 
 /**
 /**
  * Get the number of elements in the mask of a ShuffleVector instruction.
  * Get the number of elements in the mask of a ShuffleVector instruction.
@@ -4329,6 +4681,22 @@ int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
 
 
+/**
+ * Returns whether an instruction is an atomic instruction, e.g., atomicrmw,
+ * cmpxchg, fence, or loads and stores with atomic ordering.
+ */
+LLVMBool LLVMIsAtomic(LLVMValueRef Inst);
+
+/**
+ * Returns the synchronization scope ID of an atomic instruction.
+ */
+unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst);
+
+/**
+ * Sets the synchronization scope ID of an atomic instruction.
+ */
+void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID);
+
 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
                                    LLVMAtomicOrdering Ordering);
                                    LLVMAtomicOrdering Ordering);

+ 115 - 34
src/llvm-c/DebugInfo.h

@@ -16,8 +16,8 @@
 #ifndef LLVM_C_DEBUGINFO_H
 #ifndef LLVM_C_DEBUGINFO_H
 #define LLVM_C_DEBUGINFO_H
 #define LLVM_C_DEBUGINFO_H
 
 
-#include "ExternC.h"
-#include "Types.h"
+#include "llvm-c/ExternC.h"
+#include "llvm-c/Types.h"
 
 
 LLVM_C_EXTERN_C_BEGIN
 LLVM_C_EXTERN_C_BEGIN
 
 
@@ -125,7 +125,21 @@ typedef enum {
   LLVMDWARFSourceLanguageFortran18,
   LLVMDWARFSourceLanguageFortran18,
   LLVMDWARFSourceLanguageAda2005,
   LLVMDWARFSourceLanguageAda2005,
   LLVMDWARFSourceLanguageAda2012,
   LLVMDWARFSourceLanguageAda2012,
+  LLVMDWARFSourceLanguageHIP,
+  LLVMDWARFSourceLanguageAssembly,
+  LLVMDWARFSourceLanguageC_sharp,
   LLVMDWARFSourceLanguageMojo,
   LLVMDWARFSourceLanguageMojo,
+  LLVMDWARFSourceLanguageGLSL,
+  LLVMDWARFSourceLanguageGLSL_ES,
+  LLVMDWARFSourceLanguageHLSL,
+  LLVMDWARFSourceLanguageOpenCL_CPP,
+  LLVMDWARFSourceLanguageCPP_for_OpenCL,
+  LLVMDWARFSourceLanguageSYCL,
+  LLVMDWARFSourceLanguageRuby,
+  LLVMDWARFSourceLanguageMove,
+  LLVMDWARFSourceLanguageHylo,
+  LLVMDWARFSourceLanguageMetal,
+
   // Vendor extensions:
   // Vendor extensions:
   LLVMDWARFSourceLanguageMips_Assembler,
   LLVMDWARFSourceLanguageMips_Assembler,
   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
   LLVMDWARFSourceLanguageGOOGLE_RenderScript,
@@ -856,13 +870,16 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
                                 LLVMMetadataRef Ty);
                                 LLVMMetadataRef Ty);
 
 
 /**
 /**
- * Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
+ * Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
+ * is true, then also set FlagArtificial.
  * \param Builder   The DIBuilder.
  * \param Builder   The DIBuilder.
  * \param Type      The underlying type to which this pointer points.
  * \param Type      The underlying type to which this pointer points.
+ * \param Implicit  Indicates whether this pointer was implicitly generated
+ *                  (i.e., not spelled out in source).
  */
  */
-LLVMMetadataRef
-LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
-                                     LLVMMetadataRef Type);
+LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
+                                                     LLVMMetadataRef Type,
+                                                     LLVMBool Implicit);
 
 
 /**
 /**
  * Create debugging information entry for a qualified
  * Create debugging information entry for a qualified
@@ -1249,66 +1266,84 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
     LLVMMetadataRef Decl, uint32_t AlignInBits);
     LLVMMetadataRef Decl, uint32_t AlignInBits);
 
 
 /**
 /**
- * Insert a new llvm.dbg.declare intrinsic call before the given instruction.
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
+ *
+ * Insert a Declare DbgRecord before the given instruction.
  * \param Builder     The DIBuilder.
  * \param Builder     The DIBuilder.
  * \param Storage     The storage of the variable to declare.
  * \param Storage     The storage of the variable to declare.
  * \param VarInfo     The variable's debug info descriptor.
  * \param VarInfo     The variable's debug info descriptor.
  * \param Expr        A complex location expression for the variable.
  * \param Expr        A complex location expression for the variable.
  * \param DebugLoc    Debug info location.
  * \param DebugLoc    Debug info location.
- * \param Instr       Instruction acting as a location for the new intrinsic.
+ * \param Instr       Instruction acting as a location for the new record.
  */
  */
-LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
-  LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
-  LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
+LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
+    LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+    LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
 
 
 /**
 /**
- * Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
- * block. If the basic block has a terminator instruction, the intrinsic is
- * inserted before that terminator instruction.
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
+ *
+ * Insert a Declare DbgRecord at the end of the given basic block. If the basic
+ * block has a terminator instruction, the record is inserted before that
+ * terminator instruction.
  * \param Builder     The DIBuilder.
  * \param Builder     The DIBuilder.
  * \param Storage     The storage of the variable to declare.
  * \param Storage     The storage of the variable to declare.
  * \param VarInfo     The variable's debug info descriptor.
  * \param VarInfo     The variable's debug info descriptor.
  * \param Expr        A complex location expression for the variable.
  * \param Expr        A complex location expression for the variable.
  * \param DebugLoc    Debug info location.
  * \param DebugLoc    Debug info location.
- * \param Block       Basic block acting as a location for the new intrinsic.
+ * \param Block       Basic block acting as a location for the new record.
  */
  */
-LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
+LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
     LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
     LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
     LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
     LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
 
 
 /**
 /**
- * Insert a new llvm.dbg.value intrinsic call before the given instruction.
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
+ *
+ * Insert a new debug record before the given instruction.
  * \param Builder     The DIBuilder.
  * \param Builder     The DIBuilder.
  * \param Val         The value of the variable.
  * \param Val         The value of the variable.
  * \param VarInfo     The variable's debug info descriptor.
  * \param VarInfo     The variable's debug info descriptor.
  * \param Expr        A complex location expression for the variable.
  * \param Expr        A complex location expression for the variable.
  * \param DebugLoc    Debug info location.
  * \param DebugLoc    Debug info location.
- * \param Instr       Instruction acting as a location for the new intrinsic.
+ * \param Instr       Instruction acting as a location for the new record.
  */
  */
-LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
-                                               LLVMValueRef Val,
-                                               LLVMMetadataRef VarInfo,
-                                               LLVMMetadataRef Expr,
-                                               LLVMMetadataRef DebugLoc,
-                                               LLVMValueRef Instr);
+LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
+    LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+    LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
 
 
 /**
 /**
- * Insert a new llvm.dbg.value intrinsic call at the end of the given basic
- * block. If the basic block has a terminator instruction, the intrinsic is
- * inserted before that terminator instruction.
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ *
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
+ *
+ * Insert a new debug record at the end of the given basic block. If the
+ * basic block has a terminator instruction, the record is inserted before
+ * that terminator instruction.
  * \param Builder     The DIBuilder.
  * \param Builder     The DIBuilder.
  * \param Val         The value of the variable.
  * \param Val         The value of the variable.
  * \param VarInfo     The variable's debug info descriptor.
  * \param VarInfo     The variable's debug info descriptor.
  * \param Expr        A complex location expression for the variable.
  * \param Expr        A complex location expression for the variable.
  * \param DebugLoc    Debug info location.
  * \param DebugLoc    Debug info location.
- * \param Block       Basic block acting as a location for the new intrinsic.
+ * \param Block       Basic block acting as a location for the new record.
  */
  */
-LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder,
-                                              LLVMValueRef Val,
-                                              LLVMMetadataRef VarInfo,
-                                              LLVMMetadataRef Expr,
-                                              LLVMMetadataRef DebugLoc,
-                                              LLVMBasicBlockRef Block);
+LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
+    LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+    LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
 
 
 /**
 /**
  * Create a new descriptor for a local auto variable.
  * Create a new descriptor for a local auto variable.
@@ -1384,6 +1419,52 @@ LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst);
  */
  */
 void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc);
 void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc);
 
 
+/**
+ * Create a new descriptor for a label
+ *
+ * \param Builder         The DIBuilder.
+ * \param Scope           The scope to create the label in.
+ * \param Name            Variable name.
+ * \param NameLen         Length of variable name.
+ * \param File            The file to create the label in.
+ * \param LineNo          Line Number.
+ * \param AlwaysPreserve  Preserve the label regardless of optimization.
+ *
+ * @see llvm::DIBuilder::createLabel()
+ */
+LLVMMetadataRef LLVMDIBuilderCreateLabel(
+    LLVMDIBuilderRef Builder,
+    LLVMMetadataRef Context, const char *Name, size_t NameLen,
+    LLVMMetadataRef File, unsigned LineNo, LLVMBool AlwaysPreserve);
+
+/**
+ * Insert a new llvm.dbg.label intrinsic call
+ *
+ * \param Builder         The DIBuilder.
+ * \param LabelInfo       The Label's debug info descriptor
+ * \param Location        The debug info location
+ * \param InsertBefore    Location for the new intrinsic.
+ *
+ * @see llvm::DIBuilder::insertLabel()
+ */
+LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(
+    LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
+    LLVMMetadataRef Location, LLVMValueRef InsertBefore);
+
+/**
+ * Insert a new llvm.dbg.label intrinsic call
+ *
+ * \param Builder         The DIBuilder.
+ * \param LabelInfo       The Label's debug info descriptor
+ * \param Location        The debug info location
+ * \param InsertAtEnd     Location for the new intrinsic.
+ *
+ * @see llvm::DIBuilder::insertLabel()
+ */
+LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(
+    LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
+    LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd);
+
 /**
 /**
  * Obtain the enumerated type of a Metadata instance.
  * Obtain the enumerated type of a Metadata instance.
  *
  *

+ 5 - 3
src/llvm-c/Disassembler.h

@@ -15,8 +15,8 @@
 #ifndef LLVM_C_DISASSEMBLER_H
 #ifndef LLVM_C_DISASSEMBLER_H
 #define LLVM_C_DISASSEMBLER_H
 #define LLVM_C_DISASSEMBLER_H
 
 
-#include "DisassemblerTypes.h"
-#include "ExternC.h"
+#include "llvm-c/DisassemblerTypes.h"
+#include "llvm-c/ExternC.h"
 
 
 /**
 /**
  * @defgroup LLVMCDisassembler Disassembler
  * @defgroup LLVMCDisassembler Disassembler
@@ -79,8 +79,10 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);
 #define LLVMDisassembler_Option_AsmPrinterVariant 4
 #define LLVMDisassembler_Option_AsmPrinterVariant 4
 /* The option to set comment on instructions */
 /* The option to set comment on instructions */
 #define LLVMDisassembler_Option_SetInstrComments 8
 #define LLVMDisassembler_Option_SetInstrComments 8
-  /* The option to print latency information alongside instructions */
+/* The option to print latency information alongside instructions */
 #define LLVMDisassembler_Option_PrintLatency 16
 #define LLVMDisassembler_Option_PrintLatency 16
+/* The option to print in color */
+#define LLVMDisassembler_Option_Color 32
 
 
 /**
 /**
  * Dispose of a disassembler context.
  * Dispose of a disassembler context.

+ 1 - 1
src/llvm-c/DisassemblerTypes.h

@@ -10,7 +10,7 @@
 #ifndef LLVM_C_DISASSEMBLERTYPES_H
 #ifndef LLVM_C_DISASSEMBLERTYPES_H
 #define LLVM_C_DISASSEMBLERTYPES_H
 #define LLVM_C_DISASSEMBLERTYPES_H
 
 
-#include "DataTypes.h"
+#include "llvm-c/DataTypes.h"
 #ifdef __cplusplus
 #ifdef __cplusplus
 #include <cstddef>
 #include <cstddef>
 #else
 #else

+ 9 - 1
src/llvm-c/Error.h

@@ -14,7 +14,7 @@
 #ifndef LLVM_C_ERROR_H
 #ifndef LLVM_C_ERROR_H
 #define LLVM_C_ERROR_H
 #define LLVM_C_ERROR_H
 
 
-#include "ExternC.h"
+#include "llvm-c/ExternC.h"
 
 
 LLVM_C_EXTERN_C_BEGIN
 LLVM_C_EXTERN_C_BEGIN
 
 
@@ -51,6 +51,14 @@ LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err);
  */
  */
 void LLVMConsumeError(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,
  * Returns the given string's error message. This operation consumes the error,
  * and the given LLVMErrorRef value is not usable once this call returns.
  * and the given LLVMErrorRef value is not usable once this call returns.

+ 1 - 1
src/llvm-c/ErrorHandling.h

@@ -14,7 +14,7 @@
 #ifndef LLVM_C_ERRORHANDLING_H
 #ifndef LLVM_C_ERRORHANDLING_H
 #define LLVM_C_ERRORHANDLING_H
 #define LLVM_C_ERRORHANDLING_H
 
 
-#include "ExternC.h"
+#include "llvm-c/ExternC.h"
 
 
 LLVM_C_EXTERN_C_BEGIN
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 4 - 4
src/llvm-c/ExecutionEngine.h

@@ -19,10 +19,10 @@
 #ifndef LLVM_C_EXECUTIONENGINE_H
 #ifndef LLVM_C_EXECUTIONENGINE_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 2 - 2
src/llvm-c/IRReader.h

@@ -14,8 +14,8 @@
 #ifndef LLVM_C_IRREADER_H
 #ifndef LLVM_C_IRREADER_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 4 - 4
src/llvm-c/LLJIT.h

@@ -24,10 +24,10 @@
 #ifndef LLVM_C_LLJIT_H
 #ifndef LLVM_C_LLJIT_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 1 - 1
src/llvm-c/LLJITUtils.h

@@ -26,7 +26,7 @@
 #ifndef LLVM_C_LLJITUTILS_H
 #ifndef LLVM_C_LLJITUTILS_H
 #define LLVM_C_LLJITUTILS_H
 #define LLVM_C_LLJITUTILS_H
 
 
-#include "LLJIT.h"
+#include "llvm-c/LLJIT.h"
 
 
 LLVM_C_EXTERN_C_BEGIN
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 2 - 2
src/llvm-c/Linker.h

@@ -14,8 +14,8 @@
 #ifndef LLVM_C_LINKER_H
 #ifndef LLVM_C_LINKER_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 3 - 3
src/llvm-c/Object.h

@@ -19,9 +19,9 @@
 #ifndef LLVM_C_OBJECT_H
 #ifndef LLVM_C_OBJECT_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 27 - 36
src/llvm-c/Orc.h

@@ -27,9 +27,9 @@
 #ifndef LLVM_C_ORC_H
 #ifndef LLVM_C_ORC_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 
@@ -181,6 +181,15 @@ typedef struct {
  */
  */
 typedef LLVMOrcCDependenceMapPair *LLVMOrcCDependenceMapPairs;
 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
  * Lookup kind. This can be used by definition generators when deciding whether
  * to produce a definition for a requested symbol.
  * to produce a definition for a requested symbol.
@@ -808,6 +817,19 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved(
  * that all symbols covered by this MaterializationResponsibility instance
  * that all symbols covered by this MaterializationResponsibility instance
  * have been emitted.
  * 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
  * 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
  * 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
  * method returns an error then clients should log it and call
@@ -817,7 +839,8 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved(
  * LLVMErrorSuccess.
  * LLVMErrorSuccess.
  */
  */
 LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyEmitted(
 LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyEmitted(
-    LLVMOrcMaterializationResponsibilityRef MR);
+    LLVMOrcMaterializationResponsibilityRef MR,
+    LLVMOrcCSymbolDependenceGroup *SymbolDepGroups, size_t NumSymbolDepGroups);
 
 
 /**
 /**
  * Attempt to claim responsibility for new definitions. This method can be
  * Attempt to claim responsibility for new definitions. This method can be
@@ -870,38 +893,6 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityDelegate(
     LLVMOrcSymbolStringPoolEntryRef *Symbols, size_t NumSymbols,
     LLVMOrcSymbolStringPoolEntryRef *Symbols, size_t NumSymbols,
     LLVMOrcMaterializationResponsibilityRef *Result);
     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.
  * Create a "bare" JITDylib.
  *
  *

+ 5 - 5
src/llvm-c/OrcEE.h

@@ -24,11 +24,11 @@
 #ifndef LLVM_C_ORCEE_H
 #ifndef LLVM_C_ORCEE_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 2 - 2
src/llvm-c/Remarks.h

@@ -15,8 +15,8 @@
 #ifndef LLVM_C_REMARKS_H
 #ifndef LLVM_C_REMARKS_H
 #define 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
 #ifdef __cplusplus
 #include <cstddef>
 #include <cstddef>
 #else
 #else

+ 3 - 3
src/llvm-c/Support.h

@@ -14,9 +14,9 @@
 #ifndef LLVM_C_SUPPORT_H
 #ifndef LLVM_C_SUPPORT_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 16 - 16
src/llvm-c/Target.h

@@ -19,9 +19,9 @@
 #ifndef LLVM_C_TARGET_H
 #ifndef LLVM_C_TARGET_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 
@@ -40,34 +40,34 @@ typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
 /* Declare all of the target-initialization functions that are available. */
 /* Declare all of the target-initialization functions that are available. */
 #define LLVM_TARGET(TargetName) \
 #define LLVM_TARGET(TargetName) \
   void LLVMInitialize##TargetName##TargetInfo(void);
   void LLVMInitialize##TargetName##TargetInfo(void);
-#include "Config/Targets.def"
+#include "llvm-c/Config/Targets.def"
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 
 
 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void);
 #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 */
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 
 
 #define LLVM_TARGET(TargetName) \
 #define LLVM_TARGET(TargetName) \
   void LLVMInitialize##TargetName##TargetMC(void);
   void LLVMInitialize##TargetName##TargetMC(void);
-#include "Config/Targets.def"
+#include "llvm-c/Config/Targets.def"
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 
 
 /* Declare all of the available assembly printer initialization functions. */
 /* Declare all of the available assembly printer initialization functions. */
 #define LLVM_ASM_PRINTER(TargetName) \
 #define LLVM_ASM_PRINTER(TargetName) \
   void LLVMInitialize##TargetName##AsmPrinter(void);
   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 */
 #undef LLVM_ASM_PRINTER  /* Explicit undef to make SWIG happier */
 
 
 /* Declare all of the available assembly parser initialization functions. */
 /* Declare all of the available assembly parser initialization functions. */
 #define LLVM_ASM_PARSER(TargetName) \
 #define LLVM_ASM_PARSER(TargetName) \
   void LLVMInitialize##TargetName##AsmParser(void);
   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 */
 #undef LLVM_ASM_PARSER  /* Explicit undef to make SWIG happier */
 
 
 /* Declare all of the available disassembler initialization functions. */
 /* Declare all of the available disassembler initialization functions. */
 #define LLVM_DISASSEMBLER(TargetName) \
 #define LLVM_DISASSEMBLER(TargetName) \
   void LLVMInitialize##TargetName##Disassembler(void);
   void LLVMInitialize##TargetName##Disassembler(void);
-#include "Config/Disassemblers.def"
+#include "llvm-c/Config/Disassemblers.def"
 #undef LLVM_DISASSEMBLER  /* Explicit undef to make SWIG happier */
 #undef LLVM_DISASSEMBLER  /* Explicit undef to make SWIG happier */
 
 
 /** LLVMInitializeAllTargetInfos - The main program should call this function if
 /** LLVMInitializeAllTargetInfos - The main program should call this function if
@@ -75,7 +75,7 @@ typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
     support. */
     support. */
 static inline void LLVMInitializeAllTargetInfos(void) {
 static inline void LLVMInitializeAllTargetInfos(void) {
 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
 #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 */
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 }
 }
 
 
@@ -84,7 +84,7 @@ static inline void LLVMInitializeAllTargetInfos(void) {
     support. */
     support. */
 static inline void LLVMInitializeAllTargets(void) {
 static inline void LLVMInitializeAllTargets(void) {
 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
 #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 */
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 }
 }
 
 
@@ -93,7 +93,7 @@ static inline void LLVMInitializeAllTargets(void) {
     support. */
     support. */
 static inline void LLVMInitializeAllTargetMCs(void) {
 static inline void LLVMInitializeAllTargetMCs(void) {
 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
 #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 */
 #undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
 }
 }
 
 
@@ -102,7 +102,7 @@ static inline void LLVMInitializeAllTargetMCs(void) {
     available via the TargetRegistry. */
     available via the TargetRegistry. */
 static inline void LLVMInitializeAllAsmPrinters(void) {
 static inline void LLVMInitializeAllAsmPrinters(void) {
 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
 #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 */
 #undef LLVM_ASM_PRINTER  /* Explicit undef to make SWIG happier */
 }
 }
 
 
@@ -111,7 +111,7 @@ static inline void LLVMInitializeAllAsmPrinters(void) {
     available via the TargetRegistry. */
     available via the TargetRegistry. */
 static inline void LLVMInitializeAllAsmParsers(void) {
 static inline void LLVMInitializeAllAsmParsers(void) {
 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
 #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 */
 #undef LLVM_ASM_PARSER  /* Explicit undef to make SWIG happier */
 }
 }
 
 
@@ -121,7 +121,7 @@ static inline void LLVMInitializeAllAsmParsers(void) {
 static inline void LLVMInitializeAllDisassemblers(void) {
 static inline void LLVMInitializeAllDisassemblers(void) {
 #define LLVM_DISASSEMBLER(TargetName) \
 #define LLVM_DISASSEMBLER(TargetName) \
   LLVMInitialize##TargetName##Disassembler();
   LLVMInitialize##TargetName##Disassembler();
-#include "Config/Disassemblers.def"
+#include "llvm-c/Config/Disassemblers.def"
 #undef LLVM_DISASSEMBLER  /* Explicit undef to make SWIG happier */
 #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,
 LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD,
                                          unsigned AS);
                                          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. */
     See the method llvm::DataLayout::getTypeSizeInBits. */
 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty);
 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty);
 
 

+ 3 - 3
src/llvm-c/TargetMachine.h

@@ -19,9 +19,9 @@
 #ifndef LLVM_C_TARGETMACHINE_H
 #ifndef LLVM_C_TARGETMACHINE_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 

+ 21 - 3
src/llvm-c/Transforms/PassBuilder.h

@@ -14,9 +14,9 @@
 #ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H
 #ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H
 #define 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
  * @defgroup LLVMCCoreNewPM New Pass Manager
@@ -50,6 +50,16 @@ LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
                            LLVMTargetMachineRef TM,
                            LLVMTargetMachineRef TM,
                            LLVMPassBuilderOptionsRef Options);
                            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
  * Create a new set of options for a PassBuilder
  *
  *
@@ -72,6 +82,14 @@ void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options,
 void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options,
 void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options,
                                            LLVMBool DebugLogging);
                                            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(
 void LLVMPassBuilderOptionsSetLoopInterleaving(
     LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving);
     LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving);
 
 

+ 7 - 2
src/llvm-c/Types.h

@@ -14,8 +14,8 @@
 #ifndef LLVM_C_TYPES_H
 #ifndef LLVM_C_TYPES_H
 #define 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
 LLVM_C_EXTERN_C_BEGIN
 
 
@@ -169,6 +169,11 @@ typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef;
  */
  */
 typedef struct LLVMOpaqueBinary *LLVMBinaryRef;
 typedef struct LLVMOpaqueBinary *LLVMBinaryRef;
 
 
+/**
+ * @see llvm::DbgRecord
+ */
+typedef struct LLVMOpaqueDbgRecord *LLVMDbgRecordRef;
+
 /**
 /**
  * @}
  * @}
  */
  */

+ 1 - 1
src/llvm-c/lto.h

@@ -16,7 +16,7 @@
 #ifndef LLVM_C_LTO_H
 #ifndef LLVM_C_LTO_H
 #define LLVM_C_LTO_H
 #define LLVM_C_LTO_H
 
 
-#include "ExternC.h"
+#include "llvm-c/ExternC.h"
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 #include <cstddef>
 #include <cstddef>

+ 4 - 0
src/llvm_abi.cpp

@@ -256,8 +256,10 @@ gb_internal i64 lb_sizeof(LLVMTypeRef type) {
 		}
 		}
 		break;
 		break;
 
 
+#if LLVM_VERSION_MAJOR < 20
 	case LLVMX86_MMXTypeKind:
 	case LLVMX86_MMXTypeKind:
 		return 8;
 		return 8;
+#endif
 	case LLVMVectorTypeKind:
 	case LLVMVectorTypeKind:
 		{
 		{
 			LLVMTypeRef elem = OdinLLVMGetVectorElementType(type);
 			LLVMTypeRef elem = OdinLLVMGetVectorElementType(type);
@@ -310,8 +312,10 @@ gb_internal i64 lb_alignof(LLVMTypeRef type) {
 	case LLVMArrayTypeKind:
 	case LLVMArrayTypeKind:
 		return lb_alignof(OdinLLVMGetArrayElementType(type));
 		return lb_alignof(OdinLLVMGetArrayElementType(type));
 
 
+#if LLVM_VERSION_MAJOR < 20
 	case LLVMX86_MMXTypeKind:
 	case LLVMX86_MMXTypeKind:
 		return 8;
 		return 8;
+#endif
 	case LLVMVectorTypeKind:
 	case LLVMVectorTypeKind:
 		{
 		{
 			// TODO(bill): This appears to be correct but LLVM isn't necessarily "great" with regards to documentation
 			// TODO(bill): This appears to be correct but LLVM isn't necessarily "great" with regards to documentation

+ 10 - 797
src/llvm_backend.cpp

@@ -1591,797 +1591,7 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) {
 	LLVMPassBuilderOptionsRef pb_options = LLVMCreatePassBuilderOptions();
 	LLVMPassBuilderOptionsRef pb_options = LLVMCreatePassBuilderOptions();
 	defer (LLVMDisposePassBuilderOptions(pb_options));
 	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<Os>
-// Passes removed: coro, openmp, sroa
-#if LLVM_VERSION_MAJOR == 17
-		array_add(&passes, u8R"(
-annotation2metadata,
-forceattrs,
-inferattrs,
-function<eager-inv>(
-	lower-expect,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	early-cse<>
-),
-ipsccp,
-called-value-propagation,
-globalopt,
-function<eager-inv>(
-	mem2reg,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-require<globals-aa>,
-function(
-	invalidate<aa>
-),
-require<profile-summary>,
-cgscc(
-	devirt<4>(
-		inline<only-mandatory>,
-		inline,
-		function-attrs<skip-non-recursive>,
-		function<eager-inv;no-rerun>(
-			early-cse<memssa>,
-			speculative-execution,
-			jump-threading,
-			correlated-propagation,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			aggressive-instcombine,
-			constraint-elimination,
-			tailcallelim,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			reassociate,
-			loop-mssa(
-				loop-instsimplify,
-				loop-simplifycfg,
-				licm<no-allowspeculation>,
-				loop-rotate<header-duplication;no-prepare-for-lto>,
-				licm<allowspeculation>,
-				simple-loop-unswitch<no-nontrivial;trivial>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			loop(
-				loop-idiom,
-				indvars,
-				loop-deletion,
-				loop-unroll-full
-			),
-			vector-combine,
-			mldst-motion<no-split-footer-bb>,
-			gvn<>,
-			sccp,
-			bdce,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			jump-threading,
-			correlated-propagation,
-			adce,
-			memcpyopt,
-			dse,
-			move-auto-init,
-			loop-mssa(
-				licm<allowspeculation>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>
-		),
-		function-attrs,
-		function(
-			require<should-not-run-function-passes>
-		)
-	)
-),
-deadargelim,
-globalopt,
-globaldce,
-elim-avail-extern,
-rpo-function-attrs,
-recompute-globalsaa,
-function<eager-inv>(
-	float2int,
-	lower-constant-intrinsics,
-	loop(
-		loop-rotate<header-duplication;no-prepare-for-lto>,
-		loop-deletion
-	),
-	loop-distribute,
-	inject-tli-mappings,
-	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
-	loop-load-elim,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	slp-vectorizer,
-	vector-combine,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	loop-unroll<O2>,
-	transform-warning,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	loop-mssa(
-		licm<allowspeculation>
-	),
-	alignment-from-assumptions,
-	loop-sink,
-	instsimplify,
-	div-rem-pairs,
-	tailcallelim,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-globaldce,
-constmerge,
-cg-profile,
-rel-lookup-table-converter,
-function(
-	annotation-remarks
-),
-verify
-)");
-#else
-		array_add(&passes, u8R"(
-annotation2metadata,
-forceattrs,
-inferattrs,
-function<eager-inv>(
-	lower-expect,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	sroa<modify-cfg>,
-	early-cse<>
-),
-ipsccp,
-called-value-propagation,
-globalopt,
-function<eager-inv>(
-	mem2reg,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-always-inline,
-require<globals-aa>,
-function(
-	invalidate<aa>
-),
-require<profile-summary>,
-cgscc(
-	devirt<4>(
-		inline,
-		function-attrs<skip-non-recursive-function-attrs>,
-		function<eager-inv;no-rerun>(
-			sroa<modify-cfg>,
-			early-cse<memssa>,
-			speculative-execution<only-if-divergent-target>,
-			jump-threading,
-			correlated-propagation,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			aggressive-instcombine,
-			tailcallelim,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			reassociate,
-			constraint-elimination,
-			loop-mssa(
-				loop-instsimplify,
-				loop-simplifycfg,
-				licm<no-allowspeculation>,
-				loop-rotate<header-duplication;no-prepare-for-lto>,
-				licm<allowspeculation>,
-				simple-loop-unswitch<no-nontrivial;trivial>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			loop(
-				loop-idiom,
-				indvars,
-				loop-deletion,
-				loop-unroll-full
-			),
-			sroa<modify-cfg>,
-			vector-combine,
-			mldst-motion<no-split-footer-bb>,
-			gvn<>,
-			sccp,
-			bdce,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			jump-threading,
-			correlated-propagation,
-			adce,
-			memcpyopt,
-			dse,
-			move-auto-init,
-			loop-mssa(
-				licm<allowspeculation>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
-		),
-		function-attrs,
-		function(
-			require<should-not-run-function-passes>
-		)
-	)
-),
-deadargelim,
-globalopt,
-globaldce,
-elim-avail-extern,
-rpo-function-attrs,
-recompute-globalsaa,
-function<eager-inv>(
-	float2int,
-	lower-constant-intrinsics,
-	loop(
-		loop-rotate<header-duplication;no-prepare-for-lto>,
-		loop-deletion
-	),
-	loop-distribute,
-	inject-tli-mappings,
-	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
-	infer-alignment,
-	loop-load-elim,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	slp-vectorizer,
-	vector-combine,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	loop-unroll<O2>,
-	transform-warning,
-	sroa<preserve-cfg>,
-	infer-alignment,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	loop-mssa(
-		licm<allowspeculation>
-	),
-	alignment-from-assumptions,
-	loop-sink,
-	instsimplify,
-	div-rem-pairs,
-	tailcallelim,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-globaldce,
-constmerge,
-cg-profile,
-rel-lookup-table-converter,
-function(
-	annotation-remarks
-),
-verify
-)");
-#endif
-		break;
-// default<O2>
-// Passes removed: coro, openmp, sroa
-	case 2:
-#if LLVM_VERSION_MAJOR == 17
-		array_add(&passes, u8R"(
-annotation2metadata,
-forceattrs,
-inferattrs,
-function<eager-inv>(
-	lower-expect,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	early-cse<>
-),
-ipsccp,
-called-value-propagation,
-globalopt,
-function<eager-inv>(
-	mem2reg,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-require<globals-aa>,
-function(
-	invalidate<aa>
-),
-require<profile-summary>,
-cgscc(
-	devirt<4>(
-		inline<only-mandatory>,
-		inline,
-		function-attrs<skip-non-recursive>,
-		function<eager-inv;no-rerun>(
-			early-cse<memssa>,
-			speculative-execution,
-			jump-threading,
-			correlated-propagation,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			aggressive-instcombine,
-			constraint-elimination,
-			libcalls-shrinkwrap,
-			tailcallelim,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			reassociate,
-			loop-mssa(
-				loop-instsimplify,
-				loop-simplifycfg,
-				licm<no-allowspeculation>,
-				loop-rotate<header-duplication;no-prepare-for-lto>,
-				licm<allowspeculation>,
-				simple-loop-unswitch<no-nontrivial;trivial>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			loop(
-				loop-idiom,
-				indvars,
-				loop-deletion,
-				loop-unroll-full
-			),
-			vector-combine,
-			mldst-motion<no-split-footer-bb>,
-			gvn<>,
-			sccp,
-			bdce,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			jump-threading,
-			correlated-propagation,
-			adce,
-			memcpyopt,
-			dse,
-			move-auto-init,
-			loop-mssa(
-				licm<allowspeculation>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>
-		),
-		function-attrs,
-		function(
-			require<should-not-run-function-passes>
-		)
-	)
-),
-deadargelim,
-globalopt,
-globaldce,
-elim-avail-extern,
-rpo-function-attrs,
-recompute-globalsaa,
-function<eager-inv>(
-	float2int,
-	lower-constant-intrinsics,
-	loop(
-		loop-rotate<header-duplication;no-prepare-for-lto>,
-		loop-deletion
-	),
-	loop-distribute,
-	inject-tli-mappings,
-	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
-	loop-load-elim,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	slp-vectorizer,
-	vector-combine,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	loop-unroll<O2>,
-	transform-warning,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	loop-mssa(
-		licm<allowspeculation>
-	),
-	alignment-from-assumptions,
-	loop-sink,
-	instsimplify,
-	div-rem-pairs,
-	tailcallelim,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-globaldce,
-constmerge,
-cg-profile,
-rel-lookup-table-converter,
-function(
-	annotation-remarks
-),
-verify
-)");
-#else
-		array_add(&passes, u8R"(
-annotation2metadata,
-forceattrs,
-inferattrs,
-function<eager-inv>(
-	lower-expect,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	sroa<modify-cfg>,
-	early-cse<>
-),
-ipsccp,
-called-value-propagation,
-globalopt,
-function<eager-inv>(
-	mem2reg,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-always-inline,
-require<globals-aa>,
-function(
-	invalidate<aa>
-),
-require<profile-summary>,
-cgscc(
-	devirt<4>(
-		inline,
-		function-attrs<skip-non-recursive-function-attrs>,
-		function<eager-inv;no-rerun>(
-			sroa<modify-cfg>,
-			early-cse<memssa>,
-			speculative-execution<only-if-divergent-target>,
-			jump-threading,
-			correlated-propagation,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			aggressive-instcombine,
-			libcalls-shrinkwrap,
-			tailcallelim,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			reassociate,
-			constraint-elimination,
-			loop-mssa(
-				loop-instsimplify,
-				loop-simplifycfg,
-				licm<no-allowspeculation>,
-				loop-rotate<header-duplication;no-prepare-for-lto>,
-				licm<allowspeculation>,
-				simple-loop-unswitch<no-nontrivial;trivial>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			loop(
-				loop-idiom,
-				indvars,
-				loop-deletion,
-				loop-unroll-full
-			),
-			sroa<modify-cfg>,
-			vector-combine,
-			mldst-motion<no-split-footer-bb>,
-			gvn<>,
-			sccp,
-			bdce,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			jump-threading,
-			correlated-propagation,
-			adce,
-			memcpyopt,
-			dse,
-			move-auto-init,
-			loop-mssa(
-				licm<allowspeculation>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
-		),
-		function-attrs,
-		function(
-			require<should-not-run-function-passes>
-		)
-	)
-),
-deadargelim,
-globalopt,
-globaldce,
-elim-avail-extern,
-rpo-function-attrs,
-recompute-globalsaa,
-function<eager-inv>(
-	float2int,
-	lower-constant-intrinsics,
-	loop(
-		loop-rotate<header-duplication;no-prepare-for-lto>,
-		loop-deletion
-	),
-	loop-distribute,
-	inject-tli-mappings,
-	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
-	infer-alignment,
-	loop-load-elim,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	slp-vectorizer,
-	vector-combine,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	loop-unroll<O2>,
-	transform-warning,
-	sroa<modify-cfg>,
-	infer-alignment,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	loop-mssa(
-		licm<allowspeculation>
-	),
-	alignment-from-assumptions,
-	loop-sink,
-	instsimplify,
-	div-rem-pairs,
-	tailcallelim,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-globaldce,
-constmerge,
-cg-profile,
-rel-lookup-table-converter,
-function(
-	annotation-remarks
-),
-verify
-)");
-#endif
-		break;
-
-	case 3:
-// default<O3>
-// Passes removed: coro, openmp, sroa
-#if LLVM_VERSION_MAJOR == 17
-		array_add(&passes, u8R"(
-annotation2metadata,
-forceattrs,
-inferattrs,
-function<eager-inv>(
-	lower-expect,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	early-cse<>,
-	callsite-splitting
-),
-ipsccp,
-called-value-propagation,
-globalopt,
-function<eager-inv>(
-	mem2reg,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-require<globals-aa>,
-function(
-	invalidate<aa>
-),
-require<profile-summary>,
-cgscc(
-	devirt<4>(
-		inline<only-mandatory>,
-		inline,
-		function-attrs<skip-non-recursive>,
-		argpromotion,
-		function<eager-inv;no-rerun>(
-			early-cse<memssa>,
-			speculative-execution,
-			jump-threading,
-			correlated-propagation,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			aggressive-instcombine,
-			constraint-elimination,
-			libcalls-shrinkwrap,
-			tailcallelim,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			reassociate,
-			loop-mssa(
-				loop-instsimplify,
-				loop-simplifycfg,
-				licm<no-allowspeculation>,
-				loop-rotate<header-duplication;no-prepare-for-lto>,
-				licm<allowspeculation>,
-				simple-loop-unswitch<nontrivial;trivial>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			loop(
-				loop-idiom,
-				indvars,
-				loop-deletion,
-				loop-unroll-full
-			),
-			vector-combine,
-			mldst-motion<no-split-footer-bb>,
-			gvn<>,
-			sccp,
-			bdce,
-			instcombine<max-iterations=1000;no-use-loop-info>,
-			jump-threading,
-			correlated-propagation,
-			adce,
-			memcpyopt,
-			dse,
-			move-auto-init,
-			loop-mssa(
-				licm<allowspeculation>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1000;no-use-loop-info>
-		),
-		function-attrs,
-		function(
-			require<should-not-run-function-passes>
-		)
-	)
-),
-deadargelim,
-globalopt,
-globaldce,
-elim-avail-extern,
-rpo-function-attrs,
-recompute-globalsaa,
-function<eager-inv>(
-	float2int,
-	lower-constant-intrinsics,
-	chr,
-	loop(
-		loop-rotate<header-duplication;no-prepare-for-lto>,
-		loop-deletion
-	),
-	loop-distribute,
-	inject-tli-mappings,
-	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
-	loop-load-elim,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	slp-vectorizer,
-	vector-combine,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	loop-unroll<O3>,
-	transform-warning,
-	instcombine<max-iterations=1000;no-use-loop-info>,
-	loop-mssa(
-		licm<allowspeculation>
-	),
-	alignment-from-assumptions,
-	loop-sink,
-	instsimplify,
-	div-rem-pairs,
-	tailcallelim,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-globaldce,
-constmerge,
-cg-profile,
-rel-lookup-table-converter,
-function(
-	annotation-remarks
-),
-verify
-)");
-#else
-		array_add(&passes, u8R"(
-annotation2metadata,
-forceattrs,
-inferattrs,
-function<eager-inv>(
-	lower-expect,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	sroa<modify-cfg>,
-	early-cse<>,
-	callsite-splitting
-),
-ipsccp,
-called-value-propagation,
-globalopt,
-function<eager-inv>(
-	mem2reg,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-always-inline,
-require<globals-aa>,
-function(invalidate<aa>),
-require<profile-summary>,
-cgscc(
-	devirt<4>(
-		inline,
-		function-attrs<skip-non-recursive-function-attrs>,
-		argpromotion,
-		function<eager-inv;no-rerun>(
-			sroa<modify-cfg>,
-			early-cse<memssa>,
-			speculative-execution<only-if-divergent-target>,
-			jump-threading,
-			correlated-propagation,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			aggressive-instcombine,
-			libcalls-shrinkwrap,
-			tailcallelim,
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			reassociate,
-			constraint-elimination,
-			loop-mssa(
-				loop-instsimplify,
-				loop-simplifycfg,
-				licm<no-allowspeculation>,
-				loop-rotate<header-duplication;no-prepare-for-lto>,
-				licm<allowspeculation>,
-				simple-loop-unswitch<nontrivial;trivial>
-			),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			loop(
-				loop-idiom,
-				indvars,
-				loop-deletion,
-				loop-unroll-full
-			),
-			sroa<modify-cfg>,
-			vector-combine,
-			mldst-motion<no-split-footer-bb>,
-			gvn<>,
-			sccp,
-			bdce,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-			jump-threading,
-			correlated-propagation,
-			adce,
-			memcpyopt,
-			dse,
-			move-auto-init,
-			loop-mssa(licm<allowspeculation>),
-			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
-		),
-		function-attrs,
-		function(
-			require<should-not-run-function-passes>
-		)
-	)
-),
-deadargelim,
-globalopt,
-globaldce,
-elim-avail-extern,
-rpo-function-attrs,
-recompute-globalsaa,
-function<eager-inv>(
-	float2int,
-	lower-constant-intrinsics,
-	chr,
-	loop(
-		loop-rotate<header-duplication;no-prepare-for-lto>,
-		loop-deletion
-	),
-	loop-distribute,
-	inject-tli-mappings,
-	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
-	infer-alignment,
-	loop-load-elim,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
-	slp-vectorizer,
-	vector-combine,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	loop-unroll<O3>,
-	transform-warning,
-	sroa<preserve-cfg>,
-	infer-alignment,
-	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
-	loop-mssa(licm<allowspeculation>),
-	alignment-from-assumptions,
-	loop-sink,
-	instsimplify,
-	div-rem-pairs,
-	tailcallelim,
-	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
-),
-globaldce,
-constmerge,
-cg-profile,
-rel-lookup-table-converter,
-function(
-	annotation-remarks
-),
-verify
-)");
-#endif
-		break;
-	}
+	#include "llvm_backend_passes.cpp"
 
 
 	// asan - Linux, Darwin, Windows
 	// asan - Linux, Darwin, Windows
 	// msan - linux
 	// msan - linux
@@ -2958,13 +2168,16 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
 		LLVMInitializeWebAssemblyAsmParser();
 		LLVMInitializeWebAssemblyAsmParser();
 		LLVMInitializeWebAssemblyDisassembler();
 		LLVMInitializeWebAssemblyDisassembler();
 		break;
 		break;
+	case TargetArch_riscv64:
+		LLVMInitializeRISCVTargetInfo();
+		LLVMInitializeRISCVTarget();
+		LLVMInitializeRISCVTargetMC();
+		LLVMInitializeRISCVAsmPrinter();
+		LLVMInitializeRISCVAsmParser();
+		LLVMInitializeRISCVDisassembler();
+		break;
 	default:
 	default:
-		LLVMInitializeAllTargetInfos();
-		LLVMInitializeAllTargets();
-		LLVMInitializeAllTargetMCs();
-		LLVMInitializeAllAsmPrinters();
-		LLVMInitializeAllAsmParsers();
-		LLVMInitializeAllDisassemblers();
+		GB_PANIC("Unimplemented LLVM target initialization");
 		break;
 		break;
 	}
 	}
 
 

+ 5 - 0
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_debug_loc = lb_debug_location_from_token_pos(p, token.pos);
 	LLVMMetadataRef llvm_expr = LLVMDIBuilderCreateExpression(m->debug_builder, nullptr, 0);
 	LLVMMetadataRef llvm_expr = LLVMDIBuilderCreateExpression(m->debug_builder, nullptr, 0);
 	lb_set_llvm_metadata(m, ptr, llvm_expr);
 	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);
 	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) {
 gb_internal void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block) {

+ 1195 - 0
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<Os>
+// Passes removed: coro, openmp, sroa
+#if LLVM_VERSION_MAJOR == 17
+		array_add(&passes, u8R"(
+annotation2metadata,
+forceattrs,
+inferattrs,
+function<eager-inv>(
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	early-cse<>
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline<only-mandatory>,
+		inline,
+		function-attrs<skip-non-recursive>,
+		function<eager-inv;no-rerun>(
+			early-cse<memssa>,
+			speculative-execution,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			aggressive-instcombine,
+			constraint-elimination,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			reassociate,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<no-nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			loop(
+				loop-idiom,
+				indvars,
+				loop-deletion,
+				loop-unroll-full
+			),
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	loop-load-elim,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	loop-unroll<O2>,
+	transform-warning,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+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<eager-inv>(
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	sroa<modify-cfg>,
+	early-cse<>
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+always-inline,
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline,
+		function-attrs<skip-non-recursive-function-attrs>,
+		function<eager-inv;no-rerun>(
+			sroa<modify-cfg>,
+			early-cse<memssa>,
+			speculative-execution<only-if-divergent-target>,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			aggressive-instcombine,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			reassociate,
+			constraint-elimination,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<no-nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			loop(
+				loop-idiom,
+				indvars,
+				loop-deletion,
+				loop-unroll-full
+			),
+			sroa<modify-cfg>,
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	infer-alignment,
+	loop-load-elim,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	loop-unroll<O2>,
+	transform-warning,
+	sroa<preserve-cfg>,
+	infer-alignment,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+globaldce,
+constmerge,
+cg-profile,
+rel-lookup-table-converter,
+function(
+	annotation-remarks
+),
+verify
+)");
+#else
+	array_add(&passes, u8R"(
+annotation2metadata,
+forceattrs,
+inferattrs,
+function<eager-inv>(
+	ee-instrument<>,
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+	sroa<modify-cfg>,
+	early-cse<>
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>
+),
+always-inline,
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline,
+		function-attrs<skip-non-recursive-function-attrs>,
+		function<eager-inv;no-rerun>(
+			sroa<modify-cfg>,
+			early-cse<memssa>,
+			speculative-execution<only-if-divergent-target>,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			aggressive-instcombine,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			reassociate,
+			constraint-elimination,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<no-nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			loop(
+				loop-idiom,
+				indvars,
+				extra-simple-loop-unswitch-passes,
+				loop-deletion,loop-unroll-full
+			),
+			sroa<modify-cfg>,
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	infer-alignment,
+	loop-load-elim,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	loop-unroll<O2>,
+	transform-warning,
+	sroa<preserve-cfg>,
+	infer-alignment,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>
+),
+globaldce,
+constmerge,
+cg-profile,
+rel-lookup-table-converter,
+function(
+	annotation-remarks
+),
+verify
+)");
+
+#endif
+		break;
+// default<O2>
+// Passes removed: coro, openmp, sroa
+	case 2:
+#if LLVM_VERSION_MAJOR == 17
+		array_add(&passes, u8R"(
+annotation2metadata,
+forceattrs,
+inferattrs,
+function<eager-inv>(
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	early-cse<>
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline<only-mandatory>,
+		inline,
+		function-attrs<skip-non-recursive>,
+		function<eager-inv;no-rerun>(
+			early-cse<memssa>,
+			speculative-execution,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			aggressive-instcombine,
+			constraint-elimination,
+			libcalls-shrinkwrap,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			reassociate,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<no-nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			loop(
+				loop-idiom,
+				indvars,
+				loop-deletion,
+				loop-unroll-full
+			),
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	loop-load-elim,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	loop-unroll<O2>,
+	transform-warning,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+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<eager-inv>(
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	sroa<modify-cfg>,
+	early-cse<>
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+always-inline,
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline,
+		function-attrs<skip-non-recursive-function-attrs>,
+		function<eager-inv;no-rerun>(
+			sroa<modify-cfg>,
+			early-cse<memssa>,
+			speculative-execution<only-if-divergent-target>,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			aggressive-instcombine,
+			libcalls-shrinkwrap,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			reassociate,
+			constraint-elimination,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<no-nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			loop(
+				loop-idiom,
+				indvars,
+				loop-deletion,
+				loop-unroll-full
+			),
+			sroa<modify-cfg>,
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	infer-alignment,
+	loop-load-elim,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	loop-unroll<O2>,
+	transform-warning,
+	sroa<modify-cfg>,
+	infer-alignment,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+globaldce,
+constmerge,
+cg-profile,
+rel-lookup-table-converter,
+function(
+	annotation-remarks
+),
+verify
+)");
+#else
+	array_add(&passes, u8R"(
+annotation2metadata,
+forceattrs,
+inferattrs,
+function<eager-inv>(
+	ee-instrument<>,
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+	sroa<modify-cfg>,
+	early-cse<>
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>
+),
+always-inline,
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline,
+		function-attrs<skip-non-recursive-function-attrs>,
+		function<eager-inv;no-rerun>(
+			sroa<modify-cfg>,
+			early-cse<memssa>,
+			speculative-execution<only-if-divergent-target>,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			aggressive-instcombine,
+			libcalls-shrinkwrap,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			reassociate,
+			constraint-elimination,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<no-nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			loop(
+				loop-idiom,
+				indvars,
+				extra-simple-loop-unswitch-passes,
+				loop-deletion,
+				loop-unroll-full
+			),
+			sroa<modify-cfg>,
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	infer-alignment,
+	loop-load-elim,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	loop-unroll<O2>,
+	transform-warning,
+	sroa<preserve-cfg>,
+	infer-alignment,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>
+),
+globaldce,
+constmerge,
+cg-profile,
+rel-lookup-table-converter,
+function(
+	annotation-remarks
+),
+verify
+)");
+#endif
+		break;
+
+	case 3:
+// default<O3>
+// Passes removed: coro, openmp, sroa
+#if LLVM_VERSION_MAJOR == 17
+		array_add(&passes, u8R"(
+annotation2metadata,
+forceattrs,
+inferattrs,
+function<eager-inv>(
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	early-cse<>,
+	callsite-splitting
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline<only-mandatory>,
+		inline,
+		function-attrs<skip-non-recursive>,
+		argpromotion,
+		function<eager-inv;no-rerun>(
+			early-cse<memssa>,
+			speculative-execution,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			aggressive-instcombine,
+			constraint-elimination,
+			libcalls-shrinkwrap,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			reassociate,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			loop(
+				loop-idiom,
+				indvars,
+				loop-deletion,
+				loop-unroll-full
+			),
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1000;no-use-loop-info>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1000;no-use-loop-info>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	chr,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	loop-load-elim,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	loop-unroll<O3>,
+	transform-warning,
+	instcombine<max-iterations=1000;no-use-loop-info>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+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<eager-inv>(
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	sroa<modify-cfg>,
+	early-cse<>,
+	callsite-splitting
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+always-inline,
+require<globals-aa>,
+function(invalidate<aa>),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline,
+		function-attrs<skip-non-recursive-function-attrs>,
+		argpromotion,
+		function<eager-inv;no-rerun>(
+			sroa<modify-cfg>,
+			early-cse<memssa>,
+			speculative-execution<only-if-divergent-target>,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			aggressive-instcombine,
+			libcalls-shrinkwrap,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			reassociate,
+			constraint-elimination,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			loop(
+				loop-idiom,
+				indvars,
+				loop-deletion,
+				loop-unroll-full
+			),
+			sroa<modify-cfg>,
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(licm<allowspeculation>),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+			instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	chr,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	infer-alignment,
+	loop-load-elim,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	loop-unroll<O3>,
+	transform-warning,
+	sroa<preserve-cfg>,
+	infer-alignment,
+	instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
+	loop-mssa(licm<allowspeculation>),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
+),
+globaldce,
+constmerge,
+cg-profile,
+rel-lookup-table-converter,
+function(
+	annotation-remarks
+),
+verify
+)");
+#else
+	array_add(&passes, u8R"(
+annotation2metadata,
+forceattrs,
+inferattrs,
+function<eager-inv>(
+	ee-instrument<>,
+	lower-expect,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+	sroa<modify-cfg>,
+	early-cse<>,
+	callsite-splitting
+),
+ipsccp,
+called-value-propagation,
+globalopt,
+function<eager-inv>(
+	mem2reg,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>
+),
+always-inline,
+require<globals-aa>,
+function(
+	invalidate<aa>
+),
+require<profile-summary>,
+cgscc(
+	devirt<4>(
+		inline,
+		function-attrs<skip-non-recursive-function-attrs>,
+		argpromotion,
+		function<eager-inv;no-rerun>(
+			sroa<modify-cfg>,
+			early-cse<memssa>,
+			speculative-execution<only-if-divergent-target>,
+			jump-threading,
+			correlated-propagation,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			aggressive-instcombine,
+			libcalls-shrinkwrap,
+			tailcallelim,
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			reassociate,
+			constraint-elimination,
+			loop-mssa(
+				loop-instsimplify,
+				loop-simplifycfg,
+				licm<no-allowspeculation>,
+				loop-rotate<header-duplication;no-prepare-for-lto>,
+				licm<allowspeculation>,
+				simple-loop-unswitch<nontrivial;trivial>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			loop(
+				loop-idiom,
+				indvars,
+				extra-simple-loop-unswitch-passes,
+				loop-deletion,
+				loop-unroll-full
+			),
+			sroa<modify-cfg>,
+			vector-combine,
+			mldst-motion<no-split-footer-bb>,
+			gvn<>,
+			sccp,
+			bdce,
+			instcombine<max-iterations=1;no-verify-fixpoint>,
+			jump-threading,
+			correlated-propagation,
+			adce,
+			memcpyopt,
+			dse,
+			move-auto-init,
+			loop-mssa(
+				licm<allowspeculation>
+			),
+			simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+			instcombine<max-iterations=1;no-verify-fixpoint>
+		),
+		function-attrs,
+		function(
+			require<should-not-run-function-passes>
+		)
+	)
+),
+deadargelim,
+globalopt,
+globaldce,
+elim-avail-extern,
+rpo-function-attrs,
+recompute-globalsaa,
+function<eager-inv>(
+	float2int,
+	lower-constant-intrinsics,
+	chr,
+	loop(
+		loop-rotate<header-duplication;no-prepare-for-lto>,
+		loop-deletion
+	),
+	loop-distribute,
+	inject-tli-mappings,
+	loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
+	infer-alignment,
+	loop-load-elim,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,
+	slp-vectorizer,
+	vector-combine,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	loop-unroll<O3>,
+	transform-warning,
+	sroa<preserve-cfg>,
+	infer-alignment,
+	instcombine<max-iterations=1;no-verify-fixpoint>,
+	loop-mssa(
+		licm<allowspeculation>
+	),
+	alignment-from-assumptions,
+	loop-sink,
+	instsimplify,
+	div-rem-pairs,
+	tailcallelim,
+	simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>
+),
+globaldce,
+constmerge,
+cg-profile,
+rel-lookup-table-converter,
+function(
+	annotation-remarks
+),
+verify
+
+)");
+
+#endif
+		break;
+	}