Skip to content

Commit 379d105

Browse files
ice1000anydream
andauthored
Upgrade to llvm20 (#230)
Co-authored-by: anydream <[email protected]> Co-authored-by: Any <[email protected]>
1 parent 21569b9 commit 379d105

File tree

5 files changed

+24
-27
lines changed

5 files changed

+24
-27
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ jobs:
3232
run: |
3333
wget https://apt.llvm.org/llvm.sh
3434
chmod +x llvm.sh
35-
sudo ./llvm.sh 19 all
36-
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 160
37-
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 160
38-
sudo update-alternatives --install /usr/bin/lli lli /usr/bin/lli-19 160
39-
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-19 160
35+
sudo ./llvm.sh 20 all
36+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 160
37+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 160
38+
sudo update-alternatives --install /usr/bin/lli lli /usr/bin/lli-20 160
39+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 160
4040
4141
- name: Setup LLVM and GCC (MacOS)
4242
if: ${{ runner.os == 'macOS' }}
4343
run: |
44-
brew install llvm@19 gcc@14
45-
echo "$(brew --prefix llvm@19)/bin" >> $GITHUB_PATH
46-
echo "CC=$(brew --prefix llvm@19)/bin/clang" >> $GITHUB_ENV
47-
echo "CXX=$(brew --prefix llvm@19)/bin/clang++" >> $GITHUB_ENV
44+
brew install llvm@20 gcc@14
45+
echo "$(brew --prefix llvm@20)/bin" >> $GITHUB_PATH
46+
echo "CC=$(brew --prefix llvm@20)/bin/clang" >> $GITHUB_ENV
47+
echo "CXX=$(brew --prefix llvm@20)/bin/clang++" >> $GITHUB_ENV
4848
cd /usr/local/bin
4949
ln -s `which gcc-14` gcc
5050
@@ -65,7 +65,7 @@ jobs:
6565
- name: Build
6666
run: |
6767
mkdir build
68-
cmake -S . -B build -DLLVM_INCLUDE_TESTS=On -DLLVM_DIR=/usr/lib/llvm-19/cmake
68+
cmake -S . -B build -DLLVM_INCLUDE_TESTS=On -DLLVM_DIR=/usr/lib/llvm-20/cmake
6969
cmake --build build
7070
7171
- name: Test
@@ -84,7 +84,7 @@ jobs:
8484
uses: actions/checkout@master
8585
with:
8686
repository: llvm/llvm-project
87-
ref: llvmorg-19.1.1
87+
ref: llvmorg-20.1.8
8888

8989
- name: Checkout
9090
uses: actions/checkout@v5

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ if (NOT DEFINED LLVM_VERSION_MAJOR)
22
project(llvm-cbe)
33
set (USE_SYSTEM_LLVM 1)
44
cmake_minimum_required(VERSION 3.20.0)
5-
find_package(LLVM 19.1 REQUIRED CONFIG)
5+
find_package(LLVM 20.1 REQUIRED CONFIG)
66
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
77
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
88
message(STATUS "LLVM_INCLUDE_DIRS: ${LLVM_INCLUDE_DIRS}")

lib/Target/CBackend/CBackend.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,6 @@ raw_ostream &CWriter::printTypeString(raw_ostream &Out, Type *Ty,
316316
case Type::FP128TyID:
317317
return Out << "f128";
318318

319-
case Type::X86_MMXTyID:
320-
return Out << (isSigned ? "i32y2" : "u32y2");
321-
322319
case Type::FunctionTyID:
323320
llvm_unreachable(
324321
"printTypeString should never be called with a function type");
@@ -543,10 +540,6 @@ raw_ostream &CWriter::printSimpleType(raw_ostream &Out, Type *Ty,
543540
case Type::FP128TyID:
544541
return Out << "long double";
545542

546-
case Type::X86_MMXTyID:
547-
return Out << (isSigned ? "int32_t" : "uint32_t")
548-
<< " __attribute__((vector_size(8)))";
549-
550543
default:
551544
DBG_ERRS("Unknown primitive type: " << *Ty);
552545
errorWithMessage("unknown primitive type");
@@ -2380,7 +2373,7 @@ void CWriter::generateCompilerSpecificCode(raw_ostream &Out,
23802373
bool CWriter::doInitialization(Module &M) {
23812374
TheModule = &M;
23822375

2383-
TD = new DataLayout(&M);
2376+
TD = new DataLayout(M.getDataLayout());
23842377
IL = new IntrinsicLowering(*TD);
23852378

23862379
TAsm = new CBEMCAsmInfo();

lib/Target/CBackend/CTargetMachine.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CTargetSubtargetInfo : public TargetSubtargetInfo {
3232
public:
3333
CTargetSubtargetInfo(const TargetMachine &TM, const Triple &TT, StringRef CPU,
3434
StringRef TuneCPU, StringRef FS)
35-
: TargetSubtargetInfo(TT, CPU, TuneCPU, FS,
35+
: TargetSubtargetInfo(TT, CPU, TuneCPU, FS, ArrayRef<StringRef>(),
3636
ArrayRef<SubtargetFeatureKV>(),
3737
ArrayRef<SubtargetSubTypeKV>(), nullptr, nullptr,
3838
nullptr, nullptr, nullptr, nullptr),
@@ -42,16 +42,18 @@ class CTargetSubtargetInfo : public TargetSubtargetInfo {
4242
const CTargetLowering Lowering;
4343
};
4444

45-
class CTargetMachine : public LLVMTargetMachine {
45+
class CTargetMachine : public TargetMachine {
4646
public:
4747
CTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
4848
const TargetOptions &Options, std::optional<Reloc::Model> RM,
4949
std::optional<CodeModel::Model> CM, CodeGenOptLevel OL,
5050
bool /*JIT*/)
51-
: LLVMTargetMachine(T, "", TT, CPU, FS, Options,
52-
RM.value_or(Reloc::Static),
53-
CM.value_or(CodeModel::Small), OL),
54-
SubtargetInfo(*this, TT, CPU, "", FS) {}
51+
: TargetMachine(T, "", TT, CPU, FS, Options),
52+
SubtargetInfo(*this, TT, CPU, "", FS) {
53+
this->RM = RM.value_or(Reloc::Static);
54+
this->CMModel = CM.value_or(CodeModel::Small);
55+
this->OptLevel = OL;
56+
}
5557

5658
/// Add passes to the specified pass manager to get the specified file
5759
/// emitted. Typically this will involve several steps of code generation.

tools/llvm-cbe/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ if(USE_SYSTEM_LLVM)
3535
CBackendCodeGen
3636
CBackendInfo
3737
)
38-
target_link_libraries(llvm-cbe LLVM ${llvm_libs})
38+
target_link_libraries(llvm-cbe
39+
LLVM
40+
${llvm_libs})
3941
endif()

0 commit comments

Comments
 (0)