From 2de8872dbd59a1d74a5a7a37266f67b24c816397 Mon Sep 17 00:00:00 2001 From: AlexDenisov Date: Sun, 22 Oct 2023 20:00:42 +0200 Subject: [PATCH] Add LLVM 16 and drop LLVM 11 --- .github/workflows/ci-macos.yml | 4 +-- .github/workflows/ci-ubuntu-20.04.yml | 2 +- .github/workflows/ci-ubuntu-22.04.yml | 2 +- docs/Features.rst | 2 +- docs/HackingOnMull.rst | 2 +- infrastructure/helpers/integration-tests.yaml | 5 ++- infrastructure/helpers/variables.yaml | 26 +++----------- infrastructure/macos-playbook.yaml | 4 --- lib/MutationPoint.cpp | 18 +++++----- tests-lit/lit.cfg | 8 ++--- .../mull-cxx-frontend/src/ASTNodeFactory.cpp | 34 +++---------------- .../mull-cxx-frontend/src/ClangASTMutator.cpp | 30 +++++----------- .../mull-ir-frontend/mull-cxx-ir-frontend.cpp | 10 +++--- vendor/libirm | 2 +- 14 files changed, 44 insertions(+), 105 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 3966ac50b..d7909a1c0 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -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 diff --git a/.github/workflows/ci-ubuntu-20.04.yml b/.github/workflows/ci-ubuntu-20.04.yml index 7d768d7ee..c247624c0 100644 --- a/.github/workflows/ci-ubuntu-20.04.yml +++ b/.github/workflows/ci-ubuntu-20.04.yml @@ -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 diff --git a/.github/workflows/ci-ubuntu-22.04.yml b/.github/workflows/ci-ubuntu-22.04.yml index b72c85aee..88325a32d 100644 --- a/.github/workflows/ci-ubuntu-22.04.yml +++ b/.github/workflows/ci-ubuntu-22.04.yml @@ -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 diff --git a/docs/Features.rst b/docs/Features.rst index 149e68ac1..7324b59b7 100644 --- a/docs/Features.rst +++ b/docs/Features.rst @@ -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 `_. diff --git a/docs/HackingOnMull.rst b/docs/HackingOnMull.rst index 5435f3445..9bc9a3e8c 100644 --- a/docs/HackingOnMull.rst +++ b/docs/HackingOnMull.rst @@ -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). diff --git a/infrastructure/helpers/integration-tests.yaml b/infrastructure/helpers/integration-tests.yaml index 420aa134c..8d6141531 100644 --- a/infrastructure/helpers/integration-tests.yaml +++ b/infrastructure/helpers/integration-tests.yaml @@ -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 }} @@ -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" diff --git a/infrastructure/helpers/variables.yaml b/infrastructure/helpers/variables.yaml index 3bb7f4062..294b528ca 100644 --- a/infrastructure/helpers/variables.yaml +++ b/infrastructure/helpers/variables.yaml @@ -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: @@ -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": @@ -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" @@ -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" diff --git a/infrastructure/macos-playbook.yaml b/infrastructure/macos-playbook.yaml index 5866ac5e1..ebab8a05c 100644 --- a/infrastructure/macos-playbook.yaml +++ b/infrastructure/macos-playbook.yaml @@ -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 diff --git a/lib/MutationPoint.cpp b/lib/MutationPoint.cpp index 0edc754ba..970924d34 100644 --- a/lib/MutationPoint.cpp +++ b/lib/MutationPoint.cpp @@ -49,24 +49,24 @@ int MutationPointAddress::getIIndex() const { } template -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, diff --git a/tests-lit/lit.cfg b/tests-lit/lit.cfg index 0fee2ac3a..f411c2c98 100644 --- a/tests-lit/lit.cfg +++ b/tests-lit/lit.cfg @@ -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)) diff --git a/tools/mull-cxx-frontend/src/ASTNodeFactory.cpp b/tools/mull-cxx-frontend/src/ASTNodeFactory.cpp index b2562c556..50ac99e21 100644 --- a/tools/mull-cxx-frontend/src/ASTNodeFactory.cpp +++ b/tools/mull-cxx-frontend/src/ASTNodeFactory.cpp @@ -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) { @@ -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 @@ -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; } @@ -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, @@ -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; } diff --git a/tools/mull-cxx-frontend/src/ClangASTMutator.cpp b/tools/mull-cxx-frontend/src/ClangASTMutator.cpp index 8bd5cde3c..ed122c2f7 100644 --- a/tools/mull-cxx-frontend/src/ClangASTMutator.cpp +++ b/tools/mull-cxx-frontend/src/ClangASTMutator.cpp @@ -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 thenStmtsVec = {}; if (newStmt) { @@ -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, @@ -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, diff --git a/tools/mull-ir-frontend/mull-cxx-ir-frontend.cpp b/tools/mull-ir-frontend/mull-cxx-ir-frontend.cpp index c0af32f6f..4a4482a27 100644 --- a/tools/mull-ir-frontend/mull-cxx-ir-frontend.cpp +++ b/tools/mull-ir-frontend/mull-cxx-ir-frontend.cpp @@ -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()); + }); } }; } diff --git a/vendor/libirm b/vendor/libirm index 91f45ffb1..988a91877 160000 --- a/vendor/libirm +++ b/vendor/libirm @@ -1 +1 @@ -Subproject commit 91f45ffb1e70d6c6554cb5c0f24b6f937f62ef17 +Subproject commit 988a91877279c95bfe847994d006e3733a663962