[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)
https://github.com/MaskRay requested changes to this pull request. . https://github.com/llvm/llvm-project/pull/109080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)
MaskRay wrote: I understand the intention to generalize naming, but I feel that there is significance chance that the over-generalization may not work with the alternative CFI schemes, and this change could turn out to be needed when the other schemes go with different IR constructs. I feel that we should make such renaming at this time. BTW: when kcfi was proposed, I felt that it was not a good name because the strategy could only cover a very limited subset of LTO-based `-fsanitize=cfi`. kcfi is just like a brand name. https://github.com/llvm/llvm-project/pull/109080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (PR #109278)
MaskRay wrote: > > Just to be certain: the revised version of the patch is ok to commit? > > I think it would be good to get an ACK from at least one of the SPARC Leon > maintainers. > > CC @andreas-gaisler Thanks for informing the maintainer. Note: this is done as a courtesy. When we bump a setting -mcpu= for good reasons, we do not add exception code like `!isVendorA() && !isVendorB()`. clangDriver is moving out of business to hard code such vendor details and requires adoption of Clang configuration files. https://github.com/llvm/llvm-project/pull/109278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)
@@ -0,0 +1,24 @@ +// The -time option prints timing information for the various subcommands in a +// format similar to that used by gcc. When compiling and linking, this will +// include the time to call clang-${LLVM_VERSION_MAJOR} and the linker. Since +// the name of the linker could vary across platforms, and name of the compiler +// could be something different, just check that whatever is printed to stderr +// looks like timing information. + +// RUN: %clang -time -c -O3 -o /dev/null %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY +// RUN: %clang -time -S -emit-llvm -O3 -o /dev/null %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY +// RUN: %clang -time -S -O3 -o /dev/null %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY +// RUN: %clang -time -O3 -o /dev/null %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=COMPILE-AND-LINK + +// COMPILE-ONLY: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}} MaskRay wrote: add `COMPILE-ONLY-NOT: {{.}}` to ensure that there is one single line https://github.com/llvm/llvm-project/pull/109165 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)
@@ -0,0 +1,24 @@ +// The -time option prints timing information for the various subcommands in a +// format similar to that used by gcc. When compiling and linking, this will +// include the time to call clang-${LLVM_VERSION_MAJOR} and the linker. Since +// the name of the linker could vary across platforms, and name of the compiler +// could be something different, just check that whatever is printed to stderr +// looks like timing information. + +// RUN: %clang -time -c -O3 -o /dev/null %s 2>&1 \ MaskRay wrote: This requires a hard-coded target triple like `--target=x86_64` and `REQUIRES: x86-registered-target`. Delete unneeded -O3. https://github.com/llvm/llvm-project/pull/109165 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (PR #109278)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/109278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV] Fix incorrect check prefix in riscv32-toolchain.c and riscv64-toolchain.c. NFC. (PR #109390)
https://github.com/MaskRay approved this pull request. You can use `[test]` instead of `. NFC.` `-SAME: ` is preferred when testing a string on the same line https://github.com/llvm/llvm-project/pull/109390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (PR #109278)
MaskRay wrote: We try to restrict distribution differences to things like default linker options and library paths. Affecting `-mcpu=` seems very unintuitive. There are many Debian derivatives. It's weird that Debian uses -mcpu=v9 while others use -mcpu=v8. We should not increase `IsDebian` or `IsGentoo` use. If -mcpu=v9 seems the right thing for the majority of configurations, we can bump -mcpu=v9 for all Linux and ask other, older systems to use https://clang.llvm.org/docs/UsersManual.html#configuration-files to specify `-mcpu=v8`. https://github.com/llvm/llvm-project/pull/109278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Add cc1 --output-asm-variant= to set output syntax (PR #109360)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/109360 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Add cc1 --output-asm-variant= to set output syntax (PR #109360)
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/109360 2fcaa549a824efeb56e807fcf750a56bf985296b (2010) added cc1as option `-output-asm-variant` (untested) to set the output syntax. `clang -cc1as -filetype asm -output-asm-variant 1` allows AT&T input and Intel output. This patch renames the cc1as option (to avoid collision with -o) and makes it available for cc1 to set output syntax. This allows different input & output syntax: ``` echo 'asm("mov $1, %eax");' | clang -xc - -S -o - -Xclang --output-asm-variant=1 ``` Note: `AsmWriterFlavor` (with a misleading name), used to initialize MCAsmInfo::AssemblerDialect, is primarily used for assembly input, not for output. >From 7be5f9edad29769ae5bf2a49e861afed0c984014 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 19 Sep 2024 19:00:08 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td | 5 ++-- clang/lib/CodeGen/BackendUtil.cpp | 2 ++ .../test/CodeGen/inline-asm-output-variant.c | 26 +++ clang/test/Misc/cc1as-output-asm-variant.c| 8 ++ llvm/include/llvm/MC/MCTargetOptions.h| 2 ++ llvm/lib/CodeGen/LLVMTargetMachine.cpp| 4 ++- 7 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 clang/test/CodeGen/inline-asm-output-variant.c create mode 100644 clang/test/Misc/cc1as-output-asm-variant.c diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index b600198998d85b..2893377e5a38be 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -96,6 +96,7 @@ CODEGENOPT(EmulatedTLS , 1, 0) ///< Set by default or -f[no-]emulated-tls. ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off) /// Inline asm dialect, -masm=(att|intel) ENUM_CODEGENOPT(InlineAsmDialect, InlineAsmDialectKind, 1, IAD_ATT) +CODEGENOPT(OutputAsmVariant, 2, 3) ///< Set the asm variant for output (3: unspecified). CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard variables ///< are required. CODEGENOPT(FunctionSections , 1, 0) ///< Set when -ffunction-sections is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index aa3ae92fb6ae78..2586782f3e3181 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -7209,6 +7209,9 @@ def fuse_ctor_homing: Flag<["-"], "fuse-ctor-homing">, def as_secure_log_file : Separate<["-"], "as-secure-log-file">, HelpText<"Emit .secure_log_unique directives to this filename.">, MarshallingInfoString>; +def output_asm_variant : Joined<["--"], "output-asm-variant=">, + HelpText<"Select the asm variant (integer) to use for output">, + MarshallingInfoInt>; } // let Visibility = [CC1Option, CC1AsOption] @@ -8303,8 +8306,6 @@ def filetype : Separate<["-"], "filetype">, HelpText<"Specify the output file type ('asm', 'null', or 'obj')">; // Transliterate Options -def output_asm_variant : Separate<["-"], "output-asm-variant">, -HelpText<"Select the asm variant index to use for output">; def show_encoding : Flag<["-"], "show-encoding">, HelpText<"Show instruction encoding information in transliterate mode">; def show_inst : Flag<["-"], "show-inst">, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index fa49763e312f13..916c92adb89309 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -509,6 +509,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, Options.MCOptions.X86RelaxRelocations = CodeGenOpts.X86RelaxRelocations; Options.MCOptions.CompressDebugSections = CodeGenOpts.getCompressDebugSections(); + if (CodeGenOpts.OutputAsmVariant != 3) // 3 (default): not specified +Options.MCOptions.OutputAsmVariant = CodeGenOpts.OutputAsmVariant; Options.MCOptions.ABIName = TargetOpts.ABI; for (const auto &Entry : HSOpts.UserEntries) if (!Entry.IsFramework && diff --git a/clang/test/CodeGen/inline-asm-output-variant.c b/clang/test/CodeGen/inline-asm-output-variant.c new file mode 100644 index 00..5fc5c1cc09b016 --- /dev/null +++ b/clang/test/CodeGen/inline-asm-output-variant.c @@ -0,0 +1,26 @@ +// REQUIRES: x86-registered-target +/// AT&T input +// RUN: %clang_cc1 -triple x86_64 -S --output-asm-variant=0 %s -o - | FileCheck --check-prefix=ATT %s +// RUN: %clang_cc1 -triple x86_64 -S --output-asm-variant=1 %s -o - | FileCheck --check-prefix=INTEL %s + +/// Intel input +// RUN: %clang_cc1 -triple x86_64 -S -D INTEL -mllvm -x86-asm-syntax=intel -inline-asm=intel %s -o -
[clang] [Driver] Add toolchain for X86_64 UEFI target (PR #76838)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add toolchain for X86_64 UEFI target (PR #76838)
@@ -0,0 +1,14 @@ +// RUN: %clang_cl -### %s --target=x86_64-unknown-uefi \ +// RUN: --sysroot=%S/platform -fuse-ld=lld -g 2>&1 \ +// RUN: | FileCheck -check-prefixes=CHECK %s +// CHECK: "-cc1" +// CHECK-SAME: "-triple" "x86_64-unknown-uefi" +// CHECK-SAME: "-mrelocation-model" "pic" "-pic-level" "2" +// CHECK-SAME: "-mframe-pointer=all" +// CHECK-NEXT: "-nologo" +// CHECK-SAME: "-subsystem:efi_application" +// CHECK-SAME: "-entry:EfiMain" +// CHECK-SAME: "-tsaware:no" +// CHECK-SAME: "-dll" +// CHECK-SAME: "-debug" + MaskRay wrote: delete trailing blank line https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add toolchain for X86_64 UEFI target (PR #76838)
@@ -22,6 +22,10 @@ // RUN: FileCheck --check-prefix=X86_64 %s // X86_64: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +// RUN: %clang_cc1 -triple x86_64-unknown-uefi -emit-llvm -o - %s | \ MaskRay wrote: With clang/test/CodeGen/X86/uefi-data-layout.c, this is unneeded https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [mlir] [clang][flang][mlir] Support -frecord-command-line option (PR #102975)
https://github.com/MaskRay approved this pull request. LGTM. As you are renaming functions, you can fix the function naming style `tools::function` instead of `tools::Function`. While the style is largely inconsistent, we usually fix the style while renaming functions. https://github.com/llvm/llvm-project/pull/102975 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver][AArch64] Add support for aarch64-amazon-linux triple (PR #109263)
https://github.com/MaskRay requested changes to this pull request. . https://github.com/llvm/llvm-project/pull/109263 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver][AArch64] Add support for aarch64-amazon-linux triple (PR #109263)
MaskRay wrote: > The behviour was diverged between X86 and aarch64: prior to this patch, a > standard clang with no configuration works on x86 but not aarch64 amazon > linux; the latter fails to find C++ headers and libraries. This is not an issue of the source code. The system needs to do `-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-amazon-linux`. The comment is here for reasons as it doesn't scale to encode every possible target triple. https://github.com/llvm/llvm-project/pull/109263 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
MaskRay wrote: `[Driver] Add toolchain for ...' might be a more conventional patch subject. https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -0,0 +1,4 @@ +// RUN: %clang -target x86_64-unknown-uefi -S -emit-llvm -o - %s | \ +// RUN: FileCheck --check-prefix=X86_64_UEFI %s +// X86_64_UEFI: target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" + MaskRay wrote: delete trailing blank line https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -0,0 +1,88 @@ +//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===// MaskRay wrote: first line is incorrect. ensure 80-char wide and omit `C++` for `.cpp` files. https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -0,0 +1,4 @@ +// RUN: %clang -target x86_64-unknown-uefi -S -emit-llvm -o - %s | \ MaskRay wrote: test/Driver tests should generally only test `-###`, not `-emit-llvm -S` (codegen). Place such codegen tests to test/CodeGen https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -0,0 +1,61 @@ +//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H +#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H + +#include "clang/Driver/Tool.h" +#include "clang/Driver/ToolChain.h" + +namespace clang { MaskRay wrote: `namespace clang::driver {` https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libc] [libcxx] [Clang] Do not implicitly link C libraries for the GPU targets (PR #109052)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/109052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][Triple] Add `Environment` members and parsing for glibc/musl parity. (PR #107664)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/107664 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [mlir] [clang][flang][mlir] Support -frecord-command-line option (PR #102975)
MaskRay wrote: > > Why do we need the two new files? > > We have clang/lib/Driver/ToolChains/CommonArgs.cpp and > > clang/lib/Driver/ToolChain.cpp for shared code. > > Since most of the code in `CommonArgs.cpp` had to do with functions in the > `clang::driver::tools` namespace, I wasn't sure that code that is only shared > between `Clang.cpp` and `Flang.cpp` ought to go there. The other function > that was moved is a utility function to escape arguments and was originally > declared `static` in `Clang.cpp`. > > If it is ok to use `CommandArgs.cpp` for limited sharing and utilities, I can > move the code there. Adding the shared code to `CommonArgs.cpp` LGTM. Shared functions there use `tools::`, though. `rg driver:: clang/lib/Driver` reveals what files define `driver::` member functions. `CommonArgs.cpp` doesn't define `driver::`. https://github.com/llvm/llvm-project/pull/102975 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Don't warn when -S and -c are used together without -fsyntax-only (PR #104477)
https://github.com/MaskRay requested changes to this pull request. . https://github.com/llvm/llvm-project/pull/104477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][Triple] Add `Environment` members and parsing for glibc/musl parity. (PR #107664)
MaskRay wrote: Are these `musl*` environments blessed by upstream musl? @richfelker https://github.com/llvm/llvm-project/pull/107664 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [mlir] [clang][flang][mlir] Support -frecord-command-line option (PR #102975)
MaskRay wrote: Why do we need the two new files? (added) clang/lib/Driver/ToolChains/CommonUtils.cpp (+76) (added) clang/lib/Driver/ToolChains/CommonUtils.h (+44) We have clang/lib/Driver/ToolChains/CommonArgs.cpp and clang/lib/Driver/ToolChain.cpp for shared code. https://github.com/llvm/llvm-project/pull/102975 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [mlir] [clang][flang][mlir] Support -frecord-command-line option (PR #102975)
@@ -1980,9 +1980,11 @@ within a command line are combined with spaces; spaces and backslashes within an argument are escaped with backslashes. This format differs from the format of the equivalent section produced by GCC with the -frecord-gcc-switches flag. This option is currently only supported on ELF targets.}]>, - Group; + Group, MaskRay wrote: I think f_clang_Group is a legacy group for Clang options not in GCC. f_clang_Group has never gain significant adoption and it's used by any code. New -f options can just use f_Group. https://github.com/llvm/llvm-project/pull/102975 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Avoid repeated hash lookups (NFC) (PR #108676)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/108676 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Deprecate the `-fbasic-block-sections=labels` option. (PR #107494)
@@ -64,14 +64,16 @@ static lto::Config createConfig() { c.Options.BBAddrMap = config->ltoBBAddrMap; // Check if basic block sections must be used. - // Allowed values for --lto-basic-block-sections are "all", "labels", + // Allowed values for --lto-basic-block-sections are "all", // "", or none. This is the equivalent // of -fbasic-block-sections= flag in clang. if (!config->ltoBasicBlockSections.empty()) { if (config->ltoBasicBlockSections == "all") { c.Options.BBSections = BasicBlockSection::All; } else if (config->ltoBasicBlockSections == "labels") { - c.Options.BBSections = BasicBlockSection::Labels; + c.Options.BBAddrMap = true; MaskRay wrote: suggest that you create a separate change for lld/ELF. If this is deprecated, we need a test for the warning message. Please check other warnings for the style. We don't add the full stop. https://github.com/llvm/llvm-project/pull/107494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Deprecate the `-fbasic-block-sections=labels` option. (PR #107494)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/107494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Deprecate the `-fbasic-block-sections=labels` option. (PR #107494)
https://github.com/MaskRay approved this pull request. (Thanks for the patch. I am on vacation and may be slow/inconvenient to respond.) https://github.com/llvm/llvm-project/pull/107494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Deprecate the `-fbasic-block-sections=labels` option. (PR #107494)
@@ -2369,14 +2369,16 @@ are listed below. $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c $ cd $P && clang foo/name_conflict.o && bar/name_conflict.o -.. option:: -fbasic-block-sections=[labels, all, list=, none] +.. option:: -f[no]-basic-block-address-map: + Emits a ``SHT_LLVM_BB_ADDR_MAP`` which includes address offsets for each MaskRay wrote: `SHT_LLVM_BB_ADDR_MAP section` https://github.com/llvm/llvm-project/pull/107494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fix kcfi doesn't take effect when callee function has no input parameter (PR #106677)
MaskRay wrote: > If a function is declared without a prototype (pre-C23), it doesn't mean it > has a void argument list; it means the argument list is undeclared. So you > can't just assume the argument list is void; you have to compute the argument > types from the actual arguments passed to the call. +1. I don't think we have take this patch. > Or you could just forbid unprototyped functions in KCFI mode, If you don't > want to deal with the edge cases here (i.e. -Werror=strict-prototypes). Seems fine. https://github.com/llvm/llvm-project/pull/106677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Construct SmallVector with ArrayRef (NFC) (PR #105829)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/105829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Deprecate -fheinous-gnu-extensions; introduce a new warning flag (PR #105821)
https://github.com/MaskRay approved this pull request. LGTM @zatrazz https://github.com/llvm/llvm-project/pull/105821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] force libc linked with --no-as-needed when using compiler-rt (PR #95848)
MaskRay wrote: > ```shell > ../build/bin/clang test.c -o libtest.so -fPIC -shared -v -Wl,--as-needed > -Wl,--trace-symbol=__cxa_finalize > ``` This command line does not close `--as-needed` with `--no-as-needed`, so `-lc` is linked in `as-needed` mode. The driver is not responsible for forcing `--no-as-needed`. I believe this PR should be closed. https://github.com/llvm/llvm-project/pull/95848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] force libc linked with --no-as-needed when using compiler-rt (PR #95848)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/95848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)
@@ -30,8 +29,10 @@ // RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s // RUN: %clang -### -ffast-math -ffp-contract=fast-honor-pragmas -c %s 2>&1 \ -// RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST-HONOR,WARN_FM_FHP %s -// CHECK-FPC-FAST-HONOR: "-ffp-contract=fast-honor-pragmas" +// RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST-HONOR,WARN_FHP_DEPRECATED %s +// WARN_FHP_DEPRECATED: clang: warning: argument '-ffp-contract=fast-honor-pragmas' is deprecated, use '-ffp-contract=fast' instead [-Wdeprecated] MaskRay wrote: We generally don't check the string before "warning" (can be customized) https://github.com/llvm/llvm-project/pull/105746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)
https://github.com/MaskRay commented: Thanks for doing this! I support this direction as mentioned in #100453 (I'm starting a 3-week vacation this Friday and will have limited availability. Happy for other reviewers to approve.) https://github.com/llvm/llvm-project/pull/105746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/105746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Add a custom error option in multilib.yaml. (PR #105684)
@@ -130,7 +143,7 @@ class MultilibSet { /// Select compatible variants, \returns false if none are compatible bool select(const Multilib::flags_list &Flags, MaskRay wrote: For other parts of Driver, I think `const Driver &` is more commonly used as the first parameter https://github.com/llvm/llvm-project/pull/105684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Add a custom error option in multilib.yaml. (PR #105684)
https://github.com/MaskRay commented: I'm starting a 3-week vacation this Friday and will have limited availability. Happy for other reviewers to approve. https://github.com/llvm/llvm-project/pull/105684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Add a custom error option in multilib.yaml. (PR #105684)
@@ -0,0 +1,63 @@ +# REQUIRES: shell +# UNSUPPORTED: system-windows + +# RUN: rm -rf %T/baremetal_multilib MaskRay wrote: do not use `%T` https://llvm.org/docs/CommandGuide/lit.html#substitutions just use `rm -rf %t && mkdir %t` for what you do with `%T/baremetal_multilib` ? https://github.com/llvm/llvm-project/pull/105684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Add a custom error option in multilib.yaml. (PR #105684)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/105684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Allow installation of Clang .cfg files if they where generated. (PR #105580)
https://github.com/MaskRay commented: Apologies, I'm starting a 3-week vacation this Friday and will have limited availability. Happy for other reviewers to approve. https://github.com/llvm/llvm-project/pull/105580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)
@@ -2887,6 +2887,10 @@ def fxray_selected_function_group : HelpText<"When using -fxray-function-groups, select which group of functions to instrument. Valid range is 0 to fxray-function-groups - 1">, MarshallingInfoInt, "0">; +def fxray_enable_shared : Flag<["-"], "fxray-enable-shared">, Group, Visibility<[ClangOption, CC1Option]>, MaskRay wrote: Use `BoolFOption`. You can check some existing ones and how they determine whether `clang -cc1 -ffoo` or `clang -cc1 -fno-foo` is available. https://github.com/llvm/llvm-project/pull/90959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sparc] Add flags to enable errata workaround pass for GR712RC and UT700 (PR #104742)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/104742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sparc] Add flags to enable errata workaround pass for GR712RC and UT700 (PR #104742)
MaskRay wrote: This patch looks ok, but I expect justification why we need these -mfix-* options, which adds some, even if little, burden to the generic code. I asked because these are apparent workarounds. Sparc is a very old port that doesn't receive lots of development, and we should carefully balance needs and maintenance burden. https://github.com/llvm/llvm-project/pull/104742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PS5][Driver] Link main components with -pie by default (PR #102901)
@@ -1,3 +1,18 @@ +// Test that PIE is the default for main components + +// RUN: %clang --target=x86_64-scei-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PIE %s + +// CHECK-PIE: {{ld(\.exe)?}}" +// CHECK-PIE-SAME: "-pie" + +// RUN: %clang --target=x86_64-scei-ps5 -no-pie %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-PIE %s +// RUN: %clang --target=x86_64-scei-ps5 -r %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-PIE %s +// RUN: %clang --target=x86_64-scei-ps5 -shared %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-PIE %s MaskRay wrote: Suggest that the `-shared` RUN line additionally checks `-shared`. (I'm starting a 3-week vacation this Friday and will have limited availability.) https://github.com/llvm/llvm-project/pull/102901 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PS5][Driver] Link main components with -pie by default (PR #102901)
@@ -237,7 +237,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (!D.SysRoot.empty()) CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); - if (Args.hasArg(options::OPT_pie)) + // Default to PIE for non-static main components. MaskRay wrote: While the generic ABI refers to executable and shared object files as "components", "main component" isn't used. main executable or just executable https://github.com/llvm/llvm-project/pull/102901 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Use llvm::make_range(std::pair) (NFC) (PR #105470)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/105470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Fix KCFI types for generated functions with integer normalization (PR #104826)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/104826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/99615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/99615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
@@ -0,0 +1,8 @@ +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ MaskRay wrote: We don't need -fno-integrated-as tests. They are just forwarded. The -mmsa test needs a NOT. I'll push a commit to improve the test https://github.com/llvm/llvm-project/pull/99615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/99615 >From 7c839979164229ecbbdafb684107a6017b354df8 Mon Sep 17 00:00:00 2001 From: Ying Huang Date: Fri, 19 Jul 2024 04:19:09 -0400 Subject: [PATCH 1/2] [clang] Support -Wa, options -mmsa and -mno-msa --- clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td| 4 +++- clang/lib/Driver/ToolChains/Clang.cpp| 13 - clang/test/Driver/mips-msa.c | 19 +++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 clang/test/Driver/mips-msa.c diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 09e892d6d4defe..ecea476abe3232 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -176,6 +176,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants. CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled. CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. +CODEGENOPT(MipsMsa , 1, 0) ///< Set when -Wa,-mmsa is enabled. CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is ///< enabled. CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c66e035a259b3f..625a8303b9bf15 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5383,7 +5383,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, Group, def mno_madd4 : Flag<["-"], "mno-madd4">, Group, HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">; def mmsa : Flag<["-"], "mmsa">, Group, - HelpText<"Enable MSA ASE (MIPS only)">; + Visibility<[ClangOption, CC1Option, CC1AsOption]>, + HelpText<"Enable MSA ASE (MIPS only)">, + MarshallingInfoFlag>; def mno_msa : Flag<["-"], "mno-msa">, Group, HelpText<"Disable MSA ASE (MIPS only)">; def mmt : Flag<["-"], "mmt">, Group, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6180c6eeb6f07a..9fd8a0fcf50270 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2556,6 +2556,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, bool Crel = false, ExperimentalCrel = false; bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations(); bool UseNoExecStack = false; + std::optional Msa; const char *MipsTargetFeature = nullptr; StringRef ImplicitIt; for (const Arg *A : @@ -2665,7 +2666,14 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back("-soft-float"); continue; } - +if (Value == "-mmsa") { + Msa = true; + continue; +} +if (Value == "-mno-msa") { + Msa = false; + continue; +} MipsTargetFeature = llvm::StringSwitch(Value) .Case("-mips1", "+mips1") .Case("-mips2", "+mips2") @@ -2685,6 +2693,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, .Default(nullptr); if (MipsTargetFeature) continue; +break; } if (Value == "-force_cpusubtype_ALL") { @@ -2777,6 +2786,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, << "-Wa,--crel" << D.getTargetTriple(); } } + if (Msa && *Msa) +CmdArgs.push_back("-mmsa"); if (!UseRelaxRelocations) CmdArgs.push_back("-mrelax-relocations=no"); if (UseNoExecStack) diff --git a/clang/test/Driver/mips-msa.c b/clang/test/Driver/mips-msa.c new file mode 100644 index 00..78ff58288bd8a8 --- /dev/null +++ b/clang/test/Driver/mips-msa.c @@ -0,0 +1,19 @@ +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA +// CHECK-MMSA: "-cc1" {{.*}}"-mmsa" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mno-msa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mmsa,-mno-msa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-NOMMSA +// CHECK-NOMMSA: "-cc1" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN:-fno-integrated-as -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=MIPS-MSA +// MIPS-MSA: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC" "-mmsa" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN:-fn
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/99615 >From 7c839979164229ecbbdafb684107a6017b354df8 Mon Sep 17 00:00:00 2001 From: Ying Huang Date: Fri, 19 Jul 2024 04:19:09 -0400 Subject: [PATCH 1/2] [clang] Support -Wa, options -mmsa and -mno-msa --- clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td| 4 +++- clang/lib/Driver/ToolChains/Clang.cpp| 13 - clang/test/Driver/mips-msa.c | 19 +++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 clang/test/Driver/mips-msa.c diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 09e892d6d4defe..ecea476abe3232 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -176,6 +176,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants. CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled. CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. +CODEGENOPT(MipsMsa , 1, 0) ///< Set when -Wa,-mmsa is enabled. CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is ///< enabled. CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c66e035a259b3f..625a8303b9bf15 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5383,7 +5383,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, Group, def mno_madd4 : Flag<["-"], "mno-madd4">, Group, HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">; def mmsa : Flag<["-"], "mmsa">, Group, - HelpText<"Enable MSA ASE (MIPS only)">; + Visibility<[ClangOption, CC1Option, CC1AsOption]>, + HelpText<"Enable MSA ASE (MIPS only)">, + MarshallingInfoFlag>; def mno_msa : Flag<["-"], "mno-msa">, Group, HelpText<"Disable MSA ASE (MIPS only)">; def mmt : Flag<["-"], "mmt">, Group, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6180c6eeb6f07a..9fd8a0fcf50270 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2556,6 +2556,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, bool Crel = false, ExperimentalCrel = false; bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations(); bool UseNoExecStack = false; + std::optional Msa; const char *MipsTargetFeature = nullptr; StringRef ImplicitIt; for (const Arg *A : @@ -2665,7 +2666,14 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back("-soft-float"); continue; } - +if (Value == "-mmsa") { + Msa = true; + continue; +} +if (Value == "-mno-msa") { + Msa = false; + continue; +} MipsTargetFeature = llvm::StringSwitch(Value) .Case("-mips1", "+mips1") .Case("-mips2", "+mips2") @@ -2685,6 +2693,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, .Default(nullptr); if (MipsTargetFeature) continue; +break; } if (Value == "-force_cpusubtype_ALL") { @@ -2777,6 +2786,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, << "-Wa,--crel" << D.getTargetTriple(); } } + if (Msa && *Msa) +CmdArgs.push_back("-mmsa"); if (!UseRelaxRelocations) CmdArgs.push_back("-mrelax-relocations=no"); if (UseNoExecStack) diff --git a/clang/test/Driver/mips-msa.c b/clang/test/Driver/mips-msa.c new file mode 100644 index 00..78ff58288bd8a8 --- /dev/null +++ b/clang/test/Driver/mips-msa.c @@ -0,0 +1,19 @@ +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA +// CHECK-MMSA: "-cc1" {{.*}}"-mmsa" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mno-msa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mmsa,-mno-msa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-NOMMSA +// CHECK-NOMMSA: "-cc1" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN:-fno-integrated-as -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=MIPS-MSA +// MIPS-MSA: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC" "-mmsa" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN:-fn
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/99615 >From cab152b6306bf486daf478709fe5eaa3a0bb79d2 Mon Sep 17 00:00:00 2001 From: Ying Huang Date: Fri, 19 Jul 2024 04:19:09 -0400 Subject: [PATCH 1/2] [clang] Support -Wa, options -mmsa and -mno-msa --- clang/include/clang/Basic/CodeGenOptions.def | 1 + clang/include/clang/Driver/Options.td| 4 +++- clang/lib/Driver/ToolChains/Clang.cpp| 13 - clang/test/Driver/mips-msa.c | 19 +++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 clang/test/Driver/mips-msa.c diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 09e892d6d4defe..ecea476abe3232 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -176,6 +176,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants. CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled. CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. +CODEGENOPT(MipsMsa , 1, 0) ///< Set when -Wa,-mmsa is enabled. CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is ///< enabled. CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c66e035a259b3f..625a8303b9bf15 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5383,7 +5383,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, Group, def mno_madd4 : Flag<["-"], "mno-madd4">, Group, HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">; def mmsa : Flag<["-"], "mmsa">, Group, - HelpText<"Enable MSA ASE (MIPS only)">; + Visibility<[ClangOption, CC1Option, CC1AsOption]>, + HelpText<"Enable MSA ASE (MIPS only)">, + MarshallingInfoFlag>; def mno_msa : Flag<["-"], "mno-msa">, Group, HelpText<"Disable MSA ASE (MIPS only)">; def mmt : Flag<["-"], "mmt">, Group, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6180c6eeb6f07a..9fd8a0fcf50270 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2556,6 +2556,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, bool Crel = false, ExperimentalCrel = false; bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations(); bool UseNoExecStack = false; + std::optional Msa; const char *MipsTargetFeature = nullptr; StringRef ImplicitIt; for (const Arg *A : @@ -2665,7 +2666,14 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back("-soft-float"); continue; } - +if (Value == "-mmsa") { + Msa = true; + continue; +} +if (Value == "-mno-msa") { + Msa = false; + continue; +} MipsTargetFeature = llvm::StringSwitch(Value) .Case("-mips1", "+mips1") .Case("-mips2", "+mips2") @@ -2685,6 +2693,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, .Default(nullptr); if (MipsTargetFeature) continue; +break; } if (Value == "-force_cpusubtype_ALL") { @@ -2777,6 +2786,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, << "-Wa,--crel" << D.getTargetTriple(); } } + if (Msa && *Msa) +CmdArgs.push_back("-mmsa"); if (!UseRelaxRelocations) CmdArgs.push_back("-mrelax-relocations=no"); if (UseNoExecStack) diff --git a/clang/test/Driver/mips-msa.c b/clang/test/Driver/mips-msa.c new file mode 100644 index 00..78ff58288bd8a8 --- /dev/null +++ b/clang/test/Driver/mips-msa.c @@ -0,0 +1,19 @@ +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA +// CHECK-MMSA: "-cc1" {{.*}}"-mmsa" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mno-msa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-MMSA + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN: -Wa,-mmsa,-mno-msa %s -Werror 2>&1 | FileCheck %s --check-prefix=CHECK-NOMMSA +// CHECK-NOMMSA: "-cc1" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN:-fno-integrated-as -Wa,-mmsa %s -Werror 2>&1 | FileCheck %s --check-prefix=MIPS-MSA +// MIPS-MSA: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC" "-mmsa" + +// RUN: %clang -### -c --target=mips64el-unknown-linux-gnuabi64 \ +// RUN:-fn
[libunwind] [libunwind] Detect cycles of length 1 (PR #103476)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/103476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Detect cycles of length 1 (PR #103476)
MaskRay wrote: > Are you able to insert a `.cfi_undefined ` in the generated > assembly? That would tell libunwind to stop unwinding and is cleaner than > this workaround IMO. > > I just noticed a similar problem in FreeBSD's startup files but I plan to fix > those in FreeBSD instead of working around them here. Thanks for weighing in. I'll close this PR. I agree that sending a patch to musl is worth trying: > (And, IIUC, musl people generally don't want programs to be able to unwind > their own stack for debugging purposes. If I send a fix to musl, I imagine > the answer may be "gdb already works, libunwind already doesn't work, and > that's exactly how we want it", but may be worth a try.) https://github.com/llvm/llvm-project/pull/103476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add support for omitting only global destructors (PR #104899)
https://github.com/MaskRay approved this pull request. LGTM! (I'm starting a 3-week vacation this Friday and will have limited availability.) https://github.com/llvm/llvm-project/pull/104899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add support for omitting only global destructors (PR #104899)
@@ -7967,8 +7967,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_fno_keep_persistent_storage_variables); Args.addOptInFlag(CmdArgs, options::OPT_fcomplete_member_pointers, options::OPT_fno_complete_member_pointers); - Args.addOptOutFlag(CmdArgs, options::OPT_fcxx_static_destructors, - options::OPT_fno_cxx_static_destructors); + if (Arg *A = Args.getLastArg(options::OPT_cxx_static_destructors_EQ)) +CmdArgs.push_back( MaskRay wrote: `A->render(Args, CmdArgs);` https://github.com/llvm/llvm-project/pull/104899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add support for omitting only global destructors (PR #104899)
@@ -0,0 +1,9 @@ +// RUN: %clang -### -c -fc++-static-destructors=all %s 2>&1 | FileCheck --check-prefix ALL %s MaskRay wrote: thx for adding a driver test. The previous `-fc++-static-destructors` patch https://reviews.llvm.org/D50994 did not come with a driver test https://github.com/llvm/llvm-project/pull/104899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add support for omitting only global destructors (PR #104899)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/104899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add support for omitting only global destructors (PR #104899)
@@ -0,0 +1,9 @@ +// RUN: %clang -### -c -fc++-static-destructors=all %s 2>&1 | FileCheck --check-prefix ALL %s +// RUN: %clang -### -c -fc++-static-destructors %s 2>&1 | FileCheck --check-prefix ALL %s +// RUN: %clang -### -c -fc++-static-destructors=none %s 2>&1 | FileCheck --check-prefix NONE %s MaskRay wrote: You can add -fc++-static-destructors before -fc++-static-destructors=none to enhance the test to show we use the `getLastArg` semantics https://github.com/llvm/llvm-project/pull/104899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sparc] Add flags to enable errata workaround pass for GR712RC and UT700 (PR #104742)
@@ -0,0 +1,12 @@ +// RUN: %clang -target sparc -mfix-gr712rc -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-FIX-GR712RC < %t %s +// CHECK-FIX-GR712RC: "-target-feature" "+fix-tn0009" +// CHECK-FIX-GR712RC: "-target-feature" "+fix-tn0011" MaskRay wrote: If these are adjacent, you can place them on the same line. If you don't that, use `-SAME:` https://github.com/llvm/llvm-project/pull/104742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sparc] Add flags to enable errata workaround pass for GR712RC and UT700 (PR #104742)
@@ -0,0 +1,12 @@ +// RUN: %clang -target sparc -mfix-gr712rc -### %s 2> %t MaskRay wrote: `--target=` for new tests. `-target ` has been deprecated since around Clang 3.4 https://github.com/llvm/llvm-project/pull/104742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Default -msmall-data-limit= to 0 and clean up code (PR #83093)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/83093 >From dbc9ddd9a9b1b73d56f8aab5265db36a44e6fcaf Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 26 Feb 2024 17:58:55 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- clang/lib/Driver/ToolChains/Clang.cpp | 41 ++- .../CodeGen/RISCV/riscv-sdata-module-flag.c | 4 +- clang/test/Driver/riscv-sdata-warning.c | 4 -- clang/test/Driver/riscv-sdata.c | 5 +++ llvm/lib/Target/RISCV/RISCVTargetObjectFile.h | 2 +- 5 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 clang/test/Driver/riscv-sdata-warning.c create mode 100644 clang/test/Driver/riscv-sdata.c diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6e1b7e8657d0dc..9b9eab3990607f 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2029,42 +2029,6 @@ void Clang::AddPPCTargetArgs(const ArgList &Args, } } -static void SetRISCVSmallDataLimit(const ToolChain &TC, const ArgList &Args, - ArgStringList &CmdArgs) { - const Driver &D = TC.getDriver(); - const llvm::Triple &Triple = TC.getTriple(); - // Default small data limitation is eight. - const char *SmallDataLimit = "8"; - // Get small data limitation. - if (Args.getLastArg(options::OPT_shared, options::OPT_fpic, - options::OPT_fPIC)) { -// Not support linker relaxation for PIC. -SmallDataLimit = "0"; -if (Args.hasArg(options::OPT_G)) { - D.Diag(diag::warn_drv_unsupported_sdata); -} - } else if (Args.getLastArgValue(options::OPT_mcmodel_EQ) - .equals_insensitive("large") && - (Triple.getArch() == llvm::Triple::riscv64)) { -// Not support linker relaxation for RV64 with large code model. -SmallDataLimit = "0"; -if (Args.hasArg(options::OPT_G)) { - D.Diag(diag::warn_drv_unsupported_sdata); -} - } else if (Triple.isAndroid()) { -// GP relaxation is not supported on Android. -SmallDataLimit = "0"; -if (Args.hasArg(options::OPT_G)) { - D.Diag(diag::warn_drv_unsupported_sdata); -} - } else if (Arg *A = Args.getLastArg(options::OPT_G)) { -SmallDataLimit = A->getValue(); - } - // Forward the -msmall-data-limit= option. - CmdArgs.push_back("-msmall-data-limit"); - CmdArgs.push_back(SmallDataLimit); -} - void Clang::AddRISCVTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { const llvm::Triple &Triple = getToolChain().getTriple(); @@ -2073,7 +2037,10 @@ void Clang::AddRISCVTargetArgs(const ArgList &Args, CmdArgs.push_back("-target-abi"); CmdArgs.push_back(ABIName.data()); - SetRISCVSmallDataLimit(getToolChain(), Args, CmdArgs); + if (Arg *A = Args.getLastArg(options::OPT_G)) { +CmdArgs.push_back("-msmall-data-limit"); +CmdArgs.push_back(A->getValue()); + } if (!Args.hasFlag(options::OPT_mimplicit_float, options::OPT_mno_implicit_float, true)) diff --git a/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c b/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c index 9bd69e7995877e..e91b2e7f225f52 100644 --- a/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c +++ b/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c @@ -30,14 +30,14 @@ void test(void) {} -// RV32-DEFAULT: !{i32 8, !"SmallDataLimit", i32 8} +// RV32-DEFAULT: !{i32 8, !"SmallDataLimit", i32 0} // RV32-G4: !{i32 8, !"SmallDataLimit", i32 4} // RV32-S0: !{i32 8, !"SmallDataLimit", i32 0} // RV32-S2G4:!{i32 8, !"SmallDataLimit", i32 4} // RV32-T16: !{i32 8, !"SmallDataLimit", i32 16} // RV32-PIC: !{i32 8, !"SmallDataLimit", i32 0} -// RV64-DEFAULT: !{i32 8, !"SmallDataLimit", i32 8} +// RV64-DEFAULT: !{i32 8, !"SmallDataLimit", i32 0} // RV64-G4: !{i32 8, !"SmallDataLimit", i32 4} // RV64-S0: !{i32 8, !"SmallDataLimit", i32 0} // RV64-S2G4:!{i32 8, !"SmallDataLimit", i32 4} diff --git a/clang/test/Driver/riscv-sdata-warning.c b/clang/test/Driver/riscv-sdata-warning.c deleted file mode 100644 index ace9a32ee116fd..00 --- a/clang/test/Driver/riscv-sdata-warning.c +++ /dev/null @@ -1,4 +0,0 @@ -// REQUIRES: riscv-registered-target -// RUN: %clang -S --target=riscv32-unknown-elf -fpic -msmall-data-limit=8 %s 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK-PIC-SDATA %s -// CHECK-PIC-SDATA: warning: ignoring '-msmall-data-limit=' with -mcmodel=large for -fpic or RV64 diff --git a/clang/test/Driver/riscv-sdata.c b/clang/test/Driver/riscv-sdata.c new file mode 100644 index 00..84cd109813db4c --- /dev/null +++ b/clang/test/Driver/riscv-sdata.c @@ -0,0 +1,5 @@ +// RUN: %clang -### -S --target=riscv64 %s 2>&1 |
[clang] [clang][NFC] Split invalid-cpu-note tests (PR #104601)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/104601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
MaskRay wrote: > > > @MaskRay Are you OK with this change? > > > > > > Sorry for the delay. I've read through > > [discourse.llvm.org/t/making-ffp-model-fast-more-user-friendly/78402](https://discourse.llvm.org/t/making-ffp-model-fast-more-user-friendly/78402), > > how we ended up with `-ffp-contract=fast-honor-pragmas` beside `=fast` > > (GCC compatibility, sigh), some notes that ICC/GCC have behavior > > differences. A different, safer mode for `-ffp-model` (absent from GCC) > > makes sense to me. > > GCC doesn't support the pragma, and ICC doesn't have a mode that only allows > contraction within a single expression (as the C standard requires), so I > don't think compatibility with the behavior of the pragma in those compilers > makes sense. > > I personally feel very strongly that even our -ffast-math handling should > honor pragmas by default and that -ffp-contract=fast should honor pragmas > (perhaps with the addition of -ffp-contract=fast-no-honor-pragmas if anyone > really needs that). Someone else was surprised by this behavior earlier this > year (#88633). On the other hand, we've got a bug in the front end where we > crash with "#pragma STDC FP_CONTRACT DEFAULT" if you've used > "-ffp-contract=fast-honor-pragmas" > ([godbolt.org/z/EqE6Kn6Wf](https://godbolt.org/z/EqE6Kn6Wf)) so maybe I > should hold the fp-contract change back for a future patch. I've read https://discourse.llvm.org/t/fp-contract-fast-and-pragmas/58529 and I agree that `fast`/`fast-honor-pragmas` could be merged and if needed, `-fast-no-honor-pragmas` could be added (I suspect that there is no such need...) https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][rtsan] Introduce realtime sanitizer codegen and driver (PR #102622)
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsanitize=realtime -emit-llvm -o - %s | FileCheck %s MaskRay wrote: this should be merged with `at_entry.c`. https://github.com/llvm/llvm-project/pull/102622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][rtsan] Introduce realtime sanitizer codegen and driver (PR #102622)
@@ -0,0 +1,14 @@ +// RUN: %clang -target x86_64-unknown-linux -fsanitize=realtime %s -S -emit-llvm -o - | FileCheck %s MaskRay wrote: Thx for letting me know the existing asan.c/tsan. I'll try to clean up the two tests. For this driver test which will use `-###`, `-O` is entirely uninteresting. Sometimes `-O1` or above may be interesting for CodeGen tests but probably not for this. https://github.com/llvm/llvm-project/pull/102622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][rtsan] Introduce realtime sanitizer codegen and driver (PR #102622)
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsanitize=realtime -emit-llvm -o - %s | FileCheck %s + +// __rtsan_realtime_exit should be inserted at all function returns MaskRay wrote: End all full sentence comments with a `.` https://github.com/llvm/llvm-project/pull/102622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][rtsan] Introduce realtime sanitizer codegen and driver (PR #102622)
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsanitize=realtime -emit-llvm -o - %s | FileCheck %s MaskRay wrote: `*-unknown-linux-gnu` is more popular. `none` could also be used for the OS component and is slightly misleading. https://github.com/llvm/llvm-project/pull/102622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][rtsan] Introduce realtime sanitizer codegen and driver (PR #102622)
@@ -845,6 +845,15 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, if (SanOpts.has(SanitizerKind::ShadowCallStack)) Fn->addFnAttr(llvm::Attribute::ShadowCallStack); + if (SanOpts.has(SanitizerKind::Realtime)) { MaskRay wrote: remove braces per https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements https://github.com/llvm/llvm-project/pull/102622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][rtsan] Introduce realtime sanitizer codegen and driver (PR #102622)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/102622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][rtsan] Introduce realtime sanitizer codegen and driver (PR #102622)
@@ -0,0 +1,14 @@ +// RUN: %clang -target x86_64-unknown-linux -fsanitize=realtime %s -S -emit-llvm -o - | FileCheck %s MaskRay wrote: Driver tests should only use `-###` to test CC1 options. We don't test different `-O` combinations. It's not useful to test `-flto` test/CodeGen tests `%clang_cc1` We generally don't add end-to-end tests. https://github.com/llvm/llvm-project/pull/102622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Detect cycles of length 1 (PR #103476)
https://github.com/MaskRay requested changes to this pull request. . https://github.com/llvm/llvm-project/pull/103476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Detect cycles of length 1 (PR #103476)
MaskRay wrote: > This happens with musl libc in __clone(), which has incorrect DWARF unwind > information. Can you elaborate this? How is it incorrect? (tools/add-cfi.x86_64.awk on `musl/src/thread/x86_64/clone.s`, I assume) I guess this workaround does address your issue, but for the upstream we really need more principled fix, instead of adding a hack. https://github.com/llvm/llvm-project/pull/103476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Driver] Default -msmall-data-limit= to 0 and clean up code (PR #83093)
MaskRay wrote: Thanks! I'll land this in a few days. I believe it's now up to the gp default users to justify the default and why they cannot user a Clang configuration file (this is difficult to justify, as we've many many decisions to Clang configuration files). I think this is important to ensure that future sdata/sbss development like #87040 not cause disruption to users who don't use the feature. https://github.com/llvm/llvm-project/pull/83093 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
MaskRay wrote: > @MaskRay Are you OK with this change? Sorry for the delay. I've read through https://discourse.llvm.org/t/making-ffp-model-fast-more-user-friendly/78402, how we ended up with `-ffp-contract=fast-honor-pragmas` beside `=fast` (GCC compatibility, sigh), some notes that ICC/GCC have behavior differences. A different, safer mode for `-ffp-model` (absent from GCC) makes sense to me. https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
@@ -163,23 +183,41 @@ // CHECK-FEB-IGNORE: "-fno-rounding-math" // CHECK-FEB-IGNORE: "-ffp-exception-behavior=ignore" -// RUN: %clang -### -nostdinc -Werror -ffast-math -ffp-model=fast -c %s 2>&1 \ +// RUN: %clang -### -nostdinc -Werror -ffast-math -ffp-model=aggressive -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FASTMATH-FPM-AGGR %s +// CHECK-FASTMATH-FPM-AGGR: "-cc1" MaskRay wrote: perhaps pack some options on the same line to show that they are adjacent (no other option in between) If this extra check isn't important, I expect at least `-SAME:` https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
@@ -109,20 +112,37 @@ // CHECK-TRAP: "-cc1" // CHECK-TRAP: "-ffp-exception-behavior=strict" +// RUN: %clang -### -nostdinc -ffp-model=aggressive -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FPM-AGGR %s +// CHECK-FPM-AGGR: "-cc1" +// CHECK-FPM-AGGR: "-menable-no-infs" MaskRay wrote: see my other comment: pack some options (to show they are adjacent) or use `-SAME: {{^}} "-menable-no-nans"` (clang/test/Driver/linux-cross.cpp style) https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
@@ -3033,8 +3039,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, SignedZeros = true; StringRef Val = A->getValue(); - if (OFastEnabled && Val != "fast") { -// Only -ffp-model=fast is compatible with OFast, ignore. + if (OFastEnabled && Val != "aggressive") { +// Only -ffp-model=aggressive is compatible with OFast, ignore. MaskRay wrote: `-Ofast`. There isn't a variable named `OFast`. https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
https://github.com/MaskRay approved this pull request. fp-model= => -ffp-model= LGTM. I expect that the subject explicit mentions -ffp-model=fast behavior difference, even if it becomes less aggressive and unlikely breaks users. With "Introduce ...", nobody would expect behavior differences. https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
@@ -2879,10 +2879,31 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, std::string ComplexRangeStr = ""; std::string GccRangeComplexOption = ""; + auto setComplexRange = [&](LangOptions::ComplexRangeKind NewRange) { +// Warn if user expects to perform full implementation of complex +// multiplication or division in the presence of nan or ninf flags. MaskRay wrote: typo: nan => nnan ? https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
@@ -2,13 +2,13 @@ // and other floating point options get a warning diagnostic. // -// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \ +// RUN: %clang -### -ffp-model=aggressive -ffp-contract=off -c %s 2>&1 \ MaskRay wrote: It's still useful to test the behavior of `-ffp-model=fast -ffp-contract=off` https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Introduce ffp-model=aggressive (PR #100453)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/100453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Split invalid-cpu-note tests (PR #104601)
@@ -0,0 +1,90 @@ +// Use --implicit-check-not to ensure no additional CPUs are in this list + +// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --implicit-check-not={{[a-zA-Z0-9]}} +// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --implicit-check-not={{[a-zA-Z0-9]}} + +// CHECK: error: unknown target CPU 'not-a-cpu' +// CHECK-NEXT: note: valid target CPU values are: +// CHECK-SAME: a64fx, MaskRay wrote: Instead of having every CPU one the same line, you can group them by families like: ``` {{^}}, ampere1, ampere1a, ampere1b {{^}}, fooX, fooY, fooZ ``` which still looks quite good. Word diff tools are quite robust, so I think strictly avoiding packing is not necessary. https://github.com/llvm/llvm-project/pull/104601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Split invalid-cpu-note tests (PR #104601)
@@ -0,0 +1,90 @@ +// Use --implicit-check-not to ensure no additional CPUs are in this list + +// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --implicit-check-not={{[a-zA-Z0-9]}} +// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --implicit-check-not={{[a-zA-Z0-9]}} + +// CHECK: error: unknown target CPU 'not-a-cpu' +// CHECK-NEXT: note: valid target CPU values are: +// CHECK-SAME: a64fx, MaskRay wrote: clang/test/Driver/linux-cross.cpp uses the `ARCH_I686-SAME: {{^}} xxx` pattern to check the content on the same line. You can use the same pattern. I think it's useful to pack some elements on the same line, e.g. `{{^}}, ampere1, ampere1a, ampere1b` https://github.com/llvm/llvm-project/pull/104601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f861e33 - [Driver] Reject -Wa, -mrelax-relocations= for non-ELF
Author: Fangrui Song Date: 2024-08-15T18:01:10-07:00 New Revision: f861e33912732d3de05369cdff852968fcdcb3a0 URL: https://github.com/llvm/llvm-project/commit/f861e33912732d3de05369cdff852968fcdcb3a0 DIFF: https://github.com/llvm/llvm-project/commit/f861e33912732d3de05369cdff852968fcdcb3a0.diff LOG: [Driver] Reject -Wa,-mrelax-relocations= for non-ELF Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/relax.c Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 2b7241964a345d..daffa7cf96978a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2582,6 +2582,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, bool TakeNextArg = false; const llvm::Triple &Triple = C.getDefaultToolChain().getTriple(); + bool IsELF = Triple.isOSBinFormatELF(); bool Crel = false, ExperimentalCrel = false; bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations(); bool UseNoExecStack = false; @@ -2621,10 +2622,16 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, continue; // LLVM handles bigobj automatically auto Equal = Value.split('='); - auto checkArg = [&](std::initializer_list Set) { -if (!llvm::is_contained(Set, Equal.second)) + auto checkArg = [&](bool ValidTarget, + std::initializer_list Set) { +if (!ValidTarget) { + D.Diag(diag::err_drv_unsupported_opt_for_target) + << (Twine("-Wa,") + Equal.first + "=").str() + << Triple.getTriple(); +} else if (!llvm::is_contained(Set, Equal.second)) { D.Diag(diag::err_drv_unsupported_option_argument) << (Twine("-Wa,") + Equal.first + "=").str() << Equal.second; +} }; switch (C.getDefaultToolChain().getArch()) { default: @@ -2634,7 +2641,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, if (Equal.first == "-mrelax-relocations" || Equal.first == "--mrelax-relocations") { UseRelaxRelocations = Equal.second == "yes"; - checkArg({"yes", "no"}); + checkArg(IsELF, {"yes", "no"}); continue; } if (Value == "-msse2avx") { @@ -2656,7 +2663,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, if (Equal.first == "-mimplicit-it") { // Only store the value; the last value set takes effect. ImplicitIt = Equal.second; - checkArg({"always", "never", "arm", "thumb"}); + checkArg(true, {"always", "never", "arm", "thumb"}); continue; } if (Value == "-mthumb") diff --git a/clang/test/Driver/relax.c b/clang/test/Driver/relax.c index 9315a0045f1f43..93249cac7f40f8 100644 --- a/clang/test/Driver/relax.c +++ b/clang/test/Driver/relax.c @@ -8,3 +8,6 @@ // RUN: not %clang -### --target=aarch64 -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR2 // ERR2: error: unsupported argument '-mrelax-relocations=no' to option '-Wa,' + +// RUN: not %clang -### --target=x86_64-apple-darwin -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR3 +// ERR3: error: unsupported option '-Wa,-mrelax-relocations=' for target 'x86_64-apple-darwin' ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 812e049 - [Driver] Correctly handle -Wa,--crel -Wa,--no-crel
Author: Fangrui Song Date: 2024-08-15T17:32:16-07:00 New Revision: 812e049ac1c2424f96746ac4c453d6255b0a6ca5 URL: https://github.com/llvm/llvm-project/commit/812e049ac1c2424f96746ac4c453d6255b0a6ca5 DIFF: https://github.com/llvm/llvm-project/commit/812e049ac1c2424f96746ac4c453d6255b0a6ca5.diff LOG: [Driver] Correctly handle -Wa,--crel -Wa,--no-crel Follow-up to #97378 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/crel.c Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 1cba3e1220264..320d2901da06e 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1143,8 +1143,8 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args, addMachineOutlinerArgs(D, Args, CmdArgs, ToolChain.getEffectiveTriple(), /*IsLTO=*/true, PluginOptPrefix); + bool Crel = false; for (const Arg *A : Args.filtered(options::OPT_Wa_COMMA)) { -bool Crel = false; for (StringRef V : A->getValues()) { if (V == "--crel") Crel = true; @@ -1154,13 +1154,13 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args, continue; A->claim(); } -if (Crel) { - if (Triple.isOSBinFormatELF() && !Triple.isMIPS()) { -CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) + "-crel")); - } else { -D.Diag(diag::err_drv_unsupported_opt_for_target) -<< "-Wa,--crel" << D.getTargetTriple(); - } + } + if (Crel) { +if (Triple.isOSBinFormatELF() && !Triple.isMIPS()) { + CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) + "-crel")); +} else { + D.Diag(diag::err_drv_unsupported_opt_for_target) + << "-Wa,--crel" << D.getTargetTriple(); } } } diff --git a/clang/test/Driver/crel.c b/clang/test/Driver/crel.c index a47e7ebfeedd8..e1b3f58c6ea5b 100644 --- a/clang/test/Driver/crel.c +++ b/clang/test/Driver/crel.c @@ -24,8 +24,10 @@ /// The --allow-experimental-crel error check doesn't apply to LTO. // RUN: %clang -### --target=x86_64-linux -Werror -flto -Wa,--crel %s 2>&1 | FileCheck %s --check-prefix=LTO +// RUN: %clang -### --target=x86_64-linux -Werror -flto -Wa,--crel -Wa,--no-crel %s 2>&1 | FileCheck %s --check-prefix=LTO-NO // LTO: "-plugin-opt=-crel" +// LTO-NO-NOT: "-plugin-opt=-crel" // RUN: touch %t.o // RUN: not %clang -### --target=mips64-linux-gnu -flto -Wa,--crel %t.o 2>&1 | FileCheck %s --check-prefix=ERR ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9d63a09 - [Driver] Improve error message for -Wa,-x=unknown
Author: Fangrui Song Date: 2024-08-15T17:04:41-07:00 New Revision: 9d63a09b452b641e3cc5d88066464b8250bd2bf7 URL: https://github.com/llvm/llvm-project/commit/9d63a09b452b641e3cc5d88066464b8250bd2bf7 DIFF: https://github.com/llvm/llvm-project/commit/9d63a09b452b641e3cc5d88066464b8250bd2bf7.diff LOG: [Driver] Improve error message for -Wa,-x=unknown Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/arm-target-as-mimplicit-it.s clang/test/Driver/relax.c Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index c26ebd1ba56ba..2b7241964a345 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2621,6 +2621,11 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, continue; // LLVM handles bigobj automatically auto Equal = Value.split('='); + auto checkArg = [&](std::initializer_list Set) { +if (!llvm::is_contained(Set, Equal.second)) + D.Diag(diag::err_drv_unsupported_option_argument) + << (Twine("-Wa,") + Equal.first + "=").str() << Equal.second; + }; switch (C.getDefaultToolChain().getArch()) { default: break; @@ -2629,8 +2634,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, if (Equal.first == "-mrelax-relocations" || Equal.first == "--mrelax-relocations") { UseRelaxRelocations = Equal.second == "yes"; - if (llvm::is_contained({"yes", "no"}, Equal.second)) -continue; + checkArg({"yes", "no"}); + continue; } if (Value == "-msse2avx") { CmdArgs.push_back("-msse2avx"); @@ -2651,8 +2656,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, if (Equal.first == "-mimplicit-it") { // Only store the value; the last value set takes effect. ImplicitIt = Equal.second; - if (CheckARMImplicitITArg(Equal.second)) -continue; + checkArg({"always", "never", "arm", "thumb"}); + continue; } if (Value == "-mthumb") // -mthumb has already been processed in ComputeLLVMTriple() diff --git a/clang/test/Driver/arm-target-as-mimplicit-it.s b/clang/test/Driver/arm-target-as-mimplicit-it.s index d30433ab374d5..e40206dfc3a29 100644 --- a/clang/test/Driver/arm-target-as-mimplicit-it.s +++ b/clang/test/Driver/arm-target-as-mimplicit-it.s @@ -30,7 +30,7 @@ /// Test invalid input. // RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID -// RUN: not %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=XINVALID +// RUN: not %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID // RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID // RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID @@ -47,5 +47,4 @@ // NEVER-NOT: "-arm-implicit-it={{.*}}" // ARM: "-mllvm" "-arm-implicit-it=arm" // THUMB: "-mllvm" "-arm-implicit-it=thumb" -// INVALID: error: unsupported argument '-mimplicit-it=foo' to option '-Wa,' -// XINVALID: error: unsupported argument '-mimplicit-it=foo' to option '-Xassembler' +// INVALID: error: unsupported argument 'foo' to option '-Wa,-mimplicit-it=' diff --git a/clang/test/Driver/relax.c b/clang/test/Driver/relax.c index 4771b9e3af111..9315a0045f1f4 100644 --- a/clang/test/Driver/relax.c +++ b/clang/test/Driver/relax.c @@ -4,7 +4,7 @@ // CHECK: "-mrelax-relocations=no" // RUN: not %clang -### --target=x86_64 -c -Wa,-mrelax-relocations=x %s 2>&1 | FileCheck %s --check-prefix=ERR -// ERR: error: unsupported argument '-mrelax-relocations=x' to option '-Wa,' +// ERR: error: unsupported argument 'x' to option '-Wa,-mrelax-relocations=' // RUN: not %clang -### --target=aarch64 -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR2 // ERR2: error: unsupported argument '-mrelax-relocations=no' to option '-Wa,' ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d156a5a - [Driver] Reject -Wa, -mrelax-relocations= for non-x86
Author: Fangrui Song Date: 2024-08-15T16:28:42-07:00 New Revision: d156a5a1cb3b3405a6c1e941d112f262c29e15cf URL: https://github.com/llvm/llvm-project/commit/d156a5a1cb3b3405a6c1e941d112f262c29e15cf DIFF: https://github.com/llvm/llvm-project/commit/d156a5a1cb3b3405a6c1e941d112f262c29e15cf.diff LOG: [Driver] Reject -Wa,-mrelax-relocations= for non-x86 Similar to other target-specific -Wa, options. Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/ohos.c clang/test/Driver/relax.c Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 96aa930ea28612..c26ebd1ba56bab 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2620,11 +2620,18 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, Value == "-mbig-obj") continue; // LLVM handles bigobj automatically + auto Equal = Value.split('='); switch (C.getDefaultToolChain().getArch()) { default: break; case llvm::Triple::x86: case llvm::Triple::x86_64: +if (Equal.first == "-mrelax-relocations" || +Equal.first == "--mrelax-relocations") { + UseRelaxRelocations = Equal.second == "yes"; + if (llvm::is_contained({"yes", "no"}, Equal.second)) +continue; +} if (Value == "-msse2avx") { CmdArgs.push_back("-msse2avx"); continue; @@ -2641,10 +2648,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, case llvm::Triple::thumbeb: case llvm::Triple::arm: case llvm::Triple::armeb: -if (Value.starts_with("-mimplicit-it=")) { +if (Equal.first == "-mimplicit-it") { // Only store the value; the last value set takes effect. - ImplicitIt = Value.split("=").second; - if (CheckARMImplicitITArg(ImplicitIt)) + ImplicitIt = Equal.second; + if (CheckARMImplicitITArg(Equal.second)) continue; } if (Value == "-mthumb") @@ -2719,12 +2726,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, Crel = false; } else if (Value == "--allow-experimental-crel") { ExperimentalCrel = true; - } else if (Value == "-mrelax-relocations=yes" || - Value == "--mrelax-relocations=yes") { -UseRelaxRelocations = true; - } else if (Value == "-mrelax-relocations=no" || - Value == "--mrelax-relocations=no") { -UseRelaxRelocations = false; } else if (Value.starts_with("-I")) { CmdArgs.push_back(Value.data()); // We need to consume the next argument if the current arg is a plain diff --git a/clang/test/Driver/ohos.c b/clang/test/Driver/ohos.c index 8de4e6de57f7ff..af8218fb232e60 100644 --- a/clang/test/Driver/ohos.c +++ b/clang/test/Driver/ohos.c @@ -7,7 +7,6 @@ // RUN: --sysroot=%S/Inputs/ohos_native_tree/sysroot -fuse-ld=ld -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=soft 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK,CHECK-ARM-A7-SOFT %s // CHECK: {{.*}}clang{{.*}}" "-cc1" -// CHECK-NOT: "--mrelax-relocations" // CHECK-NOT: "-munwind-tables" // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]" diff --git a/clang/test/Driver/relax.c b/clang/test/Driver/relax.c index 48d22fede12d76..4771b9e3af1116 100644 --- a/clang/test/Driver/relax.c +++ b/clang/test/Driver/relax.c @@ -1,4 +1,10 @@ -// RUN: %clang -### -c -integrated-as -Wa,--mrelax-relocations=no %s 2>&1 | FileCheck %s +// RUN: %clang -### --target=x86_64 -c -Wa,--mrelax-relocations=no %s 2>&1 | FileCheck %s // CHECK: "-cc1" // CHECK: "-mrelax-relocations=no" + +// RUN: not %clang -### --target=x86_64 -c -Wa,-mrelax-relocations=x %s 2>&1 | FileCheck %s --check-prefix=ERR +// ERR: error: unsupported argument '-mrelax-relocations=x' to option '-Wa,' + +// RUN: not %clang -### --target=aarch64 -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR2 +// ERR2: error: unsupported argument '-mrelax-relocations=no' to option '-Wa,' ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3333ec1 - [Driver] Make CodeGenOptions name match MCTargetOptions names
Author: Fangrui Song Date: 2024-08-15T15:52:20-07:00 New Revision: ec1183803fa5a2353e710b8b22db6a72e292 URL: https://github.com/llvm/llvm-project/commit/ec1183803fa5a2353e710b8b22db6a72e292 DIFF: https://github.com/llvm/llvm-project/commit/ec1183803fa5a2353e710b8b22db6a72e292.diff LOG: [Driver] Make CodeGenOptions name match MCTargetOptions names * Initialize `X86RelaxRelocations`. * Fix #96860 test to actually test -Wa,-msse2avx for non-x86. Added: Modified: clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Driver/Options.td clang/lib/CodeGen/BackendUtil.cpp clang/test/Driver/msse2avx.c clang/tools/driver/cc1as_main.cpp Removed: diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 5728ab8d86702..09e892d6d4def 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -37,8 +37,6 @@ VALUE_CODEGENOPT(Name, Bits, Default) CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as CODEGENOPT(Crel, 1, 0) ///< -Wa,--crel -CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no} -CODEGENOPT(SSE2AVX , 1, 0) ///< -msse2avx CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm. CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments. CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new @@ -194,6 +192,8 @@ CODEGENOPT(HIPSaveKernelArgName, 1, 0) ///< Set when -fhip-kernel-arg-name is en CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get unique names. CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using profile information. CODEGENOPT(PPCUseFullRegisterNames, 1, 0) ///< Print full register names in assembly +CODEGENOPT(X86RelaxRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no} +CODEGENOPT(X86Sse2Avx, 1, 0) ///< -Wa,-msse2avx /// When false, this attempts to generate code as if the result of an /// overflowing conversion matches the overflowing behavior of a target's native diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 40df91dc3fe0e..c9ed08c20fc04 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5231,7 +5231,7 @@ let Flags = [TargetSpecific] in { def msse2avx : Flag<["-"], "msse2avx">, Group, Visibility<[ClangOption, CC1Option, CC1AsOption]>, HelpText<"Specify that the assembler should encode SSE instructions with VEX prefix">, - MarshallingInfoFlag>; + MarshallingInfoFlag>; } // let Flags = [TargetSpecific] defm zvector : BoolFOption<"zvector", @@ -7133,7 +7133,7 @@ def crel : Flag<["--"], "crel">, MarshallingInfoFlag>; def mrelax_relocations_no : Flag<["-"], "mrelax-relocations=no">, HelpText<"Disable x86 relax relocations">, -MarshallingInfoNegativeFlag>; +MarshallingInfoNegativeFlag>; def msave_temp_labels : Flag<["-"], "msave-temp-labels">, HelpText<"Save temporary labels in the symbol table. " "Note this may change .s semantics and shouldn't generally be used " diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 81e6702d5de66..34c08818dbb9a 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -471,7 +471,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Options.MCOptions.Crel = CodeGenOpts.Crel; - Options.MCOptions.X86RelaxRelocations = CodeGenOpts.RelaxELFRelocations; + Options.MCOptions.X86RelaxRelocations = CodeGenOpts.X86RelaxRelocations; Options.MCOptions.CompressDebugSections = CodeGenOpts.getCompressDebugSections(); Options.MCOptions.ABIName = TargetOpts.ABI; diff --git a/clang/test/Driver/msse2avx.c b/clang/test/Driver/msse2avx.c index a63ac9a6c8668..829b1b2b79360 100644 --- a/clang/test/Driver/msse2avx.c +++ b/clang/test/Driver/msse2avx.c @@ -1,7 +1,7 @@ -// RUN: %clang -### -c -target x86_64 -march=x86-64 -Xassembler -msse2avx %s 2>&1 | FileCheck %s -// RUN: %clang -### -c -target x86_64 -march=x86-64 -x assembler -Xassembler -msse2avx %s 2>&1 | FileCheck %s +// RUN: %clang -### -c --target=x86_64 -march=x86-64 -Wa,-msse2avx %s 2>&1 | FileCheck %s +// RUN: %clang -### -c --target=x86_64 -march=x86-64 -x assembler -Xassembler -msse2avx %s 2>&1 | FileCheck %s // CHECK: "-msse2avx" -// RUN: not %clang -### -c -target aarch64 -march=armv8a -msse2avx %s 2>&1 | FileCheck --check-prefix=ERR %s -// ERR: error: unsupported option '-msse2avx' for target 'aarch64' +// RUN: not %clang -### -c --target=aarch64 -march=armv8a -Wa,-msse2avx %s 2>&1 | FileCheck --check-prefix=ERR %s +//
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/99615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Support -Wa, options -mmsa and -mno-msa (PR #99615)
@@ -2630,6 +2631,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back("-massembler-no-warn"); } else if (Value == "--noexecstack") { UseNoExecStack = true; + } else if (Value == "-mmsa") { MaskRay wrote: This code block should be moved above to the `switch`. There is a `case llvm::Triple::mips:` for MIPS. https://github.com/llvm/llvm-project/pull/99615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9931357 - [-Wunsafe-buffer-usage] Fix warning after #102953
Author: Fangrui Song Date: 2024-08-15T14:17:26-07:00 New Revision: 99313575b6bb7d5acbe437c2022b6e5dc7f297f1 URL: https://github.com/llvm/llvm-project/commit/99313575b6bb7d5acbe437c2022b6e5dc7f297f1 DIFF: https://github.com/llvm/llvm-project/commit/99313575b6bb7d5acbe437c2022b6e5dc7f297f1.diff LOG: [-Wunsafe-buffer-usage] Fix warning after #102953 Added: Modified: clang/lib/Analysis/UnsafeBufferUsage.cpp Removed: diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp index 95c288bfe3fd2f..da7446913f7c87 100644 --- a/clang/lib/Analysis/UnsafeBufferUsage.cpp +++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -2797,9 +2797,8 @@ fixVariable(const VarDecl *VD, FixitStrategy::Kind K, return {}; } case FixitStrategy::Kind::Array: { -if (VD->isLocalVarDecl()) - if (auto CAT = Ctx.getAsConstantArrayType(VD->getType())) -return fixVariableWithArray(VD, Tracker, Ctx, Handler); +if (VD->isLocalVarDecl() && Ctx.getAsConstantArrayType(VD->getType())) + return fixVariableWithArray(VD, Tracker, Ctx, Handler); DEBUG_NOTE_DECL_FAIL(VD, " : not a local const-size array"); return {}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Don't warn when -S and -c are used together without -fsyntax-only (PR #104477)
MaskRay wrote: > Fixes https://github.com/llvm/llvm-project/issues/104347 I made a comment on #104347 . The warning for `-S -c` works as intended. https://github.com/llvm/llvm-project/pull/104477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits