Projects
openEuler:24.03:SP1:Everything:64G
clang
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
_service:tar_scm:clang.spec
Changed
@@ -1,6 +1,12 @@ %bcond_without sys_llvm %bcond_without check %bcond_with classic_flang +%bcond_with toolchain_clang +%bcond_without bisheng_autotuner + +%if %{with toolchain_clang} +%global toolchain clang +%endif %global maj_ver 17 %global min_ver 0 @@ -37,7 +43,7 @@ Name: %{pkg_name} Version: %{clang_version} -Release: 16 +Release: 24 Summary: A C language family front-end for LLVM License: NCSA @@ -60,6 +66,12 @@ Patch12: 0012-Fix-declaration-definition-mismatch-for-classic-flang.patch Patch13: 0013-Ignored-option-Wa-generate-missing-build-notes.patch Patch14: 0014-Update-llvm-lit-config-to-support-build_for_openeule.patch +Patch15: 0015-Backport-Defer-the-instantiation-of-explicit-specifier-until-.patch +Patch16: 0016-Add-BiSheng-Autotuner-support-for-LLVM-compiler.patch +Patch17: 0017-fix-for-missing-DENABLE_AUTOTUNER.patch +Patch18: 0018-backport-Clang-Fix-build-with-GCC-14-on-ARM-78704.patch +Patch19: 0019-AArch64-Support-HiSilicon-s-HIP09-Processor.patch +Patch20: 0020-Backport-LoongArch-fix-and-add-some-new-support.patch # Patches for clang-tools-extra # See https://reviews.llvm.org/D120301 @@ -107,6 +119,9 @@ BuildRequires: perl(Term::ANSIColor) BuildRequires: perl(Text::ParseWords) BuildRequires: perl(Sys::Hostname) +%if %{with toolchain_clang} +BuildRequires: clang +%endif Requires: %{name}-libs%{?_isa} = %{version}-%{release} @@ -267,7 +282,14 @@ %if %{with classic_flang} -DLLVM_ENABLE_CLASSIC_FLANG=ON \ %endif +%if %{with bisheng_autotuner} + -DLLVM_ENABLE_AUTOTUNER=ON \ +%endif -DBUILD_FOR_OPENEULER=ON \ +%if "%{toolchain}" == "clang" + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ +%endif -DCLANG_DEFAULT_UNWINDLIB=libgcc %ninja_build @@ -394,6 +416,31 @@ %{install_bindir}/git-clang-format %changelog +* Mon Sep 23 2024 zhanglimin <zhanglimin@loongson.cn> - 17.0.6-24 +- LoongArch Backport some new support + +* Tue Sep 10 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-23 +- AArch64 Support HiSilicon's HIP09 Processor + +* Tue Sep 03 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-22 +- Fix build with GCC that supports SME. + +* Tue Aug 20 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-21 +- Fix for missing -DENABLE_AUTOTUNER in compilation. + +* Tue Jul 30 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-20 +- Disable toolchain_clang build for BiSheng Autotuner support temporary. + +* Tue Jul 16 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-19 +- Add BiSheng Autotuner support. + +* Fri Jul 5 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-18 +- Add toolchain_clang build support + +* Tue Jun 04 2024 Zhao Mengmeng <zhaomengmeng@kylinos.cn> - 17.0.6-17 +- Fix the too-early instantiation of conditional "explict" by applying the patch + of https://github.com/llvm/llvm-project/commit/128b3b61fe6768c724975fd1df2be0abec848cf6 + * Mon Apr 29 2024 wangqiang <wangqiang1@kylinos.cn> - 17.0.6-16 - Ignored the `-Wa,--generate-missing-build-notes=` option, update llvm-lit config to support macro `build_for_openeuler`
View file
_service:tar_scm:0015-Backport-Defer-the-instantiation-of-explicit-specifier-until-.patch
Added
@@ -0,0 +1,259 @@ +From c2668403868559918b54671d3d31527fb2f04486 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E5=88=98=E9=9B=A8=E5=9F=B9?= <liuyupei951018@hotmail.com> +Date: Wed, 1 Nov 2023 21:45:48 +0800 +Subject: PATCH Defer the instantiation of explicit-specifier until + constraint checking completes (#70548) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Modifications: + +- Skip the instantiation of the explicit-specifier during Decl +substitution if we are deducing template arguments and the +explicit-specifier is value dependent. + +- Instantiate the explicit-specifier after the constraint checking +completes. + +- Make `instantiateExplicitSpecifier` a member function in order to +instantiate the explicit-specifier in different stages. + +This PR doesn’t defer the instantiation of the explicit specifier for +deduction guides, because I’m not familiar with deduction guides yet. +I’ll dig into it after this PR. + +According to my local test, GCC 13 tuple works with this PR. + +Fixes #59827. + +--------- + +Co-authored-by: Erich Keane <ekeane@nvidia.com> +--- + docs/ReleaseNotes.rst | 4 ++ + include/clang/Sema/Sema.h | 3 ++ + lib/Sema/SemaTemplateDeduction.cpp | 53 +++++++++++++++++++ + lib/Sema/SemaTemplateInstantiateDecl.cpp | 40 +++++++++----- + test/SemaCXX/cxx2a-explicit-bool-deferred.cpp | 31 +++++++++++ + 5 files changed, 117 insertions(+), 14 deletions(-) + create mode 100644 test/SemaCXX/cxx2a-explicit-bool-deferred.cpp + +diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst +index 5086a56e..05dad41c 100644 +--- a/clang/docs/ReleaseNotes.rst ++++ b/clang/docs/ReleaseNotes.rst +@@ -860,6 +860,10 @@ Bug Fixes to C++ Support + (`#64172 <https://github.com/llvm/llvm-project/issues/64172>`_) and + (`#64723 <https://github.com/llvm/llvm-project/issues/64723>`_). + ++- Clang now defers the instantiation of explicit specifier until constraint checking ++ completes (except deduction guides). Fixes: ++ (`#59827 <https://github.com/llvm/llvm-project/issues/59827>`_) ++ + Bug Fixes to AST Handling + ^^^^^^^^^^^^^^^^^^^^^^^^^ + +diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h +index 3752a23f..b2ab6d0f 100644 +--- a/clang/include/clang/Sema/Sema.h ++++ b/clang/include/clang/Sema/Sema.h +@@ -10293,6 +10293,9 @@ public: + const CXXConstructorDecl *Tmpl, + const MultiLevelTemplateArgumentList &TemplateArgs); + ++ ExplicitSpecifier instantiateExplicitSpecifier( ++ const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES); ++ + NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, + const MultiLevelTemplateArgumentList &TemplateArgs, + bool FindingInstantiatedContext = false); +diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp +index 31ea7be2..58dd1b78 100644 +--- a/clang/lib/Sema/SemaTemplateDeduction.cpp ++++ b/clang/lib/Sema/SemaTemplateDeduction.cpp +@@ -3546,6 +3546,48 @@ static unsigned getPackIndexForParam(Sema &S, + llvm_unreachable("parameter index would not be produced from template"); + } + ++// if `Specialization` is a `CXXConstructorDecl` or `CXXConversionDecl`, ++// we'll try to instantiate and update its explicit specifier after constraint ++// checking. ++static Sema::TemplateDeductionResult instantiateExplicitSpecifierDeferred( ++ Sema &S, FunctionDecl *Specialization, ++ const MultiLevelTemplateArgumentList &SubstArgs, ++ TemplateDeductionInfo &Info, FunctionTemplateDecl *FunctionTemplate, ++ ArrayRef<TemplateArgument> DeducedArgs) { ++ auto GetExplicitSpecifier = (FunctionDecl *D) { ++ return isa<CXXConstructorDecl>(D) ++ ? cast<CXXConstructorDecl>(D)->getExplicitSpecifier() ++ : cast<CXXConversionDecl>(D)->getExplicitSpecifier(); ++ }; ++ auto SetExplicitSpecifier = (FunctionDecl *D, ExplicitSpecifier ES) { ++ isa<CXXConstructorDecl>(D) ++ ? cast<CXXConstructorDecl>(D)->setExplicitSpecifier(ES) ++ : cast<CXXConversionDecl>(D)->setExplicitSpecifier(ES); ++ }; ++ ++ ExplicitSpecifier ES = GetExplicitSpecifier(Specialization); ++ Expr *ExplicitExpr = ES.getExpr(); ++ if (!ExplicitExpr) ++ return Sema::TDK_Success; ++ if (!ExplicitExpr->isValueDependent()) ++ return Sema::TDK_Success; ++ ++ Sema::InstantiatingTemplate Inst( ++ S, Info.getLocation(), FunctionTemplate, DeducedArgs, ++ Sema::CodeSynthesisContext::DeducedTemplateArgumentSubstitution, Info); ++ if (Inst.isInvalid()) ++ return Sema::TDK_InstantiationDepth; ++ Sema::SFINAETrap Trap(S); ++ const ExplicitSpecifier InstantiatedES = ++ S.instantiateExplicitSpecifier(SubstArgs, ES); ++ if (InstantiatedES.isInvalid() || Trap.hasErrorOccurred()) { ++ Specialization->setInvalidDecl(true); ++ return Sema::TDK_SubstitutionFailure; ++ } ++ SetExplicitSpecifier(Specialization, InstantiatedES); ++ return Sema::TDK_Success; ++} ++ + /// Finish template argument deduction for a function template, + /// checking the deduced template arguments for completeness and forming + /// the function template specialization. +@@ -3675,6 +3717,17 @@ Sema::TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( + } + } + ++ // We skipped the instantiation of the explicit-specifier during the ++ // substitution of `FD` before. So, we try to instantiate it back if ++ // `Specialization` is either a constructor or a conversion function. ++ if (isa<CXXConstructorDecl, CXXConversionDecl>(Specialization)) { ++ if (TDK_Success != instantiateExplicitSpecifierDeferred( ++ *this, Specialization, SubstArgs, Info, ++ FunctionTemplate, DeducedArgs)) { ++ return TDK_SubstitutionFailure; ++ } ++ } ++ + if (OriginalCallArgs) { + // C++ temp.deduct.callp4: + // In general, the deduction process attempts to find template argument +diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +index f78d46f5..a40510ce 100644 +--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp ++++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +@@ -555,18 +555,16 @@ static void instantiateDependentAMDGPUFlatWorkGroupSizeAttr( + S.addAMDGPUFlatWorkGroupSizeAttr(New, Attr, MinExpr, MaxExpr); + } + +-static ExplicitSpecifier +-instantiateExplicitSpecifier(Sema &S, +- const MultiLevelTemplateArgumentList &TemplateArgs, +- ExplicitSpecifier ES, FunctionDecl *New) { ++ExplicitSpecifier Sema::instantiateExplicitSpecifier( ++ const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES) { + if (!ES.getExpr()) + return ES; + Expr *OldCond = ES.getExpr(); + Expr *Cond = nullptr; + { + EnterExpressionEvaluationContext Unevaluated( +- S, Sema::ExpressionEvaluationContext::ConstantEvaluated); +- ExprResult SubstResult = S.SubstExpr(OldCond, TemplateArgs); ++ *this, Sema::ExpressionEvaluationContext::ConstantEvaluated); ++ ExprResult SubstResult = SubstExpr(OldCond, TemplateArgs); + if (SubstResult.isInvalid()) { + return ExplicitSpecifier::Invalid(); + } +@@ -574,7 +572,7 @@ instantiateExplicitSpecifier(Sema &S, + } + ExplicitSpecifier Result(Cond, ES.getKind()); + if (!Cond->isTypeDependent()) +- S.tryResolveExplicitSpecifier(Result); ++ tryResolveExplicitSpecifier(Result); + return Result; + } + +@@ -2065,8 +2063,8 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl( + + ExplicitSpecifier InstantiatedExplicitSpecifier; + if (auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) { +- InstantiatedExplicitSpecifier = instantiateExplicitSpecifier( +- SemaRef, TemplateArgs, DGuide->getExplicitSpecifier(), DGuide); ++ InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier( ++ TemplateArgs, DGuide->getExplicitSpecifier()); + if (InstantiatedExplicitSpecifier.isInvalid()) + return nullptr; + } +@@ -2440,11 +2438,25 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl( + } + } + +- ExplicitSpecifier InstantiatedExplicitSpecifier = +- instantiateExplicitSpecifier(SemaRef, TemplateArgs, +- ExplicitSpecifier::getFromDecl(D), D); +- if (InstantiatedExplicitSpecifier.isInvalid()) +- return nullptr; ++ auto InstantiatedExplicitSpecifier = ExplicitSpecifier::getFromDecl(D); ++ // deduction guides need this
View file
_service:tar_scm:0016-Add-BiSheng-Autotuner-support-for-LLVM-compiler.patch
Added
@@ -0,0 +1,739 @@ +From a9863e2b6e6783aa9be0b9d1d187084fd4b32a3a Mon Sep 17 00:00:00 2001 +From: Muhammad Asif Manzoor <muhammad.asif.manzoor1@huawei.com> +Date: Thu, 21 Mar 2024 12:50:38 -0400 +Subject: Add BiSheng Autotuner support for LLVM compiler + +Automatic tuning is an automatic iterative process that optimizes a given +program by manipulating compilation options for optimal performance. +BiSheng Autotuner provides a resumable interface for tuning process. BiSheng +Autotuner can tune 1) individual code segments/blocks (fine grain turning) like +loops, callsites, instructions, etc. and 2) entire modules/programs (coarse +grain tuning) for compiler flags, pass ordering, etc. +This patch enables LLVM compiler to extract tuneable code regions and then apply +suggested configuration (by Autotuner) to find out the optimal configurations. +--- + clang/include/clang/Basic/CMakeLists.txt | 15 ++ + .../clang/Basic/DiagnosticDriverKinds.td | 9 ++ + .../clang/Basic/DiagnosticFrontendKinds.td | 8 + + clang/include/clang/Driver/CMakeLists.txt | 6 +- + clang/include/clang/Driver/Driver.h | 36 +++++ + clang/include/clang/Driver/Options.td | 13 ++ + clang/lib/CodeGen/BackendUtil.cpp | 58 +++++++ + clang/lib/Driver/Driver.cpp | 82 ++++++++++ + clang/lib/Driver/ToolChains/Clang.cpp | 21 +++ + clang/lib/Driver/ToolChains/CommonArgs.cpp | 113 ++++++++++++++ + clang/lib/Driver/ToolChains/CommonArgs.h | 8 + + clang/lib/Driver/ToolChains/Gnu.cpp | 34 ++++ + .../ExecuteCompilerInvocation.cpp | 27 ++++ + .../autotune_datadir/baseline-config.yaml | 9 ++ + .../autotune_datadir/random-config.yaml | 9 ++ + .../BaselineConfig/apply-baseline-config.c | 32 ++++ + .../test/Autotuning/Driver/Inputs/config.yaml | 3 + + .../Autotuning/Driver/Inputs/template.yaml | 9 ++ + .../Driver/autotune-generate-pipeline.c | 146 ++++++++++++++++++ + .../Driver/autotune-pipeline-thin-lto.c | 42 +++++ + .../Autotuning/Driver/autotune-pipeline.c | 131 ++++++++++++++++ + .../test/Autotuning/GenerateOpp/generate.cpp | 25 +++ + .../Inputs/template.yaml | 9 ++ + .../IncrementalCompilation/Inputs/test1.c | 3 + + .../IncrementalCompilation/Inputs/test2.c | 17 ++ + .../IncrementalCompilation/Inputs/test3.c | 6 + + .../inc-compile-generate-input.cpp | 44 ++++++ + .../Inputs/datadir/corse_grain_config.yaml | 1 + + .../LTO/Inputs/datadir/fine_grain_a.out.yaml | 4 + + .../LTO/Inputs/datadir/fine_grain_output.yaml | 1 + + .../LTO/apply_config_coarse_grain.cpp | 41 +++++ + .../LTO/apply_config_fine_grain.cpp | 58 +++++++ + .../Autotuning/LTO/generate_opportunity.cpp | 56 +++++++ + .../PhaseOrdering/Inputs/template.yaml | 8 + + .../Autotuning/PhaseOrdering/pass-order.cpp | 48 ++++++ + 42 files changed, 1170 insertions(+), 1 deletion(-) + +diff --git a/clang/include/clang/Basic/CMakeLists.txt b/clang/include/clang/Basic/CMakeLists.txt +index f010e04f62cd..e449d2790597 100644 +--- a/clang/include/clang/Basic/CMakeLists.txt ++++ b/clang/include/clang/Basic/CMakeLists.txt +@@ -1,6 +1,12 @@ ++set(CLANG_BASIC_OPTIONS) ++if(LLVM_ENABLE_AUTOTUNER) ++ list(APPEND CLANG_BASIC_OPTIONS "-DENABLE_AUTOTUNER") ++endif() ++ + macro(clang_diag_gen component) + clang_tablegen(Diagnostic${component}Kinds.inc + -gen-clang-diags-defs -clang-component=${component} ++ ${CLANG_BASIC_OPTIONS} + SOURCE Diagnostic.td + TARGET ClangDiagnostic${component}) + endmacro(clang_diag_gen) +@@ -18,20 +24,24 @@ clang_diag_gen(Refactoring) + clang_diag_gen(Sema) + clang_diag_gen(Serialization) + clang_tablegen(DiagnosticGroups.inc -gen-clang-diag-groups ++ ${CLANG_BASIC_OPTIONS} + SOURCE Diagnostic.td + TARGET ClangDiagnosticGroups) + + clang_tablegen(DiagnosticIndexName.inc -gen-clang-diags-index-name ++ ${CLANG_BASIC_OPTIONS} + SOURCE Diagnostic.td + TARGET ClangDiagnosticIndexName) + + clang_tablegen(AttrList.inc -gen-clang-attr-list + -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ ++ ${CLANG_BASIC_OPTIONS} + SOURCE Attr.td + TARGET ClangAttrList) + + clang_tablegen(AttrSubMatchRulesList.inc -gen-clang-attr-subject-match-rule-list + -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ ++ ${CLANG_BASIC_OPTIONS} + SOURCE Attr.td + TARGET ClangAttrSubjectMatchRuleList) + +@@ -43,6 +53,7 @@ clang_tablegen(AttrTokenKinds.inc -gen-clang-attr-token-kinds + + clang_tablegen(AttrHasAttributeImpl.inc -gen-clang-attr-has-attribute-impl + -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ ++ ${CLANG_BASIC_OPTIONS} + SOURCE Attr.td + TARGET ClangAttrHasAttributeImpl + ) +@@ -67,15 +78,19 @@ clang_tablegen(arm_mve_builtin_aliases.inc -gen-arm-mve-builtin-aliases + SOURCE arm_mve.td + TARGET ClangARMMveBuiltinAliases) + clang_tablegen(arm_sve_builtins.inc -gen-arm-sve-builtins ++ ${CLANG_BASIC_OPTIONS} + SOURCE arm_sve.td + TARGET ClangARMSveBuiltins) + clang_tablegen(arm_sve_builtin_cg.inc -gen-arm-sve-builtin-codegen ++ ${CLANG_BASIC_OPTIONS} + SOURCE arm_sve.td + TARGET ClangARMSveBuiltinCG) + clang_tablegen(arm_sve_typeflags.inc -gen-arm-sve-typeflags ++ ${CLANG_BASIC_OPTIONS} + SOURCE arm_sve.td + TARGET ClangARMSveTypeFlags) + clang_tablegen(arm_sve_sema_rangechecks.inc -gen-arm-sve-sema-rangechecks ++ ${CLANG_BASIC_OPTIONS} + SOURCE arm_sve.td + TARGET ClangARMSveSemaRangeChecks) + clang_tablegen(arm_sme_builtins.inc -gen-arm-sme-builtins +diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td +index 37586242953f..6b68bc458b93 100644 +--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td ++++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td +@@ -248,6 +248,15 @@ def err_drv_cannot_read_config_file : Error< + "cannot read configuration file '%0': %1">; + def err_drv_arg_requires_bitcode_input: Error< + "option '%0' requires input to be LLVM bitcode">; ++#ifdef ENABLE_AUTOTUNER ++def err_drv_autotune_generic : Error<"%0">; ++def err_drv_autotune_disabled_O0 : Error< ++ "-fautotune/-fautotune-generate should not be enabled at -O0">; ++def err_drv_autotune_incorrect_env : Error< ++ "incorrect argument '%0' in environment variable used">; ++def err_drv_autotune_no_filter_types : Error< ++ "no types added for filtering with %0">; ++#endif + + def err_target_unsupported_arch + : Error<"the target architecture '%0' is not supported by the target '%1'">; +diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td +index 9ed9a88fa3d6..11022962ae9e 100644 +--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td ++++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td +@@ -346,4 +346,12 @@ def warn_profile_data_misexpect : Warning< + def err_extract_api_ignores_file_not_found : + Error<"file '%0' specified by '--extract-api-ignores=' not found">, DefaultFatal; + ++#ifdef ENABLE_AUTOTUNER ++let CategoryName = "AutoTuning Issues" in { ++def err_auto_tuning_error_reading : Error<"'%0'">; ++def err_auto_tuning_error_dumping : Error<"'%0'">; ++def err_unable_to_create_pass : Error< ++ "cannot create pass '%0' from AutoTuning input file">; ++} // end of autoTuning issue category ++#endif + } +diff --git a/clang/include/clang/Driver/CMakeLists.txt b/clang/include/clang/Driver/CMakeLists.txt +index 8c0af1528a96..56fff6a2504e 100644 +--- a/clang/include/clang/Driver/CMakeLists.txt ++++ b/clang/include/clang/Driver/CMakeLists.txt +@@ -8,7 +8,11 @@ endif() + if (LLVM_ENABLE_CLASSIC_FLANG) + list(APPEND CLANG_DRIVER_OPTIONS -DENABLE_CLASSIC_FLANG ) + endif() +- ++ ++if (LLVM_ENABLE_AUTOTUNER) ++ list(APPEND CLANG_DRIVER_OPTIONS "-DENABLE_AUTOTUNER" ) ++endif() ++ + tablegen(LLVM Options.inc ${CLANG_DRIVER_OPTIONS} -gen-opt-parser-defs ) + + add_public_tablegen_target(ClangDriverOptions) +diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h +index e3e98bad9912..dcecb473b516 100644 +--- a/clang/include/clang/Driver/Driver.h ++++ b/clang/include/clang/Driver/Driver.h +@@ -72,6 +72,14 @@ enum ModuleHeaderMode { + HeaderMode_System + }; + ++#if defined(ENABLE_AUTOTUNER) ++enum AutoTuneKind { ++ AutoTuneNone, ++ AutoTuneGenerate, ++ AutoTuneNext, ++}; ++#endif ++ + /// Driver - Encapsulate logic for constructing compilation processes + /// from a set of gcc-driver-like command line arguments. + class Driver { +@@ -119,6 +127,11 @@ class Driver { + /// LTO mode selected via -f(no-offload-)?lto(=.*)? options. + LTOKind OffloadLTOMode; + ++#if defined(ENABLE_AUTOTUNER)
View file
_service:tar_scm:0017-fix-for-missing-DENABLE_AUTOTUNER.patch
Added
@@ -0,0 +1,17 @@ +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index 949f12d3ce8c..98fcb6ea1a07 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -322,6 +322,10 @@ if (BUILD_FOR_OPENEULER) + add_definitions( -DBUILD_FOR_OPENEULER ) + endif() + ++if (LLVM_ENABLE_AUTOTUNER) ++ add_definitions( -DENABLE_AUTOTUNER ) ++endif() ++ + # Determine HOST_LINK_VERSION on Darwin. + set(HOST_LINK_VERSION) + if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*") + -- + \ No newline at end of file
View file
_service:tar_scm:0018-backport-Clang-Fix-build-with-GCC-14-on-ARM-78704.patch
Added
@@ -0,0 +1,64 @@ +From 505323d49f4621e5f7210d99fd52dd33a6223fa8 Mon Sep 17 00:00:00 2001 +From: eastb233 <xiezhiheng@huawei.com> +Date: Tue, 3 Sep 2024 11:59:57 +0800 +Subject: PATCH backportClang Fix build with GCC 14 on ARM (#78704) + +Reference: https://github.com/llvm/llvm-project/pull/78704 + +GCC 14 defines `__arm_streaming` as a macro expanding to +`arm::streaming`. Due to the nested macro use, this gets expanded +prior to concatenation. + +It doesn't look like C++ has a really clean way to prevent macro +expansion. The best I have found is to use `EMPTY ## X` where `EMPTY` is +an empty macro argument, so this is the hack I'm implementing here. + +Fixes https://github.com/llvm/llvm-project/issues/78691. +--- + clang/include/clang/Basic/TokenKinds.def | 2 +- + clang/include/clang/Basic/TokenKinds.h | 2 +- + clang/utils/TableGen/ClangAttrEmitter.cpp | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def +index ef0dad0f2dcd..afd101b007b4 100644 +--- a/clang/include/clang/Basic/TokenKinds.def ++++ b/clang/include/clang/Basic/TokenKinds.def +@@ -753,7 +753,7 @@ KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL) + + // Keywords defined by Attr.td. + #ifndef KEYWORD_ATTRIBUTE +-#define KEYWORD_ATTRIBUTE(X) KEYWORD(X, KEYALL) ++#define KEYWORD_ATTRIBUTE(X, EMPTY) KEYWORD(EMPTY ## X, KEYALL) + #endif + #include "clang/Basic/AttrTokenKinds.inc" + +diff --git a/clang/include/clang/Basic/TokenKinds.h b/clang/include/clang/Basic/TokenKinds.h +index e4857405bc7f..ff117bd5afc5 100644 +--- a/clang/include/clang/Basic/TokenKinds.h ++++ b/clang/include/clang/Basic/TokenKinds.h +@@ -109,7 +109,7 @@ bool isPragmaAnnotation(TokenKind K); + + inline constexpr bool isRegularKeywordAttribute(TokenKind K) { + return (false +-#define KEYWORD_ATTRIBUTE(X) || (K == tok::kw_##X) ++#define KEYWORD_ATTRIBUTE(X, ...) || (K == tok::kw_##X) + #include "clang/Basic/AttrTokenKinds.inc" + ); + } +diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp +index b5813c6abc2b..79db17501b64 100644 +--- a/clang/utils/TableGen/ClangAttrEmitter.cpp ++++ b/clang/utils/TableGen/ClangAttrEmitter.cpp +@@ -3430,7 +3430,7 @@ void EmitClangAttrTokenKinds(RecordKeeper &Records, raw_ostream &OS) { + "RegularKeyword attributes with arguments are not " + "yet supported"); + OS << "KEYWORD_ATTRIBUTE(" +- << S.getSpellingRecord().getValueAsString("Name") << ")\n"; ++ << S.getSpellingRecord().getValueAsString("Name") << ", )\n"; + } + OS << "#undef KEYWORD_ATTRIBUTE\n"; + } +-- +2.38.1.windows.1 +
View file
_service:tar_scm:0019-AArch64-Support-HiSilicon-s-HIP09-Processor.patch
Added
@@ -0,0 +1,176 @@ +From cac43828d26b178807d194b4bd7c5df69603df29 Mon Sep 17 00:00:00 2001 +From: xiajingze <xiajingze1@huawei.com> +Date: Wed, 31 Jul 2024 18:37:29 +0800 +Subject: PATCH AArch64 Support HiSilicon's HIP09 Processor + +Signed-off-by: xiajingze <xiajingze1@huawei.com> +--- + clang/test/CMakeLists.txt | 1 ++ + clang/test/Driver/aarch64-hip09.c | 9 ++ + .../test/Misc/target-invalid-cpu-note-hip09.c | 97 +++++++++++++++++++ + clang/test/Misc/target-invalid-cpu-note.c | 1 + + clang/test/lit.site.cfg.py.in | 4 + + 5 files changed, 112 insertions(+), 0 deletion(-) + create mode 100644 clang/test/Driver/aarch64-hip09.c + create mode 100644 clang/test/Misc/target-invalid-cpu-note-hip09.c + +diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt +index b88694deb..25e4e1f30 100644 +--- a/clang/test/CMakeLists.txt ++++ b/clang/test/CMakeLists.txt +@@ -19,6 +19,7 @@ llvm_canonicalize_cmake_booleans( + LLVM_WITH_Z3 + PPC_LINUX_DEFAULT_IEEELONGDOUBLE + LLVM_TOOL_LLVM_DRIVER_BUILD ++ LLVM_ENABLE_AARCH64_HIP09 + ) + + configure_lit_site_cfg( +diff --git a/clang/test/Driver/aarch64-hip09.c b/clang/test/Driver/aarch64-hip09.c +new file mode 100644 +index 000000000..156be3f38 +--- /dev/null ++++ b/clang/test/Driver/aarch64-hip09.c +@@ -0,0 +1,9 @@ ++// REQUIRES: enable_enable_aarch64_hip09 ++// RUN: %clang -target aarch64_be -mcpu=hip09 -### -c %s 2>&1 | FileCheck -check-prefix=hip09-BE %s ++// RUN: %clang -target aarch64 -mbig-endian -mcpu=hip09 -### -c %s 2>&1 | FileCheck -check-prefix=hip09-BE %s ++// RUN: %clang -target aarch64_be -mbig-endian -mcpu=hip09 -### -c %s 2>&1 | FileCheck -check-prefix=hip09-BE %s ++// RUN: %clang -target aarch64_be -mtune=hip09 -### -c %s 2>&1 | FileCheck -check-prefix=hip09-BE-TUNE %s ++// RUN: %clang -target aarch64 -mbig-endian -mtune=hip09 -### -c %s 2>&1 | FileCheck -check-prefix=hip09-BE-TUNE %s ++// RUN: %clang -target aarch64_be -mbig-endian -mtune=hip09 -### -c %s 2>&1 | FileCheck -check-prefix=hip09-BE-TUNE %s ++// hip09-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "hip09" ++// hip09-BE-TUNE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic" +diff --git a/clang/test/Misc/target-invalid-cpu-note-hip09.c b/clang/test/Misc/target-invalid-cpu-note-hip09.c +new file mode 100644 +index 000000000..f2561a089 +--- /dev/null ++++ b/clang/test/Misc/target-invalid-cpu-note-hip09.c +@@ -0,0 +1,97 @@ ++// REQUIRES: enable_enable_aarch64_hip09 ++// Use CHECK-NEXT instead of multiple CHECK-SAME to ensure we will fail if there is anything extra in the output. ++// RUN: not %clang_cc1 -triple armv5--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix ARM ++// ARM: error: unknown target CPU 'not-a-cpu' ++// ARM-NEXT: note: valid target CPU values are: arm8, arm810, strongarm, strongarm110, strongarm1100, strongarm1110, arm7tdmi, arm7tdmi-s, arm710t, arm720t, arm9, arm9tdmi, arm920, arm920t, arm922t, arm940t, ep9312, arm10tdmi, arm1020t, arm9e, arm946e-s, arm966e-s, arm968e-s, arm10e, arm1020e, arm1022e, arm926ej-s, arm1136j-s, arm1136jf-s, mpcore, mpcorenovfp, arm1176jz-s, arm1176jzf-s, arm1156t2-s, arm1156t2f-s, cortex-m0, cortex-m0plus, cortex-m1, sc000, cortex-a5, cortex-a7, cortex-a8, cortex-a9, cortex-a12, cortex-a15, cortex-a17, krait, cortex-r4, cortex-r4f, cortex-r5, cortex-r7, cortex-r8, cortex-r52, sc300, cortex-m3, cortex-m4, cortex-m7, cortex-m23, cortex-m33, cortex-m35p, cortex-m55, cortex-m85, cortex-a32, cortex-a35, cortex-a53, cortex-a55, cortex-a57, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-x1, cortex-x1c, neoverse-n1, neoverse-n2, neoverse-v1, cyclone, exynos-m3, exynos-m4, exynos-m5, kryo, iwmmxt, xscale, swift{{$}} ++ ++// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 ++// AARCH64: error: unknown target CPU 'not-a-cpu' ++// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, hip09, grace{{$}} ++ ++// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64 ++// TUNE_AARCH64: error: unknown target CPU 'not-a-cpu' ++// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, hip09, grace{{$}} ++ ++// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86 ++// X86: error: unknown target CPU 'not-a-cpu' ++// X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, x86-64-v2, x86-64-v3, x86-64-v4, geode{{$}} ++ ++// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64 ++// X86_64: error: unknown target CPU 'not-a-cpu' ++// X86_64-NEXT: note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, x86-64-v2, x86-64-v3, x86-64-v4{{$}} ++ ++// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86 ++// TUNE_X86: error: unknown target CPU 'not-a-cpu' ++// TUNE_X86-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, geode{{$}} ++ ++// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64 ++// TUNE_X86_64: error: unknown target CPU 'not-a-cpu' ++// TUNE_X86_64-NEXT: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, knl, knm, lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, geode{{$}} ++ ++// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX ++// NVPTX: error: unknown target CPU 'not-a-cpu' ++// NVPTX-NEXT: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80, sm_86, sm_87, sm_89, sm_90, gfx600, gfx601, gfx602, gfx700, gfx701, gfx702, gfx703, gfx704, gfx705, gfx801, gfx802, gfx803, gfx805, gfx810, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx940, gfx941, gfx942, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, gfx1036, gfx1100, gfx1101, gfx1102, gfx1103, gfx1150, gfx1151{{$}} ++ ++// RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600 ++// R600: error: unknown target CPU 'not-a-cpu' ++// R600-NEXT: note: valid target CPU values are: r600, rv630, rv635, r630, rs780, rs880, rv610, rv620, rv670, rv710, rv730, rv740, rv770, cedar, palm, cypress, hemlock, juniper, redwood, sumo, sumo2, barts, caicos, aruba, cayman, turks{{$}} ++ ++// RUN: not %clang_cc1 -triple amdgcn--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AMDGCN ++// AMDGCN: error: unknown target CPU 'not-a-cpu' ++// AMDGCN-NEXT: note: valid target CPU values are: gfx600, tahiti, gfx601, pitcairn, verde, gfx602, hainan, oland, gfx700, kaveri, gfx701, hawaii, gfx702, gfx703, kabini, mullins, gfx704, bonaire, gfx705, gfx801, carrizo, gfx802, iceland, tonga, gfx803, fiji, polaris10, polaris11, gfx805, tongapro, gfx810, stoney, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx940, gfx941, gfx942, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, gfx1036, gfx1100, gfx1101, gfx1102, gfx1103, gfx1150, gfx1151{{$}} ++ ++// RUN: not %clang_cc1 -triple wasm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix WEBASM ++// WEBASM: error: unknown target CPU 'not-a-cpu' ++// WEBASM-NEXT: note: valid target CPU values are: mvp, bleeding-edge, generic{{$}} ++ ++// RUN: not %clang_cc1 -triple systemz--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SYSTEMZ ++// SYSTEMZ: error: unknown target CPU 'not-a-cpu' ++// SYSTEMZ-NEXT: note: valid target CPU values are: arch8, z10, arch9, z196, arch10, zEC12, arch11, z13, arch12, z14, arch13, z15, arch14, z16{{$}} ++ ++// RUN: not %clang_cc1 -triple sparc--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SPARC ++// SPARC: error: unknown target CPU 'not-a-cpu' ++// SPARC-NEXT: note: valid target CPU values are: v8, supersparc, sparclite, f934, hypersparc, sparclite86x, sparclet, tsc701, v9, ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, ma2100, ma2150, ma2155, ma2450, ma2455, ma2x5x, ma2080, ma2085, ma2480, ma2485, ma2x8x, myriad2, myriad2.1, myriad2.2, myriad2.3, leon2, at697e, at697f, leon3, ut699, gr712rc, leon4, gr740{{$}} ++ ++// RUN: not %clang_cc1 -triple sparcv9--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix SPARCV9 ++// SPARCV9: error: unknown target CPU 'not-a-cpu' ++// SPARCV9-NEXT: note: valid target CPU values are: v9, ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4{{$}} ++ ++// RUN: not %clang_cc1 -triple powerpc--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix PPC ++// PPC: error: unknown target CPU 'not-a-cpu' ++// PPC-NEXT: note: valid target CPU values are: generic, 440, 450, 601, 602, 603, 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750, 8548, 970, g5, a2, e500, e500mc, e5500, power3, pwr3, power4, pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x, power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, powerpc, ppc, ppc32, powerpc64, ppc64, powerpc64le, ppc64le, future{{$}} ++ ++// RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS ++// MIPS: error: unknown target CPU 'not-a-cpu' ++// MIPS-NEXT: note: valid target CPU values are: mips1, mips2, mips3, mips4, mips5, mips32, mips32r2, mips32r3, mips32r5, mips32r6, mips64, mips64r2, mips64r3, mips64r5, mips64r6, octeon, octeon+, p5600{{$}} ++ ++// RUN: not %clang_cc1 -triple lanai--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix LANAI ++// LANAI: error: unknown target CPU 'not-a-cpu' ++// LANAI-NEXT: note: valid target CPU values are: v11{{$}} ++ ++// RUN: not %clang_cc1 -triple hexagon--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix HEXAGON ++// HEXAGON: error: unknown target CPU 'not-a-cpu' ++// HEXAGON-NEXT: note: valid target CPU values are: hexagonv5, hexagonv55, hexagonv60, hexagonv62, hexagonv65, hexagonv66, hexagonv67, hexagonv67t, hexagonv68, hexagonv69, hexagonv71, hexagonv71t, hexagonv73{{$}} ++ ++// RUN: not %clang_cc1 -triple bpf--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix BPF ++// BPF: error: unknown target CPU 'not-a-cpu' ++// BPF-NEXT: note: valid target CPU values are: generic, v1, v2, v3, probe{{$}} ++ ++// RUN: not %clang_cc1 -triple avr--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AVR ++// AVR: error: unknown target CPU 'not-a-cpu'
View file
_service:tar_scm:0020-Backport-LoongArch-fix-and-add-some-new-support.patch
Added
@@ -0,0 +1,1715 @@ +From 0cae10595a7521e2c430c605c1f830570b3c9682 Mon Sep 17 00:00:00 2001 +From: Lu Weining <luweining@loongson.cn> +Date: Thu, 30 Nov 2023 14:08:45 +0800 +Subject: PATCH 1/9 Driver Support -mcmodel= for LoongArch (#72514) + +7e42545 rejects unsupported mcmodel options, but normal/medium/extreme +should be supported models for LoongArch according to gcc +document(https://gcc.gnu.org/onlinedocs/gcc/LoongArch-Options.html). + +The mappings among `gcc`, `clang driver`, `clang cc1` and `LLVM (i.e. +llc --code-model=)` are: + +| gcc | clang driver | clang cc1 | LLVM | +| ------------- | ------------------ | ----------------- | -------------- | +| normal | normal | small | small | +| medium | medium | medium | medium | +| extreme | extreme | large | large | + +(cherry picked from commit 1296d20adfb0978afe38d67efab9818079d870ca) +--- + clang/lib/Driver/ToolChains/Clang.cpp | 38 ++++++++++++++++++++------- + clang/test/Driver/mcmodel.c | 15 +++++++++++ + 2 files changed, 44 insertions(+), 9 deletions(-) + +diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp +index fac4f03d6193..4e5f689498d6 100644 +--- a/clang/lib/Driver/ToolChains/Clang.cpp ++++ b/clang/lib/Driver/ToolChains/Clang.cpp +@@ -5773,18 +5773,38 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, + + if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) { + StringRef CM = A->getValue(); +- if (CM == "small" || CM == "kernel" || CM == "medium" || CM == "large" || +- CM == "tiny") { +- if (Triple.isOSAIX() && CM == "medium") +- CmdArgs.push_back("-mcmodel=large"); +- else if (Triple.isAArch64() && (CM == "kernel" || CM == "medium")) ++ if (Triple.isLoongArch()) { ++ bool Ok = false; ++ if (CM == "extreme" && ++ Args.hasFlagNoClaim(options::OPT_fplt, options::OPT_fno_plt, false)) ++ D.Diag(diag::err_drv_argument_not_allowed_with) ++ << A->getAsString(Args) << "-fplt"; ++ Ok = CM == "normal" || CM == "medium" || CM == "extreme"; ++ // Convert to LLVM recognizable names. ++ if (Ok) { ++ CM = llvm::StringSwitch<StringRef>(CM) ++ .Case("normal", "small") ++ .Case("extreme", "large") ++ .Default(CM); ++ CmdArgs.push_back(Args.MakeArgString("-mcmodel=" + CM)); ++ } else { + D.Diag(diag::err_drv_invalid_argument_to_option) + << CM << A->getOption().getName(); +- else +- A->render(Args, CmdArgs); ++ } + } else { +- D.Diag(diag::err_drv_invalid_argument_to_option) +- << CM << A->getOption().getName(); ++ if (CM == "small" || CM == "kernel" || CM == "medium" || CM == "large" || ++ CM == "tiny") { ++ if (Triple.isOSAIX() && CM == "medium") ++ CmdArgs.push_back("-mcmodel=large"); ++ else if (Triple.isAArch64() && (CM == "kernel" || CM == "medium")) ++ D.Diag(diag::err_drv_invalid_argument_to_option) ++ << CM << A->getOption().getName(); ++ else ++ A->render(Args, CmdArgs); ++ } else { ++ D.Diag(diag::err_drv_invalid_argument_to_option) ++ << CM << A->getOption().getName(); ++ } + } + } + +diff --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c +index 63b432036159..4aada126cf06 100644 +--- a/clang/test/Driver/mcmodel.c ++++ b/clang/test/Driver/mcmodel.c +@@ -8,6 +8,14 @@ + // RUN: not %clang -c -mcmodel=lager %s 2>&1 | FileCheck --check-prefix=INVALID %s + // RUN: not %clang -c --target=aarch64 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=AARCH64-MEDIUM %s + // RUN: not %clang -c --target=aarch64 -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=AARCH64-KERNEL %s ++// RUN: %clang --target=loongarch64 -### -S -mcmodel=normal %s 2>&1 | FileCheck --check-prefix=SMALL %s ++// RUN: %clang --target=loongarch64 -### -S -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=MEDIUM %s ++// RUN: %clang --target=loongarch64 -### -S -mcmodel=extreme %s 2>&1 | FileCheck --check-prefix=LARGE %s ++// RUN: not %clang -c --target=loongarch64 -mcmodel=tiny %s 2>&1 | FileCheck --check-prefix=ERR-LOONGARCH64-TINY %s ++// RUN: not %clang -c --target=loongarch64 -mcmodel=small %s 2>&1 | FileCheck --check-prefix=ERR-LOONGARCH64-SMALL %s ++// RUN: not %clang -c --target=loongarch64 -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=ERR-LOONGARCH64-KERNEL %s ++// RUN: not %clang -c --target=loongarch64 -mcmodel=large %s 2>&1 | FileCheck --check-prefix=ERR-LOONGARCH64-LARGE %s ++// RUN: not %clang -c --target=loongarch64 -mcmodel=extreme -fplt %s 2>&1 | FileCheck --check-prefix=ERR-LOONGARCH64-PLT-EXTREME %s + + // TINY: "-mcmodel=tiny" + // SMALL: "-mcmodel=small" +@@ -20,3 +28,10 @@ + + // AARCH64-MEDIUM: error: invalid argument 'medium' to -mcmodel= + // AARCH64-KERNEL: error: invalid argument 'kernel' to -mcmodel= ++ ++// ERR-LOONGARCH64-TINY: error: invalid argument 'tiny' to -mcmodel= ++// ERR-LOONGARCH64-SMALL: error: invalid argument 'small' to -mcmodel= ++// ERR-LOONGARCH64-KERNEL: error: invalid argument 'kernel' to -mcmodel= ++// ERR-LOONGARCH64-LARGE: error: invalid argument 'large' to -mcmodel= ++ ++// ERR-LOONGARCH64-PLT-EXTREME: error: invalid argument '-mcmodel=extreme' not allowed with '-fplt' +-- +2.20.1 + + +From b0e5225dea19a71b0c2f2168c117ac5032c2d18a Mon Sep 17 00:00:00 2001 +From: Zhaoxin Yang <yangzhaoxin@loongson.cn> +Date: Tue, 9 Jul 2024 14:13:19 +0800 +Subject: PATCH 2/9 LoongArchclang Add support for option `-msimd=` and + macro `__loongarch_simd_width`. (#97984) + +(cherry picked from commit 626c7ce33f850831949e4e724016ddbff3a34990) +--- + .../clang/Basic/DiagnosticDriverKinds.td | 2 + + clang/include/clang/Driver/Options.td | 3 + + clang/lib/Basic/Targets/LoongArch.cpp | 8 +- + .../lib/Driver/ToolChains/Arch/LoongArch.cpp | 29 ++++ + clang/test/Driver/loongarch-msimd.c | 129 ++++++++++++++++++ + clang/test/Preprocessor/init-loongarch.c | 3 + + 6 files changed, 172 insertions(+), 2 deletions(-) + create mode 100644 clang/test/Driver/loongarch-msimd.c + +diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td +index 6b68bc458b93..060f96118364 100644 +--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td ++++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td +@@ -757,6 +757,8 @@ def err_drv_loongarch_wrong_fpu_width_for_lasx : Error< + "wrong fpu width; LASX depends on 64-bit FPU.">; + def err_drv_loongarch_invalid_simd_option_combination : Error< + "invalid option combination; LASX depends on LSX.">; ++def err_drv_loongarch_invalid_msimd_EQ : Error< ++ "invalid argument '%0' to -msimd=; must be one of: none, lsx, lasx">; + + def err_drv_expand_response_file : Error< + "failed to expand response file: %0">; +diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td +index 344c8bd49da7..530bb53ea9b5 100644 +--- a/clang/include/clang/Driver/Options.td ++++ b/clang/include/clang/Driver/Options.td +@@ -4236,6 +4236,9 @@ def mlasx : Flag<"-", "mlasx">, Group<m_loongarch_Features_Group>, + HelpText<"Enable Loongson Advanced SIMD Extension (LASX).">; + def mno_lasx : Flag<"-", "mno-lasx">, Group<m_loongarch_Features_Group>, + HelpText<"Disable Loongson Advanced SIMD Extension (LASX).">; ++def msimd_EQ : Joined<"-", "msimd=">, Group<m_loongarch_Features_Group>, ++ Flags<TargetSpecific>, ++ HelpText<"Select the SIMD extension(s) to be enabled in LoongArch either 'none', 'lsx', 'lasx'.">; + def mnop_mcount : Flag<"-", "mnop-mcount">, HelpText<"Generate mcount/__fentry__ calls as nops. To activate they need to be patched in.">, + Flags<CC1Option>, Group<m_Group>, + MarshallingInfoFlag<CodeGenOpts<"MNopMCount">>; +diff --git a/clang/lib/Basic/Targets/LoongArch.cpp b/clang/lib/Basic/Targets/LoongArch.cpp +index 88537989a051..913404240916 100644 +--- a/clang/lib/Basic/Targets/LoongArch.cpp ++++ b/clang/lib/Basic/Targets/LoongArch.cpp +@@ -208,10 +208,14 @@ void LoongArchTargetInfo::getTargetDefines(const LangOptions &Opts, + TuneCPU = ArchName; + Builder.defineMacro("__loongarch_tune", Twine('"') + TuneCPU + Twine('"')); + +- if (HasFeatureLSX) ++ if (HasFeatureLASX) { ++ Builder.defineMacro("__loongarch_simd_width", "256"); + Builder.defineMacro("__loongarch_sx", Twine(1)); +- if (HasFeatureLASX) + Builder.defineMacro("__loongarch_asx", Twine(1)); ++ } else if (HasFeatureLSX) { ++ Builder.defineMacro("__loongarch_simd_width", "128"); ++ Builder.defineMacro("__loongarch_sx", Twine(1)); ++ } + + StringRef ABI = getABI(); + if (ABI == "lp64d" || ABI == "lp64f" || ABI == "lp64s") +diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp +index 31153a67ad28..2d9c3f810a06 100644 +--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp ++++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp +@@ -207,6 +207,35 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D, + } else /*-mno-lasx*/ + Features.push_back("-lasx"); + } ++ ++ // Select lsx/lasx feature determined by -msimd=. ++ // Option -msimd= has lower priority than -mno-lsx and -mno-lasx. ++ if (const Arg *A = Args.getLastArg(options::OPT_msimd_EQ)) { ++ StringRef MSIMD = A->getValue(); ++ if (MSIMD == "lsx") { ++ // Option -msimd=lsx depends on 64-bit FPU. ++ // -m*-float and -mfpu=none/0/32 conflict with -mlsx. ++ if (llvm::find(Features, "-d") != Features.end()) ++ D.Diag(diag::err_drv_loongarch_wrong_fpu_width) << /*LSX*/ 0; ++ // The previous option does not contain feature -lsx. ++ else if (llvm::find(Features, "-lsx") == Features.end()) ++ Features.push_back("+lsx"); ++ } else if (MSIMD == "lasx") { ++ // Option -msimd=lasx depends on 64-bit FPU and LSX. ++ // -m*-float and -mfpu=none/0/32 conflict with -mlsx.
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="scm">git</param> <param name="url">git@gitee.com:src-openeuler/clang.git</param> - <param name="revision">openEuler-24.03-LTS-Next</param> + <param name="revision">openEuler-24.03-LTS-SP1</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2