Skip to content

Commit

Permalink
Add support for LLVM 17 (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottslaughter committed Nov 21, 2023
1 parent 4282b6a commit 97c21b0
Show file tree
Hide file tree
Showing 21 changed files with 531 additions and 29 deletions.
1 change: 1 addition & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ freebsd_task:
# LLVM_VERSION: 14
LLVM_VERSION: 15
LLVM_VERSION: 16
LLVM_VERSION: 17
install_script: pkg install -y bash coreutils cmake gmake llvm$LLVM_VERSION
script: |
export CC=cc
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
strategy:
matrix:
os: ['macos-11', 'windows-2022']
llvm: ['11', '12', '13', '14', '15', '16']
llvm: ['11', '12', '13', '14', '15', '16', '17']
cuda: ['0', '1']
lua: ['luajit', 'moonjit']
exclude:
# macOS: exclude cuda
- os: 'macos-11'
cuda: '1'

# Windows: exclude LLVM 12-16
# Windows: exclude LLVM 12-17
- os: 'windows-2022'
llvm: '12'
- os: 'windows-2022'
Expand All @@ -39,6 +39,8 @@ jobs:
llvm: '15'
- os: 'windows-2022'
llvm: '16'
- os: 'windows-2022'
llvm: '17'

# CUDA: only LLVM 11
- llvm: '12'
Expand All @@ -51,6 +53,8 @@ jobs:
cuda: '1'
- llvm: '16'
cuda: '1'
- llvm: '17'
cuda: '1'

# Moonjit: only LLVM 12
- llvm: '11'
Expand All @@ -63,6 +67,8 @@ jobs:
lua: 'moonjit'
- llvm: '16'
lua: 'moonjit'
- llvm: '17'
lua: 'moonjit'
steps:
- uses: actions/checkout@v1
- run: ./travis.sh
Expand All @@ -87,7 +93,7 @@ jobs:
strategy:
matrix:
distro: ['ubuntu-18.04']
llvm: ['11', '12.0.1', '13.0.1', '14.0.6', '15.0.2', '16.0.3']
llvm: ['11', '12.0.1', '13.0.1', '14.0.6', '15.0.2', '16.0.3', '17.0.5']
lua: ['luajit', 'moonjit']
cuda: ['0', '1']
test: ['1']
Expand All @@ -103,6 +109,8 @@ jobs:
cuda: '1'
- llvm: '16.0.3'
cuda: '1'
- llvm: '17.0.5'
cuda: '1'

# Moonjit with LLVM 14 only:
- llvm: '11'
Expand All @@ -115,6 +123,8 @@ jobs:
lua: 'moonjit'
- llvm: '16.0.3'
lua: 'moonjit'
- llvm: '17.0.5'
lua: 'moonjit'

include:
# Defaults:
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased Changes (Intended to be Version 1.2.0)

## Added features

* Support for LLVM 17

## Fixed Bugs

* Updated LuaJIT to obtain fix for passing large arrays on macOS M1
Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ list(APPEND TERRA_LIB_SRC
tcompilerstate.h
tllvmutil.cpp tllvmutil.h
tcwrapper.cpp tcwrapper.h
tinline.cpp tinline.h
terra.cpp
lparser.cpp lparser.h
lstring.cpp lstring.h
Expand All @@ -99,6 +98,12 @@ list(APPEND TERRA_LIB_SRC
${PROJECT_BINARY_DIR}/include/terra/terra.h
)

if(LLVM_VERSION_MAJOR LESS 17)
list(APPEND TERRA_LIB_SRC
tinline.cpp tinline.h
)
endif()

list(APPEND TERRA_BIN_SRC
main.cpp
linenoise.cpp linenoise.h
Expand Down
19 changes: 15 additions & 4 deletions src/llvmheaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Vectorize.h"
#if LLVM_VERSION < 170
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#else
#include "llvm/Passes/PassBuilder.h"
#endif
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/Support/DynamicLibrary.h"
Expand All @@ -56,11 +60,13 @@
#include "llvmheaders_150.h"
#elif LLVM_VERSION < 170
#include "llvmheaders_160.h"
#elif LLVM_VERSION < 180
#include "llvmheaders_170.h"
#else
#error "unsupported LLVM version"
// for OSX code completion
#define LLVM_VERSION 160
#include "llvmheaders_160.h"
#define LLVM_VERSION 170
#include "llvmheaders_170.h"
#endif

#define UNIQUEIFY(T, x) (std::unique_ptr<T>(x))
Expand All @@ -69,13 +75,18 @@
#define FD_ERRSTR(x) ((x).message().c_str())
#define METADATA_ROOT_TYPE llvm::Metadata

#if LLVM_VERSION < 170
using llvm::legacy::FunctionPassManager;
using llvm::legacy::PassManager;
typedef llvm::legacy::PassManager PassManagerT;
typedef llvm::legacy::FunctionPassManager FunctionPassManagerT;
#else
using llvm::FunctionPassManager;
#endif

typedef llvm::raw_pwrite_stream emitobjfile_t;
typedef llvm::DIFile* DIFileP;

inline void LLVMDisposeMessage(char* Message) { free(Message); }
typedef llvm::legacy::PassManager PassManagerT;
typedef llvm::legacy::FunctionPassManager FunctionPassManagerT;

#endif
34 changes: 34 additions & 0 deletions src/llvmheaders_170.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Mangler.h"
//#include "llvm/ExecutionEngine/ObjectImage.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Linker/Linker.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"

#include "llvm/Support/VirtualFileSystem.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Rewrite/Frontend/Rewriters.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Object/SymbolSize.h"

#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Support/Error.h"

#define LLVM_PATH_TYPE std::string
#define RAW_FD_OSTREAM_NONE sys::fs::OF_None
#define RAW_FD_OSTREAM_BINARY sys::fs::OF_None
Loading

0 comments on commit 97c21b0

Please sign in to comment.