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

Upgrade to LLVM 19 #731

Merged
merged 19 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/22.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG IMAGE="ubuntu-22.04"
ARG LLVM_VERSION="18"
ARG LLVM_VERSION="19"

FROM mcr.microsoft.com/vscode/devcontainers/cpp:${IMAGE}
ARG LLVM_VERSION
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"python": "os-provided"
},
"containerEnv": {
"CMAKE_PREFIX_PATH": "/usr/lib/llvm-18/lib/cmake/mlir/;/usr/lib/llvm-18/lib/cmake/clang/",
"CMAKE_PREFIX_PATH": "/usr/lib/llvm-19/lib/cmake/mlir/;/usr/lib/llvm-19/lib/cmake/clang/",
"LLVM_EXTERNAL_LIT": "/usr/local/bin/lit"
}

Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/install-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ usage() {
exit 1;
}

CURRENT_LLVM_STABLE=18
CURRENT_LLVM_STABLE=19
BASE_URL="http://apt.llvm.org"

# Check for required tools
Expand Down Expand Up @@ -118,6 +118,7 @@ LLVM_VERSION_PATTERNS[15]="-15"
LLVM_VERSION_PATTERNS[16]="-16"
LLVM_VERSION_PATTERNS[17]="-17"
LLVM_VERSION_PATTERNS[18]="-18"
LLVM_VERSION_PATTERNS[19]="-19"

if [ ! ${LLVM_VERSION_PATTERNS[$LLVM_VERSION]+_} ]; then
echo "This script does not support LLVM version $LLVM_VERSION"
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
build:
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]
build-type: [Release, Debug]
sanitizers: [ON, OFF]
sanitizers: [OFF]
features: ["nosarif", "sarif"]

runs-on: ubuntu-${{ matrix.image-version }}
Expand Down Expand Up @@ -57,4 +57,3 @@ jobs:

- name: Test ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }}
run: ctest --preset ci-${{ matrix.features }} --build-config ${{ matrix.build-type }}

2 changes: 1 addition & 1 deletion .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]
runs-on: ubuntu-22.04
timeout-minutes: 45
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
cpp-linter:
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]

runs-on: ubuntu-${{ matrix.image-version }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
build:
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]

name: "Pre Release"
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
needs: build
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]
vast-target: ['hl', 'llvm', 'bin']
disable-unsup: ['ON','OFF']
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
needs: build
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]
vast-target: ['hl']
disable-unsup: [true, false]
Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:
needs: build
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]
vast-target: ['hl']
disable-unsup: [true, false]
Expand Down Expand Up @@ -440,7 +440,7 @@ jobs:
build_doc:
strategy:
matrix:
llvm-version: [18]
llvm-version: [19]
image-version: [22.04]
name: "Build VAST doc"
runs-on: ubuntu-${{ matrix.image-version }}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ FindAndSelectClangCompiler()
#
# LLVM & MLIR & Clang
#
find_package(LLVM 18.1 REQUIRED CONFIG)
find_package(LLVM 19.1 REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
#
Expand Down
6 changes: 3 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
"displayName": "Configure VAST for Compiler Explorer",
"inherits": "base",
"environment": {
"CMAKE_PREFIX_PATH": "/usr/lib/llvm-18"
"CMAKE_PREFIX_PATH": "/usr/lib/llvm-19"
},
"cacheVariables": {
"CMAKE_CONFIGURATION_TYPES": "Release",
"VAST_ENABLE_TESTING": "OFF",
"CMAKE_C_COMPILER": "/usr/bin/clang-18",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18",
"CMAKE_C_COMPILER": "/usr/bin/clang-19",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-19",
"CMAKE_INSTALL_PREFIX": "$env{STAGING_DIR}",
"CMAKE_INSTALL_RPATH": "$env{ORIGIN}/../lib"
}
Expand Down
4 changes: 2 additions & 2 deletions docs/GettingStarted/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

Currently, it is necessary to use `clang` (due to `gcc` bug) to build VAST. On Linux it is also necessary to use `lld` at the moment.

VAST uses `llvm-18` which can be obtained from the [repository](https://apt.llvm.org/) provided by LLVM.
VAST uses `llvm-19` which can be obtained from the [repository](https://apt.llvm.org/) provided by LLVM.

Before building (for Ubuntu) get all the necessary dependencies by running
```
apt-get install build-essential cmake ninja-build libstdc++-12-dev llvm-18 libmlir-18 libmlir-18-dev mlir-18-tools libclang-18-dev
apt-get install build-essential cmake ninja-build libstdc++-12-dev llvm-19 libmlir-19 libmlir-19-dev mlir-19-tools libclang-19-dev
```
or an equivalent command for your operating system of choice.

Expand Down
2 changes: 1 addition & 1 deletion include/vast/Conversion/TypeConverters/HLToStd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace vast::conv::tc {
protected:
auto convert_pointer_element_type() {
return [&](auto t) -> maybe_type_t {
if (t.template isa< hl::VoidType >()) {
if (mlir::isa< hl::VoidType >(t)) {
auto sign = mlir::IntegerType::SignednessSemantics::Signless;
return underlying().int_type(8u, sign);
}
Expand Down
10 changes: 5 additions & 5 deletions include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2022, Trail of Bits, Inc.

Check notice on line 1 in include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter (19, 22.04)

Run clang-format on include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp

File include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp does not conform to Custom style guidelines. (lines 196)

#pragma once

VAST_RELAX_WARNINGS

Check failure on line 5 in include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter (19, 22.04)

include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp:5:1 [clang-diagnostic-error]

unknown type name 'VAST_RELAX_WARNINGS'
#include <mlir/Analysis/DataLayoutAnalysis.h>

#include <mlir/Conversion/LLVMCommon/TypeConverter.h>
Expand All @@ -12,7 +12,7 @@
#include <mlir/IR/Types.h>

#include <llvm/ADT/ScopeExit.h>
VAST_UNRELAX_WARNINGS

Check failure on line 15 in include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter (19, 22.04)

include/vast/Conversion/TypeConverters/LLVMTypeConverter.hpp:15:1 [clang-diagnostic-error]

unknown type name 'VAST_UNRELAX_WARNINGS'

#include "vast/Dialect/Core/CoreOps.hpp"

Expand Down Expand Up @@ -99,7 +99,7 @@

auto make_ptr_type() {
return [&](auto t) {
VAST_ASSERT(!t.template isa< mlir::NoneType >());
VAST_ASSERT(!mlir::isa< mlir::NoneType >(t));
return LLVM::LLVMPointerType::get(&this->getContext(), 0);
};
}
Expand Down Expand Up @@ -139,9 +139,9 @@
maybe_type_t convert_memref_type(mlir::UnrankedMemRefType t) { return {}; }

maybe_signature_conversion_t
get_conversion_signature(mlir::FunctionOpInterface fn, bool variadic) {
get_conversion_signature(core::function_op_interface fn, bool variadic) {
signature_conversion_t conversion(fn.getNumArguments());
auto fn_type = fn.getFunctionType().dyn_cast< core::FunctionType >();
auto fn_type = mlir::dyn_cast< core::FunctionType >(fn.getFunctionType());
VAST_ASSERT(fn_type);
for (auto arg : llvm::enumerate(fn_type.getInputs())) {
auto cty = convert_arg_t(arg.value());
Expand Down Expand Up @@ -186,14 +186,14 @@
}

maybe_types_t convert_arg_t(mlir::Type t) {
if (auto lvalue = t.dyn_cast< hl::LValueType >()) {
if (auto lvalue = mlir::dyn_cast< hl::LValueType >(t)) {
return this->convert_type_to_types(lvalue.getElementType());
}
return this->convert_type_to_types(t);
}

maybe_types_t convert_ret_t(mlir::Type t) {
if (auto lvalue = t.dyn_cast< hl::LValueType >()) {
if (auto lvalue = mlir::dyn_cast< hl::LValueType >(t)) {
return this->convert_type_to_types(lvalue.getElementType());
}
return this->convert_type_to_types(t);
Expand Down
2 changes: 2 additions & 0 deletions include/vast/Conversion/TypeConverters/TypeConverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ VAST_UNRELAX_WARNINGS
#include <gap/core/crtp.hpp>

#include "vast/Dialect/Core/CoreTypes.hpp"
#include "vast/Dialect/Core/Interfaces/FunctionInterface.hpp"

#include "vast/Dialect/HighLevel/HighLevelDialect.hpp"

#include "vast/Util/Common.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022, Trail of Bits, Inc.

Check notice on line 1 in include/vast/Conversion/TypeConverters/TypeConvertingPattern.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter (19, 22.04)

Run clang-format on include/vast/Conversion/TypeConverters/TypeConvertingPattern.hpp

File include/vast/Conversion/TypeConverters/TypeConvertingPattern.hpp does not conform to Custom style guidelines. (lines 37, 118)

#pragma once

Expand Down Expand Up @@ -34,7 +34,7 @@
// TODO(conv:tc): This should probably be some interface instead, since
// we are only updating the root?
logical_result replace(
mlir::FunctionOpInterface fn,
core::function_op_interface fn,
auto &rewriter
) const {
auto old_type = fn.getFunctionType();
Expand Down Expand Up @@ -115,7 +115,7 @@
operation op, mlir::ArrayRef< mlir::Value >,
conversion_rewriter &rewriter
) const override {
if (auto func_op = mlir::dyn_cast< mlir::FunctionOpInterface >(op))
if (auto func_op = mlir::dyn_cast< core::function_op_interface >(op))
return this->replace(func_op, rewriter);
return this->replace(op, rewriter);
}
Expand Down
2 changes: 2 additions & 0 deletions include/vast/Dialect/ABI/ABIOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ VAST_RELAX_WARNINGS
#include "vast/Dialect/Core/CoreTypes.hpp"
#include "vast/Dialect/Core/CoreAttributes.hpp"
#include "vast/Dialect/Core/Func.hpp"

#include "vast/Dialect/Core/Interfaces/FunctionInterface.hpp"
#include "vast/Dialect/Core/Interfaces/SymbolInterface.hpp"
#include "vast/Dialect/Core/Interfaces/SymbolTableInterface.hpp"

Expand Down
1 change: 0 additions & 1 deletion include/vast/Dialect/Builtin/Ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "vast/Util/Warnings.hpp"

VAST_RELAX_WARNINGS
#include <mlir/Interfaces/FunctionInterfaces.h>
#include <mlir/Interfaces/CallInterfaces.h>
#include <mlir/Interfaces/InferTypeOpInterface.h>
VAST_UNRELAX_WARNINGS
Expand Down
1 change: 0 additions & 1 deletion include/vast/Dialect/Core/CoreLazy.td
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include "mlir/IR/OpBase.td"

include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/CastInterfaces.td"
include "mlir/Interfaces/FunctionInterfaces.td"
include "vast/Dialect/Core/Interfaces/SymbolInterface.td"

class Core_LazyEval< string mnemonic, list < Trait > traits = [] >
Expand Down
3 changes: 1 addition & 2 deletions include/vast/Dialect/Core/CoreOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "vast/Util/Common.hpp"
#include "vast/Util/TypeList.hpp"

#include <mlir/Interfaces/FunctionInterfaces.h>
#include <mlir/Interfaces/CallInterfaces.h>
#include <mlir/Interfaces/InferTypeOpInterface.h>
#include <mlir/Interfaces/DataLayoutInterfaces.h>
Expand All @@ -24,4 +23,4 @@

namespace vast::core {
using module = core::ModuleOp;
} // namespace vast::core
} // namespace vast::core
9 changes: 6 additions & 3 deletions include/vast/Dialect/Core/Func.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-present, Trail of Bits, Inc.

Check notice on line 1 in include/vast/Dialect/Core/Func.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter (19, 22.04)

Run clang-format on include/vast/Dialect/Core/Func.hpp

File include/vast/Dialect/Core/Func.hpp does not conform to Custom style guidelines. (lines 16)

#pragma once

Expand All @@ -13,6 +13,9 @@
#include "vast/Dialect/Core/Linkage.hpp"
#include "vast/Dialect/Core/CoreTypes.hpp"

#include "vast/Dialect/Core/Interfaces/FunctionInterface.hpp"
#include "vast/Dialect/Core/Interfaces/FunctionImplementation.hpp"

namespace vast::core {

llvm::StringRef getLinkageAttrNameString();
Expand Down Expand Up @@ -77,11 +80,11 @@
}

auto fty = op.getFunctionType();
mlir::function_interface_impl::printFunctionSignature(
vast::core::function_interface_impl::printFunctionSignature(
printer, op, fty.getInputs(), fty.isVarArg(), fty.getResults()
);

mlir::function_interface_impl::printFunctionAttributes(
vast::core::function_interface_impl::printFunctionAttributes(
printer, op, { getLinkageAttrNameString(), op.getFunctionTypeAttrName() }
);

Expand Down Expand Up @@ -160,7 +163,7 @@

template< typename DstFuncOp >
logical_result convert_and_replace_function(auto src, auto &rewriter) {
return convert_and_replace_function< DstFuncOp >(src, rewriter, src.getName());
return convert_and_replace_function< DstFuncOp >(src, rewriter, src.getSymbolName());
}

} // namespace vast::core
7 changes: 3 additions & 4 deletions include/vast/Dialect/Core/Func.td
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
include "mlir/IR/OpBase.td"

include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/FunctionInterfaces.td"
include "vast/Dialect/Core/Interfaces/SymbolInterface.td"
include "vast/Dialect/Core/Interfaces/FunctionInterface.td"

include "vast/Dialect/Core/CoreTraits.td"
include "vast/Dialect/Core/LinkageHelper.td"
Expand All @@ -22,9 +22,8 @@ class Core_FuncBaseOp< Dialect dialect, string mnemonic, list< Trait > traits =
: Op< dialect, mnemonic,
!listconcat(traits, [
AutomaticAllocationScope,
CallableOpInterface,
FunctionOpInterface,
Jezurko marked this conversation as resolved.
Show resolved Hide resolved
IsolatedFromAbove,
Core_FunctionOpInterface,
Core_FuncSymbol,
NoTerminator
])
Expand Down Expand Up @@ -86,7 +85,7 @@ class Core_FuncBaseOp< Dialect dialect, string mnemonic, list< Trait > traits =
if (arg_attrs.empty())
return;

mlir::function_interface_impl::addArgAndResultAttrs(
vast::core::function_interface_impl::addArgAndResultAttrs(
$_builder, $_state, arg_attrs, res_attrs,
getArgAttrsAttrName($_state.name), getResAttrsAttrName($_state.name)
);
Expand Down
1 change: 1 addition & 0 deletions include/vast/Dialect/Core/Interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_vast_op_interface(DeclStorageInterface)
add_vast_op_interface(FunctionInterface)
add_vast_op_interface(TypeDefinitionInterface)

add_vast_op_interface(SymbolInterface)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include "vast/Util/Warnings.hpp"

VAST_RELAX_WARNINGS
#include <mlir/Interfaces/FunctionInterfaces.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/IR/BuiltinTypes.h>
#include <mlir/IR/Dialect.h>
#include <mlir/IR/OperationSupport.h>
VAST_RELAX_WARNINGS

#include "vast/Dialect/Core/CoreOps.hpp"
#include "vast/Dialect/Core/Interfaces/FunctionInterface.hpp"

#define GET_OP_FWD_DEFINES
#include "vast/Dialect/HighLevel/HighLevel.h.inc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def Core_DeclStorageInterface : Core_OpInterface< "DeclStorageInterface" > {
return kind_attr.getValue();
}
auto st = core::get_effective_symbol_table_for< core::var_symbol >($_op)->get_defining_operation();
if (mlir::isa< mlir::FunctionOpInterface >(st))
if (mlir::isa< core::function_op_interface >(st))
return DeclContextKind::dc_function;
if (st->template hasTrait< core::ScopeLikeTrait >())
return DeclContextKind::dc_function;
Expand Down
Loading