init for Multi-Version LLVM-18.1.8

Signed-off-by: liyunfei <liyunfei33@huawei.com>
This commit is contained in:
liyunfei 2024-12-09 10:09:09 +08:00
parent c25daedd7c
commit 4c4e612b05
35 changed files with 122 additions and 76802 deletions

View File

@ -29,6 +29,16 @@ index 665cdc3132fb..fc56935e7513 100644
static const char *const X32Triples[] = {"x86_64-linux-gnux32", static const char *const X32Triples[] = {"x86_64-linux-gnux32",
"x86_64-pc-linux-gnux32"}; "x86_64-pc-linux-gnux32"};
static const char *const X32LibDirs[] = {"/libx32", "/lib"}; static const char *const X32LibDirs[] = {"/libx32", "/lib"};
@@ -2341,7 +2341,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
static const char *const LoongArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const LoongArch64Triples[] = {
- "loongarch64-linux-gnu", "loongarch64-unknown-linux-gnu"};
+ "loongarch64-linux-gnu", "loongarch64-unknown-linux-gnu",
+ "loongarch64-openEuler-linux"};
static const char *const M68kLibDirs[] = {"/lib"};
static const char *const M68kTriples[] = {
@@ -2404,7 +2404,7 @@ @@ -2404,7 +2404,7 @@
static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"};
static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",

View File

@ -1,121 +0,0 @@
From a6925b9f000008d3c1d34a401f6dcaac6e57fbbb Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
Date: Wed, 5 Jul 2023 10:55:14 +0800
Subject: Revert "Clang: Change the default DWARF version to 5"
This reverts commit d3b26dea16108c427b19b5480c9edc76edf8f5b4.
---
clang/lib/Driver/ToolChain.cpp | 2 +-
clang/test/CodeGen/dwarf-version.c | 4 ++--
clang/test/Driver/as-options.s | 2 +-
clang/test/Driver/cl-options.c | 2 +-
clang/test/Driver/clang-g-opts.c | 2 +-
clang/test/Driver/ve-toolchain.c | 2 +-
clang/test/Driver/ve-toolchain.cpp | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index f20ab164531b..53c86ee82936 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -430,7 +430,7 @@ public:
unsigned ToolChain::GetDefaultDwarfVersion() const {
// TODO: Remove the RISC-V special case when R_RISCV_SET_ULEB128 linker
// support becomes more widely available.
- return getTriple().isRISCV() ? 4 : 5;
+ return getTriple().isRISCV() ? 4 : 4;
}
Tool *ToolChain::getClang() const {
diff --git a/clang/test/CodeGen/dwarf-version.c b/clang/test/CodeGen/dwarf-version.c
index 0a6fa4768026..96f01749d0d8 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -2,8 +2,8 @@
// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3
// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
-// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
-// RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
+// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
+// RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT
// environment variable which indirecty overrides the version in the target
diff --git a/clang/test/Driver/as-options.s b/clang/test/Driver/as-options.s
index a2e350a0a835..b6159e111052 100644
--- a/clang/test/Driver/as-options.s
+++ b/clang/test/Driver/as-options.s
@@ -125,7 +125,7 @@
// RUN: FileCheck --check-prefix=DEBUG %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -g0 -g %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=DEBUG %s
-// DEBUG: "-g" "-gdwarf-5"
+// DEBUG: "-g" "-gdwarf-4"
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -g -g0 %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=NODEBUG %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf-5 -g0 %s -### 2>&1 | \
@@ -144,7 +144,7 @@
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf-2 %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=GDWARF2 %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf %s -### 2>&1 | \
-// RUN: FileCheck --check-prefix=GDWARF5 %s
+// RUN: FileCheck --check-prefix=GDWARF4 %s
// RUN: %clang --target=aarch64-linux-gnu -fno-integrated-as -gdwarf-5 %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=GDWARF5 %s
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index a2e350a0a835..b6159e111052 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -570,7 +570,7 @@
// RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
// Z7_gdwarf: "-gcodeview"
// Z7_gdwarf: "-debug-info-kind=constructor"
-// Z7_gdwarf: "-dwarf-version=
+// Z7_gdwarf: "-dwarf-version=4"
// RUN: %clang_cl /ZH:MD5 /c -### -- %s 2>&1 | FileCheck -check-prefix=ZH_MD5 %s
// ZH_MD5: "-gsrc-hash=md5"
diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c
index d982b1070cae..bb129e75769c 100644
--- a/clang/test/Driver/clang-g-opts.c
+++ b/clang/test/Driver/clang-g-opts.c
@@ -32,7 +32,7 @@
// CHECK-WITHOUT-G-NOT: -debug-info-kind
// CHECK-WITH-G: "-debug-info-kind=constructor"
-// CHECK-WITH-G: "-dwarf-version=5"
+// CHECK-WITH-G: "-dwarf-version=4"
// CHECK-WITH-G-DWARF2: "-dwarf-version=2"
// CHECK-WITH-G-STANDALONE: "-debug-info-kind=standalone"
diff --git a/clang/test/Driver/ve-toolchain.c b/clang/test/Driver/ve-toolchain.c
index 32e25769b6da..b8a2852daba8 100644
--- a/clang/test/Driver/ve-toolchain.c
+++ b/clang/test/Driver/ve-toolchain.c
@@ -6,7 +6,7 @@
/// Checking dwarf-version
// RUN: %clang -### -g --target=ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
-// DWARF_VER: "-dwarf-version=5"
+// DWARF_VER: "-dwarf-version=4"
///-----------------------------------------------------------------------------
/// Checking include-path
diff --git a/clang/test/Driver/ve-toolchain.cpp b/clang/test/Driver/ve-toolchain.cpp
index 5a33d5eceb61..cedf895b36dc 100644
--- a/clang/test/Driver/ve-toolchain.cpp
+++ b/clang/test/Driver/ve-toolchain.cpp
@@ -7,7 +7,7 @@
// RUN: %clangxx -### -g --target=ve-unknown-linux-gnu \
// RUN: %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
-// DWARF_VER: "-dwarf-version=5"
+// DWARF_VER: "-dwarf-version=4"
///-----------------------------------------------------------------------------
/// Checking include-path
--
2.28.0.windows.1

View File

@ -1,40 +0,0 @@
From 752af60afc7fd9cc986adf280d4d03714228fb04 Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
Date: Tue, 16 Jan 2024 14:47:02 +0800
Subject: [PATCH] add BUILD_FOR_OPENEULER build option to clang
---
clang/CMakeLists.txt | 5 +++++
clang/include/clang/Driver/CMakeLists.txt | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f7936d72e088..d558b0522e82 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -317,6 +317,11 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
endif()
endif ()
+option(BUILD_FOR_OPENEULER "Add gcc compatible options for openEuler toolchain" OFF)
+if (BUILD_FOR_OPENEULER)
+ add_definitions( -DBUILD_FOR_OPENEULER )
+endif()
+
# Determine HOST_LINK_VERSION on Darwin.
set(HOST_LINK_VERSION)
if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*")
diff --git a/clang/include/clang/Driver/CMakeLists.txt b/clang/include/clang/Driver/CMakeLists.txt
index a9d988047920..ea55ba0f1f27 100644
--- a/clang/include/clang/Driver/CMakeLists.txt
+++ b/clang/include/clang/Driver/CMakeLists.txt
@@ -1,3 +1,7 @@
set(LLVM_TARGET_DEFINITIONS Options.td)
+if (BUILD_FOR_OPENEULER)
+tablegen(LLVM Options.inc -gen-opt-parser-defs -DBUILD_FOR_OPENEULER)
+else()
tablegen(LLVM Options.inc -gen-opt-parser-defs)
+endif()
add_public_tablegen_target(ClangDriverOptions)
--
Gitee

View File

@ -1,86 +0,0 @@
From 6503d6b87786e005c0557961aadba739d833f80c Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
Date: Tue, 16 Jan 2024 14:48:53 +0800
Subject: [PATCH] add gcc compatible in BUILD_FOR_OPENEULER
---
clang/include/clang/Driver/Options.td | 14 ++++++++++++++
clang/lib/Driver/Driver.cpp | 8 ++++++++
clang/lib/Driver/ToolChains/Clang.cpp | 11 +++++++++++
3 files changed, 33 insertions(+)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 37e8c56b2d29..d4f7315bf8cb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1786,6 +1786,12 @@ def fmemory_profile_use_EQ : Joined<["-"], "fmemory-profile-use=">,
HelpText<"Use memory profile for profile-guided memory optimization">,
MarshallingInfoString<CodeGenOpts<"MemoryProfileUsePath">>;
+#ifdef BUILD_FOR_OPENEULER
+def fgcc_compatible : Flag<["-"], "fgcc-compatible">, Group<f_Group>,
+ HelpText<"Enable gcc compatibility for openEuler.">;
+def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Group<f_Group>;
+#endif
+
// Begin sanitizer flags. These should all be core options exposed in all driver
// modes.
let Flags = [CC1Option, CoreOption] in {
@@ -5152,6 +5158,14 @@ def falign_jumps_EQ : Joined<["-"], "falign-jumps=">, Group<clang_ignored_gcc_op
// ignore it for now to avoid breaking builds that use it.
def fdiagnostics_show_location_EQ : Joined<["-"], "fdiagnostics-show-location=">, Group<clang_ignored_f_Group>;
+#ifdef BUILD_FOR_OPENEULER
+def flifetime_dse_EQ : Joined<["-"], "flifetime-dse=">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm peephole : BooleanFFlag<"peephole">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm peephole2 : BooleanFFlag<"peephole2">, Group<clang_ignored_gcc_optimization_f_Group>;
+defm aggressive_loop_optiomizations : BooleanFFlag<"aggressive-loop-optiomizations">, Group<clang_ignored_gcc_optimization_f_Group>;
+def flto_partition_EQ : Joined<["-"], "flto-partition=">, Group<clang_ignored_gcc_optimization_f_Group>;
+#endif
+
defm check_new : BoolOption<"f", "check-new",
LangOpts<"CheckNew">, DefaultFalse,
PosFlag<SetTrue, [], "Do not assume C++ operator new may not return NULL">,
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index bdbdad9362e1..87736112fb76 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1491,6 +1491,14 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// Populate the tool chains for the offloading devices, if any.
CreateOffloadingDeviceToolChains(*C, Inputs);
+#ifdef BUILD_FOR_OPENEULER
+ if(C->getArgs().hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false)) {
+ getDiags().setDiagnosticGroupWarningAsError("unused-command-line-argument", 0);
+ getDiags().setDiagnosticGroupWarningAsError("ignored-optimization-argument", 0);
+ }
+#endif
+
// Construct the list of abstract actions to perform for this compilation. On
// MachO targets this uses the driver-driver and universal actions.
if (TC.getTriple().isOSBinFormatMachO())
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 37a07b8f224d..0921e6071d26 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4680,6 +4680,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-triple");
CmdArgs.push_back(Args.MakeArgString(TripleStr));
+#ifdef BUILD_FOR_OPENEULER
+ if (Args.hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false)) {
+ CmdArgs.push_back("-Wno-error=unknown-warning-option");
+ CmdArgs.push_back("-Wno-error=unused-parameter");
+ CmdArgs.push_back("-Wno-error=unused-function");
+ CmdArgs.push_back("-Wno-error=unused-but-set-parameter");
+ CmdArgs.push_back("-Wno-error=unused-but-set-variable");
+ }
+#endif
+
if (const Arg *MJ = Args.getLastArg(options::OPT_MJ)) {
DumpCompilationDatabase(C, MJ->getValue(), TripleStr, Output, Input, Args);
Args.ClaimAllArgs(options::OPT_MJ);
--
Gitee

View File

@ -1,46 +0,0 @@
From 8943c1fb16c225f056e93c3a9a1bbeb535370e4e Mon Sep 17 00:00:00 2001
From: laokz <laokz@foxmail.com>
Date: Fri, 1 Mar 2024 06:14:24 +0000
Subject: [PATCH] [backport] Disable InterpreterExceptionTest on RISC-V
Reference:
https://github.com/llvm/llvm-project/commit/ca003ee06d0eac7e8facc179181298a05e4d03ed
Signed-off-by: laokz <zhangkai@iscas.ac.cn>
---
From ca003ee06d0eac7e8facc179181298a05e4d03ed Mon Sep 17 00:00:00 2001
From: Alex Bradbury <asb@igalia.com>
Date: Wed, 4 Oct 2023 14:33:31 +0100
Subject: [PATCH] [clang-repl] Disable InterpreterExceptionTest on RISC-V
(#68216)
This test fails as .eh_frame handling is not yet implemented for RISC-V
in JITLink. #66067 is proposed to address this.
Skip the test until the issue is resolved. It seems that D159167 enabled
this test for more than just ppc64. As the test always failed, it just
wasn't run until now, I think skipping is the correct interim approach
(as is already done for Arm, Darwin, and others).
---
.../Interpreter/ExceptionTests/InterpreterExceptionTest.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index 70e10b1e53..3857b75598 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -114,6 +114,11 @@ extern "C" int throw_exception() {
Triple.getArch() == llvm::Triple::aarch64_32))
GTEST_SKIP();
+ // FIXME: RISC-V fails as .eh_frame handling is not yet implemented in
+ // JITLink for RISC-V. See PR #66067.
+ if (Triple.isRISCV())
+ GTEST_SKIP();
+
llvm::cantFail(Interp->ParseAndExecute(ExceptionCode));
testing::internal::CaptureStdout();
auto ThrowException =
--
2.43.0

View File

@ -1,26 +0,0 @@
From 5f03c1fa84487fa7c7c5db1dd461efec67e9c323 Mon Sep 17 00:00:00 2001
From: zhanglimin <zhanglimin@loongson.cn>
Date: Tue, 12 Mar 2024 17:38:39 +0800
Subject: [PATCH] [clang][LoongArch] Add loongarch64 to os-triple
---
clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 40038dce47d8..e9cba05e8680 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2341,7 +2341,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
static const char *const LoongArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const LoongArch64Triples[] = {
- "loongarch64-linux-gnu", "loongarch64-unknown-linux-gnu"};
+ "loongarch64-linux-gnu", "loongarch64-unknown-linux-gnu",
+ "loongarch64-openEuler-linux"};
static const char *const M68kLibDirs[] = {"/lib"};
static const char *const M68kTriples[] = {
--
2.20.1

View File

@ -1,59 +0,0 @@
From 929e5c1d4f2c36e233a26b480f1dd172b6d63362 Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
Date: Thu, 14 Mar 2024 16:04:40 +0800
Subject: [PATCH] add more warning options to -fgcc-compatible
---
clang/lib/Driver/ToolChains/Clang.cpp | 20 ++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 793af55a1e5f..f0da323d8adb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4683,11 +4683,42 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
#ifdef BUILD_FOR_OPENEULER
if (Args.hasFlag(options::OPT_fgcc_compatible,
options::OPT_fno_gcc_compatible, false)) {
+ // compatibility relevent warnings
CmdArgs.push_back("-Wno-error=unknown-warning-option");
+ CmdArgs.push_back("-Wno-error=ignored-attributes");
+ // By default, clang reports warnings, but gcc does not.
CmdArgs.push_back("-Wno-error=unused-parameter");
CmdArgs.push_back("-Wno-error=unused-function");
CmdArgs.push_back("-Wno-error=unused-but-set-parameter");
CmdArgs.push_back("-Wno-error=unused-but-set-variable");
+ CmdArgs.push_back("-Wno-error=deprecated-non-prototype");
+ CmdArgs.push_back("-Wno-error=unsafe-buffer-usage");
+ CmdArgs.push_back("-Wno-error=string-plus-int");
+ CmdArgs.push_back("-Wno-error=language-extension-token");
+ CmdArgs.push_back("-Wno-error=single-bit-bitfield-constant-conversion");
+ CmdArgs.push_back("-Wno-error=gnu-variable-sized-type-not-at-end");
+ CmdArgs.push_back("-Wno-error=header-guard");
+ CmdArgs.push_back("-Wno-error=return-type-c-linkage");
+ // By default, clang reports errors, but gcc reports warnings.
+ // when -Werror is passed don't add -Wno-error=*.
+ if(!D.getDiags().getWarningsAsErrors()) {
+ CmdArgs.push_back("-Wno-error=implicit-function-declaration");
+ CmdArgs.push_back("-Wno-error=incompatible-function-pointer-types");
+ CmdArgs.push_back("-Wno-error=register");
+ CmdArgs.push_back("-Wno-error=int-conversion");
+ CmdArgs.push_back("-Wno-error=implicit-int");
+ CmdArgs.push_back("-Wno-error=enum-constexpr-conversion");
+ CmdArgs.push_back("-Wno-error=return-type");
+ CmdArgs.push_back("-Wno-error=reserved-user-defined-literal");
+ }
+ //other warnings
+ CmdArgs.push_back("-Wno-error=cast-align");
+ CmdArgs.push_back("-Wno-error=enum-conversion");
+ CmdArgs.push_back("-Wno-error=switch");
+ CmdArgs.push_back("-Wno-error=cast-qual");
+ CmdArgs.push_back("-Wno-error=varargs");
+ CmdArgs.push_back("-Wno-error=unused-value");
+ CmdArgs.push_back("-Wno-error=format-nonliteral");
}
#endif
--
2.42.0.windows.2

File diff suppressed because it is too large Load Diff

View File

@ -1,639 +0,0 @@
From 2ff5a2bd0a7d14c675cbc5f0e11bf6916b960b20 Mon Sep 17 00:00:00 2001
From: Ami-zhang <96056515+Ami-zhang@users.noreply.github.com>
Date: Thu, 28 Sep 2023 15:20:27 +0800
Subject: [PATCH 1/9] [Driver] Support -fsanitize=cfi-icall on loongarch64
(#67310)
(cherry picked from commit 55accc82bec48acae769b086ad9a5dc29da77f02)
---
clang/lib/Driver/ToolChain.cpp | 3 ++-
clang/test/Driver/fsanitize.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 0146d8af3549..69811c095594 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1273,7 +1273,8 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
if (getTriple().getArch() == llvm::Triple::x86 ||
getTriple().getArch() == llvm::Triple::x86_64 ||
getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() ||
- getTriple().isAArch64() || getTriple().isRISCV())
+ getTriple().isAArch64() || getTriple().isRISCV() ||
+ getTriple().isLoongArch64())
Res |= SanitizerKind::CFIICall;
if (getTriple().getArch() == llvm::Triple::x86_64 ||
getTriple().isAArch64(64) || getTriple().isRISCV())
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 9442f6b91471..4a525d75ea11 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -600,6 +600,7 @@
// RUN: %clang --target=aarch64_be -fvisibility=hidden -fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// RUN: %clang --target=riscv32 -fvisibility=hidden -fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// RUN: %clang --target=riscv64 -fvisibility=hidden -fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
+// RUN: %clang --target=loongarch64 -fvisibility=hidden -fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// CHECK-CFI: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfcall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
// CHECK-CFI-NOMFCALL: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-icall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
// CHECK-CFI-DCAST: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast
--
2.20.1
From acfb50b03b0be3eda5282f26bad34ffc18595b30 Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <nathan@kernel.org>
Date: Fri, 8 Sep 2023 10:54:35 -0700
Subject: [PATCH 2/9] [Clang][LoongArch] Generate _mcount instead of mcount
(#65657)
When building the LoongArch Linux kernel without
`CONFIG_DYNAMIC_FTRACE`, the build fails to link because the mcount
symbol is `mcount`, not `_mcount` like GCC generates and the kernel
expects:
```
ld.lld: error: undefined symbol: mcount
>>> referenced by version.c
>>> init/version.o:(early_hostname) in archive vmlinux.a
>>> referenced by do_mounts.c
>>> init/do_mounts.o:(rootfs_init_fs_context) in archive vmlinux.a
>>> referenced by main.c
>>> init/main.o:(__traceiter_initcall_level) in archive vmlinux.a
>>> referenced 97011 more times
>>> did you mean: _mcount
>>> defined in: vmlinux.a(arch/loongarch/kernel/mcount.o)
```
Set `MCountName` in `LoongArchTargetInfo` to `_mcount`, which resolves
the build failure.
(cherry picked from commit cc2b09bee017147527e7bd1eb5272f4f70a7b900)
---
clang/lib/Basic/Targets/LoongArch.h | 1 +
clang/test/CodeGen/mcount.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/clang/lib/Basic/Targets/LoongArch.h b/clang/lib/Basic/Targets/LoongArch.h
index 8f4150b2539d..3313102492cb 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -40,6 +40,7 @@ public:
LongDoubleWidth = 128;
LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::IEEEquad();
+ MCountName = "_mcount";
SuitableAlign = 128;
WCharType = SignedInt;
WIntType = UnsignedInt;
diff --git a/clang/test/CodeGen/mcount.c b/clang/test/CodeGen/mcount.c
index 8f994ab4e754..bdd609c1dfc5 100644
--- a/clang/test/CodeGen/mcount.c
+++ b/clang/test/CodeGen/mcount.c
@@ -7,6 +7,8 @@
// RUN: %clang_cc1 -pg -triple x86_64-netbsd -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple arm-netbsd-eabi -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple aarch64-netbsd -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple loongarch32 -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple loongarch64 -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple mips-netbsd -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple mips-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple mipsel-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
--
2.20.1
From a841576d7a53d3d8fd61aa854af7d9c2dd204536 Mon Sep 17 00:00:00 2001
From: Weining Lu <luweining@loongson.cn>
Date: Thu, 26 Oct 2023 11:50:28 +0800
Subject: [PATCH 3/9] [LoongArch][test] Add some ABI regression tests for empty
struct. NFC
How empty structs (not as fields of container struct) are passed in C++
is not explicitly documented in psABI. This patch adds some tests
showing the current handing of clang. Some of the results are different
from gcc. Following patch(es) will try to fix the mismatch.
(cherry picked from commit 8149066fa532d82ff62a0629d5a9fab6bd4da768)
---
.../LoongArch/abi-lp64d-empty-structs.c | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
index fb90bf556c19..d0daafac336e 100644
--- a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -81,9 +81,62 @@ struct s8 test_s8(struct s8 a) {
return a;
}
+/// Note: Below tests check how empty structs are passed while above tests check
+/// empty structs as fields of container struct are ignored when flattening
+/// structs to examine whether the container structs can be passed via FARs.
+
// CHECK-C: define{{.*}} void @test_s9()
// CHECK-CXX: define{{.*}} i64 @_Z7test_s92s9(i64 {{.*}})
struct s9 { struct empty e; };
struct s9 test_s9(struct s9 a) {
return a;
}
+
+// CHECK-C: define{{.*}} void @test_s10()
+// CHECK-CXX: define{{.*}} void @_Z8test_s103s10()
+struct s10 { };
+struct s10 test_s10(struct s10 a) {
+ return a;
+}
+
+// CHECK-C: define{{.*}} void @test_s11()
+// CHECK-CXX: define{{.*}} i64 @_Z8test_s113s11(i64 {{.*}})
+struct s11 { struct { } s; };
+struct s11 test_s11(struct s11 a) {
+ return a;
+}
+
+// CHECK-C: define{{.*}} void @test_s12()
+// CHECK-CXX: define{{.*}} void @_Z8test_s123s12()
+struct s12 { int i[0]; };
+struct s12 test_s12(struct s12 a) {
+ return a;
+}
+
+// CHECK-C: define{{.*}} void @test_s13()
+// CHECK-CXX: define{{.*}} void @_Z8test_s133s13()
+struct s13 { struct { } s[0]; };
+struct s13 test_s13(struct s13 a) {
+ return a;
+}
+
+// CHECK-C: define{{.*}} void @test_s14()
+// CHECK-CXX: define{{.*}} i64 @_Z8test_s143s14(i64 {{.*}})
+struct s14 { struct { } s[1]; };
+struct s14 test_s14(struct s14 a) {
+ return a;
+}
+
+// CHECK-C: define{{.*}} void @test_s15()
+// CHECK-CXX: define{{.*}} void @_Z8test_s153s15()
+struct s15 { int : 0; };
+struct s15 test_s15(struct s15 a) {
+ return a;
+}
+
+// CHECK-C: define{{.*}} void @test_s16()
+// CHECK-CXX: define{{.*}} void @_Z8test_s163s16()
+struct s16 { int : 1; };
+struct s16 test_s16(struct s16 a) {
+ return a;
+}
--
2.20.1
From 6248fa0fc405952a8b907624c27b2dd1ee86a962 Mon Sep 17 00:00:00 2001
From: Lu Weining <luweining@loongson.cn>
Date: Tue, 31 Oct 2023 21:18:06 +0800
Subject: [PATCH 4/9] [LoongArch] Fix ABI mismatch with gcc/g++ about empty
structs passing (#70320)
How empty structs (not as fields of container struct) are passed in C++
is not explicitly documented in psABI. However, this patch fixes the
mismatch with g++.
Note that the unnamed bitfield case `struct { int : 1; }` in C is also
fixed. Previously clang regards it as an empty struct and then ignores
it when passing. Now size of the struct is counted; since it's size is
not 0, clang will not ignore it even in C.
While https://reviews.llvm.org/D156116 fixed the handling of empty
struct when considering eligibility of the container struct for the FP
calling convention ('flattening'), this patch fixes the handling of
passing the empty struct itself.
Fix https://github.com/llvm/llvm-project/issues/70319
(cherry picked from commit 9ca6bf3fb7b7df373723b3275730f101f9ff816b)
---
clang/lib/CodeGen/Targets/LoongArch.cpp | 10 ++++++----
clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c | 8 ++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/clang/lib/CodeGen/Targets/LoongArch.cpp b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 7483bf6d6d1e..bc508a99da9c 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -308,12 +308,14 @@ ABIArgInfo LoongArchABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
CGCXXABI::RAA_DirectInMemory);
}
- // Ignore empty structs/unions.
- if (isEmptyRecord(getContext(), Ty, true))
- return ABIArgInfo::getIgnore();
-
uint64_t Size = getContext().getTypeSize(Ty);
+ // Ignore empty struct or union whose size is zero, e.g. `struct { }` in C or
+ // `struct { int a[0]; }` in C++. In C++, `struct { }` is empty but it's size
+ // is 1 byte and g++ doesn't ignore it; clang++ matches this behaviour.
+ if (isEmptyRecord(getContext(), Ty, true) && Size == 0)
+ return ABIArgInfo::getIgnore();
+
// Pass floating point values via FARs if possible.
if (IsFixed && Ty->isFloatingType() && !Ty->isComplexType() &&
FRLen >= Size && FARsLeft) {
diff --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
index d0daafac336e..281b7b15841a 100644
--- a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -93,7 +93,7 @@ struct s9 test_s9(struct s9 a) {
}
// CHECK-C: define{{.*}} void @test_s10()
-// CHECK-CXX: define{{.*}} void @_Z8test_s103s10()
+// CHECK-CXX: define{{.*}} i64 @_Z8test_s103s10(i64 {{.*}})
struct s10 { };
struct s10 test_s10(struct s10 a) {
return a;
@@ -128,14 +128,14 @@ struct s14 test_s14(struct s14 a) {
}
// CHECK-C: define{{.*}} void @test_s15()
-// CHECK-CXX: define{{.*}} void @_Z8test_s153s15()
+// CHECK-CXX: define{{.*}} i64 @_Z8test_s153s15(i64 {{.*}})
struct s15 { int : 0; };
struct s15 test_s15(struct s15 a) {
return a;
}
-// CHECK-C: define{{.*}} void @test_s16()
-// CHECK-CXX: define{{.*}} void @_Z8test_s163s16()
+// CHECK-C: define{{.*}} i64 @test_s16(i64 {{.*}})
+// CHECK-CXX: define{{.*}} i64 @_Z8test_s163s16(i64 {{.*}})
struct s16 { int : 1; };
struct s16 test_s16(struct s16 a) {
return a;
--
2.20.1
From 028d0d88cd73c724f954577dc90cbbc2873a6832 Mon Sep 17 00:00:00 2001
From: Weining Lu <luweining@loongson.cn>
Date: Thu, 2 Nov 2023 09:29:43 +0800
Subject: [PATCH 5/9] [LoongArch] Pre-commit test for issue #70890
(cherry picked from commit 749083b91f31f370cf64831d3e7e6215b6d51442)
---
.../LoongArch/abi-lp64d-empty-unions.c | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c
diff --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c
new file mode 100644
index 000000000000..b0607425336e
--- /dev/null
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefix=CHECK-C %s
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - -x c++ | \
+// RUN: FileCheck --check-prefix=CHECK-CXX %s
+
+#include <stdint.h>
+
+// CHECK-C: define{{.*}} void @test1()
+// CHECK-CXX: define{{.*}} i64 @_Z5test12u1(i64{{[^,]*}})
+union u1 { };
+union u1 test1(union u1 a) {
+ return a;
+}
+
+struct s1 {
+ union u1 u;
+ int i;
+ float f;
+};
+
+// CHECK-C: define{{.*}} { i32, float } @test2(i32{{[^,]*}}, float{{[^,]*}})
+/// FIXME: This doesn't match g++.
+// CHECK-CXX: define{{.*}} { i32, float } @_Z5test22s1(i32{{[^,]*}}, float{{[^,]*}})
+struct s1 test2(struct s1 a) {
+ return a;
+}
--
2.20.1
From 8c4371c0e53635a23852d0dc7025b4c48495277b Mon Sep 17 00:00:00 2001
From: Lu Weining <luweining@loongson.cn>
Date: Sat, 4 Nov 2023 10:04:37 +0800
Subject: [PATCH 6/9] [LoongArch] Fix ABI mismatch with g++ when handling empty
unions (#71025)
In g++, empty unions are not ignored like empty structs when flattening
structs to examine whether the structs can be passed via FARs in C++.
This patch aligns clang++ with g++.
Fix https://github.com/llvm/llvm-project/issues/70890.
(cherry picked from commit 4253fdc2c462da61cc0deb74a43265665720c828)
---
clang/lib/CodeGen/Targets/LoongArch.cpp | 7 ++++---
clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c | 2 +-
clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c | 3 +--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/clang/lib/CodeGen/Targets/LoongArch.cpp b/clang/lib/CodeGen/Targets/LoongArch.cpp
index bc508a99da9c..63b9a1fdb988 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -170,10 +170,11 @@ bool LoongArchABIInfo::detectFARsEligibleStructHelper(
// copy constructor are not eligible for the FP calling convention.
if (getRecordArgABI(Ty, CGT.getCXXABI()))
return false;
- if (isEmptyRecord(getContext(), Ty, true, true))
- return true;
const RecordDecl *RD = RTy->getDecl();
- // Unions aren't eligible unless they're empty (which is caught above).
+ if (isEmptyRecord(getContext(), Ty, true, true) &&
+ (!RD->isUnion() || !isa<CXXRecordDecl>(RD)))
+ return true;
+ // Unions aren't eligible unless they're empty in C (which is caught above).
if (RD->isUnion())
return false;
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
diff --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
index 281b7b15841a..2f7596f0ebdc 100644
--- a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-structs.c
@@ -3,7 +3,7 @@
// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - -x c++ | \
// RUN: FileCheck --check-prefix=CHECK-CXX %s
-// Fields containing empty structs or unions are ignored when flattening
+// Fields containing empty structs are ignored when flattening
// structs to examine whether the structs can be passed via FARs, even in C++.
// But there is an exception that non-zero-length array of empty structures are
// not ignored in C++. These rules are not documented in psABI <https://www.github.com/loongson/la-abi-specs>
diff --git a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c
index b0607425336e..363e37efb646 100644
--- a/clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c
+++ b/clang/test/CodeGen/LoongArch/abi-lp64d-empty-unions.c
@@ -19,8 +19,7 @@ struct s1 {
};
// CHECK-C: define{{.*}} { i32, float } @test2(i32{{[^,]*}}, float{{[^,]*}})
-/// FIXME: This doesn't match g++.
-// CHECK-CXX: define{{.*}} { i32, float } @_Z5test22s1(i32{{[^,]*}}, float{{[^,]*}})
+// CHECK-CXX: define{{.*}} [2 x i64] @_Z5test22s1([2 x i64]{{[^,]*}})
struct s1 test2(struct s1 a) {
return a;
}
--
2.20.1
From 8e855955a009ec398b9f7da88e980dae9d20c420 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i@maskray.me>
Date: Tue, 14 Nov 2023 00:43:40 -0800
Subject: [PATCH 7/9] [Driver] Default LoongArch to
-fno-direct-access-external-data for non-PIC (#72221)
For -fno-pic, if an extern variable is defined in a DSO, a copy
relocation will be needed. However, loongarch*-linux does not and will
not support copy relocations.
Change Driver to default to -fno-direct-access-external-data for
LoongArch && non-PIC.
Keep Frontend conditions unchanged (-fdirect-access-external-data ||
-fno-direct-access-external-data && PIC>0 => direct access).
Fix #71645
(cherry picked from commit 47eeee297775347cbdb7624d6a766c2a3eec4a59)
---
clang/lib/Driver/ToolChains/Clang.cpp | 7 ++++++-
clang/test/Driver/fdirect-access-external-data.c | 6 ++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 6b5930990f11..b21aeaee7f5a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5632,10 +5632,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// defaults to -fno-direct-access-external-data. Pass the option if different
// from the default.
if (Arg *A = Args.getLastArg(options::OPT_fdirect_access_external_data,
- options::OPT_fno_direct_access_external_data))
+ options::OPT_fno_direct_access_external_data)) {
if (A->getOption().matches(options::OPT_fdirect_access_external_data) !=
(PICLevel == 0))
A->render(Args, CmdArgs);
+ } else if (PICLevel == 0 && Triple.isLoongArch()) {
+ // Some targets default to -fno-direct-access-external-data even for
+ // -fno-pic.
+ CmdArgs.push_back("-fno-direct-access-external-data");
+ }
if (Args.hasFlag(options::OPT_fno_plt, options::OPT_fplt, false)) {
CmdArgs.push_back("-fno-plt");
diff --git a/clang/test/Driver/fdirect-access-external-data.c b/clang/test/Driver/fdirect-access-external-data.c
index f132b1b088af..a6da776e6977 100644
--- a/clang/test/Driver/fdirect-access-external-data.c
+++ b/clang/test/Driver/fdirect-access-external-data.c
@@ -9,6 +9,12 @@
// RUN: %clang -### -c -target aarch64 %s -fpic 2>&1 | FileCheck %s --check-prefix=DEFAULT
// RUN: %clang -### -c -target aarch64 %s -fpic -fdirect-access-external-data 2>&1 | FileCheck %s --check-prefix=DIRECT
+/// loongarch* targets default to -fno-direct-access-external-data even for -fno-pic.
+// RUN: %clang -### -c --target=loongarch64 -fno-pic %s 2>&1 | FileCheck %s --check-prefix=INDIRECT
+// RUN: %clang -### -c --target=loongarch64 -fpie %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
+// RUN: %clang -### -c --target=loongarch32 -fno-pic -fdirect-access-external-data %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
+// RUN: %clang -### -c --target=loongarch32 -fpie -fdirect-access-external-data %s 2>&1 | FileCheck %s --check-prefix=DIRECT
+
// DEFAULT-NOT: direct-access-external-data"
// DIRECT: "-fdirect-access-external-data"
// INDIRECT: "-fno-direct-access-external-data"
--
2.20.1
From 29409970a5c68e20022a05457127102a66abfead Mon Sep 17 00:00:00 2001
From: wanglei <wanglei@loongson.cn>
Date: Tue, 5 Mar 2024 19:44:28 +0800
Subject: [PATCH 8/9] [Clang][LoongArch] Precommit test for fix wrong return
value type of __iocsrrd_h. NFC
(cherry picked from commit aeda1a6e800e0dd6c91c0332b4db95094ad5b301)
(cherry picked from commit a9ba36c7e7d7fa076f201843e3b826b6c6d7f5ef)
---
clang/test/CodeGen/LoongArch/intrinsic-la32.c | 29 ++++++++++++++-----
clang/test/CodeGen/LoongArch/intrinsic-la64.c | 21 ++++++++++++--
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/clang/test/CodeGen/LoongArch/intrinsic-la32.c b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
index 93d54f511a9c..6a8d99880be3 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la32.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
@@ -169,8 +169,8 @@ unsigned int cpucfg(unsigned int a) {
// LA32-LABEL: @rdtime(
// LA32-NEXT: entry:
-// LA32-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc !2
-// LA32-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !3
+// LA32-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc [[META2:![0-9]+]]
+// LA32-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc [[META3:![0-9]+]]
// LA32-NEXT: ret void
//
void rdtime() {
@@ -201,13 +201,28 @@ void loongarch_movgr2fcsr(int a) {
__builtin_loongarch_movgr2fcsr(1, a);
}
-// CHECK-LABEL: @cacop_w(
-// CHECK-NEXT: entry:
-// CHECK-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A:%.*]], i32 1024)
-// CHECK-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A]], i32 1024)
-// CHECK-NEXT: ret void
+// LA32-LABEL: @cacop_w(
+// LA32-NEXT: entry:
+// LA32-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A:%.*]], i32 1024)
+// LA32-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A]], i32 1024)
+// LA32-NEXT: ret void
//
void cacop_w(unsigned long int a) {
__cacop_w(1, a, 1024);
__builtin_loongarch_cacop_w(1, a, 1024);
}
+
+// LA32-LABEL: @iocsrrd_h_result(
+// LA32-NEXT: entry:
+// LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
+// LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
+// LA32-NEXT: [[CONV2:%.*]] = and i32 [[TMP0]], 255
+// LA32-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[CONV2]]
+// LA32-NEXT: [[CONV4:%.*]] = trunc i32 [[ADD]] to i16
+// LA32-NEXT: ret i16 [[CONV4]]
+//
+unsigned short iocsrrd_h_result(unsigned int a) {
+ unsigned short b = __iocsrrd_h(a);
+ unsigned short c = __builtin_loongarch_iocsrrd_h(a);
+ return b+c;
+}
diff --git a/clang/test/CodeGen/LoongArch/intrinsic-la64.c b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
index a740882eef54..48b6a7a3d227 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la64.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
@@ -387,7 +387,7 @@ unsigned int cpucfg(unsigned int a) {
// CHECK-LABEL: @rdtime_d(
// CHECK-NEXT: entry:
-// CHECK-NEXT: [[TMP0:%.*]] = tail call { i64, i64 } asm sideeffect "rdtime.d $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc !2
+// CHECK-NEXT: [[TMP0:%.*]] = tail call { i64, i64 } asm sideeffect "rdtime.d $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc [[META2:![0-9]+]]
// CHECK-NEXT: ret void
//
void rdtime_d() {
@@ -396,8 +396,8 @@ void rdtime_d() {
// CHECK-LABEL: @rdtime(
// CHECK-NEXT: entry:
-// CHECK-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !3
-// CHECK-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !4
+// CHECK-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc [[META3:![0-9]+]]
+// CHECK-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc [[META4:![0-9]+]]
// CHECK-NEXT: ret void
//
void rdtime() {
@@ -427,3 +427,18 @@ void loongarch_movgr2fcsr(int a) {
__movgr2fcsr(1, a);
__builtin_loongarch_movgr2fcsr(1, a);
}
+
+// CHECK-LABEL: @iocsrrd_h_result(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
+// CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
+// CHECK-NEXT: [[CONV2:%.*]] = and i32 [[TMP0]], 255
+// CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[CONV2]]
+// CHECK-NEXT: [[CONV4:%.*]] = trunc i32 [[ADD]] to i16
+// CHECK-NEXT: ret i16 [[CONV4]]
+//
+unsigned short iocsrrd_h_result(unsigned int a) {
+ unsigned short b = __iocsrrd_h(a);
+ unsigned short c = __builtin_loongarch_iocsrrd_h(a);
+ return b+c;
+}
--
2.20.1
From 47425dfdd1582ec652aba1c289f3a80fe25c1a8c Mon Sep 17 00:00:00 2001
From: wanglei <wanglei@loongson.cn>
Date: Wed, 6 Mar 2024 10:03:28 +0800
Subject: [PATCH 9/9] [Clang][LoongArch] Fix wrong return value type of
__iocsrrd_h (#84100)
relate:
https: //gcc.gnu.org/pipermail/gcc-patches/2024-February/645016.html
(cherry picked from commit 2f479b811274fede36535e34ecb545ac22e399c3)
(cherry picked from commit 9b9aee16d4dcf1b4af49988ebd7918fa4ce77e44)
---
clang/lib/Headers/larchintrin.h | 2 +-
clang/test/CodeGen/LoongArch/intrinsic-la32.c | 8 ++++----
clang/test/CodeGen/LoongArch/intrinsic-la64.c | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/lib/Headers/larchintrin.h b/clang/lib/Headers/larchintrin.h
index c5c533ee0b8c..24dd29ce91ff 100644
--- a/clang/lib/Headers/larchintrin.h
+++ b/clang/lib/Headers/larchintrin.h
@@ -156,7 +156,7 @@ extern __inline unsigned char
return (unsigned char)__builtin_loongarch_iocsrrd_b((unsigned int)_1);
}
-extern __inline unsigned char
+extern __inline unsigned short
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__iocsrrd_h(unsigned int _1) {
return (unsigned short)__builtin_loongarch_iocsrrd_h((unsigned int)_1);
diff --git a/clang/test/CodeGen/LoongArch/intrinsic-la32.c b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
index 6a8d99880be3..eb3f8cbe7ac4 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la32.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
@@ -215,11 +215,11 @@ void cacop_w(unsigned long int a) {
// LA32-LABEL: @iocsrrd_h_result(
// LA32-NEXT: entry:
// LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
+// LA32-NEXT: [[CONV_I:%.*]] = trunc i32 [[TMP0]] to i16
// LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
-// LA32-NEXT: [[CONV2:%.*]] = and i32 [[TMP0]], 255
-// LA32-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[CONV2]]
-// LA32-NEXT: [[CONV4:%.*]] = trunc i32 [[ADD]] to i16
-// LA32-NEXT: ret i16 [[CONV4]]
+// LA32-NEXT: [[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
+// LA32-NEXT: [[CONV3:%.*]] = add i16 [[TMP2]], [[CONV_I]]
+// LA32-NEXT: ret i16 [[CONV3]]
//
unsigned short iocsrrd_h_result(unsigned int a) {
unsigned short b = __iocsrrd_h(a);
diff --git a/clang/test/CodeGen/LoongArch/intrinsic-la64.c b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
index 48b6a7a3d227..50ec358f546e 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la64.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
@@ -431,11 +431,11 @@ void loongarch_movgr2fcsr(int a) {
// CHECK-LABEL: @iocsrrd_h_result(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
+// CHECK-NEXT: [[CONV_I:%.*]] = trunc i32 [[TMP0]] to i16
// CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
-// CHECK-NEXT: [[CONV2:%.*]] = and i32 [[TMP0]], 255
-// CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[CONV2]]
-// CHECK-NEXT: [[CONV4:%.*]] = trunc i32 [[ADD]] to i16
-// CHECK-NEXT: ret i16 [[CONV4]]
+// CHECK-NEXT: [[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
+// CHECK-NEXT: [[CONV3:%.*]] = add i16 [[TMP2]], [[CONV_I]]
+// CHECK-NEXT: ret i16 [[CONV3]]
//
unsigned short iocsrrd_h_result(unsigned int a) {
unsigned short b = __iocsrrd_h(a);
--
2.20.1

View File

@ -1,255 +0,0 @@
From 6804a15df7959a14b97d41dd8c069d2d695392e4 Mon Sep 17 00:00:00 2001
From: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Date: Mon, 12 Feb 2024 12:44:20 +0300
Subject: [PATCH] [clang] Avoid -Wshadow warning when init-capture named same
as class field (#74512)
Shadowing warning doesn't make much sense since field is not available
in lambda's body without capturing this.
Fixes https://github.com/llvm/llvm-project/issues/71976
(cherry picked from commit c13b7485b87909fcf739f62cfa382b55407433c0)
---
clang/docs/ReleaseNotes.rst | 3 +
clang/include/clang/Sema/ScopeInfo.h | 4 +-
clang/lib/Sema/SemaDecl.cpp | 73 +++++++++------
clang/test/SemaCXX/warn-shadow-in-lambdas.cpp | 92 ++++++++++++++++++-
4 files changed, 141 insertions(+), 31 deletions(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a1143e14562e..5086a56eb496 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -730,6 +730,9 @@ Bug Fixes in This Version
``thread_local`` instead of ``_Thread_local``.
Fixes (`#70068 <https://github.com/llvm/llvm-project/issues/70068>`_) and
(`#69167 <https://github.com/llvm/llvm-project/issues/69167>`_)
+- Clang's ``-Wshadow`` no longer warns when an init-capture is named the same as
+ a class field unless the lambda can capture this.
+ Fixes (`#71976 <https://github.com/llvm/llvm-project/issues/71976>`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/Sema/ScopeInfo.h b/clang/include/clang/Sema/ScopeInfo.h
index 26c0387dfc44..f4e1dba4e20d 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -915,8 +915,8 @@ public:
/// that were defined in parent contexts. Used to avoid warnings when the
/// shadowed variables are uncaptured by this lambda.
struct ShadowedOuterDecl {
- const VarDecl *VD;
- const VarDecl *ShadowedDecl;
+ const NamedDecl *VD;
+ const NamedDecl *ShadowedDecl;
};
llvm::SmallVector<ShadowedOuterDecl, 4> ShadowingDecls;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 21b5781a71cd..5481bbd22c66 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8269,28 +8269,40 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
unsigned WarningDiag = diag::warn_decl_shadow;
SourceLocation CaptureLoc;
- if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
- isa<CXXMethodDecl>(NewDC)) {
+ if (isa<VarDecl>(D) && NewDC && isa<CXXMethodDecl>(NewDC)) {
if (const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->getParent())) {
if (RD->isLambda() && OldDC->Encloses(NewDC->getLexicalParent())) {
- if (RD->getLambdaCaptureDefault() == LCD_None) {
- // Try to avoid warnings for lambdas with an explicit capture list.
+ if (const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
const auto *LSI = cast<LambdaScopeInfo>(getCurFunction());
- // Warn only when the lambda captures the shadowed decl explicitly.
- CaptureLoc = getCaptureLocation(LSI, cast<VarDecl>(ShadowedDecl));
- if (CaptureLoc.isInvalid())
- WarningDiag = diag::warn_decl_shadow_uncaptured_local;
- } else {
- // Remember that this was shadowed so we can avoid the warning if the
- // shadowed decl isn't captured and the warning settings allow it.
+ if (RD->getLambdaCaptureDefault() == LCD_None) {
+ // Try to avoid warnings for lambdas with an explicit capture
+ // list. Warn only when the lambda captures the shadowed decl
+ // explicitly.
+ CaptureLoc = getCaptureLocation(LSI, VD);
+ if (CaptureLoc.isInvalid())
+ WarningDiag = diag::warn_decl_shadow_uncaptured_local;
+ } else {
+ // Remember that this was shadowed so we can avoid the warning if
+ // the shadowed decl isn't captured and the warning settings allow
+ // it.
+ cast<LambdaScopeInfo>(getCurFunction())
+ ->ShadowingDecls.push_back({D, VD});
+ return;
+ }
+ }
+ if (isa<FieldDecl>(ShadowedDecl)) {
+ // If lambda can capture this, then emit default shadowing warning,
+ // Otherwise it is not really a shadowing case since field is not
+ // available in lambda's body.
+ // At this point we don't know that lambda can capture this, so
+ // remember that this was shadowed and delay until we know.
cast<LambdaScopeInfo>(getCurFunction())
- ->ShadowingDecls.push_back(
- {cast<VarDecl>(D), cast<VarDecl>(ShadowedDecl)});
+ ->ShadowingDecls.push_back({D, ShadowedDecl});
return;
}
}
-
- if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
+ if (const auto *VD = dyn_cast<VarDecl>(ShadowedDecl);
+ VD && VD->hasLocalStorage()) {
// A variable can't shadow a local variable in an enclosing scope, if
// they are separated by a non-capturing declaration context.
for (DeclContext *ParentDC = NewDC;
@@ -8337,19 +8349,28 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
/// when these variables are captured by the lambda.
void Sema::DiagnoseShadowingLambdaDecls(const LambdaScopeInfo *LSI) {
for (const auto &Shadow : LSI->ShadowingDecls) {
- const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
+ const NamedDecl *ShadowedDecl = Shadow.ShadowedDecl;
// Try to avoid the warning when the shadowed decl isn't captured.
- SourceLocation CaptureLoc = getCaptureLocation(LSI, ShadowedDecl);
const DeclContext *OldDC = ShadowedDecl->getDeclContext();
- Diag(Shadow.VD->getLocation(), CaptureLoc.isInvalid()
- ? diag::warn_decl_shadow_uncaptured_local
- : diag::warn_decl_shadow)
- << Shadow.VD->getDeclName()
- << computeShadowedDeclKind(ShadowedDecl, OldDC) << OldDC;
- if (!CaptureLoc.isInvalid())
- Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
- << Shadow.VD->getDeclName() << /*explicitly*/ 0;
- Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
+ if (const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
+ SourceLocation CaptureLoc = getCaptureLocation(LSI, VD);
+ Diag(Shadow.VD->getLocation(),
+ CaptureLoc.isInvalid() ? diag::warn_decl_shadow_uncaptured_local
+ : diag::warn_decl_shadow)
+ << Shadow.VD->getDeclName()
+ << computeShadowedDeclKind(ShadowedDecl, OldDC) << OldDC;
+ if (CaptureLoc.isValid())
+ Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
+ << Shadow.VD->getDeclName() << /*explicitly*/ 0;
+ Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
+ } else if (isa<FieldDecl>(ShadowedDecl)) {
+ Diag(Shadow.VD->getLocation(),
+ LSI->isCXXThisCaptured() ? diag::warn_decl_shadow
+ : diag::warn_decl_shadow_uncaptured_local)
+ << Shadow.VD->getDeclName()
+ << computeShadowedDeclKind(ShadowedDecl, OldDC) << OldDC;
+ Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
+ }
}
}
diff --git a/clang/test/SemaCXX/warn-shadow-in-lambdas.cpp b/clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
index bda6a65c0216..d54b394df4eb 100644
--- a/clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ b/clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow -D AVOID %s
-// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow -Wshadow-uncaptured-local %s
-// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow-all %s
+// RUN: %clang_cc1 -std=c++14 -verify=expected,cxx14 -fsyntax-only -Wshadow -D AVOID %s
+// RUN: %clang_cc1 -std=c++14 -verify=expected,cxx14 -fsyntax-only -Wshadow -Wshadow-uncaptured-local %s
+// RUN: %clang_cc1 -std=c++14 -verify=expected,cxx14 -fsyntax-only -Wshadow-all %s
// RUN: %clang_cc1 -std=c++17 -verify -fsyntax-only -Wshadow-all %s
// RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only -Wshadow-all %s
@@ -179,3 +179,89 @@ void f() {
#endif
}
}
+
+namespace GH71976 {
+#ifdef AVOID
+struct A {
+ int b = 5;
+ int foo() {
+ return [b = b]() { return b; }(); // no -Wshadow diagnostic, init-capture does not shadow b due to not capturing this
+ }
+};
+
+struct B {
+ int a;
+ void foo() {
+ auto b = [a = this->a] {}; // no -Wshadow diagnostic, init-capture does not shadow a due to not capturing his
+ }
+};
+
+struct C {
+ int b = 5;
+ int foo() {
+ return [a = b]() {
+ return [=, b = a]() { // no -Wshadow diagnostic, init-capture does not shadow b due to outer lambda
+ return b;
+ }();
+ }();
+ }
+};
+
+#else
+struct A {
+ int b = 5; // expected-note {{previous}}
+ int foo() {
+ return [b = b]() { return b; }(); // expected-warning {{declaration shadows a field}}
+ }
+};
+
+struct B {
+ int a; // expected-note {{previous}}
+ void foo() {
+ auto b = [a = this->a] {}; // expected-warning {{declaration shadows a field}}
+ }
+};
+
+struct C {
+ int b = 5; // expected-note {{previous}}
+ int foo() {
+ return [a = b]() {
+ return [=, b = a]() { // expected-warning {{declaration shadows a field}}
+ return b;
+ }();
+ }();
+ }
+};
+
+struct D {
+ int b = 5; // expected-note {{previous}}
+ int foo() {
+ return [b = b, this]() { return b; }(); // expected-warning {{declaration shadows a field}}
+ }
+};
+
+struct E {
+ int b = 5;
+ int foo() {
+ return [a = b]() { // expected-note {{previous}}
+ return [=, a = a]() { // expected-warning {{shadows a local}}
+ return a;
+ }();
+ }();
+ }
+};
+
+#endif
+
+struct S {
+ int a ;
+};
+
+int foo() {
+ auto [a] = S{0}; // expected-note {{previous}} \
+ // cxx14-warning {{decomposition declarations are a C++17 extension}}
+ [a = a] () { // expected-warning {{declaration shadows a structured binding}}
+ }();
+}
+
+}
--
2.33.0

File diff suppressed because it is too large Load Diff

View File

@ -1,326 +0,0 @@
From bf04bad2c43a69730e1cdf4dcd2d06ab786bda33 Mon Sep 17 00:00:00 2001
From: luofeng14 <luofeng13@huawei.com>
Date: Wed, 17 Apr 2024 10:49:19 +0800
Subject: [PATCH] Fix declaration definition mismatch for classic flang
---
.../clang/Basic/DiagnosticDriverKinds.td | 4 ++++
clang/include/clang/Basic/MacroBuilder.h | 7 ++++++-
clang/include/clang/Basic/Sanitizers.def | 2 ++
clang/include/clang/Driver/Options.td | 1 -
clang/include/clang/Frontend/Utils.h | 10 ++++++++-
clang/lib/CodeGen/CGDebugInfo.cpp | 21 +++++++++++++++----
clang/lib/Driver/Driver.cpp | 1 -
clang/lib/Frontend/InitPreprocessor.cpp | 21 +++++++++++++++++++
.../test/CodeGen/libpgmath-logfun-aarch64.ll | 1 +
clang/test/CodeGen/libpgmath-logfun-x86_64.ll | 2 +-
clang/test/Driver/autocomplete.c | 2 +-
.../flang/classic-flang-vscale-mbits.f95 | 2 ++
.../Driver/flang/classic-flang-vscale.f95 | 2 ++
clang/tools/driver/CMakeLists.txt | 6 +++++-
14 files changed, 71 insertions(+), 11 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 09a1949d7596..62a60e65c6a4 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -131,10 +131,12 @@ def err_drv_invalid_linker_name : Error<
"invalid linker name in argument '%0'">;
def err_drv_invalid_rtlib_name : Error<
"invalid runtime library name in argument '%0'">;
+#ifdef ENABLE_CLASSIC_FLANG
def err_drv_invalid_allocatable_mode : Error<
"invalid semantic mode for assignments to allocatables in argument '%0'">;
def err_drv_unsupported_fixed_line_length : Error<
"unsupported fixed-format line length in argument '%0'">;
+#endif
def err_drv_unsupported_rtlib_for_platform : Error<
"unsupported runtime library '%0' for platform '%1'">;
def err_drv_invalid_unwindlib_name : Error<
@@ -358,8 +360,10 @@ def err_drv_negative_columns : Error<
"invalid value '%1' in '%0', value must be 'none' or a positive integer">;
def err_drv_small_columns : Error<
"invalid value '%1' in '%0', value must be '%2' or greater">;
+#ifdef ENABLE_CLASSIC_FLANG
def err_drv_clang_unsupported_minfo_arg : Error<
"'%0' option does not support '%1' value">;
+#endif
def err_drv_invalid_malign_branch_EQ : Error<
"invalid argument '%0' to -malign-branch=; each element must be one of: %1">;
diff --git a/clang/include/clang/Basic/MacroBuilder.h b/clang/include/clang/Basic/MacroBuilder.h
index bfc5e38c15e3..54e9ea643394 100644
--- a/clang/include/clang/Basic/MacroBuilder.h
+++ b/clang/include/clang/Basic/MacroBuilder.h
@@ -24,10 +24,15 @@ class MacroBuilder {
raw_ostream &Out;
public:
MacroBuilder(raw_ostream &Output) : Out(Output) {}
+ #ifdef ENABLE_CLASSIC_FLANG
virtual ~MacroBuilder() {}
-
+ #endif
/// Append a \#define line for macro of the form "\#define Name Value\n".
+ #ifdef ENABLE_CLASSIC_FLANG
virtual void defineMacro(const Twine &Name, const Twine &Value = "1") {
+ #else
+ void defineMacro(const Twine &Name, const Twine &Value = "1") {
+ #endif
Out << "#define " << Name << ' ' << Value << '\n';
}
diff --git a/clang/include/clang/Basic/Sanitizers.def b/clang/include/clang/Basic/Sanitizers.def
index 4f0a2bf332ef..a8fcba677ee5 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -107,8 +107,10 @@ SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
SANITIZER("unreachable", Unreachable)
SANITIZER("vla-bound", VLABound)
SANITIZER("vptr", Vptr)
+#ifdef ENABLE_CLASSIC_FLANG
// fortran contiguous pointer checks
SANITIZER("discontiguous", Discontiguous)
+#endif
// IntegerSanitizer
SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 365285966a67..dab35f22e4ac 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5473,7 +5473,6 @@ defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays",
defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride",
PosFlag<SetTrue, [], "Create unit-strided versions of loops">,
NegFlag<SetFalse, [], "Do not create unit-strided loops (default)">>;
-
} // let Flags = [FC1Option, FlangOption, FlangOnlyOption]
#ifdef ENABLE_CLASSIC_FLANG
diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h
index c51c617c1379..4ac76dd348c6 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -17,10 +17,12 @@
#include "clang/Basic/LLVM.h"
#include "clang/Driver/OptionUtils.h"
#include "clang/Frontend/DependencyOutputOptions.h"
+#ifdef ENABLE_CLASSIC_FLANG
#include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/StringExtras.h"
+#endif
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
@@ -33,11 +35,13 @@
#include <utility>
#include <vector>
+#ifdef ENABLE_CLASSIC_FLANG
namespace llvm {
class StringRef;
} // namespace llvm
+#endif
namespace clang {
@@ -47,7 +51,9 @@ class CompilerInvocation;
class DiagnosticsEngine;
class ExternalSemaSource;
class FrontendOptions;
+#ifdef ENABLE_CLASSIC_FLANG
class MacroBuilder;
+#endif
class PCHContainerReader;
class Preprocessor;
class PreprocessorOptions;
@@ -63,6 +69,7 @@ void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts,
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
const PreprocessorOutputOptions &Opts);
+#ifdef ENABLE_CLASSIC_FLANG
/// DefineTypeSize - Emit a macro to the predefines buffer that declares a macro
/// named MacroName with the max value for a type with width 'TypeWidth' a
/// signedness of 'isSigned' and with a value suffix of 'ValSuffix' (e.g. LL).
@@ -85,6 +92,7 @@ static void DefineTypeSize(const Twine &MacroName, TargetInfo::IntType Ty,
DefineTypeSize(MacroName, TI.getTypeWidth(Ty), TI.getTypeConstantSuffix(Ty),
TI.isTypeSigned(Ty), Builder);
}
+#endif
/// An interface for collecting the dependencies of a compilation. Users should
/// use \c attachToPreprocessor and \c attachToASTReader to get all of the
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 3b140860cce4..30d62ae8faf6 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3981,7 +3981,10 @@ CGDebugInfo::getGlobalVariableForwardDeclaration(const VarDecl *VD) {
auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
!VD->isExternallyVisible(), nullptr, TemplateParameters,
- llvm::DINode::FlagZero, Align);
+#ifdef ENABLE_CLASSIC_FLANG
+ llvm::DINode::FlagZero,
+#endif
+ Align);
FwdDeclReplaceMap.emplace_back(
std::piecewise_construct,
std::make_tuple(cast<VarDecl>(VD->getCanonicalDecl())),
@@ -5468,7 +5471,10 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
Var->hasLocalLinkage(), true,
Expr.empty() ? nullptr : DBuilder.createExpression(Expr),
getOrCreateStaticDataMemberDeclarationOrNull(D), TemplateParameters,
- llvm::DINode::FlagZero, Align, Annotations);
+#ifdef ENABLE_CLASSIC_FLANG
+ llvm::DINode::FlagZero,
+#endif
+ Align, Annotations);
Var->addDebugInfo(GVE);
}
DeclCache[D->getCanonicalDecl()].reset(GVE);
@@ -5564,7 +5570,11 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) {
GV.reset(DBuilder.createGlobalVariableExpression(
DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,
true, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),
- TemplateParameters, llvm::DINode::FlagZero, Align));
+ TemplateParameters,
+#ifdef ENABLE_CLASSIC_FLANG
+ llvm::DINode::FlagZero,
+#endif
+ Align));
}
void CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var,
@@ -5582,7 +5592,10 @@ void CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var,
llvm::DIGlobalVariableExpression *GVE =
DBuilder.createGlobalVariableExpression(
DContext, Name, StringRef(), Unit, getLineNumber(D->getLocation()),
- Ty, false, false, nullptr, nullptr, nullptr, llvm::DINode::FlagZero,
+ Ty, false, false, nullptr, nullptr, nullptr,
+#ifdef ENABLE_CLASSIC_FLANG
+ llvm::DINode::FlagZero,
+#endif
Align);
Var->addDebugInfo(GVE);
}
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8bfee5928fe5..819d7703b2e7 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -377,7 +377,6 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
(PhaseArg = DAL.getLastArg(options::OPT_fmodule_header,
options::OPT_fmodule_header_EQ))) {
FinalPhase = phases::Precompile;
-
// -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
} else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) ||
(PhaseArg = DAL.getLastArg(options::OPT_print_supported_cpus)) ||
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 7b01cb01a45e..05682ae9f135 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -161,6 +161,27 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
Builder.defineMacro(DefPrefix + "MIN__", Twine(Min)+Ext);
}
+#ifndef ENABLE_CLASSIC_FLANG
+/// DefineTypeSize - Emit a macro to the predefines buffer that declares a macro
+/// named MacroName with the max value for a type with width 'TypeWidth' a
+/// signedness of 'isSigned' and with a value suffix of 'ValSuffix' (e.g. LL).
+static void DefineTypeSize(const Twine &MacroName, unsigned TypeWidth,
+ StringRef ValSuffix, bool isSigned,
+ MacroBuilder &Builder) {
+ llvm::APInt MaxVal = isSigned ? llvm::APInt::getSignedMaxValue(TypeWidth)
+ : llvm::APInt::getMaxValue(TypeWidth);
+ Builder.defineMacro(MacroName, toString(MaxVal, 10, isSigned) + ValSuffix);
+}
+
+/// DefineTypeSize - An overloaded helper that uses TargetInfo to determine
+/// the width, suffix, and signedness of the given type
+static void DefineTypeSize(const Twine &MacroName, TargetInfo::IntType Ty,
+ const TargetInfo &TI, MacroBuilder &Builder) {
+ DefineTypeSize(MacroName, TI.getTypeWidth(Ty), TI.getTypeConstantSuffix(Ty),
+ TI.isTypeSigned(Ty), Builder);
+}
+#endif
+
static void DefineFmt(const Twine &Prefix, TargetInfo::IntType Ty,
const TargetInfo &TI, MacroBuilder &Builder) {
bool IsSigned = TI.isTypeSigned(Ty);
diff --git a/clang/test/CodeGen/libpgmath-logfun-aarch64.ll b/clang/test/CodeGen/libpgmath-logfun-aarch64.ll
index 141fed29ccd1..be05a472016c 100644
--- a/clang/test/CodeGen/libpgmath-logfun-aarch64.ll
+++ b/clang/test/CodeGen/libpgmath-logfun-aarch64.ll
@@ -1,3 +1,4 @@
+; REQUIRES: classic_flang
; REQUIRES: aarch64-registered-target
; RUN: %clang -target aarch64-unknown-linux-gnu -Ofast -S %s -o - | FileCheck %s
diff --git a/clang/test/CodeGen/libpgmath-logfun-x86_64.ll b/clang/test/CodeGen/libpgmath-logfun-x86_64.ll
index 3ce1d910947f..c89e538f34e3 100644
--- a/clang/test/CodeGen/libpgmath-logfun-x86_64.ll
+++ b/clang/test/CodeGen/libpgmath-logfun-x86_64.ll
@@ -1,5 +1,5 @@
; REQUIRES: x86-registered-target
-
+; REQUIRES: classic_flang
; RUN: %clang -target x86_64-unknown-linux-gnu -msse -Ofast -S %s -o - | FileCheck %s
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/clang/test/Driver/autocomplete.c b/clang/test/Driver/autocomplete.c
index 8c4921c9dbd5..d6f57708b67e 100644
--- a/clang/test/Driver/autocomplete.c
+++ b/clang/test/Driver/autocomplete.c
@@ -85,7 +85,7 @@
// FVECLIBALL-NEXT: libmvec
// FVECLIBALL-NEXT: MASSV
// FVECLIBALL-NEXT: none
-// FVECLIBALL: SLEEF
+// FVECLIBALL-NEXT: SLEEF
// FVECLIBALL-NEXT: SVML
// RUN: %clang --autocomplete=-fshow-overloads= | FileCheck %s -check-prefix=FSOVERALL
// FSOVERALL: all
diff --git a/clang/test/Driver/flang/classic-flang-vscale-mbits.f95 b/clang/test/Driver/flang/classic-flang-vscale-mbits.f95
index f0ed43aa027a..089993be7b04 100644
--- a/clang/test/Driver/flang/classic-flang-vscale-mbits.f95
+++ b/clang/test/Driver/flang/classic-flang-vscale-mbits.f95
@@ -1,3 +1,5 @@
+! REQUIRES: classic_flang
+
// RUN: %clang --driver-mode=flang -### -S --target=aarch64 -march=armv8-a+sve -msve-vector-bits=128 %s 2>&1 | FileCheck -check-prefix=CHECK-SVE-128 %s
// RUN: %clang --driver-mode=flang -### -S --target=aarch64 -march=armv8-a+sve -msve-vector-bits=128+ %s 2>&1 | FileCheck -check-prefix=CHECK-SVE-128PLUS %s
// RUN: %clang --driver-mode=flang -### -S --target=aarch64 -march=armv8-a+sve -msve-vector-bits=256 %s 2>&1 | FileCheck -check-prefix=CHECK-SVE-256 %s
diff --git a/clang/test/Driver/flang/classic-flang-vscale.f95 b/clang/test/Driver/flang/classic-flang-vscale.f95
index 8110be594db5..b8496975758f 100644
--- a/clang/test/Driver/flang/classic-flang-vscale.f95
+++ b/clang/test/Driver/flang/classic-flang-vscale.f95
@@ -1,3 +1,5 @@
+! REQUIRES: classic_flang
+
// RUN: %clang --driver-mode=flang -### -S --target=aarch64 -march=armv8-a %s 2>&1 | FileCheck -check-prefix=CHECK-NEON %s
// RUN: %clang --driver-mode=flang -### -S --target=aarch64 -march=armv8-a+sve %s 2>&1 | FileCheck -check-prefix=CHECK-SVE %s
// RUN: %clang --driver-mode=flang -### -S --target=aarch64 -march=armv8-a+sve2 %s 2>&1 | FileCheck -check-prefix=CHECK-SVE2 %s
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index c269561fde69..465b05c9c0e9 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -59,7 +59,11 @@ endif()
add_dependencies(clang clang-resource-headers)
if(NOT CLANG_LINKS_TO_CREATE)
- set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp flang)
+ if (LLVM_ENABLE_CLASSIC_FLANG)
+ set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp flang)
+ else()
+ set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
+ endif()
endif()
if (CLANG_ENABLE_HLSL)
--
2.24.3 (Apple Git-128)

View File

@ -1,50 +0,0 @@
From 2ce94f822eb951dcff23036f204a98900a4fb805 Mon Sep 17 00:00:00 2001
From: wangqiang <wangqiang1@kylinos.cn>
Date: Wed, 24 Apr 2024 11:21:02 +0800
Subject: [PATCH] Ignored option `-Wa,--generate-missing-build-notes=`
---
clang/lib/Driver/ToolChains/Clang.cpp | 6 ++++++
.../Driver/test-generate-missing-build-notes.cpp | 13 +++++++++++++
2 files changed, 19 insertions(+)
create mode 100644 clang/test/Driver/test-generate-missing-build-notes.cpp
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 6b5930990..704a32912 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2731,6 +2731,12 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
CmdArgs.push_back(Value.data());
} else if (Value == "--version") {
D.PrintVersion(C, llvm::outs());
+ #ifdef BUILD_FOR_OPENEULER
+ } else if (Value.startswith("--generate-missing-build-notes=") &&
+ Args.hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false)) {
+ // Do nothing.
+ #endif
} else {
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getSpelling() << Value;
diff --git a/clang/test/Driver/test-generate-missing-build-notes.cpp b/clang/test/Driver/test-generate-missing-build-notes.cpp
new file mode 100644
index 000000000..efd5251e6
--- /dev/null
+++ b/clang/test/Driver/test-generate-missing-build-notes.cpp
@@ -0,0 +1,13 @@
+// REQUIRES: build_for_openeuler
+// RUN: %clang -### -fgcc-compatible -Wa,--generate-missing-build-notes=yes %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
+// RUN: %clang -### -fgcc-compatible -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
+// CHECK-NO-ERROR-NOT: --generate-missing-build-notes=
+// RUN: %clang -### -Wa,--generate-missing-build-notes=yes %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// RUN: %clang -### -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// RUN: %clang -### -fno-gcc-compatible -Wa,--generate-missing-build-notes=yes %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// RUN: %clang -### -fno-gcc-compatible -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: error: unsupported argument '--generate-missing-build-notes=
+
+int main() {
+ return 1;
+}
--
2.33.0

View File

@ -1,25 +0,0 @@
From 5721be433ddee5f60d4a9434df43a023f1ec4c0e Mon Sep 17 00:00:00 2001
From: wangqiang <wangqiang1@kylinos.cn>
Date: Sun, 28 Apr 2024 14:30:34 +0800
Subject: [PATCH] Update llvm-lit config to support build_for_openeuler
---
clang/test/lit.site.cfg.py.in | 1 +
1 files changed, 1 insertions(+)
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index ef75770a2..ae5309180 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -42,6 +42,7 @@ config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
config.ppc_linux_default_ieeelongdouble = @PPC_LINUX_DEFAULT_IEEELONGDOUBLE@
config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
config.use_classic_flang = @LLVM_ENABLE_CLASSIC_FLANG@
+config.build_for_openeuler = @BUILD_FOR_OPENEULER@
import lit.llvm
lit.llvm.initialize(lit_config, config)
--
2.33.0

View File

@ -1,259 +0,0 @@
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 doesnt defer the instantiation of the explicit specifier for
deduction guides, because Im not familiar with deduction guides yet.
Ill 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.call]p4:
// 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
+ const bool CouldInstantiate =
+ InstantiatedExplicitSpecifier.getExpr() == nullptr ||
+ !InstantiatedExplicitSpecifier.getExpr()->isValueDependent();
+
+ // Delay the instantiation of the explicit-specifier until after the
+ // constraints are checked during template argument deduction.
+ if (CouldInstantiate ||
+ SemaRef.CodeSynthesisContexts.back().Kind !=
+ Sema::CodeSynthesisContext::DeducedTemplateArgumentSubstitution) {
+ InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
+ TemplateArgs, InstantiatedExplicitSpecifier);
+
+ if (InstantiatedExplicitSpecifier.isInvalid())
+ return nullptr;
+ } else {
+ InstantiatedExplicitSpecifier.setKind(ExplicitSpecKind::Unresolved);
+ }
// Implicit destructors/constructors created for local classes in
// DeclareImplicit* (see SemaDeclCXX.cpp) might not have an associated TSI.
diff --git a/clang/test/SemaCXX/cxx2a-explicit-bool-deferred.cpp b/clang/test/SemaCXX/cxx2a-explicit-bool-deferred.cpp
new file mode 100644
index 00000000..4d667008
--- /dev/null
+++ b/clang/test/SemaCXX/cxx2a-explicit-bool-deferred.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
+
+template <typename T1, typename T2> struct is_same {
+ static constexpr bool value = false;
+};
+
+template <typename T> struct is_same<T, T> {
+ static constexpr bool value = true;
+};
+
+template <class T, class U>
+concept SameHelper = is_same<T, U>::value;
+template <class T, class U>
+concept same_as = SameHelper<T, U> && SameHelper<U, T>;
+
+namespace deferred_instantiation {
+template <class X> constexpr X do_not_instantiate() { return nullptr; }
+
+struct T {
+ template <same_as<float> X> explicit(do_not_instantiate<X>()) T(X) {}
+
+ T(int) {}
+};
+
+T t(5);
+// expected-error@17{{cannot initialize}}
+// expected-note@20{{in instantiation of function template specialization}}
+// expected-note@30{{while substituting deduced template arguments}}
+// expected-note@30{{in instantiation of function template specialization}}
+T t2(5.0f);
+} // namespace deferred_instantiation
--
2.33.0

View File

@ -1,739 +0,0 @@
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)
+ /// AutoTune mode selected via -fautotune or -fautotune-generate option
+ AutoTuneKind AutoTuneMode;
+#endif
+
public:
enum OpenMPRuntimeKind {
/// An unknown OpenMP runtime. We can't generate effective OpenMP code
@@ -191,6 +204,21 @@ public:
/// Information about the host which can be overridden by the user.
std::string HostBits, HostMachine, HostSystem, HostRelease;
+#if defined(ENABLE_AUTOTUNER)
+ /// The path to the llvm-autotune data directory.
+ std::string AutoTuneDirDataPath;
+ /// Path for project base directory. Base directory is removed from absolute
+ /// path and relative path is used as (coarse-grain) code region name. This
+ /// allow to port a config file from one machine/location to another.
+ std::string AutoTuneProjectDir;
+
+ /// Whether to prepare the compiler to produce additional metadata
+ /// that will be consumed by Autotuner's ML model
+ bool IsMLTuningEnabled;
+
+ std::string AutoTuneOptions;
+#endif
+
/// The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
std::string CCPrintStatReportFilename;
@@ -705,6 +733,14 @@ public:
return IsOffload ? OffloadLTOMode : LTOMode;
}
+#if defined(ENABLE_AUTOTUNER)
+ /// Returns true if we are performing any kind of AutoTune.
+ bool isUsingAutoTune() const { return AutoTuneMode != AutoTuneNone; }
+
+ /// Get the specific kind of AutoTune being performed.
+ AutoTuneKind getAutoTuneMode() const { return AutoTuneMode; }
+#endif
+
private:
/// Tries to load options from configuration files.
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index c5cc66c58f25..71d6ed66ab96 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1795,6 +1795,19 @@ def fmemory_profile_use_EQ : Joined<["-"], "fmemory-profile-use=">,
Group<f_Group>, Flags<[CC1Option, CoreOption]>, MetaVarName<"<pathname>">,
HelpText<"Use memory profile for profile-guided memory optimization">,
MarshallingInfoString<CodeGenOpts<"MemoryProfileUsePath">>;
+#ifdef ENABLE_AUTOTUNER
+// Auto-tuning flags.
+def fautotune : Flag<["-"], "fautotune">, Group<f_Group>,
+ HelpText<"Auto-tune with the compiler configuration under 'autotune_datadir' (overridden by AUTOTUNE_DATADIR env var)">;
+def fautotune_EQ : Joined<["-"], "fautotune=">, Group<f_Group>,
+ HelpText<"Auto-tune with the compiler configuration of the specified id under 'autotune_datadir' (overridden by AUTOTUNE_DATADIR env var)">;
+def fautotune_generate : Flag<["-"], "fautotune-generate">, Group<f_Group>,
+ HelpText<"Generate initial compiler configuration for Function/Loop code regions under 'autotune_datadir' (overridden by AUTOTUNE_DATADIR env var)">;
+def fautotune_generate_EQ : CommaJoined<["-"], "fautotune-generate=">, Group<f_Group>,
+ HelpText<"Generate initial compiler configuration for the given comma-separated list of code regions under 'autotune_datadir' (overridden by AUTOTUNE_DATADIR env var)">, Values<"Other,Function,Loop,MachineBasicBlock">;
+def fautotune_rank : Flag<["-"], "fautotune-rank">, Group<f_Group>,
+ HelpText<"Generate files necessary for ML-guided ranking">;
+#endif
#ifdef BUILD_FOR_OPENEULER
def fgcc_compatible : Flag<["-"], "fgcc-compatible">, Group<f_Group>,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index f962d60870d1..cef5e0d16ba7 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -88,6 +88,10 @@ using namespace llvm;
llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
#include "llvm/Support/Extension.def"
+#if defined(ENABLE_AUTOTUNER)
+#include "llvm/Analysis/AutotuningDump.h"
+#endif
+
namespace llvm {
extern cl::opt<bool> DebugInfoCorrelate;
@@ -1021,6 +1025,27 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
});
}
+#if defined(ENABLE_AUTOTUNER)
+ bool Changed = false;
+ // If autotuning is enabled (for applying configuration), use AutoTuner
+ // generated pass ordering instead of passes in compilation pipeline. Passes
+ // before and after the compilation pipeline will be intact.
+ if (autotuning::Engine.isEnabled()) {
+ std::vector<std::string> PassesList;
+ Changed = autotuning::Engine.lookUpGlobalParams("OptPass", PassesList);
+ if (Changed && PassesList.size()) {
+ std::string PassPipeline = "";
+ for (auto PassName : PassesList)
+ PassPipeline.append(PassName + ",");
+ PassPipeline.pop_back();
+
+ if (auto Err = PB.parsePassPipeline(MPM, PassPipeline))
+ errs() << "AutoTuner: cannot add pass:" << toString(std::move(Err))
+ << "\n";
+ }
+ }
+ if (!Changed) {
+#endif
if (IsThinLTO || (IsLTO && CodeGenOpts.UnifiedLTO)) {
MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
} else if (IsLTO) {
@@ -1028,6 +1053,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
} else {
MPM = PB.buildPerModuleDefaultPipeline(Level);
}
+#if defined(ENABLE_AUTOTUNER)
+ }
+#endif
}
// Add a verifier pass if requested. We don't have to do this if the action
@@ -1078,6 +1106,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
}
}
+#if defined(ENABLE_AUTOTUNER)
+ // Please ensure this pass is added after all optimization passes.
+ if (autotuning::Engine.isEnabled())
+ MPM.addPass(RequireAnalysisPass<AutotuningDumpAnalysis, llvm::Module>());
+#endif
+
// Now that we have all of the passes ready, run them.
{
PrettyStackTraceString CrashInfo("Optimizer");
@@ -1125,6 +1159,22 @@ void EmitAssemblyHelper::RunCodegenPipeline(
void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
std::unique_ptr<raw_pwrite_stream> OS) {
TimeRegion Region(CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr);
+
+#if defined(ENABLE_AUTOTUNER)
+ // AUTO-TUNING - auto-tuning initialization for this module.
+ // Initialize it before parsing command-line options because we want to
+ // overwrite the llvm options using the config file.
+ if (Error E = autotuning::Engine.init(TheModule->getModuleIdentifier())) {
+ Diags.Report(diag::err_auto_tuning_error_reading) << toString(std::move(E));
+ return;
+ }
+ if (autotuning::Engine.isEnabled() && autotuning::Engine.isParseInput() &&
+ (autotuning::Engine.LLVMParams.size() ||
+ autotuning::Engine.ProgramParams.size()))
+ llvm::cl::ParseAutoTunerOptions(autotuning::Engine.LLVMParams,
+ autotuning::Engine.ProgramParams);
+#endif
+
setCommandLineOpts(CodeGenOpts);
bool RequiresCodeGen = actionRequiresCodeGen(Action);
@@ -1142,6 +1192,14 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
RunOptimizationPipeline(Action, OS, ThinLinkOS);
RunCodegenPipeline(Action, OS, DwoOS);
+#if defined(ENABLE_AUTOTUNER)
+ // AUTO-TUNING - auto-tuning finalization for this module
+ if (Error E = autotuning::Engine.finalize()) {
+ Diags.Report(diag::err_auto_tuning_error_dumping) << toString(std::move(E));
+ return;
+ }
+#endif
+
if (ThinLinkOS)
ThinLinkOS->keep();
if (DwoOS)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 819d7703b2e7..bd9db7714f95 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -104,6 +104,14 @@
#if LLVM_ON_UNIX
#include <unistd.h> // getpid
#endif
+#if defined(ENABLE_AUTOTUNER)
+// Constant definition for environment variable to enable AutoTuner and set
+// the mode to generate opportunities or apply configurations.
+const std::string AutoTuneModeStr = "AUTOTUNE_MODE";
+// Constant definition for environment variable to specify the project base
+// directory.
+const std::string AutoTunePrjDirStr = "AUTOTUNE_PROJECT_DIR";
+#endif
using namespace clang::driver;
using namespace clang;
@@ -200,6 +208,9 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone),
Offload(OffloadHostDevice), CXX20HeaderType(HeaderMode_None),
ModulesModeCXX20(false), LTOMode(LTOK_None),
+#if defined(ENABLE_AUTOTUNER)
+ AutoTuneMode(AutoTuneNone),
+#endif
ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT),
DriverTitle(Title), CCCPrintBindings(false), CCPrintOptions(false),
CCLogDiagnostics(false), CCGenDiagnostics(false),
@@ -1379,6 +1390,77 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
setLTOMode(Args);
+#if defined(ENABLE_AUTOTUNER)
+ // Process -fautotune and -fautotune-generate flags.
+ bool IsAutoTuneGenerate = Args.hasArg(options::OPT_fautotune_generate,
+ options::OPT_fautotune_generate_EQ);
+ bool IsAutoTune =
+ Args.hasArg(options::OPT_fautotune, options::OPT_fautotune_EQ);
+ // Check if the environment variable AUTOTUNE_MODE is used instead of
+ // -fautotune-generate/-fautotune.
+ if (!IsAutoTuneGenerate && !IsAutoTune) {
+ if (std::optional<std::string> MaybeMode =
+ llvm::sys::Process::GetEnv(AutoTuneModeStr)) {
+ StringRef Mode = *MaybeMode;
+ StringRef OrgMode = *MaybeMode;
+ if (Mode.consume_front("-fautotune-generate")) {
+ if (Mode.empty() || Mode.startswith("="))
+ IsAutoTuneGenerate = true;
+ else
+ Diags.Report(diag::err_drv_autotune_incorrect_env) << OrgMode;
+ } else if (Mode.consume_front("-fautotune")) {
+ if (Mode.empty() || Mode.startswith("="))
+ IsAutoTune = true;
+ else
+ Diags.Report(diag::err_drv_autotune_incorrect_env) << OrgMode;
+ } else {
+ Diags.Report(diag::err_drv_autotune_incorrect_env) << OrgMode;
+ }
+
+ if (Mode.consume_front("=")) {
+ if (Mode.empty())
+ Diags.Report(diag::err_drv_autotune_no_filter_types)
+ << (IsAutoTuneGenerate ? "-fautotune-generate=" : "-fautotune=");
+
+ AutoTuneOptions = Mode.str();
+ }
+ }
+ }
+
+ IsMLTuningEnabled = Args.hasArg(options::OPT_fautotune_rank);
+
+ if (IsAutoTuneGenerate && IsAutoTune)
+ Diags.Report(diag::err_drv_argument_not_allowed_with)
+ << "-fautotune"
+ << "-fautotune-generate";
+
+ if (IsMLTuningEnabled && !(IsAutoTuneGenerate || IsAutoTune))
+ Diags.Report(diag::err_drv_argument_only_allowed_with)
+ << "-fautotune-rank"
+ << "-fautotune or -fautotune-generate";
+
+ if (IsAutoTuneGenerate || IsAutoTune) {
+ // Check if the environment variable AUTOTUNE_DATADIR is set.
+ if (std::optional<std::string> MaybePath =
+ llvm::sys::Process::GetEnv("AUTOTUNE_DATADIR"))
+ AutoTuneDirDataPath = *MaybePath;
+ else
+ AutoTuneDirDataPath = "autotune_datadir";
+
+ // Check if the environment variable AUTOTUNE_PROJECT_DIR is set.
+ if (std::optional<std::string> MaybeProjectDIR =
+ llvm::sys::Process::GetEnv(AutoTunePrjDirStr))
+ AutoTuneProjectDir = *MaybeProjectDIR;
+ else
+ AutoTuneProjectDir = "";
+
+ if (IsAutoTuneGenerate)
+ AutoTuneMode = AutoTuneGenerate;
+ if (IsAutoTune)
+ AutoTuneMode = AutoTuneNext;
+ }
+#endif
+
// Process -fembed-bitcode= flags.
if (Arg *A = Args.getLastArg(options::OPT_fembed_bitcode_EQ)) {
StringRef Name = A->getValue();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index a4af991b5ff3..933661685117 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5990,6 +5990,27 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (!Triple.isNVPTX() && !Triple.isAMDGCN())
addPGOAndCoverageFlags(TC, C, JA, Output, Args, SanitizeArgs, CmdArgs);
+#if defined(ENABLE_AUTOTUNER)
+ // Add Auto-tuning options.
+ if (C.getDriver().isUsingAutoTune()) {
+ Arg *A = Args.getLastArg(options::OPT_O_Group);
+ if (!A || A->getOption().matches(options::OPT_O0))
+ D.Diag(clang::diag::err_drv_autotune_disabled_O0);
+
+ // Enable debug info when Auto-tuning options are specified.
+ CmdArgs.push_back("-debug-info-kind=line-tables-only");
+ if (!D.AutoTuneProjectDir.empty()) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(Args.MakeArgString(Twine("-autotuning-project-dir=") +
+ D.AutoTuneProjectDir));
+ }
+ if (D.getAutoTuneMode() == AutoTuneKind::AutoTuneGenerate)
+ AddAutoTuningOpportunities(Args, D, CmdArgs);
+ else if (D.getAutoTuneMode() == AutoTuneKind::AutoTuneNext)
+ AddAutoTuningInput(Args, D, CmdArgs);
+ }
+#endif
+
Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ);
if (getLastProfileSampleUseArg(Args) &&
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1ccc83a468ce..e01b21e102b1 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2429,6 +2429,119 @@ void tools::addMachineOutlinerArgs(const Driver &D,
}
}
+#if defined(ENABLE_AUTOTUNER)
+static bool isAcceptableThinLTOCodeRegion(StringRef CR) {
+ if ((CR.equals("CallSite") || CR.equals("Loop") || CR.equals("Function") ||
+ CR.equals("MachineBasicBlock")))
+ return false;
+ return true;
+}
+
+static bool processOpportunitiesOptions(StringRef CR, bool IsThinLTO,
+ std::string &CodeRegionsFilterStr) {
+ // Check if the argument has a valid value.
+ if (!(CR.equals("Other") || CR.equals("LLVMParam") || CR.equals("CallSite") ||
+ CR.equals("Function") || CR.equals("Loop") ||
+ CR.equals("MachineBasicBlock") || CR.equals("Switch") ||
+ CR.equals("ProgramParam")))
+ return false;
+
+ // Disable fine grain tuning for thin LTO during link time optimization.
+ if (IsThinLTO && !isAcceptableThinLTOCodeRegion(CR)) {
+ llvm::errs()
+ << "error: fine-grained autotuning not supported in ThinLTO mode\n";
+ return false;
+ }
+
+ if (!CodeRegionsFilterStr.empty())
+ CodeRegionsFilterStr += ',';
+ CodeRegionsFilterStr += CR;
+ return true;
+}
+
+// Add AutoTuner options for generating tuning opporutnities.
+// IsThinLTO will only be true during link time optimization for -flto=thin.
+void tools::AddAutoTuningOpportunities(const ArgList &Args, const Driver &D,
+ ArgStringList &CmdArgs, bool IsThinLTO) {
+ // Dump CodeRegions into opportunity files.
+ CmdArgs.push_back("-mllvm");
+ SmallString<128> OppPath = StringRef(D.AutoTuneDirDataPath);
+ llvm::sys::path::append(OppPath, "opp");
+ StringRef RawTypeFilterStr = D.AutoTuneOptions;
+ CmdArgs.push_back(Args.MakeArgString(Twine("-auto-tuning-opp=") + OppPath));
+ if (D.IsMLTuningEnabled) {
+ // Baseline config is -1
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(Args.MakeArgString(Twine("-auto-tuning-config-id=-1")));
+ }
+ // Filter CodeRegions by type.
+ std::string CodeRegionsFilterStr;
+ if (Arg *A = Args.getLastArg(options::OPT_fautotune_generate_EQ)) {
+ for (StringRef CR : A->getValues()) {
+ if (!processOpportunitiesOptions(CR, IsThinLTO, CodeRegionsFilterStr))
+ D.Diag(diag::err_drv_unsupported_option_argument)
+ << A->getOption().getName() << CR;
+ }
+ } else if (!RawTypeFilterStr.empty()) {
+ SmallVector<StringRef, 8> TypeFilters;
+ RawTypeFilterStr.split(TypeFilters, ',');
+ for (StringRef CR : TypeFilters) {
+ if (!processOpportunitiesOptions(CR, IsThinLTO, CodeRegionsFilterStr))
+ D.Diag(diag::err_drv_unsupported_option_argument)
+ << "fautotune-generate" << CR;
+ }
+ } else {
+ if (IsThinLTO)
+ D.Diag(diag::err_drv_autotune_generic)
+ << "AutoTuner: no valid code region type specified for ThinLTO mode";
+ // Otherwise by default, dump CodeRegions of Function and Loop type.
+ CodeRegionsFilterStr = "CallSite,Function,Loop";
+ }
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(
+ Args.MakeArgString("-auto-tuning-type-filter=" + CodeRegionsFilterStr));
+}
+
+static bool processInputOptions(StringRef Options, SmallString<128> &Path,
+ const ArgList &Args, const Driver &D,
+ llvm::opt::ArgStringList &CmdArgs) {
+ unsigned Value = 0;
+ // Check if the argument is an integer type.
+ if (Options.getAsInteger(10, Value))
+ return false;
+ llvm::sys::path::append(Path, "config-" + Twine(Value) + ".yaml");
+ if (D.IsMLTuningEnabled) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(
+ Args.MakeArgString(Twine("-auto-tuning-config-id=" + Twine(Value))));
+ }
+ return true;
+}
+
+void tools::AddAutoTuningInput(const ArgList &Args, const Driver &D,
+ llvm::opt::ArgStringList &CmdArgs) {
+ SmallString<128> InputPath = StringRef(D.AutoTuneDirDataPath);
+ StringRef RawOptionsStr = D.AutoTuneOptions;
+
+ if (Arg *A = Args.getLastArg(options::OPT_fautotune_EQ)) {
+ if (!processInputOptions(StringRef(A->getValue()), InputPath, Args, D,
+ CmdArgs))
+ D.Diag(diag::err_drv_invalid_int_value)
+ << A->getAsString(Args) << A->getValue();
+ } else if (!RawOptionsStr.empty()) {
+ if (!processInputOptions(RawOptionsStr, InputPath, Args, D, CmdArgs))
+ D.Diag(diag::err_drv_invalid_int_value)
+ << "-fautotune=" + RawOptionsStr.str() << RawOptionsStr;
+ } else {
+ llvm::sys::path::append(InputPath, "config.yaml");
+ }
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(
+ Args.MakeArgString(Twine("-auto-tuning-input=") + InputPath));
+ setenv("AUTOTUNE_INPUT", Args.MakeArgString(InputPath), 1);
+}
+#endif
+
void tools::addOpenMPDeviceRTL(const Driver &D,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h
index bd5cb1bb866e..36103655c522 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -240,6 +240,14 @@ void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
const llvm::Triple &Triple, bool IsLTO,
const StringRef PluginOptPrefix = "");
+#if defined(ENABLE_AUTOTUNER)
+void AddAutoTuningOpportunities(const llvm::opt::ArgList &Args, const Driver &D,
+ llvm::opt::ArgStringList &CmdArgs,
+ bool isThinLTO = false);
+void AddAutoTuningInput(const llvm::opt::ArgList &Args, const Driver &D,
+ llvm::opt::ArgStringList &CmdArgs);
+#endif
+
void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
StringRef BitcodeSuffix, const llvm::Triple &Triple);
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 42050dced99c..91a9eda9d78c 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -682,6 +682,40 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddAllArgs(CmdArgs, options::OPT_T);
+#if defined(ENABLE_AUTOTUNER)
+ // AutoTuner related features will only be enabled for LTO build during
+ // linking phase. Otherwise, non LTO build will require lld linker
+ // unnecessarily (other linkers do not support AutoTuner).
+ if (D.isUsingAutoTune() && D.isUsingLTO()) {
+ bool LinkerIsLLD = false;
+ (void) ToolChain.GetLinkerPath(&LinkerIsLLD);
+ // AutoTuner support is only available for LLD Linker.
+ if (!LinkerIsLLD)
+ D.Diag(clang::diag::err_drv_lto_without_lld);
+
+ bool IsThinLTO = D.getLTOMode() == LTOK_Thin;
+ if (!D.AutoTuneProjectDir.empty()) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(Args.MakeArgString(Twine("-autotuning-project-dir=") +
+ D.AutoTuneProjectDir));
+ }
+ // Enable tuning of callsites cause all of the callsites will have local
+ // linkage during LTO and they are not tuned by default.
+ CmdArgs.push_back(Args.MakeArgString("-mllvm"));
+ CmdArgs.push_back(
+ Args.MakeArgString("-auto-tuning-enable-local-callsite-tuning=true"));
+ if (D.getAutoTuneMode() == AutoTuneKind::AutoTuneGenerate) {
+ AddAutoTuningOpportunities(Args, D, CmdArgs, IsThinLTO);
+ } else if (D.getAutoTuneMode() == AutoTuneKind::AutoTuneNext) {
+ AddAutoTuningInput(Args, D, CmdArgs);
+ if (IsThinLTO) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-autotuning-thin-lto=true");
+ }
+ }
+ }
+#endif
+
const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileCurCP(),
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 310f67774a66..92beeef9bd5e 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -222,6 +222,33 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
// This should happen AFTER plugins have been loaded!
if (!Clang->getFrontendOpts().LLVMArgs.empty()) {
unsigned NumArgs = Clang->getFrontendOpts().LLVMArgs.size();
+#if defined(ENABLE_AUTOTUNER)
+ // Both incremental compilation (for AutoTuner) and 'opt-bisect-limit'
+ // changes the behavior of compilation pipeline. If incremental compilation
+ // is used along with 'opt-bisect-limit' then 'opt-bisect-limit' is
+ // preferred and incremental compilation is disabled.
+ unsigned BisectLimitFound = 0;
+ unsigned CompileModeFound = 0;
+ for (unsigned Idx = 0; Idx != NumArgs; ++Idx) {
+ if (Clang->getFrontendOpts().LLVMArgs[Idx].find("-opt-bisect-limit=") !=
+ std::string::npos)
+ BisectLimitFound = Idx;
+ if (Clang->getFrontendOpts().LLVMArgs[Idx].find(
+ "-auto-tuning-compile-mode=") != std::string::npos)
+ CompileModeFound = Idx;
+ if (BisectLimitFound && CompileModeFound)
+ break;
+ }
+ if (BisectLimitFound && CompileModeFound &&
+ Clang->getFrontendOpts().LLVMArgs[CompileModeFound].compare(
+ "-auto-tuning-compile-mode=Inactive") != 0) {
+ Clang->getFrontendOpts().LLVMArgs[CompileModeFound] =
+ "-auto-tuning-compile-mode=Inactive";
+ llvm::errs() << "AutoTunerCompile: Incremental compilation cannot work "
+ "with '-opt-bisect-limit' flag.\n"
+ "Disabling incremental compilation.\n";
+ }
+#endif
auto Args = std::make_unique<const char*[]>(NumArgs + 2);
Args[0] = "clang (LLVM option parsing)";
for (unsigned i = 0; i != NumArgs; ++i)
--
2.33.0

View File

@ -1,17 +0,0 @@
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.*")
--

View File

@ -1,64 +0,0 @@
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] [backport][Clang] 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

@ -1,176 +0,0 @@
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'
+// AVR-NEXT: note: valid target CPU values are: avr1, at90s1200, attiny11, attiny12, attiny15, attiny28, avr2, at90s2313, at90s2323, at90s2333, at90s2343, attiny22, attiny26, at86rf401, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, at90s8535, avr25, ata5272, ata6616c, attiny13, attiny13a, attiny2313, attiny2313a, attiny24, attiny24a, attiny4313, attiny44, attiny44a, attiny84, attiny84a, attiny25, attiny45, attiny85, attiny261, attiny261a, attiny441, attiny461, attiny461a, attiny841, attiny861, attiny861a, attiny87, attiny43u, attiny48, attiny88, attiny828, avr3, at43usb355, at76c711, avr31, atmega103, at43usb320, avr35, attiny167, at90usb82, at90usb162, ata5505, ata6617c, ata664251, atmega8u2, atmega16u2, atmega32u2, attiny1634, avr4, atmega8, ata6289, atmega8a, ata6285, ata6286, ata6612c, atmega48, atmega48a, atmega48pa, atmega48pb, atmega48p, atmega88, atmega88a, atmega88p, atmega88pa, atmega88pb, atmega8515, atmega8535, atmega8hva, at90pwm1, at90pwm2, at90pwm2b, at90pwm3, at90pwm3b, at90pwm81, avr5, ata5702m322, ata5782, ata5790, ata5790n, ata5791, ata5795, ata5831, ata6613c, ata6614q, ata8210, ata8510, atmega16, atmega16a, atmega161, atmega162, atmega163, atmega164a, atmega164p, atmega164pa, atmega165, atmega165a, atmega165p, atmega165pa, atmega168, atmega168a, atmega168p, atmega168pa, atmega168pb, atmega169, atmega169a, atmega169p, atmega169pa, atmega32, atmega32a, atmega323, atmega324a, atmega324p, atmega324pa, atmega324pb, atmega325, atmega325a, atmega325p, atmega325pa, atmega3250, atmega3250a, atmega3250p, atmega3250pa, atmega328, atmega328p, atmega328pb, atmega329, atmega329a, atmega329p, atmega329pa, atmega3290, atmega3290a, atmega3290p, atmega3290pa, atmega406, atmega64, atmega64a, atmega640, atmega644, atmega644a, atmega644p, atmega644pa, atmega645, atmega645a, atmega645p, atmega649, atmega649a, atmega649p, atmega6450, atmega6450a, atmega6450p, atmega6490, atmega6490a, atmega6490p, atmega64rfr2, atmega644rfr2, atmega16hva, atmega16hva2, atmega16hvb, atmega16hvbrevb, atmega32hvb, atmega32hvbrevb, atmega64hve, atmega64hve2, at90can32, at90can64, at90pwm161, at90pwm216, at90pwm316, atmega32c1, atmega64c1, atmega16m1, atmega32m1, atmega64m1, atmega16u4, atmega32u4, atmega32u6, at90usb646, at90usb647, at90scr100, at94k, m3000, avr51, atmega128, atmega128a, atmega1280, atmega1281, atmega1284, atmega1284p, atmega128rfa1, atmega128rfr2, atmega1284rfr2, at90can128, at90usb1286, at90usb1287, avr6, atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2, avrxmega2, atxmega16a4, atxmega16a4u, atxmega16c4, atxmega16d4, atxmega32a4, atxmega32a4u, atxmega32c3, atxmega32c4, atxmega32d3, atxmega32d4, atxmega32e5, atxmega16e5, atxmega8e5, avrxmega4, atxmega64a3, atxmega64a3u, atxmega64a4u, atxmega64b1, atxmega64b3, atxmega64c3, atxmega64d3, atxmega64d4, avrxmega5, atxmega64a1, atxmega64a1u, avrxmega6, atxmega128a3, atxmega128a3u, atxmega128b1, atxmega128b3, atxmega128c3, atxmega128d3, atxmega128d4, atxmega192a3, atxmega192a3u, atxmega192c3, atxmega192d3, atxmega256a3, atxmega256a3u, atxmega256a3b, atxmega256a3bu, atxmega256c3, atxmega256d3, atxmega384c3, atxmega384d3, avrxmega7, atxmega128a1, atxmega128a1u, atxmega128a4u, avrtiny, attiny4, attiny5, attiny9, attiny10, attiny20, attiny40, attiny102, attiny104, avrxmega3, attiny202, attiny402, attiny204, attiny404, attiny804, attiny1604, attiny406, attiny806, attiny1606, attiny807, attiny1607, attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614, attiny416, attiny816, attiny1616, attiny3216, attiny417, attiny817, attiny1617, attiny3217, attiny1624, attiny1626, attiny1627, atmega808, atmega809, atmega1608, atmega1609, atmega3208, atmega3209, atmega4808, atmega4809
+
+// RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
+// RISCV32: error: unknown target CPU 'not-a-cpu'
+// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max{{$}}
+
+// RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
+// RISCV64: error: unknown target CPU 'not-a-cpu'
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280{{$}}
+
+// RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
+// TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
+// TUNE-RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, generic, rocket, sifive-7-series{{$}}
+
+// RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
+// TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}
diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c
index cd1b0bc15..466b26263 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: 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'
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 89b7cafdc..7728be7d4 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -44,9 +44,13 @@ config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
config.use_classic_flang = @LLVM_ENABLE_CLASSIC_FLANG@
config.build_for_openeuler = @BUILD_FOR_OPENEULER@
+config.enable_enable_aarch64_hip09 = @LLVM_ENABLE_AARCH64_HIP09@
import lit.llvm
lit.llvm.initialize(lit_config, config)
+if config.enable_enable_aarch64_hip09:
+ config.available_features.add("enable_enable_aarch64_hip09")
+
# Let the main config do the real work.
lit_config.load_config(
config, os.path.join(config.clang_src_dir, "test/lit.cfg.py"))
--
2.19.1

File diff suppressed because it is too large Load Diff

View File

@ -1,184 +0,0 @@
From 42b0d16ab1ced5720e017fa9f6059c32489ab1bd Mon Sep 17 00:00:00 2001
From: xiajingze <xiajingze1@huawei.com>
Date: Wed, 9 Oct 2024 17:13:49 +0800
Subject: [PATCH] [AArch64] Delete hip09 macro
Signed-off-by: xiajingze <xiajingze1@huawei.com>
---
clang/test/CMakeLists.txt | 1 -
clang/test/Driver/aarch64-hip09.c | 1 -
.../test/Misc/target-invalid-cpu-note-hip09.c | 97 -------------------
clang/test/Misc/target-invalid-cpu-note.c | 5 +-
clang/test/lit.site.cfg.py.in | 4 -
5 files changed, 2 insertions(+), 106 deletions(-)
delete mode 100644 clang/test/Misc/target-invalid-cpu-note-hip09.c
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 25e4e1f300bd..b88694deb818 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -19,7 +19,6 @@ 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
index 156be3f38cde..5851796a2bd6 100644
--- a/clang/test/Driver/aarch64-hip09.c
+++ b/clang/test/Driver/aarch64-hip09.c
@@ -1,4 +1,3 @@
-// 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
diff --git a/clang/test/Misc/target-invalid-cpu-note-hip09.c b/clang/test/Misc/target-invalid-cpu-note-hip09.c
deleted file mode 100644
index f2561a0890fc..000000000000
--- a/clang/test/Misc/target-invalid-cpu-note-hip09.c
+++ /dev/null
@@ -1,97 +0,0 @@
-// 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'
-// AVR-NEXT: note: valid target CPU values are: avr1, at90s1200, attiny11, attiny12, attiny15, attiny28, avr2, at90s2313, at90s2323, at90s2333, at90s2343, attiny22, attiny26, at86rf401, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, at90s8535, avr25, ata5272, ata6616c, attiny13, attiny13a, attiny2313, attiny2313a, attiny24, attiny24a, attiny4313, attiny44, attiny44a, attiny84, attiny84a, attiny25, attiny45, attiny85, attiny261, attiny261a, attiny441, attiny461, attiny461a, attiny841, attiny861, attiny861a, attiny87, attiny43u, attiny48, attiny88, attiny828, avr3, at43usb355, at76c711, avr31, atmega103, at43usb320, avr35, attiny167, at90usb82, at90usb162, ata5505, ata6617c, ata664251, atmega8u2, atmega16u2, atmega32u2, attiny1634, avr4, atmega8, ata6289, atmega8a, ata6285, ata6286, ata6612c, atmega48, atmega48a, atmega48pa, atmega48pb, atmega48p, atmega88, atmega88a, atmega88p, atmega88pa, atmega88pb, atmega8515, atmega8535, atmega8hva, at90pwm1, at90pwm2, at90pwm2b, at90pwm3, at90pwm3b, at90pwm81, avr5, ata5702m322, ata5782, ata5790, ata5790n, ata5791, ata5795, ata5831, ata6613c, ata6614q, ata8210, ata8510, atmega16, atmega16a, atmega161, atmega162, atmega163, atmega164a, atmega164p, atmega164pa, atmega165, atmega165a, atmega165p, atmega165pa, atmega168, atmega168a, atmega168p, atmega168pa, atmega168pb, atmega169, atmega169a, atmega169p, atmega169pa, atmega32, atmega32a, atmega323, atmega324a, atmega324p, atmega324pa, atmega324pb, atmega325, atmega325a, atmega325p, atmega325pa, atmega3250, atmega3250a, atmega3250p, atmega3250pa, atmega328, atmega328p, atmega328pb, atmega329, atmega329a, atmega329p, atmega329pa, atmega3290, atmega3290a, atmega3290p, atmega3290pa, atmega406, atmega64, atmega64a, atmega640, atmega644, atmega644a, atmega644p, atmega644pa, atmega645, atmega645a, atmega645p, atmega649, atmega649a, atmega649p, atmega6450, atmega6450a, atmega6450p, atmega6490, atmega6490a, atmega6490p, atmega64rfr2, atmega644rfr2, atmega16hva, atmega16hva2, atmega16hvb, atmega16hvbrevb, atmega32hvb, atmega32hvbrevb, atmega64hve, atmega64hve2, at90can32, at90can64, at90pwm161, at90pwm216, at90pwm316, atmega32c1, atmega64c1, atmega16m1, atmega32m1, atmega64m1, atmega16u4, atmega32u4, atmega32u6, at90usb646, at90usb647, at90scr100, at94k, m3000, avr51, atmega128, atmega128a, atmega1280, atmega1281, atmega1284, atmega1284p, atmega128rfa1, atmega128rfr2, atmega1284rfr2, at90can128, at90usb1286, at90usb1287, avr6, atmega2560, atmega2561, atmega256rfr2, atmega2564rfr2, avrxmega2, atxmega16a4, atxmega16a4u, atxmega16c4, atxmega16d4, atxmega32a4, atxmega32a4u, atxmega32c3, atxmega32c4, atxmega32d3, atxmega32d4, atxmega32e5, atxmega16e5, atxmega8e5, avrxmega4, atxmega64a3, atxmega64a3u, atxmega64a4u, atxmega64b1, atxmega64b3, atxmega64c3, atxmega64d3, atxmega64d4, avrxmega5, atxmega64a1, atxmega64a1u, avrxmega6, atxmega128a3, atxmega128a3u, atxmega128b1, atxmega128b3, atxmega128c3, atxmega128d3, atxmega128d4, atxmega192a3, atxmega192a3u, atxmega192c3, atxmega192d3, atxmega256a3, atxmega256a3u, atxmega256a3b, atxmega256a3bu, atxmega256c3, atxmega256d3, atxmega384c3, atxmega384d3, avrxmega7, atxmega128a1, atxmega128a1u, atxmega128a4u, avrtiny, attiny4, attiny5, attiny9, attiny10, attiny20, attiny40, attiny102, attiny104, avrxmega3, attiny202, attiny402, attiny204, attiny404, attiny804, attiny1604, attiny406, attiny806, attiny1606, attiny807, attiny1607, attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614, attiny416, attiny816, attiny1616, attiny3216, attiny417, attiny817, attiny1617, attiny3217, attiny1624, attiny1626, attiny1627, atmega808, atmega809, atmega1608, atmega1609, atmega3208, atmega3209, atmega4808, atmega4809
-
-// RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
-// RISCV32: error: unknown target CPU 'not-a-cpu'
-// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max{{$}}
-
-// RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
-// RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280{{$}}
-
-// RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
-// TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, generic, rocket, sifive-7-series{{$}}
-
-// RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
-// TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}
diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c
index 466b262639a2..906be590e857 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -1,4 +1,3 @@
-// UNSUPPORTED: 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'
@@ -6,11 +5,11 @@
// 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, grace{{$}}
+// 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, grace{{$}}
+// 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'
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 7728be7d4d8d..89b7cafdc1d8 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -43,14 +43,10 @@ config.ppc_linux_default_ieeelongdouble = @PPC_LINUX_DEFAULT_IEEELONGDOUBLE@
config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
config.use_classic_flang = @LLVM_ENABLE_CLASSIC_FLANG@
config.build_for_openeuler = @BUILD_FOR_OPENEULER@
-config.enable_enable_aarch64_hip09 = @LLVM_ENABLE_AARCH64_HIP09@
import lit.llvm
lit.llvm.initialize(lit_config, config)
-if config.enable_enable_aarch64_hip09:
- config.available_features.add("enable_enable_aarch64_hip09")
-
# Let the main config do the real work.
lit_config.load_config(
config, os.path.join(config.clang_src_dir, "test/lit.cfg.py"))
--
2.43.0

View File

@ -1,93 +0,0 @@
From 822d849ad922edc6306f96efe3e936359bb4541f Mon Sep 17 00:00:00 2001
From: xiajingze <xiajingze1@huawei.com>
Date: Thu, 31 Oct 2024 16:30:51 +0800
Subject: [PATCH] [Driver] Pass -z\<arg\> and -Wl,-z \<arg\> option to the
linker
Signed-off-by: xiajingze <xiajingze1@huawei.com>
---
clang/include/clang/Driver/Options.td | 5 +++++
clang/lib/Driver/Driver.cpp | 18 ++++++++++++++++++
clang/test/Driver/z-args.c | 15 +++++++++++++++
3 files changed, 38 insertions(+)
create mode 100644 clang/test/Driver/z-args.c
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 344c8bd49da7..b40046a740a8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -886,8 +886,13 @@ def Xopenmp_target : Separate<["-"], "Xopenmp-target">, Group<CompileOnly_Group>
def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">, Group<CompileOnly_Group>,
HelpText<"Pass <arg> to the target offloading toolchain identified by <triple>.">,
MetaVarName<"<triple> <arg>">;
+#ifdef BUILD_FOR_OPENEULER
+def z : JoinedOrSeparate<["-"], "z">, Flags<[LinkerInput]>,
+ HelpText<"Pass -z<arg> or -z <arg> to the linker">, MetaVarName<"<arg>">,
+#else
def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
HelpText<"Pass -z <arg> to the linker">, MetaVarName<"<arg>">,
+#endif
Group<Link_Group>;
def offload_link : Flag<["--"], "offload-link">, Group<Link_Group>,
HelpText<"Use the new offloading linker to perform the link job.">;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index bd9db7714f95..28b33c8862e4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2597,6 +2597,16 @@ void Driver::BuildUniversalActions(Compilation &C, const ToolChain &TC,
}
}
+#ifdef BUILD_FOR_OPENEULER
+llvm::DenseSet<StringRef> ZArgsList{
+ "defs", "muldefs", "execstack", "noexecstack", "globalaudit", "combreloc",
+ "nocombreloc", "global", "initfirst", "interpose", "lazy", "loadfltr",
+ "nocopyreloc", "nodefaultlib", "nodelete", "nodlopen", "nodump", "now",
+ "origin", "relro", "norelro", "separate-code", "noseparate-code", "common",
+ "nocommon", "text", "notext", "textoff"
+};
+#endif
+
bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value,
types::ID Ty, bool TypoCorrect) const {
if (!getCheckInputsExist())
@@ -2673,6 +2683,14 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value,
if (IsCLMode() && Ty == types::TY_Object && !Value.startswith("/"))
return true;
+#ifdef BUILD_FOR_OPENEULER
+ if (ZArgsList.find(Value) != ZArgsList.end() ||
+ Value.starts_with("common-page-size=") ||
+ Value.starts_with("max-page-size=") ||
+ Value.starts_with("stack-size="))
+ return true;
+#endif
+
Diag(clang::diag::err_drv_no_such_file) << Value;
return false;
}
diff --git a/clang/test/Driver/z-args.c b/clang/test/Driver/z-args.c
new file mode 100644
index 000000000000..83bb2b570e69
--- /dev/null
+++ b/clang/test/Driver/z-args.c
@@ -0,0 +1,15 @@
+// REQUIRES: build_for_openeuler
+// RUN: %clang -### -znow 2>&1 | FileCheck -check-prefix=CHECK-LINKER %s
+// CHECK-LINKER: "-z" "now"
+
+// RUN: %clang -### -Wl,-z now 2>&1 | FileCheck -check-prefix=CHECK-WLCOMMAZ %s
+// CHECK-WLCOMMAZ: "-z" "now"
+// RUN: %clang -### -Wl,-z -Wl,now 2>&1 | FileCheck \
+// RUN: -check-prefix=CHECK-WLCOMMAZ1 %s
+// CHECK-WLCOMMAZ1: "-z" "now"
+// RUN: %clang -### -Wl,-z -O3 now 2>&1 | FileCheck \
+// RUN: -check-prefix=CHECK-WLCOMMAZ2 %s
+// CHECK-WLCOMMAZ2: "-z" "now"
+// RUN: %clang -### -Wl,-z stack-size=1 2>&1 | FileCheck \
+// RUN: -check-prefix=CHECK-WLCOMMAZ3 %s
+// CHECK-WLCOMMAZ3: "-z" "stack-size=1"
\ No newline at end of file
--
2.43.0

View File

@ -1,225 +0,0 @@
From 001e7941bc936847b07da2fdb4b19a8adcba7718 Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
Date: Fri, 19 Jul 2024 10:44:49 +0800
Subject: [PATCH 1/2] Complete -fgcc-compatible option scope
Complete -fgcc-compatible option scope to Langopts and Diagopts
(cherry picked from commit 8881224782ade2afaab4860f3462e44b7d5c2601)
Signed-off-by: wangqiang <wangqiang1@kylinos.cn>
---
clang/include/clang/Basic/DiagnosticOptions.def | 4 ++++
clang/include/clang/Basic/LangOptions.def | 4 ++++
clang/include/clang/Driver/Options.td | 6 ++++--
clang/lib/Driver/ToolChains/Clang.cpp | 2 ++
clang/lib/Frontend/CompilerInvocation.cpp | 15 +++++++++++++--
5 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def
index 6d0c1b14acc1..5253e951d403 100644
--- a/clang/include/clang/Basic/DiagnosticOptions.def
+++ b/clang/include/clang/Basic/DiagnosticOptions.def
@@ -99,6 +99,10 @@ VALUE_DIAGOPT(MessageLength, 32, 0)
DIAGOPT(ShowSafeBufferUsageSuggestions, 1, 0)
+#ifdef BUILD_FOR_OPENEULER
+DIAGOPT(GccCompatible, 1, 0) /// -fgcc-compatible
+#endif
+
#undef DIAGOPT
#undef ENUM_DIAGOPT
#undef VALUE_DIAGOPT
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index f7ec0406f33e..eb62a4951c65 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -468,6 +468,10 @@ LANGOPT(IncrementalExtensions, 1, 0, " True if we want to process statements"
BENIGN_LANGOPT(CheckNew, 1, 0, "Do not assume C++ operator new may not return NULL")
+#ifdef BUILD_FOR_OPENEULER
+LANGOPT(GccCompatible, 1, 0, "Enable gcc compatibility for openEuler.")
+#endif
+
#undef LANGOPT
#undef COMPATIBLE_LANGOPT
#undef BENIGN_LANGOPT
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 71d6ed66ab96..344c8bd49da7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1810,9 +1810,11 @@ def fautotune_rank : Flag<["-"], "fautotune-rank">, Group<f_Group>,
#endif
#ifdef BUILD_FOR_OPENEULER
-def fgcc_compatible : Flag<["-"], "fgcc-compatible">, Group<f_Group>,
+def fgcc_compatible : Flag<["-"], "fgcc-compatible">,
+ Flags<[CC1Option]>,
+ MarshallingInfoFlag<DiagnosticOpts<"GccCompatible">>,
HelpText<"Enable gcc compatibility for openEuler.">;
-def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Group<f_Group>;
+def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Flags<[CC1Option]>;
#endif
// Begin sanitizer flags. These should all be core options exposed in all driver
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index c49cb43ff19c..fac4f03d6193 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-Wno-error=varargs");
CmdArgs.push_back("-Wno-error=unused-value");
CmdArgs.push_back("-Wno-error=format-nonliteral");
+
+ CmdArgs.push_back("-fgcc-compatible");
}
#endif
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 1fba91bed041..d7b609ef276c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -818,8 +818,9 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::vector<std::string> &Diagnostics) {
for (auto *A : Args.filtered(Group)) {
if (A->getOption().getKind() == Option::FlagClass) {
- // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
- // its name (minus the "W" or "R" at the beginning) to the diagnostics.
+ // The argument is a pure flag (such as OPT_Wall or
+ // OPT_Wdeprecated). Add its name (minus the "W" or "R" at the
+ // beginning) to the diagnostics.
Diagnostics.push_back(
std::string(A->getOption().getName().drop_front(1)));
} else if (A->getOption().matches(GroupWithValue)) {
@@ -829,6 +830,7 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
+
Diagnostics.push_back(A->getValue());
}
}
@@ -3522,6 +3524,11 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
if (!Opts.RandstructSeed.empty())
GenerateArg(Args, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed, SA);
+
+#ifdef BUILD_FOR_OPENEULER
+ if (Opts.GccCompatible)
+ GenerateArg(Args, OPT_fgcc_compatible, SA);
+#endif
}
bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
@@ -4073,6 +4080,10 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
}
+#ifdef BUILD_FOR_OPENEULER
+ Opts.GccCompatible = Args.hasArg(options::OPT_fgcc_compatible);
+#endif
+
return Diags.getNumErrors() == NumErrorsBefore;
}
--
2.43.0
From c6f76aa5cdb02c376df17aafadf2dd7cf41fe5b1 Mon Sep 17 00:00:00 2001
From: wangqiang <wangqiang1@kylinos.cn>
Date: Fri, 19 Jul 2024 11:01:22 +0800
Subject: [PATCH 2/2] Handling of option `-Wall` and `-Werror=format=2`
override `-Wno`
Fix nfs-utils build issue
Signed-off-by: wangqiang <wangqiang1@kylinos.cn>
---
clang/lib/Frontend/CompilerInvocation.cpp | 32 ++++++++++++++++++++++-
clang/test/Driver/test-warnning.c | 15 +++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
create mode 100644 clang/test/Driver/test-warnning.c
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d7b609ef276c..cbb122cc6eeb 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -817,10 +817,40 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
OptSpecifier GroupWithValue,
std::vector<std::string> &Diagnostics) {
for (auto *A : Args.filtered(Group)) {
+#ifdef BUILD_FOR_OPENEULER
+ bool GccCompatible = Args.hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false);
if (A->getOption().getKind() == Option::FlagClass) {
// The argument is a pure flag (such as OPT_Wall or
// OPT_Wdeprecated). Add its name (minus the "W" or "R" at the
// beginning) to the diagnostics.
+ if (A->getOption().getName() == "Wall" && GccCompatible) {
+ // Avoid -Wall and -Werror=format=2 override -Wno-xxx
+ Diagnostics.insert(
+ Diagnostics.begin(),
+ std::string(A->getOption().getName().drop_front(1)));
+ } else {
+ Diagnostics.push_back(
+ std::string(A->getOption().getName().drop_front(1)));
+ }
+ } else if (A->getOption().matches(GroupWithValue)) {
+ // This is -Wfoo= or -Rfoo=, where foo is the name of the diagnostic
+ // group. Add only the group name to the diagnostics.
+ Diagnostics.push_back(std::string(
+ A->getOption().getName().drop_front(1).rtrim("=-")));
+ } else {
+ // Otherwise, add its value (for OPT_W_Joined and similar).
+ if (std::string(A->getValue()) == "error=format=2" && GccCompatible) {
+ // Avoid -Werror=format=2 override -Wno-xxx
+ Diagnostics.insert(Diagnostics.begin(), A->getValue());
+ } else {
+ Diagnostics.push_back(A->getValue());
+ }
+ }
+#else
+ if (A->getOption().getKind() == Option::FlagClass) {
+ // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
+ // its name (minus the "W" or "R" at the beginning) to the diagnostics.
Diagnostics.push_back(
std::string(A->getOption().getName().drop_front(1)));
} else if (A->getOption().matches(GroupWithValue)) {
@@ -830,9 +860,9 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
-
Diagnostics.push_back(A->getValue());
}
+#endif
}
}
diff --git a/clang/test/Driver/test-warnning.c b/clang/test/Driver/test-warnning.c
new file mode 100644
index 000000000000..641f9e3512d5
--- /dev/null
+++ b/clang/test/Driver/test-warnning.c
@@ -0,0 +1,15 @@
+// REQUIRES: build_for_openeuler
+
+// RUN: %clang -v -fgcc-compatible -Wno-format-security -Werror=format=2 -Wall %s
+// RUN: %clang -v -Wall %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: warning: format string is not a string literal (potentially insecure)
+// RUN: %clang -v -Wno-format-security -Werror=format=2 -Wall %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: error: format string is not a string literal (potentially insecure)
+
+#include <stdio.h>
+
+int main() {
+ char *str = "llvm-project";
+ printf(str);
+ return 0;
+}
\ No newline at end of file
--
2.43.0

View File

@ -1,146 +0,0 @@
From 25282cd2e1bbae9c68a4f0df21fef831331503f4 Mon Sep 17 00:00:00 2001
From: Carlos Eduardo Seo <carlos.seo@linaro.org>
Date: Sun, 24 Sep 2023 11:58:14 -0300
Subject: [PATCH] [Clang][CodeGen] Add __builtin_bcopy (#67130)
Add __builtin_bcopy to the list of GNU builtins. This was causing a
series of test failures in glibc.
Adjust the tests to reflect the changes in codegen.
Fixes #51409.
Fixes #63065.
---
clang/include/clang/Basic/Builtins.def | 3 ++-
clang/lib/AST/Decl.cpp | 6 ++++++
clang/lib/CodeGen/CGBuiltin.cpp | 14 ++++++++++++++
clang/test/Analysis/bstring.c | 3 +--
clang/test/Analysis/security-syntax-checks.m | 4 ++--
.../CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c | 6 +++---
6 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index 6dad8b512bd2..3f2cbcedc4b5 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -560,7 +560,7 @@ BUILTIN(__builtin_va_copy, "vAA", "n")
BUILTIN(__builtin_stdarg_start, "vA.", "nt")
BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nctE")
BUILTIN(__builtin_bcmp, "ivC*vC*z", "FnE")
-BUILTIN(__builtin_bcopy, "vv*v*z", "n")
+BUILTIN(__builtin_bcopy, "vvC*v*z", "nF")
BUILTIN(__builtin_bzero, "vv*z", "nF")
BUILTIN(__builtin_free, "vv*", "nF")
BUILTIN(__builtin_malloc, "v*z", "nF")
@@ -1154,6 +1154,7 @@ LIBBUILTIN(strndup, "c*cC*z", "f", STRING_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(index, "c*cC*i", "f", STRINGS_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(rindex, "c*cC*i", "f", STRINGS_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(bzero, "vv*z", "f", STRINGS_H, ALL_GNU_LANGUAGES)
+LIBBUILTIN(bcopy, "vvC*v*z", "f", STRINGS_H, ALL_GNU_LANGUAGES)
LIBBUILTIN(bcmp, "ivC*vC*z", "fE", STRINGS_H, ALL_GNU_LANGUAGES)
// In some systems str[n]casejmp is a macro that expands to _str[n]icmp.
// We undefine then here to avoid wrong name.
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index fbc45fb6397f..3de1e4509bc0 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4320,6 +4320,10 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
case Builtin::BIbzero:
return Builtin::BIbzero;
+ case Builtin::BI__builtin_bcopy:
+ case Builtin::BIbcopy:
+ return Builtin::BIbcopy;
+
case Builtin::BIfree:
return Builtin::BIfree;
@@ -4351,6 +4355,8 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
return Builtin::BIstrlen;
if (FnInfo->isStr("bzero"))
return Builtin::BIbzero;
+ if (FnInfo->isStr("bcopy"))
+ return Builtin::BIbcopy;
} else if (isInStdNamespace()) {
if (FnInfo->isStr("free"))
return Builtin::BIfree;
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e512762fafaf..8f87c4d46109 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3555,6 +3555,20 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
return RValue::get(nullptr);
}
+
+ case Builtin::BIbcopy:
+ case Builtin::BI__builtin_bcopy: {
+ Address Src = EmitPointerWithAlignment(E->getArg(0));
+ Address Dest = EmitPointerWithAlignment(E->getArg(1));
+ Value *SizeVal = EmitScalarExpr(E->getArg(2));
+ EmitNonNullArgCheck(RValue::get(Src.getPointer()), E->getArg(0)->getType(),
+ E->getArg(0)->getExprLoc(), FD, 0);
+ EmitNonNullArgCheck(RValue::get(Dest.getPointer()), E->getArg(1)->getType(),
+ E->getArg(1)->getExprLoc(), FD, 0);
+ Builder.CreateMemMove(Dest, Src, SizeVal, false);
+ return RValue::get(Dest.getPointer());
+ }
+
case Builtin::BImemcpy:
case Builtin::BI__builtin_memcpy:
case Builtin::BImempcpy:
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index a7c7bdb23683..5d86241a4ac9 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -483,8 +483,7 @@ int memcmp8(char *a, size_t n) {
//===----------------------------------------------------------------------===
#define bcopy BUILTIN(bcopy)
-// __builtin_bcopy is not defined with const in Builtins.def.
-void bcopy(/*const*/ void *s1, void *s2, size_t n);
+void bcopy(const void *s1, void *s2, size_t n);
void bcopy0 (void) {
diff --git a/clang/test/Analysis/security-syntax-checks.m b/clang/test/Analysis/security-syntax-checks.m
index 5b4f35055f51..59e60f685236 100644
--- a/clang/test/Analysis/security-syntax-checks.m
+++ b/clang/test/Analysis/security-syntax-checks.m
@@ -77,9 +77,9 @@ int test_bcmp(void *a, void *b, size_t n) {
}
// Obsolete function bcopy
-void bcopy(void *, void *, size_t);
+void bcopy(const void *, void *, size_t);
-void test_bcopy(void *a, void *b, size_t n) {
+void test_bcopy(const void *a, void *b, size_t n) {
bcopy(a, b, n); // expected-warning{{The bcopy() function is obsoleted by memcpy() or memmove(}}
}
diff --git a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
index cced16431926..64bd6e3ed41e 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-macros.c
@@ -167,15 +167,15 @@ void testalignx(const void *pointer) {
}
// 64BIT-LABEL: @testbcopy(
-// 64BIT: call void @bcopy(ptr noundef {{%.*}}, ptr noundef {{%.*}}, i64 noundef {{%.*}})
+// 64BIT: call void @llvm.memmove.p0.p0.i64(ptr align 1 {{%.*}}, ptr align 1 {{%.*}}, i64 {{%.*}}, i1 false)
// 64BIT-NEXT: ret void
//
// 32BIT-LABEL: @testbcopy(
-// 32BIT: call void @bcopy(ptr noundef {{%.*}}, ptr noundef {{%.*}}, i32 noundef {{%.*}})
+// 32BIT: call void @llvm.memmove.p0.p0.i32(ptr align 1 {{%.*}}, ptr align 1 {{%.*}}, i32 {{%.*}}, i1 false)
// 32BIT-NEXT: ret void
//
void testbcopy(const void *src, void *dest, size_t n) {
- __bcopy(src, dest, n);
+ bcopy(src, dest, n);
}
// 64BIT-LABEL: @testbzero(
--
Gitee

View File

@ -1,27 +0,0 @@
From 9efda5a71de8b117366152aa35a8837af0545d0f Mon Sep 17 00:00:00 2001
From: eastb233 <xiezhiheng@huawei.com>
Date: Mon, 28 Oct 2024 16:20:14 +0800
Subject: [PATCH] [clang] Increase the number of driver diagnostics
It hits the limited number of driver diagnostics,
increase `DIAG_SIZE_DRIVER`.
---
clang/include/clang/Basic/DiagnosticIDs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index bf4995175ef1..8bc45b91911c 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -31,7 +31,7 @@ namespace clang {
// Size of each of the diagnostic categories.
enum {
DIAG_SIZE_COMMON = 300,
- DIAG_SIZE_DRIVER = 300,
+ DIAG_SIZE_DRIVER = 350,
DIAG_SIZE_FRONTEND = 150,
DIAG_SIZE_SERIALIZATION = 120,
DIAG_SIZE_LEX = 400,
--
2.38.1.windows.1

View File

@ -1,27 +0,0 @@
From cd2d6fe2cdcb0fa047c77993c23da1fb612970be Mon Sep 17 00:00:00 2001
From: jianghaibo <jianghaibo9@huawei.com>
Date: Wed, 6 Nov 2024 16:04:39 +0800
Subject: [PATCH] [Driver] add option -fGNU-compatibility aliased with
-fgcc-compatible
---
clang/include/clang/Driver/Options.td | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 530bb53ea9b5..2faa65763234 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1814,6 +1814,9 @@ def fgcc_compatible : Flag<["-"], "fgcc-compatible">,
Flags<[CC1Option]>,
MarshallingInfoFlag<DiagnosticOpts<"GccCompatible">>,
HelpText<"Enable gcc compatibility for openEuler.">;
+def : Flag["-"], "fGNU-compatibility">,
+ Flags<[CC1Option]>, Alias<fgcc_compatible>,
+ HelpText<"Alias for -fgcc_compatible">;
def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Flags<[CC1Option]>;
#endif
--
2.38.1.windows.1

View File

@ -1,38 +0,0 @@
From 82d51aca563c40c84b70c0e295a9561d3dd4092b Mon Sep 17 00:00:00 2001
From: jianghaibo <jianghaibo9@huawei.com>
Date: Wed, 20 Nov 2024 16:13:04 +0800
Subject: [PATCH] [Driver] fix compile error for -fGNU-compatibility
---
clang/include/clang/Driver/Options.td | 2 +-
clang/test/Driver/test-generate-missing-build-notes.cpp | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index ccf395dad35a..c109d7a8fcab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1819,7 +1819,7 @@ def fgcc_compatible : Flag<["-"], "fgcc-compatible">,
Flags<[CC1Option]>,
MarshallingInfoFlag<DiagnosticOpts<"GccCompatible">>,
HelpText<"Enable gcc compatibility for openEuler.">;
-def : Flag["-"], "fGNU-compatibility">,
+def fGNU_compatibility : Flag<["-"], "fGNU-compatibility">,
Flags<[CC1Option]>, Alias<fgcc_compatible>,
HelpText<"Alias for -fgcc_compatible">;
def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Flags<[CC1Option]>;
diff --git a/clang/test/Driver/test-generate-missing-build-notes.cpp b/clang/test/Driver/test-generate-missing-build-notes.cpp
index efd5251e6a1c..54ac4c66a5b0 100644
--- a/clang/test/Driver/test-generate-missing-build-notes.cpp
+++ b/clang/test/Driver/test-generate-missing-build-notes.cpp
@@ -1,6 +1,7 @@
// REQUIRES: build_for_openeuler
// RUN: %clang -### -fgcc-compatible -Wa,--generate-missing-build-notes=yes %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
// RUN: %clang -### -fgcc-compatible -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
+// RUN: %clang -### -fGNU-compatibility -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
// CHECK-NO-ERROR-NOT: --generate-missing-build-notes=
// RUN: %clang -### -Wa,--generate-missing-build-notes=yes %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
// RUN: %clang -### -Wa,--generate-missing-build-notes=no %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
--
2.38.1.windows.1

View File

@ -1,14 +1,22 @@
# clang # clang-latest
#### Description #### Description
clang: noun C Language Family Front-end
1. A loud, resonant, metallic sound.
2. The strident call of a crane or goose.
3. C-language family front-end toolkit.
The goal of the Clang project is to create a new C, C++, Objective C #### Software Architecture
and Objective C++ front-end for the LLVM compiler. Its tools are built Software architecture description
as libraries and designed to be loosely-coupled and extensible.
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution #### Contribution

View File

@ -1,14 +1,23 @@
# clang # clang-latest
#### 介绍 #### 介绍
clang: noun C Language Family Front-end
1. A loud, resonant, metallic sound.
2. The strident call of a crane or goose.
3. C-language family front-end toolkit.
The goal of the Clang project is to create a new C, C++, Objective C #### 软件架构
and Objective C++ front-end for the LLVM compiler. Its tools are built 软件架构说明
as libraries and designed to be loosely-coupled and extensible.
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献 #### 参与贡献
@ -18,11 +27,11 @@ as libraries and designed to be loosely-coupled and extensible.
4. 新建 Pull Request 4. 新建 Pull Request
#### 码云特技 #### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1,9 +0,0 @@
#include <bits/wordsize.h>
#if __WORDSIZE == 32
#include "config-32.h"
#elif __WORDSIZE == 64
#include "config-64.h"
#else
#error "Unknown word size"
#endif

Binary file not shown.

Binary file not shown.

View File

@ -1,28 +1,21 @@
%undefine __cmake_in_source_build
%bcond_without sys_llvm
%bcond_without check %bcond_without check
%bcond_with classic_flang %bcond_without toolchain_clang
%bcond_with toolchain_clang
%bcond_without bisheng_autotuner
%if %{with toolchain_clang} %if %{with toolchain_clang}
%global toolchain clang %global toolchain clang
%endif %endif
%global maj_ver 17 %global maj_ver 18
%global min_ver 0 %global min_ver 1
%global patch_ver 6 %global patch_ver 8
%global clang_version %{maj_ver}.%{min_ver}.%{patch_ver} %global clang_version %{maj_ver}.%{min_ver}.%{patch_ver}
%if %{with sys_llvm} %global _scl_prefix /opt/openEuler
%global pkg_name clang %{?scl:%scl_package %scl}
%global install_prefix %{_prefix} %{!?scl:%global scl_prefix llvm-toolset-%{maj_ver}-}
%global install_datadir %{_datadir} %{!?scl:%global pkg_name %{name}}
%else %global install_prefix %{!?scl:%{_scl_prefix}/llvm-toolset-%{maj_ver}/root}%{_prefix}
%global pkg_name clang%{maj_ver} %global install_datadir %{!?scl:%{_scl_prefix}/llvm-toolset-%{maj_ver}/root}%{_datadir}
%global install_prefix %{_libdir}/llvm%{maj_ver}
%global install_datadir %{install_prefix}/share
%endif
%global install_bindir %{install_prefix}/bin %global install_bindir %{install_prefix}/bin
%global install_includedir %{install_prefix}/include %global install_includedir %{install_prefix}/include
@ -42,10 +35,11 @@
# Disable LTO as this causes crash if gcc lto enabled. # Disable LTO as this causes crash if gcc lto enabled.
%define _lto_cflags %{nil} %define _lto_cflags %{nil}
Name: %{pkg_name} Name: %{?scl_prefix}clang
Version: %{clang_version} Version: %{clang_version}
Release: 31 Release: 1
Summary: A C language family front-end for LLVM Summary: A C language family front-end for LLVM
License: NCSA License: NCSA
URL: http://llvm.org URL: http://llvm.org
Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_version}/%{clang_srcdir}.tar.xz Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_version}/%{clang_srcdir}.tar.xz
@ -53,32 +47,6 @@ Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{clang_
Patch0: fedora-PATCH-clang-Don-t-install-static-libraries.patch Patch0: fedora-PATCH-clang-Don-t-install-static-libraries.patch
Patch1: 0001-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch Patch1: 0001-Add-triples-for-X86_64-AArch64-Riscv64-openEuler-gcc.patch
Patch2: 0002-Revert-Clang-Change-the-default-DWARF-version-to-5.patch
Patch3: 0003-add-BUILD_FOR_OPENEULER-build-option-to-clang.patch
Patch4: 0004-add-gcc-compatible-in-BUILD_FOR_OPENEULER.patch
Patch5: 0005-backport-Disable-InterpreterExceptionTest-on-RISC-V.patch
Patch6: 0006-clang-LoongArch-Add-loongarch64-to-os-triple.patch
Patch7: 0007-add-more-warning-options-to-fgcc-compatible.patch
Patch8: 0008-Backport-LoongArch-Add-the-support-for-vector.patch
Patch9: 0009-Backport-LoongArch-improve-the-support-for-compiler-rt-and-bugfix.patch
Patch10: 0010-Backport-clang-Avoid-Wshadow-warning-when-init-capture-named.patch
Patch11: 0011-Add-the-support-for-classic-flang.patch
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
Patch21: 0021-AArch64-Delete-hip09-macro.patch
Patch22: 0022-Driver-Pass-z-arg-and-Wl-z-arg-option-to-the-linker.patch
Patch23: 0023-Handling-of-option-Wall-and-Werror-format-2-override.patch
Patch24: 0024-Backport-PATCH-Clang-CodeGen-Add__builtin_bcopy.patch
Patch25: 0025-clang-Increase-the-number-of-driver-diagnostics.patch
Patch26: 0026-Driver-add-option-fGNU-compatibility-aliased-with-fg.patch
Patch27: 0027-Driver-fix-compile-error-for-fGNU-compatibility.patch
# Patches for clang-tools-extra # Patches for clang-tools-extra
# See https://reviews.llvm.org/D120301 # See https://reviews.llvm.org/D120301
@ -89,21 +57,12 @@ BuildRequires: gcc-c++
BuildRequires: cmake BuildRequires: cmake
BuildRequires: libatomic BuildRequires: libatomic
%if %{with sys_llvm} BuildRequires: %{?scl_prefix}llvm-libs = %{version}
BuildRequires: llvm-libs = %{version} BuildRequires: %{?scl_prefix}llvm-devel = %{version}
BuildRequires: llvm-devel = %{version} BuildRequires: %{?scl_prefix}llvm-static = %{version}
BuildRequires: llvm-static = %{version} BuildRequires: %{?scl_prefix}llvm-test = %{version}
BuildRequires: llvm-test = %{version} BuildRequires: %{?scl_prefix}llvm-googletest = %{version}
BuildRequires: llvm-googletest = %{version} BuildRequires: %{?scl_prefix}llvm-cmake-utils = %{version}
BuildRequires: llvm-cmake-utils = %{version}
%else
BuildRequires: llvm%{maj_ver}-libs = %{version}
BuildRequires: llvm%{maj_ver}-devel = %{version}
BuildRequires: llvm%{maj_ver}-static = %{version}
BuildRequires: llvm%{maj_ver}-test = %{version}
BuildRequires: llvm%{maj_ver}-googletest = %{version}
BuildRequires: llvm%{maj_ver}-cmake-utils = %{version}
%endif
BuildRequires: libxml2-devel BuildRequires: libxml2-devel
BuildRequires: multilib-rpm-config BuildRequires: multilib-rpm-config
@ -112,7 +71,7 @@ BuildRequires: ncurses-devel
BuildRequires: perl-generators BuildRequires: perl-generators
BuildRequires: python3-lit >= %{version} BuildRequires: python3-lit >= %{version}
BuildRequires: python3-sphinx BuildRequires: python3-sphinx
BuildRequires: python3-recommonmark BuildRequires: python3-myst-parser
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: perl(Digest::MD5) BuildRequires: perl(Digest::MD5)
@ -129,17 +88,18 @@ BuildRequires: perl(Sys::Hostname)
%if %{with toolchain_clang} %if %{with toolchain_clang}
BuildRequires: clang BuildRequires: clang
%endif %endif
%{?scl:Requires: %scl_runtime}
Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires: %{pkg_name}-libs%{?_isa} = %{version}-%{release}
Requires: libstdc++-devel Requires: libstdc++-devel
# Require gcc libs installed during rumtime # Require gcc libs installed during rumtime
Requires: gcc Requires: gcc
Requires: gcc-c++ Requires: gcc-c++
Provides: clang(major) = %{maj_ver} Provides: %{pkg_name}(major) = %{maj_ver}
Conflicts: compiler-rt < 11.0.0 Conflicts: %{?scl_prefix}compiler-rt < 11.0.0
%description %description
clang: noun clang: noun
@ -157,35 +117,40 @@ libomp-devel to enable -fopenmp.
%package libs %package libs
Summary: Runtime library for clang Summary: Runtime library for clang
Requires: %{name}-resource-filesystem%{?_isa} = %{version} Requires: %{pkg_name}-resource-filesystem = %{version}
Recommends: compiler-rt%{?_isa} = %{version} Requires: %{?scl_prefix}llvm-libs = %{version}
Recommends: libatomic%{?_isa} Recommends: %{?scl_prefix}compiler-rt%{?_isa} = %{version}
Recommends: libomp-devel%{_isa} = %{version} Recommends: %{?scl_prefix}libatomic%{?_isa}
Recommends: libomp%{_isa} = %{version} Recommends: %{?scl_prefix}libomp-devel%{_isa} = %{version}
Recommends: %{?scl_prefix}libomp%{_isa} = %{version}
%description libs %description libs
Runtime library for clang. Runtime library for clang.
%package devel %package devel
Summary: Development header files for clang Summary: Development header files for clang
Requires: %{name}-libs = %{version}-%{release} Requires: %{pkg_name}-libs = %{version}-%{release}
Requires: %{pkg_name}%{?_isa} = %{version}-%{release}
# The clang CMake files reference tools from clang-tools-extra.
Requires: %{pkg_name}-tools-extra%{?_isa} = %{version}-%{release}
Provides: %{pkg_name}-devel(major) = %{maj_ver}
%description devel %description devel
Development header files for clang. Development header files for clang.
%package resource-filesystem %package resource-filesystem
Summary: Filesystem package that owns the clang resource directory Summary: Filesystem package that owns the clang resource directory
Provides: %{name}-resource-filesystem(major) = %{maj_ver} Provides: %{pkg_name}-resource-filesystem(major) = %{maj_ver}
BuildArch: noarch
%description resource-filesystem %description resource-filesystem
This package owns the clang resouce directory: $libdir/clang/$version/ This package owns the clang resouce directory: $libdir/clang/$version/
%package analyzer %package analyzer
Summary: A source code analysis framework Summary: A source code analysis framework
License: NCSA and MIT License: NCSA and MIT
BuildArch: noarch BuildArch: noarch
Requires: %{name} = %{version}-%{release} Requires: %{pkg_name} = %{version}-%{release}
%description analyzer %description analyzer
The Clang Static Analyzer consists of both a source code analysis The Clang Static Analyzer consists of both a source code analysis
@ -195,7 +160,7 @@ intended to run in tandem with a build of a project or code base.
%package tools-extra %package tools-extra
Summary: Extra tools for clang Summary: Extra tools for clang
Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires: %{pkg_name}-libs%{?_isa} = %{version}-%{release}
Requires: emacs-filesystem Requires: emacs-filesystem
%description tools-extra %description tools-extra
@ -203,18 +168,18 @@ A set of extra tools built using Clang's tooling API.
%package tools-extra-devel %package tools-extra-devel
Summary: Development header files for clang tools Summary: Development header files for clang tools
Requires: %{name}-tools-extra = %{version}-%{release} Requires: %{pkg_name}-tools-extra = %{version}-%{release}
%description tools-extra-devel %description tools-extra-devel
Development header files for clang tools. Development header files for clang tools.
%package -n git-clang-format %package -n %{?scl_prefix}git-clang-format
Summary: Integration of clang-format for git Summary: Integration of clang-format for git
Requires: %{name}-tools-extra = %{version}-%{release} Requires: %{pkg_name}-tools-extra = %{version}-%{release}
Requires: git Requires: git
Requires: python3 Requires: python3
%description -n git-clang-format %description -n %{?scl_prefix}git-clang-format
clang-format integration for git. clang-format integration for git.
%prep %prep
@ -242,11 +207,13 @@ pathfix.py -i %{__python3} -pn \
tools/scan-build-py/libexec/* tools/scan-build-py/libexec/*
%build %build
%cmake -G Ninja \ mkdir -p _build
cd _build
%cmake .. -G Ninja \
-DCLANG_DEFAULT_PIE_ON_LINUX=ON \ -DCLANG_DEFAULT_PIE_ON_LINUX=ON \
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \ -DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DPYTHON_EXECUTABLE=%{__python3} \ -DPYTHON_EXECUTABLE=%{__python3} \
-DCMAKE_SKIP_RPATH:BOOL=ON \ -DCMAKE_SKIP_RPATH:BOOL=ON \
-DCLANG_BUILD_TOOLS:BOOL=ON \ -DCLANG_BUILD_TOOLS:BOOL=ON \
@ -273,31 +240,28 @@ pathfix.py -i %{__python3} -pn \
-DCLANG_BUILD_EXAMPLES:BOOL=OFF \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \
-DBUILD_SHARED_LIBS=OFF \ -DBUILD_SHARED_LIBS=OFF \
-DCLANG_REPOSITORY_STRING="%{?distro} %{version}-%{release}" \ -DCLANG_REPOSITORY_STRING="%{?distro} %{version}-%{release}" \
-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=%{_vpath_srcdir}/../%{clang_tools_srcdir} \ -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../../%{clang_tools_srcdir} \
-DCLANG_RESOURCE_DIR=../%{_lib}/clang/%{maj_ver} \ %if 0%{?__isa_bits} == 64
-DCLANG_RESOURCE_DIR=../lib64/clang/%{maj_ver} \
%else
-DCLANG_RESOURCE_DIR=../lib/clang/%{maj_ver} \
%endif
%if 0%{?__isa_bits} == 64 %if 0%{?__isa_bits} == 64
-DLLVM_LIBDIR_SUFFIX=64 \ -DLLVM_LIBDIR_SUFFIX=64 \
%else %else
-DLLVM_LIBDIR_SUFFIX= \ -DLLVM_LIBDIR_SUFFIX= \
%endif %endif
%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" %if "%{toolchain}" == "clang"
-DCMAKE_C_COMPILER=clang \ -DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_COMPILER=clang++ \
%endif %endif
-DCLANG_DEFAULT_UNWINDLIB=libgcc -DCLANG_DEFAULT_UNWINDLIB=libgcc
%cmake_build %ninja_build
%install %install
%cmake_install %ninja_install -C _build
mkdir -p %{buildroot}/%{_bindir} mkdir -p %{buildroot}/%{_bindir}
rm -vf %{buildroot}%{_datadir}/clang/clang-format-bbedit.applescript rm -vf %{buildroot}%{_datadir}/clang/clang-format-bbedit.applescript
@ -313,10 +277,15 @@ rm -vf %{buildroot}%{install_sharedir}/clang/bash-autocomplete.sh
mkdir -p %{buildroot}%{install_libdir}/clang/%{maj_ver}/{bin,include,lib,share}/ mkdir -p %{buildroot}%{install_libdir}/clang/%{maj_ver}/{bin,include,lib,share}/
# Add a symlink in /usr/bin to clang-format-diff
ln -s %{install_datadir}/clang/clang-format-diff.py %{buildroot}%{install_bindir}/clang-format-diff
# Add clang++-{version} symlink
ln -s %{install_bindir}/clang++ %{buildroot}%{install_bindir}/clang++-%{maj_ver}
%check %check
%if %{with check} %if %{with check}
# requires lit.py from LLVM utilities
LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake_builddir} LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build/
%endif %endif
%files %files
@ -324,12 +293,10 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmak
%{install_bindir}/clang %{install_bindir}/clang
%{install_bindir}/clang++ %{install_bindir}/clang++
%{install_bindir}/clang-%{maj_ver} %{install_bindir}/clang-%{maj_ver}
%{install_bindir}/clang++-%{maj_ver}
%{install_bindir}/clang-cl %{install_bindir}/clang-cl
%{install_bindir}/clang-cpp %{install_bindir}/clang-cpp
%{install_prefix}/share/man/man1/* %{install_prefix}/share/man/man1/*
%if %{with classic_flang}
%{install_bindir}/flang
%endif
%files libs %files libs
%{install_libdir}/*.so.* %{install_libdir}/*.so.*
@ -340,15 +307,16 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmak
%{install_includedir}/clang/ %{install_includedir}/clang/
%{install_includedir}/clang-c/ %{install_includedir}/clang-c/
%{install_libdir}/cmake/* %{install_libdir}/cmake/*
%{_bindir}/clang-tblgen %{install_bindir}/clang-tblgen
%dir %{_datadir}/clang/ %dir %{install_datadir}/clang/
%files resource-filesystem %files resource-filesystem
%dir %{install_libdir}/clang/
%dir %{install_libdir}/clang/%{maj_ver}/ %dir %{install_libdir}/clang/%{maj_ver}/
%dir %{install_libdir}/clang/%{maj_ver}/bin/
%dir %{install_libdir}/clang/%{maj_ver}/include/ %dir %{install_libdir}/clang/%{maj_ver}/include/
%dir %{install_libdir}/clang/%{maj_ver}/lib/ %dir %{install_libdir}/clang/%{maj_ver}/lib/
%dir %{install_libdir}/clang/%{maj_ver}/share/ %dir %{install_libdir}/clang/%{maj_ver}/share/
%dir %{install_libdir}/clang/
%files analyzer %files analyzer
%{install_libexecdir}/ccc-analyzer %{install_libexecdir}/ccc-analyzer
@ -399,6 +367,7 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmak
%{install_bindir}/pp-trace %{install_bindir}/pp-trace
%{install_bindir}/find-all-symbols %{install_bindir}/find-all-symbols
%{install_bindir}/modularize %{install_bindir}/modularize
%{install_bindir}/clang-format-diff
%{install_bindir}/run-clang-tidy %{install_bindir}/run-clang-tidy
%{install_sharedir}/clang/clang-format.el %{install_sharedir}/clang/clang-format.el
%{install_sharedir}/clang/clang-rename.el %{install_sharedir}/clang/clang-rename.el
@ -413,10 +382,13 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmak
%files tools-extra-devel %files tools-extra-devel
%{install_includedir}/clang-tidy/ %{install_includedir}/clang-tidy/
%files -n git-clang-format %files -n %{?scl_prefix}git-clang-format
%{install_bindir}/git-clang-format %{install_bindir}/git-clang-format
%changelog %changelog
* Fri Dec 6 2024 liyunfei <liyunfei33@huawei.com> - 18.1.8-1
- init for Multi-Version LLVM-18.1.8
* Thu Nov 21 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-31 * Thu Nov 21 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-31
- Add option -fGNU-compatibility - Add option -fGNU-compatibility

View File

@ -1,4 +0,0 @@
version_control: github
src_repo: llvm/llvm-project
tag_prefix: ^llvmorg-
separator: .