Skip to content

Commit fc38576

Browse files
authored
Upgrade to LLVM 17 (#193)
Closes #132. Upgrade the qss-compiler to LLVM 17.0.5. This is a major change and has a corresponding significant diff. Work to be done before coming out of draft - [x] Building - [x] Tests passing - [x] Tested internally with hardware
1 parent 0d65d9e commit fc38576

File tree

266 files changed

+4516
-3372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+4516
-3372
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ list(APPEND RUN_CLANG_TIDY_BIN_ARGS
246246
-clang-apply-replacements-binary ${CLANG_AR_BIN}
247247
-style=file
248248
-quiet
249-
-header-filter="${CMAKE_SOURCE_DIR}/[^b].*"
250249
)
251250

252251
# run clang-tidy linter only when compiling with clang (compiler flags may be

cmake/AddQSSC.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,3 @@ macro(package_add_test_with_libs TESTNAME)
349349
package_add_test(${TESTNAME} ${ARG_UNPARSED_ARGUMENTS})
350350
target_link_libraries(${TESTNAME} GTest::gtest_main GTest::gtest ${ARG_LIBRARIES})
351351
endmacro()
352-
353-
354-
# Version adapter for add_mlir_doc during transition from LLVM 12 to newer
355-
# (order of parameters differs)
356-
function(qssc_add_mlir_doc doc_filename output_file output_directory command)
357-
if("${LLVM_VERSION_MAJOR}" EQUAL "12")
358-
add_mlir_doc(${doc_filename} ${command} ${output_file} ${output_directory})
359-
else()
360-
add_mlir_doc(${doc_filename} ${output_file} ${output_directory} ${command})
361-
endif()
362-
endfunction()

cmake/apple-clang.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ set (CXX_FLAGS
1717
-fno-omit-frame-pointer
1818
-Werror
1919
)
20+
21+
option(DETECT_TARGET_TRIPLE "Automatically detect the target triple for clang" ON)
22+
if (DETECT_TARGET_TRIPLE)
23+
execute_process (
24+
COMMAND bash -c "llvm-config --host-target | tr -d '\n'"
25+
OUTPUT_VARIABLE LLVM_TARGET_TRIPLE
26+
)
27+
list(APPEND CXX_FLAGS "-target ${LLVM_TARGET_TRIPLE}")
28+
endif()
29+
2030
list (JOIN CXX_FLAGS " " CXX_FLAGS_STR)
2131
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_STR}")
2232

cmake/llvm-clang.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ set (CXX_FLAGS
1919

2020
-Werror
2121
)
22+
23+
option(DETECT_TARGET_TRIPLE "Automatically detect the target triple for clang" ON)
24+
if (DETECT_TARGET_TRIPLE)
25+
execute_process (
26+
COMMAND bash -c "llvm-config --host-target | tr -d '\n'"
27+
OUTPUT_VARIABLE LLVM_TARGET_TRIPLE
28+
)
29+
list(APPEND CXX_FLAGS "-target ${LLVM_TARGET_TRIPLE}")
30+
endif()
31+
2232
list (JOIN CXX_FLAGS " " CXX_FLAGS_STR)
2333
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_STR}")
2434

conan/clang-tools-extra/conanfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
import os
2121
import shutil
2222

23-
LLVM_TAG = "llvmorg-14.0.6"
23+
LLVM_TAG = "llvmorg-17.0.5"
2424

2525

2626
class ClangToolsExtraConan(ConanFile):
2727
name = "clang-tools-extra"
28-
version = "14.0.6"
28+
version = "17.0.5-0"
2929
description = "A toolkit for analysis of c++ projects."
3030
license = "Apache-2.0 WITH LLVM-exception"
3131
topics = ("conan", "llvm", "clang-tools-extra")

conan/llvm/conanfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
from conan.tools.apple import is_apple_os
2323

24-
LLVM_TAG = "llvmorg-14.0.6"
24+
LLVM_TAG = "llvmorg-17.0.5"
2525

2626

2727
class LLVMConan(ConanFile):
2828
name = "llvm"
29-
version = "14.0.6-2"
29+
version = "17.0.5-0"
3030
description = (
3131
"A toolkit for the construction of highly optimized compilers,"
3232
"optimizers, and runtime environments."

conandata.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ requirements:
22
- gtest/1.11.0
33
- libzip/1.10.1
44
- zlib/1.2.13
5+
- zstd/1.5.5
56
- nlohmann_json/3.9.1
67
- pybind11/2.10.1
7-
- clang-tools-extra/14.0.6@
8-
- llvm/14.0.6-2@
8+
- clang-tools-extra/17.0.5-0@
9+
- llvm/17.0.5-0@
910
- qasm/0.3.0@qss/stable

conanfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class QSSCompilerConan(ConanFile):
3434
author = "IBM Quantum development team"
3535
topics = ("Compiler", "Scheduler", "OpenQASM3")
3636
description = "An LLVM- and MLIR-based Quantum compiler that consumes OpenQASM 3.0"
37-
generators = ["CMakeToolchain", "CMakeDeps"]
37+
generators = ["CMakeToolchain", "CMakeDeps", "VirtualBuildEnv"]
3838
exports_sources = "*"
3939

4040
def requirements(self):
@@ -46,6 +46,10 @@ def configure(self):
4646
if self.settings.os == "Macos":
4747
self.options["qasm"].shared = True
4848

49+
# LLVM prefers ZSTD shared libraries by default now so we force building
50+
# https://github.com/llvm/llvm-project/commit/fc1da043f4f9198303abd6f643cf23439115ce73
51+
self.options["zstd"].shared = True
52+
4953
def build_requirements(self):
5054
tool_pkgs = ["llvm", "clang-tools-extra"]
5155
# Add packages necessary for build.

include/Arguments/Arguments.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
namespace qssc::arguments {
3636

37-
using ArgumentType = std::variant<llvm::Optional<double>>;
37+
using ArgumentType = std::variant<std::optional<double>>;
3838
using OptDiagnosticCallback = std::optional<qssc::DiagnosticCallback>;
3939

4040
class ArgumentSource {

include/Arguments/Signature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/ADT/StringRef.h"
3030
#include "llvm/Support/Error.h"
3131

32+
#include <map>
3233
#include <string>
3334
#include <vector>
3435

@@ -58,7 +59,8 @@ using PatchPointVector = std::vector<PatchPoint>;
5859

5960
struct Signature {
6061
// TODO consider deduplicating strings by using UniqueStringSaver
61-
llvm::StringMap<std::vector<PatchPoint>> patchPointsByBinary;
62+
// Use std::map instead of StringMap to preserve order
63+
std::map<std::string, std::vector<PatchPoint>> patchPointsByBinary;
6264

6365
public:
6466
void addParameterPatchPoint(llvm::StringRef expression,

0 commit comments

Comments
 (0)