[clang] [clang][driver] Support option '-r' for target AVR (PR #68484)
https://github.com/benshi001 updated https://github.com/llvm/llvm-project/pull/68484 >From 88e173ea772e2b4996c874a093bab087d5c98187 Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Sat, 7 Oct 2023 20:49:36 +0800 Subject: [PATCH] [clang][driver] Support option '-r' for target AVR If '-r' is specified with target AVR: 1. Do not link to the avr-libc. 2. Do not emit some conflict options. 3. Do not emit any sub-target related address information/warning. --- clang/lib/Driver/ToolChains/AVR.cpp | 37 - clang/test/Driver/avr-ld.c | 27 + 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp index 81f501d417345d1..e312fa155e11bf8 100644 --- a/clang/lib/Driver/ToolChains/AVR.cpp +++ b/clang/lib/Driver/ToolChains/AVR.cpp @@ -457,7 +457,8 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Output.getFilename()); // Enable garbage collection of unused sections. - CmdArgs.push_back("--gc-sections"); + if (!Args.hasArg(options::OPT_r)) +CmdArgs.push_back("--gc-sections"); // Add library search paths before we specify libraries. Args.AddAllArgs(CmdArgs, options::OPT_L); @@ -471,7 +472,7 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, // Only add default libraries if the user hasn't explicitly opted out. bool LinkStdlib = false; - if (!Args.hasArg(options::OPT_nostdlib) && + if (!Args.hasArg(options::OPT_nostdlib) && !Args.hasArg(options::OPT_r) && !Args.hasArg(options::OPT_nodefaultlibs)) { if (!CPU.empty()) { if (!FamilyName) { @@ -497,13 +498,17 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, D.Diag(diag::warn_drv_avr_stdlib_not_linked); } - if (SectionAddressData) { -CmdArgs.push_back( -Args.MakeArgString("--defsym=__DATA_REGION_ORIGIN__=0x" + - Twine::utohexstr(*SectionAddressData))); - } else { -// We do not have an entry for this CPU in the address mapping table yet. -D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) << CPU; + if (!Args.hasArg(options::OPT_r)) { +if (SectionAddressData) { + CmdArgs.push_back( + Args.MakeArgString("--defsym=__DATA_REGION_ORIGIN__=0x" + + Twine::utohexstr(*SectionAddressData))); +} else { + // We do not have an entry for this CPU in the address mapping table + // yet. + D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) + << CPU; +} } if (D.isUsingLTO()) { @@ -554,17 +559,17 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) CmdArgs.push_back("--relax"); - -// Specify the family name as the emulation mode to use. -// This is almost always required because otherwise avr-ld -// will assume 'avr2' and warn about the program being larger -// than the bare minimum supports. -if (Linker.find("avr-ld") != std::string::npos) - CmdArgs.push_back(Args.MakeArgString(std::string("-m") + *FamilyName)); } else { AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); } + // Specify the family name as the emulation mode to use. + // This is almost always required because otherwise avr-ld + // will assume 'avr2' and warn about the program being larger + // than the bare minimum supports. + if (Linker.find("avr-ld") != std::string::npos && FamilyName) +CmdArgs.push_back(Args.MakeArgString(std::string("-m") + *FamilyName)); + C.addCommand(std::make_unique( JA, *this, ResponseFileSupport::AtFileCurCP(), Args.MakeArgString(Linker), CmdArgs, Inputs, Output)); diff --git a/clang/test/Driver/avr-ld.c b/clang/test/Driver/avr-ld.c index 4042ecb89adf5f1..d1da270c634da86 100644 --- a/clang/test/Driver/avr-ld.c +++ b/clang/test/Driver/avr-ld.c @@ -57,3 +57,30 @@ // RUN: %clang -### --target=avr -mmcu=atmega328 -fuse-ld=lld -flto --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKS %s // LINKS: {{".*ld.*"}} {{.*}} "--defsym=__DATA_REGION_ORIGIN__=0x800100" "-plugin-opt=mcpu=atmega328" // LINKS-NOT: "-plugin-opt=thinlto" + +// RUN: %clang -### -r --target=avr -mmcu=atmega328 --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck --check-prefix=LINKU %s +// LINKU: {{".*ld.*"}} {{.*}} "-r" {{.*}} "-mavr5" +// LINKU-NOT: "--gc-sections" +// LINKU-NOT: {{"--defsym.*"}} +// LINKU-NOT: {{"-l.*"}} + +// RUN: %clang -### -r --target=avr -mmcu=atmega328 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck --check-prefix=LINKV %s +// LINKV: {{".*ld.*"}} {{.*}} "-r" +// LINKV-NOT: "--gc-sections" +// LINKV-NOT: {{"--defsym.*"}} +// LINKV-NOT: {{"-l.*"}} +// LINKV-NOT: {{"-m.*"}} + +// RUN: %clang -### -r --target=avr -mmcu=atmega328 -lm --sysroot %S/Inp
[clang-tools-extra] [mlir][memref]: Add expand/collapse rewrite pattern to MemRef::CopyOp (PR #67808)
https://github.com/AviadCo updated https://github.com/llvm/llvm-project/pull/67808 >From a760c42f0c8b75361f822e1efcbdae30151b2180 Mon Sep 17 00:00:00 2001 From: Aviad Cohen Date: Fri, 29 Sep 2023 15:32:18 +0300 Subject: [PATCH] [mlir][memref]: Add expand/collapse rewrite pattern to MemRef::CopyOp This pattern is useful to adjust the memref copy ranks. --- .../MemRef/Transforms/ExpandCollapseCopyOps.h | 45 .../Dialect/MemRef/Transforms/CMakeLists.txt | 1 + .../Transforms/ExpandCollapseCopyOps.cpp | 238 ++ .../Transforms/expand-collapse-copy-ops.mlir | 141 +++ mlir/test/lib/Dialect/MemRef/CMakeLists.txt | 1 + .../MemRef/TestExpandCollapseCopyOps.cpp | 66 + mlir/tools/mlir-opt/mlir-opt.cpp | 2 + 7 files changed, 494 insertions(+) create mode 100644 mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h create mode 100644 mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp create mode 100644 mlir/test/Transforms/expand-collapse-copy-ops.mlir create mode 100644 mlir/test/lib/Dialect/MemRef/TestExpandCollapseCopyOps.cpp diff --git a/mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h b/mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h new file mode 100644 index 000..27a69ab93e42c74 --- /dev/null +++ b/mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h @@ -0,0 +1,45 @@ +//===-- ExpandCollapseCopyOps.h - Expand/Collapse MemRef copy ranks --===// +// +// 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 +// +//===--===// +// +// Patterns for expand collapse MemRef copies. +// +//===--===// + +#ifndef MLIR_DIALECT_MEMREF_TRANSFORMS_EXPAND_COLLAPSE_COPY_OPS_H_ +#define MLIR_DIALECT_MEMREF_TRANSFORMS_EXPAND_COLLAPSE_COPY_OPS_H_ + +#include "mlir/Dialect/MemRef/IR/MemRef.h" + +#include + +namespace mlir { +class MLIRContext; +class RewritePatternSet; + +namespace memref { + +typedef std::function ExpandCollapseFuncCB; +inline bool expandCollapseAny([[maybe_unused]] memref::CopyOp copyOp) { + return true; +} + +/// ExpandCollapseCopyOpConverter is a rewrite pattern that checks +/// if a `memref::CopyOp` should be expanded/collapsed into `minRank` +/// `maxRank` ranks. A selective callback may be provided to distinguish +/// which operations should be expanded/collapsed. +/// In some cases (i.e. the source/target are strided in whole dims), +/// it will not be possible to expanded/collapsed the `memref::CopyOp`. + +void populateExpandCollapseCopyOpsPatterns( +RewritePatternSet &patterns, unsigned minRank = 1, unsigned maxRank = 1, +ExpandCollapseFuncCB funcCB = expandCollapseAny); + +} // namespace memref +} // namespace mlir + +#endif // MLIR_DIALECT_MEMREF_TRANSFORMS_EXPAND_COLLAPSE_COPY_OPS_H_ diff --git a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt index b16c281c93640ea..924feca4cad3012 100644 --- a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt @@ -2,6 +2,7 @@ add_mlir_dialect_library(MLIRMemRefTransforms AllocationOpInterfaceImpl.cpp BufferizableOpInterfaceImpl.cpp ComposeSubView.cpp + ExpandCollapseCopyOps.cpp ExpandOps.cpp ExpandRealloc.cpp ExpandStridedMetadata.cpp diff --git a/mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp b/mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp new file mode 100644 index 000..7905254e71e19fc --- /dev/null +++ b/mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp @@ -0,0 +1,238 @@ +//===- ExpandCollapseCopyOps.cpp - Expand/Collapse rank of source/target copies +//-===// +// +// 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 +// +//===---===// +// +// This file contains rewrite patterns (transformations) to expand/collapse +// MemRef copies. This is useful in architecture which have limitations on +// dimensions of the copy operation. +// +//===--===// + +#include "mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h" +#include "mlir/Dialect/Utils/ReshapeOpsUtils.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Transforms/DialectConversion.h" +#include "mlir/Transforms/GreedyPatternRewriteDriver.h" + +#include + +#define DEBUG_TYPE "expand-collapse-copy-ops" +
[clang] [mlir][memref]: Add expand/collapse rewrite pattern to MemRef::CopyOp (PR #67808)
https://github.com/AviadCo updated https://github.com/llvm/llvm-project/pull/67808 >From a760c42f0c8b75361f822e1efcbdae30151b2180 Mon Sep 17 00:00:00 2001 From: Aviad Cohen Date: Fri, 29 Sep 2023 15:32:18 +0300 Subject: [PATCH] [mlir][memref]: Add expand/collapse rewrite pattern to MemRef::CopyOp This pattern is useful to adjust the memref copy ranks. --- .../MemRef/Transforms/ExpandCollapseCopyOps.h | 45 .../Dialect/MemRef/Transforms/CMakeLists.txt | 1 + .../Transforms/ExpandCollapseCopyOps.cpp | 238 ++ .../Transforms/expand-collapse-copy-ops.mlir | 141 +++ mlir/test/lib/Dialect/MemRef/CMakeLists.txt | 1 + .../MemRef/TestExpandCollapseCopyOps.cpp | 66 + mlir/tools/mlir-opt/mlir-opt.cpp | 2 + 7 files changed, 494 insertions(+) create mode 100644 mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h create mode 100644 mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp create mode 100644 mlir/test/Transforms/expand-collapse-copy-ops.mlir create mode 100644 mlir/test/lib/Dialect/MemRef/TestExpandCollapseCopyOps.cpp diff --git a/mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h b/mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h new file mode 100644 index 000..27a69ab93e42c74 --- /dev/null +++ b/mlir/include/mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h @@ -0,0 +1,45 @@ +//===-- ExpandCollapseCopyOps.h - Expand/Collapse MemRef copy ranks --===// +// +// 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 +// +//===--===// +// +// Patterns for expand collapse MemRef copies. +// +//===--===// + +#ifndef MLIR_DIALECT_MEMREF_TRANSFORMS_EXPAND_COLLAPSE_COPY_OPS_H_ +#define MLIR_DIALECT_MEMREF_TRANSFORMS_EXPAND_COLLAPSE_COPY_OPS_H_ + +#include "mlir/Dialect/MemRef/IR/MemRef.h" + +#include + +namespace mlir { +class MLIRContext; +class RewritePatternSet; + +namespace memref { + +typedef std::function ExpandCollapseFuncCB; +inline bool expandCollapseAny([[maybe_unused]] memref::CopyOp copyOp) { + return true; +} + +/// ExpandCollapseCopyOpConverter is a rewrite pattern that checks +/// if a `memref::CopyOp` should be expanded/collapsed into `minRank` +/// `maxRank` ranks. A selective callback may be provided to distinguish +/// which operations should be expanded/collapsed. +/// In some cases (i.e. the source/target are strided in whole dims), +/// it will not be possible to expanded/collapsed the `memref::CopyOp`. + +void populateExpandCollapseCopyOpsPatterns( +RewritePatternSet &patterns, unsigned minRank = 1, unsigned maxRank = 1, +ExpandCollapseFuncCB funcCB = expandCollapseAny); + +} // namespace memref +} // namespace mlir + +#endif // MLIR_DIALECT_MEMREF_TRANSFORMS_EXPAND_COLLAPSE_COPY_OPS_H_ diff --git a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt index b16c281c93640ea..924feca4cad3012 100644 --- a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt @@ -2,6 +2,7 @@ add_mlir_dialect_library(MLIRMemRefTransforms AllocationOpInterfaceImpl.cpp BufferizableOpInterfaceImpl.cpp ComposeSubView.cpp + ExpandCollapseCopyOps.cpp ExpandOps.cpp ExpandRealloc.cpp ExpandStridedMetadata.cpp diff --git a/mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp b/mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp new file mode 100644 index 000..7905254e71e19fc --- /dev/null +++ b/mlir/lib/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.cpp @@ -0,0 +1,238 @@ +//===- ExpandCollapseCopyOps.cpp - Expand/Collapse rank of source/target copies +//-===// +// +// 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 +// +//===---===// +// +// This file contains rewrite patterns (transformations) to expand/collapse +// MemRef copies. This is useful in architecture which have limitations on +// dimensions of the copy operation. +// +//===--===// + +#include "mlir/Dialect/MemRef/Transforms/ExpandCollapseCopyOps.h" +#include "mlir/Dialect/Utils/ReshapeOpsUtils.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Transforms/DialectConversion.h" +#include "mlir/Transforms/GreedyPatternRewriteDriver.h" + +#include + +#define DEBUG_TYPE "expand-collapse-copy-ops" +
[clang] [clang][driver] Add avr-libc's default linker script to lld (PR #68507)
https://github.com/benshi001 created https://github.com/llvm/llvm-project/pull/68507 If `-fuse-ld=lld` is specified but no user linker script is offered, we try to use avr-libc's default one for lld. (not needed for GNU ld) >From 2ac033cc4750ffda8f1aded4b896de93713047ad Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Sun, 8 Oct 2023 15:00:32 +0800 Subject: [PATCH] [clang][driver] Add avr-libc's default linker script to lld If `-fuse-ld=lld` is specified but no user linker script is offered, we try to use avr-libc's default one for lld. (not needed for GNU ld) --- clang/lib/Driver/ToolChains/AVR.cpp | 14 +++-- .../usr/lib/avr/lib/ldscripts/avrtiny.x | 0 .../usr/lib/avr/lib/ldscripts/avrxmega6.x | 0 clang/test/Driver/avr-ld.c| 21 +++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x create mode 100644 clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp index 81f501d417345d1..9b15b22ecb2218a 100644 --- a/clang/lib/Driver/ToolChains/AVR.cpp +++ b/clang/lib/Driver/ToolChains/AVR.cpp @@ -549,8 +549,18 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("--end-group"); -// Add user specified linker script. -Args.AddAllArgs(CmdArgs, options::OPT_T); +// Add avr-libc's linker script to lld by default, if it exists. +if (!Args.hasArg(options::OPT_T) && +Linker.find("lld") != std::string::npos) { + std::string Path(*AVRLibcRoot + "/lib/ldscripts/"); + Path += *FamilyName; + Path += ".x"; + if (llvm::sys::fs::exists(Path)) +CmdArgs.push_back(Args.MakeArgString("-T" + Path)); +} +// Otherwise add user specified linker script to either avr-ld or lld. +else + Args.AddAllArgs(CmdArgs, options::OPT_T); if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) CmdArgs.push_back("--relax"); diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x new file mode 100644 index 000..e69de29bb2d1d64 diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x new file mode 100644 index 000..e69de29bb2d1d64 diff --git a/clang/test/Driver/avr-ld.c b/clang/test/Driver/avr-ld.c index 4042ecb89adf5f1..769eb8763caaf61 100644 --- a/clang/test/Driver/avr-ld.c +++ b/clang/test/Driver/avr-ld.c @@ -57,3 +57,24 @@ // RUN: %clang -### --target=avr -mmcu=atmega328 -fuse-ld=lld -flto --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKS %s // LINKS: {{".*ld.*"}} {{.*}} "--defsym=__DATA_REGION_ORIGIN__=0x800100" "-plugin-opt=mcpu=atmega328" // LINKS-NOT: "-plugin-opt=thinlto" + +// RUN: %clang -### --target=avr -mmcu=attiny40 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT0 %s +// LINKT0: {{".*lld.*"}} {{.*}} {{"-T.*avrtiny.x"}} +// LINKT0-NOT: "-mavrtiny" + +// RUN: %clang -### --target=avr -mmcu=atxmega384c3 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT1 %s +// LINKT1: {{".*lld.*"}} {{.*}} {{"-T.*avrxmega6.x"}} +// LINKT1-NOT: "-mavrxmega6" + +// RUN: %clang -### --target=avr -mmcu=atmega328 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT2 %s +// LINKT2: {{".*lld.*"}} +// LINKT2-NOT: {{"-T.*"}} + +// RUN: %clang -### --target=avr -mmcu=attiny40 --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT3 %s +// LINKT3: {{".*ld.*"}} {{.*}} "-mavrtiny" +// LINKT3-NOT: {{"-T.*"}} + +// RUN: %clang -### --target=avr -mmcu=attiny40 --sysroot %S/Inputs/basic_avr_tree -fuse-ld=lld -T %S/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x %s 2>&1 | FileCheck -check-prefix LINKT4 %s +// LINKT4: {{".*lld.*"}} {{.*}} {{"-T.*avrxmega6.x"}} +// LINKT4-NOT: {{"-T.*avrtiny.x"}} +// LINKT4-NOT: "-mavrtiny" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add avr-libc's default linker script to lld (PR #68507)
llvmbot wrote: @llvm/pr-subscribers-clang Changes If `-fuse-ld=lld` is specified but no user linker script is offered, we try to use avr-libc's default one for lld. (not needed for GNU ld) --- Full diff: https://github.com/llvm/llvm-project/pull/68507.diff 4 Files Affected: - (modified) clang/lib/Driver/ToolChains/AVR.cpp (+12-2) - (added) clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x () - (added) clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x () - (modified) clang/test/Driver/avr-ld.c (+21) ``diff diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp index 81f501d417345d1..9b15b22ecb2218a 100644 --- a/clang/lib/Driver/ToolChains/AVR.cpp +++ b/clang/lib/Driver/ToolChains/AVR.cpp @@ -549,8 +549,18 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("--end-group"); -// Add user specified linker script. -Args.AddAllArgs(CmdArgs, options::OPT_T); +// Add avr-libc's linker script to lld by default, if it exists. +if (!Args.hasArg(options::OPT_T) && +Linker.find("lld") != std::string::npos) { + std::string Path(*AVRLibcRoot + "/lib/ldscripts/"); + Path += *FamilyName; + Path += ".x"; + if (llvm::sys::fs::exists(Path)) +CmdArgs.push_back(Args.MakeArgString("-T" + Path)); +} +// Otherwise add user specified linker script to either avr-ld or lld. +else + Args.AddAllArgs(CmdArgs, options::OPT_T); if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) CmdArgs.push_back("--relax"); diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x new file mode 100644 index 000..e69de29bb2d1d64 diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x new file mode 100644 index 000..e69de29bb2d1d64 diff --git a/clang/test/Driver/avr-ld.c b/clang/test/Driver/avr-ld.c index 4042ecb89adf5f1..769eb8763caaf61 100644 --- a/clang/test/Driver/avr-ld.c +++ b/clang/test/Driver/avr-ld.c @@ -57,3 +57,24 @@ // RUN: %clang -### --target=avr -mmcu=atmega328 -fuse-ld=lld -flto --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKS %s // LINKS: {{".*ld.*"}} {{.*}} "--defsym=__DATA_REGION_ORIGIN__=0x800100" "-plugin-opt=mcpu=atmega328" // LINKS-NOT: "-plugin-opt=thinlto" + +// RUN: %clang -### --target=avr -mmcu=attiny40 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT0 %s +// LINKT0: {{".*lld.*"}} {{.*}} {{"-T.*avrtiny.x"}} +// LINKT0-NOT: "-mavrtiny" + +// RUN: %clang -### --target=avr -mmcu=atxmega384c3 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT1 %s +// LINKT1: {{".*lld.*"}} {{.*}} {{"-T.*avrxmega6.x"}} +// LINKT1-NOT: "-mavrxmega6" + +// RUN: %clang -### --target=avr -mmcu=atmega328 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT2 %s +// LINKT2: {{".*lld.*"}} +// LINKT2-NOT: {{"-T.*"}} + +// RUN: %clang -### --target=avr -mmcu=attiny40 --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT3 %s +// LINKT3: {{".*ld.*"}} {{.*}} "-mavrtiny" +// LINKT3-NOT: {{"-T.*"}} + +// RUN: %clang -### --target=avr -mmcu=attiny40 --sysroot %S/Inputs/basic_avr_tree -fuse-ld=lld -T %S/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x %s 2>&1 | FileCheck -check-prefix LINKT4 %s +// LINKT4: {{".*lld.*"}} {{.*}} {{"-T.*avrxmega6.x"}} +// LINKT4-NOT: {{"-T.*avrtiny.x"}} +// LINKT4-NOT: "-mavrtiny" `` https://github.com/llvm/llvm-project/pull/68507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add avr-libc's default linker script to lld (PR #68507)
https://github.com/benshi001 updated https://github.com/llvm/llvm-project/pull/68507 >From f13fad7cfcfbf654052d595cf3dd985fbaefeb76 Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Sun, 8 Oct 2023 15:00:32 +0800 Subject: [PATCH] [clang][driver] Add avr-libc's default linker script to lld If `-fuse-ld=lld` is specified but no user linker script is offered, we try to use avr-libc's default one for lld. (not needed for GNU ld) --- clang/lib/Driver/ToolChains/AVR.cpp | 14 +++-- .../usr/lib/avr/lib/ldscripts/avrtiny.x | 0 .../usr/lib/avr/lib/ldscripts/avrxmega6.x | 0 clang/test/Driver/avr-ld.c| 21 +++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x create mode 100644 clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp index 81f501d417345d1..9b15b22ecb2218a 100644 --- a/clang/lib/Driver/ToolChains/AVR.cpp +++ b/clang/lib/Driver/ToolChains/AVR.cpp @@ -549,8 +549,18 @@ void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("--end-group"); -// Add user specified linker script. -Args.AddAllArgs(CmdArgs, options::OPT_T); +// Add avr-libc's linker script to lld by default, if it exists. +if (!Args.hasArg(options::OPT_T) && +Linker.find("lld") != std::string::npos) { + std::string Path(*AVRLibcRoot + "/lib/ldscripts/"); + Path += *FamilyName; + Path += ".x"; + if (llvm::sys::fs::exists(Path)) +CmdArgs.push_back(Args.MakeArgString("-T" + Path)); +} +// Otherwise add user specified linker script to either avr-ld or lld. +else + Args.AddAllArgs(CmdArgs, options::OPT_T); if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) CmdArgs.push_back("--relax"); diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrtiny.x new file mode 100644 index 000..e69de29bb2d1d64 diff --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x new file mode 100644 index 000..e69de29bb2d1d64 diff --git a/clang/test/Driver/avr-ld.c b/clang/test/Driver/avr-ld.c index 4042ecb89adf5f1..0019e46629ae52b 100644 --- a/clang/test/Driver/avr-ld.c +++ b/clang/test/Driver/avr-ld.c @@ -57,3 +57,24 @@ // RUN: %clang -### --target=avr -mmcu=atmega328 -fuse-ld=lld -flto --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKS %s // LINKS: {{".*ld.*"}} {{.*}} "--defsym=__DATA_REGION_ORIGIN__=0x800100" "-plugin-opt=mcpu=atmega328" // LINKS-NOT: "-plugin-opt=thinlto" + +// RUN: %clang -### --target=avr -mmcu=attiny40 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT0 %s +// LINKT0: {{".*lld.*"}} {{.*}} {{"-T.*avrtiny.x"}} +// LINKT0-NOT: "-mavrtiny" + +// RUN: %clang -### --target=avr -mmcu=atxmega384c3 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT1 %s +// LINKT1: {{".*lld.*"}} {{.*}} {{"-T.*avrxmega6.x"}} +// LINKT1-NOT: {{"-m.*"}} + +// RUN: %clang -### --target=avr -mmcu=atmega328 -fuse-ld=lld --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT2 %s +// LINKT2: {{".*lld.*"}} +// LINKT2-NOT: {{"-T.*"}} + +// RUN: %clang -### --target=avr -mmcu=attiny40 --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKT3 %s +// LINKT3: {{".*ld.*"}} {{.*}} "-mavrtiny" +// LINKT3-NOT: {{"-T.*"}} + +// RUN: %clang -### --target=avr -mmcu=attiny40 --sysroot %S/Inputs/basic_avr_tree -fuse-ld=lld -T %S/Inputs/basic_avr_tree/usr/lib/avr/lib/ldscripts/avrxmega6.x %s 2>&1 | FileCheck -check-prefix LINKT4 %s +// LINKT4: {{".*lld.*"}} {{.*}} {{"-T.*avrxmega6.x"}} +// LINKT4-NOT: {{"-T.*avrtiny.x"}} +// LINKT4-NOT: {{"-m.*"}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] Don't emit function bodies which is noinline and av… (PR #68501)
https://github.com/ChuanqiXu9 edited https://github.com/llvm/llvm-project/pull/68501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analysis]Use dyn_cast_or_null instead cast to prevent crash (PR #68510)
https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/68510 `getStorageLocation` may return `nullptr` and this will produce crash when use `cast`, use `dyn_cast_or_null` instead. I test it locally using [FTXUI](https://github.com/ArthurSonzogni/FTXUI) and it may be the cause of issue [issue](https://github.com/llvm/llvm-project/issues/68412), but I am not sure. >From 870856a94dbf10390baaca703d48f988ce070979 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Sun, 8 Oct 2023 16:00:29 +0800 Subject: [PATCH] [clang][analysis]Use dyn_cast_or_null instead cast to prevent crash --- .../FlowSensitive/Models/UncheckedOptionalAccessModel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp index f61f26ff27804ec..dda1c6cfca017d0 100644 --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp @@ -26,6 +26,7 @@ #include "clang/Analysis/FlowSensitive/NoopLattice.h" #include "clang/Analysis/FlowSensitive/StorageLocation.h" #include "clang/Analysis/FlowSensitive/Value.h" +#include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" @@ -599,7 +600,7 @@ void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal, LatticeTransferState &State) { assert(E->getNumArgs() > 0); - if (auto *Loc = cast( + if (auto *Loc = dyn_cast_or_null( State.Env.getStorageLocation(*E->getArg(0 { createOptionalValue(*Loc, HasValueVal, State.Env); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analysis]Use dyn_cast_or_null instead cast to prevent crash (PR #68510)
llvmbot wrote: @llvm/pr-subscribers-clang-analysis Changes `getStorageLocation` may return `nullptr` and this will produce crash when use `cast`, use `dyn_cast_or_null` instead. I test it locally using [FTXUI](https://github.com/ArthurSonzogni/FTXUI) and it may be the cause of issue [issue](https://github.com/llvm/llvm-project/issues/68412), but I am not sure. --- Full diff: https://github.com/llvm/llvm-project/pull/68510.diff 1 Files Affected: - (modified) clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp (+2-1) ``diff diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp index f61f26ff27804ec..dda1c6cfca017d0 100644 --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp @@ -26,6 +26,7 @@ #include "clang/Analysis/FlowSensitive/NoopLattice.h" #include "clang/Analysis/FlowSensitive/StorageLocation.h" #include "clang/Analysis/FlowSensitive/Value.h" +#include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" @@ -599,7 +600,7 @@ void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal, LatticeTransferState &State) { assert(E->getNumArgs() > 0); - if (auto *Loc = cast( + if (auto *Loc = dyn_cast_or_null( State.Env.getStorageLocation(*E->getArg(0 { createOptionalValue(*Loc, HasValueVal, State.Env); `` https://github.com/llvm/llvm-project/pull/68510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow][]Use dyn_cast_or_null instead cast to prevent crash (PR #68510)
https://github.com/jcsxky edited https://github.com/llvm/llvm-project/pull/68510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow]Use dyn_cast_or_null instead cast to prevent crash (PR #68510)
https://github.com/jcsxky edited https://github.com/llvm/llvm-project/pull/68510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow]Use dyn_cast_or_null instead cast to prevent crash (PR #68510)
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/68510 >From b0f13442dd6c41331f9ab43f1cd8ac6bbf0deabe Mon Sep 17 00:00:00 2001 From: huqizhi Date: Sun, 8 Oct 2023 16:00:29 +0800 Subject: [PATCH] [clang][analysis]Use dyn_cast_or_null instead cast to prevent crash --- .../FlowSensitive/Models/UncheckedOptionalAccessModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp index f61f26ff27804ec..3a20bdc4285aee9 100644 --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp @@ -599,7 +599,7 @@ void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal, LatticeTransferState &State) { assert(E->getNumArgs() > 0); - if (auto *Loc = cast( + if (auto *Loc = dyn_cast_or_null( State.Env.getStorageLocation(*E->getArg(0 { createOptionalValue(*Loc, HasValueVal, State.Env); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Add check for bitfield assignments to larger integral types (PR #68276)
vabridgers wrote: Hi @AaronBallman , I ran a compile using this change on clang as you asked and have results. The compile ran with no crashes or errors, and produced 1478 bitfield-conversion warnings. I'll show a few examples below. To put that number into context, I enabled -Wconversion to compare the new warning - bitfield-conversion - with the other conversion checks. You can see from the results that while 1478 findings is large, it's less than 10% of the total conversion findings that exist - so looking at those numbers in context is helpful. Are there any other suggested improvements for this patch, or do you think it's ok to merge?  https://github.com/llvm/llvm-project/pull/68276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU][CUDA] Handle __builtin_printf for device printf (PR #68515)
https://github.com/Maetveis created https://github.com/llvm/llvm-project/pull/68515 Previously `__builtin_printf` would result to emitting call to `printf`, even though directly calling `printf` was translated. Ref: #68478 From 193c652ac8a7a387ce99a63cd09b17bdc44f20a1 Mon Sep 17 00:00:00 2001 From: Gergely Meszaros Date: Sun, 8 Oct 2023 09:30:24 + Subject: [PATCH] [clang][AMDGPU][CUDA] Handle __builtin_printf for device printf Previously __builtin_printf would result to emitting call to printf, even though directly calling printf was translated. Ref: #68478 --- clang/lib/CodeGen/CGBuiltin.cpp | 1 + clang/lib/CodeGen/CGGPUBuiltin.cpp | 3 ++- clang/test/CodeGenCUDA/printf-builtin.cu | 20 clang/test/CodeGenHIP/printf-builtin.hip | 21 + 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGenCUDA/printf-builtin.cu create mode 100644 clang/test/CodeGenHIP/printf-builtin.hip diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index bf984861bccb5cc..c16c005787ca778 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5464,6 +5464,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, Value *HalfVal = Builder.CreateLoad(Address); return RValue::get(Builder.CreateFPExt(HalfVal, Builder.getFloatTy())); } + case Builtin::BI__builtin_printf: case Builtin::BIprintf: if (getTarget().getTriple().isNVPTX() || getTarget().getTriple().isAMDGCN()) { diff --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp b/clang/lib/CodeGen/CGGPUBuiltin.cpp index 75fb06de938425d..794be0520163157 100644 --- a/clang/lib/CodeGen/CGGPUBuiltin.cpp +++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp @@ -135,7 +135,8 @@ RValue EmitDevicePrintfCallExpr(const CallExpr *E, CodeGenFunction *CGF, llvm::Function *Decl, bool WithSizeArg) { CodeGenModule &CGM = CGF->CGM; CGBuilderTy &Builder = CGF->Builder; - assert(E->getBuiltinCallee() == Builtin::BIprintf); + assert(E->getBuiltinCallee() == Builtin::BIprintf || + E->getBuiltinCallee() == Builtin::BI__builtin_printf); assert(E->getNumArgs() >= 1); // printf always has at least one arg. // Uses the same format as nvptx for the argument packing, but also passes diff --git a/clang/test/CodeGenCUDA/printf-builtin.cu b/clang/test/CodeGenCUDA/printf-builtin.cu new file mode 100644 index 000..586d00a878ddf89 --- /dev/null +++ b/clang/test/CodeGenCUDA/printf-builtin.cu @@ -0,0 +1,20 @@ +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -emit-llvm -disable-llvm-optzns -fno-builtin-printf -fcuda-is-device \ +// RUN: -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +extern "C" __device__ int printf(const char *format, ...); + +// CHECK-LABEL: @_Z4foo1v() +__device__ int foo1() { + // CHECK-NOT: call i32 (ptr, ...) @printf + return __builtin_printf("Hello World\n"); +} + +// CHECK-LABEL: @_Z4foo2v() +__device__ int foo2() { + // CHECK: call i32 (ptr, ...) @printf + return printf("Hello World\n"); +} diff --git a/clang/test/CodeGenHIP/printf-builtin.hip b/clang/test/CodeGenHIP/printf-builtin.hip new file mode 100644 index 000..76c7d41376c972d --- /dev/null +++ b/clang/test/CodeGenHIP/printf-builtin.hip @@ -0,0 +1,21 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -disable-llvm-optzns -mprintf-kind=hostcall -fno-builtin-printf -fcuda-is-device \ +// RUN: -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -disable-llvm-optzns -mprintf-kind=buffered -fno-builtin-printf -fcuda-is-device \ +// RUN: -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +extern "C" __device__ int printf(const char *format, ...); + +// CHECK-LABEL: @_Z4foo1v() +__device__ int foo1() { + // CHECK-NOT: call i32 (ptr, ...) @printf + return __builtin_printf("Hello World\n"); +} + +// CHECK-LABEL: @_Z4foo2v() +__device__ int foo2() { + // CHECK: call i32 (ptr, ...) @printf + return printf("Hello World\n"); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU][CUDA] Handle __builtin_printf for device printf (PR #68515)
llvmbot wrote: @llvm/pr-subscribers-clang Changes Previously `__builtin_printf` would result to emitting call to `printf`, even though directly calling `printf` was translated. Ref: #68478 --- Full diff: https://github.com/llvm/llvm-project/pull/68515.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1) - (modified) clang/lib/CodeGen/CGGPUBuiltin.cpp (+2-1) - (added) clang/test/CodeGenCUDA/printf-builtin.cu (+20) - (added) clang/test/CodeGenHIP/printf-builtin.hip (+21) ``diff diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index bf984861bccb5cc..c16c005787ca778 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5464,6 +5464,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, Value *HalfVal = Builder.CreateLoad(Address); return RValue::get(Builder.CreateFPExt(HalfVal, Builder.getFloatTy())); } + case Builtin::BI__builtin_printf: case Builtin::BIprintf: if (getTarget().getTriple().isNVPTX() || getTarget().getTriple().isAMDGCN()) { diff --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp b/clang/lib/CodeGen/CGGPUBuiltin.cpp index 75fb06de938425d..794be0520163157 100644 --- a/clang/lib/CodeGen/CGGPUBuiltin.cpp +++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp @@ -135,7 +135,8 @@ RValue EmitDevicePrintfCallExpr(const CallExpr *E, CodeGenFunction *CGF, llvm::Function *Decl, bool WithSizeArg) { CodeGenModule &CGM = CGF->CGM; CGBuilderTy &Builder = CGF->Builder; - assert(E->getBuiltinCallee() == Builtin::BIprintf); + assert(E->getBuiltinCallee() == Builtin::BIprintf || + E->getBuiltinCallee() == Builtin::BI__builtin_printf); assert(E->getNumArgs() >= 1); // printf always has at least one arg. // Uses the same format as nvptx for the argument packing, but also passes diff --git a/clang/test/CodeGenCUDA/printf-builtin.cu b/clang/test/CodeGenCUDA/printf-builtin.cu new file mode 100644 index 000..586d00a878ddf89 --- /dev/null +++ b/clang/test/CodeGenCUDA/printf-builtin.cu @@ -0,0 +1,20 @@ +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -emit-llvm -disable-llvm-optzns -fno-builtin-printf -fcuda-is-device \ +// RUN: -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +extern "C" __device__ int printf(const char *format, ...); + +// CHECK-LABEL: @_Z4foo1v() +__device__ int foo1() { + // CHECK-NOT: call i32 (ptr, ...) @printf + return __builtin_printf("Hello World\n"); +} + +// CHECK-LABEL: @_Z4foo2v() +__device__ int foo2() { + // CHECK: call i32 (ptr, ...) @printf + return printf("Hello World\n"); +} diff --git a/clang/test/CodeGenHIP/printf-builtin.hip b/clang/test/CodeGenHIP/printf-builtin.hip new file mode 100644 index 000..76c7d41376c972d --- /dev/null +++ b/clang/test/CodeGenHIP/printf-builtin.hip @@ -0,0 +1,21 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -disable-llvm-optzns -mprintf-kind=hostcall -fno-builtin-printf -fcuda-is-device \ +// RUN: -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -disable-llvm-optzns -mprintf-kind=buffered -fno-builtin-printf -fcuda-is-device \ +// RUN: -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +extern "C" __device__ int printf(const char *format, ...); + +// CHECK-LABEL: @_Z4foo1v() +__device__ int foo1() { + // CHECK-NOT: call i32 (ptr, ...) @printf + return __builtin_printf("Hello World\n"); +} + +// CHECK-LABEL: @_Z4foo2v() +__device__ int foo2() { + // CHECK: call i32 (ptr, ...) @printf + return printf("Hello World\n"); +} `` https://github.com/llvm/llvm-project/pull/68515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][NFC]Update test cases after D159250 (PR #68517)
https://github.com/XinWang10 created https://github.com/llvm/llvm-project/pull/68517 None >From 64bd9a87f3043ee6dcab15f8444902657031539c Mon Sep 17 00:00:00 2001 From: XinWang10 Date: Sun, 8 Oct 2023 17:45:32 +0800 Subject: [PATCH] [X86][NFC]Update test cases after D159250 --- .../Preprocessor/predefined-arch-macros-x86.c | 1 + .../Preprocessor/predefined-arch-macros.c | 24 +++ 2 files changed, 25 insertions(+) diff --git a/clang/test/Preprocessor/predefined-arch-macros-x86.c b/clang/test/Preprocessor/predefined-arch-macros-x86.c index 37b7c612b49196e..a727e51bdd45f4f 100644 --- a/clang/test/Preprocessor/predefined-arch-macros-x86.c +++ b/clang/test/Preprocessor/predefined-arch-macros-x86.c @@ -52,3 +52,4 @@ // X86_64_V4-NEXT: #define __AVX512F__ 1 // X86_64_V4-NEXT: #define __AVX512VL__ 1 // X86_64_V4-NOT: #define __AVX512{{.*}} +// X86_64_V4: #define __EVEX512__ 1 diff --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c index 5bb4edb218ec209..d95992dcdff2a94 100644 --- a/clang/test/Preprocessor/predefined-arch-macros.c +++ b/clang/test/Preprocessor/predefined-arch-macros.c @@ -799,6 +799,7 @@ // CHECK_KNL_M32: #define __AVX__ 1 // CHECK_KNL_M32: #define __BMI2__ 1 // CHECK_KNL_M32: #define __BMI__ 1 +// CHECK_KNL_M32: #define __EVEX512__ 1 // CHECK_KNL_M32: #define __F16C__ 1 // CHECK_KNL_M32: #define __FMA__ 1 // CHECK_KNL_M32: #define __LZCNT__ 1 @@ -836,6 +837,7 @@ // CHECK_KNL_M64: #define __AVX__ 1 // CHECK_KNL_M64: #define __BMI2__ 1 // CHECK_KNL_M64: #define __BMI__ 1 +// CHECK_KNL_M64: #define __EVEX512__ 1 // CHECK_KNL_M64: #define __F16C__ 1 // CHECK_KNL_M64: #define __FMA__ 1 // CHECK_KNL_M64: #define __LZCNT__ 1 @@ -877,6 +879,7 @@ // CHECK_KNM_M32: #define __AVX__ 1 // CHECK_KNM_M32: #define __BMI2__ 1 // CHECK_KNM_M32: #define __BMI__ 1 +// CHECK_KNM_M32: #define __EVEX512__ 1 // CHECK_KNM_M32: #define __F16C__ 1 // CHECK_KNM_M32: #define __FMA__ 1 // CHECK_KNM_M32: #define __LZCNT__ 1 @@ -912,6 +915,7 @@ // CHECK_KNM_M64: #define __AVX__ 1 // CHECK_KNM_M64: #define __BMI2__ 1 // CHECK_KNM_M64: #define __BMI__ 1 +// CHECK_KNM_M64: #define __EVEX512__ 1 // CHECK_KNM_M64: #define __F16C__ 1 // CHECK_KNM_M64: #define __FMA__ 1 // CHECK_KNM_M64: #define __LZCNT__ 1 @@ -952,6 +956,7 @@ // CHECK_SKX_M32: #define __BMI__ 1 // CHECK_SKX_M32: #define __CLFLUSHOPT__ 1 // CHECK_SKX_M32: #define __CLWB__ 1 +// CHECK_SKX_M32: #define __EVEX512__ 1 // CHECK_SKX_M32: #define __F16C__ 1 // CHECK_SKX_M32: #define __FMA__ 1 // CHECK_SKX_M32: #define __INVPCID__ 1 @@ -997,6 +1002,7 @@ // CHECK_SKX_M64: #define __BMI__ 1 // CHECK_SKX_M64: #define __CLFLUSHOPT__ 1 // CHECK_SKX_M64: #define __CLWB__ 1 +// CHECK_SKX_M64: #define __EVEX512__ 1 // CHECK_SKX_M64: #define __F16C__ 1 // CHECK_SKX_M64: #define __FMA__ 1 // CHECK_SKX_M64: #define __INVPCID__ 1 @@ -1046,6 +1052,7 @@ // CHECK_CLX_M32: #define __BMI__ 1 // CHECK_CLX_M32: #define __CLFLUSHOPT__ 1 // CHECK_CLX_M32: #define __CLWB__ 1 +// CHECK_CLX_M32: #define __EVEX512__ 1 // CHECK_CLX_M32: #define __F16C__ 1 // CHECK_CLX_M32: #define __FMA__ 1 // CHECK_CLX_M32: #define __INVPCID__ 1 @@ -1092,6 +1099,7 @@ // CHECK_CLX_M64: #define __BMI__ 1 // CHECK_CLX_M64: #define __CLFLUSHOPT__ 1 // CHECK_CLX_M64: #define __CLWB__ 1 +// CHECK_CLX_M64: #define __EVEX512__ 1 // CHECK_CLX_M64: #define __F16C__ 1 // CHECK_CLX_M64: #define __FMA__ 1 // CHECK_CLX_M64: #define __INVPCID__ 1 @@ -1142,6 +1150,7 @@ // CHECK_CPX_M32: #define __BMI__ 1 // CHECK_CPX_M32: #define __CLFLUSHOPT__ 1 // CHECK_CPX_M32: #define __CLWB__ 1 +// CHECK_CPX_M32: #define __EVEX512__ 1 // CHECK_CPX_M32: #define __F16C__ 1 // CHECK_CPX_M32: #define __FMA__ 1 // CHECK_CPX_M32: #define __INVPCID__ 1 @@ -1189,6 +1198,7 @@ // CHECK_CPX_M64: #define __BMI__ 1 // CHECK_CPX_M64: #define __CLFLUSHOPT__ 1 // CHECK_CPX_M64: #define __CLWB__ 1 +// CHECK_CPX_M64: #define __EVEX512__ 1 // CHECK_CPX_M64: #define __F16C__ 1 // CHECK_CPX_M64: #define __FMA__ 1 // CHECK_CPX_M64: #define __INVPCID__ 1 @@ -1239,6 +1249,7 @@ // CHECK_CNL_M32: #define __BMI__ 1 // CHECK_CNL_M32: #define __CLFLUSHOPT__ 1 // CHECK_CNL_M32-NOT: #define __CLWB__ 1 +// CHECK_CNL_M32: #define __EVEX512__ 1 // CHECK_CNL_M32: #define __F16C__ 1 // CHECK_CNL_M32: #define __FMA__ 1 // CHECK_CNL_M32: #define __INVPCID__ 1 @@ -1287,6 +1298,7 @@ // CHECK_CNL_M64: #define __BMI__ 1 // CHECK_CNL_M64: #define __CLFLUSHOPT__ 1 // CHECK_CNL_M64-NOT: #define __CLWB__ 1 +// CHECK_CNL_M64: #define __EVEX512__ 1 // CHECK_CNL_M64: #define __F16C__ 1 // CHECK_CNL_M64: #define __FMA__ 1 // CHECK_CNL_M64: #define __INVPCID__ 1 @@ -1343,6 +1355,7 @@ // CHECK_ICL_M32: #define __BMI__ 1 // CHECK_ICL_M32: #define __CLFLUSHOPT__ 1 // CHECK_ICL_M32-NOT: #define __CLWB__ 1 +// CHECK_ICL_M32: #define __EVEX512__ 1 // CHECK_ICL_M32: #define __F16C__ 1 // CHECK_ICL_M32: #define __FMA__ 1 // CHECK_I
[libunwind] MIPS/libunwind: Use -mfp64 if compiler is FPXX (PR #68521)
https://github.com/wzssyqa created https://github.com/llvm/llvm-project/pull/68521 Libunwind supports FP64 and FP32 modes, but not FPXX. The reason is that, FP64 and FP32 have different way to save/restore FPRs. If libunwind is built as FPXX, we have no idea which one should we use. If libunwind is built as FP64, it will interoperatable with FPXX/FP64 APPs, and if it is built as FP32, it will interoperatable with FP32/FPXX. Currently most of O32 APPs are FPXX or FP64, while few are FP32. So if the compiler is FPXX, which is the default value of most toolchain, let's switch it to FP64. >From dad17bc3806edd2055fae654a023f4c5473a8276 Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Sun, 8 Oct 2023 07:12:45 -0400 Subject: [PATCH] MIPS/libunwind: Use -mfp64 if compiler is FPXX Libunwind supports FP64 and FP32 modes, but not FPXX. The reason is that, FP64 and FP32 have different way to save/restore FPRs. If libunwind is built as FPXX, we have no idea which one should we use. If libunwind is built as FP64, it will interoperatable with FPXX/FP64 APPs, and if it is built as FP32, it will interoperatable with FP32/FPXX. Currently most of O32 APPs are FPXX or FP64, while few are FP32. So if the compiler is FPXX, which is the default value of most toolchain, let's switch it to FP64. --- libunwind/CMakeLists.txt | 19 +++ 1 file changed, 19 insertions(+) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 84f8ce296a7410b..387d4b43b5746a6 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -21,6 +21,7 @@ set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH "Specify path to libc++ source.") include(GNUInstallDirs) +include(CheckSymbolExists) #=== # Setup CMake Options @@ -101,6 +102,20 @@ endif() option(LIBUNWIND_HIDE_SYMBOLS "Do not export any symbols from the static library." ${LIBUNWIND_DEFAULT_HIDE_SYMBOLS}) +# If toolchain is FPXX, we switch to FP64 to save the full FPRs. See: +# https://web.archive.org/web/20180828210612/https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking +check_symbol_exists(__mips_hard_float "" __MIPSHF) +check_symbol_exists(_ABIO32 "" __MIPS_O32) +if (__MIPSHF AND __MIPS_O32) + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/mips_is_fpxx.c +"#if __mips_fpr != 0\n" +"# error\n" +"#endif\n") + try_compile(MIPS_FPABI_FPXX ${CMAKE_BINARY_DIR} +${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/mips_is_fpxx.c +CMAKE_FLAGS -DCMAKE_C_LINK_EXECUTABLE='echo') +endif() + #=== # Configure System #=== @@ -184,6 +199,10 @@ if (WIN32) add_compile_flags_if_supported(-Wno-dll-attribute-on-redeclaration) endif() +if (MIPS_FPABI_FPXX) + add_compile_flags(-mfp64) +endif() + # Get feature flags. # Exceptions # Catches C++ exceptions only and tells the compiler to assume that extern C ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] MIPS/libunwind: Use -mfp64 if compiler is FPXX (PR #68521)
llvmbot wrote: @llvm/pr-subscribers-libunwind Changes Libunwind supports FP64 and FP32 modes, but not FPXX. The reason is that, FP64 and FP32 have different way to save/restore FPRs. If libunwind is built as FPXX, we have no idea which one should we use. If libunwind is built as FP64, it will interoperatable with FPXX/FP64 APPs, and if it is built as FP32, it will interoperatable with FP32/FPXX. Currently most of O32 APPs are FPXX or FP64, while few are FP32. So if the compiler is FPXX, which is the default value of most toolchain, let's switch it to FP64. --- Full diff: https://github.com/llvm/llvm-project/pull/68521.diff 1 Files Affected: - (modified) libunwind/CMakeLists.txt (+19) ``diff diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 84f8ce296a7410b..387d4b43b5746a6 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -21,6 +21,7 @@ set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH "Specify path to libc++ source.") include(GNUInstallDirs) +include(CheckSymbolExists) #=== # Setup CMake Options @@ -101,6 +102,20 @@ endif() option(LIBUNWIND_HIDE_SYMBOLS "Do not export any symbols from the static library." ${LIBUNWIND_DEFAULT_HIDE_SYMBOLS}) +# If toolchain is FPXX, we switch to FP64 to save the full FPRs. See: +# https://web.archive.org/web/20180828210612/https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking +check_symbol_exists(__mips_hard_float "" __MIPSHF) +check_symbol_exists(_ABIO32 "" __MIPS_O32) +if (__MIPSHF AND __MIPS_O32) + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/mips_is_fpxx.c +"#if __mips_fpr != 0\n" +"# error\n" +"#endif\n") + try_compile(MIPS_FPABI_FPXX ${CMAKE_BINARY_DIR} +${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/mips_is_fpxx.c +CMAKE_FLAGS -DCMAKE_C_LINK_EXECUTABLE='echo') +endif() + #=== # Configure System #=== @@ -184,6 +199,10 @@ if (WIN32) add_compile_flags_if_supported(-Wno-dll-attribute-on-redeclaration) endif() +if (MIPS_FPABI_FPXX) + add_compile_flags(-mfp64) +endif() + # Get feature flags. # Exceptions # Catches C++ exceptions only and tells the compiler to assume that extern C `` https://github.com/llvm/llvm-project/pull/68521 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][NFC]Update test cases after D159250 (PR #68517)
https://github.com/FreddyLeaf approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/68517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] __is_trivially_equality_comparable for types containing lambdas (PR #68506)
https://github.com/AMP999 updated https://github.com/llvm/llvm-project/pull/68506 >From ae2cd56b1c68353aae6c74524e71973ce6ca6904 Mon Sep 17 00:00:00 2001 From: Amirreza Ashouri Date: Sat, 7 Oct 2023 19:02:34 +0330 Subject: [PATCH 1/2] [clang] Rename some misleading names (Non-functional) These names could be misleading; should we change them to `NonTriviallyComparable` instead? --- clang/test/SemaCXX/type-traits.cpp | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp index a35689d52978fcc..a1315f1966a6dd4 100644 --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/test/SemaCXX/type-traits.cpp @@ -3160,11 +3160,18 @@ static_assert(!__is_trivially_equality_comparable(float), ""); static_assert(!__is_trivially_equality_comparable(double), ""); static_assert(!__is_trivially_equality_comparable(long double), ""); -struct TriviallyEqualityComparableNoDefaultedComparator { +struct NonTriviallyEqualityComparableNoComparator { int i; int j; }; -static_assert(!__is_trivially_equality_comparable(TriviallyEqualityComparableNoDefaultedComparator), ""); +static_assert(!__is_trivially_equality_comparable(NonTriviallyEqualityComparableNoComparator), ""); + +struct NonTriviallyEqualityComparableNonDefaultedComparator { + int i; + int j; + bool operator==(const NonTriviallyEqualityComparableNonDefaultedComparator&); +}; +static_assert(!__is_trivially_equality_comparable(NonTriviallyEqualityComparableNonDefaultedComparator), ""); #if __cplusplus >= 202002L @@ -3177,7 +3184,7 @@ struct TriviallyEqualityComparable { bool operator==(const TriviallyEqualityComparable&) const = default; }; -static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable), ""); +static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable)); struct TriviallyEqualityComparableContainsArray { int a[4]; >From a584b4bdd6bad3a8c8db3249b096e18c5e955839 Mon Sep 17 00:00:00 2001 From: Amirreza Ashouri Date: Sat, 7 Oct 2023 19:07:32 +0330 Subject: [PATCH 2/2] [clang] __is_trivially_equality_comparable for types containing lambdas Lambdas (closure types) are trivially equality-comparable iff they are non-capturing, because non-capturing lambdas are convertible to function pointers: if (lam1 == lam2) compiles, then lam1 and lam2 must have the same type, and be always-equal, and be empty. --- clang/lib/AST/Type.cpp | 828 +++-- clang/test/SemaCXX/type-traits.cpp | 11 + 2 files changed, 452 insertions(+), 387 deletions(-) diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 4c433f7fe9daca0..324f5321e631b52 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -59,21 +59,21 @@ using namespace clang; bool Qualifiers::isStrictSupersetOf(Qualifiers Other) const { return (*this != Other) && -// CVR qualifiers superset -(((Mask & CVRMask) | (Other.Mask & CVRMask)) == (Mask & CVRMask)) && -// ObjC GC qualifiers superset -((getObjCGCAttr() == Other.getObjCGCAttr()) || - (hasObjCGCAttr() && !Other.hasObjCGCAttr())) && -// Address space superset. -((getAddressSpace() == Other.getAddressSpace()) || - (hasAddressSpace()&& !Other.hasAddressSpace())) && -// Lifetime qualifier superset. -((getObjCLifetime() == Other.getObjCLifetime()) || - (hasObjCLifetime() && !Other.hasObjCLifetime())); -} - -const IdentifierInfo* QualType::getBaseTypeIdentifier() const { - const Type* ty = getTypePtr(); + // CVR qualifiers superset + (((Mask & CVRMask) | (Other.Mask & CVRMask)) == (Mask & CVRMask)) && + // ObjC GC qualifiers superset + ((getObjCGCAttr() == Other.getObjCGCAttr()) || + (hasObjCGCAttr() && !Other.hasObjCGCAttr())) && + // Address space superset. + ((getAddressSpace() == Other.getAddressSpace()) || + (hasAddressSpace() && !Other.hasAddressSpace())) && + // Lifetime qualifier superset. + ((getObjCLifetime() == Other.getObjCLifetime()) || + (hasObjCLifetime() && !Other.hasObjCLifetime())); +} + +const IdentifierInfo *QualType::getBaseTypeIdentifier() const { + const Type *ty = getTypePtr(); NamedDecl *ND = nullptr; if (ty->isPointerType() || ty->isReferenceType()) return ty->getPointeeType().getBaseTypeIdentifier(); @@ -84,8 +84,9 @@ const IdentifierInfo* QualType::getBaseTypeIdentifier() const { else if (ty->getTypeClass() == Type::Typedef) ND = ty->castAs()->getDecl(); else if (ty->isArrayType()) -return ty->castAsArrayTypeUnsafe()-> -getElementType().getBaseTypeIdentifier(); +return ty->castAsArrayTypeUnsafe() +->getElementType() +.getBaseTypeIdentifier(); if (ND) return ND->getIdentifier(); @@ -114,7 +115,7 @@ bool QualType::isConstant(QualType T, const ASTContext &Ctx) { std::optional QualType::isNonConstantStorage(cons
[clang] [Clang][Frontend] Fix a crash when -Wdocumentation is used (PR #68525)
https://github.com/bc-lee created https://github.com/llvm/llvm-project/pull/68525 This commit resolves a crash issue in Clang's frontend caused while using the `-Wdocumentation` compiler flag. The flaw was due to the lack of necessary checks before the extraction of text between the comment and the declaration in the `ASTContext.cpp` file. Specifically, there was no verification to ensure that the second component of the declaration location's decomposition is not less than the comment's end offset. This could lead to an invalid length being passed to the `StringRef` constructor, triggering the crash. I have added a check to prevent this crash from occurring. Fixes #68524. >From 83977fda4860a6b2a99c9f5ad166fd62a8735da1 Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Sun, 8 Oct 2023 21:47:05 +0900 Subject: [PATCH] [Clang][Frontend] Fix a crash when -Wdocumentation is used This commit resolves a crash issue in Clang's frontend caused while using the `-Wdocumentation` compiler flag. The flaw was due to the lack of necessary checks before the extraction of text between the comment and the declaration in the `ASTContext.cpp` file. Specifically, there was no verification to ensure that the second component of the declaration location's decomposition is not less than the comment's end offset. This could lead to an invalid length being passed to the `StringRef` constructor, triggering the crash. I have added a check to prevent this crash from occurring. Fixes #68524. --- clang/lib/AST/ASTContext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index cdc3d62bca00873..7b4a4202921281c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -344,6 +344,9 @@ RawComment *ASTContext::getRawCommentForDeclNoCacheImpl( if (Invalid) return nullptr; + if (DeclLocDecomp.second < CommentEndOffset) +return nullptr; + // Extract text between the comment and declaration. StringRef Text(Buffer + CommentEndOffset, DeclLocDecomp.second - CommentEndOffset); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Frontend] Fix a crash when -Wdocumentation is used (PR #68525)
llvmbot wrote: @llvm/pr-subscribers-clang Changes This commit resolves a crash issue in Clang's frontend caused while using the `-Wdocumentation` compiler flag. The flaw was due to the lack of necessary checks before the extraction of text between the comment and the declaration in the `ASTContext.cpp` file. Specifically, there was no verification to ensure that the second component of the declaration location's decomposition is not less than the comment's end offset. This could lead to an invalid length being passed to the `StringRef` constructor, triggering the crash. I have added a check to prevent this crash from occurring. Fixes #68524. --- Full diff: https://github.com/llvm/llvm-project/pull/68525.diff 1 Files Affected: - (modified) clang/lib/AST/ASTContext.cpp (+3) ``diff diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index cdc3d62bca00873..7b4a4202921281c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -344,6 +344,9 @@ RawComment *ASTContext::getRawCommentForDeclNoCacheImpl( if (Invalid) return nullptr; + if (DeclLocDecomp.second < CommentEndOffset) +return nullptr; + // Extract text between the comment and declaration. StringRef Text(Buffer + CommentEndOffset, DeclLocDecomp.second - CommentEndOffset); `` https://github.com/llvm/llvm-project/pull/68525 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] static operators should evaluate object argument (PR #68485)
https://github.com/SuperSodaSea updated https://github.com/llvm/llvm-project/pull/68485 >From 03276260c48d9cafb2a0d80825156e77cdf02eba Mon Sep 17 00:00:00 2001 From: SuperSodaSea Date: Sat, 7 Oct 2023 21:05:17 +0800 Subject: [PATCH 1/2] [clang] static operators should evaluate object argument --- clang/lib/AST/ExprConstant.cpp| 3 +- clang/lib/CodeGen/CGExpr.cpp | 2 +- clang/lib/CodeGen/CGExprCXX.cpp | 41 -- clang/lib/CodeGen/CodeGenFunction.h | 3 + clang/lib/Sema/SemaChecking.cpp | 5 +- clang/lib/Sema/SemaOverload.cpp | 33 --- clang/test/AST/ast-dump-static-operators.cpp | 55 +++ .../CodeGenCXX/cxx2b-static-call-operator.cpp | 26 ++--- .../cxx2b-static-subscript-operator.cpp | 11 +++- 9 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 clang/test/AST/ast-dump-static-operators.cpp diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5a33e918db8e8c0..a6c81f467fbe01c 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -7806,7 +7806,8 @@ class ExprEvaluatorBase // Overloaded operator calls to member functions are represented as normal // calls with '*this' as the first argument. const CXXMethodDecl *MD = dyn_cast(FD); - if (MD && MD->isImplicitObjectMemberFunction()) { + if (MD && + (MD->isImplicitObjectMemberFunction() || (OCE && MD->isStatic( { // FIXME: When selecting an implicit conversion for an overloaded // operator delete, we sometimes try to evaluate calls to conversion // operators without a 'this' parameter! diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 54a1d300a9ac738..19406ff174dea14 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -5070,7 +5070,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, if (const auto *CE = dyn_cast(E)) if (const auto *MD = dyn_cast_if_present(CE->getCalleeDecl()); -MD && MD->isImplicitObjectMemberFunction()) +MD && !MD->isExplicitObjectMemberFunction()) return EmitCXXOperatorMemberCallExpr(CE, MD, ReturnValue); CGCallee callee = EmitCallee(E->getCallee()); diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 2e7059cc8f5b639..a580c635998510f 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -489,11 +489,42 @@ RValue CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue) { - assert(MD->isImplicitObjectMemberFunction() && - "Trying to emit a member call expr on a static method!"); - return EmitCXXMemberOrOperatorMemberCallExpr( - E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, - /*IsArrow=*/false, E->getArg(0)); + assert(!MD->isExplicitObjectMemberFunction() && + "Trying to emit a member call expr on an explicit object member " + "function!"); + + if (MD->isStatic()) +return EmitCXXStaticOperatorMemberCallExpr(E, MD, ReturnValue); + else +return EmitCXXMemberOrOperatorMemberCallExpr( +E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, +/*IsArrow=*/false, E->getArg(0)); +} + +RValue CodeGenFunction::EmitCXXStaticOperatorMemberCallExpr( +const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, +ReturnValueSlot ReturnValue) { + assert(MD->isStatic()); + + CGCallee Callee = EmitCallee(E->getCallee()); + + // Emit and ignore `this` pointer. + EmitIgnoredExpr(E->getArg(0)); + + auto ProtoType = MD->getFunctionType()->castAs(); + + // Emit the rest of the call args. + CallArgList Args; + EmitCallArgs(Args, ProtoType, drop_begin(E->arguments(), 1), + E->getDirectCallee()); + + bool Chain = E == MustTailCall; + const CGFunctionInfo &FnInfo = + CGM.getTypes().arrangeFreeFunctionCall(Args, ProtoType, Chain); + llvm::CallBase *CallOrInvoke = nullptr; + + return EmitCall(FnInfo, Callee, ReturnValue, Args, &CallOrInvoke, Chain, + E->getExprLoc()); } RValue CodeGenFunction::EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index d5336382a2b9c95..42de125e7489911 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4163,6 +4163,9 @@ class CodeGenFunction : public CodeGenTypeCache { RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue); + RValue EmitCXXStaticOperatorMemberCallExpr(const CXXOperatorCallEx
[clang] [clang] static operators should evaluate object argument (PR #68485)
https://github.com/SuperSodaSea edited https://github.com/llvm/llvm-project/pull/68485 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][NFC]Update test cases after D159250 (PR #68517)
https://github.com/phoebewang approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/68517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Frontend] Fix a crash when -Wdocumentation is used (PR #68525)
https://github.com/bc-lee updated https://github.com/llvm/llvm-project/pull/68525 >From b272173acb8c2f92b5c5b7ebca4c00e4ac21037c Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Sun, 8 Oct 2023 21:47:05 +0900 Subject: [PATCH] [Clang][Frontend] Fix a crash when -Wdocumentation is used This commit resolves a crash issue in Clang's frontend caused while using the `-Wdocumentation` compiler flag. The flaw was due to the lack of necessary checks before the extraction of text between the comment and the declaration in the `ASTContext.cpp` file. Specifically, there was no verification to ensure that the second component of the declaration location's decomposition is not less than the comment's end offset. This could lead to an invalid length being passed to the `StringRef` constructor, triggering the crash. I have added a check to prevent this crash from occurring. Fixes #68524. --- clang/lib/AST/ASTContext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index cdc3d62bca00873..7b4a4202921281c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -344,6 +344,9 @@ RawComment *ASTContext::getRawCommentForDeclNoCacheImpl( if (Invalid) return nullptr; + if (DeclLocDecomp.second < CommentEndOffset) +return nullptr; + // Extract text between the comment and declaration. StringRef Text(Buffer + CommentEndOffset, DeclLocDecomp.second - CommentEndOffset); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] __is_trivially_equality_comparable for types containing lambdas (PR #68506)
https://github.com/AMP999 updated https://github.com/llvm/llvm-project/pull/68506 >From ae2cd56b1c68353aae6c74524e71973ce6ca6904 Mon Sep 17 00:00:00 2001 From: Amirreza Ashouri Date: Sat, 7 Oct 2023 19:02:34 +0330 Subject: [PATCH 1/2] [clang] Rename some misleading names (Non-functional) These names could be misleading; should we change them to `NonTriviallyComparable` instead? --- clang/test/SemaCXX/type-traits.cpp | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp index a35689d52978fcc..a1315f1966a6dd4 100644 --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/test/SemaCXX/type-traits.cpp @@ -3160,11 +3160,18 @@ static_assert(!__is_trivially_equality_comparable(float), ""); static_assert(!__is_trivially_equality_comparable(double), ""); static_assert(!__is_trivially_equality_comparable(long double), ""); -struct TriviallyEqualityComparableNoDefaultedComparator { +struct NonTriviallyEqualityComparableNoComparator { int i; int j; }; -static_assert(!__is_trivially_equality_comparable(TriviallyEqualityComparableNoDefaultedComparator), ""); +static_assert(!__is_trivially_equality_comparable(NonTriviallyEqualityComparableNoComparator), ""); + +struct NonTriviallyEqualityComparableNonDefaultedComparator { + int i; + int j; + bool operator==(const NonTriviallyEqualityComparableNonDefaultedComparator&); +}; +static_assert(!__is_trivially_equality_comparable(NonTriviallyEqualityComparableNonDefaultedComparator), ""); #if __cplusplus >= 202002L @@ -3177,7 +3184,7 @@ struct TriviallyEqualityComparable { bool operator==(const TriviallyEqualityComparable&) const = default; }; -static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable), ""); +static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable)); struct TriviallyEqualityComparableContainsArray { int a[4]; >From d703c4a219f94342db942c2a786eaae86587d242 Mon Sep 17 00:00:00 2001 From: Amirreza Ashouri Date: Sun, 8 Oct 2023 18:00:51 +0330 Subject: [PATCH 2/2] [clang] __is_trivially_equality_comparable for types containing lambdas Lambdas (closure types) are trivially equality-comparable iff they are non-capturing, because non-capturing lambdas are convertible to function pointers: if `(lam1 == lam2)` compiles, then `lam1` and `lam2` must have the same type, and be always-equal, and be empty. --- clang/lib/AST/Type.cpp | 3 +++ clang/test/SemaCXX/type-traits.cpp | 11 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 4c433f7fe9daca0..23f856c715a5e13 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2663,6 +2663,9 @@ static bool HasNonDeletedDefaultedEqualityComparison(const CXXRecordDecl *Decl) { if (Decl->isUnion()) return false; + if (Decl->isLambda()) +return Decl->captures().empty() && + (Decl->getLambdaCaptureDefault() == LCD_None); auto IsDefaultedOperatorEqualEqual = [&](const FunctionDecl *Function) { return Function->getOverloadedOperator() == diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp index a1315f1966a6dd4..275ddcbae73930d 100644 --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/test/SemaCXX/type-traits.cpp @@ -3200,6 +3200,17 @@ struct TriviallyEqualityComparableContainsMultiDimensionArray { }; static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsMultiDimensionArray)); +auto GetNonCapturingLambda() { return [](){ return 42; }; } + +struct TriviallyEqualityComparableContainsLambda { + [[no_unique_address]] decltype(GetNonCapturingLambda()) l; + int i; + + bool operator==(const TriviallyEqualityComparableContainsLambda&) const = default; +}; +static_assert(!__is_trivially_equality_comparable(decltype(GetNonCapturingLambda(; // padding +static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsLambda)); + struct TriviallyEqualityComparableNonTriviallyCopyable { TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable&); ~TriviallyEqualityComparableNonTriviallyCopyable(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)
nikic added a comment. FYI this causes some compile-time regression: http://llvm-compile-time-tracker.com/compare.php?from=bc7d88faf1a595ab59952a2054418cdd0d98&to=af4751738db89a142a8880c782d12d4201b222a8&stat=instructions:u About 0.7% for C++ code at `O0`. Sample for a file with >2% would be btSoftSoftCollisionAlgorithm.cpp. Not sure to what degree this is expected or not. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140828/new/ https://reviews.llvm.org/D140828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] -fsanitize=alignment: check memcpy/memmove arguments (PR #67766)
MaskRay wrote: > @zygoloid Thanks for the explanation! I wasn't aware this fell under > unspecified behavior. It's weird that alignment information can survive a > `void *` cast, but it does make some sense. Yes, `(void *)x` decreases the alignment requirement to 1 byte like `(char *)x`. > What seems worrying here is that apparently GCC and Clang do not agree on > semantics in this case > ([godbolt.org/z/1r9df5a4a](https://godbolt.org/z/1r9df5a4a)). GCC does not > assume that the pointers are aligned. The perils of unspecified behavior Yes... I am out of town and will merge this PR later. https://github.com/llvm/llvm-project/pull/67766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D154893: [Clang] Fix some triviality computations
royjacobson added a comment. I, uh, got preoccupied by some recent events. Don't think I'll have the time for this unfortunately. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154893/new/ https://reviews.llvm.org/D154893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D159393: [clang] Fix several issues in the generated AttrHasAttributeImpl.inc
barannikov88 updated this revision to Diff 557642. barannikov88 added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D159393/new/ https://reviews.llvm.org/D159393 Files: clang/test/Preprocessor/has_attribute.c clang/test/Preprocessor/has_attribute.cpp clang/test/Preprocessor/has_c_attribute.c clang/utils/TableGen/ClangAttrEmitter.cpp Index: clang/utils/TableGen/ClangAttrEmitter.cpp === --- clang/utils/TableGen/ClangAttrEmitter.cpp +++ clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3434,9 +3434,10 @@ } static void GenerateHasAttrSpellingStringSwitch( -const std::vector &Attrs, raw_ostream &OS, -const std::string &Variety = "", const std::string &Scope = "") { - for (const auto *Attr : Attrs) { +const std::vector> &Attrs, +raw_ostream &OS, const std::string &Variety, +const std::string &Scope = "") { + for (const auto &[Attr, Spelling] : Attrs) { // C++11-style attributes have specific version information associated with // them. If the attribute has no scope, the version information must not // have the default value (1), as that's incorrect. Instead, the unscoped @@ -3455,26 +3456,22 @@ // a way that is impactful to the end user. int Version = 1; -std::vector Spellings = GetFlattenedSpellings(*Attr); +assert(Spelling.variety() == Variety); std::string Name = ""; -for (const auto &Spelling : Spellings) { - if (Spelling.variety() == Variety && - (Spelling.nameSpace().empty() || Scope == Spelling.nameSpace())) { -Name = Spelling.name(); -Version = static_cast( -Spelling.getSpellingRecord().getValueAsInt("Version")); -// Verify that explicitly specified CXX11 and C23 spellings (i.e. -// not inferred from Clang/GCC spellings) have a version that's -// different than the default (1). -bool RequiresValidVersion = -(Variety == "CXX11" || Variety == "C23") && -Spelling.getSpellingRecord().getValueAsString("Variety") == Variety; -if (RequiresValidVersion && Scope.empty() && Version == 1) - PrintError(Spelling.getSpellingRecord().getLoc(), - "Standard attributes must have " - "valid version information."); -break; - } +if (Spelling.nameSpace().empty() || Scope == Spelling.nameSpace()) { + Name = Spelling.name(); + Version = static_cast( + Spelling.getSpellingRecord().getValueAsInt("Version")); + // Verify that explicitly specified CXX11 and C23 spellings (i.e. + // not inferred from Clang/GCC spellings) have a version that's + // different from the default (1). + bool RequiresValidVersion = + (Variety == "CXX11" || Variety == "C23") && + Spelling.getSpellingRecord().getValueAsString("Variety") == Variety; + if (RequiresValidVersion && Scope.empty() && Version == 1) +PrintError(Spelling.getSpellingRecord().getLoc(), + "Standard attributes must have " + "valid version information."); } std::string Test; @@ -3514,10 +3511,8 @@ std::string TestStr = !Test.empty() ? Test + " ? " + llvm::itostr(Version) + " : 0" : llvm::itostr(Version); -for (const auto &S : Spellings) - if (Variety.empty() || (Variety == S.variety() && - (Scope.empty() || Scope == S.nameSpace( -OS << ".Case(\"" << S.name() << "\", " << TestStr << ")\n"; +if (Scope.empty() || Scope == Spelling.nameSpace()) + OS << ".Case(\"" << Spelling.name() << "\", " << TestStr << ")\n"; } OS << ".Default(0);\n"; } @@ -3550,8 +3545,11 @@ // Separate all of the attributes out into four group: generic, C++11, GNU, // and declspecs. Then generate a big switch statement for each of them. std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - std::vector Declspec, Microsoft, GNU, Pragma, HLSLSemantic; - std::map> CXX, C23; + std::vector> Declspec, Microsoft, + GNU, Pragma, HLSLSemantic; + std::map>> + CXX, C23; // Walk over the list of all attributes, and split them out based on the // spelling variety. @@ -3560,19 +3558,19 @@ for (const auto &SI : Spellings) { const std::string &Variety = SI.variety(); if (Variety == "GNU") -GNU.push_back(R); +GNU.emplace_back(R, SI); else if (Variety == "Declspec") -Declspec.push_back(R); +Declspec.emplace_back(R, SI); else if (Variety == "Microsoft") -Microsoft.push_back(R); +Microsoft.emplace_back(R, SI); else if (Variety == "CXX11") -CXX[SI.nameSpace()].push_back(R); +CXX[SI.nameSpace()].emplace_back(R, SI); else if (Variety == "C23") -C23[SI.nameS
[clang] [C++20] [Modules] Don't emit function bodies which is noinline and av… (PR #68501)
dwblaikie wrote: This doesn't seem all that useful/important to me - a user can move the body of the function into an implementation unit rather than putting it in the interface unit and marking it noinline, right? This is the same recommendation we'd make if someone wrote a complex function definition in a header - and I think it's fine that the advice remains valid/relevant even in a modules build. https://github.com/llvm/llvm-project/pull/68501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] Don't emit function bodies which is noinline and av… (PR #68501)
philnik777 wrote: > This doesn't seem all that useful/important to me - a user can move the body > of the function into an implementation unit rather than putting it in the > interface unit and marking it noinline, right? This is the same > recommendation we'd make if someone wrote a complex function definition in a > header - and I think it's fine that the advice remains valid/relevant even in > a modules build. I think this makes a lot of sense for things like `string`, which requires all function definitions to be available for `constexpr` and template reasons, but we want to mark some functions as `noinline` for better optimizations. We haven't done that yet in libc++, but we'll have to at some point to address some regressions from making `string` `constexpr` in C++20. https://github.com/llvm/llvm-project/pull/68501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][MBD] set up module build daemon infrastructure (PR #67562)
iains wrote: A possible mechanism might be to have a watchdog process, with which instances of the server are registered with a time-to-live. I guess this might be easier to construct as a scheme for test-suites than for end-user. https://github.com/llvm/llvm-project/pull/67562 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Annotate more r_braces (PR #68534)
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/68534 In preparation of #67906. From 28c69947fb451db2176284f162c789b081600209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 8 Oct 2023 22:12:28 +0200 Subject: [PATCH] [clang-format][NFC] Annotate more r_braces In preparation of #67906. --- clang/lib/Format/FormatToken.h| 4 clang/lib/Format/UnwrappedLineParser.cpp | 16 ++-- clang/unittests/Format/TokenAnnotatorTest.cpp | 12 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 5877b0a6124742a..092ad4126451bd7 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -42,6 +42,7 @@ namespace format { TYPE(CaseLabelColon) \ TYPE(CastRParen) \ TYPE(ClassLBrace) \ + TYPE(ClassRBrace) \ /* ternary ?: expression */ \ TYPE(ConditionalExpr) \ /* the condition in an if statement */ \ @@ -125,6 +126,7 @@ namespace format { TYPE(PureVirtualSpecifier) \ TYPE(RangeBasedForLoopColon) \ TYPE(RecordLBrace) \ + TYPE(RecordRBrace) \ TYPE(RegexLiteral) \ TYPE(RequiresClause) \ TYPE(RequiresClauseInARequiresExpression) \ @@ -141,6 +143,7 @@ namespace format { * braces need to be added to split it. Not used for other languages. */ \ TYPE(StringInConcatenation) \ TYPE(StructLBrace) \ + TYPE(StructRBrace) \ TYPE(StructuredBindingLSquare) \ TYPE(TemplateCloser) \ TYPE(TemplateOpener) \ @@ -153,6 +156,7 @@ namespace format { TYPE(TypenameMacro) \ TYPE(UnaryOperator) \ TYPE(UnionLBrace) \ + TYPE(UnionRBrace) \ TYPE(UntouchableMacroFunc) \ /* Like in 'assign x = 0, y = 1;' . */ \ TYPE(VerilogAssignComma) \ diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index dda5fd077e590e5..1737018c6a78f8e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3920,21 +3920,23 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } while (!eof()); } - auto GetBraceType = [](const FormatToken &RecordTok) { + auto GetBraceTypes = + [](const FormatToken &RecordTok) -> std::pair { switch (RecordTok.Tok.getKind()) { case tok::kw_class: - return TT_ClassLBrace; + return {TT_ClassLBrace, TT_ClassRBrace}; case tok::kw_struct: - return TT_StructLBrace; + return {TT_StructLBrace, TT_StructRBrace}; case tok::kw_union: - return TT_UnionLBrace; + return {TT_UnionLBrace, TT_UnionRBrace}; default: // Useful for e.g. interface. - return TT_RecordLBrace; + return {TT_RecordLBrace, TT_RecordRBrace}; } }; if (FormatTok->is(tok::l_brace)) { -FormatTok->setFinalizedType(GetBraceType(InitialToken)); +auto [OpenBraceType, ClosingBraceType] = GetBraceTypes(InitialToken); +FormatTok->setFinalizedType(OpenBraceType); if (ParseAsExpr) { parseChildBlock(); } else { @@ -3944,6 +3946,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { unsigned AddLevels = Style.IndentAccessModifiers ? 2u : 1u; parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/false); } +if (auto Prev = FormatTok->Previous; Prev && Prev->is(tok::r_brace)) + Prev->setFinalizedType(ClosingBraceType); } // There is no addUnwrappedLine() here so that we fall through to parsing
[clang] [clang-format][NFC] Annotate more r_braces (PR #68534)
llvmbot wrote: @llvm/pr-subscribers-clang-format Changes In preparation of #67906. --- Full diff: https://github.com/llvm/llvm-project/pull/68534.diff 3 Files Affected: - (modified) clang/lib/Format/FormatToken.h (+4) - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+10-6) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+12) ``diff diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 5877b0a6124742a..092ad4126451bd7 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -42,6 +42,7 @@ namespace format { TYPE(CaseLabelColon) \ TYPE(CastRParen) \ TYPE(ClassLBrace) \ + TYPE(ClassRBrace) \ /* ternary ?: expression */ \ TYPE(ConditionalExpr) \ /* the condition in an if statement */ \ @@ -125,6 +126,7 @@ namespace format { TYPE(PureVirtualSpecifier) \ TYPE(RangeBasedForLoopColon) \ TYPE(RecordLBrace) \ + TYPE(RecordRBrace) \ TYPE(RegexLiteral) \ TYPE(RequiresClause) \ TYPE(RequiresClauseInARequiresExpression) \ @@ -141,6 +143,7 @@ namespace format { * braces need to be added to split it. Not used for other languages. */ \ TYPE(StringInConcatenation) \ TYPE(StructLBrace) \ + TYPE(StructRBrace) \ TYPE(StructuredBindingLSquare) \ TYPE(TemplateCloser) \ TYPE(TemplateOpener) \ @@ -153,6 +156,7 @@ namespace format { TYPE(TypenameMacro) \ TYPE(UnaryOperator) \ TYPE(UnionLBrace) \ + TYPE(UnionRBrace) \ TYPE(UntouchableMacroFunc) \ /* Like in 'assign x = 0, y = 1;' . */ \ TYPE(VerilogAssignComma) \ diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index dda5fd077e590e5..1737018c6a78f8e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3920,21 +3920,23 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } while (!eof()); } - auto GetBraceType = [](const FormatToken &RecordTok) { + auto GetBraceTypes = + [](const FormatToken &RecordTok) -> std::pair { switch (RecordTok.Tok.getKind()) { case tok::kw_class: - return TT_ClassLBrace; + return {TT_ClassLBrace, TT_ClassRBrace}; case tok::kw_struct: - return TT_StructLBrace; + return {TT_StructLBrace, TT_StructRBrace}; case tok::kw_union: - return TT_UnionLBrace; + return {TT_UnionLBrace, TT_UnionRBrace}; default: // Useful for e.g. interface. - return TT_RecordLBrace; + return {TT_RecordLBrace, TT_RecordRBrace}; } }; if (FormatTok->is(tok::l_brace)) { -FormatTok->setFinalizedType(GetBraceType(InitialToken)); +auto [OpenBraceType, ClosingBraceType] = GetBraceTypes(InitialToken); +FormatTok->setFinalizedType(OpenBraceType); if (ParseAsExpr) { parseChildBlock(); } else { @@ -3944,6 +3946,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { unsigned AddLevels = Style.IndentAccessModifiers ? 2u : 1u; parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/false); } +if (auto Prev = FormatTok->Previous; Prev && Prev->is(tok::r_brace)) + Prev->setFinalizedType(ClosingBraceType); } // There is no addUnwrappedLine() here so that we fall through to parsing a // structural element afterwards. Thus, in "class A {} n, m;", diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 62ec460eba7fd90..4f006ac8eb951f5 100644 --- a/clang/u
[clang] [clang-format][NFC] Annotate more r_braces (PR #68534)
https://github.com/HazardyKnusperkeks updated https://github.com/llvm/llvm-project/pull/68534 From f8b65d778b81e2dccc6773303d4b17843078864c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 8 Oct 2023 22:12:28 +0200 Subject: [PATCH] [clang-format][NFC] Annotate more r_braces In preparation of #67906. --- clang/lib/Format/FormatToken.h| 4 clang/lib/Format/UnwrappedLineParser.cpp | 18 -- clang/unittests/Format/TokenAnnotatorTest.cpp | 12 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 5877b0a6124742a..092ad4126451bd7 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -42,6 +42,7 @@ namespace format { TYPE(CaseLabelColon) \ TYPE(CastRParen) \ TYPE(ClassLBrace) \ + TYPE(ClassRBrace) \ /* ternary ?: expression */ \ TYPE(ConditionalExpr) \ /* the condition in an if statement */ \ @@ -125,6 +126,7 @@ namespace format { TYPE(PureVirtualSpecifier) \ TYPE(RangeBasedForLoopColon) \ TYPE(RecordLBrace) \ + TYPE(RecordRBrace) \ TYPE(RegexLiteral) \ TYPE(RequiresClause) \ TYPE(RequiresClauseInARequiresExpression) \ @@ -141,6 +143,7 @@ namespace format { * braces need to be added to split it. Not used for other languages. */ \ TYPE(StringInConcatenation) \ TYPE(StructLBrace) \ + TYPE(StructRBrace) \ TYPE(StructuredBindingLSquare) \ TYPE(TemplateCloser) \ TYPE(TemplateOpener) \ @@ -153,6 +156,7 @@ namespace format { TYPE(TypenameMacro) \ TYPE(UnaryOperator) \ TYPE(UnionLBrace) \ + TYPE(UnionRBrace) \ TYPE(UntouchableMacroFunc) \ /* Like in 'assign x = 0, y = 1;' . */ \ TYPE(VerilogAssignComma) \ diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index dda5fd077e590e5..399318e26b970ac 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3920,21 +3920,23 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } while (!eof()); } - auto GetBraceType = [](const FormatToken &RecordTok) { + auto GetBraceTypes = + [](const FormatToken &RecordTok) -> std::pair { switch (RecordTok.Tok.getKind()) { case tok::kw_class: - return TT_ClassLBrace; + return {TT_ClassLBrace, TT_ClassRBrace}; case tok::kw_struct: - return TT_StructLBrace; + return {TT_StructLBrace, TT_StructRBrace}; case tok::kw_union: - return TT_UnionLBrace; + return {TT_UnionLBrace, TT_UnionRBrace}; default: // Useful for e.g. interface. - return TT_RecordLBrace; + return {TT_RecordLBrace, TT_RecordRBrace}; } }; if (FormatTok->is(tok::l_brace)) { -FormatTok->setFinalizedType(GetBraceType(InitialToken)); +auto [OpenBraceType, ClosingBraceType] = GetBraceTypes(InitialToken); +FormatTok->setFinalizedType(OpenBraceType); if (ParseAsExpr) { parseChildBlock(); } else { @@ -3944,6 +3946,10 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { unsigned AddLevels = Style.IndentAccessModifiers ? 2u : 1u; parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/false); } +if (auto Prev = FormatTok->getPreviousNonComment(); +Prev && Prev->is(tok::r_brace)) { + Prev->setFinalizedType(ClosingBraceType); +} } // There is no addUnwrappedLine() here so that we fall through to
[clang] Annotate enum r brace (PR #68535)
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/68535 This review is only for the second commit. Is there a way to build pull request upon each other? From f8b65d778b81e2dccc6773303d4b17843078864c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 8 Oct 2023 22:12:28 +0200 Subject: [PATCH 1/2] [clang-format][NFC] Annotate more r_braces In preparation of #67906. --- clang/lib/Format/FormatToken.h| 4 clang/lib/Format/UnwrappedLineParser.cpp | 18 -- clang/unittests/Format/TokenAnnotatorTest.cpp | 12 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 5877b0a6124742a..092ad4126451bd7 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -42,6 +42,7 @@ namespace format { TYPE(CaseLabelColon) \ TYPE(CastRParen) \ TYPE(ClassLBrace) \ + TYPE(ClassRBrace) \ /* ternary ?: expression */ \ TYPE(ConditionalExpr) \ /* the condition in an if statement */ \ @@ -125,6 +126,7 @@ namespace format { TYPE(PureVirtualSpecifier) \ TYPE(RangeBasedForLoopColon) \ TYPE(RecordLBrace) \ + TYPE(RecordRBrace) \ TYPE(RegexLiteral) \ TYPE(RequiresClause) \ TYPE(RequiresClauseInARequiresExpression) \ @@ -141,6 +143,7 @@ namespace format { * braces need to be added to split it. Not used for other languages. */ \ TYPE(StringInConcatenation) \ TYPE(StructLBrace) \ + TYPE(StructRBrace) \ TYPE(StructuredBindingLSquare) \ TYPE(TemplateCloser) \ TYPE(TemplateOpener) \ @@ -153,6 +156,7 @@ namespace format { TYPE(TypenameMacro) \ TYPE(UnaryOperator) \ TYPE(UnionLBrace) \ + TYPE(UnionRBrace) \ TYPE(UntouchableMacroFunc) \ /* Like in 'assign x = 0, y = 1;' . */ \ TYPE(VerilogAssignComma) \ diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index dda5fd077e590e5..399318e26b970ac 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3920,21 +3920,23 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } while (!eof()); } - auto GetBraceType = [](const FormatToken &RecordTok) { + auto GetBraceTypes = + [](const FormatToken &RecordTok) -> std::pair { switch (RecordTok.Tok.getKind()) { case tok::kw_class: - return TT_ClassLBrace; + return {TT_ClassLBrace, TT_ClassRBrace}; case tok::kw_struct: - return TT_StructLBrace; + return {TT_StructLBrace, TT_StructRBrace}; case tok::kw_union: - return TT_UnionLBrace; + return {TT_UnionLBrace, TT_UnionRBrace}; default: // Useful for e.g. interface. - return TT_RecordLBrace; + return {TT_RecordLBrace, TT_RecordRBrace}; } }; if (FormatTok->is(tok::l_brace)) { -FormatTok->setFinalizedType(GetBraceType(InitialToken)); +auto [OpenBraceType, ClosingBraceType] = GetBraceTypes(InitialToken); +FormatTok->setFinalizedType(OpenBraceType); if (ParseAsExpr) { parseChildBlock(); } else { @@ -3944,6 +3946,10 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { unsigned AddLevels = Style.IndentAccessModifiers ? 2u : 1u; parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/false); } +if (auto Prev = FormatTok->getPreviousNonComment(); +Prev && Prev->is(tok::r_brace)) { + Prev->setFinalizedT
[clang] Annotate enum r brace (PR #68535)
=?utf-8?q?Björn_Schäpers?= Message-ID: In-Reply-To: llvmbot wrote: @llvm/pr-subscribers-clang-format Changes This review is only for the second commit. Is there a way to build pull request upon each other? --- Full diff: https://github.com/llvm/llvm-project/pull/68535.diff 3 Files Affected: - (modified) clang/lib/Format/FormatToken.h (+5) - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+16-6) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+13) ``diff diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 5877b0a6124742a..527f1d744a58089 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -42,6 +42,7 @@ namespace format { TYPE(CaseLabelColon) \ TYPE(CastRParen) \ TYPE(ClassLBrace) \ + TYPE(ClassRBrace) \ /* ternary ?: expression */ \ TYPE(ConditionalExpr) \ /* the condition in an if statement */ \ @@ -67,6 +68,7 @@ namespace format { TYPE(DictLiteral) \ TYPE(ElseLBrace) \ TYPE(EnumLBrace) \ + TYPE(EnumRBrace) \ TYPE(FatArrow) \ TYPE(ForEachMacro) \ TYPE(FunctionAnnotationRParen) \ @@ -125,6 +127,7 @@ namespace format { TYPE(PureVirtualSpecifier) \ TYPE(RangeBasedForLoopColon) \ TYPE(RecordLBrace) \ + TYPE(RecordRBrace) \ TYPE(RegexLiteral) \ TYPE(RequiresClause) \ TYPE(RequiresClauseInARequiresExpression) \ @@ -141,6 +144,7 @@ namespace format { * braces need to be added to split it. Not used for other languages. */ \ TYPE(StringInConcatenation) \ TYPE(StructLBrace) \ + TYPE(StructRBrace) \ TYPE(StructuredBindingLSquare) \ TYPE(TemplateCloser) \ TYPE(TemplateOpener) \ @@ -153,6 +157,7 @@ namespace format { TYPE(TypenameMacro) \ TYPE(UnaryOperator) \ TYPE(UnionLBrace) \ + TYPE(UnionRBrace) \ TYPE(UntouchableMacroFunc) \ /* Like in 'assign x = 0, y = 1;' . */ \ TYPE(VerilogAssignComma) \ diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index dda5fd077e590e5..3275d7b6a71aaa0 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3713,6 +3713,10 @@ bool UnwrappedLineParser::parseEnum() { nextToken(); addUnwrappedLine(); } + if (auto Prev = FormatTok->getPreviousNonComment(); + Prev && Prev->is(tok::r_brace)) { +Prev->setFinalizedType(TT_EnumRBrace); + } return true; // There is no addUnwrappedLine() here so that we fall through to parsing a @@ -3920,21 +3924,23 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } while (!eof()); } - auto GetBraceType = [](const FormatToken &RecordTok) { + auto GetBraceTypes = + [](const FormatToken &RecordTok) -> std::pair { switch (RecordTok.Tok.getKind()) { case tok::kw_class: - return TT_ClassLBrace; + return {TT_ClassLBrace, TT_ClassRBrace}; case tok::kw_struct: - return TT_StructLBrace; + return {TT_StructLBrace, TT_StructRBrace}; case tok::kw_union: - return TT_UnionLBrace; + return {TT_UnionLBrace, TT_UnionRBrace}; d
[PATCH] D159393: [clang] Fix several issues in the generated AttrHasAttributeImpl.inc
barannikov88 updated this revision to Diff 557643. barannikov88 added a comment. Add a release note Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D159393/new/ https://reviews.llvm.org/D159393 Files: clang/docs/ReleaseNotes.rst clang/test/Preprocessor/has_attribute.c clang/test/Preprocessor/has_attribute.cpp clang/test/Preprocessor/has_c_attribute.c clang/utils/TableGen/ClangAttrEmitter.cpp Index: clang/utils/TableGen/ClangAttrEmitter.cpp === --- clang/utils/TableGen/ClangAttrEmitter.cpp +++ clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3434,9 +3434,10 @@ } static void GenerateHasAttrSpellingStringSwitch( -const std::vector &Attrs, raw_ostream &OS, -const std::string &Variety = "", const std::string &Scope = "") { - for (const auto *Attr : Attrs) { +const std::vector> &Attrs, +raw_ostream &OS, const std::string &Variety, +const std::string &Scope = "") { + for (const auto &[Attr, Spelling] : Attrs) { // C++11-style attributes have specific version information associated with // them. If the attribute has no scope, the version information must not // have the default value (1), as that's incorrect. Instead, the unscoped @@ -3455,26 +3456,22 @@ // a way that is impactful to the end user. int Version = 1; -std::vector Spellings = GetFlattenedSpellings(*Attr); +assert(Spelling.variety() == Variety); std::string Name = ""; -for (const auto &Spelling : Spellings) { - if (Spelling.variety() == Variety && - (Spelling.nameSpace().empty() || Scope == Spelling.nameSpace())) { -Name = Spelling.name(); -Version = static_cast( -Spelling.getSpellingRecord().getValueAsInt("Version")); -// Verify that explicitly specified CXX11 and C23 spellings (i.e. -// not inferred from Clang/GCC spellings) have a version that's -// different than the default (1). -bool RequiresValidVersion = -(Variety == "CXX11" || Variety == "C23") && -Spelling.getSpellingRecord().getValueAsString("Variety") == Variety; -if (RequiresValidVersion && Scope.empty() && Version == 1) - PrintError(Spelling.getSpellingRecord().getLoc(), - "Standard attributes must have " - "valid version information."); -break; - } +if (Spelling.nameSpace().empty() || Scope == Spelling.nameSpace()) { + Name = Spelling.name(); + Version = static_cast( + Spelling.getSpellingRecord().getValueAsInt("Version")); + // Verify that explicitly specified CXX11 and C23 spellings (i.e. + // not inferred from Clang/GCC spellings) have a version that's + // different from the default (1). + bool RequiresValidVersion = + (Variety == "CXX11" || Variety == "C23") && + Spelling.getSpellingRecord().getValueAsString("Variety") == Variety; + if (RequiresValidVersion && Scope.empty() && Version == 1) +PrintError(Spelling.getSpellingRecord().getLoc(), + "Standard attributes must have " + "valid version information."); } std::string Test; @@ -3514,10 +3511,8 @@ std::string TestStr = !Test.empty() ? Test + " ? " + llvm::itostr(Version) + " : 0" : llvm::itostr(Version); -for (const auto &S : Spellings) - if (Variety.empty() || (Variety == S.variety() && - (Scope.empty() || Scope == S.nameSpace( -OS << ".Case(\"" << S.name() << "\", " << TestStr << ")\n"; +if (Scope.empty() || Scope == Spelling.nameSpace()) + OS << ".Case(\"" << Spelling.name() << "\", " << TestStr << ")\n"; } OS << ".Default(0);\n"; } @@ -3550,8 +3545,11 @@ // Separate all of the attributes out into four group: generic, C++11, GNU, // and declspecs. Then generate a big switch statement for each of them. std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - std::vector Declspec, Microsoft, GNU, Pragma, HLSLSemantic; - std::map> CXX, C23; + std::vector> Declspec, Microsoft, + GNU, Pragma, HLSLSemantic; + std::map>> + CXX, C23; // Walk over the list of all attributes, and split them out based on the // spelling variety. @@ -3560,19 +3558,19 @@ for (const auto &SI : Spellings) { const std::string &Variety = SI.variety(); if (Variety == "GNU") -GNU.push_back(R); +GNU.emplace_back(R, SI); else if (Variety == "Declspec") -Declspec.push_back(R); +Declspec.emplace_back(R, SI); else if (Variety == "Microsoft") -Microsoft.push_back(R); +Microsoft.emplace_back(R, SI); else if (Variety == "CXX11") -CXX[SI.nameSpace()].push_back(R); +CXX[SI.nameSpace()].emplace_back(R, SI); else i
[PATCH] D159393: [clang] Fix several issues in the generated AttrHasAttributeImpl.inc
barannikov88 added a comment. @aaron.ballman I added a release note as requested. Please see if it looks the way it should. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D159393/new/ https://reviews.llvm.org/D159393 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D159393: [clang] Fix several issues in the generated AttrHasAttributeImpl.inc
barannikov88 updated this revision to Diff 557644. barannikov88 added a comment. Add a hyphen Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D159393/new/ https://reviews.llvm.org/D159393 Files: clang/docs/ReleaseNotes.rst clang/test/Preprocessor/has_attribute.c clang/test/Preprocessor/has_attribute.cpp clang/test/Preprocessor/has_c_attribute.c clang/utils/TableGen/ClangAttrEmitter.cpp Index: clang/utils/TableGen/ClangAttrEmitter.cpp === --- clang/utils/TableGen/ClangAttrEmitter.cpp +++ clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3434,9 +3434,10 @@ } static void GenerateHasAttrSpellingStringSwitch( -const std::vector &Attrs, raw_ostream &OS, -const std::string &Variety = "", const std::string &Scope = "") { - for (const auto *Attr : Attrs) { +const std::vector> &Attrs, +raw_ostream &OS, const std::string &Variety, +const std::string &Scope = "") { + for (const auto &[Attr, Spelling] : Attrs) { // C++11-style attributes have specific version information associated with // them. If the attribute has no scope, the version information must not // have the default value (1), as that's incorrect. Instead, the unscoped @@ -3455,26 +3456,22 @@ // a way that is impactful to the end user. int Version = 1; -std::vector Spellings = GetFlattenedSpellings(*Attr); +assert(Spelling.variety() == Variety); std::string Name = ""; -for (const auto &Spelling : Spellings) { - if (Spelling.variety() == Variety && - (Spelling.nameSpace().empty() || Scope == Spelling.nameSpace())) { -Name = Spelling.name(); -Version = static_cast( -Spelling.getSpellingRecord().getValueAsInt("Version")); -// Verify that explicitly specified CXX11 and C23 spellings (i.e. -// not inferred from Clang/GCC spellings) have a version that's -// different than the default (1). -bool RequiresValidVersion = -(Variety == "CXX11" || Variety == "C23") && -Spelling.getSpellingRecord().getValueAsString("Variety") == Variety; -if (RequiresValidVersion && Scope.empty() && Version == 1) - PrintError(Spelling.getSpellingRecord().getLoc(), - "Standard attributes must have " - "valid version information."); -break; - } +if (Spelling.nameSpace().empty() || Scope == Spelling.nameSpace()) { + Name = Spelling.name(); + Version = static_cast( + Spelling.getSpellingRecord().getValueAsInt("Version")); + // Verify that explicitly specified CXX11 and C23 spellings (i.e. + // not inferred from Clang/GCC spellings) have a version that's + // different from the default (1). + bool RequiresValidVersion = + (Variety == "CXX11" || Variety == "C23") && + Spelling.getSpellingRecord().getValueAsString("Variety") == Variety; + if (RequiresValidVersion && Scope.empty() && Version == 1) +PrintError(Spelling.getSpellingRecord().getLoc(), + "Standard attributes must have " + "valid version information."); } std::string Test; @@ -3514,10 +3511,8 @@ std::string TestStr = !Test.empty() ? Test + " ? " + llvm::itostr(Version) + " : 0" : llvm::itostr(Version); -for (const auto &S : Spellings) - if (Variety.empty() || (Variety == S.variety() && - (Scope.empty() || Scope == S.nameSpace( -OS << ".Case(\"" << S.name() << "\", " << TestStr << ")\n"; +if (Scope.empty() || Scope == Spelling.nameSpace()) + OS << ".Case(\"" << Spelling.name() << "\", " << TestStr << ")\n"; } OS << ".Default(0);\n"; } @@ -3550,8 +3545,11 @@ // Separate all of the attributes out into four group: generic, C++11, GNU, // and declspecs. Then generate a big switch statement for each of them. std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - std::vector Declspec, Microsoft, GNU, Pragma, HLSLSemantic; - std::map> CXX, C23; + std::vector> Declspec, Microsoft, + GNU, Pragma, HLSLSemantic; + std::map>> + CXX, C23; // Walk over the list of all attributes, and split them out based on the // spelling variety. @@ -3560,19 +3558,19 @@ for (const auto &SI : Spellings) { const std::string &Variety = SI.variety(); if (Variety == "GNU") -GNU.push_back(R); +GNU.emplace_back(R, SI); else if (Variety == "Declspec") -Declspec.push_back(R); +Declspec.emplace_back(R, SI); else if (Variety == "Microsoft") -Microsoft.push_back(R); +Microsoft.emplace_back(R, SI); else if (Variety == "CXX11") -CXX[SI.nameSpace()].push_back(R); +CXX[SI.nameSpace()].emplace_back(R, SI); else if (Var
[clang] [C++20] [Modules] Don't emit function bodies which is noinline and av… (PR #68501)
dwblaikie wrote: *shrug* I guess it's OK. https://github.com/llvm/llvm-project/pull/68501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] Don't emit function bodies which is noinline and av… (PR #68501)
https://github.com/dwblaikie approved this pull request. https://github.com/llvm/llvm-project/pull/68501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/aaronpuchert edited https://github.com/llvm/llvm-project/pull/67095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -8141,6 +8141,16 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl *D, if (!AL.checkAtLeastNumArgs(S, 1)) return; + // We allow this on function declaration as well as + // variable declarations of function pointer type. + if (!D->isFunctionPointerType() && !isa(D)) { aaronpuchert wrote: This looks like the attribute sits on the `Decl` and not its type, or am I misunderstanding this? https://github.com/llvm/llvm-project/pull/67095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -136,6 +136,17 @@ int main(void) { // Cleanup happens automatically -> no warning. } + /// Function pointers + { +int __attribute__((requires_capability(&mu1))) (*function_ptr)(int) = Foo_fun1; aaronpuchert wrote: Right, we would likely want to catch function pointer conversions that drop the attribute. But this should be a separate change. https://github.com/llvm/llvm-project/pull/67095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/aaronpuchert commented: > This was much easier than expected actually. Making it a `DeclOrType` attribute is indeed a nice idea, this would allow existing attributes to stay where they are. Is it still inheritable, i.e. does it also apply to later redeclarations? Of course I'm also wondering why we don't have to change anything in the analysis, aren't we currently only looking at declaration attributes, and wouldn't consider attributes on the type? Or is there some mechanism that gives us the combined set of declaration and type attributes? > I'm starting a new review here instead of continuing the one in Phab since > this is a completely different attempt. I hope that's ok. Yeah, since it's a completely different approach than https://reviews.llvm.org/D152246 we're not really losing any history. https://github.com/llvm/llvm-project/pull/67095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Annotate enum r brace (PR #68535)
=?utf-8?q?Bj=C3=B6rn_Sch=C3=A4pers?= Message-ID: In-Reply-To: https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/68535 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Annotate enum r brace (PR #68535)
=?utf-8?q?Bj=C3=B6rn_Sch=C3=A4pers?= Message-ID: In-Reply-To: owenca wrote: See https://github.com/llvm/llvm-project/issues/56636. https://github.com/llvm/llvm-project/pull/68535 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 7cc1bfa - [clang-tidy][modernize-return-braced-init-list]fix false-positives (#68491)
Author: Congcong Cai Date: 2023-10-09T07:20:23+08:00 New Revision: 7cc1bfaf371c4a816cf4e62fe31d8515bf8f6fbd URL: https://github.com/llvm/llvm-project/commit/7cc1bfaf371c4a816cf4e62fe31d8515bf8f6fbd DIFF: https://github.com/llvm/llvm-project/commit/7cc1bfaf371c4a816cf4e62fe31d8515bf8f6fbd.diff LOG: [clang-tidy][modernize-return-braced-init-list]fix false-positives (#68491) Added: Modified: clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp index 407de610d13a79f..d779d0db252 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp @@ -9,6 +9,7 @@ #include "ReturnBracedInitListCheck.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Lex/Lexer.h" #include "clang/Tooling/FixIt.h" @@ -17,11 +18,27 @@ using namespace clang::ast_matchers; namespace clang::tidy::modernize { void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) { - // Skip list initialization and constructors with an initializer list. + auto SemanticallyDifferentContainer = allOf( + hasDeclaration( + // Container(size_type count, const T &value, + // const Allocator &alloc = Allocator()); + cxxConstructorDecl(parameterCountIs(3), + hasParameter(0, hasType(qualType(hasCanonicalType( + isInteger())), + hasType(cxxRecordDecl(hasAnyName("::std::basic_string", "::std::vector", + "::std::deque", "::std::forward_list", + "::std::list"; + auto ConstructExpr = cxxConstructExpr( - unless(anyOf(hasDeclaration(cxxConstructorDecl(isExplicit())), - isListInitialization(), hasDescendant(initListExpr() + unless(anyOf( + // Skip explicit constructor. + hasDeclaration(cxxConstructorDecl(isExplicit())), + // Skip list initialization and constructors with an initializer + // list. + isListInitialization(), hasDescendant(initListExpr()), + // Skip container `vector(size_type, const T&, ...)`. + SemanticallyDifferentContainer))) .bind("ctor"); Finder->addMatcher( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index c1b926b296b055a..60d92ccf971490e 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -269,6 +269,11 @@ Changes in existing checks ` to support for-loops with iterators initialized by free functions like ``begin``, ``end``, or ``size``. +- Improved :doc:`modernize-return-braced-init-list + ` check to ignore + false-positives when constructing the container with ``count`` copies of + elements with value ``value``. + - Improved :doc:`modernize-use-equals-delete ` check to ignore false-positives when special member function is actually used or implicit. diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp index 4db1d49da2ea8b9..02e95e15499dc2d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp @@ -30,12 +30,16 @@ class initializer_list { }; template +struct allocator {}; + +template > class vector { public: - vector(T) {} - vector(std::initializer_list) {} + vector(T); + vector(size_t, T, const Allocator &alloc = Allocator()); + vector(std::initializer_list); }; -} +} // namespace std class Bar {}; @@ -98,12 +102,26 @@ Foo f6() { return Foo(b6, 1); } -std::vector f7() { +std::vector vectorWithOneParameter() { int i7 = 1; return std::vector(i7); // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type } +std::vector vectorIntWithTwoParameter() { + return std::vector(1, 2); +} + +std::vector vectorDoubleWithTwoParameter() { + return std::vector(1, 2.1); +} +struct A {}; +std::vector vectorRecordWithTwoParameter() { + A a{}; + return std::vector(1, a); +} + + Bar f8() { return {}; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin
[clang-tools-extra] [clang-tidy][modernize-return-braced-init-list]fix false-positives (PR #68491)
https://github.com/HerrCai0907 closed https://github.com/llvm/llvm-project/pull/68491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy][modernize-return-braced-init-list]fix false-positives (PR #68491)
ax3l wrote: Thank you! :tada: https://github.com/llvm/llvm-project/pull/68491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [libcxx] Allow string to use SSO in constant evaluation. (PR #66576)
https://github.com/jyknight updated https://github.com/llvm/llvm-project/pull/66576 >From 209a8f9c06a7633737e9f022bc4e61d580ad95e7 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Sat, 16 Sep 2023 12:32:21 + Subject: [PATCH 1/6] [libcxx] Allow string to use SSO in constant evaluation. Previously, libcxx forced all strings created during constant evaluation to point to allocated memory. That was apparently done due to implementation difficultites, but it turns out not to be necessary: this patch shows that it is feasible to use SSO strings during constant evaluation. It also simplifies the implementation. However, I'm not convinced that this is a good idea. It is currently an error in C++ for a pointer created during constant-evaluation-time to attempt to escape into the binary and become runtime-allocated memory. Thus, the existing string implementation has the property that NO constant-evaluation-created string object can escape to runtime. It is always an error. On the other hand, once we permit SSO strings at constant-evaluation-time, then "short enough" strings will be permitted to escape to runtime, while longer strings will produce an error. Thus, whether code will successfully compile now depends on whether the text is smaller than the SSO capacity. Given that the maximum SSO string length is an unspecified internal implementation detail which differs between implementations or platforms, having it become an important part of the API seems unfortunate. It is a new way to inadvertently write non-portable code, and to write difficult-to-modify code. If you depend on constexpr string initialization for a string that initially fits, it may be tricky to later modify your code to no longer depend on constexpr string initialization when it turns out you need a slightly longer string, or to port the code to a different implementation. That said, the other implementations already permit this, and don't seem to have any inclination to change. So, perhaps it's best to just follow suit. Currently, libstdc++ and MSVC allow constant-initialized strings to escape to runtime if they're 15 bytes or less (excluding the trailing NUL) -- except that libstdc++ does allow it for function-locals, only globals. With this patch, libc++ will permit such strings up to 22 bytes on 64-bit platforms, and up to 10 bytes on 32-bit platforms. --- libcxx/include/string | 54 --- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/libcxx/include/string b/libcxx/include/string index 4b96273698166dd..349c892b9243ddb 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -830,8 +830,8 @@ private: { union { -__long __l; __short __s; +__long __l; __raw __r; }; }; @@ -1729,8 +1729,10 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_long() const _NOEXCEPT { -if (__libcpp_is_constant_evaluated()) -return true; +if (__libcpp_is_constant_evaluated()) { +if (__builtin_constant_p(__r_.first().__l.__is_long_)) +return __r_.first().__l.__is_long_; +} return __r_.first().__s.__is_long_; } @@ -1748,24 +1750,11 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __default_init() { __r_.first() = __rep(); -if (__libcpp_is_constant_evaluated()) { -size_type __sz = __recommend(0) + 1; -pointer __ptr = __alloc_traits::allocate(__alloc(), __sz); -__begin_lifetime(__ptr, __sz); -__set_long_pointer(__ptr); -__set_long_cap(__sz); -__set_long_size(0); -} -} - -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __deallocate_constexpr() { -if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr) -__alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap()); } _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly -return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); +return (__sz < __min_cap); } template @@ -1877,10 +1866,7 @@ private: size_type __recommend(size_type __s) _NOEXCEPT { if (__s < __min_cap) { -if (__libcpp_is_constant_evaluated()) -return static_cast(__min_cap); -else -return static_cast(__min_cap) - 1; +return static_cast(__min_cap) - 1; } size_type __guess = __align_it (__s+1) - 1; @@ -1969,7 +1955,8 @@ private: allocator_type __a = __str.__alloc(); auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); __begin_lifetime(
[clang-tools-extra] [libcxx] Allow string to use SSO in constant evaluation. (PR #66576)
jyknight wrote: Looks like the debug/hardened/safe mode tests are failing libcxx/std/utilities/template.bitset/bitset.members/to_string.pass.cpp because the constant evaluations for ``` static_assert(test_to_string<64>()); static_assert(test_to_string<65>()); ``` now both hit the constant evaluation step limit. With the previous code, it would work until length 80 (after creating a get_test_cases<80> function with similar patterns), but with the new impl, 63 is the max in those modes. I'm not sure whether we should care? I've fixed the test by splitting up the test function. Sample failure: ``` # | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:129:17: error: static assertion expression is not an integral constant expression # | 129 | static_assert(test_to_string<64>()); # | | ^~~~ # | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/build/generic-hardened-mode/include/c++/v1/string:1164:10: note: constexpr evaluation hit maximum step limit; possible infinite loop? # | 1164 | {return __is_long() ? __get_long_size() : __get_short_size();} # | | ^ # | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/build/generic-hardened-mode/include/c++/v1/string:1205:50: note: in call to 'this->size()' # | 1205 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), "string index out of bounds"); # | | ^ # | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:38:20: note: in call to 's.operator[](42)' # |38 | assert(s[b.size() - 1 - i] == one); # | |^ # | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:98:13: note: in call to 'check_equal(s, v, 48, 49)' # |98 | check_equal(s, v, '0', '1'); # | | ^ # | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:129:17: note: in call to 'test_to_string()' # | 129 | static_assert(test_to_string<64>()); ``` https://github.com/llvm/llvm-project/pull/66576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] Allow string to use SSO in constant evaluation. (PR #66576)
philnik777 wrote: @jyknight I don't think we have to worry much about that. The step count is quite arbitrary (maybe something like AST nodes?) and doesn't seem to have anything to do with the actual cost or compile time of the program. e.g. a `__builtin_memmove` of arbitrary size and a single assignment have the same step count AFAICT. You can avoid the test complexity by adding `// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200` to the test to increase the step limit. https://github.com/llvm/llvm-project/pull/66576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [libcxx] Allow string to use SSO in constant evaluation. (PR #66576)
philnik777 wrote: @jyknight I don't think we have to worry much about that. The step count is quite arbitrary (maybe something like AST nodes?) and doesn't seem to have anything to do with the actual cost or compile time of the program. e.g. a `__builtin_memmove` of arbitrary size and a single assignment have the same step count AFAICT. You can avoid the test complexity by adding `// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200` to the test to increase the step limit. https://github.com/llvm/llvm-project/pull/66576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Annotate more r_braces (PR #68534)
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/68534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86310: [X86] Align i128 to 16 bytes in x86 datalayouts
hvdijk added inline comments. Comment at: llvm/lib/IR/AutoUpgrade.cpp:5233 + SmallVector Groups; + Regex R("(.*-i64:64)(-.*)"); + if (R.match(Res, &Groups)) hvdijk wrote: > nikic wrote: > > I don't think this will work for the 32-bit targets that don't have > > `-i64:64`. > Oh, you're right, thanks. That was intentional but wrong: there is a test > that we do not upgrade data layout strings that do not look sufficiently > close to valid, and this was intended to address that. But this also avoids > it for data layout strings that do need upgrading. I'll have to figure out > how to handle both; will update when I know how. This should now be fixed. X86 data layout strings always have their components in the same order, `mpifnaS`, where some may be omitted. I make use of this by looking for any leading `-m`/`-p`/`-i` components and inserting `-i128:128` after the last of those. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86310/new/ https://reviews.llvm.org/D86310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] Don't emit function bodies which is noinline and av… (PR #68501)
ChuanqiXu9 wrote: > This doesn't seem all that useful/important to me - a user can move the body > of the function into an implementation unit rather than putting it in the > interface unit and marking it noinline, right? This is the same > recommendation we'd make if someone wrote a complex function definition in a > header - and I think it's fine that the advice remains valid/relevant even in > a modules build. It is helpful for **some** cases. e.g., we're lazy to create the implementation file. (I know it doesn't sound smart but such style exists. And the cost we pay in this patch are really little) https://github.com/llvm/llvm-project/pull/68501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Support option '-r' for target AVR (PR #68484)
https://github.com/jacquesguan approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/68484 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Hook up Haiku ARM support (PR #67222)
brad0 wrote: @nielx https://github.com/llvm/llvm-project/pull/67222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Have -rdynamic be a no-op on Haiku (PR #67872)
brad0 wrote: @nielx https://github.com/llvm/llvm-project/pull/67872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Differentiate between identifier and string EnumArgument (PR #68550)
https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/68550 EnumArgument may be a string or an identifier. If it is a string, it should be parsed as unevaluated string literal. Add IsString flag to EnumArgument so that the parser can choose the correct parsing method. Target-specific attributes that share spelling may have different attribute "prototypes". For example, ARM's version of "interrupt" attribute accepts a string enum, while MSP430's version accepts an unsigned integer. Adjust ClangAttrEmitter so that the generated `attributeStringLiteralListArg` returns the correct mask depending on target triple. It is worth noting that even after this change some string arguments are still parsed as identifiers or, worse, as expressions. This is because of some special logic in ParseAttributeArgsCommon. Fixing it is out of scope of this patch. >From eb100a554b6802df794a966c81820873823fa1b3 Mon Sep 17 00:00:00 2001 From: Sergei Barannikov Date: Mon, 9 Oct 2023 01:38:33 +0300 Subject: [PATCH] [clang] Differentiate between identifier and string EnumArgument EnumArgument may be a string or an identifier. If it is a string, it should be parsed as unevaluated string literal. Add IsString flag to EnumArgument so that the parser can choose the correct parsing method. Target-specific attributes that share spelling may have different attribute "prototypes". For example, ARM's version of "interrupt" attribute accepts a string enum, while MSP430's version accepts an unsigned integer. Adjust ClangAttrEmitter so that the generated `attributeStringLiteralListArg` returns the correct mask depending on target triple. It is worth noting that even after this change some string arguments are still parsed as identifiers or, worse, as expressions. This is because of some special logic in ParseAttributeArgsCommon. Fixing it is out of scope of this patch. --- clang/include/clang/Basic/Attr.td| 84 +++- clang/lib/Parse/ParseDecl.cpp| 4 +- clang/test/Sema/attr-function-return.c | 2 +- clang/test/Sema/callingconv-iamcu.c | 2 +- clang/test/Sema/callingconv.c| 2 +- clang/test/Sema/zero_call_used_regs.c| 2 +- clang/test/SemaCXX/warn-consumed-parsing.cpp | 2 +- clang/test/SemaHLSL/shader_type_attr.hlsl| 4 +- clang/utils/TableGen/ClangAttrEmitter.cpp| 80 +++ 9 files changed, 119 insertions(+), 63 deletions(-) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 5c9eb7b8a981037..46f36d517c11137 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -274,20 +274,27 @@ class DefaultIntArgument : IntArgument { } // This argument is more complex, it includes the enumerator type name, -// a list of strings to accept, and a list of enumerators to map them to. -class EnumArgument values, +// a list of possible values, and a list of enumerators to map them to. +class EnumArgument values, list enums, bit opt = 0, bit fake = 0> : Argument { string Type = type; + // When true, the argument will be parsed as an unevaluated string literal + // and otherwise as an identifier. + bit IsString = is_string; list Values = values; list Enums = enums; } // FIXME: There should be a VariadicArgument type that takes any other type //of argument and generates the appropriate type. -class VariadicEnumArgument values, - list enums> : Argument { +class VariadicEnumArgument values, list enums> +: Argument { string Type = type; + // When true, the argument will be parsed as an unevaluated string literal + // and otherwise as an identifier. + bit IsString = is_string; list Values = values; list Enums = enums; } @@ -886,7 +893,7 @@ def ARMInterrupt : InheritableAttr, TargetSpecificAttr { // MSP430Interrupt's, MipsInterrupt's and AnyX86Interrupt's spellings // must match. let Spellings = [GCC<"interrupt">]; - let Args = [EnumArgument<"Interrupt", "InterruptType", + let Args = [EnumArgument<"Interrupt", "InterruptType", /*is_string=*/true, ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""], ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"], 1>]; @@ -1011,7 +1018,8 @@ def ExternalSourceSymbol : InheritableAttr { def Blocks : InheritableAttr { let Spellings = [Clang<"blocks">]; - let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; + let Args = [EnumArgument<"Type", "BlockType", /*is_string=*/true, + ["byref"], ["ByRef"]>]; let Documentation = [Undocumented]; } @@ -1549,7 +1557,7 @@ def FlagEnum : InheritableAttr { def EnumExtensibility : InheritableAttr { let Spellings = [Clang<"enum_extensibility">]; let Subjects = SubjectList<[Enum]>; - let Args = [EnumArgument<"Extensibility", "Kind
[clang] [clang] Differentiate between identifier and string EnumArgument (PR #68550)
https://github.com/s-barannikov edited https://github.com/llvm/llvm-project/pull/68550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Differentiate between identifier and string EnumArgument (PR #68550)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 7cc1bfaf371c4a816cf4e62fe31d8515bf8f6fbd eb100a554b6802df794a966c81820873823fa1b3 -- clang/lib/Parse/ParseDecl.cpp clang/test/Sema/attr-function-return.c clang/test/Sema/callingconv-iamcu.c clang/test/Sema/callingconv.c clang/test/Sema/zero_call_used_regs.c clang/test/SemaCXX/warn-consumed-parsing.cpp clang/utils/TableGen/ClangAttrEmitter.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index afe55450b..e23bbdbb5 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -2369,7 +2369,7 @@ static void emitClangAttrUnevaluatedStringLiteralList(RecordKeeper &Records, }; auto AddMaskWithTargetCheck = [](const Record *Attr, uint32_t Mask, - std::string &MaskStr) { + std::string &MaskStr) { const Record *T = Attr->getValueAsDef("Target"); std::vector Arches = T->getValueAsListOfStrings("Arches"); std::string Test; `` https://github.com/llvm/llvm-project/pull/68550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Differentiate between identifier and string EnumArgument (PR #68550)
s-barannikov wrote: I'll add some test for 'interrupt' attribute that is the only attribute affected by `emitClangAttrUnevaluatedStringLiteralList` changes. https://github.com/llvm/llvm-project/pull/68550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Differentiate between identifier and string EnumArgument (PR #68550)
@@ -45,7 +45,7 @@ int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}} int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \ s-barannikov wrote: Here is an example when a string argument is not parsed as unevaluated string literal. https://github.com/llvm/llvm-project/pull/68550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Differentiate between identifier and string EnumArgument (PR #68550)
https://github.com/s-barannikov updated https://github.com/llvm/llvm-project/pull/68550 >From 7199c73d5c9dc04c5c4a1915fc9f5bb0e824d40a Mon Sep 17 00:00:00 2001 From: Sergei Barannikov Date: Mon, 9 Oct 2023 01:38:33 +0300 Subject: [PATCH] [clang] Differentiate between identifier and string EnumArgument EnumArgument may be a string or an identifier. If it is a string, it should be parsed as unevaluated string literal. Add IsString flag to EnumArgument so that the parser can choose the correct parsing method. Target-specific attributes that share spelling may have different attribute "prototypes". For example, ARM's version of "interrupt" attribute accepts a string enum, while MSP430's version accepts an unsigned integer. Adjust ClangAttrEmitter so that the generated `attributeStringLiteralListArg` returns the correct mask depending on target triple. It is worth noting that even after this change some string arguments are still parsed as identifiers or, worse, as expressions. This is because of some special logic in `ParseAttributeArgsCommon`. Fixing it is out of scope of this patch. --- clang/include/clang/Basic/Attr.td| 84 +++- clang/lib/Parse/ParseDecl.cpp| 4 +- clang/test/Sema/attr-function-return.c | 2 +- clang/test/Sema/callingconv-iamcu.c | 2 +- clang/test/Sema/callingconv.c| 2 +- clang/test/Sema/zero_call_used_regs.c| 2 +- clang/test/SemaCXX/warn-consumed-parsing.cpp | 2 +- clang/test/SemaHLSL/shader_type_attr.hlsl| 4 +- clang/utils/TableGen/ClangAttrEmitter.cpp| 80 +++ 9 files changed, 119 insertions(+), 63 deletions(-) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 5c9eb7b8a981037..46f36d517c11137 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -274,20 +274,27 @@ class DefaultIntArgument : IntArgument { } // This argument is more complex, it includes the enumerator type name, -// a list of strings to accept, and a list of enumerators to map them to. -class EnumArgument values, +// a list of possible values, and a list of enumerators to map them to. +class EnumArgument values, list enums, bit opt = 0, bit fake = 0> : Argument { string Type = type; + // When true, the argument will be parsed as an unevaluated string literal + // and otherwise as an identifier. + bit IsString = is_string; list Values = values; list Enums = enums; } // FIXME: There should be a VariadicArgument type that takes any other type //of argument and generates the appropriate type. -class VariadicEnumArgument values, - list enums> : Argument { +class VariadicEnumArgument values, list enums> +: Argument { string Type = type; + // When true, the argument will be parsed as an unevaluated string literal + // and otherwise as an identifier. + bit IsString = is_string; list Values = values; list Enums = enums; } @@ -886,7 +893,7 @@ def ARMInterrupt : InheritableAttr, TargetSpecificAttr { // MSP430Interrupt's, MipsInterrupt's and AnyX86Interrupt's spellings // must match. let Spellings = [GCC<"interrupt">]; - let Args = [EnumArgument<"Interrupt", "InterruptType", + let Args = [EnumArgument<"Interrupt", "InterruptType", /*is_string=*/true, ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""], ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"], 1>]; @@ -1011,7 +1018,8 @@ def ExternalSourceSymbol : InheritableAttr { def Blocks : InheritableAttr { let Spellings = [Clang<"blocks">]; - let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>]; + let Args = [EnumArgument<"Type", "BlockType", /*is_string=*/true, + ["byref"], ["ByRef"]>]; let Documentation = [Undocumented]; } @@ -1549,7 +1557,7 @@ def FlagEnum : InheritableAttr { def EnumExtensibility : InheritableAttr { let Spellings = [Clang<"enum_extensibility">]; let Subjects = SubjectList<[Enum]>; - let Args = [EnumArgument<"Extensibility", "Kind", + let Args = [EnumArgument<"Extensibility", "Kind", /*is_string=*/false, ["closed", "open"], ["Closed", "Open"]>]; let Documentation = [EnumExtensibilityDocs]; } @@ -1715,7 +1723,7 @@ def MipsInterrupt : InheritableAttr, TargetSpecificAttr { // must match. let Spellings = [GCC<"interrupt">]; let Subjects = SubjectList<[Function]>; - let Args = [EnumArgument<"Interrupt", "InterruptType", + let Args = [EnumArgument<"Interrupt", "InterruptType", /*is_string=*/true, ["vector=sw0", "vector=sw1", "vector=hw0", "vector=hw1", "vector=hw2", "vector=hw3", "vector=hw4", "vector=hw5", "eic", ""], @@ -1903,7 +1911,7 @@ def NoMicroMips : InheritableAttr, TargetSpecificAttr { def RISCVI
[clang-tools-extra] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
jrtc27 wrote: > This patch is moved from https://reviews.llvm.org/D134600 Why? That loses all the context in the Phabricator review. Keep the review there. https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 7cc1bfaf371c4a816cf4e62fe31d8515bf8f6fbd 20d59b945dcd57fb523118e3116492a2863a7b4d -- lld/ELF/Arch/RISCV.cpp lld/ELF/Config.h lld/ELF/Driver.cpp lld/ELF/SyntheticSections.h lld/ELF/Target.h lld/ELF/Writer.cpp `` View the diff from clang-format here. ``diff diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp index 859dcdb10fd8..7adaa6925ddf 100644 --- a/lld/ELF/Arch/RISCV.cpp +++ b/lld/ELF/Arch/RISCV.cpp @@ -607,7 +607,7 @@ static void initSymbolAnchors() { } static bool relaxTableJump(const InputSection &sec, size_t i, uint64_t loc, - Relocation &r, uint32_t &remove) { + Relocation &r, uint32_t &remove) { if (!in.riscvTableJumpSection || !in.riscvTableJumpSection->isFinalized) return false; `` https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
Xinlong-Wu wrote: > > This patch is moved from https://reviews.llvm.org/D134600 > > Why? That loses all the context in the Phabricator review. Keep the review > there. yes, I will keep it there. But the [Phabricator shutdown timeline](https://discourse.llvm.org/t/update-on-github-pull-requests/71540) said that > Phabricator becomes read-only after October 1 So I thought it may means we can't add comments or update it? That's why I moved it from Phabricator. If you mean we still can review&update it at Phabricator, I will close this pr. ) https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
Xinlong-Wu wrote: > > This patch is moved from https://reviews.llvm.org/D134600 > > Why? That loses all the context in the Phabricator review. Keep the review > there. yes, I will keep it there. But the [Phabricator shutdown timeline](https://discourse.llvm.org/t/update-on-github-pull-requests/71540) said that > Phabricator becomes read-only after October 1 So I thought it may means we can't add comments or update it? That's why I moved it from Phabricator. If you mean we still can review&update it at Phabricator, I will close this pr. ) https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] llvm-canon (PR #68176)
plotfi wrote: > Please don't use the term canon/canonicalize for this pass or tool. LLVM has > an existing notion of "canonicalization" which does not coincide with what is > being done here. The term comes from an older pass that did similar algorithms on MIR. They are only borrowing the term from it. https://github.com/llvm/llvm-project/pull/68176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] llvm-canon (PR #68176)
plotfi wrote: > Please don't use the term canon/canonicalize for this pass or tool. LLVM has > an existing notion of "canonicalization" which does not coincide with what is > being done here. The term comes from an older pass that did similar algorithms on MIR. They are only borrowing the term from it. https://github.com/llvm/llvm-project/pull/68176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
jrtc27 wrote: > > > This patch is moved from https://reviews.llvm.org/D134600 > > > > > > Why? That loses all the context in the Phabricator review. Keep the review > > there. > > yes, I will keep it there. > > But the [Phabricator shutdown > timeline](https://discourse.llvm.org/t/update-on-github-pull-requests/71540) > said that > > > Phabricator becomes read-only after October 1 > > So I thought it may means we can't add comments or update it? That's why I > moved it from Phabricator. > > If you mean we still can review&update it at Phabricator, I will close this > pr. ) Scroll down the thread and you will find https://discourse.llvm.org/t/update-on-github-pull-requests/71540/124. There's consensus that Phabricator will remain usable for existing revisions for a while longer for this specific kind of situation, and that migrating revisions off of it loses valuable context and should be avoided. https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] llvm-canon (PR #68176)
michalpaszkowski wrote: > Please don't use the term canon/canonicalize for this pass or tool. LLVM has > an existing notion of "canonicalization" which does not coincide with what is > being done here. @nikic I don't think the name "canon" or "canonicalizer" will lead to any confusion here. This is in fact what the pass is doing and mimics the name of MIR canonicalizer with similar assumptions as @plotfi noted . Using the term "canonicalization" for the current/existing set of passes is not really common or well defined. As for the RFC, there was a discussion thread in the LLVM Dev Mailing: https://lists.llvm.org/pipermail/llvm-dev/2019-August/134475.html https://github.com/llvm/llvm-project/pull/68176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] llvm-canon (PR #68176)
michalpaszkowski wrote: > Please don't use the term canon/canonicalize for this pass or tool. LLVM has > an existing notion of "canonicalization" which does not coincide with what is > being done here. @nikic I don't think the name "canon" or "canonicalizer" will lead to any confusion here. This is in fact what the pass is doing and mimics the name of MIR canonicalizer with similar assumptions as @plotfi noted . Using the term "canonicalization" for the current/existing set of passes is not really common or well defined. As for the RFC, there was a discussion thread in the LLVM Dev Mailing: https://lists.llvm.org/pipermail/llvm-dev/2019-August/134475.html https://github.com/llvm/llvm-project/pull/68176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
https://github.com/Xinlong-Wu closed https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
Xinlong-Wu wrote: > > > > This patch is moved from https://reviews.llvm.org/D134600 > > > > > > > > > Why? That loses all the context in the Phabricator review. Keep the > > > review there. > > > > > > yes, I will keep it there. > > But the [Phabricator shutdown > > timeline](https://discourse.llvm.org/t/update-on-github-pull-requests/71540) > > said that > > > Phabricator becomes read-only after October 1 > > > > > > So I thought it may means we can't add comments or update it? That's why I > > moved it from Phabricator. > > If you mean we still can review&update it at Phabricator, I will close this > > pr. ) > > Scroll down the thread and you will find > https://discourse.llvm.org/t/update-on-github-pull-requests/71540/125. > There's consensus that Phabricator will remain usable for existing revisions > for a while longer for this specific kind of situation, and that migrating > revisions off of it loses valuable context and should be avoided. That make sense. I will close this pr https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #68551)
https://github.com/Xinlong-Wu closed https://github.com/llvm/llvm-project/pull/68551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Hook up Haiku ARM support (PR #67222)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/67222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7cfe32d - [Driver] Hook up Haiku ARM support (#67222)
Author: Brad Smith Date: 2023-10-09T00:49:53-04:00 New Revision: 7cfe32d4d8da6eb6ea558a584a3a52e2e8a97a3c URL: https://github.com/llvm/llvm-project/commit/7cfe32d4d8da6eb6ea558a584a3a52e2e8a97a3c DIFF: https://github.com/llvm/llvm-project/commit/7cfe32d4d8da6eb6ea558a584a3a52e2e8a97a3c.diff LOG: [Driver] Hook up Haiku ARM support (#67222) Added: Modified: clang/lib/Basic/Targets.cpp clang/lib/Basic/Targets/ARM.cpp clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/test/Driver/arm-abi.c clang/test/Driver/haiku.c llvm/lib/TargetParser/ARMTargetParser.cpp Removed: diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 80822f65662850d..8130f90a276749e 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -219,6 +219,8 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, return std::make_unique>(Triple, Opts); case llvm::Triple::RTEMS: return std::make_unique>(Triple, Opts); +case llvm::Triple::Haiku: + return std::make_unique>(Triple, Opts); case llvm::Triple::NaCl: return std::make_unique>(Triple, Opts); case llvm::Triple::Win32: diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp index 06e99e67c875584..1e809283748b66c 100644 --- a/clang/lib/Basic/Targets/ARM.cpp +++ b/clang/lib/Basic/Targets/ARM.cpp @@ -257,6 +257,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple, bool IsFreeBSD = Triple.isOSFreeBSD(); bool IsOpenBSD = Triple.isOSOpenBSD(); bool IsNetBSD = Triple.isOSNetBSD(); + bool IsHaiku = Triple.isOSHaiku(); // FIXME: the isOSBinFormatMachO is a workaround for identifying a Darwin-like // environment where size_t is `unsigned long` rather than `unsigned int` @@ -323,7 +324,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple, default: if (IsNetBSD) setABI("apcs-gnu"); - else if (IsFreeBSD || IsOpenBSD) + else if (IsFreeBSD || IsOpenBSD || IsHaiku) setABI("aapcs-linux"); else setABI("aapcs"); diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index bb66db5feae8c3b..8e1cff0b443eeeb 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -404,6 +404,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple &Triple) { } break; + case llvm::Triple::Haiku: case llvm::Triple::OpenBSD: return FloatABI::SoftFP; diff --git a/clang/test/Driver/arm-abi.c b/clang/test/Driver/arm-abi.c index 7bf5977992f65a2..139456cf98e1478 100644 --- a/clang/test/Driver/arm-abi.c +++ b/clang/test/Driver/arm-abi.c @@ -33,6 +33,8 @@ // RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s // RUN: %clang -target arm--openbsd- %s -### -o %t.o 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s +// RUN: %clang -target arm--haiku- %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s // Otherwise, ABI is selected based on environment // RUN: %clang -target arm---android %s -### -o %t.o 2>&1 \ diff --git a/clang/test/Driver/haiku.c b/clang/test/Driver/haiku.c index 021ab522be06e5c..3888c6732923228 100644 --- a/clang/test/Driver/haiku.c +++ b/clang/test/Driver/haiku.c @@ -65,3 +65,8 @@ // CHECK-X86_64-SHARED-SAME: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-X86_64-SHARED: "{{.*}}ld{{(.exe)?}}" // CHECK-X86_64-SHARED-NOT: "[[SYSROOT]]/boot/system/develop/lib/start_dyn.o" + +// Check default ARM CPU, ARMv6 +// RUN: %clang -### %s 2>&1 --target=arm-unknown-haiku \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-CPU %s +// CHECK-ARM-CPU: "-target-cpu" "arm1176jzf-s" diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp b/llvm/lib/TargetParser/ARMTargetParser.cpp index c84928eeb07b140..20225232b3cccb7 100644 --- a/llvm/lib/TargetParser/ARMTargetParser.cpp +++ b/llvm/lib/TargetParser/ARMTargetParser.cpp @@ -526,7 +526,8 @@ StringRef ARM::computeDefaultTargetABI(const Triple &TT, StringRef CPU) { default: if (TT.isOSNetBSD()) return "apcs-gnu"; -if (TT.isOSFreeBSD() || TT.isOSOpenBSD() || TT.isOHOSFamily()) +if (TT.isOSFreeBSD() || TT.isOSOpenBSD() || TT.isOSHaiku() || +TT.isOHOSFamily()) return "aapcs-linux"; return "aapcs"; } @@ -542,6 +543,7 @@ StringRef ARM::getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch) { case llvm::Triple::FreeBSD: case llvm::Triple::NetBSD: case llvm::Triple::OpenBSD: + case llvm::Triple::Haiku: if (!MArch.empty() && MArch == "v6") return "arm1176jzf-s"; if (!MArch.empty() && MArch == "v7") @@ -574,6 +576,8 @@ StringRef ARM::getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch) { // If no specific architecture version is requested, return the minimum CPU // required by the OS and environment. switch
[PATCH] D70401: [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs
zixuan-wu added a comment. ping? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70401/new/ https://reviews.llvm.org/D70401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Support] Deprecate system_endianness (PR #68279)
@@ -248,7 +248,7 @@ class HashBuilder : public HashBuilderBase { /// template s-barannikov wrote: This should've been updated too, I guess. Same below. https://github.com/llvm/llvm-project/pull/68279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits