[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
https://github.com/bricknerb edited https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) (PR #80309)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-s390x-linux` running on `systemz-1` while building `clang,lldb,llvm` at step 6 "test-openmp". Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/3573 Here is the relevant piece of the build log for the reference ``` Step 6 (test-openmp) failure: test (failure) TEST 'libomp :: tasking/issue-94260-2.c' FAILED Exit Code: -11 Command Output (stdout): -- # RUN: at line 1 /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic && /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp # executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic # executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp # note: command had no output on stdout or stderr # error: command failed with exit status: -11 -- ``` https://github.com/llvm/llvm-project/pull/80309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] insert ``static`` keyword in correct position for misc-use-internal-linkage (PR #108792)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/108792 >From 795b3ae677210ff50f7710a0cf73d435889b68ae Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Mon, 16 Sep 2024 13:47:10 +0800 Subject: [PATCH 1/3] [clang-tidy] insert ``static`` keyword in correct position for misc-use-internal-linkage Fixes: #108760 --- .../misc/UseInternalLinkageCheck.cpp | 34 +-- .../clang-tidy/utils/LexerUtils.cpp | 4 ++- clang-tools-extra/docs/ReleaseNotes.rst | 4 +++ .../misc/use-internal-linkage-func.cpp| 21 .../misc/use-internal-linkage-var.cpp | 12 +++ 5 files changed, 72 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp index c086e7721e02bd..a92448c15ef3a9 100644 --- a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp @@ -8,12 +8,15 @@ #include "UseInternalLinkageCheck.h" #include "../utils/FileExtensionsUtils.h" +#include "../utils/LexerUtils.h" #include "clang/AST/Decl.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/ASTMatchers/ASTMatchersMacros.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/TokenKinds.h" +#include "clang/Lex/Token.h" #include "llvm/ADT/STLExtras.h" using namespace clang::ast_matchers; @@ -110,10 +113,36 @@ static constexpr StringRef Message = "%0 %1 can be made static or moved into an anonymous namespace " "to enforce internal linkage"; +static SourceLocation getQualifiedTypeStartLoc(SourceLocation L, + const SourceManager &SM, + const ASTContext &Context) { + const SourceLocation StartOfFile = SM.getLocForStartOfFile(SM.getFileID(L)); + if (L.isInvalid() || L.isMacroID()) +return L; + bool HasChanged = true; + while (HasChanged) { +if (L == StartOfFile) + return L; +auto [Tok, Loc] = +utils::lexer::getPreviousTokenAndStart(L, SM, Context.getLangOpts()); +if (Tok.is(tok::raw_identifier)) { + IdentifierInfo &Info = Context.Idents.get( + StringRef(SM.getCharacterData(Tok.getLocation()), Tok.getLength())); + Tok.setIdentifierInfo(&Info); + Tok.setKind(Info.getTokenID()); +} +HasChanged = Tok.isOneOf(tok::kw_const, tok::kw_volatile); +if (HasChanged) + L = Loc; + } + return L; +} + void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *FD = Result.Nodes.getNodeAs("fn")) { DiagnosticBuilder DB = diag(FD->getLocation(), Message) << "function" << FD; -SourceLocation FixLoc = FD->getTypeSpecStartLoc(); +const SourceLocation FixLoc = getQualifiedTypeStartLoc( +FD->getTypeSpecStartLoc(), *Result.SourceManager, *Result.Context); if (FixLoc.isInvalid() || FixLoc.isMacroID()) return; if (FixMode == FixModeKind::UseStatic) @@ -128,7 +157,8 @@ void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) { return; DiagnosticBuilder DB = diag(VD->getLocation(), Message) << "variable" << VD; -SourceLocation FixLoc = VD->getTypeSpecStartLoc(); +const SourceLocation FixLoc = getQualifiedTypeStartLoc( +VD->getTypeSpecStartLoc(), *Result.SourceManager, *Result.Context); if (FixLoc.isInvalid() || FixLoc.isMacroID()) return; if (FixMode == FixModeKind::UseStatic) diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp index df2b0bef576ca3..92c3e0ed7894e1 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp @@ -24,13 +24,15 @@ getPreviousTokenAndStart(SourceLocation Location, const SourceManager &SM, if (Location.isInvalid()) return {Token, Location}; - auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location)); + const auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location)); while (Location != StartOfFile) { Location = Lexer::GetBeginningOfToken(Location, SM, LangOpts); if (!Lexer::getRawToken(Location, Token, SM, LangOpts) && (!SkipComments || !Token.is(tok::comment))) { break; } +if (Location == StartOfFile) + return {Token, Location}; Location = Location.getLocWithOffset(-1); } return {Token, Location}; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 8d0c093b312dd5..7cbcc23f28efaf 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -128,6 +128,10 @@ Changes in existing checks ` check to avoid false positive for C++23 deducing this. +- Improved
[clang] [flang] [flang][driver] Make -stdlib= option visible to flang and silently ignored by it (PR #110598)
Meinersbur wrote: > I don’t personally think that the flang driver should ever attempt to link a > C++ library of any kind. FWIW while there’s no stdlib option to consider in > their case, g++ will never auto link the gfortran runtimes and gfortran will > never auto link libstdc++ gfortran doesn't have a flag that means "use this C++ standard library". Without this PR, Flang doesn't either which would be fine with me. OP would need to fix their build system. With this PR, `flang --help` will list an option `-stdlib` with the help text "C++ standard library to use". But it doesn't do anything. It feels like it would be ignoring `-lc++`. > If we were to do things this way, what should flang do if no -stdlib flag is > provided? Should it link the default C++ stdlib as clang++ does, or break > with clang++ and not link any C++ stdlib if nothing is provided? Both would > be surprising behavior in my opinion, and both would also risk breaking the > existing cmake support. No `-stdlib` means no linking to any C++ standard library for Flang, no change of behavior without the flag. It also does not break cmake support since it never passes `-stdlib` by itself. Just asking for the flag's behavior to match its description. https://github.com/llvm/llvm-project/pull/110598 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
@@ -2866,12 +2877,14 @@ ConditionTruthVal RangeConstraintManager::checkNull(ProgramStateRef State, const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St, SymbolRef Sym) const { - const RangeSet *T = getConstraint(St, Sym); - return T ? T->getConcreteValue() : nullptr; + auto &MutableSelf = const_cast(*this); + return MutableSelf.getRange(St, Sym).getConcreteValue(); } const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St, SymbolRef Sym) const { + // TODO: Use `getRange()` like in `getSymVal()`, but that would make some + // of the reports of `BitwiseShiftChecker` look awkward. NagyDonat wrote: Could you show an example for an awkward report? https://github.com/llvm/llvm-project/pull/112583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
@@ -1485,6 +1487,18 @@ class SymbolicRangeInferrer Sym->getType()); } + std::optional getRangeCommutativeSymSym(const SymSymExpr *SSE) { +bool IsCommutative = llvm::is_contained({BO_Add, BO_Mul}, SSE->getOpcode()); +if (!IsCommutative) + return std::nullopt; + +SymbolRef Commuted = State->getSymbolManager().getSymSymExpr( +SSE->getRHS(), BO_Add, SSE->getLHS(), SSE->getType()); NagyDonat wrote: ```suggestion SSE->getRHS(), SSE->getOpcode(), SSE->getLHS(), SSE->getType()); ``` Don't hardcode addition here! https://github.com/llvm/llvm-project/pull/112583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/112583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
https://github.com/NagyDonat approved this pull request. LGTM overall, see inline remarks for details. https://github.com/llvm/llvm-project/pull/112583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
@@ -50,28 +50,17 @@ void test2() { b = d; a -= d; + clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}} + if (a != 0) return; - clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} - - /* The BASELINE passes these checks ('wrning' is used to avoid lit to match) - // The parent state is already infeasible, look at this contradiction: - clang_analyzer_eval(b > 0); // expected-wrning{{FALSE}} - clang_analyzer_eval(b <= 0); // expected-wrning{{FALSE}} - // Crashes with expensive checks. - if (b > 0) { -clang_analyzer_warnIfReached(); // no-warning, OK -return; - } - // Should not be reachable. - clang_analyzer_warnIfReached(); // expected-wrning{{REACHABLE}} - */ + clang_analyzer_warnIfReached(); // no-warning: Even the parent state is unreachable. // The parent state is already infeasible, but we realize that only if b is // constrained. - clang_analyzer_eval(b > 0); // expected-warning{{UNKNOWN}} - clang_analyzer_eval(b <= 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(b > 0); // no-warning + clang_analyzer_eval(b <= 0); // no-warning if (b > 0) { clang_analyzer_warnIfReached(); // no-warning return; NagyDonat wrote: Perhaps just delete this part of the test now that it's completely unreachable behind a `warnIfReached()` that does not trigger? https://github.com/llvm/llvm-project/pull/112583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
https://github.com/NagyDonat requested changes to this pull request. (The "approve mark" was accidental, this should not be merged without fixing the trivial mistake that hardcodes addition.) https://github.com/llvm/llvm-project/pull/112583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 375690c - clang/HIP: Remove REQUIRES libgcc from a test (#112412)
Author: Matt Arsenault Date: 2024-10-17T13:15:12+04:00 New Revision: 375690c0a1a1caacad1bbd243a611ae5c2970996 URL: https://github.com/llvm/llvm-project/commit/375690c0a1a1caacad1bbd243a611ae5c2970996 DIFF: https://github.com/llvm/llvm-project/commit/375690c0a1a1caacad1bbd243a611ae5c2970996.diff LOG: clang/HIP: Remove REQUIRES libgcc from a test (#112412) Added: Modified: clang/test/Driver/hip-include-path.hip Removed: diff --git a/clang/test/Driver/hip-include-path.hip b/clang/test/Driver/hip-include-path.hip index 1b4179e65c0b97..52f5ce0d5b 100644 --- a/clang/test/Driver/hip-include-path.hip +++ b/clang/test/Driver/hip-include-path.hip @@ -1,4 +1,3 @@ -// REQUIRES: libgcc // UNSUPPORTED: system-windows // RUN: %clang -c -### --target=x86_64-unknown-linux-gnu --cuda-gpu-arch=gfx900 \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/HIP: Remove REQUIRES libgcc from a test (PR #112412)
https://github.com/arsenm closed https://github.com/llvm/llvm-project/pull/112412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 77ea619 - clang/HIP: Remove REQUIRES windows from a test (#112411)
Author: Matt Arsenault Date: 2024-10-17T13:17:10+04:00 New Revision: 77ea619bc6cdcdf734105e0c96c92e060aadc011 URL: https://github.com/llvm/llvm-project/commit/77ea619bc6cdcdf734105e0c96c92e060aadc011 DIFF: https://github.com/llvm/llvm-project/commit/77ea619bc6cdcdf734105e0c96c92e060aadc011.diff LOG: clang/HIP: Remove REQUIRES windows from a test (#112411) Added: Modified: clang/test/Driver/hip-runtime-libs-msvc.hip Removed: diff --git a/clang/test/Driver/hip-runtime-libs-msvc.hip b/clang/test/Driver/hip-runtime-libs-msvc.hip index 8085e77d457e56..943cd0569f4fd1 100644 --- a/clang/test/Driver/hip-runtime-libs-msvc.hip +++ b/clang/test/Driver/hip-runtime-libs-msvc.hip @@ -1,5 +1,3 @@ -// REQUIRES: system-windows - // RUN: touch %t.o // Test HIP runtime lib args specified by --rocm-path. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/HIP: Remove REQUIRES windows from a test (PR #112411)
https://github.com/arsenm closed https://github.com/llvm/llvm-project/pull/112411 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)
yingopq wrote: > This looks technically fine, but I'm having trouble finding a normative > reference for this. Is there an ABI specification for N32/N64 somewhere? > > Also, what alignment does clang use for o32 with ForceEnableInt128? > > https://github.com/llvm/llvm-project/blob/cb2f1619575400a402ffe11040bb927b0fa35910/clang/lib/Basic/Targets/Mips.h#L441 > > Possibly we need to specify the alignment in that case as well to cover that > option. @nikic I checked several other arch-32 situations with ForceEnableInt128, and they all use `alloca i128, align 16`. But they did not modify the target datalayout content with `i128:128`, should mips be consistent? https://github.com/llvm/llvm-project/pull/112084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][MC][AArch64] Assembler support for Armv9.6-A memory systems extensions (PR #112341)
@@ -0,0 +1,395 @@ +# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py +// RUN: llvm-mc -triple aarch64 -mattr=+lsui -show-encoding %s | FileCheck %s nasherm wrote: Done https://github.com/llvm/llvm-project/pull/112341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Explicitly truncate in IntegralAP::from() (PR #112683)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/112683 Add Integral::toAPInt(), which truncates to the given BitWidth, similar to the toAPSInt() we already have. >From eeef15e2121a4bfa520f93037b4f04eb1e3dffa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 17 Oct 2024 11:28:50 +0200 Subject: [PATCH] [clang][bytecode] Explicitly truncate in IntegralAP::from() Add Integral::toAPInt(), which truncates to the given BitWidth, similar to the toAPSInt() we already have. --- clang/lib/AST/ByteCode/Integral.h | 9 ++--- clang/lib/AST/ByteCode/IntegralAP.h | 7 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/clang/lib/AST/ByteCode/Integral.h b/clang/lib/AST/ByteCode/Integral.h index e06ec1669259da..be537d22d5af1b 100644 --- a/clang/lib/AST/ByteCode/Integral.h +++ b/clang/lib/AST/ByteCode/Integral.h @@ -122,11 +122,14 @@ template class Integral final { APSInt toAPSInt() const { return APSInt(APInt(Bits, static_cast(V), Signed), !Signed); } - APSInt toAPSInt(unsigned NumBits) const { + APSInt toAPSInt(unsigned BitWidth) const { return APSInt(toAPInt(BitWidth)); } + APInt toAPInt(unsigned BitWidth) const { if constexpr (Signed) - return APSInt(toAPSInt().sextOrTrunc(NumBits), !Signed); + return APInt(Bits, static_cast(V), Signed) + .sextOrTrunc(BitWidth); else - return APSInt(toAPSInt().zextOrTrunc(NumBits), !Signed); + return APInt(Bits, static_cast(V), Signed) + .zextOrTrunc(BitWidth); } APValue toAPValue(const ASTContext &) const { return APValue(toAPSInt()); } diff --git a/clang/lib/AST/ByteCode/IntegralAP.h b/clang/lib/AST/ByteCode/IntegralAP.h index 252d7243bee73e..f8aeaaca398fe8 100644 --- a/clang/lib/AST/ByteCode/IntegralAP.h +++ b/clang/lib/AST/ByteCode/IntegralAP.h @@ -112,12 +112,7 @@ template class IntegralAP final { template static IntegralAP from(Integral I, unsigned BitWidth) { -// TODO: Avoid implicit trunc? -// See https://github.com/llvm/llvm-project/issues/112510. -APInt Copy = APInt(BitWidth, static_cast(I), InputSigned, - /*implicitTrunc=*/true); - -return IntegralAP(Copy); +return IntegralAP(I.toAPInt(BitWidth)); } static IntegralAP zero(int32_t BitWidth) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-include-cleaner] Fix -Wpessimizing-move warning introduced in 4cda28c1ada702a08f6960eb4c93919187c1d4d1 (PR #112684)
https://github.com/bc-lee created https://github.com/llvm/llvm-project/pull/112684 Failing log: https://lab.llvm.org/buildbot/#/builders/145/builds/2540 >From b6d67fc85457e3c374d7fc0520f593e95e2cbaec Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Thu, 17 Oct 2024 18:30:28 +0900 Subject: [PATCH] [clang-include-cleaner] Fix -Wpessimizing-move warning introduced in 4cda28c1ada702a08f6960eb4c93919187c1d4d1 Failing log: https://lab.llvm.org/buildbot/#/builders/145/builds/2540 --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 6bd9c40c70753c..f85dbc0e0c31f2 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -299,7 +299,7 @@ mapInputsToAbsPaths(clang::tooling::CompilationDatabase &CDB, if (auto Err = VFS->makeAbsolute(AbsPath)) { llvm::errs() << "Failed to get absolute path for " << Source << " : " << Err.message() << '\n'; - return std::move(llvm::errorCodeToError(Err)); + return llvm::errorCodeToError(Err); } std::vector Cmds = CDB.getCompileCommands(AbsPath); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Explicitly truncate in IntegralAP::from() (PR #112683)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes Add Integral::toAPInt(), which truncates to the given BitWidth, similar to the toAPSInt() we already have. --- Full diff: https://github.com/llvm/llvm-project/pull/112683.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Integral.h (+6-3) - (modified) clang/lib/AST/ByteCode/IntegralAP.h (+1-6) ``diff diff --git a/clang/lib/AST/ByteCode/Integral.h b/clang/lib/AST/ByteCode/Integral.h index e06ec1669259da..be537d22d5af1b 100644 --- a/clang/lib/AST/ByteCode/Integral.h +++ b/clang/lib/AST/ByteCode/Integral.h @@ -122,11 +122,14 @@ template class Integral final { APSInt toAPSInt() const { return APSInt(APInt(Bits, static_cast(V), Signed), !Signed); } - APSInt toAPSInt(unsigned NumBits) const { + APSInt toAPSInt(unsigned BitWidth) const { return APSInt(toAPInt(BitWidth)); } + APInt toAPInt(unsigned BitWidth) const { if constexpr (Signed) - return APSInt(toAPSInt().sextOrTrunc(NumBits), !Signed); + return APInt(Bits, static_cast(V), Signed) + .sextOrTrunc(BitWidth); else - return APSInt(toAPSInt().zextOrTrunc(NumBits), !Signed); + return APInt(Bits, static_cast(V), Signed) + .zextOrTrunc(BitWidth); } APValue toAPValue(const ASTContext &) const { return APValue(toAPSInt()); } diff --git a/clang/lib/AST/ByteCode/IntegralAP.h b/clang/lib/AST/ByteCode/IntegralAP.h index 252d7243bee73e..f8aeaaca398fe8 100644 --- a/clang/lib/AST/ByteCode/IntegralAP.h +++ b/clang/lib/AST/ByteCode/IntegralAP.h @@ -112,12 +112,7 @@ template class IntegralAP final { template static IntegralAP from(Integral I, unsigned BitWidth) { -// TODO: Avoid implicit trunc? -// See https://github.com/llvm/llvm-project/issues/112510. -APInt Copy = APInt(BitWidth, static_cast(I), InputSigned, - /*implicitTrunc=*/true); - -return IntegralAP(Copy); +return IntegralAP(I.toAPInt(BitWidth)); } static IntegralAP zero(int32_t BitWidth) { `` https://github.com/llvm/llvm-project/pull/112683 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
@@ -45,10 +48,14 @@ enum LifetimeKind { /// a default member initializer), the program is ill-formed. LK_MemInitializer, - /// The lifetime of a temporary bound to this entity probably ends too soon, + /// The lifetime of a temporary bound to this entity may end too soon, bricknerb wrote: Move this change outside this pull request? https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
@@ -1091,21 +1104,22 @@ static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) { } static bool shouldRunGSLAssignmentAnalysis(const Sema &SemaRef, - const AssignedEntity &Entity) { + const CapturingEntity &Entity) { bool EnableGSLAssignmentWarnings = !SemaRef.getDiagnostics().isIgnored( diag::warn_dangling_lifetime_pointer_assignment, SourceLocation()); return (EnableGSLAssignmentWarnings && - (isRecordWithAttr(Entity.LHS->getType()) || + (isRecordWithAttr(Entity.Expression->getType()) || isAssignmentOperatorLifetimeBound(Entity.AssignmentOperator))); } static void checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity, const InitializedEntity *ExtendingEntity, LifetimeKind LK, - const AssignedEntity *AEntity, Expr *Init) { - assert((AEntity && LK == LK_Assignment) || - (InitEntity && LK != LK_Assignment)); + const CapturingEntity *CEntity, Expr *Init) { bricknerb wrote: Can we name CEntity with something more readable? Perhaps even CaptEntity? https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Allow overload of __builtin_amdgcn_mov/update_dpp (PR #112447)
@@ -102,20 +102,66 @@ void test_s_dcache_wb() __builtin_amdgcn_s_dcache_wb(); } -// CHECK-LABEL: @test_mov_dpp +// CHECK-LABEL: @test_mov_dpp_int // CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.update.dpp.i32(i32 poison, i32 %src, i32 0, i32 0, i32 0, i1 false) -void test_mov_dpp(global int* out, int src) +void test_mov_dpp_int(global int* out, int src) { *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false); } -// CHECK-LABEL: @test_update_dpp +// CHECK-LABEL: @test_mov_dpp_long +// CHECK: %0 = tail call{{.*}} i64 @llvm.amdgcn.update.dpp.i64(i64 poison, i64 %x, i32 257, i32 15, i32 15, i1 false) +// CHECK-NEXT: store i64 %0, +void test_mov_dpp_long(long x, global long *p) { + *p = __builtin_amdgcn_mov_dpp(x, 0x101, 0xf, 0xf, 0); +} + +// CHECK-LABEL: @test_mov_dpp_float +// CHECK: %0 = bitcast float %x to i32 +// CHECK-NEXT: %1 = tail call{{.*}} i32 @llvm.amdgcn.update.dpp.i32(i32 poison, i32 %0, i32 257, i32 15, i32 15, i1 false) +// CHECK-NEXT: store i32 %1, +void test_mov_dpp_float(float x, global float *p) { + *p = __builtin_amdgcn_mov_dpp(x, 0x101, 0xf, 0xf, 0); +} + +// CHECK-LABEL: @test_mov_dpp_double +// CHECK: %0 = bitcast double %x to i64 +// CHECK-NEXT: %1 = tail call{{.*}} i64 @llvm.amdgcn.update.dpp.i64(i64 poison, i64 %0, i32 257, i32 15, i32 15, i1 false) +// CHECK-NEXT: store i64 %1, +void test_mov_dpp_double(double x, global double *p) { + *p = __builtin_amdgcn_mov_dpp(x, 0x101, 0xf, 0xf, 0); +} + rampitec wrote: Pointers and vectors are currently unsupported. Pointer negative test is in the sema test. I may add vector test there. In theory vectors can be handled though. Right now sema check rejects any non-arithmetic type, which is not int or fp. https://github.com/llvm/llvm-project/pull/112447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-include-cleaner] Fix incorrect directory issue for writing files (PR #111375)
kadircet wrote: btw, LMK if you don't have commit access and I should merge this for you https://github.com/llvm/llvm-project/pull/111375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
@@ -18,29 +18,42 @@ namespace clang::sema { -/// Describes an entity that is being assigned. -struct AssignedEntity { - // The left-hand side expression of the assignment. - Expr *LHS = nullptr; +struct CapturingEntity { bricknerb wrote: I think that using CapturingEntity for both use cases, with one of them keeping a field null makes it much harder to follow. Is it possible to use a more specific type? https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Allow overload of __builtin_amdgcn_mov/update_dpp (PR #112447)
@@ -102,20 +102,66 @@ void test_s_dcache_wb() __builtin_amdgcn_s_dcache_wb(); } -// CHECK-LABEL: @test_mov_dpp +// CHECK-LABEL: @test_mov_dpp_int // CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.update.dpp.i32(i32 poison, i32 %src, i32 0, i32 0, i32 0, i1 false) -void test_mov_dpp(global int* out, int src) +void test_mov_dpp_int(global int* out, int src) { *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false); } -// CHECK-LABEL: @test_update_dpp +// CHECK-LABEL: @test_mov_dpp_long +// CHECK: %0 = tail call{{.*}} i64 @llvm.amdgcn.update.dpp.i64(i64 poison, i64 %x, i32 257, i32 15, i32 15, i1 false) +// CHECK-NEXT: store i64 %0, +void test_mov_dpp_long(long x, global long *p) { + *p = __builtin_amdgcn_mov_dpp(x, 0x101, 0xf, 0xf, 0); +} + +// CHECK-LABEL: @test_mov_dpp_float +// CHECK: %0 = bitcast float %x to i32 +// CHECK-NEXT: %1 = tail call{{.*}} i32 @llvm.amdgcn.update.dpp.i32(i32 poison, i32 %0, i32 257, i32 15, i32 15, i1 false) +// CHECK-NEXT: store i32 %1, +void test_mov_dpp_float(float x, global float *p) { + *p = __builtin_amdgcn_mov_dpp(x, 0x101, 0xf, 0xf, 0); +} + +// CHECK-LABEL: @test_mov_dpp_double +// CHECK: %0 = bitcast double %x to i64 +// CHECK-NEXT: %1 = tail call{{.*}} i64 @llvm.amdgcn.update.dpp.i64(i64 poison, i64 %0, i32 257, i32 15, i32 15, i1 false) +// CHECK-NEXT: store i64 %1, +void test_mov_dpp_double(double x, global double *p) { + *p = __builtin_amdgcn_mov_dpp(x, 0x101, 0xf, 0xf, 0); +} + rampitec wrote: Practically vectors of arithmetic types might be limited usable. For dot and fma_mix. Now vectors are rejected though (as the argument defined as int), and rejected in the code in the patch to due to arithmetic sema check. https://github.com/llvm/llvm-project/pull/112447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
@@ -269,6 +271,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) { } } +static bool IsPointerLikeType(QualType QT) { + QT = QT.getNonReferenceType(); + // if (QT->isPointerType()) + // return true; + auto *RD = QT->getAsCXXRecordDecl(); + if (!RD) +return false; + RD = RD->getCanonicalDecl(); + if (auto *CTSD = dyn_cast(RD)) +RD = CTSD->getSpecializedTemplate()->getTemplatedDecl(); + return RD->hasAttr(); +} + +void Sema::inferLifetimeCaptureByAttribute(FunctionDecl *FD) { + if (!FD) +return; + auto *MD = dyn_cast(FD); + if (!MD || !MD->getIdentifier() || !MD->getParent()->isInStdNamespace()) +return; + static const llvm::StringSet<> CapturingMethods{"insert", "push", + "push_front", "push_back"}; bricknerb wrote: Do we not have emplace* methods on purpose? https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [clang] Introduce diagnostics suppression mappings (PR #112517)
https://github.com/kadircet updated https://github.com/llvm/llvm-project/pull/112517 From 01a538fbbd93a7f26e1309c9c95d5be0c8500402 Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Mon, 14 Oct 2024 11:20:55 +0200 Subject: [PATCH 1/2] [clang] Introduce diagnostics suppression mappings This implements https://discourse.llvm.org/t/rfc-add-support-for-controlling-diagnostics-severities-at-file-level-granularity-through-command-line/81292. Users now can suppress warnings for certain headers by providing a mapping with globs, a sample file looks like: ``` [unused] src:* src:*clang/*=emit ``` This will suppress warnings from `-Wunused` group in all files that aren't under `clang/` directory. This mapping file can be passed to clang via `--warning-suppression-mappings=foo.txt`. At a high level, mapping file is stored in DiagnosticOptions and then processed with rest of the warning flags when creating a DiagnosticsEngine. This is a functor that uses SpecialCaseLists underneath to match against globs coming from the mappings file. This implies processing warning options now performs IO, relevant interfaces are updated to take in a VFS, falling back to RealFileSystem when one is not available. --- .../ExpandModularHeadersPPCallbacks.cpp | 3 +- clang/include/clang/Basic/Diagnostic.h| 15 +- .../clang/Basic/DiagnosticDriverKinds.td | 3 + clang/include/clang/Basic/DiagnosticOptions.h | 3 + clang/include/clang/Driver/Options.td | 5 + .../include/clang/Frontend/CompilerInstance.h | 10 +- clang/lib/Basic/Diagnostic.cpp| 12 ++ clang/lib/Basic/DiagnosticIDs.cpp | 27 ++- clang/lib/Basic/Warnings.cpp | 107 clang/lib/Driver/ToolChains/Clang.cpp | 7 + clang/lib/Frontend/ASTUnit.cpp| 15 +- clang/lib/Frontend/CompilerInstance.cpp | 21 ++- clang/lib/Frontend/CompilerInvocation.cpp | 8 + clang/lib/Frontend/PrecompiledPreamble.cpp| 2 +- clang/lib/Interpreter/CodeCompletion.cpp | 4 +- clang/lib/Serialization/ASTReader.cpp | 4 +- .../test/Misc/Inputs/suppression-mapping.txt | 4 + .../Misc/warning-suppression-mappings.cpp | 16 ++ clang/tools/driver/cc1gen_reproducer_main.cpp | 7 +- clang/tools/driver/driver.cpp | 7 +- clang/unittests/Basic/DiagnosticTest.cpp | 164 ++ .../Frontend/CompilerInvocationTest.cpp | 10 ++ llvm/include/llvm/Support/SpecialCaseList.h | 1 - 23 files changed, 419 insertions(+), 36 deletions(-) create mode 100644 clang/test/Misc/Inputs/suppression-mapping.txt create mode 100644 clang/test/Misc/warning-suppression-mappings.cpp diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp index fef086c5a99d86..4c34f9ea122d9e 100644 --- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp +++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp @@ -81,7 +81,8 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks( Diags.setSourceManager(&Sources); // FIXME: Investigate whatever is there better way to initialize DiagEngine // or whatever DiagEngine can be shared by multiple preprocessors - ProcessWarningOptions(Diags, Compiler.getDiagnosticOpts()); + ProcessWarningOptions(Diags, Compiler.getDiagnosticOpts(), +Compiler.getVirtualFileSystem()); LangOpts.Modules = false; diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index 3b1efdb12824c7..79b7545e92d6da 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -20,11 +20,13 @@ #include "clang/Basic/Specifiers.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/VirtualFileSystem.h" #include #include #include @@ -555,6 +557,10 @@ class DiagnosticsEngine : public RefCountedBase { void *ArgToStringCookie = nullptr; ArgToStringFnTy ArgToStringFn; + /// Whether the diagnostic should be suppressed in FilePath. + llvm::unique_function + DiagSuppressionMapping; + public: explicit DiagnosticsEngine(IntrusiveRefCntPtr Diags, IntrusiveRefCntPtr DiagOpts, @@ -946,6 +952,13 @@ class DiagnosticsEngine : public RefCountedBase { return (Level)Diags->getDiagnosticLevel(DiagID, Loc, *this); } + /// Diagnostic suppression mappings can be used to ignore diagnostics based on + /// the file they occur in. + /// These take presumed locations into account, and can still be overriden by + /// clang-diagnostics pragmas. + void setDiagSuppressionMapping(decltype(Diag
[clang] [CLANG][AArch64]Add SVE tuple types for mfloat8_t (PR #112687)
https://github.com/CarolineConcatto created https://github.com/llvm/llvm-project/pull/112687 This patch adds scalable tuple types vectors for MFloat_8 type, according to the ACLE[1]. [1] https://github.com/ARM-software/acle.git >From 310e16c83e60ff64dadc27528da9b4e266d7db2e Mon Sep 17 00:00:00 2001 From: Caroline Concatto Date: Thu, 17 Oct 2024 10:01:17 + Subject: [PATCH] [CLANG][AArch64]Add SVE tuple types for mfloat8_t This patch adds scalable tuple types vectors for MFloat_8 type, according to the ACLE[1]. [1] https://github.com/ARM-software/acle.git --- .../clang/Basic/AArch64SVEACLETypes.def | 6 ++ .../include/clang/Serialization/ASTBitCodes.h | 2 +- .../CodeGenCXX/aarch64-mangle-sve-vectors.cpp | 86 ++- .../CodeGenCXX/aarch64-sve-vector-init.cpp| 70 +++ clang/utils/TableGen/SveEmitter.cpp | 4 + 5 files changed, 166 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 72df1e35aaec20..2b80e43b506384 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -138,6 +138,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) + // // x3 // @@ -158,6 +160,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) + // // x4 // @@ -178,6 +182,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4, false) + SVE_PREDICATE_TYPE_ALL("__SVBool_t", "__SVBool_t", SveBool, SveBoolTy, 16, 1) SVE_PREDICATE_TYPE_ALL("__clang_svboolx2_t", "svboolx2_t", SveBoolx2, SveBoolx2Ty, 16, 2) SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4Ty, 16, 4) diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index d735e2dcaa8c56..e397dff097652b 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1149,7 +1149,7 @@ enum PredefinedTypeIDs { /// /// Type IDs for non-predefined types will start at /// NUM_PREDEF_TYPE_IDs. -const unsigned NUM_PREDEF_TYPE_IDS = 506; +const unsigned NUM_PREDEF_TYPE_IDS = 509; // Ensure we do not overrun the predefined types we reserved // in the enum PredefinedTypeIDs above. diff --git a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp index 3f2b0622d55162..9f481e1f0f0857 100644 --- a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp +++ b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp @@ -59,6 +59,9 @@ void f(__clang_svbfloat16x3_t, __clang_svbfloat16x3_t); void f(__clang_svbfloat16x4_t, __clang_svbfloat16x4_t); void f(__clang_svboolx2_t, __clang_svboolx2_t); void f(__clang_svboolx4_t, __clang_svboolx4_t); +void f(__clang_svmfloat8x2_t, __clang_svmfloat8x2_t); +void f(__clang_svmfloat8x3_t, __clang_svmfloat8x3_t); +void f(__clang_svmfloat8x4_t, __clang_svmfloat8x4_t); // CHECK-LABEL: define dso_local void @_Z3foov( // CHECK-SAME: ) #[[ATTR0:[0-9]+]] { @@ -139,6 +142,12 @@ void f(__clang_svboolx4_t, __clang_svboolx4_t); // CHECK-NEXT:[[COERCE73:%.*]] = alloca { , }, align 2 // CHECK-NEXT:[[COERCE74:%.*]] = alloca { , , , }, align 2 // CHECK-NEXT:[[COERCE75:%.*]] = alloca { , , , }, align 2 +// CHECK-NEXT:[[COERCE76:%.*]] = alloca { , }, align 16 +// CHECK-NEXT:[[COERCE77:%.*]] = alloca { , }, align 16 +// CHECK-NEXT:[[COERCE78:%.*]] = alloca { , , }, align 16 +// CHECK-NEXT:[[COERCE79:%.*]] = alloca { , , }, align 16 +// CHECK-NEXT:[[COERCE80:%.*]] = alloca { , , , }, align 16 +// CHECK-NEXT:[[COERCE81:%.*]] = alloca { , , , }, align 16 // CHECK-NEXT:call void @_Z1fu10__SVInt8_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu11__SVInt16_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu11__SVInt16_tS_( zeroinitializer, zeroinitializer) @@ -151,7 +160,7 @@ void f(__clang_svboolx4_t, __clang_svboolx4_t); // CHECK-NEXT:call void @_Z1fu13__SVFloat16_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu13__SVFloat32_tS_( zeroinitializer, zeroinitializer) /
[clang] [CLANG][AArch64]Add SVE tuple types for mfloat8_t (PR #112687)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: None (CarolineConcatto) Changes This patch adds scalable tuple types vectors for MFloat_8 type, according to the ACLE[1]. [1] https://github.com/ARM-software/acle.git --- Patch is 27.58 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/112687.diff 5 Files Affected: - (modified) clang/include/clang/Basic/AArch64SVEACLETypes.def (+6) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+1-1) - (modified) clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp (+85-1) - (modified) clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp (+70) - (modified) clang/utils/TableGen/SveEmitter.cpp (+4) ``diff diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 72df1e35aaec20..2b80e43b506384 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -138,6 +138,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) + // // x3 // @@ -158,6 +160,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) + // // x4 // @@ -178,6 +182,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4, false) + SVE_PREDICATE_TYPE_ALL("__SVBool_t", "__SVBool_t", SveBool, SveBoolTy, 16, 1) SVE_PREDICATE_TYPE_ALL("__clang_svboolx2_t", "svboolx2_t", SveBoolx2, SveBoolx2Ty, 16, 2) SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4Ty, 16, 4) diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index d735e2dcaa8c56..e397dff097652b 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1149,7 +1149,7 @@ enum PredefinedTypeIDs { /// /// Type IDs for non-predefined types will start at /// NUM_PREDEF_TYPE_IDs. -const unsigned NUM_PREDEF_TYPE_IDS = 506; +const unsigned NUM_PREDEF_TYPE_IDS = 509; // Ensure we do not overrun the predefined types we reserved // in the enum PredefinedTypeIDs above. diff --git a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp index 3f2b0622d55162..9f481e1f0f0857 100644 --- a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp +++ b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp @@ -59,6 +59,9 @@ void f(__clang_svbfloat16x3_t, __clang_svbfloat16x3_t); void f(__clang_svbfloat16x4_t, __clang_svbfloat16x4_t); void f(__clang_svboolx2_t, __clang_svboolx2_t); void f(__clang_svboolx4_t, __clang_svboolx4_t); +void f(__clang_svmfloat8x2_t, __clang_svmfloat8x2_t); +void f(__clang_svmfloat8x3_t, __clang_svmfloat8x3_t); +void f(__clang_svmfloat8x4_t, __clang_svmfloat8x4_t); // CHECK-LABEL: define dso_local void @_Z3foov( // CHECK-SAME: ) #[[ATTR0:[0-9]+]] { @@ -139,6 +142,12 @@ void f(__clang_svboolx4_t, __clang_svboolx4_t); // CHECK-NEXT:[[COERCE73:%.*]] = alloca { , }, align 2 // CHECK-NEXT:[[COERCE74:%.*]] = alloca { , , , }, align 2 // CHECK-NEXT:[[COERCE75:%.*]] = alloca { , , , }, align 2 +// CHECK-NEXT:[[COERCE76:%.*]] = alloca { , }, align 16 +// CHECK-NEXT:[[COERCE77:%.*]] = alloca { , }, align 16 +// CHECK-NEXT:[[COERCE78:%.*]] = alloca { , , }, align 16 +// CHECK-NEXT:[[COERCE79:%.*]] = alloca { , , }, align 16 +// CHECK-NEXT:[[COERCE80:%.*]] = alloca { , , , }, align 16 +// CHECK-NEXT:[[COERCE81:%.*]] = alloca { , , , }, align 16 // CHECK-NEXT:call void @_Z1fu10__SVInt8_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu11__SVInt16_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu11__SVInt16_tS_( zeroinitializer, zeroinitializer) @@ -151,7 +160,7 @@ void f(__clang_svboolx4_t, __clang_svboolx4_t); // CHECK-NEXT:call void @_Z1fu13__SVFloat16_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu13__SVFloat32_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu13__SVFloat64_tS_( zeroinitializer, zeroinitializer) -// CHECK-NEXT: call void @_Z1fu13__SVMfloat8_tS_( zeroinitializer, zeroinitializer) +// CHECK-NEXT:
[clang] [clang] Reject if constexpr in C (PR #112685)
https://github.com/cor3ntin approved this pull request. LGTM - I think we should backport that to 19 (so we don't need a changelog) https://github.com/llvm/llvm-project/pull/112685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][Clang][NEON] Remove undefined vcmla intrinsics (PR #112575)
https://github.com/SpencerAbson closed https://github.com/llvm/llvm-project/pull/112575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 53d89ef - [AArch64][Clang][NEON] Remove undefined vcmla intrinsics (#112575)
Author: SpencerAbson Date: 2024-10-17T11:16:06+01:00 New Revision: 53d89ef34005f4dc4f764db0c009130bb52a6a78 URL: https://github.com/llvm/llvm-project/commit/53d89ef34005f4dc4f764db0c009130bb52a6a78 DIFF: https://github.com/llvm/llvm-project/commit/53d89ef34005f4dc4f764db0c009130bb52a6a78.diff LOG: [AArch64][Clang][NEON] Remove undefined vcmla intrinsics (#112575) arm_neon.td currently generates the same 24 `vcmla` intrinsic prototypes for each of the f16, f32, and f64 base types. This is incorrect, the only valid vcmla intrinsics for the f64 base type are: - `vcmlaq_f64` - `vcmlaq_rot90_f64` - `vcmlaq_rot180_f64` - `vcmlaq_rot270_f64` (see ACLE https://github.com/ARM-software/acle/blob/main/neon_intrinsics/advsimd.md) This patch removes the incorrect intrinsic prototypes. Added: clang/test/Sema/aarch64-vcmla-undef.c Modified: clang/include/clang/Basic/arm_neon.td clang/test/Sema/aarch64-neon-target.c Removed: diff --git a/clang/include/clang/Basic/arm_neon.td b/clang/include/clang/Basic/arm_neon.td index 8652b5e3a9c901..ec829f566ef5fc 100644 --- a/clang/include/clang/Basic/arm_neon.td +++ b/clang/include/clang/Basic/arm_neon.td @@ -1968,13 +1968,16 @@ let TargetGuard = "v8.3a,neon" in { def VCADDQ_ROT90 : SInst<"vcaddq_rot90", "QQQ", "f">; def VCADDQ_ROT270 : SInst<"vcaddq_rot270", "QQQ", "f">; - defm VCMLA_F32: VCMLA_ROTS<"f", "uint64x1_t", "uint64x2_t">; + defm VCMLA_F32: VCMLA_ROTS<"f", "uint64x1_t", "uint64x2_t">; } let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = "v8.3a,neon" in { def VCADDQ_ROT90_FP64 : SInst<"vcaddq_rot90", "QQQ", "d">; def VCADDQ_ROT270_FP64 : SInst<"vcaddq_rot270", "QQQ", "d">; - defm VCMLA_FP64 : VCMLA_ROTS<"d", "uint64x2_t", "uint64x2_t">; + def VCMLAQ_FP64: SInst<"vcmlaq", "", "d">; + def VCMLAQ_ROT90_FP64 : SInst<"vcmlaq_rot90", "", "d">; + def VCMLAQ_ROT180_FP64 : SInst<"vcmlaq_rot180", "", "d">; + def VCMLAQ_ROT270_FP64 : SInst<"vcmlaq_rot270", "", "d">; } // V8.2-A BFloat intrinsics diff --git a/clang/test/Sema/aarch64-neon-target.c b/clang/test/Sema/aarch64-neon-target.c index fd84b7f2eb00a1..07d763ec84bd12 100644 --- a/clang/test/Sema/aarch64-neon-target.c +++ b/clang/test/Sema/aarch64-neon-target.c @@ -58,7 +58,7 @@ __attribute__((target("arch=armv8.3-a+fp16"))) void test_v83(float32x4_t v4f32, float16x4_t v4f16, float64x2_t v2f64) { vcaddq_rot90_f32(v4f32, v4f32); vcmla_rot90_f16(v4f16, v4f16, v4f16); - vcmlaq_rot270_laneq_f64(v2f64, v2f64, v2f64, 1); + vcmlaq_rot270_f64(v2f64, v2f64, v2f64); } __attribute__((target("arch=armv8.5-a"))) @@ -95,7 +95,7 @@ void undefined(uint32x2_t v2i32, uint32x4_t v4i32, uint16x8_t v8i16, uint8x16_t // 8.3 - complex vcaddq_rot90_f32(v4f32, v4f32); // expected-error {{always_inline function 'vcaddq_rot90_f32' requires target feature 'v8.3a'}} vcmla_rot90_f16(v4f16, v4f16, v4f16); // expected-error {{always_inline function 'vcmla_rot90_f16' requires target feature 'v8.3a'}} - vcmlaq_rot270_laneq_f64(v2f64, v2f64, v2f64, 1); // expected-error {{always_inline function 'vcmlaq_rot270_f64' requires target feature 'v8.3a'}} + vcmlaq_rot270_f64(v2f64, v2f64, v2f64); // expected-error {{always_inline function 'vcmlaq_rot270_f64' requires target feature 'v8.3a'}} // 8.5 - frint vrnd32xq_f32(v4f32); // expected-error {{always_inline function 'vrnd32xq_f32' requires target feature 'v8.5a'}} diff --git a/clang/test/Sema/aarch64-vcmla-undef.c b/clang/test/Sema/aarch64-vcmla-undef.c new file mode 100644 index 00..8a777ff6156339 --- /dev/null +++ b/clang/test/Sema/aarch64-vcmla-undef.c @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -target-feature +v8.3a -ffreestanding -fsyntax-only -verify -verify-ignore-unexpected=note %s + +// REQUIRES: aarch64-registered-target + +#include + +void test(float64x1_t v1f64, float64x2_t v2f64) { +vcmla_f64(v1f64, v1f64, v1f64); // expected-error {{call to undeclared function 'vcmla_f64'}} +vcmla_lane_f64(v1f64, v1f64, v1f64, 0); // expected-error {{call to undeclared function 'vcmla_lane_f64'}} +vcmla_laneq_f64(v1f64, v1f64, v2f64, 0); // expected-error {{call to undeclared function 'vcmla_laneq_f64'}} +vcmlaq_lane_f64(v2f64, v2f64, v1f64, 0); // expected-error {{call to undeclared function 'vcmlaq_lane_f64'}} +vcmlaq_laneq_f64(v2f64, v2f64, v2f64, 0); // expected-error {{call to undeclared function 'vcmlaq_laneq_f64'}} + +vcmla_rot90_f64(v1f64, v1f64, v1f64); // expected-error {{call to undeclared function 'vcmla_rot90_f64'}} +vcmla_rot90_lane_f64(v1f64, v1f64, v1f64, 0); // expected-error {{call to undeclared function 'vcmla_rot90_lane_f64'}} +vcmla_rot90_laneq_f64(v1f64, v1f64, v2f64, 0); // expected-error {{call to undeclared function 'vcmla_rot90_laneq_f64'}} +vcml
[clang] [CLANG][AArch64]Add SVE tuple types for mfloat8_t (PR #112687)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (CarolineConcatto) Changes This patch adds scalable tuple types vectors for MFloat_8 type, according to the ACLE[1]. [1] https://github.com/ARM-software/acle.git --- Patch is 27.58 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/112687.diff 5 Files Affected: - (modified) clang/include/clang/Basic/AArch64SVEACLETypes.def (+6) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+1-1) - (modified) clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp (+85-1) - (modified) clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp (+70) - (modified) clang/utils/TableGen/SveEmitter.cpp (+4) ``diff diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 72df1e35aaec20..2b80e43b506384 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -138,6 +138,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) + // // x3 // @@ -158,6 +160,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) + // // x4 // @@ -178,6 +182,8 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) +SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4, false) + SVE_PREDICATE_TYPE_ALL("__SVBool_t", "__SVBool_t", SveBool, SveBoolTy, 16, 1) SVE_PREDICATE_TYPE_ALL("__clang_svboolx2_t", "svboolx2_t", SveBoolx2, SveBoolx2Ty, 16, 2) SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4Ty, 16, 4) diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index d735e2dcaa8c56..e397dff097652b 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1149,7 +1149,7 @@ enum PredefinedTypeIDs { /// /// Type IDs for non-predefined types will start at /// NUM_PREDEF_TYPE_IDs. -const unsigned NUM_PREDEF_TYPE_IDS = 506; +const unsigned NUM_PREDEF_TYPE_IDS = 509; // Ensure we do not overrun the predefined types we reserved // in the enum PredefinedTypeIDs above. diff --git a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp index 3f2b0622d55162..9f481e1f0f0857 100644 --- a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp +++ b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp @@ -59,6 +59,9 @@ void f(__clang_svbfloat16x3_t, __clang_svbfloat16x3_t); void f(__clang_svbfloat16x4_t, __clang_svbfloat16x4_t); void f(__clang_svboolx2_t, __clang_svboolx2_t); void f(__clang_svboolx4_t, __clang_svboolx4_t); +void f(__clang_svmfloat8x2_t, __clang_svmfloat8x2_t); +void f(__clang_svmfloat8x3_t, __clang_svmfloat8x3_t); +void f(__clang_svmfloat8x4_t, __clang_svmfloat8x4_t); // CHECK-LABEL: define dso_local void @_Z3foov( // CHECK-SAME: ) #[[ATTR0:[0-9]+]] { @@ -139,6 +142,12 @@ void f(__clang_svboolx4_t, __clang_svboolx4_t); // CHECK-NEXT:[[COERCE73:%.*]] = alloca { , }, align 2 // CHECK-NEXT:[[COERCE74:%.*]] = alloca { , , , }, align 2 // CHECK-NEXT:[[COERCE75:%.*]] = alloca { , , , }, align 2 +// CHECK-NEXT:[[COERCE76:%.*]] = alloca { , }, align 16 +// CHECK-NEXT:[[COERCE77:%.*]] = alloca { , }, align 16 +// CHECK-NEXT:[[COERCE78:%.*]] = alloca { , , }, align 16 +// CHECK-NEXT:[[COERCE79:%.*]] = alloca { , , }, align 16 +// CHECK-NEXT:[[COERCE80:%.*]] = alloca { , , , }, align 16 +// CHECK-NEXT:[[COERCE81:%.*]] = alloca { , , , }, align 16 // CHECK-NEXT:call void @_Z1fu10__SVInt8_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu11__SVInt16_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu11__SVInt16_tS_( zeroinitializer, zeroinitializer) @@ -151,7 +160,7 @@ void f(__clang_svboolx4_t, __clang_svboolx4_t); // CHECK-NEXT:call void @_Z1fu13__SVFloat16_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu13__SVFloat32_tS_( zeroinitializer, zeroinitializer) // CHECK-NEXT:call void @_Z1fu13__SVFloat64_tS_( zeroinitializer, zeroinitializer) -// CHECK-NEXT: call void @_Z1fu13__SVMfloat8_tS_( zeroinitializer, zeroinitializer) +// CHECK-NEXT:call vo
[clang] [clang][ASTImporter] Fix of unchecked Error object (NFC) (PR #112688)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Balázs Kéri (balazske) Changes After a previous fix and commit 30a9cac error handling in function 'importTemplateParameterDefaultArgument' was not correct because std::move was removed from return of an Error object and this caused crash "Error value was Success" in some cases. --- Full diff: https://github.com/llvm/llvm-project/pull/112688.diff 1 Files Affected: - (modified) clang/lib/AST/ASTImporter.cpp (+13-13) ``diff diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 020a2f396b5aa0..e7a6509167f0a0 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -362,24 +362,24 @@ namespace clang { template Error importTemplateParameterDefaultArgument(const TemplateParmDeclT *D, TemplateParmDeclT *ToD) { - Error Err = Error::success(); if (D->hasDefaultArgument()) { if (D->defaultArgumentWasInherited()) { - auto *ToInheritedFrom = const_cast( - importChecked(Err, D->getDefaultArgStorage().getInheritedFrom())); - if (Err) -return Err; + Expected ToInheritedFromOrErr = + import(D->getDefaultArgStorage().getInheritedFrom()); + if (!ToInheritedFromOrErr) +return ToInheritedFromOrErr.takeError(); + TemplateParmDeclT *ToInheritedFrom = *ToInheritedFromOrErr; if (!ToInheritedFrom->hasDefaultArgument()) { // Resolve possible circular dependency between default value of the // template argument and the template declaration. -const auto ToInheritedDefaultArg = -importChecked(Err, D->getDefaultArgStorage() - .getInheritedFrom() - ->getDefaultArgument()); -if (Err) - return Err; +Expected ToInheritedDefaultArgOrErr = +import(D->getDefaultArgStorage() + .getInheritedFrom() + ->getDefaultArgument()); +if (!ToInheritedDefaultArgOrErr) + return ToInheritedDefaultArgOrErr.takeError(); ToInheritedFrom->setDefaultArgument(Importer.getToContext(), -ToInheritedDefaultArg); +*ToInheritedDefaultArgOrErr); } ToD->setInheritedDefaultArgument(ToD->getASTContext(), ToInheritedFrom); @@ -395,7 +395,7 @@ namespace clang { *ToDefaultArgOrErr); } } - return Err; + return Error::success(); } public: `` https://github.com/llvm/llvm-project/pull/112688 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Fix of unchecked Error object (NFC) (PR #112688)
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/112688 After a previous fix and commit 30a9cac error handling in function 'importTemplateParameterDefaultArgument' was not correct because std::move was removed from return of an Error object and this caused crash "Error value was Success" in some cases. From 0694ea396728fe34f031fa1102460f56da4d3822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 17 Oct 2024 12:03:55 +0200 Subject: [PATCH] [clang][ASTImporter] Fix of unchecked Error object (NFC) After a previous fix and commit 30a9cac error handling in function 'importTemplateParameterDefaultArgument' was not correct because std::move was removed from return of an Error object and this caused crash "Error value was Success" in some cases. --- clang/lib/AST/ASTImporter.cpp | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 020a2f396b5aa0..e7a6509167f0a0 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -362,24 +362,24 @@ namespace clang { template Error importTemplateParameterDefaultArgument(const TemplateParmDeclT *D, TemplateParmDeclT *ToD) { - Error Err = Error::success(); if (D->hasDefaultArgument()) { if (D->defaultArgumentWasInherited()) { - auto *ToInheritedFrom = const_cast( - importChecked(Err, D->getDefaultArgStorage().getInheritedFrom())); - if (Err) -return Err; + Expected ToInheritedFromOrErr = + import(D->getDefaultArgStorage().getInheritedFrom()); + if (!ToInheritedFromOrErr) +return ToInheritedFromOrErr.takeError(); + TemplateParmDeclT *ToInheritedFrom = *ToInheritedFromOrErr; if (!ToInheritedFrom->hasDefaultArgument()) { // Resolve possible circular dependency between default value of the // template argument and the template declaration. -const auto ToInheritedDefaultArg = -importChecked(Err, D->getDefaultArgStorage() - .getInheritedFrom() - ->getDefaultArgument()); -if (Err) - return Err; +Expected ToInheritedDefaultArgOrErr = +import(D->getDefaultArgStorage() + .getInheritedFrom() + ->getDefaultArgument()); +if (!ToInheritedDefaultArgOrErr) + return ToInheritedDefaultArgOrErr.takeError(); ToInheritedFrom->setDefaultArgument(Importer.getToContext(), -ToInheritedDefaultArg); +*ToInheritedDefaultArgOrErr); } ToD->setInheritedDefaultArgument(ToD->getASTContext(), ToInheritedFrom); @@ -395,7 +395,7 @@ namespace clang { *ToDefaultArgOrErr); } } - return Err; + return Error::success(); } public: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Deduplicate the logic that only warns once when stack is almost full (PR #112552)
@@ -0,0 +1,45 @@ +//===--- SingleWarningStackAwareExecutor.h - A utility for warning once when +// close to out of stack space ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +/// +/// \file +/// Defines a utilitiy for warning once when close to out of stack space. +/// +//===--===// + +#ifndef LLVM_CLANG_BASIC_SINGLE_WARNING_STACK_AWARE_EXECUTOR_H +#define LLVM_CLANG_BASIC_SINGLE_WARNING_STACK_AWARE_EXECUTOR_H + +#include "clang/Basic/Diagnostic.h" + +namespace clang { +class SingleWarningStackAwareExecutor { cor3ntin wrote: The primary functionality is to grow the stack, The name should be more reflective of that Maybe `StackExhaustionHandler" or some such https://github.com/llvm/llvm-project/pull/112552 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer] Introduce MutexModeling checker (PR #111381)
Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= , Endre =?utf-8?q?Fülöp?= Message-ID: In-Reply-To: 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 4091bc61e315f187829dca877dd908a07ba9cb91 efaa0ec4f1bf72c0232a89b563ee92f530dce1e5 --extensions cpp,h,c -- clang/lib/StaticAnalyzer/Checkers/MutexModeling.cpp clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDefs.h clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDomain.h clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingGDM.h clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexRegionExtractor.h clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp clang/test/Analysis/analyzer-enabled-checkers.c clang/test/Analysis/block-in-critical-section.cpp clang/test/Analysis/pthreadlock_state.c clang/test/Analysis/pthreadlock_state_nottracked.c clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c `` View the diff from clang-format here. ``diff diff --git a/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h b/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h index bcc076a256..a597d860e4 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h +++ b/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingAPI.h @@ -53,9 +53,9 @@ MakeFirstArgExtractor(ArrayRef NameParts, int NumArgsRequired = 1, CallDescription{MatchAs, NameParts, NumArgsRequired}}; } -inline auto MakeMemberExtractor(ArrayRef NameParts, -int NumArgsRequired = 0, -CallDescription::Mode MatchAs = CDM::CXXMethod) { +inline auto +MakeMemberExtractor(ArrayRef NameParts, int NumArgsRequired = 0, +CallDescription::Mode MatchAs = CDM::CXXMethod) { return MemberMutexExtractor{ CallDescription{MatchAs, NameParts, NumArgsRequired}}; } diff --git a/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDefs.h b/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDefs.h index d0b2f5957b..48d1bedffb 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDefs.h +++ b/clang/lib/StaticAnalyzer/Checkers/MutexModeling/MutexModelingDefs.h @@ -22,8 +22,8 @@ namespace clang::ento::mutex_modeling { static auto getHandledEvents(){return std::vector { // - Pthread - EventDescriptor{MakeFirstArgExtractor({"pthread_mutex_init"}), EventKind::Init, - LibraryKind::Pthread}, + EventDescriptor{MakeFirstArgExtractor({"pthread_mutex_init"}), + EventKind::Init, LibraryKind::Pthread}, #if 0 // TODO: pthread_rwlock_init(2 arguments). // TODO: lck_mtx_init(3 arguments). `` https://github.com/llvm/llvm-project/pull/111381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)
ckandeler wrote: Needs rebase and another typo fix. Looks good to me otherwise. https://github.com/llvm/llvm-project/pull/81640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] constexpr built-in abs function. (PR #112539)
cor3ntin wrote: Please add an entry to `clang/docs/ReleaseNotes.rst`, thanks! https://github.com/llvm/llvm-project/pull/112539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5b4071c - [clang][bytecode] Explicitly truncate in IntegralAP::from() (#112683)
Author: Timm Baeder Date: 2024-10-17T12:26:44+02:00 New Revision: 5b4071c7554ab4feeae4817e3d41013016308586 URL: https://github.com/llvm/llvm-project/commit/5b4071c7554ab4feeae4817e3d41013016308586 DIFF: https://github.com/llvm/llvm-project/commit/5b4071c7554ab4feeae4817e3d41013016308586.diff LOG: [clang][bytecode] Explicitly truncate in IntegralAP::from() (#112683) Add Integral::toAPInt(), which truncates to the given BitWidth, similar to the toAPSInt() we already have. Added: Modified: clang/lib/AST/ByteCode/Integral.h clang/lib/AST/ByteCode/IntegralAP.h Removed: diff --git a/clang/lib/AST/ByteCode/Integral.h b/clang/lib/AST/ByteCode/Integral.h index e06ec1669259da..be537d22d5af1b 100644 --- a/clang/lib/AST/ByteCode/Integral.h +++ b/clang/lib/AST/ByteCode/Integral.h @@ -122,11 +122,14 @@ template class Integral final { APSInt toAPSInt() const { return APSInt(APInt(Bits, static_cast(V), Signed), !Signed); } - APSInt toAPSInt(unsigned NumBits) const { + APSInt toAPSInt(unsigned BitWidth) const { return APSInt(toAPInt(BitWidth)); } + APInt toAPInt(unsigned BitWidth) const { if constexpr (Signed) - return APSInt(toAPSInt().sextOrTrunc(NumBits), !Signed); + return APInt(Bits, static_cast(V), Signed) + .sextOrTrunc(BitWidth); else - return APSInt(toAPSInt().zextOrTrunc(NumBits), !Signed); + return APInt(Bits, static_cast(V), Signed) + .zextOrTrunc(BitWidth); } APValue toAPValue(const ASTContext &) const { return APValue(toAPSInt()); } diff --git a/clang/lib/AST/ByteCode/IntegralAP.h b/clang/lib/AST/ByteCode/IntegralAP.h index 252d7243bee73e..f8aeaaca398fe8 100644 --- a/clang/lib/AST/ByteCode/IntegralAP.h +++ b/clang/lib/AST/ByteCode/IntegralAP.h @@ -112,12 +112,7 @@ template class IntegralAP final { template static IntegralAP from(Integral I, unsigned BitWidth) { -// TODO: Avoid implicit trunc? -// See https://github.com/llvm/llvm-project/issues/112510. -APInt Copy = APInt(BitWidth, static_cast(I), InputSigned, - /*implicitTrunc=*/true); - -return IntegralAP(Copy); +return IntegralAP(I.toAPInt(BitWidth)); } static IntegralAP zero(int32_t BitWidth) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Explicitly truncate in IntegralAP::from() (PR #112683)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/112683 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Deduplicate the logic that only warns once when stack is almost full (PR #112552)
https://github.com/ilya-biryukov approved this pull request. LGTM, but please fix the comment from @cor3ntin before submitting about renaming the class https://github.com/llvm/llvm-project/pull/112552 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 4cda28c - [clang-include-cleaner] Fix incorrect directory issue for writing files (#111375)
Author: Byoungchan Lee Date: 2024-10-17T10:16:07+02:00 New Revision: 4cda28c1ada702a08f6960eb4c93919187c1d4d1 URL: https://github.com/llvm/llvm-project/commit/4cda28c1ada702a08f6960eb4c93919187c1d4d1 DIFF: https://github.com/llvm/llvm-project/commit/4cda28c1ada702a08f6960eb4c93919187c1d4d1.diff LOG: [clang-include-cleaner] Fix incorrect directory issue for writing files (#111375) If the current working directory of `clang-include-cleaner` differs from the directory of the input files specified in the compilation database, it doesn't adjust the input file paths properly. As a result, `clang-include-cleaner` either writes files to the wrong directory or fails to write files altogether. This pull request fixes the issue by adjusting the input file paths based on the directory specified in the compilation database. If that directory is not writable, `clang-include-cleaner` will write the output relative to the current working directory. Fixes #110843. Added: Modified: clang-tools-extra/include-cleaner/test/tool.cpp clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp Removed: diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp index 2155eec189d186..d72d2317ce2b1d 100644 --- a/clang-tools-extra/include-cleaner/test/tool.cpp +++ b/clang-tools-extra/include-cleaner/test/tool.cpp @@ -48,3 +48,13 @@ int x = foo(); //RUN: clang-include-cleaner -edit --ignore-headers="foobar\.h,foo\.h" %t.cpp -- -I%S/Inputs/ //RUN: FileCheck --match-full-lines --check-prefix=EDIT2 %s < %t.cpp // EDIT2-NOT: {{^}}#include "foo.h"{{$}} + +//RUN: rm -rf %t.dir && mkdir -p %t.dir +//RUN: cp %s %t.cpp +//RUN: echo "[{\"directory\":\"%t.dir\",\"file\":\"../%{t:stem}.tmp.cpp\",\"command\":\":clang++ -I%S/Inputs/ ../%{t:stem}.tmp.cpp\"}]" | sed -e 's/\\//g' > %t.dir/compile_commands.json +//RUN: pushd %t.dir +//RUN: clang-include-cleaner -p %{t:stem}.tmp.dir -edit ../%{t:stem}.tmp.cpp +//RUN: popd +//RUN: FileCheck --match-full-lines --check-prefix=EDIT3 %s < %t.cpp +// EDIT3: #include "foo.h" +// EDIT3-NOT: {{^}}#include "foobar.h"{{$}} diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 080099adc9a07a..6bd9c40c70753c 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -173,9 +173,11 @@ class Action : public clang::ASTFrontendAction { if (!HTMLReportPath.empty()) writeHTML(); -llvm::StringRef Path = -SM.getFileEntryRefForID(SM.getMainFileID())->getName(); -assert(!Path.empty() && "Main file path not known?"); +// Source File's path of compiler invocation, converted to absolute path. +llvm::SmallString<256> AbsPath( +SM.getFileEntryRefForID(SM.getMainFileID())->getName()); +assert(!AbsPath.empty() && "Main file path not known?"); +SM.getFileManager().makeAbsolutePath(AbsPath); llvm::StringRef Code = SM.getBufferData(SM.getMainFileID()); auto Results = @@ -185,7 +187,7 @@ class Action : public clang::ASTFrontendAction { Results.Missing.clear(); if (!Remove) Results.Unused.clear(); -std::string Final = fixIncludes(Results, Path, Code, getStyle(Path)); +std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); if (Print.getNumOccurrences()) { switch (Print) { @@ -202,7 +204,7 @@ class Action : public clang::ASTFrontendAction { } if (!Results.Missing.empty() || !Results.Unused.empty()) - EditedFiles.try_emplace(Path, Final); + EditedFiles.try_emplace(AbsPath, Final); } void writeHTML() { @@ -280,6 +282,48 @@ std::function headerFilter() { }; } +// Maps absolute path of each files of each compilation commands to the +// absolute path of the input file. +llvm::Expected> +mapInputsToAbsPaths(clang::tooling::CompilationDatabase &CDB, +llvm::IntrusiveRefCntPtr VFS, +const std::vector &Inputs) { + std::map CDBToAbsPaths; + // Factory.editedFiles()` will contain the final code, along with the + // path given in the compilation database. That path can be + // absolute or relative, and if it is relative, it is relative to the + // "Directory" field in the compilation database. We need to make it + // absolute to write the final code to the correct path. + for (auto &Source : Inputs) { +llvm::SmallString<256> AbsPath(Source); +if (auto Err = VFS->makeAbsolute(AbsPath)) { + llvm::errs() << "Failed to get absolute path for " << Source << " : " + << Err.message() << '\n'; + return std::move(llvm::errorCodeToError(Err)); +} +std::vector Cmds = +CDB.getCompileCommand
[clang-tools-extra] [clang-include-cleaner] Fix incorrect directory issue for writing files (PR #111375)
https://github.com/kadircet closed https://github.com/llvm/llvm-project/pull/111375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenCL] Replace a CreatePointerCast call; NFC (PR #112676)
https://github.com/svenvh created https://github.com/llvm/llvm-project/pull/112676 With opaque pointers, the only purpose of the cast here is to cast between address spaces, similar to the 4-argument case below. >From 7dff616c6cd8ffb2c58e26132370f9329a0bf4cd Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Thu, 17 Oct 2024 09:01:14 +0100 Subject: [PATCH] [OpenCL] Replace a CreatePointerCast call; NFC With opaque pointers, the only purpose of the cast here is to cast between address spaces, similar to the 4-argument case below. --- clang/lib/CodeGen/CGBuiltin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index f6d7db2c204c12..b2af4295fe99fe 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5641,10 +5641,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, llvm::Type *ArgTys[] = {Arg0->getType(), I8PTy, Int32Ty, Int32Ty}; llvm::FunctionType *FTy = llvm::FunctionType::get( Int32Ty, llvm::ArrayRef(ArgTys), false); - Value *BCast = Builder.CreatePointerCast(Arg1, I8PTy); + Value *ACast = Builder.CreateAddrSpaceCast(Arg1, I8PTy); return RValue::get( EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name), - {Arg0, BCast, PacketSize, PacketAlign})); + {Arg0, ACast, PacketSize, PacketAlign})); } else { assert(4 == E->getNumArgs() && "Illegal number of parameters to pipe function"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenCL] Replace a CreatePointerCast call; NFC (PR #112676)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Sven van Haastregt (svenvh) Changes With opaque pointers, the only purpose of the cast here is to cast between address spaces, similar to the 4-argument case below. --- Full diff: https://github.com/llvm/llvm-project/pull/112676.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+2-2) ``diff diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index f6d7db2c204c12..b2af4295fe99fe 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5641,10 +5641,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, llvm::Type *ArgTys[] = {Arg0->getType(), I8PTy, Int32Ty, Int32Ty}; llvm::FunctionType *FTy = llvm::FunctionType::get( Int32Ty, llvm::ArrayRef(ArgTys), false); - Value *BCast = Builder.CreatePointerCast(Arg1, I8PTy); + Value *ACast = Builder.CreateAddrSpaceCast(Arg1, I8PTy); return RValue::get( EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name), - {Arg0, BCast, PacketSize, PacketAlign})); + {Arg0, ACast, PacketSize, PacketAlign})); } else { assert(4 == E->getNumArgs() && "Illegal number of parameters to pipe function"); `` https://github.com/llvm/llvm-project/pull/112676 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make -fveclib={ArmPL, SLEEF} imply -fno-math-errno (PR #112580)
@@ -36,16 +36,23 @@ /* Verify that the correct vector library is passed to LTO flags. */ // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=LIBMVEC -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBMVEC %s +// CHECK-LTO-LIBMVEC: "-fmath-errno" // CHECK-LTO-LIBMVEC: "-plugin-opt=-vector-library=LIBMVEC-X86" // RUN: %clang -### --target=powerpc64-unknown-linux-gnu -fveclib=MASSV -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-MASSV %s +// CHECK-LTO-MASSV: "-fmath-errno" // CHECK-LTO-MASSV: "-plugin-opt=-vector-library=MASSV" // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=SVML -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-SVML %s +// CHECK-LTO-SVML: "-fmath-errno" // CHECK-LTO-SVML: "-plugin-opt=-vector-library=SVML" // RUN: %clang -### --target=aarch64-linux-gnu -fveclib=SLEEF -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-SLEEF %s +// CHECK-LTO-SLEEF-NOT: "-fmath-errno" // CHECK-LTO-SLEEF: "-plugin-opt=-vector-library=sleefgnuabi" +// CHECK-LTO-SLEEF-NOT: "-fmath-errno" // RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-ARMPL %s +// CHECK-LTO-ARMPL-NOT: "-fmath-errno" mgabka wrote: I think it might be worth to add tests for "-fveclib=ArmPL -fmath-errno" and similar for sleefm to ensure that the order of flags in properly honoured. https://github.com/llvm/llvm-project/pull/112580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG]Add Scalable vectors for mfloat8_t (PR #101644)
https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/101644 >From 7134302c7e1054021af36a207dbfd0c40c9e8c51 Mon Sep 17 00:00:00 2001 From: Caroline Concatto Date: Fri, 2 Aug 2024 08:47:18 + Subject: [PATCH 1/3] [CLANG]Add Scalable vectors for mfloat8_t This patch adds these new vector sizes for sve: svmfloat8_t According to the ARM ACLE PR#323[1]. [1] ARM-software/acle#323 --- .../clang/Basic/AArch64SVEACLETypes.def | 7 clang/include/clang/Basic/arm_sve_sme_incl.td | 1 + .../include/clang/Serialization/ASTBitCodes.h | 2 +- clang/lib/AST/ASTContext.cpp | 14 ++-- clang/test/CodeGen/arm-mfp8.c | 28 clang/test/Modules/no-external-type-id.cppm | 2 +- clang/test/Sema/arm-mfp8.cpp | 13 clang/utils/TableGen/SveEmitter.cpp | 33 --- 8 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 clang/test/CodeGen/arm-mfp8.c create mode 100644 clang/test/Sema/arm-mfp8.cpp diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 55ed9c36f6c5cd..b72327af61844a 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -69,6 +69,11 @@ #ifndef SVE_VECTOR_TYPE_BFLOAT #define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, true, false, true) +#endif + +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif @@ -114,6 +119,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat32_t", "__SVFloat32_t", SveFloat32, SveFloat32Ty SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty, 2, 64, 1) SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -183,6 +189,7 @@ SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy) #undef SVE_VECTOR_TYPE #undef SVE_VECTOR_TYPE_BFLOAT +#undef SVE_VECTOR_TYPE_MFLOAT #undef SVE_VECTOR_TYPE_FLOAT #undef SVE_VECTOR_TYPE_INT #undef SVE_PREDICATE_TYPE diff --git a/clang/include/clang/Basic/arm_sve_sme_incl.td b/clang/include/clang/Basic/arm_sve_sme_incl.td index fdf4ba55fe9382..50911fb63e818e 100644 --- a/clang/include/clang/Basic/arm_sve_sme_incl.td +++ b/clang/include/clang/Basic/arm_sve_sme_incl.td @@ -162,6 +162,7 @@ def EltTyBool16 : EltType<10>; def EltTyBool32 : EltType<11>; def EltTyBool64 : EltType<12>; def EltTyBFloat16 : EltType<13>; +def EltTyMFloat8 : EltType<14>; class MemEltType { int Value = val; diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 5be33ae0ed1b98..d468d49e1e632f 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1145,7 +1145,7 @@ enum PredefinedTypeIDs { /// /// Type IDs for non-predefined types will start at /// NUM_PREDEF_TYPE_IDs. -const unsigned NUM_PREDEF_TYPE_IDS = 505; +const unsigned NUM_PREDEF_TYPE_IDS = 506; // Ensure we do not overrun the predefined types we reserved // in the enum PredefinedTypeIDs above. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index fd8aa8de79b49f..7c11fec02a3f60 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4304,7 +4304,6 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const { switch (Ty->getKind()) { default: llvm_unreachable("Unsupported builtin vector type"); - #define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \ ElBits, NF, IsSigned) \ case BuiltinType::Id: \ @@ -4319,12 +4318,16 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const { ElBits, NF) \ case BuiltinType::Id: \ return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF}; +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \ + ElBits, NF) \ + case BuiltinType::Id: \ +return {getIntTypeForBitwidth(ElBits, false), \ +llvm::ElementCount::getScalable(NumEls), NF}; #define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \ cas
[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
@@ -3223,6 +3225,49 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl, << ParamName << (FDecl != nullptr) << FDecl; } +void Sema::checkLifetimeCaptureBy(FunctionDecl *FD, bool IsMemberFunction, + const Expr *ThisArg, + ArrayRef Args) { + auto GetArgAt = [&](int Idx) { +if (IsMemberFunction && Idx == 0) + return const_cast(ThisArg); +return const_cast(Args[Idx - int(IsMemberFunction)]); + }; + for (unsigned I = 0; I < FD->getNumParams(); ++I) { +auto *CapturedByAttr = +FD->getParamDecl(I)->getAttr(); +if (!CapturedByAttr) + continue; +for (int CapturingParamIdx : CapturedByAttr->params()) { + Expr *Capturing = GetArgAt(CapturingParamIdx); + Expr *Captured = GetArgAt(I + IsMemberFunction); + CapturingEntity CE{Capturing}; bricknerb wrote: Consider making this initialization clearer by writing .Expression = Capturing https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG]Add Scalable vectors for mfloat8_t (PR #101644)
https://github.com/CarolineConcatto closed https://github.com/llvm/llvm-project/pull/101644 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cb43021 - [CLANG]Add Scalable vectors for mfloat8_t (#101644)
Author: CarolineConcatto Date: 2024-10-17T09:22:55+01:00 New Revision: cb43021e5726a4462f28a999fb66a8dc20dc354b URL: https://github.com/llvm/llvm-project/commit/cb43021e5726a4462f28a999fb66a8dc20dc354b DIFF: https://github.com/llvm/llvm-project/commit/cb43021e5726a4462f28a999fb66a8dc20dc354b.diff LOG: [CLANG]Add Scalable vectors for mfloat8_t (#101644) This patch adds these new vector sizes for sve: svmfloat8_t According to the ARM ACLE PR#323[1]. [1] ARM-software/acle#323 Added: clang/test/Sema/arm-mfp8.cpp Modified: clang/include/clang/Basic/AArch64SVEACLETypes.def clang/include/clang/Basic/arm_sve_sme_incl.td clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/Type.cpp clang/test/AST/ast-dump-aarch64-sve-types.c clang/test/CodeGen/aarch64-sve.c clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp clang/test/CodeGenCXX/aarch64-sve-typeinfo.cpp clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp clang/test/CodeGenObjC/aarch64-sve-types.m clang/test/Modules/no-external-type-id.cppm clang/test/Sema/aarch64-sve-types.c clang/test/SemaObjC/aarch64-sve-types.m clang/utils/TableGen/SveEmitter.cpp Removed: diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 55ed9c36f6c5cd..72df1e35aaec20 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -115,6 +115,9 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) +// This is a 8 bits opaque type. +SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) + // // x2 // diff --git a/clang/include/clang/Basic/arm_sve_sme_incl.td b/clang/include/clang/Basic/arm_sve_sme_incl.td index fdf4ba55fe9382..50911fb63e818e 100644 --- a/clang/include/clang/Basic/arm_sve_sme_incl.td +++ b/clang/include/clang/Basic/arm_sve_sme_incl.td @@ -162,6 +162,7 @@ def EltTyBool16 : EltType<10>; def EltTyBool32 : EltType<11>; def EltTyBool64 : EltType<12>; def EltTyBFloat16 : EltType<13>; +def EltTyMFloat8 : EltType<14>; class MemEltType { int Value = val; diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 4b79d4b7711905..d735e2dcaa8c56 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1149,7 +1149,7 @@ enum PredefinedTypeIDs { /// /// Type IDs for non-predefined types will start at /// NUM_PREDEF_TYPE_IDs. -const unsigned NUM_PREDEF_TYPE_IDS = 505; +const unsigned NUM_PREDEF_TYPE_IDS = 506; // Ensure we do not overrun the predefined types we reserved // in the enum PredefinedTypeIDs above. diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index f013ed11d12935..6f23a1a13d0518 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2525,6 +2525,7 @@ bool Type::isSveVLSBuiltinType() const { case BuiltinType::SveBool: case BuiltinType::SveBoolx2: case BuiltinType::SveBoolx4: +case BuiltinType::SveMFloat8: return true; default: return false; diff --git a/clang/test/AST/ast-dump-aarch64-sve-types.c b/clang/test/AST/ast-dump-aarch64-sve-types.c index b5a0b00b492803..386133e05b1d13 100644 --- a/clang/test/AST/ast-dump-aarch64-sve-types.c +++ b/clang/test/AST/ast-dump-aarch64-sve-types.c @@ -45,6 +45,9 @@ // CHECK: TypedefDecl {{.*}} implicit __SVBfloat16_t '__SVBfloat16_t' // CHECK-NEXT: -BuiltinType {{.*}} '__SVBfloat16_t' +// CHECK: TypedefDecl {{.*}} implicit __SVMfloat8_t '__SVMfloat8_t' +// CHECK-NEXT: -BuiltinType {{.*}} '__SVMfloat8_t' + // CHECK: TypedefDecl {{.*}} implicit __SVBool_t '__SVBool_t' // CHECK-NEXT: -BuiltinType {{.*}} '__SVBool_t' diff --git a/clang/test/CodeGen/aarch64-sve.c b/clang/test/CodeGen/aarch64-sve.c index 5f6a0178aa4425..690b010e967ad7 100644 --- a/clang/test/CodeGen/aarch64-sve.c +++ b/clang/test/CodeGen/aarch64-sve.c @@ -13,6 +13,7 @@ // CHECK: %f16 = alloca , align 16 // CHECK: %f32 = alloca , align 16 // CHECK: %f64 = alloca , align 16 +// CHECK: %mf8 = alloca , align 16 // CHECK: %bf16 = alloca , align 16 // CHECK: %b8 = alloca , align 2 @@ -33,6 +34,7 @@ void test_locals(void) { __SVFloat32_t f32; __SVFloat64_t f64; + __SVMfloat8_t mf8; __SVBfloat16_t bf16; __SVBool_t b8; diff --git a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp index dfe31ff2ce25fb..3f2b0622d55162 100644 --- a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp +++ b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp @@ -17,6 +17,7 @@ void f(__SVFloat16_t, __SVFloat16_t); void f(__SVFloat
[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
@@ -18,29 +18,42 @@ namespace clang::sema { -/// Describes an entity that is being assigned. -struct AssignedEntity { - // The left-hand side expression of the assignment. - Expr *LHS = nullptr; +struct CapturingEntity { + // The expression of the entity which captures another entity. + // For example: + // 1. In an assignment, this would be the left-hand side expression. + //std::string_view sv; + //sv = std::string(); // Here 'sv' is the 'Entity'. + // + // 2. In an function call involving a lifetime capture, this would be the + // argument capturing the lifetime of another argument. + //void addToSet(std::string_view s [[clang::lifetime_capture_by(sv)]], bricknerb wrote: Is sv here referring to sv in (1) or a typo? https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][MC][AArch64] Assembler support for Armv9.6-A memory systems extensions (PR #112341)
@@ -4020,6 +4079,33 @@ defm STNPD : StorePairNoAlloc<0b01, 1, FPR64Op, simm7s8, "stnp">; defm STNPQ : StorePairNoAlloc<0b10, 1, FPR128Op, simm7s16, "stnp">; } +// Armv9.6-a Load/store no-allocate pair (FEAT_LSUI) +let Predicates = [HasLSUI] in { + defm LDTP: LoadPairOffset<0b11, 0, GPR64z, simm7s8, "ldtp">; + def LDTPpre : LoadPairPreIdx<0b11, 0, GPR64z, simm7s8, "ldtp">; + def LDTPpost : LoadPairPostIdx<0b11, 0, GPR64z, simm7s8, "ldtp">; + + defm STTNPX : StorePairNoAllocLSUI<0b11, 0, GPR64z, simm7s8, "sttnp">; + defm LDTNPX : LoadPairNoAllocLSUI<0b11, 0, GPR64z, simm7s8, "ldtnp">; + + defm STTP: StorePairOffset<0b11, 0, GPR64z, simm7s8, "sttp">; + def STTPpre : StorePairPreIdx<0b11, 0, GPR64z, simm7s8, "sttp">; + def STTPpost : StorePairPostIdx<0b11, 0, GPR64z, simm7s8, "sttp">; +} + +let Predicates = [HasLSUI, HasFPARMv8] in { nasherm wrote: That's a mistake on my part. Thanks for spotting https://github.com/llvm/llvm-project/pull/112341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)
@@ -105,7 +105,7 @@ bool isRootStmt(const Node *N) { if (N->Selected == SelectionTree::Partial) return false; // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire - // selection range in selectionTree. Additionally, an CXXOperatorCallExpr of a + // selection range in selectionTree. Additionally, a CXXOperatorCallExpr of a // binary operation can be unselected because it's children claim the entire ckandeler wrote: "it's" should also be changed to "its" https://github.com/llvm/llvm-project/pull/81640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reject if constexpr in C (PR #112685)
https://github.com/Fznamznon created https://github.com/llvm/llvm-project/pull/112685 Fixes https://github.com/llvm/llvm-project/issues/112587 >From 6fda18661ef51185a7d24dbfb66684f55dd20f26 Mon Sep 17 00:00:00 2001 From: "Podchishchaeva, Mariya" Date: Thu, 17 Oct 2024 02:55:04 -0700 Subject: [PATCH] [clang] Reject if constexpr in C Fixes https://github.com/llvm/llvm-project/issues/112587 --- clang/lib/Parse/ParseStmt.cpp | 11 +++ clang/test/Sema/constexpr.c | 7 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 6480e88316a7d5..60d647da48f053 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1518,10 +1518,13 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) { SourceLocation ConstevalLoc; if (Tok.is(tok::kw_constexpr)) { -Diag(Tok, getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_constexpr_if -: diag::ext_constexpr_if); -IsConstexpr = true; -ConsumeToken(); +// C23 supports constexpr keyword, but only for object definitions. +if (getLangOpts().CPlusPlus) { + Diag(Tok, getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_constexpr_if + : diag::ext_constexpr_if); + IsConstexpr = true; + ConsumeToken(); +} } else { if (Tok.is(tok::exclaim)) { NotLocation = ConsumeToken(); diff --git a/clang/test/Sema/constexpr.c b/clang/test/Sema/constexpr.c index 0cf9491c4a42bf..eaa000b3b97758 100644 --- a/clang/test/Sema/constexpr.c +++ b/clang/test/Sema/constexpr.c @@ -367,3 +367,10 @@ struct S10 { constexpr struct S10 c = { 255 }; // FIXME-expected-error@-1 {{constexpr initializer evaluates to 255 which is not exactly representable in 'long long' bit-field with width 8}} // See: GH#101299 + +void constexprif() { + if constexpr (300) {} //expected-error {{expected '(' after 'if'}} +} +void constevalif() { + if consteval (300) {} //expected-error {{expected '(' after 'if'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reject if constexpr in C (PR #112685)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Mariya Podchishchaeva (Fznamznon) Changes Fixes https://github.com/llvm/llvm-project/issues/112587 --- Full diff: https://github.com/llvm/llvm-project/pull/112685.diff 2 Files Affected: - (modified) clang/lib/Parse/ParseStmt.cpp (+7-4) - (modified) clang/test/Sema/constexpr.c (+7) ``diff diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 6480e88316a7d5..60d647da48f053 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1518,10 +1518,13 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) { SourceLocation ConstevalLoc; if (Tok.is(tok::kw_constexpr)) { -Diag(Tok, getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_constexpr_if -: diag::ext_constexpr_if); -IsConstexpr = true; -ConsumeToken(); +// C23 supports constexpr keyword, but only for object definitions. +if (getLangOpts().CPlusPlus) { + Diag(Tok, getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_constexpr_if + : diag::ext_constexpr_if); + IsConstexpr = true; + ConsumeToken(); +} } else { if (Tok.is(tok::exclaim)) { NotLocation = ConsumeToken(); diff --git a/clang/test/Sema/constexpr.c b/clang/test/Sema/constexpr.c index 0cf9491c4a42bf..eaa000b3b97758 100644 --- a/clang/test/Sema/constexpr.c +++ b/clang/test/Sema/constexpr.c @@ -367,3 +367,10 @@ struct S10 { constexpr struct S10 c = { 255 }; // FIXME-expected-error@-1 {{constexpr initializer evaluates to 255 which is not exactly representable in 'long long' bit-field with width 8}} // See: GH#101299 + +void constexprif() { + if constexpr (300) {} //expected-error {{expected '(' after 'if'}} +} +void constevalif() { + if consteval (300) {} //expected-error {{expected '(' after 'if'}} +} `` https://github.com/llvm/llvm-project/pull/112685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make -fveclib={ArmPL, SLEEF} imply -fno-math-errno (PR #112580)
@@ -36,16 +36,23 @@ /* Verify that the correct vector library is passed to LTO flags. */ // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=LIBMVEC -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBMVEC %s +// CHECK-LTO-LIBMVEC: "-fmath-errno" // CHECK-LTO-LIBMVEC: "-plugin-opt=-vector-library=LIBMVEC-X86" // RUN: %clang -### --target=powerpc64-unknown-linux-gnu -fveclib=MASSV -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-MASSV %s +// CHECK-LTO-MASSV: "-fmath-errno" // CHECK-LTO-MASSV: "-plugin-opt=-vector-library=MASSV" // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=SVML -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-SVML %s +// CHECK-LTO-SVML: "-fmath-errno" // CHECK-LTO-SVML: "-plugin-opt=-vector-library=SVML" // RUN: %clang -### --target=aarch64-linux-gnu -fveclib=SLEEF -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-SLEEF %s +// CHECK-LTO-SLEEF-NOT: "-fmath-errno" // CHECK-LTO-SLEEF: "-plugin-opt=-vector-library=sleefgnuabi" +// CHECK-LTO-SLEEF-NOT: "-fmath-errno" // RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-ARMPL %s +// CHECK-LTO-ARMPL-NOT: "-fmath-errno" paulwalker-arm wrote: I agree but I think it should be stronger and we should emit a warning diagnostic that says the potential to use the specified vector library will be hampered because -fmath-errnor has been requested. I'm suggesting a warning rather than remark because we're basically saying the user has likely made a mistake because it doesn't make sense to request both features. https://github.com/llvm/llvm-project/pull/112580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make -fveclib={ArmPL, SLEEF} imply -fno-math-errno (PR #112580)
@@ -3125,6 +3129,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, TrappingMathPresent = true; FPExceptionBehavior = "strict"; break; +case options::OPT_fveclib: + if (llvm::is_contained(VecLibImpliesNoMathErrno, A->getValue())) +MathErrno = false; + break; paulwalker-arm wrote: As @mgabka says, this is a property of the library rather than an architecture specific decision. https://github.com/llvm/llvm-project/pull/112580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Introduce new armv9.6 features (PR #111677)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-s390x-linux` running on `systemz-1` while building `clang,llvm` at step 6 "test-openmp". Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/3579 Here is the relevant piece of the build log for the reference ``` Step 6 (test-openmp) failure: test (failure) TEST 'libomp :: tasking/issue-94260-2.c' FAILED Exit Code: -11 Command Output (stdout): -- # RUN: at line 1 /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic && /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp # executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic # executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp # note: command had no output on stdout or stderr # error: command failed with exit status: -11 -- ``` https://github.com/llvm/llvm-project/pull/111677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MIPS] LLVM data layout give i128 an alignment of 16 for mips64 (PR #112084)
nikic wrote: > @nikic I checked several other arch-32 situations with ForceEnableInt128, and > they all use `alloca i128, align 16`. But they did not modify the target > datalayout content with `i128:128`, should mips be consistent? I think either way is fine here. Something to consider though, is that the AutoUpgrade for the DataLayout has to match. So if you don't add `i128:128` to the o32 DL, then it shouldn't get added by AutoUpgrade either. https://github.com/llvm/llvm-project/pull/112084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] constexpr built-in abs function. (PR #112539)
@@ -265,6 +265,15 @@ namespace fpclassify { char classify_subnorm [__builtin_fpclassify(-1, -1, -1, +1, -1, 1.0e-38f)]; } +namespace abs { +static_assert(__builtin_abs(14) == 14, ""); +static_assert(__builtin_labs(14L) == 14L, ""); +static_assert(__builtin_llabs(14LL) == 14LL, ""); +static_assert(__builtin_abs(-14) == 14, ""); +static_assert(__builtin_labs(-0x14L) == 0x14L, ""); +static_assert(__builtin_llabs(-0x141414141414LL) == 0x141414141414LL, ""); tbaederr wrote: ```suggestion static_assert(__builtin_abs(14) == 14, ""); static_assert(__builtin_labs(14L) == 14L, ""); static_assert(__builtin_llabs(14LL) == 14LL, ""); static_assert(__builtin_abs(-14) == 14, ""); static_assert(__builtin_labs(-0x14L) == 0x14L, ""); static_assert(__builtin_llabs(-0x141414141414LL) == 0x141414141414LL, ""); ``` https://github.com/llvm/llvm-project/pull/112539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] constexpr built-in abs function. (PR #112539)
@@ -563,6 +563,19 @@ static bool interp__builtin_fabs(InterpState &S, CodePtr OpPC, return true; } +static bool interp__builtin_abs(InterpState &S, CodePtr OpPC, +const InterpFrame *Frame, const Function *Func, +const CallExpr *Call) { + PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType()); + APSInt Val = peekToAPSInt(S.Stk, ArgT); + if (Val == APSInt(APSInt::getSignedMinValue(Val.getBitWidth()), false)) tbaederr wrote: ```suggestion if (Val == APSInt(APInt::getSignedMinValue(Val.getBitWidth()), /*IsUnsigned=*/false)) ``` Same with the other implementation https://github.com/llvm/llvm-project/pull/112539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-include-cleaner] Fix incorrect directory issue for writing files (PR #111375)
bc-lee wrote: I will fix the following error within an hour (currently away from keyboard). ``` FAILED: tools/clang/tools/extra/include-cleaner/tool/CMakeFiles/clang-include-cleaner.dir/IncludeCleaner.cpp.o ccache /home/docker/llvm-external-buildbots/clang.17.0.6/bin/clang++ --gcc-toolchain=/gcc-toolchain/usr -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/tools/extra/include-cleaner/tool -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/include-cleaner/tool -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/include-cleaner/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/include-cleaner/tool/../lib -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/tools/extra/include-cleaner/tool/CMakeFiles/clang-include-cleaner.dir/IncludeCleaner.cpp.o -MF tools/clang/tools/extra/include-cleaner/tool/CMakeFiles/clang-include-cleaner.dir/IncludeCleaner.cpp.o.d -o tools/clang/tools/extra/include-cleaner/tool/CMakeFiles/clang-include-cleaner.dir/IncludeCleaner.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:302:14: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] 302 | return std::move(llvm::errorCodeToError(Err)); | ^ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:302:14: note: remove std::move call here 302 | return std::move(llvm::errorCodeToError(Err)); | ^~ ~ 1 error generated. ``` https://github.com/llvm/llvm-project/pull/111375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][Clang][NEON] Remove undefined vcmla intrinsics (PR #112575)
https://github.com/momchil-velikov approved this pull request. LGTM, cheers! https://github.com/llvm/llvm-project/pull/112575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make -fveclib={ArmPL, SLEEF} imply -fno-math-errno (PR #112580)
MacDue wrote: > > Have you checked the flang driver? Is it not applicable there since errno > > is not used in Flang? > > We don't support the gfortran extension for checking errno in flang and I > can't see another way of checking it portably, so I wonder if we should just > have this flag on by default in flang in general? It shouldn't provide any > observable change and might increase performance as far as I can tell. As far as I can tell from looking at the `flang` driver, it already defaults to the equivalent of `-fno-math-errno` (looks like there's no way to set `-fmath-errno` at all). That's corroborated by looking at the LLVM IR for a call to `sin` which uses the non-errno setting LLVM intrinsic by default: https://godbolt.org/z/dvTvP3vPr. https://github.com/llvm/llvm-project/pull/112580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Deduplicate the logic that only warns once when stack is almost full (PR #112552)
bricknerb wrote: This pull request is a replacement for https://github.com/llvm/llvm-project/pull/112371. https://github.com/llvm/llvm-project/pull/112552 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add IRNormalizer Pass (PR #68176)
plotfi wrote: LGTM, I would prefer if we landed this and added improvements as needed 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] [clang-include-cleaner] Fix incorrect directory issue for writing files (PR #111375)
bc-lee wrote: I don't have commit access to LLVM. Please merge this PR. Thanks! https://github.com/llvm/llvm-project/pull/111375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)
@@ -1091,21 +1104,22 @@ static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) { } static bool shouldRunGSLAssignmentAnalysis(const Sema &SemaRef, - const AssignedEntity &Entity) { + const CapturingEntity &Entity) { bool EnableGSLAssignmentWarnings = !SemaRef.getDiagnostics().isIgnored( diag::warn_dangling_lifetime_pointer_assignment, SourceLocation()); return (EnableGSLAssignmentWarnings && - (isRecordWithAttr(Entity.LHS->getType()) || + (isRecordWithAttr(Entity.Expression->getType()) || isAssignmentOperatorLifetimeBound(Entity.AssignmentOperator))); } static void checkExprLifetimeImpl(Sema &SemaRef, bricknerb wrote: IIUC, this function handles different use cases and for different use cases it needs different args to be set. Since it's becoming more complex with this change, would it make sense to split it to different functions and only reuse the shared logic between the different use cases? I think this could simplify the asserts and make the calling this method much clearer and safer. https://github.com/llvm/llvm-project/pull/111499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-include-cleaner] Fix -Wpessimizing-move warning introduced in 4cda28c1ada702a08f6960eb4c93919187c1d4d1 (PR #112684)
bc-lee wrote: Original PR: https://github.com/llvm/llvm-project/pull/111375 https://github.com/llvm/llvm-project/pull/112684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-include-cleaner] Fix -Wpessimizing-move warning introduced in 4cda28c1ada702a08f6960eb4c93919187c1d4d1 (PR #112684)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: Byoungchan Lee (bc-lee) Changes Failing log: https://lab.llvm.org/buildbot/#/builders/145/builds/2540 --- Full diff: https://github.com/llvm/llvm-project/pull/112684.diff 1 Files Affected: - (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (+1-1) ``diff diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 6bd9c40c70753c..f85dbc0e0c31f2 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -299,7 +299,7 @@ mapInputsToAbsPaths(clang::tooling::CompilationDatabase &CDB, if (auto Err = VFS->makeAbsolute(AbsPath)) { llvm::errs() << "Failed to get absolute path for " << Source << " : " << Err.message() << '\n'; - return std::move(llvm::errorCodeToError(Err)); + return llvm::errorCodeToError(Err); } std::vector Cmds = CDB.getCompileCommands(AbsPath); `` https://github.com/llvm/llvm-project/pull/112684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b584478 - [AArch64] Introduce new armv9.6 features (#111677)
Author: Lukacma Date: 2024-10-17T10:43:17+01:00 New Revision: b584478e0068fd627b7f5e9f63574caab78cc56e URL: https://github.com/llvm/llvm-project/commit/b584478e0068fd627b7f5e9f63574caab78cc56e DIFF: https://github.com/llvm/llvm-project/commit/b584478e0068fd627b7f5e9f63574caab78cc56e.diff LOG: [AArch64] Introduce new armv9.6 features (#111677) This patch implements new features introduced in 2024 release of ARM ISA and creates predicates, which will be used by new instructions. Co-authored-by: Caroline Concatto caroline.conca...@arm.com Co-authored-by: Spencer Abson spencer.ab...@arm.com Added: Modified: clang/test/Driver/aarch64-v96a.c clang/test/Driver/print-supported-extensions-aarch64.c llvm/lib/Target/AArch64/AArch64Features.td llvm/lib/Target/AArch64/AArch64InstrInfo.td llvm/unittests/TargetParser/TargetParserTest.cpp Removed: diff --git a/clang/test/Driver/aarch64-v96a.c b/clang/test/Driver/aarch64-v96a.c index 0aaadddb2842f8..80c99be934334e 100644 --- a/clang/test/Driver/aarch64-v96a.c +++ b/clang/test/Driver/aarch64-v96a.c @@ -6,7 +6,7 @@ // RUN: %clang -target aarch64 -mlittle-endian -march=armv9.6-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A %s // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.6a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A %s // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.6-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A %s -// GENERICV96A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a" +// GENERICV96A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a"{{.*}} "-target-feature" "+cmpbr"{{.*}} "-target-feature" "+fprcvt"{{.*}} "-target-feature" "+sve2p2" // RUN: %clang -target aarch64_be -march=armv9.6a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A-BE %s // RUN: %clang -target aarch64_be -march=armv9.6-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A-BE %s @@ -14,6 +14,42 @@ // RUN: %clang -target aarch64 -mbig-endian -march=armv9.6-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A-BE %s // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.6a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A-BE %s // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.6-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV96A-BE %s -// GENERICV96A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a" -// +// GENERICV96A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a"{{.*}} "-target-feature" "+cmpbr"{{.*}} "-target-feature" "+fprcvt"{{.*}} "-target-feature" "+sve2p2" + // = Features supported on aarch64 = + +// RUN: %clang -target aarch64 -march=armv9.6a+f8f16mm -### -c %s 2>&1 | FileCheck -check-prefix=V96A-F8F16MM %s +// RUN: %clang -target aarch64 -march=armv9.6-a+f8f16mm -### -c %s 2>&1 | FileCheck -check-prefix=V96A-F8F16MM %s +// V96A-F8F16MM: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a"{{.*}} "-target-feature" "+f8f16mm" + +// RUN: %clang -target aarch64 -march=armv9.6a+f8f32mm -### -c %s 2>&1 | FileCheck -check-prefix=V96A-F8F32MM %s +// RUN: %clang -target aarch64 -march=armv9.6-a+f8f32mm -### -c %s 2>&1 | FileCheck -check-prefix=V96A-F8F32MM %s +// V96A-F8F32MM: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a"{{.*}} "-target-feature" "+f8f32mm" + +// RUN: %clang -target aarch64 -march=armv9.6a+lsfe -### -c %s 2>&1 | FileCheck -check-prefix=V96A-LSFE %s +// RUN: %clang -target aarch64 -march=armv9.6-a+lsfe -### -c %s 2>&1 | FileCheck -check-prefix=V96A-LSFE %s +// V96A-LSFE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a"{{.*}} "-target-feature" "+lsfe" + +// RUN: %clang -target aarch64 -march=armv9.6a+sme2p2 -### -c %s 2>&1 | FileCheck -check-prefix=V96A-SME2p2 %s +// RUN: %clang -target aarch64 -march=armv9.6-a+sme2p2 -### -c %s 2>&1 | FileCheck -check-prefix=V96A-SME2p2 %s +// V96A-SME2p2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a"{{.*}} "-target-feature" "+sme2p2" + +// RUN: %clang -target aarch64 -march=armv9.6a+ssve-aes -### -c %s 2>&1 | FileCheck -check-prefix=V96A-SSVE-AES %s +// RUN: %clang -target aarch64 -march=armv9.6-a+ssve-aes -### -c %s 2>&1 | FileCheck -check-prefix=V96A-SSVE-AES %s +// V96A-SSVE-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.6a"{{.*}} "-target-feature" "+ssve-aes" + +// RUN: %clang -target aarch64 -march=armv9.6a+sve2p2 -### -c %s 2>&1 | FileCheck -check-prefix=V96A-SVE2p2 %s +// RUN: %clang -target aarch64 -march=armv9.6-a+sve2p2 -### -c %s 2>&1 | FileCheck -check-prefix=V96A-SVE2p2 %s +// V96A-SVE2p2:
[clang] [llvm] [AArch64] Introduce new armv9.6 features (PR #111677)
https://github.com/Lukacma closed https://github.com/llvm/llvm-project/pull/111677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PAC] Fix address discrimination for type info vtable pointers (PR #102199)
@@ -4207,16 +4214,31 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo( break; } - llvm::Constant *Init = llvm::ConstantStruct::getAnon(Fields); - SmallString<256> Name; llvm::raw_svector_ostream Out(Name); CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty, Out); llvm::Module &M = CGM.getModule(); llvm::GlobalVariable *OldGV = M.getNamedGlobal(Name); - llvm::GlobalVariable *GV = - new llvm::GlobalVariable(M, Init->getType(), - /*isConstant=*/true, Linkage, Init, Name); + llvm::GlobalVariable *GV = new llvm::GlobalVariable( + M, llvm::ConstantStruct::getTypeForElements(Fields), kovdan01 wrote: @efriedma-quic Thanks for suggestion! Followed this way in b08172fa576e5bb7849aa13d503180cfef5bcd0b. This actually changes order of globals definitions in output IR and requires changing related tests correspondingly (see c9d26dd6dd7648c25e44e576891e838a418eacae), but, as far as I understand, this should not cause any problems. https://github.com/llvm/llvm-project/pull/102199 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1251687 - [clang][bytecode][NFC] Remove a leftover dump call
Author: Timm Bäder Date: 2024-10-17T12:40:14+02:00 New Revision: 125168744810f4aba039208afd9ffe1d11b1 URL: https://github.com/llvm/llvm-project/commit/125168744810f4aba039208afd9ffe1d11b1 DIFF: https://github.com/llvm/llvm-project/commit/125168744810f4aba039208afd9ffe1d11b1.diff LOG: [clang][bytecode][NFC] Remove a leftover dump call Added: Modified: clang/lib/AST/ByteCode/Interp.cpp Removed: diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 40137de19c4e1b..fdc4b38b8aa6dc 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1040,7 +1040,6 @@ bool Free(InterpState &S, CodePtr OpPC, bool DeleteIsArrayForm, return nullptr; }; - AllocType->dump(); if (const FunctionDecl *VirtualDelete = getVirtualOperatorDelete(AllocType); VirtualDelete && ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [FMV][AArch64] Unify features memtag and memtag2. (PR #112511)
labrinea wrote: > I don't understand this distinction: why is FMV seen as user-space only? I had to clarify this with @Wilco1 and @DanielKristofKiss. My understanding is that FMV implementations which rely on ifuncs (Linux) only work in address spaces where a dynamic linker can be used. This limitation rules out OS and baremetal environments. However, there are FMV implementations which emulate ifuncs via function pointers (Windows), but the specification must be possible to implement on all platforms, and therefore it is bound by the ifunc limitation. https://github.com/llvm/llvm-project/pull/112511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add basic support for C++/CLI (#27126) (PR #112689)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Calum Robinson (calumr) Changes * This only looks for ^ as a pointer/reference token, which is the main issue when trying to format C++/CLI. Obviously there's more to C++/CLI than this minor change, but it's extremely useful to be able to clang-format our whole codebase now without a ^ mangling the output. --- Full diff: https://github.com/llvm/llvm-project/pull/112689.diff 7 Files Affected: - (modified) clang/include/clang/Basic/LangOptions.def (+1) - (modified) clang/lib/Format/Format.cpp (+1) - (modified) clang/lib/Format/FormatToken.h (+3-1) - (modified) clang/lib/Format/QualifierAlignmentFixer.cpp (+1-1) - (modified) clang/lib/Format/TokenAnnotator.cpp (+18-16) - (modified) clang/lib/Format/WhitespaceManager.cpp (+13-11) - (modified) clang/lib/Format/WhitespaceManager.h (+3-1) ``diff diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 68db400c22e6c1..1285ce06d845f3 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -101,6 +101,7 @@ LANGOPT(CPlusPlus17 , 1, 0, "C++17") LANGOPT(CPlusPlus20 , 1, 0, "C++20") LANGOPT(CPlusPlus23 , 1, 0, "C++23") LANGOPT(CPlusPlus26 , 1, 0, "C++26") +LANGOPT(CPlusPlusCLI , 1, 0, "C++/CLI") LANGOPT(ObjC , 1, 0, "Objective-C") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, "Objective-C auto-synthesized properties") diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 148270795c562f..4344b5b2ad4c26 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -3914,6 +3914,7 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) { LangOpts.Bool = 1; LangOpts.ObjC = 1; LangOpts.MicrosoftExt = 1;// To get kw___try, kw___finally. + LangOpts.CPlusPlusCLI = 1; LangOpts.DeclSpecKeyword = 1; // To get __declspec. LangOpts.C99 = 1; // To get kw_restrict for non-underscore-prefixed restrict. return LangOpts; diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 7d342a7dcca01d..cdf613774fa6bc 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -731,7 +731,9 @@ struct FormatToken { TT_LambdaArrow, TT_LeadingJavaAnnotation); } - bool isPointerOrReference() const { + bool isPointerOrReference(const LangOptions &LangOpts) const { +if (LangOpts.CPlusPlusCLI && is(tok::caret)) + return true; return isOneOf(tok::star, tok::amp, tok::ampamp); } diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp index 593f8efff25aa9..f07c8913b907ac 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.cpp +++ b/clang/lib/Format/QualifierAlignmentFixer.cpp @@ -385,7 +385,7 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft( // For left qualifiers preceeded by nothing, a template declaration, or *,&,&& // we only perform sorting. - if (!TypeToken || TypeToken->isPointerOrReference() || + if (!TypeToken || TypeToken->isPointerOrReference(LangOpts) || TypeToken->ClosesRequiresClause || TypeToken->ClosesTemplateDeclaration) { // Don't sort past a non-configured qualifier token. diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index fcefaa7bb298ea..5a33c1c00c8b24 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -468,8 +468,8 @@ class AnnotatingParser { // void (&&FunctionReference)(void); // void (^ObjCBlock)(void); bool MightBeFunctionType = !Contexts[Contexts.size() - 2].IsExpression; -bool ProbablyFunctionType = -CurrentToken->isPointerOrReference() || CurrentToken->is(tok::caret); +bool ProbablyFunctionType = CurrentToken->isPointerOrReference(LangOpts) || +CurrentToken->is(tok::caret); bool HasMultipleLines = false; bool HasMultipleParametersOnALine = false; bool MightBeObjCForRangeLoop = @@ -507,7 +507,8 @@ class AnnotatingParser { // auto my_lambda = MACRO((Type *type, int i) { .. body .. }); for (FormatToken *Tok = &OpeningParen; Tok != CurrentToken; Tok = Tok->Next) { -if (Tok->is(TT_BinaryOperator) && Tok->isPointerOrReference()) +if (Tok->is(TT_BinaryOperator) && +Tok->isPointerOrReference(LangOpts)) Tok->setType(TT_PointerOrReference); } } @@ -578,7 +579,7 @@ class AnnotatingParser { Tok != CurrentToken && !Tok->isOneOf(tok::equal, tok::l_paren, tok::l_brace); Tok = Tok->Next) { - if (Tok->isPointerOrReference()) + if (Tok->isPointerOrReference(LangOpts)) Tok->setFinalizedType(TT_PointerOrReference); } } @@ -1411
[clang] [clang-format] Add basic support for C++/CLI (#27126) (PR #112689)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Calum Robinson (calumr) Changes * This only looks for ^ as a pointer/reference token, which is the main issue when trying to format C++/CLI. Obviously there's more to C++/CLI than this minor change, but it's extremely useful to be able to clang-format our whole codebase now without a ^ mangling the output. --- Full diff: https://github.com/llvm/llvm-project/pull/112689.diff 7 Files Affected: - (modified) clang/include/clang/Basic/LangOptions.def (+1) - (modified) clang/lib/Format/Format.cpp (+1) - (modified) clang/lib/Format/FormatToken.h (+3-1) - (modified) clang/lib/Format/QualifierAlignmentFixer.cpp (+1-1) - (modified) clang/lib/Format/TokenAnnotator.cpp (+18-16) - (modified) clang/lib/Format/WhitespaceManager.cpp (+13-11) - (modified) clang/lib/Format/WhitespaceManager.h (+3-1) ``diff diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 68db400c22e6c1..1285ce06d845f3 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -101,6 +101,7 @@ LANGOPT(CPlusPlus17 , 1, 0, "C++17") LANGOPT(CPlusPlus20 , 1, 0, "C++20") LANGOPT(CPlusPlus23 , 1, 0, "C++23") LANGOPT(CPlusPlus26 , 1, 0, "C++26") +LANGOPT(CPlusPlusCLI , 1, 0, "C++/CLI") LANGOPT(ObjC , 1, 0, "Objective-C") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, "Objective-C auto-synthesized properties") diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 148270795c562f..4344b5b2ad4c26 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -3914,6 +3914,7 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) { LangOpts.Bool = 1; LangOpts.ObjC = 1; LangOpts.MicrosoftExt = 1;// To get kw___try, kw___finally. + LangOpts.CPlusPlusCLI = 1; LangOpts.DeclSpecKeyword = 1; // To get __declspec. LangOpts.C99 = 1; // To get kw_restrict for non-underscore-prefixed restrict. return LangOpts; diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 7d342a7dcca01d..cdf613774fa6bc 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -731,7 +731,9 @@ struct FormatToken { TT_LambdaArrow, TT_LeadingJavaAnnotation); } - bool isPointerOrReference() const { + bool isPointerOrReference(const LangOptions &LangOpts) const { +if (LangOpts.CPlusPlusCLI && is(tok::caret)) + return true; return isOneOf(tok::star, tok::amp, tok::ampamp); } diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp index 593f8efff25aa9..f07c8913b907ac 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.cpp +++ b/clang/lib/Format/QualifierAlignmentFixer.cpp @@ -385,7 +385,7 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft( // For left qualifiers preceeded by nothing, a template declaration, or *,&,&& // we only perform sorting. - if (!TypeToken || TypeToken->isPointerOrReference() || + if (!TypeToken || TypeToken->isPointerOrReference(LangOpts) || TypeToken->ClosesRequiresClause || TypeToken->ClosesTemplateDeclaration) { // Don't sort past a non-configured qualifier token. diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index fcefaa7bb298ea..5a33c1c00c8b24 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -468,8 +468,8 @@ class AnnotatingParser { // void (&&FunctionReference)(void); // void (^ObjCBlock)(void); bool MightBeFunctionType = !Contexts[Contexts.size() - 2].IsExpression; -bool ProbablyFunctionType = -CurrentToken->isPointerOrReference() || CurrentToken->is(tok::caret); +bool ProbablyFunctionType = CurrentToken->isPointerOrReference(LangOpts) || +CurrentToken->is(tok::caret); bool HasMultipleLines = false; bool HasMultipleParametersOnALine = false; bool MightBeObjCForRangeLoop = @@ -507,7 +507,8 @@ class AnnotatingParser { // auto my_lambda = MACRO((Type *type, int i) { .. body .. }); for (FormatToken *Tok = &OpeningParen; Tok != CurrentToken; Tok = Tok->Next) { -if (Tok->is(TT_BinaryOperator) && Tok->isPointerOrReference()) +if (Tok->is(TT_BinaryOperator) && +Tok->isPointerOrReference(LangOpts)) Tok->setType(TT_PointerOrReference); } } @@ -578,7 +579,7 @@ class AnnotatingParser { Tok != CurrentToken && !Tok->isOneOf(tok::equal, tok::l_paren, tok::l_brace); Tok = Tok->Next) { - if (Tok->isPointerOrReference()) + if (Tok->isPointerOrReference(LangOpts)) Tok->setFinalizedType(TT_PointerOrReference); } } @@ -1411,7 +141
[clang-tools-extra] [clang-include-cleaner] Fix -Wpessimizing-move warning introduced in 4cda28c1ada702a08f6960eb4c93919187c1d4d1 (PR #112684)
mikaelholmen wrote: Already fixed in 2954d1f7bc8f ``` [include-cleaner] Fix -Wpessimizing-move in IncludeCleaner.cpp (NFC) /llvm-project/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:302:14: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] return std::move(llvm::errorCodeToError(Err)); ^ /llvm-project/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:302:14: note: remove std::move call here return std::move(llvm::errorCodeToError(Err)); ^~ ~ 1 error generated. ``` https://github.com/llvm/llvm-project/pull/112684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/112583 >From 4bf74c7f9caf89b67e6001b601f70741c1a672cc Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Wed, 16 Oct 2024 15:52:31 +0200 Subject: [PATCH 1/5] [analyzer][Solver] Improve getSymVal and friends Instead of just doing a lookup in the existing constraints, let's use `getRange()` for dissambling SymSymExprs and inferring from the constraint system what end range set we can simplify. This means that `getSymVal` gets more expensive while getting smarter. I don't expect it to be an issue as this API is only rarely used, and `getRange` is used a lot more often - yet without any observable hit on performance. This patch also removes dead declarations of EQClass overloads. --- .../Core/RangeConstraintManager.cpp | 11 + clang/test/Analysis/infeasible-sink.c | 23 +-- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 70d5a609681790..d1999c86f8ecd8 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -1939,11 +1939,8 @@ class RangeConstraintManager : public RangedConstraintManager { RangeSet::Factory F; RangeSet getRange(ProgramStateRef State, SymbolRef Sym); - RangeSet getRange(ProgramStateRef State, EquivalenceClass Class); ProgramStateRef setRange(ProgramStateRef State, SymbolRef Sym, RangeSet Range); - ProgramStateRef setRange(ProgramStateRef State, EquivalenceClass Class, - RangeSet Range); RangeSet getSymLTRange(ProgramStateRef St, SymbolRef Sym, const llvm::APSInt &Int, @@ -2866,12 +2863,14 @@ ConditionTruthVal RangeConstraintManager::checkNull(ProgramStateRef State, const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St, SymbolRef Sym) const { - const RangeSet *T = getConstraint(St, Sym); - return T ? T->getConcreteValue() : nullptr; + auto &MutableSelf = const_cast(*this); + return MutableSelf.getRange(St, Sym).getConcreteValue(); } const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St, SymbolRef Sym) const { + // TODO: Use `getRange()` like in `getSymVal()`, but that would make some + // of the reports of `BitwiseShiftChecker` look awkward. const RangeSet *T = getConstraint(St, Sym); if (!T || T->isEmpty()) return nullptr; @@ -2880,6 +2879,8 @@ const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St, const llvm::APSInt *RangeConstraintManager::getSymMaxVal(ProgramStateRef St, SymbolRef Sym) const { + // TODO: Use `getRange()` like in `getSymVal()`, but that would make some + // of the reports of `BitwiseShiftChecker` look awkward. const RangeSet *T = getConstraint(St, Sym); if (!T || T->isEmpty()) return nullptr; diff --git a/clang/test/Analysis/infeasible-sink.c b/clang/test/Analysis/infeasible-sink.c index 9cb66fcac0b6be..d5b4e82268f5b6 100644 --- a/clang/test/Analysis/infeasible-sink.c +++ b/clang/test/Analysis/infeasible-sink.c @@ -38,7 +38,7 @@ void test1(int x) { } int a, b, c, d, e; -void test2() { +void test2(void) { if (a == 0) return; @@ -50,28 +50,17 @@ void test2() { b = d; a -= d; + clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}} + if (a != 0) return; - clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} - - /* The BASELINE passes these checks ('wrning' is used to avoid lit to match) - // The parent state is already infeasible, look at this contradiction: - clang_analyzer_eval(b > 0); // expected-wrning{{FALSE}} - clang_analyzer_eval(b <= 0); // expected-wrning{{FALSE}} - // Crashes with expensive checks. - if (b > 0) { -clang_analyzer_warnIfReached(); // no-warning, OK -return; - } - // Should not be reachable. - clang_analyzer_warnIfReached(); // expected-wrning{{REACHABLE}} - */ + clang_analyzer_warnIfReached(); // no-warning: Even the parent state is unreachable. // The parent state is already infeasible, but we realize that only if b is // constrained. - clang_analyzer_eval(b > 0); // expected-warning{{UNKNOWN}} - clang_analyzer_eval(b <= 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(b > 0); // no-warning + clang_analyzer_eval(b <= 0); // no-warning if (b > 0) { clang_analyzer_warnIfReached(); // no-warning return; >From be65bb0694be3353fda260ab73777aea28de9113 Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Wed, 16 Oct 2024 15:53:20 +0200 Subject: [PATCH 2/5] [analyzer][Solver] Teach SymbolicRangeInferrer about commutativity This patch shou
[clang] [clang] constexpr built-in abs function. (PR #112539)
https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/112539 >From dfa1585af3f080987cbd15830c45c34bfecc1fca Mon Sep 17 00:00:00 2001 From: c8ef Date: Wed, 16 Oct 2024 01:18:13 + Subject: [PATCH 01/10] implement constexpr builtin {l}abs --- clang/include/clang/Basic/Builtins.td | 1 + clang/lib/AST/ExprConstant.cpp| 11 +++ clang/test/AST/ByteCode/builtin-functions.cpp | 9 + 3 files changed, 21 insertions(+) diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index bda8a48be92bda..e1b4d5b1fdc0a5 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -2714,6 +2714,7 @@ def Abs : IntMathTemplate, LibBuiltin<"stdlib.h"> { let Attributes = [NoThrow, Const]; let Prototype = "T(T)"; let AddBuiltinPrefixedAlias = 1; + let OnlyBuiltinPrefixedAliasIsConstexpr = 1; } def Calloc : LibBuiltin<"stdlib.h"> { diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 52a7f5778ce6d2..69539a7f03feba 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -13055,6 +13055,17 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E, return Success(Val.popcount() % 2, E); } + case Builtin::BI__builtin_abs: + case Builtin::BI__builtin_labs: + case Builtin::BI__builtin_llabs: { +APSInt Val; +if (!EvaluateInteger(E->getArg(0), Val, Info)) + return false; +if (Val.isNegative()) + Val.negate(); +return Success(Val, E); + } + case Builtin::BI__builtin_popcount: case Builtin::BI__builtin_popcountl: case Builtin::BI__builtin_popcountll: diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 450ff5671314db..46e5b0579bd575 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -265,6 +265,15 @@ namespace fpclassify { char classify_subnorm [__builtin_fpclassify(-1, -1, -1, +1, -1, 1.0e-38f)]; } +namespace abs { +static_assert(__builtin_abs(14) == 14, ""); +static_assert(__builtin_labs(14L) == 14L, ""); +static_assert(__builtin_llabs(14LL) == 14LL, ""); +static_assert(__builtin_abs(-14) == 14, ""); +static_assert(__builtin_labs(-14L) == 14L, ""); +static_assert(__builtin_llabs(-14LL) == 14LL, ""); +} // namespace abs + namespace fabs { static_assert(__builtin_fabs(-14.0) == 14.0, ""); } >From 52e1d070b392ea4651acf5f7f984a1defb035459 Mon Sep 17 00:00:00 2001 From: c8ef Date: Wed, 16 Oct 2024 12:32:37 +0800 Subject: [PATCH 02/10] Update InterpBuiltin.cpp --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 18 ++ 1 file changed, 18 insertions(+) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 65c7b4e5306d72..1e1a75e5514aec 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -563,6 +563,17 @@ static bool interp__builtin_fabs(InterpState &S, CodePtr OpPC, return true; } +static bool interp__builtin_abs(InterpState &S, CodePtr OpPC, +const InterpFrame *Frame, const Function *Func, +const CallExpr *Call) { + PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType()); + APSInt Val = peekToAPSInt(S.Stk, ArgT); + if (Val.isNegative()) +Val.negate(); + pushInteger(S, Val, Call->getType()); + return true; +} + static bool interp__builtin_popcount(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const Function *Func, @@ -1808,6 +1819,13 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F, return false; break; + case Builtin::BI__builtin_abs: + case Builtin::BI__builtin_labs: + case Builtin::BI__builtin_llabs: + if (!interp__builtin_abs(S, OpPC, Frame, F, Call)) +return false; + break; + case Builtin::BI__builtin_popcount: case Builtin::BI__builtin_popcountl: case Builtin::BI__builtin_popcountll: >From 227193529178a1c1484c0da42a06289a26c75114 Mon Sep 17 00:00:00 2001 From: c8ef Date: Wed, 16 Oct 2024 12:33:29 +0800 Subject: [PATCH 03/10] Update ExprConstant.cpp --- clang/lib/AST/ExprConstant.cpp | 11 --- 1 file changed, 11 deletions(-) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 69539a7f03feba..52a7f5778ce6d2 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -13055,17 +13055,6 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E, return Success(Val.popcount() % 2, E); } - case Builtin::BI__builtin_abs: - case Builtin::BI__builtin_labs: - case Builtin::BI__builtin_llabs: { -APSInt Val; -if (!EvaluateInteger(E->getArg(0), Val, Info)) - return false; -if (Val.isNegative()) - Va
[clang] [clang] Reject if constexpr in C (PR #112685)
llvmbot wrote: Failed to cherry-pick: e21c80ac73a9da5c86c20dbce37c9227a17ab06a https://github.com/llvm/llvm-project/actions/runs/11384260535 Please manually backport the fix and push it to your github fork. Once this is done, please create a [pull request](https://github.com/llvm/llvm-project/compare) https://github.com/llvm/llvm-project/pull/112685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add basic support for C++/CLI (#27126) (PR #112689)
calumr wrote: > How would a user specify to use CLI? getFormattingLangOpts seems to turn on MicrosoftExt and some other options by default, so I just copied that. https://github.com/llvm/llvm-project/pull/112689 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reject if constexpr in C (PR #112685)
Fznamznon wrote: https://github.com/llvm/llvm-project/pull/112697 https://github.com/llvm/llvm-project/pull/112685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Improve solver (PR #112583)
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/112583 >From 4bf74c7f9caf89b67e6001b601f70741c1a672cc Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Wed, 16 Oct 2024 15:52:31 +0200 Subject: [PATCH 1/7] [analyzer][Solver] Improve getSymVal and friends Instead of just doing a lookup in the existing constraints, let's use `getRange()` for dissambling SymSymExprs and inferring from the constraint system what end range set we can simplify. This means that `getSymVal` gets more expensive while getting smarter. I don't expect it to be an issue as this API is only rarely used, and `getRange` is used a lot more often - yet without any observable hit on performance. This patch also removes dead declarations of EQClass overloads. --- .../Core/RangeConstraintManager.cpp | 11 + clang/test/Analysis/infeasible-sink.c | 23 +-- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 70d5a609681790..d1999c86f8ecd8 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -1939,11 +1939,8 @@ class RangeConstraintManager : public RangedConstraintManager { RangeSet::Factory F; RangeSet getRange(ProgramStateRef State, SymbolRef Sym); - RangeSet getRange(ProgramStateRef State, EquivalenceClass Class); ProgramStateRef setRange(ProgramStateRef State, SymbolRef Sym, RangeSet Range); - ProgramStateRef setRange(ProgramStateRef State, EquivalenceClass Class, - RangeSet Range); RangeSet getSymLTRange(ProgramStateRef St, SymbolRef Sym, const llvm::APSInt &Int, @@ -2866,12 +2863,14 @@ ConditionTruthVal RangeConstraintManager::checkNull(ProgramStateRef State, const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St, SymbolRef Sym) const { - const RangeSet *T = getConstraint(St, Sym); - return T ? T->getConcreteValue() : nullptr; + auto &MutableSelf = const_cast(*this); + return MutableSelf.getRange(St, Sym).getConcreteValue(); } const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St, SymbolRef Sym) const { + // TODO: Use `getRange()` like in `getSymVal()`, but that would make some + // of the reports of `BitwiseShiftChecker` look awkward. const RangeSet *T = getConstraint(St, Sym); if (!T || T->isEmpty()) return nullptr; @@ -2880,6 +2879,8 @@ const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St, const llvm::APSInt *RangeConstraintManager::getSymMaxVal(ProgramStateRef St, SymbolRef Sym) const { + // TODO: Use `getRange()` like in `getSymVal()`, but that would make some + // of the reports of `BitwiseShiftChecker` look awkward. const RangeSet *T = getConstraint(St, Sym); if (!T || T->isEmpty()) return nullptr; diff --git a/clang/test/Analysis/infeasible-sink.c b/clang/test/Analysis/infeasible-sink.c index 9cb66fcac0b6be..d5b4e82268f5b6 100644 --- a/clang/test/Analysis/infeasible-sink.c +++ b/clang/test/Analysis/infeasible-sink.c @@ -38,7 +38,7 @@ void test1(int x) { } int a, b, c, d, e; -void test2() { +void test2(void) { if (a == 0) return; @@ -50,28 +50,17 @@ void test2() { b = d; a -= d; + clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}} + if (a != 0) return; - clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} - - /* The BASELINE passes these checks ('wrning' is used to avoid lit to match) - // The parent state is already infeasible, look at this contradiction: - clang_analyzer_eval(b > 0); // expected-wrning{{FALSE}} - clang_analyzer_eval(b <= 0); // expected-wrning{{FALSE}} - // Crashes with expensive checks. - if (b > 0) { -clang_analyzer_warnIfReached(); // no-warning, OK -return; - } - // Should not be reachable. - clang_analyzer_warnIfReached(); // expected-wrning{{REACHABLE}} - */ + clang_analyzer_warnIfReached(); // no-warning: Even the parent state is unreachable. // The parent state is already infeasible, but we realize that only if b is // constrained. - clang_analyzer_eval(b > 0); // expected-warning{{UNKNOWN}} - clang_analyzer_eval(b <= 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(b > 0); // no-warning + clang_analyzer_eval(b <= 0); // no-warning if (b > 0) { clang_analyzer_warnIfReached(); // no-warning return; >From be65bb0694be3353fda260ab73777aea28de9113 Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Wed, 16 Oct 2024 15:53:20 +0200 Subject: [PATCH 2/7] [analyzer][Solver] Teach SymbolicRangeInferrer about commutativity This patch shou
[clang] [clang-format] Handle template opener/closer in braced list (PR #112494)
https://github.com/mydeveloperday approved this pull request. https://github.com/llvm/llvm-project/pull/112494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: NAKAMURA Takumi (chapuni) Changes This aggregates the generation of branch counter pair as `ExecCnt` and `SkipCnt`, to aggregate `CounterExpr::subtract`. At the moment: - This change preserves the behavior of `llvm::EnableSingleByteCoverage`. Almost of SingleByteCoverage will be cleaned up by coming commits. - `getBranchCounterPair()` is not called in `llvm::EnableSingleByteCoverage`. I will implement the new behavior of SingleByteCoverage in it. - `IsCounterEqual(Out, Par)` is introduced instead of `Counter::operator==`. Tweaks would be required for the comparison for additional counters. - Braces around `assert()` is intentional. I will add a statement there. https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492 --- Full diff: https://github.com/llvm/llvm-project/pull/112702.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+102-75) ``diff diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 07015834bc84f3..0bfad9cbcbe12b 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, + Counter ParentCnt) { +Counter ExecCnt = getRegionCounter(S); +return {ExecCnt, Builder.subtract(ParentCnt, ExecCnt)}; + } + + bool IsCounterEqual(Counter OutCount, Counter ParentCount) { +if (OutCount == ParentCount) + return true; + +return false; + } + /// Push a region onto the stack. /// /// Returns the index on the stack where the region was pushed. This can be @@ -1592,6 +1605,13 @@ struct CounterCoverageMappingBuilder llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(ParentCount, BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSingleByteCoverage + ? std::make_pair(getRegionCounter(S), Counter::getZero()) + : getBranchCounterPair(S, CondCount)); +if (!llvm::EnableSingleByteCoverage) { + assert(ExecCount.isZero() || ExecCount == BodyCount); +} propagateCounts(CondCount, S->getCond()); adjustForOutOfOrderTraversal(getEnd(S)); @@ -1600,13 +1620,11 @@ struct CounterCoverageMappingBuilder if (Gap) fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), BodyCount); -Counter OutCount = -llvm::EnableSingleByteCoverage -? getRegionCounter(S) -: addCounters(BC.BreakCount, - subtractCounters(CondCount, BodyCount)); +Counter OutCount = llvm::EnableSingleByteCoverage + ? getRegionCounter(S) + : addCounters(BC.BreakCount, ExitCount); -if (OutCount != ParentCount) { +if (!IsCounterEqual(OutCount, ParentCount)) { pushRegion(OutCount); GapRegionCounter = OutCount; if (BodyHasTerminateStmt) @@ -1615,8 +1633,7 @@ struct CounterCoverageMappingBuilder // Create Branch Region around condition. if (!llvm::EnableSingleByteCoverage) - createBranchRegion(S->getCond(), BodyCount, - subtractCounters(CondCount, BodyCount)); + createBranchRegion(S->getCond(), BodyCount, ExitCount); } void VisitDoStmt(const DoStmt *S) { @@ -1645,22 +1662,26 @@ struct CounterCoverageMappingBuilder Counter CondCount = llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSingleByteCoverage + ? std::make_pair(getRegionCounter(S), Counter::getZero()) + : getBranchCounterPair(S, CondCount)); +if (!llvm::EnableSingleByteCoverage) { + assert(ExecCount.isZero() || ExecCount == BodyCount); +} propagateCounts(CondCount, S->getCond()); -Counter OutCount = -llvm::EnableSingleByteCoverage -? getRegionCounter(S) -: addCounters(BC.BreakCount, - subtractCounters(CondCount, BodyCount)); -if (OutCount != ParentCount) { +Counter OutCount = llvm::EnableSingleByteCoverage + ? getRegionCounter(S) + : addCounters(BC.BreakCount, ExitCount); +if (!IsCounterEqual(OutCount, ParentCount)) { pushRegion(OutCount); GapRegionCounter = OutCount; } // Create Branch Region around condition. if (!llvm::EnableSingleByteCoverage) - createBranchRegion(S->getCond(), BodyCount, - subtractCounters(CondCount, BodyCount)); + createBran
[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)
https://github.com/chapuni created https://github.com/llvm/llvm-project/pull/112702 This aggregates the generation of branch counter pair as `ExecCnt` and `SkipCnt`, to aggregate `CounterExpr::subtract`. At the moment: - This change preserves the behavior of `llvm::EnableSingleByteCoverage`. Almost of SingleByteCoverage will be cleaned up by coming commits. - `getBranchCounterPair()` is not called in `llvm::EnableSingleByteCoverage`. I will implement the new behavior of SingleByteCoverage in it. - `IsCounterEqual(Out, Par)` is introduced instead of `Counter::operator==`. Tweaks would be required for the comparison for additional counters. - Braces around `assert()` is intentional. I will add a statement there. https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH] [Coverage] Introduce `getBranchCounterPair()`. NFC. This aggregates the generation of branch counter pair as `ExecCnt` and `SkipCnt`, to aggregate `CounterExpr::subtract`. At the moment: - This change preserves the behavior of `llvm::EnableSingleByteCoverage`. Almost of SingleByteCoverage will be cleaned up by coming commits. - `getBranchCounterPair()` is not called in `llvm::EnableSingleByteCoverage`. I will implement the new behavior of SingleByteCoverage in it. - `IsCounterEqual(Out, Par)` is introduced instead of `Counter::operator==`. Tweaks would be required for the comparison for additional counters. - Braces around `assert()` is intentional. I will add a statement there. https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 177 +-- 1 file changed, 102 insertions(+), 75 deletions(-) diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 07015834bc84f3..0bfad9cbcbe12b 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, + Counter ParentCnt) { +Counter ExecCnt = getRegionCounter(S); +return {ExecCnt, Builder.subtract(ParentCnt, ExecCnt)}; + } + + bool IsCounterEqual(Counter OutCount, Counter ParentCount) { +if (OutCount == ParentCount) + return true; + +return false; + } + /// Push a region onto the stack. /// /// Returns the index on the stack where the region was pushed. This can be @@ -1592,6 +1605,13 @@ struct CounterCoverageMappingBuilder llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(ParentCount, BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSingleByteCoverage + ? std::make_pair(getRegionCounter(S), Counter::getZero()) + : getBranchCounterPair(S, CondCount)); +if (!llvm::EnableSingleByteCoverage) { + assert(ExecCount.isZero() || ExecCount == BodyCount); +} propagateCounts(CondCount, S->getCond()); adjustForOutOfOrderTraversal(getEnd(S)); @@ -1600,13 +1620,11 @@ struct CounterCoverageMappingBuilder if (Gap) fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), BodyCount); -Counter OutCount = -llvm::EnableSingleByteCoverage -? getRegionCounter(S) -: addCounters(BC.BreakCount, - subtractCounters(CondCount, BodyCount)); +Counter OutCount = llvm::EnableSingleByteCoverage + ? getRegionCounter(S) + : addCounters(BC.BreakCount, ExitCount); -if (OutCount != ParentCount) { +if (!IsCounterEqual(OutCount, ParentCount)) { pushRegion(OutCount); GapRegionCounter = OutCount; if (BodyHasTerminateStmt) @@ -1615,8 +1633,7 @@ struct CounterCoverageMappingBuilder // Create Branch Region around condition. if (!llvm::EnableSingleByteCoverage) - createBranchRegion(S->getCond(), BodyCount, - subtractCounters(CondCount, BodyCount)); + createBranchRegion(S->getCond(), BodyCount, ExitCount); } void VisitDoStmt(const DoStmt *S) { @@ -1645,22 +1662,26 @@ struct CounterCoverageMappingBuilder Counter CondCount = llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSingleByteCoverage + ? std::make_pair(getRegionCounter(S), Counter::getZero()) + : getBranchCounterPair(S, CondCount)); +if (!llvm::EnableSingleByteCoverage) { + assert(ExecCoun
[clang] modified AST for SEI redemption project (PR #111705)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
https://github.com/AaronBallman commented: Thank you for this! There's a pile of comments, but most of them are trivial reworking of comments in the code. There's an outstanding question about the funding notification. The only big thing that's missing from the changes is test coverage. You should add tests to `clang/test/AST/` which exercise the new functionality; there are existing tests in that directory which you can base your tests on for dumping JSON or Text and testing the output. It would be especially good to get test coverage for more complex types like a function pointer returning a function pointer and accepting an array of function pointers, or something along those lines. FWIW, I am a bit concerned about how we're dumping the type information out currently. The ideal I'd like to shoot for is having a type database spit out at the start of the JSON, and then a separate AST tree that refers back to the type database so we don't have to repeat type information all over the place. But this would then allow us to issue complete type information for each AST node (like splitting out return types, parameter lists, etc). However, the problem with that is that we stream out the AST nodes as we hit them, which means we'd need to walk the AST twice in order to build the type database and then spit out the AST nodes referring to it, or we'd need to collect all the information while walking and then stream everything out at the end of the TU, and either of those would be a pretty big undertaking so I don't insist on that as a change for this PR. However, it would be nice to capture this in a FIXME comment in the code so we remember to come back and clean this up more in the future. https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -177,14 +193,34 @@ class ASTNodeTraverser if (!SQT.Quals.hasQualifiers()) return Visit(SQT.Ty); -getNodeDelegate().AddChild([=] { +// SEI: changed from default label to "qualTypeDetail" +getNodeDelegate().AddChild("qualTypeDetail", [this, T] { getNodeDelegate().Visit(T); Visit(T.split().Ty); }); + +// SEI function pointer support. this gets called whenever the three +// conditions are met: +// 1. the function pointer is not typedef'd +// 2. after Visit(VarDecl *) gets called +// 3. if VarDecl determines this is a function pointer +if (T->isFunctionPointerType()) { + // create as a child node to this type AaronBallman wrote: ```suggestion // This gets used whenever the three conditions are met: // 1. the function pointer is not typedef'd // 2. after Visit(VarDecl *) gets called // 3. if VarDecl determines this is a function pointer if (T->isFunctionPointerType()) { // Create as a child node to this type. ``` https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [libcxxabi] [libunwind] [CMake] Handle multiple flags in ADDITIONAL_COMPILE_FLAGS properly (PR #112703)
https://github.com/stephanosio created https://github.com/llvm/llvm-project/pull/112703 When multiple space-separated compile flags are specified in an `ADDITIONAL_COMPILE_FLAGS` cache string, the resulting flags are enclosed by double quotes because `ADDITIONAL_COMPILE_FLAGS` is a string (i.e. not a list) and CMake `target_compile_options` treats the multiple space-separated arguments as single argument containing spaces. For example, when libcxx is configured with the following multiple space-separated additional compile flags: cmake ... "-DLIBCXX_ADDITIONAL_COMPILE_FLAGS=--flag1 --flag2" ... The resulting compiler command line is as follows: cc ... "--flag1 --flag2" ... The above can be problematic for some compilers -- for instance, GCC treats it as a file path and prints out an error. This patch, by calling `separate_arguments` on `ADDITIONAL_COMPILE_FLAGS` to convert it into the standard semicolon-separated list form, which is properly handled by `target_compile_options`, ensures that multiple compile flags are handled as such. With this change, the resulting compiler command line is as follows: cc ... --flag1 --flag2 ... >From 3763d810e4cb248285a56f1491162a95ebf482f8 Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Thu, 17 Oct 2024 20:55:11 +0900 Subject: [PATCH] [CMake] Handle multiple flags in ADDITIONAL_COMPILE_FLAGS properly When multiple space-separated compile flags are specified in an `ADDITIONAL_COMPILE_FLAGS` cache string, the resulting flags are enclosed by double quotes because `ADDITIONAL_COMPILE_FLAGS` is a string (i.e. not a list) and CMake `target_compile_options` treats the multiple space-separated arguments as single argument containing spaces. For example, when libcxx is configured with the following multiple space-separated additional compile flags: cmake ... "-DLIBCXX_ADDITIONAL_COMPILE_FLAGS=--flag1 --flag2" ... The resulting compiler command line is as follows: cc ... "--flag1 --flag2" ... The above can be problematic for some compilers -- for instance, GCC treats it as a file path and prints out an error. This patch, by calling `separate_arguments` on `ADDITIONAL_COMPILE_FLAGS` to convert it into the standard semicolon-separated list form, which is properly handled by `target_compile_options`, ensures that multiple compile flags are handled as such. With this change, the resulting compiler command line is as follows: cc ... --flag1 --flag2 ... Signed-off-by: Stephanos Ioannidis --- libcxx/CMakeLists.txt| 3 ++- libcxxabi/CMakeLists.txt | 1 + libcxxabi/src/CMakeLists.txt | 4 ++-- libunwind/CMakeLists.txt | 1 + libunwind/src/CMakeLists.txt | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 75c926f5432aea..f9cdeaa0fe84b6 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -460,6 +460,7 @@ set(LIBCXX_LINK_FLAGS "") set(LIBCXX_LIBRARIES "") set(LIBCXX_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING "Additional Compile only flags which can be provided in cache") +separate_arguments(LIBCXX_ADDITIONAL_COMPILE_FLAGS) set(LIBCXX_ADDITIONAL_LIBRARIES "" CACHE STRING "Additional libraries libc++ is linked to which can be provided in cache") @@ -549,7 +550,7 @@ function(cxx_add_basic_build_flags target) target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_RT_LIB) endif() endif() - target_compile_options(${target} PUBLIC "${LIBCXX_ADDITIONAL_COMPILE_FLAGS}") + target_compile_options(${target} PUBLIC ${LIBCXX_ADDITIONAL_COMPILE_FLAGS}) endfunction() # Exception flags = diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index ac1ee69d5f11c9..ef7473bf1a6cbb 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -224,6 +224,7 @@ set(LIBCXXABI_LINK_FLAGS "") set(LIBCXXABI_LIBRARIES "") set(LIBCXXABI_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING "Additional Compile only flags which can be provided in cache") +separate_arguments(LIBCXXABI_ADDITIONAL_COMPILE_FLAGS) set(LIBCXXABI_ADDITIONAL_LIBRARIES "" CACHE STRING "Additional libraries libc++abi is linked to which can be provided in cache") diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt index 84fe2784bec5ca..3fc822ffdbcd6b 100644 --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -182,7 +182,7 @@ set_target_properties(cxxabi_shared_objects if (CMAKE_POSITION_INDEPENDENT_CODE OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) set_target_properties(cxxabi_shared_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) # must set manually because it's an object library endif() -target_compile_options(cxxabi_shared_objects PRIVATE "${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}") +target_compile_options(cxxabi_shared_objects PRIVATE ${LIBCXXABI_ADDITIONAL_COMPILE_FLAGS}) add_library(cxxabi_shared SHARED) s
[clang] modified AST for SEI redemption project (PR #111705)
@@ -87,13 +100,44 @@ void JSONNodeDumper::Visit(const Type *T) { T->containsUnexpandedParameterPack()); attributeOnlyIfTrue("isImported", T->isFromAST()); InnerTypeVisitor::Visit(T); + // SEI + VisitQualTypeDetails(T->getCanonicalTypeInternal()); } void JSONNodeDumper::Visit(QualType T) { - JOS.attribute("id", createPointerRepresentation(T.getAsOpaquePtr())); - JOS.attribute("kind", "QualType"); - JOS.attribute("type", createQualType(T)); - JOS.attribute("qualifiers", T.split().Quals.getAsString()); + + // SEI: used AddChild to prevent qualType from being part added to a list + // JOS.attributeArray("qualTypes", [=] { + + // SEI: force qualType into its own block, otherwise multiple Visits + // create a bunch of siblings, which is invalid JSON AaronBallman wrote: ```suggestion // Force qualType into its own block, otherwise multiple Visits // create a bunch of siblings, which is invalid JSON. ``` https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -183,6 +199,12 @@ class TextNodeDumper void Visit(TypeLoc); + // SEI: added support for getting ReturnType information + void VisitReturnType(QualType T); + + // SEI: added support for more QT details. it's a passthrough for this class + void VisitQualTypeDetails(QualType T) {} AaronBallman wrote: ```suggestion void VisitReturnType(QualType T); void VisitQualTypeDetails(QualType T) {} ``` https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -111,6 +155,64 @@ void JSONNodeDumper::Visit(TypeLoc TL) { [TL, this] { writeSourceRange(TL.getSourceRange()); }); } +void JSONNodeDumper::VisitQualTypeDetails(QualType T) { + // SEI: get more detailed info on type. this info is not transferrable + // with the refId, so this must be called on every type even if that type + // has been cached + JOS.attributeBegin("qualDetails"); + JOS.arrayBegin(); + + auto CT = T->getCanonicalTypeInternal(); + + if (CT->isStructureType()) +JOS.value("struct"); + + if (CT->isNullPtrType()) +JOS.value("null"); + if (CT->isUndeducedType()) +JOS.value("undeduced"); + + if (CT->isPointerType()) AaronBallman wrote: References? https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -1346,6 +1460,8 @@ void JSONNodeDumper::VisitDeclRefExpr(const DeclRefExpr *DRE) { case NOUR_Discarded: JOS.attribute("nonOdrUseReason", "discarded"); break; } attributeOnlyIfTrue("isImmediateEscalating", DRE->isImmediateEscalating()); + // SEI: this doesn't call VisitNamedDecl, so we force it AaronBallman wrote: ```suggestion // This doesn't call VisitNamedDecl, so we force it. ``` https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -87,13 +100,44 @@ void JSONNodeDumper::Visit(const Type *T) { T->containsUnexpandedParameterPack()); attributeOnlyIfTrue("isImported", T->isFromAST()); InnerTypeVisitor::Visit(T); + // SEI + VisitQualTypeDetails(T->getCanonicalTypeInternal()); } void JSONNodeDumper::Visit(QualType T) { - JOS.attribute("id", createPointerRepresentation(T.getAsOpaquePtr())); - JOS.attribute("kind", "QualType"); - JOS.attribute("type", createQualType(T)); - JOS.attribute("qualifiers", T.split().Quals.getAsString()); + + // SEI: used AddChild to prevent qualType from being part added to a list + // JOS.attributeArray("qualTypes", [=] { + + // SEI: force qualType into its own block, otherwise multiple Visits + // create a bunch of siblings, which is invalid JSON + JOS.attributeBegin("qualType"); + JOS.objectBegin(); + + // SEI: cache visited addresses and add only its refId + // instead of the kind, type, quals, but leave the qual type details + // because those can differ among IDs + if (cacheAddress(T.getAsOpaquePtr())) { +JOS.attribute("refId", createPointerRepresentation(T.getAsOpaquePtr())); + } else { +JOS.attribute("id", createPointerRepresentation(T.getAsOpaquePtr())); +JOS.attribute("kind", "QualType"); +JOS.attribute("type", createQualType(T)); +JOS.attribute("qualifiers", T.split().Quals.getAsString()); + } + + // SEI: get add'l info required for redemption analysis + // the qual type details differ even among cached references + VisitQualTypeDetails(T); + + // SEI: if this is a pointer type, then recursively call ourselves + // until it's not + if (T->isPointerType()) +Visit(T->getPointeeType()); + + JOS.objectEnd(); + JOS.attributeEnd(); + //} ); AaronBallman wrote: ```suggestion JOS.attributeEnd(); ``` https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -11,6 +11,22 @@ // similar to RecursiveASTVisitor. // //===--===// +// +// Modifications to this file by SEI staff are copyright Carnegie Mellon +// University and contributed under the Apache License v2.0 with LLVM +// Exceptions. +// +// SEI Contributions are made with funding sand support from the Department of +// Defense under Contract No. FA8702-15-D-0002 with Carnegie Mellon University +// for the operation of the Software Engineering Institute, a federally funded +// research and development center. +// +// The view, opinions, and/or findings contained in this material are those of +// the author(s) and should not be construed as an official Government position, +// policy, or decision, unless designated by other documentation. +// DM24-0194 AaronBallman wrote: We don't accept these kinds of comments in the source as 1) the copyright part is not necessary per https://llvm.org/docs/DeveloperPolicy.html#copyright-license-patents, 2) it doesn't scale well because the files will quickly become littered with such notices, 3) I think anything like this would require LLVM Foundation approval. Is it a requirement for your contract to have these kinds of comments in the source code? Or would putting some of it (not the copyright paragraph) into the commit message when landing the changes suffice? https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -177,14 +193,34 @@ class ASTNodeTraverser if (!SQT.Quals.hasQualifiers()) return Visit(SQT.Ty); -getNodeDelegate().AddChild([=] { +// SEI: changed from default label to "qualTypeDetail" AaronBallman wrote: ```suggestion ``` We don't add changelog comments directly in the source code, and we also don't attribute comments to particular individuals or entities (unless it's actually relevant to understanding the code). https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] modified AST for SEI redemption project (PR #111705)
@@ -177,14 +193,34 @@ class ASTNodeTraverser if (!SQT.Quals.hasQualifiers()) return Visit(SQT.Ty); -getNodeDelegate().AddChild([=] { +// SEI: changed from default label to "qualTypeDetail" +getNodeDelegate().AddChild("qualTypeDetail", [this, T] { getNodeDelegate().Visit(T); Visit(T.split().Ty); }); + +// SEI function pointer support. this gets called whenever the three +// conditions are met: +// 1. the function pointer is not typedef'd +// 2. after Visit(VarDecl *) gets called +// 3. if VarDecl determines this is a function pointer +if (T->isFunctionPointerType()) { + // create as a child node to this type + getNodeDelegate().AddChild( + [=] { getNodeDelegate().Visit(T->getPointeeType()); }); +} + +// SEI: traverse PointerType information +if (T->isPointerType()) + Visit(T->getPointeeType()); } + // SEI: traverse ReturnType information + void VisitReturnType(QualType T) { getNodeDelegate().VisitReturnType(T); } + void Visit(const Type *T) { -getNodeDelegate().AddChild([=] { +// SEI: renamed this from default label AaronBallman wrote: ```suggestion ``` https://github.com/llvm/llvm-project/pull/111705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits