[clang] [Clang][CodeGen][UBSan] Add more precise attributes to recoverable ubsan handlers (PR #130990)
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/130990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Optimize Module Dependency Handling for Efficient Memory Usage (PR #132638)
ayushpareek2003 wrote: @Bigcheese sir please have a look https://github.com/llvm/llvm-project/pull/132638 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Format] Use a range constructor of DenseSet (NFC) (PR #133382)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Kazu Hirata (kazutakahirata) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/133382.diff 1 Files Affected: - (modified) clang/lib/Format/MacroCallReconstructor.cpp (+3-3) ``diff diff --git a/clang/lib/Format/MacroCallReconstructor.cpp b/clang/lib/Format/MacroCallReconstructor.cpp index 101acefdfe7a3..f69a6aabc7d47 100644 --- a/clang/lib/Format/MacroCallReconstructor.cpp +++ b/clang/lib/Format/MacroCallReconstructor.cpp @@ -365,9 +365,9 @@ void MacroCallReconstructor::endReconstruction(FormatToken *Token) { } void MacroCallReconstructor::debugParentMap() const { - llvm::DenseSet Values; - for (const auto &P : SpelledParentToReconstructedParent) -Values.insert(P.second); + llvm::DenseSet Values( + llvm::from_range, + llvm::make_second_range(SpelledParentToReconstructedParent)); for (const auto &P : SpelledParentToReconstructedParent) { if (Values.contains(P.first)) `` https://github.com/llvm/llvm-project/pull/133382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 0a74cbf - [libclc] Pass -fapprox-func when compiling 'native' builtins (#133119)
Author: Fraser Cormack Date: 2025-03-28T08:22:19Z New Revision: 0a74cbfac462dfbf446e1f560e987619f93194ac URL: https://github.com/llvm/llvm-project/commit/0a74cbfac462dfbf446e1f560e987619f93194ac DIFF: https://github.com/llvm/llvm-project/commit/0a74cbfac462dfbf446e1f560e987619f93194ac.diff LOG: [libclc] Pass -fapprox-func when compiling 'native' builtins (#133119) The libclc build system isn't well set up to pass arbitrary options to arbitrary source files in a non-intrusive way. There isn't currently any other motivating example to warrant rewriting the build system just to satisfy this requirement. So this commit uses a filename-based approach to inserting this option into the list of compile flags. Added: Modified: libclc/CMakeLists.txt libclc/cmake/modules/AddLibclc.cmake Removed: diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 3de7ee9b707a8..59a70a200c95c 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -262,6 +262,28 @@ if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- IN_LIST LIBCLC_TARGETS set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" ) endif() +set_source_files_properties( + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_divide.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp2.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log2.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_powr.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_recip.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_rsqrt.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sin.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sqrt.cl + ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_tan.cl + ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_exp.cl + ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log.cl + ${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log10.cl + ${CMAKE_CURRENT_SOURCE_DIR}/r600/lib/math/native_rsqrt.cl + PROPERTIES COMPILE_OPTIONS -fapprox-func +) + enable_testing() foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index be8937cd13107..e88f9e4643356 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -261,11 +261,17 @@ function(add_libclc_builtin_set) get_filename_component( file_dir ${file} DIRECTORY ) +set( file_specific_compile_options ) +get_source_file_property( compile_opts ${file} COMPILE_OPTIONS) +if( compile_opts ) + set( file_specific_compile_options "${compile_opts}" ) +endif() + compile_to_bc( TRIPLE ${ARG_TRIPLE} INPUT ${input_file} OUTPUT ${output_file} - EXTRA_OPTS -fno-builtin -nostdlib + EXTRA_OPTS -fno-builtin -nostdlib "${file_specific_compile_options}" "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir} DEPENDENCIES ${input_file_dep} ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PATCH] [clang][frontend] Fix serialization for CXXConstructorDecl (refs llvm#132794) (PR #133077)
https://github.com/koplas edited https://github.com/llvm/llvm-project/pull/133077 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Pass -fapprox-func when compiling 'native' builtins (PR #133119)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/133119 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PATCH] [clang][frontend] Fix serialization for CXXConstructorDecl (refs llvm#132794) (PR #133077)
koplas wrote: @shafik, I updated the commit message based on the feedback of @cor3ntin. I have now updated the title and description to reflect the new commit message, to avoid further confusion. https://github.com/llvm/llvm-project/pull/133077 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Fix the crash when dump the deserialized decl (PR #133395)
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/133395 None >From 4095be6747a5d6f3cd619c644490c4170ab44d89 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 28 Mar 2025 09:32:50 +0100 Subject: [PATCH] [WIP] Fix the crash when dump the deserialized decl --- .../ASTDeserializationListener.h | 4 ++ clang/lib/Frontend/FrontendAction.cpp | 42 --- clang/lib/Serialization/ASTReader.cpp | 2 + 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h b/clang/include/clang/Serialization/ASTDeserializationListener.h index ea96faa07c191..0ea96ecb01c50 100644 --- a/clang/include/clang/Serialization/ASTDeserializationListener.h +++ b/clang/include/clang/Serialization/ASTDeserializationListener.h @@ -27,6 +27,8 @@ class MacroInfo; class Module; class SourceLocation; +// IMPORTANT: when you add a new interface to this class, please update the +// DelegatingDeserializationListener in FrontendAction.cpp class ASTDeserializationListener { public: virtual ~ASTDeserializationListener(); @@ -57,6 +59,8 @@ class ASTDeserializationListener { /// A module import was read from the AST file. virtual void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) {} + /// The deserialization of the AST file was finished + virtual void FinishedDeserializing() {} }; } diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 9f789f093f55d..f6ad89c4d2821 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -76,6 +76,10 @@ class DelegatingDeserializationListener : public ASTDeserializationListener { if (Previous) Previous->IdentifierRead(ID, II); } + void MacroRead(serialization::MacroID ID, MacroInfo *MI) override { +if (Previous) + Previous->MacroRead(ID, MI); + } void TypeRead(serialization::TypeIdx Idx, QualType T) override { if (Previous) Previous->TypeRead(Idx, T); @@ -93,6 +97,19 @@ class DelegatingDeserializationListener : public ASTDeserializationListener { if (Previous) Previous->MacroDefinitionRead(PPID, MD); } + void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override { +if (Previous) + Previous->ModuleRead(ID, Mod); + } + void ModuleImportRead(serialization::SubmoduleID ID, +SourceLocation ImportLoc) override { +if (Previous) + Previous->ModuleImportRead(ID, ImportLoc); + } + void FinishedDeserializing() override { +if (Previous) + Previous->FinishedDeserializing(); + } }; /// Dumps deserialized declarations. @@ -103,15 +120,28 @@ class DeserializedDeclsDumper : public DelegatingDeserializationListener { : DelegatingDeserializationListener(Previous, DeletePrevious) {} void DeclRead(GlobalDeclID ID, const Decl *D) override { -llvm::outs() << "PCH DECL: " << D->getDeclKindName(); -if (const NamedDecl *ND = dyn_cast(D)) { - llvm::outs() << " - "; - ND->printQualifiedName(llvm::outs()); +PendingDecls.push_back(D); +DelegatingDeserializationListener::DeclRead(ID, D); + } + void FinishedDeserializing() override { +auto Decls = std::move(PendingDecls); +for (const auto *D : Decls) { + llvm::outs() << "PCH DECL: " << D->getDeclKindName(); + if (const NamedDecl *ND = dyn_cast(D)) { +llvm::outs() << " - "; +ND->printQualifiedName(llvm::outs()); + } + llvm::outs() << "\n"; } -llvm::outs() << "\n"; -DelegatingDeserializationListener::DeclRead(ID, D); +if (!PendingDecls.empty()) { + llvm::errs() << "triger deseralization more!\n"; + PendingDecls.clear(); +} +DelegatingDeserializationListener::FinishedDeserializing(); } +private: + std::vector PendingDecls; }; /// Checks deserialized declarations and emits error if a name diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 0cd2cedb48dd9..9e3712226491a 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -10877,6 +10877,8 @@ void ASTReader::FinishedDeserializing() { // decls to the consumer. if (Consumer) PassInterestingDeclsToConsumer(); +if (DeserializationListener) + DeserializationListener->FinishedDeserializing(); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Fix the crash when dump the deserialized decl (PR #133395)
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 420c056f853d9d5475fc98407ea99b67a11841eb 4095be6747a5d6f3cd619c644490c4170ab44d89 --extensions cpp,h -- clang/include/clang/Serialization/ASTDeserializationListener.h clang/lib/Frontend/FrontendAction.cpp clang/lib/Serialization/ASTReader.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index f6ad89c4d2..279aa9a106 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -108,7 +108,7 @@ public: } void FinishedDeserializing() override { if (Previous) - Previous->FinishedDeserializing(); + Previous->FinishedDeserializing(); } }; @@ -140,8 +140,9 @@ public: } DelegatingDeserializationListener::FinishedDeserializing(); } + private: - std::vector PendingDecls; + std::vector PendingDecls; }; /// Checks deserialized declarations and emits error if a name `` https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Unknown array lvalue element (PR #133381)
https://github.com/T-Gruber updated https://github.com/llvm/llvm-project/pull/133381 >From 241c95a956a440b9a118654baad55fb253d2413c Mon Sep 17 00:00:00 2001 From: T-Gruber Date: Fri, 28 Mar 2025 07:37:59 +0100 Subject: [PATCH 1/5] Remove early return for UnknownVal --- clang/lib/StaticAnalyzer/Core/Store.cpp | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/Store.cpp b/clang/lib/StaticAnalyzer/Core/Store.cpp index 5f30fae4b7047..96e139143bc90 100644 --- a/clang/lib/StaticAnalyzer/Core/Store.cpp +++ b/clang/lib/StaticAnalyzer/Core/Store.cpp @@ -511,13 +511,10 @@ SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset, // Only allow non-integer offsets if the base region has no offset itself. // FIXME: This is a somewhat arbitrary restriction. We should be using // SValBuilder here to add the two offsets without checking their types. - if (!isa(Offset)) { -if (isa(BaseRegion->StripCasts())) - return UnknownVal(); - + if (!isa(Offset)) return loc::MemRegionVal(MRMgr.getElementRegion( elementType, Offset, cast(ElemR->getSuperRegion()), Ctx)); - } + const llvm::APSInt& OffI = Offset.castAs().getValue(); assert(BaseIdxI.isSigned()); >From d993a7f96aebff6f558c1185d1ea6bd7834ede3f Mon Sep 17 00:00:00 2001 From: T-Gruber Date: Fri, 28 Mar 2025 07:38:46 +0100 Subject: [PATCH 2/5] Unittests for StoreManager::getLValueElement --- clang/unittests/StaticAnalyzer/CMakeLists.txt | 1 + .../StoreManagerLValueElement.cpp | 148 ++ 2 files changed, 149 insertions(+) create mode 100644 clang/unittests/StaticAnalyzer/StoreManagerLValueElement.cpp diff --git a/clang/unittests/StaticAnalyzer/CMakeLists.txt b/clang/unittests/StaticAnalyzer/CMakeLists.txt index 3b01a4e9e5327..c95dc39c0c001 100644 --- a/clang/unittests/StaticAnalyzer/CMakeLists.txt +++ b/clang/unittests/StaticAnalyzer/CMakeLists.txt @@ -19,6 +19,7 @@ add_clang_unittest(StaticAnalysisTests ParamRegionTest.cpp RangeSetTest.cpp RegisterCustomCheckersTest.cpp + StoreManagerLValueElement.cpp StoreTest.cpp SymbolReaperTest.cpp SValSimplifyerTest.cpp diff --git a/clang/unittests/StaticAnalyzer/StoreManagerLValueElement.cpp b/clang/unittests/StaticAnalyzer/StoreManagerLValueElement.cpp new file mode 100644 index 0..3949a168c9284 --- /dev/null +++ b/clang/unittests/StaticAnalyzer/StoreManagerLValueElement.cpp @@ -0,0 +1,148 @@ +//===- LValueElementTest.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "CheckerRegistration.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" +#include "llvm/Support/raw_ostream.h" +#include "gtest/gtest.h" +#include + +using namespace clang; +using namespace ento; + +namespace { + +class LValueElementChecker +: public Checker> { +public: + void checkPreStmt(const ArraySubscriptExpr *ASE, CheckerContext &CC) const { +const Expr *BaseEx = ASE->getBase()->IgnoreParens(); +const Expr *IdxEx = ASE->getIdx()->IgnoreParens(); + +SVal BaseVal = CC.getSVal(BaseEx); +SVal IdxVal = CC.getSVal(IdxEx); + +auto IdxNonLoc = IdxVal.getAs(); +ASSERT_TRUE(IdxNonLoc) << "Expect NonLoc as index SVal\n"; + +QualType ArrayT = ASE->getType(); +SVal LValue = +CC.getStoreManager().getLValueElement(ArrayT, *IdxNonLoc, BaseVal); + +if (ExplodedNode *Node = CC.generateNonFatalErrorNode(CC.getState())) { + std::string TmpStr; + llvm::raw_string_ostream TmpStream{TmpStr}; + LValue.dumpToStream(TmpStream); + auto Report = std::make_unique(Bug, TmpStr, Node); + CC.emitReport(std::move(Report)); +} + } + +private: + const BugType Bug{this, "LValueElementBug"}; +}; + +void addLValueElementChecker(AnalysisASTConsumer &AnalysisConsumer, + AnalyzerOptions &AnOpts) { + AnOpts.CheckersAndPackages = {{"LValueElementChecker", true}}; + AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { +Registry.addChecker("LValueElementChecker", "Desc", + "DocsURI"); + }); +} + +bool runLValueElementChecker(StringRef Code, std::string &Output) { + return runCheckerOnCode(Code.str(), Output, + /*OnlyEmitWarnings=*/true); +} + +TEST(LValueElementTest, IdxConInt) { + StringRef Code = R"cpp( +const int index = 1; +extern int array[3]; + +void top() { + array[index]; +})cpp"; + + std::
[clang] [RISCV] Implement Clang Builtins for XCVmac Extension in CV32E40P (PR #110623)
https://github.com/realqhc updated https://github.com/llvm/llvm-project/pull/110623 >From da8b2fc0b5815f5870efe650ba5d585ec14e1a08 Mon Sep 17 00:00:00 2001 From: Qihan Cai Date: Tue, 1 Oct 2024 12:14:15 +1000 Subject: [PATCH 1/4] [RISCV] Implement Clang Builtins for XCVmac Extension in CV32E40P This commit adds the Clang Builtins, C API header and relevant tests for XCVmac extension. Spec: https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md Contributor: @PaoloS02 --- clang/include/clang/Basic/BuiltinsRISCVXCV.td | 72 +++- clang/lib/CodeGen/CGBuiltin.cpp | 55 +++ clang/lib/Headers/CMakeLists.txt | 1 + clang/lib/Headers/riscv_corev_mac.h | 109 ++ clang/test/CodeGen/RISCV/riscv-xcvmac-c-api.c | 343 ++ clang/test/CodeGen/RISCV/riscv-xcvmac.c | 309 6 files changed, 872 insertions(+), 17 deletions(-) create mode 100644 clang/lib/Headers/riscv_corev_mac.h create mode 100644 clang/test/CodeGen/RISCV/riscv-xcvmac-c-api.c create mode 100644 clang/test/CodeGen/RISCV/riscv-xcvmac.c diff --git a/clang/include/clang/Basic/BuiltinsRISCVXCV.td b/clang/include/clang/Basic/BuiltinsRISCVXCV.td index 06ce07ade5c12..4c813ecf3d33d 100644 --- a/clang/include/clang/Basic/BuiltinsRISCVXCV.td +++ b/clang/include/clang/Basic/BuiltinsRISCVXCV.td @@ -11,7 +11,7 @@ // //===--===// -class RISCXCVBuiltin : TargetBuiltin { +class RISCVXCVBuiltin : TargetBuiltin { let Spellings = ["__builtin_riscv_cv_" # NAME]; let Prototype = prototype; let Features = features; @@ -21,21 +21,59 @@ let Attributes = [NoThrow, Const] in { //===--===// // XCValu extension. //===--===// -def alu_slet : RISCXCVBuiltin<"int(int, int)", "xcvalu">; -def alu_sletu : RISCXCVBuiltin<"int(unsigned int, unsigned int)", "xcvalu">; -def alu_exths : RISCXCVBuiltin<"int(int)", "xcvalu">; -def alu_exthz : RISCXCVBuiltin<"unsigned int(unsigned int)", "xcvalu">; -def alu_extbs : RISCXCVBuiltin<"int(int)", "xcvalu">; -def alu_extbz : RISCXCVBuiltin<"unsigned int(unsigned int)", "xcvalu">; +def alu_slet : RISCVXCVBuiltin<"int(int, int)", "xcvalu">; +def alu_sletu : RISCVXCVBuiltin<"int(unsigned int, unsigned int)", "xcvalu">; +def alu_exths : RISCVXCVBuiltin<"int(int)", "xcvalu">; +def alu_exthz : RISCVXCVBuiltin<"unsigned int(unsigned int)", "xcvalu">; +def alu_extbs : RISCVXCVBuiltin<"int(int)", "xcvalu">; +def alu_extbz : RISCVXCVBuiltin<"unsigned int(unsigned int)", "xcvalu">; -def alu_clip : RISCXCVBuiltin<"int(int, int)", "xcvalu">; -def alu_clipu : RISCXCVBuiltin<"unsigned int(unsigned int, unsigned int)", "xcvalu">; -def alu_addN : RISCXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; -def alu_adduN : RISCXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; -def alu_addRN : RISCXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; -def alu_adduRN : RISCXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; -def alu_subN : RISCXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; -def alu_subuN : RISCXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; -def alu_subRN : RISCXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; -def alu_subuRN : RISCXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; +def alu_clip : RISCVXCVBuiltin<"int(int, int)", "xcvalu">; +def alu_clipu : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int)", "xcvalu">; +def alu_addN : RISCVXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; +def alu_adduN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; +def alu_addRN : RISCVXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; +def alu_adduRN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; +def alu_subN : RISCVXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; +def alu_subuN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; +def alu_subRN : RISCVXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; +def alu_subuRN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; + +//===--===// +// XCVmac extension. +//===--===// +def mac_mac : RISCVXCVBuiltin<"int(int, int, int)", "xcvmac">; +def mac_msu : RISCVXCVBuiltin<"int(int, int, int)", "xcvmac">; +def mac_muluN: RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_mulhhuN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int,
[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be initialized by a constant expression}} \ + // nointerpreter-note {{initializer of 'r' is not a constant expression}} \ + // nointerpreter-note {{declared here}} + constexpr int &rr = (rr, y); + constexpr int &g() { +int &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// nointerpreter-note {{declared here}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +return x; + } + constexpr int &gg = g(); // expected-error {{must be initialized by a constant expression}} \ + // nointerpreter-note {{reference to 'x' is not a constant expression}} \ + // interpreter-note {{in call to 'g()'}} + constexpr int g2() { +int &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +return x; + } + constexpr int gg2 = g2(); // expected-error {{must be initialized by a constant expression}} \ + // interpreter-note {{in call to 'g2()'}} + constexpr int &g3() { +int &x = (x,y); // expected-warning{{left operand of comma operator has no effect}} \ +// expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} +return x; + } + constexpr int &gg3 = g3(); + typedef decltype(sizeof(1)) uintptr_t; + constexpr uintptr_t g4() { +uintptr_t * &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +*(uintptr_t*)x = 10; +return 3; + } + constexpr uintptr_t gg4 = g4(); // expected-error {{must be initialized by a constant expression}} \ + // interpreter-note {{in call to 'g4()'}} + constexpr int g5() { +int &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +return 3; + } + constexpr uintptr_t gg5 = g5(); // interpreter-error {{must be initialized by a constant expression}} \ + // interpreter-note {{in call to 'g5()'}} cor3ntin wrote: @zygoloid https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1318a7b - Reland [MIPS] Define SubTargetFeature for i6500 cpu (#132907) (#133366)
Author: Mallikarjuna Gouda Date: 2025-03-28T09:49:38+01:00 New Revision: 1318a7bb098ff055533d7b3fe2f5d9201f3d79a6 URL: https://github.com/llvm/llvm-project/commit/1318a7bb098ff055533d7b3fe2f5d9201f3d79a6 DIFF: https://github.com/llvm/llvm-project/commit/1318a7bb098ff055533d7b3fe2f5d9201f3d79a6.diff LOG: Reland [MIPS] Define SubTargetFeature for i6500 cpu (#132907) (#133366) Relands #132907 with a fix in the testcase: clang/test/CodeGen/Mips/subtarget-feature-test.c enable this test for only mips64 target PR #130587 defined same SubTargetFeature for CPUs i6400 and i6500 which resulted into following warning when -mcpu=i6500 was used: +i6500' is not a recognized feature for this target (ignoring feature) This PR fixes above issue by defining separate SubTargetFeature for i6500. Added: clang/test/CodeGen/Mips/subtarget-feature-test.c Modified: llvm/lib/Target/Mips/Mips.td llvm/lib/Target/Mips/MipsSubtarget.h Removed: diff --git a/clang/test/CodeGen/Mips/subtarget-feature-test.c b/clang/test/CodeGen/Mips/subtarget-feature-test.c new file mode 100644 index 0..4923e2d1fbfd4 --- /dev/null +++ b/clang/test/CodeGen/Mips/subtarget-feature-test.c @@ -0,0 +1,6 @@ +// REQUIRES: mips64-registered-target +// RUN: %clang --target=mips64-linux-gnu -mcpu=i6400 -o %t -c %s 2>&1 | FileCheck --allow-empty %s +// CHECK-NOT: {{.*}} is not a recognized feature for this target + +// RUN: %clang --target=mips64-linux-gnu -mcpu=i6500 -o %t -c %s 2>&1 | FileCheck --allow-empty %s +// CHECK-NOT: {{.*}} is not a recognized feature for this target diff --git a/llvm/lib/Target/Mips/Mips.td b/llvm/lib/Target/Mips/Mips.td index 9159d11fd486f..43a5ae8133d83 100644 --- a/llvm/lib/Target/Mips/Mips.td +++ b/llvm/lib/Target/Mips/Mips.td @@ -242,7 +242,11 @@ def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl", // same CPU architecture. def ImplI6400 : SubtargetFeature<"i6400", "ProcImpl", "MipsSubtarget::CPU::I6400", - "MIPS I6400/I6500 Processors", [FeatureMips64r6]>; + "MIPS I6400 Processor", [FeatureMips64r6]>; + +def ImplI6500 +: SubtargetFeature<"i6500", "ProcImpl", "MipsSubtarget::CPU::I6500", + "MIPS I6500 Processor", [FeatureMips64r6]>; class Proc Features> : ProcessorModel; @@ -268,7 +272,7 @@ def : Proc<"octeon", [FeatureMips64r2, FeatureCnMips]>; def : Proc<"octeon+", [FeatureMips64r2, FeatureCnMips, FeatureCnMipsP]>; def : ProcessorModel<"p5600", MipsP5600Model, [ImplP5600]>; def : ProcessorModel<"i6400", NoSchedModel, [ImplI6400]>; -def : ProcessorModel<"i6500", NoSchedModel, [ImplI6400]>; +def : ProcessorModel<"i6500", NoSchedModel, [ImplI6500]>; def MipsAsmParser : AsmParser { let ShouldEmitMatchRegisterName = 0; diff --git a/llvm/lib/Target/Mips/MipsSubtarget.h b/llvm/lib/Target/Mips/MipsSubtarget.h index 0c75597d3decf..15127b11d5cdd 100644 --- a/llvm/lib/Target/Mips/MipsSubtarget.h +++ b/llvm/lib/Target/Mips/MipsSubtarget.h @@ -43,7 +43,7 @@ class MipsSubtarget : public MipsGenSubtargetInfo { Mips3, Mips4, Mips5, Mips64, Mips64r2, Mips64r3, Mips64r5, Mips64r6 }; - enum class CPU { P5600, I6400 }; + enum class CPU { P5600, I6400, I6500 }; // Used to avoid printing dsp warnings multiple times. static bool DspWarningPrinted; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Reland [MIPS] Define SubTargetFeature for i6500 cpu (#132907) (PR #133366)
https://github.com/djtodoro approved this pull request. https://github.com/llvm/llvm-project/pull/133366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Reland [MIPS] Define SubTargetFeature for i6500 cpu (#132907) (PR #133366)
https://github.com/djtodoro closed https://github.com/llvm/llvm-project/pull/133366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [flang] [libc] [libcxx] [llvm] [Clang][AMDGPU] Remove special handling for COV4 libraries (PR #132870)
https://github.com/saiislam approved this pull request. Thanks, Joseph! LGTM. https://github.com/llvm/llvm-project/pull/132870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move pow, powr & pown to the CLC library (PR #133294)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/133294 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PATCH] [clang][frontend] Fix serialization for CXXConstructorDecl (refs llvm#132794) (PR #133077)
https://github.com/koplas edited https://github.com/llvm/llvm-project/pull/133077 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Haojian Wu (hokein) Changes This fixes crashes with `-dump-deserialized-decls`. The `DeserializedDeclsDumper` implementation has two issues: 1. The `DelegatingDeserializationListener` does not fully implement all interfaces. As a result, the `Previous` listener object misses some critical state updates, leading to inconsistencies and eventual crashes; 3. Print declaration names in the middle of deserialization is not safe, because the decl may still be incomplete; we should do it after the deserialization is finished; No unittest is included -- crash was discovered by @VitaNuo in an internal isolated test which is still large, depending on the stl/absl modules. The issue no longer occurs with this change. --- Full diff: https://github.com/llvm/llvm-project/pull/133395.diff 4 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/include/clang/Serialization/ASTDeserializationListener.h (+4) - (modified) clang/lib/Frontend/FrontendAction.cpp (+38-6) - (modified) clang/lib/Serialization/ASTReader.cpp (+2) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 04ec2cfef679c..9ae29d7e58626 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -316,6 +316,7 @@ Bug Fixes in This Version - Fixed a modules crash where exception specifications were not propagated properly (#GH121245, relanded in #GH129982) - Fixed a problematic case with recursive deserialization within ``FinishedDeserializing()`` where ``PassInterestingDeclsToConsumer()`` was called before the declarations were safe to be passed. (#GH129982) +- Fixed a module crash with `-dump-deserialized-decls` Bug Fixes to Compiler Builtins ^^ diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h b/clang/include/clang/Serialization/ASTDeserializationListener.h index ea96faa07c191..ccbaae93f9048 100644 --- a/clang/include/clang/Serialization/ASTDeserializationListener.h +++ b/clang/include/clang/Serialization/ASTDeserializationListener.h @@ -27,6 +27,8 @@ class MacroInfo; class Module; class SourceLocation; +// IMPORTANT: when you add a new interface to this class, please update the +// DelegatingDeserializationListener in FrontendAction.cpp class ASTDeserializationListener { public: virtual ~ASTDeserializationListener(); @@ -57,6 +59,8 @@ class ASTDeserializationListener { /// A module import was read from the AST file. virtual void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) {} + /// The deserialization of the AST file was finished. + virtual void FinishedDeserializing() {} }; } diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 9f789f093f55d..416ee50593e74 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -76,6 +76,10 @@ class DelegatingDeserializationListener : public ASTDeserializationListener { if (Previous) Previous->IdentifierRead(ID, II); } + void MacroRead(serialization::MacroID ID, MacroInfo *MI) override { +if (Previous) + Previous->MacroRead(ID, MI); + } void TypeRead(serialization::TypeIdx Idx, QualType T) override { if (Previous) Previous->TypeRead(Idx, T); @@ -93,6 +97,19 @@ class DelegatingDeserializationListener : public ASTDeserializationListener { if (Previous) Previous->MacroDefinitionRead(PPID, MD); } + void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override { +if (Previous) + Previous->ModuleRead(ID, Mod); + } + void ModuleImportRead(serialization::SubmoduleID ID, +SourceLocation ImportLoc) override { +if (Previous) + Previous->ModuleImportRead(ID, ImportLoc); + } + void FinishedDeserializing() override { +if (Previous) + Previous->FinishedDeserializing(); + } }; /// Dumps deserialized declarations. @@ -103,15 +120,30 @@ class DeserializedDeclsDumper : public DelegatingDeserializationListener { : DelegatingDeserializationListener(Previous, DeletePrevious) {} void DeclRead(GlobalDeclID ID, const Decl *D) override { -llvm::outs() << "PCH DECL: " << D->getDeclKindName(); -if (const NamedDecl *ND = dyn_cast(D)) { - llvm::outs() << " - "; - ND->printQualifiedName(llvm::outs()); +PendingDecls.push_back(D); +DelegatingDeserializationListener::DeclRead(ID, D); + } + void FinishedDeserializing() override { +auto Decls = std::move(PendingDecls); +for (const auto *D : Decls) { + llvm::outs() << "PCH DECL: " << D->getDeclKindName(); + if (const NamedDecl *ND = dyn_cast(D)) { +llvm::outs() << " - "; +ND->printQualifiedName(llvm::outs()); + } + llvm::outs() << "\n"; } -llvm::outs() << "\n"; -DelegatingDeserializationListene
[clang] [RFC][clang] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)
@@ -1390,7 +1390,19 @@ class ASTReader /// predefines buffer may contain additional definitions. std::string SuggestedPredefines; - llvm::DenseMap DefinitionSource; + struct DefinitionSourceFlags { ChuanqiXu9 wrote: ```suggestion struct DefinitionSourceBits { ``` nit: Personal taste https://github.com/llvm/llvm-project/pull/132214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RFC][clang] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)
@@ -1390,7 +1390,19 @@ class ASTReader /// predefines buffer may contain additional definitions. std::string SuggestedPredefines; - llvm::DenseMap DefinitionSource; + struct DefinitionSourceFlags { +ExtKind HasExternalDefinitions : 2; + +/// Indicates if given function declaration was a definition but its body +/// was removed due to declaration merging. +bool ThisDeclarationWasADefinition : 1; + +DefinitionSourceFlags() +: HasExternalDefinitions(EK_ReplyHazy), + ThisDeclarationWasADefinition(false) {} + }; + + llvm::DenseMap DefinitionSource; ChuanqiXu9 wrote: It might be better to add another new map for it. e.g., Decl is not a function. https://github.com/llvm/llvm-project/pull/132214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Serialization] Fix lazy template loading (PR #133057)
ChuanqiXu9 wrote: > > > > While I may not able to look into them in detail recently, it may be > > > > helpful to split this into seperate patches to review and to land. > > > > > > > > > I initially considered this, but @vgvassilev said in > > > [root-project/root#17722 > > > (comment)](https://github.com/root-project/root/pull/17722#issuecomment-2706555950) > > > he prefers a single PR, also for external testing. > > > > > > Maybe you can test it with this and land it with different patches. So that > > we can revert one of them if either of them are problematic but other parts > > are fine. > > This is a relatively small patch focused on reducing the round trips to > modules deserialization. I see this as an atomic change that if it goes in > partially would defeat its purpose. What's the goal of a partial optimization? I think partial optimizations are optimization too. If these codes are not dependent on each other, it should be better to split them. Given the scale of the patch, it may not be serious problem actually. I still think it is better to land them separately, but if you want to save some typings. I don't feel too bad. https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Fix the crash when dump the deserialized decl (PR #133395)
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: Haojian Wu (hokein) Changes This fixes crashes with `-dump-deserialized-decls`. The `DeserializedDeclsDumper` implementation has two issues: 1. The `DelegatingDeserializationListener` does not fully implement all interfaces. As a result, the `Previous` listener object misses some critical state updates, leading to inconsistencies and eventual crashes; 3. Print declaration names in the middle of deserialization is not safe, because the decl may still be incomplete; we should do it after the deserialization is finished; No unittest is included -- crash was discovered by @VitaNuo in an internal isolated test which is still large, depending on the stl/absl modules. The issue no longer occurs with this change. --- Full diff: https://github.com/llvm/llvm-project/pull/133395.diff 4 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/include/clang/Serialization/ASTDeserializationListener.h (+4) - (modified) clang/lib/Frontend/FrontendAction.cpp (+38-6) - (modified) clang/lib/Serialization/ASTReader.cpp (+2) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 04ec2cfef679c..9ae29d7e58626 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -316,6 +316,7 @@ Bug Fixes in This Version - Fixed a modules crash where exception specifications were not propagated properly (#GH121245, relanded in #GH129982) - Fixed a problematic case with recursive deserialization within ``FinishedDeserializing()`` where ``PassInterestingDeclsToConsumer()`` was called before the declarations were safe to be passed. (#GH129982) +- Fixed a module crash with `-dump-deserialized-decls` Bug Fixes to Compiler Builtins ^^ diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h b/clang/include/clang/Serialization/ASTDeserializationListener.h index ea96faa07c191..ccbaae93f9048 100644 --- a/clang/include/clang/Serialization/ASTDeserializationListener.h +++ b/clang/include/clang/Serialization/ASTDeserializationListener.h @@ -27,6 +27,8 @@ class MacroInfo; class Module; class SourceLocation; +// IMPORTANT: when you add a new interface to this class, please update the +// DelegatingDeserializationListener in FrontendAction.cpp class ASTDeserializationListener { public: virtual ~ASTDeserializationListener(); @@ -57,6 +59,8 @@ class ASTDeserializationListener { /// A module import was read from the AST file. virtual void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) {} + /// The deserialization of the AST file was finished. + virtual void FinishedDeserializing() {} }; } diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 9f789f093f55d..416ee50593e74 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -76,6 +76,10 @@ class DelegatingDeserializationListener : public ASTDeserializationListener { if (Previous) Previous->IdentifierRead(ID, II); } + void MacroRead(serialization::MacroID ID, MacroInfo *MI) override { +if (Previous) + Previous->MacroRead(ID, MI); + } void TypeRead(serialization::TypeIdx Idx, QualType T) override { if (Previous) Previous->TypeRead(Idx, T); @@ -93,6 +97,19 @@ class DelegatingDeserializationListener : public ASTDeserializationListener { if (Previous) Previous->MacroDefinitionRead(PPID, MD); } + void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override { +if (Previous) + Previous->ModuleRead(ID, Mod); + } + void ModuleImportRead(serialization::SubmoduleID ID, +SourceLocation ImportLoc) override { +if (Previous) + Previous->ModuleImportRead(ID, ImportLoc); + } + void FinishedDeserializing() override { +if (Previous) + Previous->FinishedDeserializing(); + } }; /// Dumps deserialized declarations. @@ -103,15 +120,30 @@ class DeserializedDeclsDumper : public DelegatingDeserializationListener { : DelegatingDeserializationListener(Previous, DeletePrevious) {} void DeclRead(GlobalDeclID ID, const Decl *D) override { -llvm::outs() << "PCH DECL: " << D->getDeclKindName(); -if (const NamedDecl *ND = dyn_cast(D)) { - llvm::outs() << " - "; - ND->printQualifiedName(llvm::outs()); +PendingDecls.push_back(D); +DelegatingDeserializationListener::DeclRead(ID, D); + } + void FinishedDeserializing() override { +auto Decls = std::move(PendingDecls); +for (const auto *D : Decls) { + llvm::outs() << "PCH DECL: " << D->getDeclKindName(); + if (const NamedDecl *ND = dyn_cast(D)) { +llvm::outs() << " - "; +ND->printQualifiedName(llvm::outs()); + } + llvm::outs() << "\n"; } -llvm::outs() << "\n"; -DelegatingDeserializatio
[clang] [Serialization] Fix lazy template loading (PR #133057)
vgvassilev wrote: > > > > > While I may not able to look into them in detail recently, it may be > > > > > helpful to split this into seperate patches to review and to land. > > > > > > > > > > > > I initially considered this, but @vgvassilev said in > > > > [root-project/root#17722 > > > > (comment)](https://github.com/root-project/root/pull/17722#issuecomment-2706555950) > > > > he prefers a single PR, also for external testing. > > > > > > > > > Maybe you can test it with this and land it with different patches. So > > > that we can revert one of them if either of them are problematic but > > > other parts are fine. > > > > > > This is a relatively small patch focused on reducing the round trips to > > modules deserialization. I see this as an atomic change that if it goes in > > partially would defeat its purpose. What's the goal of a partial > > optimization? > > I think partial optimizations are optimization too. If these codes are not > dependent on each other, it should be better to split them. > > Given the scale of the patch, it may not be serious problem actually. I still > think it is better to land them separately, but if you want to save some > typings. I don't feel too bad. Honestly I am more concerned about the tests that @ilya-biryukov is running. As long as they are happy I do not particularly care about commit style. Although it'd be weird to land 40 line patch in many commits :) https://github.com/llvm/llvm-project/pull/133057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RFC][clang] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)
ChuanqiXu9 wrote: LGTM generally. Some other personal suggestion to the title, it might be better to add `[modules]` to the title. Since my mail filter will highlight these mails with the tag : ) This might be why I missed you last ping. https://github.com/llvm/llvm-project/pull/132214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream SelectOp and ShiftOp (PR #133405)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Morris Hafner (mmha) Changes Since SelectOp will only generated by a future pass that transforms a TernaryOp this only includes the lowering bits. This patch also improves the testing of the existing binary operators. --- Patch is 28.28 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/133405.diff 7 Files Affected: - (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+73) - (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+5-4) - (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+43) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+87) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+20) - (modified) clang/test/CIR/CodeGen/binop.cpp (+303-14) - (added) clang/test/CIR/Lowering/select.cir (+48) ``diff diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 455cc2b8b0277..5c3d0549c1c47 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -889,6 +889,79 @@ def BinOp : CIR_Op<"binop", [Pure, let hasVerifier = 1; } +//===--===// +// ShiftOp +//===--===// + +def ShiftOp : CIR_Op<"shift", [Pure]> { + let summary = "Shift"; + let description = [{ +Shift `left` or `right`, according to the first operand. Second operand is +the shift target and the third the amount. Second and the thrid operand are +integers. + +```mlir +%7 = cir.shift(left, %1 : !u64i, %4 : !s32i) -> !u64i +``` + }]; + + // TODO(cir): Support vectors. CIR_IntType -> CIR_AnyIntOrVecOfInt. Also + // update the description above. + let results = (outs CIR_IntType:$result); + let arguments = (ins CIR_IntType:$value, CIR_IntType:$amount, + UnitAttr:$isShiftleft); + + let assemblyFormat = [{ +`(` + (`left` $isShiftleft^) : (```right`)? + `,` $value `:` type($value) + `,` $amount `:` type($amount) +`)` `->` type($result) attr-dict + }]; + + let hasVerifier = 1; +} + +//===--===// +// SelectOp +//===--===// + +def SelectOp : CIR_Op<"select", [Pure, +AllTypesMatch<["true_value", "false_value", "result"]>]> { + let summary = "Yield one of two values based on a boolean value"; + let description = [{ +The `cir.select` operation takes three operands. The first operand +`condition` is a boolean value of type `!cir.bool`. The second and the third +operand can be of any CIR types, but their types must be the same. If the +first operand is `true`, the operation yields its second operand. Otherwise, +the operation yields its third operand. + +Example: + +```mlir +%0 = cir.const #cir.bool : !cir.bool +%1 = cir.const #cir.int<42> : !s32i +%2 = cir.const #cir.int<72> : !s32i +%3 = cir.select if %0 then %1 else %2 : (!cir.bool, !s32i, !s32i) -> !s32i +``` + }]; + + let arguments = (ins CIR_BoolType:$condition, CIR_AnyType:$true_value, + CIR_AnyType:$false_value); + let results = (outs CIR_AnyType:$result); + + let assemblyFormat = [{ +`if` $condition `then` $true_value `else` $false_value +`:` `(` + qualified(type($condition)) `,` + qualified(type($true_value)) `,` + qualified(type($false_value)) +`)` `->` qualified(type($result)) attr-dict + }]; + + let hasFolder = 1; +} + //===--===// // GlobalOp //===--===// diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 52bd3b2933744..3a904fa656104 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -1138,8 +1138,9 @@ mlir::Value ScalarExprEmitter::emitShl(const BinOpInfo &ops) { mlir::isa(ops.lhs.getType())) cgf.cgm.errorNYI("sanitizers"); - cgf.cgm.errorNYI("shift ops"); - return {}; + return builder.create(cgf.getLoc(ops.loc), + cgf.convertType(ops.fullType), ops.lhs, + ops.rhs, cgf.getBuilder().getUnitAttr()); } mlir::Value ScalarExprEmitter::emitShr(const BinOpInfo &ops) { @@ -1163,8 +1164,8 @@ mlir::Value ScalarExprEmitter::emitShr(const BinOpInfo &ops) { // Note that we don't need to distinguish unsigned treatment at this // point since it will be handled later by LLVM lowering. - cgf.cgm.errorNYI("shift ops"); - return {}; + return builder.create( + cgf.getLoc(ops.loc), cgf.convertType(ops.fullType), ops.lhs, ops.rh
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
https://github.com/VitaNuo approved this pull request. Thank you @hokein! https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream SelectOp and ShiftOp (PR #133405)
llvmbot wrote: @llvm/pr-subscribers-clangir Author: Morris Hafner (mmha) Changes Since SelectOp will only generated by a future pass that transforms a TernaryOp this only includes the lowering bits. This patch also improves the testing of the existing binary operators. --- Patch is 28.28 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/133405.diff 7 Files Affected: - (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+73) - (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+5-4) - (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+43) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+87) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+20) - (modified) clang/test/CIR/CodeGen/binop.cpp (+303-14) - (added) clang/test/CIR/Lowering/select.cir (+48) ``diff diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 455cc2b8b0277..5c3d0549c1c47 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -889,6 +889,79 @@ def BinOp : CIR_Op<"binop", [Pure, let hasVerifier = 1; } +//===--===// +// ShiftOp +//===--===// + +def ShiftOp : CIR_Op<"shift", [Pure]> { + let summary = "Shift"; + let description = [{ +Shift `left` or `right`, according to the first operand. Second operand is +the shift target and the third the amount. Second and the thrid operand are +integers. + +```mlir +%7 = cir.shift(left, %1 : !u64i, %4 : !s32i) -> !u64i +``` + }]; + + // TODO(cir): Support vectors. CIR_IntType -> CIR_AnyIntOrVecOfInt. Also + // update the description above. + let results = (outs CIR_IntType:$result); + let arguments = (ins CIR_IntType:$value, CIR_IntType:$amount, + UnitAttr:$isShiftleft); + + let assemblyFormat = [{ +`(` + (`left` $isShiftleft^) : (```right`)? + `,` $value `:` type($value) + `,` $amount `:` type($amount) +`)` `->` type($result) attr-dict + }]; + + let hasVerifier = 1; +} + +//===--===// +// SelectOp +//===--===// + +def SelectOp : CIR_Op<"select", [Pure, +AllTypesMatch<["true_value", "false_value", "result"]>]> { + let summary = "Yield one of two values based on a boolean value"; + let description = [{ +The `cir.select` operation takes three operands. The first operand +`condition` is a boolean value of type `!cir.bool`. The second and the third +operand can be of any CIR types, but their types must be the same. If the +first operand is `true`, the operation yields its second operand. Otherwise, +the operation yields its third operand. + +Example: + +```mlir +%0 = cir.const #cir.bool : !cir.bool +%1 = cir.const #cir.int<42> : !s32i +%2 = cir.const #cir.int<72> : !s32i +%3 = cir.select if %0 then %1 else %2 : (!cir.bool, !s32i, !s32i) -> !s32i +``` + }]; + + let arguments = (ins CIR_BoolType:$condition, CIR_AnyType:$true_value, + CIR_AnyType:$false_value); + let results = (outs CIR_AnyType:$result); + + let assemblyFormat = [{ +`if` $condition `then` $true_value `else` $false_value +`:` `(` + qualified(type($condition)) `,` + qualified(type($true_value)) `,` + qualified(type($false_value)) +`)` `->` qualified(type($result)) attr-dict + }]; + + let hasFolder = 1; +} + //===--===// // GlobalOp //===--===// diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 52bd3b2933744..3a904fa656104 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -1138,8 +1138,9 @@ mlir::Value ScalarExprEmitter::emitShl(const BinOpInfo &ops) { mlir::isa(ops.lhs.getType())) cgf.cgm.errorNYI("sanitizers"); - cgf.cgm.errorNYI("shift ops"); - return {}; + return builder.create(cgf.getLoc(ops.loc), + cgf.convertType(ops.fullType), ops.lhs, + ops.rhs, cgf.getBuilder().getUnitAttr()); } mlir::Value ScalarExprEmitter::emitShr(const BinOpInfo &ops) { @@ -1163,8 +1164,8 @@ mlir::Value ScalarExprEmitter::emitShr(const BinOpInfo &ops) { // Note that we don't need to distinguish unsigned treatment at this // point since it will be handled later by LLVM lowering. - cgf.cgm.errorNYI("shift ops"); - return {}; + return builder.create( + cgf.getLoc(ops.loc), cgf.convertType(ops.fullType), ops.lhs, ops.
[clang] [Clang] Fix UB in #131515 (PR #132091)
llvmbot wrote: @llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) Changes It turns out trailing objects are uninitialized and APValue assignment operator requires a fully initialized object. --- Full diff: https://github.com/llvm/llvm-project/pull/132091.diff 3 Files Affected: - (modified) clang/include/clang/AST/ExprCXX.h (+1-1) - (modified) clang/lib/AST/ExprCXX.cpp (+10-2) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+2-2) ``diff diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 724ed437f1075..223d74993e9e6 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -2777,7 +2777,7 @@ class TypeTraitExpr final ArrayRef Args, SourceLocation RParenLoc, std::variant Value); - TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) {} + TypeTraitExpr(EmptyShell Empty, bool IsStoredAsBool); size_t numTrailingObjects(OverloadToken) const { return getNumArgs(); diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index c2cf4ffe506c6..a000e988e6834 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -1868,7 +1868,8 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, if (TypeTraitExprBits.IsBooleanTypeTrait) TypeTraitExprBits.Value = std::get(Value); else -*getTrailingObjects() = std::get(std::move(Value)); +::new (getTrailingObjects()) +APValue(std::get(std::move(Value))); TypeTraitExprBits.NumArgs = Args.size(); assert(Args.size() == TypeTraitExprBits.NumArgs && @@ -1884,6 +1885,13 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, "Only int values are supported by clang"); } +TypeTraitExpr::TypeTraitExpr(EmptyShell Empty, bool IsStoredAsBool) +: Expr(TypeTraitExprClass, Empty) { + TypeTraitExprBits.IsBooleanTypeTrait = IsStoredAsBool; + if (!IsStoredAsBool) +::new (getTrailingObjects()) APValue(); +} + TypeTraitExpr *TypeTraitExpr::Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, @@ -1909,7 +1917,7 @@ TypeTraitExpr *TypeTraitExpr::CreateDeserialized(const ASTContext &C, unsigned NumArgs) { void *Mem = C.Allocate(totalSizeToAlloc( IsStoredAsBool ? 0 : 1, NumArgs)); - return new (Mem) TypeTraitExpr(EmptyShell()); + return new (Mem) TypeTraitExpr(EmptyShell(), IsStoredAsBool); } CUDAKernelCallExpr::CUDAKernelCallExpr(Expr *Fn, CallExpr *Config, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index bd6321c46a78f..a1551e8027cd3 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1681,7 +1681,7 @@ std::optional Sema::GetDecompositionElementCount(QualType T, llvm::APSInt TupleSize(Ctx.getTypeSize(Ctx.getSizeType())); switch (isTupleLike(*this, Loc, T, TupleSize)) { case IsTupleLike::Error: -return {}; +return std::nullopt; case IsTupleLike::TupleLike: return TupleSize.getExtValue(); case IsTupleLike::NotTupleLike: @@ -1706,7 +1706,7 @@ std::optional Sema::GetDecompositionElementCount(QualType T, RD->fields(), [](FieldDecl *FD) { return !FD->isUnnamedBitField(); }); if (CheckMemberDecompositionFields(*this, Loc, OrigRD, T, BasePair)) -return true; +return std::nullopt; return NumFields; } `` https://github.com/llvm/llvm-project/pull/132091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/131237 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [modules] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)
@@ -1390,7 +1390,19 @@ class ASTReader /// predefines buffer may contain additional definitions. std::string SuggestedPredefines; - llvm::DenseMap DefinitionSource; + struct DefinitionSourceFlags { dmpolukhin wrote: Done https://github.com/llvm/llvm-project/pull/132214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [modules] Handle friend function that was a definition but became only a declaration during AST deserialization (PR #132214)
@@ -1390,7 +1390,19 @@ class ASTReader /// predefines buffer may contain additional definitions. std::string SuggestedPredefines; - llvm::DenseMap DefinitionSource; + struct DefinitionSourceFlags { +ExtKind HasExternalDefinitions : 2; + +/// Indicates if given function declaration was a definition but its body +/// was removed due to declaration merging. +bool ThisDeclarationWasADefinition : 1; + +DefinitionSourceFlags() +: HasExternalDefinitions(EK_ReplyHazy), + ThisDeclarationWasADefinition(false) {} + }; + + llvm::DenseMap DefinitionSource; dmpolukhin wrote: I think memory overhead for another map will be higher. The value_type was bool but in reality at least 4-8 bytes were allocated for it so converting it to struct with 3 bits only shouldn't take extra space. https://github.com/llvm/llvm-project/pull/132214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][WIP][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)
@@ -10905,6 +10983,93 @@ bool OverloadCandidate::NotValidBecauseConstraintExprHasError() const { ->Satisfaction.ContainsErrors; } +void OverloadCandidateSet::AddNonDeducedTemplateCandidate( +FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, +ArrayRef Args, bool SuppressUserConversions, +bool PartialOverloading, bool AllowExplicit, +CallExpr::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, +bool AggregateCandidateDeduction) { + NonDeducedFunctionTemplateOverloadCandidate C{FunctionTemplate, +FoundDecl, +Args, +IsADLCandidate, +PO, +SuppressUserConversions, +PartialOverloading, +AllowExplicit, +AggregateCandidateDeduction}; + NonDeducedCandidates.emplace_back(std::move(C)); +} + +void OverloadCandidateSet::AddNonDeducedMethodTemplateCandidate( +FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, +CXXRecordDecl *ActingContext, QualType ObjectType, +Expr::Classification ObjectClassification, ArrayRef Args, +bool SuppressUserConversions, bool PartialOverloading, +OverloadCandidateParamOrder PO) { + NonDeducedMethodTemplateOverloadCandidate C{ + MethodTmpl, FoundDecl, Args, ActingContext, + ObjectClassification, ObjectType, PO, SuppressUserConversions, + PartialOverloading}; + NonDeducedCandidates.emplace_back(std::move(C)); +} + +void OverloadCandidateSet::AddNonDeducedConversionTemplateCandidate( +FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, +CXXRecordDecl *ActingContext, Expr *From, QualType ToType, +bool AllowObjCConversionOnExplicit, bool AllowExplicit, +bool AllowResultConversion) { + + NonDeducedConversionTemplateOverloadCandidate C{ + FunctionTemplate, FoundDecl, + ActingContext,From, + ToType, AllowObjCConversionOnExplicit, + AllowExplicit,AllowResultConversion}; + + NonDeducedCandidates.emplace_back(std::move(C)); +} + +static void +AddTemplateOverloadCandidate(Sema &S, OverloadCandidateSet &CandidateSet, + NonDeducedMethodTemplateOverloadCandidate &&C) { + + S.AddMethodTemplateCandidateImmediately( + CandidateSet, C.FunctionTemplate, C.FoundDecl, C.ActingContext, + /*ExplicitTemplateArgs=*/nullptr, C.ObjectType, C.ObjectClassification, + C.Args, C.SuppressUserConversions, C.PartialOverloading, C.PO); +} + +static void +AddTemplateOverloadCandidate(Sema &S, OverloadCandidateSet &CandidateSet, + NonDeducedFunctionTemplateOverloadCandidate &&C) { + S.AddTemplateOverloadCandidateImmediately( + CandidateSet, C.FunctionTemplate, C.FoundDecl, + /*ExplicitTemplateArgs=*/nullptr, C.Args, C.SuppressUserConversions, + C.PartialOverloading, C.AllowExplicit, C.IsADLCandidate, C.PO, + C.AggregateCandidateDeduction); +} + +static void AddTemplateOverloadCandidate( +Sema &S, OverloadCandidateSet &CandidateSet, +NonDeducedConversionTemplateOverloadCandidate &&C) { + return S.AddTemplateConversionCandidateImmediately( zyn0217 wrote: Can we reuse `InjectNonDeducedTemplateCandidates` for `*Immediately` functions or vice versa? https://github.com/llvm/llvm-project/pull/133426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][WIP][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)
@@ -10918,7 +11083,44 @@ bool OverloadCandidate::NotValidBecauseConstraintExprHasError() const { OverloadingResult OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, iterator &Best) { + + bool TwoPhaseResolution = + !NonDeducedCandidates.empty() && Kind != CSK_CodeCompletion && + Kind != CSK_InitByUserDefinedConversion && Kind != CSK_InitByConstructor; + + if (TwoPhaseResolution) { +Best = end(); +for (auto It = begin(); It != end(); ++It) { + if (It->isPerfectMatch(S.getASTContext())) { +if (Best == end()) { + Best = It; +} else { + Best = end(); + break; +} + } +} +if (Best != end()) { + Best->Best = true; + if (Best->Function && Best->Function->isDeleted()) +return OR_Deleted; + if (auto *M = dyn_cast_or_null(Best->Function); + Kind == CSK_AddressOfOverloadSet && M && + M->isImplicitObjectMemberFunction()) { +return OR_No_Viable_Function; zyn0217 wrote: This does not look obvious to me. Can you explain? https://github.com/llvm/llvm-project/pull/133426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][WIP][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)
@@ -10918,7 +11083,44 @@ bool OverloadCandidate::NotValidBecauseConstraintExprHasError() const { OverloadingResult OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, iterator &Best) { + + bool TwoPhaseResolution = + !NonDeducedCandidates.empty() && Kind != CSK_CodeCompletion && + Kind != CSK_InitByUserDefinedConversion && Kind != CSK_InitByConstructor; + + if (TwoPhaseResolution) { +Best = end(); +for (auto It = begin(); It != end(); ++It) { + if (It->isPerfectMatch(S.getASTContext())) { +if (Best == end()) { + Best = It; +} else { + Best = end(); + break; +} + } zyn0217 wrote: If there are two+ perfect matches, I presume the reason for going on adding template candidates is that we want every candidates to be present in the diagnostic? https://github.com/llvm/llvm-project/pull/133426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][WIP][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)
@@ -10975,9 +11176,8 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, if (Best == end()) return OR_No_Viable_Function; + llvm::SmallVector PendingBest; llvm::SmallVector EquivalentCands; - - llvm::SmallVector PendingBest; zyn0217 wrote: unrelated changes (sorry for nitpicks at this point) https://github.com/llvm/llvm-project/pull/133426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)
https://github.com/jsjodin updated https://github.com/llvm/llvm-project/pull/133310 >From 50fefbb31f4de7352c241c48fe5382785daaef21 Mon Sep 17 00:00:00 2001 From: Jan Leyonberg Date: Sun, 23 Mar 2025 09:56:51 -0400 Subject: [PATCH 01/10] Initial modifications to support reductions in flang. --- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 3 +- .../llvm/Frontend/OpenMP/OMPIRBuilder.h | 3 -- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 30 +++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index feb2448297542..d30bef9e7f0ba 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -1659,7 +1659,6 @@ void CGOpenMPRuntimeGPU::emitReduction( return; bool ParallelReduction = isOpenMPParallelDirective(Options.ReductionKind); - bool DistributeReduction = isOpenMPDistributeDirective(Options.ReductionKind); bool TeamsReduction = isOpenMPTeamsDirective(Options.ReductionKind); ASTContext &C = CGM.getContext(); @@ -1756,7 +1755,7 @@ void CGOpenMPRuntimeGPU::emitReduction( llvm::OpenMPIRBuilder::InsertPointTy AfterIP = cantFail(OMPBuilder.createReductionsGPU( OmpLoc, AllocaIP, CodeGenIP, ReductionInfos, false, TeamsReduction, - DistributeReduction, llvm::OpenMPIRBuilder::ReductionGenCBKind::Clang, + llvm::OpenMPIRBuilder::ReductionGenCBKind::Clang, CGF.getTarget().getGridValue(), C.getLangOpts().OpenMPCUDAReductionBufNum, RTLoc)); CGF.Builder.restoreIP(AfterIP); diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h index 28909cef4748d..9b67d0c050e46 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -1905,8 +1905,6 @@ class OpenMPIRBuilder { /// nowait. /// \param IsTeamsReduction Optional flag set if it is a teams /// reduction. - /// \param HasDistribute Optional flag set if it is a - /// distribute reduction. /// \param GridValue Optional GPU grid value. /// \param ReductionBufNumOptional OpenMPCUDAReductionBufNumValue to be /// used for teams reduction. @@ -1915,7 +1913,6 @@ class OpenMPIRBuilder { const LocationDescription &Loc, InsertPointTy AllocaIP, InsertPointTy CodeGenIP, ArrayRef ReductionInfos, bool IsNoWait = false, bool IsTeamsReduction = false, - bool HasDistribute = false, ReductionGenCBKind ReductionGenCBKind = ReductionGenCBKind::MLIR, std::optional GridValue = {}, unsigned ReductionBufNum = 1024, Value *SrcLocInfo = nullptr); diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 2e5ce5308eea5..0001626086d7c 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -3495,9 +3495,9 @@ checkReductionInfos(ArrayRef ReductionInfos, OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createReductionsGPU( const LocationDescription &Loc, InsertPointTy AllocaIP, InsertPointTy CodeGenIP, ArrayRef ReductionInfos, -bool IsNoWait, bool IsTeamsReduction, bool HasDistribute, -ReductionGenCBKind ReductionGenCBKind, std::optional GridValue, -unsigned ReductionBufNum, Value *SrcLocInfo) { +bool IsNoWait, bool IsTeamsReduction, ReductionGenCBKind ReductionGenCBKind, +std::optional GridValue, unsigned ReductionBufNum, +Value *SrcLocInfo) { if (!updateToLocation(Loc)) return InsertPointTy(); Builder.restoreIP(CodeGenIP); @@ -3514,6 +3514,16 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createReductionsGPU( if (ReductionInfos.size() == 0) return Builder.saveIP(); + BasicBlock *ContinuationBlock = nullptr; + if (ReductionGenCBKind != ReductionGenCBKind::Clang) { +// Copied code from createReductions +BasicBlock *InsertBlock = Loc.IP.getBlock(); +ContinuationBlock = +InsertBlock->splitBasicBlock(Loc.IP.getPoint(), "reduce.finalize"); +InsertBlock->getTerminator()->eraseFromParent(); +Builder.SetInsertPoint(InsertBlock, InsertBlock->end()); + } + Function *CurFunc = Builder.GetInsertBlock()->getParent(); AttributeList FuncAttrs; AttrBuilder AttrBldr(Ctx); @@ -3669,11 +3679,21 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createReductionsGPU( ReductionFunc; }); } else { - assert(false && "Unhandled ReductionGenCBKind"); + Value *LHSValue = Builder.CreateLoad(RI.ElementType, LHS, "final.lhs"); + Value *RHSValue = Builder.CreateLoad(RI.ElementType, RHS, "final.rhs"); + Value *Reduced; + InsertPointOrErrorTy AfterIP = + RI.ReductionGen(Builder.saveIP(), RHSValue, LHSValue, Reduced); + if
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
@@ -57,6 +59,8 @@ class ASTDeserializationListener { /// A module import was read from the AST file. virtual void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) {} + /// The deserialization of the AST file was finished. + virtual void FinishedDeserializing() {} ilya-biryukov wrote: Yes, I saw that. But in any case you probably want the other callback too. Having both callbacks would allow to add assertions about the invariants implementation expect. E.g. my concerns about reentrancy could be expressed as `bool IsDeserializing` field and a few assertions. https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
@@ -103,15 +120,30 @@ class DeserializedDeclsDumper : public DelegatingDeserializationListener { : DelegatingDeserializationListener(Previous, DeletePrevious) {} void DeclRead(GlobalDeclID ID, const Decl *D) override { -llvm::outs() << "PCH DECL: " << D->getDeclKindName(); -if (const NamedDecl *ND = dyn_cast(D)) { - llvm::outs() << " - "; - ND->printQualifiedName(llvm::outs()); +PendingDecls.push_back(D); +DelegatingDeserializationListener::DeclRead(ID, D); + } + void FinishedDeserializing() override { +auto Decls = std::move(PendingDecls); +for (const auto *D : Decls) { + llvm::outs() << "PCH DECL: " << D->getDeclKindName(); + if (const NamedDecl *ND = dyn_cast(D)) { +llvm::outs() << " - "; +ND->printQualifiedName(llvm::outs()); + } + llvm::outs() << "\n"; } -llvm::outs() << "\n"; -DelegatingDeserializationListener::DeclRead(ID, D); +if (!PendingDecls.empty()) { ilya-biryukov wrote: > I tested it with the crash case, and printQualifiedName does not cause > further deserialization with this change, I'm not certain now. > I think a broader question is: once deserialization is finished, can we > safely assume that using a loaded declaration will never trigger additional > deserialization? No, we cannot assume that. E.g. we can load a function without a body and requesting a body at any other point in code may cause deserialization of the body itself, all declarations it references and so on. > after deserialization is fully completed. Deserializations get started and completed throughout the program many times and it's generally fine. > One possible solution is to disallow this behavior, e.g we could add an > assertion in ASTReader.cpp. I don't think this works, actually. It's very hard to write code that does not deserialize. And it's probably not necessary to actually have that level of scrutiny. Deserializing from inside the callbacks in the deserialization itself is cheesy, but deserializing more outside of the deserialization is a perfectly valid use-case. I would recommend a different approach and instead putting it on the author of the interface to figure out when they want to process their results. E.g. `HandleTranslationUnit` or `HandleTopLevelDecl` from `ASTConsumer` are safe places. One happens once per invocation, another one happens more often (if you need more gradual results). Some users might prefer `EndSourceFile`. We would require wiring up other callbacks (`ASTConsumer`, the whole `FrontendAction`, etc) in addition to deserialization listener. But that's already the case, e.g.`PPCallbacks` rarely live outside something else. So maybe just remove this callback and rely on other ways to output the buffered declarations? How does that sound? And for the problem at hand... > I tested it with the crash case, and printQualifiedName does not cause > further deserialization with this change, I'm not certain now. So maybe it crashed simply because we did not propagate the other callbacks? If that's the case, a more narrow change that does not add more methods to the interface would be enough. Or is that not the case? https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement some missing interfaces for DelegatingDeserializationListener (PR #133424)
https://github.com/ilya-biryukov approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/133424 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)
ilya-biryukov wrote: > I'm happy to split the patch. I agree that (2) requires more thought and > careful consideration. I'm not sure I'll have time to finish it before my > leave, so I might have to leave it to you. But I can take care of (1). Yeah, I feel it makes sense to abandon this until you are back or we really need it. Forwarding the callbacks is a clear improvement anyway. https://github.com/llvm/llvm-project/pull/133395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c4bc1b1 - [clang] Update Mach-O ptrauth driver defaults (#132834)
Author: Nico Weber Date: 2025-03-28T08:34:25-04:00 New Revision: c4bc1b1d8177961c50c7a197bfb97b5226e749ff URL: https://github.com/llvm/llvm-project/commit/c4bc1b1d8177961c50c7a197bfb97b5226e749ff DIFF: https://github.com/llvm/llvm-project/commit/c4bc1b1d8177961c50c7a197bfb97b5226e749ff.diff LOG: [clang] Update Mach-O ptrauth driver defaults (#132834) Xcode clang default-enables a bunch of ptrauth flags when targeting arm64e. Let's match that. Added: clang/test/Driver/arch-arm64e.c Modified: clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/Darwin.h Removed: diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 4c88722730598..32a5fe68e8cff 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1201,6 +1201,13 @@ void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const { } } +void DarwinClang::addClangTargetOptions( +const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, +Action::OffloadKind DeviceOffloadKind) const { + + Darwin::addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadKind); +} + /// Take a path that speculatively points into Xcode and return the /// `XCODE/Contents/Developer` path if it is an Xcode path, or an empty path /// otherwise. @@ -3056,9 +3063,43 @@ bool Darwin::isSizedDeallocationUnavailable() const { return TargetVersion < sizedDeallocMinVersion(OS); } +void MachO::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const { + + ToolChain::addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadKind); + + // On arm64e, enable pointer authentication (for the return address and + // indirect calls), as well as usage of the intrinsics. + if (getArchName() == "arm64e") { +if (!DriverArgs.hasArg(options::OPT_fptrauth_returns, + options::OPT_fno_ptrauth_returns)) + CC1Args.push_back("-fptrauth-returns"); + +if (!DriverArgs.hasArg(options::OPT_fptrauth_intrinsics, + options::OPT_fno_ptrauth_intrinsics)) + CC1Args.push_back("-fptrauth-intrinsics"); + +if (!DriverArgs.hasArg(options::OPT_fptrauth_calls, + options::OPT_fno_ptrauth_calls)) + CC1Args.push_back("-fptrauth-calls"); + +if (!DriverArgs.hasArg(options::OPT_fptrauth_indirect_gotos, + options::OPT_fno_ptrauth_indirect_gotos)) + CC1Args.push_back("-fptrauth-indirect-gotos"); + +if (!DriverArgs.hasArg(options::OPT_fptrauth_auth_traps, + options::OPT_fno_ptrauth_auth_traps)) + CC1Args.push_back("-fptrauth-auth-traps"); + } +} + void Darwin::addClangTargetOptions( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const { + + MachO::addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadKind); + // Pass "-faligned-alloc-unavailable" only when the user hasn't manually // enabled or disabled aligned allocations. if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation, diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index c44780c577f4f..751a3ba2ad5e4 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -145,6 +145,11 @@ class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain { Tool *buildStaticLibTool() const override; Tool *getTool(Action::ActionClass AC) const override; + void + addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, +llvm::opt::ArgStringList &CC1Args, +Action::OffloadKind DeviceOffloadKind) const override; + private: mutable std::unique_ptr Lipo; mutable std::unique_ptr Dsymutil; @@ -653,6 +658,11 @@ class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin { void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override; + void + addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, +llvm::opt::ArgStringList &CC1Args, +Action::OffloadKind DeviceOffloadKind) const override; + void AddLinkARCArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; diff --git a/clang/test/Driver/arch-arm64e.c b/clang/test/Driver/arch-arm64e.c new file mode 100644 index 0..0fb12d4dcc5e3 --- /dev/null +++ b/clang/test/Driver/arch-arm64e.c @@ -0,0 +1,66 @@ +// Check that we can manually enable specific ptrauth features. + +// RUN: %clang -target arm64-apple-darwin -c %s -### 2>&1 | FileCheck %s --check-prefix NONE +// NONE: "-cc1" +// NONE-NOT: "-fptr
[clang] [clang] Update Mach-O ptrauth driver defaults (PR #132834)
nico wrote: Thanks! I'm feeling reasonably confident about this one and it's been a few days, so I'll hit the button :) https://github.com/llvm/llvm-project/pull/132834 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Update Mach-O ptrauth driver defaults (PR #132834)
https://github.com/nico closed https://github.com/llvm/llvm-project/pull/132834 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 772173f - [Clang][AMDGPU] Remove special handling for COV4 libraries (#132870)
Author: Joseph Huber Date: 2025-03-28T07:35:16-05:00 New Revision: 772173f54868eef6e1a4d40ab93b0ee6c04b1aca URL: https://github.com/llvm/llvm-project/commit/772173f54868eef6e1a4d40ab93b0ee6c04b1aca DIFF: https://github.com/llvm/llvm-project/commit/772173f54868eef6e1a4d40ab93b0ee6c04b1aca.diff LOG: [Clang][AMDGPU] Remove special handling for COV4 libraries (#132870) Summary: When we were first porting to COV5, this lead to some ABI issues due to a change in how we looked up the work group size. Bitcode libraries relied on the builtins to emit code, but this was changed between versions. This prevented the bitcode libraries, like OpenMP or libc, from being used for both COV4 and COV5. The solution was to have this 'none' functionality which effectively emitted code that branched off of a global to resolve to either version. This isn't a great solution because it forced every TU to have this variable in it. The patch in https://github.com/llvm/llvm-project/pull/131033 removed support for COV4 from OpenMP, which was the only consumer of this functionality. Other users like HIP and OpenCL did not use this because they linked the ROCm Device Library directly which has its own handling (The name was borrowed from it after all). So, now that we don't need to worry about backward compatibility with COV4, we can remove this special handling. Users can still emit COV4 code, this simply removes the special handling used to make the OpenMP device runtime bitcode version agnostic. Added: Modified: clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp clang/lib/CodeGen/Targets/AMDGPU.cpp clang/test/CodeGen/amdgpu-abi-version.c clang/test/CodeGen/amdgpu-address-spaces.cpp clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu clang/test/CodeGenCXX/dynamic-cast-address-space.cpp clang/test/CodeGenHIP/default-attributes.hip clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl clang/test/OpenMP/amdgcn_target_global_constructor.cpp compiler-rt/cmake/builtin-config-ix.cmake compiler-rt/lib/builtins/CMakeLists.txt flang/lib/Frontend/FrontendActions.cpp libc/cmake/modules/LLVMLibCCompileOptionRules.cmake libcxx/cmake/caches/AMDGPU.cmake offload/DeviceRTL/CMakeLists.txt Removed: clang/test/CodeGenCUDA/amdgpu-code-object-version-linking.cu flang/test/Lower/AMD/code-object-version.f90 diff --git a/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp b/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp index e312e59aaae4b..b56b739094ff3 100644 --- a/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp +++ b/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp @@ -57,9 +57,6 @@ Value *EmitAMDGPUImplicitArgPtr(CodeGenFunction &CGF) { /// COV_NONE : Emit code to load a global variable "__oclc_ABI_version" ///and use its value for COV_4 or COV_5+ approach. It is used for ///compiling device libraries in an ABI-agnostic way. -/// -/// Note: "__oclc_ABI_version" is supposed to be emitted and intialized by -/// clang during compilation of user code. Value *EmitAMDGPUWorkGroupSize(CodeGenFunction &CGF, unsigned Index) { llvm::LoadInst *LD; diff --git a/clang/lib/CodeGen/Targets/AMDGPU.cpp b/clang/lib/CodeGen/Targets/AMDGPU.cpp index e3c8243cbb0b5..db2a2c5740646 100644 --- a/clang/lib/CodeGen/Targets/AMDGPU.cpp +++ b/clang/lib/CodeGen/Targets/AMDGPU.cpp @@ -305,8 +305,6 @@ class AMDGPUTargetCodeGenInfo : public TargetCodeGenInfo { void setFunctionDeclAttributes(const FunctionDecl *FD, llvm::Function *F, CodeGenModule &CGM) const; - void emitTargetGlobals(CodeGen::CodeGenModule &CGM) const override; - void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const override; unsigned getOpenCLKernelCallingConv() const override; @@ -414,40 +412,6 @@ void AMDGPUTargetCodeGenInfo::setFunctionDeclAttributes( } } -/// Emits control constants used to change per-architecture behaviour in the -/// AMDGPU ROCm device libraries. -void AMDGPUTargetCodeGenInfo::emitTargetGlobals( -CodeGen::CodeGenModule &CGM) const { - StringRef Name = "__oclc_ABI_version"; - llvm::GlobalVariable *OriginalGV = CGM.getModule().getNamedGlobal(Name); - if (OriginalGV && !llvm::GlobalVariable::isExternalLinkage(OriginalGV->getLinkage())) -return; - - if (CGM.getTarget().getTargetOpts().CodeObjectVersion == - llvm::CodeObjectVersionKind::COV_None) -return; - - auto *Type = llvm::IntegerType::getIntNTy(CGM.getModule().getContext(), 32); - llvm::Constant *COV = llvm::ConstantInt::get( - Type, CGM.getTarget().getTargetOpts().CodeObjectVersion); - - // It needs to be constant weak_odr without externally_initialized so that - // the load instuction can be eliminated by the IPSCCP. - auto *GV = new llvm::GlobalVariable( - CGM.getModule(), Type, true, llvm::GlobalValue::WeakODRLin
[clang-tools-extra] [clang-tidy][NFC] improve documentation for `bugprone-argument-comment` check (PR #133436)
https://github.com/vbvictor created https://github.com/llvm/llvm-project/pull/133436 Improve docs for `bugprone-argument-comment` check by writing explicitly default values for options. Before this change, it was unclear what values are default. >From 916062c02019d805f94f494e9ded33c0f40462e2 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 28 Mar 2025 15:33:02 +0300 Subject: [PATCH] [clang-tidy][NFC] improve documentation for `bugprone-argument-comment` check --- .../checks/bugprone/argument-comment.rst | 25 --- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/argument-comment.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/argument-comment.rst index ab7e668b971c0..8770d7224137a 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/argument-comment.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/argument-comment.rst @@ -24,18 +24,19 @@ Options .. option:: StrictMode - When `false` (default value), the check will ignore leading and trailing + When `false`, the check will ignore leading and trailing underscores and case when comparing names -- otherwise they are taken into - account. + account. Default is `false`. .. option:: IgnoreSingleArgument - When `true`, the check will ignore the single argument. + When `true`, the check will ignore the single argument. Default is `false`. .. option:: CommentBoolLiterals When `true`, the check will add argument comments in the format ``/*ParameterName=*/`` right before the boolean literal argument. + Default is `false`. Before: @@ -55,8 +56,9 @@ After: .. option:: CommentIntegerLiterals - When true, the check will add argument comments in the format + When `true`, the check will add argument comments in the format ``/*ParameterName=*/`` right before the integer literal argument. + Default is `false`. Before: @@ -76,8 +78,9 @@ After: .. option:: CommentFloatLiterals - When true, the check will add argument comments in the format + When `true`, the check will add argument comments in the format ``/*ParameterName=*/`` right before the float/double literal argument. + Default is `false`. Before: @@ -97,8 +100,9 @@ After: .. option:: CommentStringLiterals - When true, the check will add argument comments in the format + When `true`, the check will add argument comments in the format ``/*ParameterName=*/`` right before the string literal argument. + Default is `false`. Before: @@ -122,8 +126,9 @@ After: .. option:: CommentCharacterLiterals - When true, the check will add argument comments in the format + When `true`, the check will add argument comments in the format ``/*ParameterName=*/`` right before the character literal argument. + Default is `false`. Before: @@ -143,8 +148,9 @@ After: .. option:: CommentUserDefinedLiterals - When true, the check will add argument comments in the format + When `true`, the check will add argument comments in the format ``/*ParameterName=*/`` right before the user defined literal argument. + Default is `false`. Before: @@ -168,8 +174,9 @@ After: .. option:: CommentNullPtrs - When true, the check will add argument comments in the format + When `true`, the check will add argument comments in the format ``/*ParameterName=*/`` right before the nullptr literal argument. + Default is `false`. Before: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Fix format attribute handling in GenericTaintChecker (PR #132765)
=?utf-8?q?Donát?= Nagy , =?utf-8?q?Donát?= Nagy Message-ID: In-Reply-To: llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-aarch64-sve-vla-2stage` running on `linaro-g3-01` while building `clang` at step 12 "ninja check 2". Full details are available at: https://lab.llvm.org/buildbot/#/builders/41/builds/5807 Here is the relevant piece of the build log for the reference ``` Step 12 (ninja check 2) failure: stage 2 checked (failure) ... PASS: DataFlowSanitizer-aarch64 :: origin_ldst.c (25155 of 97434) PASS: Flang :: Driver/print-effective-triple.f90 (25156 of 97434) PASS: Flang :: Driver/print-resource-dir.F90 (25157 of 97434) PASS: Flang :: Driver/implicit-none.f90 (25158 of 97434) PASS: Flang :: Driver/bbc-openmp-version-macro.f90 (25159 of 97434) PASS: Flang :: Driver/predefined-macros-compiler-version.F90 (25160 of 97434) PASS: Flang :: Driver/override-triple.ll (25161 of 97434) PASS: Flang :: Driver/mlir-pass-pipeline.f90 (25162 of 97434) PASS: Flang :: Driver/macro-def-undef.F90 (25163 of 97434) UNRESOLVED: Flang :: Driver/slp-vectorize.ll (25164 of 97434) TEST 'Flang :: Driver/slp-vectorize.ll' FAILED Test has no 'RUN:' line PASS: Flang :: Driver/parse-error.ll (25165 of 97434) PASS: Flang :: Driver/missing-arg.f90 (25166 of 97434) PASS: Flang :: Driver/print-pipeline-passes.f90 (25167 of 97434) PASS: Flang :: Driver/mlink-builtin-bc.f90 (25168 of 97434) PASS: Flang :: Driver/parse-fir-error.ll (25169 of 97434) PASS: Flang :: Driver/include-header.f90 (25170 of 97434) PASS: Flang :: Driver/fd-lines-as.f90 (25171 of 97434) PASS: Flang :: Driver/phases.f90 (25172 of 97434) PASS: Flang :: Driver/print-target-triple.f90 (25173 of 97434) PASS: Flang :: Driver/scanning-error.f95 (25174 of 97434) PASS: Flang :: Driver/pthread.f90 (25175 of 97434) PASS: Flang :: Driver/parse-ir-error.f95 (25176 of 97434) PASS: Flang :: Driver/std2018-wrong.f90 (25177 of 97434) PASS: Flang :: Driver/supported-suffices/f03-suffix.f03 (25178 of 97434) PASS: Clangd Unit Tests :: ./ClangdTests/71/81 (25179 of 97434) PASS: Flang :: Driver/supported-suffices/f08-suffix.f08 (25180 of 97434) PASS: Flang :: Driver/pp-fixed-form.f90 (25181 of 97434) PASS: Clangd Unit Tests :: ./ClangdTests/80/81 (25182 of 97434) PASS: Flang :: Driver/target-gpu-features.f90 (25183 of 97434) PASS: Flang :: Driver/pass-plugin-not-found.f90 (25184 of 97434) PASS: Clangd Unit Tests :: ./ClangdTests/68/81 (25185 of 97434) PASS: Flang :: Driver/tco-code-gen-llvm.fir (25186 of 97434) PASS: Flang :: Driver/config-file.f90 (25187 of 97434) PASS: Flang :: Driver/target.f90 (25188 of 97434) PASS: Flang :: Driver/q-unused-arguments.f90 (25189 of 97434) PASS: Flang :: Driver/multiple-input-files.f90 (25190 of 97434) PASS: Flang :: Driver/lto-bc.f90 (25191 of 97434) PASS: Flang :: Driver/unsupported-vscale-max-min.f90 (25192 of 97434) PASS: Flang :: Driver/linker-flags.f90 (25193 of 97434) PASS: Flang :: Driver/mllvm.f90 (25194 of 97434) PASS: Flang :: Driver/no-duplicate-main.f90 (25195 of 97434) PASS: DataFlowSanitizer-aarch64 :: pair.cpp (25196 of 97434) PASS: Flang :: Driver/target-machine-error.f90 (25197 of 97434) PASS: Flang :: Driver/unparse-with-modules.f90 (25198 of 97434) PASS: Flang :: Driver/lto-flags.f90 (25199 of 97434) PASS: Flang :: Driver/fixed-line-length.f90 (25200 of 97434) ``` https://github.com/llvm/llvm-project/pull/132765 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [flang] [libc] [libcxx] [llvm] [Clang][AMDGPU] Remove special handling for COV4 libraries (PR #132870)
https://github.com/jhuber6 closed https://github.com/llvm/llvm-project/pull/132870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy][NFC] improve documentation for `bugprone-argument-comment` check (PR #133436)
https://github.com/carlosgalvezp approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/133436 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)
hulxv wrote: @ilovepi Ping https://github.com/llvm/llvm-project/pull/131280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [PGO][Offload] Allow PGO flags to be used on GPU targets (PR #94268)
Artem-B wrote: @jhuber6 @jdoerfert I propose reverting the change, unless it can be quickly fixed forward so it does not affect CUDA/NVPTX. https://github.com/llvm/llvm-project/pull/94268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Allow setting a base directory for hosted pages (PR #132482)
ilovepi wrote: ### Merge activity * **Mar 28, 3:48 PM EDT**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/132482). https://github.com/llvm/llvm-project/pull/132482 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Allow setting a base directory for hosted pages (PR #132482)
https://github.com/ilovepi closed https://github.com/llvm/llvm-project/pull/132482 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [PGO][Offload] Allow PGO flags to be used on GPU targets (PR #94268)
EthanLuisMcDonough wrote: Thank you all for making me aware of this. I'll look into fixing this as soon as possible. https://github.com/llvm/llvm-project/pull/94268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)
https://github.com/fmayer updated https://github.com/llvm/llvm-project/pull/133350 >From 8ece858e76fad0962b2567f03bf80bcaf2828348 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Thu, 27 Mar 2025 18:25:23 -0700 Subject: [PATCH 1/7] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- .../SmartPointerAccessorCaching.h | 6 +- .../SmartPointerAccessorCaching.cpp | 125 ++ .../SmartPointerAccessorCachingTest.cpp | 40 ++ 3 files changed, 114 insertions(+), 57 deletions(-) diff --git a/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h b/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h index b4291347e0969..e55b83aa845d4 100644 --- a/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h +++ b/clang/include/clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h @@ -62,8 +62,10 @@ ast_matchers::StatementMatcher isPointerLikeOperatorStar(); ast_matchers::StatementMatcher isSmartPointerLikeOperatorStar(); ast_matchers::StatementMatcher isPointerLikeOperatorArrow(); ast_matchers::StatementMatcher isSmartPointerLikeOperatorArrow(); -ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall(); -ast_matchers::StatementMatcher isSmartPointerLikeGetMethodCall(); +ast_matchers::StatementMatcher +isSmartPointerLikeValueMethodCall(clang::StringRef MethodName = "value"); +ast_matchers::StatementMatcher +isSmartPointerLikeGetMethodCall(clang::StringRef MethodName = "get"); // Common transfer functions. diff --git a/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp b/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp index 0860cc1dbaf8e..638f5211152b2 100644 --- a/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp +++ b/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp @@ -2,6 +2,7 @@ #include "clang/AST/CanonicalType.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/Type.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/ASTMatchers/ASTMatchersMacros.h" #include "clang/Basic/OperatorKinds.h" @@ -23,8 +24,7 @@ using ast_matchers::pointerType; using ast_matchers::referenceType; using ast_matchers::returns; -bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, - bool &HasValue) { +CanQualType pointerLikeReturnType(const CXXRecordDecl &RD) { // We may want to cache this search, but in current profiles it hasn't shown // up as a hot spot (possibly because there aren't many hits, relatively). bool HasArrow = false; @@ -55,38 +55,47 @@ bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, .getUnqualifiedType(); } break; -case OO_None: { - IdentifierInfo *II = MD->getIdentifier(); - if (II == nullptr) -continue; - if (II->isStr("get")) { -if (MD->getReturnType()->isPointerType()) { - HasGet = true; - GetReturnType = MD->getReturnType() - ->getPointeeType() - ->getCanonicalTypeUnqualified() - .getUnqualifiedType(); -} - } else if (II->isStr("value")) { -if (MD->getReturnType()->isReferenceType()) { - HasValue = true; - ValueReturnType = MD->getReturnType() -.getNonReferenceType() -->getCanonicalTypeUnqualified() -.getUnqualifiedType(); -} - } -} break; default: break; } } + if (HasStar && HasArrow && StarReturnType == ArrowReturnType) +return StarReturnType; - if (!HasStar || !HasArrow || StarReturnType != ArrowReturnType) -return false; - HasGet = HasGet && (GetReturnType == StarReturnType); - HasValue = HasValue && (ValueReturnType == StarReturnType); - return true; + return {}; +} +CanQualType getLikeReturnType(QualType RT) { + if (!RT.isNull() && RT->isPointerType()) { +return RT->getPointeeType() +->getCanonicalTypeUnqualified() +.getUnqualifiedType(); + } + return {}; +} + +CanQualType valueLikeReturnType(QualType RT) { + if (!RT.isNull() && RT->isReferenceType()) { +return RT.getNonReferenceType() +->getCanonicalTypeUnqualified() +.getUnqualifiedType(); + } + return {}; +} + +QualType findReturnType(const CXXRecordDecl &RD, StringRef MethodName) { + for (const auto *MD : RD.methods()) { +// We only consider methods that are const and have zero parameters. +// It may be that there is a non-const overload for the method, but +// there should at least be a const overload as well. +if (!MD->isConst() || MD->getNumParams() != 0 || +MD->getOverloadedOp
[clang-tools-extra] d4dc571 - [clang-doc] Allow setting a base directory for hosted pages (#132482)
Author: Paul Kirth Date: 2025-03-28T12:49:43-07:00 New Revision: d4dc5712c47dab5f5dcfc329db8121059b591fb1 URL: https://github.com/llvm/llvm-project/commit/d4dc5712c47dab5f5dcfc329db8121059b591fb1 DIFF: https://github.com/llvm/llvm-project/commit/d4dc5712c47dab5f5dcfc329db8121059b591fb1.diff LOG: [clang-doc] Allow setting a base directory for hosted pages (#132482) Currently, when we set URLs from JS, we set them only using the protocol and host locations. This works fine when docs are served from the base directory of the site, but if you want to nest it under another directory, our JS fails to set the correct path, leading to broken links. This patch adds a --base option to specify the path prefix to use, which is set in the generated index_json.js file. index.json can then fill in the prefix appropriately when generating links in a browser. This flag has no effect for non HTML output. Given an index hosted at: www.docs.com/base_directory/index.html we used to generate the following link: www.docs.com/file.html Using --base base_directory we now generate: www.docs.com/base_directory/file.html This allows such links to work when hosting pages without using a custom index.js. Added: Modified: clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/assets/index.js clang-tools-extra/clang-doc/tool/ClangDocMain.cpp clang-tools-extra/test/clang-doc/assets.cpp clang-tools-extra/test/clang-doc/test-path-abs.cpp clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp Removed: diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp index a8404479569f9..9b95d082fdfe7 100644 --- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp @@ -1078,6 +1078,11 @@ static llvm::Error serializeIndex(ClangDocContext &CDCtx) { std::replace(RootPathEscaped.begin(), RootPathEscaped.end(), '\\', '/'); OS << "var RootPath = \"" << RootPathEscaped << "\";\n"; + llvm::SmallString<128> Base(CDCtx.Base); + std::string BaseEscaped = Base.str().str(); + std::replace(BaseEscaped.begin(), BaseEscaped.end(), '\\', '/'); + OS << "var Base = \"" << BaseEscaped << "\";\n"; + CDCtx.Idx.sort(); llvm::json::OStream J(OS, 2); std::function IndexToJSON = [&](const Index &I) { diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp index 4da93b24c131f..fd206fb6a18cc 100644 --- a/clang-tools-extra/clang-doc/Representation.cpp +++ b/clang-tools-extra/clang-doc/Representation.cpp @@ -367,10 +367,10 @@ void Index::sort() { ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName, bool PublicOnly, StringRef OutDirectory, StringRef SourceRoot, - StringRef RepositoryUrl, + StringRef RepositoryUrl, StringRef Base, std::vector UserStylesheets) : ECtx(ECtx), ProjectName(ProjectName), PublicOnly(PublicOnly), - OutDirectory(OutDirectory), UserStylesheets(UserStylesheets) { + OutDirectory(OutDirectory), UserStylesheets(UserStylesheets), Base(Base) { llvm::SmallString<128> SourceRootDir(SourceRoot); if (SourceRoot.empty()) // If no SourceRoot was provided the current path is used as the default diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h index 1f2ea51e06b71..5473439cec319 100644 --- a/clang-tools-extra/clang-doc/Representation.h +++ b/clang-tools-extra/clang-doc/Representation.h @@ -507,7 +507,7 @@ struct ClangDocContext { ClangDocContext() = default; ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName, bool PublicOnly, StringRef OutDirectory, StringRef SourceRoot, - StringRef RepositoryUrl, + StringRef RepositoryUrl, StringRef Base, std::vector UserStylesheets); tooling::ExecutionContext *ECtx; std::string ProjectName; // Name of project clang-doc is documenting. @@ -523,6 +523,7 @@ struct ClangDocContext { std::vector UserStylesheets; // JavaScript files that will be imported in all HTML files. std::vector JsScripts; + StringRef Base; Index Idx; }; diff --git a/clang-tools-extra/clang-doc/assets/index.js b/clang-tools-extra/clang-doc/assets/index.js index 58a92f049f19f..8a83f072526f9 100644 --- a/clang-tools-extra/clang-doc/assets/index.js +++ b/clang-tools-extra/clang-doc/assets/index.js @@ -1,9 +1,10 @@ function genLink(Ref) { // we treat the file paths diff erent depending on if we're // serving via a http server or vi
[clang] [alpha.webkit.RawPtrRefMemberChecker] The checker doesn't warn Objective-C types in ivars. (PR #132833)
rniwa wrote: Thanks for the review! https://github.com/llvm/llvm-project/pull/132833 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)
https://github.com/s-perron edited https://github.com/llvm/llvm-project/pull/133469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL][NFC] Use method builder to create default resource constructor (PR #131384)
https://github.com/hekota closed https://github.com/llvm/llvm-project/pull/131384 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Do not share ownership of `PreprocessorOptions` (PR #133467)
https://github.com/benlangmuir approved this pull request. Sounds great, thanks for explaining! https://github.com/llvm/llvm-project/pull/133467 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG-CL] ignores wpadded (PR #130182)
=?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes Message-ID: In-Reply-To: https://github.com/therealcoochieman updated https://github.com/llvm/llvm-project/pull/130182 >From 3a9bc908a791669c82f288ff745664411bf285ac Mon Sep 17 00:00:00 2001 From: Theo de Magalhaes Date: Thu, 6 Mar 2025 22:26:37 +0100 Subject: [PATCH 01/11] chore(clang-format): formatted clang/lib/AST/RecordLayoutBuilder.cpp --- clang/lib/AST/RecordLayoutBuilder.cpp | 199 -- 1 file changed, 94 insertions(+), 105 deletions(-) diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index b8600e6a344a4..695771f67868d 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -43,7 +43,7 @@ struct BaseSubobjectInfo { bool IsVirtual; /// Bases - Information about the base subobjects. - SmallVector Bases; + SmallVector Bases; /// PrimaryVirtualBaseInfo - Holds the base info for the primary virtual base /// of this base info (if one exists). @@ -77,8 +77,7 @@ struct ExternalLayout { /// Get the offset of the given field. The external source must provide /// entries for all fields in the record. uint64_t getExternalFieldOffset(const FieldDecl *FD) { -assert(FieldOffsets.count(FD) && - "Field does not have an external offset"); +assert(FieldOffsets.count(FD) && "Field does not have an external offset"); return FieldOffsets[FD]; } @@ -167,16 +166,15 @@ class EmptySubobjectMap { CharUnits SizeOfLargestEmptySubobject; EmptySubobjectMap(const ASTContext &Context, const CXXRecordDecl *Class) - : Context(Context), CharWidth(Context.getCharWidth()), Class(Class) { - ComputeEmptySubobjectSizes(); + : Context(Context), CharWidth(Context.getCharWidth()), Class(Class) { +ComputeEmptySubobjectSizes(); } /// CanPlaceBaseAtOffset - Return whether the given base class can be placed /// at the given offset. /// Returns false if placing the record will result in two components /// (direct or indirect) of the same type having the same offset. - bool CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info, -CharUnits Offset); + bool CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info, CharUnits Offset); /// CanPlaceFieldAtOffset - Return whether a field can be placed at the given /// offset. @@ -227,9 +225,8 @@ void EmptySubobjectMap::ComputeEmptySubobjectSizes() { } } -bool -EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD, - CharUnits Offset) const { +bool EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD, + CharUnits Offset) const { // We only need to check empty bases. if (!RD->isEmpty()) return true; @@ -265,9 +262,8 @@ void EmptySubobjectMap::AddSubobjectAtOffset(const CXXRecordDecl *RD, MaxEmptyClassOffset = Offset; } -bool -EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info, - CharUnits Offset) { +bool EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset( +const BaseSubobjectInfo *Info, CharUnits Offset) { // We don't have to keep looking past the maximum offset that's known to // contain an empty class. if (!AnyEmptySubobjectsBeyondOffset(Offset)) @@ -368,10 +364,9 @@ bool EmptySubobjectMap::CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info, return true; } -bool -EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD, - const CXXRecordDecl *Class, - CharUnits Offset) const { +bool EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset( +const CXXRecordDecl *RD, const CXXRecordDecl *Class, +CharUnits Offset) const { // We don't have to keep looking past the maximum offset that's known to // contain an empty class. if (!AnyEmptySubobjectsBeyondOffset(Offset)) @@ -418,9 +413,8 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD, return true; } -bool -EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD, - CharUnits Offset) const { +bool EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD, + CharUnits Offset) const { // We don't have to keep looking past the maximum offset that's known to // contain an empty class. if (!AnyEmptySubobjectsBeyondOffset(Offset)) @@ -560,7 +554,7 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects( } } -typedef llvm::SmallPtrSet ClassSetTy; +t
[clang] [HLSL] Handle incomplete array types (PR #133508)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Chris B (llvm-beanz) Changes This refactors the initialization list transformation code to handle incomplete array types. Fixes #132958 --- Full diff: https://github.com/llvm/llvm-project/pull/133508.diff 3 Files Affected: - (modified) clang/lib/Sema/SemaHLSL.cpp (+91-40) - (added) clang/test/SemaHLSL/Language/InitIncompleteArrays.hlsl (+53) - (modified) clang/test/SemaHLSL/Language/InitListAST.hlsl (+78) ``diff diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 07d03e2c58b9a..cad8aa4ed0dec 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -3249,33 +3249,42 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) { } } } +namespace { +class InitListTransformer { + Sema &S; + ASTContext &Ctx; + QualType InitTy; + QualType *DstIt = nullptr; + Expr **ArgIt = nullptr; + bool Wrap; -static bool CastInitializer(Sema &S, ASTContext &Ctx, Expr *E, -llvm::SmallVectorImpl &List, -llvm::SmallVectorImpl &DestTypes) { - if (List.size() >= DestTypes.size()) { -List.push_back(E); -// This is odd, but it isn't technically a failure due to conversion, we -// handle mismatched counts of arguments differently. -return true; + bool castInitializer(Expr *E) { + assert(DstIt && "This should always be something!"); + if (DstIt == DestTypes.end()) { +if (!Wrap) { + ArgExprs.push_back(E); + // This is odd, but it isn't technically a failure due to conversion, we + // handle mismatched counts of arguments differently. + return true; +} +DstIt = DestTypes.begin(); } - InitializedEntity Entity = InitializedEntity::InitializeParameter( - Ctx, DestTypes[List.size()], false); + InitializedEntity Entity = + InitializedEntity::InitializeParameter(Ctx, *DstIt, true); ExprResult Res = S.PerformCopyInitialization(Entity, E->getBeginLoc(), E); if (Res.isInvalid()) return false; Expr *Init = Res.get(); - List.push_back(Init); + ArgExprs.push_back(Init); + DstIt++; return true; } -static bool BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E, - llvm::SmallVectorImpl &List, - llvm::SmallVectorImpl &DestTypes) { +bool buildInitializerListImpl(Expr *E) { // If this is an initialization list, traverse the sub initializers. if (auto *Init = dyn_cast(E)) { for (auto *SubInit : Init->inits()) - if (!BuildInitializerList(S, Ctx, SubInit, List, DestTypes)) + if (!buildInitializerListImpl(SubInit)) return false; return true; } @@ -3284,7 +3293,7 @@ static bool BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E, QualType Ty = E->getType(); if (Ty->isScalarType() || (Ty->isRecordType() && !Ty->isAggregateType())) -return CastInitializer(S, Ctx, E, List, DestTypes); +return castInitializer(E); if (auto *VecTy = Ty->getAs()) { uint64_t Size = VecTy->getNumElements(); @@ -3299,7 +3308,7 @@ static bool BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E, E, E->getBeginLoc(), Idx, E->getEndLoc()); if (ElExpr.isInvalid()) return false; - if (!CastInitializer(S, Ctx, ElExpr.get(), List, DestTypes)) + if (!castInitializer(ElExpr.get())) return false; } return true; @@ -3316,7 +3325,7 @@ static bool BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E, E, E->getBeginLoc(), Idx, E->getEndLoc()); if (ElExpr.isInvalid()) return false; - if (!BuildInitializerList(S, Ctx, ElExpr.get(), List, DestTypes)) + if (!buildInitializerListImpl(ElExpr.get())) return false; } return true; @@ -3341,7 +3350,7 @@ static bool BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E, E, false, E->getBeginLoc(), CXXScopeSpec(), FD, Found, NameInfo); if (Res.isInvalid()) return false; -if (!BuildInitializerList(S, Ctx, Res.get(), List, DestTypes)) +if (!buildInitializerListImpl(Res.get())) return false; } } @@ -3349,11 +3358,11 @@ static bool BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E, return true; } -static Expr *GenerateInitLists(ASTContext &Ctx, QualType Ty, - llvm::SmallVectorImpl::iterator &It) { - if (Ty->isScalarType() || (Ty->isRecordType() && !Ty->isAggregateType())) { -return *(It++); - } +Expr *generateInitListsImpl(QualType Ty) { + assert(ArgIt != ArgExprs.end() && "Something is off in iteration!"); + if (Ty->isScalarType() || (Ty->isRecordType() && !Ty->isAggregateType())) +return *(ArgIt++); + llvm::SmallVector Inits; assert(!isa(Ty) && "Matrix types not yet supported in HLSL"); Ty = Ty.getDesugaredType(Ctx); @@ -3369,7 +3378,7 @@ static Expr *GenerateInitLists(ASTContext &Ctx, QualType Ty
[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)
@@ -23,12 +24,27 @@ using ast_matchers::pointerType; using ast_matchers::referenceType; using ast_matchers::returns; -bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, - bool &HasValue) { +CanQualType getLikeReturnType(QualType RT) { + if (!RT.isNull() && RT->isPointerType()) { +return RT->getPointeeType() +->getCanonicalTypeUnqualified() +.getUnqualifiedType(); + } + return {}; +} + +CanQualType valueLikeReturnType(QualType RT) { + if (!RT.isNull() && RT->isReferenceType()) { +return RT.getNonReferenceType() +->getCanonicalTypeUnqualified() +.getUnqualifiedType(); + } + return {}; +} + +CanQualType pointerLikeReturnType(const CXXRecordDecl &RD) { // We may want to cache this search, but in current profiles it hasn't shown // up as a hot spot (possibly because there aren't many hits, relatively). - bool HasArrow = false; - bool HasStar = false; CanQualType StarReturnType, ArrowReturnType, GetReturnType, ValueReturnType; fmayer wrote: oh yes, thanks https://github.com/llvm/llvm-project/pull/133350 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add regression test for test comments in macros (PR #132510)
@@ -0,0 +1,34 @@ +// Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test. ilovepi wrote: ```suggestion // Regression test for https://github.com/llvm/llvm-project/issues/59819 ``` https://github.com/llvm/llvm-project/pull/132510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Automatically add the `returns_twice` attribute to certain functions even if `-fno-builtin` is set (PR #133511)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Alan Zhao (alanzhao1) Changes Certain functions require the `returns_twice` attribute in order to produce correct codegen. However, `-fno-builtin` removes all knowledge of functions that require this attribute, so this PR modifies Clang to add the `returns_twice` attribute even if `-fno-builtin` is set. This behavior is also consistent with what GCC does. It's not (easily) possible to get the builtin information from `Builtins.td` because `-fno-builtin` causes Clang to never initialize any builtins, so functions never get tokenized as functions/builtins that require `returns_twice`. Therefore, the most straightforward solution is to explicitly hard code the function names that require `returns_twice`. Fixes #122840 --- Full diff: https://github.com/llvm/llvm-project/pull/133511.diff 3 Files Affected: - (modified) clang/lib/CodeGen/CGCall.cpp (+9) - (modified) clang/test/CodeGen/2003-08-20-vfork-bug.c (+4-1) - (modified) clang/test/CodeGen/setjmp.c (+15) ``diff diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 7aa77e55dbfcc..76119617f22e6 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2607,6 +2607,15 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, if (shouldDisableTailCalls()) FuncAttrs.addAttribute("disable-tail-calls", "true"); +// These functions require the returns_twice attribute for correct codegen, +// but the attribute may not be added if -fno-builtin is specified. We +// explicitly add that attribute here. +static const llvm::StringSet<> ReturnsTwiceFn{ +"_setjmpex", "setjmp", "_setjmp", "vfork", +"sigsetjmp", "__sigsetjmp", "savectx", "getcontext"}; +if (ReturnsTwiceFn.contains(Name)) + FuncAttrs.addAttribute(llvm::Attribute::ReturnsTwice); + // CPU/feature overrides. addDefaultFunctionDefinitionAttributes // handles these separately to set them based on the global defaults. GetCPUAndFeaturesAttributes(CalleeInfo.getCalleeDecl(), FuncAttrs); diff --git a/clang/test/CodeGen/2003-08-20-vfork-bug.c b/clang/test/CodeGen/2003-08-20-vfork-bug.c index 4966ab20904d4..438604f321da3 100644 --- a/clang/test/CodeGen/2003-08-20-vfork-bug.c +++ b/clang/test/CodeGen/2003-08-20-vfork-bug.c @@ -1,5 +1,8 @@ -// RUN: %clang_cc1 -emit-llvm %s -o /dev/null +// RUN: %clang_cc1 -x c %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -x c %s -triple x86_64-linux-gnu -emit-llvm -fno-builtin -o - | FileCheck %s +// CHECK: ; Function Attrs: returns_twice +// CHECK-NEXT: declare {{.*}} @vfork( extern int vfork(void); void test() { vfork(); diff --git a/clang/test/CodeGen/setjmp.c b/clang/test/CodeGen/setjmp.c index 77dde35e69cae..00341e459941a 100644 --- a/clang/test/CodeGen/setjmp.c +++ b/clang/test/CodeGen/setjmp.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -x c %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -x c %s -triple x86_64-linux-gnu -emit-llvm -fno-builtin -o - | FileCheck %s // RUN: %clang_cc1 -x c++ %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s #ifdef __cplusplus @@ -6,13 +7,17 @@ extern "C" { #endif struct __jmp_buf_tag { int n; }; +struct __ucontext_t_tag { int n; }; int setjmp(struct __jmp_buf_tag*); int sigsetjmp(struct __jmp_buf_tag*, int); int _setjmp(struct __jmp_buf_tag*); int __sigsetjmp(struct __jmp_buf_tag*, int); +int _setjmpex(struct __jmp_buf_tag* env); +int getcontext(struct __ucontext_t_tag*); typedef struct __jmp_buf_tag jmp_buf[1]; typedef struct __jmp_buf_tag sigjmp_buf[1]; +typedef struct __ucontext_t_tag ucontext_t[1]; #ifdef __cplusplus } @@ -20,6 +25,7 @@ typedef struct __jmp_buf_tag sigjmp_buf[1]; void f(void) { jmp_buf jb; + ucontext_t ut; // CHECK: call {{.*}}@setjmp( setjmp(jb); // CHECK: call {{.*}}@sigsetjmp( @@ -28,6 +34,10 @@ void f(void) { _setjmp(jb); // CHECK: call {{.*}}@__sigsetjmp( __sigsetjmp(jb, 0); + // CHECK: call {{.*}}@_setjmpex( + _setjmpex(jb); + // CHECK: call {{.*}}@getcontext( + getcontext(ut); } // CHECK: ; Function Attrs: returns_twice @@ -42,3 +52,8 @@ void f(void) { // CHECK: ; Function Attrs: returns_twice // CHECK-NEXT: declare {{.*}} @__sigsetjmp( +// CHECK: ; Function Attrs: returns_twice +// CHECK-NEXT: declare {{.*}} @_setjmpex( + +// CHECK: ; Function Attrs: returns_twice +// CHECK-NEXT: declare {{.*}} @getcontext( `` https://github.com/llvm/llvm-project/pull/133511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add regression test for test comments in macros (PR #132510)
ilovepi wrote: > I just have submitted a GSoC proposal, can you give me some advices? This is a review thread for this feature. Please ask for feedback on the discourse thread. Typically you'd share a draft of your proposal w/ both prospective mentors over email (e.g. share a google doc or equivalent), and notify the thread that you'd like feedback. https://github.com/llvm/llvm-project/pull/132510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)
https://github.com/farzonl approved this pull request. This looks, good. really minor nit needs to be addressed then merge. https://github.com/llvm/llvm-project/pull/132288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] add option to control bin-packing keyworded parameters (PR #131605)
zeule wrote: Thank you, @HazardyKnusperkeks ! https://github.com/llvm/llvm-project/pull/131605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)
ilovepi wrote: If the premerge checks pass, then I'll land this. https://github.com/llvm/llvm-project/pull/131280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
@@ -5087,6 +5087,19 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, assert(EllipsisLoc.isInvalid() && "Friend ellipsis but not friend-specified?"); + if (DS.isExportSpecified()) { +VisibilityAttr *existingAttr = TagD->getAttr(); +if (existingAttr) { + VisibilityAttr::VisibilityType existingValue = + existingAttr->getVisibility(); + if (existingValue != VisibilityAttr::Default) +Diag(DS.getExportSpecLoc(), diag::err_mismatched_visibility); +} else { + Tag->addAttr( perry-ca wrote: When -fvisibility=hidden (which is the default on z/OS), etc this is needed to ensure the symbol is exported. This is analogous to a declaration with the default visibility attribute specified. https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be initialized by a constant expression}} \ + // nointerpreter-note {{initializer of 'r' is not a constant expression}} \ + // nointerpreter-note {{declared here}} + constexpr int &rr = (rr, y); + constexpr int &g() { +int &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// nointerpreter-note {{declared here}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +return x; + } + constexpr int &gg = g(); // expected-error {{must be initialized by a constant expression}} \ + // nointerpreter-note {{reference to 'x' is not a constant expression}} \ + // interpreter-note {{in call to 'g()'}} + constexpr int g2() { +int &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +return x; + } + constexpr int gg2 = g2(); // expected-error {{must be initialized by a constant expression}} \ + // interpreter-note {{in call to 'g2()'}} + constexpr int &g3() { +int &x = (x,y); // expected-warning{{left operand of comma operator has no effect}} \ +// expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} +return x; + } + constexpr int &gg3 = g3(); + typedef decltype(sizeof(1)) uintptr_t; + constexpr uintptr_t g4() { +uintptr_t * &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +*(uintptr_t*)x = 10; +return 3; + } + constexpr uintptr_t gg4 = g4(); // expected-error {{must be initialized by a constant expression}} \ + // interpreter-note {{in call to 'g4()'}} + constexpr int g5() { +int &x = x; // expected-warning {{reference 'x' is not yet bound to a value when used within its own initialization}} \ +// interpreter-note {{read of uninitialized object is not allowed in a constant expression}} +return 3; + } + constexpr uintptr_t gg5 = g5(); // interpreter-error {{must be initialized by a constant expression}} \ + // interpreter-note {{in call to 'g5()'}} shafik wrote: based on [cwg453](https://wg21.link/cwg453) this is UB and we should not accept it. https://github.com/llvm/llvm-project/pull/132990 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [PGO][Offload] Allow PGO flags to be used on GPU targets (PR #94268)
Artem-B wrote: The crash is blocking our compiler updates. If nothing depends on this change yet, it would be great to revert the patch and re-land it once it's fixed. https://github.com/llvm/llvm-project/pull/94268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL][RootSignature] Make Root Signature lexer keywords case-insensitive (PR #132967)
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/132967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IRBuilder] Add new overload for CreateIntrinsic (PR #131942)
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/131942 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Add WaveReadLaneAt unsigned integer overloads (PR #133520)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Sarah Spall (spall) Changes Add WaveReadLaneAt unsigned integer overloads 2nd argument of WaveReadLaneAt should be a uint32_t and not an int32_t add tests Closes #133473 --- Full diff: https://github.com/llvm/llvm-project/pull/133520.diff 2 Files Affected: - (modified) clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h (+59-28) - (modified) clang/test/CodeGenHLSL/builtins/WaveReadLaneAt.hlsl (+39) ``diff diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h index b0ff9075377d8..0de04f13b7ec4 100644 --- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h +++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h @@ -2358,77 +2358,108 @@ __attribute__((convergent)) bool WaveIsFirstLane(); // the specified wave. _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool WaveReadLaneAt(bool, int32_t); +__attribute__((convergent)) bool WaveReadLaneAt(bool, uint32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool2 WaveReadLaneAt(bool2, int32_t); +__attribute__((convergent)) bool2 WaveReadLaneAt(bool2, uint32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool3 WaveReadLaneAt(bool3, int32_t); +__attribute__((convergent)) bool3 WaveReadLaneAt(bool3, uint32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool4 WaveReadLaneAt(bool4, int32_t); +__attribute__((convergent)) bool4 WaveReadLaneAt(bool4, uint32_t); #ifdef __HLSL_ENABLE_16_BIT _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t WaveReadLaneAt(int16_t, int32_t); +__attribute__((convergent)) int16_t WaveReadLaneAt(int16_t, uint32_t); _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t2 WaveReadLaneAt(int16_t2, int32_t); +__attribute__((convergent)) int16_t2 WaveReadLaneAt(int16_t2, uint32_t); _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t3 WaveReadLaneAt(int16_t3, int32_t); +__attribute__((convergent)) int16_t3 WaveReadLaneAt(int16_t3, uint32_t); _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t4 WaveReadLaneAt(int16_t4, int32_t); +__attribute__((convergent)) int16_t4 WaveReadLaneAt(int16_t4, uint32_t); + +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t WaveReadLaneAt(uint16_t, uint32_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t2 WaveReadLaneAt(uint16_t2, uint32_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t3 WaveReadLaneAt(uint16_t3, uint32_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t4 WaveReadLaneAt(uint16_t4, uint32_t); #endif _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half WaveReadLaneAt(half, int32_t); +__attribute__((convergent)) half WaveReadLaneAt(half, uint32_t); _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half2 WaveReadLaneAt(half2, int32_t); +__attribute__((convergent)) half2 WaveReadLaneAt(half2, uint32_t); _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half3 WaveReadLaneAt(half3, int32_t); +__attribute__((convergent)) half3 WaveReadLaneAt(half3, uint32_t); _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half4 WaveReadLaneAt(half4, int32_t); +__attribute__((convergent)) half4 WaveReadLaneAt(half4, uint32_t); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int WaveReadLaneAt(int, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int2 WaveReadLaneAt(int2, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int3 WaveReadLaneAt(int3, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int4 WaveReadLaneAt(int4, uint32_t); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint WaveReadLaneAt(uint, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint2 WaveReadLaneAt(uint2, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__att
[clang] [HLSL] Add WaveReadLaneAt unsigned integer overloads (PR #133520)
https://github.com/spall created https://github.com/llvm/llvm-project/pull/133520 Add WaveReadLaneAt unsigned integer overloads 2nd argument of WaveReadLaneAt should be a uint32_t and not an int32_t add tests Closes #133473 >From 69d23f1ba200ceab78d1c108b629875b108689c0 Mon Sep 17 00:00:00 2001 From: Sarah Spall Date: Fri, 28 Mar 2025 14:07:37 -0700 Subject: [PATCH] add unsigned support + tests + 2nd arg should always be unsigned --- .../lib/Headers/hlsl/hlsl_alias_intrinsics.h | 87 +-- .../CodeGenHLSL/builtins/WaveReadLaneAt.hlsl | 39 + 2 files changed, 98 insertions(+), 28 deletions(-) diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h index b0ff9075377d8..0de04f13b7ec4 100644 --- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h +++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h @@ -2358,77 +2358,108 @@ __attribute__((convergent)) bool WaveIsFirstLane(); // the specified wave. _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool WaveReadLaneAt(bool, int32_t); +__attribute__((convergent)) bool WaveReadLaneAt(bool, uint32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool2 WaveReadLaneAt(bool2, int32_t); +__attribute__((convergent)) bool2 WaveReadLaneAt(bool2, uint32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool3 WaveReadLaneAt(bool3, int32_t); +__attribute__((convergent)) bool3 WaveReadLaneAt(bool3, uint32_t); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) bool4 WaveReadLaneAt(bool4, int32_t); +__attribute__((convergent)) bool4 WaveReadLaneAt(bool4, uint32_t); #ifdef __HLSL_ENABLE_16_BIT _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t WaveReadLaneAt(int16_t, int32_t); +__attribute__((convergent)) int16_t WaveReadLaneAt(int16_t, uint32_t); _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t2 WaveReadLaneAt(int16_t2, int32_t); +__attribute__((convergent)) int16_t2 WaveReadLaneAt(int16_t2, uint32_t); _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t3 WaveReadLaneAt(int16_t3, int32_t); +__attribute__((convergent)) int16_t3 WaveReadLaneAt(int16_t3, uint32_t); _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) int16_t4 WaveReadLaneAt(int16_t4, int32_t); +__attribute__((convergent)) int16_t4 WaveReadLaneAt(int16_t4, uint32_t); + +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t WaveReadLaneAt(uint16_t, uint32_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t2 WaveReadLaneAt(uint16_t2, uint32_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t3 WaveReadLaneAt(uint16_t3, uint32_t); +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint16_t4 WaveReadLaneAt(uint16_t4, uint32_t); #endif _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half WaveReadLaneAt(half, int32_t); +__attribute__((convergent)) half WaveReadLaneAt(half, uint32_t); _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half2 WaveReadLaneAt(half2, int32_t); +__attribute__((convergent)) half2 WaveReadLaneAt(half2, uint32_t); _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half3 WaveReadLaneAt(half3, int32_t); +__attribute__((convergent)) half3 WaveReadLaneAt(half3, uint32_t); _HLSL_16BIT_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) -__attribute__((convergent)) half4 WaveReadLaneAt(half4, int32_t); +__attribute__((convergent)) half4 WaveReadLaneAt(half4, uint32_t); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int WaveReadLaneAt(int, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int2 WaveReadLaneAt(int2, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int3 WaveReadLaneAt(int3, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) int4 WaveReadLaneAt(int4, uint32_t); + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) uint WaveReadLaneAt(uint, uint32_t); +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_w
[clang] Optimize Module Dependency Handling for Efficient Memory Usage (PR #132638)
https://github.com/ayushpareek2003 updated https://github.com/llvm/llvm-project/pull/132638 >From ba67caab088be29018c17bfe47e3064db357788d Mon Sep 17 00:00:00 2001 From: Ayush Pareek Date: Mon, 24 Mar 2025 03:33:31 +0530 Subject: [PATCH] Optimize Module Dependency Handling for Efficient Memory Usage -Optimized addModuleFiles functions for both CompilerInvocation and CowCompilerInvocation to reduce redundant function calls and improve efficiency -Introduced memory preallocation using reserve() when eager load is enabled to reduce reallocation overhead -Used try_emplace() instead of insert() for PrebuiltModuleFiles to avoid unnecessary overwrites --- .../DependencyScanning/ModuleDepCollector.cpp | 60 --- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp index d715ef874e002..b8b646ffb6d09 100644 --- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -393,41 +393,57 @@ void ModuleDepCollector::addModuleMapFiles( CompilerInvocation &CI, ArrayRef ClangModuleDeps) const { if (Service.shouldEagerLoadModules()) return; // Only pcm is needed for eager load. - + // Preallocate memory to avoid multiple allocations + CI.getFrontendOpts().ModuleMapFiles.reserve( + CI.getFrontendOpts().ModuleMapFiles.size() + ClangModuleDeps.size()); + for (const ModuleID &MID : ClangModuleDeps) { -ModuleDeps *MD = ModuleDepsByID.lookup(MID); -assert(MD && "Inconsistent dependency info"); -CI.getFrontendOpts().ModuleMapFiles.push_back(MD->ClangModuleMapFile); +if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) { // Single lookup + assert(MD && "Inconsistent dependency info"); + CI.getFrontendOpts().ModuleMapFiles.emplace_back(MD->ClangModuleMapFile); + } } } void ModuleDepCollector::addModuleFiles( CompilerInvocation &CI, ArrayRef ClangModuleDeps) const { +// Preallocate memory if eager load is enabled + if (Service.shouldEagerLoadModules()) { + CI.getFrontendOpts().ModuleFiles.reserve( + CI.getFrontendOpts().ModuleFiles.size() + ClangModuleDeps.size()); + } for (const ModuleID &MID : ClangModuleDeps) { -ModuleDeps *MD = ModuleDepsByID.lookup(MID); -std::string PCMPath = -Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile); - -if (Service.shouldEagerLoadModules()) - CI.getFrontendOpts().ModuleFiles.push_back(std::move(PCMPath)); -else - CI.getHeaderSearchOpts().PrebuiltModuleFiles.insert( - {MID.ModuleName, std::move(PCMPath)}); +if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) { + std::string PCMPath = + Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile); + if (Service.shouldEagerLoadModules()) { + CI.getFrontendOpts().ModuleFiles.emplace_back(std::move(PCMPath)); + } else { + CI.getHeaderSearchOpts().PrebuiltModuleFiles.try_emplace( + MID.ModuleName, std::move(PCMPath)); + } +} } } void ModuleDepCollector::addModuleFiles( CowCompilerInvocation &CI, ArrayRef ClangModuleDeps) const { + // Preallocation + if (Service.shouldEagerLoadModules()) { + CI.getMutFrontendOpts().ModuleFiles.reserve( + CI.getMutFrontendOpts().ModuleFiles.size() + ClangModuleDeps.size()); + } for (const ModuleID &MID : ClangModuleDeps) { -ModuleDeps *MD = ModuleDepsByID.lookup(MID); -std::string PCMPath = -Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile); - -if (Service.shouldEagerLoadModules()) - CI.getMutFrontendOpts().ModuleFiles.push_back(std::move(PCMPath)); -else - CI.getMutHeaderSearchOpts().PrebuiltModuleFiles.insert( - {MID.ModuleName, std::move(PCMPath)}); +if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) { + std::string PCMPath = + Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile); + if (Service.shouldEagerLoadModules()) { + CI.getMutFrontendOpts().ModuleFiles.emplace_back(std::move(PCMPath)); + } else { + CI.getMutHeaderSearchOpts().PrebuiltModuleFiles.try_emplace( + MID.ModuleName, std::move(PCMPath)); + } + } } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Add WaveReadLaneAt unsigned integer overloads (PR #133520)
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/133520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [PGO][Offload] Allow PGO flags to be used on GPU targets (PR #94268)
jhuber6 wrote: > The crash is blocking our compiler updates. If nothing depends on this change > yet, it would be great to revert the patch and re-land it once it's fixed. Go ahead and revert it, but I think there were some follow-up patches. Also the `pgo1.c` and `pgo2.c` tests were flaky so I'm it's definitely the right move. https://github.com/llvm/llvm-project/pull/94268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [PGO][Offload] Allow PGO flags to be used on GPU targets (PR #94268)
EthanLuisMcDonough wrote: This patch should disable PGO on nvidia targets: https://github.com/llvm/llvm-project/pull/133522. I'll merge it after I'm done running some tests https://github.com/llvm/llvm-project/pull/94268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)
https://github.com/kmpeng updated https://github.com/llvm/llvm-project/pull/132288 >From 1d28510653b39fcabe45ad37197674bdd0217add Mon Sep 17 00:00:00 2001 From: kmpeng Date: Tue, 18 Mar 2025 13:25:10 -0700 Subject: [PATCH 01/11] create int_spv_smoothstep intrinsic, create smoothstep lowering & map to int_spv_smoothstep, create SPIR-V backend test cases --- llvm/include/llvm/IR/IntrinsicsSPIRV.td | 1 + .../Target/SPIRV/SPIRVInstructionSelector.cpp | 2 + .../SPIRV/hlsl-intrinsics/smoothstep.ll | 60 ++ llvm/test/CodeGen/SPIRV/opencl/smoothstep.ll | 61 +++ 4 files changed, 124 insertions(+) create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll create mode 100644 llvm/test/CodeGen/SPIRV/opencl/smoothstep.ll diff --git a/llvm/include/llvm/IR/IntrinsicsSPIRV.td b/llvm/include/llvm/IR/IntrinsicsSPIRV.td index 906bdfdcd4eb1..4389b86745d7f 100644 --- a/llvm/include/llvm/IR/IntrinsicsSPIRV.td +++ b/llvm/include/llvm/IR/IntrinsicsSPIRV.td @@ -75,6 +75,7 @@ let TargetPrefix = "spv" in { def int_spv_reflect : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>], [IntrNoMem]>; def int_spv_rsqrt : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty], [IntrNoMem]>; def int_spv_saturate : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], [IntrNoMem]>; + def int_spv_smoothstep : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [llvm_anyfloat_ty, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>; def int_spv_step : DefaultAttrsIntrinsic<[LLVMMatchType<0>], [LLVMMatchType<0>, llvm_anyfloat_ty], [IntrNoMem]>; def int_spv_fdot : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp index fd598904d7ba5..644223ccdc0a7 100644 --- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp @@ -3083,6 +3083,8 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, return selectExtInst(ResVReg, ResType, I, CL::rsqrt, GL::InverseSqrt); case Intrinsic::spv_sign: return selectSign(ResVReg, ResType, I); + case Intrinsic::spv_smoothstep: +return selectExtInst(ResVReg, ResType, I, CL::smoothstep, GL::SmoothStep); case Intrinsic::spv_firstbituhigh: // There is no CL equivalent of FindUMsb return selectFirstBitHigh(ResVReg, ResType, I, /*IsSigned=*/false); case Intrinsic::spv_firstbitshigh: // There is no CL equivalent of FindSMsb diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll new file mode 100644 index 0..09f93ab7955d3 --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/smoothstep.ll @@ -0,0 +1,60 @@ +; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; Make sure SPIRV operation function calls for smoothstep are lowered correctly. + +; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "GLSL.std.450" +; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 +; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 +; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 +; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 + +define noundef half @smoothstep_half(half noundef %a, half noundef %b, half noundef %c) { +entry: + ; CHECK: %[[#]] = OpFunction %[[#float_16]] None %[[#]] + ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#float_16]] + ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#float_16]] + ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#float_16]] + ; CHECK: %[[#]] = OpExtInst %[[#float_16]] %[[#op_ext_glsl]] SmoothStep %[[#arg0]] %[[#arg1]] %[[#arg2]] + %spv.smoothstep = call half @llvm.spv.smoothstep.f16(half %a, half %b, half %c) + ret half %spv.smoothstep +} + +define noundef float @smoothstep_float(float noundef %a, float noundef %b, float noundef %c) { +entry: + ; CHECK: %[[#]] = OpFunction %[[#float_32]] None %[[#]] + ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#float_32]] + ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#float_32]] + ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#float_32]] + ; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext_glsl]] SmoothStep %[[#arg0]] %[[#arg1]] %[[#arg2]] + %spv.smoothstep = call float @llvm.spv.smoothstep.f32(float %a, float %b, float %c) + ret float %spv.smoothstep +} + +define noundef <4 x half> @smoothstep_half4(<4 x half> noundef %a, <4 x half> noundef %b, <4 x half> noundef %c) { +entry: + ; CHECK: %[[#]] = OpFunction %[[#vec4_float_16]] None %[[#]] + ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_16]] + ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_16]] + ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#vec4_float_16]] + ; CHECK: %[[#]] = OpExtIns
[clang] [llvm] [PGO][Offload] Disable PGO on NVPTX (PR #133522)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Ethan Luis McDonough (EthanLuisMcDonough) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/133522.diff 5 Files Affected: - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-1) - (added) clang/test/Driver/cuda-no-pgo-or-coverage.cu (+33) - (modified) llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test (+1-1) - (modified) offload/test/offloading/gpupgo/pgo1.c (+1-1) - (modified) offload/test/offloading/gpupgo/pgo2.c (+1-1) ``diff diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 26fa234dd4e9b..5f45cf0865b9e 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6397,7 +6397,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fconvergent_functions, options::OPT_fno_convergent_functions); - addPGOAndCoverageFlags(TC, C, JA, Output, Args, SanitizeArgs, CmdArgs); + // NVPTX doesn't support PGO or coverage + if (!Triple.isNVPTX()) +addPGOAndCoverageFlags(TC, C, JA, Output, Args, SanitizeArgs, CmdArgs); Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ); diff --git a/clang/test/Driver/cuda-no-pgo-or-coverage.cu b/clang/test/Driver/cuda-no-pgo-or-coverage.cu new file mode 100644 index 0..b84587e1e182b --- /dev/null +++ b/clang/test/Driver/cuda-no-pgo-or-coverage.cu @@ -0,0 +1,33 @@ +// Check that profiling/coverage arguments doen't get passed down to device-side +// compilation. +// +// +// XRUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \ +// XRUN: -fprofile-generate %s 2>&1 | \ +// XRUN: FileCheck --check-prefixes=CHECK,PROF %s +// +// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \ +// RUN: -fprofile-instr-generate %s 2>&1 | \ +// RUN: FileCheck --check-prefixes=CHECK,PROF %s +// +// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \ +// RUN: -coverage %s 2>&1 | \ +// RUN: FileCheck --check-prefixes=CHECK,GCOV %s +// +// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \ +// RUN: -ftest-coverage %s 2>&1 | \ +// RUN: FileCheck --check-prefixes=CHECK,GCOV %s +// +// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 \ +// RUN: -fprofile-instr-generate -fcoverage-mapping %s 2>&1 | \ +// RUN: FileCheck --check-prefixes=CHECK,PROF %s +// +// +// CHECK-NOT: error: unsupported option '-fprofile +// CHECK-NOT: error: invalid argument +// CHECK-DAG: "-fcuda-is-device" +// CHECK-NOT: "-f{{[^"/]*coverage.*}}" +// CHECK-NOT: "-fprofile{{[^"]*}}" +// CHECK: "-triple" "x86_64-unknown-linux-gnu" +// PROF: "-fprofile{{.*}}" +// GCOV: "-coverage-notes-file= diff --git a/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test b/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test index 49c5ae9b0931d..83cf76f68fb63 100644 --- a/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test +++ b/llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test @@ -1,7 +1,7 @@ // Header // // INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic()) -// INSTR_PROF_RAW_HEADER(uint64_t, Version, Version) +// INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version()) // INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL)) // INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize) // INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize) diff --git a/offload/test/offloading/gpupgo/pgo1.c b/offload/test/offloading/gpupgo/pgo1.c index c8011cbae83c0..af6d8e806cd37 100644 --- a/offload/test/offloading/gpupgo/pgo1.c +++ b/offload/test/offloading/gpupgo/pgo1.c @@ -14,7 +14,7 @@ // RUN: %target_triple.%basename_t.clang.profraw | \ // RUN: %fcheck-generic --check-prefix="CLANG-PGO" -// REQUIRES: gpu +// REQUIRES: amdgpu // REQUIRES: pgo int test1(int a) { return a / 2; } diff --git a/offload/test/offloading/gpupgo/pgo2.c b/offload/test/offloading/gpupgo/pgo2.c index b75b0beaffdec..b67a63bc8fc3d 100644 --- a/offload/test/offloading/gpupgo/pgo2.c +++ b/offload/test/offloading/gpupgo/pgo2.c @@ -48,7 +48,7 @@ // RUN: %target_triple.%basename_t.hfdi.profraw \ // RUN: | %fcheck-generic --check-prefix="LLVM-DEVICE" -// REQUIRES: gpu +// REQUIRES: amdgpu // REQUIRES: pgo int main() { `` https://github.com/llvm/llvm-project/pull/133522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL][RootSignature] Make Root Signature lexer keywords case-insensitive (PR #132967)
https://github.com/inbelic closed https://github.com/llvm/llvm-project/pull/132967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 83c4cb3 - [HLSL][RootSignature] Make Root Signature lexer keywords case-insensitive (#132967)
Author: Finn Plummer Date: 2025-03-28T14:27:24-07:00 New Revision: 83c4cb36aaa41cc58f8d9fed5cb364e46e5c7db5 URL: https://github.com/llvm/llvm-project/commit/83c4cb36aaa41cc58f8d9fed5cb364e46e5c7db5 DIFF: https://github.com/llvm/llvm-project/commit/83c4cb36aaa41cc58f8d9fed5cb364e46e5c7db5.diff LOG: [HLSL][RootSignature] Make Root Signature lexer keywords case-insensitive (#132967) >From the corrections to the Root Signature specification here: https://github.com/llvm/wg-hlsl/issues/192. It was denoted that keywords are also case-insensitive in DXC. This pr adjusts the lexer to adhere to the updated spec. We also have a NFC to add a missing license to a file while in the area. - Co-authored-by: Finn Plummer Added: Modified: clang/lib/Lex/LexHLSLRootSignature.cpp clang/unittests/Lex/LexHLSLRootSignatureTest.cpp Removed: diff --git a/clang/lib/Lex/LexHLSLRootSignature.cpp b/clang/lib/Lex/LexHLSLRootSignature.cpp index 8344aad15a9bc..fb4aab20c7275 100644 --- a/clang/lib/Lex/LexHLSLRootSignature.cpp +++ b/clang/lib/Lex/LexHLSLRootSignature.cpp @@ -1,3 +1,11 @@ +//=== LexHLSLRootSignature.cpp - Lex Root Signature ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + #include "clang/Lex/LexHLSLRootSignature.h" namespace clang { @@ -87,7 +95,7 @@ RootSignatureToken RootSignatureLexer::LexToken() { // Define a large string switch statement for all the keywords and enums auto Switch = llvm::StringSwitch(TokSpelling); -#define KEYWORD(NAME) Switch.Case(#NAME, TokenKind::kw_##NAME); +#define KEYWORD(NAME) Switch.CaseLower(#NAME, TokenKind::kw_##NAME); #define ENUM(NAME, LIT) Switch.CaseLower(LIT, TokenKind::en_##NAME); #include "clang/Lex/HLSLRootSignatureTokenKinds.def" diff --git a/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp b/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp index 0576f08c4c276..d72a842922f98 100644 --- a/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp +++ b/clang/unittests/Lex/LexHLSLRootSignatureTest.cpp @@ -120,6 +120,36 @@ TEST_F(LexHLSLRootSignatureTest, ValidLexAllTokensTest) { CheckTokens(Lexer, Tokens, Expected); } +TEST_F(LexHLSLRootSignatureTest, ValidCaseInsensitiveKeywordsTest) { + // This test will check that we can lex keywords in an case-insensitive + // manner + const llvm::StringLiteral Source = R"cc( +DeScRiPtOrTaBlE + +CBV srv UAV sampler +SPACE visibility FLAGS +numDescriptors OFFSET + )cc"; + auto TokLoc = SourceLocation(); + hlsl::RootSignatureLexer Lexer(Source, TokLoc); + + SmallVector Tokens; + SmallVector Expected = { + hlsl::TokenKind::kw_DescriptorTable, + hlsl::TokenKind::kw_CBV, + hlsl::TokenKind::kw_SRV, + hlsl::TokenKind::kw_UAV, + hlsl::TokenKind::kw_Sampler, + hlsl::TokenKind::kw_space, + hlsl::TokenKind::kw_visibility, + hlsl::TokenKind::kw_flags, + hlsl::TokenKind::kw_numDescriptors, + hlsl::TokenKind::kw_offset, + }; + + CheckTokens(Lexer, Tokens, Expected); +} + TEST_F(LexHLSLRootSignatureTest, ValidLexPeekTest) { // This test will check that we the peek api is correctly used const llvm::StringLiteral Source = R"cc( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PGO][Offload] Disable PGO on NVPTX (PR #133522)
@@ -6397,7 +6397,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fconvergent_functions, options::OPT_fno_convergent_functions); - addPGOAndCoverageFlags(TC, C, JA, Output, Args, SanitizeArgs, CmdArgs); + // NVPTX doesn't support PGO or coverage Artem-B wrote: I'd add the pointer to the failure details mentioning circular data references and, maybe, point for the PR comment with the details. https://github.com/llvm/llvm-project/pull/133522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PGO][Offload] Disable PGO on NVPTX (PR #133522)
https://github.com/Artem-B approved this pull request. LGTM with a comment nit. https://github.com/llvm/llvm-project/pull/133522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Add SPIR-V target type for RWStructuredBuffers (PR #133468)
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/133468 >From 7838678ca8ec5870cd8df81b109f9e1b30699f4e Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Fri, 24 Jan 2025 13:04:29 -0500 Subject: [PATCH 1/2] [HLSL] Add SPIR-V target type for RWStructuredBuffers This PR adds the target type for main storage for HLSL raw buffer types. It does not handle the counter variables that are associated with those buffers. This is implementing part of https://github.com/llvm/wg-hlsl/blob/main/proposals/0018-spirv-resource-representation.md. We do not handle other HLSL raw buffer types. --- clang/lib/CodeGen/Targets/SPIR.cpp| 15 +++- .../StructuredBuffers-constructors.hlsl | 69 +++ 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/clang/lib/CodeGen/Targets/SPIR.cpp b/clang/lib/CodeGen/Targets/SPIR.cpp index 43f511e572d37..8e8c46ef74041 100644 --- a/clang/lib/CodeGen/Targets/SPIR.cpp +++ b/clang/lib/CodeGen/Targets/SPIR.cpp @@ -386,13 +386,22 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType( if (ContainedTy.isNull()) return nullptr; -assert(!ResAttrs.RawBuffer && - "Raw buffers handles are not implemented for SPIR-V yet"); assert(!ResAttrs.IsROV && "Rasterizer order views not implemented for SPIR-V yet"); -// convert element type llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy); +if (ResAttrs.RawBuffer) { + llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0); + + uint32_t StorageClass = /* StorageBuffer storage class */ 12; + bool IsWritable = + ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV; + return llvm::TargetExtType::get(Ctx, "spirv.VulkanBuffer", + {RuntimeArrayType}, + {StorageClass, IsWritable}); +} + +// convert element type return getSPIRVImageTypeFromHLSLResource(ResAttrs, ElemType, Ctx); } case llvm::dxil::ResourceClass::CBuffer: diff --git a/clang/test/CodeGenHLSL/builtins/StructuredBuffers-constructors.hlsl b/clang/test/CodeGenHLSL/builtins/StructuredBuffers-constructors.hlsl index 04534c5550252..8a1429fd1a6fc 100644 --- a/clang/test/CodeGenHLSL/builtins/StructuredBuffers-constructors.hlsl +++ b/clang/test/CodeGenHLSL/builtins/StructuredBuffers-constructors.hlsl @@ -1,59 +1,70 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DXIL -// RUN-DISABLED: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV +// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -DSPIRV -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV -// NOTE: SPIRV codegen for resource types is not yet implemented StructuredBuffer Buf : register(t10); RWStructuredBuffer Buf2 : register(u5, space1); + +#ifndef SPIRV +// NOTE: SPIRV codegen for these resource types is not implemented yet. AppendStructuredBuffer Buf3 : register(u3); ConsumeStructuredBuffer Buf4 : register(u4); RasterizerOrderedStructuredBuffer Buf5 : register(u1, space2); +#endif + +// CHECK-DXIL: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", float, 0, 0) } +// CHECK-DXIL: %"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 0) } +// CHECK-DXIL: %"class.hlsl::AppendStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 0) } +// CHECK-DXIL: %"class.hlsl::ConsumeStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 0) } +// CHECK-DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 1) } + +// CHECK-SPIRV: %"class.hlsl::StructuredBuffer" = type { target("spirv.VulkanBuffer", [0 x float], 12, 0) } +// CHECK-SPIRV: %"class.hlsl::RWStructuredBuffer" = type { target("spirv.VulkanBuffer", [0 x float], 12, 1) } -// CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", float, 0, 0) } -// CHECK: %"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 0) } -// CHECK: %"class.hlsl::AppendStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 0) } -// CHECK: %"class.hlsl::ConsumeStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 0) } -// CHECK: %"class.hlsl::RasterizerOrderedStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 1) } -// CHECK: @_ZL3Buf = internal global %"class.hlsl::StructuredBuffer" poison, align 4 -// CHECK: @_ZL4Buf2 = internal global %"class.hlsl::RWStructuredBuffer" poison, align 4 -// CHECK: @_ZL4Buf3 = internal global %"class.hlsl::AppendStructuredBuffer" poison, align 4 -// CHECK: @_ZL4Buf4 = internal global %"class.hlsl::ConsumeStructuredBuffer" poison, align 4 -// CHECK: @_ZL4Buf5 = internal global %"class.hlsl::RasterizerOrderedStructuredBuf
[clang] [HIP] Claim `--offload-compress` for `-M` (PR #133456)
https://github.com/jhuber6 approved this pull request. Didn't notice the indentation, LGTM. https://github.com/llvm/llvm-project/pull/133456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)
https://github.com/s-perron commented: The changes look correct, but I want to double check that they are complete. https://github.com/llvm/llvm-project/pull/133469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][SPIR-V] Fix convergence tokens for dtor (PR #133469)
@@ -57,22 +58,37 @@ void main(unsigned GI : SV_GroupIndex) { // CHECK: define void @main() // CHECK-NEXT: entry: // Verify destructor is emitted -// NOINLINE-NEXT: call void @_GLOBAL__sub_I_GlobalDestructors.hlsl() -// NOINLINE-NEXT: %0 = call i32 @llvm.dx.flattened.thread.id.in.group() -// NOINLINE-NEXT: call void @_Z4mainj(i32 %0) -// NOINLINE-NEXT: call void @_GLOBAL__D_a() -// NOINLINE-NEXT: ret void +// NOINLINE-DXIL-NEXT: call void @_GLOBAL__sub_I_GlobalDestructors.hlsl() +// NOINLINE-DXIL-NEXT: %0 = call i32 @llvm.dx.flattened.thread.id.in.group() +// NOINLINE-DXIL-NEXT: call void @_Z4mainj(i32 %0) +// NOINLINE-DXIL-NEXT: call void @_GLOBAL__D_a() +// NOINLINE-DXIL-NEXT: ret void + +// NOINLINE-SPIRV-NEXT: %0 = call token @llvm.experimental.convergence.entry() +// NOINLINE-SPIRV-NEXT: call spir_func void @_GLOBAL__sub_I_GlobalDestructors.hlsl() [ "convergencectrl"(token %0) ] s-perron wrote: Does the definition of the destructor have the convergence tokens in it? I believe the inliner gets confused if some functions have convergence tokens and others do not. https://github.com/llvm/llvm-project/pull/133469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b0bb86e - [HLSL][NFC] Use method builder to create default resource constructor (#131384)
Author: Helena Kotas Date: 2025-03-28T12:04:03-07:00 New Revision: b0bb86e239b2b09476ca58976094cc645ea9194f URL: https://github.com/llvm/llvm-project/commit/b0bb86e239b2b09476ca58976094cc645ea9194f DIFF: https://github.com/llvm/llvm-project/commit/b0bb86e239b2b09476ca58976094cc645ea9194f.diff LOG: [HLSL][NFC] Use method builder to create default resource constructor (#131384) Updates `BuiltinTypeMethodBuilder` helper class to support creation of constructors and updates the code that creates default constructor for resource classes to use it. This enables us to share code when creating builtin methods and constructors and will come in handy when we add more constructors in the future. Depends on #131032. Added: Modified: clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp Removed: diff --git a/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp b/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp index 6b7cc86fefa8f..2d3e1088557ab 100644 --- a/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp +++ b/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp @@ -67,45 +67,50 @@ struct TemplateParameterListBuilder { BuiltinTypeDeclBuilder &finalizeTemplateArgs(ConceptDecl *CD = nullptr); }; -// Builder for methods of builtin types. Allows adding methods to builtin types -// using the builder pattern like this: +// Builder for methods or constructors of builtin types. Allows creating methods +// or constructors of builtin types using the builder pattern like this: // // BuiltinTypeMethodBuilder(RecordBuilder, "MethodName", ReturnType) // .addParam("param_name", Type, InOutModifier) // .callBuiltin("builtin_name", BuiltinParams...) -// .finalizeMethod(); +// .finalize(); // -// The builder needs to have all of the method parameters before it can create -// a CXXMethodDecl. It collects them in addParam calls and when a first -// method that builds the body is called or when access to 'this` is needed it -// creates the CXXMethodDecl and ParmVarDecls instances. These can then be -// referenced from the body building methods. Destructor or an explicit call to -// finalizeMethod() will complete the method definition. +// The builder needs to have all of the parameters before it can create +// a CXXMethodDecl or CXXConstructorDecl. It collects them in addParam calls and +// when a first method that builds the body is called or when access to 'this` +// is needed it creates the CXXMethodDecl/CXXConstructorDecl and ParmVarDecls +// instances. These can then be referenced from the body building methods. +// Destructor or an explicit call to finalize() will complete the method +// definition. // // The callBuiltin helper method accepts constants via `Expr *` or placeholder // value arguments to indicate which function arguments to forward to the // builtin. // // If the method that is being built has a non-void return type the -// finalizeMethod will create a return statent with the value of the last -// statement (unless the last statement is already a ReturnStmt). +// finalize() will create a return statement with the value of the last +// statement (unless the last statement is already a ReturnStmt or the return +// value is void). struct BuiltinTypeMethodBuilder { private: - struct MethodParam { + struct Param { const IdentifierInfo &NameII; QualType Ty; HLSLParamModifierAttr::Spelling Modifier; -MethodParam(const IdentifierInfo &NameII, QualType Ty, -HLSLParamModifierAttr::Spelling Modifier) +Param(const IdentifierInfo &NameII, QualType Ty, + HLSLParamModifierAttr::Spelling Modifier) : NameII(NameII), Ty(Ty), Modifier(Modifier) {} }; BuiltinTypeDeclBuilder &DeclBuilder; - DeclarationNameInfo NameInfo; + DeclarationName Name; QualType ReturnTy; + // method or constructor declaration + // (CXXConstructorDecl derives from CXXMethodDecl) CXXMethodDecl *Method; bool IsConst; - llvm::SmallVector Params; + bool IsCtor; + llvm::SmallVector Params; llvm::SmallVector StmtsList; // Argument placeholders, inspired by std::placeholder. These are the indices @@ -124,15 +129,17 @@ struct BuiltinTypeMethodBuilder { friend BuiltinTypeDeclBuilder; BuiltinTypeMethodBuilder(BuiltinTypeDeclBuilder &DB, DeclarationName &Name, - QualType ReturnTy, bool IsConst = false) - : DeclBuilder(DB), NameInfo(DeclarationNameInfo(Name, SourceLocation())), -ReturnTy(ReturnTy), Method(nullptr), IsConst(IsConst) {} - - BuiltinTypeMethodBuilder(BuiltinTypeDeclBuilder &DB, StringRef Name, - QualType ReturnTy, bool IsConst = false); + QualType ReturnTy, bool IsConst = false, + bool IsCtor = false) + : DeclBuilder(DB), Name(Name), ReturnTy(ReturnTy), Method(nullptr), +IsConst(IsConst), IsCtor(IsCtor) {} +
[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)
@@ -23,12 +24,27 @@ using ast_matchers::pointerType; using ast_matchers::referenceType; using ast_matchers::returns; -bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, - bool &HasValue) { +CanQualType getLikeReturnType(QualType RT) { + if (!RT.isNull() && RT->isPointerType()) { +return RT->getPointeeType() +->getCanonicalTypeUnqualified() +.getUnqualifiedType(); + } + return {}; +} + +CanQualType valueLikeReturnType(QualType RT) { + if (!RT.isNull() && RT->isReferenceType()) { +return RT.getNonReferenceType() +->getCanonicalTypeUnqualified() +.getUnqualifiedType(); + } + return {}; +} + +CanQualType pointerLikeReturnType(const CXXRecordDecl &RD) { // We may want to cache this search, but in current profiles it hasn't shown // up as a hot spot (possibly because there aren't many hits, relatively). - bool HasArrow = false; - bool HasStar = false; CanQualType StarReturnType, ArrowReturnType, GetReturnType, ValueReturnType; jvoung wrote: Can remove the 'GetReturnType, ValueReturnType' variables too https://github.com/llvm/llvm-project/pull/133350 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)
zygoloid wrote: Ping. https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add regression test for test comments in macros (PR #132510)
@@ -0,0 +1,34 @@ +// Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test. +// RUN: rm -rf %t && mkdir -p %t +// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS +// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS-LINE +// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS + +#define DECLARE_METHODS \ +/** \ + * @brief Declare a method to calculate the sum of two numbers\ + */ \ +int Add(int a, int b) \ +{ \ +return a + b; \ +} + +// MD-MYCLASS: ### Add +// MD-MYCLASS: *public int Add(int a, int b)* +// MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers + +// HTML-MYCLASS: public int Add(int a, int b) +// HTML-MYCLASS: brief +// HTML-MYCLASS: Declare a method to calculate the sum of two numbers ilovepi wrote: > I also have another problem: Why HTML match is not similar to Markdown? > > Because I refer to `enum.cpp` to write this match. It matchs different parts. > So I don't make sense which part must match in HTML. > > Markdown match is clearly, HTML seem to ignore something. I'm not sure what you are asking. FileCheck pattern matching will match what it finds in the file that matches. IIRC it will take the last thing it finds that matches, not the first. So your lines may match arbitrary things in the output. The markdown has a lot of empty lines, which makes writing checks w/ a `-NEXT` suffix hard to do. HTML is much more structured, so its (generally) more difficult to accidentally match something if you write stricter checks. https://github.com/llvm/llvm-project/pull/132510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)
@@ -164,16 +161,19 @@ ast_matchers::StatementMatcher isPointerLikeOperatorArrow() { ofClass(pointerClass(); } -ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall() { +ast_matchers::StatementMatcher +isSmartPointerLikeValueMethodCall(clang::StringRef MethodName) { return cxxMemberCallExpr(callee(cxxMethodDecl( parameterCountIs(0), returns(hasCanonicalType(referenceType())), - hasName("value"), ofClass(smartPointerClassWithValue(); + hasName(MethodName), fmayer wrote: The short-term plan is to use this for a data type that uses `Get` instead of `get` but otherwise models a smartpointerlike. https://github.com/llvm/llvm-project/pull/133350 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)
ilovepi wrote: The branch has conflicts that need to be resolved. While its not a problem, we typically wait for 1 week between reviews to "ping" a reviewer. https://llvm.org/docs/CodeReview.html#lgtm-how-a-patch-is-accepted https://github.com/llvm/llvm-project/pull/131280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)
hulxv wrote: > While its not a problem, we typically wait for 1 week between reviews to > "ping" a reviewer. > https://llvm.org/docs/CodeReview.html#lgtm-how-a-patch-is-accepted Ok, I am sorry for that https://github.com/llvm/llvm-project/pull/131280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits