[clang-tools-extra] [clang-tidy] Fix `cert-err33-c` to ignore functions with same prefixes as target (PR #135160)
bjosv wrote: > I think we should provide an entry in `ReleaseNotes.rst` since the change > alters behavior of the check (fixes false-positives). Missed that, thanks. Done. https://github.com/llvm/llvm-project/pull/135160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Fix `cert-err33-c` to ignore functions with same prefixes as target (PR #135160)
=?utf-8?q?Bj=C3=B6rn?= Svensson , =?utf-8?q?Bj=C3=B6rn?= Svensson Message-ID: In-Reply-To: @@ -50,183 +50,183 @@ namespace { // with NULL argument and in this case the check is not applicable: // `mblen, mbrlen, mbrtowc, mbtowc, wctomb, wctomb_s`. // FIXME: The check can be improved to handle such cases. -const llvm::StringRef CertErr33CCheckedFunctions = "^::aligned_alloc;" - "^::asctime_s;" - "^::at_quick_exit;" - "^::atexit;" - "^::bsearch;" - "^::bsearch_s;" - "^::btowc;" - "^::c16rtomb;" - "^::c32rtomb;" - "^::calloc;" - "^::clock;" - "^::cnd_broadcast;" - "^::cnd_init;" - "^::cnd_signal;" - "^::cnd_timedwait;" - "^::cnd_wait;" - "^::ctime_s;" - "^::fclose;" - "^::fflush;" - "^::fgetc;" - "^::fgetpos;" - "^::fgets;" - "^::fgetwc;" - "^::fopen;" - "^::fopen_s;" - "^::fprintf;" - "^::fprintf_s;" - "^::fputc;" - "^::fputs;" - "^::fputwc;" - "^::fputws;" - "^::fread;" - "^::freopen;" - "^::freopen_s;" - "^::fscanf;" - "^::fscanf_s;" - "^::fseek;" - "^::fsetpos;" - "^::ftell;" - "^::fwprintf;" - "^::fwprintf_s;" - "^::fwrite;" - "^::fwscanf;" - "^::fwscanf_s;" - "^::getc;" - "^::getchar;" - "^::getenv;" - "^::getenv_s;" - "^::gets_s;" - "^::getwc;" - "^::getwchar;" - "^::gmtime;" - "^::gmtime_s;" - "^::localtime;" - "^::localtime_s;" - "^::malloc;" - "^::mbrtoc16;" - "^::mbrtoc32;" - "^::mbsrtowcs;" - "^::mbsrtowcs_s;" - "^::mbstowcs;" - "^::mbstowcs_s;" - "^::memchr;" - "^::mktime;" - "^::mtx_init;" - "^::mtx_lock;" - "^::mtx_timedlock;" - "^::mtx_trylock;" - "^::mtx_unlock;" - "^::printf_s;" -
[clang-tools-extra] [clang-tidy] Fix `cert-err33-c` to ignore functions with same prefixes as target (PR #135160)
=?utf-8?q?Björn?= Svensson , =?utf-8?q?Björn?= Svensson Message-ID: In-Reply-To: https://github.com/carlosgalvezp closed https://github.com/llvm/llvm-project/pull/135160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 0276915 - [clang-tidy] Fix `cert-err33-c` to ignore functions with same prefixes as target (#135160)
Author: Björn Svensson Date: 2025-04-11T10:08:29+02:00 New Revision: 0276915a6c888906b2140a3d97e5ce32057a3ca5 URL: https://github.com/llvm/llvm-project/commit/0276915a6c888906b2140a3d97e5ce32057a3ca5 DIFF: https://github.com/llvm/llvm-project/commit/0276915a6c888906b2140a3d97e5ce32057a3ca5.diff LOG: [clang-tidy] Fix `cert-err33-c` to ignore functions with same prefixes as target (#135160) PR #82952 introduced regex matching for `CheckedFunctions` in `UnusedReturnValueCheck` which is used by the checker `cert-err33-c`. Add a testcase and fix false positives by adding end-of-string to target regex's. - Signed-off-by: Björn Svensson Added: Modified: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/test/clang-tidy/checkers/cert/err33-c.c Removed: diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp index 26befe0de59ae..cc092a9627c5f 100644 --- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp @@ -50,183 +50,183 @@ namespace { // with NULL argument and in this case the check is not applicable: // `mblen, mbrlen, mbrtowc, mbtowc, wctomb, wctomb_s`. // FIXME: The check can be improved to handle such cases. -const llvm::StringRef CertErr33CCheckedFunctions = "^::aligned_alloc;" - "^::asctime_s;" - "^::at_quick_exit;" - "^::atexit;" - "^::bsearch;" - "^::bsearch_s;" - "^::btowc;" - "^::c16rtomb;" - "^::c32rtomb;" - "^::calloc;" - "^::clock;" - "^::cnd_broadcast;" - "^::cnd_init;" - "^::cnd_signal;" - "^::cnd_timedwait;" - "^::cnd_wait;" - "^::ctime_s;" - "^::fclose;" - "^::fflush;" - "^::fgetc;" - "^::fgetpos;" - "^::fgets;" - "^::fgetwc;" - "^::fopen;" - "^::fopen_s;" - "^::fprintf;" - "^::fprintf_s;" - "^::fputc;" - "^::fputs;" - "^::fputwc;" - "^::fputws;" - "^::fread;" - "^::freopen;" - "^::freopen_s;" - "^::fscanf;" - "^::fscanf_s;" - "^::fseek;" - "^::fsetpos;" - "^::ftell;" - "^::fwprintf;" - "^::fwprintf_s;" - "^::fwrite;" - "^::fwscanf;" - "^::fwscanf_s;" - "^::getc;" - "^::getchar;" - "^::getenv;" - "^::getenv_s;" - "^::gets_s;" - "^::getwc;" - "^::getwchar;" - "^::gmtime;" - "^::gmtime_s;" -
[clang] [Clang][Sema] Fix -Whigher-precision-for-complex-division (PR #131477)
https://github.com/Maetveis updated https://github.com/llvm/llvm-project/pull/131477 From d3da72bf61ae8268a25e5331acefe895c783905a Mon Sep 17 00:00:00 2001 From: Gergely Meszaros Date: Sat, 15 Mar 2025 22:37:07 +0100 Subject: [PATCH] [Clang][Sema] Fix -Whigher-precision-for-complex-division - Fix false positive when divisor is a real number - Fix false negative when divident is real, but divisor is complex - Fix false negative when due to promotion the division is performed in higher precision than the divident. - Fix false negative in divide and assign (`a /= b`) Fixes: #131127 --- clang/docs/ReleaseNotes.rst | 11 +++ clang/lib/Sema/SemaExpr.cpp | 78 .../complex-div-warn-higher-precision.cpp | 93 +++ 3 files changed, 144 insertions(+), 38 deletions(-) create mode 100644 clang/test/Sema/complex-div-warn-higher-precision.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 46d2debec3621..ae04ff52cdfdc 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -349,6 +349,17 @@ Improvements to Clang's diagnostics - Now correctly diagnose a tentative definition of an array with static storage duration in pedantic mode in C. (#GH50661) +- ``-Whigher-precisision-for-complex-divison`` no longer incorrectly warns when the divisor is real + in complex division. (#GH131127) + +- ``-Whigher-precisision-for-complex-divison`` now correctly warns when: + + - The dividend is real, but the divisor is complex. + - When the complex division happens in a higher precision type than the dividend due to arithmetic promotion. + - When using the divide and assign operator (``/=``) + + Fixes #GH131127 + Improvements to Clang's time-trace -- diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index c25daaa022f49..1ac84d7e95323 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -10591,6 +10591,45 @@ static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); } +static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy, + SourceLocation OpLoc) { + // If the divisor is real, then this is real/real or complex/real division. + // Either way there can be no precision loss. + auto *CT = DivisorTy->getAs(); + if (!CT) +return; + + QualType ElementType = CT->getElementType(); + bool IsComplexRangePromoted = S.getLangOpts().getComplexRange() == +LangOptions::ComplexRangeKind::CX_Promoted; + if (!ElementType->isFloatingType() || !IsComplexRangePromoted) +return; + + ASTContext &Ctx = S.getASTContext(); + QualType HigherElementType = Ctx.GetHigherPrecisionFPType(ElementType); + const llvm::fltSemantics &ElementTypeSemantics = + Ctx.getFloatTypeSemantics(ElementType); + const llvm::fltSemantics &HigherElementTypeSemantics = + Ctx.getFloatTypeSemantics(HigherElementType); + + if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 > + llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) || + (HigherElementType == Ctx.LongDoubleTy && + !Ctx.getTargetInfo().hasLongDoubleType())) { +// Retain the location of the first use of higher precision type. +if (!S.LocationOfExcessPrecisionNotSatisfied.isValid()) + S.LocationOfExcessPrecisionNotSatisfied = OpLoc; +for (auto &[Type, Num] : S.ExcessPrecisionNotSatisfied) { + if (Type == HigherElementType) { +Num++; +return; + } +} +S.ExcessPrecisionNotSatisfied.push_back(std::make_pair( +HigherElementType, S.ExcessPrecisionNotSatisfied.size())); + } +} + static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc) { const auto *LUE = dyn_cast(LHS); @@ -10685,6 +10724,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, if (compType.isNull() || !compType->isArithmeticType()) return InvalidOperands(Loc, LHS, RHS); if (IsDiv) { +DetectPrecisionLossInComplexDivision(*this, RHS.get()->getType(), Loc); DiagnoseBadDivideOrRemainderValues(*this, LHS, RHS, Loc, IsDiv); DiagnoseDivisionSizeofPointerOrArray(*this, LHS.get(), RHS.get(), Loc); } @@ -15336,39 +15376,6 @@ static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, DiagnoseShiftCompare(Self, OpLoc, LHSExpr, RHSExpr); } -static void DetectPrecisionLossInComplexDivision(Sema &S, SourceLocation OpLoc, - Expr *Operand) { - if (auto *CT = Operand->getType()->getAs()) { -QualType ElementType = CT->getElementType(); -bool IsComplexRangePromoted = S.getLangOpts().getComplexRange() == -
[clang] [alpha.webkit.RetainPtrCtorAdoptChecker] An assortment of small enhancements (PR #135329)
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 HEAD~1 HEAD --extensions cpp,h -- clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp clang/test/Analysis/Checkers/WebKit/objc-mock-types.h `` View the diff from clang-format here. ``diff diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp index 348dc9752..264b7928a 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp @@ -125,11 +125,11 @@ public: return isAdoptFnName(safeGetName(FnDecl)); } - bool isAdoptFnName(const std::string& Name) const { + bool isAdoptFnName(const std::string &Name) const { return isAdoptNS(Name) || Name == "adoptCF" || Name == "adoptCFArc"; } - bool isAdoptNS(const std::string& Name) const { + bool isAdoptNS(const std::string &Name) const { return Name == "adoptNS" || Name == "adoptNSArc"; } @@ -165,7 +165,7 @@ public: checkCreateOrCopyFunction(CE, DeclWithIssue); } - void checkAdoptCall(const CallExpr *CE, const std::string& FnName, + void checkAdoptCall(const CallExpr *CE, const std::string &FnName, const Decl *DeclWithIssue) const { if (!CE->getNumArgs()) return; @@ -259,20 +259,21 @@ public: if (ParamDecl->hasAttr()) CreateOrCopyOutArguments.insert(Decl); } else { -// No callee or a variadic argument. Conservatively assume it's an out argument. +// No callee or a variadic argument. Conservatively assume it's an out +// argument. if (RTC.isUnretained(Decl->getType())) CreateOrCopyOutArguments.insert(Decl); } } auto Summary = Summaries->getSummary(AnyCall(CE)); switch (Summary->getRetEffect().getKind()) { - case RetEffect::OwnedSymbol: - case RetEffect::OwnedWhenTrackedReceiver: -if (!CreateOrCopyFnCall.contains(CE)) - reportLeak(CE, DeclWithIssue); -break; - default: -break; +case RetEffect::OwnedSymbol: +case RetEffect::OwnedWhenTrackedReceiver: + if (!CreateOrCopyFnCall.contains(CE)) +reportLeak(CE, DeclWithIssue); + break; +default: + break; } } @@ -340,7 +341,7 @@ public: else if (isCreateOrCopy(Arg)) reportLeak(Name, CE, DeclWithIssue); } - + void visitVarDecl(const VarDecl *VD) const { auto *Init = VD->getInit(); if (!Init || !RTC.isARCEnabled()) @@ -446,7 +447,7 @@ public: auto *Receiver = ObjCMsgExpr->getInstanceReceiver()->IgnoreParenCasts(); if (!Receiver) return false; - if (auto *Inner = dyn_cast(Receiver)) { +if (auto *Inner = dyn_cast(Receiver)) { if (InnerExpr) *InnerExpr = Inner; auto InnerSelector = Inner->getSelector(); `` https://github.com/llvm/llvm-project/pull/135329 ___ 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)
vgvassilev wrote: > > Here's a new reproducer, this time verifying that a semi-fresh > > tip-of-the-tree doesn't trigger the same error: > > https://pastebin.com/7tYfjazz. Apologies for the delay. > > Thanks. I gave it a try, but I don't see any `use of overloaded operator '=' > is ambiguous` error. In fact, there isn't a `operator =` in the sources at > all. What am I missing? 🤔 Creduce-like tools are very bad at finding reject valid codes. @emaxx-google, can you paste your interestingness test? 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] [clang][ReleaseNotes] Fix code block not rendering (PR #135330)
Maetveis wrote: Before (https://clang.llvm.org/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics):  With this PR:  https://github.com/llvm/llvm-project/pull/135330 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ReleaseNotes] Fix code block not rendering (PR #135330)
https://github.com/Maetveis ready_for_review https://github.com/llvm/llvm-project/pull/135330 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ReleaseNotes] Fix code block not rendering (PR #135330)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Mészáros Gergely (Maetveis) Changes Bullet lists require a blank line between paragraphs therefore the `.. code-block::` directive only renders correctly if preceded by a blank line. --- Full diff: https://github.com/llvm/llvm-project/pull/135330.diff 1 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 46d2debec3621..69c7369755c67 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -334,6 +334,7 @@ Improvements to Clang's diagnostics - Fixed an assertion when referencing an out-of-bounds parameter via a function attribute whose argument list refers to parameters by index and the function is variadic. e.g., + .. code-block:: c __attribute__ ((__format_arg__(2))) void test (int i, ...) { } `` https://github.com/llvm/llvm-project/pull/135330 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [alpha.webkit.RetainPtrCtorAdoptChecker] An assortment of small enhancements (PR #135329)
https://github.com/rniwa updated https://github.com/llvm/llvm-project/pull/135329 >From ffeb0f6f3252579fe77460ba05b57f7b68189bab Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Fri, 11 Apr 2025 01:15:55 -0700 Subject: [PATCH 1/2] [alpha.webkit.RetainPtrCtorAdoptChecker] An assortment of small enhancements This PR implements various small enhancements to alpha.webkit.RetainPtrCtorAdoptChecker: - Detect leaks from [[X alloc] init] when ARC is disabled. - Detect leaks from calling Create, Copy, and other +1 CF functions. - Recognize [allocX() init] pattern where allocX is a C/C++ function. - Recognize _init in addition to init as an init function. - Recognize [[[X alloc] init] autorelease]. - Recognize CFBridgingRelease. - Support CF_RETRUNS_RETAINED on out arguments of a C function. - Support returning +1 object in Create, Copy, and other +1 functions or +1 selectors. - Support variadic Create, Copy, and other +1 C/C++ functions. To make these enhancements, this PR introduces new visit functions for ObjCMessageExpr, ReturnStmt, VarDecl, and BinaryOperator. These functions look for a specific construct mentioned above and adds an expression such as [[X alloc] init] or CreateX to a DenseSet CreateOrCopyFnCall when the expression does not result in leaks. When the code to detect leaks such as the one in visitObjCMessageExpr later encounters this expression, it can bail out early if the expression is in the set. --- .../WebKit/RetainPtrCtorAdoptChecker.cpp | 275 -- .../Checkers/WebKit/objc-mock-types.h | 10 +- .../WebKit/retain-ptr-ctor-adopt-use-arc.mm | 195 - .../WebKit/retain-ptr-ctor-adopt-use.mm | 204 - 4 files changed, 648 insertions(+), 36 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp index d372c5d1ba626..348dc9752f8dc 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp @@ -12,6 +12,7 @@ #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/StmtVisitor.h" +#include "clang/Analysis/DomainSpecific/CocoaConventions.h" #include "clang/Analysis/RetainSummaryManager.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" @@ -90,6 +91,26 @@ class RetainPtrCtorAdoptChecker Checker->visitConstructExpr(CE, DeclWithIssue); return true; } + + bool VisitObjCMessageExpr(const ObjCMessageExpr *ObjCMsgExpr) { +Checker->visitObjCMessageExpr(ObjCMsgExpr, DeclWithIssue); +return true; + } + + bool VisitReturnStmt(const ReturnStmt *RS) { +Checker->visitReturnStmt(RS, DeclWithIssue); +return true; + } + + bool VisitVarDecl(const VarDecl *VD) { +Checker->visitVarDecl(VD); +return true; + } + + bool VisitBinaryOperator(const BinaryOperator *BO) { +Checker->visitBinaryOperator(BO); +return true; + } }; LocalVisitor visitor(this); @@ -101,13 +122,14 @@ class RetainPtrCtorAdoptChecker } bool isAdoptFn(const Decl *FnDecl) const { -auto Name = safeGetName(FnDecl); -return Name == "adoptNS" || Name == "adoptCF" || Name == "adoptNSArc" || - Name == "adoptCFArc"; +return isAdoptFnName(safeGetName(FnDecl)); } - bool isAdoptNS(const Decl *FnDecl) const { -auto Name = safeGetName(FnDecl); + bool isAdoptFnName(const std::string& Name) const { +return isAdoptNS(Name) || Name == "adoptCF" || Name == "adoptCFArc"; + } + + bool isAdoptNS(const std::string& Name) const { return Name == "adoptNS" || Name == "adoptNSArc"; } @@ -116,44 +138,104 @@ class RetainPtrCtorAdoptChecker if (BR->getSourceManager().isInSystemHeader(CE->getExprLoc())) return; -auto *F = CE->getDirectCallee(); -if (!F) +std::string FnName; +if (auto *F = CE->getDirectCallee()) { + FnName = safeGetName(F); + if (isAdoptFnName(FnName)) +checkAdoptCall(CE, FnName, DeclWithIssue); + else { +checkCreateOrCopyFunction(CE, DeclWithIssue); +checkBridgingRelease(CE, F, DeclWithIssue); + } return; +} -if (!isAdoptFn(F) || !CE->getNumArgs()) { - checkCreateOrCopyFunction(CE, F, DeclWithIssue); +auto *CalleeExpr = CE->getCallee(); +if (!CalleeExpr) return; +CalleeExpr = CalleeExpr->IgnoreParenCasts(); +if (auto *UnresolvedExpr = dyn_cast(CalleeExpr)) { + auto Name = UnresolvedExpr->getName(); + if (!Name.isIdentifier()) +return; + FnName = Name.getAsString(); + if (isAdoptFnName(FnName)) +checkAdoptCall(CE, FnName, DeclWithIssue); } +checkCreateOrCopyFunction(CE, DeclWithIssue); +
[clang] [clang][ReleaseNotes] Fix code block not rendering (PR #135330)
https://github.com/Maetveis created https://github.com/llvm/llvm-project/pull/135330 Bullet lists require a blank line between paragraphs therefore the `.. code-block::` directive only renders correctly if preceded by a blank line. From d5f1688b4675442804ae6c8610b8d2e9b60e33db Mon Sep 17 00:00:00 2001 From: Gergely Meszaros Date: Fri, 11 Apr 2025 01:34:11 -0700 Subject: [PATCH] [clang][ReleaseNotes] Fix code block not rendering Bullet lists require a blank line between paragraphs therefore the `.. code-block::` directive only renders correctly if preceded by a blank line. --- clang/docs/ReleaseNotes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 46d2debec3621..69c7369755c67 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -334,6 +334,7 @@ Improvements to Clang's diagnostics - Fixed an assertion when referencing an out-of-bounds parameter via a function attribute whose argument list refers to parameters by index and the function is variadic. e.g., + .. code-block:: c __attribute__ ((__format_arg__(2))) void test (int i, ...) { } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)
@@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s + +int __attribute__((not_tail_called)) foo1(int a) { +return a + 1; +} + + +int foo2(int a) { +[[clang::musttail]] +return foo1(a); // expected-error{{cannot perform a tail call to function'musttail' because its signature is incompatible with the calling function}} MillePlateaux wrote: > This diagnostic seems odd to me because of `function'musttail'` Is there > really no whitespace there? @AaronBallman Since we reuse ``err_musttail_mismatch``, and the function itself does not have spaces, I tried to add spaces , but the test case did not pass.I've pasted the code below. ```cpp def err_musttail_mismatch : Error< "cannot perform a tail call to function%select{| %1}0 " "because its signature is incompatible with the calling function">; https://github.com/llvm/llvm-project/pull/134465 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Misc TypeidPointer fixes (PR #135322)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while building `clang` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/8116 Here is the relevant piece of the build log for the reference ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... [ OK ] AddressSanitizer.AtoiAndFriendsOOBTest (2290 ms) [ RUN ] AddressSanitizer.HasFeatureAddressSanitizerTest [ OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms) [ RUN ] AddressSanitizer.CallocReturnsZeroMem [ OK ] AddressSanitizer.CallocReturnsZeroMem (13 ms) [ DISABLED ] AddressSanitizer.DISABLED_TSDTest [ RUN ] AddressSanitizer.IgnoreTest [ OK ] AddressSanitizer.IgnoreTest (0 ms) [ RUN ] AddressSanitizer.SignalTest [ OK ] AddressSanitizer.SignalTest (207 ms) [ RUN ] AddressSanitizer.ReallocTest [ OK ] AddressSanitizer.ReallocTest (51 ms) [ RUN ] AddressSanitizer.WrongFreeTest [ OK ] AddressSanitizer.WrongFreeTest (131 ms) [ RUN ] AddressSanitizer.LongJmpTest [ OK ] AddressSanitizer.LongJmpTest (0 ms) [ RUN ] AddressSanitizer.ThreadStackReuseTest [ OK ] AddressSanitizer.ThreadStackReuseTest (8 ms) [ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest [ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest [ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest [ RUN ] AddressSanitizer.UseThenFreeThenUseTest [ OK ] AddressSanitizer.UseThenFreeThenUseTest (125 ms) [ RUN ] AddressSanitizer.FileNameInGlobalReportTest [ OK ] AddressSanitizer.FileNameInGlobalReportTest (151 ms) [ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest [ RUN ] AddressSanitizer.MlockTest [ OK ] AddressSanitizer.MlockTest (0 ms) [ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest [ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest [ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest [ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn [ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft [ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight [ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh [ DISABLED ] AddressSanitizer.DISABLED_DemoOOM [ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest [ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest [ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest [ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest [ RUN ] AddressSanitizer.LongDoubleNegativeTest [ OK ] AddressSanitizer.LongDoubleNegativeTest (0 ms) [--] 19 tests from AddressSanitizer (28064 ms total) [--] Global test environment tear-down [==] 22 tests from 2 test suites ran. (28079 ms total) [ PASSED ] 22 tests. YOU HAVE 1 DISABLED TEST Step 34 (run instrumented asan tests [aarch64/bluejay-userdebug/TQ3A.230805.001]) failure: run instrumented asan tests [aarch64/bluejay-userdebug/TQ3A.230805.001] (failure) ... [ RUN ] AddressSanitizer.HasFeatureAddressSanitizerTest [ OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms) [ RUN ] AddressSanitizer.CallocReturnsZeroMem [ OK ] AddressSanitizer.CallocReturnsZeroMem (13 ms) [ DISABLED ] AddressSanitizer.DISABLED_TSDTest [ RUN ] AddressSanitizer.IgnoreTest [ OK ] AddressSanitizer.IgnoreTest (0 ms) [ RUN ] AddressSanitizer.SignalTest [ OK ] AddressSanitizer.SignalTest (207 ms) [ RUN ] AddressSanitizer.ReallocTest [ OK ] AddressSanitizer.ReallocTest (51 ms) [ RUN ] AddressSanitizer.WrongFreeTest [ OK ] AddressSanitizer.WrongFreeTest (131 ms) [ RUN ] AddressSanitizer.LongJmpTest [ OK ] AddressSanitizer.LongJmpTest (0 ms) [ RUN ] AddressSanitizer.ThreadStackReuseTest [ OK ] AddressSanitizer.ThreadStackReuseTest (8 ms) [ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest [ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest [ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest [ RUN ] AddressSanitizer.UseThenFreeThenUseTest [ OK ] AddressSanitizer.UseThenFreeThenUseTest (125 ms) [ RUN ] AddressSanitizer.FileNameInGlobalReportTest [ OK ] AddressSanitizer.FileNameInGlobalReportTest (151 ms) [ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest [ RUN ] AddressSanitizer.MlockTest [ OK ] AddressSanitizer.MlockTest (0 ms) [ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest [ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest [ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest [ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn [ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft [ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight [ DISABLED ] Ad
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -0,0 +1,112 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +#ifdef SME_OVERLOADED_FORMS +#define SME_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3 +#else +#define SME_ACLE_FUNC(A1,A2,A3) A1##A2##A3 +#endif + +// CHECK-LABEL: @test_svtmopa_lane_za32_s8_s8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.stmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_s8_s8(svint8x2_t zn, svint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_s8_s8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_u8_u8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.utmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_u8_u8(svuint8x2_t zn, svuint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_u8_u8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_s8_u8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.sutmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_s8_u8(svint8x2_t zn, svuint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_s8_u8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_u8_s8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.ustmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_u8_s8(svuint8x2_t zn, svint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_u8_s8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_s16_s16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.stmopa.nxv8i16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_s16_s16(svint16x2_t zn, svint16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_s16_s16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_u16_u16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.utmopa.nxv8i16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_u16_u16(svuint16x2_t zn, svuint16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_u16_u16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_f16_f16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.tmopa.nxv8f16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_f16_f16(svfloat16x2_t zn, svfloat16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_f16_f16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_bf16_bf16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.tmopa.nxv8bf16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_bf16_bf16(svbfloat16x2_t zn, svbfloat16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_bf16_bf16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za16_f16_f16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.
[clang] [clang][CodeGen] Fix metadata when vectorization is disabled by pragma (PR #135163)
https://github.com/kasuga-fj updated https://github.com/llvm/llvm-project/pull/135163 >From 79186af3df57357d40ec3b3e4eaf9da978b31ef6 Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga Date: Fri, 4 Apr 2025 12:32:57 + Subject: [PATCH 1/4] [clang][CodeGen] Fix metadata when vectorization is disabled by pragma There are two ways to disable vectorization with pragma, `vectorize(disable)` and `vectorize_width(1)`. The document (https://clang.llvm.org/docs/LanguageExtensions.html#vectorization-interleaving-and-predication) states: > Specifying a width/count of 1 disables the optimization, and is equivalent to `vectorize(disable)` or `interleave(disable)`. So the behavior should be the same when using either is used. However, the current implementation doesn't satisfy this. When `vectorize(disable)` is specified, it is converted internally to the same as `vectorize_width(1)`, and the metadata is generated as if vectorization is not explicitly specified as enabled or disabled. This can cause a problem when other transformations are also specified by pragma. For example, if `unroll_count(8)` is specified, the loop should have a metadata that contains the information directly, like: ``` !loop0 = !{!"loop0", !vectorize_disable, !unroll} !vectorize_disable = {...} !unroll = !{!"llvm.loop.unroll_count", i32 8} ``` But now it's attached into followup metadata for vectorization. ``` !loop0 = !{!"loop0", !vectorize_width, !followup} !vectorize_width = !{!"llvm.loop.vectorize.width", i32 1} !followup = !{!"llvm.loop.vectorize.followup_all", !unroll} !unroll = !{!"llvm.loop.unroll_count", i32 8} ``` As a result, the unroll attributes are ignored because the vectorization is not applied. This patch fixes this issue by generating metadata that disables vectorization when `vectorize(disable)` or `vectorize_width(1)` are specified. The document also says: > If the transformation is disabled (e.g. vectorize(disable)), that takes precedence over transformations option pragmas implying that transformation. Therefore, if vectorization is disabled, all other vectorize options like `vectorize_predicate` should be ignored. This patch also omits to generate attributes for vectorization when it is disabled. Fix #75839 --- clang/lib/CodeGen/CGLoopInfo.cpp | 7 ++--- clang/test/CodeGenCXX/pragma-loop-pr27643.cpp | 12 .../test/CodeGenCXX/pragma-loop-predicate.cpp | 22 +++--- clang/test/CodeGenCXX/pragma-loop-safety.cpp | 4 +-- clang/test/CodeGenCXX/pragma-loop.cpp | 29 --- 5 files changed, 47 insertions(+), 27 deletions(-) diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 2b7d7881ab990..e9d622d78bf6d 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -200,7 +200,8 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs, LLVMContext &Ctx = Header->getContext(); std::optional Enabled; - if (Attrs.VectorizeEnable == LoopAttributes::Disable) + if (Attrs.VectorizeEnable == LoopAttributes::Disable || + Attrs.VectorizeWidth == 1) Enabled = false; else if (Attrs.VectorizeEnable != LoopAttributes::Unspecified || Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified || @@ -643,9 +644,7 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx, case LoopHintAttr::Disable: switch (Option) { case LoopHintAttr::Vectorize: -// Disable vectorization by specifying a width of 1. -setVectorizeWidth(1); -setVectorizeScalable(LoopAttributes::Unspecified); +setVectorizeEnable(false); break; case LoopHintAttr::Interleave: // Disable interleaving by speciyfing a count of 1. diff --git a/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp b/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp index 37e29776264b6..b4614c4d39be4 100644 --- a/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp @@ -40,14 +40,14 @@ void loop4(int *List, int Length) { List[i] = i * 2; } -// CHECK: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP:![0-9]+]], ![[VEC_WIDTH_1:.*]], ![[FIXED_WIDTH:.*]], ![[VEC_ENABLE:.*]]} -// CHECK: ![[VEC_WIDTH_1]] = !{!"llvm.loop.vectorize.width", i32 1} -// CHECK: ![[FIXED_WIDTH]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} -// CHECK: ![[VEC_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true} +// CHECK: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP:![0-9]+]], ![[VEC_DISABLE:[0-9]+]]} +// CHECK: ![[VEC_DISABLE]] = !{!"llvm.loop.vectorize.enable", i1 false} -// CHECK: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], ![[VEC_WIDTH_2:.*]], ![[FIXED_WIDTH:.*]], ![[VEC_ENABLE]]} +// CHECK: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], ![[VEC_WIDTH_2:.*]], ![[FIXED_WIDTH:[0-9]+]], ![[VEC_ENABLE:[0-9]+]]} // CHECK: ![[VEC_WIDTH_2]] = !{!"llvm.loop.vectorize.width", i32 2} +// CHECK: ![[FIXED_WIDTH]] = !{!"llvm.loop.vectorize.scal
[clang] [clang][CodeGen] Fix metadata when vectorization is disabled by pragma (PR #135163)
@@ -194,7 +194,7 @@ void for_test_scalable(int *List, int Length) { } } -// Verify for loop is performing scalable vectorization +// Verify for loop is NOT performing vectorization because the width is 1 kasuga-fj wrote: Fixed both code and docs. Thanks. https://github.com/llvm/llvm-project/pull/135163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Fix metadata when vectorization is disabled by pragma (PR #135163)
https://github.com/kasuga-fj edited https://github.com/llvm/llvm-project/pull/135163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -907,6 +907,48 @@ let SMETargetGuard = "sme-f16f16" in { } + +// SME2 - TMOP, SUTMOP, USTMOP + +multiclass USTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2x[i", t, MergeNone, "aarch64_sme_ustmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +multiclass SUTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2u[i", t, MergeNone, "aarch64_sme_sutmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +let SMETargetGuard = "sme2,sme-tmop" in { + def SVTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "hbf", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVSTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "cs", MergeNone, "aarch64_sme_stmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVUTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "UcUs", MergeNone, "aarch64_sme_utmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + + defm SVSUTMOPA_S : SUTMOP<"za32", "c", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + defm SVUSTMOPA_S : USTMOP<"za32", "Uc", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-f16f16" in { + def SVTMOPA_F16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "hb", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; jthackray wrote: Thanks, updated. https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -0,0 +1,112 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s + +#include + +#ifdef SME_OVERLOADED_FORMS +#define SME_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3 +#else +#define SME_ACLE_FUNC(A1,A2,A3) A1##A2##A3 +#endif + +// CHECK-LABEL: @test_svtmopa_lane_za32_s8_s8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.stmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_s8_s8(svint8x2_t zn, svint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_s8_s8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_u8_u8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.utmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_u8_u8(svuint8x2_t zn, svuint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_u8_u8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_s8_u8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.sutmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_s8_u8(svint8x2_t zn, svuint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_s8_u8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_u8_s8( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.ustmopa.nxv16i8(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_u8_s8(svuint8x2_t zn, svint8_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_u8_s8,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_s16_s16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.stmopa.nxv8i16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_s16_s16(svint16x2_t zn, svint16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_s16_s16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_u16_u16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.utmopa.nxv8i16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_u16_u16(svuint16x2_t zn, svuint16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_u16_u16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_f16_f16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.tmopa.nxv8f16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_f16_f16(svfloat16x2_t zn, svfloat16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_f16_f16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za32_bf16_bf16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.aarch64.sme.tmopa.nxv8bf16(i32 1, [[ZN_COERCE0:%.*]], [[ZN_COERCE1:%.*]], [[ZM:%.*]], [[ZK:%.*]], i32 3) +// CHECK-NEXT:ret void +// +void test_svtmopa_lane_za32_bf16_bf16(svbfloat16x2_t zn, svbfloat16_t zm, svuint8_t zk) __arm_streaming __arm_inout("za") { + SME_ACLE_FUNC(svtmopa_lane_za32,_bf16_bf16,)(1, zn, zm, zk, 3); +} + +// CHECK-LABEL: @test_svtmopa_lane_za16_f16_f16( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.
[clang] 9eeafc6 - Implement `-dump-minimization-hints` flag. (#133910)
Author: Viktoriia Bakalova Date: 2025-04-11T12:48:18+02:00 New Revision: 9eeafc63d2f06f7aa216ddcf2370b20fbb1d9015 URL: https://github.com/llvm/llvm-project/commit/9eeafc63d2f06f7aa216ddcf2370b20fbb1d9015 DIFF: https://github.com/llvm/llvm-project/commit/9eeafc63d2f06f7aa216ddcf2370b20fbb1d9015.diff LOG: Implement `-dump-minimization-hints` flag. (#133910) This PR implements a CC1 flag `-dump-minimization-hints`. The flag allows to specify a file path to dump ranges of deserialized declarations in `ASTReader`. Example usage: ``` clang -Xclang=-dump-minimization-hints=/tmp/decls -c file.cc -o file.o ``` Example output: ``` // /tmp/decls { "required_ranges": [ { "file": "foo.h", "range": [ { "from": { "line": 26, "column": 1 }, "to": { "line": 27, "column": 77 } } ] }, { "file": "bar.h", "range": [ { "from": { "line": 30, "column": 1 }, "to": { "line": 35, "column": 1 } }, { "from": { "line": 92, "column": 1 }, "to": { "line": 95, "column": 1 } } ] } ] } ``` Specifying the flag creates an instance of `DeserializedDeclsSourceRangePrinter`, which dumps ranges of deserialized declarations to aid debugging and bug minimization (we use is as input to [C-Vise](https://github.com/emaxx-google/cvise/tree/multifile-hints). Required ranges are computed from source ranges of Decls. `TranslationUnitDecl`, `LinkageSpecDecl` and `NamespaceDecl` are ignored for the sake of this PR. Technical details: * `DeserializedDeclsSourceRangePrinter` implements `ASTConsumer` and `ASTDeserializationListener`, so that an object of `DeserializedDeclsSourceRangePrinter` registers as its own listener. * `ASTDeserializationListener` interface provides the `DeclRead` callback that we use to collect the deserialized Decls. Printing or otherwise processing them as this point is dangerous, since that could trigger additional deserialization and crash compilation. * The collected Decls are processed in `HandleTranslationUnit` method of `ASTConsumer`. This is a safe point, since we know that by this point all the Decls needed by the compiler frontend have been deserialized. * In case our processing causes further deserialization, `DeclRead` from the listener might be called again. However, at that point we don't accept any more Decls for processing. Added: clang/test/Frontend/dump-minimization-hints.cpp Modified: clang/include/clang/Driver/Options.td clang/include/clang/Frontend/FrontendOptions.h clang/lib/Frontend/FrontendAction.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 2242269c30b0f..49c2ff4cb91ce 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8045,6 +8045,10 @@ def print_dependency_directives_minimized_source : Flag<["-"], "print-dependency-directives-minimized-source">, HelpText<"Print the output of the dependency directives source minimizer">; } +def dump_minimization_hints : Joined<["-"], + "dump-minimization-hints=">, + HelpText<"Dump ranges of deserialized declarations to use as bug minimization hints">, + MarshallingInfoString>; defm emit_llvm_uselists : BoolOption<"", "emit-llvm-uselists", CodeGenOpts<"EmitLLVMUseLists">, DefaultFalse, diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index a9c9849ff52ab..c919a53ae089e 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -530,6 +530,10 @@ class FrontendOptions { /// Output Path for module output file. std::string ModuleOutputPath; + /// Output path to dump ranges of deserialized declarations to use as + /// minimization hints. + std::string DumpMinimizationHintsPath; + public: FrontendOptions() : DisableFree(false), RelocatablePCH(false), ShowHelp(false), diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 2d77f06be7446..bd084aa94fc37 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -13,9 +13,13 @@ #include "clang/Basic/Builtins.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileEntry.h" +#include "clang/Basic/LangOptions.h" #include "clang/Basic/LangStandard.h" #include "clang/Basic/Sarif.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/SourceManager.h" #include "clang/Basic/Stack.h" +#include "clang/Basic/TokenKinds.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/C
[clang] Implement `-dump-minimization-hints` flag. (PR #133910)
https://github.com/VitaNuo closed https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
https://github.com/jryans approved this pull request. New docs look good, thanks for working on this! Yes, the value is quite clear indeed. :smile: https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
jryans wrote: IIRC, there are still some open review threads in this PR, mainly related to reducing duplication in the symbolication bits. https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -0,0 +1,176 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -target-feature +bf16 -target-feature +sme-f16f16 -target-feature +sme-b16b16 -verify -emit-llvm -o - %s + +// REQUIRES: aarch64-registered-target + +#include + +void test_features() __arm_streaming __arm_inout("za") { +svuint8x2_t zn_u8; +svint8x2_t zn_s8; +svuint8_t zm_u8; +svint8_t zm_s8; +svuint16x2_t zn_u16; +svint16x2_t zn_s16; +svuint16_t zm_u16; +svint16_t zm_s16; +svbfloat16x2_t zn_bf16; +svfloat16x2_t zn_f16; +svbfloat16_t zm_bf16; +svfloat16_t zm_f16; +svfloat32x2_t zn_f32; +svfloat32_t zm_f32; +fpm_t fpm = 0; +svuint8_t zk; + +// expected-error@+1 {{'svtmopa_lane_za32_s8_s8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_s8_s8(0, zn_s8, zm_s8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_u8_u8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_u8_u8(0, zn_u8, zm_u8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_s8_u8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_s8_u8(0, zn_s8, zm_u8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_u8_s8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_u8_s8(0, zn_u8, zm_s8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_s16_s16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_s16_s16(0, zn_s16, zm_s16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_u16_u16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_u16_u16(0, zn_u16, zm_u16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_f16_f16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_f16_f16(0, zn_f16, zm_f16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_bf16_bf16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_bf16_bf16(0, zn_bf16, zm_bf16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za16_f16_f16' needs target feature sme,sme2,sme-tmop,sme-f16f16}} +svtmopa_lane_za16_f16_f16(0, zn_f16, zm_f16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za16_bf16_bf16' needs target feature sme,sme2,sme-tmop,sme-f16f16}} +svtmopa_lane_za16_bf16_bf16(0, zn_bf16, zm_bf16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za16_mf8_mf8_fpm' needs target feature sme,sme2,sme-tmop,sme-f8f16}} +svtmopa_lane_za16_mf8_mf8_fpm(0, zn_f32, zm_f32, zk, 0, fpm); +// expected-error@+1 {{'svtmopa_lane_za32_mf8_mf8_fpm' needs target feature sme,sme2,sme-tmop,sme-f8f32}} +svtmopa_lane_za32_mf8_mf8_fpm(0, zn_f32, zm_f32, zk, 0, fpm); +} + +void test_imm() __arm_streaming __arm_inout("za") { +svuint8x2_t zn_u8; +svint8x2_t zn_s8; +svuint8_t zm_u8; +svint8_t zm_s8; +svuint16x2_t zn_u16; +svint16x2_t zn_s16; +svuint16_t zm_u16; +svint16_t zm_s16; +svbfloat16x2_t zn_bf16; +svfloat16x2_t zn_f16; +svbfloat16_t zm_bf16; +svfloat16_t zm_f16; +svfloat32x2_t zn_f32; +svfloat32_t zm_f32; +fpm_t fpm; +svuint8_t zk; + +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_s8(3, zn_s8, zm_s8, zk, 4); +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_s8(4, zn_s8, zm_s8, zk, 3); +// expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_s8(0, zn_s8, zm_s8, zk, -1); +// expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_s8(-1, zn_s8, zm_s8, zk, 0); + +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_u8_u8(3, zn_u8, zm_u8, zk, 4); +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_u8_u8(4, zn_u8, zm_u8, zk, 3); +// expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} +svtmopa_lane_za32_u8_u8(0, zn_u8, zm_u8, zk, -1); +// expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} +svtmopa_lane_za32_u8_u8(-1, zn_u8, zm_u8, zk, 0); + +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_u8(3, zn_s8, zm_u8, zk, 4); +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_u8(4, zn_s8, zm_u8, zk, 3); +// expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_u8(0, zn_s8, zm_u8, zk, -1); +// expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} +svtmopa_lane_za32_s8_u8(-1, zn_s8, zm_u8, zk, 0); + +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_u8_s8(3, zn_u8, zm_s8, zk, 4); +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} +svtmopa_lane_za32_u8_s8(4, zn_u8,
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -3593,6 +3578,25 @@ class sme_tmopa_32b opc, RegisterOperand zn_ty, RegisterOperand zm_ty, s let Constraints = "$ZAda = $_ZAda"; } +multiclass sme_tmopa_16b opc, RegisterOperand zn_ty, RegisterOperand zm_ty, ValueType vt, string mnemonic, string intrinsic> { + def NAME : sme_int_sparse_outer_product_i16, SMEPseudo2Instr { + let Uses = [FPMR, FPCR]; + } + + def NAME # _PSEUDO : sme_sparse_outer_product_pseudo, SMEPseudo2Instr; + + def _ : SME2_ZA_TMOP_Pat(intrinsic), timm32_0_3, vt>; jthackray wrote: Thanks for spotting this, now fixed. https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang][NVPTX] Add builtins and intrinsics for conversions of new FP types (PR #134345)
https://github.com/Wolfram70 edited https://github.com/llvm/llvm-project/pull/134345 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
https://github.com/jthackray updated https://github.com/llvm/llvm-project/pull/135145 >From c0bff6fe1d1630ba93361ac29bca798810a64178 Mon Sep 17 00:00:00 2001 From: Jonathan Thackray Date: Mon, 3 Mar 2025 16:16:46 + Subject: [PATCH 1/3] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) instrinics Implement all {BF/F/S/U/SU/US}TMOP intrinsics in clang and llvm following the ACLE in https://github.com/ARM-software/acle/pull/380/files --- clang/include/clang/Basic/arm_sme.td | 42 + .../AArch64/sme2-intrinsics/acle_sme2_tmop.c | 112 +++ .../acle_sme2_tmop.cpp| 176 ++ llvm/include/llvm/IR/IntrinsicsAArch64.td | 17 ++ .../lib/Target/AArch64/AArch64RegisterInfo.td | 6 +- .../lib/Target/AArch64/AArch64SMEInstrInfo.td | 42 ++--- llvm/lib/Target/AArch64/SMEInstrFormats.td| 66 --- .../AArch64/GlobalISel/regbank-inlineasm.mir | 6 +- .../emit_fneg_with_non_register_operand.mir | 4 +- .../CodeGen/AArch64/peephole-insvigpr.mir | 4 +- .../CodeGen/AArch64/sme2-intrinsics-tmop.ll | 138 ++ 11 files changed, 552 insertions(+), 61 deletions(-) create mode 100644 clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c create mode 100644 clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_tmop.cpp create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-tmop.ll diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index 1bfcf4c31d552..d425c2c1e38bb 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -907,6 +907,48 @@ let SMETargetGuard = "sme-f16f16" in { } + +// SME2 - TMOP, SUTMOP, USTMOP + +multiclass USTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2x[i", t, MergeNone, "aarch64_sme_ustmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +multiclass SUTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2u[i", t, MergeNone, "aarch64_sme_sutmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +let SMETargetGuard = "sme2,sme-tmop" in { + def SVTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "hbf", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVSTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "cs", MergeNone, "aarch64_sme_stmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVUTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "UcUs", MergeNone, "aarch64_sme_utmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + + defm SVSUTMOPA_S : SUTMOP<"za32", "c", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + defm SVUSTMOPA_S : USTMOP<"za32", "Uc", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-f16f16" in { + def SVTMOPA_F16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "hb", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-b16b16" in { + def SVTMOPA_BF16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "U", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-f8f16" in { + def SVTMOPA_ZA16_FPM : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2.MM[i>", "m", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-f8f32" in { + def SVTMOPA_ZA32_FPM : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2.MM[i>", "m", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + multiclass ZAReadz ch> { let SMETargetGuard = "sme2p1" in { def NAME # _H : SInst<"svreadz_hor_" # n_suffix # "_{d}_vg" # vg_num, vg_num # "im", t, diff --git a/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c b/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c new file mode 100644 index 0..a1456275dd810 --- /dev/null +++ b/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c @@ -0,0 +1,112 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | File
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
SLTozer wrote: > IIRC, there are still some open review threads in this PR, mainly related to > reducing duplication in the symbolication bits. Yes, this part won't land quite yet; as I'm kicking these reviews back into action, I'll be pushing up some other reviews to come before this one in the patch stack. The origin-tracking feature here is very useful for actually triaging bugs, but the most important features to land first are enabling coverage-tracking in its entirety, including annotating existing sites in the compiler, so I'll be coming back to this patch after landing the remaining coverage-focused patches. https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C99] Remove the tgmath.h header (PR #135236)
AaronBallman wrote: What I am taking away from this conversation is: 1) We need to keep tgmath.h, so this PR can be closed. 2) We should consider implementing `__builtin_tgmath`, 3) We should consider bumping the `__GNUC__` version we report. I think all of those are sensible, though (2) seems more straightforward than (3). https://github.com/llvm/llvm-project/pull/135236 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C99] Remove the tgmath.h header (PR #135236)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/135236 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)
@@ -0,0 +1,142 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s + +#define AQ __ptrauth(1,1,50) +#define AQ2 __ptrauth(1,1,51) +#define IQ __ptrauth(1,0,50) + +struct __attribute__((trivial_abi)) AddrDisc { // expected-warning {{'trivial_abi' cannot be applied to 'AddrDisc'}} expected-note {{'trivial_abi' is disallowed on 'AddrDisc' because it has an address-discriminated '__ptrauth' field}} + int * AQ m0; +}; + +struct __attribute__((trivial_abi)) NoAddrDisc { + int * IQ m0; +}; + +namespace test_union { + + union U0 { +int * AQ f0; // expected-note 4 {{'U0' is implicitly deleted because variant field 'f0' has an address-discriminated '__ptrauth' qualifier}} + +// ptrauth fields that don't have an address-discriminated qualifier don't +// delete the special functions. +int * IQ f1; + }; + + union U1 { +int * AQ f0; // expected-note 8 {{'U1' is implicitly deleted because variant field 'f0' has an address-discriminated '__ptrauth' qualifier}} +U1() = default; +~U1() = default; +U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}} expected-note{{replace 'default'}} +U1(U1 &&) = default; // expected-warning {{explicitly defaulted move constructor is implicitly deleted}} expected-note{{replace 'default'}} +U1 & operator=(const U1 &) = default; // expected-warning {{explicitly defaulted copy assignment operator is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}} expected-note{{replace 'default'}} +U1 & operator=(U1 &&) = default; // expected-warning {{explicitly defaulted move assignment operator is implicitly deleted}} expected-note{{replace 'default'}} + }; + + // It's fine if the user has explicitly defined the special functions. + union U2 { +int * AQ f0; +U2() = default; +~U2() = default; +U2(const U2 &); +U2(U2 &&); +U2 & operator=(const U2 &); +U2 & operator=(U2 &&); + }; + + // Address-discriminated ptrauth fields in anonymous union fields delete the + // defaulted copy/move constructors/assignment operators of the containing + // class. + struct S0 { +union { + int * AQ f0; // expected-note 4 {{' is implicitly deleted because variant field 'f0' has an address-discriminated '__ptrauth' qualifier}} + char f1; +}; + }; + + struct S1 { +union { + union { +int * AQ f0; // expected-note 4 {{implicitly deleted because variant field 'f0' has an address-discriminated '__ptrauth' qualifier}} +char f1; + } u; // expected-note 4 {{'S1' is implicitly deleted because field 'u' has a deleted}} + int f2; +}; + }; + + U0 *x0; + U1 *x1; + U2 *x2; + S0 *x3; + S1 *x4; + + // No diagnostics since constructors/destructors of the unions aren't deleted by default. + void testDefaultConstructor() { +U0 u0; +U1 u1; +U2 u2; +S0 s0; +S1 s1; + } + + // No diagnostics since destructors of the unions aren't deleted by default. + void testDestructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) { +delete u0; +delete u1; +delete u2; +delete s0; +delete s1; + } + + void testCopyConstructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) { +U0 t0(*u0); // expected-error {{call to implicitly-deleted copy constructor}} +U1 t1(*u1); // expected-error {{call to implicitly-deleted copy constructor}} +U2 t2(*u2); +S0 t3(*s0); // expected-error {{call to implicitly-deleted copy constructor}} +S1 t4(*s1); // expected-error {{call to implicitly-deleted copy constructor}} + } + + void testCopyAssignment(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) { +*x0 = *u0; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +*x1 = *u1; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +*x2 = *u2; +*x3 = *s0; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +*x4 = *s1; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} + } + + void testMoveConstructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) { +U0 t0(static_cast(*u0)); // expected-error {{call to implicitly-deleted copy constructor}} +U1 t1(static_cast(*u1)); // expected-error {{call to implicitly-deleted copy constructor}} +U2 t2(static_cast(*u2)); +S0 t3(static_cast(*s0)); // expected-error {{call to implicitly-deleted copy constructor}} +S1 t4(static_cast(*s1)); // expected-error {{call to implicitly-deleted copy constructor}} + } + + void testMoveAssignme
[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)
@@ -2850,6 +2850,26 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals, const DependentAddressSp if (Quals.hasUnaligned()) mangleVendorQualifier("__unaligned"); + // __ptrauth. Note that this is parameterized. + if (PointerAuthQualifier PtrAuth = Quals.getPointerAuth()) { AaronBallman wrote: Oops, I missed the question that was here, but this does still need to be addressed. We don't need MS to be involved, we can pick our own mangling and try to avoid potential conflicts by making it ugly (we do this for plenty of other extensions). But we're missing test coverage because we have no C++ tests for mangling or demangling (Microsoft or Itanium). I think we're missing the demangling implementation entirely, but we lately have been trying to get folks to do them at the same time so the demangler stays closer in sync with the mangler. (Test coverage would be: CodeGen tests with an Itanium and a Microsoft ABI making sure we emit the expected manglings in C++ with a FileCheck test + `llvm/test/Demangle` tests to make sure the generated manglings will demangle back to an expected signature.) https://github.com/llvm/llvm-project/pull/100830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c58777c - [clang][ReleaseNotes] Fix code block not rendering (#135330)
Author: Mészáros Gergely Date: 2025-04-11T13:53:33+02:00 New Revision: c58777c2ad3464cfddc62e1da13dae443e868f3e URL: https://github.com/llvm/llvm-project/commit/c58777c2ad3464cfddc62e1da13dae443e868f3e DIFF: https://github.com/llvm/llvm-project/commit/c58777c2ad3464cfddc62e1da13dae443e868f3e.diff LOG: [clang][ReleaseNotes] Fix code block not rendering (#135330) Bullet lists require a blank line between paragraphs therefore the `.. code-block::` directive only renders correctly if preceded by a blank line. Added: Modified: clang/docs/ReleaseNotes.rst Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 46d2debec3621..69c7369755c67 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -334,6 +334,7 @@ Improvements to Clang's diagnostics - Fixed an assertion when referencing an out-of-bounds parameter via a function attribute whose argument list refers to parameters by index and the function is variadic. e.g., + .. code-block:: c __attribute__ ((__format_arg__(2))) void test (int i, ...) { } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ReleaseNotes] Fix code block not rendering (PR #135330)
https://github.com/Maetveis closed https://github.com/llvm/llvm-project/pull/135330 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen][X86] don't coerce int128 into `{i64,i64}` for SysV-like ABIs (PR #135230)
jmorse wrote: There's precedent for splitting the debug-info into fragments early, we do something similar for C++ structured-bindings in SROA and a very similar process happens when the i128 argument is split up in instruction-selection. Split-up locations become brittle to optimisations though: any source-expression that gets salvaged into a DIExpression can't be decomposed into two fragments, and we have to mark them optimised out. Any salvaging into DIExpression for an i128 will almost certainly fail when the value gets split up in isel. Plus I believe DWARF doesn't support values on the expression stack larger than the machine-address-size, but that's an assumption that can be bent. Presumably the desire here is to improve the variable availability of parameters rather than fully supporting i128's through LLVM debug-info? If so, the least invasive approach may be to teach SROA to decompose into fragments similar to structured-bindings for the first variable location in the function. Or, passing an i128 instead works alright, I have no opinion on ABI matters. (Paging @OCHyams as he worked on structured bindings; and @slinder1 as this is another scenario that might be easier with a typed expression stack) https://github.com/llvm/llvm-project/pull/135230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] Revert "[clang] Improved canonicalization for template specialization types" (PR #135354)
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/135354 Reverts llvm/llvm-project#135119 because of the assert in ASTContext.cpp, line 5619. See #135352 for details. >From 2c7b3620502462008c3150df0522b441fb9527b3 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Fri, 11 Apr 2025 16:12:19 +0400 Subject: [PATCH] =?UTF-8?q?Revert=20"[clang]=20Improved=20canonicalization?= =?UTF-8?q?=20for=20template=20specialization=20types=20(=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3954d258a5d20c418718bb2f655665e02e6a7475. --- clang-tools-extra/clangd/AST.cpp | 3 +- clang/docs/ReleaseNotes.rst | 2 - clang/include/clang/AST/ASTContext.h | 46 ++-- clang/include/clang/AST/PropertiesBase.td | 5 +- clang/include/clang/AST/TemplateBase.h| 13 +- clang/include/clang/AST/Type.h| 7 +- clang/include/clang/AST/TypeProperties.td | 30 ++- clang/lib/AST/ASTContext.cpp | 236 -- clang/lib/AST/ASTDiagnostic.cpp | 8 +- clang/lib/AST/ASTImporter.cpp | 34 +-- clang/lib/AST/DeclTemplate.cpp| 7 +- clang/lib/AST/QualTypeNames.cpp | 3 +- clang/lib/AST/TemplateBase.cpp| 19 +- clang/lib/AST/Type.cpp| 50 ++-- clang/lib/Sema/SemaCXXScopeSpec.cpp | 18 +- clang/lib/Sema/SemaExpr.cpp | 20 +- clang/lib/Sema/SemaLookup.cpp | 3 +- clang/lib/Sema/SemaTemplate.cpp | 162 ++-- clang/lib/Sema/SemaTemplateDeduction.cpp | 45 ++-- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 11 +- clang/lib/Sema/SemaTemplateVariadic.cpp | 3 +- clang/lib/Sema/TreeTransform.h| 13 +- .../class.derived.general/p2.cpp | 2 +- .../temp/temp.decls/temp.class.spec/p6.cpp| 4 +- .../undefined-partial-specialization.cpp | 2 +- clang/test/SemaTemplate/make_integer_seq.cpp | 61 +++-- clang/test/SemaTemplate/type_pack_element.cpp | 57 +++-- clang/unittests/AST/TypePrinterTest.cpp | 6 +- 28 files changed, 422 insertions(+), 448 deletions(-) diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp index 3b991e5e9013f..66b587f00ff4a 100644 --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -439,8 +439,7 @@ QualType declaredType(const TypeDecl *D) { if (const auto *CTSD = llvm::dyn_cast(D)) if (const auto *Args = CTSD->getTemplateArgsAsWritten()) return Context.getTemplateSpecializationType( - TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(), - /*CanonicalArgs=*/std::nullopt); + TemplateName(CTSD->getSpecializedTemplate()), Args->arguments()); return Context.getTypeDeclType(D); } diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 69c7369755c67..db8dad268a8a7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -301,8 +301,6 @@ Improvements to Clang's diagnostics - Clang now better preserves the sugared types of pointers to member. - Clang now better preserves the presence of the template keyword with dependent prefixes. -- Clang now in more cases avoids printing 'type-parameter-X-X' instead of the name of - the template parameter. - Clang now respects the current language mode when printing expressions in diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also a bunch of HLSL types being printed as their C++ equivalents. diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index b8ea2af9215d2..b1e6344576eb5 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -367,6 +367,9 @@ class ASTContext : public RefCountedBase { const ASTContext&> CanonTemplateTemplateParms; + TemplateTemplateParmDecl * +getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; + /// The typedef for the __int128_t type. mutable TypedefDecl *Int128Decl = nullptr; @@ -1808,26 +1811,22 @@ class ASTContext : public RefCountedBase { bool ParameterPack, TemplateTypeParmDecl *ParmDecl = nullptr) const; - QualType getCanonicalTemplateSpecializationType( - TemplateName T, ArrayRef CanonicalArgs) const; + QualType getTemplateSpecializationType(TemplateName T, + ArrayRef Args, + QualType Canon = QualType()) const; QualType - getTemplateSpecializationType(TemplateName T, -ArrayRef SpecifiedArgs, -ArrayRef CanonicalArgs, -QualType Under
[clang] [clang-tools-extra] Revert "[clang] Improved canonicalization for template specialization types" (PR #135354)
llvmbot wrote: @llvm/pr-subscribers-clangd Author: Dmitry Vasilyev (slydiman) Changes Reverts llvm/llvm-project#135119 because of the assert in ASTContext.cpp, line 5619. See #135352 for details. --- Patch is 89.49 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/135354.diff 28 Files Affected: - (modified) clang-tools-extra/clangd/AST.cpp (+1-2) - (modified) clang/docs/ReleaseNotes.rst (-2) - (modified) clang/include/clang/AST/ASTContext.h (+15-31) - (modified) clang/include/clang/AST/PropertiesBase.td (+1-4) - (modified) clang/include/clang/AST/TemplateBase.h (+2-11) - (modified) clang/include/clang/AST/Type.h (+4-3) - (modified) clang/include/clang/AST/TypeProperties.td (+25-5) - (modified) clang/lib/AST/ASTContext.cpp (+107-129) - (modified) clang/lib/AST/ASTDiagnostic.cpp (+4-4) - (modified) clang/lib/AST/ASTImporter.cpp (+13-21) - (modified) clang/lib/AST/DeclTemplate.cpp (+2-5) - (modified) clang/lib/AST/QualTypeNames.cpp (+1-2) - (modified) clang/lib/AST/TemplateBase.cpp (+4-15) - (modified) clang/lib/AST/Type.cpp (+23-27) - (modified) clang/lib/Sema/SemaCXXScopeSpec.cpp (+10-8) - (modified) clang/lib/Sema/SemaExpr.cpp (+3-17) - (modified) clang/lib/Sema/SemaLookup.cpp (+1-2) - (modified) clang/lib/Sema/SemaTemplate.cpp (+84-78) - (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+18-27) - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+5-6) - (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+1-2) - (modified) clang/lib/Sema/TreeTransform.h (+4-9) - (modified) clang/test/CXX/class.derived/class.derived.general/p2.cpp (+1-1) - (modified) clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp (+2-2) - (modified) clang/test/SemaCXX/undefined-partial-specialization.cpp (+1-1) - (modified) clang/test/SemaTemplate/make_integer_seq.cpp (+45-16) - (modified) clang/test/SemaTemplate/type_pack_element.cpp (+42-15) - (modified) clang/unittests/AST/TypePrinterTest.cpp (+3-3) ``diff diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp index 3b991e5e9013f..66b587f00ff4a 100644 --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -439,8 +439,7 @@ QualType declaredType(const TypeDecl *D) { if (const auto *CTSD = llvm::dyn_cast(D)) if (const auto *Args = CTSD->getTemplateArgsAsWritten()) return Context.getTemplateSpecializationType( - TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(), - /*CanonicalArgs=*/std::nullopt); + TemplateName(CTSD->getSpecializedTemplate()), Args->arguments()); return Context.getTypeDeclType(D); } diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 69c7369755c67..db8dad268a8a7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -301,8 +301,6 @@ Improvements to Clang's diagnostics - Clang now better preserves the sugared types of pointers to member. - Clang now better preserves the presence of the template keyword with dependent prefixes. -- Clang now in more cases avoids printing 'type-parameter-X-X' instead of the name of - the template parameter. - Clang now respects the current language mode when printing expressions in diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also a bunch of HLSL types being printed as their C++ equivalents. diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index b8ea2af9215d2..b1e6344576eb5 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -367,6 +367,9 @@ class ASTContext : public RefCountedBase { const ASTContext&> CanonTemplateTemplateParms; + TemplateTemplateParmDecl * +getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; + /// The typedef for the __int128_t type. mutable TypedefDecl *Int128Decl = nullptr; @@ -1808,26 +1811,22 @@ class ASTContext : public RefCountedBase { bool ParameterPack, TemplateTypeParmDecl *ParmDecl = nullptr) const; - QualType getCanonicalTemplateSpecializationType( - TemplateName T, ArrayRef CanonicalArgs) const; + QualType getTemplateSpecializationType(TemplateName T, + ArrayRef Args, + QualType Canon = QualType()) const; QualType - getTemplateSpecializationType(TemplateName T, -ArrayRef SpecifiedArgs, -ArrayRef CanonicalArgs, -QualType Underlying = QualType()) const; + getCanonicalTemplateSpecializationType(TemplateName T, + ArrayRef Args) const; - QualType - getTemplateSpecializationType(TemplateName T, -ArrayRef SpecifiedArgs, -
[clang] [Serialization] Fix lazy template loading (PR #133057)
emaxx-google wrote: > > Here's a new reproducer, this time verifying that a semi-fresh > > tip-of-the-tree doesn't trigger the same error: > > https://pastebin.com/7tYfjazz. Apologies for the delay. > > Thanks. I gave it a try, but I don't see any `use of overloaded operator '=' > is ambiguous` error. In fact, there isn't a `operator =` in the sources at > all. What am I missing? 🤔 I didn't investigate the error - but could it come from autogenerated operators? > Creduce-like tools are very bad at finding reject valid codes. @emaxx-google, > can you paste your interestingness test? Here's the (slightly smaller) input: https://pastebin.com/dBy1T9fc . The simplified script: https://pastebin.com/udVTaPYV . Its output: https://pastebin.com/Mcq0Y0rf . 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] [clang-tools-extra] Revert "[clang] Improved canonicalization for template specialization types" (PR #135354)
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 HEAD~1 HEAD --extensions cpp,h -- clang-tools-extra/clangd/AST.cpp clang/include/clang/AST/ASTContext.h clang/include/clang/AST/TemplateBase.h clang/include/clang/AST/Type.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTDiagnostic.cpp clang/lib/AST/ASTImporter.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/AST/QualTypeNames.cpp clang/lib/AST/TemplateBase.cpp clang/lib/AST/Type.cpp clang/lib/Sema/SemaCXXScopeSpec.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/TreeTransform.h clang/test/CXX/class.derived/class.derived.general/p2.cpp clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp clang/test/SemaCXX/undefined-partial-specialization.cpp clang/test/SemaTemplate/make_integer_seq.cpp clang/test/SemaTemplate/type_pack_element.cpp clang/unittests/AST/TypePrinterTest.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index b1e634457..d0b6b2fcf 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -368,7 +368,7 @@ class ASTContext : public RefCountedBase { CanonTemplateTemplateParms; TemplateTemplateParmDecl * -getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; + getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; /// The typedef for the __int128_t type. mutable TypedefDecl *Int128Decl = nullptr; diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9f6189440..36ffa5423 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -6676,10 +6676,8 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode { /// replacement must, recursively, be one of these). TemplateName Template; - TemplateSpecializationType(TemplateName T, - ArrayRef Args, - QualType Canon, - QualType Aliased); + TemplateSpecializationType(TemplateName T, ArrayRef Args, + QualType Canon, QualType Aliased); public: /// Determine whether any of the given template arguments are dependent. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 00e2fa267..0122652be 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -5538,11 +5538,9 @@ QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index, return QualType(TypeParm, 0); } -TypeSourceInfo * -ASTContext::getTemplateSpecializationTypeInfo(TemplateName Name, - SourceLocation NameLoc, -const TemplateArgumentListInfo &Args, - QualType Underlying) const { +TypeSourceInfo *ASTContext::getTemplateSpecializationTypeInfo( +TemplateName Name, SourceLocation NameLoc, +const TemplateArgumentListInfo &Args, QualType Underlying) const { assert(!Name.getAsDependentTemplateName() && "No dependent template names here!"); QualType TST = @@ -5613,9 +5611,8 @@ ASTContext::getTemplateSpecializationType(TemplateName Template, sizeof(TemplateArgument) * Args.size() + (IsTypeAlias ? sizeof(QualType) : 0), alignof(TemplateSpecializationType)); - auto *Spec -= new (Mem) TemplateSpecializationType(Template, Args, CanonType, - IsTypeAlias ? Underlying : QualType()); + auto *Spec = new (Mem) TemplateSpecializationType( + Template, Args, CanonType, IsTypeAlias ? Underlying : QualType()); Types.push_back(Spec); return QualType(Spec, 0); @@ -5640,20 +5637,18 @@ QualType ASTContext::getCanonicalTemplateSpecializationType( // Determine whether this canonical template specialization type already // exists. llvm::FoldingSetNodeID ID; - TemplateSpecializationType::Profile(ID, CanonTemplate, - CanonArgs, *this); + TemplateSpecializationType::Profile(ID, CanonTemplate, CanonArgs, *this); void *InsertPos = nullptr; - TemplateSpecializationType *Spec -= TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos); + TemplateSpecializationType *Spec = + TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos); if (!Spec) { // Allocate a new canonical template specialization type. void *Mem = Allocate((sizeof(TemplateSpecializationType) +
[clang] [clang][CodeGen] Add range metadata for atomic load of boolean type. #131476 (PR #133546)
https://github.com/janagor updated https://github.com/llvm/llvm-project/pull/133546 From 4581169d6fbe72357bb83b95fe36c8cc606efa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3rski?= Date: Fri, 28 Mar 2025 23:36:18 +0100 Subject: [PATCH 1/9] [clang][CodeGen] Added llvm ir pre-commit test. --- clang/test/CodeGen/atomic-ops-load.c | 11 +++ 1 file changed, 11 insertions(+) create mode 100644 clang/test/CodeGen/atomic-ops-load.c diff --git a/clang/test/CodeGen/atomic-ops-load.c b/clang/test/CodeGen/atomic-ops-load.c new file mode 100644 index 0..adcaf9a2112fa --- /dev/null +++ b/clang/test/CodeGen/atomic-ops-load.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple riscv64 -O1 -emit-llvm %s -o - | FileCheck %s +#include + +extern bool t1; +bool test1(void) { +// CHECK-LABEL: define{{.*}} i1 @test1 +// CHECK: load atomic i8, ptr @t1 monotonic, align 1 +// CHECK-NEXT: trunc i8 %{{.*}} to i1 +// CHECK-NEXT: ret i1 %{{.*}} + return __atomic_load_n(&t1, __ATOMIC_RELAXED); +} From 852b691fac487b3cef7b0df8875c26573bc58daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3rski?= Date: Sat, 29 Mar 2025 00:53:23 +0100 Subject: [PATCH 2/9] [clang][CodeGen] Added `!range` metadata to atomic load for `bool`. --- clang/lib/CodeGen/CGAtomic.cpp | 23 +++ clang/test/CodeGen/atomic-ops-load.c | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp index 3adb2a7ad207f..70ae7180a9adc 100644 --- a/clang/lib/CodeGen/CGAtomic.cpp +++ b/clang/lib/CodeGen/CGAtomic.cpp @@ -590,6 +590,29 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, Address Dest, llvm::LoadInst *Load = CGF.Builder.CreateLoad(Ptr); Load->setAtomic(Order, Scope); Load->setVolatile(E->isVolatile()); + +if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) { + CGF.Builder.CreateStore(Load, Dest); + return; +} + +QualType Ty = E->getValueType(); +if (!Ty->isBooleanType()) { + CGF.Builder.CreateStore(Load, Dest); + return; +} + +llvm::MDBuilder MDHelper(CGF.getLLVMContext()); +llvm::APInt BooleanMin = llvm::APInt(CGF.getContext().getTypeSize(Ty), 0); +llvm::APInt BooleanEnd = llvm::APInt(CGF.getContext().getTypeSize(Ty), 2); + +if (llvm::MDNode *RangeInfo = +MDHelper.createRange(BooleanMin, BooleanEnd)) { + Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo); + Load->setMetadata(llvm::LLVMContext::MD_noundef, + llvm::MDNode::get(CGF.getLLVMContext(), {})); +} + CGF.Builder.CreateStore(Load, Dest); return; } diff --git a/clang/test/CodeGen/atomic-ops-load.c b/clang/test/CodeGen/atomic-ops-load.c index adcaf9a2112fa..778a7ebdc2618 100644 --- a/clang/test/CodeGen/atomic-ops-load.c +++ b/clang/test/CodeGen/atomic-ops-load.c @@ -4,8 +4,8 @@ extern bool t1; bool test1(void) { // CHECK-LABEL: define{{.*}} i1 @test1 -// CHECK: load atomic i8, ptr @t1 monotonic, align 1 -// CHECK-NEXT: trunc i8 %{{.*}} to i1 +// CHECK: load atomic i8, ptr @t1 monotonic, align 1, !range ![[$WS_RANGE:[0-9]*]], !noundef !{{[0-9]+}} +// CHECK-NEXT: trunc nuw i8 %{{.*}} to i1 // CHECK-NEXT: ret i1 %{{.*}} return __atomic_load_n(&t1, __ATOMIC_RELAXED); } From e42772bbc0851696d73ded4abc3edf651f4e8b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3rski?= Date: Sat, 29 Mar 2025 01:12:18 +0100 Subject: [PATCH 3/9] Updated codestyle. --- clang/lib/CodeGen/CGAtomic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp index 70ae7180a9adc..2c9613deef744 100644 --- a/clang/lib/CodeGen/CGAtomic.cpp +++ b/clang/lib/CodeGen/CGAtomic.cpp @@ -607,10 +607,10 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, Address Dest, llvm::APInt BooleanEnd = llvm::APInt(CGF.getContext().getTypeSize(Ty), 2); if (llvm::MDNode *RangeInfo = -MDHelper.createRange(BooleanMin, BooleanEnd)) { +MDHelper.createRange(BooleanMin, BooleanEnd)) { Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo); Load->setMetadata(llvm::LLVMContext::MD_noundef, - llvm::MDNode::get(CGF.getLLVMContext(), {})); +llvm::MDNode::get(CGF.getLLVMContext(), {})); } CGF.Builder.CreateStore(Load, Dest); From c95f16cf2df51e8f7a1d4952918c977104271072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B3rski?= Date: Fri, 4 Apr 2025 11:20:30 +0200 Subject: [PATCH 4/9] Refactored early returns into normal if statement. --- clang/lib/CodeGen/CGAtomic.cpp | 29 ++--- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp index 2c9613deef744..c40bf3cd77d86 100644 --- a/clang/lib/CodeGen/CGAtomic.cpp +++ b/clang/lib/CodeGen/CGAtomic.cpp @@ -591,26 +591,17 @@ static void EmitAtom
[clang] [Serialization] Fix lazy template loading (PR #133057)
hahnjo wrote: > The simplified script: https://pastebin.com/udVTaPYV Aaaah, the important line is `EXTRA_CFLAGS='-Xclang -fallow-pcm-with-compiler-errors -ferror-limit=0'`. With that I indeed get the following diff between logs from `main` and a rebased version of this branch: ```diff --- main.log2025-04-11 14:31:26.655249634 +0200 +++ clang-modules-rebased.log 2025-04-11 14:30:12.184305904 +0200 @@ -417,12 +417,15 @@ TR7.cc:4:1: error: a type specifier is required for all declarations 4 | std ( | ^ -TR7.cc:8:1: error: 'operator type-parameter-0-0' is a private member of 'sr::g' +TR7.cc:7:3: error: use of overloaded operator '=' is ambiguous (with operand types 'uz' and 'g') +7 | q = + | ~ ^ 8 | dp(h, '\n') - | ^~~ -./UL8.h:6:1: note: implicitly declared private here -6 | operator pzx(; - | ^ + | ~~~ +L3Z:31:7: note: candidate function (the implicit copy assignment operator) + 31 | class uz {typede x t; + | ^ +L3Z:31:7: note: candidate function (the implicit move assignment operator) TR7.cc:8:12: error: expected ';' after expression 8 | dp(h, '\n') |^ ``` When I have time, I will need to see that I turn the reduced example into actual valid code to understand what is going on... 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] [Clang] add option --offload-jobs=N (PR #135229)
https://github.com/jhuber6 approved this pull request. LG with one nit. https://github.com/llvm/llvm-project/pull/135229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] add option --offload-jobs=N (PR #135229)
@@ -1234,6 +1234,10 @@ def offload_compression_level_EQ : Joined<["--"], "offload-compression-level=">, Flags<[HelpHidden]>, HelpText<"Compression level for offload device binaries (HIP only)">; +def offload_jobs_EQ : Joined<["--"], "offload-jobs=">, + HelpText<"Specify the number of threads for the clang-linker-wrapper" + " (--wrapper-jobs=N)">; jhuber6 wrote: This seems a little too specific, the average user isn't going to even know what the linker wrapper is. https://github.com/llvm/llvm-project/pull/135229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] add option --offload-jobs=N (PR #135229)
https://github.com/jhuber6 edited https://github.com/llvm/llvm-project/pull/135229 ___ 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)
vgvassilev wrote: > > > Here's a new reproducer, this time verifying that a semi-fresh > > > tip-of-the-tree doesn't trigger the same error: > > > https://pastebin.com/7tYfjazz. Apologies for the delay. > > > > > > Thanks. I gave it a try, but I don't see any `use of overloaded operator > > '=' is ambiguous` error. In fact, there isn't a `operator =` in the sources > > at all. What am I missing? 🤔 > > I didn't investigate the error - but could it come from autogenerated > operators? > > > Creduce-like tools are very bad at finding reject valid codes. > > @emaxx-google, can you paste your interestingness test? > > Here's the (slightly smaller) input: https://pastebin.com/dBy1T9fc . The > simplified script: https://pastebin.com/udVTaPYV . Its output: > https://pastebin.com/Mcq0Y0rf . A reduce strategy that often worked for me is to have the broken compiler in modules mode but the working compiler in non-modules mode. If you prepend a tool such as https://github.com/Teemperor/hippie you can get all read by the compiler files in a readable area. Then you can use (-isysroot or the same tool to feed them back to the compiler). In this case you will have a "flat" TU which can run in both modules and non-modules mode. I hope that helps with that case, too... 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] [Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)
@@ -3161,7 +3161,7 @@ def err_musttail_member_mismatch : Error< def note_musttail_callee_defined_here : Note<"%0 declared here">; def note_tail_call_required : Note<"tail call required by %0 attribute here">; def err_musttail_mismatch : Error< - "cannot perform a tail call to function%select{| %1}0 because its signature " + "cannot perform a tail call to function %select{| %1}0 because its signature " AaronBallman wrote: The original code here was correct and should not lead to any missing whitespace. You'd either get: `... to function because its signature...` or you'd get `to function 'foo' because`. With your changes, you'd get `...to function 'foo' because` (note the extra whitespace before `'foo'`). https://github.com/llvm/llvm-project/pull/134465 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] ItaniumMangle: fix mangling for unresolved types (PR #135312)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/135312 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU][Clang] Add builtins for gfx12 ray tracing intrinsics (PR #135224)
https://github.com/yxsamliu approved this pull request. https://github.com/llvm/llvm-project/pull/135224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Teach Barmetal toolchain about GCC installation (PR #121829)
@@ -110,20 +110,81 @@ static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) { return std::string(SysRootDir); } +static bool hasGCCToolChainAlongSideClang(const Driver &D) { + SmallString<128> GCCDir; + llvm::sys::path::append(GCCDir, D.Dir, "..", D.getTargetTriple(), + "lib/crt0.o"); + return llvm::sys::fs::exists(GCCDir); +} + +std::string BareMetal::computeSysRoot() const { + if (!SysRoot.empty()) +return SysRoot; + + const Driver &D = getDriver(); + if (!D.SysRoot.empty()) +return D.SysRoot; + + // Verify the GCC installation from -gcc-install-dir, --gcc-toolchain, or + // alongside clang. If valid, form the sysroot. Otherwise, check + // lib/clang-runtimes above the driver. + SmallString<128> SysRootDir; + if (GCCInstallation.isValid()) { +StringRef LibDir = GCCInstallation.getParentLibPath(); +StringRef TripleStr = GCCInstallation.getTriple().str(); +llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr); + } else if (hasGCCToolChainAlongSideClang(D)) { +// Use the triple as provided to the driver. Unlike the parsed triple +// this has not been normalized to always contain every field. +llvm::sys::path::append(SysRootDir, D.Dir, "..", D.getTargetTriple()); + } + + if (llvm::sys::fs::exists(SysRootDir)) +return std::string(SysRootDir); + return computeBaseSysRoot(D, /*IncludeTriple*/ true); +} + +static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs, + const Multilib &Multilib, + StringRef InstallPath, + ToolChain::path_list &Paths) { + if (const auto &PathsCallback = Multilibs.filePathsCallback()) +for (const auto &Path : PathsCallback(Multilib)) + addPathIfExists(D, InstallPath + Path, Paths); +} + BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) -: ToolChain(D, Triple, Args), - SysRoot(computeBaseSysRoot(D, /*IncludeTriple=*/true)) { - getProgramPaths().push_back(getDriver().Dir); - - findMultilibs(D, Triple, Args); - SmallString<128> SysRoot(computeSysRoot()); - if (!SysRoot.empty()) { -for (const Multilib &M : getOrderedMultilibs()) { - SmallString<128> Dir(SysRoot); - llvm::sys::path::append(Dir, M.osSuffix(), "lib"); - getFilePaths().push_back(std::string(Dir)); - getLibraryPaths().push_back(std::string(Dir)); +: Generic_ELF(D, Triple, Args) { + GCCInstallation.init(Triple, Args); + SysRoot = computeSysRoot(); + if (GCCInstallation.isValid()) { +Multilibs = GCCInstallation.getMultilibs(); +SelectedMultilibs.assign({GCCInstallation.getMultilib()}); smithp35 wrote: Are we delegating GCC multilibs entirely to the GNU toolchain driver? As I understand it these are hard-coded at the moment, so I expect the GNU arm-none-eabi toolchains won't work unless their multilibs are added. Have I got that right? Or will this only work with toolchains, possibly RISCV, that already have their multilib structure encoded in GCCInstallation. https://github.com/llvm/llvm-project/pull/121829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Teach Barmetal toolchain about GCC installation (PR #121829)
https://github.com/smithp35 commented: I'm looking at this patch in isolation, so its possible that the comments here are addressed elasewhere. It looks like useful functionality to add to the bare metal driver. It also looks like there is some scope for some documentation, for users and for toolchain developers. Users will need to know about what options to set to point at their GCC installation (or place adjacent). Non-GNU toolchain developers will need to avoid `/lib/crt0.o`. If multilibs doesn't work for all toolchains yet, would be good to add that as a limitation. That could be done with a follow up patch though. https://github.com/llvm/llvm-project/pull/121829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Teach Barmetal toolchain about GCC installation (PR #121829)
https://github.com/smithp35 edited https://github.com/llvm/llvm-project/pull/121829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Allow simpler visibility annotations when targeting win32 and mingw (PR #133699)
https://github.com/philnik777 ready_for_review https://github.com/llvm/llvm-project/pull/133699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU][Clang] Add builtins for gfx12 ray tracing intrinsics (PR #135224)
https://github.com/shiltian closed https://github.com/llvm/llvm-project/pull/135224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] Fix signal frame unwinding (PR #135367)
https://github.com/trungnt2910 created https://github.com/llvm/llvm-project/pull/135367 The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame. >From 9f9a3e70740331a7a4ac9f52e580d76f94b5e8fd Mon Sep 17 00:00:00 2001 From: Trung Nguyen <57174311+trungnt2...@users.noreply.github.com> Date: Fri, 11 Apr 2025 23:11:04 +1000 Subject: [PATCH] Fix signal frame unwinding The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame. --- libunwind/src/CMakeLists.txt | 16 --- libunwind/src/UnwindCursor.hpp | 223 - 2 files changed, 163 insertions(+), 76 deletions(-) diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index d69013e5dace1..70bd3a017cda7 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -118,22 +118,6 @@ if (HAIKU) add_compile_flags("-D_DEFAULT_SOURCE") add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME") - - find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS -"commpage_defs.h" -PATHS ${CMAKE_SYSTEM_INCLUDE_PATH} -PATH_SUFFIXES "/private/system" -NO_DEFAULT_PATH -REQUIRED) - - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}") - if (LIBUNWIND_TARGET_TRIPLE) -if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64") - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64") -endif() - else() -include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}") - endif() endif () string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..fc1f8e91724b2 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -41,6 +41,14 @@ #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif +#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) +#include +#include +#include +#include +#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1 +#endif + #include "AddressSpace.hpp" #include "CompactUnwinder.hpp" #include "config.h" @@ -1015,7 +1023,7 @@ class UnwindCursor : public AbstractUnwindCursor{ template int stepThroughSigReturn(Registers &) { return UNW_STEP_END; } -#elif defined(_LIBUNWIND_TARGET_HAIKU) +#elif defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) bool setInfoForSigReturn(); int stepThroughSigReturn(); #endif @@ -2559,7 +2567,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, tbtable *TBTable, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) _isSigReturn = false; #endif @@ -2684,7 +2692,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (setInfoForSigReturn()) return; #endif @@ -2760,63 +2768,6 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) { _isSignalFrame = true; return UNW_STEP_SUCCESS; } - -#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) -#include -#include - -extern "C" { -extern void *__gCommPageAddress; -} - -template -bool UnwindCursor::setInfoForSigReturn() { -#if defined(_LIBUNWIND_TARGET_X86_64) - addr_t signal_handler = - (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] + - (addr_t)__gCommPageAddress); - addr_t signal_handler_ret = signal_handler + 45; -#endif - pint_t pc = static_cast(this->getReg(UNW_REG_IP)); - if (pc == signal_handler_ret) { -_info = {}; -_info.start_ip = signal_handler; -_info.end_ip = signal_handler_ret; -_isSigReturn = true; -return true; - } - return false; -} - -template -int UnwindCursor::stepThroughSigReturn() { - _isSignalFrame = true; - pint_t sp = _registers.getSP(); -#if defined(_LIBUNWIND_TARGET_X86_64) - vregs *regs = (vregs *
[libunwind] Fix signal frame unwinding (PR #135367)
llvmbot wrote: @llvm/pr-subscribers-libunwind Author: Trung Nguyen (trungnt2910) Changes The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame. --- Full diff: https://github.com/llvm/llvm-project/pull/135367.diff 2 Files Affected: - (modified) libunwind/src/CMakeLists.txt (-16) - (modified) libunwind/src/UnwindCursor.hpp (+163-60) ``diff diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index d69013e5dace1..70bd3a017cda7 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -118,22 +118,6 @@ if (HAIKU) add_compile_flags("-D_DEFAULT_SOURCE") add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME") - - find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS -"commpage_defs.h" -PATHS ${CMAKE_SYSTEM_INCLUDE_PATH} -PATH_SUFFIXES "/private/system" -NO_DEFAULT_PATH -REQUIRED) - - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}") - if (LIBUNWIND_TARGET_TRIPLE) -if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64") - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64") -endif() - else() -include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}") - endif() endif () string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..fc1f8e91724b2 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -41,6 +41,14 @@ #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif +#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) +#include +#include +#include +#include +#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1 +#endif + #include "AddressSpace.hpp" #include "CompactUnwinder.hpp" #include "config.h" @@ -1015,7 +1023,7 @@ class UnwindCursor : public AbstractUnwindCursor{ template int stepThroughSigReturn(Registers &) { return UNW_STEP_END; } -#elif defined(_LIBUNWIND_TARGET_HAIKU) +#elif defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) bool setInfoForSigReturn(); int stepThroughSigReturn(); #endif @@ -2559,7 +2567,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, tbtable *TBTable, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) _isSigReturn = false; #endif @@ -2684,7 +2692,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (setInfoForSigReturn()) return; #endif @@ -2760,63 +2768,6 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) { _isSignalFrame = true; return UNW_STEP_SUCCESS; } - -#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) -#include -#include - -extern "C" { -extern void *__gCommPageAddress; -} - -template -bool UnwindCursor::setInfoForSigReturn() { -#if defined(_LIBUNWIND_TARGET_X86_64) - addr_t signal_handler = - (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] + - (addr_t)__gCommPageAddress); - addr_t signal_handler_ret = signal_handler + 45; -#endif - pint_t pc = static_cast(this->getReg(UNW_REG_IP)); - if (pc == signal_handler_ret) { -_info = {}; -_info.start_ip = signal_handler; -_info.end_ip = signal_handler_ret; -_isSigReturn = true; -return true; - } - return false; -} - -template -int UnwindCursor::stepThroughSigReturn() { - _isSignalFrame = true; - pint_t sp = _registers.getSP(); -#if defined(_LIBUNWIND_TARGET_X86_64) - vregs *regs = (vregs *)(sp + 0x70); - - _registers.setRegister(UNW_REG_IP, regs->rip); - _registers.setRegister(UNW_REG_SP, regs->rsp); - _registers.setRegister(UNW_X86_64_RAX, regs->rax); - _registers.setRegister(UNW_X86_64_RDX, regs->rdx); - _registers.setRegister(UNW_X86_64_RCX, regs->rcx); - _registers.setRegister(UNW_X86_64_RBX, regs->rbx); - _registers.setRegister(UNW_X86_64_RSI, regs->rsi); - _registers.setRegister(UNW_X86_64_RDI, regs->rdi); - _registers.setRegister(UNW_X86_64_RBP, regs->rbp); - _registers.setRegister(UNW_X86_64_R8, regs->r8); - _registers.setRegister(UNW_X86_64_R9, regs->r9); - _registers.setRegister(UNW_X
[libunwind] Fix signal frame unwinding (PR #135367)
github-actions[bot] wrote: ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information. https://github.com/llvm/llvm-project/pull/135367 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Allow simpler visibility annotations when targeting win32 and mingw (PR #133699)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Nikolas Klauser (philnik777) Changes MinGW and Win32 disagree on where the `__declspec(dllexport)` should be placed. However, there doesn't fundamentally seem to be a problem with putting the annotation in both places. This patch adds a new diagnostic group and `-Wattribute-ignored` warnings about where the attribute is placed if the attribute is different on the declaration and definition. There is another new warning group `-Wdllexport-explicit-instantiation` that also diagnoses places where the attribue is technically ignored, even though the correct place is also annotated. This makes it possible to significantly simplify libc++'s visibility annotations (see #133704). --- Full diff: https://github.com/llvm/llvm-project/pull/133699.diff 7 Files Affected: - (modified) clang/include/clang/Basic/Attr.td (+8) - (modified) clang/include/clang/Basic/DiagnosticGroups.td (+5-1) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+11-1) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+4-1) - (modified) clang/lib/Sema/SemaTemplate.cpp (+18-2) - (added) clang/test/SemaCXX/dllexport-explicit-instantiation.cpp (+19) - (modified) clang/test/SemaCXX/dllexport.cpp (+3) ``diff diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 0999d8065e9f5..6bb8fc05b119a 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4185,6 +4185,14 @@ def DLLExport : InheritableAttr, TargetSpecificAttr { let Documentation = [DLLExportDocs]; } +def DLLExportOnDecl : InheritableAttr, TargetSpecificAttr { + // This attribute is only used to warn if there was a `__declspec(dllexport)` + // on a declaration, but not on the defintion of an explciit instantiation + let Spellings = []; + let Subjects = SubjectList<[CXXRecord]>; + let Documentation = [InternalOnly]; +} + def DLLExportStaticLocal : InheritableAttr, TargetSpecificAttr { // This attribute is used internally only when -fno-dllexport-inlines is // passed. This attribute is added to inline functions of a class having the diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index b9f08d96151c9..80f27771248bb 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -487,6 +487,9 @@ def Dangling : DiagGroup<"dangling", [DanglingAssignment, ReturnStackAddress]>; def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">; def DllexportExplicitInstantiationDecl : DiagGroup<"dllexport-explicit-instantiation-decl">; +def DllexportExplicitInstantiation : + DiagGroup<"dllexport-explicit-instantiation", +[DllexportExplicitInstantiationDecl]>; def ExcessInitializers : DiagGroup<"excess-initializers">; def ExpansionToDefined : DiagGroup<"expansion-to-defined">; def FlagEnum : DiagGroup<"flag-enum">; @@ -870,7 +873,8 @@ def NSReturnsMismatch : DiagGroup<"nsreturns-mismatch">; def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">; def UnknownAttributes : DiagGroup<"unknown-attributes">; -def IgnoredAttributes : DiagGroup<"ignored-attributes">; +def IgnoredAttributes : DiagGroup<"ignored-attributes", + [DllexportExplicitInstantiation]>; def Attributes : DiagGroup<"attributes", [UnknownAttributes, IgnoredAttributes]>; def UnknownSanitizers : DiagGroup<"unknown-sanitizers">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1e900437d41ce..31324b6b1262f 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3736,9 +3736,19 @@ def warn_attribute_dllimport_static_field_definition : Warning< def warn_attribute_dllexport_explicit_instantiation_decl : Warning< "explicit instantiation declaration should not be 'dllexport'">, InGroup; -def warn_attribute_dllexport_explicit_instantiation_def : Warning< +def warn_attr_dllexport_explicit_inst_def : Warning< "'dllexport' attribute ignored on explicit instantiation definition">, + InGroup; +def warn_attr_dllexport_explicit_inst_def_mismatch : Warning< + "'dllexport' attribute ignored on explicit instantiation definition">, + InGroup; +def note_prev_decl_missing_dllexport : Note< + "'dllexport' attribute is missing on previous declaration">; +def warn_dllexport_on_decl_ignored : Warning< + "explicit instantiation definition is not exported without 'dllexport'">, InGroup; +def note_dllexport_on_decl : Note< + "'dllexport' attribute on the declaration is ignored">; def warn_attribute_exclude_from_explicit_instantiation_local_class : Warning< "%0 attribute ignored on local class%select{| member}1">, InGroup; diff --git a/clang/lib/Sema/SemaDeclCXX.
[clang] 9e90e10 - [AMDGPU][Clang] Add builtins for gfx12 ray tracing intrinsics (#135224)
Author: Shilei Tian Date: 2025-04-11T09:33:32-04:00 New Revision: 9e90e10e76eeb796d2d9e8609b98b90d760e1eb0 URL: https://github.com/llvm/llvm-project/commit/9e90e10e76eeb796d2d9e8609b98b90d760e1eb0 DIFF: https://github.com/llvm/llvm-project/commit/9e90e10e76eeb796d2d9e8609b98b90d760e1eb0.diff LOG: [AMDGPU][Clang] Add builtins for gfx12 ray tracing intrinsics (#135224) Added: Modified: clang/include/clang/Basic/BuiltinsAMDGPU.def clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp clang/test/CodeGenOpenCL/builtins-amdgcn-raytracing.cl Removed: diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index cbef637be213a..39fef9e4601f8 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -506,6 +506,18 @@ TARGET_BUILTIN(__builtin_amdgcn_global_load_tr_b128_v4bf16, "V4yV4y*1", "nc", "g TARGET_BUILTIN(__builtin_amdgcn_ds_bpermute_fi_b32, "iii", "nc", "gfx12-insts") +// For the following two builtins, the second and third return values of the +// intrinsics are returned through the last two pointer-type function arguments. +TARGET_BUILTIN(__builtin_amdgcn_image_bvh8_intersect_ray, "V10UiWUifUcV3fV3fUiV4UiV3f*V3f*", "nc", "gfx12-insts") +TARGET_BUILTIN(__builtin_amdgcn_image_bvh_dual_intersect_ray, "V10UiWUifUcV3fV3fV2UiV4UiV3f*V3f*", "nc", "gfx12-insts") + +TARGET_BUILTIN(__builtin_amdgcn_ds_bvh_stack_push4_pop1_rtn, "V2UiUiUiV4UiIi", "n", "gfx11-insts") +TARGET_BUILTIN(__builtin_amdgcn_ds_bvh_stack_push8_pop1_rtn, "V2UiUiUiV8UiIi", "n", "gfx12-insts") + +// The intrinsic returns {i64, i32}, the builtin returns <2 x i64>. +// The second return value of the intrinsic is zext'ed. +TARGET_BUILTIN(__builtin_amdgcn_ds_bvh_stack_push8_pop2_rtn, "V2WUiUiUiV8UiIi", "n", "gfx12-insts") + //===--===// // WMMA builtins. // Postfix w32 indicates the builtin requires wavefront size of 32. diff --git a/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp b/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp index b56b739094ff3..35c9f8ae48c80 100644 --- a/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp +++ b/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp @@ -616,19 +616,81 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, return Builder.CreateCall(F, {NodePtr, RayExtent, RayOrigin, RayDir, RayInverseDir, TextureDescr}); } + case AMDGPU::BI__builtin_amdgcn_image_bvh8_intersect_ray: + case AMDGPU::BI__builtin_amdgcn_image_bvh_dual_intersect_ray: { +Intrinsic::ID IID; +switch (BuiltinID) { +case AMDGPU::BI__builtin_amdgcn_image_bvh8_intersect_ray: + IID = Intrinsic::amdgcn_image_bvh8_intersect_ray; + break; +case AMDGPU::BI__builtin_amdgcn_image_bvh_dual_intersect_ray: + IID = Intrinsic::amdgcn_image_bvh_dual_intersect_ray; + break; +} +llvm::Value *NodePtr = EmitScalarExpr(E->getArg(0)); +llvm::Value *RayExtent = EmitScalarExpr(E->getArg(1)); +llvm::Value *InstanceMask = EmitScalarExpr(E->getArg(2)); +llvm::Value *RayOrigin = EmitScalarExpr(E->getArg(3)); +llvm::Value *RayDir = EmitScalarExpr(E->getArg(4)); +llvm::Value *Offset = EmitScalarExpr(E->getArg(5)); +llvm::Value *TextureDescr = EmitScalarExpr(E->getArg(6)); + +Address RetRayOriginPtr = EmitPointerWithAlignment(E->getArg(7)); +Address RetRayDirPtr = EmitPointerWithAlignment(E->getArg(8)); + +llvm::Function *IntrinsicFunc = CGM.getIntrinsic(IID); + +llvm::CallInst *CI = Builder.CreateCall( +IntrinsicFunc, {NodePtr, RayExtent, InstanceMask, RayOrigin, RayDir, +Offset, TextureDescr}); + +llvm::Value *RetVData = Builder.CreateExtractValue(CI, 0); +llvm::Value *RetRayOrigin = Builder.CreateExtractValue(CI, 1); +llvm::Value *RetRayDir = Builder.CreateExtractValue(CI, 2); + +Builder.CreateStore(RetRayOrigin, RetRayOriginPtr); +Builder.CreateStore(RetRayDir, RetRayDirPtr); + +return RetVData; + } + + case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_rtn: + case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push4_pop1_rtn: + case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop1_rtn: + case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop2_rtn: { +Intrinsic::ID IID; +switch (BuiltinID) { +case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_rtn: + IID = Intrinsic::amdgcn_ds_bvh_stack_rtn; + break; +case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push4_pop1_rtn: + IID = Intrinsic::amdgcn_ds_bvh_stack_push4_pop1_rtn; + break; +case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop1_rtn: + IID = Intrinsic::amdgcn_ds_bvh_stack_push8_pop1_rtn; + break; +case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop2_rtn: + IID = Intrinsic::amdgcn_ds_bvh_stack_push8_pop2_rtn
[libunwind] Fix signal frame unwinding (PR #135367)
https://github.com/trungnt2910 updated https://github.com/llvm/llvm-project/pull/135367 >From d213e68a98b5c92656122aa13bf853b77e6c0b7a Mon Sep 17 00:00:00 2001 From: Trung Nguyen <57174311+trungnt2...@users.noreply.github.com> Date: Fri, 11 Apr 2025 23:11:04 +1000 Subject: [PATCH] Fix signal frame unwinding The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame. --- libunwind/src/CMakeLists.txt | 16 --- libunwind/src/UnwindCursor.hpp | 227 - 2 files changed, 167 insertions(+), 76 deletions(-) diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index d69013e5dace1..70bd3a017cda7 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -118,22 +118,6 @@ if (HAIKU) add_compile_flags("-D_DEFAULT_SOURCE") add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME") - - find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS -"commpage_defs.h" -PATHS ${CMAKE_SYSTEM_INCLUDE_PATH} -PATH_SUFFIXES "/private/system" -NO_DEFAULT_PATH -REQUIRED) - - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}") - if (LIBUNWIND_TARGET_TRIPLE) -if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64") - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64") -endif() - else() -include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}") - endif() endif () string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..1c545978673b4 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -41,6 +41,14 @@ #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif +#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) +#include +#include +#include +#include +#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1 +#endif + #include "AddressSpace.hpp" #include "CompactUnwinder.hpp" #include "config.h" @@ -1015,7 +1023,7 @@ class UnwindCursor : public AbstractUnwindCursor{ template int stepThroughSigReturn(Registers &) { return UNW_STEP_END; } -#elif defined(_LIBUNWIND_TARGET_HAIKU) +#elif defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) bool setInfoForSigReturn(); int stepThroughSigReturn(); #endif @@ -2559,7 +2567,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, tbtable *TBTable, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) _isSigReturn = false; #endif @@ -2684,7 +2692,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (setInfoForSigReturn()) return; #endif @@ -2760,63 +2768,6 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) { _isSignalFrame = true; return UNW_STEP_SUCCESS; } - -#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) -#include -#include - -extern "C" { -extern void *__gCommPageAddress; -} - -template -bool UnwindCursor::setInfoForSigReturn() { -#if defined(_LIBUNWIND_TARGET_X86_64) - addr_t signal_handler = - (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] + - (addr_t)__gCommPageAddress); - addr_t signal_handler_ret = signal_handler + 45; -#endif - pint_t pc = static_cast(this->getReg(UNW_REG_IP)); - if (pc == signal_handler_ret) { -_info = {}; -_info.start_ip = signal_handler; -_info.end_ip = signal_handler_ret; -_isSigReturn = true; -return true; - } - return false; -} - -template -int UnwindCursor::stepThroughSigReturn() { - _isSignalFrame = true; - pint_t sp = _registers.getSP(); -#if defined(_LIBUNWIND_TARGET_X86_64) - vregs *regs = (vregs *)(sp + 0x70); - - _registers.setRegister(UNW_REG_IP, regs->rip); - _registers.setRegister(UNW_REG_SP, regs->rsp); - _registers.setRegister(UNW_X86_64_RAX, regs->rax); - _registers.setRegister(UNW_X86_64_RDX, regs->rdx); - _registers.setRegister(UNW_X86_64_RCX, regs->rcx); - _registers.setRegister(UNW_X86_64_RBX, regs->rbx); - _registers.setRegister(UNW_X86_64_RSI, regs->rsi); - _registers.setRegister(UNW_X86_64_RDI, regs->rdi); - _registers.set
[clang] [Clang] Allow simpler visibility annotations when targeting win32 and mingw (PR #133699)
mstorsjo wrote: I can't really comment much on the implementation here, I would mostly leave that up to people more familiar with those bits in Clang. A little nitpickery wrt the text; it'd be clearer if it'd talk about "MSVC and mingw". Both MSVC mode and mingw mode are equally much "win32" or "windows". It's just that if you specify a triple like `x86_64-win32`, it gets expanded/normalized into `x86_64-windows-msvc` (same if you'd just do `x86_64-windows`), while `x86_64-mingw32` gets expanded into `x86_64-windows-gnu`. Then for the description of the issue, it would be less confusing if it explicitly mentions template instantiations. For simpler things, like a plain function declaration, MSVC mode and mingw mode agree about where the dllexport/import attributes should be placed. Or in practice, mingw mode accepts the attributes in a superset of the locations where msvc mode accepts them. So when reading the subject/description, I first wondered why we need two different things at all, as one place should work for both. But for explicit template instantiations there's inded a bit of conflict in how it needs to be done, and we need the two different approaches. https://github.com/llvm/llvm-project/pull/133699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] Fix signal frame unwinding (PR #135367)
https://github.com/trungnt2910 updated https://github.com/llvm/llvm-project/pull/135367 >From dd2b01926ad901836465c1aaf1bf142688cbb768 Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Fri, 11 Apr 2025 23:49:36 +1000 Subject: [PATCH] Fix signal frame unwinding The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame. --- libunwind/src/CMakeLists.txt | 16 --- libunwind/src/UnwindCursor.hpp | 227 - 2 files changed, 167 insertions(+), 76 deletions(-) diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index d69013e5dace1..70bd3a017cda7 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -118,22 +118,6 @@ if (HAIKU) add_compile_flags("-D_DEFAULT_SOURCE") add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME") - - find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS -"commpage_defs.h" -PATHS ${CMAKE_SYSTEM_INCLUDE_PATH} -PATH_SUFFIXES "/private/system" -NO_DEFAULT_PATH -REQUIRED) - - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}") - if (LIBUNWIND_TARGET_TRIPLE) -if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64") - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64") -endif() - else() -include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}") - endif() endif () string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..1c545978673b4 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -41,6 +41,14 @@ #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif +#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) +#include +#include +#include +#include +#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1 +#endif + #include "AddressSpace.hpp" #include "CompactUnwinder.hpp" #include "config.h" @@ -1015,7 +1023,7 @@ class UnwindCursor : public AbstractUnwindCursor{ template int stepThroughSigReturn(Registers &) { return UNW_STEP_END; } -#elif defined(_LIBUNWIND_TARGET_HAIKU) +#elif defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) bool setInfoForSigReturn(); int stepThroughSigReturn(); #endif @@ -2559,7 +2567,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, tbtable *TBTable, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) _isSigReturn = false; #endif @@ -2684,7 +2692,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (setInfoForSigReturn()) return; #endif @@ -2760,63 +2768,6 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) { _isSignalFrame = true; return UNW_STEP_SUCCESS; } - -#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) -#include -#include - -extern "C" { -extern void *__gCommPageAddress; -} - -template -bool UnwindCursor::setInfoForSigReturn() { -#if defined(_LIBUNWIND_TARGET_X86_64) - addr_t signal_handler = - (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] + - (addr_t)__gCommPageAddress); - addr_t signal_handler_ret = signal_handler + 45; -#endif - pint_t pc = static_cast(this->getReg(UNW_REG_IP)); - if (pc == signal_handler_ret) { -_info = {}; -_info.start_ip = signal_handler; -_info.end_ip = signal_handler_ret; -_isSigReturn = true; -return true; - } - return false; -} - -template -int UnwindCursor::stepThroughSigReturn() { - _isSignalFrame = true; - pint_t sp = _registers.getSP(); -#if defined(_LIBUNWIND_TARGET_X86_64) - vregs *regs = (vregs *)(sp + 0x70); - - _registers.setRegister(UNW_REG_IP, regs->rip); - _registers.setRegister(UNW_REG_SP, regs->rsp); - _registers.setRegister(UNW_X86_64_RAX, regs->rax); - _registers.setRegister(UNW_X86_64_RDX, regs->rdx); - _registers.setRegister(UNW_X86_64_RCX, regs->rcx); - _registers.setRegister(UNW_X86_64_RBX, regs->rbx); - _registers.setRegister(UNW_X86_64_RSI, regs->rsi); - _registers.setRegister(UNW_X86_64_RDI, regs->rdi); - _registers.setRegister(UNW_X86_64_RBP, regs->rbp); - _regist
[libunwind] Fix signal frame unwinding (PR #135367)
https://github.com/trungnt2910 updated https://github.com/llvm/llvm-project/pull/135367 >From 06e16ff58a908d6fd47a264f95f4b53eb6ad51a5 Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Fri, 11 Apr 2025 23:50:16 +1000 Subject: [PATCH] Fix signal frame unwinding The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame. --- libunwind/src/CMakeLists.txt | 16 --- libunwind/src/UnwindCursor.hpp | 227 - 2 files changed, 167 insertions(+), 76 deletions(-) diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index d69013e5dace1..70bd3a017cda7 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -118,22 +118,6 @@ if (HAIKU) add_compile_flags("-D_DEFAULT_SOURCE") add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME") - - find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS -"commpage_defs.h" -PATHS ${CMAKE_SYSTEM_INCLUDE_PATH} -PATH_SUFFIXES "/private/system" -NO_DEFAULT_PATH -REQUIRED) - - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}") - if (LIBUNWIND_TARGET_TRIPLE) -if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64") - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64") -endif() - else() -include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}") - endif() endif () string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..1c545978673b4 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -41,6 +41,14 @@ #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif +#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) +#include +#include +#include +#include +#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1 +#endif + #include "AddressSpace.hpp" #include "CompactUnwinder.hpp" #include "config.h" @@ -1015,7 +1023,7 @@ class UnwindCursor : public AbstractUnwindCursor{ template int stepThroughSigReturn(Registers &) { return UNW_STEP_END; } -#elif defined(_LIBUNWIND_TARGET_HAIKU) +#elif defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) bool setInfoForSigReturn(); int stepThroughSigReturn(); #endif @@ -2559,7 +2567,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, tbtable *TBTable, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) _isSigReturn = false; #endif @@ -2684,7 +2692,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (setInfoForSigReturn()) return; #endif @@ -2760,63 +2768,6 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) { _isSignalFrame = true; return UNW_STEP_SUCCESS; } - -#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) -#include -#include - -extern "C" { -extern void *__gCommPageAddress; -} - -template -bool UnwindCursor::setInfoForSigReturn() { -#if defined(_LIBUNWIND_TARGET_X86_64) - addr_t signal_handler = - (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] + - (addr_t)__gCommPageAddress); - addr_t signal_handler_ret = signal_handler + 45; -#endif - pint_t pc = static_cast(this->getReg(UNW_REG_IP)); - if (pc == signal_handler_ret) { -_info = {}; -_info.start_ip = signal_handler; -_info.end_ip = signal_handler_ret; -_isSigReturn = true; -return true; - } - return false; -} - -template -int UnwindCursor::stepThroughSigReturn() { - _isSignalFrame = true; - pint_t sp = _registers.getSP(); -#if defined(_LIBUNWIND_TARGET_X86_64) - vregs *regs = (vregs *)(sp + 0x70); - - _registers.setRegister(UNW_REG_IP, regs->rip); - _registers.setRegister(UNW_REG_SP, regs->rsp); - _registers.setRegister(UNW_X86_64_RAX, regs->rax); - _registers.setRegister(UNW_X86_64_RDX, regs->rdx); - _registers.setRegister(UNW_X86_64_RCX, regs->rcx); - _registers.setRegister(UNW_X86_64_RBX, regs->rbx); - _registers.setRegister(UNW_X86_64_RSI, regs->rsi); - _registers.setRegister(UNW_X86_64_RDI, regs->rdi); - _registers.setRegister(UNW_X86_64_RBP, regs->rbp); - _regist
[libunwind] Fix signal frame unwinding (PR #135367)
https://github.com/trungnt2910 updated https://github.com/llvm/llvm-project/pull/135367 >From 116b60a6740831b1376377e33762faf53305f6c2 Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Fri, 11 Apr 2025 23:53:14 +1000 Subject: [PATCH] Fix signal frame unwinding The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame. --- libunwind/src/CMakeLists.txt | 16 --- libunwind/src/UnwindCursor.hpp | 227 - 2 files changed, 167 insertions(+), 76 deletions(-) diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index d69013e5dace1..70bd3a017cda7 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -118,22 +118,6 @@ if (HAIKU) add_compile_flags("-D_DEFAULT_SOURCE") add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME") - - find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS -"commpage_defs.h" -PATHS ${CMAKE_SYSTEM_INCLUDE_PATH} -PATH_SUFFIXES "/private/system" -NO_DEFAULT_PATH -REQUIRED) - - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}") - if (LIBUNWIND_TARGET_TRIPLE) -if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64") - include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64") -endif() - else() -include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}") - endif() endif () string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}") diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..1c545978673b4 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -41,6 +41,14 @@ #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif +#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) +#include +#include +#include +#include +#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1 +#endif + #include "AddressSpace.hpp" #include "CompactUnwinder.hpp" #include "config.h" @@ -1015,7 +1023,7 @@ class UnwindCursor : public AbstractUnwindCursor{ template int stepThroughSigReturn(Registers &) { return UNW_STEP_END; } -#elif defined(_LIBUNWIND_TARGET_HAIKU) +#elif defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) bool setInfoForSigReturn(); int stepThroughSigReturn(); #endif @@ -2559,7 +2567,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, tbtable *TBTable, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) _isSigReturn = false; #endif @@ -2684,7 +2692,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \ -defined(_LIBUNWIND_TARGET_HAIKU) +defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN) if (setInfoForSigReturn()) return; #endif @@ -2760,63 +2768,6 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) { _isSignalFrame = true; return UNW_STEP_SUCCESS; } - -#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64) -#include -#include - -extern "C" { -extern void *__gCommPageAddress; -} - -template -bool UnwindCursor::setInfoForSigReturn() { -#if defined(_LIBUNWIND_TARGET_X86_64) - addr_t signal_handler = - (((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] + - (addr_t)__gCommPageAddress); - addr_t signal_handler_ret = signal_handler + 45; -#endif - pint_t pc = static_cast(this->getReg(UNW_REG_IP)); - if (pc == signal_handler_ret) { -_info = {}; -_info.start_ip = signal_handler; -_info.end_ip = signal_handler_ret; -_isSigReturn = true; -return true; - } - return false; -} - -template -int UnwindCursor::stepThroughSigReturn() { - _isSignalFrame = true; - pint_t sp = _registers.getSP(); -#if defined(_LIBUNWIND_TARGET_X86_64) - vregs *regs = (vregs *)(sp + 0x70); - - _registers.setRegister(UNW_REG_IP, regs->rip); - _registers.setRegister(UNW_REG_SP, regs->rsp); - _registers.setRegister(UNW_X86_64_RAX, regs->rax); - _registers.setRegister(UNW_X86_64_RDX, regs->rdx); - _registers.setRegister(UNW_X86_64_RCX, regs->rcx); - _registers.setRegister(UNW_X86_64_RBX, regs->rbx); - _registers.setRegister(UNW_X86_64_RSI, regs->rsi); - _registers.setRegister(UNW_X86_64_RDI, regs->rdi); - _registers.setRegister(UNW_X86_64_RBP, regs->rbp); - _regist
[clang] [Driver] Teach Barmetal toolchain about GCC installation (PR #121829)
@@ -110,20 +110,81 @@ static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) { return std::string(SysRootDir); } +static bool hasGCCToolChainAlongSideClang(const Driver &D) { smithp35 wrote: IIUC this is when we have something like clang copied into a GNU installation bin directory or another directory at the same level. So that `bin\clang\..\\lib\crt0.o` One minor concern is that almost any toolchain will have a `crt0.o` although in the current bare-metal driver they are most likely in `clang-runtimes` so won't clash with the location. I'm wondering if there's a common file that is really GCC specific so we can avoid inferring a GNU toolchain by mistake. We could decide that this is unlikely, or make it a requirment that non GNU based bare-metal toolchains just avoid this. If that's the case could we document this? I'll leave a separate comment surrounding documentation. https://github.com/llvm/llvm-project/pull/121829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -907,6 +907,48 @@ let SMETargetGuard = "sme-f16f16" in { } + +// SME2 - TMOP, SUTMOP, USTMOP + +multiclass USTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2x[i", t, MergeNone, "aarch64_sme_ustmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +multiclass SUTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2u[i", t, MergeNone, "aarch64_sme_sutmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +let SMETargetGuard = "sme2,sme-tmop" in { + def SVTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "hbf", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVSTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "cs", MergeNone, "aarch64_sme_stmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVUTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "UcUs", MergeNone, "aarch64_sme_utmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + + defm SVSUTMOPA_S : SUTMOP<"za32", "c", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + defm SVUSTMOPA_S : USTMOP<"za32", "Uc", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; Lukacma wrote: I think multiclasses are unnecessary and you can just define intrinsics record here. Also for consistency it is probably good idea to stick to either SInst or Inst. https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -907,6 +907,48 @@ let SMETargetGuard = "sme-f16f16" in { } + +// SME2 - TMOP, SUTMOP, USTMOP + +multiclass USTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2x[i", t, MergeNone, "aarch64_sme_ustmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +multiclass SUTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2u[i", t, MergeNone, "aarch64_sme_sutmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +let SMETargetGuard = "sme2,sme-tmop" in { + def SVTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "hbf", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVSTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "cs", MergeNone, "aarch64_sme_stmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVUTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "UcUs", MergeNone, "aarch64_sme_utmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + + defm SVSUTMOPA_S : SUTMOP<"za32", "c", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + defm SVUSTMOPA_S : USTMOP<"za32", "Uc", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-f16f16" in { + def SVTMOPA_F16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "hb", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; Lukacma wrote: Bfloat variant needs to be guarded by sme-b16b16b not sme-f16f16 https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -907,6 +907,48 @@ let SMETargetGuard = "sme-f16f16" in { } + +// SME2 - TMOP, SUTMOP, USTMOP + +multiclass USTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2x[i", t, MergeNone, "aarch64_sme_ustmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +multiclass SUTMOP checks> { + def _ : SInst<"svtmopa_lane_" # za # "[_{d}_{3}]", +"vi2u[i", t, MergeNone, "aarch64_sme_sutmopa", +[IsStreaming, IsInOutZA], +checks>; +} + +let SMETargetGuard = "sme2,sme-tmop" in { + def SVTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "hbf", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVSTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "cs", MergeNone, "aarch64_sme_stmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + def SVUTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "UcUs", MergeNone, "aarch64_sme_utmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + + defm SVSUTMOPA_S : SUTMOP<"za32", "c", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; + defm SVUSTMOPA_S : USTMOP<"za32", "Uc", [ImmCheck<0, ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-f16f16" in { + def SVTMOPA_F16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "hb", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_1>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-b16b16" in { + def SVTMOPA_BF16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "U", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_1>, ImmCheck<4, ImmCheck0_3>]>; +} + +let SMETargetGuard = "sme2,sme-tmop,sme-f8f16" in { + def SVTMOPA_ZA16_FPM : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2.~~[i>", "m", MergeNone, "aarch64_sme_tmopa", [IsStreaming, IsInOutZA], [ImmCheck<0, ImmCheck0_1>, ImmCheck<4, ImmCheck0_3>]>; Lukacma wrote: No need to use ~ here. You can just use d https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -0,0 +1,133 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py + +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme-tmop -target-feature +sme-f16f16 -target-feature +sme-b16b16 -target-feature +sme-f8f16 -target-feature +sme-f8f32 -target-feature +sme -target-feature +sme2 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s Lukacma wrote: Probably good idea to add runlines for c++ mode similarly to other test files. https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -0,0 +1,191 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -target-feature +bf16 -target-feature +sme-f16f16 -target-feature +sme-b16b16 -verify -emit-llvm -o - %s Lukacma wrote: What is the purpose adding all these target-feature here ? https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -3107,6 +3107,23 @@ let TargetPrefix = "aarch64" in { } } + class SME_OuterProduct_TMOP_Intrinsic + : DefaultAttrsIntrinsic<[], + [llvm_i32_ty, + llvm_anyvector_ty, + LLVMMatchType<0>, + LLVMMatchType<0>, + llvm_nxv16i8_ty, + llvm_i32_ty], + [ImmArg>, ImmArg>, + IntrNoMem, IntrHasSideEffects]>; Lukacma wrote: We are no longer using IntrHasSideEffects for ZA accesses ( PR: #132058). This should have IntrInaccessibleMemOnly property instead. https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -281,6 +289,12 @@ class SME2_ZA_Tile_Vec_Multi_Single_Pat : Pat<(intrinsic imm_ty:$tile, vt:$Zn1, vt:$Zn2, vt:$Zm1, vt:$Zm2), (!cast(name # _PSEUDO) $tile, (REG_SEQUENCE ZPR2Mul2, vt:$Zn1, zsub0, vt:$Zn2, zsub1), (REG_SEQUENCE ZPR2Mul2, vt:$Zm1, zsub0, vt:$Zm2, zsub1))>; + +class SME2_ZA_TMOP_Pat +: Pat<(intrinsic tile_imm:$tile, vt:$Zn1, vt:$Zn2, vt:$Zm, (nxv16i8 ZK:$Zk), imm_ty:$idx), Lukacma wrote: ```suggestion : Pat<(intrinsic tile_imm:$tile, vt:$Zn1, vt:$Zn2, vt:$Zm, nxv16i8:$Zk, imm_ty:$idx), ``` ZK is unnecessary here https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] Revert "[clang] Improved canonicalization for template specialization types" (PR #135354)
https://github.com/slydiman closed https://github.com/llvm/llvm-project/pull/135354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cbba960 - Revert "[clang] Improved canonicalization for template specialization types" (#135354)
Author: Dmitry Vasilyev Date: 2025-04-11T17:55:11+04:00 New Revision: cbba9600ae4faeb06619ed8b52c22d8a38708230 URL: https://github.com/llvm/llvm-project/commit/cbba9600ae4faeb06619ed8b52c22d8a38708230 DIFF: https://github.com/llvm/llvm-project/commit/cbba9600ae4faeb06619ed8b52c22d8a38708230.diff LOG: Revert "[clang] Improved canonicalization for template specialization types" (#135354) Reverts llvm/llvm-project#135119 because of the assert in ASTContext.cpp, line 5619. See #135352 for details. Added: Modified: clang-tools-extra/clangd/AST.cpp clang/docs/ReleaseNotes.rst clang/include/clang/AST/ASTContext.h clang/include/clang/AST/PropertiesBase.td clang/include/clang/AST/TemplateBase.h clang/include/clang/AST/Type.h clang/include/clang/AST/TypeProperties.td clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTDiagnostic.cpp clang/lib/AST/ASTImporter.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/AST/QualTypeNames.cpp clang/lib/AST/TemplateBase.cpp clang/lib/AST/Type.cpp clang/lib/Sema/SemaCXXScopeSpec.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/TreeTransform.h clang/test/CXX/class.derived/class.derived.general/p2.cpp clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp clang/test/SemaCXX/undefined-partial-specialization.cpp clang/test/SemaTemplate/make_integer_seq.cpp clang/test/SemaTemplate/type_pack_element.cpp clang/unittests/AST/TypePrinterTest.cpp Removed: diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp index 3b991e5e9013f..66b587f00ff4a 100644 --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -439,8 +439,7 @@ QualType declaredType(const TypeDecl *D) { if (const auto *CTSD = llvm::dyn_cast(D)) if (const auto *Args = CTSD->getTemplateArgsAsWritten()) return Context.getTemplateSpecializationType( - TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(), - /*CanonicalArgs=*/std::nullopt); + TemplateName(CTSD->getSpecializedTemplate()), Args->arguments()); return Context.getTypeDeclType(D); } diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 69c7369755c67..db8dad268a8a7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -301,8 +301,6 @@ Improvements to Clang's diagnostics - Clang now better preserves the sugared types of pointers to member. - Clang now better preserves the presence of the template keyword with dependent prefixes. -- Clang now in more cases avoids printing 'type-parameter-X-X' instead of the name of - the template parameter. - Clang now respects the current language mode when printing expressions in diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also a bunch of HLSL types being printed as their C++ equivalents. diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index b8ea2af9215d2..b1e6344576eb5 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -367,6 +367,9 @@ class ASTContext : public RefCountedBase { const ASTContext&> CanonTemplateTemplateParms; + TemplateTemplateParmDecl * +getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; + /// The typedef for the __int128_t type. mutable TypedefDecl *Int128Decl = nullptr; @@ -1808,26 +1811,22 @@ class ASTContext : public RefCountedBase { bool ParameterPack, TemplateTypeParmDecl *ParmDecl = nullptr) const; - QualType getCanonicalTemplateSpecializationType( - TemplateName T, ArrayRef CanonicalArgs) const; + QualType getTemplateSpecializationType(TemplateName T, + ArrayRef Args, + QualType Canon = QualType()) const; QualType - getTemplateSpecializationType(TemplateName T, -ArrayRef SpecifiedArgs, -ArrayRef CanonicalArgs, -QualType Underlying = QualType()) const; + getCanonicalTemplateSpecializationType(TemplateName T, + ArrayRef Args) const; - QualType - getTemplateSpecializationType(TemplateName T, -ArrayRef SpecifiedArgs, -ArrayRef CanonicalArgs, -QualType Canon = QualType()) const; + QualType getTemplateSpecializationType(TemplateName T, + ArrayRef Arg
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -281,6 +289,12 @@ class SME2_ZA_Tile_Vec_Multi_Single_Pat : Pat<(intrinsic imm_ty:$tile, vt:$Zn1, vt:$Zn2, vt:$Zm1, vt:$Zm2), (!cast(name # _PSEUDO) $tile, (REG_SEQUENCE ZPR2Mul2, vt:$Zn1, zsub0, vt:$Zn2, zsub1), (REG_SEQUENCE ZPR2Mul2, vt:$Zm1, zsub0, vt:$Zm2, zsub1))>; + +class SME2_ZA_TMOP_Pat +: Pat<(intrinsic tile_imm:$tile, vt:$Zn1, vt:$Zn2, vt:$Zm, (nxv16i8 ZK:$Zk), imm_ty:$idx), Lukacma wrote: I think since $idx is always the same operand type here, we don't need to pass it as a template argument. https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Accept builtins in lambda declarations (PR #135027)
https://github.com/jmmartinez updated https://github.com/llvm/llvm-project/pull/135027 From a22e56d063e91df667d89ed5238bd886ce10bd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= Date: Wed, 9 Apr 2025 15:11:19 +0200 Subject: [PATCH] [Clang][AMDGPU] Accept builtins in lambda declarations Sema::getCurFunctionDecl(AllowLambda = false) returns a nullptr when the lambda declaration is outside a function (for example, when used in an assignment). Using Sema::getCurFunctionDecl(AllowLambda = true) returns the declaration of the enclosing lambda. --- clang/lib/Sema/SemaAMDGPU.cpp | 2 +- ...n-in-lambda-with-unsupported-attribute.hip | 34 .../test/SemaHIP/amdgpu-builtin-in-lambda.hip | 53 +++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaHIP/amdgpu-builtin-in-lambda-with-unsupported-attribute.hip create mode 100644 clang/test/SemaHIP/amdgpu-builtin-in-lambda.hip diff --git a/clang/lib/Sema/SemaAMDGPU.cpp b/clang/lib/Sema/SemaAMDGPU.cpp index 7fec099374152..a6366aceec2a6 100644 --- a/clang/lib/Sema/SemaAMDGPU.cpp +++ b/clang/lib/Sema/SemaAMDGPU.cpp @@ -27,7 +27,7 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, // position of memory order and scope arguments in the builtin unsigned OrderIndex, ScopeIndex; - const auto *FD = SemaRef.getCurFunctionDecl(); + const auto *FD = SemaRef.getCurFunctionDecl(/*AllowLambda=*/true); assert(FD && "AMDGPU builtins should not be used outside of a function"); llvm::StringMap CallerFeatureMap; getASTContext().getFunctionFeatureMap(CallerFeatureMap, FD); diff --git a/clang/test/SemaHIP/amdgpu-builtin-in-lambda-with-unsupported-attribute.hip b/clang/test/SemaHIP/amdgpu-builtin-in-lambda-with-unsupported-attribute.hip new file mode 100644 index 0..5b9223f2eaa3a --- /dev/null +++ b/clang/test/SemaHIP/amdgpu-builtin-in-lambda-with-unsupported-attribute.hip @@ -0,0 +1,34 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu tahiti -emit-llvm -fcuda-is-device -verify=no-memrealtime -o - %s +// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu gfx950 -emit-llvm -fcuda-is-device -o - %s + +#define __device__ __attribute__((device)) +#define __shared__ __attribute__((shared)) + +struct S { +static constexpr auto memrealtime_lambda = []() { +__builtin_amdgcn_s_memrealtime(); // no-memrealtime-error{{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}} +}; +}; + +__attribute__((target("s-memrealtime"))) +__device__ void test_target_dependant_builtin_attr_fail() { +S::memrealtime_lambda(); +} + +constexpr auto memrealtime_lambda = []() { +__builtin_amdgcn_s_memrealtime(); // no-memrealtime-error{{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}} +}; + +__attribute__((target("s-memrealtime"))) +__device__ void global_test_target_dependant_builtin_attr_fail() { +memrealtime_lambda(); +} + +__attribute__((target("s-memrealtime"))) +__device__ void local_test_target_dependant_builtin_attr_fail() { +static constexpr auto f = []() { +__builtin_amdgcn_s_memrealtime(); // no-memrealtime-error{{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}} +}; +f(); +} diff --git a/clang/test/SemaHIP/amdgpu-builtin-in-lambda.hip b/clang/test/SemaHIP/amdgpu-builtin-in-lambda.hip new file mode 100644 index 0..8f0b14b7379d2 --- /dev/null +++ b/clang/test/SemaHIP/amdgpu-builtin-in-lambda.hip @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu gfx90a -fsyntax-only -fcuda-is-device -verify=gfx90a -o - %s +// RUN: %clang_cc1 -std=c++20 -triple amdgcn -target-cpu gfx950 -fsyntax-only -fcuda-is-device -o - %s + +#define __device__ __attribute__((device)) +#define __shared__ __attribute__((shared)) + +struct S { +static constexpr auto make_buffer_rsrc_lambda = [](void *p, short stride, int num, int flags) { +return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); +}; + +static constexpr auto global_load_lds_lambda = [](void* src, __shared__ void *dst) { +__builtin_amdgcn_global_load_lds(src, dst, 16, 0, 0); // gfx90a-error{{invalid size value}} gfx90a-note{{size must be 1, 2, or 4}} +}; +}; + +__device__ __amdgpu_buffer_rsrc_t test_simple_builtin(void *p, short stride, int num, int flags) { +return S::make_buffer_rsrc_lambda(p, stride, num, flags); +} + +__device__ void test_target_dependant_builtin(void *src, __shared__ void *dst) { +S::global_load_lds_lambda(src, dst); +} + +constexpr auto make_buffer_rsrc_lambda = [](void *p, short stride, int num, int flags) { +return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); +}; + +constexpr auto global_load_lds_lambda = [](void* src, __shared__ void *dst) { +__builtin_amdgcn_global_load_lds(src, dst, 16, 0, 0); // gfx90a-error
[clang] [C23] Fix failed assertions with invalid #embed parameters (PR #135368)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes If the invalid parameter was not the last parameter given, we would fail to skip to the end of the directive and trip a failed assertion. Fixes #126940 --- Full diff: https://github.com/llvm/llvm-project/pull/135368.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+2) - (modified) clang/lib/Lex/PPDirectives.cpp (+3-1) - (modified) clang/test/Preprocessor/embed_parameter_unrecognized.c (+9-1) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 69c7369755c67..11f62bc881b03 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -170,6 +170,8 @@ C23 Feature Support scope. - Fixed a bug where you could not cast a null pointer constant to type ``nullptr_t``. Fixes #GH133644. +- Fixed a failed assertion with an invalid parameter to the ``#embed`` + directive. Fixes #GH126940. C11 Feature Support ^^^ diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index d97a6e8d64f9c..dfdba6bd09fd8 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -3897,7 +3897,9 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) { return std::nullopt; } if (!ForHasEmbed) { -Diag(CurTok, diag::err_pp_unknown_parameter) << 1 << Parameter; +Diag(ParamStartLoc, diag::err_pp_unknown_parameter) << 1 << Parameter; +if (CurTok.isNot(tok::eod)) + DiscardUntilEndOfDirective(CurTok); return std::nullopt; } } diff --git a/clang/test/Preprocessor/embed_parameter_unrecognized.c b/clang/test/Preprocessor/embed_parameter_unrecognized.c index b03384341a00a..c6fef941b7b88 100644 --- a/clang/test/Preprocessor/embed_parameter_unrecognized.c +++ b/clang/test/Preprocessor/embed_parameter_unrecognized.c @@ -1,5 +1,4 @@ // RUN: %clang_cc1 %s -std=c23 -E -verify -// okay-no-diagnostics #embed __FILE__ unrecognized // expected-error@-1 {{unknown embed preprocessor parameter 'unrecognized'}} @@ -7,3 +6,12 @@ // expected-error@-1 {{unknown embed preprocessor parameter 'unrecognized::param'}} #embed __FILE__ unrecognized::param(with, args) // expected-error@-1 {{unknown embed preprocessor parameter 'unrecognized::param'}} + +// The first of these two cases was causing a failed assertion due to not being +// at the end of the directive when we finished skipping past `bla`. +#embed __FILE__ bla(2) limit(2) // expected-error {{unknown embed preprocessor parameter 'bla'}} +#embed __FILE__ limit(2) bla(2) // expected-error {{unknown embed preprocessor parameter 'bla'}} + +// We intentionally only tell you about one invalid parameter at a time so that +// we can skip over invalid token soup. +#embed __FILE__ bla(2) limit(2) bork // expected-error {{unknown embed preprocessor parameter 'bla'}} `` https://github.com/llvm/llvm-project/pull/135368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Accept builtins in lambda declarations (PR #135027)
jmmartinez wrote: > IIRC there were bugs when you try to use lambda in conjunction with the > target attribute. Can you add a test where you try to use a builtin that > depends on a subtarget feature, in a function marked with the target > attribute (and not available in the main compile target), that we still error? I've added a separate test for this (the error is not triggered with -fsyntax-only but it is with -emit-llvm). I've also added tests for local variables inside a function. https://github.com/llvm/llvm-project/pull/135027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][OpenMP][ROCM] Enable rocm-device-lib-path for flang (PR #135307)
https://github.com/agozillon closed https://github.com/llvm/llvm-project/pull/135307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 39f1190 - [Flang][OpenMP][ROCM] Enable rocm-device-lib-path for flang (#135307)
Author: agozillon Date: 2025-04-11T15:57:30+02:00 New Revision: 39f119086f115e2af79ebb187a647ea2efad2d5c URL: https://github.com/llvm/llvm-project/commit/39f119086f115e2af79ebb187a647ea2efad2d5c DIFF: https://github.com/llvm/llvm-project/commit/39f119086f115e2af79ebb187a647ea2efad2d5c.diff LOG: [Flang][OpenMP][ROCM] Enable rocm-device-lib-path for flang (#135307) Currently rocm-device-lib-path is not enabled for Flang, so when the compiler warns / requests a user to provide this option in cases where it can't find rocm a user cannot actually set the device libraries using rocm-device-lib-path. The alternative rocm_path that's also mentioned via the warning can be used, but we should enable both mentioned options to not confuse users (and myself). Added: Modified: clang/include/clang/Driver/Options.td flang/test/Driver/omp-driver-offload.f90 Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 49c2ff4cb91ce..c1020b234b136 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1341,8 +1341,8 @@ def hipstdpar_prim_path_EQ : Joined<["--"], "hipstdpar-prim-path=">, HelpText< "rocPrim path, required by the HIP Standard Parallel Algorithm " "Acceleration library, used to implicitly include the rocPrim library">; -def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group, - HelpText<"ROCm device library path. Alternative to rocm-path.">; +def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Visibility<[FlangOption]>, + Group, HelpText<"ROCm device library path. Alternative to rocm-path.">; def : Joined<["--"], "hip-device-lib-path=">, Alias; def hip_device_lib_EQ : Joined<["--"], "hip-device-lib=">, Group, HelpText<"HIP device library">; diff --git a/flang/test/Driver/omp-driver-offload.f90 b/flang/test/Driver/omp-driver-offload.f90 index a6e3b87a605d5..335bfad4b1884 100644 --- a/flang/test/Driver/omp-driver-offload.f90 +++ b/flang/test/Driver/omp-driver-offload.f90 @@ -181,6 +181,11 @@ ! RUN: | FileCheck --check-prefix=ROCM-PATH %s ! ROCM-PATH: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd +! RUN: %flang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx900 \ +! RUN: --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s 2>&1 | \ +! RUN: FileCheck %s --check-prefix=ROCM-DEVICE-LIB +! ROCM-DEVICE-LIB: "-fc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_off.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_900.bc" + ! Test -fopenmp-force-usm option without offload ! RUN: %flang -S -### %s -o %t 2>&1 \ ! RUN: -fopenmp -fopenmp-force-usm \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reject character devices in #embed for now (PR #135370)
https://github.com/Fznamznon created https://github.com/llvm/llvm-project/pull/135370 See https://github.com/llvm/llvm-project/issues/126629 . Right not they are not supported properly and support requires modifying several layers of LLVM. For now simply reject them while proper support is being developed to avoid potential security problems. >From 49e347a73709661fcf3a4805f38cfa2d78e3a196 Mon Sep 17 00:00:00 2001 From: "Podchishchaeva, Mariya" Date: Fri, 11 Apr 2025 06:46:00 -0700 Subject: [PATCH] [clang] Reject character devices in #embed for now See https://github.com/llvm/llvm-project/issues/126629 . Right not they are not supported properly and support requires modifying several layers of LLVM. For now simply reject them while proper support is being developed to avoid potential security problems. --- clang/include/clang/Basic/DiagnosticLexKinds.td | 2 ++ clang/include/clang/Basic/FileEntry.h | 6 ++ clang/lib/Basic/FileManager.cpp | 2 ++ clang/lib/Lex/PPDirectives.cpp | 6 ++ 4 files changed, 16 insertions(+) diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index 912b8bd46e194..f29edfa835d42 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -458,6 +458,8 @@ def warn_compat_pp_embed_directive : Warning< InGroup, DefaultIgnore; def err_pp_embed_dup_params : Error< "cannot specify parameter '%0' twice in the same '#embed' directive">; +def err_pp_embed_device_file : Error< + "device files are not yet supported by '#embed' directive">; def ext_pp_extra_tokens_at_eol : ExtWarn< "extra tokens at end of #%0 directive">, InGroup; diff --git a/clang/include/clang/Basic/FileEntry.h b/clang/include/clang/Basic/FileEntry.h index da5ba90974293..c973ba38bdf7e 100644 --- a/clang/include/clang/Basic/FileEntry.h +++ b/clang/include/clang/Basic/FileEntry.h @@ -82,6 +82,7 @@ class FileEntryRef { inline const llvm::sys::fs::UniqueID &getUniqueID() const; inline time_t getModificationTime() const; inline bool isNamedPipe() const; + inline bool isDeviceFile() const; inline void closeFile() const; /// Check if the underlying FileEntry is the same, intentially ignoring @@ -316,6 +317,7 @@ class FileEntry { llvm::sys::fs::UniqueID UniqueID; unsigned UID = 0; // A unique (small) ID for the file. bool IsNamedPipe = false; + bool IsDeviceFile = false; /// The open file, if it is owned by the \p FileEntry. mutable std::unique_ptr File; @@ -340,6 +342,7 @@ class FileEntry { /// Check whether the file is a named pipe (and thus can't be opened by /// the native FileManager methods). bool isNamedPipe() const { return IsNamedPipe; } + bool isDeviceFile() const { return IsDeviceFile; } void closeFile() const; }; @@ -357,6 +360,9 @@ time_t FileEntryRef::getModificationTime() const { } bool FileEntryRef::isNamedPipe() const { return getFileEntry().isNamedPipe(); } +bool FileEntryRef::isDeviceFile() const { + return getFileEntry().isDeviceFile(); +} void FileEntryRef::closeFile() const { getFileEntry().closeFile(); } diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index ec84aad72e6be..86fe352df0461 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -330,6 +330,8 @@ llvm::Expected FileManager::getFileRef(StringRef Filename, UFE->UID = NextFileUID++; UFE->UniqueID = Status.getUniqueID(); UFE->IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file; + UFE->IsDeviceFile = + Status.getType() == llvm::sys::fs::file_type::character_file; UFE->File = std::move(F); if (UFE->File) { diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index d97a6e8d64f9c..318b8fdad2e04 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -4010,6 +4010,12 @@ void Preprocessor::HandleEmbedDirective(SourceLocation HashLoc, Token &EmbedTok, Diag(FilenameTok, diag::err_pp_file_not_found) << Filename; return; } + + if (MaybeFileRef->isDeviceFile()) { +Diag(FilenameTok, diag::err_pp_embed_device_file) << Filename; +return; + } + std::optional MaybeFile = getSourceManager().getMemoryBufferForFileOrNone(*MaybeFileRef); if (!MaybeFile) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reject character devices in #embed for now (PR #135370)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Mariya Podchishchaeva (Fznamznon) Changes See https://github.com/llvm/llvm-project/issues/126629 . Right not they are not supported properly and support requires modifying several layers of LLVM. For now simply reject them while proper support is being developed to avoid potential security problems. --- Full diff: https://github.com/llvm/llvm-project/pull/135370.diff 4 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (+2) - (modified) clang/include/clang/Basic/FileEntry.h (+6) - (modified) clang/lib/Basic/FileManager.cpp (+2) - (modified) clang/lib/Lex/PPDirectives.cpp (+6) ``diff diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index 912b8bd46e194..f29edfa835d42 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -458,6 +458,8 @@ def warn_compat_pp_embed_directive : Warning< InGroup, DefaultIgnore; def err_pp_embed_dup_params : Error< "cannot specify parameter '%0' twice in the same '#embed' directive">; +def err_pp_embed_device_file : Error< + "device files are not yet supported by '#embed' directive">; def ext_pp_extra_tokens_at_eol : ExtWarn< "extra tokens at end of #%0 directive">, InGroup; diff --git a/clang/include/clang/Basic/FileEntry.h b/clang/include/clang/Basic/FileEntry.h index da5ba90974293..c973ba38bdf7e 100644 --- a/clang/include/clang/Basic/FileEntry.h +++ b/clang/include/clang/Basic/FileEntry.h @@ -82,6 +82,7 @@ class FileEntryRef { inline const llvm::sys::fs::UniqueID &getUniqueID() const; inline time_t getModificationTime() const; inline bool isNamedPipe() const; + inline bool isDeviceFile() const; inline void closeFile() const; /// Check if the underlying FileEntry is the same, intentially ignoring @@ -316,6 +317,7 @@ class FileEntry { llvm::sys::fs::UniqueID UniqueID; unsigned UID = 0; // A unique (small) ID for the file. bool IsNamedPipe = false; + bool IsDeviceFile = false; /// The open file, if it is owned by the \p FileEntry. mutable std::unique_ptr File; @@ -340,6 +342,7 @@ class FileEntry { /// Check whether the file is a named pipe (and thus can't be opened by /// the native FileManager methods). bool isNamedPipe() const { return IsNamedPipe; } + bool isDeviceFile() const { return IsDeviceFile; } void closeFile() const; }; @@ -357,6 +360,9 @@ time_t FileEntryRef::getModificationTime() const { } bool FileEntryRef::isNamedPipe() const { return getFileEntry().isNamedPipe(); } +bool FileEntryRef::isDeviceFile() const { + return getFileEntry().isDeviceFile(); +} void FileEntryRef::closeFile() const { getFileEntry().closeFile(); } diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index ec84aad72e6be..86fe352df0461 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -330,6 +330,8 @@ llvm::Expected FileManager::getFileRef(StringRef Filename, UFE->UID = NextFileUID++; UFE->UniqueID = Status.getUniqueID(); UFE->IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file; + UFE->IsDeviceFile = + Status.getType() == llvm::sys::fs::file_type::character_file; UFE->File = std::move(F); if (UFE->File) { diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index d97a6e8d64f9c..318b8fdad2e04 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -4010,6 +4010,12 @@ void Preprocessor::HandleEmbedDirective(SourceLocation HashLoc, Token &EmbedTok, Diag(FilenameTok, diag::err_pp_file_not_found) << Filename; return; } + + if (MaybeFileRef->isDeviceFile()) { +Diag(FilenameTok, diag::err_pp_embed_device_file) << Filename; +return; + } + std::optional MaybeFile = getSourceManager().getMemoryBufferForFileOrNone(*MaybeFileRef); if (!MaybeFile) { `` https://github.com/llvm/llvm-project/pull/135370 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)
@@ -0,0 +1,191 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -target-feature +bf16 -target-feature +sme-f16f16 -target-feature +sme-b16b16 -verify -emit-llvm -o - %s + +// REQUIRES: aarch64-registered-target + +#include + +void test_features() __arm_streaming __arm_inout("za") { +svuint8x2_t zn_u8; +svint8x2_t zn_s8; +svuint8_t zm_u8; +svint8_t zm_s8; +svuint16x2_t zn_u16; +svint16x2_t zn_s16; +svuint16_t zm_u16; +svint16_t zm_s16; +svbfloat16x2_t zn_bf16; +svfloat16x2_t zn_f16; +svbfloat16_t zm_bf16; +svfloat16_t zm_f16; +svfloat32x2_t zn_f32; +svfloat32_t zm_f32; +svmfloat8x2_t zn_f8; +svmfloat8_t zm_f8; +fpm_t fpm = 0; +svuint8_t zk; + +// expected-error@+1 {{'svtmopa_lane_za32_s8_s8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_s8_s8(0, zn_s8, zm_s8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_u8_u8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_u8_u8(0, zn_u8, zm_u8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_s8_u8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_s8_u8(0, zn_s8, zm_u8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_u8_s8' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_u8_s8(0, zn_u8, zm_s8, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_s16_s16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_s16_s16(0, zn_s16, zm_s16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_u16_u16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_u16_u16(0, zn_u16, zm_u16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_f16_f16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_f16_f16(0, zn_f16, zm_f16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_f32_f32' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_f32_f32(0, zn_f32, zm_f32, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za32_bf16_bf16' needs target feature sme,sme2,sme-tmop}} +svtmopa_lane_za32_bf16_bf16(0, zn_bf16, zm_bf16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za16_f16_f16' needs target feature sme,sme2,sme-tmop,sme-f16f16}} +svtmopa_lane_za16_f16_f16(0, zn_f16, zm_f16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za16_bf16_bf16' needs target feature sme,sme2,sme-tmop,sme-f16f16}} +svtmopa_lane_za16_bf16_bf16(0, zn_bf16, zm_bf16, zk, 0); +// expected-error@+1 {{'svtmopa_lane_za16_mf8_mf8_fpm' needs target feature sme,sme2,sme-tmop,sme-f8f16}} +svtmopa_lane_za16_mf8_mf8_fpm(0, zn_f8, zm_f8, zk, 0, fpm); +// expected-error@+1 {{'svtmopa_lane_za32_mf8_mf8_fpm' needs target feature sme,sme2,sme-tmop,sme-f8f32}} +svtmopa_lane_za32_mf8_mf8_fpm(0, zn_f8, zm_f8, zk, 0, fpm); +} + +void test_imm() __arm_streaming __arm_inout("za") { +svuint8x2_t zn_u8; +svint8x2_t zn_s8; +svuint8_t zm_u8; +svint8_t zm_s8; +svuint16x2_t zn_u16; +svint16x2_t zn_s16; +svuint16_t zm_u16; +svint16_t zm_s16; +svbfloat16x2_t zn_bf16; +svfloat16x2_t zn_f16; +svbfloat16_t zm_bf16; +svfloat16_t zm_f16; +svfloat32x2_t zn_f32; +svfloat32_t zm_f32; +svmfloat8x2_t zn_f8; +svmfloat8_t zm_f8; +fpm_t fpm; +svuint8_t zk; + +// expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} Lukacma wrote: You can leave it be for this patch, but there is no point to test both lower and upper bounds here as correct range can be checked from error message https://github.com/llvm/llvm-project/pull/135145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C23] Fix failed assertions with invalid #embed parameters (PR #135368)
https://github.com/Fznamznon approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/135368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream binary assignments and comma (PR #135115)
https://github.com/mmha updated https://github.com/llvm/llvm-project/pull/135115 >From bcaeadf7fff01d2d92b0d234b40f8d5884974e4c Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Thu, 10 Apr 2025 03:53:43 +0200 Subject: [PATCH 1/3] [CIR] Upstream binary assignments and comma This patch adds `VisitBinAssign` and `VisitBinComma` to the ClangIR `ScalarExprEmitter` to enable assignments and the comma operator. --- clang/include/clang/CIR/MissingFeatures.h | 1 + clang/lib/CIR/CodeGen/CIRGenDecl.cpp | 8 +++ clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 7 +++ clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 60 ++ clang/lib/CIR/CodeGen/CIRGenFunction.h | 8 +++ clang/test/CIR/CodeGen/binassign.c | 56 clang/test/CIR/CodeGen/comma.c | 53 +++ clang/test/CIR/IR/binassign.cir| 45 8 files changed, 238 insertions(+) create mode 100644 clang/test/CIR/CodeGen/binassign.c create mode 100644 clang/test/CIR/CodeGen/comma.c create mode 100644 clang/test/CIR/IR/binassign.cir diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index 3188429ea3b1b..19cd9c03635b3 100644 --- a/clang/include/clang/CIR/MissingFeatures.h +++ b/clang/include/clang/CIR/MissingFeatures.h @@ -113,6 +113,7 @@ struct MissingFeatures { static bool incrementProfileCounter() { return false; } static bool insertBuiltinUnpredictable() { return false; } static bool objCGC() { return false; } + static bool bitfields() { return false; } // Missing types static bool dataMemberType() { return false; } diff --git a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp index b8e72f299acb6..58797c5dd253a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenDecl.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenDecl.cpp @@ -277,3 +277,11 @@ void CIRGenFunction::emitDecl(const Decl &d) { cgm.errorNYI(d.getSourceRange(), "emitDecl: unhandled decl type"); } } + +void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, + SourceLocation loc) { + if (!sanOpts.has(SanitizerKind::NullabilityAssign)) +return; + + assert(!cir::MissingFeatures::sanitizers()); +} diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 4b6652ad0b9e6..66caea26c3636 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -219,6 +219,13 @@ void CIRGenFunction::emitStoreOfScalar(mlir::Value value, Address addr, assert(!cir::MissingFeatures::opTBAA()); } +void CIRGenFunction::emitStoreThroughBitfieldLValue(RValue src, LValue dst, +mlir::Value &result) { + assert(!cir::MissingFeatures::bitfields()); + cgm.errorNYI("bitfields"); + result = {}; +} + mlir::Value CIRGenFunction::emitToMemory(mlir::Value value, QualType ty) { // Bool has a different representation in memory than in registers, // but in ClangIR, it is simply represented as a cir.bool value. diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 4042f5dc23e4b..955082047bd38 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -21,6 +21,7 @@ #include "mlir/IR/Value.h" #include +#include using namespace clang; using namespace clang::CIRGen; @@ -807,6 +808,65 @@ class ScalarExprEmitter : public StmtVisitor { VISITCOMP(EQ) VISITCOMP(NE) #undef VISITCOMP + + mlir::Value VisitBinAssign(const BinaryOperator *e) { +const bool ignore = std::exchange(ignoreResultAssign, false); + +mlir::Value rhs; +LValue lhs; + +switch (e->getLHS()->getType().getObjCLifetime()) { +case Qualifiers::OCL_Strong: +case Qualifiers::OCL_Autoreleasing: +case Qualifiers::OCL_ExplicitNone: +case Qualifiers::OCL_Weak: + assert(!cir::MissingFeatures::objCLifetime()); + break; +case Qualifiers::OCL_None: + // __block variables need to have the rhs evaluated first, plus this + // should improve codegen just a little. + rhs = Visit(e->getRHS()); + assert(!cir::MissingFeatures::sanitizers()); + // TODO(cir): This needs to be emitCheckedLValue() once we support + // sanitizers + lhs = cgf.emitLValue(e->getLHS()); + + // Store the value into the LHS. Bit-fields are handled specially because + // the result is altered by the store, i.e., [C99 6.5.16p1] + // 'An assignment expression has the value of the left operand after the + // assignment...'. + if (lhs.isBitField()) { +cgf.emitStoreThroughBitfieldLValue(RValue::get(rhs), lhs, rhs); + } else { +cgf.emitNullabilityCheck(lhs, rhs, e->getExprLoc()); +CIRGenFunction::SourceLocRAIIObject loc{ +cgf, cgf.getLoc(e->getSourceRange())}; +cgf.emitStoreThroughLVa
[clang] [CIR] Upstream binary assignments and comma (PR #135115)
@@ -807,6 +808,65 @@ class ScalarExprEmitter : public StmtVisitor { VISITCOMP(EQ) VISITCOMP(NE) #undef VISITCOMP + + mlir::Value VisitBinAssign(const BinaryOperator *e) { +const bool ignore = std::exchange(ignoreResultAssign, false); + +mlir::Value rhs; +LValue lhs; + +switch (e->getLHS()->getType().getObjCLifetime()) { mmha wrote: Hmm, I don't know about the performance implications (I'd expect them to be insignificant) but I find your suggestion to be less readable. I still need a `case Qualifiers::OCL_None:` with an `llvm_unreachable()` to satisfy clang-tidy and it just adds more branches to the function to follow https://github.com/llvm/llvm-project/pull/135115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)
https://github.com/MillePlateaux updated https://github.com/llvm/llvm-project/pull/134465 >From 596679a60bcae58ac1c9e1b3066b21399a58f24b Mon Sep 17 00:00:00 2001 From: MillePlateaux Date: Fri, 4 Apr 2025 16:26:25 -0700 Subject: [PATCH 1/6] [llvm][Stmt]:git clang format --- clang/lib/Sema/SemaStmt.cpp | 8 1 file changed, 8 insertions(+) diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index e1b9ccc693bd5..c8354198a5614 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -717,6 +717,14 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr &MTA) { return false; } + if (const FunctionDecl *CalleeDecl = CE->getDirectCallee()) { +if (CalleeDecl->hasAttr()) { + Diag(St->getBeginLoc(), diag::err_musttail_conflicts_with_not_tail_called) + << &MTA; + return false; +} + } + if (const auto *EWC = dyn_cast(E)) { if (EWC->cleanupsHaveSideEffects()) { Diag(St->getBeginLoc(), diag::err_musttail_needs_trivial_args) << &MTA; >From 8999e0fc13b0d6f174b7e8ecdd4ce90e79f3943a Mon Sep 17 00:00:00 2001 From: MillePlateaux Date: Tue, 8 Apr 2025 01:42:02 -0700 Subject: [PATCH 2/6] Add error report --- .../clang/Basic/DiagnosticSemaKinds.td| 337 ++ 1 file changed, 187 insertions(+), 150 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1ad09aba60935..411755ddf5fd7 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12,61 +12,6 @@ let Component = "Sema" in { let CategoryName = "Semantic Issue" in { -// C++11 compatibility with C++98. -defm nonclass_type_friend : CXX11Compat<"non-class friend type %0 is">; -defm static_data_member_in_union : CXX11Compat<"static data member %0 in union is">; -defm templ_default_in_function_templ : CXX11Compat< - "default template arguments for a function template are">; -defm template_arg_extra_parens : CXX11Compat< - "parentheses around address non-type template argument are">; -defm typename_outside_of_template : CXX11Compat<"'typename' outside of a template is">; - -// C++14 compatibility with C++11 and earlier. -defm constexpr_type_definition : CXX14Compat< - "type definition in a constexpr %select{function|constructor}0 is">; -defm constexpr_local_var : CXX14Compat< - "variable declaration in a constexpr %select{function|constructor}0 is">; -defm constexpr_body_multiple_return : CXX14Compat< - "multiple return statements in constexpr function is">; -defm variable_template : CXX14Compat<"variable templates are">; - -// C++17 compatibility with C++14 and earlier. -defm decomp_decl : CXX17Compat<"decomposition declarations are">; -defm inline_variable : CXX17Compat<"inline variables are">; - -// C++20 compatibility with C++17 and earlier. -defm decomp_decl_spec : CXX20Compat< - "decomposition declaration declared " - "%plural{1:'%1'|:with '%1' specifiers}0 is">; -defm constexpr_local_var_no_init : CXX20Compat< - "uninitialized variable in a constexpr %select{function|constructor}0 is">; -defm constexpr_function_try_block : CXX20Compat< - "function try block in constexpr %select{function|constructor}0 is">; -defm constexpr_union_ctor_no_init : CXX20Compat< - "constexpr union constructor that does not initialize any member is">; -defm constexpr_ctor_missing_init : CXX20Compat< - "constexpr constructor that does not initialize all members is">; -defm adl_only_template_id : CXX20Compat< - "use of function template name with no prior declaration in function call " - "with explicit template arguments is">; -defm ctad_for_alias_templates -: CXX20Compat<"class template argument deduction for alias templates is">; - -// C++23 compatibility with C++20 and earlier. -defm constexpr_static_var : CXX23Compat< - "definition of a %select{static|thread_local}1 variable " - "in a constexpr %select{function|constructor}0 " - "is">; - -// C++26 compatibility with C++23 and earlier. -defm decomp_decl_cond : CXX26Compat<"structured binding declaration in a condition is">; - -// Compatibility warnings duplicated across multiple language versions. -foreach std = [14, 20, 23] in { - defm cxx#std#_constexpr_body_invalid_stmt : CXXCompat< -"use of this statement in a constexpr %select{function|constructor}0 is", std>; -} - def note_previous_decl : Note<"%0 declared here">; def note_entity_declared_at : Note<"%0 declared here">; def note_callee_decl : Note<"%0 declared here">; @@ -547,7 +492,7 @@ def warn_qual_return_type : Warning< InGroup, DefaultIgnore; def warn_qual_base_type : Warning< "'%0' qualifier%s1 on base class type %2 %plural{1:has|:have}1 no effect">, - InGroup, DefaultIgnore; + InGroup, DefaultIgnore; def warn_deprecated_redundant_constexpr_static_def : Warning< "out-of-line definition of constexpr static data member is redundant " @@ -578,9 +523,30 @@ def warn_
[clang] [OpenACC] Switch Clang to use the Flang 'appertainment' rules for cla… (PR #135372)
erichkeane wrote: @razvanlupusoru @clementval @jefflarkin : This is the place I discussed/promised. Note I used 'flang' for a stand-in as "after using the Acc.td file in clang", so some of those might not be perfectly accurate. BUT are ones that need discussion in some way. We can discuss the changes to OpenACC Spec via email/discussion, as it probably keeps them best organized (and perhaps 1x at a time?). As you can see, there is plenty to do/discuss :) https://github.com/llvm/llvm-project/pull/135372 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to APValue::dump(). (PR #135178)
YLChenZ wrote: > I don't think we can test `DynamicAllocLValue` like this, since we can't save > it in the `APValue` for an initialized global. You'll have to add a call to > `dump()` e.g. like: > > ```diff > diff --git i/clang/lib/AST/ExprConstant.cpp w/clang/lib/AST/ExprConstant.cpp > index d1cc722fb794..df52ff82ea2a 100644 > --- i/clang/lib/AST/ExprConstant.cpp > +++ w/clang/lib/AST/ExprConstant.cpp > @@ -17087,6 +17087,8 @@ bool Expr::EvaluateAsInitializer(APValue &Value, > const ASTContext &Ctx, > return false; > } > > +Value.dump(); > + > // At this point, any lifetime-extended temporaries are completely > // initialized. > Info.performLifetimeExtension(); > ``` > > then you can compile > > ```c++ > constexpr int *m = new int(12); > ``` > > to reproduce it. Okay, I got it. Already reproduced the crash. ``` lambda@ubuntu22:~/test$ clang++ -std=c++20 -Xclang -ast-dump -fsyntax-only DAtest.cpp LValue Base=DynamicAllocLValue, Null=0, Offset=0, HasPath=1, PathLength=0, Path=() DAtest.cpp:1:16: error: constexpr variable 'm' must be initialized by a constant expression 1 | constexpr int *m = new int(42); |^ ~~~ DAtest.cpp:1:16: note: pointer to heap-allocated object is not a constant expression DAtest.cpp:1:20: note: heap allocation performed here 1 | constexpr int *m = new int(42); |^ LValue Base=DynamicAllocLValue, Null=0, Offset=0, HasPath=1, PathLength=0, Path=() ``` https://github.com/llvm/llvm-project/pull/135178 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC][Clang] Don't check hardcode op num (PR #135375)
https://github.com/jsji created https://github.com/llvm/llvm-project/pull/135375 The num will change for any downstream customization. >From 5f3c9d4df3aa06cd34593c4f3187b6d9f389a8f3 Mon Sep 17 00:00:00 2001 From: Jinsong Ji Date: Fri, 11 Apr 2025 07:20:20 -0700 Subject: [PATCH] [NFC][Clang] Don't check hardcode op num The num will change for any downstream customization. --- clang/test/Modules/no-external-type-id.cppm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Modules/no-external-type-id.cppm b/clang/test/Modules/no-external-type-id.cppm index d067e574e72e3..2c05769e4f082 100644 --- a/clang/test/Modules/no-external-type-id.cppm +++ b/clang/test/Modules/no-external-type-id.cppm @@ -23,7 +23,7 @@ export module b; import a; export int b(); -// CHECK: https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Incoherence between TargetParser and AMDGPU.td (PR #135376)
https://github.com/jmmartinez created https://github.com/llvm/llvm-project/pull/135376 The vmem-to-lds-loads-insts feature is only available on gfx9/10. While target-parser was also enabling it for gfx6,7,8. From 90c95af57317103f399ee4059a4e4ec01ddc98de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= Date: Fri, 11 Apr 2025 15:00:44 +0200 Subject: [PATCH] [AMDGPU] Incoherence between TargetParser and AMDGPU.td The vmem-to-lds-loads-insts feature is only available on gfx9/10. While target-parser was also enabling it for gfx6,7,8. --- .../builtins-amdgcn-raw-buffer-load-lds.cl | 12 .../CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl | 9 - ...ns-amdgcn-raw-ptr-buffer-load-lds-target-error.cl | 4 llvm/lib/TargetParser/TargetParser.cpp | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl new file mode 100644 index 0..8256b61525f9d --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl @@ -0,0 +1,12 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx90a -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_raw_ptr_buffer_load_lds( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.amdgcn.raw.ptr.buffer.load.lds(ptr addrspace(8) [[RSRC:%.*]], ptr addrspace(3) [[LDS:%.*]], i32 1, i32 [[OFFSET:%.*]], i32 [[SOFFSET:%.*]], i32 2, i32 3) +// CHECK-NEXT:ret void +// +void test_amdgcn_raw_ptr_buffer_load_lds(__amdgpu_buffer_rsrc_t rsrc, __local void * lds, int offset, int soffset) { +__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, lds, 1, offset, soffset, 2, 3); +} diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl index 5e3ed9027c17a..3403b69e07e4b 100644 --- a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl @@ -170,12 +170,3 @@ v3u32 test_amdgcn_raw_ptr_buffer_load_b96_non_const_soffset(__amdgpu_buffer_rsrc v4u32 test_amdgcn_raw_ptr_buffer_load_b128_non_const_soffset(__amdgpu_buffer_rsrc_t rsrc, int offset, int soffset) { return __builtin_amdgcn_raw_buffer_load_b128(rsrc, /*offset=*/0, soffset, /*aux=*/0); } - -// CHECK-LABEL: @test_amdgcn_raw_ptr_buffer_load_lds( -// CHECK-NEXT: entry: -// CHECK-NEXT:tail call void @llvm.amdgcn.raw.ptr.buffer.load.lds(ptr addrspace(8) [[RSRC:%.*]], ptr addrspace(3) [[LDS:%.*]], i32 1, i32 [[OFFSET:%.*]], i32 [[SOFFSET:%.*]], i32 2, i32 3) -// CHECK-NEXT:ret void -// -void test_amdgcn_raw_ptr_buffer_load_lds(__amdgpu_buffer_rsrc_t rsrc, __local void * lds, int offset, int soffset) { -__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, lds, 1, offset, soffset, 2, 3); -} diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl b/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl index 768f894e9180d..74944f2d93c72 100644 --- a/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl +++ b/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl @@ -1,4 +1,8 @@ +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tahiti -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu bonaire -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu carrizo -S -verify -o - %s // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1200 -S -verify -o - %s // REQUIRES: amdgpu-registered-target void test_amdgcn_raw_ptr_buffer_load_lds(__amdgpu_buffer_rsrc_t rsrc, __local void* lds, int offset, int soffset, int x) { diff --git a/llvm/lib/TargetParser/TargetParser.cpp b/llvm/lib/TargetParser/TargetParser.cpp index f7d99ccb57507..7c54901dae47d 100644 --- a/llvm/lib/TargetParser/TargetParser.cpp +++ b/llvm/lib/TargetParser/TargetParser.cpp @@ -564,6 +564,7 @@ void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, case GK_GFX900: case GK_GFX9_GENERIC: Features["gfx9-insts"] = true; + Features["vmem-to-lds-load-insts"] = true; [[fallthrough]]; case GK_GFX810: case GK_GFX805: @@ -589,7 +590,6 @@ void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, Features["image-insts"] = true; Features["s-memtime-inst"] = true; Features["gws"] = true; - Features["vmem-to-lds-load-insts"] = true; break; case GK_NONE: break;
[clang] [llvm] [AMDGPU] vmem-to-lds-load-insts incoherence between TargetParser and AMDGPU.td (PR #135376)
https://github.com/jmmartinez edited https://github.com/llvm/llvm-project/pull/135376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] vmem-to-lds-load-insts incoherence between TargetParser and AMDGPU.td (PR #135376)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Juan Manuel Martinez Caamaño (jmmartinez) Changes The vmem-to-lds-loads-insts feature is only available on gfx9/10. While target-parser was also enabling it for gfx6,7,8. --- Full diff: https://github.com/llvm/llvm-project/pull/135376.diff 4 Files Affected: - (added) clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl (+12) - (modified) clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl (-9) - (modified) clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl (+4) - (modified) llvm/lib/TargetParser/TargetParser.cpp (+1-1) ``diff diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl new file mode 100644 index 0..8256b61525f9d --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load-lds.cl @@ -0,0 +1,12 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx90a -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_raw_ptr_buffer_load_lds( +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void @llvm.amdgcn.raw.ptr.buffer.load.lds(ptr addrspace(8) [[RSRC:%.*]], ptr addrspace(3) [[LDS:%.*]], i32 1, i32 [[OFFSET:%.*]], i32 [[SOFFSET:%.*]], i32 2, i32 3) +// CHECK-NEXT:ret void +// +void test_amdgcn_raw_ptr_buffer_load_lds(__amdgpu_buffer_rsrc_t rsrc, __local void * lds, int offset, int soffset) { +__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, lds, 1, offset, soffset, 2, 3); +} diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl index 5e3ed9027c17a..3403b69e07e4b 100644 --- a/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-raw-buffer-load.cl @@ -170,12 +170,3 @@ v3u32 test_amdgcn_raw_ptr_buffer_load_b96_non_const_soffset(__amdgpu_buffer_rsrc v4u32 test_amdgcn_raw_ptr_buffer_load_b128_non_const_soffset(__amdgpu_buffer_rsrc_t rsrc, int offset, int soffset) { return __builtin_amdgcn_raw_buffer_load_b128(rsrc, /*offset=*/0, soffset, /*aux=*/0); } - -// CHECK-LABEL: @test_amdgcn_raw_ptr_buffer_load_lds( -// CHECK-NEXT: entry: -// CHECK-NEXT:tail call void @llvm.amdgcn.raw.ptr.buffer.load.lds(ptr addrspace(8) [[RSRC:%.*]], ptr addrspace(3) [[LDS:%.*]], i32 1, i32 [[OFFSET:%.*]], i32 [[SOFFSET:%.*]], i32 2, i32 3) -// CHECK-NEXT:ret void -// -void test_amdgcn_raw_ptr_buffer_load_lds(__amdgpu_buffer_rsrc_t rsrc, __local void * lds, int offset, int soffset) { -__builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, lds, 1, offset, soffset, 2, 3); -} diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl b/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl index 768f894e9180d..74944f2d93c72 100644 --- a/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl +++ b/clang/test/SemaOpenCL/builtins-amdgcn-raw-ptr-buffer-load-lds-target-error.cl @@ -1,4 +1,8 @@ +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tahiti -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu bonaire -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu carrizo -S -verify -o - %s // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1200 -S -verify -o - %s // REQUIRES: amdgpu-registered-target void test_amdgcn_raw_ptr_buffer_load_lds(__amdgpu_buffer_rsrc_t rsrc, __local void* lds, int offset, int soffset, int x) { diff --git a/llvm/lib/TargetParser/TargetParser.cpp b/llvm/lib/TargetParser/TargetParser.cpp index f7d99ccb57507..7c54901dae47d 100644 --- a/llvm/lib/TargetParser/TargetParser.cpp +++ b/llvm/lib/TargetParser/TargetParser.cpp @@ -564,6 +564,7 @@ void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, case GK_GFX900: case GK_GFX9_GENERIC: Features["gfx9-insts"] = true; + Features["vmem-to-lds-load-insts"] = true; [[fallthrough]]; case GK_GFX810: case GK_GFX805: @@ -589,7 +590,6 @@ void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, Features["image-insts"] = true; Features["s-memtime-inst"] = true; Features["gws"] = true; - Features["vmem-to-lds-load-insts"] = true; break; case GK_NONE: break; `` https://github.com/llvm/llvm-project/pull/135376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] vmem-to-lds-load-insts incoherence between TargetParser and AMDGPU.td (PR #135376)
https://github.com/shiltian approved this pull request. https://github.com/llvm/llvm-project/pull/135376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC][Clang] Don't check hardcode op num (PR #135375)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: Jinsong Ji (jsji) Changes The num will change for any downstream customization. --- Full diff: https://github.com/llvm/llvm-project/pull/135375.diff 1 Files Affected: - (modified) clang/test/Modules/no-external-type-id.cppm (+1-1) ``diff diff --git a/clang/test/Modules/no-external-type-id.cppm b/clang/test/Modules/no-external-type-id.cppm index d067e574e72e3..2c05769e4f082 100644 --- a/clang/test/Modules/no-external-type-id.cppm +++ b/clang/test/Modules/no-external-type-id.cppm @@ -23,7 +23,7 @@ export module b; import a; export int b(); -// CHECK: https://github.com/llvm/llvm-project/pull/135375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reject character devices in #embed for now (PR #135370)
AaronBallman wrote: > I'm not sure what to say in the release note. Sorry folks, we never really > supported these but now we reject to be safe? I would say something like "the '#embed' directive now diagnoses use of a non-character file (device file) such as `/dev/urandom` as an error. This restriction may be relaxed in the future." or something along those lines. https://github.com/llvm/llvm-project/pull/135370 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] vmem-to-lds-load-insts incoherence between TargetParser and AMDGPU.td (PR #135376)
https://github.com/jmmartinez closed https://github.com/llvm/llvm-project/pull/135376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] ItaniumMangle: fix mangling for unresolved types (PR #135312)
https://github.com/mizvekov closed https://github.com/llvm/llvm-project/pull/135312 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7113aec - [clang] ItaniumMangle: fix mangling for unresolved types (#135312)
Author: Matheus Izvekov Date: 2025-04-11T11:31:26-03:00 New Revision: 7113aece4eaa634cdcea5c4057da171c17229b40 URL: https://github.com/llvm/llvm-project/commit/7113aece4eaa634cdcea5c4057da171c17229b40 DIFF: https://github.com/llvm/llvm-project/commit/7113aece4eaa634cdcea5c4057da171c17229b40.diff LOG: [clang] ItaniumMangle: fix mangling for unresolved types (#135312) Added: Modified: clang/lib/AST/ItaniumMangle.cpp clang/test/CodeGenCXX/mangle.cpp Removed: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 8790a5282a96b..c73f040ba1cb7 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -2511,7 +2511,6 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty, case Type::PackIndexing: case Type::TemplateTypeParm: case Type::UnaryTransform: - case Type::SubstTemplateTypeParm: unresolvedType: // Some callers want a prefix before the mangled type. Out << Prefix; @@ -2524,6 +2523,16 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty, // so we return directly. return true; + case Type::SubstTemplateTypeParm: { +auto *ST = cast(Ty); +// If this was replaced from a type alias, this is not substituted +// from an outer template parameter, so it's not an unresolved-type. +if (auto *TD = dyn_cast(ST->getAssociatedDecl()); +TD && TD->isTypeAlias()) + return mangleUnresolvedTypeOrSimpleId(ST->getReplacementType(), Prefix); +goto unresolvedType; + } + case Type::Typedef: mangleSourceNameWithAbiTags(cast(Ty)->getDecl()); break; diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp index cf506aff92f0e..f4dc17bc4561e 100644 --- a/clang/test/CodeGenCXX/mangle.cpp +++ b/clang/test/CodeGenCXX/mangle.cpp @@ -1220,3 +1220,30 @@ namespace test61 { // CHECK-LABEL: @_ZN6test611fINS_1XEEEvNT_1Y1aENS3_1bE template void f(int, int); } + +namespace test62 { + template struct integral_constant { +static const int value = true; + }; + template struct _OrImpl {}; + template using _Or = _OrImpl<_Args::value>; + template + void f(_Or>) {} + // CHECK-LABEL: @_ZN6test621fIiEEvNS_7_OrImplIXsr17integral_constantIT_EE5valueEEE + template void f(_OrImpl<1>); +} // namespace test62 + +namespace test63 { + namespace { +template struct integral_constant { + static const int value = true; +}; +template struct _And {}; +template struct _OrImpl {}; +template using _Or = _OrImpl<_First::value>; +template +void f(_And, _Or>>); + } // namespace + // CHECK-LABEL: @_ZN6test6312_GLOBAL__N_11fIiEEvNS0_4_AndINS0_17integral_constantIivEENS0_7_OrImplIXsr17integral_constantIT_iEE5valueE + void g() { f({}); } +} // namespace test63 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reject character devices in #embed for now (PR #135370)
Fznamznon wrote: > on Windows we could use something like COM1 on Windows. How would that look like? https://github.com/llvm/llvm-project/pull/135370 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits