Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set minimum LLVM to 15+ #2074

Merged
merged 19 commits into from
Sep 11, 2024
8 changes: 2 additions & 6 deletions .github/workflows/bcload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
fail-fast: false
matrix:
# BCLoad tests only run with old pass manager [aka up to and including 13]
llvm: ["11", "12", "13"]
llvm: ["15"]
build: ["Release"] # "RelWithDebInfo"
os: [ubuntu-20.04]
os: [ubuntu-22.04]

timeout-minutes: 30
steps:
Expand All @@ -23,10 +23,6 @@ jobs:
sudo apt-add-repository "deb http://apt.llvm.org/`lsb_release -c | cut -f2`/ llvm-toolchain-`lsb_release -c | cut -f2`-${{ matrix.llvm }} main" || true
sudo apt-get install -y cmake gcc g++ llvm-${{ matrix.llvm }}-dev clang-${{ matrix.llvm }} libclang-${{ matrix.llvm }}-dev
sudo python3 -m pip install --upgrade pip lit
if [[ '${{ matrix.llvm }}' == '13' ]]; then
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v4
- name: mkdir
run: cd enzyme && rm -rf build && mkdir build
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: ["13", "14", "15", "16"]
llvm: ["16", "17", "18"]
build: ["Release", "Debug"] # "RelWithDebInfo"
os: [openstack18]
timeout-minutes: 120
Expand All @@ -33,10 +33,6 @@ jobs:
sudo apt-get install -y python3-pip autoconf cmake gcc g++ libtool gfortran libblas-dev llvm-${{ matrix.llvm }}-dev clang-${{ matrix.llvm }} libeigen3-dev libboost-dev
sudo python3 -m pip install lit pathlib
sudo touch /usr/lib/llvm-${{ matrix.llvm }}/bin/yaml-bench
if [[ '${{ matrix.llvm }}' == '13' ]]; then
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: ["11", "12", "13", "14", "15", "16", "17"]
llvm: ["15", "16", "17", "18"]
build: ["Release"] # "RelWithDebInfo"
os: [ubuntu-20.04]

Expand All @@ -31,10 +31,6 @@ jobs:
sudo apt-add-repository "deb http://apt.llvm.org/`lsb_release -c | cut -f2`/ llvm-toolchain-`lsb_release -c | cut -f2`-${{ matrix.llvm }} main" || true
sudo apt-get install -y cmake gcc g++ llvm-${{ matrix.llvm }}-dev libomp-${{ matrix.llvm }}-dev lld-${{ matrix.llvm }} clang-${{ matrix.llvm }} libclang-${{ matrix.llvm }}-dev libeigen3-dev libboost-dev libzstd-dev
sudo python3 -m pip install --upgrade pip lit
if [[ '${{ matrix.llvm }}' == '13' ]]; then
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
docs:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/enzyme-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: ["11", "12", "13", "14", "15", "16"]
llvm: ["15", "16"]
build: ["Release", "Debug"] # "RelWithDebInfo"
os: [ubuntu-20.04]
os: [ubuntu-22.04]

timeout-minutes: 30

Expand All @@ -28,10 +28,6 @@ jobs:
sudo apt-add-repository "deb http://apt.llvm.org/`lsb_release -c | cut -f2`/ llvm-toolchain-`lsb_release -c | cut -f2`-${{ matrix.llvm }} main" || true
sudo apt-get install -y cmake gcc g++ llvm-${{ matrix.llvm }}-dev libzstd-dev
sudo python3 -m pip install --upgrade pip lit
if [[ '${{ matrix.llvm }}' == '13' ]]; then
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
Expand Down Expand Up @@ -61,7 +57,7 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: ["12", "13", "14", "15", "16"]
llvm: ["15", "16"]
build: ["Release", "Debug"] # "RelWithDebInfo"

timeout-minutes: 30
Expand Down Expand Up @@ -100,7 +96,7 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: ["13"] #, "14"]
llvm: ["16"]
build: ["Release"] # "RelWithDebInfo"

timeout-minutes: 30
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/enzyme-julia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.7'
- '1.8'
- '1.10'
os:
- ubuntu-latest
- macOS-latest
Expand All @@ -31,7 +29,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: 'wsmoses/Enzyme.jl'
repository: 'EnzymeAD/Enzyme.jl'
path: ./jl
ref: main
- uses: julia-actions/setup-julia@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
token: ${{ steps.generate_token.outputs.token }}
reviewers: vchuravy
branch: enzyme/${{ github.ref }}
body: "Automatic PR generated for https://github.com/wsmoses/Enzyme "
body: "Automatic PR generated for https://github.com/EnzymeAD/Enzyme "
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
Expand Down
4 changes: 2 additions & 2 deletions .packaging/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repo = "https://github.com/EnzymeAD/Enzyme.git"
auto_version = "%ENZYME_VERSION%"
version = VersionNumber(split(auto_version, "/")[end])

llvm_versions = [v"11.0.1", v"12.0.1", v"13.0.1", v"14.0.2", v"15.0.7", v"16.0.6", v"17.0.6"]
llvm_versions = [v"15.0.7", v"16.0.6", v"17.0.6"]

# Collection of sources required to build attr
sources = [
Expand Down Expand Up @@ -167,6 +167,6 @@ for (i,build) in enumerate(builds)
build_tarballs(i == lastindex(builds) ? non_platform_ARGS : non_reg_ARGS,
name, version, sources, script,
build.platforms, build.products, build.dependencies;
preferred_gcc_version=build.gcc_version, julia_compat="1.6",
preferred_gcc_version=build.gcc_version, julia_compat="1.10",
augment_platform_block, lazy_artifacts=true) # drop when julia_compat >= 1.7
end
10 changes: 0 additions & 10 deletions enzyme/BCLoad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ set_target_properties(blasheaders PROPERTIES EXCLUDE_FROM_ALL TRUE)
endif()

if ((NOT ("${BC_LOAD_HEADER}" STREQUAL "")) OR ${Clang_FOUND})
if (${LLVM_VERSION_MAJOR} LESS 8)
add_llvm_loadable_module( BCPass-${LLVM_VERSION_MAJOR}
BCLoader.cpp ClangBCLoader.cpp
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)
else()
# on windows `PLUGIN_TOOL` doesn't link against LLVM.dll
if ((WIN32 OR CYGWIN) AND LLVM_LINK_LLVM_DYLIB)
add_llvm_library( BCPass-${LLVM_VERSION_MAJOR}
Expand All @@ -112,7 +103,6 @@ else()
BUILDTREE_ONLY
)
endif()
endif()

add_dependencies(BCPass-${LLVM_VERSION_MAJOR} blasheaders)
target_include_directories(BCPass-${LLVM_VERSION_MAJOR} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gsl)
Expand Down
17 changes: 2 additions & 15 deletions enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ message("LLVM_INCLUDE_DIRS: ${LLVM_INCLUDE_DIRS}")
message("found LLVM definitions " ${LLVM_DEFINITIONS})
message("found LLVM version " ${LLVM_VERSION_MAJOR})

if(LLVM_VERSION_MAJOR LESS 9)
message(FATAL_ERROR "LLVM version < 9 is not supported")
if(LLVM_VERSION_MAJOR LESS 15)
message(FATAL_ERROR "LLVM version < 15 is not supported")
endif()

option(ENZYME_FLANG_VERSION "Build for non-version compliant FLANG" OFF)
Expand Down Expand Up @@ -257,20 +257,7 @@ file(READ ${LLVM_IDIR}/llvm/Analysis/TargetLibraryInfo.h INPUT_TEXT)
string(REPLACE "class TargetLibraryInfo {" "class TargetLibraryInfo {public:" INPUT_TEXT "${INPUT_TEXT}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/SCEV/TargetLibraryInfo.h" "${INPUT_TEXT}")

if (${LLVM_VERSION_MAJOR} GREATER_EQUAL 11)
file(READ ${LLVM_IDIR}/llvm/Transforms/Utils/ScalarEvolutionExpander.h INPUT_TEXT)
else()
file(READ ${LLVM_IDIR}/llvm/Analysis/ScalarEvolutionExpander.h INPUT_TEXT)
endif()

if (${LLVM_VERSION_MAJOR} LESS 12)
string(REPLACE "#define LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H" "#define LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H\n#include \"SCEV/ScalarEvolution.h\"" INPUT_TEXT "${INPUT_TEXT}")
string(REPLACE "LLVM_ANALYSIS" "FAKELLVM_ANALYSIS" INPUT_TEXT "${INPUT_TEXT}")
string(REPLACE "class SCEVExpander " "namespace fake {\n class SCEVExpander " INPUT_TEXT "${INPUT_TEXT}")
string(REPLACE "struct SCEVOperand " "namespace fake {\n struct SCEVOperand " INPUT_TEXT "${INPUT_TEXT}")
string(REPLACE "};\n}" "};\n}}" INPUT_TEXT "${INPUT_TEXT}")
string(REPLACE "const SCEV* S;\n};\n" "const SCEV* S;\n};\n}\n" INPUT_TEXT "${INPUT_TEXT}")
endif()

find_library(MPFR_LIB_PATH mpfr)
CHECK_INCLUDE_FILE("mpfr.h" HAS_MPFR_H)
Expand Down
44 changes: 5 additions & 39 deletions enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@

using namespace llvm;

#if LLVM_VERSION_MAJOR >= 14
#define addAttribute addAttributeAtIndex
#define removeAttribute removeAttributeAtIndex
#define getAttribute getAttributeAtIndex
#define hasAttribute hasAttributeAtIndex
#endif

extern "C" {
cl::opt<bool>
Expand Down Expand Up @@ -301,9 +299,7 @@ const StringSet<> KnownInactiveFunctions = {
};

const std::set<Intrinsic::ID> KnownInactiveIntrinsics = {
#if LLVM_VERSION_MAJOR >= 12
Intrinsic::experimental_noalias_scope_decl,
#endif
Intrinsic::objectsize,
Intrinsic::floor,
Intrinsic::ceil,
Expand Down Expand Up @@ -559,12 +555,7 @@ bool ActivityAnalyzer::isFunctionArgumentConstant(CallInst *CI, Value *val) {

bool all_inactive = val != CI->getCalledOperand();

#if LLVM_VERSION_MAJOR >= 14
for (size_t i = 0; i < CI->arg_size(); i++)
#else
for (size_t i = 0; i < CI->getNumArgOperands(); i++)
#endif
{
for (size_t i = 0; i < CI->arg_size(); i++) {
if (val == CI->getArgOperand(i)) {
if (!CI->getAttributes().hasParamAttr(i, "enzyme_inactive") &&
!(F && F->getCallingConv() == CI->getCallingConv() &&
Expand Down Expand Up @@ -663,12 +654,7 @@ static inline void propagateArgumentInformation(
}

if (Name == "julia.call" || Name == "julia.call2") {
#if LLVM_VERSION_MAJOR >= 14
for (size_t i = 1; i < CI.arg_size(); i++)
#else
for (size_t i = 1; i < CI.getNumArgOperands(); i++)
#endif
{
for (size_t i = 1; i < CI.arg_size(); i++) {
propagateFromOperand(CI.getOperand(i));
}
return;
Expand Down Expand Up @@ -707,12 +693,7 @@ static inline void propagateArgumentInformation(
// For other calls, check all operands of the instruction
// as conservatively they may impact the activity of the call
size_t i = 0;
#if LLVM_VERSION_MAJOR >= 14
for (auto &a : CI.args())
#else
for (auto &a : CI.arg_operands())
#endif
{
for (auto &a : CI.args()) {

if (CI.getAttributes().hasParamAttr(i, "enzyme_inactive") ||
(F && F->getCallingConv() == CI.getCallingConv() &&
Expand Down Expand Up @@ -1941,13 +1922,8 @@ bool ActivityAnalyzer::isConstantValue(TypeResults const &TR, Value *Val) {
}
}

#if LLVM_VERSION_MAJOR >= 12
auto AARes = AA.getModRefInfo(
I, MemoryLocation(memval, LocationSize::beforeOrAfterPointer()));
#else
auto AARes =
AA.getModRefInfo(I, MemoryLocation(memval, LocationSize::unknown()));
#endif

// Still having failed to replace the location used by AA, fall back to
// getModref against any location.
Expand Down Expand Up @@ -2974,12 +2950,7 @@ bool ActivityAnalyzer::isValueInactiveFromUsers(TypeResults const &TR,
auto F = getFunctionFromCall(call);

size_t idx = 0;
#if LLVM_VERSION_MAJOR >= 14
for (auto &arg : call->args())
#else
for (auto &arg : call->arg_operands())
#endif
{
for (auto &arg : call->args()) {
if (arg != parent) {
idx++;
continue;
Expand Down Expand Up @@ -3138,12 +3109,7 @@ bool ActivityAnalyzer::isValueInactiveFromUsers(TypeResults const &TR,
if (isa<LoadInst>(operand)) {
bool legal = true;

#if LLVM_VERSION_MAJOR >= 14
for (unsigned i = 0; i < call->arg_size() + 1; ++i)
#else
for (unsigned i = 0; i < call->getNumArgOperands() + 1; ++i)
#endif
{
for (unsigned i = 0; i < call->arg_size() + 1; ++i) {
Value *a = call->getOperand(i);

if (isa<ConstantInt>(a))
Expand Down
5 changes: 0 additions & 5 deletions enzyme/Enzyme/ActivityAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@
#include <deque>

#include <llvm/Config/llvm-config.h>
#if LLVM_VERSION_MAJOR >= 16
#define private public
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#undef private
#else
#include "SCEV/ScalarEvolution.h"
#include "SCEV/ScalarEvolutionExpander.h"
#endif

#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/IR/Constants.h"
Expand Down
13 changes: 0 additions & 13 deletions enzyme/Enzyme/ActivityAnalysisPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@
//===----------------------------------------------------------------------===//
#include <llvm/Config/llvm-config.h>

#if LLVM_VERSION_MAJOR >= 16
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#else
#include "SCEV/ScalarEvolution.h"
#include "SCEV/ScalarEvolutionExpander.h"
#endif

#include "llvm/ADT/SmallVector.h"

Expand Down Expand Up @@ -90,18 +85,14 @@ bool printActivityAnalysis(llvm::Function &F, TargetLibraryInfo &TLI) {
dt = ConcreteType(a.getType()->getScalarType());
} else if (a.getType()->isPointerTy()) {
#if LLVM_VERSION_MAJOR < 17
#if LLVM_VERSION_MAJOR >= 13
if (a.getContext().supportsTypedPointers()) {
#endif
auto et = a.getType()->getPointerElementType();
if (et->isFPOrFPVectorTy()) {
dt = TypeTree(ConcreteType(et->getScalarType())).Only(-1, nullptr);
} else if (et->isPointerTy()) {
dt = TypeTree(ConcreteType(BaseType::Pointer)).Only(-1, nullptr);
}
#if LLVM_VERSION_MAJOR >= 13
}
#endif
#endif
} else if (a.getType()->isIntOrIntVectorTy()) {
dt = ConcreteType(BaseType::Integer);
Expand All @@ -119,18 +110,14 @@ bool printActivityAnalysis(llvm::Function &F, TargetLibraryInfo &TLI) {
dt = ConcreteType(F.getReturnType()->getScalarType());
} else if (F.getReturnType()->isPointerTy()) {
#if LLVM_VERSION_MAJOR < 17
#if LLVM_VERSION_MAJOR >= 13
if (F.getContext().supportsTypedPointers()) {
#endif
auto et = F.getReturnType()->getPointerElementType();
if (et->isFPOrFPVectorTy()) {
dt = TypeTree(ConcreteType(et->getScalarType())).Only(-1, nullptr);
} else if (et->isPointerTy()) {
dt = TypeTree(ConcreteType(BaseType::Pointer)).Only(-1, nullptr);
}
#if LLVM_VERSION_MAJOR >= 13
}
#endif
#endif
} else if (F.getReturnType()->isIntOrIntVectorTy()) {
dt = ConcreteType(BaseType::Integer);
Expand Down
Loading
Loading