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

Add LLVM 16 and drop LLVM 11 #1036

Merged
merged 1 commit into from
Oct 22, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ on:
jobs:
macos-11:
name: LLVM ${{ matrix.LLVM_VERSION }}
runs-on: macos-11
runs-on: macos-12
strategy:
matrix:
LLVM_VERSION: [11, 12, 13, 14]
LLVM_VERSION: [12, 13, 14, 16]

steps:
- name: Debugging
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-ubuntu-20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
container: ubuntu:20.04
strategy:
matrix:
LLVM_VERSION: [11, 12]
LLVM_VERSION: [12]
env:
DISTR_REPO: "ubuntu/focal"
DEBIAN_FRONTEND: noninteractive
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-ubuntu-22.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
container: ubuntu:22.04
strategy:
matrix:
LLVM_VERSION: [11, 13, 14, 15]
LLVM_VERSION: [13, 14, 15]
env:
DISTR_REPO: "ubuntu/jammy"
DEBIAN_FRONTEND: noninteractive
Expand Down
2 changes: 1 addition & 1 deletion docs/Features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Features
Working with mutations found in Git Diff changesets.

- Mull requires test programs to be compiled with Clang/LLVM. Mull supports
all LLVM versions starting from LLVM 11 (older versions support older versions).
all LLVM versions starting from LLVM 12 (older versions support older versions).

For a more detailed description of Mull's architecture, see
`How Mull works <HowMullWorks.html>`_.
2 changes: 1 addition & 1 deletion docs/HackingOnMull.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LLVM
----

You need LLVM to build and debug Mull.
You can use any LLVM version between 11.0 and 15.0.
You can use any LLVM version between 12.0 and 16.0.

As of the version 0.14.0, Mull can be compiled against LLVM/Clang available
through your package manager (e.g. apt or homebrew).
Expand Down
5 changes: 2 additions & 3 deletions infrastructure/helpers/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- cmake
- -G
- Ninja
- -DCMAKE_CXX_FLAGS={{ test_opt_level }} -grecord-command-line -fexperimental-new-pass-manager -fpass-plugin=/usr/local/lib/mull-ir-frontend-{{ llvm_version }} --sysroot={{ SDKROOT }}
- -DCMAKE_CXX_FLAGS={{ pass_manager_flag }} -grecord-command-line -fpass-plugin=/usr/local/lib/mull-ir-frontend-{{ llvm_version }} --sysroot={{ SDKROOT }}
- -DCMAKE_BUILD_TYPE=Debug
- -DCMAKE_C_COMPILER={{ cmake_c_compiler }}
- -DCMAKE_CXX_COMPILER={{ cmake_cxx_compiler }}
Expand Down Expand Up @@ -58,9 +58,8 @@
- ./config
- -g
- -O0
- "{{ test_opt_level }}"
- -grecord-command-line
- -fexperimental-new-pass-manager
- "{{ pass_manager_flag }}"
- -fpass-plugin=/usr/local/lib/mull-ir-frontend-{{ llvm_version }}
- --sysroot={{ SDKROOT }}
chdir: "{{ working_dir }}/integration/openssl"
Expand Down
26 changes: 5 additions & 21 deletions infrastructure/helpers/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ SDKROOT: /
llvm_mapping:
macos:
"16":
cmake_search_paths: "/usr/local/opt/llvm/lib/cmake/llvm/;/usr/local/opt/llvm/lib/cmake/clang/"
cmake_search_paths: "/usr/local/opt/llvm@16/lib/cmake/llvm/;/usr/local/opt/llvm@16/lib/cmake/clang/"
packages:
- llvm
cmake_cc: /usr/local/opt/llvm/bin/clang
cmake_cxx: /usr/local/opt/llvm/bin/clang++
- llvm@16
cmake_cc: /usr/local/opt/llvm@16/bin/clang
cmake_cxx: /usr/local/opt/llvm@16/bin/clang++
"15":
cmake_search_paths: "/usr/local/opt/llvm@15/lib/cmake/llvm/;/usr/local/opt/llvm@15/lib/cmake/clang/"
packages:
Expand All @@ -36,12 +36,6 @@ llvm_mapping:
- llvm@12
cmake_cc: /usr/local/opt/llvm@12/bin/clang
cmake_cxx: /usr/local/opt/llvm@12/bin/clang++
"11":
cmake_search_paths: "/usr/local/opt/llvm@11/lib/cmake/llvm/;/usr/local/opt/llvm@11/lib/cmake/clang/"
packages:
- llvm@11
cmake_cc: /usr/local/opt/llvm@11/bin/clang
cmake_cxx: /usr/local/opt/llvm@11/bin/clang++

ubuntu:
"15":
Expand Down Expand Up @@ -84,16 +78,6 @@ llvm_mapping:
- clang-12
cmake_cc: clang-12
cmake_cxx: clang++-12
"11":
cmake_search_paths: "/usr/lib/llvm-11/cmake/;/usr/lib/cmake/clang-11/"
packages:
- llvm-11-dev
- libclang-11-dev
- libc++-11-dev
- libc++abi-11-dev
- clang-11
cmake_cc: clang-11
cmake_cxx: clang++-11

source_dir: "{{ working_dir }}/mull"
debug_build_dir: "{{ working_dir }}/build.mull.debug.dir"
Expand All @@ -108,5 +92,5 @@ cmake_search_paths: "{{ llvm_mapping[platform][llvm_version].cmake_search_paths
llvm_packages: "{{ llvm_mapping[platform][llvm_version].packages }}"
cmake_c_compiler: "{{ llvm_mapping[platform][llvm_version].cmake_cc }}"
cmake_cxx_compiler: "{{ llvm_mapping[platform][llvm_version].cmake_cxx }}"
test_opt_level: "{{ '-O0' if llvm_version | int > 11 else '-O1' }}"
pass_manager_flag: "{{ '' if llvm_version | int > 15 else '-fexperimental-new-pass-manager' }}"
test_mull_config: "{{ source_dir }}/infrastructure/helpers/mull.yml"
4 changes: 0 additions & 4 deletions infrastructure/macos-playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
- helpers/variables.yaml

tasks:
- name: Change Xcode
command: xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer
become: true

- name: Prepare Working Directory
include: helpers/working-directory.yaml

Expand Down
18 changes: 9 additions & 9 deletions lib/MutationPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@ int MutationPointAddress::getIIndex() const {
}

template <typename Container, typename Value>
static size_t getIndex(Container &container, Value *value) {
static size_t getIndex(const Container &container, Value *value) {
// LLVM's begin/end don't play well with std::find, so handcrafting the find here
size_t index = 0;
auto begin = container.begin();
auto end = container.end();
for (; begin != end; begin++, index++) {
if (&*begin == value) {
for (auto &val : *container) {
if (&val == value) {
break;
}
index++;
}
assert(index < container->size() && "Value not found in the container");
return index;
}

MutationPointAddress
MutationPointAddress::addressFromInstruction(const llvm::Instruction *instruction) {
return MutationPointAddress(
getIndex(instruction->getModule()->getFunctionList(), instruction->getFunction()),
getIndex(instruction->getFunction()->getBasicBlockList(), instruction->getParent()),
getIndex(instruction->getParent()->getInstList(), instruction));
return MutationPointAddress(getIndex(instruction->getModule(), instruction->getFunction()),
getIndex(instruction->getFunction(), instruction->getParent()),
getIndex(instruction->getParent(), instruction));
}

MutationPoint::MutationPoint(Mutator *mutator, irm::IRMutation *irMutator,
Expand Down
8 changes: 3 additions & 5 deletions tests-lit/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ if platform.system() == 'Darwin':
else:
config.available_features.add('LINUX')

if int(llvm_major_version) > 11:
config.substitutions.append(('%pass_mull_ir_frontend', "-fexperimental-new-pass-manager -fpass-plugin=" + mull_ir_frontend))
if int(llvm_major_version) >= 16:
config.substitutions.append(('%pass_mull_ir_frontend', "-fpass-plugin=" + mull_ir_frontend))
else:
# LLVM 9 and 10 doesn't include the pass if no optimizations enabled
config.substitutions.append(('%pass_mull_ir_frontend', "-O1 -fexperimental-new-pass-manager -fpass-plugin=" + mull_ir_frontend))

config.substitutions.append(('%pass_mull_ir_frontend', "-fexperimental-new-pass-manager -fpass-plugin=" + mull_ir_frontend))
34 changes: 5 additions & 29 deletions tools/mull-cxx-frontend/src/ASTNodeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ clang::FunctionDecl *ASTNodeFactory::createFunctionDecl(std::string name,
#endif
false, /// bool isInlineSpecified = false,
true, /// bool hasWrittenPrototype = true,
#if LLVM_VERSION_MAJOR >= 12
clang::ConstexprSpecKind::Unspecified
#else
clang::CSK_unspecified /// ConstexprSpecKind ConstexprKind =
/// CSK_unspecified
#endif
);
clang::ConstexprSpecKind::Unspecified);
}

clang::IntegerLiteral *ASTNodeFactory::createIntegerLiteral(int value) {
Expand Down Expand Up @@ -70,7 +64,6 @@ clang::IfStmt *ASTNodeFactory::createIfStmt(clang::Expr *condExpr, clang::Stmt *
clang::Stmt *elseStmt) {
assert(condExpr);
assert(thenStmt);
#if LLVM_VERSION_MAJOR >= 12
clang::IfStmt *ifStmt = clang::IfStmt::Create(context,
NULL_LOCATION,
#if LLVM_VERSION_MAJOR > 13
Expand All @@ -86,10 +79,6 @@ clang::IfStmt *ASTNodeFactory::createIfStmt(clang::Expr *condExpr, clang::Stmt *
thenStmt,
NULL_LOCATION,
elseStmt);
#else
clang::IfStmt *ifStmt = clang::IfStmt::Create(
context, NULL_LOCATION, false, nullptr, nullptr, condExpr, thenStmt, NULL_LOCATION, elseStmt);
#endif
return ifStmt;
}

Expand All @@ -101,17 +90,8 @@ clang::ImplicitCastExpr *ASTNodeFactory::createImplicitCastExpr(clang::Expr *exp
clang::QualType qualType,
clang::CastKind castKind,
clang::ExprValueKind valueKind) {
return clang::ImplicitCastExpr::Create(context,
qualType,
castKind,
expr,
nullptr,
valueKind
#if LLVM_VERSION_MAJOR >= 12
,
clang::FPOptionsOverride()
#endif
);
return clang::ImplicitCastExpr::Create(
context, qualType, castKind, expr, nullptr, valueKind, clang::FPOptionsOverride());
}

clang::UnaryOperator *ASTNodeFactory::createUnaryOperator(clang::UnaryOperator::Opcode opcode,
Expand Down Expand Up @@ -174,12 +154,8 @@ clang::CallExpr *ASTNodeFactory::createCallExprSingleArg(clang::Expr *function,
{ argument },
returnType,
valueKind,
NULL_LOCATION
#if LLVM_VERSION_MAJOR >= 12
,
clang::FPOptionsOverride()
#endif
);
NULL_LOCATION,
clang::FPOptionsOverride());

return callExpr;
}
Expand Down
30 changes: 9 additions & 21 deletions tools/mull-cxx-frontend/src/ClangASTMutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ clang::IfStmt *ClangASTMutator::createMutatedStatement(clang::Stmt *oldStmt, cla
getenvCallExpr,
nullptr,
#if LLVM_VERSION_MAJOR >= 13
clang::VK_PRValue
clang::VK_PRValue,
#else
clang::VK_RValue
clang::VK_RValue,
#endif
#if LLVM_VERSION_MAJOR >= 12
,
clang::FPOptionsOverride()
#endif
);
clang::FPOptionsOverride());

std::vector<clang::Stmt *> thenStmtsVec = {};
if (newStmt) {
Expand Down Expand Up @@ -119,15 +115,11 @@ clang::ConditionalOperator *ClangASTMutator::createMutatedExpression(clang::Expr
mullShouldMutateCallExpr,
nullptr,
#if LLVM_VERSION_MAJOR >= 13
clang::VK_PRValue
clang::VK_PRValue,
#else
clang::VK_RValue
#endif
#if LLVM_VERSION_MAJOR >= 12
,
clang::FPOptionsOverride()
clang::VK_RValue,
#endif
);
clang::FPOptionsOverride());

clang::ConditionalOperator *conditionalOperator =
new (context) clang::ConditionalOperator(implicitCastExpr3,
Expand Down Expand Up @@ -183,15 +175,11 @@ clang::CallExpr *ClangASTMutator::createGetenvCallExpr(std::string identifier) {
stringLiteral,
nullptr,
#if LLVM_VERSION_MAJOR >= 13
clang::VK_PRValue
clang::VK_PRValue,
#else
clang::VK_RValue
#endif
#if LLVM_VERSION_MAJOR >= 12
,
clang::FPOptionsOverride()
clang::VK_RValue,
#endif
);
clang::FPOptionsOverride());

clang::CallExpr *callExpr = factory.createCallExprSingleArg(implicitCastExpr,
implicitCastExpr2,
Expand Down
10 changes: 4 additions & 6 deletions tools/mull-ir-frontend/mull-cxx-ir-frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ llvmGetPassPluginInfo() {
"mull-ir-frontend",
LLVM_VERSION_STRING,
[](llvm::PassBuilder &PB) {
PB.registerPipelineStartEPCallback([](llvm::ModulePassManager &modulePassManager
#if LLVM_VERSION_MAJOR > 11
,
OptimizationLevel optimizationLevel
#endif
) { modulePassManager.addPass(MullIRFrontend()); });
PB.registerPipelineStartEPCallback([](llvm::ModulePassManager &modulePassManager,
OptimizationLevel optimizationLevel) {
modulePassManager.addPass(MullIRFrontend());
});
} };
}

Expand Down
Loading