diff --git a/bolt/runtime/CMakeLists.txt b/bolt/runtime/CMakeLists.txt --- a/bolt/runtime/CMakeLists.txt +++ b/bolt/runtime/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) include(CheckIncludeFiles) include(GNUInstallDirs) diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h @@ -54,10 +54,10 @@ }; struct HungarianNotationOption { - HungarianNotationOption() : HPType(HungarianPrefixType::HPT_Off) {} + HungarianNotationOption() = default; std::optional Case; - HungarianPrefixType HPType; + HungarianPrefixType HPType = HungarianPrefixType::HPT_Off; llvm::StringMap General; llvm::StringMap CString; llvm::StringMap PrimitiveType; diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt --- a/clang-tools-extra/clangd/CMakeLists.txt +++ b/clang-tools-extra/clangd/CMakeLists.txt @@ -148,6 +148,7 @@ DEPENDS omp_gen + ClangDriverOptions ) # Include generated CompletionModel headers. diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -11,6 +11,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(Clang) set(CLANG_BUILT_STANDALONE TRUE) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() endif() # Must go below project(..) diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -11160,7 +11160,7 @@ if (Kind == ParamKindTy::Uniform) return false; - if (Kind == ParamKindTy::LinearUVal || ParamKindTy::LinearRef) + if (Kind == ParamKindTy::LinearUVal || Kind == ParamKindTy::LinearRef) return false; if ((Kind == ParamKindTy::Linear || Kind == ParamKindTy::LinearVal) && diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -1125,7 +1125,8 @@ Style.IndentWidth; } - if (NextNonComment->is(tok::l_brace) && NextNonComment->is(BK_Block)) { + if ((NextNonComment->is(tok::l_brace) && NextNonComment->is(BK_Block)) || + (Style.isVerilog() && Keywords.isVerilogBegin(*NextNonComment))) { if (Current.NestingLevel == 0 || (Style.LambdaBodyIndentation == FormatStyle::LBI_OuterScope && State.NextToken->is(TT_LambdaLBrace))) { diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -1068,6 +1068,7 @@ kw_delay_mode_zero = &IdentTable.get("delay_mode_zero"); kw_disable = &IdentTable.get("disable"); kw_dist = &IdentTable.get("dist"); + kw_edge = &IdentTable.get("edge"); kw_elsif = &IdentTable.get("elsif"); kw_end = &IdentTable.get("end"); kw_end_keywords = &IdentTable.get("end_keywords"); @@ -1113,10 +1114,12 @@ kw_macromodule = &IdentTable.get("macromodule"); kw_matches = &IdentTable.get("matches"); kw_medium = &IdentTable.get("medium"); + kw_negedge = &IdentTable.get("negedge"); kw_nounconnected_drive = &IdentTable.get("nounconnected_drive"); kw_output = &IdentTable.get("output"); kw_packed = &IdentTable.get("packed"); kw_parameter = &IdentTable.get("parameter"); + kw_posedge = &IdentTable.get("posedge"); kw_primitive = &IdentTable.get("primitive"); kw_priority = &IdentTable.get("priority"); kw_program = &IdentTable.get("program"); @@ -1198,132 +1201,71 @@ // Some keywords are not included here because they don't need special // treatment like `showcancelled` or they should be treated as identifiers // like `int` and `logic`. - VerilogExtraKeywords = - std::unordered_set({kw_always, - kw_always_comb, - kw_always_ff, - kw_always_latch, - kw_assert, - kw_assign, - kw_assume, - kw_automatic, - kw_before, - kw_begin, - kw_bins, - kw_binsof, - kw_casex, - kw_casez, - kw_celldefine, - kw_checker, - kw_clocking, - kw_constraint, - kw_cover, - kw_covergroup, - kw_coverpoint, - kw_disable, - kw_dist, - kw_end, - kw_endcase, - kw_endchecker, - kw_endclass, - kw_endclocking, - kw_endfunction, - kw_endgenerate, - kw_endgroup, - kw_endinterface, - kw_endmodule, - kw_endpackage, - kw_endprimitive, - kw_endprogram, - kw_endproperty, - kw_endsequence, - kw_endspecify, - kw_endtable, - kw_endtask, - kw_extends, - kw_final, - kw_foreach, - kw_forever, - kw_fork, - kw_function, - kw_generate, - kw_highz0, - kw_highz1, - kw_iff, - kw_ifnone, - kw_ignore_bins, - kw_illegal_bins, - kw_implements, - kw_import, - kw_initial, - kw_inout, - kw_input, - kw_inside, - kw_interconnect, - kw_interface, - kw_intersect, - kw_join, - kw_join_any, - kw_join_none, - kw_large, - kw_let, - kw_local, - kw_localparam, - kw_macromodule, - kw_matches, - kw_medium, - kw_output, - kw_package, - kw_packed, - kw_parameter, - kw_primitive, - kw_priority, - kw_program, - kw_property, - kw_pull0, - kw_pull1, - kw_pure, - kw_rand, - kw_randc, - kw_randcase, - kw_randsequence, - kw_ref, - kw_repeat, - kw_sample, - kw_scalared, - kw_sequence, - kw_small, - kw_soft, - kw_solve, - kw_specify, - kw_specparam, - kw_strong0, - kw_strong1, - kw_supply0, - kw_supply1, - kw_table, - kw_tagged, - kw_task, - kw_tri, - kw_tri0, - kw_tri1, - kw_triand, - kw_trior, - kw_trireg, - kw_unique, - kw_unique0, - kw_uwire, - kw_var, - kw_vectored, - kw_wand, - kw_weak0, - kw_weak1, - kw_wildcard, - kw_wire, - kw_with, - kw_wor, - kw_verilogHash, - kw_verilogHashHash}); + VerilogExtraKeywords = std::unordered_set( + {kw_always, kw_always_comb, + kw_always_ff, kw_always_latch, + kw_assert, kw_assign, + kw_assume, kw_automatic, + kw_before, kw_begin, + kw_bins, kw_binsof, + kw_casex, kw_casez, + kw_celldefine, kw_checker, + kw_clocking, kw_constraint, + kw_cover, kw_covergroup, + kw_coverpoint, kw_disable, + kw_dist, kw_edge, + kw_end, kw_endcase, + kw_endchecker, kw_endclass, + kw_endclocking, kw_endfunction, + kw_endgenerate, kw_endgroup, + kw_endinterface, kw_endmodule, + kw_endpackage, kw_endprimitive, + kw_endprogram, kw_endproperty, + kw_endsequence, kw_endspecify, + kw_endtable, kw_endtask, + kw_extends, kw_final, + kw_foreach, kw_forever, + kw_fork, kw_function, + kw_generate, kw_highz0, + kw_highz1, kw_iff, + kw_ifnone, kw_ignore_bins, + kw_illegal_bins, kw_implements, + kw_import, kw_initial, + kw_inout, kw_input, + kw_inside, kw_interconnect, + kw_interface, kw_intersect, + kw_join, kw_join_any, + kw_join_none, kw_large, + kw_let, kw_local, + kw_localparam, kw_macromodule, + kw_matches, kw_medium, + kw_negedge, kw_output, + kw_package, kw_packed, + kw_parameter, kw_posedge, + kw_primitive, kw_priority, + kw_program, kw_property, + kw_pull0, kw_pull1, + kw_pure, kw_rand, + kw_randc, kw_randcase, + kw_randsequence, kw_ref, + kw_repeat, kw_sample, + kw_scalared, kw_sequence, + kw_small, kw_soft, + kw_solve, kw_specify, + kw_specparam, kw_strong0, + kw_strong1, kw_supply0, + kw_supply1, kw_table, + kw_tagged, kw_task, + kw_tri, kw_tri0, + kw_tri1, kw_triand, + kw_trior, kw_trireg, + kw_unique, kw_unique0, + kw_uwire, kw_var, + kw_vectored, kw_wand, + kw_weak0, kw_weak1, + kw_wildcard, kw_wire, + kw_with, kw_wor, + kw_verilogHash, kw_verilogHashHash}); } // Context sensitive keywords. @@ -1462,6 +1404,7 @@ IdentifierInfo *kw_disable; IdentifierInfo *kw_dist; IdentifierInfo *kw_elsif; + IdentifierInfo *kw_edge; IdentifierInfo *kw_end; IdentifierInfo *kw_end_keywords; IdentifierInfo *kw_endcase; @@ -1506,10 +1449,12 @@ IdentifierInfo *kw_macromodule; IdentifierInfo *kw_matches; IdentifierInfo *kw_medium; + IdentifierInfo *kw_negedge; IdentifierInfo *kw_nounconnected_drive; IdentifierInfo *kw_output; IdentifierInfo *kw_packed; IdentifierInfo *kw_parameter; + IdentifierInfo *kw_posedge; IdentifierInfo *kw_primitive; IdentifierInfo *kw_priority; IdentifierInfo *kw_program; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -15732,7 +15732,8 @@ } } - if (!VD->hasGlobalStorage()) return; + if (!VD->hasGlobalStorage() || !VD->needsDestruction(Context)) + return; // Emit warning for non-trivial dtor in global scope (a real global, // class-static, function-static). diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c --- a/clang/test/Driver/riscv-arch.c +++ b/clang/test/Driver/riscv-arch.c @@ -218,16 +218,6 @@ // RV32-ORDER: error: invalid arch name 'rv32imcq', // RV32-ORDER: standard user-level extension not given in canonical order 'q' -// RUN: %clang --target=riscv32-unknown-elf -march=rv32izve32f -### %s \ -// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVE32F-ER %s -// RV32-ZVE32F-ER: error: invalid arch name 'rv32izve32f', -// RV32-ZVE32F-ER: 'zve32f' requires 'f' or 'zfinx' extension to also be specified - -// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve64d -### %s \ -// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVE64D-ER %s -// RV32-ZVE64D-ER: error: invalid arch name 'rv32ifzve64d', -// RV32-ZVE64D-ER: 'zve64d' requires 'd' or 'zdinx' extension to also be specified - // RUN: %clang --target=riscv32-unknown-elf -march=rv32izvl64b -### %s \ // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVL64B-ER %s // RV32-ZVL64B-ER: error: invalid arch name 'rv32izvl64b', @@ -498,10 +488,6 @@ // RV32-ZVE32X-GOODVERS: "-target-feature" "+zve32x" // RUN: %clang --target=riscv32-unknown-elf -march=rv32izve32f -### %s -c 2>&1 | \ -// RUN: FileCheck -check-prefix=RV32-ZVE32F-REQUIRE-F %s -// RV32-ZVE32F-REQUIRE-F: error: invalid arch name 'rv32izve32f', 'zve32f' requires 'f' or 'zfinx' extension to also be specified - -// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve32f -### %s -c 2>&1 | \ // RUN: FileCheck -check-prefix=RV32-ZVE32F-GOOD %s // RV32-ZVE32F-GOOD: "-target-feature" "+zve32f" @@ -510,18 +496,10 @@ // RV32-ZVE64X: "-target-feature" "+zve64x" // RUN: %clang --target=riscv32-unknown-elf -march=rv32izve64f -### %s -c 2>&1 | \ -// RUN: FileCheck -check-prefix=RV32-ZVE64F-REQUIRE-F %s -// RV32-ZVE64F-REQUIRE-F: error: invalid arch name 'rv32izve64f', 'zve32f' requires 'f' or 'zfinx' extension to also be specified - -// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve64f -### %s -c 2>&1 | \ // RUN: FileCheck -check-prefix=RV32-ZVE64F-GOOD %s // RV32-ZVE64F-GOOD: "-target-feature" "+zve64f" -// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve64d -### %s -c 2>&1 | \ -// RUN: FileCheck -check-prefix=RV32-ZVE64D-REQUIRE-D %s -// RV32-ZVE64D-REQUIRE-D: error: invalid arch name 'rv32ifzve64d', 'zve64d' requires 'd' or 'zdinx' extension to also be specified - -// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifdzve64d -### %s -c 2>&1 | \ +// RUN: %clang --target=riscv32-unknown-elf -march=rv32izve64d -### %s -c 2>&1 | \ // RUN: FileCheck -check-prefix=RV32-ZVE64D-GOOD %s // RV32-ZVE64D-GOOD: "-target-feature" "+zve64d" diff --git a/clang/test/SemaCXX/warn-exit-time-destructors.cpp b/clang/test/SemaCXX/warn-exit-time-destructors.cpp --- a/clang/test/SemaCXX/warn-exit-time-destructors.cpp +++ b/clang/test/SemaCXX/warn-exit-time-destructors.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify=expected,cxx11 +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wexit-time-destructors %s -verify=expected namespace test1 { struct A { ~A(); }; @@ -48,3 +49,22 @@ struct A { ~A(); }; [[clang::no_destroy]] A a; // no warning } + +namespace test5 { +#if __cplusplus >= 202002L +#define CPP20_CONSTEXPR constexpr +#else +#define CPP20_CONSTEXPR +#endif + struct S { + CPP20_CONSTEXPR ~S() {} + }; + S s; // cxx11-warning {{exit-time destructor}} + + struct T { + CPP20_CONSTEXPR ~T() { if (b) {} } + bool b; + }; + T t; // expected-warning {{exit-time destructor}} +#undef CPP20_CONSTEXPR +} diff --git a/clang/test/SemaCXX/warn-global-constructors.cpp b/clang/test/SemaCXX/warn-global-constructors.cpp --- a/clang/test/SemaCXX/warn-global-constructors.cpp +++ b/clang/test/SemaCXX/warn-global-constructors.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s -verify +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s -verify=expected,cxx11 +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wglobal-constructors %s -verify=expected int opaque_int(); @@ -145,3 +146,22 @@ const HasUnnamedBitfield nonConstexprConst{1}; // expected-warning {{global constructor}} HasUnnamedBitfield nonConstexprMutable{1}; // expected-warning {{global constructor}} } + +namespace test7 { +#if __cplusplus >= 202002L +#define CPP20_CONSTEXPR constexpr +#else +#define CPP20_CONSTEXPR +#endif + struct S { + CPP20_CONSTEXPR ~S() {} + }; + S s; // cxx11-warning {{global destructor}} + + struct T { + CPP20_CONSTEXPR ~T() { if (b) {} } + bool b; + }; + T t; // expected-warning {{global destructor}} +#undef CPP20_CONSTEXPR +} diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt --- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt +++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt @@ -1,6 +1,6 @@ project(exec C) -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) include(CheckCCompilerFlag) check_c_compiler_flag("-std=c99" C99_SUPPORTED) diff --git a/clang/unittests/Format/FormatTestVerilog.cpp b/clang/unittests/Format/FormatTestVerilog.cpp --- a/clang/unittests/Format/FormatTestVerilog.cpp +++ b/clang/unittests/Format/FormatTestVerilog.cpp @@ -162,6 +162,39 @@ "x = x;"); verifyFormat("rand join x x;\n" "x = x;"); + // The begin keyword should not be indented if it is too long to fit on the + // same line. + verifyFormat("while (true) //\n" + "begin\n" + " while (true) //\n" + " begin\n" + " end\n" + "end"); + verifyFormat("while (true) //\n" + "begin : x\n" + " while (true) //\n" + " begin : x\n" + " end : x\n" + "end : x"); + verifyFormat("while (true) //\n" + "fork\n" + " while (true) //\n" + " fork\n" + " join\n" + "join"); + auto Style = getDefaultStyle(); + Style.ColumnLimit = 17; + verifyFormat("while (true)\n" + "begin\n" + " while (true)\n" + " begin\n" + " end\n" + "end", + "while (true) begin\n" + " while (true) begin" + " end\n" + "end", + Style); } TEST_F(FormatTestVerilog, Case) { @@ -1157,6 +1190,14 @@ " x <= x;"); verifyFormat("always @(posedge x)\n" " x <= x;"); + verifyFormat("always @(posedge x or posedge y)\n" + " x <= x;"); + verifyFormat("always @(posedge x, posedge y)\n" + " x <= x;"); + verifyFormat("always @(negedge x, negedge y)\n" + " x <= x;"); + verifyFormat("always @(edge x, edge y)\n" + " x <= x;"); verifyFormat("always\n" " x <= x;"); verifyFormat("always @*\n" diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -1684,6 +1684,15 @@ Tokens = Annotate("case (x) endcase;"); ASSERT_EQ(Tokens.size(), 7u) << Tokens; EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ConditionLParen); + + // Sensitivity list. The TT_Unknown type is clearly not binding for the + // future, please adapt if those tokens get annotated. This test is only here + // to prevent the comma from being annotated as TT_VerilogInstancePortComma. + Tokens = Annotate("always @(posedge x, posedge y);"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_Unknown); + EXPECT_TOKEN(Tokens[5], tok::comma, TT_Unknown); + EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown); } TEST_F(TokenAnnotatorTest, UnderstandConstructors) { diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -3,13 +3,20 @@ # An important constraint of the build is that it only produces libraries # based on the ability of the host toolchain to target various platforms. -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) # Check if compiler-rt is built as a standalone project. if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD) project(CompilerRT C CXX ASM) set(COMPILER_RT_STANDALONE_BUILD TRUE) set_property(GLOBAL PROPERTY USE_FOLDERS ON) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() endif() set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -3,7 +3,14 @@ # architecture-specific code in various subdirectories. if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) project(CompilerRTBuiltins C ASM) diff --git a/compiler-rt/lib/crt/CMakeLists.txt b/compiler-rt/lib/crt/CMakeLists.txt --- a/compiler-rt/lib/crt/CMakeLists.txt +++ b/compiler-rt/lib/crt/CMakeLists.txt @@ -1,5 +1,12 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) project(CompilerRTCRT C) diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -39,6 +39,13 @@ message("Building Flang as a standalone project.") project(Flang) set(FLANG_STANDALONE_BUILD ON) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() else() set(FLANG_STANDALONE_BUILD OFF) endif() diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt --- a/flang/lib/Decimal/CMakeLists.txt +++ b/flang/lib/Decimal/CMakeLists.txt @@ -1,5 +1,5 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) project(FortranDecimal C CXX) diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt --- a/flang/runtime/CMakeLists.txt +++ b/flang/runtime/CMakeLists.txt @@ -7,7 +7,14 @@ #===------------------------------------------------------------------------===# if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() project(FlangRuntime C CXX) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) # Include LLVM's cmake policies. if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/libc/docs/compiler_support.rst b/libc/docs/compiler_support.rst --- a/libc/docs/compiler_support.rst +++ b/libc/docs/compiler_support.rst @@ -5,7 +5,7 @@ ================ ``LLVM libc`` compiles from both ``Clang`` and ``GCC`` but for maximum -performance we recommand using ``Clang``. +performance we recommend using ``Clang``. Indeed, some memory function implementations rely on `compiler intrinsics`__ that are not currently available in ``GCC``. diff --git a/libc/docs/dev/clang_tidy_checks.rst b/libc/docs/dev/clang_tidy_checks.rst --- a/libc/docs/dev/clang_tidy_checks.rst +++ b/libc/docs/dev/clang_tidy_checks.rst @@ -30,7 +30,7 @@ --------------------------- It is part of our implementation standards that all implementation pieces live -under the ``__llvm_libc`` namespace. This prevents polution of the global +under the ``__llvm_libc`` namespace. This prevents pollution of the global namespace. Without a formal check to ensure this, an implementation might compile and pass unit tests, but not produce a usable libc function. diff --git a/libc/docs/dev/cmake_build_rules.rst b/libc/docs/dev/cmake_build_rules.rst --- a/libc/docs/dev/cmake_build_rules.rst +++ b/libc/docs/dev/cmake_build_rules.rst @@ -6,7 +6,7 @@ At the cost of verbosity, we want to keep the build system of LLVM libc as simple as possible. We also want to be highly modular with our build -targets. This makes picking and choosing desired pieces a straighforward +targets. This makes picking and choosing desired pieces a straightforward task. Targets for entrypoints diff --git a/libc/docs/dev/implementation_standard.rst b/libc/docs/dev/implementation_standard.rst --- a/libc/docs/dev/implementation_standard.rst +++ b/libc/docs/dev/implementation_standard.rst @@ -15,7 +15,7 @@ the directory of its own named ``src/math/round/``. Implementation of entrypoints can span multiple ``.cpp`` and ``.h`` files, but -there will be atleast one header file with name of the form +there will be at least one header file with name of the form ``.h`` for every entrypoint. This header file is called as the implementation header file. For the ``round`` function, the path to the implementation header file will be ``src/math/round/round.h``. The rest of this diff --git a/libc/examples/hello_world/CMakeLists.txt b/libc/examples/hello_world/CMakeLists.txt --- a/libc/examples/hello_world/CMakeLists.txt +++ b/libc/examples/hello_world/CMakeLists.txt @@ -1,5 +1,5 @@ project(hello_world) -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) include(../examples.cmake) add_example( diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) project( libclc VERSION 0.2.0 LANGUAGES CXX C) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -4,7 +4,7 @@ #=============================================================================== # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") diff --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv --- a/libcxx/docs/Status/Cxx2bIssues.csv +++ b/libcxx/docs/Status/Cxx2bIssues.csv @@ -214,7 +214,7 @@ "`3754 `__","Class template expected synopsis contains declarations that do not match the detailed description", "November 2022","|Nothing to do|","","" "`3755 `__","``tuple-for-each`` can call ``user-defined`` ``operator,``", "November 2022","|Complete|","17.0","" "`3757 `__","What's the effect of ``std::forward_like(x)``?", "November 2022","","","" -"`3759 `__","``ranges::rotate_copy`` should use ``std::move``", "November 2022","","","|ranges|" +"`3759 `__","``ranges::rotate_copy`` should use ``std::move``", "November 2022","|Complete|","15.0","|ranges|" "`3760 `__","``cartesian_product_view::iterator``'s ``parent_`` is never valid", "November 2022","","","|ranges|" "`3761 `__","``cartesian_product_view::iterator::operator-`` should pass by reference", "November 2022","","","|ranges|" "`3762 `__","``generator::iterator::operator==`` should pass by reference", "November 2022","","","" diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -4,7 +4,7 @@ # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -2,7 +2,7 @@ # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -30,7 +30,8 @@ # CMake doesn't work correctly with assembly on AIX. Workaround by compiling # as C files as well. if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR - (MINGW AND CMAKE_VERSION VERSION_LESS 3.17)) + (MINGW AND CMAKE_VERSION VERSION_LESS 3.17) OR + (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C) endif() diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -31,7 +31,8 @@ #endif #if defined(_LIBUNWIND_TARGET_LINUX) && \ - (defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_S390X)) + (defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_RISCV) || \ + defined(_LIBUNWIND_TARGET_S390X)) #include #include #include @@ -993,6 +994,10 @@ bool setInfoForSigReturn(Registers_arm64 &); int stepThroughSigReturn(Registers_arm64 &); #endif +#if defined(_LIBUNWIND_TARGET_RISCV) + bool setInfoForSigReturn(Registers_riscv &); + int stepThroughSigReturn(Registers_riscv &); +#endif #if defined(_LIBUNWIND_TARGET_S390X) bool setInfoForSigReturn(Registers_s390x &); int stepThroughSigReturn(Registers_s390x &); @@ -2720,6 +2725,60 @@ #endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) && // defined(_LIBUNWIND_TARGET_AARCH64) +#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) && \ + defined(_LIBUNWIND_TARGET_RISCV) +template +bool UnwindCursor::setInfoForSigReturn(Registers_riscv &) { + const pint_t pc = static_cast(getReg(UNW_REG_IP)); + uint32_t instructions[2]; + struct iovec local_iov = {&instructions, sizeof instructions}; + struct iovec remote_iov = {reinterpret_cast(pc), sizeof instructions}; + long bytesRead = + syscall(SYS_process_vm_readv, getpid(), &local_iov, 1, &remote_iov, 1, 0); + // Look for the two instructions used in the sigreturn trampoline + // __vdso_rt_sigreturn: + // + // 0x08b00893 li a7,0x8b + // 0x00000073 ecall + if (bytesRead != sizeof instructions || instructions[0] != 0x08b00893 || + instructions[1] != 0x00000073) + return false; + + _info = {}; + _info.start_ip = pc; + _info.end_ip = pc + 4; + _isSigReturn = true; + return true; +} + +template +int UnwindCursor::stepThroughSigReturn(Registers_riscv &) { + // In the signal trampoline frame, sp points to an rt_sigframe[1], which is: + // - 128-byte siginfo struct + // - ucontext_t struct: + // - 8-byte long (__uc_flags) + // - 8-byte pointer (*uc_link) + // - 24-byte uc_stack + // - 8-byte uc_sigmask + // - 120-byte of padding to allow sigset_t to be expanded in the future + // - 8 bytes of padding because sigcontext has 16-byte alignment + // - struct sigcontext uc_mcontext + // [1] + // https://github.com/torvalds/linux/blob/master/arch/riscv/kernel/signal.c + const pint_t kOffsetSpToSigcontext = 128 + 8 + 8 + 24 + 8 + 128; + + const pint_t sigctx = _registers.getSP() + kOffsetSpToSigcontext; + _registers.setIP(_addressSpace.get64(sigctx)); + for (int i = UNW_RISCV_X1; i <= UNW_RISCV_X31; ++i) { + uint64_t value = _addressSpace.get64(sigctx + static_cast(i * 8)); + _registers.setRegister(i, value); + } + _isSignalFrame = true; + return UNW_STEP_SUCCESS; +} +#endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) && + // defined(_LIBUNWIND_TARGET_RISCV) + #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) && \ defined(_LIBUNWIND_TARGET_S390X) template diff --git a/libunwind/test/signal_unwind.pass.cpp b/libunwind/test/signal_unwind.pass.cpp --- a/libunwind/test/signal_unwind.pass.cpp +++ b/libunwind/test/signal_unwind.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // Ensure that the unwinder can cope with the signal handler. -// REQUIRES: target={{(aarch64|s390x|x86_64)-.+linux.*}} +// REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}} // TODO: Figure out why this fails with Memory Sanitizer. // XFAIL: msan diff --git a/libunwind/test/unwind_leaffunction.pass.cpp b/libunwind/test/unwind_leaffunction.pass.cpp --- a/libunwind/test/unwind_leaffunction.pass.cpp +++ b/libunwind/test/unwind_leaffunction.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // Ensure that leaf function can be unwund. -// REQUIRES: target={{(aarch64|s390x|x86_64)-.+linux.*}} +// REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}} // TODO: Figure out why this fails with Memory Sanitizer. // XFAIL: msan diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -11,6 +11,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(lld) set(LLD_BUILT_STANDALONE TRUE) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() endif() # Must go below project(..) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -19,6 +19,13 @@ project(lldb) set(LLDB_BUILT_STANDALONE TRUE) set(LLVM_INCLUDE_TESTS ON CACHE INTERNAL "") + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() endif() # Must go below project(..) diff --git a/lldb/include/lldb/Target/Trace.h b/lldb/include/lldb/Target/Trace.h --- a/lldb/include/lldb/Target/Trace.h +++ b/lldb/include/lldb/Target/Trace.h @@ -570,7 +570,7 @@ llvm::DenseMap live_process_data; /// \} - /// The list of cpus being traced. Might be \b None depending on the + /// The list of cpus being traced. Might be \b std::nullopt depending on the /// plug-in. std::optional> cpus; diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -2420,7 +2420,7 @@ } CommandOptions m_options; - // Last traversed id used to continue a repeat command. None means + // Last traversed id used to continue a repeat command. std::nullopt means // that all the trace has been consumed. std::optional m_last_id; }; diff --git a/lldb/source/Plugins/Process/Linux/Perf.h b/lldb/source/Plugins/Process/Linux/Perf.h --- a/lldb/source/Plugins/Process/Linux/Perf.h +++ b/lldb/source/Plugins/Process/Linux/Perf.h @@ -122,8 +122,8 @@ /// Configuration information for the event. /// /// \param[in] pid - /// The process or thread to be monitored by the event. If \b None, then - /// all threads and processes are monitored. + /// The process or thread to be monitored by the event. If \b + /// std::nullopt, then all threads and processes are monitored. static llvm::Expected Init(perf_event_attr &attr, std::optional pid, std::optional core = std::nullopt); diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp --- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -409,7 +409,7 @@ return error; } - RegSetKind set = opt_set.getValue(); + RegSetKind set = *opt_set; error = ReadRegisterSet(set); if (error.Fail()) return error; @@ -476,7 +476,7 @@ return error; } - RegSetKind set = opt_set.getValue(); + RegSetKind set = *opt_set; uint64_t new_xstate_bv = 0; error = ReadRegisterSet(set); diff --git a/lldb/source/Plugins/TraceExporter/common/TraceHTR.h b/lldb/source/Plugins/TraceExporter/common/TraceHTR.h --- a/lldb/source/Plugins/TraceExporter/common/TraceHTR.h +++ b/lldb/source/Plugins/TraceExporter/common/TraceHTR.h @@ -215,7 +215,7 @@ /// /// \param[in] func_name /// The name of the function the 'call' instruction is calling if it can - /// be determined, None otherwise. + /// be determined, std::nullopt otherwise. void AddCallInstructionMetadata(lldb::addr_t load_addr, std::optional func_name); diff --git a/lldb/tools/debugserver/CMakeLists.txt b/lldb/tools/debugserver/CMakeLists.txt --- a/lldb/tools/debugserver/CMakeLists.txt +++ b/lldb/tools/debugserver/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) project(Debugserver LANGUAGES C CXX ASM-ATT) @@ -7,6 +7,13 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(LLDB_BUILT_STANDALONE TRUE) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} diff --git a/lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp b/lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp --- a/lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp +++ b/lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp @@ -92,7 +92,7 @@ } } -TEST(CPlusPlusLanguage, InvalidMethodNameParsing) { +TEST(ObjCLanguage, InvalidMethodNameParsing) { // Tests that we correctly reject malformed function names llvm::StringRef test_cases[] = {"+[Uh oh!", diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt --- a/llvm-libgcc/CMakeLists.txt +++ b/llvm-libgcc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libunwind") message(FATAL_ERROR "llvm-libgcc requires being built in a monorepo layout with libunwind available") diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1,6 +1,13 @@ # See docs/CMake.html for instructions about how to build LLVM with CMake. -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) +if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") +endif() set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst --- a/llvm/docs/CMake.rst +++ b/llvm/docs/CMake.rst @@ -34,7 +34,7 @@ We use here the command-line, non-interactive CMake interface. #. `Download `_ and install - CMake. Version 3.20.0 is the minimum required. + CMake. Version 3.13.4 is the minimum required. #. Open a shell. Your development tools must be reachable from this shell through the PATH environment variable. @@ -911,7 +911,7 @@ .. code-block:: cmake - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) project(SimpleProject) find_package(LLVM REQUIRED CONFIG) diff --git a/llvm/docs/GettingStarted.rst b/llvm/docs/GettingStarted.rst --- a/llvm/docs/GettingStarted.rst +++ b/llvm/docs/GettingStarted.rst @@ -280,7 +280,7 @@ =========================================================== ============ ========================================== Package Version Notes =========================================================== ============ ========================================== -`CMake `__ >=3.20.0 Makefile/workspace generator +`CMake `__ >=3.13.4 Makefile/workspace generator `GCC `_ >=7.1.0 C/C++ compiler\ :sup:`1` `python `_ >=3.6 Automated test suite\ :sup:`2` `zlib `_ >=1.2.3.4 Compression library\ :sup:`3` diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -47,11 +47,6 @@ Update on required toolchains to build LLVM ------------------------------------------- -With LLVM 17.x we raised the version requirement of CMake used to build LLVM. -The new requirements are as follows: - -* CMake >= 3.20.0 - Changes to the LLVM IR ---------------------- @@ -181,6 +176,8 @@ RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and ``checkTuneCPUKind``. * Add sifive-x280 processor. +* Zve32f is no longer allowed with Zfinx. Zve64d is no longer allowed with + Zdinx. Changes to the WebAssembly Backend ---------------------------------- diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -4042,9 +4042,11 @@ } SDValue DAGCombiner::visitSUBSAT(SDNode *N) { + unsigned Opcode = N->getOpcode(); SDValue N0 = N->getOperand(0); SDValue N1 = N->getOperand(1); EVT VT = N0.getValueType(); + bool IsSigned = Opcode == ISD::SSUBSAT; SDLoc DL(N); // fold (sub_sat x, undef) -> 0 @@ -4056,7 +4058,7 @@ return DAG.getConstant(0, DL, VT); // fold (sub_sat c1, c2) -> c3 - if (SDValue C = DAG.FoldConstantArithmetic(N->getOpcode(), DL, VT, {N0, N1})) + if (SDValue C = DAG.FoldConstantArithmetic(Opcode, DL, VT, {N0, N1})) return C; // fold vector ops @@ -4073,6 +4075,10 @@ if (isNullConstant(N1)) return N0; + // If it cannot overflow, transform into an sub. + if (DAG.computeOverflowForSub(IsSigned, N0, N1) == SelectionDAG::OFK_Never) + return DAG.getNode(ISD::SUB, DL, VT, N0, N1); + return SDValue(); } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3943,6 +3943,20 @@ return Known; } +/// Convert ConstantRange OverflowResult into SelectionDAG::OverflowKind. +static SelectionDAG::OverflowKind mapOverflowResult(ConstantRange::OverflowResult OR) { + switch (OR) { + case ConstantRange::OverflowResult::MayOverflow: + return SelectionDAG::OFK_Sometime; + case ConstantRange::OverflowResult::AlwaysOverflowsLow: + case ConstantRange::OverflowResult::AlwaysOverflowsHigh: + return SelectionDAG::OFK_Always; + case ConstantRange::OverflowResult::NeverOverflows: + return SelectionDAG::OFK_Never; + } + llvm_unreachable("Unknown OverflowResult"); +} + SelectionDAG::OverflowKind SelectionDAG::computeOverflowForSignedAdd(SDValue N0, SDValue N1) const { // X + 0 never overflow @@ -3964,30 +3978,21 @@ if (isNullConstant(N1)) return OFK_Never; - KnownBits N1Known = computeKnownBits(N1); - if (N1Known.Zero.getBoolValue()) { - KnownBits N0Known = computeKnownBits(N0); - - bool overflow; - (void)N0Known.getMaxValue().uadd_ov(N1Known.getMaxValue(), overflow); - if (!overflow) - return OFK_Never; - } - // mulhi + 1 never overflow + KnownBits N1Known = computeKnownBits(N1); if (N0.getOpcode() == ISD::UMUL_LOHI && N0.getResNo() == 1 && - (N1Known.getMaxValue() & 0x01) == N1Known.getMaxValue()) + N1Known.getMaxValue().ult(2)) return OFK_Never; - if (N1.getOpcode() == ISD::UMUL_LOHI && N1.getResNo() == 1) { - KnownBits N0Known = computeKnownBits(N0); - - if ((N0Known.getMaxValue() & 0x01) == N0Known.getMaxValue()) - return OFK_Never; - } + KnownBits N0Known = computeKnownBits(N0); + if (N1.getOpcode() == ISD::UMUL_LOHI && N1.getResNo() == 1 && + N0Known.getMaxValue().ult(2)) + return OFK_Never; - // TODO: Add ConstantRange::unsignedAddMayOverflow handling. - return OFK_Sometime; + // Fallback to ConstantRange::unsignedAddMayOverflow handling. + ConstantRange N0Range = ConstantRange::fromKnownBits(N0Known, false); + ConstantRange N1Range = ConstantRange::fromKnownBits(N1Known, false); + return mapOverflowResult(N0Range.unsignedAddMayOverflow(N1Range)); } SelectionDAG::OverflowKind diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -856,10 +856,7 @@ bool HasD = Exts.count("d") != 0; bool HasF = Exts.count("f") != 0; bool HasZfinx = Exts.count("zfinx") != 0; - bool HasZdinx = Exts.count("zdinx") != 0; bool HasVector = Exts.count("zve32x") != 0; - bool HasZve32f = Exts.count("zve32f") != 0; - bool HasZve64d = Exts.count("zve64d") != 0; bool HasZvl = MinVLen != 0; bool HasZcmt = Exts.count("zcmt") != 0; bool HasZcd = Exts.count("zcd") != 0; @@ -868,22 +865,10 @@ return createStringError(errc::invalid_argument, "'f' and 'zfinx' extensions are incompatible"); - if (HasZve32f && !HasF && !HasZfinx) + if (Exts.count("zvfh") && !Exts.count("zfh") && !Exts.count("zfhmin")) return createStringError( errc::invalid_argument, - "'zve32f' requires 'f' or 'zfinx' extension to also be specified"); - - if (HasZve64d && !HasD && !HasZdinx) - return createStringError( - errc::invalid_argument, - "'zve64d' requires 'd' or 'zdinx' extension to also be specified"); - - if (Exts.count("zvfh") && !Exts.count("zfh") && !Exts.count("zfhmin") && - !Exts.count("zhinx") && !Exts.count("zhinxmin")) - return createStringError( - errc::invalid_argument, - "'zvfh' requires 'zfh', 'zfhmin', 'zhinx' or 'zhinxmin' extension to " - "also be specified"); + "'zvfh' requires 'zfh' or 'zfhmin extension to also be specified"); if (HasZvl && !HasVector) return createStringError( @@ -949,9 +934,9 @@ static const char *ImpliedExtsZkn[] = {"zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"}; static const char *ImpliedExtsZks[] = {"zbkb", "zbkc", "zbkx", "zksed", "zksh"}; -static const char *ImpliedExtsZve32f[] = {"zve32x"}; +static const char *ImpliedExtsZve32f[] = {"zve32x", "f"}; static const char *ImpliedExtsZve32x[] = {"zvl32b", "zicsr"}; -static const char *ImpliedExtsZve64d[] = {"zve64f"}; +static const char *ImpliedExtsZve64d[] = {"zve64f", "d"}; static const char *ImpliedExtsZve64f[] = {"zve64x", "zve32f"}; static const char *ImpliedExtsZve64x[] = {"zve32x", "zvl64b"}; static const char *ImpliedExtsZvfh[] = {"zve32f"}; diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.h b/llvm/lib/Target/ARM/ARMAsmPrinter.h --- a/llvm/lib/Target/ARM/ARMAsmPrinter.h +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.h @@ -120,9 +120,6 @@ // Helpers for emitStartOfAsmFile() and emitEndOfAsmFile() void emitAttributes(); - // Generic helper used to emit e.g. ARMv5 mul pseudos - void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc); - void EmitUnwindingInstruction(const MachineInstr *MI); // emitPseudoExpansionLowering - tblgen'erated. diff --git a/llvm/lib/Target/ARM/ARMISelLowering.h b/llvm/lib/Target/ARM/ARMISelLowering.h --- a/llvm/lib/Target/ARM/ARMISelLowering.h +++ b/llvm/lib/Target/ARM/ARMISelLowering.h @@ -824,7 +824,6 @@ TLSModel::Model model) const; SDValue LowerGlobalTLSAddressDarwin(SDValue Op, SelectionDAG &DAG) const; SDValue LowerGlobalTLSAddressWindows(SDValue Op, SelectionDAG &DAG) const; - SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const; SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSignedALUO(SDValue Op, SelectionDAG &DAG) const; SDValue LowerUnsignedALUO(SDValue Op, SelectionDAG &DAG) const; diff --git a/llvm/lib/Target/ARM/MVETailPredication.cpp b/llvm/lib/Target/ARM/MVETailPredication.cpp --- a/llvm/lib/Target/ARM/MVETailPredication.cpp +++ b/llvm/lib/Target/ARM/MVETailPredication.cpp @@ -116,11 +116,6 @@ /// Insert the intrinsic to represent the effect of tail predication. void InsertVCTPIntrinsic(IntrinsicInst *ActiveLaneMask, Value *Start); - - /// Rematerialize the iteration count in exit blocks, which enables - /// ARMLowOverheadLoops to better optimise away loop update statements inside - /// hardware-loops. - void RematerializeIterCount(); }; } // end namespace diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h @@ -34,8 +34,6 @@ const PPCSubtarget *getST() const { return ST; } const PPCTargetLowering *getTLI() const { return TLI; } - bool mightUseCTR(BasicBlock *BB, TargetLibraryInfo *LibInfo, - SmallPtrSetImpl &Visited); public: explicit PPCTTIImpl(const PPCTargetMachine *TM, const Function &F) diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -397,7 +397,7 @@ : SubtargetFeature<"zve32f", "HasStdExtZve32f", "true", "'Zve32f' (Vector Extensions for Embedded Processors " "with maximal 32 EEW and F extension)", - [FeatureStdExtZve32x]>; + [FeatureStdExtZve32x, FeatureStdExtF]>; def FeatureStdExtZve64x : SubtargetFeature<"zve64x", "HasStdExtZve64x", "true", @@ -415,13 +415,12 @@ : SubtargetFeature<"zve64d", "HasStdExtZve64d", "true", "'Zve64d' (Vector Extensions for Embedded Processors " "with maximal 64 EEW, F and D extension)", - [FeatureStdExtZve64f]>; + [FeatureStdExtZve64f, FeatureStdExtD]>; def FeatureStdExtV : SubtargetFeature<"v", "HasStdExtV", "true", "'V' (Vector Extension for Application Processors)", - [FeatureStdExtZvl128b, FeatureStdExtZve64d, - FeatureStdExtF, FeatureStdExtD]>; + [FeatureStdExtZvl128b, FeatureStdExtZve64d]>; def HasVInstructions : Predicate<"Subtarget->hasVInstructions()">, AssemblerPredicate< diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h @@ -140,11 +140,6 @@ SDValue LowerLoad(SDValue Op, SelectionDAG &DAG) const; SDValue LowerStore(SDValue Op, SelectionDAG &DAG) const; - // Helper for LoadLoad and LowerStore - bool MatchTableForLowering(SelectionDAG &DAG, const SDLoc &DL, - const SDValue &Base, GlobalAddressSDNode *&GA, - SDValue &Idx) const; - // Custom DAG combine hooks SDValue PerformDAGCombine(SDNode *N, diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1282,12 +1282,9 @@ }; } // end anonymous namespace -/// @name Auto-generated Match Functions -/// { - -static unsigned MatchRegisterName(StringRef Name); - -/// } +#define GET_REGISTER_MATCHER +#define GET_SUBTARGET_FEATURE_NAME +#include "X86GenAsmMatcher.inc" static bool CheckBaseRegAndIndexRegAndScale(unsigned BaseReg, unsigned IndexReg, unsigned Scale, bool Is64BitMode, @@ -3929,8 +3926,6 @@ return false; } -static const char *getSubtargetFeatureName(uint64_t Val); - void X86AsmParser::emitWarningForSpecialLVIInstruction(SMLoc Loc) { Warning(Loc, "Instruction may be vulnerable to LVI and " "requires manual mitigation"); @@ -4985,7 +4980,5 @@ RegisterMCAsmParser Y(getTheX86_64Target()); } -#define GET_REGISTER_MATCHER #define GET_MATCHER_IMPLEMENTATION -#define GET_SUBTARGET_FEATURE_NAME #include "X86GenAsmMatcher.inc" diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -651,11 +651,6 @@ Instruction *SimplifyAnyMemSet(AnyMemSetInst *MI); Value *EvaluateInDifferentType(Value *V, Type *Ty, bool isSigned); - - /// Returns a value X such that Val = X * Scale, or null if none. - /// - /// If the multiplication is known not to overflow then NoSignedWrap is set. - Value *Descale(Value *Val, APInt Scale, bool &NoSignedWrap); }; class Negator final { diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1366,248 +1366,6 @@ return true; } -/// Return a value X such that Val = X * Scale, or null if none. -/// If the multiplication is known not to overflow, then NoSignedWrap is set. -Value *InstCombinerImpl::Descale(Value *Val, APInt Scale, bool &NoSignedWrap) { - assert(isa(Val->getType()) && "Can only descale integers!"); - assert(cast(Val->getType())->getBitWidth() == - Scale.getBitWidth() && "Scale not compatible with value!"); - - // If Val is zero or Scale is one then Val = Val * Scale. - if (match(Val, m_Zero()) || Scale == 1) { - NoSignedWrap = true; - return Val; - } - - // If Scale is zero then it does not divide Val. - if (Scale.isMinValue()) - return nullptr; - - // Look through chains of multiplications, searching for a constant that is - // divisible by Scale. For example, descaling X*(Y*(Z*4)) by a factor of 4 - // will find the constant factor 4 and produce X*(Y*Z). Descaling X*(Y*8) by - // a factor of 4 will produce X*(Y*2). The principle of operation is to bore - // down from Val: - // - // Val = M1 * X || Analysis starts here and works down - // M1 = M2 * Y || Doesn't descend into terms with more - // M2 = Z * 4 \/ than one use - // - // Then to modify a term at the bottom: - // - // Val = M1 * X - // M1 = Z * Y || Replaced M2 with Z - // - // Then to work back up correcting nsw flags. - - // Op - the term we are currently analyzing. Starts at Val then drills down. - // Replaced with its descaled value before exiting from the drill down loop. - Value *Op = Val; - - // Parent - initially null, but after drilling down notes where Op came from. - // In the example above, Parent is (Val, 0) when Op is M1, because M1 is the - // 0'th operand of Val. - std::pair Parent; - - // Set if the transform requires a descaling at deeper levels that doesn't - // overflow. - bool RequireNoSignedWrap = false; - - // Log base 2 of the scale. Negative if not a power of 2. - int32_t logScale = Scale.exactLogBase2(); - - for (;; Op = Parent.first->getOperand(Parent.second)) { // Drill down - if (ConstantInt *CI = dyn_cast(Op)) { - // If Op is a constant divisible by Scale then descale to the quotient. - APInt Quotient(Scale), Remainder(Scale); // Init ensures right bitwidth. - APInt::sdivrem(CI->getValue(), Scale, Quotient, Remainder); - if (!Remainder.isMinValue()) - // Not divisible by Scale. - return nullptr; - // Replace with the quotient in the parent. - Op = ConstantInt::get(CI->getType(), Quotient); - NoSignedWrap = true; - break; - } - - if (BinaryOperator *BO = dyn_cast(Op)) { - if (BO->getOpcode() == Instruction::Mul) { - // Multiplication. - NoSignedWrap = BO->hasNoSignedWrap(); - if (RequireNoSignedWrap && !NoSignedWrap) - return nullptr; - - // There are three cases for multiplication: multiplication by exactly - // the scale, multiplication by a constant different to the scale, and - // multiplication by something else. - Value *LHS = BO->getOperand(0); - Value *RHS = BO->getOperand(1); - - if (ConstantInt *CI = dyn_cast(RHS)) { - // Multiplication by a constant. - if (CI->getValue() == Scale) { - // Multiplication by exactly the scale, replace the multiplication - // by its left-hand side in the parent. - Op = LHS; - break; - } - - // Otherwise drill down into the constant. - if (!Op->hasOneUse()) - return nullptr; - - Parent = std::make_pair(BO, 1); - continue; - } - - // Multiplication by something else. Drill down into the left-hand side - // since that's where the reassociate pass puts the good stuff. - if (!Op->hasOneUse()) - return nullptr; - - Parent = std::make_pair(BO, 0); - continue; - } - - if (logScale > 0 && BO->getOpcode() == Instruction::Shl && - isa(BO->getOperand(1))) { - // Multiplication by a power of 2. - NoSignedWrap = BO->hasNoSignedWrap(); - if (RequireNoSignedWrap && !NoSignedWrap) - return nullptr; - - Value *LHS = BO->getOperand(0); - int32_t Amt = cast(BO->getOperand(1))-> - getLimitedValue(Scale.getBitWidth()); - // Op = LHS << Amt. - - if (Amt == logScale) { - // Multiplication by exactly the scale, replace the multiplication - // by its left-hand side in the parent. - Op = LHS; - break; - } - if (Amt < logScale || !Op->hasOneUse()) - return nullptr; - - // Multiplication by more than the scale. Reduce the multiplying amount - // by the scale in the parent. - Parent = std::make_pair(BO, 1); - Op = ConstantInt::get(BO->getType(), Amt - logScale); - break; - } - } - - if (!Op->hasOneUse()) - return nullptr; - - if (CastInst *Cast = dyn_cast(Op)) { - if (Cast->getOpcode() == Instruction::SExt) { - // Op is sign-extended from a smaller type, descale in the smaller type. - unsigned SmallSize = Cast->getSrcTy()->getPrimitiveSizeInBits(); - APInt SmallScale = Scale.trunc(SmallSize); - // Suppose Op = sext X, and we descale X as Y * SmallScale. We want to - // descale Op as (sext Y) * Scale. In order to have - // sext (Y * SmallScale) = (sext Y) * Scale - // some conditions need to hold however: SmallScale must sign-extend to - // Scale and the multiplication Y * SmallScale should not overflow. - if (SmallScale.sext(Scale.getBitWidth()) != Scale) - // SmallScale does not sign-extend to Scale. - return nullptr; - assert(SmallScale.exactLogBase2() == logScale); - // Require that Y * SmallScale must not overflow. - RequireNoSignedWrap = true; - - // Drill down through the cast. - Parent = std::make_pair(Cast, 0); - Scale = SmallScale; - continue; - } - - if (Cast->getOpcode() == Instruction::Trunc) { - // Op is truncated from a larger type, descale in the larger type. - // Suppose Op = trunc X, and we descale X as Y * sext Scale. Then - // trunc (Y * sext Scale) = (trunc Y) * Scale - // always holds. However (trunc Y) * Scale may overflow even if - // trunc (Y * sext Scale) does not, so nsw flags need to be cleared - // from this point up in the expression (see later). - if (RequireNoSignedWrap) - return nullptr; - - // Drill down through the cast. - unsigned LargeSize = Cast->getSrcTy()->getPrimitiveSizeInBits(); - Parent = std::make_pair(Cast, 0); - Scale = Scale.sext(LargeSize); - if (logScale + 1 == (int32_t)Cast->getType()->getPrimitiveSizeInBits()) - logScale = -1; - assert(Scale.exactLogBase2() == logScale); - continue; - } - } - - // Unsupported expression, bail out. - return nullptr; - } - - // If Op is zero then Val = Op * Scale. - if (match(Op, m_Zero())) { - NoSignedWrap = true; - return Op; - } - - // We know that we can successfully descale, so from here on we can safely - // modify the IR. Op holds the descaled version of the deepest term in the - // expression. NoSignedWrap is 'true' if multiplying Op by Scale is known - // not to overflow. - - if (!Parent.first) - // The expression only had one term. - return Op; - - // Rewrite the parent using the descaled version of its operand. - assert(Parent.first->hasOneUse() && "Drilled down when more than one use!"); - assert(Op != Parent.first->getOperand(Parent.second) && - "Descaling was a no-op?"); - replaceOperand(*Parent.first, Parent.second, Op); - Worklist.push(Parent.first); - - // Now work back up the expression correcting nsw flags. The logic is based - // on the following observation: if X * Y is known not to overflow as a signed - // multiplication, and Y is replaced by a value Z with smaller absolute value, - // then X * Z will not overflow as a signed multiplication either. As we work - // our way up, having NoSignedWrap 'true' means that the descaled value at the - // current level has strictly smaller absolute value than the original. - Instruction *Ancestor = Parent.first; - do { - if (BinaryOperator *BO = dyn_cast(Ancestor)) { - // If the multiplication wasn't nsw then we can't say anything about the - // value of the descaled multiplication, and we have to clear nsw flags - // from this point on up. - bool OpNoSignedWrap = BO->hasNoSignedWrap(); - NoSignedWrap &= OpNoSignedWrap; - if (NoSignedWrap != OpNoSignedWrap) { - BO->setHasNoSignedWrap(NoSignedWrap); - Worklist.push(Ancestor); - } - } else if (Ancestor->getOpcode() == Instruction::Trunc) { - // The fact that the descaled input to the trunc has smaller absolute - // value than the original input doesn't tell us anything useful about - // the absolute values of the truncations. - NoSignedWrap = false; - } - assert((Ancestor->getOpcode() != Instruction::SExt || NoSignedWrap) && - "Failed to keep proper track of nsw flags while drilling down?"); - - if (Ancestor == Val) - // Got to the top, all done! - return Val; - - // Move up one level in the expression. - assert(Ancestor->hasOneUse() && "Drilled down when more than one use!"); - Ancestor = Ancestor->user_back(); - } while (true); -} - Instruction *InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) { if (!isa(Inst.getType())) return nullptr; diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp --- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp +++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -256,6 +256,48 @@ INITIALIZE_PASS_END(InferAddressSpaces, DEBUG_TYPE, "Infer address spaces", false, false) +static unsigned getPtrOrVecOfPtrsAddressSpace(Type *Ty) { + if (Ty->isVectorTy()) { + Ty = cast(Ty)->getElementType(); + } + assert(Ty->isPointerTy()); + return Ty->getPointerAddressSpace(); +} + +static bool isPtrOrVecOfPtrsType(Type *Ty) { + if (Ty->isVectorTy()) { + Ty = cast(Ty)->getElementType(); + } + return Ty->isPointerTy(); +} + +static Type *getPtrOrVecOfPtrsWithNewAS(Type *Ty, unsigned NewAddrSpace) { + if (!Ty->isVectorTy()) { + assert(Ty->isPointerTy()); + return PointerType::getWithSamePointeeType(cast(Ty), + NewAddrSpace); + } + + Type *PT = cast(Ty)->getElementType(); + assert(PT->isPointerTy()); + + Type *NPT = + PointerType::getWithSamePointeeType(cast(PT), NewAddrSpace); + return VectorType::get(NPT, cast(Ty)->getElementCount()); +} + +static bool hasSameElementOfPtrOrVecPtrs(Type *Ty1, Type *Ty2) { + assert(isPtrOrVecOfPtrsType(Ty1) && isPtrOrVecOfPtrsType(Ty2)); + assert(Ty1->isVectorTy() == Ty2->isVectorTy()); + if (Ty1->isVectorTy()) { + Ty1 = cast(Ty1)->getElementType(); + Ty2 = cast(Ty2)->getElementType(); + } + + assert(Ty1->isPointerTy() && Ty2->isPointerTy()); + return cast(Ty1)->hasSameElementTypeAs(cast(Ty2)); +} + // Check whether that's no-op pointer bicast using a pair of // `ptrtoint`/`inttoptr` due to the missing no-op pointer bitcast over // different address spaces. @@ -279,8 +321,9 @@ // arithmetic may also be undefined after invalid pointer reinterpret cast. // However, as we confirm through the target hooks that it's a no-op // addrspacecast, it doesn't matter since the bits should be the same. - unsigned P2IOp0AS = P2I->getOperand(0)->getType()->getPointerAddressSpace(); - unsigned I2PAS = I2P->getType()->getPointerAddressSpace(); + unsigned P2IOp0AS = + getPtrOrVecOfPtrsAddressSpace(P2I->getOperand(0)->getType()); + unsigned I2PAS = getPtrOrVecOfPtrsAddressSpace(I2P->getType()); return CastInst::isNoopCast(Instruction::CastOps(I2P->getOpcode()), I2P->getOperand(0)->getType(), I2P->getType(), DL) && @@ -301,14 +344,14 @@ switch (Op->getOpcode()) { case Instruction::PHI: - assert(Op->getType()->isPointerTy()); + assert(isPtrOrVecOfPtrsType(Op->getType())); return true; case Instruction::BitCast: case Instruction::AddrSpaceCast: case Instruction::GetElementPtr: return true; case Instruction::Select: - return Op->getType()->isPointerTy(); + return isPtrOrVecOfPtrsType(Op->getType()); case Instruction::Call: { const IntrinsicInst *II = dyn_cast(&V); return II && II->getIntrinsicID() == Intrinsic::ptrmask; @@ -373,6 +416,24 @@ case Intrinsic::ptrmask: // This is handled as an address expression, not as a use memory operation. return false; + case Intrinsic::masked_gather: { + Type *RetTy = II->getType(); + Type *NewPtrTy = NewV->getType(); + Function *NewDecl = + Intrinsic::getDeclaration(M, II->getIntrinsicID(), {RetTy, NewPtrTy}); + II->setArgOperand(0, NewV); + II->setCalledFunction(NewDecl); + return true; + } + case Intrinsic::masked_scatter: { + Type *ValueTy = II->getOperand(0)->getType(); + Type *NewPtrTy = NewV->getType(); + Function *NewDecl = + Intrinsic::getDeclaration(M, II->getIntrinsicID(), {ValueTy, NewPtrTy}); + II->setArgOperand(1, NewV); + II->setCalledFunction(NewDecl); + return true; + } default: { Value *Rewrite = TTI->rewriteIntrinsicWithAddressSpace(II, OldV, NewV); if (!Rewrite) @@ -394,6 +455,14 @@ appendsFlatAddressExpressionToPostorderStack(II->getArgOperand(0), PostorderStack, Visited); break; + case Intrinsic::masked_gather: + appendsFlatAddressExpressionToPostorderStack(II->getArgOperand(0), + PostorderStack, Visited); + break; + case Intrinsic::masked_scatter: + appendsFlatAddressExpressionToPostorderStack(II->getArgOperand(1), + PostorderStack, Visited); + break; default: SmallVector OpIndexes; if (TTI->collectFlatAddressOperands(OpIndexes, IID)) { @@ -412,7 +481,7 @@ void InferAddressSpacesImpl::appendsFlatAddressExpressionToPostorderStack( Value *V, PostorderStackTy &PostorderStack, DenseSet &Visited) const { - assert(V->getType()->isPointerTy()); + assert(isPtrOrVecOfPtrsType(V->getType())); // Generic addressing expressions may be hidden in nested constant // expressions. @@ -424,7 +493,7 @@ return; } - if (V->getType()->getPointerAddressSpace() == FlatAddrSpace && + if (getPtrOrVecOfPtrsAddressSpace(V->getType()) == FlatAddrSpace && isAddressExpression(*V, *DL, TTI)) { if (Visited.insert(V).second) { PostorderStack.emplace_back(V, false); @@ -460,8 +529,7 @@ // addressing calculations may also be faster. for (Instruction &I : instructions(F)) { if (auto *GEP = dyn_cast(&I)) { - if (!GEP->getType()->isVectorTy()) - PushPtrOperand(GEP->getPointerOperand()); + PushPtrOperand(GEP->getPointerOperand()); } else if (auto *LI = dyn_cast(&I)) PushPtrOperand(LI->getPointerOperand()); else if (auto *SI = dyn_cast(&I)) @@ -481,13 +549,12 @@ collectRewritableIntrinsicOperands(II, PostorderStack, Visited); else if (ICmpInst *Cmp = dyn_cast(&I)) { // FIXME: Handle vectors of pointers - if (Cmp->getOperand(0)->getType()->isPointerTy()) { + if (isPtrOrVecOfPtrsType(Cmp->getOperand(0)->getType())) { PushPtrOperand(Cmp->getOperand(0)); PushPtrOperand(Cmp->getOperand(1)); } } else if (auto *ASC = dyn_cast(&I)) { - if (!ASC->getType()->isVectorTy()) - PushPtrOperand(ASC->getPointerOperand()); + PushPtrOperand(ASC->getPointerOperand()); } else if (auto *I2P = dyn_cast(&I)) { if (isNoopPtrIntCastPair(cast(I2P), *DL, TTI)) PushPtrOperand( @@ -501,7 +568,7 @@ // If the operands of the expression on the top are already explored, // adds that expression to the resultant postorder. if (PostorderStack.back().getInt()) { - if (TopVal->getType()->getPointerAddressSpace() == FlatAddrSpace) + if (getPtrOrVecOfPtrsAddressSpace(TopVal->getType()) == FlatAddrSpace) Postorder.push_back(TopVal); PostorderStack.pop_back(); continue; @@ -529,8 +596,7 @@ SmallVectorImpl *UndefUsesToFix) { Value *Operand = OperandUse.get(); - Type *NewPtrTy = PointerType::getWithSamePointeeType( - cast(Operand->getType()), NewAddrSpace); + Type *NewPtrTy = getPtrOrVecOfPtrsWithNewAS(Operand->getType(), NewAddrSpace); if (Constant *C = dyn_cast(Operand)) return ConstantExpr::getAddrSpaceCast(C, NewPtrTy); @@ -543,8 +609,7 @@ if (I != PredicatedAS.end()) { // Insert an addrspacecast on that operand before the user. unsigned NewAS = I->second; - Type *NewPtrTy = PointerType::getWithSamePointeeType( - cast(Operand->getType()), NewAS); + Type *NewPtrTy = getPtrOrVecOfPtrsWithNewAS(Operand->getType(), NewAS); auto *NewI = new AddrSpaceCastInst(Operand, NewPtrTy); NewI->insertBefore(Inst); NewI->setDebugLoc(Inst->getDebugLoc()); @@ -572,15 +637,14 @@ const ValueToValueMapTy &ValueWithNewAddrSpace, const PredicatedAddrSpaceMapTy &PredicatedAS, SmallVectorImpl *UndefUsesToFix) const { - Type *NewPtrType = PointerType::getWithSamePointeeType( - cast(I->getType()), NewAddrSpace); + Type *NewPtrType = getPtrOrVecOfPtrsWithNewAS(I->getType(), NewAddrSpace); if (I->getOpcode() == Instruction::AddrSpaceCast) { Value *Src = I->getOperand(0); // Because `I` is flat, the source address space must be specific. // Therefore, the inferred address space must be the source space, according // to our algorithm. - assert(Src->getType()->getPointerAddressSpace() == NewAddrSpace); + assert(getPtrOrVecOfPtrsAddressSpace(Src->getType()) == NewAddrSpace); if (Src->getType() != NewPtrType) return new BitCastInst(Src, NewPtrType); return Src; @@ -607,8 +671,7 @@ if (AS != UninitializedAddressSpace) { // For the assumed address space, insert an `addrspacecast` to make that // explicit. - Type *NewPtrTy = PointerType::getWithSamePointeeType( - cast(I->getType()), AS); + Type *NewPtrTy = getPtrOrVecOfPtrsWithNewAS(I->getType(), AS); auto *NewI = new AddrSpaceCastInst(I, NewPtrTy); NewI->insertAfter(I); return NewI; @@ -617,7 +680,7 @@ // Computes the converted pointer operands. SmallVector NewPointerOperands; for (const Use &OperandUse : I->operands()) { - if (!OperandUse.get()->getType()->isPointerTy()) + if (!isPtrOrVecOfPtrsType(OperandUse.get()->getType())) NewPointerOperands.push_back(nullptr); else NewPointerOperands.push_back(operandWithNewAddressSpaceOrCreateUndef( @@ -629,7 +692,7 @@ case Instruction::BitCast: return new BitCastInst(NewPointerOperands[0], NewPtrType); case Instruction::PHI: { - assert(I->getType()->isPointerTy()); + assert(isPtrOrVecOfPtrsType(I->getType())); PHINode *PHI = cast(I); PHINode *NewPHI = PHINode::Create(NewPtrType, PHI->getNumIncomingValues()); for (unsigned Index = 0; Index < PHI->getNumIncomingValues(); ++Index) { @@ -648,7 +711,7 @@ return NewGEP; } case Instruction::Select: - assert(I->getType()->isPointerTy()); + assert(isPtrOrVecOfPtrsType(I->getType())); return SelectInst::Create(I->getOperand(0), NewPointerOperands[1], NewPointerOperands[2], "", nullptr, I); case Instruction::IntToPtr: { @@ -674,16 +737,16 @@ ConstantExpr *CE, unsigned NewAddrSpace, const ValueToValueMapTy &ValueWithNewAddrSpace, const DataLayout *DL, const TargetTransformInfo *TTI) { - Type *TargetType = CE->getType()->isPointerTy() - ? PointerType::getWithSamePointeeType( - cast(CE->getType()), NewAddrSpace) - : CE->getType(); + Type *TargetType = + isPtrOrVecOfPtrsType(CE->getType()) + ? getPtrOrVecOfPtrsWithNewAS(CE->getType(), NewAddrSpace) + : CE->getType(); if (CE->getOpcode() == Instruction::AddrSpaceCast) { // Because CE is flat, the source address space must be specific. // Therefore, the inferred address space must be the source space according // to our algorithm. - assert(CE->getOperand(0)->getType()->getPointerAddressSpace() == + assert(getPtrOrVecOfPtrsAddressSpace(CE->getOperand(0)->getType()) == NewAddrSpace); return ConstantExpr::getBitCast(CE->getOperand(0), TargetType); } @@ -697,7 +760,7 @@ if (CE->getOpcode() == Instruction::IntToPtr) { assert(isNoopPtrIntCastPair(cast(CE), *DL, TTI)); Constant *Src = cast(CE->getOperand(0))->getOperand(0); - assert(Src->getType()->getPointerAddressSpace() == NewAddrSpace); + assert(getPtrOrVecOfPtrsAddressSpace(Src->getType()) == NewAddrSpace); return ConstantExpr::getBitCast(Src, TargetType); } @@ -753,7 +816,7 @@ const PredicatedAddrSpaceMapTy &PredicatedAS, SmallVectorImpl *UndefUsesToFix) const { // All values in Postorder are flat address expressions. - assert(V->getType()->getPointerAddressSpace() == FlatAddrSpace && + assert(getPtrOrVecOfPtrsAddressSpace(V->getType()) == FlatAddrSpace && isAddressExpression(*V, *DL, TTI)); if (Instruction *I = dyn_cast(V)) { @@ -898,12 +961,14 @@ Value *Src1 = Op.getOperand(2); auto I = InferredAddrSpace.find(Src0); - unsigned Src0AS = (I != InferredAddrSpace.end()) ? - I->second : Src0->getType()->getPointerAddressSpace(); + unsigned Src0AS = (I != InferredAddrSpace.end()) + ? I->second + : getPtrOrVecOfPtrsAddressSpace(Src0->getType()); auto J = InferredAddrSpace.find(Src1); - unsigned Src1AS = (J != InferredAddrSpace.end()) ? - J->second : Src1->getType()->getPointerAddressSpace(); + unsigned Src1AS = (J != InferredAddrSpace.end()) + ? J->second + : getPtrOrVecOfPtrsAddressSpace(Src1->getType()); auto *C0 = dyn_cast(Src0); auto *C1 = dyn_cast(Src1); @@ -932,7 +997,7 @@ auto I = InferredAddrSpace.find(PtrOperand); unsigned OperandAS; if (I == InferredAddrSpace.end()) { - OperandAS = PtrOperand->getType()->getPointerAddressSpace(); + OperandAS = getPtrOrVecOfPtrsAddressSpace(PtrOperand->getType()); if (OperandAS == FlatAddrSpace) { // Check AC for assumption dominating V. unsigned AS = getPredicatedAddrSpace(V, PtrOperand); @@ -1057,7 +1122,7 @@ unsigned NewAS) const { assert(NewAS != UninitializedAddressSpace); - unsigned SrcAS = C->getType()->getPointerAddressSpace(); + unsigned SrcAS = getPtrOrVecOfPtrsAddressSpace(C->getType()); if (SrcAS == NewAS || isa(C)) return true; @@ -1075,7 +1140,7 @@ return isSafeToCastConstAddrSpace(cast(Op->getOperand(0)), NewAS); if (Op->getOpcode() == Instruction::IntToPtr && - Op->getType()->getPointerAddressSpace() == FlatAddrSpace) + getPtrOrVecOfPtrsAddressSpace(Op->getType()) == FlatAddrSpace) return true; } @@ -1111,7 +1176,7 @@ if (NewAddrSpace == UninitializedAddressSpace) continue; - if (V->getType()->getPointerAddressSpace() != NewAddrSpace) { + if (getPtrOrVecOfPtrsAddressSpace(V->getType()) != NewAddrSpace) { Value *New = cloneValueWithNewAddressSpace(V, NewAddrSpace, ValueWithNewAddrSpace, PredicatedAS, &UndefUsesToFix); @@ -1168,7 +1233,7 @@ I = skipToNextUser(I, E); if (isSimplePointerUseValidToReplace( - *TTI, U, V->getType()->getPointerAddressSpace())) { + *TTI, U, getPtrOrVecOfPtrsAddressSpace(V->getType()))) { // If V is used as the pointer operand of a compatible memory operation, // sets the pointer operand to NewV. This replacement does not change // the element type, so the resultant load/store is still valid. @@ -1199,13 +1264,13 @@ // into // %cmp = icmp eq float addrspace(3)* %new_p, %new_q - unsigned NewAS = NewV->getType()->getPointerAddressSpace(); + unsigned NewAS = getPtrOrVecOfPtrsAddressSpace(NewV->getType()); int SrcIdx = U.getOperandNo(); int OtherIdx = (SrcIdx == 0) ? 1 : 0; Value *OtherSrc = Cmp->getOperand(OtherIdx); if (Value *OtherNewV = ValueWithNewAddrSpace.lookup(OtherSrc)) { - if (OtherNewV->getType()->getPointerAddressSpace() == NewAS) { + if (getPtrOrVecOfPtrsAddressSpace(OtherNewV->getType()) == NewAS) { Cmp->setOperand(OtherIdx, OtherNewV); Cmp->setOperand(SrcIdx, NewV); continue; @@ -1224,11 +1289,10 @@ } if (AddrSpaceCastInst *ASC = dyn_cast(CurUser)) { - unsigned NewAS = NewV->getType()->getPointerAddressSpace(); - if (ASC->getDestAddressSpace() == NewAS) { - if (!cast(ASC->getType()) - ->hasSameElementTypeAs( - cast(NewV->getType()))) { + unsigned NewAS = getPtrOrVecOfPtrsAddressSpace(NewV->getType()); + if (getPtrOrVecOfPtrsAddressSpace(ASC->getType()) == NewAS) { + if (!hasSameElementOfPtrOrVecPtrs(ASC->getType(), + NewV->getType())) { BasicBlock::iterator InsertPos; if (Instruction *NewVInst = dyn_cast(NewV)) InsertPos = std::next(NewVInst->getIterator()); diff --git a/llvm/test/CodeGen/X86/combine-sub-ssat.ll b/llvm/test/CodeGen/X86/combine-sub-ssat.ll --- a/llvm/test/CodeGen/X86/combine-sub-ssat.ll +++ b/llvm/test/CodeGen/X86/combine-sub-ssat.ll @@ -115,6 +115,41 @@ ret <8 x i16> %1 } +; fold (ssub_sat x, y) -> (sub x, y) iff no overflow +define i32 @combine_no_overflow_i32(i32 %a0, i32 %a1) { +; CHECK-LABEL: combine_no_overflow_i32: +; CHECK: # %bb.0: +; CHECK-NEXT: movl %edi, %eax +; CHECK-NEXT: sarl $16, %eax +; CHECK-NEXT: shrl $16, %esi +; CHECK-NEXT: subl %esi, %eax +; CHECK-NEXT: retq + %1 = ashr i32 %a0, 16 + %2 = lshr i32 %a1, 16 + %3 = call i32 @llvm.ssub.sat.i32(i32 %1, i32 %2) + ret i32 %3 +} + +define <8 x i16> @combine_no_overflow_v8i16(<8 x i16> %a0, <8 x i16> %a1) { +; SSE-LABEL: combine_no_overflow_v8i16: +; SSE: # %bb.0: +; SSE-NEXT: psraw $10, %xmm0 +; SSE-NEXT: psrlw $10, %xmm1 +; SSE-NEXT: psubw %xmm1, %xmm0 +; SSE-NEXT: retq +; +; AVX-LABEL: combine_no_overflow_v8i16: +; AVX: # %bb.0: +; AVX-NEXT: vpsraw $10, %xmm0, %xmm0 +; AVX-NEXT: vpsrlw $10, %xmm1, %xmm1 +; AVX-NEXT: vpsubw %xmm1, %xmm0, %xmm0 +; AVX-NEXT: retq + %1 = ashr <8 x i16> %a0, + %2 = lshr <8 x i16> %a1, + %3 = call <8 x i16> @llvm.ssub.sat.v8i16(<8 x i16> %1, <8 x i16> %2) + ret <8 x i16> %3 +} + ; fold (ssub_sat (shuffle x, u, m), (shuffle y, u, m)) -> (shuffle (ssub_sat x, y), u, m) define <8 x i16> @combine_shuffle_shuffle_v8i16(<8 x i16> %x0, <8 x i16> %y0) { ; SSE-LABEL: combine_shuffle_shuffle_v8i16: diff --git a/llvm/test/CodeGen/X86/combine-sub-usat.ll b/llvm/test/CodeGen/X86/combine-sub-usat.ll --- a/llvm/test/CodeGen/X86/combine-sub-usat.ll +++ b/llvm/test/CodeGen/X86/combine-sub-usat.ll @@ -116,6 +116,42 @@ ret <8 x i16> %1 } +; fold (usub_sat x, y) -> (sub x, y) iff no overflow +define i32 @combine_no_overflow_i32(i32 %a0, i32 %a1) { +; CHECK-LABEL: combine_no_overflow_i32: +; CHECK: # %bb.0: +; CHECK-NEXT: shrl $16, %edi +; CHECK-NEXT: shrl $16, %esi +; CHECK-NEXT: xorl %eax, %eax +; CHECK-NEXT: subl %esi, %edi +; CHECK-NEXT: cmovael %edi, %eax +; CHECK-NEXT: retq + %1 = lshr i32 %a0, 16 + %2 = lshr i32 %a1, 16 + %3 = call i32 @llvm.usub.sat.i32(i32 %1, i32 %2) + ret i32 %3 +} + +define <8 x i16> @combine_no_overflow_v8i16(<8 x i16> %a0, <8 x i16> %a1) { +; SSE-LABEL: combine_no_overflow_v8i16: +; SSE: # %bb.0: +; SSE-NEXT: psrlw $10, %xmm0 +; SSE-NEXT: psrlw $10, %xmm1 +; SSE-NEXT: psubusw %xmm1, %xmm0 +; SSE-NEXT: retq +; +; AVX-LABEL: combine_no_overflow_v8i16: +; AVX: # %bb.0: +; AVX-NEXT: vpsrlw $10, %xmm0, %xmm0 +; AVX-NEXT: vpsrlw $10, %xmm1, %xmm1 +; AVX-NEXT: vpsubusw %xmm1, %xmm0, %xmm0 +; AVX-NEXT: retq + %1 = lshr <8 x i16> %a0, + %2 = lshr <8 x i16> %a1, + %3 = call <8 x i16> @llvm.usub.sat.v8i16(<8 x i16> %1, <8 x i16> %2) + ret <8 x i16> %3 +} + ; FIXME: fold (trunc (usub_sat zext(x), y)) -> usub_sat(x, trunc(umin(y,satlimit))) define i16 @combine_trunc_i32_i16(i16 %a0, i32 %a1) { ; CHECK-LABEL: combine_trunc_i32_i16: diff --git a/llvm/test/CodeGen/X86/dagcombine-cse.ll b/llvm/test/CodeGen/X86/dagcombine-cse.ll --- a/llvm/test/CodeGen/X86/dagcombine-cse.ll +++ b/llvm/test/CodeGen/X86/dagcombine-cse.ll @@ -50,6 +50,7 @@ ; X86-NEXT: pushl %ebx ; X86-NEXT: pushl %edi ; X86-NEXT: pushl %esi +; X86-NEXT: pushl %eax ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi ; X86-NEXT: movl %edi, %eax @@ -72,37 +73,31 @@ ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi ; X86-NEXT: movl %esi, %eax ; X86-NEXT: mull %edi -; X86-NEXT: movl %edx, %edi +; X86-NEXT: movl %edx, (%esp) ## 4-byte Spill ; X86-NEXT: movl %eax, %ebp ; X86-NEXT: movl %esi, %eax ; X86-NEXT: mull {{[0-9]+}}(%esp) -; X86-NEXT: movl %eax, %esi -; X86-NEXT: addl %edi, %esi -; X86-NEXT: adcl $0, %edx +; X86-NEXT: movl %edx, %esi +; X86-NEXT: movl %eax, %edi +; X86-NEXT: addl (%esp), %edi ## 4-byte Folded Reload +; X86-NEXT: adcl $0, %esi ; X86-NEXT: addl %ebp, %ebx -; X86-NEXT: adcl %esi, %ecx -; X86-NEXT: setb %al -; X86-NEXT: movl %edx, %edi -; X86-NEXT: adcl $0, %edi +; X86-NEXT: adcl %edi, %ecx +; X86-NEXT: movl %esi, %eax +; X86-NEXT: adcl $0, %eax +; X86-NEXT: setb %dl ; X86-NEXT: addl %ebp, %ebx -; X86-NEXT: adcl %ecx, %esi -; X86-NEXT: setb %cl -; X86-NEXT: adcl %edx, %edi -; X86-NEXT: addb $255, %cl -; X86-NEXT: movl %edx, %ecx +; X86-NEXT: adcl %ecx, %edi +; X86-NEXT: movzbl %dl, %ecx +; X86-NEXT: adcl %eax, %esi ; X86-NEXT: adcl $0, %ecx -; X86-NEXT: setb %ah -; X86-NEXT: addb $255, %al -; X86-NEXT: adcl %edx, %ecx -; X86-NEXT: movzbl %ah, %ebx -; X86-NEXT: adcl $0, %ebx ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax ; X86-NEXT: mull %eax -; X86-NEXT: addl %eax, %edi -; X86-NEXT: adcl %edx, %ebx -; X86-NEXT: movl %esi, %eax -; X86-NEXT: movl %edi, %edx -; X86-NEXT: movl %ebx, %ecx +; X86-NEXT: addl %eax, %esi +; X86-NEXT: adcl %edx, %ecx +; X86-NEXT: movl %edi, %eax +; X86-NEXT: movl %esi, %edx +; X86-NEXT: addl $4, %esp ; X86-NEXT: popl %esi ; X86-NEXT: popl %edi ; X86-NEXT: popl %ebx diff --git a/llvm/test/CodeGen/X86/or-with-overflow.ll b/llvm/test/CodeGen/X86/or-with-overflow.ll --- a/llvm/test/CodeGen/X86/or-with-overflow.ll +++ b/llvm/test/CodeGen/X86/or-with-overflow.ll @@ -163,29 +163,26 @@ ; X86: # %bb.0: ; X86-NEXT: pushl %esi ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-NEXT: movl {{[0-9]+}}(%esp), %edx ; X86-NEXT: movl %eax, %ecx -; X86-NEXT: orl $-17, %ecx +; X86-NEXT: orl $17, %ecx ; X86-NEXT: cmpl $1, %ecx -; X86-NEXT: movl $-1, %edx -; X86-NEXT: movl $-1, %esi +; X86-NEXT: movl %edx, %esi ; X86-NEXT: sbbl $0, %esi -; X86-NEXT: jl .LBB6_1 -; X86-NEXT: # %bb.2: +; X86-NEXT: jl .LBB6_2 +; X86-NEXT: # %bb.1: ; X86-NEXT: movl %ecx, %eax -; X86-NEXT: popl %esi -; X86-NEXT: retl -; X86-NEXT: .LBB6_1: -; X86-NEXT: movl {{[0-9]+}}(%esp), %edx +; X86-NEXT: .LBB6_2: ; X86-NEXT: popl %esi ; X86-NEXT: retl ; ; X64-LABEL: or_i64_ri: ; X64: # %bb.0: ; X64-NEXT: movq %rdi, %rax -; X64-NEXT: orq $-17, %rax +; X64-NEXT: orq $17, %rax ; X64-NEXT: cmovleq %rdi, %rax ; X64-NEXT: retq - %3 = or i64 %0, -17 + %3 = or i64 %0, 17 %4 = icmp slt i64 %3, 1 %5 = select i1 %4, i64 %0, i64 %3 ret i64 %5 diff --git a/llvm/test/Transforms/InferAddressSpaces/AMDGPU/icmp.ll b/llvm/test/Transforms/InferAddressSpaces/AMDGPU/icmp.ll --- a/llvm/test/Transforms/InferAddressSpaces/AMDGPU/icmp.ll +++ b/llvm/test/Transforms/InferAddressSpaces/AMDGPU/icmp.ll @@ -147,9 +147,8 @@ ret i1 %cmp } -; TODO: Should be handled ; CHECK-LABEL: @icmp_flat_flat_from_group_vector( -; CHECK: %cmp = icmp eq <2 x ptr> %cast0, %cast1 +; CHECK: %cmp = icmp eq <2 x ptr addrspace(3)> %group.ptr.0, %group.ptr.1 define <2 x i1> @icmp_flat_flat_from_group_vector(<2 x ptr addrspace(3)> %group.ptr.0, <2 x ptr addrspace(3)> %group.ptr.1) #0 { %cast0 = addrspacecast <2 x ptr addrspace(3)> %group.ptr.0 to <2 x ptr> %cast1 = addrspacecast <2 x ptr addrspace(3)> %group.ptr.1 to <2 x ptr> diff --git a/llvm/test/Transforms/InferAddressSpaces/masked-gather-scatter.ll b/llvm/test/Transforms/InferAddressSpaces/masked-gather-scatter.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/InferAddressSpaces/masked-gather-scatter.ll @@ -0,0 +1,25 @@ +; RUN: opt -S -passes=infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck %s + +; CHECK-LABEL: @masked_gather_inferas( +; CHECK: tail call <4 x i32> @llvm.masked.gather.v4i32.v4p1 +define <4 x i32> @masked_gather_inferas(ptr addrspace(1) %out, <4 x i64> %index) { +entry: + %out.1 = addrspacecast ptr addrspace(1) %out to ptr + %ptrs = getelementptr inbounds i32, ptr %out.1, <4 x i64> %index + %value = tail call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> %ptrs, i32 4, <4 x i1> , <4 x i32> poison) + ret <4 x i32> %value +} + +; CHECK-LABEL: @masked_scatter_inferas( +; CHECK: tail call void @llvm.masked.scatter.v4i32.v4p1 +define void @masked_scatter_inferas(ptr addrspace(1) %out, <4 x i64> %index, <4 x i32> %value) { +entry: + %out.1 = addrspacecast ptr addrspace(1) %out to ptr + %ptrs = getelementptr inbounds i32, ptr %out.1, <4 x i64> %index + tail call void @llvm.masked.scatter.v4i32.v4p0(<4 x i32> %value, <4 x ptr> %ptrs, i32 4, <4 x i1> ) + ret void +} + +declare <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr>, i32 immarg, <4 x i1>, <4 x i32>) + +declare void @llvm.masked.scatter.v4i32.v4p0(<4 x i32>, <4 x ptr>, i32 immarg, <4 x i1>) \ No newline at end of file diff --git a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/cppcoreguidelines/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/cppcoreguidelines/BUILD.gn --- a/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/cppcoreguidelines/BUILD.gn +++ b/llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/cppcoreguidelines/BUILD.gn @@ -27,6 +27,7 @@ "InterfacesGlobalInitCheck.cpp", "MacroUsageCheck.cpp", "MisleadingCaptureDefaultByValueCheck.cpp", + "MissingStdForwardCheck.cpp", "NarrowingConversionsCheck.cpp", "NoMallocCheck.cpp", "OwningMemoryCheck.cpp", diff --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn --- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn +++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn @@ -32,7 +32,6 @@ "_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS=1", "_LIBCPP_NO_VCRUNTIME=", "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=", - "_LIBCPP_HAS_PARALLEL_ALGORITHMS=", "_LIBCPP_HAS_NO_RANDOM_DEVICE=", "_LIBCPP_HAS_NO_LOCALIZATION=", "_LIBCPP_HAS_NO_WIDE_CHARACTERS=", @@ -700,9 +699,6 @@ "__support/musl/xlocale.h", "__support/newlib/xlocale.h", "__support/openbsd/xlocale.h", - "__support/solaris/floatingpoint.h", - "__support/solaris/wchar.h", - "__support/solaris/xlocale.h", "__support/win32/locale_win32.h", "__support/xlocale/__nop_locale_mgmt.h", "__support/xlocale/__posix_l_fallback.h", diff --git a/llvm/utils/gn/secondary/libcxx/src/BUILD.gn b/llvm/utils/gn/secondary/libcxx/src/BUILD.gn --- a/llvm/utils/gn/secondary/libcxx/src/BUILD.gn +++ b/llvm/utils/gn/secondary/libcxx/src/BUILD.gn @@ -187,9 +187,6 @@ "support/win32/thread_win32.cpp", ] } -if (target_os == "solaris") { - cxx_sources += [ "support/solaris/xlocale.cpp" ] -} if (target_os == "zos") { cxx_sources += [ "support/ibm/mbsnrtowcs.cpp", diff --git a/llvm/utils/gn/secondary/lld/test/BUILD.gn b/llvm/utils/gn/secondary/lld/test/BUILD.gn --- a/llvm/utils/gn/secondary/lld/test/BUILD.gn +++ b/llvm/utils/gn/secondary/lld/test/BUILD.gn @@ -21,6 +21,7 @@ "LLD_SOURCE_DIR=" + rebase_path("//lld"), "LLVM_BINARY_DIR=" + rebase_path(get_label_info("//llvm", "target_out_dir")), + "LLVM_HOST_TRIPLE=$llvm_current_triple", "LLVM_LIBS_DIR=", # needed only for shared builds "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build. "LLVM_SOURCE_DIR=" + rebase_path("//llvm"), diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/LoongArch/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/LoongArch/BUILD.gn --- a/llvm/utils/gn/secondary/llvm/lib/Target/LoongArch/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/Target/LoongArch/BUILD.gn @@ -44,6 +44,7 @@ "LoongArchRegisterInfo.cpp", "LoongArchSubtarget.cpp", "LoongArchTargetMachine.cpp", + "LoongArchTargetTransformInfo.cpp", ] } diff --git a/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn --- a/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn @@ -66,6 +66,7 @@ "OptimizedStructLayoutTest.cpp", "ParallelTest.cpp", "Path.cpp", + "PerThreadBumpPtrAllocatorTest.cpp", "ProcessTest.cpp", "ProgramTest.cpp", "RISCVAttributeParserTest.cpp", diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -1,5 +1,5 @@ # MLIR project. -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -11,6 +11,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(mlir) set(MLIR_STANDALONE_BUILD TRUE) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() endif() # Must go below project(..) diff --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md --- a/mlir/docs/LangRef.md +++ b/mlir/docs/LangRef.md @@ -287,20 +287,20 @@ Syntax: ``` -operation ::= op-result-list? (generic-operation | custom-operation) - trailing-location? -generic-operation ::= string-literal `(` value-use-list? `)` successor-list? - dictionary-properties? region-list? dictionary-attribute? - `:` function-type -custom-operation ::= bare-id custom-operation-format -op-result-list ::= op-result (`,` op-result)* `=` -op-result ::= value-id (`:` integer-literal) -successor-list ::= `[` successor (`,` successor)* `]` -successor ::= caret-id (`:` block-arg-list)? -dictionary-propertes ::= `<` dictionary-attribute `>` -region-list ::= `(` region (`,` region)* `)` -dictionary-attribute ::= `{` (attribute-entry (`,` attribute-entry)*)? `}` -trailing-location ::= (`loc` `(` location `)`)? +operation ::= op-result-list? (generic-operation | custom-operation) + trailing-location? +generic-operation ::= string-literal `(` value-use-list? `)` successor-list? + dictionary-properties? region-list? dictionary-attribute? + `:` function-type +custom-operation ::= bare-id custom-operation-format +op-result-list ::= op-result (`,` op-result)* `=` +op-result ::= value-id (`:` integer-literal) +successor-list ::= `[` successor (`,` successor)* `]` +successor ::= caret-id (`:` block-arg-list)? +dictionary-properties ::= `<` dictionary-attribute `>` +region-list ::= `(` region (`,` region)* `)` +dictionary-attribute ::= `{` (attribute-entry (`,` attribute-entry)*)? `}` +trailing-location ::= (`loc` `(` location `)`)? ``` MLIR introduces a uniform concept called *operations* to enable describing many diff --git a/mlir/examples/standalone/CMakeLists.txt b/mlir/examples/standalone/CMakeLists.txt --- a/mlir/examples/standalone/CMakeLists.txt +++ b/mlir/examples/standalone/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) project(standalone-dialect LANGUAGES CXX C) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -187,7 +187,8 @@ } } if (!result.propertiesAttr) { - Optional info = result.name.getRegisteredInfo(); + std::optional info = + result.name.getRegisteredInfo(); if (info) { if (failed(info->verifyInherentAttrs(result.attributes, [&]() { return parser.emitError(attrsLoc) diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -12,6 +12,13 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") set(OPENMP_STANDALONE_BUILD TRUE) project(openmp C CXX) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() endif() # Must go below project(..) diff --git a/openmp/cmake/DetectTestCompiler/CMakeLists.txt b/openmp/cmake/DetectTestCompiler/CMakeLists.txt --- a/openmp/cmake/DetectTestCompiler/CMakeLists.txt +++ b/openmp/cmake/DetectTestCompiler/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) project(DetectTestCompiler C CXX) include(CheckCCompilerFlag) diff --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst --- a/openmp/docs/SupportAndFAQ.rst +++ b/openmp/docs/SupportAndFAQ.rst @@ -307,7 +307,7 @@ .. code-block:: cmake - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) project(offloadTest VERSION 1.0 LANGUAGES CXX) list(APPEND CMAKE_MODULE_PATH "${PATH_TO_OPENMP_INSTALL}/lib/cmake/openmp") @@ -318,7 +318,7 @@ target_link_libraries(offload PRIVATE OpenMPTarget::OpenMPTarget_NVPTX) target_sources(offload PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp) -Using this module requires at least CMake version 3.20.0. Supported languages +Using this module requires at least CMake version 3.13.4. Supported languages are C and C++ with Fortran support planned in the future. Compiler support is best for Clang but this module should work for other compiler vendors such as IBM, GNU. diff --git a/openmp/libompd/src/CMakeLists.txt b/openmp/libompd/src/CMakeLists.txt --- a/openmp/libompd/src/CMakeLists.txt +++ b/openmp/libompd/src/CMakeLists.txt @@ -9,7 +9,7 @@ # project (libompd) -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) add_library (ompd SHARED TargetValue.cpp omp-debug.cpp omp-state.cpp omp-icv.cpp) diff --git a/openmp/libomptarget/plugins/remote/src/CMakeLists.txt b/openmp/libomptarget/plugins/remote/src/CMakeLists.txt --- a/openmp/libomptarget/plugins/remote/src/CMakeLists.txt +++ b/openmp/libomptarget/plugins/remote/src/CMakeLists.txt @@ -10,7 +10,7 @@ # ##===----------------------------------------------------------------------===## -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) # Define the suffix for the runtime messaging dumps. add_definitions(-DTARGET_NAME=RPC) diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt --- a/openmp/libomptarget/src/CMakeLists.txt +++ b/openmp/libomptarget/src/CMakeLists.txt @@ -31,6 +31,10 @@ Support Object + LINK_LIBS + PUBLIC + omp + NO_INSTALL_RPATH ) target_include_directories(omptarget PRIVATE ${LIBOMPTARGET_INCLUDE_DIR}) diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt --- a/openmp/runtime/src/CMakeLists.txt +++ b/openmp/runtime/src/CMakeLists.txt @@ -272,7 +272,7 @@ set(LIBOMP_GENERATED_DEF_FILE ${LIBOMP_LIB_NAME}.def) add_custom_target(libomp-needed-def-file DEPENDS ${LIBOMP_GENERATED_DEF_FILE}) add_dependencies(omp libomp-needed-def-file) - + # Create the main def file with ordinals to use for building the runtime dll to maintain backwards compatible exports order libomp_get_gdflags(LIBOMP_GDFLAGS) libomp_string_to_list("${LIBOMP_GDFLAGS}" LIBOMP_GDFLAGS) @@ -286,7 +286,7 @@ if(MSVC) # For toolchains that generated the import library importing by ordinal, re-generate it to import by name set(LIBOMP_IMP_LIB_TARGET ompimp) - # Create the auxiliary def file without ordinals to use for building the import library to import by name + # Create the auxiliary def file without ordinals to use for building the import library to import by name set(LIBOMPIMP_GENERATED_DEF_FILE ${LIBOMP_LIB_NAME}.imp.def) add_custom_target(libompimp-needed-def-file DEPENDS ${LIBOMPIMP_GENERATED_DEF_FILE}) add_custom_command( @@ -295,7 +295,7 @@ -o ${LIBOMPIMP_GENERATED_DEF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/dllexports DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dllexports ${LIBOMP_TOOLS_DIR}/generate-def.pl ) - # while this merely generates an import library off a def file, CMAKE still requires it to have a "source" so feed it a dummy one, + # while this merely generates an import library off a def file, CMAKE still requires it to have a "source" so feed it a dummy one, # making it a .txt which CMAKE will filter out from the librarian (a .cpp will make lib.exe punt trying to resolve the .def symbols) add_library(${LIBOMP_IMP_LIB_TARGET} STATIC kmp_dummy.txt) set_target_properties(${LIBOMP_IMP_LIB_TARGET} PROPERTIES @@ -354,11 +354,18 @@ endif() add_dependencies(libomp-micro-tests libomp-test-deps) +# `omp` needs to be exported if in-tree build. +set(export_to_llvmexports) +if (NOT OPENMP_STANDALONE_BUILD) + get_target_export_arg(omp LLVM export_to_llvmexports) + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS omp) +endif() + # Install rules # We want to install libomp in ${DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR} # We want to install headers in ${DESTDIR}/${CMAKE_INSTALL_FULL_INCLUDEDIR} if(WIN32) - install(TARGETS omp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + install(TARGETS omp ${export_to_llvmexports} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}") # Create aliases (regular copies) of the library for backwards compatibility set(LIBOMP_ALIASES "libiomp5md") @@ -371,7 +378,7 @@ endforeach() else() - install(TARGETS omp ${LIBOMP_INSTALL_KIND} DESTINATION "${OPENMP_INSTALL_LIBDIR}") + install(TARGETS omp ${export_to_llvmexports} ${LIBOMP_INSTALL_KIND} DESTINATION "${OPENMP_INSTALL_LIBDIR}") if(${LIBOMP_INSTALL_ALIASES}) # Create aliases (symlinks) of the library for backwards compatibility diff --git a/openmp/tools/Modules/FindOpenMPTarget.cmake b/openmp/tools/Modules/FindOpenMPTarget.cmake --- a/openmp/tools/Modules/FindOpenMPTarget.cmake +++ b/openmp/tools/Modules/FindOpenMPTarget.cmake @@ -79,7 +79,7 @@ # TODO: Test more compilers cmake_policy(PUSH) -cmake_policy(VERSION 3.20.0) +cmake_policy(VERSION 3.13.4) find_package(OpenMP ${OpenMPTarget_FIND_VERSION} REQUIRED) diff --git a/openmp/tools/Modules/README.rst b/openmp/tools/Modules/README.rst --- a/openmp/tools/Modules/README.rst +++ b/openmp/tools/Modules/README.rst @@ -26,7 +26,7 @@ .. code-block:: cmake - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) project(offloadTest VERSION 1.0 LANGUAGES CXX) list(APPEND CMAKE_MODULE_PATH "${PATH_TO_OPENMP_INSTALL}/lib/cmake/openmp") @@ -37,7 +37,7 @@ target_link_libraries(offload PRIVATE OpenMPTarget::OpenMPTarget_NVPTX) target_sources(offload PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp) -Using this module requires at least CMake version 3.20.0. Supported languages +Using this module requires at least CMake version 3.13.4. Supported languages are C and C++ with Fortran support planned in the future. If your application requires building for a specific device architecture you can set the ``OpenMPTarget__ARCH=`` variable. Compiler support is best for diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt --- a/polly/CMakeLists.txt +++ b/polly/CMakeLists.txt @@ -1,7 +1,14 @@ # Check if this is a in tree build. if (NOT DEFINED LLVM_MAIN_SRC_DIR) project(Polly) - cmake_minimum_required(VERSION 3.20.0) + cmake_minimum_required(VERSION 3.13.4) + if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") + endif() set(POLLY_STANDALONE_BUILD TRUE) endif() diff --git a/pstl/CMakeLists.txt b/pstl/CMakeLists.txt --- a/pstl/CMakeLists.txt +++ b/pstl/CMakeLists.txt @@ -5,7 +5,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===----------------------------------------------------------------------===## -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h") file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$") diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -1,5 +1,12 @@ # This file handles building LLVM runtime sub-projects. -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required(VERSION 3.13.4) +if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " + "minimum version of CMake required to build LLVM will become 3.20.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.20.0 now to avoid issues in the future!") +endif() project(Runtimes C CXX ASM) # Add path for custom and the LLVM build's modules to the CMake module path. diff --git a/utils/bazel/llvm-project-overlay/bolt/BUILD.bazel b/utils/bazel/llvm-project-overlay/bolt/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/bolt/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/bolt/BUILD.bazel @@ -267,6 +267,7 @@ "//llvm:MCParser", "//llvm:Object", "//llvm:Support", + "//llvm:TargetParser", "//llvm:ir_headers", ], ) diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel @@ -114,6 +114,7 @@ name = "utils", deps = [ ":lib", + "//clang:analysis", "//clang:sema", "//clang:tooling", "//clang:transformer", @@ -135,6 +136,7 @@ deps = [ ":lib", ":readability", + ":utils", ], ) @@ -221,6 +223,7 @@ name = "mpi", deps = [ ":lib", + "//clang:static_analyzer_checkers", "//clang:static_analyzer_core", "//clang:static_analyzer_frontend", "//clang:tooling", diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel @@ -1720,6 +1720,7 @@ "//llvm:ExecutionEngine", "//llvm:Option", "//llvm:OrcJIT", + "//llvm:OrcShared", "//llvm:OrcTargetProcess", "//llvm:Support", "//llvm:Target", diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -2277,6 +2277,7 @@ ":__support_cpp_string_view", ":__support_float_to_string", ":__support_fputil_fenv_impl", + ":__support_fputil_float_properties", ":__support_fputil_fp_bits", ":__support_integer_to_string", ":__support_libc_assert", diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -1743,6 +1743,7 @@ ":TransformUtils", ":asm_printer_defs", ":config", + ":vt_gen", ], )