Projects
Mega:23.09
clang
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 14
View file
_service:tar_scm:clang.spec
Changed
@@ -1,5 +1,6 @@ %bcond_without sys_llvm %bcond_without check +%bcond_with classic_flang %global maj_ver 17 %global min_ver 0 @@ -36,7 +37,7 @@ Name: %{pkg_name} Version: %{clang_version} -Release: 10 +Release: 15 Summary: A C language family front-end for LLVM License: NCSA @@ -52,6 +53,11 @@ 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 # Patches for clang-tools-extra # See https://reviews.llvm.org/D120301 @@ -256,6 +262,9 @@ %else -DLLVM_LIBDIR_SUFFIX= \ %endif +%if %{with classic_flang} + -DLLVM_ENABLE_CLASSIC_FLANG=ON \ +%endif -DBUILD_FOR_OPENEULER=ON \ -DCLANG_DEFAULT_UNWINDLIB=libgcc @@ -293,6 +302,9 @@ %{install_bindir}/clang-cl %{install_bindir}/clang-cpp %{install_prefix}/share/man/man1/* +%if %{with classic_flang} +%{install_bindir}/flang +%endif %files libs %{install_libdir}/*.so.* @@ -380,6 +392,21 @@ %{install_bindir}/git-clang-format %changelog +* Wed Apr 17 2024 luofeng <luofeng13@huawei.com> -17.0.6-15 +- Add the support for classic flang + +* Tue Apr 16 2024 wangqiang <wangqiang1@kylinos.cn> -17.0.6-14 +- Avoid -Wshadow warning when init-capture named same as class field. + +* Sat Apr 13 2024 liyunfei <liyunfei33@huawei.com> -17.0.6-13 +- Add more warning options to BUILD_FOR_OPENEULER gcc compatible part 3. + +* Tue Apr 09 2024 zhanglimin <zhanglimin@loongson.cn> - 17.0.6-12 +- Improve the support for compiler-rt and fix some bugs on LoongArch. + +* Fri Mar 29 2024 zhanglimin <zhanglimin@loongson.cn> -17.0.6-11 +- Add the support for vector on LoongArch. + * Thu Mar 28 2024 liyunfei <liyunfei33@huawei.com> -17.0.6-10 - Add more warning options to BUILD_FOR_OPENEULER gcc compatible part 2.
View file
_service:tar_scm:0007-add-more-warning-options-to-fgcc-compatible.patch
Changed
@@ -5,13 +5,13 @@ --- clang/lib/Driver/ToolChains/Clang.cpp | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) + 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,37 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, +@@ -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)) { @@ -41,11 +41,16 @@ + 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
View file
_service:tar_scm:0008-Backport-LoongArch-Add-the-support-for-vector.patch
Added
@@ -0,0 +1,67252 @@ +From 6ff32ae0ca7a400249535b19d9ca489b44deae19 Mon Sep 17 00:00:00 2001 +From: wanglei <wanglei@loongson.cn> +Date: Wed, 9 Aug 2023 16:01:37 +0800 +Subject: PATCH 1/8 ClangLoongArch Use the ClangBuiltin class to + automatically generate support for CBE and CFE + +Fixed the type modifier (L->W), removed redundant feature checking code +since the feature has already been checked in `EmitBuiltinExpr`. And +Cleaned up unused diagnostic information. + +Reviewed By: SixWeining + +Differential Revision: https://reviews.llvm.org/D156866 + +(cherry picked from commit ea8d3b1f9f2d7385d97fcd34d14db0eb2cb2795c) +--- + .../include/clang/Basic/BuiltinsLoongArch.def | 25 ++-- + .../clang/Basic/DiagnosticSemaKinds.td | 7 - + clang/lib/CodeGen/CGBuiltin.cpp | 130 ------------------ + clang/lib/CodeGen/CodeGenFunction.h | 1 - + clang/lib/Sema/SemaChecking.cpp | 50 +------ + .../CodeGen/LoongArch/intrinsic-la32-error.c | 118 +++++++--------- + 6 files changed, 64 insertions(+), 267 deletions(-) + +diff --git a/clang/include/clang/Basic/BuiltinsLoongArch.def b/clang/include/clang/Basic/BuiltinsLoongArch.def +index 7f2c8403410d..20510e18fe58 100644 +--- a/clang/include/clang/Basic/BuiltinsLoongArch.def ++++ b/clang/include/clang/Basic/BuiltinsLoongArch.def +@@ -16,8 +16,7 @@ + #endif + + // TODO: Support more builtins. +-// TODO: Added feature constraints. +-TARGET_BUILTIN(__builtin_loongarch_cacop_d, "vLiULiLi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_cacop_d, "vWiUWiWi", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_cacop_w, "viUii", "nc", "32bit") + TARGET_BUILTIN(__builtin_loongarch_dbar, "vIUi", "nc", "") + TARGET_BUILTIN(__builtin_loongarch_ibar, "vIUi", "nc", "") +@@ -26,36 +25,36 @@ TARGET_BUILTIN(__builtin_loongarch_movgr2fcsr, "vIUiUi", "nc", "f") + TARGET_BUILTIN(__builtin_loongarch_break, "vIUi", "nc", "") + TARGET_BUILTIN(__builtin_loongarch_syscall, "vIUi", "nc", "") + TARGET_BUILTIN(__builtin_loongarch_cpucfg, "UiUi", "nc", "") +-TARGET_BUILTIN(__builtin_loongarch_asrtle_d, "vLiLi", "nc", "64bit") +-TARGET_BUILTIN(__builtin_loongarch_asrtgt_d, "vLiLi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_asrtle_d, "vWiWi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_asrtgt_d, "vWiWi", "nc", "64bit") + + TARGET_BUILTIN(__builtin_loongarch_crc_w_b_w, "iii", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_crc_w_h_w, "iii", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_crc_w_w_w, "iii", "nc", "64bit") +-TARGET_BUILTIN(__builtin_loongarch_crc_w_d_w, "iLii", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_crc_w_d_w, "iWii", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_crcc_w_b_w, "iii", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_crcc_w_h_w, "iii", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_crcc_w_w_w, "iii", "nc", "64bit") +-TARGET_BUILTIN(__builtin_loongarch_crcc_w_d_w, "iLii", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_crcc_w_d_w, "iWii", "nc", "64bit") + + TARGET_BUILTIN(__builtin_loongarch_csrrd_w, "UiIUi", "nc", "") +-TARGET_BUILTIN(__builtin_loongarch_csrrd_d, "ULiIUi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_csrrd_d, "UWiIUi", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_csrwr_w, "UiUiIUi", "nc", "") +-TARGET_BUILTIN(__builtin_loongarch_csrwr_d, "ULiULiIUi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_csrwr_d, "UWiUWiIUi", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_csrxchg_w, "UiUiUiIUi", "nc", "") +-TARGET_BUILTIN(__builtin_loongarch_csrxchg_d, "ULiULiULiIUi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_csrxchg_d, "UWiUWiUWiIUi", "nc", "64bit") + + TARGET_BUILTIN(__builtin_loongarch_iocsrrd_b, "UiUi", "nc", "") + TARGET_BUILTIN(__builtin_loongarch_iocsrrd_h, "UiUi", "nc", "") + TARGET_BUILTIN(__builtin_loongarch_iocsrrd_w, "UiUi", "nc", "") +-TARGET_BUILTIN(__builtin_loongarch_iocsrrd_d, "ULiUi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_iocsrrd_d, "UWiUi", "nc", "64bit") + TARGET_BUILTIN(__builtin_loongarch_iocsrwr_b, "vUiUi", "nc", "") + TARGET_BUILTIN(__builtin_loongarch_iocsrwr_h, "vUiUi", "nc", "") + TARGET_BUILTIN(__builtin_loongarch_iocsrwr_w, "vUiUi", "nc", "") +-TARGET_BUILTIN(__builtin_loongarch_iocsrwr_d, "vULiUi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_iocsrwr_d, "vUWiUi", "nc", "64bit") + +-TARGET_BUILTIN(__builtin_loongarch_lddir_d, "LiLiIULi", "nc", "64bit") +-TARGET_BUILTIN(__builtin_loongarch_ldpte_d, "vLiIULi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_lddir_d, "WiWiIUWi", "nc", "64bit") ++TARGET_BUILTIN(__builtin_loongarch_ldpte_d, "vWiIUWi", "nc", "64bit") + + #undef BUILTIN + #undef TARGET_BUILTIN +diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td +index c88f25209fc0..0e97620945af 100644 +--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td ++++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td +@@ -11853,10 +11853,6 @@ def err_non_designated_init_used : Error< + def err_cast_from_randomized_struct : Error< + "casting from randomized structure pointer type %0 to %1">; + +-// LoongArch-specific Diagnostics +-def err_loongarch_builtin_requires_la64 : Error< +- "this builtin requires target: loongarch64">; +- + // Unsafe buffer usage diagnostics. + def warn_unsafe_buffer_variable : Warning< + "%0 is an %select{unsafe pointer used for buffer access|unsafe buffer that " +@@ -11872,9 +11868,6 @@ def note_unsafe_buffer_variable_fixit_group : Note< + "change type of %0 to '%select{std::span|std::array|std::span::iterator}1' to preserve bounds information%select{|, and change %2 to '%select{std::span|std::array|std::span::iterator}1' to propagate bounds information between them}3">; + def note_safe_buffer_usage_suggestions_disabled : Note< + "pass -fsafe-buffer-usage-suggestions to receive code hardening suggestions">; +-def err_loongarch_builtin_requires_la32 : Error< +- "this builtin requires target: loongarch32">; +- + def err_builtin_pass_in_regs_non_class : Error< + "argument %0 is not an unqualified class type">; + +diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp +index 30f5f4e7061c..e512762fafaf 100644 +--- a/clang/lib/CodeGen/CGBuiltin.cpp ++++ b/clang/lib/CodeGen/CGBuiltin.cpp +@@ -43,7 +43,6 @@ + #include "llvm/IR/IntrinsicsARM.h" + #include "llvm/IR/IntrinsicsBPF.h" + #include "llvm/IR/IntrinsicsHexagon.h" +-#include "llvm/IR/IntrinsicsLoongArch.h" + #include "llvm/IR/IntrinsicsNVPTX.h" + #include "llvm/IR/IntrinsicsPowerPC.h" + #include "llvm/IR/IntrinsicsR600.h" +@@ -5588,9 +5587,6 @@ static Value *EmitTargetArchBuiltinExpr(CodeGenFunction *CGF, + case llvm::Triple::riscv32: + case llvm::Triple::riscv64: + return CGF->EmitRISCVBuiltinExpr(BuiltinID, E, ReturnValue); +- case llvm::Triple::loongarch32: +- case llvm::Triple::loongarch64: +- return CGF->EmitLoongArchBuiltinExpr(BuiltinID, E); + default: + return nullptr; + } +@@ -20418,129 +20414,3 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID, + llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); + return Builder.CreateCall(F, Ops, ""); + } +- +-Value *CodeGenFunction::EmitLoongArchBuiltinExpr(unsigned BuiltinID, +- const CallExpr *E) { +- SmallVector<Value *, 4> Ops; +- +- for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) +- Ops.push_back(EmitScalarExpr(E->getArg(i))); +- +- Intrinsic::ID ID = Intrinsic::not_intrinsic; +- +- switch (BuiltinID) { +- default: +- llvm_unreachable("unexpected builtin ID."); +- case LoongArch::BI__builtin_loongarch_cacop_d: +- ID = Intrinsic::loongarch_cacop_d; +- break; +- case LoongArch::BI__builtin_loongarch_cacop_w: +- ID = Intrinsic::loongarch_cacop_w; +- break; +- case LoongArch::BI__builtin_loongarch_dbar: +- ID = Intrinsic::loongarch_dbar; +- break; +- case LoongArch::BI__builtin_loongarch_break: +- ID = Intrinsic::loongarch_break; +- break; +- case LoongArch::BI__builtin_loongarch_ibar: +- ID = Intrinsic::loongarch_ibar; +- break; +- case LoongArch::BI__builtin_loongarch_movfcsr2gr: +- ID = Intrinsic::loongarch_movfcsr2gr; +- break; +- case LoongArch::BI__builtin_loongarch_movgr2fcsr: +- ID = Intrinsic::loongarch_movgr2fcsr; +- break; +- case LoongArch::BI__builtin_loongarch_syscall: +- ID = Intrinsic::loongarch_syscall; +- break; +- case LoongArch::BI__builtin_loongarch_crc_w_b_w: +- ID = Intrinsic::loongarch_crc_w_b_w; +- break; +- case LoongArch::BI__builtin_loongarch_crc_w_h_w: +- ID = Intrinsic::loongarch_crc_w_h_w; +- break; +- case LoongArch::BI__builtin_loongarch_crc_w_w_w: +- ID = Intrinsic::loongarch_crc_w_w_w; +- break; +- case LoongArch::BI__builtin_loongarch_crc_w_d_w: +- ID = Intrinsic::loongarch_crc_w_d_w; +- break; +- case LoongArch::BI__builtin_loongarch_crcc_w_b_w: +- ID = Intrinsic::loongarch_crcc_w_b_w; +- break; +- case LoongArch::BI__builtin_loongarch_crcc_w_h_w: +- ID = Intrinsic::loongarch_crcc_w_h_w; +- break; +- case LoongArch::BI__builtin_loongarch_crcc_w_w_w: +- ID = Intrinsic::loongarch_crcc_w_w_w; +- break; +- case LoongArch::BI__builtin_loongarch_crcc_w_d_w: +- ID = Intrinsic::loongarch_crcc_w_d_w; +- break; +- case LoongArch::BI__builtin_loongarch_csrrd_w:
View file
_service:tar_scm:0009-Backport-LoongArch-improve-the-support-for-compiler-rt-and-bugfix.patch
Added
@@ -0,0 +1,639 @@ +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 ClangLoongArch 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 LoongArchtest 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 i0; }; ++struct s12 test_s12(struct s12 a) { ++ return a; ++} ++ ++// CHECK-C: define{{.*}} void @test_s13() ++// CHECK-CXX: define{{.*}} void @_Z8test_s133s13() ++struct s13 { struct { } s0; }; ++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 { } s1; }; ++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
View file
_service:tar_scm:0010-Backport-clang-Avoid-Wshadow-warning-when-init-capture-named.patch
Added
@@ -0,0 +1,255 @@ +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}}
View file
_service:tar_scm:0011-Add-the-support-for-classic-flang.patch
Added
@@ -0,0 +1,4031 @@ +From 3d36d3891f2a654d5ec2a0ce3c2ff47b597d1c42 Mon Sep 17 00:00:00 2001 +From: luofeng14 <luofeng13@huawei.com> +Date: Mon, 11 Mar 2024 21:25:03 +0800 +Subject: PATCH sync classic flang patch + +--- + clang/CMakeLists.txt | 5 + + clang/include/clang/Basic/CodeGenOptions.h | 3 + + .../clang/Basic/DiagnosticDriverKinds.td | 6 + + clang/include/clang/Basic/MacroBuilder.h | 3 +- + clang/include/clang/Basic/Sanitizers.def | 2 + + clang/include/clang/Driver/CMakeLists.txt | 13 +- + clang/include/clang/Driver/Options.td | 197 ++- + clang/include/clang/Driver/ToolChain.h | 17 + + clang/include/clang/Driver/Types.def | 7 + + clang/include/clang/Driver/Types.h | 8 + + clang/include/clang/Frontend/Utils.h | 32 + + clang/lib/CodeGen/BackendUtil.cpp | 6 + + clang/lib/CodeGen/CGDebugInfo.cpp | 10 +- + clang/lib/Driver/CMakeLists.txt | 8 +- + clang/lib/Driver/Driver.cpp | 60 +- + clang/lib/Driver/OffloadBundler.cpp | 4 + + clang/lib/Driver/ToolChain.cpp | 36 +- + clang/lib/Driver/ToolChains/Clang.cpp | 60 + + clang/lib/Driver/ToolChains/ClassicFlang.cpp | 1217 +++++++++++++++++ + clang/lib/Driver/ToolChains/ClassicFlang.h | 49 + + clang/lib/Driver/ToolChains/CommonArgs.cpp | 69 +- + clang/lib/Driver/ToolChains/CommonArgs.h | 20 + + clang/lib/Driver/ToolChains/Cuda.cpp | 35 + + clang/lib/Driver/ToolChains/Cuda.h | 5 + + clang/lib/Driver/ToolChains/Darwin.cpp | 4 + + clang/lib/Driver/ToolChains/Gnu.cpp | 4 + + clang/lib/Driver/ToolChains/Linux.cpp | 190 +++ + clang/lib/Driver/ToolChains/Linux.h | 5 + + clang/lib/Driver/ToolChains/MSVC.cpp | 115 ++ + clang/lib/Driver/ToolChains/MSVC.h | 11 + + clang/lib/Driver/ToolChains/MinGW.cpp | 4 + + clang/lib/Driver/Types.cpp | 50 + + clang/lib/Frontend/InitPreprocessor.cpp | 20 - + clang/test/CMakeLists.txt | 1 + + .../test/CodeGen/libpgmath-logfun-aarch64.ll | 58 + + clang/test/CodeGen/libpgmath-logfun-x86_64.ll | 57 + + clang/test/Driver/autocomplete.c | 2 +- + clang/test/Driver/emit-flang-attrs.f90 | 58 + + .../test/Driver/flang/Inputs/llvm-ir-input.ll | 0 + .../flang/classic-flang-emit-flang-llvm.f95 | 10 + + .../flang/classic-flang-fp-contract.f95 | 27 + + .../flang/classic-flang-must-preprocess.F | 12 + + .../flang/classic-flang-must-preprocess.F95 | 12 + + .../test/Driver/flang/classic-flang-version.f | 3 + + .../flang/classic-flang-vscale-mbits.f95 | 28 + + .../Driver/flang/classic-flang-vscale.f95 | 28 + + clang/test/Driver/flang/classic-flang.f | 26 + + clang/test/Driver/flang/classic-flang.f95 | 120 ++ + clang/test/Driver/flang/flang.f90 | 2 + + clang/test/Driver/flang/flang_ucase.F90 | 2 + + clang/test/Driver/flang/llvm-ir-input.f | 7 + + .../Driver/flang/multiple-inputs-mixed.f90 | 2 + + clang/test/Driver/flang/multiple-inputs.f90 | 2 + + clang/test/Driver/flang/reassoc.f90 | 59 + + clang/test/Driver/fortran-phases.f90 | 119 ++ + clang/test/Driver/fortran-preprocessor.f90 | 48 + + clang/test/Driver/fortran.f95 | 2 + + clang/test/Driver/gfortran.f90 | 1 + + clang/test/Driver/lit.local.cfg | 3 + + clang/test/lit.cfg.py | 3 + + clang/test/lit.site.cfg.py.in | 1 + + clang/tools/driver/CMakeLists.txt | 2 +- + 62 files changed, 2933 insertions(+), 37 deletions(-) + create mode 100644 clang/lib/Driver/ToolChains/ClassicFlang.cpp + create mode 100644 clang/lib/Driver/ToolChains/ClassicFlang.h + mode change 100644 => 100755 clang/lib/Driver/Types.cpp + create mode 100644 clang/test/CodeGen/libpgmath-logfun-aarch64.ll + create mode 100644 clang/test/CodeGen/libpgmath-logfun-x86_64.ll + create mode 100644 clang/test/Driver/emit-flang-attrs.f90 + create mode 100644 clang/test/Driver/flang/Inputs/llvm-ir-input.ll + create mode 100644 clang/test/Driver/flang/classic-flang-emit-flang-llvm.f95 + create mode 100644 clang/test/Driver/flang/classic-flang-fp-contract.f95 + create mode 100644 clang/test/Driver/flang/classic-flang-must-preprocess.F + create mode 100644 clang/test/Driver/flang/classic-flang-must-preprocess.F95 + create mode 100644 clang/test/Driver/flang/classic-flang-version.f + create mode 100644 clang/test/Driver/flang/classic-flang-vscale-mbits.f95 + create mode 100644 clang/test/Driver/flang/classic-flang-vscale.f95 + create mode 100644 clang/test/Driver/flang/classic-flang.f + create mode 100644 clang/test/Driver/flang/classic-flang.f95 + create mode 100644 clang/test/Driver/flang/llvm-ir-input.f + create mode 100644 clang/test/Driver/flang/reassoc.f90 + create mode 100644 clang/test/Driver/fortran-phases.f90 + create mode 100644 clang/test/Driver/fortran-preprocessor.f90 + +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index d558b0522e82..949f12d3ce8c 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -392,6 +392,11 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + endif() + endif() + ++option(LLVM_ENABLE_CLASSIC_FLANG "Build support for classic Flang instead of the new built-in Flang" OFF) ++if(LLVM_ENABLE_CLASSIC_FLANG) ++ add_definitions( -DENABLE_CLASSIC_FLANG ) ++endif() ++ + option(CLANG_BUILD_TOOLS + "Build the Clang tools. If OFF, just generate build targets." ON) + +diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h +index 14fc94fe27f9..41577b97e030 100644 +--- a/clang/include/clang/Basic/CodeGenOptions.h ++++ b/clang/include/clang/Basic/CodeGenOptions.h +@@ -59,6 +59,9 @@ public: + Accelerate, // Use the Accelerate framework. + LIBMVEC, // GLIBC vector math library. + MASSV, // IBM MASS vector library. ++#ifdef ENABLE_CLASSIC_FLANG ++ PGMATH, // PGI math library. ++#endif + SVML, // Intel short vector math library. + SLEEF, // SLEEF SIMD Library for Evaluating Elementary Functions. + Darwin_libsystem_m, // Use Darwin's libsytem_m vector functions. +diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td +index 1b69324d073a..09a1949d7596 100644 +--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td ++++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td +@@ -131,6 +131,10 @@ 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'">; ++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'">; + def err_drv_unsupported_rtlib_for_platform : Error< + "unsupported runtime library '%0' for platform '%1'">; + def err_drv_invalid_unwindlib_name : Error< +@@ -354,6 +358,8 @@ 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">; ++def err_drv_clang_unsupported_minfo_arg : Error< ++ "'%0' option does not support '%1' value">; + + 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 96e67cbbfa3f..bfc5e38c15e3 100644 +--- a/clang/include/clang/Basic/MacroBuilder.h ++++ b/clang/include/clang/Basic/MacroBuilder.h +@@ -24,9 +24,10 @@ class MacroBuilder { + raw_ostream &Out; + public: + MacroBuilder(raw_ostream &Output) : Out(Output) {} ++ virtual ~MacroBuilder() {} + + /// Append a \#define line for macro of the form "\#define Name Value\n". +- void defineMacro(const Twine &Name, const Twine &Value = "1") { ++ virtual void defineMacro(const Twine &Name, const Twine &Value = "1") { + Out << "#define " << Name << ' ' << Value << '\n'; + } + +diff --git a/clang/include/clang/Basic/Sanitizers.def b/clang/include/clang/Basic/Sanitizers.def +index c2137e3f61f6..4f0a2bf332ef 100644 +--- a/clang/include/clang/Basic/Sanitizers.def ++++ b/clang/include/clang/Basic/Sanitizers.def +@@ -107,6 +107,8 @@ SANITIZER("signed-integer-overflow", SignedIntegerOverflow) + SANITIZER("unreachable", Unreachable) + SANITIZER("vla-bound", VLABound) + SANITIZER("vptr", Vptr) ++// fortran contiguous pointer checks ++SANITIZER("discontiguous", Discontiguous) + + // IntegerSanitizer + SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow) +diff --git a/clang/include/clang/Driver/CMakeLists.txt b/clang/include/clang/Driver/CMakeLists.txt +index ea55ba0f1f27..8c0af1528a96 100644 +--- a/clang/include/clang/Driver/CMakeLists.txt ++++ b/clang/include/clang/Driver/CMakeLists.txt +@@ -1,7 +1,14 @@ + set(LLVM_TARGET_DEFINITIONS Options.td) ++ ++set(CLANG_DRIVER_OPTIONS) + if (BUILD_FOR_OPENEULER) +-tablegen(LLVM Options.inc -gen-opt-parser-defs -DBUILD_FOR_OPENEULER) +-else() +-tablegen(LLVM Options.inc -gen-opt-parser-defs) ++ list(APPEND CLANG_DRIVER_OPTIONS -DBUILD_FOR_OPENEULER ) + endif() ++ ++if (LLVM_ENABLE_CLASSIC_FLANG) ++ list(APPEND CLANG_DRIVER_OPTIONS -DENABLE_CLASSIC_FLANG ) ++endif() ++ ++tablegen(LLVM Options.inc ${CLANG_DRIVER_OPTIONS} -gen-opt-parser-defs ) ++ + add_public_tablegen_target(ClangDriverOptions) +diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td +index d4f7315bf8cb..365285966a67 100644 +--- a/clang/include/clang/Driver/Options.td ++++ b/clang/include/clang/Driver/Options.td
View file
_service:tar_scm:0012-Fix-declaration-definition-mismatch-for-classic-flang.patch
Added
@@ -0,0 +1,326 @@ +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); + } + DeclCacheD->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 =
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2