[clang] [CMake] Change GCC_INSTALL_PREFIX from warning to fatal error (PR #85891)
haampie wrote: Users of `GCC_INSTALL_PREFIX` typically have GCC installed in a unique, non-standard prefix, where clang's default search just worked. Now those users have to generate config files for post-install, AND figure out how to make clang behave correctly when building runtimes. That's not ideal. @MaskRay can you please make the error message more informative? It should probably say that users additionally have to set `RUNTIMES_CMAKE_ARGS=...` as well as generating `clang.cfg`, `clang++.cfg` config files. (And what about `flang.cfg` and/or `flang-new.cfg`?) More clarity please :) https://github.com/llvm/llvm-project/pull/85891 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)
https://github.com/HighCommander4 converted_to_draft https://github.com/llvm/llvm-project/pull/89557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)
HighCommander4 wrote: I'm planning to revise the patch to make the following changes: 1. Put the new behaviour behind a config option (I'm thinking `Hover` --> `ShowFields`) 2. Add C language mode tests 3. Use `PrintingCallbacks` instead of a `PrintingPolicy` flag https://github.com/llvm/llvm-project/pull/89557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)
HighCommander4 wrote: > I have a few questions: > >1. Do we want an RFC in discourse for the changes in `DeclPrinter`? An RFC might be overkill, but asking for review from a clang code owner for changes to an interface such as `PrintingPolicy` or `PrintingCallbacks` is probably a good idea. (If the clang reviewer feels an RFC is warranted, we can do it then.) >2. Do you think we should also add some test cases to > `DeclPrinterTest.cpp`? Yep, good call! https://github.com/llvm/llvm-project/pull/89557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)
HighCommander4 wrote: > > 3. Regarding the implementation approach, is it fine to add a flag to > > `PrintingPolicy` (which is a clang utility class used in a variety of > > places) for a clangd-specific use case like this? I did it this way because > > the alternative seemed to involve duplicating a bunch of code related to > > decl-printing, but I'm happy to explore alternatives if this is an issue. > > I feel like "print only public fields" is too specific for clangd use case, > and probably won't generalize to other callers at all. But I definitely agree > with all the concerns around duplicating code. Looks like we have some > `PrintingCallbacks`, maybe we can have something like `SummarizeTagDecl`, > which enables customizing what to put into the body, when printing a TagDecl > in terse mode? Thanks for the suggestion! Using `PrintingCallbacks` here sounds like a promising idea. https://github.com/llvm/llvm-project/pull/89557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MC/DC][Coverage] Workaround for `##` conditions (PR #89573)
chapuni wrote: @whentojump Thanks. Would you like to take this over? Then I will close this. https://github.com/llvm/llvm-project/pull/89573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)
@@ -474,6 +477,17 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) { for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end(); D != DEnd; ++D) { +// Print enum members and public struct fields when +// PrintTagTypeContents=true. Only applicable when TerseOutput=true since +// otherwise all members are printed. +if (Policy.TerseOutput) { + assert(Policy.PrintTagTypeContents); + if (!(isa(*D) || +(isa(*D) && + dyn_cast(*D)->getAccess() == AS_public))) HighCommander4 wrote: The patch does seem to work for me on C files, but adding a test to exercise the code in C mode is definitely a good idea. Thanks! https://github.com/llvm/llvm-project/pull/89557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Mark ill-formed partial specialization as invalid (PR #89536)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/89536 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 805d563 - [clang] Mark ill-formed partial specialization as invalid (#89536)
Author: Vlad Serebrennikov Date: 2024-04-24T10:45:38+04:00 New Revision: 805d5637a0d50caa073f435b55940c1338aae0fc URL: https://github.com/llvm/llvm-project/commit/805d5637a0d50caa073f435b55940c1338aae0fc DIFF: https://github.com/llvm/llvm-project/commit/805d5637a0d50caa073f435b55940c1338aae0fc.diff LOG: [clang] Mark ill-formed partial specialization as invalid (#89536) Fixes #89374 Solution suggested by @cor3ntin Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/test/SemaCXX/template-specialization.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3db558a1c11a3f..64526ed6d06f55 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -415,6 +415,9 @@ Bug Fixes in This Version operator. Fixes (#GH83267). +- Fix crash on ill-formed partial specialization with CRTP. + Fixes (#GH89374). + - Clang now correctly generates overloads for bit-precise integer types for builtin operators in C++. Fixes #GH82998. diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 4bda31ba67c02d..bbcb7c33a98579 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -9460,6 +9460,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization( Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized) << ClassTemplate->getDeclName(); isPartialSpecialization = false; + Invalid = true; } } @@ -9675,6 +9676,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization( if (SkipBody && SkipBody->ShouldSkip) return SkipBody->Previous; + Specialization->setInvalidDecl(Invalid); return Specialization; } diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 0b6375001f5326..c3815bca038554 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1914,6 +1914,9 @@ static TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch( if (!S.isCompleteType(Info.getLocation(), A)) return Result; + if (getCanonicalRD(A)->isInvalidDecl()) +return Result; + // Reset the incorrectly deduced argument from above. Deduced = DeducedOrig; diff --git a/clang/test/SemaCXX/template-specialization.cpp b/clang/test/SemaCXX/template-specialization.cpp index 7b26ff9f5c5ba4..eabb84f2e13d3e 100644 --- a/clang/test/SemaCXX/template-specialization.cpp +++ b/clang/test/SemaCXX/template-specialization.cpp @@ -52,3 +52,31 @@ void instantiate() { } } + +namespace GH89374 { + +struct A {}; + +template +struct MatrixBase { // #GH89374-MatrixBase + template + Derived &operator=(const MatrixBase &); // #GH89374-copy-assignment +}; + +template +struct solve_retval; + +template +struct solve_retval : MatrixBase > {}; +// expected-error@-1 {{partial specialization of 'solve_retval' does not use any of its template parameters}} + +void ApproximateChebyshev() { + MatrixBase c; + c = solve_retval(); + // expected-error@-1 {{no viable overloaded '='}} + // expected-note@#GH89374-copy-assignment {{candidate template ignored: could not match 'MatrixBase' against 'solve_retval'}} + // expected-note@#GH89374-MatrixBase {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'solve_retval' to 'const MatrixBase' for 1st argument}} + // expected-note@#GH89374-MatrixBase {{candidate function (the implicit move assignment operator) not viable: no known conversion from 'solve_retval' to 'MatrixBase' for 1st argument}} +} + +} // namespace GH89374 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h (PR #89873)
https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/89873 >From d83b9cda6c7d943e90c324fa2c1c7e7ffaf88e1c Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Wed, 24 Apr 2024 13:35:01 +0800 Subject: [PATCH] [NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h Previously, the DeclID is defined in serialization/ASTBitCodes.h under clang::serialization namespace. However, actually the DeclID is not purely used in serialization part. The DeclID is already widely used in AST and all around the clang project via classes like `LazyPtrDecl` or calling `ExternalASTSource::getExernalDecl()`. All such uses are via the raw underlying type of `DeclID` as `uint32_t`. This is not pretty good. This patch moves the DeclID class family to a new header `AST/DeclID.h` so that the whole project can use the wrapped class `DeclID`, `GlobalDeclID` and `LocalDeclID` instead of the raw underlying type. This can improve the readability and the type safety. --- clang/include/clang/AST/ASTContext.h | 4 +- clang/include/clang/AST/DeclBase.h| 4 +- clang/include/clang/AST/DeclID.h | 177 ++ clang/include/clang/AST/DeclTemplate.h| 2 +- clang/include/clang/AST/ExternalASTSource.h | 4 +- clang/include/clang/Frontend/ASTUnit.h| 2 +- .../clang/Frontend/MultiplexConsumer.h| 2 +- .../clang/Sema/MultiplexExternalSemaSource.h | 2 +- .../include/clang/Serialization/ASTBitCodes.h | 161 +--- .../ASTDeserializationListener.h | 2 +- clang/include/clang/Serialization/ASTReader.h | 126 ++--- .../clang/Serialization/ASTRecordReader.h | 6 +- clang/include/clang/Serialization/ASTWriter.h | 22 +-- .../include/clang/Serialization/ModuleFile.h | 8 +- clang/lib/AST/ASTContext.cpp | 3 +- clang/lib/AST/Decl.cpp| 46 ++--- clang/lib/AST/DeclBase.cpp| 4 +- clang/lib/AST/DeclCXX.cpp | 63 +++ clang/lib/AST/DeclFriend.cpp | 2 +- clang/lib/AST/DeclObjC.cpp| 24 +-- clang/lib/AST/DeclOpenMP.cpp | 18 +- clang/lib/AST/DeclTemplate.cpp| 41 ++-- clang/lib/AST/ExternalASTSource.cpp | 2 +- clang/lib/Frontend/ASTUnit.cpp| 4 +- clang/lib/Frontend/FrontendAction.cpp | 6 +- clang/lib/Frontend/MultiplexConsumer.cpp | 3 +- .../lib/Sema/MultiplexExternalSemaSource.cpp | 2 +- clang/lib/Serialization/ASTReader.cpp | 16 +- clang/lib/Serialization/ASTReaderDecl.cpp | 18 +- clang/lib/Serialization/ASTWriter.cpp | 4 +- clang/lib/Serialization/ASTWriterDecl.cpp | 4 +- 31 files changed, 384 insertions(+), 398 deletions(-) create mode 100644 clang/include/clang/AST/DeclID.h diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index d5ed20ff50157d..ecec9bfcf30079 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -455,7 +455,7 @@ class ASTContext : public RefCountedBase { /// initialization of another module). struct PerModuleInitializers { llvm::SmallVector Initializers; -llvm::SmallVector LazyInitializers; +llvm::SmallVector LazyInitializers; void resolve(ASTContext &Ctx); }; @@ -1059,7 +1059,7 @@ class ASTContext : public RefCountedBase { /// or an ImportDecl nominating another module that has initializers. void addModuleInitializer(Module *M, Decl *Init); - void addLazyModuleInitializers(Module *M, ArrayRef IDs); + void addLazyModuleInitializers(Module *M, ArrayRef IDs); /// Get the initializations to perform when importing a module, if any. ArrayRef getModuleInitializers(Module *M); diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index d8cafc3d81526e..474e51c1df6d68 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -15,6 +15,7 @@ #include "clang/AST/ASTDumperUtils.h" #include "clang/AST/AttrIterator.h" +#include "clang/AST/DeclID.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/SelectorLocationsKind.h" #include "clang/Basic/IdentifierTable.h" @@ -239,9 +240,6 @@ class alignas(8) Decl { ModulePrivate }; - /// An ID number that refers to a declaration in an AST file. - using DeclID = uint32_t; - protected: /// The next declaration within the same lexical /// DeclContext. These pointers form the linked list that is diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h new file mode 100644 index 00..e2c6dd65e86bc3 --- /dev/null +++ b/clang/include/clang/AST/DeclID.h @@ -0,0 +1,177 @@ +//===--- DeclID.h - ID number for deserialized declarations *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See ht
[clang] [Driver] Restore compiler-rt arch suffix for PS and Windows (PR #89775)
tru wrote: I agree that if downstream want to change stuff, they need to engage. We can't guess what microsoft wants to do (or sony) unless we have a discussion about it. This is also documented in the developer policy. If there are missed release notes, they need to be added of course. That said - if I understand your problem correctly @pogo59 you are building clang yourself, but you are using the asan libraries from MSVC? I am not sure that would ever be a supported configuration if the compiler isn't built from the same source as the runtime libraries. If you would have built compiler-rt/asan yourself it should have been found and used correctly. I think it might make sense to make a RFC (again I guess) to remove the old paths and have a grace period where there is a cmake option to force the old layout. This would harmonize so that we have just one layout and remove the biggest problem (in my mind) which is the fallback that can load the wrong runtime library if you are unlucky. https://github.com/llvm/llvm-project/pull/89775 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstCombine] Swap out range metadata to range attribute for cttz/ctlz/ctpop (PR #88776)
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/88776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Fix the process return code if diagnostics occurred. (PR #89879)
https://github.com/vgvassilev updated https://github.com/llvm/llvm-project/pull/89879 >From d6b3d2a7b93399f8e895118e9f43378a2efa21f1 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Wed, 24 Apr 2024 06:30:55 + Subject: [PATCH] [clang-repl] Fix the process return code if diagnostics occurred. --- clang/test/Interpreter/fail.cpp | 11 --- clang/tools/clang-repl/ClangRepl.cpp | 17 +++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/clang/test/Interpreter/fail.cpp b/clang/test/Interpreter/fail.cpp index 4e301f37548f1f..b9035aca3cb7b1 100644 --- a/clang/test/Interpreter/fail.cpp +++ b/clang/test/Interpreter/fail.cpp @@ -1,12 +1,9 @@ -// FIXME: There're some inconsistencies between interactive and non-interactive -// modes. For example, when clang-repl runs in the interactive mode, issues an -// error, and then successfully recovers if we decide it's a success then for -// the non-interactive mode the exit code should be a failure. -// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;" // REQUIRES: host-supports-jit // UNSUPPORTED: system-aix -// RUN: cat %s | not clang-repl | FileCheck %s -BOOM! +// RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;" +// RUN: cat %s | clang-repl | FileCheck %s +// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s +BOOM! // expected-error {{intended to fail the -verify test}} extern "C" int printf(const char *, ...); int i = 42; auto r1 = printf("i = %d\n", i); diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp index aecf61b97fc719..9cfc70462893dd 100644 --- a/clang/tools/clang-repl/ClangRepl.cpp +++ b/clang/tools/clang-repl/ClangRepl.cpp @@ -215,13 +215,15 @@ int main(int argc, const char **argv) { } else Interp = ExitOnErr(clang::Interpreter::create(std::move(CI))); + bool HasError = false; + for (const std::string &input : OptInputs) { -if (auto Err = Interp->ParseAndExecute(input)) +if (auto Err = Interp->ParseAndExecute(input)) { llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); + HasError = true; +} } - bool HasError = false; - if (OptInputs.empty()) { llvm::LineEditor LE("clang-repl"); std::string Input; @@ -241,18 +243,13 @@ int main(int argc, const char **argv) { break; } if (Input == R"(%undo)") { -if (auto Err = Interp->Undo()) { +if (auto Err = Interp->Undo()) llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); - HasError = true; -} } else if (Input.rfind("%lib ", 0) == 0) { -if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) { +if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); - HasError = true; -} } else if (auto Err = Interp->ParseAndExecute(Input)) { llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); -HasError = true; } Input = ""; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Fix the process return code if diagnostics occurred. (PR #89879)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vassil Vassilev (vgvassilev) Changes Should fix the failure seen in the pre-merge infrastructure of #89804. --- Full diff: https://github.com/llvm/llvm-project/pull/89879.diff 2 Files Affected: - (modified) clang/test/Interpreter/fail.cpp (+4-7) - (modified) clang/tools/clang-repl/ClangRepl.cpp (+7-9) ``diff diff --git a/clang/test/Interpreter/fail.cpp b/clang/test/Interpreter/fail.cpp index 4e301f37548f1f..b9035aca3cb7b1 100644 --- a/clang/test/Interpreter/fail.cpp +++ b/clang/test/Interpreter/fail.cpp @@ -1,12 +1,9 @@ -// FIXME: There're some inconsistencies between interactive and non-interactive -// modes. For example, when clang-repl runs in the interactive mode, issues an -// error, and then successfully recovers if we decide it's a success then for -// the non-interactive mode the exit code should be a failure. -// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;" // REQUIRES: host-supports-jit // UNSUPPORTED: system-aix -// RUN: cat %s | not clang-repl | FileCheck %s -BOOM! +// RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;" +// RUN: cat %s | clang-repl | FileCheck %s +// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s +BOOM! // expected-error {{intended to fail the -verify test}} extern "C" int printf(const char *, ...); int i = 42; auto r1 = printf("i = %d\n", i); diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp index aecf61b97fc719..bdc740c33a8f72 100644 --- a/clang/tools/clang-repl/ClangRepl.cpp +++ b/clang/tools/clang-repl/ClangRepl.cpp @@ -215,12 +215,15 @@ int main(int argc, const char **argv) { } else Interp = ExitOnErr(clang::Interpreter::create(std::move(CI))); + bool HasError = false; + for (const std::string &input : OptInputs) { -if (auto Err = Interp->ParseAndExecute(input)) +if (auto Err = Interp->ParseAndExecute(input)) { llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); + HasError = true; +} } - bool HasError = false; if (OptInputs.empty()) { llvm::LineEditor LE("clang-repl"); @@ -241,18 +244,13 @@ int main(int argc, const char **argv) { break; } if (Input == R"(%undo)") { -if (auto Err = Interp->Undo()) { +if (auto Err = Interp->Undo()) llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); - HasError = true; -} } else if (Input.rfind("%lib ", 0) == 0) { -if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) { +if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); - HasError = true; -} } else if (auto Err = Interp->ParseAndExecute(Input)) { llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); -HasError = true; } Input = ""; `` https://github.com/llvm/llvm-project/pull/89879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ARM] Armv8-R does not require fp64 or neon. (PR #88287)
chrisnc wrote: @davemgreen which change? Specifying `-mcpu=cortex-r52` will behave the same way as before. The original manual for the R52 provided for a no-neon sp-only variant, and they exist in the wild, and this lets "architecture-generic" builds automatically support both. One example where this comes up is in the Rust project, which recently gained armv8r support, but due to the over-spec'ing of the base armv8r in LLVM, it requires `-feature` additions in the default target feature list to build the `core` crate in a way that will support lesser r52's by default. Then, when users specify cortex-r52 as their target cpu, they are still left with the `-feature` additions overriding what the r52 should enable by default. https://github.com/rust-lang/rust/pull/123159 This change will allow the feature flags and target CPUs to interact in a more predictable way as compared to other Cortex-R and -M CPUs. https://github.com/llvm/llvm-project/pull/88287 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Fix the process return code if diagnostics occurred. (PR #89879)
https://github.com/vgvassilev created https://github.com/llvm/llvm-project/pull/89879 Should fix the failure seen in the pre-merge infrastructure of #89804. >From 066029973ac937f3a810bd4aefaed8c8f6e0af51 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Wed, 24 Apr 2024 06:30:55 + Subject: [PATCH] [clang-repl] Fix the process return code if diagnostics occurred. --- clang/test/Interpreter/fail.cpp | 11 --- clang/tools/clang-repl/ClangRepl.cpp | 16 +++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/clang/test/Interpreter/fail.cpp b/clang/test/Interpreter/fail.cpp index 4e301f37548f1f..b9035aca3cb7b1 100644 --- a/clang/test/Interpreter/fail.cpp +++ b/clang/test/Interpreter/fail.cpp @@ -1,12 +1,9 @@ -// FIXME: There're some inconsistencies between interactive and non-interactive -// modes. For example, when clang-repl runs in the interactive mode, issues an -// error, and then successfully recovers if we decide it's a success then for -// the non-interactive mode the exit code should be a failure. -// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;" // REQUIRES: host-supports-jit // UNSUPPORTED: system-aix -// RUN: cat %s | not clang-repl | FileCheck %s -BOOM! +// RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;" +// RUN: cat %s | clang-repl | FileCheck %s +// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s +BOOM! // expected-error {{intended to fail the -verify test}} extern "C" int printf(const char *, ...); int i = 42; auto r1 = printf("i = %d\n", i); diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp index aecf61b97fc719..bdc740c33a8f72 100644 --- a/clang/tools/clang-repl/ClangRepl.cpp +++ b/clang/tools/clang-repl/ClangRepl.cpp @@ -215,12 +215,15 @@ int main(int argc, const char **argv) { } else Interp = ExitOnErr(clang::Interpreter::create(std::move(CI))); + bool HasError = false; + for (const std::string &input : OptInputs) { -if (auto Err = Interp->ParseAndExecute(input)) +if (auto Err = Interp->ParseAndExecute(input)) { llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); + HasError = true; +} } - bool HasError = false; if (OptInputs.empty()) { llvm::LineEditor LE("clang-repl"); @@ -241,18 +244,13 @@ int main(int argc, const char **argv) { break; } if (Input == R"(%undo)") { -if (auto Err = Interp->Undo()) { +if (auto Err = Interp->Undo()) llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); - HasError = true; -} } else if (Input.rfind("%lib ", 0) == 0) { -if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) { +if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); - HasError = true; -} } else if (auto Err = Interp->ParseAndExecute(Input)) { llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: "); -HasError = true; } Input = ""; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
https://github.com/whentojump edited https://github.com/llvm/llvm-project/pull/89869 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls (PR #81662)
HighCommander4 wrote: (OpenMP failure still remains to be fixed.) https://github.com/llvm/llvm-project/pull/81662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls (PR #81662)
@@ -3453,6 +3453,10 @@ ExprResult Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, NeedsADL, R.isOverloadedResult(), R.begin(), R.end()); + if (ULE && R.isSingleResult() && R.getFoundDecl()->isInvalidDecl()) { HighCommander4 wrote: Done, thanks https://github.com/llvm/llvm-project/pull/81662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls (PR #81662)
https://github.com/HighCommander4 updated https://github.com/llvm/llvm-project/pull/81662 >From 480cabcfeb42542746026bba753b4170e08bb8ae Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Tue, 13 Feb 2024 12:26:17 -0500 Subject: [PATCH] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls Passing AcceptInvalidDecl=true to BuildDeclarationNameExpr() allows the RecoveryExpr that's constructed to retain a DeclRefExpr pointing to the invalid decl as a child, preserving information about the reference for use by tools such as clangd. Fixes https://github.com/clangd/clangd/issues/1820 --- clang/lib/Sema/SemaExpr.cpp | 6 +- clang/test/AST/ast-dump-recovery.cpp | 6 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 2a0e86c37f1bfc..ee999646a3a218 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2928,7 +2928,7 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS, return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs); } - return BuildDeclarationNameExpr(SS, R, ADL); + return BuildDeclarationNameExpr(SS, R, ADL, /*AcceptInvalidDecl=*/true); } /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified @@ -3453,6 +3453,10 @@ ExprResult Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, NeedsADL, R.isOverloadedResult(), R.begin(), R.end()); + if (R.isSingleResult() && R.getFoundDecl()->isInvalidDecl()) { +return CreateRecoveryExpr(ULE->getBeginLoc(), ULE->getEndLoc(), {ULE}); + } + return ULE; } diff --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp index cfb013585ad744..f628fa913da1e6 100644 --- a/clang/test/AST/ast-dump-recovery.cpp +++ b/clang/test/AST/ast-dump-recovery.cpp @@ -402,6 +402,7 @@ void returnInitListFromVoid() { // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 8 } +void FuncTakingUnknown(Unknown); void RecoveryExprForInvalidDecls(Unknown InvalidDecl) { InvalidDecl + 1; // CHECK: BinaryOperator {{.*}} @@ -411,6 +412,11 @@ void RecoveryExprForInvalidDecls(Unknown InvalidDecl) { InvalidDecl(); // CHECK: CallExpr {{.*}} // CHECK-NEXT: `-RecoveryExpr {{.*}} '' + FuncTakingUnknown(InvalidDecl); + // CHECK: CallExpr {{.*}} '' + // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' + // CHECK-NEXT: `-RecoveryExpr {{.*}} '' + // CHECK-NEXT: `-DeclRefExpr {{.*}} 'InvalidDecl' 'int' } void RecoverToAnInvalidDecl() { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)
https://github.com/HighCommander4 updated https://github.com/llvm/llvm-project/pull/88645 >From c24e79da57fc69d2f353a5533a3cc26313301a71 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sun, 14 Apr 2024 02:41:48 -0400 Subject: [PATCH] [clang][Sema] Preserve the initializer of invalid VarDecls Fixes https://github.com/clangd/clangd/issues/1821 --- clang/lib/Sema/JumpDiagnostics.cpp | 3 ++- clang/lib/Sema/SemaDecl.cpp | 16 +--- clang/test/AST/ast-dump-recovery.cpp | 8 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp index ec3892e92f3c3b..27d5284fdb67e7 100644 --- a/clang/lib/Sema/JumpDiagnostics.cpp +++ b/clang/lib/Sema/JumpDiagnostics.cpp @@ -179,7 +179,8 @@ static ScopePair GetDiagForGotoScopeDecl(Sema &S, const Decl *D) { } const Expr *Init = VD->getInit(); -if (S.Context.getLangOpts().CPlusPlus && VD->hasLocalStorage() && Init) { +if (S.Context.getLangOpts().CPlusPlus && VD->hasLocalStorage() && Init && +!Init->containsErrors()) { // C++11 [stmt.dcl]p3: // A program that jumps from a point where a variable with automatic // storage duration is not in scope to a point where it is in scope diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 9fdd8eb236d1ee..e6eaa98bda98e5 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -13435,15 +13435,16 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc, void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { // If there is no declaration, there was an error parsing it. Just ignore // the initializer. - if (!RealDecl || RealDecl->isInvalidDecl()) { + if (!RealDecl) { CorrectDelayedTyposInExpr(Init, dyn_cast_or_null(RealDecl)); return; } - if (CXXMethodDecl *Method = dyn_cast(RealDecl)) { + if (auto *Method = dyn_cast(RealDecl); + Method && !Method->isInvalidDecl()) { // Pure-specifiers are handled in ActOnPureSpecifier. Diag(Method->getLocation(), diag::err_member_function_initialization) - << Method->getDeclName() << Init->getSourceRange(); +<< Method->getDeclName() << Init->getSourceRange(); Method->setInvalidDecl(); return; } @@ -13456,6 +13457,15 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { return; } + if (VDecl->isInvalidDecl()) { +CorrectDelayedTyposInExpr(Init, VDecl); +ExprResult Recovery = +CreateRecoveryExpr(Init->getBeginLoc(), Init->getEndLoc(), {Init}); +if (Expr *E = Recovery.get()) + VDecl->setInit(E); +return; + } + // WebAssembly tables can't be used to initialise a variable. if (Init && !Init->getType().isNull() && Init->getType()->isWebAssemblyTableType()) { diff --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp index cfb013585ad744..77527743fe8577 100644 --- a/clang/test/AST/ast-dump-recovery.cpp +++ b/clang/test/AST/ast-dump-recovery.cpp @@ -413,6 +413,14 @@ void RecoveryExprForInvalidDecls(Unknown InvalidDecl) { // CHECK-NEXT: `-RecoveryExpr {{.*}} '' } +void InitializerOfInvalidDecl() { + int ValidDecl; + Unkown InvalidDecl = ValidDecl; + // CHECK: VarDecl {{.*}} invalid InvalidDecl + // CHECK-NEXT: `-RecoveryExpr {{.*}} '' contains-errors + // CHECK-NEXT: `-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'ValidDecl' +} + void RecoverToAnInvalidDecl() { Unknown* foo; // invalid decl goo; // the typo was correct to the invalid foo. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)
https://github.com/HighCommander4 edited https://github.com/llvm/llvm-project/pull/88645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)
@@ -13435,16 +13435,18 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc, void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { // If there is no declaration, there was an error parsing it. Just ignore // the initializer. - if (!RealDecl || RealDecl->isInvalidDecl()) { + if (!RealDecl) { CorrectDelayedTyposInExpr(Init, dyn_cast_or_null(RealDecl)); return; } if (CXXMethodDecl *Method = dyn_cast(RealDecl)) { HighCommander4 wrote: Note, I believe in this formulation it needs to be: ``` if (auto *Method = dyn_cast(RealDecl); Method && !Method->isInvalidDecl()) ``` https://github.com/llvm/llvm-project/pull/88645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Wentao Zhang (whentojump) Changes The problematic program is as follows: ```shell #define pre_a 0 #define PRE(x) pre_##x void f(void) { PRE(a) && 0; } int main(void) { return 0; } ``` in which after token concatenation (`##`), there's another nested macro `pre_a`. Currently only the outer expansion region will be produced. ([compiler explorer link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:29,endLineNumber:8,positionColumn:29,positionLineNumber:8,selectionStartColumn:29,selectionStartLineNumber:8,startColumn:29,startLineNumber:8),source:'%23define+pre_a+0%0A%23define+PRE(x)+pre_%23%23x%0A%0Avoid+f(void)+%7B%0APRE(a)+%26%26+0%3B%0A%7D%0A%0Aint+main(void)+%7B+return+0%3B+%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:51.69491525423727,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:cclang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,libs:!(),options:'-fprofile-instr-generate+-fcoverage-mapping+-fcoverage-mcdc+-Xclang+-dump-coverage-mapping+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0')),k:34.5741843594503,l:'4',m:28.903654485049834,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:2,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%232)',t:'0')),header:(),l:'4',m:71.09634551495017,n:'0',o:'',s:0,t:'0')),k:48.30508474576271,l:'3',n:'0',o:'',t:'0')),l:'2',m:100,n:'0',o:'',t:'0')),version:4)) ```text f: File 0, 4:14 -> 6:2 = #0 Decision,File 0, 5:5 -> 5:16 = M:0, C:2 Expansion,File 0, 5:5 -> 5:8 = #0 (Expanded file = 1) File 0, 5:15 -> 5:16 = #1 Branch,File 0, 5:15 -> 5:16 = 0, 0 [2,0,0] File 1, 2:16 -> 2:23 = #0 File 2, 1:15 -> 1:16 = #0 File 2, 1:15 -> 1:16 = #0 Branch,File 2, 1:15 -> 1:16 = 0, 0 [1,2,0] ``` The inner expansion region isn't produced because: 1. In the range-based for loop quoted below, each sloc is processed and possibly emit a corresponding expansion region. 2. For our sloc in question, its direct parent returned by `getIncludeOrExpansionLoc()` is a ``, because that's how `##` is processed. https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L518-L520 3. This ` ` cannot be found in the FileID mapping so `ParentFileID` will be assigned an `std::nullopt` https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L521-L526 4. As a result this iteration of for loop finishes early and no expansion region is added for the sloc. This problem gets worse with MC/DC: as the example shows, there's a branch from File 2 but File 2 itself is missing. This will trigger assertion failures. The fix is more or less a workaround and takes a similar approach as #89573. Depends on #89573. This and #89573 together fix #87000. --- Full diff: https://github.com/llvm/llvm-project/pull/89869.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+29-2) - (modified) clang/test/CoverageMapping/builtinmacro.c (+1-1) - (modified) clang/test/CoverageMapping/macros.c (+5-3) - (added) clang/test/CoverageMapping/mcdc-scratch-space.c (+65) ``diff diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 733686d4946b3c..9268ac5b4c61a3 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -298,6 +298,22 @@ class CoverageMappingBuilder { : SM.getIncludeLoc(SM.getFileID(Loc)); } + /// Find out where the current file is included or macro is expanded. If the + /// found expansion is a , keep looking. + SourceLocation getIncludeOrNonScratchExpansionLoc(SourceLocation Loc) { +if (Loc.isMacroID()) { + Loc = SM.getImmediateExpansionRange(Loc).getBegin(); + while (Loc.isMacroID() && + SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) { +auto ExpansionRange = SM.getImmediateExpansionRange(Loc); +Loc = ExpansionRange.getBegin(); + } +} else { + Loc = SM.getIncludeLoc(SM.getFileID(Loc)); +} +return Loc; + } + /// Return true if \c Loc is a location in a built-in macro. bool isInBuiltin(SourceLocation Loc) { return SM.getBufferName(SM.getSpellingLoc(Loc)) == ""; @@ -339,8 +355,18 @@ class CoverageMappingBuilder { ll
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Wentao Zhang (whentojump) Changes The problematic program is as follows: ```shell #define pre_a 0 #define PRE(x) pre_##x void f(void) { PRE(a) && 0; } int main(void) { return 0; } ``` in which after token concatenation (`##`), there's another nested macro `pre_a`. Currently only the outer expansion region will be produced. ([compiler explorer link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:29,endLineNumber:8,positionColumn:29,positionLineNumber:8,selectionStartColumn:29,selectionStartLineNumber:8,startColumn:29,startLineNumber:8),source:'%23define+pre_a+0%0A%23define+PRE(x)+pre_%23%23x%0A%0Avoid+f(void)+%7B%0APRE(a)+%26%26+0%3B%0A%7D%0A%0Aint+main(void)+%7B+return+0%3B+%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:51.69491525423727,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:cclang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,libs:!(),options:'-fprofile-instr-generate+-fcoverage-mapping+-fcoverage-mcdc+-Xclang+-dump-coverage-mapping+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0')),k:34.5741843594503,l:'4',m:28.903654485049834,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:2,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%232)',t:'0')),header:(),l:'4',m:71.09634551495017,n:'0',o:'',s:0,t:'0')),k:48.30508474576271,l:'3',n:'0',o:'',t:'0')),l:'2',m:100,n:'0',o:'',t:'0')),version:4)) ```text f: File 0, 4:14 -> 6:2 = #0 Decision,File 0, 5:5 -> 5:16 = M:0, C:2 Expansion,File 0, 5:5 -> 5:8 = #0 (Expanded file = 1) File 0, 5:15 -> 5:16 = #1 Branch,File 0, 5:15 -> 5:16 = 0, 0 [2,0,0] File 1, 2:16 -> 2:23 = #0 File 2, 1:15 -> 1:16 = #0 File 2, 1:15 -> 1:16 = #0 Branch,File 2, 1:15 -> 1:16 = 0, 0 [1,2,0] ``` The inner expansion region isn't produced because: 1. In the range-based for loop quoted below, each sloc is processed and possibly emit a corresponding expansion region. 2. For our sloc in question, its direct parent returned by `getIncludeOrExpansionLoc()` is a ``, because that's how `##` is processed. https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L518-L520 3. This ` ` cannot be found in the FileID mapping so `ParentFileID` will be assigned an `std::nullopt` https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L521-L526 4. As a result this iteration of for loop finishes early and no expansion region is added for the sloc. This problem gets worse with MC/DC: as the example shows, there's a branch from File 2 but File 2 itself is missing. This will trigger assertion failures. The fix is more or less a workaround and takes a similar approach as #89573. Depends on #89573. This and #89573 together fix #87000. --- Full diff: https://github.com/llvm/llvm-project/pull/89869.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+29-2) - (modified) clang/test/CoverageMapping/builtinmacro.c (+1-1) - (modified) clang/test/CoverageMapping/macros.c (+5-3) - (added) clang/test/CoverageMapping/mcdc-scratch-space.c (+65) ``diff diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 733686d4946b3c..9268ac5b4c61a3 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -298,6 +298,22 @@ class CoverageMappingBuilder { : SM.getIncludeLoc(SM.getFileID(Loc)); } + /// Find out where the current file is included or macro is expanded. If the + /// found expansion is a , keep looking. + SourceLocation getIncludeOrNonScratchExpansionLoc(SourceLocation Loc) { +if (Loc.isMacroID()) { + Loc = SM.getImmediateExpansionRange(Loc).getBegin(); + while (Loc.isMacroID() && + SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) { +auto ExpansionRange = SM.getImmediateExpansionRange(Loc); +Loc = ExpansionRange.getBegin(); + } +} else { + Loc = SM.getIncludeLoc(SM.getFileID(Loc)); +} +return Loc; + } + /// Return true if \c Loc is a location in a built-in macro. bool isInBuiltin(SourceLocation Loc) { return SM.getBufferName(SM.getSpellingLoc(Loc)) == ""; @@ -339,8 +355,18 @@ class CoverageMappingBuilder {
[clang] [Clang][AArch64] Extend diagnostics when warning non/streaming about … (PR #88380)
https://github.com/sdesmalen-arm approved this pull request. https://github.com/llvm/llvm-project/pull/88380 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)
https://github.com/aheejin updated https://github.com/llvm/llvm-project/pull/80923 >From d6fd48794112d6c140024d7cd55b5fe5e55e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 6 Feb 2024 00:31:59 + Subject: [PATCH 1/5] [WebAssembly] Add more features to generic CPU config This enables nontrapping-fptoint, multivlaue, reference-types, and bulk-memory in `-mcpu=generic` configuration. These proposals have been standardized and supported in all major browsers for several years at this point: https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md --- clang/docs/ReleaseNotes.rst| 4 clang/lib/Basic/Targets/WebAssembly.cpp| 18 -- clang/test/Preprocessor/wasm-target-features.c | 8 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 802c44b6c86080..5a07dcca106876 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -259,6 +259,10 @@ AIX Support WebAssembly Support ^^^ +The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue, +reference-types, and bulk-memory.These proposals are standardized and available +in all major engines. + AVR Support ^^^ diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp index f1c925d90cb649..38fe4013090f40 100644 --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -147,19 +147,25 @@ void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap &Features, bool WebAssemblyTargetInfo::initFeatureMap( llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector &FeaturesVec) const { - if (CPU == "bleeding-edge") { -Features["nontrapping-fptoint"] = true; + auto addGenericFeatures = [&]() { Features["sign-ext"] = true; +Features["mutable-globals"] = true; +Features["nontrapping-fptoint"] = true; Features["bulk-memory"] = true; +Features["reference-types"] = true; +Features["multivalue"] = true; + }; + auto addBleedingEdgeFeatures = [&]() { Features["atomics"] = true; -Features["mutable-globals"] = true; Features["tail-call"] = true; -Features["reference-types"] = true; Features["multimemory"] = true; setSIMDLevel(Features, SIMD128, true); + }; + if (CPU == "bleeding-edge") { +addGenericFeatures(); +addBleedingEdgeFeatures(); } else if (CPU == "generic") { -Features["sign-ext"] = true; -Features["mutable-globals"] = true; +addGenericFeatures(); } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c index eccd432aa8eee6..5834e6d183bc9c 100644 --- a/clang/test/Preprocessor/wasm-target-features.c +++ b/clang/test/Preprocessor/wasm-target-features.c @@ -155,15 +155,15 @@ // // GENERIC-DAG:#define __wasm_sign_ext__ 1{{$}} // GENERIC-DAG:#define __wasm_mutable_globals__ 1{{$}} -// GENERIC-NOT:#define __wasm_nontrapping_fptoint__ 1{{$}} -// GENERIC-NOT:#define __wasm_bulk_memory__ 1{{$}} +// GENERIC-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}} +// GENERIC-DAG:#define __wasm_bulk_memory__ 1{{$}} +// GENERIC-DAG:#define __wasm_multivalue__ 1{{$}} +// GENERIC-DAG:#define __wasm_reference_types__ 1{{$}} // GENERIC-NOT:#define __wasm_simd128__ 1{{$}} // GENERIC-NOT:#define __wasm_atomics__ 1{{$}} // GENERIC-NOT:#define __wasm_tail_call__ 1{{$}} // GENERIC-NOT:#define __wasm_multimemory__ 1{{$}} // GENERIC-NOT:#define __wasm_exception_handling__ 1{{$}} -// GENERIC-NOT:#define __wasm_multivalue__ 1{{$}} -// GENERIC-NOT:#define __wasm_reference_types__ 1{{$}} // GENERIC-NOT:#define __wasm_extended_const__ 1{{$}} // RUN: %clang -E -dM %s -o - 2>&1 \ >From 01ac8bd38aaa86e62b00709790a36e050528f853 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 23 Feb 2024 00:31:41 + Subject: [PATCH 2/5] Mention that ABI is not turned on --- clang/docs/ReleaseNotes.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 5a07dcca106876..ec85d8882c1861 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -261,7 +261,8 @@ WebAssembly Support The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue, reference-types, and bulk-memory.These proposals are standardized and available -in all major engines. +in all major engines. Enabling multivalue here only enables the language feature +but does not turn on the multivalue ABI. AVR Support ^^^ >From de6aa6aa0891bb11ae7402d2cbccbcd82cd4fc77 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 23 Apr 2024 13:21:15 + Subject: [PATCH 3/5] Enable only multivalue and reference types --- clang/docs/ReleaseNotes.rst
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
https://github.com/whentojump ready_for_review https://github.com/llvm/llvm-project/pull/89869 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ARM] Armv8-R does not require fp64 or neon. (PR #88287)
davemgreen wrote: I'm not sure I would make this change, mostly due to it potentially causing a break for existing users and making performance worse, but can see the reasoning. I am willing to defer to others if they have an opinion. https://github.com/llvm/llvm-project/pull/88287 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions (PR #89867)
https://github.com/topperc approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/89867 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
@@ -8343,58 +8343,52 @@ bool Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, // C++1z [temp.arg.template]p3: (DR 150) // A template-argument matches a template template-parameter P when P // is at least as specialized as the template-argument A. - // FIXME: We should enable RelaxedTemplateTemplateArgs by default as it is a - // defect report resolution from C++17 and shouldn't be introduced by - // concepts. - if (getLangOpts().RelaxedTemplateTemplateArgs) { cor3ntin wrote: I also wonder if, at least for the time being, we should leave C++03 alone (despite the paper being a DR) https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
@@ -507,10 +507,62 @@ static TemplateDeductionResult DeduceNonTypeTemplateArgument( S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced); } +static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A, + TemplateArgument Default) { + switch (A->getKind()) { + case Decl::TemplateTypeParm: { +auto *T = cast(A); +// FIXME: DefaultArgument can't represent a pack. +if (T->isParameterPack()) cor3ntin wrote: Should we assert here? https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
@@ -519,13 +571,45 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, return TemplateDeductionResult::Success; } - if (TemplateTemplateParmDecl *TempParam -= dyn_cast(ParamDecl)) { + if (auto *TempParam = dyn_cast(ParamDecl)) { // If we're not deducing at this depth, there's nothing to deduce. if (TempParam->getDepth() != Info.getDeducedDepth()) return TemplateDeductionResult::Success; -DeducedTemplateArgument NewDeduced(S.Context.getCanonicalTemplateName(Arg)); +auto NewDeduced = DeducedTemplateArgument(Arg); +// Provisional resolution for CWG2398: If Arg is also a template template +// param, and it names a template specialization, then we deduce a +// synthesized template template parameter based on A, but using the TS's +// arguments as defaults. +if (auto *TempArg = dyn_cast_or_null( +Arg.getAsTemplateDecl())) { + assert(Arg.getKind() == TemplateName::Template); + assert(!TempArg->isExpandedParameterPack()); + + TemplateParameterList *As = TempArg->getTemplateParameters(); + if (DefaultArguments.size() != 0) { +assert(DefaultArguments.size() <= As->size()); +SmallVector Params(As->size()); +for (unsigned I = 0; I < DefaultArguments.size(); ++I) + Params[I] = + DeduceTemplateArguments(S, As->getParam(I), DefaultArguments[I]); +for (unsigned I = DefaultArguments.size(); I < As->size(); ++I) + Params[I] = As->getParam(I); +// FIXME: We could unique these, and also the parameters, but we don't +// expect programs to contain a large enough amount of these deductions +// for that to be worthwhile. cor3ntin wrote: Double checking: These parameters are only used for deduction, so not unique them would not affect type identity? https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
@@ -507,10 +507,62 @@ static TemplateDeductionResult DeduceNonTypeTemplateArgument( S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced); } +static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A, + TemplateArgument Default) { + switch (A->getKind()) { + case Decl::TemplateTypeParm: { +auto *T = cast(A); +// FIXME: DefaultArgument can't represent a pack. +if (T->isParameterPack()) + return A; +auto *R = TemplateTypeParmDecl::Create( +S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(), +T->getDepth(), T->getIndex(), T->getIdentifier(), +T->wasDeclaredWithTypename(), /*ParameterPack=*/false, +T->hasTypeConstraint()); +R->setDefaultArgument( +S.Context.getTrivialTypeSourceInfo(Default.getAsType())); +if (R->hasTypeConstraint()) { + auto *C = R->getTypeConstraint(); + R->setTypeConstraint(C->getConceptReference(), + C->getImmediatelyDeclaredConstraint()); cor3ntin wrote: We probably want tests for constrainted declarations https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
@@ -507,10 +507,62 @@ static TemplateDeductionResult DeduceNonTypeTemplateArgument( S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced); } +static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A, + TemplateArgument Default) { + switch (A->getKind()) { + case Decl::TemplateTypeParm: { +auto *T = cast(A); +// FIXME: DefaultArgument can't represent a pack. +if (T->isParameterPack()) + return A; +auto *R = TemplateTypeParmDecl::Create( +S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(), +T->getDepth(), T->getIndex(), T->getIdentifier(), +T->wasDeclaredWithTypename(), /*ParameterPack=*/false, +T->hasTypeConstraint()); +R->setDefaultArgument( +S.Context.getTrivialTypeSourceInfo(Default.getAsType())); +if (R->hasTypeConstraint()) { + auto *C = R->getTypeConstraint(); + R->setTypeConstraint(C->getConceptReference(), + C->getImmediatelyDeclaredConstraint()); +} +return R; + } + case Decl::NonTypeTemplateParm: { +auto *T = cast(A); +// FIXME: DefaultArgument can't represent a pack. +if (T->isParameterPack()) + return A; +auto *R = NonTypeTemplateParmDecl::Create( +S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(), +T->getDepth(), T->getIndex(), T->getIdentifier(), T->getType(), +/*ParameterPack=*/false, T->getTypeSourceInfo()); +R->setDefaultArgument(Default.getAsExpr()); +if (auto *PTC = T->getPlaceholderTypeConstraint()) + R->setPlaceholderTypeConstraint(PTC); +return R; + } + case Decl::TemplateTemplateParm: { cor3ntin wrote: I don't see how the `TemplateTemplateParm` case is ever used, right? https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
@@ -1133,8 +1133,8 @@ C++17 implementation status Matching template template parameters to compatible arguments - https://wg21.link/p0522r0";>P0522R0 - Partial (10) + https://wg21.link/p0522r0";>P0522R0 (DR) + Clang 4 (10) cor3ntin wrote: ```suggestion Clang 19(10) ``` Even if we previously had an some implementation it was well hidden :) I think there is value in keeping the note. But the note might change as we want to keep a way to disable the new behavior. https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
@@ -507,10 +507,62 @@ static TemplateDeductionResult DeduceNonTypeTemplateArgument( S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced); } +static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A, cor3ntin wrote: This definitely needs a comment. The name should probably be along the lines of "SynthesizeTemplateArgumentWithDefaultArg" https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
https://github.com/cor3ntin commented: I'm pretty happy with the direction this is going in. I'd like to see the specific test in https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2398, the ones we exchanged by mails and some tests with constraints https://github.com/llvm/llvm-project/pull/89807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
https://github.com/whentojump edited https://github.com/llvm/llvm-project/pull/89869 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
@@ -2824,8 +2827,12 @@ bool RISCVAsmParser::parseDirectiveOption() { break; } - auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch); - if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch || + std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch); yetingk wrote: Done. https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
https://github.com/yetingk updated https://github.com/llvm/llvm-project/pull/89727 >From a43014cf3daa1b0fd9092bfe41da979205ba64aa Mon Sep 17 00:00:00 2001 From: Yeting Kuo Date: Tue, 23 Apr 2024 02:16:04 -0700 Subject: [PATCH 1/3] [RISCV] Teach .option arch to support experimental extensions. Previously .option arch denied extenions are not belongs to RISC-V features. But experimental features have experimental- prefix, so .option arch can not serve for experimental extension. This patch uses the features of extensions to identify extension existance. --- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 7 --- llvm/test/MC/RISCV/option-arch.s | 9 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 3f4a73ad89bf8a..80ff70f1095f4c 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -2824,8 +2824,9 @@ bool RISCVAsmParser::parseDirectiveOption() { break; } - auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch); - if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch || + std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch); + auto Ext = llvm::lower_bound(RISCVFeatureKV, Feature); + if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Feature || !RISCVISAInfo::isSupportedExtension(Arch)) { if (isDigit(Arch.back())) return Error( @@ -2834,7 +2835,7 @@ bool RISCVAsmParser::parseDirectiveOption() { return Error(Loc, "unknown extension feature"); } - Args.emplace_back(Type, Ext->Key); + Args.emplace_back(Type, Arch.str()); if (Type == RISCVOptionArchArgType::Plus) { FeatureBitset OldFeatureBits = STI->getFeatureBits(); diff --git a/llvm/test/MC/RISCV/option-arch.s b/llvm/test/MC/RISCV/option-arch.s index 6ee133c7159a27..40675f9e4b434b 100644 --- a/llvm/test/MC/RISCV/option-arch.s +++ b/llvm/test/MC/RISCV/option-arch.s @@ -1,7 +1,7 @@ # RUN: llvm-mc -triple riscv32 -show-encoding < %s \ # RUN: | FileCheck -check-prefixes=CHECK %s # RUN: llvm-mc -triple riscv32 -filetype=obj < %s \ -# RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba -d -M no-aliases - \ +# RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \ # RUN: | FileCheck -check-prefixes=CHECK-INST %s # Test '.option arch, +' and '.option arch, -' directive @@ -78,6 +78,13 @@ lr.w t0, (t1) # CHECK: encoding: [0xb3,0x22,0x73,0x20] sh1add t0, t1, t2 +# Test experimental extension +# CHECK: .option arch, +zicfiss +.option arch, +zicfiss +# CHECK-INST: sspopchk ra +# CHECK: encoding: [0x73,0xc0,0xc0,0xcd] +sspopchk ra + # Test '.option arch, ' directive # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0 .option arch, rv32i2p1_m2p0_a2p1_c2p0 >From 471abce617a9d18ef91370303eef90bab228d9d3 Mon Sep 17 00:00:00 2001 From: Yeting Kuo Date: Tue, 23 Apr 2024 21:55:12 -0700 Subject: [PATCH 2/3] Make this pr obey menable-experimental-extensions. --- clang/lib/Driver/ToolChains/Clang.cpp | 5 + clang/test/Driver/riscv-option-arch.s | 5 + llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 6 ++ 3 files changed, 16 insertions(+) create mode 100644 clang/test/Driver/riscv-option-arch.s diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 5894a48e0e378b..8b0f523763486f 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8449,6 +8449,11 @@ void ClangAs::AddRISCVTargetArgs(const ArgList &Args, CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-riscv-add-build-attributes"); } + + if (!Args.hasArg(options::OPT_menable_experimental_extensions)) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back("-riscv-disable-experimental-ext"); + } } void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/test/Driver/riscv-option-arch.s b/clang/test/Driver/riscv-option-arch.s new file mode 100644 index 00..8ce84dd8ffe79d --- /dev/null +++ b/clang/test/Driver/riscv-option-arch.s @@ -0,0 +1,5 @@ +# RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o /dev/null %s +# RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck -check-prefixes=CHECK-ERR %s + +.option arch, +zicfiss +# CHECK-ERR: Unexpected experimental extensions. diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 80ff70f1095f4c..6225e0707015fe 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed, static cl::opt AddBuildAttributes("riscv-add-
[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)
@@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const BinaryOperator *E, // If during the evaluation of an expression, the result is not // mathematically defined [...], the behavior is undefined. // FIXME: C++ rules require us to not conform to IEEE 754 here. - if (LHS.isNaN()) { + if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) { frederick-vs-ja wrote: There's an open CWG issue ([CWG2168](https://cplusplus.github.io/CWG/issues/2168.html)) about this. https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
@@ -2824,8 +2827,12 @@ bool RISCVAsmParser::parseDirectiveOption() { break; } - auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch); - if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch || + std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch); topperc wrote: I think you should just use `std::string Feature`. I think `std::string &&Feature` will just make a reference to a hidden temporary object. https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
https://github.com/yetingk edited https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
https://github.com/yetingk edited https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
@@ -2824,8 +2827,12 @@ bool RISCVAsmParser::parseDirectiveOption() { break; } - auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch); - if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch || + std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch); yetingk wrote: I think it might less call a string constructor() and just use the return string value. https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h (PR #89873)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Chuanqi Xu (ChuanqiXu9) Changes Previously, the DeclID is defined in serialization/ASTBitCodes.h under clang::serialization namespace. However, actually the DeclID is not purely used in serialization part. The DeclID is already widely used in AST and all around the clang project via classes like `LazyPtrDecl` or calling `ExternalASTSource::getExernalDecl()`. All such uses are via the raw underlying type of `DeclID` as `uint32_t`. This is not pretty good. This patch moves the DeclID class family to a new header `AST/DeclID.h` so that the whole project can use the wrapped class `DeclID`, `GlobalDeclID` and `LocalDeclID` instead of the raw underlying type. This can improve the readability and the type safety. --- Patch is 93.07 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/89873.diff 31 Files Affected: - (modified) clang/include/clang/AST/ASTContext.h (+2-2) - (modified) clang/include/clang/AST/DeclBase.h (+1-3) - (added) clang/include/clang/AST/DeclID.h (+175) - (modified) clang/include/clang/AST/DeclTemplate.h (+1-1) - (modified) clang/include/clang/AST/ExternalASTSource.h (+2-2) - (modified) clang/include/clang/Frontend/ASTUnit.h (+1-1) - (modified) clang/include/clang/Frontend/MultiplexConsumer.h (+1-1) - (modified) clang/include/clang/Sema/MultiplexExternalSemaSource.h (+1-1) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+4-157) - (modified) clang/include/clang/Serialization/ASTDeserializationListener.h (+1-1) - (modified) clang/include/clang/Serialization/ASTReader.h (+54-72) - (modified) clang/include/clang/Serialization/ASTRecordReader.h (+2-4) - (modified) clang/include/clang/Serialization/ASTWriter.h (+10-12) - (modified) clang/include/clang/Serialization/ModuleFile.h (+4-4) - (modified) clang/lib/AST/ASTContext.cpp (+1-2) - (modified) clang/lib/AST/Decl.cpp (+23-23) - (modified) clang/lib/AST/DeclBase.cpp (+2-2) - (modified) clang/lib/AST/DeclCXX.cpp (+30-33) - (modified) clang/lib/AST/DeclFriend.cpp (+1-1) - (modified) clang/lib/AST/DeclObjC.cpp (+12-12) - (modified) clang/lib/AST/DeclOpenMP.cpp (+8-10) - (modified) clang/lib/AST/DeclTemplate.cpp (+19-22) - (modified) clang/lib/AST/ExternalASTSource.cpp (+1-1) - (modified) clang/lib/Frontend/ASTUnit.cpp (+2-2) - (modified) clang/lib/Frontend/FrontendAction.cpp (+3-3) - (modified) clang/lib/Frontend/MultiplexConsumer.cpp (+1-2) - (modified) clang/lib/Sema/MultiplexExternalSemaSource.cpp (+1-1) - (modified) clang/lib/Serialization/ASTReader.cpp (+7-9) - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+8-10) - (modified) clang/lib/Serialization/ASTWriter.cpp (+2-2) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+2-2) ``diff diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index d5ed20ff50157d..ecec9bfcf30079 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -455,7 +455,7 @@ class ASTContext : public RefCountedBase { /// initialization of another module). struct PerModuleInitializers { llvm::SmallVector Initializers; -llvm::SmallVector LazyInitializers; +llvm::SmallVector LazyInitializers; void resolve(ASTContext &Ctx); }; @@ -1059,7 +1059,7 @@ class ASTContext : public RefCountedBase { /// or an ImportDecl nominating another module that has initializers. void addModuleInitializer(Module *M, Decl *Init); - void addLazyModuleInitializers(Module *M, ArrayRef IDs); + void addLazyModuleInitializers(Module *M, ArrayRef IDs); /// Get the initializations to perform when importing a module, if any. ArrayRef getModuleInitializers(Module *M); diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index d8cafc3d81526e..474e51c1df6d68 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -15,6 +15,7 @@ #include "clang/AST/ASTDumperUtils.h" #include "clang/AST/AttrIterator.h" +#include "clang/AST/DeclID.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/SelectorLocationsKind.h" #include "clang/Basic/IdentifierTable.h" @@ -239,9 +240,6 @@ class alignas(8) Decl { ModulePrivate }; - /// An ID number that refers to a declaration in an AST file. - using DeclID = uint32_t; - protected: /// The next declaration within the same lexical /// DeclContext. These pointers form the linked list that is diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h new file mode 100644 index 00..37e40e198f2776 --- /dev/null +++ b/clang/include/clang/AST/DeclID.h @@ -0,0 +1,175 @@ +//===--- DeclID.h - ID number for deserialized declarations *- 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-Id
[clang] [NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h (PR #89873)
https://github.com/ChuanqiXu9 ready_for_review https://github.com/llvm/llvm-project/pull/89873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h (PR #89873)
https://github.com/ChuanqiXu9 created https://github.com/llvm/llvm-project/pull/89873 Previously, the DeclID is defined in serialization/ASTBitCodes.h under clang::serialization namespace. However, actually the DeclID is not purely used in serialization part. The DeclID is already widely used in AST and all around the clang project via classes like `LazyPtrDecl` or calling `ExternalASTSource::getExernalDecl()`. All such uses are via the raw underlying type of `DeclID` as `uint32_t`. This is not pretty good. This patch moves the DeclID class family to a new header `AST/DeclID.h` so that the whole project can use the wrapped class `DeclID`, `GlobalDeclID` and `LocalDeclID` instead of the raw underlying type. This can improve the readability and the type safety. >From 3c8e76dcf7746d7ede5434e0fbf025802590bd68 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Wed, 24 Apr 2024 13:35:01 +0800 Subject: [PATCH] [NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h Previously, the DeclID is defined in serialization/ASTBitCodes.h under clang::serialization namespace. However, actually the DeclID is not purely used in serialization part. The DeclID is already widely used in AST and all around the clang project via classes like `LazyPtrDecl` or calling `ExternalASTSource::getExernalDecl()`. All such uses are via the raw underlying type of `DeclID` as `uint32_t`. This is not pretty good. This patch moves the DeclID class family to a new header `AST/DeclID.h` so that the whole project can use the wrapped class `DeclID`, `GlobalDeclID` and `LocalDeclID` instead of the raw underlying type. This can improve the readability and the type safety. --- clang/include/clang/AST/ASTContext.h | 4 +- clang/include/clang/AST/DeclBase.h| 4 +- clang/include/clang/AST/DeclID.h | 175 ++ clang/include/clang/AST/DeclTemplate.h| 2 +- clang/include/clang/AST/ExternalASTSource.h | 4 +- clang/include/clang/Frontend/ASTUnit.h| 2 +- .../clang/Frontend/MultiplexConsumer.h| 2 +- .../clang/Sema/MultiplexExternalSemaSource.h | 2 +- .../include/clang/Serialization/ASTBitCodes.h | 161 +--- .../ASTDeserializationListener.h | 2 +- clang/include/clang/Serialization/ASTReader.h | 126 ++--- .../clang/Serialization/ASTRecordReader.h | 6 +- clang/include/clang/Serialization/ASTWriter.h | 22 +-- .../include/clang/Serialization/ModuleFile.h | 8 +- clang/lib/AST/ASTContext.cpp | 3 +- clang/lib/AST/Decl.cpp| 46 ++--- clang/lib/AST/DeclBase.cpp| 4 +- clang/lib/AST/DeclCXX.cpp | 63 +++ clang/lib/AST/DeclFriend.cpp | 2 +- clang/lib/AST/DeclObjC.cpp| 24 +-- clang/lib/AST/DeclOpenMP.cpp | 18 +- clang/lib/AST/DeclTemplate.cpp| 41 ++-- clang/lib/AST/ExternalASTSource.cpp | 2 +- clang/lib/Frontend/ASTUnit.cpp| 4 +- clang/lib/Frontend/FrontendAction.cpp | 6 +- clang/lib/Frontend/MultiplexConsumer.cpp | 3 +- .../lib/Sema/MultiplexExternalSemaSource.cpp | 2 +- clang/lib/Serialization/ASTReader.cpp | 16 +- clang/lib/Serialization/ASTReaderDecl.cpp | 18 +- clang/lib/Serialization/ASTWriter.cpp | 4 +- clang/lib/Serialization/ASTWriterDecl.cpp | 4 +- 31 files changed, 382 insertions(+), 398 deletions(-) create mode 100644 clang/include/clang/AST/DeclID.h diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index d5ed20ff50157d..ecec9bfcf30079 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -455,7 +455,7 @@ class ASTContext : public RefCountedBase { /// initialization of another module). struct PerModuleInitializers { llvm::SmallVector Initializers; -llvm::SmallVector LazyInitializers; +llvm::SmallVector LazyInitializers; void resolve(ASTContext &Ctx); }; @@ -1059,7 +1059,7 @@ class ASTContext : public RefCountedBase { /// or an ImportDecl nominating another module that has initializers. void addModuleInitializer(Module *M, Decl *Init); - void addLazyModuleInitializers(Module *M, ArrayRef IDs); + void addLazyModuleInitializers(Module *M, ArrayRef IDs); /// Get the initializations to perform when importing a module, if any. ArrayRef getModuleInitializers(Module *M); diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index d8cafc3d81526e..474e51c1df6d68 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -15,6 +15,7 @@ #include "clang/AST/ASTDumperUtils.h" #include "clang/AST/AttrIterator.h" +#include "clang/AST/DeclID.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/SelectorLocationsKind.h" #include "clang/Basic/Identifie
[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)
@@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo &Info, const BinaryOperator *E, // If during the evaluation of an expression, the result is not // mathematically defined [...], the behavior is undefined. // FIXME: C++ rules require us to not conform to IEEE 754 here. - if (LHS.isNaN()) { + if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) { cor3ntin wrote: > My understanding of the intended design was that operations producing NaNs > from non-NaNs in C++ What is "operation" here? NaN in arithmetics / conversions / other core language etc are one thing, but when calling a function which is specifically specified to produce NaN in some cases... it's very unclear to me that the program should be invalid. If that's the intent, is there anywhere where it would be documented? https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][PAC][clang][ELF] Support PAuth ABI core info (PR #85235)
@@ -0,0 +1,59 @@ +// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ kovdan01 wrote: Fixed, thanks, see fdb26a14024f5f8297480a74982a37ee988cd30f https://github.com/llvm/llvm-project/pull/85235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][PAC][clang][ELF] Support PAuth ABI core info (PR #85235)
https://github.com/kovdan01 updated https://github.com/llvm/llvm-project/pull/85235 >From 919af72c09216838bfe586c3da503f5d74104a7d Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Tue, 19 Mar 2024 23:57:06 +0300 Subject: [PATCH 1/8] [PAC][clang] Define ptrauth driver flags and preprocessor features Define the following clang driver flags: - `-fptrauth-intrinsics`: `PointerAuth.intrinsics()` in `LangOptions`, `ptrauth_intrinsics` preprocessor feature; - `-fptrauth-calls`: `PointerAuth.calls()` in `LangOptions`, `ptrauth_calls` and and `ptrauth_member_function_pointer_type_discrimination` preprocessor features; - `-fptrauth-returns`: `PointerAuth.returns()` in `LangOptions`, `ptrauth_returns` preprocessor feature; - `-fptrauth-auth-traps`: `PointerAuth.authTraps()` in `LangOptions`; - `-fptrauth-vtable-pointer-address-discrimination`: `PointerAuth.vtptrAddressDiscrimination()` in `LangOptions`, `ptrauth_vtable_pointer_address_discrimination` preprocessor feature; - `-fptrauth-vtable-pointer-type-discrimination`: `PointerAuth.vtptrTypeDiscrimination()` in `LangOptions`, `ptrauth_vtable_pointer_type_discrimination` preprocessor feature; - `-fptrauth-init-fini`: `PointerAuth.initFini()` in `LangOptions`, `ptrauth_init_fini` preprocessor feature. The patch only defines the flags and having corresponding `LangOptions` set does not affect codegen yet. Co-authored-by: Ahmed Bougacha --- clang/include/clang/Basic/Features.def| 6 ++ clang/include/clang/Basic/LangOptions.def | 6 ++ clang/include/clang/Driver/Options.td | 18 clang/lib/Driver/ToolChains/Clang.cpp | 27 ++ clang/lib/Frontend/CompilerInvocation.cpp | 20 clang/test/Driver/ptrauth.c | 32 +++ clang/test/Preprocessor/ptrauth_feature.c | 107 +- 7 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 clang/test/Driver/ptrauth.c diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def index eeed5f4751f2f4..1c6236aa4f9748 100644 --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -102,6 +102,12 @@ FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread)) FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow)) FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo)) FEATURE(ptrauth_intrinsics, LangOpts.PointerAuthIntrinsics) +FEATURE(ptrauth_calls, LangOpts.PointerAuthCalls) +FEATURE(ptrauth_returns, LangOpts.PointerAuthReturns) +FEATURE(ptrauth_vtable_pointer_address_discrimination, LangOpts.PointerAuthVTPtrAddressDiscrimination) +FEATURE(ptrauth_vtable_pointer_type_discrimination, LangOpts.PointerAuthVTPtrTypeDiscrimination) +FEATURE(ptrauth_member_function_pointer_type_discrimination, LangOpts.PointerAuthCalls) +FEATURE(ptrauth_init_fini, LangOpts.PointerAuthInitFini) FEATURE(swiftasynccc, PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) == clang::TargetInfo::CCCR_OK) diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 8ef6700ecdc78e..4b99e70298462f 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -162,6 +162,12 @@ LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of template t LANGOPT(ExperimentalLibrary, 1, 0, "enable unstable and experimental library features") LANGOPT(PointerAuthIntrinsics, 1, 0, "pointer authentication intrinsics") +LANGOPT(PointerAuthCalls , 1, 0, "function pointer authentication") +LANGOPT(PointerAuthReturns, 1, 0, "return pointer authentication") +LANGOPT(PointerAuthAuthTraps, 1, 0, "pointer authentication failure traps") +LANGOPT(PointerAuthVTPtrAddressDiscrimination, 1, 0, "incorporate address discrimination in authenticated vtable pointers") +LANGOPT(PointerAuthVTPtrTypeDiscrimination, 1, 0, "incorporate type discrimination in authenticated vtable pointers") +LANGOPT(PointerAuthInitFini, 1, 0, "sign function pointers in init/fini arrays") LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for all language standard modes") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 29c226f4bd8da7..e624eed2a15316 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4110,8 +4110,26 @@ let Group = f_Group in { let Visibility = [ClangOption,CC1Option] in { def fptrauth_intrinsics : Flag<["-"], "fptrauth-intrinsics">, HelpText<"Enable pointer authentication intrinsics">; +def fptrauth_calls : Flag<["-"], "fptrauth-calls">, + HelpText<"Enable signing and authentication of all indirect calls">; +def fptrauth_returns : Flag<["-"], "fptrauth-returns">, + HelpText<"Enable signing and authentication of return addresses">; +def fptrauth_auth_traps : Flag<["-"], "fptrauth-auth-traps">, + Hel
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
@@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed, static cl::opt AddBuildAttributes("riscv-add-build-attributes", cl::init(false)); +static cl::opt +DisableExperimentalExtension("riscv-disable-experimental-ext", yetingk wrote: Since only clang needs specific option to allows experimental extensions. https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)
https://github.com/aheejin updated https://github.com/llvm/llvm-project/pull/80923 >From d6fd48794112d6c140024d7cd55b5fe5e55e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 6 Feb 2024 00:31:59 + Subject: [PATCH 1/5] [WebAssembly] Add more features to generic CPU config This enables nontrapping-fptoint, multivlaue, reference-types, and bulk-memory in `-mcpu=generic` configuration. These proposals have been standardized and supported in all major browsers for several years at this point: https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md --- clang/docs/ReleaseNotes.rst| 4 clang/lib/Basic/Targets/WebAssembly.cpp| 18 -- clang/test/Preprocessor/wasm-target-features.c | 8 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 802c44b6c86080..5a07dcca106876 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -259,6 +259,10 @@ AIX Support WebAssembly Support ^^^ +The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue, +reference-types, and bulk-memory.These proposals are standardized and available +in all major engines. + AVR Support ^^^ diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp index f1c925d90cb649..38fe4013090f40 100644 --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -147,19 +147,25 @@ void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap &Features, bool WebAssemblyTargetInfo::initFeatureMap( llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector &FeaturesVec) const { - if (CPU == "bleeding-edge") { -Features["nontrapping-fptoint"] = true; + auto addGenericFeatures = [&]() { Features["sign-ext"] = true; +Features["mutable-globals"] = true; +Features["nontrapping-fptoint"] = true; Features["bulk-memory"] = true; +Features["reference-types"] = true; +Features["multivalue"] = true; + }; + auto addBleedingEdgeFeatures = [&]() { Features["atomics"] = true; -Features["mutable-globals"] = true; Features["tail-call"] = true; -Features["reference-types"] = true; Features["multimemory"] = true; setSIMDLevel(Features, SIMD128, true); + }; + if (CPU == "bleeding-edge") { +addGenericFeatures(); +addBleedingEdgeFeatures(); } else if (CPU == "generic") { -Features["sign-ext"] = true; -Features["mutable-globals"] = true; +addGenericFeatures(); } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c index eccd432aa8eee6..5834e6d183bc9c 100644 --- a/clang/test/Preprocessor/wasm-target-features.c +++ b/clang/test/Preprocessor/wasm-target-features.c @@ -155,15 +155,15 @@ // // GENERIC-DAG:#define __wasm_sign_ext__ 1{{$}} // GENERIC-DAG:#define __wasm_mutable_globals__ 1{{$}} -// GENERIC-NOT:#define __wasm_nontrapping_fptoint__ 1{{$}} -// GENERIC-NOT:#define __wasm_bulk_memory__ 1{{$}} +// GENERIC-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}} +// GENERIC-DAG:#define __wasm_bulk_memory__ 1{{$}} +// GENERIC-DAG:#define __wasm_multivalue__ 1{{$}} +// GENERIC-DAG:#define __wasm_reference_types__ 1{{$}} // GENERIC-NOT:#define __wasm_simd128__ 1{{$}} // GENERIC-NOT:#define __wasm_atomics__ 1{{$}} // GENERIC-NOT:#define __wasm_tail_call__ 1{{$}} // GENERIC-NOT:#define __wasm_multimemory__ 1{{$}} // GENERIC-NOT:#define __wasm_exception_handling__ 1{{$}} -// GENERIC-NOT:#define __wasm_multivalue__ 1{{$}} -// GENERIC-NOT:#define __wasm_reference_types__ 1{{$}} // GENERIC-NOT:#define __wasm_extended_const__ 1{{$}} // RUN: %clang -E -dM %s -o - 2>&1 \ >From 01ac8bd38aaa86e62b00709790a36e050528f853 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 23 Feb 2024 00:31:41 + Subject: [PATCH 2/5] Mention that ABI is not turned on --- clang/docs/ReleaseNotes.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 5a07dcca106876..ec85d8882c1861 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -261,7 +261,8 @@ WebAssembly Support The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue, reference-types, and bulk-memory.These proposals are standardized and available -in all major engines. +in all major engines. Enabling multivalue here only enables the language feature +but does not turn on the multivalue ABI. AVR Support ^^^ >From de6aa6aa0891bb11ae7402d2cbccbcd82cd4fc77 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 23 Apr 2024 13:21:15 + Subject: [PATCH 3/5] Enable only multivalue and reference types --- clang/docs/ReleaseNotes.rst
[clang] [llvm] [ConstantFolding] Canonicalize constexpr GEPs to i8 (PR #89872)
@@ -944,43 +943,18 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, return ConstantExpr::getIntToPtr(C, ResTy); } - // Otherwise form a regular getelementptr. Recompute the indices so that - // we eliminate over-indexing of the notional static type array bounds. - // This makes it easy to determine if the getelementptr is "inbounds". - - // For GEPs of GlobalValues, use the value type, otherwise use an i8 GEP. - if (auto *GV = dyn_cast(Ptr)) -SrcElemTy = GV->getValueType(); - else -SrcElemTy = Type::getInt8Ty(Ptr->getContext()); - - if (!SrcElemTy->isSized()) -return nullptr; - - Type *ElemTy = SrcElemTy; - SmallVector Indices = DL.getGEPIndicesForOffset(ElemTy, Offset); - if (Offset != 0) -return nullptr; - - // Try to add additional zero indices to reach the desired result element - // type. - // TODO: Should we avoid extra zero indices if ResElemTy can't be reached and - // we'll have to insert a bitcast anyway? - while (ElemTy != ResElemTy) { -Type *NextTy = GetElementPtrInst::getTypeAtIndex(ElemTy, (uint64_t)0); -if (!NextTy) - break; - -Indices.push_back(APInt::getZero(isa(ElemTy) ? 32 : BitWidth)); -ElemTy = NextTy; + // Try to infer inbounds for GEPs of globals. + if (!InBounds && Offset.isNonNegative()) { +bool CanBeNull, CanBeFreed; +uint64_t DerefBytes = +Ptr->getPointerDereferenceableBytes(DL, CanBeNull, CanBeFreed); +InBounds = DerefBytes != 0 && !CanBeNull && Offset.sle(DerefBytes); nikic wrote: I've added this inference in this patch, because we lose out on this inference in the DataLayout-independent constant folding: https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/llvm/lib/IR/ConstantFold.cpp#L1717-L1724 As such, we need a (more powerful version of) this inference in the DataLayout-aware constant folding code. https://github.com/llvm/llvm-project/pull/89872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ConstantFolding] Canonicalize constexpr GEPs to i8 (PR #89872)
llvmbot wrote: @llvm/pr-subscribers-backend-systemz @llvm/pr-subscribers-backend-risc-v @llvm/pr-subscribers-function-specialization Author: Nikita Popov (nikic) Changes This patch canonicalizes constant expression GEPs to use i8 source element type, aka ptradd. This is the ConstantFolding equivalent of the InstCombine canonicalization introduced in #68882. I believe all our optimizations working on constant expression GEPs (like GlobalOpt etc) have already been switched to work on offsets, so I don't expect any significant fallout from this change. This is part of: https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699 --- Patch is 258.02 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/89872.diff 96 Files Affected: - (modified) clang/test/CodeGen/RISCV/riscv-inline-asm.c (+3-3) - (modified) clang/test/CodeGen/attr-counted-by.c (+29-29) - (modified) clang/test/CodeGenCXX/atomicinit.cpp (+2-2) - (modified) clang/test/CodeGenCXX/auto-var-init.cpp (+2-2) - (modified) clang/test/Profile/c-unreachable-after-switch.c (+2-2) - (modified) llvm/lib/Analysis/ConstantFolding.cpp (+10-36) - (modified) llvm/test/Other/constant-fold-gep.ll (+7-7) - (modified) llvm/test/Other/optimize-inrange-gep.ll (+1-1) - (modified) llvm/test/Transforms/FunctionSpecialization/function-specialization-constant-expression.ll (+3-3) - (modified) llvm/test/Transforms/GVN/PRE/load-pre-licm.ll (+1-1) - (modified) llvm/test/Transforms/GVN/PRE/phi-translate-2.ll (+2-2) - (modified) llvm/test/Transforms/IndVarSimplify/D108043.ll (+1-1) - (modified) llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll (+1-1) - (modified) llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll (+2-2) - (modified) llvm/test/Transforms/IndVarSimplify/lftr-dead-ivs.ll (+3-3) - (modified) llvm/test/Transforms/IndVarSimplify/lftr.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/addrspacecast.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/align-addr.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/binop-select-cast-of-select-cond.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/constant-fold-address-space-pointer.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/constant-fold-gep.ll (+20-20) - (modified) llvm/test/Transforms/InstCombine/fmul.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/force-opaque-ptr.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/fortify-folding.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/gep-custom-dl.ll (+3-3) - (modified) llvm/test/Transforms/InstCombine/getelementptr.ll (+14-14) - (modified) llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/loadstore-alignment.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/memchr-2.ll (+5-5) - (modified) llvm/test/Transforms/InstCombine/memchr-4.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/memchr-6.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/memchr-7.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/memchr-8.ll (+3-3) - (modified) llvm/test/Transforms/InstCombine/memchr-9.ll (+18-18) - (modified) llvm/test/Transforms/InstCombine/memchr.ll (+6-6) - (modified) llvm/test/Transforms/InstCombine/memcmp-8.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/memcpy-from-global.ll (+4-4) - (modified) llvm/test/Transforms/InstCombine/memrchr-3.ll (+10-10) - (modified) llvm/test/Transforms/InstCombine/memrchr-4.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/merging-multiple-stores-into-successor.ll (+3-3) - (modified) llvm/test/Transforms/InstCombine/objsize.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/pr25342.ll (+5-5) - (modified) llvm/test/Transforms/InstCombine/pr33453.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/pr38984-inseltpoison.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/pr38984.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/pr83947.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/ptr-replace-alloca.ll (+4-4) - (modified) llvm/test/Transforms/InstCombine/rem.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/select-and-or.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/simplify-libcalls-i16.ll (+5-5) - (modified) llvm/test/Transforms/InstCombine/simplify-libcalls.ll (+5-5) - (modified) llvm/test/Transforms/InstCombine/snprintf-2.ll (+24-24) - (modified) llvm/test/Transforms/InstCombine/snprintf-3.ll (+24-24) - (modified) llvm/test/Transforms/InstCombine/snprintf-4.ll (+15-15) - (modified) llvm/test/Transforms/InstCombine/stpcpy-1.ll (+2-2) - (modified) llvm/test/Transforms/InstCombine/stpcpy_chk-1.ll (+5-5) - (modified) llvm/test/Transforms/InstCombine/stpncpy-1.ll (+19-16) - (modified) llvm/test/Transforms/InstCombine/str-int-2.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/str-int-3.ll
[clang] 88b6186 - [WebAssembly] Tidy up wasm-target-features.c (#89778)
Author: Heejin Ahn Date: 2024-04-24T14:26:09+09:00 New Revision: 88b6186af3908c55b357858eb348b5143f21c289 URL: https://github.com/llvm/llvm-project/commit/88b6186af3908c55b357858eb348b5143f21c289 DIFF: https://github.com/llvm/llvm-project/commit/88b6186af3908c55b357858eb348b5143f21c289.diff LOG: [WebAssembly] Tidy up wasm-target-features.c (#89778) This tidies up `wasm-target-features.c` cosmetically: - Sorts the feature tests alphabetically - Adds a space after colons Added: Modified: clang/lib/Basic/Targets/WebAssembly.cpp clang/test/Preprocessor/wasm-target-features.c Removed: diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp index f1c925d90cb649..d473fd19086460 100644 --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -148,18 +148,18 @@ bool WebAssemblyTargetInfo::initFeatureMap( llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector &FeaturesVec) const { if (CPU == "bleeding-edge") { -Features["nontrapping-fptoint"] = true; -Features["sign-ext"] = true; -Features["bulk-memory"] = true; Features["atomics"] = true; +Features["bulk-memory"] = true; +Features["multimemory"] = true; Features["mutable-globals"] = true; -Features["tail-call"] = true; +Features["nontrapping-fptoint"] = true; Features["reference-types"] = true; -Features["multimemory"] = true; +Features["sign-ext"] = true; +Features["tail-call"] = true; setSIMDLevel(Features, SIMD128, true); } else if (CPU == "generic") { -Features["sign-ext"] = true; Features["mutable-globals"] = true; +Features["sign-ext"] = true; } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c index 983cd01cf8117e..32e24ad1b71656 100644 --- a/clang/test/Preprocessor/wasm-target-features.c +++ b/clang/test/Preprocessor/wasm-target-features.c @@ -1,38 +1,29 @@ // RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm32-unknown-unknown -msimd128 \ -// RUN: | FileCheck %s -check-prefix=SIMD128 -// RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm64-unknown-unknown -msimd128 \ -// RUN: | FileCheck %s -check-prefix=SIMD128 -// -// SIMD128:#define __wasm_simd128__ 1{{$}} - -// RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm32-unknown-unknown -mrelaxed-simd \ -// RUN: | FileCheck %s -check-prefix=RELAXED-SIMD +// RUN: -target wasm32-unknown-unknown -matomics \ +// RUN: | FileCheck %s -check-prefix=ATOMICS // RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm64-unknown-unknown -mrelaxed-simd \ -// RUN: | FileCheck %s -check-prefix=RELAXED-SIMD +// RUN: -target wasm64-unknown-unknown -matomics \ +// RUN: | FileCheck %s -check-prefix=ATOMICS // -// RELAXED-SIMD:#define __wasm_relaxed_simd__ 1{{$}} +// ATOMICS: #define __wasm_atomics__ 1{{$}} // RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm32-unknown-unknown -mnontrapping-fptoint \ -// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT +// RUN: -target wasm32-unknown-unknown -pthread \ +// RUN: | FileCheck %s -check-prefix=PTHREAD // RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm64-unknown-unknown -mnontrapping-fptoint \ -// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT +// RUN: -target wasm64-unknown-unknown -pthread \ +// RUN: | FileCheck %s -check-prefix=PTHREAD // -// NONTRAPPING-FPTOINT:#define __wasm_nontrapping_fptoint__ 1{{$}} +// PTHREAD: #define __wasm_atomics__ 1{{$}} // RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm32-unknown-unknown -msign-ext \ -// RUN: | FileCheck %s -check-prefix=SIGN-EXT +// RUN: -target wasm32-unknown-unknown -mbulk-memory \ +// RUN: | FileCheck %s -check-prefix=BULK-MEMORY // RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm64-unknown-unknown -msign-ext \ -// RUN: | FileCheck %s -check-prefix=SIGN-EXT +// RUN: -target wasm64-unknown-unknown -mbulk-memory \ +// RUN: | FileCheck %s -check-prefix=BULK-MEMORY // -// SIGN-EXT:#define __wasm_sign_ext__ 1{{$}} +// BULK-MEMORY: #define __wasm_bulk_memory__ 1{{$}} // RUN: %clang -E -dM %s -o - 2>&1 \ // RUN: -target wasm32-unknown-unknown -mexception-handling \ @@ -41,34 +32,34 @@ // RUN: -target wasm64-unknown-unknown -mexception-handling \ // RUN: | FileCheck %s -check-prefix=EXCEPTION-HANDLING // -// EXCEPTION-HANDLING:#define __wasm_exception_handling__ 1{{$}} +// EXCEPTION-HANDLING: #define __wasm_exception_handling__ 1{{$}} // RUN: %clang -E -dM %s -o - 2>&1 \ -// RUN: -target wasm32-unknown-unknown -mbulk-memory \ -// RUN: | FileCheck %s -check-prefix=BULK-MEMORY +// RUN: -target wasm32-unknown-unknown -m
[clang] [WebAssembly] Tidy up wasm-target-features.c (PR #89778)
https://github.com/aheejin closed https://github.com/llvm/llvm-project/pull/89778 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lambda itself and not a derived class. +auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl(); +auto *LambdaTy = cast(Field->getParent()); +if (ThisTy != LambdaTy) { + CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, + /*DetectVirtual=*/false); + + [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths); + assert(Derived && "Type not derived from lambda type?"); cor3ntin wrote: Richard got you beat by a few days https://cplusplus.github.io/CWG/issues/2881.html https://github.com/llvm/llvm-project/pull/89828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Fix uses of -DAG and -NOT in wasm-target-features.c (PR #89777)
https://github.com/aheejin closed https://github.com/llvm/llvm-project/pull/89777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c8c1e4e - [WebAssembly] Fix uses of -DAG and -NOT in wasm-target-features.c (#89777)
Author: Heejin Ahn Date: 2024-04-24T14:23:54+09:00 New Revision: c8c1e4e0e576f6e735a55dca4a2eb75ce73ee1db URL: https://github.com/llvm/llvm-project/commit/c8c1e4e0e576f6e735a55dca4a2eb75ce73ee1db DIFF: https://github.com/llvm/llvm-project/commit/c8c1e4e0e576f6e735a55dca4a2eb75ce73ee1db.diff LOG: [WebAssembly] Fix uses of -DAG and -NOT in wasm-target-features.c (#89777) We are currently using `PREFIX-DAG` and `PREFIX-NOT` within a single `PREFIX` test in a mixed way, but `-DAG` and `-NOT` do not work that way. For example: Result: ``` 1 2 3 ``` Test file: ```c // CHECK-DAG: 3 // CHECK-DAG: 1 // CHECK-NOT: 2 ``` This does not work. The last line `CHECK-NOT: 2` does not trigger any error, because we've already covered all three lines (1~3) while matching `CHECK-DAG: 3` and `CHECK-DAG: 1`, and FileCheck tries to check the line `CHECK-NOT: 2` _after_ the line `3`. Actually, we have ```c // BLEEDING-EDGE-NOT:#define __wasm_reference_types__ 1{{$}} ``` even though reference-types is enabled in 'bleeding-edge' config, and this has not triggered any error. This section (https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive) explains the interactions between `CHECK-DAG` and `CHECK-NOT`s: > As a result, the surrounding `CHECK-DAG:` directives cannot be reordered, i.e. all occurrences matching `CHECK-DAG:` before `CHECK-NOT:` must not fall behind occurrences matching `CHECK-DAG:` after `CHECK-NOT:`. So in order to test the 'include' lists and 'not-include' lists, we have to run the tests twice with different prefixes. This splits `GENERIC` and `BLEEDING-EDGE` tests in two configs (`***-INCLUDE` and `***`) to test them correctly. This also adds some spaces after colons, sorts the feature lists, and adds `1{{$}}` to the `MVP` tests to make them consistent with `GENERIC` and `BLEEDING-EDGE` tests. Added: Modified: clang/test/Preprocessor/wasm-target-features.c Removed: diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c index eccd432aa8eee6..983cd01cf8117e 100644 --- a/clang/test/Preprocessor/wasm-target-features.c +++ b/clang/test/Preprocessor/wasm-target-features.c @@ -132,20 +132,30 @@ // RUN: -target wasm64-unknown-unknown -mcpu=mvp \ // RUN: | FileCheck %s -check-prefix=MVP // -// MVP-NOT:#define __wasm_simd128__ -// MVP-NOT:#define __wasm_nontrapping_fptoint__ -// MVP-NOT:#define __wasm_sign_ext__ -// MVP-NOT:#define __wasm_exception_handling__ -// MVP-NOT:#define __wasm_bulk_memory__ -// MVP-NOT:#define __wasm_atomics__ -// MVP-NOT:#define __wasm_mutable_globals__ -// MVP-NOT:#define __wasm_multivalue__ -// MVP-NOT:#define __wasm_tail_call__ -// MVP-NOT:#define __wasm_reference_types__ -// MVP-NOT:#define __wasm_extended_const__ -// MVP-NOT:#define __wasm_multimemory__ -// MVP-NOT:#define __wasm_relaxed_simd__ +// MVP-NOT: #define __wasm_atomics__ 1{{$}} +// MVP-NOT: #define __wasm_bulk_memory__ 1{{$}} +// MVP-NOT: #define __wasm_exception_handling__ 1{{$}} +// MVP-NOT: #define __wasm_extended_const__ 1{{$}} +// MVP-NOT: #define __wasm_multimemory__ 1{{$}} +// MVP-NOT: #define __wasm_multivalue__ 1{{$}} +// MVP-NOT: #define __wasm_mutable_globals__ 1{{$}} +// MVP-NOT: #define __wasm_nontrapping_fptoint__ 1{{$}} +// MVP-NOT: #define __wasm_reference_types__ 1{{$}} +// MVP-NOT: #define __wasm_relaxed_simd__ 1{{$}} +// MVP-NOT: #define __wasm_sign_ext__ 1{{$}} +// MVP-NOT: #define __wasm_simd128__ 1{{$}} +// MVP-NOT: #define __wasm_tail_call__ 1{{$}} +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target wasm32-unknown-unknown -mcpu=generic \ +// RUN: | FileCheck %s -check-prefix=GENERIC-INCLUDE +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target wasm64-unknown-unknown -mcpu=generic \ +// RUN: | FileCheck %s -check-prefix=GENERIC-INCLUDE +// +// GENERIC-INCLUDE-DAG: #define __wasm_mutable_globals__ 1{{$}} +// GENERIC-INCLUDE-DAG: #define __wasm_sign_ext__ 1{{$}} +// // RUN: %clang -E -dM %s -o - 2>&1 \ // RUN: -target wasm32-unknown-unknown -mcpu=generic \ // RUN: | FileCheck %s -check-prefix=GENERIC @@ -153,19 +163,35 @@ // RUN: -target wasm64-unknown-unknown -mcpu=generic \ // RUN: | FileCheck %s -check-prefix=GENERIC // -// GENERIC-DAG:#define __wasm_sign_ext__ 1{{$}} -// GENERIC-DAG:#define __wasm_mutable_globals__ 1{{$}} -// GENERIC-NOT:#define __wasm_nontrapping_fptoint__ 1{{$}} -// GENERIC-NOT:#define __wasm_bulk_memory__ 1{{$}} -// GENERIC-NOT:#define __wasm_simd128__ 1{{$}} -// GENERIC-NOT:#define __wasm_atomics__ 1{{$}} -// GENERIC-NOT:#define __wasm_tail_call__ 1{{$}} -// GENERIC-NOT:#define __wasm_multimemory__ 1{{$}} -// GENERIC-NOT:#define __wasm_exception_handling__ 1{{$}} -// GENERIC-NOT:#define __wasm_multivalue__ 1{{$}} -// GENERIC-NOT:#define __wasm_reference_types__ 1{{$}} -// GENERIC-NOT:#define __wasm_extended_const__ 1{{$}} +// GENERIC-NOT: #define __wasm_atom
[clang] [Clang] Improve testing for the flexible array member (PR #89462)
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/89462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Annotate enum braces as BK_Block (PR #89871)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) Changes Fixes #89759. --- Full diff: https://github.com/llvm/llvm-project/pull/89871.diff 2 Files Affected: - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+12-12) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+17) ``diff diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 6e4e6901e473f7..3a263955a6a8fe 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -534,11 +534,11 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { case tok::r_brace: if (LBraceStack.empty()) break; - if (LBraceStack.back().Tok->is(BK_Unknown)) { + if (auto *LBrace = LBraceStack.back().Tok; LBrace->is(BK_Unknown)) { bool ProbablyBracedList = false; if (Style.Language == FormatStyle::LK_Proto) { ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square); -} else { +} else if (LBrace->isNot(TT_EnumLBrace)) { // Using OriginalColumn to distinguish between ObjC methods and // binary operators is a bit hacky. bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) && @@ -552,7 +552,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { // If we already marked the opening brace as braced list, the closing // must also be part of it. - ProbablyBracedList = LBraceStack.back().Tok->is(TT_BracedListLBrace); + ProbablyBracedList = LBrace->is(TT_BracedListLBrace); ProbablyBracedList = ProbablyBracedList || (Style.isJavaScript() && @@ -608,13 +608,9 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { ProbablyBracedList = true; } } -if (ProbablyBracedList) { - Tok->setBlockKind(BK_BracedInit); - LBraceStack.back().Tok->setBlockKind(BK_BracedInit); -} else { - Tok->setBlockKind(BK_Block); - LBraceStack.back().Tok->setBlockKind(BK_Block); -} +const auto BlockKind = ProbablyBracedList ? BK_BracedInit : BK_Block; +Tok->setBlockKind(BlockKind); +LBrace->setBlockKind(BlockKind); } LBraceStack.pop_back(); break; @@ -2418,6 +2414,7 @@ bool UnwrappedLineParser::tryToParseChildBlock() { } bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) { + assert(!IsAngleBracket || !IsEnum); bool HasError = false; // FIXME: Once we have an expression parser in the UnwrappedLineParser, @@ -2440,8 +2437,11 @@ bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) { } } if (FormatTok->is(IsAngleBracket ? tok::greater : tok::r_brace)) { - if (IsEnum && !Style.AllowShortEnumsOnASingleLine) -addUnwrappedLine(); + if (IsEnum) { +FormatTok->setBlockKind(BK_Block); +if (!Style.AllowShortEnumsOnASingleLine) + addUnwrappedLine(); + } nextToken(); return !HasError; } diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 6b8ab441cb46f8..dff5251d2e9406 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2915,6 +2915,23 @@ TEST_F(TokenAnnotatorTest, BraceKind) { ASSERT_EQ(Tokens.size(), 10u) << Tokens; EXPECT_BRACE_KIND(Tokens[6], BK_BracedInit); EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit); + + Tokens = annotate("#ifdef DEBUG_ENABLED\n" +"#else\n" +"#endif\n" +"class RenderingServer : Object {\n" +"#ifndef DISABLE_DEPRECATED\n" +" enum Features {\n" +"FEATURE_SHADERS,\n" +"FEATURE_MULTITHREADED,\n" +" };\n" +"#endif\n" +"};"); + ASSERT_EQ(Tokens.size(), 29u) << Tokens; + EXPECT_BRACE_KIND(Tokens[11], BK_Block); + EXPECT_BRACE_KIND(Tokens[17], BK_Block); + EXPECT_BRACE_KIND(Tokens[22], BK_Block); + EXPECT_BRACE_KIND(Tokens[26], BK_Block); } TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { `` https://github.com/llvm/llvm-project/pull/89871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Annotate enum braces as BK_Block (PR #89871)
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/89871 Fixes #89759. >From dfd275f3d2f89e2cabffcc0d573f2b4571c0ead4 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 23 Apr 2024 21:59:43 -0700 Subject: [PATCH] [clang-format] Annotate enum braces as BK_Block Fixes #89759. --- clang/lib/Format/UnwrappedLineParser.cpp | 24 +-- clang/unittests/Format/TokenAnnotatorTest.cpp | 17 + 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 6e4e6901e473f7..3a263955a6a8fe 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -534,11 +534,11 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { case tok::r_brace: if (LBraceStack.empty()) break; - if (LBraceStack.back().Tok->is(BK_Unknown)) { + if (auto *LBrace = LBraceStack.back().Tok; LBrace->is(BK_Unknown)) { bool ProbablyBracedList = false; if (Style.Language == FormatStyle::LK_Proto) { ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square); -} else { +} else if (LBrace->isNot(TT_EnumLBrace)) { // Using OriginalColumn to distinguish between ObjC methods and // binary operators is a bit hacky. bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) && @@ -552,7 +552,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { // If we already marked the opening brace as braced list, the closing // must also be part of it. - ProbablyBracedList = LBraceStack.back().Tok->is(TT_BracedListLBrace); + ProbablyBracedList = LBrace->is(TT_BracedListLBrace); ProbablyBracedList = ProbablyBracedList || (Style.isJavaScript() && @@ -608,13 +608,9 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { ProbablyBracedList = true; } } -if (ProbablyBracedList) { - Tok->setBlockKind(BK_BracedInit); - LBraceStack.back().Tok->setBlockKind(BK_BracedInit); -} else { - Tok->setBlockKind(BK_Block); - LBraceStack.back().Tok->setBlockKind(BK_Block); -} +const auto BlockKind = ProbablyBracedList ? BK_BracedInit : BK_Block; +Tok->setBlockKind(BlockKind); +LBrace->setBlockKind(BlockKind); } LBraceStack.pop_back(); break; @@ -2418,6 +2414,7 @@ bool UnwrappedLineParser::tryToParseChildBlock() { } bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) { + assert(!IsAngleBracket || !IsEnum); bool HasError = false; // FIXME: Once we have an expression parser in the UnwrappedLineParser, @@ -2440,8 +2437,11 @@ bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) { } } if (FormatTok->is(IsAngleBracket ? tok::greater : tok::r_brace)) { - if (IsEnum && !Style.AllowShortEnumsOnASingleLine) -addUnwrappedLine(); + if (IsEnum) { +FormatTok->setBlockKind(BK_Block); +if (!Style.AllowShortEnumsOnASingleLine) + addUnwrappedLine(); + } nextToken(); return !HasError; } diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 6b8ab441cb46f8..dff5251d2e9406 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2915,6 +2915,23 @@ TEST_F(TokenAnnotatorTest, BraceKind) { ASSERT_EQ(Tokens.size(), 10u) << Tokens; EXPECT_BRACE_KIND(Tokens[6], BK_BracedInit); EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit); + + Tokens = annotate("#ifdef DEBUG_ENABLED\n" +"#else\n" +"#endif\n" +"class RenderingServer : Object {\n" +"#ifndef DISABLE_DEPRECATED\n" +" enum Features {\n" +"FEATURE_SHADERS,\n" +"FEATURE_MULTITHREADED,\n" +" };\n" +"#endif\n" +"};"); + ASSERT_EQ(Tokens.size(), 29u) << Tokens; + EXPECT_BRACE_KIND(Tokens[11], BK_Block); + EXPECT_BRACE_KIND(Tokens[17], BK_Block); + EXPECT_BRACE_KIND(Tokens[22], BK_Block); + EXPECT_BRACE_KIND(Tokens[26], BK_Block); } TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
@@ -2824,8 +2827,12 @@ bool RISCVAsmParser::parseDirectiveOption() { break; } - auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch); - if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch || + std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch); topperc wrote: Why an rvalue reference? https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
@@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed, static cl::opt AddBuildAttributes("riscv-add-build-attributes", cl::init(false)); +static cl::opt +DisableExperimentalExtension("riscv-disable-experimental-ext", topperc wrote: Why disable instead of enable? https://github.com/llvm/llvm-project/pull/89727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][PAC][clang][ELF] Support PAuth ABI core info (PR #85235)
@@ -0,0 +1,59 @@ +// RUN: %clang --target=aarch64-linux -S -emit-llvm -o - \ MaskRay wrote: We prefer `%clang_cc1` for codegen tests. `%clang` is not used in clang/test/Driver https://github.com/llvm/llvm-project/pull/85235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)
https://github.com/yetingk updated https://github.com/llvm/llvm-project/pull/89727 >From a43014cf3daa1b0fd9092bfe41da979205ba64aa Mon Sep 17 00:00:00 2001 From: Yeting Kuo Date: Tue, 23 Apr 2024 02:16:04 -0700 Subject: [PATCH 1/2] [RISCV] Teach .option arch to support experimental extensions. Previously .option arch denied extenions are not belongs to RISC-V features. But experimental features have experimental- prefix, so .option arch can not serve for experimental extension. This patch uses the features of extensions to identify extension existance. --- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 7 --- llvm/test/MC/RISCV/option-arch.s | 9 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 3f4a73ad89bf8a..80ff70f1095f4c 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -2824,8 +2824,9 @@ bool RISCVAsmParser::parseDirectiveOption() { break; } - auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch); - if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch || + std::string &&Feature = RISCVISAInfo::getTargetFeatureForExtension(Arch); + auto Ext = llvm::lower_bound(RISCVFeatureKV, Feature); + if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Feature || !RISCVISAInfo::isSupportedExtension(Arch)) { if (isDigit(Arch.back())) return Error( @@ -2834,7 +2835,7 @@ bool RISCVAsmParser::parseDirectiveOption() { return Error(Loc, "unknown extension feature"); } - Args.emplace_back(Type, Ext->Key); + Args.emplace_back(Type, Arch.str()); if (Type == RISCVOptionArchArgType::Plus) { FeatureBitset OldFeatureBits = STI->getFeatureBits(); diff --git a/llvm/test/MC/RISCV/option-arch.s b/llvm/test/MC/RISCV/option-arch.s index 6ee133c7159a27..40675f9e4b434b 100644 --- a/llvm/test/MC/RISCV/option-arch.s +++ b/llvm/test/MC/RISCV/option-arch.s @@ -1,7 +1,7 @@ # RUN: llvm-mc -triple riscv32 -show-encoding < %s \ # RUN: | FileCheck -check-prefixes=CHECK %s # RUN: llvm-mc -triple riscv32 -filetype=obj < %s \ -# RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba -d -M no-aliases - \ +# RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \ # RUN: | FileCheck -check-prefixes=CHECK-INST %s # Test '.option arch, +' and '.option arch, -' directive @@ -78,6 +78,13 @@ lr.w t0, (t1) # CHECK: encoding: [0xb3,0x22,0x73,0x20] sh1add t0, t1, t2 +# Test experimental extension +# CHECK: .option arch, +zicfiss +.option arch, +zicfiss +# CHECK-INST: sspopchk ra +# CHECK: encoding: [0x73,0xc0,0xc0,0xcd] +sspopchk ra + # Test '.option arch, ' directive # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0 .option arch, rv32i2p1_m2p0_a2p1_c2p0 >From 471abce617a9d18ef91370303eef90bab228d9d3 Mon Sep 17 00:00:00 2001 From: Yeting Kuo Date: Tue, 23 Apr 2024 21:55:12 -0700 Subject: [PATCH 2/2] Make this pr obey menable-experimental-extensions. --- clang/lib/Driver/ToolChains/Clang.cpp | 5 + clang/test/Driver/riscv-option-arch.s | 5 + llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 6 ++ 3 files changed, 16 insertions(+) create mode 100644 clang/test/Driver/riscv-option-arch.s diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 5894a48e0e378b..8b0f523763486f 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8449,6 +8449,11 @@ void ClangAs::AddRISCVTargetArgs(const ArgList &Args, CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-riscv-add-build-attributes"); } + + if (!Args.hasArg(options::OPT_menable_experimental_extensions)) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back("-riscv-disable-experimental-ext"); + } } void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/test/Driver/riscv-option-arch.s b/clang/test/Driver/riscv-option-arch.s new file mode 100644 index 00..8ce84dd8ffe79d --- /dev/null +++ b/clang/test/Driver/riscv-option-arch.s @@ -0,0 +1,5 @@ +# RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o /dev/null %s +# RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck -check-prefixes=CHECK-ERR %s + +.option arch, +zicfiss +# CHECK-ERR: Unexpected experimental extensions. diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 80ff70f1095f4c..6225e0707015fe 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed, static cl::opt AddBuildAttributes("riscv-add-
[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)
@@ -4781,6 +4782,7 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, } } setDSOLocal(F); + markRegisterParameterAttributes(F); efriedma-quic wrote: To clarify, the code in llvm/ still needs to exist because we need some approximation of the calling convention even if we don't have access to the clang AST. But clang shouldn't use it; clang's native representation of calling conventions is better. (It's a long-standing request to try to give LLVM a representation of calling conventions that's closer to clang's representation, but it's a large problem, and nobody has really made any progress on it.) https://github.com/llvm/llvm-project/pull/89707 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d9715c6 - [RISCV] Don't make Zacas or Zabha imply A in RISCVISAInfo.cpp
Author: Craig Topper Date: 2024-04-23T21:34:04-07:00 New Revision: d9715c698c4940e65e9bd036e22fb5cab3aa2c6f URL: https://github.com/llvm/llvm-project/commit/d9715c698c4940e65e9bd036e22fb5cab3aa2c6f DIFF: https://github.com/llvm/llvm-project/commit/d9715c698c4940e65e9bd036e22fb5cab3aa2c6f.diff LOG: [RISCV] Don't make Zacas or Zabha imply A in RISCVISAInfo.cpp Zabha and Zacas are both documented as depending on Zaamo. I'm hesitant to make them imply Zaamo instead. So remove the implication and replace with a check that either A or Zaamo is enabled. Added: Modified: clang/test/Preprocessor/riscv-target-features.c llvm/lib/TargetParser/RISCVISAInfo.cpp llvm/test/CodeGen/RISCV/attributes.ll llvm/test/MC/RISCV/attribute-arch.s llvm/test/MC/RISCV/rv32zacas-invalid.s llvm/test/MC/RISCV/rv32zacas-valid.s llvm/test/MC/RISCV/rv64zacas-valid.s llvm/test/MC/RISCV/rvzabha-invalid.s llvm/test/MC/RISCV/rvzabha-valid.s llvm/test/MC/RISCV/rvzabha-zacas-valid.s Removed: diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index 646043681fe330..ee4f81cd654bca 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -174,6 +174,7 @@ // CHECK-NOT: __riscv_ssqosid{{.*$}} // CHECK-NOT: __riscv_supm{{.*$}} // CHECK-NOT: __riscv_zaamo {{.*$}} +// CHECK-NOT: __riscv_zabha {{.*$}} // CHECK-NOT: __riscv_zalasr {{.*$}} // CHECK-NOT: __riscv_zalrsc {{.*$}} // CHECK-NOT: __riscv_zfbfmin {{.*$}} @@ -698,10 +699,10 @@ // CHECK-ZA64RS-EXT: __riscv_za64rs 100{{$}} // RUN: %clang --target=riscv32 \ -// RUN: -march=rv32i_zacas1p0 -E -dM %s \ +// RUN: -march=rv32ia_zacas1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s // RUN: %clang --target=riscv64 \ -// RUN: -march=rv64i_zacas1p0 -E -dM %s \ +// RUN: -march=rv64ia_zacas1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}} @@ -1552,6 +1553,14 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s // CHECK-ZAAMO-EXT: __riscv_zaamo 2000{{$}} +// RUN: %clang --target=riscv32 -menable-experimental-extensions \ +// RUN: -march=rv32ia_zabha1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s +// RUN: %clang --target=riscv64 -menable-experimental-extensions \ +// RUN: -march=rv64ia_zabha1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s +// CHECK-ZABHA-EXT: __riscv_zabha 100{{$}} + // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32i_zalasr0p1 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALASR-EXT %s diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp index c103449f8067b7..bd907fc9a9f267 100644 --- a/llvm/lib/TargetParser/RISCVISAInfo.cpp +++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp @@ -1028,6 +1028,16 @@ Error RISCVISAInfo::checkDependency() { return createStringError(errc::invalid_argument, "'zcf' is only supported for 'rv32'"); + if (Exts.count("zacas") && !(Exts.count("a") || Exts.count("zamo"))) +return createStringError( +errc::invalid_argument, +"'zacas' requires 'a' or 'zaamo' extension to also be specified"); + + if (Exts.count("zabha") && !(Exts.count("a") || Exts.count("zamo"))) +return createStringError( +errc::invalid_argument, +"'zabha' requires 'a' or 'zaamo' extension to also be specified"); + return Error::success(); } @@ -1040,8 +1050,6 @@ static const char *ImpliedExtsXSfvfnrclipxfqf[] = {"zve32f"}; static const char *ImpliedExtsXSfvfwmaccqqq[] = {"zvfbfmin"}; static const char *ImpliedExtsXSfvqmaccdod[] = {"zve32x"}; static const char *ImpliedExtsXSfvqmaccqoq[] = {"zve32x"}; -static const char *ImpliedExtsZabha[] = {"a"}; -static const char *ImpliedExtsZacas[] = {"a"}; static const char *ImpliedExtsZcb[] = {"zca"}; static const char *ImpliedExtsZcd[] = {"d", "zca"}; static const char *ImpliedExtsZce[] = {"zcb", "zcmp", "zcmt"}; @@ -1115,8 +1123,6 @@ static constexpr ImpliedExtsEntry ImpliedExts[] = { {{"xsfvqmaccdod"}, {ImpliedExtsXSfvqmaccdod}}, {{"xsfvqmaccqoq"}, {ImpliedExtsXSfvqmaccqoq}}, {{"xtheadvdot"}, {ImpliedExtsXTHeadVdot}}, -{{"zabha"}, {ImpliedExtsZabha}}, -{{"zacas"}, {ImpliedExtsZacas}}, {{"zcb"}, {ImpliedExtsZcb}}, {{"zcd"}, {ImpliedExtsZcd}}, {{"zce"}, {ImpliedExtsZce}}, diff --git a/llvm/test/CodeGen/RISCV/attributes.ll b/llvm/test/CodeGen/RISCV/attributes.ll index 453da6de878d11..141d5ea4182892 100644 --- a/llvm/test/CodeGen/RISCV/attributes.ll +++ b/llvm/test/CodeGen/RISCV/attributes.ll @@ -112,12 +112,12 @@ ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - |
[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)
@@ -4781,6 +4782,7 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, } } setDSOLocal(F); + markRegisterParameterAttributes(F); efriedma-quic wrote: Zero/sign-extend attributes are also missing, I think. Which probably doesn't affect x86, but could have obscure effects on some targets. Using SetLLVMFunctionAttributes here isn't really a problem, except that it takes a clang::Type, not an llvm::Type type, and we only have a conversion in the other direction. So you'd need to modify the callers. And there are a lot of callers. https://github.com/llvm/llvm-project/pull/89707 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Correctly annotate list init braces of class types (PR #89706)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/89706 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 469c8a0 - [clang-format] Correctly annotate list init braces of class types (#89706)
Author: Owen Pan Date: 2024-04-23T21:27:27-07:00 New Revision: 469c8a0a4ef9edae4e236d554901e60b2adca074 URL: https://github.com/llvm/llvm-project/commit/469c8a0a4ef9edae4e236d554901e60b2adca074 DIFF: https://github.com/llvm/llvm-project/commit/469c8a0a4ef9edae4e236d554901e60b2adca074.diff LOG: [clang-format] Correctly annotate list init braces of class types (#89706) Fixes #71939. Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 603268f771ac52..6e4e6901e473f7 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -819,8 +819,11 @@ FormatToken *UnwrappedLineParser::parseBlock(bool MustBeDeclaration, return IfLBrace; } - if (FormatTok->is(tok::r_brace) && Tok->is(TT_NamespaceLBrace)) -FormatTok->setFinalizedType(TT_NamespaceRBrace); + if (FormatTok->is(tok::r_brace)) { +FormatTok->setBlockKind(BK_Block); +if (Tok->is(TT_NamespaceLBrace)) + FormatTok->setFinalizedType(TT_NamespaceRBrace); + } const bool IsFunctionRBrace = FormatTok->is(tok::r_brace) && Tok->is(TT_FunctionLBrace); @@ -3910,6 +3913,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { const FormatToken &InitialToken = *FormatTok; nextToken(); + const FormatToken *ClassName = nullptr; + bool IsDerived = false; auto IsNonMacroIdentifier = [](const FormatToken *Tok) { return Tok->is(tok::identifier) && Tok->TokenText != Tok->TokenText.upper(); }; @@ -3934,15 +3939,35 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } if (FormatTok->is(tok::l_square) && handleCppAttributes()) continue; +const auto *Previous = FormatTok; nextToken(); -// We can have macros in between 'class' and the class name. -if (!IsNonMacroIdentifier(FormatTok->Previous) && -FormatTok->is(tok::l_paren)) { - parseParens(); +switch (FormatTok->Tok.getKind()) { +case tok::l_paren: + // We can have macros in between 'class' and the class name. + if (!IsNonMacroIdentifier(Previous)) +parseParens(); + break; +case tok::coloncolon: + break; +default: + if (!ClassName && Previous->is(tok::identifier)) +ClassName = Previous; } } + auto IsListInitialization = [&] { +if (!ClassName || IsDerived) + return false; +assert(FormatTok->is(tok::l_brace)); +const auto *Prev = FormatTok->getPreviousNonComment(); +assert(Prev); +return Prev != ClassName && Prev->is(tok::identifier) && + Prev->isNot(Keywords.kw_final) && tryToParseBracedList(); + }; + if (FormatTok->isOneOf(tok::colon, tok::less)) { +if (FormatTok->is(tok::colon)) + IsDerived = true; int AngleNestingLevel = 0; do { if (FormatTok->is(tok::less)) @@ -3955,6 +3980,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { break; } if (FormatTok->is(tok::l_brace)) { +if (AngleNestingLevel == 0 && IsListInitialization()) + return; calculateBraceTypes(/*ExpectClassBody=*/true); if (!tryToParseBracedList()) break; @@ -3999,6 +4026,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { } }; if (FormatTok->is(tok::l_brace)) { +if (IsListInitialization()) + return; auto [OpenBraceType, ClosingBraceType] = GetBraceTypes(InitialToken); FormatTok->setFinalizedType(OpenBraceType); if (ParseAsExpr) { diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 34999b7376397b..6b8ab441cb46f8 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2855,6 +2855,66 @@ TEST_F(TokenAnnotatorTest, BraceKind) { ASSERT_EQ(Tokens.size(), 18u) << Tokens; EXPECT_BRACE_KIND(Tokens[8], BK_BracedInit); EXPECT_BRACE_KIND(Tokens[16], BK_BracedInit); + + Tokens = annotate("struct {};"); + ASSERT_EQ(Tokens.size(), 5u) << Tokens; + EXPECT_BRACE_KIND(Tokens[1], BK_Block); + EXPECT_BRACE_KIND(Tokens[2], BK_Block); + + Tokens = annotate("struct : Base {};"); + ASSERT_EQ(Tokens.size(), 7u) << Tokens; + EXPECT_BRACE_KIND(Tokens[3], BK_Block); + EXPECT_BRACE_KIND(Tokens[4], BK_Block); + + Tokens = annotate("struct Foo {};"); + ASSERT_EQ(Tokens.size(), 6u) << Tokens; + EXPECT_BRACE_KIND(Tokens[2], BK_Block); + EXPECT_BRACE_KIND(Tokens[3], BK_Block); + + Tokens = annotate("struct ::Foo {};"); + ASSERT_EQ(Tokens.size(), 7u) << Tokens; + EXPECT_BRACE_KIND(Tokens[3], BK_Block); + EXPECT_BRACE_KIND(Tokens[4], BK_Block); + + Tokens = annotate("struct NS::Foo {};"); + ASSERT_EQ(Tokens.size(), 8u) << Tokens; + EXPECT_BRACE_KIND(Tokens[4], BK_B
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
https://github.com/whentojump updated https://github.com/llvm/llvm-project/pull/89869 >From 968ef430dd09ee4545323426d0c5b550c6a0f690 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Fri, 19 Apr 2024 15:16:05 +0900 Subject: [PATCH 1/2] [MC/DC][Coverage] Workaround for `##` conditions A synthesized identifier with `##` is emitted to ``. `llvm-cov` cannot handle ` since it doesn't have actual files. As a workaround, peel `` to the actual definition if the definition is present. This affects predefined built-in macros, like __LINE__. Fixes #87000 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 12 +- clang/test/CoverageMapping/builtinmacro.c | 2 +- clang/test/CoverageMapping/macros.c | 8 ++-- .../test/CoverageMapping/mcdc-scratch-space.c | 39 +++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 clang/test/CoverageMapping/mcdc-scratch-space.c diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 733686d4946b3c1..f92706f579a7b9e 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -339,8 +339,18 @@ class CoverageMappingBuilder { llvm::SmallSet Visited; SmallVector, 8> FileLocs; -for (const auto &Region : SourceRegions) { +for (auto &Region : SourceRegions) { SourceLocation Loc = Region.getBeginLoc(); + + // Replace Region with its definition if it is in . + while (Loc.isMacroID() && + SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) { +auto ExpansionRange = SM.getImmediateExpansionRange(Loc); +Loc = ExpansionRange.getBegin(); +Region.setStartLoc(Loc); +Region.setEndLoc(ExpansionRange.getEnd()); + } + FileID File = SM.getFileID(Loc); if (!Visited.insert(File).second) continue; diff --git a/clang/test/CoverageMapping/builtinmacro.c b/clang/test/CoverageMapping/builtinmacro.c index abcdc191523a5d5..5d5a176aa7d87e2 100644 --- a/clang/test/CoverageMapping/builtinmacro.c +++ b/clang/test/CoverageMapping/builtinmacro.c @@ -4,7 +4,7 @@ // CHECK: filename const char *filename (const char *name) { // CHECK-NEXT: File 0, [[@LINE]]:41 -> [[@LINE+3]]:2 = #0 - static const char this_file[] = __FILE__; + static const char this_file[] = __FILE__; // CHECK-NEXT: File 0, [[@LINE]]:35 -> [[@LINE]]:35 = #0 return this_file; } diff --git a/clang/test/CoverageMapping/macros.c b/clang/test/CoverageMapping/macros.c index 6bd3be434139a21..fcf21170ef135cf 100644 --- a/clang/test/CoverageMapping/macros.c +++ b/clang/test/CoverageMapping/macros.c @@ -80,12 +80,14 @@ void func7(void) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+6]]:2 = #0 int kk,ll; // CHECK-NEXT: File 0, [[@LINE+1]]:7 -> [[@LINE+1]]:8 = #0 if (k) // CHECK-NEXT: Branch,File 0, [[@LINE]]:7 -> [[@LINE]]:8 = #1 m(k); // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:9 -> [[@LINE]]:5 = #1 - else // CHECK-NEXT: Expansion,File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:6 = #0 + else // CHECK-NEXT: Expansion,File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:6 = #1 l = m(l); // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:7 -> [[@LINE]]:5 = (#0 - #1) } // CHECK-NEXT: File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:10 = (#0 - #1) // CHECK-NEXT: Expansion,File 0, [[@LINE-2]]:9 -> [[@LINE-2]]:10 = (#0 - #1) - // CHECK-NEXT: File 1, [[@LINE-9]]:14 -> [[@LINE-9]]:18 = #0 - // CHECK-NEXT: File 2, [[@LINE-10]]:14 -> [[@LINE-10]]:15 = (#0 - #1) + // CHECK-NEXT: File 1, [[@LINE-9]]:14 -> [[@LINE-9]]:17 = #1 + // CHECK-NEXT: File 1, [[@LINE-10]]:14 -> [[@LINE-10]]:18 = #0 + // CHECK-NEXT: File 2, [[@LINE-11]]:14 -> [[@LINE-11]]:17 = (#0 - #1) + // CHECK-NEXT: File 2, [[@LINE-12]]:14 -> [[@LINE-12]]:15 = (#0 - #1) int main(int argc, const char *argv[]) { func(); diff --git a/clang/test/CoverageMapping/mcdc-scratch-space.c b/clang/test/CoverageMapping/mcdc-scratch-space.c new file mode 100644 index 000..1b8735cd27445a1 --- /dev/null +++ b/clang/test/CoverageMapping/mcdc-scratch-space.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c99 -fcoverage-mcdc -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s + +// CHECK: builtin_macro0: +int builtin_macro0(int a) { + // CHECK: Decision,File 0, [[@LINE+1]]:11 -> [[@LINE+2]]:15 = M:0, C:2 + return (__LINE__ // CHECK: Branch,File 0, [[@LINE]]:11 -> [[@LINE]]:11 = 0, 0 [1,2,0] + && a); // CHECK: Branch,File 0, [[@LINE]]:14 -> [[@LINE]]:15 = #2, (#1 - #2) [2,0,0] +} + +// CHECK: builtin_macro1: +int builtin_macro1(int a) { + // CHECK: Decision,File 0, [[@LINE+1]]:11 -> [[@LINE+2]]:22 = M:0, C:2 + return (a // CHECK: Branch,File 0, [[@LINE]]:11 -> [[@LINE]]:12 = (#0 -
[clang] [MC/DC][Coverage] Workaround for `##` conditions (PR #89573)
whentojump wrote: @chapuni Would you please take a look at #89869? Specifically, the extra one commit atop yours. Essentially I did similar things to `getIncludeOrExpansionLoc()`. https://github.com/llvm/llvm-project/pull/89573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
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 92631a4824a91f3268a5716dd3459df8dc6bfb63 2010fb3d7da4790985e16aabc634a50e9562bad3 -- clang/test/CoverageMapping/mcdc-scratch-space.c clang/lib/CodeGen/CoverageMappingGen.cpp clang/test/CoverageMapping/builtinmacro.c clang/test/CoverageMapping/macros.c `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 3ec11d13cf..9268ac5b4c 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -304,7 +304,7 @@ public: if (Loc.isMacroID()) { Loc = SM.getImmediateExpansionRange(Loc).getBegin(); while (Loc.isMacroID() && -SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) { + SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) { auto ExpansionRange = SM.getImmediateExpansionRange(Loc); Loc = ExpansionRange.getBegin(); } @@ -543,7 +543,8 @@ public: SourceRegionFilter Filter; for (const auto &FM : FileIDMapping) { SourceLocation ExpandedLoc = FM.second.second; - SourceLocation ParentLoc = getIncludeOrNonScratchExpansionLoc(ExpandedLoc); + SourceLocation ParentLoc = + getIncludeOrNonScratchExpansionLoc(ExpandedLoc); if (ParentLoc.isInvalid()) continue; `` https://github.com/llvm/llvm-project/pull/89869 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
https://github.com/whentojump created https://github.com/llvm/llvm-project/pull/89869 None >From 968ef430dd09ee4545323426d0c5b550c6a0f690 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Fri, 19 Apr 2024 15:16:05 +0900 Subject: [PATCH 1/2] [MC/DC][Coverage] Workaround for `##` conditions A synthesized identifier with `##` is emitted to ``. `llvm-cov` cannot handle ` since it doesn't have actual files. As a workaround, peel `` to the actual definition if the definition is present. This affects predefined built-in macros, like __LINE__. Fixes #87000 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 12 +- clang/test/CoverageMapping/builtinmacro.c | 2 +- clang/test/CoverageMapping/macros.c | 8 ++-- .../test/CoverageMapping/mcdc-scratch-space.c | 39 +++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 clang/test/CoverageMapping/mcdc-scratch-space.c diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 733686d4946b3c1..f92706f579a7b9e 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -339,8 +339,18 @@ class CoverageMappingBuilder { llvm::SmallSet Visited; SmallVector, 8> FileLocs; -for (const auto &Region : SourceRegions) { +for (auto &Region : SourceRegions) { SourceLocation Loc = Region.getBeginLoc(); + + // Replace Region with its definition if it is in . + while (Loc.isMacroID() && + SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) { +auto ExpansionRange = SM.getImmediateExpansionRange(Loc); +Loc = ExpansionRange.getBegin(); +Region.setStartLoc(Loc); +Region.setEndLoc(ExpansionRange.getEnd()); + } + FileID File = SM.getFileID(Loc); if (!Visited.insert(File).second) continue; diff --git a/clang/test/CoverageMapping/builtinmacro.c b/clang/test/CoverageMapping/builtinmacro.c index abcdc191523a5d5..5d5a176aa7d87e2 100644 --- a/clang/test/CoverageMapping/builtinmacro.c +++ b/clang/test/CoverageMapping/builtinmacro.c @@ -4,7 +4,7 @@ // CHECK: filename const char *filename (const char *name) { // CHECK-NEXT: File 0, [[@LINE]]:41 -> [[@LINE+3]]:2 = #0 - static const char this_file[] = __FILE__; + static const char this_file[] = __FILE__; // CHECK-NEXT: File 0, [[@LINE]]:35 -> [[@LINE]]:35 = #0 return this_file; } diff --git a/clang/test/CoverageMapping/macros.c b/clang/test/CoverageMapping/macros.c index 6bd3be434139a21..fcf21170ef135cf 100644 --- a/clang/test/CoverageMapping/macros.c +++ b/clang/test/CoverageMapping/macros.c @@ -80,12 +80,14 @@ void func7(void) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+6]]:2 = #0 int kk,ll; // CHECK-NEXT: File 0, [[@LINE+1]]:7 -> [[@LINE+1]]:8 = #0 if (k) // CHECK-NEXT: Branch,File 0, [[@LINE]]:7 -> [[@LINE]]:8 = #1 m(k); // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:9 -> [[@LINE]]:5 = #1 - else // CHECK-NEXT: Expansion,File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:6 = #0 + else // CHECK-NEXT: Expansion,File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:6 = #1 l = m(l); // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:7 -> [[@LINE]]:5 = (#0 - #1) } // CHECK-NEXT: File 0, [[@LINE-1]]:5 -> [[@LINE-1]]:10 = (#0 - #1) // CHECK-NEXT: Expansion,File 0, [[@LINE-2]]:9 -> [[@LINE-2]]:10 = (#0 - #1) - // CHECK-NEXT: File 1, [[@LINE-9]]:14 -> [[@LINE-9]]:18 = #0 - // CHECK-NEXT: File 2, [[@LINE-10]]:14 -> [[@LINE-10]]:15 = (#0 - #1) + // CHECK-NEXT: File 1, [[@LINE-9]]:14 -> [[@LINE-9]]:17 = #1 + // CHECK-NEXT: File 1, [[@LINE-10]]:14 -> [[@LINE-10]]:18 = #0 + // CHECK-NEXT: File 2, [[@LINE-11]]:14 -> [[@LINE-11]]:17 = (#0 - #1) + // CHECK-NEXT: File 2, [[@LINE-12]]:14 -> [[@LINE-12]]:15 = (#0 - #1) int main(int argc, const char *argv[]) { func(); diff --git a/clang/test/CoverageMapping/mcdc-scratch-space.c b/clang/test/CoverageMapping/mcdc-scratch-space.c new file mode 100644 index 000..1b8735cd27445a1 --- /dev/null +++ b/clang/test/CoverageMapping/mcdc-scratch-space.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c99 -fcoverage-mcdc -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s + +// CHECK: builtin_macro0: +int builtin_macro0(int a) { + // CHECK: Decision,File 0, [[@LINE+1]]:11 -> [[@LINE+2]]:15 = M:0, C:2 + return (__LINE__ // CHECK: Branch,File 0, [[@LINE]]:11 -> [[@LINE]]:11 = 0, 0 [1,2,0] + && a); // CHECK: Branch,File 0, [[@LINE]]:14 -> [[@LINE]]:15 = #2, (#1 - #2) [2,0,0] +} + +// CHECK: builtin_macro1: +int builtin_macro1(int a) { + // CHECK: Decision,File 0, [[@LINE+1]]:11 -> [[@LINE+2]]:22 = M:0, C:2 + return (a // CHECK: Branch,File 0, [[@LINE]]:11 -> [[@LINE]]:12 =
[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lambda itself and not a derived class. +auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl(); +auto *LambdaTy = cast(Field->getParent()); +if (ThisTy != LambdaTy) { + CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, + /*DetectVirtual=*/false); + + [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths); + assert(Derived && "Type not derived from lambda type?"); Sirraide wrote: > Also, maybe we should record the correct path in the AST somewhere? That would probably be less of a hack than doing this here, but the main problem I see is that all we have here is a DRE; it just seems a bit strange to store cast paths in one—at least to me. https://github.com/llvm/llvm-project/pull/89828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lambda itself and not a derived class. +auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl(); +auto *LambdaTy = cast(Field->getParent()); +if (ThisTy != LambdaTy) { + CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, + /*DetectVirtual=*/false); + + [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths); + assert(Derived && "Type not derived from lambda type?"); efriedma-quic wrote: https://isocpp.org/std/submit-issue for defect reports Also, maybe we should record the correct path in the AST somewhere? https://github.com/llvm/llvm-project/pull/89828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Correctly determine the toolchain linker (PR #89803)
madhur13490 wrote: Thanks for fixing this after our discord chats! https://github.com/llvm/llvm-project/pull/89803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions (PR #89867)
https://github.com/4vtomat updated https://github.com/llvm/llvm-project/pull/89867 >From 4db9d00610f110a163a1b7d5b168461f6a91f4ed Mon Sep 17 00:00:00 2001 From: Brandon Wu Date: Tue, 23 Apr 2024 20:42:33 -0700 Subject: [PATCH] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions Since the requirement is EEW=32, it's impossible that EGW=128 needs LMUL=8. --- clang/include/clang/Basic/riscv_vector.td | 3 +-- .../non-policy/non-overloaded/vaesdf.c | 10 -- .../non-policy/non-overloaded/vaesdm.c | 10 -- .../non-policy/non-overloaded/vaesef.c | 10 -- .../non-policy/non-overloaded/vaesem.c | 10 -- .../non-policy/non-overloaded/vaesz.c | 10 -- .../non-policy/non-overloaded/vsm4r.c | 10 -- .../non-policy/overloaded/vaesdf.c | 10 -- .../non-policy/overloaded/vaesdm.c | 10 -- .../non-policy/overloaded/vaesef.c | 10 -- .../non-policy/overloaded/vaesem.c | 10 -- .../non-policy/overloaded/vaesz.c | 10 -- .../non-policy/overloaded/vsm4r.c | 10 -- .../policy/non-overloaded/vaesdf.c | 10 -- .../policy/non-overloaded/vaesdm.c | 10 -- .../policy/non-overloaded/vaesef.c | 10 -- .../policy/non-overloaded/vaesem.c | 10 -- .../policy/non-overloaded/vaesz.c | 10 -- .../policy/non-overloaded/vsm4r.c | 10 -- .../policy/overloaded/vaesdf.c | 10 -- .../policy/overloaded/vaesdm.c | 10 -- .../policy/overloaded/vaesef.c | 10 -- .../policy/overloaded/vaesem.c | 10 -- .../policy/overloaded/vaesz.c | 10 -- .../policy/overloaded/vsm4r.c | 10 -- 25 files changed, 1 insertion(+), 242 deletions(-) diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td index 98ae17ec22a047..cca4367751b92b 100644 --- a/clang/include/clang/Basic/riscv_vector.td +++ b/clang/include/clang/Basic/riscv_vector.td @@ -2601,8 +2601,7 @@ multiclass RVVOutBuiltinSetZvk { if HasVS then { foreach vs2_lmul = ["(SEFixedLog2LMUL:-1)", "(SEFixedLog2LMUL:0)", -"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)", -"(SEFixedLog2LMUL:3)"] in { +"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)"] in { defvar name = NAME # !if(!eq(NAME, "vaesz"), "", "_vs"); let OverloadedName = name, IRName = NAME # "_vs", Name = NAME # "_vs", IntrinsicTypes = [-1, 1] in diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c index 76a9ddc0d52946..3e37ac4b774997 100644 --- a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c +++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c @@ -206,13 +206,3 @@ vuint32m8_t test_vaesdf_vv_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { return __riscv_vaesdf_vv_u32m8(vd, vs2, vl); } -// CHECK-RV64-LABEL: define dso_local @test_vaesdf_vs_u32m8_u32m8 -// CHECK-RV64-SAME: ( [[VD:%.*]], [[VS2:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] { -// CHECK-RV64-NEXT: entry: -// CHECK-RV64-NEXT:[[TMP0:%.*]] = call @llvm.riscv.vaesdf.vs.nxv16i32.nxv16i32.i64( [[VD]], [[VS2]], i64 [[VL]], i64 3) -// CHECK-RV64-NEXT:ret [[TMP0]] -// -vuint32m8_t test_vaesdf_vs_u32m8_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { - return __riscv_vaesdf_vs_u32m8_u32m8(vd, vs2, vl); -} - diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c index 468c3f18378d3c..c29c1e983fce67 100644 --- a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c +++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c @@ -206,13 +206,3 @@ vuint32m8_t test_vaesdm_vv_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { return __riscv_vaesdm_vv_u32m8(vd, vs2, vl); } -// CHECK-RV64-LABEL: define dso_local @test_vaesdm_vs_u32m8_u32m8 -// CHECK-RV64-SAME: ( [[VD:%.*]], [[VS2:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] { -// CHECK-RV64-NEXT: entry: -// CHECK-RV64-NEXT:[[TMP0:%.*]] = call @llvm.riscv.vaesdm.vs.nxv16i32.nxv16i32.i64( [[VD]], [[VS2]], i64 [[VL]], i64 3) -// CHECK-RV6
[clang] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions (PR #89867)
https://github.com/4vtomat edited https://github.com/llvm/llvm-project/pull/89867 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions (PR #89867)
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v Author: Brandon Wu (4vtomat) Changes Since the minimum requirement is EEW=32, it's impossible that EGW=128 needs LMUL=8. --- Patch is 28.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/89867.diff 25 Files Affected: - (modified) clang/include/clang/Basic/riscv_vector.td (+1-2) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsm4r.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsm4r.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsm4r.c (-10) ``diff diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td index 98ae17ec22a047..cca4367751b92b 100644 --- a/clang/include/clang/Basic/riscv_vector.td +++ b/clang/include/clang/Basic/riscv_vector.td @@ -2601,8 +2601,7 @@ multiclass RVVOutBuiltinSetZvk { if HasVS then { foreach vs2_lmul = ["(SEFixedLog2LMUL:-1)", "(SEFixedLog2LMUL:0)", -"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)", -"(SEFixedLog2LMUL:3)"] in { +"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)"] in { defvar name = NAME # !if(!eq(NAME, "vaesz"), "", "_vs"); let OverloadedName = name, IRName = NAME # "_vs", Name = NAME # "_vs", IntrinsicTypes = [-1, 1] in diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c index 76a9ddc0d52946..3e37ac4b774997 100644 --- a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c +++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c @@ -206,13 +206,3 @@ vuint32m8_t test_vaesdf_vv_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { return __riscv_vaesdf_vv_u32m8(vd, vs2, vl); } -// CHECK-RV64-LABEL: define dso_local @test_vaesdf_vs_u32m8_u32m8 -// CHECK-RV64-SAME: ( [[VD:%.*]], [[VS2:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] { -// CHECK-RV64-NEXT: entry: -// CHECK-RV64-NEXT:[[TMP0:%.*]] = call @llvm.riscv.vaesdf.vs.nxv16i32.nxv16i32.i64( [[VD]], [[VS2]], i64 [[VL]], i64 3) -// CHECK-RV64-NEXT:ret [[TMP0]] -// -vuint32m8_t test_vaesdf_vs_u32m8_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { - return __riscv_vaesdf_vs_u32m8_u32m8(vd, vs2, vl); -} - diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overl
[clang] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions (PR #89867)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Brandon Wu (4vtomat) Changes Since the minimum requirement is EEW=32, it's impossible that EGW=128 needs LMUL=8. --- Patch is 28.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/89867.diff 25 Files Affected: - (modified) clang/include/clang/Basic/riscv_vector.td (+1-2) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsm4r.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsm4r.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesdf.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesdm.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesef.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesem.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaesz.c (-10) - (modified) clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsm4r.c (-10) ``diff diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td index 98ae17ec22a047..cca4367751b92b 100644 --- a/clang/include/clang/Basic/riscv_vector.td +++ b/clang/include/clang/Basic/riscv_vector.td @@ -2601,8 +2601,7 @@ multiclass RVVOutBuiltinSetZvk { if HasVS then { foreach vs2_lmul = ["(SEFixedLog2LMUL:-1)", "(SEFixedLog2LMUL:0)", -"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)", -"(SEFixedLog2LMUL:3)"] in { +"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)"] in { defvar name = NAME # !if(!eq(NAME, "vaesz"), "", "_vs"); let OverloadedName = name, IRName = NAME # "_vs", Name = NAME # "_vs", IntrinsicTypes = [-1, 1] in diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c index 76a9ddc0d52946..3e37ac4b774997 100644 --- a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c +++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c @@ -206,13 +206,3 @@ vuint32m8_t test_vaesdf_vv_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { return __riscv_vaesdf_vv_u32m8(vd, vs2, vl); } -// CHECK-RV64-LABEL: define dso_local @test_vaesdf_vs_u32m8_u32m8 -// CHECK-RV64-SAME: ( [[VD:%.*]], [[VS2:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] { -// CHECK-RV64-NEXT: entry: -// CHECK-RV64-NEXT:[[TMP0:%.*]] = call @llvm.riscv.vaesdf.vs.nxv16i32.nxv16i32.i64( [[VD]], [[VS2]], i64 [[VL]], i64 3) -// CHECK-RV64-NEXT:ret [[TMP0]] -// -vuint32m8_t test_vaesdf_vs_u32m8_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { - return __riscv_vaesdf_vs_u32m8_u32m8(vd, vs2, vl); -} - diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vae
[clang] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions (PR #89867)
https://github.com/4vtomat created https://github.com/llvm/llvm-project/pull/89867 Since the minimum requirement is EEW=32, it's impossible that EGW=128 needs LMUL=8. >From 1ed74c3732194512da7eee2e16bc252269f0e6ef Mon Sep 17 00:00:00 2001 From: Brandon Wu Date: Tue, 23 Apr 2024 20:42:33 -0700 Subject: [PATCH] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions Since the minimum requirement is EEW=32, it's impossible that EGW=128 needs LMUL=8. --- clang/include/clang/Basic/riscv_vector.td | 3 +-- .../non-policy/non-overloaded/vaesdf.c | 10 -- .../non-policy/non-overloaded/vaesdm.c | 10 -- .../non-policy/non-overloaded/vaesef.c | 10 -- .../non-policy/non-overloaded/vaesem.c | 10 -- .../non-policy/non-overloaded/vaesz.c | 10 -- .../non-policy/non-overloaded/vsm4r.c | 10 -- .../non-policy/overloaded/vaesdf.c | 10 -- .../non-policy/overloaded/vaesdm.c | 10 -- .../non-policy/overloaded/vaesef.c | 10 -- .../non-policy/overloaded/vaesem.c | 10 -- .../non-policy/overloaded/vaesz.c | 10 -- .../non-policy/overloaded/vsm4r.c | 10 -- .../policy/non-overloaded/vaesdf.c | 10 -- .../policy/non-overloaded/vaesdm.c | 10 -- .../policy/non-overloaded/vaesef.c | 10 -- .../policy/non-overloaded/vaesem.c | 10 -- .../policy/non-overloaded/vaesz.c | 10 -- .../policy/non-overloaded/vsm4r.c | 10 -- .../policy/overloaded/vaesdf.c | 10 -- .../policy/overloaded/vaesdm.c | 10 -- .../policy/overloaded/vaesef.c | 10 -- .../policy/overloaded/vaesem.c | 10 -- .../policy/overloaded/vaesz.c | 10 -- .../policy/overloaded/vsm4r.c | 10 -- 25 files changed, 1 insertion(+), 242 deletions(-) diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td index 98ae17ec22a047..cca4367751b92b 100644 --- a/clang/include/clang/Basic/riscv_vector.td +++ b/clang/include/clang/Basic/riscv_vector.td @@ -2601,8 +2601,7 @@ multiclass RVVOutBuiltinSetZvk { if HasVS then { foreach vs2_lmul = ["(SEFixedLog2LMUL:-1)", "(SEFixedLog2LMUL:0)", -"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)", -"(SEFixedLog2LMUL:3)"] in { +"(SEFixedLog2LMUL:1)", "(SEFixedLog2LMUL:2)"] in { defvar name = NAME # !if(!eq(NAME, "vaesz"), "", "_vs"); let OverloadedName = name, IRName = NAME # "_vs", Name = NAME # "_vs", IntrinsicTypes = [-1, 1] in diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c index 76a9ddc0d52946..3e37ac4b774997 100644 --- a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c +++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c @@ -206,13 +206,3 @@ vuint32m8_t test_vaesdf_vv_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { return __riscv_vaesdf_vv_u32m8(vd, vs2, vl); } -// CHECK-RV64-LABEL: define dso_local @test_vaesdf_vs_u32m8_u32m8 -// CHECK-RV64-SAME: ( [[VD:%.*]], [[VS2:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] { -// CHECK-RV64-NEXT: entry: -// CHECK-RV64-NEXT:[[TMP0:%.*]] = call @llvm.riscv.vaesdf.vs.nxv16i32.nxv16i32.i64( [[VD]], [[VS2]], i64 [[VL]], i64 3) -// CHECK-RV64-NEXT:ret [[TMP0]] -// -vuint32m8_t test_vaesdf_vs_u32m8_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { - return __riscv_vaesdf_vs_u32m8_u32m8(vd, vs2, vl); -} - diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c index 468c3f18378d3c..c29c1e983fce67 100644 --- a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c +++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c @@ -206,13 +206,3 @@ vuint32m8_t test_vaesdm_vv_u32m8(vuint32m8_t vd, vuint32m8_t vs2, size_t vl) { return __riscv_vaesdm_vv_u32m8(vd, vs2, vl); } -// CHECK-RV64-LABEL: define dso_local @test_vaesdm_vs_u32m8_u32m8 -// CHECK-RV64-SAME: ( [[VD:%.*]], [[VS2:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] { -// CHECK-RV64-NEXT: entry: -// CHECK-RV64-NEXT:[[TMP0:%.*]] = call @
[clang] [AMDGPU] Correctly determine the toolchain linker (PR #89803)
@@ -24,3 +24,9 @@ // RUN: -L. -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=MCPU %s // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions" // MCPU: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906" + +// We do not suppor the BFD linker, but we should be able to override the madhur13490 wrote: s/suppor/support https://github.com/llvm/llvm-project/pull/89803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] fix a bug on template partial specialization (PR #89862)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Qizhi Hu (jcsxky) Changes attempt to fix https://github.com/llvm/llvm-project/issues/68885#issuecomment-1764201896 Deduction of NTTP whose type is `decltype(auto)` would create an implicit cast expression to dependent type and makes the type of primary template definition (`InjectedClassNameSpecialization`) and its partial specialization different. Prevent emitting cast expression to make clang knows their types are identical by removing `CTAK == CTAK_Deduced` when the type is `decltype(auto)`. --- Full diff: https://github.com/llvm/llvm-project/pull/89862.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/SemaTemplate.cpp (+1-1) - (added) clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp (+13) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3db558a1c11a3f..27341fb0e3a772 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -561,6 +561,7 @@ Bug Fixes to C++ Support - Fixed a crash when trying to evaluate a user-defined ``static_assert`` message whose ``size()`` function returns a large or negative value. Fixes (#GH89407). - Fixed a use-after-free bug in parsing of type constraints with default arguments that involve lambdas. (#GH67235) +- Fix a bug on template partial specialization whose template parameter is `decltype(auto)`. Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 4bda31ba67c02d..345d77849b49d0 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7706,7 +7706,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // FIXME: The language rules don't say what happens in this case. // FIXME: We get an opaque dependent type out of decltype(auto) if the // expression is merely instantiation-dependent; is this enough? -if (CTAK == CTAK_Deduced && Arg->isTypeDependent()) { +if (Arg->isTypeDependent()) { auto *AT = dyn_cast(DeducedT); if (AT && AT->isDecltypeAuto()) { SugaredConverted = TemplateArgument(Arg); diff --git a/clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp b/clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp new file mode 100644 index 00..ad51ca8252ef50 --- /dev/null +++ b/clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s + +template +struct S { // expected-note {{previous definition is here}} +static constexpr int i = 42; +}; + +template +struct S { // expected-error {{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} \ + // expected-error {{redefinition of 'S'}} +static constexpr int i = 0; +}; `` https://github.com/llvm/llvm-project/pull/89862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] fix a bug on template partial specialization (PR #89862)
https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/89862 attempt to fix https://github.com/llvm/llvm-project/issues/68885#issuecomment-1764201896 Deduction of NTTP whose type is `decltype(auto)` would create an implicit cast expression to dependent type and makes the type of primary template definition (`InjectedClassNameSpecialization`) and its partial specialization different. Prevent emitting cast expression to make clang knows their types are identical by removing `CTAK == CTAK_Deduced` when the type is `decltype(auto)`. >From 9b3e69844033a99be0eef90e816b9dff3e64c901 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Wed, 24 Apr 2024 09:37:53 +0800 Subject: [PATCH] [Clang][Sema] fix a bug on template partial specialization --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaTemplate.cpp | 2 +- ...dentical-type-primary-partial-specialization.cpp | 13 + 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3db558a1c11a3f..27341fb0e3a772 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -561,6 +561,7 @@ Bug Fixes to C++ Support - Fixed a crash when trying to evaluate a user-defined ``static_assert`` message whose ``size()`` function returns a large or negative value. Fixes (#GH89407). - Fixed a use-after-free bug in parsing of type constraints with default arguments that involve lambdas. (#GH67235) +- Fix a bug on template partial specialization whose template parameter is `decltype(auto)`. Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 4bda31ba67c02d..345d77849b49d0 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7706,7 +7706,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // FIXME: The language rules don't say what happens in this case. // FIXME: We get an opaque dependent type out of decltype(auto) if the // expression is merely instantiation-dependent; is this enough? -if (CTAK == CTAK_Deduced && Arg->isTypeDependent()) { +if (Arg->isTypeDependent()) { auto *AT = dyn_cast(DeducedT); if (AT && AT->isDecltypeAuto()) { SugaredConverted = TemplateArgument(Arg); diff --git a/clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp b/clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp new file mode 100644 index 00..ad51ca8252ef50 --- /dev/null +++ b/clang/test/SemaCXX/identical-type-primary-partial-specialization.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s + +template +struct S { // expected-note {{previous definition is here}} +static constexpr int i = 42; +}; + +template +struct S { // expected-error {{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} \ + // expected-error {{redefinition of 'S'}} +static constexpr int i = 0; +}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lambda itself and not a derived class. +auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl(); +auto *LambdaTy = cast(Field->getParent()); +if (ThisTy != LambdaTy) { + CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, + /*DetectVirtual=*/false); + + [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths); + assert(Derived && "Type not derived from lambda type?"); Sirraide wrote: > We can manually resolve between the `operator()`s at the call site with a > qualified member name Ah, that’s what I was missing. > I think you need to open a DR with the committee. That sounds reasonable, but I candidly have no idea how to do that. > Please go ahead and diagnose that condition in Sema. Will do. https://github.com/llvm/llvm-project/pull/89828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lambda itself and not a derived class. +auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl(); +auto *LambdaTy = cast(Field->getParent()); +if (ThisTy != LambdaTy) { + CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, + /*DetectVirtual=*/false); + + [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths); + assert(Derived && "Type not derived from lambda type?"); rjmccall wrote: We can manually resolve between the `operator()`s at the call site with a qualified member name, and the `operator()` should still get called with the original `Overloaded` without any hint about which subobject it was called on. We could also have `Overloaded` just pick one of its bases to `using` the `operator()` from, but then I suppose someone might argue that the operator ought to pick up on that to decide the base path. (That would be absurd, IMO.) Example of the first: https://godbolt.org/z/rqvKGfevY I think you need to open a DR with the committee. It just needs to be ill-formed for a lambda call operator with an explicit `this` parameter to be instantiated such that the `this` parameter has a type with multiple base subobjects of the lambda type. I can't imagine any other resolution short of something absurd like adding an implicit offset parameter, which would then be breaking in other ways. Please go ahead and diagnose that condition in Sema. https://github.com/llvm/llvm-project/pull/89828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
ChuanqiXu9 wrote: @rjmccall @dwblaikie ping https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)
https://github.com/ChuanqiXu9 edited https://github.com/llvm/llvm-project/pull/89751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Set the default arch for z/OS to be arch10 (PR #89854)
MaskRay wrote: We are trying to remove such cmake variables in favor of configuration file. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][PAC][clang][ELF] Support PAuth ABI core info (PR #85235)
kovdan01 wrote: @MaskRay Please see fixes for your previous comments in several latest commits. Would be glad to see new feedback on the PR. Note: the buildkite failure on Windows is flang-related and not related to these changes. https://github.com/llvm/llvm-project/pull/85235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lambda itself and not a derived class. +auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl(); +auto *LambdaTy = cast(Field->getParent()); +if (ThisTy != LambdaTy) { + CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, + /*DetectVirtual=*/false); + + [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths); + assert(Derived && "Type not derived from lambda type?"); Sirraide wrote: That’s something I’m not entirely sure about, but I couldn’t come up with a way to actually end up with more than one path from a derived class to the lambda’s type such that both would still be accessible. https://github.com/llvm/llvm-project/pull/89828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lambda itself and not a derived class. +auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl(); +auto *LambdaTy = cast(Field->getParent()); +if (ThisTy != LambdaTy) { + CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/true, + /*DetectVirtual=*/false); + + [[maybe_unused]] bool Derived = ThisTy->isDerivedFrom(LambdaTy, Paths); + assert(Derived && "Type not derived from lambda type?"); rjmccall wrote: Is there a reason there has to be a unique base subobject of the lambda type? https://github.com/llvm/llvm-project/pull/89828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)
https://github.com/ChuanqiXu9 commented: The higher level idea looks fine. https://github.com/llvm/llvm-project/pull/89751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)
@@ -1523,24 +1442,16 @@ struct SwitchCoroutineSplitter { createResumeEntryBlock(F, Shape); auto *ResumeClone = -createClone(F, ".resume", Shape, CoroCloner::Kind::SwitchResume); +createClone(F, ".resume", Shape, CoroCloner::Kind::SwitchResume, TTI); auto *DestroyClone = -createClone(F, ".destroy", Shape, CoroCloner::Kind::SwitchUnwind); +createClone(F, ".destroy", Shape, CoroCloner::Kind::SwitchUnwind, TTI); auto *CleanupClone = -createClone(F, ".cleanup", Shape, CoroCloner::Kind::SwitchCleanup); +createClone(F, ".cleanup", Shape, CoroCloner::Kind::SwitchCleanup, TTI); postSplitCleanup(*ResumeClone); postSplitCleanup(*DestroyClone); postSplitCleanup(*CleanupClone); -// Adding musttail call to support symmetric transfer. -// Skip targets which don't support tail call. -// -// FIXME: Could we support symmetric transfer effectively without musttail ChuanqiXu9 wrote: Maybe we need to remain the FIXME https://github.com/llvm/llvm-project/pull/89751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)
https://github.com/ChuanqiXu9 edited https://github.com/llvm/llvm-project/pull/89751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits