From e7402c5802024215f6eaafbbc125f36cea3b8868 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 07:35:43 +0200 Subject: [PATCH 01/53] Adding Python to the CI process --- build/init.yml | 6 ++++++ build/test.ps1 | 2 ++ 2 files changed, 8 insertions(+) diff --git a/build/init.yml b/build/init.yml index 5c0c420205..5a16b85219 100644 --- a/build/init.yml +++ b/build/init.yml @@ -31,3 +31,9 @@ steps: inputs: command: 'custom' customCommand: 'install -g npm@latest' + +- task: UsePythonVersion@0 + inputs: + versionSpec: "3.9" + addToPath: true + architecture: "x64" diff --git a/build/test.ps1 b/build/test.ps1 index adfd20f7e5..81837e4ba9 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -38,6 +38,8 @@ function Test-One { } } +python + Test-One '../QsCompiler.sln' Test-One '../QsFmt.sln' From 7c8acd6dcea89c7df5a16a6dd75b6b62fca06c13 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:02:30 +0200 Subject: [PATCH 02/53] Creating development script --- build/development.ps1 | 8 ++++++++ build/steps.yml | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 build/development.ps1 diff --git a/build/development.ps1 b/build/development.ps1 new file mode 100644 index 0000000000..f4befab8ed --- /dev/null +++ b/build/development.ps1 @@ -0,0 +1,8 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +$ErrorActionPreference = 'Stop' + +python --version + +throw "Preventing other steps from running." diff --git a/build/steps.yml b/build/steps.yml index cd530df6be..7dfdbab857 100644 --- a/build/steps.yml +++ b/build/steps.yml @@ -1,4 +1,8 @@ steps: +- pwsh: ./development.ps1 + displayName: "Development setep" + workingDirectory: $(System.DefaultWorkingDirectory)/build + - pwsh: ./build.ps1 displayName: "Build all" workingDirectory: $(System.DefaultWorkingDirectory)/build From 330da4bff937979e8b5e50f29faf876e0662c98a Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:21:51 +0200 Subject: [PATCH 03/53] Udpating development script --- build/ci.yml | 4 ++++ build/development.ps1 | 10 ++++++++++ build/linux-ci.yml | 13 +++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 build/linux-ci.yml diff --git a/build/ci.yml b/build/ci.yml index c679045f59..4a6da118cc 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -30,6 +30,10 @@ pool: vmImage: windows-latest jobs: +- job: Passes Linux CI + steps: + - template: linux-ci.yml + - job: Build steps: - template: init.yml diff --git a/build/development.ps1 b/build/development.ps1 index f4befab8ed..bb853e86d7 100644 --- a/build/development.ps1 +++ b/build/development.ps1 @@ -4,5 +4,15 @@ $ErrorActionPreference = 'Stop' python --version +pip --version +virtualenv --version + +# Installing requirements for CI +cd src/Passes +pip install -r requirements.txt + +# Running CI +python manage runci + throw "Preventing other steps from running." diff --git a/build/linux-ci.yml b/build/linux-ci.yml new file mode 100644 index 0000000000..93170f828d --- /dev/null +++ b/build/linux-ci.yml @@ -0,0 +1,13 @@ +pool: + name: Azure Pipelines + vmImage: ubuntu-20.04 + +#variables: +# system.debug: 'true' + +steps: +- script: | + sudo apt update -y + sudo apt install -y clang cmake + sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime + pwd \ No newline at end of file From 2628e7564d6fac8f6c6380925444f769b78b5588 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:24:44 +0200 Subject: [PATCH 04/53] Disabling Linux for the time being --- build/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/ci.yml b/build/ci.yml index 4a6da118cc..29f46f4e34 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -30,10 +30,10 @@ pool: vmImage: windows-latest jobs: -- job: Passes Linux CI - steps: - - template: linux-ci.yml - +#- job: Passes Linux CI +# steps: +# - template: linux-ci.yml + - job: Build steps: - template: init.yml From 730decd5cd10b4b8a2fc0ae7817ec79cef5d2fec Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:28:24 +0200 Subject: [PATCH 05/53] Reactivating linux CI --- build/ci.yml | 15 ++++++++++----- build/linux-ci.yml | 6 ------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build/ci.yml b/build/ci.yml index 29f46f4e34..d75f803ef6 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -26,19 +26,22 @@ schedules: - main always: true -pool: - vmImage: windows-latest + jobs: -#- job: Passes Linux CI -# steps: -# - template: linux-ci.yml +- job: Passes Linux CI + steps: + - template: linux-ci.yml + pool: + vmImage: windows-latest - job: Build steps: - template: init.yml - template: steps.yml - template: wrap-up.yml + pool: + vmImage: windows-latest - job: Style steps: @@ -47,3 +50,5 @@ jobs: - script: dotnet tool run fantomas -- --check --recurse . displayName: Fantomas + pool: + vmImage: windows-latest \ No newline at end of file diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 93170f828d..d905acfddd 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -1,9 +1,3 @@ -pool: - name: Azure Pipelines - vmImage: ubuntu-20.04 - -#variables: -# system.debug: 'true' steps: - script: | From fafdab534771664a0c2e023179641b9872738381 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:29:52 +0200 Subject: [PATCH 06/53] Removing the need for virtualenv --- build/development.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/build/development.ps1 b/build/development.ps1 index bb853e86d7..36349363a2 100644 --- a/build/development.ps1 +++ b/build/development.ps1 @@ -5,7 +5,6 @@ $ErrorActionPreference = 'Stop' python --version pip --version -virtualenv --version # Installing requirements for CI cd src/Passes From 8eb3909492573a5ca252fd76eb66303c466226d3 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:40:43 +0200 Subject: [PATCH 07/53] Updating linux image --- build/ci.yml | 13 +++++++------ build/linux-ci.yml | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build/ci.yml b/build/ci.yml index d75f803ef6..1b6a457120 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -29,12 +29,6 @@ schedules: jobs: -- job: Passes Linux CI - steps: - - template: linux-ci.yml - pool: - vmImage: windows-latest - - job: Build steps: - template: init.yml @@ -43,6 +37,13 @@ jobs: pool: vmImage: windows-latest +- job: Passes - Linux Build & Test + steps: + - template: linux-ci.yml + pool: + vmImage: ubuntu-20.04 + + - job: Style steps: - script: dotnet tool restore diff --git a/build/linux-ci.yml b/build/linux-ci.yml index d905acfddd..9b84e49219 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -1,7 +1,8 @@ steps: - script: | - sudo apt update -y - sudo apt install -y clang cmake - sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime - pwd \ No newline at end of file + sudo apt update -y + sudo apt install -y clang cmake + sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime + pwd + From 6c8627ba3f568b569630e77e32714f475909b477 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:43:43 +0200 Subject: [PATCH 08/53] Updating name of linux build --- build/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ci.yml b/build/ci.yml index 1b6a457120..619a2b1be5 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -37,7 +37,7 @@ jobs: pool: vmImage: windows-latest -- job: Passes - Linux Build & Test +- job: Passes Linux Build and Test steps: - template: linux-ci.yml pool: From 8ab615897179d9e624674bc219b36cf9231ca177 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:46:12 +0200 Subject: [PATCH 09/53] Updating name of linux build --- build/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ci.yml b/build/ci.yml index 619a2b1be5..7e9dac51b5 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -37,7 +37,7 @@ jobs: pool: vmImage: windows-latest -- job: Passes Linux Build and Test +- job: LinuxBuild steps: - template: linux-ci.yml pool: From 6a2f1117488d38222cfcaa32d793b5bcd6823c67 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:52:59 +0200 Subject: [PATCH 10/53] Updating working directory --- build/steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/steps.yml b/build/steps.yml index 7dfdbab857..5b4d0fa3fa 100644 --- a/build/steps.yml +++ b/build/steps.yml @@ -1,7 +1,7 @@ steps: - pwsh: ./development.ps1 displayName: "Development setep" - workingDirectory: $(System.DefaultWorkingDirectory)/build + workingDirectory: $(System.DefaultWorkingDirectory) - pwsh: ./build.ps1 displayName: "Build all" From 50d753b3b94d2ecc9e92e89b4d257c99e54a00e7 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 08:57:34 +0200 Subject: [PATCH 11/53] Updating scripts --- build/development.ps1 | 2 +- build/linux-ci.yml | 6 ++++-- build/steps.yml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build/development.ps1 b/build/development.ps1 index 36349363a2..e5825a5c54 100644 --- a/build/development.ps1 +++ b/build/development.ps1 @@ -7,7 +7,7 @@ python --version pip --version # Installing requirements for CI -cd src/Passes +cd ../src/Passes pip install -r requirements.txt # Running CI diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 9b84e49219..01f8d32d31 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -2,7 +2,9 @@ steps: - script: | sudo apt update -y - sudo apt install -y clang cmake + sudo apt install -y clang cmake clang-format clang-tidy sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime - pwd + cd src/build + chmod +x manage + ./manage runci diff --git a/build/steps.yml b/build/steps.yml index 5b4d0fa3fa..7dfdbab857 100644 --- a/build/steps.yml +++ b/build/steps.yml @@ -1,7 +1,7 @@ steps: - pwsh: ./development.ps1 displayName: "Development setep" - workingDirectory: $(System.DefaultWorkingDirectory) + workingDirectory: $(System.DefaultWorkingDirectory)/build - pwsh: ./build.ps1 displayName: "Build all" From 62955a48d2411a067edbb93e3ca39a78f7333924 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 09:11:55 +0200 Subject: [PATCH 12/53] Fixing linux path and updating clang search function --- build/development.ps1 | 2 +- build/linux-ci.yml | 2 +- src/Passes/site-packages/TasksCI/toolchain.py | 24 +++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/build/development.ps1 b/build/development.ps1 index e5825a5c54..3180d9efe6 100644 --- a/build/development.ps1 +++ b/build/development.ps1 @@ -7,7 +7,7 @@ python --version pip --version # Installing requirements for CI -cd ../src/Passes +cd ../src/Passes/ pip install -r requirements.txt # Running CI diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 01f8d32d31..161c71896b 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -4,7 +4,7 @@ steps: sudo apt update -y sudo apt install -y clang cmake clang-format clang-tidy sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime - cd src/build + cd src/Passes/ chmod +x manage ./manage runci diff --git a/src/Passes/site-packages/TasksCI/toolchain.py b/src/Passes/site-packages/TasksCI/toolchain.py index 2d935323dd..8c9b01b883 100644 --- a/src/Passes/site-packages/TasksCI/toolchain.py +++ b/src/Passes/site-packages/TasksCI/toolchain.py @@ -8,25 +8,41 @@ def discover_formatter() -> str: """ Finds the clang-format executable """ - return shutil.which("clang-format") + ret = shutil.which("clang-format") + if ret is None: + raise BaseException("Clang format not found") + + return ret def discover_tidy() -> str: """ Finds the clang-tidy executable """ - return shutil.which("clang-tidy") + ret = shutil.which("clang-tidy") + if ret is None: + raise BaseException("Clang tidy not found") + + return ret def discover_cmake() -> str: """ Finds the cmake executable """ - return shutil.which("cmake") + ret = shutil.which("cmake") + if ret is None: + raise BaseException("CMake not found") + + return ret def discover_ctest() -> str: """ Finds the ctest executable """ - return shutil.which("ctest") + ret = shutil.which("ctest") + if ret is None: + raise BaseException("CTest not found") + + return ret From 25f402eb6dc75f2c6eca10cdaa4a140df51b603d Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 09:39:28 +0200 Subject: [PATCH 13/53] Upgrading clang-format to version 11 --- build/linux-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 161c71896b..768306b4be 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -2,7 +2,7 @@ steps: - script: | sudo apt update -y - sudo apt install -y clang cmake clang-format clang-tidy + sudo apt install -y clang cmake clang-format-11 clang-tidy-11 llvm-toolchain-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime cd src/Passes/ chmod +x manage From 65bde4348708e2e8b5ccbfa54df26a484124c8c0 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 09:53:32 +0200 Subject: [PATCH 14/53] Formatting to LLVM 11 toolchain --- src/Passes/libs/OpsCounter/LibOpsCounter.cpp | 43 +++++++++---------- src/Passes/libs/OpsCounter/OpsCounter.cpp | 4 ++ .../site-packages/TasksCI/formatting.py | 7 ++- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/Passes/libs/OpsCounter/LibOpsCounter.cpp b/src/Passes/libs/OpsCounter/LibOpsCounter.cpp index 65a7a238b9..a07379f656 100644 --- a/src/Passes/libs/OpsCounter/LibOpsCounter.cpp +++ b/src/Passes/libs/OpsCounter/LibOpsCounter.cpp @@ -16,30 +16,27 @@ llvm::PassPluginLibraryInfo getOpsCounterPluginInfo() using namespace microsoft::quantum; using namespace llvm; - return { - LLVM_PLUGIN_API_VERSION, "OpsCounter", LLVM_VERSION_STRING, - [](PassBuilder& pb) - { - // Registering the printer - pb.registerPipelineParsingCallback( - [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) - { - if (name == "print") - { + return {LLVM_PLUGIN_API_VERSION, "OpsCounter", LLVM_VERSION_STRING, [](PassBuilder& pb) { + // Registering the printer + pb.registerPipelineParsingCallback( + [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) { + if (name == "print") + { + fpm.addPass(OpsCounterPrinter(llvm::errs())); + return true; + } + return false; + }); + + pb.registerVectorizerStartEPCallback( + [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) { fpm.addPass(OpsCounterPrinter(llvm::errs())); - return true; - } - return false; - }); - - pb.registerVectorizerStartEPCallback( - [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) - { fpm.addPass(OpsCounterPrinter(llvm::errs())); }); - - // Registering the analysis module - pb.registerAnalysisRegistrationCallback([](FunctionAnalysisManager& fam) - { fam.registerPass([] { return OpsCounterAnalytics(); }); }); - }}; + }); + + // Registering the analysis module + pb.registerAnalysisRegistrationCallback( + [](FunctionAnalysisManager& fam) { fam.registerPass([] { return OpsCounterAnalytics(); }); }); + }}; } } // namespace diff --git a/src/Passes/libs/OpsCounter/OpsCounter.cpp b/src/Passes/libs/OpsCounter/OpsCounter.cpp index f642970b1a..99c2e5c41b 100644 --- a/src/Passes/libs/OpsCounter/OpsCounter.cpp +++ b/src/Passes/libs/OpsCounter/OpsCounter.cpp @@ -21,10 +21,14 @@ namespace quantum { for (auto& instruction : basic_block) { + /* + TODO(tfr): Enable this block once we upgrade to LLVM 12 or above if (instruction.isDebugOrPseudoInst()) { continue; } + */ + auto name = instruction.getOpcodeName(); if (opcode_map.find(name) == opcode_map.end()) diff --git a/src/Passes/site-packages/TasksCI/formatting.py b/src/Passes/site-packages/TasksCI/formatting.py index 1d2bdfa4f0..ae00834177 100644 --- a/src/Passes/site-packages/TasksCI/formatting.py +++ b/src/Passes/site-packages/TasksCI/formatting.py @@ -10,6 +10,7 @@ from .settings import PROJECT_ROOT from .toolchain import discover_formatter from typing import Union, List, Callable +import difflib OptionalInt = Union[int, None] OptionalStr = Union[str, None] @@ -91,8 +92,10 @@ def enforce_formatting(filename: str, contents: str, cursor: int, fix_issues: bo with open(filename, "w") as filebuffer: filebuffer.write(formatted) return cursor, False - - logger.error("{} was not correctly formatted.".format(filename)) + else: + logger.error("{} was not correctly formatted.".format(filename)) + sys.stdout.writelines(difflib.unified_diff(contents, formatted, + fromfile=filename, tofile="formatted_{}".format(filename))) return cursor, True return cursor, False From c7bde932ea6743b9b0822ddd7082ed4701c96af9 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 10:06:11 +0200 Subject: [PATCH 15/53] Removing visibility check in CMake --- src/Passes/CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Passes/CMakeLists.txt b/src/Passes/CMakeLists.txt index 41ca853b39..60ed31a79e 100644 --- a/src/Passes/CMakeLists.txt +++ b/src/Passes/CMakeLists.txt @@ -25,14 +25,6 @@ if(NOT LLVM_ENABLE_RTTI) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") endif() -# -fvisibility-inlines-hidden is set when building LLVM and on Darwin warnings -# are triggered if llvm-tutor is built without this flag (though otherwise it -# builds fine). For consistency, add it here too. -check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG) -if (${SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG} EQUAL "1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") -endif() - # We export the compile commands which are needed by clang-tidy # to run the static analysis set(CMAKE_EXPORT_COMPILE_COMMANDS ON) From 8e3b886da59ef0be637db581f2cc676383bea753 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 10:10:26 +0200 Subject: [PATCH 16/53] Forcing Clang as compiler --- build/linux-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 768306b4be..994ccb777e 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -4,6 +4,8 @@ steps: sudo apt update -y sudo apt install -y clang cmake clang-format-11 clang-tidy-11 llvm-toolchain-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime + export CC=clang + export CXX=clang++ cd src/Passes/ chmod +x manage ./manage runci From 1ce8619c77d4c040e23c43c87e0fd56f71259b9d Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 10:15:00 +0200 Subject: [PATCH 17/53] Removing llvm-toolchain-11 --- build/linux-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 994ccb777e..c742059526 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -2,7 +2,8 @@ steps: - script: | sudo apt update -y - sudo apt install -y clang cmake clang-format-11 clang-tidy-11 llvm-toolchain-11 + sudo apt install -y clang cmake clang-format-11 clang-tidy-11 + # sudo apt install -y llvm-toolchain-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime export CC=clang export CXX=clang++ From 47897bcbf7b8d472067b705cd22c7d143567d904 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 10:23:13 +0200 Subject: [PATCH 18/53] Improving search for clang tidy --- build/linux-ci.yml | 4 +-- src/Passes/site-packages/TasksCI/toolchain.py | 36 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/build/linux-ci.yml b/build/linux-ci.yml index c742059526..3e97e7e073 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -2,10 +2,10 @@ steps: - script: | sudo apt update -y - sudo apt install -y clang cmake clang-format-11 clang-tidy-11 + sudo apt install -y clang-11 clang++-11 cmake clang-format-11 clang-tidy-11 # sudo apt install -y llvm-toolchain-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime - export CC=clang + export CC=clang-11 export CXX=clang++ cd src/Passes/ chmod +x manage diff --git a/src/Passes/site-packages/TasksCI/toolchain.py b/src/Passes/site-packages/TasksCI/toolchain.py index 8c9b01b883..e9d8027bfe 100644 --- a/src/Passes/site-packages/TasksCI/toolchain.py +++ b/src/Passes/site-packages/TasksCI/toolchain.py @@ -9,10 +9,15 @@ def discover_formatter() -> str: Finds the clang-format executable """ ret = shutil.which("clang-format") - if ret is None: - raise BaseException("Clang format not found") + if ret is not None: + return ret - return ret + for v in ["11", "10", "12"]: + ret = shutil.which("clang-format-{}".format(v)) + if ret is not None: + return ret + + raise BaseException("Clang format not found") def discover_tidy() -> str: @@ -20,10 +25,15 @@ def discover_tidy() -> str: Finds the clang-tidy executable """ ret = shutil.which("clang-tidy") - if ret is None: - raise BaseException("Clang tidy not found") + if ret is not None: + return ret + + for v in ["11", "10", "12"]: + ret = shutil.which("clang-tidy-{}".format(v)) + if ret is not None: + return ret - return ret + raise BaseException("Clang tidy not found") def discover_cmake() -> str: @@ -31,10 +41,11 @@ def discover_cmake() -> str: Finds the cmake executable """ ret = shutil.which("cmake") - if ret is None: - raise BaseException("CMake not found") - return ret + if ret is not None: + return ret + + raise BaseException("CMake not found") def discover_ctest() -> str: @@ -42,7 +53,8 @@ def discover_ctest() -> str: Finds the ctest executable """ ret = shutil.which("ctest") - if ret is None: - raise BaseException("CTest not found") - return ret + if ret is not None: + return ret + + raise BaseException("CTest not found") From 2c0504ab23cb089ba98aedd55aeaf07ec7f978ec Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 10:32:53 +0200 Subject: [PATCH 19/53] Extending Clang tidy search --- src/Passes/site-packages/TasksCI/toolchain.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Passes/site-packages/TasksCI/toolchain.py b/src/Passes/site-packages/TasksCI/toolchain.py index e9d8027bfe..28a36f9274 100644 --- a/src/Passes/site-packages/TasksCI/toolchain.py +++ b/src/Passes/site-packages/TasksCI/toolchain.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import shutil +import os def discover_formatter() -> str: @@ -28,11 +29,22 @@ def discover_tidy() -> str: if ret is not None: return ret - for v in ["11", "10", "12"]: + for v in ["11", "11.0", "10", "10.0", "12", "12.0"]: ret = shutil.which("clang-tidy-{}".format(v)) if ret is not None: return ret + possible_commands = [ + "/usr/bin/clang-tidy-10", + "/usr/bin/clang-tidy-11", + "/usr/local/bin/clang-tidy-10", + "/usr/local/bin/clang-tidy-11", + ] + + for c in possible_commands: + if os.path.exists(c): + return c + raise BaseException("Clang tidy not found") From 1c70da9568a96524309d8fbd076ebbf1335a7a8e Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 10:35:21 +0200 Subject: [PATCH 20/53] Fixing apt install --- build/linux-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 3e97e7e073..0dfe03158e 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -2,8 +2,7 @@ steps: - script: | sudo apt update -y - sudo apt install -y clang-11 clang++-11 cmake clang-format-11 clang-tidy-11 - # sudo apt install -y llvm-toolchain-11 + sudo apt install -y clang-11 clang++ cmake clang-format-11 clang-tidy-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime export CC=clang-11 export CXX=clang++ From 60e0a02c2aa0bcb462ca684b1ce11b208054f6a1 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 10:37:30 +0200 Subject: [PATCH 21/53] Fixing apt install --- build/linux-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/linux-ci.yml b/build/linux-ci.yml index 0dfe03158e..f9f725a084 100644 --- a/build/linux-ci.yml +++ b/build/linux-ci.yml @@ -2,7 +2,7 @@ steps: - script: | sudo apt update -y - sudo apt install -y clang-11 clang++ cmake clang-format-11 clang-tidy-11 + sudo apt install -y clang-11 cmake clang-format-11 clang-tidy-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime export CC=clang-11 export CXX=clang++ From 008c9d409aca4a1d265c27a8b189bd7deb529760 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 11:08:12 +0200 Subject: [PATCH 22/53] Refactoring names and updating windows --- build/ci.yml | 4 +--- build/development.ps1 | 17 ---------------- build/{linux-ci.yml => passes-linux.yml} | 0 build/passes-windows.ps1 | 25 ++++++++++++++++++++++++ build/steps.yml | 4 ++-- 5 files changed, 28 insertions(+), 22 deletions(-) delete mode 100644 build/development.ps1 rename build/{linux-ci.yml => passes-linux.yml} (100%) create mode 100644 build/passes-windows.ps1 diff --git a/build/ci.yml b/build/ci.yml index 7e9dac51b5..9d93cc0552 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -27,7 +27,6 @@ schedules: always: true - jobs: - job: Build steps: @@ -39,11 +38,10 @@ jobs: - job: LinuxBuild steps: - - template: linux-ci.yml + - template: passes-linux.yml pool: vmImage: ubuntu-20.04 - - job: Style steps: - script: dotnet tool restore diff --git a/build/development.ps1 b/build/development.ps1 deleted file mode 100644 index 3180d9efe6..0000000000 --- a/build/development.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -$ErrorActionPreference = 'Stop' - -python --version -pip --version - -# Installing requirements for CI -cd ../src/Passes/ -pip install -r requirements.txt - -# Running CI -python manage runci - - -throw "Preventing other steps from running." diff --git a/build/linux-ci.yml b/build/passes-linux.yml similarity index 100% rename from build/linux-ci.yml rename to build/passes-linux.yml diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 new file mode 100644 index 0000000000..49f2b3f9b2 --- /dev/null +++ b/build/passes-windows.ps1 @@ -0,0 +1,25 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +$ErrorActionPreference = 'Stop' + +python --version +pip --version + +# Installing requirements for CI +cd ../src/Passes/ +pip install -r requirements.txt + +# Installing Clang, CMake and LLVM +if (!(Get-Command clang -ErrorAction SilentlyContinue)) { + choco install llvm --version=11.1.0 +} +if (!(Get-Command ninja -ErrorAction SilentlyContinue)) { + choco install ninja +} +if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { + choco install cmake +} + +# Running CI +python manage runci diff --git a/build/steps.yml b/build/steps.yml index 7dfdbab857..f9b1384764 100644 --- a/build/steps.yml +++ b/build/steps.yml @@ -1,6 +1,6 @@ steps: -- pwsh: ./development.ps1 - displayName: "Development setep" +- pwsh: ./passes-windows.ps1 + displayName: "Passes style, build & test" workingDirectory: $(System.DefaultWorkingDirectory)/build - pwsh: ./build.ps1 From ce61df0de503259517c435ce62ab0d69c8651207 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 11:10:40 +0200 Subject: [PATCH 23/53] Minor Windows CI update --- build/passes-windows.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 49f2b3f9b2..28573a78e3 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -14,9 +14,7 @@ pip install -r requirements.txt if (!(Get-Command clang -ErrorAction SilentlyContinue)) { choco install llvm --version=11.1.0 } -if (!(Get-Command ninja -ErrorAction SilentlyContinue)) { - choco install ninja -} + if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { choco install cmake } From 54d8725b68e424002c3178a7056a20a9ae2342c1 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 11:22:54 +0200 Subject: [PATCH 24/53] Improving search for excutables --- src/Passes/site-packages/TasksCI/toolchain.py | 60 ++++++++++++++++--- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/src/Passes/site-packages/TasksCI/toolchain.py b/src/Passes/site-packages/TasksCI/toolchain.py index 28a36f9274..25c5b22943 100644 --- a/src/Passes/site-packages/TasksCI/toolchain.py +++ b/src/Passes/site-packages/TasksCI/toolchain.py @@ -4,24 +4,39 @@ import shutil import os +extensions = [""] +try: + extensions = [x.lower() for x in os.getenv('PATHEXT').split(";")] +except: # noqa: E722 + pass -def discover_formatter() -> str: + +def discover_formatter_impl(ext: str) -> str: """ Finds the clang-format executable """ - ret = shutil.which("clang-format") + ret = shutil.which("clang-format{}".format(ext)) if ret is not None: return ret for v in ["11", "10", "12"]: - ret = shutil.which("clang-format-{}".format(v)) + ret = shutil.which("clang-format-{}{}".format(v, ext)) + if ret is not None: + return ret + + return None + + +def discover_formatter() -> str: + for ext in extensions: + ret = discover_formatter_impl(ext) if ret is not None: return ret raise BaseException("Clang format not found") -def discover_tidy() -> str: +def discover_tidy_impl(ext: str) -> str: """ Finds the clang-tidy executable """ @@ -30,7 +45,7 @@ def discover_tidy() -> str: return ret for v in ["11", "11.0", "10", "10.0", "12", "12.0"]: - ret = shutil.which("clang-tidy-{}".format(v)) + ret = shutil.which("clang-tidy-{}{}".format(v, ext)) if ret is not None: return ret @@ -45,28 +60,55 @@ def discover_tidy() -> str: if os.path.exists(c): return c + return None + + +def discover_tidy() -> str: + for ext in extensions: + ret = discover_tidy_impl(ext) + if ret is not None: + return ret + raise BaseException("Clang tidy not found") -def discover_cmake() -> str: +def discover_cmake_impl(ext: str) -> str: """ Finds the cmake executable """ - ret = shutil.which("cmake") + ret = shutil.which("cmake{}".format(ext)) if ret is not None: return ret + return None + + +def discover_cmake() -> str: + for ext in extensions: + ret = discover_cmake_impl(ext) + if ret is not None: + return ret + raise BaseException("CMake not found") -def discover_ctest() -> str: +def discover_ctest_impl(ext: str) -> str: """ Finds the ctest executable """ - ret = shutil.which("ctest") + ret = shutil.which("ctest{}".format(ext)) if ret is not None: return ret + return None + + +def discover_ctest() -> str: + for ext in extensions: + ret = discover_ctest_impl(ext) + if ret is not None: + return ret + raise BaseException("CTest not found") From b99273787ddef8c2d73943c22bb60ff9dfe1eb89 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 11:32:23 +0200 Subject: [PATCH 25/53] Adding Windos debug and OS X CI --- build/ci.yml | 6 ++++++ build/passes-mac.yml | 10 ++++++++++ build/passes-windows.ps1 | 11 +++++++++++ 3 files changed, 27 insertions(+) create mode 100644 build/passes-mac.yml diff --git a/build/ci.yml b/build/ci.yml index 9d93cc0552..d0781e563f 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -42,6 +42,12 @@ jobs: pool: vmImage: ubuntu-20.04 +- job: MacOSBuild + steps: + - template: passes-mac.yml + pool: + vmImage: macOS-latest + - job: Style steps: - script: dotnet tool restore diff --git a/build/passes-mac.yml b/build/passes-mac.yml new file mode 100644 index 0000000000..fee85314f5 --- /dev/null +++ b/build/passes-mac.yml @@ -0,0 +1,10 @@ + +steps: +- script: | + brew install llvm@11 + brew install cmake + + cd src/Passes/ + chmod +x manage + ./manage runci + diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 28573a78e3..346646d637 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -19,5 +19,16 @@ if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { choco install cmake } +refreshenv + +dir C:\Program Files\LLVM\bin\ +clang.exe --version + +cmake.exe --version + +clang-format.exe --version + +clang-tidy.exe --version + # Running CI python manage runci From 4e191d0d7e12133c815888354ebdc14cc3899ce9 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 11:38:18 +0200 Subject: [PATCH 26/53] Fixing OS X tests --- build/passes-linux.yml | 2 ++ build/passes-mac.yml | 2 ++ build/passes-windows.ps1 | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build/passes-linux.yml b/build/passes-linux.yml index f9f725a084..75584b7847 100644 --- a/build/passes-linux.yml +++ b/build/passes-linux.yml @@ -7,6 +7,8 @@ steps: export CC=clang-11 export CXX=clang++ cd src/Passes/ + + pip install -r requirements.txt chmod +x manage ./manage runci diff --git a/build/passes-mac.yml b/build/passes-mac.yml index fee85314f5..7a3cdcfc22 100644 --- a/build/passes-mac.yml +++ b/build/passes-mac.yml @@ -3,8 +3,10 @@ steps: - script: | brew install llvm@11 brew install cmake + brew install python@3.9 cd src/Passes/ + pip install -r requirements.txt chmod +x manage ./manage runci diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 346646d637..326037f604 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -21,7 +21,7 @@ if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { refreshenv -dir C:\Program Files\LLVM\bin\ +dir "C:\Program Files\LLVM\bin\" clang.exe --version cmake.exe --version From f69e47349cf8f2822dd93b26f8477685bf2d837b Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 11:46:31 +0200 Subject: [PATCH 27/53] Updating links and paths to executables --- build/passes-mac.yml | 2 ++ build/passes-windows.ps1 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/build/passes-mac.yml b/build/passes-mac.yml index 7a3cdcfc22..41e14046f9 100644 --- a/build/passes-mac.yml +++ b/build/passes-mac.yml @@ -4,6 +4,8 @@ steps: brew install llvm@11 brew install cmake brew install python@3.9 + brew link --overwrite python + export PATH="/usr/local/opt/llvm@11/bin:$PATH" cd src/Passes/ pip install -r requirements.txt diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 326037f604..f216929ffd 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -20,6 +20,8 @@ if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { } refreshenv +$env:Path += ";C:\Program Files\LLVM\bin\" + dir "C:\Program Files\LLVM\bin\" clang.exe --version From d1f79f5ac87e00e97bb69cd44f09242520352ca7 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 11:50:20 +0200 Subject: [PATCH 28/53] Updating OS X build --- build/passes-mac.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/passes-mac.yml b/build/passes-mac.yml index 41e14046f9..f28dbea0c5 100644 --- a/build/passes-mac.yml +++ b/build/passes-mac.yml @@ -4,8 +4,13 @@ steps: brew install llvm@11 brew install cmake brew install python@3.9 - brew link --overwrite python + brew unlink python@3.9 && brew link python@3.9 + + # Updating paths + export PATH="/usr/local/opt/python/libexec/bin:$PATH" export PATH="/usr/local/opt/llvm@11/bin:$PATH" + export LDFLAGS="-L/usr/local/opt/llvm@11/lib" + export CPPFLAGS="-I/usr/local/opt/llvm@11/include" cd src/Passes/ pip install -r requirements.txt From 25b8dd9b261367dcd15714a4123f090aff7d1240 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 12:05:48 +0200 Subject: [PATCH 29/53] Attempting to fix Windows build --- build/passes-mac.yml | 4 ++-- build/passes-windows.ps1 | 2 +- src/Passes/CMakeLists.txt | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/build/passes-mac.yml b/build/passes-mac.yml index f28dbea0c5..b4783bbef6 100644 --- a/build/passes-mac.yml +++ b/build/passes-mac.yml @@ -9,8 +9,8 @@ steps: # Updating paths export PATH="/usr/local/opt/python/libexec/bin:$PATH" export PATH="/usr/local/opt/llvm@11/bin:$PATH" - export LDFLAGS="-L/usr/local/opt/llvm@11/lib" - export CPPFLAGS="-I/usr/local/opt/llvm@11/include" + export LDFLAGS="${LDFLAGS} -L/usr/local/opt/llvm@11/lib" + export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/llvm@11/include" cd src/Passes/ pip install -r requirements.txt diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index f216929ffd..b21b1ea34b 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -23,7 +23,7 @@ refreshenv $env:Path += ";C:\Program Files\LLVM\bin\" -dir "C:\Program Files\LLVM\bin\" +dir "C:\Program Files\LLVM\" clang.exe --version cmake.exe --version diff --git a/src/Passes/CMakeLists.txt b/src/Passes/CMakeLists.txt index 60ed31a79e..f8fde2347e 100644 --- a/src/Passes/CMakeLists.txt +++ b/src/Passes/CMakeLists.txt @@ -1,8 +1,14 @@ cmake_minimum_required(VERSION 3.4.3) -project(QSharpPasses) +project(Passes) + +if (WIN32) + find_package(LLVM REQUIRED CONFIG PATHS "C:\Program Files\LLVM\" "C:\Program Files\LLVM\cmake") +else() + find_package(LLVM REQUIRED CONFIG) +endif() + -find_package(LLVM REQUIRED CONFIG) include(CheckCXXCompilerFlag) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") From c37361a61f56d03160435b44be7ecf89144c442a Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 12:09:18 +0200 Subject: [PATCH 30/53] Fixing CMake config --- src/Passes/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Passes/CMakeLists.txt b/src/Passes/CMakeLists.txt index f8fde2347e..016211e798 100644 --- a/src/Passes/CMakeLists.txt +++ b/src/Passes/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.4.3) project(Passes) if (WIN32) - find_package(LLVM REQUIRED CONFIG PATHS "C:\Program Files\LLVM\" "C:\Program Files\LLVM\cmake") + find_package(LLVM REQUIRED PATHS "C:\\Program Files\\LLVM\\" "C:\\Program Files\\LLVM\\cmake" CONFIG ) else() find_package(LLVM REQUIRED CONFIG) endif() From 81ed1631271c3a717233da1fe375ebfd16a12db7 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 12:20:04 +0200 Subject: [PATCH 31/53] Attempting to fix Windows path --- src/Passes/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Passes/CMakeLists.txt b/src/Passes/CMakeLists.txt index 016211e798..56e3fe8c36 100644 --- a/src/Passes/CMakeLists.txt +++ b/src/Passes/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.4.3) project(Passes) if (WIN32) - find_package(LLVM REQUIRED PATHS "C:\\Program Files\\LLVM\\" "C:\\Program Files\\LLVM\\cmake" CONFIG ) + find_package(LLVM REQUIRED PATHS "C:\\Program Files\\LLVM\\lib" CONFIG ) else() find_package(LLVM REQUIRED CONFIG) endif() From abd1c7cf71123cd9da20e2a65ee3908ed665c229 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 13:00:56 +0200 Subject: [PATCH 32/53] Adding message to CMake --- src/Passes/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Passes/CMakeLists.txt b/src/Passes/CMakeLists.txt index 56e3fe8c36..c2f9504a6c 100644 --- a/src/Passes/CMakeLists.txt +++ b/src/Passes/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.4.3) project(Passes) if (WIN32) + message(STATUS "Adding C:\\Program Files\\LLVM\\lib to LLVM paths") find_package(LLVM REQUIRED PATHS "C:\\Program Files\\LLVM\\lib" CONFIG ) else() find_package(LLVM REQUIRED CONFIG) From 05d01c27080b4bfc156cf3c0394713e0189f3abb Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 15:47:30 +0200 Subject: [PATCH 33/53] Updating with VCWhere --- build/passes-windows.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index b21b1ea34b..4e425665f5 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -32,5 +32,12 @@ clang-format.exe --version clang-tidy.exe --version + +$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" +$vcvarspath = &$vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath +Write-Output "vc tools located at: $vcvarspath" +cmd.exe /c "call `"$vcvarspath\VC\Auxiliary\Build\vcvars64.bat`" + + # Running CI python manage runci From 4dc626f92330bec489e42113317420d30a4e69be Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 17:26:58 +0200 Subject: [PATCH 34/53] Updating CI for Windows --- build/passes-windows.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 4e425665f5..7c532f134a 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -32,11 +32,13 @@ clang-format.exe --version clang-tidy.exe --version +cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt" -$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -$vcvarspath = &$vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -Write-Output "vc tools located at: $vcvarspath" -cmd.exe /c "call `"$vcvarspath\VC\Auxiliary\Build\vcvars64.bat`" +Get-Content "$env:temp\vcvars.txt" | Foreach-Object { + if ($_ -match "^(.*?)=(.*)$") { + Set-Content "env:\$($matches[1])" $matches[2] + } +} # Running CI From 0acead51c03e398a5b331fb229f3e0d80f14beac Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 17:45:19 +0200 Subject: [PATCH 35/53] Disabling CMake install --- build/passes-windows.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 7c532f134a..330e62d007 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -15,9 +15,9 @@ if (!(Get-Command clang -ErrorAction SilentlyContinue)) { choco install llvm --version=11.1.0 } -if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { - choco install cmake -} +# if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { +# choco install cmake +# } refreshenv $env:Path += ";C:\Program Files\LLVM\bin\" From 287fffd003e3885efe9b27c817391582d407929e Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 17:56:23 +0200 Subject: [PATCH 36/53] Changing to Conda package manager --- build/passes-windows.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 330e62d007..7fbf15bb0b 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -12,7 +12,8 @@ pip install -r requirements.txt # Installing Clang, CMake and LLVM if (!(Get-Command clang -ErrorAction SilentlyContinue)) { - choco install llvm --version=11.1.0 + conda install -c conda-forge llvm-tools=11.1.0 + conda install -c conda-forge llvmdev=11.1.0 } # if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { From 0cca8ec22cfcfd592462f67b13d7d2661e8e26c1 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 18:03:09 +0200 Subject: [PATCH 37/53] Adding conda environment --- build/passes-windows.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 7fbf15bb0b..97d0742036 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -10,6 +10,8 @@ pip --version cd ../src/Passes/ pip install -r requirements.txt +& $env:CONDA + # Installing Clang, CMake and LLVM if (!(Get-Command clang -ErrorAction SilentlyContinue)) { conda install -c conda-forge llvm-tools=11.1.0 From 69c7c62a68a681af8204b0abfbe1effcf71f745b Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 18:03:39 +0200 Subject: [PATCH 38/53] Adding conda environment --- build/passes-windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index 97d0742036..a166a79cbb 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -10,7 +10,7 @@ pip --version cd ../src/Passes/ pip install -r requirements.txt -& $env:CONDA +& $env:CONDA\conda # Installing Clang, CMake and LLVM if (!(Get-Command clang -ErrorAction SilentlyContinue)) { From b2e50590f5f895c3a617961cde23a1f3a13f07e4 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 18:11:37 +0200 Subject: [PATCH 39/53] Updating the environment --- build/passes-windows.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index a166a79cbb..bfb1f6f786 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -$ErrorActionPreference = 'Stop' +$ErrorActionPreference = 'Continue' python --version pip --version @@ -10,7 +10,11 @@ pip --version cd ../src/Passes/ pip install -r requirements.txt -& $env:CONDA\conda +$env:Path += ";C:\Miniconda\" +$env:Path += ";C:\Miniconda\bin\" +ls $env:CONDA + +& $env:CONDA\conda.exe # Installing Clang, CMake and LLVM if (!(Get-Command clang -ErrorAction SilentlyContinue)) { From 5df0095b0a558d29d41dffb5225bddf58b7b6b55 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 18:21:13 +0200 Subject: [PATCH 40/53] Updating conda --- build/passes-windows.ps1 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index bfb1f6f786..df41f22721 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -10,16 +10,12 @@ pip --version cd ../src/Passes/ pip install -r requirements.txt -$env:Path += ";C:\Miniconda\" -$env:Path += ";C:\Miniconda\bin\" -ls $env:CONDA - -& $env:CONDA\conda.exe + # Installing Clang, CMake and LLVM if (!(Get-Command clang -ErrorAction SilentlyContinue)) { - conda install -c conda-forge llvm-tools=11.1.0 - conda install -c conda-forge llvmdev=11.1.0 + & (Join-Path $env:CONDA scripts conda.exe) install -c conda-forge llvm-tools=11.1.0 + & (Join-Path $env:CONDA scripts conda.exe) install -c conda-forge llvmdev=11.1.0 } # if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { From 76cad51e20af5b827b6ff1e817e48e637d466373 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Mon, 2 Aug 2021 18:28:53 +0200 Subject: [PATCH 41/53] Attempting to load LLVM in CMake --- build/passes-windows.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index df41f22721..fb3a46ff8b 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -23,7 +23,8 @@ if (!(Get-Command clang -ErrorAction SilentlyContinue)) { # } refreshenv -$env:Path += ";C:\Program Files\LLVM\bin\" +$env:Path += ";C:\Miniconda\Library\LLVM\bin\" +$env:LLVM = "C:\Miniconda\Library\LLVM\" dir "C:\Program Files\LLVM\" From be473a6f1898b66708f697f3baa8b7f8995e25d7 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Wed, 4 Aug 2021 14:57:27 +0200 Subject: [PATCH 42/53] Disbaling Windows CI --- build/passes-windows.ps1 | 14 -------------- build/steps.yml | 8 +++++--- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/build/passes-windows.ps1 b/build/passes-windows.ps1 index fb3a46ff8b..9ca5e44267 100644 --- a/build/passes-windows.ps1 +++ b/build/passes-windows.ps1 @@ -18,24 +18,10 @@ if (!(Get-Command clang -ErrorAction SilentlyContinue)) { & (Join-Path $env:CONDA scripts conda.exe) install -c conda-forge llvmdev=11.1.0 } -# if (!(Get-Command cmake -ErrorAction SilentlyContinue)) { -# choco install cmake -# } - refreshenv $env:Path += ";C:\Miniconda\Library\LLVM\bin\" $env:LLVM = "C:\Miniconda\Library\LLVM\" - -dir "C:\Program Files\LLVM\" -clang.exe --version - -cmake.exe --version - -clang-format.exe --version - -clang-tidy.exe --version - cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt" Get-Content "$env:temp\vcvars.txt" | Foreach-Object { diff --git a/build/steps.yml b/build/steps.yml index f9b1384764..7e727de392 100644 --- a/build/steps.yml +++ b/build/steps.yml @@ -1,7 +1,9 @@ steps: -- pwsh: ./passes-windows.ps1 - displayName: "Passes style, build & test" - workingDirectory: $(System.DefaultWorkingDirectory)/build +# Windows CI is disabled until we have a fully working +# configuration of LLVM with CMake +# - pwsh: ./passes-windows.ps1 +# displayName: "Passes style, build & test" +# workingDirectory: $(System.DefaultWorkingDirectory)/build - pwsh: ./build.ps1 displayName: "Build all" From f622d68e63907686ae61ffb55fc29c95dc88a3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20F=2E=20R=C3=B8nnow?= <574350+troelsfr@users.noreply.github.com> Date: Thu, 5 Aug 2021 07:37:08 +0200 Subject: [PATCH 43/53] Update build/test.ps1 --- build/test.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/build/test.ps1 b/build/test.ps1 index 81837e4ba9..9f9aee059d 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -38,7 +38,6 @@ function Test-One { } } -python Test-One '../QsCompiler.sln' Test-One '../QsFmt.sln' From 7bb0516b4f627fa709f2f28a6c9fd9960fcf00a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20F=2E=20R=C3=B8nnow?= <574350+troelsfr@users.noreply.github.com> Date: Thu, 5 Aug 2021 07:39:29 +0200 Subject: [PATCH 44/53] Update build/passes-linux.yml --- build/passes-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/passes-linux.yml b/build/passes-linux.yml index 75584b7847..d29af4b47c 100644 --- a/build/passes-linux.yml +++ b/build/passes-linux.yml @@ -1,6 +1,7 @@ steps: -- script: | +- name: Linux Passes Build & Tests + script: | sudo apt update -y sudo apt install -y clang-11 cmake clang-format-11 clang-tidy-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime @@ -11,4 +12,3 @@ steps: pip install -r requirements.txt chmod +x manage ./manage runci - From 20b15d4d92d9133c63b60ee7ef01c91d98e405f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20F=2E=20R=C3=B8nnow?= <574350+troelsfr@users.noreply.github.com> Date: Thu, 5 Aug 2021 07:41:15 +0200 Subject: [PATCH 45/53] Update src/Passes/site-packages/TasksCI/toolchain.py --- src/Passes/site-packages/TasksCI/toolchain.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Passes/site-packages/TasksCI/toolchain.py b/src/Passes/site-packages/TasksCI/toolchain.py index 25c5b22943..4f83c7cd58 100644 --- a/src/Passes/site-packages/TasksCI/toolchain.py +++ b/src/Passes/site-packages/TasksCI/toolchain.py @@ -81,6 +81,9 @@ def discover_cmake_impl(ext: str) -> str: if ret is not None: return ret + # Test more locations here + + # Finally returns None to indicate failed attempt at finding CMake return None From 2b812339552358c11f0e093352b2c607a1a9373a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20F=2E=20R=C3=B8nnow?= <574350+troelsfr@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:37:46 +0200 Subject: [PATCH 46/53] Update build/passes-linux.yml --- build/passes-linux.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/build/passes-linux.yml b/build/passes-linux.yml index d29af4b47c..289c696516 100644 --- a/build/passes-linux.yml +++ b/build/passes-linux.yml @@ -1,6 +1,5 @@ steps: -- name: Linux Passes Build & Tests script: | sudo apt update -y sudo apt install -y clang-11 cmake clang-format-11 clang-tidy-11 From b534ee2d0024fd27b3ab99bbf850199ac3617b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20F=2E=20R=C3=B8nnow?= <574350+troelsfr@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:38:46 +0200 Subject: [PATCH 47/53] Update build/passes-linux.yml --- build/passes-linux.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/build/passes-linux.yml b/build/passes-linux.yml index 289c696516..2f701a7e58 100644 --- a/build/passes-linux.yml +++ b/build/passes-linux.yml @@ -1,5 +1,6 @@ steps: + displayName: Linux build and CI for passes script: | sudo apt update -y sudo apt install -y clang-11 cmake clang-format-11 clang-tidy-11 From 4e50ac1d5da527567caa2cf2c1f3f3496b31a400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20F=2E=20R=C3=B8nnow?= <574350+troelsfr@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:41:40 +0200 Subject: [PATCH 48/53] Update build/passes-linux.yml --- build/passes-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/passes-linux.yml b/build/passes-linux.yml index 2f701a7e58..dad71bfb6d 100644 --- a/build/passes-linux.yml +++ b/build/passes-linux.yml @@ -1,6 +1,6 @@ steps: - displayName: Linux build and CI for passes +- displayName: "Linux build and CI for passes" script: | sudo apt update -y sudo apt install -y clang-11 cmake clang-format-11 clang-tidy-11 From 2ab06388a9960b8c67609813249319a364c09f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20F=2E=20R=C3=B8nnow?= <574350+troelsfr@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:42:06 +0200 Subject: [PATCH 49/53] Update build/passes-linux.yml --- build/passes-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/passes-linux.yml b/build/passes-linux.yml index dad71bfb6d..770cda62b0 100644 --- a/build/passes-linux.yml +++ b/build/passes-linux.yml @@ -1,6 +1,6 @@ steps: -- displayName: "Linux build and CI for passes" +- displayName: "Linux build and CI for passes" script: | sudo apt update -y sudo apt install -y clang-11 cmake clang-format-11 clang-tidy-11 From 429e5219598649ebd16df8ce53b9a32c67948e4d Mon Sep 17 00:00:00 2001 From: bettinaheim <34236215+bettinaheim@users.noreply.github.com> Date: Mon, 9 Aug 2021 23:40:40 -0700 Subject: [PATCH 50/53] Build issue --- build/passes-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/passes-linux.yml b/build/passes-linux.yml index 770cda62b0..58f666b149 100644 --- a/build/passes-linux.yml +++ b/build/passes-linux.yml @@ -1,7 +1,6 @@ steps: -- displayName: "Linux build and CI for passes" - script: | +- script: | sudo apt update -y sudo apt install -y clang-11 cmake clang-format-11 clang-tidy-11 sudo apt-get install -y llvm-11 lldb-11 llvm-11-dev libllvm11 llvm-11-runtime @@ -12,3 +11,4 @@ steps: pip install -r requirements.txt chmod +x manage ./manage runci + displayName: Linux build and CI for passes From bb2a40e42ee7d194d1178cdcbaf1bf568490d086 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Tue, 10 Aug 2021 09:01:14 +0200 Subject: [PATCH 51/53] Fixing style --- src/Passes/libs/OpsCounter/LibOpsCounter.cpp | 43 +++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Passes/libs/OpsCounter/LibOpsCounter.cpp b/src/Passes/libs/OpsCounter/LibOpsCounter.cpp index a07379f656..65a7a238b9 100644 --- a/src/Passes/libs/OpsCounter/LibOpsCounter.cpp +++ b/src/Passes/libs/OpsCounter/LibOpsCounter.cpp @@ -16,27 +16,30 @@ llvm::PassPluginLibraryInfo getOpsCounterPluginInfo() using namespace microsoft::quantum; using namespace llvm; - return {LLVM_PLUGIN_API_VERSION, "OpsCounter", LLVM_VERSION_STRING, [](PassBuilder& pb) { - // Registering the printer - pb.registerPipelineParsingCallback( - [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) { - if (name == "print") - { - fpm.addPass(OpsCounterPrinter(llvm::errs())); - return true; - } - return false; - }); - - pb.registerVectorizerStartEPCallback( - [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) { + return { + LLVM_PLUGIN_API_VERSION, "OpsCounter", LLVM_VERSION_STRING, + [](PassBuilder& pb) + { + // Registering the printer + pb.registerPipelineParsingCallback( + [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) + { + if (name == "print") + { fpm.addPass(OpsCounterPrinter(llvm::errs())); - }); - - // Registering the analysis module - pb.registerAnalysisRegistrationCallback( - [](FunctionAnalysisManager& fam) { fam.registerPass([] { return OpsCounterAnalytics(); }); }); - }}; + return true; + } + return false; + }); + + pb.registerVectorizerStartEPCallback( + [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) + { fpm.addPass(OpsCounterPrinter(llvm::errs())); }); + + // Registering the analysis module + pb.registerAnalysisRegistrationCallback([](FunctionAnalysisManager& fam) + { fam.registerPass([] { return OpsCounterAnalytics(); }); }); + }}; } } // namespace From 16d4cd33f8e2deca38a4598212407076a571a5ad Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Tue, 10 Aug 2021 09:13:32 +0200 Subject: [PATCH 52/53] Fixing style --- .../LibExpandStaticAllocation.cpp | 28 ++++++------ src/Passes/libs/OpsCounter/LibOpsCounter.cpp | 43 +++++++++---------- .../LibQubitAllocationAnalysis.cpp | 43 +++++++++---------- 3 files changed, 52 insertions(+), 62 deletions(-) diff --git a/src/Passes/libs/ExpandStaticAllocation/LibExpandStaticAllocation.cpp b/src/Passes/libs/ExpandStaticAllocation/LibExpandStaticAllocation.cpp index e73a64b7d8..fa4291001e 100644 --- a/src/Passes/libs/ExpandStaticAllocation/LibExpandStaticAllocation.cpp +++ b/src/Passes/libs/ExpandStaticAllocation/LibExpandStaticAllocation.cpp @@ -15,23 +15,19 @@ llvm::PassPluginLibraryInfo getExpandStaticAllocationPluginInfo() using namespace microsoft::quantum; using namespace llvm; - return { - LLVM_PLUGIN_API_VERSION, "ExpandStaticAllocation", LLVM_VERSION_STRING, - [](PassBuilder& pb) - { - // Registering the pass - pb.registerPipelineParsingCallback( - [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) - { - if (name == "expand-static-allocation") - { - fpm.addPass(ExpandStaticAllocationPass()); - return true; - } + return {LLVM_PLUGIN_API_VERSION, "ExpandStaticAllocation", LLVM_VERSION_STRING, [](PassBuilder& pb) { + // Registering the pass + pb.registerPipelineParsingCallback( + [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) { + if (name == "expand-static-allocation") + { + fpm.addPass(ExpandStaticAllocationPass()); + return true; + } - return false; - }); - }}; + return false; + }); + }}; } } // namespace diff --git a/src/Passes/libs/OpsCounter/LibOpsCounter.cpp b/src/Passes/libs/OpsCounter/LibOpsCounter.cpp index 65a7a238b9..a07379f656 100644 --- a/src/Passes/libs/OpsCounter/LibOpsCounter.cpp +++ b/src/Passes/libs/OpsCounter/LibOpsCounter.cpp @@ -16,30 +16,27 @@ llvm::PassPluginLibraryInfo getOpsCounterPluginInfo() using namespace microsoft::quantum; using namespace llvm; - return { - LLVM_PLUGIN_API_VERSION, "OpsCounter", LLVM_VERSION_STRING, - [](PassBuilder& pb) - { - // Registering the printer - pb.registerPipelineParsingCallback( - [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) - { - if (name == "print") - { + return {LLVM_PLUGIN_API_VERSION, "OpsCounter", LLVM_VERSION_STRING, [](PassBuilder& pb) { + // Registering the printer + pb.registerPipelineParsingCallback( + [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) { + if (name == "print") + { + fpm.addPass(OpsCounterPrinter(llvm::errs())); + return true; + } + return false; + }); + + pb.registerVectorizerStartEPCallback( + [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) { fpm.addPass(OpsCounterPrinter(llvm::errs())); - return true; - } - return false; - }); - - pb.registerVectorizerStartEPCallback( - [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) - { fpm.addPass(OpsCounterPrinter(llvm::errs())); }); - - // Registering the analysis module - pb.registerAnalysisRegistrationCallback([](FunctionAnalysisManager& fam) - { fam.registerPass([] { return OpsCounterAnalytics(); }); }); - }}; + }); + + // Registering the analysis module + pb.registerAnalysisRegistrationCallback( + [](FunctionAnalysisManager& fam) { fam.registerPass([] { return OpsCounterAnalytics(); }); }); + }}; } } // namespace diff --git a/src/Passes/libs/QubitAllocationAnalysis/LibQubitAllocationAnalysis.cpp b/src/Passes/libs/QubitAllocationAnalysis/LibQubitAllocationAnalysis.cpp index ac03bc1f41..991bcd2f08 100644 --- a/src/Passes/libs/QubitAllocationAnalysis/LibQubitAllocationAnalysis.cpp +++ b/src/Passes/libs/QubitAllocationAnalysis/LibQubitAllocationAnalysis.cpp @@ -16,31 +16,28 @@ llvm::PassPluginLibraryInfo getQubitAllocationAnalysisPluginInfo() using namespace microsoft::quantum; using namespace llvm; - return { - LLVM_PLUGIN_API_VERSION, "QubitAllocationAnalysis", LLVM_VERSION_STRING, - [](PassBuilder& pb) - { - // Registering a printer for the anaylsis - pb.registerPipelineParsingCallback( - [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) - { - if (name == "print") - { + return {LLVM_PLUGIN_API_VERSION, "QubitAllocationAnalysis", LLVM_VERSION_STRING, [](PassBuilder& pb) { + // Registering a printer for the anaylsis + pb.registerPipelineParsingCallback( + [](StringRef name, FunctionPassManager& fpm, ArrayRef /*unused*/) { + if (name == "print") + { + fpm.addPass(QubitAllocationAnalysisPrinter(llvm::errs())); + return true; + } + return false; + }); + + pb.registerVectorizerStartEPCallback( + [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) { fpm.addPass(QubitAllocationAnalysisPrinter(llvm::errs())); - return true; - } - return false; - }); - - pb.registerVectorizerStartEPCallback( - [](llvm::FunctionPassManager& fpm, llvm::PassBuilder::OptimizationLevel /*level*/) - { fpm.addPass(QubitAllocationAnalysisPrinter(llvm::errs())); }); + }); - // Registering the analysis module - pb.registerAnalysisRegistrationCallback( - [](FunctionAnalysisManager& fam) - { fam.registerPass([] { return QubitAllocationAnalysisAnalytics(); }); }); - }}; + // Registering the analysis module + pb.registerAnalysisRegistrationCallback([](FunctionAnalysisManager& fam) { + fam.registerPass([] { return QubitAllocationAnalysisAnalytics(); }); + }); + }}; } } // namespace From 43a97f8365b6935a76af3228950dac64c6b4c731 Mon Sep 17 00:00:00 2001 From: "Troels F. Roennow" Date: Tue, 10 Aug 2021 10:11:05 +0200 Subject: [PATCH 53/53] Fixing missing function --- .../libs/QubitAllocationAnalysis/QubitAllocationAnalysis.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Passes/libs/QubitAllocationAnalysis/QubitAllocationAnalysis.cpp b/src/Passes/libs/QubitAllocationAnalysis/QubitAllocationAnalysis.cpp index 60ef6aaeb7..a3f130e591 100644 --- a/src/Passes/libs/QubitAllocationAnalysis/QubitAllocationAnalysis.cpp +++ b/src/Passes/libs/QubitAllocationAnalysis/QubitAllocationAnalysis.cpp @@ -65,10 +65,13 @@ namespace quantum void QubitAllocationAnalysisAnalytics::analyseCall(Instruction& instruction) { // Skipping debug code + /* + TODO(tfr): enable in LLVM12 if (instruction.isDebugOrPseudoInst()) { return; } + */ // Recovering the call information auto* call_instr = llvm::dyn_cast(&instruction);