Skip to content

Commit

Permalink
Merge pull request #563 from hvdijk/remove-llvm-17
Browse files Browse the repository at this point in the history
Remove LLVM 17 support.
  • Loading branch information
hvdijk authored Oct 14, 2024
2 parents 395fd92 + bbfacf0 commit 1d3a925
Show file tree
Hide file tree
Showing 33 changed files with 70 additions and 283 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup_ubuntu_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ inputs:
description: 'llvm Build type (Release, RelAssert) - note we need to use RelAssert for the cache pattern matching'
default: RelAssert
llvm_version:
description: 'Major llvm version to use for fetching llvm cache e.g. 17'
default: 17
description: 'Major llvm version to use for fetching llvm cache e.g. 18'
default: 18
ubuntu_version:
description: 'Version of ubuntu used for cache retrieval and prerequisites'
default: 22.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_pr_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

# installs tools, ninja and installs llvm (default 17, RelAssert) and sets up cache
# installs tools, ninja and installs llvm (default 18, RelAssert) and sets up cache
- name: setup-ubuntu
uses: ./.github/actions/setup_ubuntu_build
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

# installs tools, ninja and installs llvm (default 17, RelAssert) and sets up cache
# installs tools, ninja and installs llvm (default 18, RelAssert) and sets up cache
- name: setup-ubuntu
uses: ./.github/actions/setup_ubuntu_build
with:
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

# installs tools, ninja and installs llvm (default 17, RelAssert) and sets up cache
# installs tools, ninja and installs llvm (default 18, RelAssert) and sets up cache
- name: setup-ubuntu
uses: ./.github/actions/setup_ubuntu_build
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/create_llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ jobs:
create_llvm_cache:
strategy:
matrix:
version: [17, 18]
version: [18, 19]
os: [ubuntu-22.04, windows-2019]
build_type: [Release, RelAssert]
arch : [x86, x86_64, aarch64]
exclude:
# Reduce the versions of llvm for aarch64 & x86 architectures and windows, as
# well as any windows os variants to reduce cache usage.
- arch: aarch64
version: 17
version: 18
- arch: aarch64
build_type: Release
- arch: x86
version: 17
version: 18
- arch: x86
build_type: Release
- os: windows-2019
version: 17
version: 18
- os: windows-2019
build_type: Release
- os: windows-2019
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_publish_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup ubuntu
uses: ./.github/actions/setup_ubuntu_build
with:
llvm_version: 17
llvm_version: 18
llvm_build_type: Release

- name: Setup python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_ock_demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: setup ubuntu
uses: ./.github/actions/setup_ubuntu_build
with:
llvm_version: 17
llvm_version: 18
llvm_build_type: RelAssert

- name: setup python
Expand Down
63 changes: 5 additions & 58 deletions cmake/DetectLLVMMSVCCRT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,63 +34,10 @@ endif()

# LLVM 18 uses the CMake default setting, which depends on the mode LLVM
# was built in, not the mode we were built in.
if(LLVM_VERSION_MAJOR GREATER_EQUAL 18)
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if(LLVM_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if(LLVM_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
return()
endif()

# Get the directory of cl.exe
get_filename_component(tools_dir "${CMAKE_C_COMPILER}" DIRECTORY)

# Find the dumpbin.exe executable in the directory of cl.exe
find_program(dumpbin "dumpbin.exe" PATHS "${tools_dir}" NO_DEFAULT_PATH)

if("${dumpbin}" STREQUAL "dumpbin-NOTFOUND")
message(WARNING "Could not detect which CRT LLVM was built against - "
"could not find 'dumpbin.exe'.")
return()
endif()

# Get the location in the file-system of LLVMCore.lib
get_target_property(llvmcore LLVMCore LOCATION)

if("${llvmcore}" STREQUAL "llvmcore-NOTFOUND")
message(WARNING "Could not detect which CRT LLVM was built against - "
"could not find location of 'LLVMCore.lib'.")
return()
endif()

# Get the directives that LLVMCore.lib contains
execute_process(COMMAND "${dumpbin}" "/DIRECTIVES" "${llvmcore}"
OUTPUT_VARIABLE output)

# Find the first directive specifying what CRT to use
string(FIND "${output}" "/FAILIFMISMATCH:RuntimeLibrary=" position)

# Strip away everything but the directive we want to examine
string(SUBSTRING "${output}" ${position} 128 output)

# Remove the directive prefix which we don't need
string(REPLACE "/FAILIFMISMATCH:RuntimeLibrary=" "" output "${output}")

# Get the position of the '_' character that breaks the CRT from all else
string(FIND "${output}" "_" position)

# Substring output to be one of the four CRT values: MDd MD MTd MT
string(SUBSTRING "${output}" 0 ${position} output)

# Set all possible CMAKE_BUILD_TYPE's to the CRT that LLVM was linked against
set(LLVM_USE_CRT_DEBUG "${output}")
set(LLVM_USE_CRT_RELWITHDEBINFO "${output}")
set(LLVM_USE_CRT_MINSIZEREL "${output}")
set(LLVM_USE_CRT_RELEASEASSERT "${output}")
set(LLVM_USE_CRT_RELEASE "${output}")

# Include the LLVM cmake module to choose the correct CRT for our libraries
include(ChooseMSVCCRT)
4 changes: 2 additions & 2 deletions cmake/ImportLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ include(DetectLLVMMSVCCRT)
:cmake:variable:`LLVM_PACKAGE_VERSION` from the imported LLVM install is
a supported version.
#]=======================================================================]
set(CA_LLVM_MINIMUM_VERSION 17.0.0)
set(CA_LLVM_MAXIMUM_VERSION 18)
set(CA_LLVM_MINIMUM_VERSION 18.0.0)
set(CA_LLVM_MAXIMUM_VERSION 19)
string(REPLACE ";" "', '" CA_LLVM_VERSIONS_PRETTY "${CA_LLVM_VERSIONS}")
if("${LLVM_PACKAGE_VERSION}" VERSION_LESS "${CA_LLVM_MINIMUM_VERSION}")
message(FATAL_ERROR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,7 @@ Function *cloneFunctionUpdatingTypes(Function &func,

// Take attributes of old function
newFunc->takeName(&func);
#if LLVM_VERSION_GREATER_EQUAL(18, 0)
newFunc->updateAfterNameChange();
#else
newFunc->recalculateIntrinsicID();
#endif
newFunc->setCallingConv(func.getCallingConv());

assert(func.isIntrinsic() == newFunc->isIntrinsic() &&
Expand Down
4 changes: 0 additions & 4 deletions modules/compiler/compiler_pipeline/source/barrier_regions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,11 +971,7 @@ void compiler::utils::Barrier::MakeLiveVariableMemType() {

// Check if the alloca has a debug info source variable attached. If
// so record this and the matching byte offset into the struct.
#if LLVM_VERSION_GREATER_EQUAL(18, 0)
auto DbgIntrinsics = findDbgDeclares(member.value);
#else
auto DbgIntrinsics = FindDbgDeclareUses(member.value);
#endif
for (auto DII : DbgIntrinsics) {
if (auto dbgDeclare = dyn_cast<DbgDeclareInst>(DII)) {
debug_intrinsics_.push_back(std::make_pair(dbgDeclare, offset));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,7 @@ PreservedAnalyses compiler::utils::ManualTypeLegalizationPass::run(
auto *&FPExt = FPExtVals[{V, ExtTy}];
if (!FPExt) {
if (auto *I = dyn_cast<Instruction>(V)) {
#if LLVM_VERSION_GREATER_EQUAL(18, 0)
std::optional<BasicBlock::iterator> IPAD;
IPAD = I->getInsertionPointAfterDef();
#else
std::optional<Instruction *> IPAD;
if (auto *IPADRaw = I->getInsertionPointAfterDef()) {
IPAD = IPADRaw;
}
#endif
auto IPAD = I->getInsertionPointAfterDef();
assert(IPAD &&
"getInsertionPointAfterDef() should return an insertion point "
"for all FP16 instructions");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ static llvm::TargetMachine *createTargetMachine(const {{cookiecutter.target_name
return llvm_target->createTargetMachine(
target.llvm_triple, target.llvm_cpu, target.llvm_features, options,
{{cookiecutter.link_shared}} ? llvm::Reloc::Model::PIC_ : llvm::Reloc::Model::Static,
llvm::CodeModel::Small,
multi_llvm::CodeGenOptLevel::Aggressive);
llvm::CodeModel::Small, llvm::CodeGenOptLevel::Aggressive);
}

llvm::TargetMachine *{{cookiecutter.target_name.capitalize()}}Module::getTargetMachine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@
#include <hal.h>

#include <llvm/Target/TargetMachine.h>
#include <llvm/TargetParser/Host.h>
#include <multi_llvm/multi_llvm.h>
#include <{{cookiecutter.target_name}}/device_info.h>
#include <{{cookiecutter.target_name}}/module.h>
#include <{{cookiecutter.target_name}}/target.h>
#include "{{cookiecutter.target_name}}/module.h"

#if LLVM_VERSION_GREATER_EQUAL(18, 0)
#include <llvm/TargetParser/Host.h>
#else
#include <llvm/Support/Host.h>
#endif

namespace {{cookiecutter.target_name}} {
{{cookiecutter.target_name.capitalize()}}Target::{{cookiecutter.target_name.capitalize()}}Target(const compiler::Info *compiler_info,
compiler::Context *context,
Expand Down
41 changes: 0 additions & 41 deletions modules/compiler/multi_llvm/include/multi_llvm/basicblock_helper.h

This file was deleted.

46 changes: 0 additions & 46 deletions modules/compiler/multi_llvm/include/multi_llvm/enums.h

This file was deleted.

13 changes: 5 additions & 8 deletions modules/compiler/multi_llvm/include/multi_llvm/loop_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// under the License.
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef MULTI_LLVM_LOOP_UTILS_H_INCLUDED
#define MULTI_LLVM_LOOP_UTILS_H_INCLUDED

Expand All @@ -21,17 +22,13 @@

namespace multi_llvm {

inline llvm::Value *createSimpleTargetReduction(
llvm::IRBuilderBase &B, const llvm::TargetTransformInfo *TTI,
llvm::Value *Src, llvm::RecurKind RdxKind) {
inline llvm::Value *createSimpleReduction(llvm::IRBuilderBase &B,
llvm::Value *Src,
llvm::RecurKind RdxKind) {
#if LLVM_VERSION_MAJOR >= 20
(void)TTI;
return llvm::createSimpleReduction(B, Src, RdxKind);
#elif LLVM_VERSION_MAJOR >= 18
(void)TTI;
return llvm::createSimpleTargetReduction(B, Src, RdxKind);
#else
return llvm::createSimpleTargetReduction(B, TTI, Src, RdxKind);
return llvm::createSimpleTargetReduction(B, Src, RdxKind);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef MULTI_LLVM_MULTI_LLVM_H_INCLUDED
#define MULTI_LLVM_MULTI_LLVM_H_INCLUDED

#include <multi_llvm/enums.h>
#include <multi_llvm/llvm_version.h>
#include <multi_llvm/loop_utils.h>

Expand Down
2 changes: 1 addition & 1 deletion modules/compiler/riscv/source/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static llvm::TargetMachine *createTargetMachine(
target.llvm_triple, target.llvm_cpu, target.llvm_features, options,
target.riscv_hal_device_info->link_shared ? llvm::Reloc::Model::PIC_
: llvm::Reloc::Model::Static,
llvm::CodeModel::Small, multi_llvm::CodeGenOptLevel::Aggressive);
llvm::CodeModel::Small, llvm::CodeGenOptLevel::Aggressive);
}

llvm::TargetMachine *riscv::RiscvModule::getTargetMachine() {
Expand Down
12 changes: 5 additions & 7 deletions modules/compiler/source/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,11 @@ endif()
set(CLANG_LIBS "clangCodeGen" "clangFrontend" "clangDriver"
"clangParse" "clangSerialization" "clangSema"
"clangAnalysis" "clangAST" "clangEdit" "clangASTMatchers"
"clangLex" "clangBasic" "clangSupport")
set(LLVM_LIBS "LLVMCodeGen" "LLVMOption" "LLVMCoroutines" "LLVMCoverage"
"LLVMLTO" "LLVMWindowsDriver" "LLVMFrontendHLSL")
if(LLVM_VERSION_MAJOR GREATER_EQUAL 18)
list(APPEND CLANG_LIBS "clangAPINotes" "clangBasic")
list(APPEND LLVM_LIBS "LLVMFrontendDriver")
endif()
"clangLex" "clangBasic" "clangSupport" "clangAPINotes"
"clangBasic")
set(LLVM_LIBS "LLVMCodeGen" "LLVMCoroutines" "LLVMCoverage"
"LLVMFrontendDriver" "LLVMFrontendHLSL" "LLVMLTO" "LLVMOption"
"LLVMWindowsDriver")

# In-tree, we should have each of these library targets available.
# Otherwise, we have to provide the full path to them.
Expand Down
Loading

0 comments on commit 1d3a925

Please sign in to comment.