[clang] [clang][bytecode] Change the way we do init chains (PR #122871)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/122871 See the comment in Compiler<>::VisitCXXThisExpr. We need to mark the InitList explicitly, so we later know what to refer to when the init chain is active. >From 7fec8f1137b7aea844400030a32d46b37b1a99e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 14 Jan 2025 09:19:27 +0100 Subject: [PATCH] [clang][bytecode] Change the way we do init chains See the comment in Compiler<>::VisitCXXThisExpr. We need to mark the InitList explicitly, so we later know what to refer to when the init chain is active. --- clang/lib/AST/ByteCode/Compiler.cpp | 44 +++-- clang/lib/AST/ByteCode/Compiler.h | 2 ++ clang/test/AST/ByteCode/records.cpp | 6 clang/test/AST/ByteCode/unions.cpp | 20 + 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 036f9608bf3ca1..b97d54ece4e598 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -90,6 +90,8 @@ bool InitLink::emit(Compiler *Ctx, const Expr *E) const { if (!Ctx->emitConstUint32(Offset, E)) return false; return Ctx->emitArrayElemPtrPopUint32(E); + case K_InitList: +return true; default: llvm_unreachable("Unhandled InitLink kind"); } @@ -1717,6 +1719,8 @@ bool Compiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) { template bool Compiler::visitInitList(ArrayRef Inits, const Expr *ArrayFiller, const Expr *E) { + InitLinkScope ILS(this, InitLink::InitList()); + QualType QT = E->getType(); if (const auto *AT = QT->getAs()) QT = AT->getValueType(); @@ -1754,6 +1758,7 @@ bool Compiler::visitInitList(ArrayRef Inits, auto initPrimitiveField = [=](const Record::Field *FieldToInit, const Expr *Init, PrimType T) -> bool { InitStackScope ISS(this, isa(Init)); + InitLinkScope ILS(this, InitLink::Field(FieldToInit->Offset)); if (!this->visit(Init)) return false; @@ -1766,6 +1771,7 @@ bool Compiler::visitInitList(ArrayRef Inits, const Expr *Init) -> bool { InitStackScope ISS(this, isa(Init)); InitLinkScope ILS(this, InitLink::Field(FieldToInit->Offset)); + // Non-primitive case. Get a pointer to the field-to-initialize // on the stack and recurse into visitInitializer(). if (!this->emitGetPtrField(FieldToInit->Offset, Init)) @@ -3812,6 +3818,7 @@ template bool Compiler::visit(const Expr *E) { if (!this->emitGetPtrLocal(*LocalIndex, E)) return false; +InitLinkScope ILS(this, InitLink::Temp(*LocalIndex)); return this->visitInitializer(E); } @@ -4848,18 +4855,49 @@ bool Compiler::VisitCXXThisExpr(const CXXThisExpr *E) { // instance pointer of the current function frame, but e.g. to the declaration // currently being initialized. Here we emit the necessary instruction(s) for // this scenario. - if (!InitStackActive || !E->isImplicit()) + if (!InitStackActive) return this->emitThis(E); - if (InitStackActive && !InitStack.empty()) { + if (!InitStack.empty()) { +// If our init stack is, for example: +// 0 Stack: 3 (decl) +// 1 Stack: 6 (init list) +// 2 Stack: 1 (field) +// 3 Stack: 6 (init list) +// 4 Stack: 1 (field) +// +// We want to find the LAST element in it that's an init list, +// which is marked with the K_InitList marker. The index right +// before that points to an init list. We need to find the +// elements before the K_InitList element that point to a base +// (e.g. a decl or This), optionally followed by field, elem, etc. +// In the example above, we want to emit elements [0..2]. unsigned StartIndex = 0; +unsigned EndIndex = 0; +// Findteh init list. for (StartIndex = InitStack.size() - 1; StartIndex > 0; --StartIndex) { + if (InitStack[StartIndex].Kind == InitLink::K_InitList || + InitStack[StartIndex].Kind == InitLink::K_This) { +EndIndex = StartIndex; +--StartIndex; +break; + } +} + +// Walk backwards to find the base. +for (; StartIndex > 0; --StartIndex) { + if (InitStack[StartIndex].Kind == InitLink::K_InitList) +continue; + if (InitStack[StartIndex].Kind != InitLink::K_Field && InitStack[StartIndex].Kind != InitLink::K_Elem) break; } -for (unsigned I = StartIndex, N = InitStack.size(); I != N; ++I) { +// Emit the instructions. +for (unsigned I = StartIndex; I != EndIndex; ++I) { + if (InitStack[I].Kind == InitLink::K_InitList) +continue; if (!InitStack[I].template emit(this, E)) return false; } diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h index 71765b18cb1a9
[clang] [clang][bytecode] Change the way we do init chains (PR #122871)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes See the comment in Compiler<>::VisitCXXThisExpr. We need to mark the InitList explicitly, so we later know what to refer to when the init chain is active. --- Full diff: https://github.com/llvm/llvm-project/pull/122871.diff 4 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+41-3) - (modified) clang/lib/AST/ByteCode/Compiler.h (+2) - (modified) clang/test/AST/ByteCode/records.cpp (+6) - (modified) clang/test/AST/ByteCode/unions.cpp (+20) ``diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 036f9608bf3ca1..b97d54ece4e598 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -90,6 +90,8 @@ bool InitLink::emit(Compiler *Ctx, const Expr *E) const { if (!Ctx->emitConstUint32(Offset, E)) return false; return Ctx->emitArrayElemPtrPopUint32(E); + case K_InitList: +return true; default: llvm_unreachable("Unhandled InitLink kind"); } @@ -1717,6 +1719,8 @@ bool Compiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) { template bool Compiler::visitInitList(ArrayRef Inits, const Expr *ArrayFiller, const Expr *E) { + InitLinkScope ILS(this, InitLink::InitList()); + QualType QT = E->getType(); if (const auto *AT = QT->getAs()) QT = AT->getValueType(); @@ -1754,6 +1758,7 @@ bool Compiler::visitInitList(ArrayRef Inits, auto initPrimitiveField = [=](const Record::Field *FieldToInit, const Expr *Init, PrimType T) -> bool { InitStackScope ISS(this, isa(Init)); + InitLinkScope ILS(this, InitLink::Field(FieldToInit->Offset)); if (!this->visit(Init)) return false; @@ -1766,6 +1771,7 @@ bool Compiler::visitInitList(ArrayRef Inits, const Expr *Init) -> bool { InitStackScope ISS(this, isa(Init)); InitLinkScope ILS(this, InitLink::Field(FieldToInit->Offset)); + // Non-primitive case. Get a pointer to the field-to-initialize // on the stack and recurse into visitInitializer(). if (!this->emitGetPtrField(FieldToInit->Offset, Init)) @@ -3812,6 +3818,7 @@ template bool Compiler::visit(const Expr *E) { if (!this->emitGetPtrLocal(*LocalIndex, E)) return false; +InitLinkScope ILS(this, InitLink::Temp(*LocalIndex)); return this->visitInitializer(E); } @@ -4848,18 +4855,49 @@ bool Compiler::VisitCXXThisExpr(const CXXThisExpr *E) { // instance pointer of the current function frame, but e.g. to the declaration // currently being initialized. Here we emit the necessary instruction(s) for // this scenario. - if (!InitStackActive || !E->isImplicit()) + if (!InitStackActive) return this->emitThis(E); - if (InitStackActive && !InitStack.empty()) { + if (!InitStack.empty()) { +// If our init stack is, for example: +// 0 Stack: 3 (decl) +// 1 Stack: 6 (init list) +// 2 Stack: 1 (field) +// 3 Stack: 6 (init list) +// 4 Stack: 1 (field) +// +// We want to find the LAST element in it that's an init list, +// which is marked with the K_InitList marker. The index right +// before that points to an init list. We need to find the +// elements before the K_InitList element that point to a base +// (e.g. a decl or This), optionally followed by field, elem, etc. +// In the example above, we want to emit elements [0..2]. unsigned StartIndex = 0; +unsigned EndIndex = 0; +// Findteh init list. for (StartIndex = InitStack.size() - 1; StartIndex > 0; --StartIndex) { + if (InitStack[StartIndex].Kind == InitLink::K_InitList || + InitStack[StartIndex].Kind == InitLink::K_This) { +EndIndex = StartIndex; +--StartIndex; +break; + } +} + +// Walk backwards to find the base. +for (; StartIndex > 0; --StartIndex) { + if (InitStack[StartIndex].Kind == InitLink::K_InitList) +continue; + if (InitStack[StartIndex].Kind != InitLink::K_Field && InitStack[StartIndex].Kind != InitLink::K_Elem) break; } -for (unsigned I = StartIndex, N = InitStack.size(); I != N; ++I) { +// Emit the instructions. +for (unsigned I = StartIndex; I != EndIndex; ++I) { + if (InitStack[I].Kind == InitLink::K_InitList) +continue; if (!InitStack[I].template emit(this, E)) return false; } diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h index 71765b18cb1a90..2d5b76f789543e 100644 --- a/clang/lib/AST/ByteCode/Compiler.h +++ b/clang/lib/AST/ByteCode/Compiler.h @@ -51,9 +51,11 @@ struct InitLink { K_Temp = 2, K_Decl = 3, K_Elem = 5, +K_InitList = 6 }; static InitLink This() { return InitLink{K_This}; } + static InitLink InitList() { return In
[clang] [clang][bytecode] Change the way we do init chains (PR #122871)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/122871 >From d1de505faaebb9f59c45a2951f106a86ed296e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 14 Jan 2025 09:19:27 +0100 Subject: [PATCH] [clang][bytecode] Change the way we do init chains See the comment in Compiler<>::VisitCXXThisExpr. We need to mark the InitList explicitly, so we later know what to refer to when the init chain is active. --- clang/lib/AST/ByteCode/Compiler.cpp | 44 +++-- clang/lib/AST/ByteCode/Compiler.h | 2 ++ clang/test/AST/ByteCode/records.cpp | 6 clang/test/AST/ByteCode/unions.cpp | 20 + 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 036f9608bf3ca1..2326480fe2eaf4 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -90,6 +90,8 @@ bool InitLink::emit(Compiler *Ctx, const Expr *E) const { if (!Ctx->emitConstUint32(Offset, E)) return false; return Ctx->emitArrayElemPtrPopUint32(E); + case K_InitList: +return true; default: llvm_unreachable("Unhandled InitLink kind"); } @@ -1717,6 +1719,8 @@ bool Compiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) { template bool Compiler::visitInitList(ArrayRef Inits, const Expr *ArrayFiller, const Expr *E) { + InitLinkScope ILS(this, InitLink::InitList()); + QualType QT = E->getType(); if (const auto *AT = QT->getAs()) QT = AT->getValueType(); @@ -1754,6 +1758,7 @@ bool Compiler::visitInitList(ArrayRef Inits, auto initPrimitiveField = [=](const Record::Field *FieldToInit, const Expr *Init, PrimType T) -> bool { InitStackScope ISS(this, isa(Init)); + InitLinkScope ILS(this, InitLink::Field(FieldToInit->Offset)); if (!this->visit(Init)) return false; @@ -1766,6 +1771,7 @@ bool Compiler::visitInitList(ArrayRef Inits, const Expr *Init) -> bool { InitStackScope ISS(this, isa(Init)); InitLinkScope ILS(this, InitLink::Field(FieldToInit->Offset)); + // Non-primitive case. Get a pointer to the field-to-initialize // on the stack and recurse into visitInitializer(). if (!this->emitGetPtrField(FieldToInit->Offset, Init)) @@ -3812,6 +3818,7 @@ template bool Compiler::visit(const Expr *E) { if (!this->emitGetPtrLocal(*LocalIndex, E)) return false; +InitLinkScope ILS(this, InitLink::Temp(*LocalIndex)); return this->visitInitializer(E); } @@ -4848,18 +4855,49 @@ bool Compiler::VisitCXXThisExpr(const CXXThisExpr *E) { // instance pointer of the current function frame, but e.g. to the declaration // currently being initialized. Here we emit the necessary instruction(s) for // this scenario. - if (!InitStackActive || !E->isImplicit()) + if (!InitStackActive) return this->emitThis(E); - if (InitStackActive && !InitStack.empty()) { + if (!InitStack.empty()) { +// If our init stack is, for example: +// 0 Stack: 3 (decl) +// 1 Stack: 6 (init list) +// 2 Stack: 1 (field) +// 3 Stack: 6 (init list) +// 4 Stack: 1 (field) +// +// We want to find the LAST element in it that's an init list, +// which is marked with the K_InitList marker. The index right +// before that points to an init list. We need to find the +// elements before the K_InitList element that point to a base +// (e.g. a decl or This), optionally followed by field, elem, etc. +// In the example above, we want to emit elements [0..2]. unsigned StartIndex = 0; +unsigned EndIndex = 0; +// Find the init list. for (StartIndex = InitStack.size() - 1; StartIndex > 0; --StartIndex) { + if (InitStack[StartIndex].Kind == InitLink::K_InitList || + InitStack[StartIndex].Kind == InitLink::K_This) { +EndIndex = StartIndex; +--StartIndex; +break; + } +} + +// Walk backwards to find the base. +for (; StartIndex > 0; --StartIndex) { + if (InitStack[StartIndex].Kind == InitLink::K_InitList) +continue; + if (InitStack[StartIndex].Kind != InitLink::K_Field && InitStack[StartIndex].Kind != InitLink::K_Elem) break; } -for (unsigned I = StartIndex, N = InitStack.size(); I != N; ++I) { +// Emit the instructions. +for (unsigned I = StartIndex; I != EndIndex; ++I) { + if (InitStack[I].Kind == InitLink::K_InitList) +continue; if (!InitStack[I].template emit(this, E)) return false; } diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h index 71765b18cb1a90..2d5b76f789543e 100644 --- a/clang/lib/AST/ByteCode/Compiler.h +++ b/clang/lib/AST/ByteCode/Compiler.h @@ -51,9 +51,11 @@ struct InitLink { K_Temp =
[clang] 6d25345 - Remove the `CustomEntry` escape hatch from builtin TableGen (#120861)
Author: Chandler Carruth Date: 2025-01-14T01:10:42-08:00 New Revision: 6d2534546582721b8d7f10963c329de0a04f0bfe URL: https://github.com/llvm/llvm-project/commit/6d2534546582721b8d7f10963c329de0a04f0bfe DIFF: https://github.com/llvm/llvm-project/commit/6d2534546582721b8d7f10963c329de0a04f0bfe.diff LOG: Remove the `CustomEntry` escape hatch from builtin TableGen (#120861) This was an especially challenging escape hatch because it directly forced the use of a specific X-macro structure and prevented any other form of TableGen emission. The problematic feature that motivated this is a case where a builtin's prototype can't be represented in the mini-language used by TableGen. Instead of adding a complete custom entry for this, this PR just teaches the prototype handling to do the same thing the X-macros did in this case: emit an empty string and let the Clang builtin handling respond appropriately. This should produce identical results while preserving all the rest of the structured representation in the builtin TableGen code. Added: Modified: clang/include/clang/Basic/Builtins.td clang/include/clang/Basic/BuiltinsBase.td clang/utils/TableGen/ClangBuiltinsEmitter.cpp Removed: diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index f4216bd01a0743..ea22690ce4f5cc 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -3347,10 +3347,12 @@ def VFork : LibBuiltin<"unistd.h"> { } // POSIX pthread.h -// FIXME: This should be a GNULibBuiltin, but it's currently missing the prototype. -def PthreadCreate : CustomEntry { - let Entry = "LIBBUILTIN(pthread_create, \"\", \"fC<2,3>\", PTHREAD_H, ALL_GNU_LANGUAGES)"; +def PthreadCreate : GNULibBuiltin<"pthread.h"> { + let Spellings = ["pthread_create"]; + let Attributes = [FunctionWithoutBuiltinPrefix, Callback<[2, 3]>]; + // Note that we don't have an expressable prototype so we leave it empty. + let Prototype = ""; } def SigSetJmp : LibBuiltin<"setjmp.h"> { diff --git a/clang/include/clang/Basic/BuiltinsBase.td b/clang/include/clang/Basic/BuiltinsBase.td index 1a1096d41da40a..6180a94aa4b5c7 100644 --- a/clang/include/clang/Basic/BuiltinsBase.td +++ b/clang/include/clang/Basic/BuiltinsBase.td @@ -17,6 +17,11 @@ class IndexedAttribute : Attribute { int Index = I; } +class MultiIndexAttribute Is> +: Attribute { + list Indices = Is; +} + // Standard Attributes // --- def NoReturn : Attribute<"r">; @@ -77,6 +82,10 @@ def Constexpr : Attribute<"E">; // Builtin is immediate and must be constant evaluated. Implies Constexpr, and will only be supported in C++20 mode. def Consteval : Attribute<"EG">; +// Callback behavior: the first index argument is called with the arguments +// indicated by the remaining indices. +class Callback ArgIndices> : MultiIndexAttribute<"C", ArgIndices>; + // Builtin kinds // = @@ -92,10 +101,6 @@ class Builtin { bit EnableOpenCLLong = 0; } -class CustomEntry { - string Entry; -} - class AtomicBuiltin : Builtin; class LibBuiltin : Builtin { diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp index 94cc2183760026..6aca4edfdfb888 100644 --- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp +++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp @@ -11,6 +11,7 @@ //===--===// #include "TableGenBackends.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" @@ -39,6 +40,14 @@ class PrototypeParser { private: void ParsePrototype(StringRef Prototype) { Prototype = Prototype.trim(); + +// Some builtins don't have an expressible prototype, simply emit an empty +// string for them. +if (Prototype.empty()) { + Type = ""; + return; +} + ParseTypes(Prototype); } @@ -246,8 +255,15 @@ void PrintAttributes(const Record *Builtin, BuiltinType BT, raw_ostream &OS) { for (const auto *Attr : Builtin->getValueAsListOfDefs("Attributes")) { OS << Attr->getValueAsString("Mangling"); -if (Attr->isSubClassOf("IndexedAttribute")) +if (Attr->isSubClassOf("IndexedAttribute")) { OS << ':' << Attr->getValueAsInt("Index") << ':'; +} else if (Attr->isSubClassOf("MultiIndexAttribute")) { + OS << '<'; + llvm::ListSeparator Sep(","); + for (int64_t Index : Attr->getValueAsListOfInts("Indices")) +OS << Sep << Index; + OS << '>'; +} } OS << '\"'; } @@ -405,10 +421,6 @@ void clang::EmitClangBuiltins(const RecordKeeper &Records, raw_ostream &OS) { EmitBuiltin(OS, Builtin); } - for (const auto *Entry : Records.getAllDerivedDefinitions("CustomEntry")) { -OS << Entry->getValueA
[clang] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Chandler Carruth (chandlerc) Changes This switches them to use tho common TableGen layer, extending it to support the missing features needed by the NVPTX backend. The biggest thing was to build a TableGen system that computes the cumulative SM and PTX feature sets the same way the macros did. That's done with some string concatenation tricks in TableGen, but they worked out pretty neatly and are very comparable in complexity to the macro version. Then the actual defines were mapped over using a very hacky Python script. It was never productionized or intended to work in the future, but for posterity: https://gist.github.com/chandlerc/10bdf8fb1312e252b4a501bace184b66 Last but not least, there was a very odd "bug" in one of the converted builtins' prototype in the TableGen model: it didn't handle uses of `Z` and `U` both as *qualifiers* of a single type, treating `Z` as its own `int32_t` type. So my hacky Python script converted `ZUi` into two types, an `int32_t` and an `unsigned int`. This produced a very wrong prototype. But the tests caught this nicely and I fixed it manually rather than trying to improve the Python script as it occurred in exactly one place I could find. This should provide direct benefits of allowing future refactorings to more directly leverage TableGen to express builtins more structurally rather than textually. It will also make my efforts to move builtins to string tables significantly more effective for the NVPTX backend where the X-macro approach resulted in *significantly* less efficient string tables than other targets due to the long repeated feature strings. --- Patch is 121.94 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122873.diff 6 Files Affected: - (removed) clang/include/clang/Basic/BuiltinsNVPTX.def (-1116) - (added) clang/include/clang/Basic/BuiltinsNVPTX.td (+885) - (modified) clang/include/clang/Basic/CMakeLists.txt (+4) - (modified) clang/include/clang/Basic/TargetBuiltins.h (+1-1) - (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1-5) - (modified) clang/utils/TableGen/ClangBuiltinsEmitter.cpp (+37) ``diff diff --git a/clang/include/clang/Basic/BuiltinsNVPTX.def b/clang/include/clang/Basic/BuiltinsNVPTX.def deleted file mode 100644 index 969dd9e41ebfa3..00 --- a/clang/include/clang/Basic/BuiltinsNVPTX.def +++ /dev/null @@ -1,1116 +0,0 @@ -//===--- BuiltinsPTX.def - PTX Builtin function database *- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// -// -// This file defines the PTX-specific builtin function database. Users of -// this file must define the BUILTIN macro to make use of this information. -// -//===--===// - -// The format of this database matches clang/Basic/Builtins.def. - -#if defined(BUILTIN) && !defined(TARGET_BUILTIN) -# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) -#endif - -#pragma push_macro("SM_53") -#pragma push_macro("SM_70") -#pragma push_macro("SM_72") -#pragma push_macro("SM_75") -#pragma push_macro("SM_80") -#pragma push_macro("SM_86") -#pragma push_macro("SM_87") -#pragma push_macro("SM_89") -#pragma push_macro("SM_90") -#pragma push_macro("SM_90a") -#pragma push_macro("SM_100") -#define SM_100 "sm_100" -#define SM_90a "sm_90a" -#define SM_90 "sm_90|" SM_90a "|" SM_100 -#define SM_89 "sm_89|" SM_90 -#define SM_87 "sm_87|" SM_89 -#define SM_86 "sm_86|" SM_87 -#define SM_80 "sm_80|" SM_86 -#define SM_75 "sm_75|" SM_80 -#define SM_72 "sm_72|" SM_75 -#define SM_70 "sm_70|" SM_72 - -#pragma push_macro("SM_60") -#define SM_60 "sm_60|sm_61|sm_62|" SM_70 -#define SM_53 "sm_53|" SM_60 - -#pragma push_macro("PTX42") -#pragma push_macro("PTX60") -#pragma push_macro("PTX61") -#pragma push_macro("PTX62") -#pragma push_macro("PTX63") -#pragma push_macro("PTX64") -#pragma push_macro("PTX65") -#pragma push_macro("PTX70") -#pragma push_macro("PTX71") -#pragma push_macro("PTX72") -#pragma push_macro("PTX73") -#pragma push_macro("PTX74") -#pragma push_macro("PTX75") -#pragma push_macro("PTX76") -#pragma push_macro("PTX77") -#pragma push_macro("PTX78") -#pragma push_macro("PTX80") -#pragma push_macro("PTX81") -#pragma push_macro("PTX82") -#pragma push_macro("PTX83") -#pragma push_macro("PTX84") -#pragma push_macro("PTX85") -#pragma push_macro("PTX86") -#define PTX86 "ptx86" -#define PTX85 "ptx85|" PTX86 -#define PTX84 "ptx84|" PTX85 -#define PTX83 "ptx83|" PTX84 -#define PTX82 "ptx82|" PTX83 -#define PTX81 "ptx81|" PTX82 -#define PTX80 "ptx80|" PTX81 -#define PTX78 "ptx78|" PTX80 -#define PTX77 "ptx77|" PTX78 -#define PTX76 "ptx76|" PTX77 -#defin
[clang] Remove the `CustomEntry` escape hatch from builtin TableGen (PR #120861)
https://github.com/chandlerc closed https://github.com/llvm/llvm-project/pull/120861 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC][AArch64] Add relnote saying SVE2.1 and SME2.1 now fully implemented by ACLE (PR #122705)
https://github.com/jthackray closed https://github.com/llvm/llvm-project/pull/122705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e4e85e0 - [NFC][AArch64] Add relnote saying SVE2.1 and SME2.1 now fully implemented by ACLE (#122705)
Author: Jonathan Thackray Date: 2025-01-14T08:34:39Z New Revision: e4e85e04c33bbb9ab298ab18d56e2d6de89f80c2 URL: https://github.com/llvm/llvm-project/commit/e4e85e04c33bbb9ab298ab18d56e2d6de89f80c2 DIFF: https://github.com/llvm/llvm-project/commit/e4e85e04c33bbb9ab298ab18d56e2d6de89f80c2.diff LOG: [NFC][AArch64] Add relnote saying SVE2.1 and SME2.1 now fully implemented by ACLE (#122705) Added: Modified: clang/docs/ReleaseNotes.rst Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9eeb872aa57d79..794943b24a003c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1068,6 +1068,9 @@ X86 Support Arm and AArch64 Support ^^^ +- Implementation of SVE2.1 and SME2.1 in accordance with the Arm C Language + Extensions (ACLE) is now available. + - In the ARM Target, the frame pointer (FP) of a leaf function can be retained by using the ``-fno-omit-frame-pointer`` option. If you want to eliminate the FP in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #122854)
https://github.com/nikic commented: > Literal migration would result in dyn_cast_if_present (see the > definition of PointerUnion::dyn_cast), but this patch uses dyn_cast > because we expect Source to be nonnull. You are still using dyn_cast_if_present :) https://github.com/llvm/llvm-project/pull/122854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StaticAnalyzer] Migrate away from PointerUnion::dyn_cast (NFC) (PR #122856)
https://github.com/nikic commented: This one also uses dyn_cast_if_present. https://github.com/llvm/llvm-project/pull/122856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AST] Avoid repeated map lookups (NFC) (PR #122858)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/122858 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Migrate away from PointerUnion::dyn_cast (NFC) (PR #122855)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/122855 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/122621 >From b2c656afdf99eff52d019b68fcbbc6ce4bbdd7d3 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 12 Jan 2025 00:51:47 +0200 Subject: [PATCH 1/8] [Clang] disallow the use of asterisks preceding constructor and destructor names --- clang/docs/ReleaseNotes.rst | 1 + clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 clang/lib/Sema/SemaDeclCXX.cpp | 13 + clang/test/SemaCXX/constructor.cpp | 10 ++ clang/test/SemaCXX/destructor.cpp| 7 +++ 5 files changed, 35 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 197b3692b8a181..9e5bbbf6dc055a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -764,6 +764,7 @@ Improvements to Clang's diagnostics scope.Unlock(); require(scope); // Warning! Requires mu1. } +- Clang now disallows the use of asterisks preceding constructor and destructor names (#GH121706). Improvements to Clang's time-trace -- diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index d4e897868f1a9a..ec0be4ea8b6ce0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2202,6 +2202,8 @@ def err_invalid_qualified_constructor : Error< "'%0' qualifier is not allowed on a constructor">; def err_ref_qualifier_constructor : Error< "ref-qualifier '%select{&&|&}0' is not allowed on a constructor">; +def err_invalid_constructor_decl : Error< + "invalid constructor declaration">; def err_constructor_return_type : Error< "constructor cannot have a return type">; @@ -2223,6 +2225,8 @@ def err_destructor_not_member : Error< def err_destructor_cannot_be : Error<"destructor cannot be declared '%0'">; def err_invalid_qualified_destructor : Error< "'%0' qualifier is not allowed on a destructor">; +def err_invalid_destructor_decl : Error< + "invalid destructor declaration">; def err_ref_qualifier_destructor : Error< "ref-qualifier '%select{&&|&}0' is not allowed on a destructor">; def err_destructor_return_type : Error<"destructor cannot have a return type">; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c4bee44f5ec048..bb6f6e14713d9b 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID) { } } +static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) { + if (D.getNumTypeObjects() > 0) { +DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1); +if (Chunk.Kind == DeclaratorChunk::Pointer) { + SourceLocation PointerLoc = Chunk.getSourceRange().getBegin(); + S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange(); + D.setInvalidType(); +} + } +} + QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC) { bool isVirtual = D.getDeclSpec().isVirtualSpecified(); @@ -10792,6 +10803,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R, } checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_constructor); + checkMethodPointerType(*this, D, diag::err_invalid_constructor_decl); // C++0x [class.ctor]p4: // A constructor shall not be declared with a ref-qualifier. @@ -10958,6 +10970,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R, } checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_destructor); + checkMethodPointerType(*this, D, diag::err_invalid_destructor_decl); // C++0x [class.dtor]p2: // A destructor shall not be declared with a ref-qualifier. diff --git a/clang/test/SemaCXX/constructor.cpp b/clang/test/SemaCXX/constructor.cpp index abd7dbe18a0e6a..c6df7be25c1fac 100644 --- a/clang/test/SemaCXX/constructor.cpp +++ b/clang/test/SemaCXX/constructor.cpp @@ -96,3 +96,13 @@ namespace PR38286 { template struct C; // expected-note {{non-type declaration found}} template C::~C() {} // expected-error {{identifier 'C' after '~' in destructor name does not name a type}} } + +namespace GH121706 { +struct S { + *S(); // expected-error {{invalid constructor declaration}} + **S(); // expected-error {{invalid constructor declaration}} + + **S(const S &); // expected-error {{invalid constructor declaration}} + *S(S &&); // expected-error {{invalid constructor declaration}} +}; +} diff --git a/clang/test/SemaCXX/destructor.cpp b/clang/test/SemaCXX/destructor.cpp index dfcd1b033af5a2..f188e95c25d174 100644 --- a/clang/test/SemaCXX/destructor.cpp +++ b/clang/test/SemaCXX/destructor.cpp @@ -586,4 +586,11 @@ struct Y : X {} y1{ }; // expected-error
[clang] [libcxx] [Clang] emit -Wignored-qualifiers diagnostic for cv-qualified base classes (PR #121419)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/121419 >From 3f6b1d68978857035a972f49b1cfd9d9d0151be9 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 1 Jan 2025 01:47:17 +0200 Subject: [PATCH 1/4] [Clang] emit -Wignored-qualifiers diagnostic for cv-qualified base classes --- clang/docs/ReleaseNotes.rst | 1 + .../clang/Basic/DiagnosticSemaKinds.td| 4 clang/lib/Sema/SemaDeclCXX.cpp| 9 + .../SemaCXX/warn-base-type-qualifiers.cpp | 20 +++ 4 files changed, 34 insertions(+) create mode 100644 clang/test/SemaCXX/warn-base-type-qualifiers.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b7da12bcf65818..659f0ebd97fc46 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -733,6 +733,7 @@ Improvements to Clang's diagnostics scope.Unlock(); require(scope); // Warning! Requires mu1. } +- Clang now emits a ``-Wignored-qualifiers`` diagnostic when a base class includes cv-qualifiers (#GH55474). Improvements to Clang's time-trace -- diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 330ae045616aba..294cfa24975a73 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -487,6 +487,10 @@ def err_noreturn_non_function : Error< def warn_qual_return_type : Warning< "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">, InGroup, DefaultIgnore; +def warn_qual_base_type : Warning< + "'%0' qualifier%s1 on base class type %2 have no effect">, + InGroup, DefaultIgnore; + def warn_deprecated_redundant_constexpr_static_def : Warning< "out-of-line definition of constexpr static data member is redundant " "in C++17 and is deprecated">, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c5a72cf812ebc9..b82ca1541ba249 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2655,6 +2655,15 @@ CXXBaseSpecifier *Sema::CheckBaseSpecifier(CXXRecordDecl *Class, return nullptr; } +if (BaseType.hasQualifiers() && !isa(BaseType)) { + auto Quals = + BaseType.getQualifiers().getAsString(Context.getPrintingPolicy()); + Diag(BaseLoc, diag::warn_qual_base_type) + << Quals << std::count(Quals.begin(), Quals.end(), ' ') + 1 + << BaseType; + Diag(BaseLoc, diag::note_base_class_specified_here) << BaseType; +} + // For the MS ABI, propagate DLL attributes to base class templates. if (Context.getTargetInfo().getCXXABI().isMicrosoft() || Context.getTargetInfo().getTriple().isPS()) { diff --git a/clang/test/SemaCXX/warn-base-type-qualifiers.cpp b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp new file mode 100644 index 00..a5af7ec7415bf5 --- /dev/null +++ b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -verify + +class A { }; + +typedef const A A_Const; +class B : public A_Const { }; // expected-warning {{'const' qualifier on base class type 'A_Const' (aka 'const A') have no effect}} \ + // expected-note {{base class 'A_Const' (aka 'const A') specified here}} + +typedef const volatile A A_Const_Volatile; +class C : public A_Const_Volatile { }; // expected-warning {{'const volatile' qualifiers on base class type 'A_Const_Volatile' (aka 'const volatile A') have no effect}} \ + // expected-note {{base class 'A_Const_Volatile' (aka 'const volatile A') specified here}} + +struct D { + D(int); +}; +template struct E : T { + using T::T; + E(int &) : E(0) {} +}; +E e(1); >From 397097340707dbefe5f4b07357523ff7ad515304 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Thu, 2 Jan 2025 17:06:05 +0200 Subject: [PATCH 2/4] use explicit variable type --- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index b82ca1541ba249..c4ec7fa4742bdf 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2656,7 +2656,7 @@ CXXBaseSpecifier *Sema::CheckBaseSpecifier(CXXRecordDecl *Class, } if (BaseType.hasQualifiers() && !isa(BaseType)) { - auto Quals = + std::string Quals = BaseType.getQualifiers().getAsString(Context.getPrintingPolicy()); Diag(BaseLoc, diag::warn_qual_base_type) << Quals << std::count(Quals.begin(), Quals.end(), ' ') + 1 >From 3129f7521984c68969f3dd0140d6001b25ab1a28 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Fri, 3 Jan 2025 00:47:47 +0200 Subject: [PATCH 3/4] eliminate template type constraint and add additional tests --- clang/lib/Sema/SemaDeclCXX.cpp
[clang] [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (PR #122875)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Younan Zhang (zyn0217) Changes We should have been checking desugar() for the type of the right-hand side of a typedef declaration, instead of using getCanonicalType(), which points to the end of the type alias chain. Fixes https://github.com/llvm/llvm-project/issues/122417 --- Full diff: https://github.com/llvm/llvm-project/pull/122875.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1-1) - (modified) clang/lib/Sema/TreeTransform.h (+1-1) - (modified) clang/test/SemaCXX/fold_lambda_with_variadics.cpp (+6) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 07a1a4195427d8..a5da6c9c88328c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -810,7 +810,7 @@ Bug Fixes to C++ Support module imports in those situations. (#GH60336) - Fix init-capture packs having a size of one before being instantiated. (#GH63677) - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667), - (#GH99877). + (#GH99877), (#GH122417). - Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions. - Fixed an assertion failure when selecting a function from an overload set that includes a specialization of a conversion function template. diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 4a3c739ecbeab8..79df5cf4f2bb56 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -8496,7 +8496,7 @@ TreeTransform::TransformDeclStmt(DeclStmt *S) { getSema() .getASTContext() .getTypeDeclType(TD) -.getCanonicalType() +.getSingleStepDesugaredType(getSema().getASTContext()) ->containsUnexpandedParameterPack(); if (auto *VD = dyn_cast(Transformed)) diff --git a/clang/test/SemaCXX/fold_lambda_with_variadics.cpp b/clang/test/SemaCXX/fold_lambda_with_variadics.cpp index 2257a4c2d975a8..69572bea3664a7 100644 --- a/clang/test/SemaCXX/fold_lambda_with_variadics.cpp +++ b/clang/test/SemaCXX/fold_lambda_with_variadics.cpp @@ -7,6 +7,8 @@ struct identity { using type = T; }; +template using ElementType = int; + template void f() { static_assert([](Is... x) { @@ -47,6 +49,10 @@ template void f() { }(), ...); }(1, 2); + [](Is...) { +([] { using T = ElementType; }(), ...); + }(1); + [](auto ...y) { ([y] { }(), ...); }(); `` https://github.com/llvm/llvm-project/pull/122875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
https://github.com/jeanPerier approved this pull request. Beware there is a formatting issue (see github CI). LGTM otherwise, thanks Kiran! https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (PR #122875)
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/122875 We should have been checking desugar() for the type of the right-hand side of a typedef declaration, instead of using getCanonicalType(), which points to the end of the type alias chain. Fixes https://github.com/llvm/llvm-project/issues/122417 >From bda66af1a35a120ad017fcfa310d68e977629ce2 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Tue, 14 Jan 2025 16:49:41 +0800 Subject: [PATCH] [Clang] Correctly propagate type aliases' unexpanded flags up to lambda We should have been checking desugar() for the type of the right-hand side of a typedef declaration, instead of using getCanonicalType(), which points to the end of the type alias chain. --- clang/docs/ReleaseNotes.rst | 2 +- clang/lib/Sema/TreeTransform.h| 2 +- clang/test/SemaCXX/fold_lambda_with_variadics.cpp | 6 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 07a1a4195427d8..a5da6c9c88328c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -810,7 +810,7 @@ Bug Fixes to C++ Support module imports in those situations. (#GH60336) - Fix init-capture packs having a size of one before being instantiated. (#GH63677) - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667), - (#GH99877). + (#GH99877), (#GH122417). - Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions. - Fixed an assertion failure when selecting a function from an overload set that includes a specialization of a conversion function template. diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 4a3c739ecbeab8..79df5cf4f2bb56 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -8496,7 +8496,7 @@ TreeTransform::TransformDeclStmt(DeclStmt *S) { getSema() .getASTContext() .getTypeDeclType(TD) -.getCanonicalType() +.getSingleStepDesugaredType(getSema().getASTContext()) ->containsUnexpandedParameterPack(); if (auto *VD = dyn_cast(Transformed)) diff --git a/clang/test/SemaCXX/fold_lambda_with_variadics.cpp b/clang/test/SemaCXX/fold_lambda_with_variadics.cpp index 2257a4c2d975a8..69572bea3664a7 100644 --- a/clang/test/SemaCXX/fold_lambda_with_variadics.cpp +++ b/clang/test/SemaCXX/fold_lambda_with_variadics.cpp @@ -7,6 +7,8 @@ struct identity { using type = T; }; +template using ElementType = int; + template void f() { static_assert([](Is... x) { @@ -47,6 +49,10 @@ template void f() { }(), ...); }(1, 2); + [](Is...) { +([] { using T = ElementType; }(), ...); + }(1); + [](auto ...y) { ([y] { }(), ...); }(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
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 a94f08174c0312bca0ff6405640eb8a3ff986084 eb81d2dd82c90599a2486d2f2f0302ab2273109a --extensions h,cpp -- clang/include/clang/Basic/TargetBuiltins.h clang/lib/Basic/Targets/NVPTX.cpp clang/utils/TableGen/ClangBuiltinsEmitter.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h index a2d2dfac14..7404a7b8ab 100644 --- a/clang/include/clang/Basic/TargetBuiltins.h +++ b/clang/include/clang/Basic/TargetBuiltins.h @@ -101,12 +101,12 @@ namespace clang { /// NVPTX builtins namespace NVPTX { -enum { -LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, + enum { +LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, #define BUILTIN(ID, TYPE, ATTRS) BI##ID, #include "clang/Basic/BuiltinsNVPTX.inc" -LastTSBuiltin -}; +LastTSBuiltin + }; } /// AMDGPU builtins `` https://github.com/llvm/llvm-project/pull/122873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
chandlerc wrote: > ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️ Note that the PR doesn't actually change the lines that `clang-format` changes here, and the `clang-format` change makes these lines inconsistent with the rest of the file, so I intentionally did not apply these formatting changes. My guess was that the community would prefer to not have deviations from the surrounding file introduced like this. If instead folks would prefer me to apply the changes from `clang-format`, happy to do so. Just let me know. https://github.com/llvm/llvm-project/pull/122873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
chandlerc wrote: > > ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️ > > Note that the PR doesn't actually change the lines that `clang-format` > changes here, and the `clang-format` change makes these lines inconsistent > with the rest of the file, so I intentionally did not apply these formatting > changes. My guess was that the community would prefer to not have deviations > from the surrounding file introduced like this. Well, I did this and wrote this reply after looking at the diff shown by `git`... But looking at it in GitHub, this file is already inconsistent and many parts are clang-formatted. Nevermind, no real consistency argument. I've updated the PR to be formatted. https://github.com/llvm/llvm-project/pull/122873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (PR #107627)
ilya-biryukov wrote: Thanks and sorry for the long review delays. LGTM, let's work on the details in follow-ups. https://github.com/llvm/llvm-project/pull/107627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (PR #107627)
https://github.com/ilya-biryukov approved this pull request. https://github.com/llvm/llvm-project/pull/107627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (PR #107627)
@@ -3250,26 +3285,17 @@ static void mergeParamDeclAttributes(ParmVarDecl *newDecl, diag::note_carries_dependency_missing_first_decl) << 1/*Param*/; } - if (!oldDecl->hasAttrs()) -return; - - bool foundAny = newDecl->hasAttrs(); - - // Ensure that any moving of objects within the allocated map is - // done before we process them. - if (!foundAny) newDecl->setAttrs(AttrVec()); - - for (const auto *I : oldDecl->specific_attrs()) { -if (!DeclHasAttr(newDecl, I)) { - InheritableAttr *newAttr = -cast(I->clone(S.Context)); - newAttr->setInherited(true); - newDecl->addAttr(newAttr); - foundAny = true; -} - } - - if (!foundAny) newDecl->dropAttrs(); + propagateAttributes( + newDecl, oldDecl, [&S](ParmVarDecl *toDecl, const ParmVarDecl *fromDecl) { +unsigned found = 0; +found += propagateAttribute(toDecl, fromDecl, S); +// Propagate the lifetimebound attribute from parameters to the +// most recent declaration. Note that this doesn't include the implicit +// 'this' parameter, as the attribute is applied to the function type in +// that case. +found += propagateAttribute(toDecl, fromDecl, S); ilya-biryukov wrote: > It doesn't seem like InheritableParamAttr works on types. In any case, other > attributes indicate they have this problem too, so let's worry about solving > it separately for all of them in the future? okay, that's something we can also do in a follow-up. https://github.com/llvm/llvm-project/pull/107627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)
https://github.com/zwuis updated https://github.com/llvm/llvm-project/pull/108837 >From 7e5f88c322852939ae68c65f6adf4a5d2973d095 Mon Sep 17 00:00:00 2001 From: Yanzuo Liu Date: Mon, 16 Sep 2024 21:50:11 +0800 Subject: [PATCH 1/4] Fix computing result type of conditional operand --- clang/docs/ReleaseNotes.rst| 2 ++ clang/lib/Sema/SemaExpr.cpp| 4 +--- clang/test/SemaCXX/conditional-gnu-ext.cpp | 19 +++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 clang/test/SemaCXX/conditional-gnu-ext.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 17ec1fe0b946de..db8a7568a12114 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -389,6 +389,8 @@ Bug Fixes to C++ Support - Fixed a crash when clang tries to subtitute parameter pack while retaining the parameter pack. #GH63819, #GH107560 - Fix a crash when a static assert declaration has an invalid close location. (#GH108687) +- Fixed a bug in computing result type of conditional operator with omitted middle operand + (a GNU extension). (#GH15998) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8f3e15cc9a9bb7..8414a55e4868b9 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8785,11 +8785,9 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, commonExpr = result.get(); } // We usually want to apply unary conversions *before* saving, except -// in the special case of a C++ l-value conditional. +// in the special case in C++ that operands have the same type. if (!(getLangOpts().CPlusPlus && !commonExpr->isTypeDependent() - && commonExpr->getValueKind() == RHSExpr->getValueKind() - && commonExpr->isGLValue() && commonExpr->isOrdinaryOrBitFieldObject() && RHSExpr->isOrdinaryOrBitFieldObject() && Context.hasSameType(commonExpr->getType(), RHSExpr->getType( { diff --git a/clang/test/SemaCXX/conditional-gnu-ext.cpp b/clang/test/SemaCXX/conditional-gnu-ext.cpp new file mode 100644 index 00..83a6fff8467863 --- /dev/null +++ b/clang/test/SemaCXX/conditional-gnu-ext.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -fexperimental-new-constant-interpreter +// expected-no-diagnostics + +/* +FIXME: Support constexpr + +constexpr int evaluate_once(int x) { + return (++x) ? : 10; +} +static_assert(evaluate_once(0) == 1, ""); +*/ + +namespace GH15998 { + enum E { Zero, One }; + E test(E e) { +return e ? : One; + } +} >From 447c8b9c6e957308c9ff62e8c83b15b12f7fc1cb Mon Sep 17 00:00:00 2001 From: Yanzuo Liu Date: Mon, 16 Sep 2024 23:05:50 +0800 Subject: [PATCH 2/4] Format code --- clang/lib/Sema/SemaExpr.cpp | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8414a55e4868b9..c232d40ca31ac6 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8786,11 +8786,10 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, } // We usually want to apply unary conversions *before* saving, except // in the special case in C++ that operands have the same type. -if (!(getLangOpts().CPlusPlus - && !commonExpr->isTypeDependent() - && commonExpr->isOrdinaryOrBitFieldObject() - && RHSExpr->isOrdinaryOrBitFieldObject() - && Context.hasSameType(commonExpr->getType(), RHSExpr->getType( { +if (!(getLangOpts().CPlusPlus && !commonExpr->isTypeDependent() && + commonExpr->isOrdinaryOrBitFieldObject() && + RHSExpr->isOrdinaryOrBitFieldObject() && + Context.hasSameType(commonExpr->getType(), RHSExpr->getType( { ExprResult commonRes = UsualUnaryConversions(commonExpr); if (commonRes.isInvalid()) return ExprError(); >From 4c3dbacae0c8935384e1bfd39bf1397d5a81ad1d Mon Sep 17 00:00:00 2001 From: Yanzuo Liu Date: Sun, 12 Jan 2025 18:50:29 +0800 Subject: [PATCH 3/4] Fix previously undiscovered case and address review feedbacks 'conditional-gnu-exp.cpp' is mainly copied and modified from 'conditional-expr.cpp' 'conditional-gnu-ext.c' is mainly copied and modified from 'conditional-expr.c' --- clang/lib/Sema/SemaExpr.cpp| 12 +- clang/test/CXX/drs/cwg5xx.cpp | 12 + clang/test/Sema/conditional-expr.c | 2 - clang/test/Sema/conditional-gnu-ext.c | 111 ++ clang/test/SemaCXX/conditional-expr.cpp| 24 -- clang/test/SemaCXX/conditional-gnu-ext.cpp | 442 - 6 files changed, 563 insertions(+), 40 deletions(-) create mode 100644 clang/test/Sema/conditional-gnu-ext.c diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index
[clang] 4cc9bf1 - Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (#107627)
Author: higher-performance Date: 2025-01-14T10:22:20+01:00 New Revision: 4cc9bf149f07edec5ea910af8b3ead17ae8b29b7 URL: https://github.com/llvm/llvm-project/commit/4cc9bf149f07edec5ea910af8b3ead17ae8b29b7 DIFF: https://github.com/llvm/llvm-project/commit/4cc9bf149f07edec5ea910af8b3ead17ae8b29b7.diff LOG: Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (#107627) This partially fixes #62072 by making sure that re-declarations of a function do not have the effect of removing lifetimebound from the canonical declaration. It doesn't handle the implicit 'this' parameter, but that can be addressed in a separate fix. Added: Modified: clang/lib/Sema/CheckExprLifetime.cpp clang/lib/Sema/SemaDecl.cpp clang/test/SemaCXX/attr-lifetimebound.cpp Removed: diff --git a/clang/lib/Sema/CheckExprLifetime.cpp b/clang/lib/Sema/CheckExprLifetime.cpp index 837414c4840d75..27e6b5b2cb3930 100644 --- a/clang/lib/Sema/CheckExprLifetime.cpp +++ b/clang/lib/Sema/CheckExprLifetime.cpp @@ -525,7 +525,20 @@ static bool isNormalAssignmentOperator(const FunctionDecl *FD) { return false; } +static const FunctionDecl * +getDeclWithMergedLifetimeBoundAttrs(const FunctionDecl *FD) { + return FD != nullptr ? FD->getMostRecentDecl() : nullptr; +} + +static const CXXMethodDecl * +getDeclWithMergedLifetimeBoundAttrs(const CXXMethodDecl *CMD) { + const FunctionDecl *FD = CMD; + return cast_if_present( + getDeclWithMergedLifetimeBoundAttrs(FD)); +} + bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) { + FD = getDeclWithMergedLifetimeBoundAttrs(FD); const TypeSourceInfo *TSI = FD->getTypeSourceInfo(); if (!TSI) return false; @@ -647,9 +660,9 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, } } - for (unsigned I = 0, -N = std::min(Callee->getNumParams(), Args.size()); - I != N; ++I) { + const FunctionDecl *CanonCallee = getDeclWithMergedLifetimeBoundAttrs(Callee); + unsigned NP = std::min(Callee->getNumParams(), CanonCallee->getNumParams()); + for (unsigned I = 0, N = std::min(NP, Args.size()); I != N; ++I) { Expr *Arg = Args[I]; RevertToOldSizeRAII RAII(Path); if (auto *DAE = dyn_cast(Arg)) { @@ -657,11 +670,12 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, {IndirectLocalPathEntry::DefaultArg, DAE, DAE->getParam()}); Arg = DAE->getExpr(); } -if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr()) - VisitLifetimeBoundArg(Callee->getParamDecl(I), Arg); +if (CheckCoroCall || +CanonCallee->getParamDecl(I)->hasAttr()) + VisitLifetimeBoundArg(CanonCallee->getParamDecl(I), Arg); else if (const auto *CaptureAttr = - Callee->getParamDecl(I)->getAttr(); - CaptureAttr && isa(Callee) && + CanonCallee->getParamDecl(I)->getAttr(); + CaptureAttr && isa(CanonCallee) && llvm::any_of(CaptureAttr->params(), [](int ArgIdx) { return ArgIdx == LifetimeCaptureByAttr::THIS; })) @@ -678,11 +692,11 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, // `lifetimebound` and shares the same code path. This implies the emitted // diagnostics will be emitted under `-Wdangling`, not // `-Wdangling-capture`. - VisitLifetimeBoundArg(Callee->getParamDecl(I), Arg); + VisitLifetimeBoundArg(CanonCallee->getParamDecl(I), Arg); else if (EnableGSLAnalysis && I == 0) { // Perform GSL analysis for the first argument - if (shouldTrackFirstArgument(Callee)) { -VisitGSLPointerArg(Callee, Arg); + if (shouldTrackFirstArgument(CanonCallee)) { +VisitGSLPointerArg(CanonCallee, Arg); } else if (auto *Ctor = dyn_cast(Call); Ctor && shouldTrackFirstArgumentForConstructor(Ctor)) { VisitGSLPointerArg(Ctor->getConstructor(), Arg); @@ -1245,7 +1259,8 @@ static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path, return Report; } -static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) { +static bool isAssignmentOperatorLifetimeBound(const CXXMethodDecl *CMD) { + CMD = getDeclWithMergedLifetimeBoundAttrs(CMD); return CMD && isNormalAssignmentOperator(CMD) && CMD->param_size() == 1 && CMD->getParamDecl(0)->hasAttr(); } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5b7275c316f74a..f5e57988b7fa8d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3239,6 +3239,42 @@ void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old, if (!foundAny) New->dropAttrs(); } +// Returns the number of added attributes. +template +static unsigned propagateAttribute(ParmVarDecl *To, const ParmVarDecl
[clang] Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (PR #107627)
https://github.com/ilya-biryukov closed https://github.com/llvm/llvm-project/pull/107627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
@@ -3494,6 +3494,12 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group; def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group, Visibility<[ClangOption, FlangOption]>; +defm init_global_zero : BoolFOption<"init-global-zero", carlocab wrote: `-fzero-init-globals`, maybe? Feel free to ignore if you disagree, though. https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not allow unorderable features in [[gnu::target{,_clones}]] (PR #98426)
https://github.com/phoebewang approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/98426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not allow unorderable features in [[gnu::target{,_clones}]] (PR #98426)
phoebewang wrote: @DanShaders let me know if you need me to merge it for you. https://github.com/llvm/llvm-project/pull/98426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/116051 >From 1f5cd91c67e12e19dd9a142273af5a90a63cbf38 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Wed, 27 Nov 2024 11:33:01 + Subject: [PATCH] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode This patch introduces a `TargetKernelRuntimeAttrs` structure to hold host-evaluated `num_teams`, `thread_limit`, `num_threads` and trip count values passed to the runtime kernel offloading call. Additionally, kernel type information is used to influence target device code generation and the `IsSPMD` flag is replaced by `ExecFlags`, which provide more granularity. --- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 5 +- .../llvm/Frontend/OpenMP/OMPIRBuilder.h | 38 ++- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 129 +--- .../Frontend/OpenMPIRBuilderTest.cpp | 275 -- .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 12 +- 5 files changed, 392 insertions(+), 67 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index 81993dafae2b03..87c3635ed3f70e 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -20,6 +20,7 @@ #include "clang/AST/StmtVisitor.h" #include "clang/Basic/Cuda.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" using namespace clang; @@ -745,7 +746,9 @@ void CGOpenMPRuntimeGPU::emitKernelInit(const OMPExecutableDirective &D, CodeGenFunction &CGF, EntryFunctionState &EST, bool IsSPMD) { llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs Attrs; - Attrs.IsSPMD = IsSPMD; + Attrs.ExecFlags = + IsSPMD ? llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_SPMD + : llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_GENERIC; computeMinAndMaxThreadsAndTeams(D, CGF, Attrs); CGBuilderTy &Bld = CGF.Builder; diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h index 8ca3bc08b5ad49..7eceec3d8cf8f5 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -1389,9 +1389,6 @@ class OpenMPIRBuilder { /// Supporting functions for Reductions CodeGen. private: - /// Emit the llvm.used metadata. - void emitUsed(StringRef Name, std::vector &List); - /// Get the id of the current thread on the GPU. Value *getGPUThreadID(); @@ -2013,6 +2010,13 @@ class OpenMPIRBuilder { /// Value. GlobalValue *createGlobalFlag(unsigned Value, StringRef Name); + /// Emit the llvm.used metadata. + void emitUsed(StringRef Name, ArrayRef List); + + /// Emit the kernel execution mode. + GlobalVariable *emitKernelExecutionMode(StringRef KernelName, + omp::OMPTgtExecModeFlags Mode); + /// Generate control flow and cleanup for cancellation. /// /// \param CancelFlag Flag indicating if the cancellation is performed. @@ -2233,13 +2237,34 @@ class OpenMPIRBuilder { /// time. The number of max values will be 1 except for the case where /// ompx_bare is set. struct TargetKernelDefaultAttrs { -bool IsSPMD = false; +omp::OMPTgtExecModeFlags ExecFlags = +omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_GENERIC; SmallVector MaxTeams = {-1}; int32_t MinTeams = 1; SmallVector MaxThreads = {-1}; int32_t MinThreads = 1; }; + /// Container to pass LLVM IR runtime values or constants related to the + /// number of teams and threads with which the kernel must be launched, as + /// well as the trip count of the loop, if it is an SPMD or Generic-SPMD + /// kernel. These must be defined in the host prior to the call to the kernel + /// launch OpenMP RTL function. + struct TargetKernelRuntimeAttrs { +SmallVector MaxTeams = {nullptr}; +Value *MinTeams = nullptr; +SmallVector TargetThreadLimit = {nullptr}; +SmallVector TeamsThreadLimit = {nullptr}; + +/// 'parallel' construct 'num_threads' clause value, if present and it is an +/// SPMD kernel. +Value *MaxThreads = nullptr; + +/// Total number of iterations of the SPMD or Generic-SPMD kernel or null if +/// it is a generic kernel. +Value *LoopTripCount = nullptr; + }; + /// Data structure that contains the needed information to construct the /// kernel args vector. struct TargetKernelArgs { @@ -2971,7 +2996,9 @@ class OpenMPIRBuilder { /// \param CodeGenIP The insertion point where the call to the outlined /// function should be emitted. /// \param EntryInfo The entry information about the function. - /// \param DefaultAttrs Structure containing the default numbers of threads + /// \param DefaultAttrs Structure containing the default attributes, in
[clang] [NFC][analyzer][docs] Improve Annotations.rst (PR #122749)
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/122749 From 098e884885cc3f82eac66b735203610a6e2af01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Mon, 13 Jan 2025 18:20:06 +0100 Subject: [PATCH 1/2] [NFC][analyzer][docs] Improve Annotations.rst This commit fixes three issues within the documentation file `Annotations.rst` which was recently created by my earlier commit https://github.com/llvm/llvm-project/pull/122246 . (1) The section title "Annotations to Enhance Generic Checks" is changed to "General Purpose Annotations" because it was a bit too verbose and it used the obsolete name "checks" for what we now call "checkers" in the static analyzer. (2) Several code blocks were missing from the generated html because I accidentally used `.. code-block: c` instead of `.. code-block:: c` and so Sphinx parsed them as comment blocks. (Without printing any error or warning...) (3) The `ownership_*` attributes (which are used by `MallocChecker`) were missing from this document, so I wrote a section that briefly describes them and links to their full documentation. --- clang/docs/analyzer/user-docs/Annotations.rst | 51 --- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/clang/docs/analyzer/user-docs/Annotations.rst b/clang/docs/analyzer/user-docs/Annotations.rst index d87e8f4df99c31..2ed609d3594c4f 100644 --- a/clang/docs/analyzer/user-docs/Annotations.rst +++ b/clang/docs/analyzer/user-docs/Annotations.rst @@ -23,8 +23,8 @@ recognized by GCC. Their use can be conditioned using preprocessor macros .. contents:: :local: -Annotations to Enhance Generic Checks -_ +General Purpose Annotations +___ Null Pointer Checking # @@ -79,7 +79,7 @@ implemented with a macro, with the macro performing a check for the assertion condition and, when the check fails, calling an assertion handler. For example, consider the following code fragment: -.. code-block: c +.. code-block:: c void foo(int *p) { assert(p != NULL); @@ -87,7 +87,7 @@ example, consider the following code fragment: When this code is preprocessed on Mac OS X it expands to the following: -.. code-block: c +.. code-block:: c void foo(int *p) { (__builtin_expect(!(p != NULL), 0) ? __assert_rtn(__func__, "t.c", 4, "p != NULL") : (void)0); @@ -131,7 +131,7 @@ return. On Mac OS X, the function prototype for ``__assert_rtn`` (declared in ``assert.h``) is specifically annotated with the 'noreturn' attribute: -.. code-block: c +.. code-block:: c void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__)); @@ -151,7 +151,7 @@ the use of preprocessor macros. **Example** -.. code-block: c +.. code-block:: c #ifndef CLANG_ANALYZER_NORETURN #if __has_feature(attribute_analyzer_noreturn) @@ -163,6 +163,42 @@ the use of preprocessor macros. void my_assert_rtn(const char *, const char *, int, const char *) CLANG_ANALYZER_NORETURN; +Dynamic Memory Modeling Annotations +### + +If a project uses custom functions for dynamic memory management (that e.g. act as wrappers around ``malloc``/``free`` or ``new``/``delete`` in C++) and the analyzer cannot "see" the _definitions_ of these functions, it's possible to annotate their declarations to let the analyzer model their behavior. (Otherwise the analyzer cannot know that the opaque ``my_free()`` is basically equivalent to a standard ``free()`` call.) + +**This page only provides a brief list of these annotations.** For a full documentation, see the main `Attributes in Clang <../../AttributeReference.html#ownership-holds-ownership-returns-ownership-takes-clang-static-analyzer>`_ page. + +Attribute 'ownership_returns' (Clang-specific) +-- + +Use this attribute to mark functions that return dynamically allocated memory. Takes a single argument, the type of the allocation (e.g. ``malloc`` or ``new``). + +.. code-block:: c + + void __attribute((ownership_returns(malloc))) *my_malloc(size_t); + +Attribute 'ownership_takes' (Clang-specific) + + +Use this attribute to mark functions that deallocate memory. Takes two arguments: the type of the allocation (e.g. ``malloc`` or ``new``) and the index of the parameter that is being deallocated (counting from 1). + +.. code-block:: c + + void __attribute((ownership_takes(malloc, 1))) my_free(void *); + +Attribute 'ownership_holds' (Clang-specific) + + +Use this attribute to mark functions that take ownership of memory and will deallocate it at some unspecified point in the future. Takes two arguments: the type of the allocation (e.g. ``malloc`` or ``new``) and the index of the parameter that is being held (counting from 1). + +.. code-block:: c +
[clang] [NFC][analyzer][docs] Improve Annotations.rst (PR #122749)
@@ -163,6 +163,42 @@ the use of preprocessor macros. void my_assert_rtn(const char *, const char *, int, const char *) CLANG_ANALYZER_NORETURN; +Dynamic Memory Modeling Annotations +### + +If a project uses custom functions for dynamic memory management (that e.g. act as wrappers around ``malloc``/``free`` or ``new``/``delete`` in C++) and the analyzer cannot "see" the _definitions_ of these functions, it's possible to annotate their declarations to let the analyzer model their behavior. (Otherwise the analyzer cannot know that the opaque ``my_free()`` is basically equivalent to a standard ``free()`` call.) + +**This page only provides a brief list of these annotations.** For a full documentation, see the main `Attributes in Clang <../../AttributeReference.html#ownership-holds-ownership-returns-ownership-takes-clang-static-analyzer>`_ page. NagyDonat wrote: Thanks for the suggestion, I did not know about this feature. https://github.com/llvm/llvm-project/pull/122749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/116051 >From 0c19f7119c1da0646466b0eb1c3c77faedabaebf Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Wed, 27 Nov 2024 11:33:01 + Subject: [PATCH] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode This patch introduces a `TargetKernelRuntimeAttrs` structure to hold host-evaluated `num_teams`, `thread_limit`, `num_threads` and trip count values passed to the runtime kernel offloading call. Additionally, kernel type information is used to influence target device code generation and the `IsSPMD` flag is replaced by `ExecFlags`, which provide more granularity. --- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 5 +- .../llvm/Frontend/OpenMP/OMPIRBuilder.h | 38 ++- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 129 +--- .../Frontend/OpenMPIRBuilderTest.cpp | 281 -- .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 12 +- 5 files changed, 398 insertions(+), 67 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index 81993dafae2b03..87c3635ed3f70e 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -20,6 +20,7 @@ #include "clang/AST/StmtVisitor.h" #include "clang/Basic/Cuda.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" using namespace clang; @@ -745,7 +746,9 @@ void CGOpenMPRuntimeGPU::emitKernelInit(const OMPExecutableDirective &D, CodeGenFunction &CGF, EntryFunctionState &EST, bool IsSPMD) { llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs Attrs; - Attrs.IsSPMD = IsSPMD; + Attrs.ExecFlags = + IsSPMD ? llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_SPMD + : llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_GENERIC; computeMinAndMaxThreadsAndTeams(D, CGF, Attrs); CGBuilderTy &Bld = CGF.Builder; diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h index 8ca3bc08b5ad49..7eceec3d8cf8f5 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -1389,9 +1389,6 @@ class OpenMPIRBuilder { /// Supporting functions for Reductions CodeGen. private: - /// Emit the llvm.used metadata. - void emitUsed(StringRef Name, std::vector &List); - /// Get the id of the current thread on the GPU. Value *getGPUThreadID(); @@ -2013,6 +2010,13 @@ class OpenMPIRBuilder { /// Value. GlobalValue *createGlobalFlag(unsigned Value, StringRef Name); + /// Emit the llvm.used metadata. + void emitUsed(StringRef Name, ArrayRef List); + + /// Emit the kernel execution mode. + GlobalVariable *emitKernelExecutionMode(StringRef KernelName, + omp::OMPTgtExecModeFlags Mode); + /// Generate control flow and cleanup for cancellation. /// /// \param CancelFlag Flag indicating if the cancellation is performed. @@ -2233,13 +2237,34 @@ class OpenMPIRBuilder { /// time. The number of max values will be 1 except for the case where /// ompx_bare is set. struct TargetKernelDefaultAttrs { -bool IsSPMD = false; +omp::OMPTgtExecModeFlags ExecFlags = +omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_GENERIC; SmallVector MaxTeams = {-1}; int32_t MinTeams = 1; SmallVector MaxThreads = {-1}; int32_t MinThreads = 1; }; + /// Container to pass LLVM IR runtime values or constants related to the + /// number of teams and threads with which the kernel must be launched, as + /// well as the trip count of the loop, if it is an SPMD or Generic-SPMD + /// kernel. These must be defined in the host prior to the call to the kernel + /// launch OpenMP RTL function. + struct TargetKernelRuntimeAttrs { +SmallVector MaxTeams = {nullptr}; +Value *MinTeams = nullptr; +SmallVector TargetThreadLimit = {nullptr}; +SmallVector TeamsThreadLimit = {nullptr}; + +/// 'parallel' construct 'num_threads' clause value, if present and it is an +/// SPMD kernel. +Value *MaxThreads = nullptr; + +/// Total number of iterations of the SPMD or Generic-SPMD kernel or null if +/// it is a generic kernel. +Value *LoopTripCount = nullptr; + }; + /// Data structure that contains the needed information to construct the /// kernel args vector. struct TargetKernelArgs { @@ -2971,7 +2996,9 @@ class OpenMPIRBuilder { /// \param CodeGenIP The insertion point where the call to the outlined /// function should be emitted. /// \param EntryInfo The entry information about the function. - /// \param DefaultAttrs Structure containing the default numbers of threads + /// \param DefaultAttrs Structure containing the default attributes, in
[clang] [clang] document that by default FP turned off for ARM baremetal (PR #122881)
@@ -1076,6 +1076,8 @@ Arm and AArch64 Support in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding the ``-momit-leaf-frame-pointer`` option. +- For ARM baremetal targets, the frame pointer (FP) is now turned off by default. stuij wrote: done https://github.com/llvm/llvm-project/pull/122881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] document that by default FP turned off for ARM baremetal (PR #122881)
https://github.com/stuij updated https://github.com/llvm/llvm-project/pull/122881 >From 7865fd2bf4e0bb9c35b3d14f362732c994914568 Mon Sep 17 00:00:00 2001 From: Ties Stuij Date: Tue, 14 Jan 2025 10:01:33 + Subject: [PATCH 1/2] [clang] document that by default FP turned off for ARM baremetal As per #117140. --- clang/docs/ReleaseNotes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 794943b24a003c..663e7561f715c0 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1076,6 +1076,8 @@ Arm and AArch64 Support in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding the ``-momit-leaf-frame-pointer`` option. +- For ARM baremetal targets, the frame pointer (FP) is now turned off by default. + - Support has been added for the following processors (-mcpu identifiers in parenthesis): For AArch64: >From 69669604d4b37193ef8487af13043cd9d78484e3 Mon Sep 17 00:00:00 2001 From: Ties Stuij Date: Tue, 14 Jan 2025 11:42:41 + Subject: [PATCH 2/2] Address review comment by moving text up and expanding on it --- clang/docs/ReleaseNotes.rst | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 663e7561f715c0..27193ca9349a6e 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1071,13 +1071,15 @@ Arm and AArch64 Support - Implementation of SVE2.1 and SME2.1 in accordance with the Arm C Language Extensions (ACLE) is now available. +- For ARM baremetal targets, the frame pointer (FP) is now turned off by + default. To turn on frame pointers for Arm baremetal targets, use + the ``-fno-omit-frame-pointer`` command line option. + - In the ARM Target, the frame pointer (FP) of a leaf function can be retained by using the ``-fno-omit-frame-pointer`` option. If you want to eliminate the FP in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding the ``-momit-leaf-frame-pointer`` option. -- For ARM baremetal targets, the frame pointer (FP) is now turned off by default. - - Support has been added for the following processors (-mcpu identifiers in parenthesis): For AArch64: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][AArch64] Add new feature +sme-mop4 and +sme-tmop (PR #121935)
https://github.com/Lukacma commented: Thank you for the patch Carol it looks good ! I think we should also add dependency test for the new features, to both TargetParserTest.cpp and aarch64-implied-sme-features.c . https://github.com/llvm/llvm-project/pull/121935 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] document that by default FP turned off for ARM baremetal (PR #122881)
https://github.com/DavidSpickett approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/122881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] document that by default FP turned off for ARM baremetal (PR #122881)
@@ -1071,6 +1071,10 @@ Arm and AArch64 Support - Implementation of SVE2.1 and SME2.1 in accordance with the Arm C Language Extensions (ACLE) is now available. +- For ARM baremetal targets, the frame pointer (FP) is now turned off by + default. To turn on frame pointers for Arm baremetal targets, use DavidSpickett wrote: Arm -> ARM https://github.com/llvm/llvm-project/pull/122881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/122890 >From c660f891b2c54c795fea58807be4405710e7a6b0 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 8 Jan 2025 13:42:11 + Subject: [PATCH 1/2] [clang] Infer capture_by for insert_or_assign --- clang/lib/Sema/SemaAttr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index 44485e71d57a01..42aa68d2905c03 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -307,8 +307,8 @@ void Sema::inferLifetimeCaptureByAttribute(FunctionDecl *FD) { Annotate(MD); return; } - static const llvm::StringSet<> CapturingMethods{"insert", "push", - "push_front", "push_back"}; + static const llvm::StringSet<> CapturingMethods{ + "insert", "insert_or_assign", "push", "push_front", "push_back"}; if (!CapturingMethods.contains(MD->getName())) return; Annotate(MD); >From a63d4aa088fc8b58fd56eb7a0881106da88d3ab5 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Tue, 14 Jan 2025 11:50:57 + Subject: [PATCH 2/2] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. --- llvm/include/llvm/Support/Path.h | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h index ce69f32b6cc81b..bbf1c5037e6751 100644 --- a/llvm/include/llvm/Support/Path.h +++ b/llvm/include/llvm/Support/Path.h @@ -119,22 +119,24 @@ class reverse_iterator /// Get begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first component of \a path. -const_iterator begin(StringRef path, Style style = Style::native); +const_iterator begin(StringRef path LLVM_LIFETIME_BOUND, + Style style = Style::native); /// Get end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the end of \a path. -const_iterator end(StringRef path); +const_iterator end(StringRef path LLVM_LIFETIME_BOUND); /// Get reverse begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first reverse component of \a path. -reverse_iterator rbegin(StringRef path, Style style = Style::native); +reverse_iterator rbegin(StringRef path LLVM_LIFETIME_BOUND, +Style style = Style::native); /// Get reverse end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the reverse end of \a path. -reverse_iterator rend(StringRef path); +reverse_iterator rend(StringRef path LLVM_LIFETIME_BOUND); /// @} /// @name Lexical Modifiers @@ -199,7 +201,7 @@ bool replace_path_prefix(SmallVectorImpl &Path, StringRef OldPrefix, /// /// @param path Input path. /// @result The cleaned-up \a path. -StringRef remove_leading_dotslash(StringRef path, Style style = Style::native); +StringRef remove_leading_dotslash(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// In-place remove any './' and optionally '../' components from a path. /// @@ -295,7 +297,7 @@ std::string convert_to_slash(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The root name of \a path if it has one, otherwise "". -StringRef root_name(StringRef path, Style style = Style::native); +StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get root directory. /// @@ -308,7 +310,7 @@ StringRef root_name(StringRef path, Style style = Style::native); /// @param path Input path. /// @result The root directory of \a path if it has one, otherwise /// "". -StringRef root_directory(StringRef path, Style style = Style::native); +StringRef root_directory(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get root path. /// @@ -316,7 +318,7 @@ StringRef root_directory(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The root path of \a path if it has one, otherwise "". -StringRef root_path(StringRef path, Style style = Style::native); +StringRef root_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get relative path. /// @@ -328,7 +330,7 @@ StringRef root_path(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The path starting after root_path if one exists, otherwise "". -StringRef relative_path(StringRef path, Style style = Style::native); +StringRef relative_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get parent path. /// @@ -340,7 +342,8 @@ StringRef relative_path(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The parent path of \a path if one exists, otherwise "". -StringRef parent_path(StringRef path, Styl
[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/122890 None >From c660f891b2c54c795fea58807be4405710e7a6b0 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Wed, 8 Jan 2025 13:42:11 + Subject: [PATCH 1/2] [clang] Infer capture_by for insert_or_assign --- clang/lib/Sema/SemaAttr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index 44485e71d57a01..42aa68d2905c03 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -307,8 +307,8 @@ void Sema::inferLifetimeCaptureByAttribute(FunctionDecl *FD) { Annotate(MD); return; } - static const llvm::StringSet<> CapturingMethods{"insert", "push", - "push_front", "push_back"}; + static const llvm::StringSet<> CapturingMethods{ + "insert", "insert_or_assign", "push", "push_front", "push_back"}; if (!CapturingMethods.contains(MD->getName())) return; Annotate(MD); >From a63d4aa088fc8b58fd56eb7a0881106da88d3ab5 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Tue, 14 Jan 2025 11:50:57 + Subject: [PATCH 2/2] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. --- llvm/include/llvm/Support/Path.h | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h index ce69f32b6cc81b..bbf1c5037e6751 100644 --- a/llvm/include/llvm/Support/Path.h +++ b/llvm/include/llvm/Support/Path.h @@ -119,22 +119,24 @@ class reverse_iterator /// Get begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first component of \a path. -const_iterator begin(StringRef path, Style style = Style::native); +const_iterator begin(StringRef path LLVM_LIFETIME_BOUND, + Style style = Style::native); /// Get end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the end of \a path. -const_iterator end(StringRef path); +const_iterator end(StringRef path LLVM_LIFETIME_BOUND); /// Get reverse begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first reverse component of \a path. -reverse_iterator rbegin(StringRef path, Style style = Style::native); +reverse_iterator rbegin(StringRef path LLVM_LIFETIME_BOUND, +Style style = Style::native); /// Get reverse end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the reverse end of \a path. -reverse_iterator rend(StringRef path); +reverse_iterator rend(StringRef path LLVM_LIFETIME_BOUND); /// @} /// @name Lexical Modifiers @@ -199,7 +201,7 @@ bool replace_path_prefix(SmallVectorImpl &Path, StringRef OldPrefix, /// /// @param path Input path. /// @result The cleaned-up \a path. -StringRef remove_leading_dotslash(StringRef path, Style style = Style::native); +StringRef remove_leading_dotslash(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// In-place remove any './' and optionally '../' components from a path. /// @@ -295,7 +297,7 @@ std::string convert_to_slash(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The root name of \a path if it has one, otherwise "". -StringRef root_name(StringRef path, Style style = Style::native); +StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get root directory. /// @@ -308,7 +310,7 @@ StringRef root_name(StringRef path, Style style = Style::native); /// @param path Input path. /// @result The root directory of \a path if it has one, otherwise /// "". -StringRef root_directory(StringRef path, Style style = Style::native); +StringRef root_directory(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get root path. /// @@ -316,7 +318,7 @@ StringRef root_directory(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The root path of \a path if it has one, otherwise "". -StringRef root_path(StringRef path, Style style = Style::native); +StringRef root_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get relative path. /// @@ -328,7 +330,7 @@ StringRef root_path(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The path starting after root_path if one exists, otherwise "". -StringRef relative_path(StringRef path, Style style = Style::native); +StringRef relative_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get parent path. /// @@ -340,7 +342,8 @@ StringRef relative_path(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The parent path of \a path if one exists, otherwise "". -StringRef parent_path(StringRef path
[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)
llvmbot wrote: @llvm/pr-subscribers-llvm-support Author: Utkarsh Saxena (usx95) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/122890.diff 1 Files Affected: - (modified) llvm/include/llvm/Support/Path.h (+17-13) ``diff diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h index ce69f32b6cc81b..bbf1c5037e6751 100644 --- a/llvm/include/llvm/Support/Path.h +++ b/llvm/include/llvm/Support/Path.h @@ -119,22 +119,24 @@ class reverse_iterator /// Get begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first component of \a path. -const_iterator begin(StringRef path, Style style = Style::native); +const_iterator begin(StringRef path LLVM_LIFETIME_BOUND, + Style style = Style::native); /// Get end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the end of \a path. -const_iterator end(StringRef path); +const_iterator end(StringRef path LLVM_LIFETIME_BOUND); /// Get reverse begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first reverse component of \a path. -reverse_iterator rbegin(StringRef path, Style style = Style::native); +reverse_iterator rbegin(StringRef path LLVM_LIFETIME_BOUND, +Style style = Style::native); /// Get reverse end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the reverse end of \a path. -reverse_iterator rend(StringRef path); +reverse_iterator rend(StringRef path LLVM_LIFETIME_BOUND); /// @} /// @name Lexical Modifiers @@ -199,7 +201,7 @@ bool replace_path_prefix(SmallVectorImpl &Path, StringRef OldPrefix, /// /// @param path Input path. /// @result The cleaned-up \a path. -StringRef remove_leading_dotslash(StringRef path, Style style = Style::native); +StringRef remove_leading_dotslash(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// In-place remove any './' and optionally '../' components from a path. /// @@ -295,7 +297,7 @@ std::string convert_to_slash(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The root name of \a path if it has one, otherwise "". -StringRef root_name(StringRef path, Style style = Style::native); +StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get root directory. /// @@ -308,7 +310,7 @@ StringRef root_name(StringRef path, Style style = Style::native); /// @param path Input path. /// @result The root directory of \a path if it has one, otherwise /// "". -StringRef root_directory(StringRef path, Style style = Style::native); +StringRef root_directory(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get root path. /// @@ -316,7 +318,7 @@ StringRef root_directory(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The root path of \a path if it has one, otherwise "". -StringRef root_path(StringRef path, Style style = Style::native); +StringRef root_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get relative path. /// @@ -328,7 +330,7 @@ StringRef root_path(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The path starting after root_path if one exists, otherwise "". -StringRef relative_path(StringRef path, Style style = Style::native); +StringRef relative_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get parent path. /// @@ -340,7 +342,8 @@ StringRef relative_path(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The parent path of \a path if one exists, otherwise "". -StringRef parent_path(StringRef path, Style style = Style::native); +StringRef parent_path(StringRef path LLVM_LIFETIME_BOUND, + Style style = Style::native); /// Get filename. /// @@ -354,7 +357,7 @@ StringRef parent_path(StringRef path, Style style = Style::native); /// @param path Input path. /// @result The filename part of \a path. This is defined as the last component /// of \a path. Similar to the POSIX "basename" utility. -StringRef filename(StringRef path, Style style = Style::native); +StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get stem. /// @@ -372,7 +375,7 @@ StringRef filename(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The stem of \a path. -StringRef stem(StringRef path, Style style = Style::native); +StringRef stem(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); /// Get extension. /// @@ -388,7 +391,8 @@ StringRef stem(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The extension of \a path. -StringRef extension(StringRef
[clang] [llvm] [llvm] Add lifetimebound to llvm::sys::path::filename, etc. (PR #122890)
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 b87fdd9ce612d53b0e0b73d7c062b39a042e8629 50fc88359edcc43833a0c39445bc187e2a983fc2 --extensions h -- llvm/include/llvm/Support/Path.h `` View the diff from clang-format here. ``diff diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h index bbf1c5037e..ce549a995c 100644 --- a/llvm/include/llvm/Support/Path.h +++ b/llvm/include/llvm/Support/Path.h @@ -201,7 +201,8 @@ bool replace_path_prefix(SmallVectorImpl &Path, StringRef OldPrefix, /// /// @param path Input path. /// @result The cleaned-up \a path. -StringRef remove_leading_dotslash(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); +StringRef remove_leading_dotslash(StringRef path LLVM_LIFETIME_BOUND, + Style style = Style::native); /// In-place remove any './' and optionally '../' components from a path. /// @@ -297,7 +298,8 @@ std::string convert_to_slash(StringRef path, Style style = Style::native); /// /// @param path Input path. /// @result The root name of \a path if it has one, otherwise "". -StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); +StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, +Style style = Style::native); /// Get root directory. /// @@ -310,7 +312,8 @@ StringRef root_name(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::nat /// @param path Input path. /// @result The root directory of \a path if it has one, otherwise /// "". -StringRef root_directory(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); +StringRef root_directory(StringRef path LLVM_LIFETIME_BOUND, + Style style = Style::native); /// Get root path. /// @@ -318,7 +321,8 @@ StringRef root_directory(StringRef path LLVM_LIFETIME_BOUND, Style style = Style /// /// @param path Input path. /// @result The root path of \a path if it has one, otherwise "". -StringRef root_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); +StringRef root_path(StringRef path LLVM_LIFETIME_BOUND, +Style style = Style::native); /// Get relative path. /// @@ -330,7 +334,8 @@ StringRef root_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::nat /// /// @param path Input path. /// @result The path starting after root_path if one exists, otherwise "". -StringRef relative_path(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); +StringRef relative_path(StringRef path LLVM_LIFETIME_BOUND, +Style style = Style::native); /// Get parent path. /// @@ -357,7 +362,8 @@ StringRef parent_path(StringRef path LLVM_LIFETIME_BOUND, /// @param path Input path. /// @result The filename part of \a path. This is defined as the last component /// of \a path. Similar to the POSIX "basename" utility. -StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style = Style::native); +StringRef filename(StringRef path LLVM_LIFETIME_BOUND, + Style style = Style::native); /// Get stem. /// `` https://github.com/llvm/llvm-project/pull/122890 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fabc443 - [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (#116051)
Author: Sergio Afonso Date: 2025-01-14T12:34:37Z New Revision: fabc443e9394e460d328984d75570d9f017fe709 URL: https://github.com/llvm/llvm-project/commit/fabc443e9394e460d328984d75570d9f017fe709 DIFF: https://github.com/llvm/llvm-project/commit/fabc443e9394e460d328984d75570d9f017fe709.diff LOG: [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (#116051) This patch introduces a `TargetKernelRuntimeAttrs` structure to hold host-evaluated `num_teams`, `thread_limit`, `num_threads` and trip count values passed to the runtime kernel offloading call. Additionally, kernel type information is used to influence target device code generation and the `IsSPMD` flag is replaced by `ExecFlags`, which provides more granularity. Added: Modified: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index 81993dafae2b03..87c3635ed3f70e 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -20,6 +20,7 @@ #include "clang/AST/StmtVisitor.h" #include "clang/Basic/Cuda.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" using namespace clang; @@ -745,7 +746,9 @@ void CGOpenMPRuntimeGPU::emitKernelInit(const OMPExecutableDirective &D, CodeGenFunction &CGF, EntryFunctionState &EST, bool IsSPMD) { llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs Attrs; - Attrs.IsSPMD = IsSPMD; + Attrs.ExecFlags = + IsSPMD ? llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_SPMD + : llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_GENERIC; computeMinAndMaxThreadsAndTeams(D, CGF, Attrs); CGBuilderTy &Bld = CGF.Builder; diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h index 8ca3bc08b5ad49..7eceec3d8cf8f5 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -1389,9 +1389,6 @@ class OpenMPIRBuilder { /// Supporting functions for Reductions CodeGen. private: - /// Emit the llvm.used metadata. - void emitUsed(StringRef Name, std::vector &List); - /// Get the id of the current thread on the GPU. Value *getGPUThreadID(); @@ -2013,6 +2010,13 @@ class OpenMPIRBuilder { /// Value. GlobalValue *createGlobalFlag(unsigned Value, StringRef Name); + /// Emit the llvm.used metadata. + void emitUsed(StringRef Name, ArrayRef List); + + /// Emit the kernel execution mode. + GlobalVariable *emitKernelExecutionMode(StringRef KernelName, + omp::OMPTgtExecModeFlags Mode); + /// Generate control flow and cleanup for cancellation. /// /// \param CancelFlag Flag indicating if the cancellation is performed. @@ -2233,13 +2237,34 @@ class OpenMPIRBuilder { /// time. The number of max values will be 1 except for the case where /// ompx_bare is set. struct TargetKernelDefaultAttrs { -bool IsSPMD = false; +omp::OMPTgtExecModeFlags ExecFlags = +omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_GENERIC; SmallVector MaxTeams = {-1}; int32_t MinTeams = 1; SmallVector MaxThreads = {-1}; int32_t MinThreads = 1; }; + /// Container to pass LLVM IR runtime values or constants related to the + /// number of teams and threads with which the kernel must be launched, as + /// well as the trip count of the loop, if it is an SPMD or Generic-SPMD + /// kernel. These must be defined in the host prior to the call to the kernel + /// launch OpenMP RTL function. + struct TargetKernelRuntimeAttrs { +SmallVector MaxTeams = {nullptr}; +Value *MinTeams = nullptr; +SmallVector TargetThreadLimit = {nullptr}; +SmallVector TeamsThreadLimit = {nullptr}; + +/// 'parallel' construct 'num_threads' clause value, if present and it is an +/// SPMD kernel. +Value *MaxThreads = nullptr; + +/// Total number of iterations of the SPMD or Generic-SPMD kernel or null if +/// it is a generic kernel. +Value *LoopTripCount = nullptr; + }; + /// Data structure that contains the needed information to construct the /// kernel args vector. struct TargetKernelArgs { @@ -2971,7 +2996,9 @@ class OpenMPIRBuilder { /// \param CodeGenIP The insertion point where the call to the outlined /// function should be emitted. /// \param EntryInfo The entry information about the function. - /// \param DefaultAttrs Structure contai
[clang] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)
https://github.com/skatrak closed https://github.com/llvm/llvm-project/pull/116051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] Propagate attributes to outlined target regions (PR #117875)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/117875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [mlir] [MLIR][OpenMP] LLVM IR translation of host_eval (PR #116052)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/116052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Mark global decls with diagnostics invalid (PR #122895)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/122895 Even if their evaluation succeeds, mark them as invalid. This fixes some long standing differences to the ast walker interpeter. >From 66c1a54bf96661aa0e5b60cf121b03776a8dcbbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 14 Jan 2025 13:16:31 +0100 Subject: [PATCH] [clang][bytecode] Mark global decls with diagnostics invalid Even if their evaluation succeeds, mark them as invalid. This fixes some long standing differences to the ast walker interpeter. --- clang/lib/AST/ByteCode/EvalEmitter.cpp | 12 clang/test/AST/ByteCode/arrays.cpp | 15 +++ clang/test/AST/ByteCode/cxx23.cpp | 9 +++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp index 9763fe89b73742..f9220e89abbc85 100644 --- a/clang/lib/AST/ByteCode/EvalEmitter.cpp +++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp @@ -71,6 +71,18 @@ EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD, if (!this->visitDeclAndReturn(VD, S.inConstantContext())) EvalResult.setInvalid(); + // Mark global variables as invalid if any diagnostic was produced. + if (S.hasPriorDiagnostic() && Context::shouldBeGloballyIndexed(VD)) { +if (auto GlobalIndex = P.getGlobal(VD)) { + Block *GlobalBlock = P.getGlobal(*GlobalIndex); + GlobalInlineDescriptor &GD = + *reinterpret_cast(GlobalBlock->rawData()); + GD.InitState = GlobalInitState::InitializerFailed; + if (GlobalBlock->isInitialized()) +GlobalBlock->invokeDtor(); +} + } + S.EvaluatingDecl = nullptr; updateGlobalTemporaries(); return std::move(this->EvalResult); diff --git a/clang/test/AST/ByteCode/arrays.cpp b/clang/test/AST/ByteCode/arrays.cpp index 4097c65f7c6fba..297894659ff199 100644 --- a/clang/test/AST/ByteCode/arrays.cpp +++ b/clang/test/AST/ByteCode/arrays.cpp @@ -402,14 +402,13 @@ namespace NoInitMapLeak { constexpr int a[] = {1,2,3,4/0,5}; // both-error {{must be initialized by a constant expression}} \ // both-note {{division by zero}} \ - // ref-note {{declared here}} - - /// FIXME: This should fail in the new interpreter as well. - constexpr int b = a[0]; // ref-error {{must be initialized by a constant expression}} \ - // ref-note {{is not a constant expression}} \ - // ref-note {{declared here}} - static_assert(b == 1, ""); // ref-error {{not an integral constant expression}} \ - // ref-note {{not a constant expression}} + // both-note {{declared here}} + + constexpr int b = a[0]; // both-error {{must be initialized by a constant expression}} \ + // both-note {{is not a constant expression}} \ + // both-note {{declared here}} + static_assert(b == 1, ""); // both-error {{not an integral constant expression}} \ + // both-note {{not a constant expression}} constexpr int f() { // both-error {{never produces a constant expression}} int a[] = {19,2,3/0,4}; // both-note 2{{division by zero}} \ diff --git a/clang/test/AST/ByteCode/cxx23.cpp b/clang/test/AST/ByteCode/cxx23.cpp index 6a62ac11cde792..5c437c2eef84bf 100644 --- a/clang/test/AST/ByteCode/cxx23.cpp +++ b/clang/test/AST/ByteCode/cxx23.cpp @@ -217,16 +217,13 @@ namespace UndefinedThreeWay { // all-note {{undefined function 'operator<=>' cannot be used in a constant expression}} } -/// FIXME: The new interpreter is missing the "initializer of q is not a constant expression" diagnostics.a -/// That's because the cast from void* to int* is considered fine, but diagnosed. So we don't consider -/// q to be uninitialized. namespace VoidCast { constexpr void* p = nullptr; constexpr int* q = static_cast(p); // all-error {{must be initialized by a constant expression}} \ // all-note {{cast from 'void *' is not allowed in a constant expression}} \ - // ref-note {{declared here}} - static_assert(q == nullptr); // ref-error {{not an integral constant expression}} \ - // ref-note {{initializer of 'q' is not a constant expression}} + // all-note {{declared here}} + static_assert(q == nullptr); // all-error {{not an integral constant expression}} \ + // all-note {{initializer of 'q' is not a constant expression}} } namespace ExplicitLambdaInstancePointer { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com
[clang] [clang][bytecode] Mark global decls with diagnostics invalid (PR #122895)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes Even if their evaluation succeeds, mark them as invalid. This fixes some long standing differences to the ast walker interpeter. --- Full diff: https://github.com/llvm/llvm-project/pull/122895.diff 3 Files Affected: - (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+12) - (modified) clang/test/AST/ByteCode/arrays.cpp (+7-8) - (modified) clang/test/AST/ByteCode/cxx23.cpp (+3-6) ``diff diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp index 9763fe89b73742..f9220e89abbc85 100644 --- a/clang/lib/AST/ByteCode/EvalEmitter.cpp +++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp @@ -71,6 +71,18 @@ EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD, if (!this->visitDeclAndReturn(VD, S.inConstantContext())) EvalResult.setInvalid(); + // Mark global variables as invalid if any diagnostic was produced. + if (S.hasPriorDiagnostic() && Context::shouldBeGloballyIndexed(VD)) { +if (auto GlobalIndex = P.getGlobal(VD)) { + Block *GlobalBlock = P.getGlobal(*GlobalIndex); + GlobalInlineDescriptor &GD = + *reinterpret_cast(GlobalBlock->rawData()); + GD.InitState = GlobalInitState::InitializerFailed; + if (GlobalBlock->isInitialized()) +GlobalBlock->invokeDtor(); +} + } + S.EvaluatingDecl = nullptr; updateGlobalTemporaries(); return std::move(this->EvalResult); diff --git a/clang/test/AST/ByteCode/arrays.cpp b/clang/test/AST/ByteCode/arrays.cpp index 4097c65f7c6fba..297894659ff199 100644 --- a/clang/test/AST/ByteCode/arrays.cpp +++ b/clang/test/AST/ByteCode/arrays.cpp @@ -402,14 +402,13 @@ namespace NoInitMapLeak { constexpr int a[] = {1,2,3,4/0,5}; // both-error {{must be initialized by a constant expression}} \ // both-note {{division by zero}} \ - // ref-note {{declared here}} - - /// FIXME: This should fail in the new interpreter as well. - constexpr int b = a[0]; // ref-error {{must be initialized by a constant expression}} \ - // ref-note {{is not a constant expression}} \ - // ref-note {{declared here}} - static_assert(b == 1, ""); // ref-error {{not an integral constant expression}} \ - // ref-note {{not a constant expression}} + // both-note {{declared here}} + + constexpr int b = a[0]; // both-error {{must be initialized by a constant expression}} \ + // both-note {{is not a constant expression}} \ + // both-note {{declared here}} + static_assert(b == 1, ""); // both-error {{not an integral constant expression}} \ + // both-note {{not a constant expression}} constexpr int f() { // both-error {{never produces a constant expression}} int a[] = {19,2,3/0,4}; // both-note 2{{division by zero}} \ diff --git a/clang/test/AST/ByteCode/cxx23.cpp b/clang/test/AST/ByteCode/cxx23.cpp index 6a62ac11cde792..5c437c2eef84bf 100644 --- a/clang/test/AST/ByteCode/cxx23.cpp +++ b/clang/test/AST/ByteCode/cxx23.cpp @@ -217,16 +217,13 @@ namespace UndefinedThreeWay { // all-note {{undefined function 'operator<=>' cannot be used in a constant expression}} } -/// FIXME: The new interpreter is missing the "initializer of q is not a constant expression" diagnostics.a -/// That's because the cast from void* to int* is considered fine, but diagnosed. So we don't consider -/// q to be uninitialized. namespace VoidCast { constexpr void* p = nullptr; constexpr int* q = static_cast(p); // all-error {{must be initialized by a constant expression}} \ // all-note {{cast from 'void *' is not allowed in a constant expression}} \ - // ref-note {{declared here}} - static_assert(q == nullptr); // ref-error {{not an integral constant expression}} \ - // ref-note {{initializer of 'q' is not a constant expression}} + // all-note {{declared here}} + static_assert(q == nullptr); // all-error {{not an integral constant expression}} \ + // all-note {{initializer of 'q' is not a constant expression}} } namespace ExplicitLambdaInstancePointer { `` https://github.com/llvm/llvm-project/pull/122895 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -3134,6 +3139,17 @@ Attr *ASTRecordReader::readAttr() { // Kind is stored as a 1-based integer because 0 is used to indicate a null // Attr pointer. auto Kind = static_cast(V - 1); + if (Kind == attr::PreferredName && D != nullptr) { +if (D != nullptr) { VitaNuo wrote: > D is never null here, this if seems to be redundant. This is actually not true. This is a trick that allows to send deserialization on two different paths when (1) deserializing the decl in the main deserialization round vs. (2) deserializing the pending attribute. In (1) Decl is not null, and the attribute is deferred (and the Decl stored in the pending attributes structure), whereas in (2) the deserialization of the attribute has been initiated by processing the pending attributes, and we don't want to send it on a circle by deferring it again, so we set the Decl to `nullptr` in this call `readOrDeferAttrImpl`. https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] [Modules] Delay reading type source info of the preferred_name attribute. (PR #122250)
ilya-biryukov wrote: I have jumped ahead of the train and left some comments. Feel free to ignore them for now, I'd be happy to do another round of review when it's actually ready. https://github.com/llvm/llvm-project/pull/122250 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -4424,6 +4454,51 @@ void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) { ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent); } +void ASTReader::loadPreferredNameAttribute( +const PendingPreferredNameAttribute &PreferredNameAttribute) { + Decl *D = PreferredNameAttribute.D; + ModuleFile *M = getOwningModuleFile(D); + + unsigned LocalDeclIndex = D->getGlobalID().getLocalDeclIndex(); + const DeclOffset &DOffs = M->DeclOffsets[LocalDeclIndex]; + RecordLocation Loc(M, DOffs.getBitOffset(M->DeclsBlockStartOffset)); + + llvm::BitstreamCursor &Cursor = Loc.F->DeclsCursor; + SavedStreamPosition SavedPosition(Cursor); + if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) { +Error(std::move(Err)); + } + + Expected MaybeCode = Cursor.ReadCode(); + if (!MaybeCode) { +llvm::report_fatal_error( +Twine("ASTReader::loadPreferredNameAttribute failed reading code: ") + +toString(MaybeCode.takeError())); + } + unsigned Code = MaybeCode.get(); + + ASTRecordReader Record(*this, *Loc.F); + Expected MaybeRecCode = Record.readRecord(Cursor, Code); + if (!MaybeRecCode) { +llvm::report_fatal_error( +Twine( +"ASTReader::loadPreferredNameAttribute failed reading rec code: ") + +toString(MaybeCode.takeError())); + } + unsigned RecCode = MaybeRecCode.get(); + if (RecCode != DECL_CXX_RECORD) { +llvm::report_fatal_error( +Twine("ASTReader::loadPreferredNameAttribute failed reading rec code: " + "expected CXXRecord") + +toString(MaybeCode.takeError())); + } + + Record.skipInts(PreferredNameAttribute.RecordIdx); + Attr *PreferredNameAttr = Record.readAttr(nullptr); + AttrVec &Attrs = getContext().getDeclAttrs(D); + Attrs.push_back(PreferredNameAttr); ilya-biryukov wrote: NIT: maybe merge the two lines? `getContext().getDeclAttrs(D).push_back(PreferredNameAttr)` https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -4424,6 +4454,51 @@ void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) { ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent); } +void ASTReader::loadPreferredNameAttribute( +const PendingPreferredNameAttribute &PreferredNameAttribute) { + Decl *D = PreferredNameAttribute.D; + ModuleFile *M = getOwningModuleFile(D); + + unsigned LocalDeclIndex = D->getGlobalID().getLocalDeclIndex(); + const DeclOffset &DOffs = M->DeclOffsets[LocalDeclIndex]; + RecordLocation Loc(M, DOffs.getBitOffset(M->DeclsBlockStartOffset)); + + llvm::BitstreamCursor &Cursor = Loc.F->DeclsCursor; + SavedStreamPosition SavedPosition(Cursor); + if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) { +Error(std::move(Err)); + } + + Expected MaybeCode = Cursor.ReadCode(); + if (!MaybeCode) { +llvm::report_fatal_error( +Twine("ASTReader::loadPreferredNameAttribute failed reading code: ") + +toString(MaybeCode.takeError())); + } + unsigned Code = MaybeCode.get(); + + ASTRecordReader Record(*this, *Loc.F); + Expected MaybeRecCode = Record.readRecord(Cursor, Code); + if (!MaybeRecCode) { +llvm::report_fatal_error( +Twine( +"ASTReader::loadPreferredNameAttribute failed reading rec code: ") + +toString(MaybeCode.takeError())); + } + unsigned RecCode = MaybeRecCode.get(); + if (RecCode != DECL_CXX_RECORD) { ilya-biryukov wrote: Any reason to limit this to this particular `Decl`? I think having a generic mechanism that works for any decls is fine here, just in case we need to defer more attributes. https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -3134,6 +3139,17 @@ Attr *ASTRecordReader::readAttr() { // Kind is stored as a 1-based integer because 0 is used to indicate a null // Attr pointer. auto Kind = static_cast(V - 1); + if (Kind == attr::PreferredName && D != nullptr) { ilya-biryukov wrote: Could you add a comment explaining why we need to defer some attribute? https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -4925,6 +4930,11 @@ void ASTRecordWriter::AddAttr(const Attr *A) { Record.push_back(A->isRegularKeywordAttribute()); #include "clang/Serialization/AttrPCHWrite.inc" + + if (A->getKind() == attr::PreferredName) +// Record the actual size of preferred_name attribute (-1 to count the ilya-biryukov wrote: LLVM Style Guide covers this situation and suggests to have braces when there are comments in the single branch, see https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements. Could you add braces here? The `if` above is a bit more borderline, but I'd also suggest adding braces there. https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -4424,6 +4454,51 @@ void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) { ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent); } +void ASTReader::loadPreferredNameAttribute( +const PendingPreferredNameAttribute &PreferredNameAttribute) { + Decl *D = PreferredNameAttribute.D; + ModuleFile *M = getOwningModuleFile(D); + + unsigned LocalDeclIndex = D->getGlobalID().getLocalDeclIndex(); ilya-biryukov wrote: I thought we might need to store the indices separately, but having the declaration around we actually have enough to look up the bitstream position. Nice trick, kudos for coming up with this! https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -3134,6 +3139,17 @@ Attr *ASTRecordReader::readAttr() { // Kind is stored as a 1-based integer because 0 is used to indicate a null // Attr pointer. auto Kind = static_cast(V - 1); + if (Kind == attr::PreferredName && D != nullptr) { +if (D != nullptr) { ilya-biryukov wrote: D is never null here, this if seems to be redundant. Also, should we `assert` that `D != nullptr` when we deserialize `PreferredName`? If we start deferring more attributes at some point, an assertion like this might not hold up, but it gives a good sanity check for preferred name specifically, because it should always be attached to some declaration. https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -1205,6 +1205,12 @@ class ASTReader /// been completed. std::deque PendingDeclContextInfos; + struct PendingPreferredNameAttribute { ilya-biryukov wrote: NIT: there's nothing specific to `PreferredName` her, could we just call it `DeferredAttribute`? (Same for functions that have it as a substring) https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -1205,6 +1205,12 @@ class ASTReader /// been completed. std::deque PendingDeclContextInfos; + struct PendingPreferredNameAttribute { +uint64_t RecordIdx; +Decl *D; ilya-biryukov wrote: Could we use a more descriptive name and/or add a comment explaining why we have this `Decl` here? `D` looks fine for parameters, but a little too short for a `struct`. https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
https://github.com/ilya-biryukov commented: I know this is marked as `WIP`, but I find the direction promising so I went ahead and actually made a round of review. Please wait for @ChuanqiXu9 in case he'll have more comments, but I hope two of us are not too far off in terms of where we want this to go. https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [flang] [libc] [lldb] [llvm] [mlir] [llvm-project] Fix typos mutli and mutliple. NFC. (PR #122880)
llvmbot wrote: @llvm/pr-subscribers-debuginfo Author: Jay Foad (jayfoad) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/122880.diff 17 Files Affected: - (modified) clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp (+2-2) - (modified) clang/lib/Basic/SourceManager.cpp (+1-1) - (modified) flang/test/HLFIR/associate-codegen.fir (+1-1) - (modified) libc/test/src/unistd/getopt_test.cpp (+1-1) - (modified) lldb/source/Commands/CommandObjectMemory.cpp (+1-1) - (modified) lldb/source/Target/StructuredDataPlugin.cpp (+1-1) - (modified) lldb/unittests/Target/RegisterFlagsTest.cpp (+1-1) - (modified) llvm/include/llvm/IR/DebugInfoMetadata.h (+1-1) - (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-1) - (modified) llvm/test/CodeGen/AArch64/eon.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/multiple-at-const-val.ll (+1-1) - (modified) llvm/test/Transforms/EarlyCSE/guards.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/matrix-multiplication-negation.ll (+6-6) - (modified) llvm/test/Transforms/LoopVectorize/RISCV/blend-any-of-reduction-cost.ll (+2-2) - (modified) mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir (+6-6) - (modified) mlir/test/Transforms/mem2reg.mlir (+1-1) - (modified) mlir/test/Transforms/sroa.mlir (+1-1) ``diff diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp index aec67808846b12..7a2d804e173ce4 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp @@ -342,7 +342,7 @@ static void ignoreTypeLocClasses( Loc = Loc.getNextTypeLoc(); } -static bool isMutliLevelPointerToTypeLocClasses( +static bool isMultiLevelPointerToTypeLocClasses( TypeLoc Loc, std::initializer_list const &LocClasses) { ignoreTypeLocClasses(Loc, {TypeLoc::Paren, TypeLoc::Qualified}); @@ -424,7 +424,7 @@ void UseAutoCheck::replaceExpr( auto Diag = diag(Range.getBegin(), Message); - bool ShouldReplenishVariableName = isMutliLevelPointerToTypeLocClasses( + bool ShouldReplenishVariableName = isMultiLevelPointerToTypeLocClasses( TSI->getTypeLoc(), {TypeLoc::FunctionProto, TypeLoc::ConstantArray}); // Space after 'auto' to handle cases where the '*' in the pointer type is diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 44e982d3ee67fb..b1f2180c1d4627 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1222,7 +1222,7 @@ unsigned SourceManager::getPresumedColumnNumber(SourceLocation Loc, return PLoc.getColumn(); } -// Check if mutli-byte word x has bytes between m and n, included. This may also +// Check if multi-byte word x has bytes between m and n, included. This may also // catch bytes equal to n + 1. // The returned value holds a 0x80 at each byte position that holds a match. // see http://graphics.stanford.edu/~seander/bithacks.html#HasBetweenInWord diff --git a/flang/test/HLFIR/associate-codegen.fir b/flang/test/HLFIR/associate-codegen.fir index f5e015c4169f60..ad64959984a14a 100644 --- a/flang/test/HLFIR/associate-codegen.fir +++ b/flang/test/HLFIR/associate-codegen.fir @@ -372,7 +372,7 @@ func.func @_QPtest_multiple_expr_uses_inside_elemental() { // CHECK: return // CHECK: } -// Verify that we properly recognize mutliple consequent hlfir.associate using +// Verify that we properly recognize multiple consequent hlfir.associate using // the same result of hlfir.elemental. func.func @_QPtest_multitple_associates_for_same_expr() { %c1 = arith.constant 1 : index diff --git a/libc/test/src/unistd/getopt_test.cpp b/libc/test/src/unistd/getopt_test.cpp index e6e87720cde48d..8217f7bb6e7313 100644 --- a/libc/test/src/unistd/getopt_test.cpp +++ b/libc/test/src/unistd/getopt_test.cpp @@ -155,7 +155,7 @@ TEST_F(LlvmLibcGetoptTest, ParseArgInNext) { EXPECT_EQ(test_globals::optind, 3); } -TEST_F(LlvmLibcGetoptTest, ParseMutliInOne) { +TEST_F(LlvmLibcGetoptTest, ParseMultiInOne) { array argv{"prog"_c, "-abc"_c, nullptr}; EXPECT_EQ(LIBC_NAMESPACE::getopt(2, argv.data(), "abc"), (int)'a'); diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index b5612f21f11563..164c61d1720171 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1737,7 +1737,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed { // It is important that we track the address used to request the region as // this will give the correct section name in the case that regions overlap. -// On Windows we get mutliple regions that start at the same place but are +// On Windows we get multiple regions that start at the same place but are // different sizes and refer to different sections. std::v
[clang] [clang-tools-extra] [flang] [libc] [lldb] [llvm] [mlir] [llvm-project] Fix typos mutli and mutliple. NFC. (PR #122880)
llvmbot wrote: @llvm/pr-subscribers-clang-tidy @llvm/pr-subscribers-lldb @llvm/pr-subscribers-clang Author: Jay Foad (jayfoad) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/122880.diff 17 Files Affected: - (modified) clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp (+2-2) - (modified) clang/lib/Basic/SourceManager.cpp (+1-1) - (modified) flang/test/HLFIR/associate-codegen.fir (+1-1) - (modified) libc/test/src/unistd/getopt_test.cpp (+1-1) - (modified) lldb/source/Commands/CommandObjectMemory.cpp (+1-1) - (modified) lldb/source/Target/StructuredDataPlugin.cpp (+1-1) - (modified) lldb/unittests/Target/RegisterFlagsTest.cpp (+1-1) - (modified) llvm/include/llvm/IR/DebugInfoMetadata.h (+1-1) - (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+1-1) - (modified) llvm/test/CodeGen/AArch64/eon.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/multiple-at-const-val.ll (+1-1) - (modified) llvm/test/Transforms/EarlyCSE/guards.ll (+1-1) - (modified) llvm/test/Transforms/InstCombine/matrix-multiplication-negation.ll (+6-6) - (modified) llvm/test/Transforms/LoopVectorize/RISCV/blend-any-of-reduction-cost.ll (+2-2) - (modified) mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir (+6-6) - (modified) mlir/test/Transforms/mem2reg.mlir (+1-1) - (modified) mlir/test/Transforms/sroa.mlir (+1-1) ``diff diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp index aec67808846b12..7a2d804e173ce4 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp @@ -342,7 +342,7 @@ static void ignoreTypeLocClasses( Loc = Loc.getNextTypeLoc(); } -static bool isMutliLevelPointerToTypeLocClasses( +static bool isMultiLevelPointerToTypeLocClasses( TypeLoc Loc, std::initializer_list const &LocClasses) { ignoreTypeLocClasses(Loc, {TypeLoc::Paren, TypeLoc::Qualified}); @@ -424,7 +424,7 @@ void UseAutoCheck::replaceExpr( auto Diag = diag(Range.getBegin(), Message); - bool ShouldReplenishVariableName = isMutliLevelPointerToTypeLocClasses( + bool ShouldReplenishVariableName = isMultiLevelPointerToTypeLocClasses( TSI->getTypeLoc(), {TypeLoc::FunctionProto, TypeLoc::ConstantArray}); // Space after 'auto' to handle cases where the '*' in the pointer type is diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 44e982d3ee67fb..b1f2180c1d4627 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1222,7 +1222,7 @@ unsigned SourceManager::getPresumedColumnNumber(SourceLocation Loc, return PLoc.getColumn(); } -// Check if mutli-byte word x has bytes between m and n, included. This may also +// Check if multi-byte word x has bytes between m and n, included. This may also // catch bytes equal to n + 1. // The returned value holds a 0x80 at each byte position that holds a match. // see http://graphics.stanford.edu/~seander/bithacks.html#HasBetweenInWord diff --git a/flang/test/HLFIR/associate-codegen.fir b/flang/test/HLFIR/associate-codegen.fir index f5e015c4169f60..ad64959984a14a 100644 --- a/flang/test/HLFIR/associate-codegen.fir +++ b/flang/test/HLFIR/associate-codegen.fir @@ -372,7 +372,7 @@ func.func @_QPtest_multiple_expr_uses_inside_elemental() { // CHECK: return // CHECK: } -// Verify that we properly recognize mutliple consequent hlfir.associate using +// Verify that we properly recognize multiple consequent hlfir.associate using // the same result of hlfir.elemental. func.func @_QPtest_multitple_associates_for_same_expr() { %c1 = arith.constant 1 : index diff --git a/libc/test/src/unistd/getopt_test.cpp b/libc/test/src/unistd/getopt_test.cpp index e6e87720cde48d..8217f7bb6e7313 100644 --- a/libc/test/src/unistd/getopt_test.cpp +++ b/libc/test/src/unistd/getopt_test.cpp @@ -155,7 +155,7 @@ TEST_F(LlvmLibcGetoptTest, ParseArgInNext) { EXPECT_EQ(test_globals::optind, 3); } -TEST_F(LlvmLibcGetoptTest, ParseMutliInOne) { +TEST_F(LlvmLibcGetoptTest, ParseMultiInOne) { array argv{"prog"_c, "-abc"_c, nullptr}; EXPECT_EQ(LIBC_NAMESPACE::getopt(2, argv.data(), "abc"), (int)'a'); diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index b5612f21f11563..164c61d1720171 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1737,7 +1737,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed { // It is important that we track the address used to request the region as // this will give the correct section name in the case that regions overlap. -// On Windows we get mutliple regions that start at the same place but are +// On Windows we get multiple regions that start at the same place but are // differ
[clang] [clang-tools-extra] [flang] [libc] [lldb] [llvm] [mlir] [llvm-project] Fix typos mutli and mutliple. NFC. (PR #122880)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/122880 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] Introduce struct to hold default kernel teams/threads (PR #116050)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/116050 >From 219d430cf7697eb2c4bcb5832695571ff472e0e2 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Fri, 8 Nov 2024 15:46:48 + Subject: [PATCH] [OMPIRBuilder] Introduce struct to hold default kernel teams/threads This patch introduces the `OpenMPIRBuilder::TargetKernelDefaultAttrs` structure used to simplify passing default and constant values for number of teams and threads, and possibly other target kernel-related information in the future. This is used to forward values passed to `createTarget` to `createTargetInit`, which previously used a default unrelated set of values. --- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 13 ++-- clang/lib/CodeGen/CGOpenMPRuntime.h | 9 +-- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 10 +-- .../llvm/Frontend/OpenMP/OMPIRBuilder.h | 41 ++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 75 +++ .../Frontend/OpenMPIRBuilderTest.cpp | 22 -- .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 12 +-- .../LLVMIR/omptarget-region-device-llvm.mlir | 2 +- 8 files changed, 106 insertions(+), 78 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 1868b57cea9039..244e3066f8fe41 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -5880,10 +5880,13 @@ void CGOpenMPRuntime::emitUsesAllocatorsFini(CodeGenFunction &CGF, void CGOpenMPRuntime::computeMinAndMaxThreadsAndTeams( const OMPExecutableDirective &D, CodeGenFunction &CGF, -int32_t &MinThreadsVal, int32_t &MaxThreadsVal, int32_t &MinTeamsVal, -int32_t &MaxTeamsVal) { +llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs &Attrs) { + assert(Attrs.MaxTeams.size() == 1 && Attrs.MaxThreads.size() == 1 && + "invalid default attrs structure"); + int32_t &MaxTeamsVal = Attrs.MaxTeams.front(); + int32_t &MaxThreadsVal = Attrs.MaxThreads.front(); - getNumTeamsExprForTargetDirective(CGF, D, MinTeamsVal, MaxTeamsVal); + getNumTeamsExprForTargetDirective(CGF, D, Attrs.MinTeams, MaxTeamsVal); getNumThreadsExprForTargetDirective(CGF, D, MaxThreadsVal, /*UpperBoundOnly=*/true); @@ -5901,12 +5904,12 @@ void CGOpenMPRuntime::computeMinAndMaxThreadsAndTeams( else continue; - MinThreadsVal = std::max(MinThreadsVal, AttrMinThreadsVal); + Attrs.MinThreads = std::max(Attrs.MinThreads, AttrMinThreadsVal); if (AttrMaxThreadsVal > 0) MaxThreadsVal = MaxThreadsVal > 0 ? std::min(MaxThreadsVal, AttrMaxThreadsVal) : AttrMaxThreadsVal; - MinTeamsVal = std::max(MinTeamsVal, AttrMinBlocksVal); + Attrs.MinTeams = std::max(Attrs.MinTeams, AttrMinBlocksVal); if (AttrMaxBlocksVal > 0) MaxTeamsVal = MaxTeamsVal > 0 ? std::min(MaxTeamsVal, AttrMaxBlocksVal) : AttrMaxBlocksVal; diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h index 8ab5ee70a19fa2..3791bb71592350 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -313,12 +313,9 @@ class CGOpenMPRuntime { llvm::OpenMPIRBuilder OMPBuilder; /// Helper to determine the min/max number of threads/teams for \p D. - void computeMinAndMaxThreadsAndTeams(const OMPExecutableDirective &D, - CodeGenFunction &CGF, - int32_t &MinThreadsVal, - int32_t &MaxThreadsVal, - int32_t &MinTeamsVal, - int32_t &MaxTeamsVal); + void computeMinAndMaxThreadsAndTeams( + const OMPExecutableDirective &D, CodeGenFunction &CGF, + llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs &Attrs); /// Helper to emit outlined function for 'target' directive. /// \param D Directive to emit. diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index dbb19f2a8d825a..81993dafae2b03 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -744,14 +744,12 @@ void CGOpenMPRuntimeGPU::emitNonSPMDKernel(const OMPExecutableDirective &D, void CGOpenMPRuntimeGPU::emitKernelInit(const OMPExecutableDirective &D, CodeGenFunction &CGF, EntryFunctionState &EST, bool IsSPMD) { - int32_t MinThreadsVal = 1, MaxThreadsVal = -1, MinTeamsVal = 1, - MaxTeamsVal = -1; - computeMinAndMaxThreadsAndTeams(D, CGF, MinThreadsVal, MaxThreadsVal, - MinTeamsVal, MaxTeamsVal); + llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs Attrs; + Attrs.IsSPMD = IsSPMD; + computeMinAndMaxThreadsAndTeams(D,
[clang] 9988309 - [clang] Do not allow unorderable features in [[gnu::target{,_clones}]] (#98426)
Author: Dan Klishch Date: 2025-01-14T18:27:51+08:00 New Revision: 9988309d5537e2954376005b07e9750cb62574a3 URL: https://github.com/llvm/llvm-project/commit/9988309d5537e2954376005b07e9750cb62574a3 DIFF: https://github.com/llvm/llvm-project/commit/9988309d5537e2954376005b07e9750cb62574a3.diff LOG: [clang] Do not allow unorderable features in [[gnu::target{,_clones}]] (#98426) This partially addresses #98244. Added: Modified: clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/test/Sema/attr-target-clones.c clang/test/Sema/attr-target-mv.c clang/test/Sema/attr-target.c Removed: diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f5e57988b7fa8d..fd3a5ec49771d9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -11136,7 +11136,8 @@ static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD) { } if (!TargetInfo.validateCpuSupports(BareFeat) || - !TargetInfo.isValidFeatureName(BareFeat)) { + !TargetInfo.isValidFeatureName(BareFeat) || + (BareFeat != "default" && TargetInfo.getFMVPriority(BareFeat) == 0)) { S.Diag(FD->getLocation(), diag::err_bad_multiversion_option) << Feature << BareFeat; return true; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index c1663f2d15c88b..c2d82b9aa9b321 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -3289,7 +3289,8 @@ bool Sema::checkTargetClonesAttrString( } else if (Cur == "default") { DefaultIsDupe = HasDefault; HasDefault = true; - } else if (!Context.getTargetInfo().isValidFeatureName(Cur)) + } else if (!Context.getTargetInfo().isValidFeatureName(Cur) || + Context.getTargetInfo().getFMVPriority(Cur) == 0) return Diag(CurLoc, diag::warn_unsupported_target_attribute) << Unsupported << None << Cur << TargetClones; if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe) diff --git a/clang/test/Sema/attr-target-clones.c b/clang/test/Sema/attr-target-clones.c index e287fce7699b77..4597ea54d02bfe 100644 --- a/clang/test/Sema/attr-target-clones.c +++ b/clang/test/Sema/attr-target-clones.c @@ -122,3 +122,6 @@ void good_overload5(int) __attribute__((target_clones("mmx", "sse4.2", "default" void good_isa_level(int) __attribute__((target_clones("default", "arch=x86-64", "arch=x86-64-v2", "arch=x86-64-v3", "arch=x86-64-v4"))); // expected-warning@+1 {{unsupported CPU 'x86-64-v5' in the 'target_clones' attribute string; 'target_clones' attribute ignored}} void bad_isa_level(int) __attribute__((target_clones("default", "arch=x86-64-v5"))); + +// expected-warning@+1 {{unsupported 'sha' in the 'target_clones' attribute string; 'target_clones' attribute ignored}} +void bad_feature(void) __attribute__((target_clones("default", "sse4.2", "sha"))); diff --git a/clang/test/Sema/attr-target-mv.c b/clang/test/Sema/attr-target-mv.c index 8218771275e1bd..ddb1d82b02f098 100644 --- a/clang/test/Sema/attr-target-mv.c +++ b/clang/test/Sema/attr-target-mv.c @@ -170,3 +170,17 @@ int __attribute__((__overloadable__)) __attribute__((target("arch=sandybridge")) int __attribute__((__overloadable__)) __attribute__((target("sse4.2"))) good_overload7(void); int __attribute__((target("arch=sandybridge"))) good_overload7(int); + +// expected-error@+2 {{function multiversioning doesn't support feature 'sha'}} +// expected-note@+2 {{function multiversioning caused by this declaration}} +int __attribute__((target("sha"))) no_priority1(void); +int __attribute__((target("default"))) no_priority1(void); + +int __attribute__((target("default"))) no_priority2(void); +// expected-error@+1 {{function multiversioning doesn't support feature 'sha'}} +int __attribute__((target("sha"))) no_priority2(void); + +int __attribute__((target("default"))) no_priority3(void); +int __attribute__((target("avx2"))) no_priority3(void); +// expected-error@+1 {{function multiversioning doesn't support feature 'sha'}} +int __attribute__((target("sha"))) no_priority3(void); diff --git a/clang/test/Sema/attr-target.c b/clang/test/Sema/attr-target.c index 5328f056507a71..65ece3c27d2990 100644 --- a/clang/test/Sema/attr-target.c +++ b/clang/test/Sema/attr-target.c @@ -33,6 +33,8 @@ void __attribute__((target("x86-64"))) baseline(void) {} //expected-warning@+1 {{unsupported 'x86-64-v2' in the 'target' attribute string}} void __attribute__((target("x86-64-v2"))) v2(void) {} +int __attribute__((target("sha"))) good_target_but_not_for_fmv() { return 5; } + #elifdef __aarch64__ int __attribute__((target("sve,arch=armv8-a"))) foo(void) { return 4; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -4424,6 +4454,51 @@ void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) { ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent); } +void ASTReader::loadPreferredNameAttribute( +const PendingPreferredNameAttribute &PreferredNameAttribute) { + Decl *D = PreferredNameAttribute.D; + ModuleFile *M = getOwningModuleFile(D); + + unsigned LocalDeclIndex = D->getGlobalID().getLocalDeclIndex(); + const DeclOffset &DOffs = M->DeclOffsets[LocalDeclIndex]; + RecordLocation Loc(M, DOffs.getBitOffset(M->DeclsBlockStartOffset)); + + llvm::BitstreamCursor &Cursor = Loc.F->DeclsCursor; + SavedStreamPosition SavedPosition(Cursor); + if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) { +Error(std::move(Err)); + } + + Expected MaybeCode = Cursor.ReadCode(); + if (!MaybeCode) { +llvm::report_fatal_error( +Twine("ASTReader::loadPreferredNameAttribute failed reading code: ") + +toString(MaybeCode.takeError())); + } + unsigned Code = MaybeCode.get(); + + ASTRecordReader Record(*this, *Loc.F); + Expected MaybeRecCode = Record.readRecord(Cursor, Code); + if (!MaybeRecCode) { +llvm::report_fatal_error( +Twine( +"ASTReader::loadPreferredNameAttribute failed reading rec code: ") + +toString(MaybeCode.takeError())); + } + unsigned RecCode = MaybeRecCode.get(); + if (RecCode != DECL_CXX_RECORD) { VitaNuo wrote: True. Though I think I still need to check that `RecCode` is a valid [DeclCode](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Serialization/ASTBitCodes.h#L1227). https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not allow unorderable features in [[gnu::target{,_clones}]] (PR #98426)
https://github.com/phoebewang closed https://github.com/llvm/llvm-project/pull/98426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Refactor implementation of FP8 types (NFC) (PR #118969)
https://github.com/momchil-velikov updated https://github.com/llvm/llvm-project/pull/118969 >From e8a216c5effbf426ada5b9deb89fc2b5d9405f7c Mon Sep 17 00:00:00 2001 From: Momchil Velikov Date: Fri, 6 Dec 2024 13:09:23 + Subject: [PATCH 1/2] [AArch64] Refactor implementation of FP8 types (NFC) * The FP8 scalar type (`__mfp8`) was described as a vector type * The FP8 vector types were described/assumed to have integer element type (the element type ought to be `__mfp8`), * Add support for `m` type specifier (denoting `__mfp8`) in `DecodeTypeFromStr` and create SVE builtin prototypes using the specifier, instead of `int8_t`. --- clang/include/clang/AST/Type.h| 5 +++ .../clang/Basic/AArch64SVEACLETypes.def | 24 +--- clang/lib/AST/ASTContext.cpp | 37 +++ clang/lib/AST/ItaniumMangle.cpp | 5 +++ clang/lib/AST/Type.cpp| 4 +- clang/lib/CodeGen/CodeGenTypes.cpp| 13 +-- clang/lib/CodeGen/Targets/AArch64.cpp | 7 +++- clang/utils/TableGen/SveEmitter.cpp | 4 +- 8 files changed, 76 insertions(+), 23 deletions(-) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 09c98f642852fc3..aa313719a657552 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2518,6 +2518,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8532,6 +8533,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58ee7..6b704b386536c9b 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, false) +#endif + #ifndef SVE_VECTOR_TYPE_FLOAT #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, true, false) @@ -125,8 +135,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) -// This is a 8 bits opaque type. -SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -148,7 +157,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2) // // x3 @@ -170,7 +179,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3) // // x4 @@ -192,7 +201,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat
[clang] [Clang][AArch64] Allow FP8 Neon vector types to be used by __builtin_shufflevector (PR #119031)
https://github.com/momchil-velikov updated https://github.com/llvm/llvm-project/pull/119031 >From e8a216c5effbf426ada5b9deb89fc2b5d9405f7c Mon Sep 17 00:00:00 2001 From: Momchil Velikov Date: Fri, 6 Dec 2024 13:09:23 + Subject: [PATCH 1/5] [AArch64] Refactor implementation of FP8 types (NFC) * The FP8 scalar type (`__mfp8`) was described as a vector type * The FP8 vector types were described/assumed to have integer element type (the element type ought to be `__mfp8`), * Add support for `m` type specifier (denoting `__mfp8`) in `DecodeTypeFromStr` and create SVE builtin prototypes using the specifier, instead of `int8_t`. --- clang/include/clang/AST/Type.h| 5 +++ .../clang/Basic/AArch64SVEACLETypes.def | 24 +--- clang/lib/AST/ASTContext.cpp | 37 +++ clang/lib/AST/ItaniumMangle.cpp | 5 +++ clang/lib/AST/Type.cpp| 4 +- clang/lib/CodeGen/CodeGenTypes.cpp| 13 +-- clang/lib/CodeGen/Targets/AArch64.cpp | 7 +++- clang/utils/TableGen/SveEmitter.cpp | 4 +- 8 files changed, 76 insertions(+), 23 deletions(-) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 09c98f642852fc3..aa313719a657552 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2518,6 +2518,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8532,6 +8533,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58ee7..6b704b386536c9b 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, false) +#endif + #ifndef SVE_VECTOR_TYPE_FLOAT #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, true, false) @@ -125,8 +135,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) -// This is a 8 bits opaque type. -SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -148,7 +157,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2) // // x3 @@ -170,7 +179,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3) // // x4 @@ -192,7 +201,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat
[clang-tools-extra] e87f94a - [llvm-project] Fix typos mutli and mutliple. NFC. (#122880)
Author: Jay Foad Date: 2025-01-14T11:59:41Z New Revision: e87f94a6a806a941242506680f88573d6a87a828 URL: https://github.com/llvm/llvm-project/commit/e87f94a6a806a941242506680f88573d6a87a828 DIFF: https://github.com/llvm/llvm-project/commit/e87f94a6a806a941242506680f88573d6a87a828.diff LOG: [llvm-project] Fix typos mutli and mutliple. NFC. (#122880) Added: Modified: clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp clang/lib/Basic/SourceManager.cpp flang/test/HLFIR/associate-codegen.fir libc/test/src/unistd/getopt_test.cpp lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Target/StructuredDataPlugin.cpp lldb/unittests/Target/RegisterFlagsTest.cpp llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/Target/X86/X86LowerAMXType.cpp llvm/test/CodeGen/AArch64/eon.ll llvm/test/DebugInfo/X86/multiple-at-const-val.ll llvm/test/Transforms/EarlyCSE/guards.ll llvm/test/Transforms/InstCombine/matrix-multiplication-negation.ll llvm/test/Transforms/LoopVectorize/RISCV/blend-any-of-reduction-cost.ll mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir mlir/test/Transforms/mem2reg.mlir mlir/test/Transforms/sroa.mlir Removed: diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp index aec67808846b12..7a2d804e173ce4 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp @@ -342,7 +342,7 @@ static void ignoreTypeLocClasses( Loc = Loc.getNextTypeLoc(); } -static bool isMutliLevelPointerToTypeLocClasses( +static bool isMultiLevelPointerToTypeLocClasses( TypeLoc Loc, std::initializer_list const &LocClasses) { ignoreTypeLocClasses(Loc, {TypeLoc::Paren, TypeLoc::Qualified}); @@ -424,7 +424,7 @@ void UseAutoCheck::replaceExpr( auto Diag = diag(Range.getBegin(), Message); - bool ShouldReplenishVariableName = isMutliLevelPointerToTypeLocClasses( + bool ShouldReplenishVariableName = isMultiLevelPointerToTypeLocClasses( TSI->getTypeLoc(), {TypeLoc::FunctionProto, TypeLoc::ConstantArray}); // Space after 'auto' to handle cases where the '*' in the pointer type is diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 44e982d3ee67fb..b1f2180c1d4627 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1222,7 +1222,7 @@ unsigned SourceManager::getPresumedColumnNumber(SourceLocation Loc, return PLoc.getColumn(); } -// Check if mutli-byte word x has bytes between m and n, included. This may also +// Check if multi-byte word x has bytes between m and n, included. This may also // catch bytes equal to n + 1. // The returned value holds a 0x80 at each byte position that holds a match. // see http://graphics.stanford.edu/~seander/bithacks.html#HasBetweenInWord diff --git a/flang/test/HLFIR/associate-codegen.fir b/flang/test/HLFIR/associate-codegen.fir index f5e015c4169f60..ad64959984a14a 100644 --- a/flang/test/HLFIR/associate-codegen.fir +++ b/flang/test/HLFIR/associate-codegen.fir @@ -372,7 +372,7 @@ func.func @_QPtest_multiple_expr_uses_inside_elemental() { // CHECK: return // CHECK: } -// Verify that we properly recognize mutliple consequent hlfir.associate using +// Verify that we properly recognize multiple consequent hlfir.associate using // the same result of hlfir.elemental. func.func @_QPtest_multitple_associates_for_same_expr() { %c1 = arith.constant 1 : index diff --git a/libc/test/src/unistd/getopt_test.cpp b/libc/test/src/unistd/getopt_test.cpp index e6e87720cde48d..8217f7bb6e7313 100644 --- a/libc/test/src/unistd/getopt_test.cpp +++ b/libc/test/src/unistd/getopt_test.cpp @@ -155,7 +155,7 @@ TEST_F(LlvmLibcGetoptTest, ParseArgInNext) { EXPECT_EQ(test_globals::optind, 3); } -TEST_F(LlvmLibcGetoptTest, ParseMutliInOne) { +TEST_F(LlvmLibcGetoptTest, ParseMultiInOne) { array argv{"prog"_c, "-abc"_c, nullptr}; EXPECT_EQ(LIBC_NAMESPACE::getopt(2, argv.data(), "abc"), (int)'a'); diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index b5612f21f11563..164c61d1720171 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1737,7 +1737,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed { // It is important that we track the address used to request the region as // this will give the correct section name in the case that regions overlap. -// On Windows we get mutliple regions that start at the same place but are +// On Windows we get multiple regions that start at the same place but are // diff erent sizes and refer to diff erent sections. std::
[clang] [clang-tools-extra] [flang] [libc] [lldb] [llvm] [mlir] [llvm-project] Fix typos mutli and mutliple. NFC. (PR #122880)
https://github.com/jayfoad closed https://github.com/llvm/llvm-project/pull/122880 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e87f94a - [llvm-project] Fix typos mutli and mutliple. NFC. (#122880)
Author: Jay Foad Date: 2025-01-14T11:59:41Z New Revision: e87f94a6a806a941242506680f88573d6a87a828 URL: https://github.com/llvm/llvm-project/commit/e87f94a6a806a941242506680f88573d6a87a828 DIFF: https://github.com/llvm/llvm-project/commit/e87f94a6a806a941242506680f88573d6a87a828.diff LOG: [llvm-project] Fix typos mutli and mutliple. NFC. (#122880) Added: Modified: clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp clang/lib/Basic/SourceManager.cpp flang/test/HLFIR/associate-codegen.fir libc/test/src/unistd/getopt_test.cpp lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Target/StructuredDataPlugin.cpp lldb/unittests/Target/RegisterFlagsTest.cpp llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/Target/X86/X86LowerAMXType.cpp llvm/test/CodeGen/AArch64/eon.ll llvm/test/DebugInfo/X86/multiple-at-const-val.ll llvm/test/Transforms/EarlyCSE/guards.ll llvm/test/Transforms/InstCombine/matrix-multiplication-negation.ll llvm/test/Transforms/LoopVectorize/RISCV/blend-any-of-reduction-cost.ll mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir mlir/test/Transforms/mem2reg.mlir mlir/test/Transforms/sroa.mlir Removed: diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp index aec67808846b12..7a2d804e173ce4 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp @@ -342,7 +342,7 @@ static void ignoreTypeLocClasses( Loc = Loc.getNextTypeLoc(); } -static bool isMutliLevelPointerToTypeLocClasses( +static bool isMultiLevelPointerToTypeLocClasses( TypeLoc Loc, std::initializer_list const &LocClasses) { ignoreTypeLocClasses(Loc, {TypeLoc::Paren, TypeLoc::Qualified}); @@ -424,7 +424,7 @@ void UseAutoCheck::replaceExpr( auto Diag = diag(Range.getBegin(), Message); - bool ShouldReplenishVariableName = isMutliLevelPointerToTypeLocClasses( + bool ShouldReplenishVariableName = isMultiLevelPointerToTypeLocClasses( TSI->getTypeLoc(), {TypeLoc::FunctionProto, TypeLoc::ConstantArray}); // Space after 'auto' to handle cases where the '*' in the pointer type is diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 44e982d3ee67fb..b1f2180c1d4627 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1222,7 +1222,7 @@ unsigned SourceManager::getPresumedColumnNumber(SourceLocation Loc, return PLoc.getColumn(); } -// Check if mutli-byte word x has bytes between m and n, included. This may also +// Check if multi-byte word x has bytes between m and n, included. This may also // catch bytes equal to n + 1. // The returned value holds a 0x80 at each byte position that holds a match. // see http://graphics.stanford.edu/~seander/bithacks.html#HasBetweenInWord diff --git a/flang/test/HLFIR/associate-codegen.fir b/flang/test/HLFIR/associate-codegen.fir index f5e015c4169f60..ad64959984a14a 100644 --- a/flang/test/HLFIR/associate-codegen.fir +++ b/flang/test/HLFIR/associate-codegen.fir @@ -372,7 +372,7 @@ func.func @_QPtest_multiple_expr_uses_inside_elemental() { // CHECK: return // CHECK: } -// Verify that we properly recognize mutliple consequent hlfir.associate using +// Verify that we properly recognize multiple consequent hlfir.associate using // the same result of hlfir.elemental. func.func @_QPtest_multitple_associates_for_same_expr() { %c1 = arith.constant 1 : index diff --git a/libc/test/src/unistd/getopt_test.cpp b/libc/test/src/unistd/getopt_test.cpp index e6e87720cde48d..8217f7bb6e7313 100644 --- a/libc/test/src/unistd/getopt_test.cpp +++ b/libc/test/src/unistd/getopt_test.cpp @@ -155,7 +155,7 @@ TEST_F(LlvmLibcGetoptTest, ParseArgInNext) { EXPECT_EQ(test_globals::optind, 3); } -TEST_F(LlvmLibcGetoptTest, ParseMutliInOne) { +TEST_F(LlvmLibcGetoptTest, ParseMultiInOne) { array argv{"prog"_c, "-abc"_c, nullptr}; EXPECT_EQ(LIBC_NAMESPACE::getopt(2, argv.data(), "abc"), (int)'a'); diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index b5612f21f11563..164c61d1720171 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1737,7 +1737,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed { // It is important that we track the address used to request the region as // this will give the correct section name in the case that regions overlap. -// On Windows we get mutliple regions that start at the same place but are +// On Windows we get multiple regions that start at the same place but are // diff erent sizes and refer to diff erent sections. std::
[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)
sivan-shani wrote: Fixed according to comments above https://github.com/llvm/llvm-project/pull/118771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] FP8 implicit bitcast (PR #122893)
https://github.com/momchil-velikov created https://github.com/llvm/llvm-project/pull/122893 The intrinsics generated in `arm_neon.h` heavily rely on C-style cast operator having bitcast semantics for vector operands. This patch allows such expressions to "convert" to/from FP8 builtin Neon vector types. >From e8a216c5effbf426ada5b9deb89fc2b5d9405f7c Mon Sep 17 00:00:00 2001 From: Momchil Velikov Date: Fri, 6 Dec 2024 13:09:23 + Subject: [PATCH 1/6] [AArch64] Refactor implementation of FP8 types (NFC) * The FP8 scalar type (`__mfp8`) was described as a vector type * The FP8 vector types were described/assumed to have integer element type (the element type ought to be `__mfp8`), * Add support for `m` type specifier (denoting `__mfp8`) in `DecodeTypeFromStr` and create SVE builtin prototypes using the specifier, instead of `int8_t`. --- clang/include/clang/AST/Type.h| 5 +++ .../clang/Basic/AArch64SVEACLETypes.def | 24 +--- clang/lib/AST/ASTContext.cpp | 37 +++ clang/lib/AST/ItaniumMangle.cpp | 5 +++ clang/lib/AST/Type.cpp| 4 +- clang/lib/CodeGen/CodeGenTypes.cpp| 13 +-- clang/lib/CodeGen/Targets/AArch64.cpp | 7 +++- clang/utils/TableGen/SveEmitter.cpp | 4 +- 8 files changed, 76 insertions(+), 23 deletions(-) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 09c98f642852fc3..aa313719a657552 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2518,6 +2518,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8532,6 +8533,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58ee7..6b704b386536c9b 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, false) +#endif + #ifndef SVE_VECTOR_TYPE_FLOAT #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, true, false) @@ -125,8 +135,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) -// This is a 8 bits opaque type. -SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -148,7 +157,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2) // // x3 @@ -170,7 +179,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3) // // x4 @@ -192,7 +201,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveF
[clang] [AArch64] FP8 implicit bitcast (PR #122893)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-backend-aarch64 Author: Momchil Velikov (momchil-velikov) Changes The intrinsics generated in `arm_neon.h` heavily rely on C-style cast operator having bitcast semantics for vector operands. This patch allows such expressions to "convert" to/from FP8 builtin Neon vector types. --- Patch is 48.82 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122893.diff 17 Files Affected: - (modified) clang/include/clang/AST/Type.h (+9) - (modified) clang/include/clang/Basic/AArch64SVEACLETypes.def (+18-6) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+7) - (modified) clang/include/clang/Sema/Sema.h (+5) - (modified) clang/lib/AST/ASTContext.cpp (+30-7) - (modified) clang/lib/AST/ItaniumMangle.cpp (+5) - (modified) clang/lib/AST/Type.cpp (+16-3) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+13-3) - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+5-2) - (modified) clang/lib/Sema/SemaCast.cpp (+22) - (modified) clang/lib/Sema/SemaChecking.cpp (+33-6) - (modified) clang/lib/Sema/SemaExpr.cpp (+48) - (added) clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c (+123) - (added) clang/test/CodeGen/AArch64/fp8-cast.c (+193) - (added) clang/test/Sema/aarch64-fp8-cast.c (+102) - (added) clang/test/Sema/builtin-shufflevector.c (+29) - (modified) clang/utils/TableGen/SveEmitter.cpp (+2-2) ``diff diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 09c98f642852fc3..fbc62f61ad5a553 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2404,6 +2404,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// SVE vector or predicate, excluding tuple types such as svint32x4_t. bool isSveVLSBuiltinType() const; + /// Determines if this is a *builtin* NEON vector type, a type not built with + /// `neon_vector_type` + bool isNeonVectorBuiltinType() const; + /// Returns the representative type for the element of an SVE builtin type. /// This is used to represent fixed-length SVE vectors created with the /// 'arm_sve_vector_bits' type attribute as VectorType. @@ -2518,6 +2522,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8532,6 +8537,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58ee7..6b704b386536c9b 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, false) +#endif + #ifndef SVE_VECTOR_TYPE_FLOAT #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, true, false) @@ -125,8 +135,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) -// This is a 8 bits opaque type. -SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -148,7 +157,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) +SVE_V
[clang] [AArch64] Refactor implementation of FP8 types (NFC) (PR #118969)
@@ -650,6 +655,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { // An ext_vector_type of Bool is really a vector of bits. llvm::Type *IRElemTy = VT->isExtVectorBoolType() ? llvm::Type::getInt1Ty(getLLVMContext()) + : VT->getElementType()->isMFloat8Type() momchil-velikov wrote: I added a comment in one of the places. https://github.com/llvm/llvm-project/pull/118969 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (PR #122875)
@@ -810,7 +810,7 @@ Bug Fixes to C++ Support module imports in those situations. (#GH60336) - Fix init-capture packs having a size of one before being instantiated. (#GH63677) - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667), - (#GH99877). + (#GH99877), (#GH122417). zyn0217 wrote: Nothing wrong with that, this is just another case falling into that entry - we should have fixed this one in that PR :) https://github.com/llvm/llvm-project/pull/122875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Allow FP8 Neon vector types to be used by __builtin_shufflevector (PR #119031)
@@ -2578,6 +2576,19 @@ bool Type::isSveVLSBuiltinType() const { return false; } +bool Type::isNeonVectorBuiltinType() const { momchil-velikov wrote: Done https://github.com/llvm/llvm-project/pull/119031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Allow FP8 Neon vector types to be used by __builtin_shufflevector (PR #119031)
@@ -0,0 +1,123 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple aarch64-linux -target-feature +neon -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s + +// REQUIRES: aarch64-registered-target + +typedef __attribute__((neon_vector_type(8))) signed char int8x8_t; +typedef __attribute__((neon_vector_type(16))) signed char int8x16_t; + +typedef __MFloat8x8_t mfloat8x8_t; +typedef __MFloat8x16_t mfloat8x16_t; + +// CHECK-LABEL: define dso_local <8 x i8> @f0( +// CHECK-SAME: <8 x i8> [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:[[SHUFFLE:%.*]] = shufflevector <8 x i8> [[X]], <8 x i8> [[X]], <8 x i32> +// CHECK-NEXT:ret <8 x i8> [[SHUFFLE]] +// +mfloat8x8_t f0(mfloat8x8_t x) { + return __builtin_shufflevector(x, x, 3, 2, 1, 0, 3, 2, 1, 0); +} + +// CHECK-LABEL: define dso_local <8 x i8> @f1( +// CHECK-SAME: <8 x i8> [[X:%.*]], <8 x i8> noundef [[P:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:[[MASK:%.*]] = and <8 x i8> [[P]], splat (i8 7) +// CHECK-NEXT:[[SHUF_IDX:%.*]] = extractelement <8 x i8> [[MASK]], i64 0 +// CHECK-NEXT:[[SHUF_ELT:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX]] +// CHECK-NEXT:[[SHUF_INS:%.*]] = insertelement <8 x i8> poison, i8 [[SHUF_ELT]], i64 0 +// CHECK-NEXT:[[SHUF_IDX1:%.*]] = extractelement <8 x i8> [[MASK]], i64 1 +// CHECK-NEXT:[[SHUF_ELT2:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX1]] +// CHECK-NEXT:[[SHUF_INS3:%.*]] = insertelement <8 x i8> [[SHUF_INS]], i8 [[SHUF_ELT2]], i64 1 +// CHECK-NEXT:[[SHUF_IDX4:%.*]] = extractelement <8 x i8> [[MASK]], i64 2 +// CHECK-NEXT:[[SHUF_ELT5:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX4]] +// CHECK-NEXT:[[SHUF_INS6:%.*]] = insertelement <8 x i8> [[SHUF_INS3]], i8 [[SHUF_ELT5]], i64 2 +// CHECK-NEXT:[[SHUF_IDX7:%.*]] = extractelement <8 x i8> [[MASK]], i64 3 +// CHECK-NEXT:[[SHUF_ELT8:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX7]] +// CHECK-NEXT:[[SHUF_INS9:%.*]] = insertelement <8 x i8> [[SHUF_INS6]], i8 [[SHUF_ELT8]], i64 3 +// CHECK-NEXT:[[SHUF_IDX10:%.*]] = extractelement <8 x i8> [[MASK]], i64 4 +// CHECK-NEXT:[[SHUF_ELT11:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX10]] +// CHECK-NEXT:[[SHUF_INS12:%.*]] = insertelement <8 x i8> [[SHUF_INS9]], i8 [[SHUF_ELT11]], i64 4 +// CHECK-NEXT:[[SHUF_IDX13:%.*]] = extractelement <8 x i8> [[MASK]], i64 5 +// CHECK-NEXT:[[SHUF_ELT14:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX13]] +// CHECK-NEXT:[[SHUF_INS15:%.*]] = insertelement <8 x i8> [[SHUF_INS12]], i8 [[SHUF_ELT14]], i64 5 +// CHECK-NEXT:[[SHUF_IDX16:%.*]] = extractelement <8 x i8> [[MASK]], i64 6 +// CHECK-NEXT:[[SHUF_ELT17:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX16]] +// CHECK-NEXT:[[SHUF_INS18:%.*]] = insertelement <8 x i8> [[SHUF_INS15]], i8 [[SHUF_ELT17]], i64 6 +// CHECK-NEXT:[[SHUF_IDX19:%.*]] = extractelement <8 x i8> [[MASK]], i64 7 +// CHECK-NEXT:[[SHUF_ELT20:%.*]] = extractelement <8 x i8> [[X]], i8 [[SHUF_IDX19]] +// CHECK-NEXT:[[SHUF_INS21:%.*]] = insertelement <8 x i8> [[SHUF_INS18]], i8 [[SHUF_ELT20]], i64 7 +// CHECK-NEXT:ret <8 x i8> [[SHUF_INS21]] +// +mfloat8x8_t f1(mfloat8x8_t x, int8x8_t p) { + return __builtin_shufflevector(x, p); +} + +// CHECK-LABEL: define dso_local <16 x i8> @f3( +// CHECK-SAME: <16 x i8> [[X:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:[[SHUFFLE:%.*]] = shufflevector <16 x i8> [[X]], <16 x i8> [[X]], <16 x i32> +// CHECK-NEXT:ret <16 x i8> [[SHUFFLE]] +// +mfloat8x16_t f3(mfloat8x16_t x) { + return __builtin_shufflevector(x, x, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, + 1, 0); +} + +// CHECK-LABEL: define dso_local <16 x i8> @f4( +// CHECK-SAME: <16 x i8> [[X:%.*]], <16 x i8> noundef [[P:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:[[MASK:%.*]] = and <16 x i8> [[P]], splat (i8 15) +// CHECK-NEXT:[[SHUF_IDX:%.*]] = extractelement <16 x i8> [[MASK]], i64 0 +// CHECK-NEXT:[[SHUF_ELT:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX]] +// CHECK-NEXT:[[SHUF_INS:%.*]] = insertelement <16 x i8> poison, i8 [[SHUF_ELT]], i64 0 +// CHECK-NEXT:[[SHUF_IDX1:%.*]] = extractelement <16 x i8> [[MASK]], i64 1 +// CHECK-NEXT:[[SHUF_ELT2:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX1]] +// CHECK-NEXT:[[SHUF_INS3:%.*]] = insertelement <16 x i8> [[SHUF_INS]], i8 [[SHUF_ELT2]], i64 1 +// CHECK-NEXT:[[SHUF_IDX4:%.*]] = extractelement <16 x i8> [[MASK]], i64 2 +// CHECK-NEXT:[[SHUF_ELT5:%.*]] = extractelement <16 x i8> [[X]], i8 [[SHUF_IDX4]] +// CHECK-NEXT:[[SHUF_INS6:%.*]] = insertelement <16 x i8> [[SHUF_INS3]], i8 [[SHUF_ELT5]], i64 2 +// CHECK-NEXT:[[SHUF_IDX7:%.*]] = extractelement <16 x i8> [[MASK]], i64
[clang] [Clang][AArch64] Allow FP8 Neon vector types to be used by __builtin_shufflevector (PR #119031)
@@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -verify %s + +// REQUIRES: aarch64-registered-target + +typedef __attribute__((neon_vector_type(8))) signed char int8x8_t; +typedef __attribute__((neon_vector_type(16))) signed char int8x16_t; + +typedef __MFloat8x8_t mfloat8x8_t; +typedef __MFloat8x16_t mfloat8x16_t; momchil-velikov wrote: Removed. https://github.com/llvm/llvm-project/pull/119031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add Neon FP8 conversion intrinsics (PR #119033)
@@ -0,0 +1,308 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1-triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix CHECK-CXX momchil-velikov wrote: Only `mem2reg` left https://github.com/llvm/llvm-project/pull/119033 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Emit DW_AT_object_pointer on function definitions with explicit `this` (PR #122897)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/122897 We currently don't emit `DW_AT_object_pointer` on function declarations or definitions. GCC suffers from the same issue: https://godbolt.org/z/h4jeT54G5 If I interpreted the DWARFv5 spec correctly, it doesn't mandate this attribute be present *only* for implicit object parameters: ``` If the member function entry describes a non-static member function, then that entry has a DW_AT_object_pointer attribute whose value is a reference to the formal parameter entry that corresponds to the object for which the function is called. That parameter also has a DW_AT_artificial attribute whose value is true. ``` This patch attaches the `DW_AT_object_pointer` for function *defintions*. The declarations will be handled in a separate patch. The part about `DW_AT_artificial` seems overly restrictive, and not true for explicit object parameters. We probably should relax this part of the DWARF spec. This will help LLDB identify static vs. non-static member functions (see https://github.com/llvm/llvm-project/issues/120856). Partially fixes https://github.com/llvm/llvm-project/issues/120974 >From d221dd5ef2c54f63fb6966ca5de8e41c5a8dd6bf Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 14 Jan 2025 11:33:33 + Subject: [PATCH] [clang][DebugInfo] Emit DW_AT_object_pointer on function definitions with explicit `this` We currently don't emit `DW_AT_object_pointer` on function declarations or definitions. The DWARFv5 spec doesn't mandate this attribute be present *only* for implicit object parameters: ``` If the member function entry describes a non-static member function, then that entry has a DW_AT_object_pointer attribute whose value is a reference to the formal parameter entry that corresponds to the object for which the function is called. That parameter also has a DW_AT_artificial attribute whose value is true. ``` The part about `DW_AT_artificial` seems overly restrictive, and not true for explicit object parameters. We probably should relax this part of the DWARF spec. This will help LLDB identify static vs. non-static member functions (see https://github.com/llvm/llvm-project/issues/120856). GCC suffers from the same issue: https://godbolt.org/z/h4jeT54G5 Partially fixes https://github.com/llvm/llvm-project/issues/120974 --- clang/lib/CodeGen/CGDebugInfo.cpp | 3 ++ .../CodeGenCXX/debug-info-object-pointer.cpp | 29 +++ 2 files changed, 32 insertions(+) create mode 100644 clang/test/CodeGenCXX/debug-info-object-pointer.cpp diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index d7e5e95b7873a0..f9cba414dcfe2c 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4829,6 +4829,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, if (IPD->getParameterKind() == ImplicitParamKind::CXXThis || IPD->getParameterKind() == ImplicitParamKind::ObjCSelf) Flags |= llvm::DINode::FlagObjectPointer; + } else if (const auto *PVD = dyn_cast(VD)) { +if (PVD->isExplicitObjectParameter()) + Flags |= llvm::DINode::FlagObjectPointer; } // Note: Older versions of clang used to emit byval references with an extra diff --git a/clang/test/CodeGenCXX/debug-info-object-pointer.cpp b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp new file mode 100644 index 00..594d4da791ee84 --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -x c++ -std=c++23 -debug-info-kind=limited -emit-llvm < %s | FileCheck %s + +// CHECK: !DISubprogram(name: "bar", +// CHECK-SAME: flags: DIFlagPrototyped +// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type +// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer +// +// // FIXME: DIFlagObjectPointer not attached to the explicit object +// // argument in the subprogram declaration. +// CHECK: !DISubprogram(name: "explicit_this", +// flags: DIFlagPrototyped +// CHECK-NOT: DIFlagObjectPointer +// CHECK-NOT: DIFlagArtificial +// +// CHECK: !DILocalVariable(name: "this", arg: 1 +// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer +// +// CHECK-NOT: DIFlagArtificial +// CHECK: !DILocalVariable(arg: 1, {{.*}}, flags: DIFlagObjectPointer) + +struct Foo { + void bar() {} + void explicit_this(this Foo &&) {} +}; + +void f() { + Foo{}.bar(); + Foo{}.explicit_this(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] emit -Wignored-qualifiers diagnostic for cv-qualified base classes (PR #121419)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/121419 >From 3f6b1d68978857035a972f49b1cfd9d9d0151be9 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 1 Jan 2025 01:47:17 +0200 Subject: [PATCH 1/5] [Clang] emit -Wignored-qualifiers diagnostic for cv-qualified base classes --- clang/docs/ReleaseNotes.rst | 1 + .../clang/Basic/DiagnosticSemaKinds.td| 4 clang/lib/Sema/SemaDeclCXX.cpp| 9 + .../SemaCXX/warn-base-type-qualifiers.cpp | 20 +++ 4 files changed, 34 insertions(+) create mode 100644 clang/test/SemaCXX/warn-base-type-qualifiers.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b7da12bcf65818..659f0ebd97fc46 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -733,6 +733,7 @@ Improvements to Clang's diagnostics scope.Unlock(); require(scope); // Warning! Requires mu1. } +- Clang now emits a ``-Wignored-qualifiers`` diagnostic when a base class includes cv-qualifiers (#GH55474). Improvements to Clang's time-trace -- diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 330ae045616aba..294cfa24975a73 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -487,6 +487,10 @@ def err_noreturn_non_function : Error< def warn_qual_return_type : Warning< "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">, InGroup, DefaultIgnore; +def warn_qual_base_type : Warning< + "'%0' qualifier%s1 on base class type %2 have no effect">, + InGroup, DefaultIgnore; + def warn_deprecated_redundant_constexpr_static_def : Warning< "out-of-line definition of constexpr static data member is redundant " "in C++17 and is deprecated">, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c5a72cf812ebc9..b82ca1541ba249 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2655,6 +2655,15 @@ CXXBaseSpecifier *Sema::CheckBaseSpecifier(CXXRecordDecl *Class, return nullptr; } +if (BaseType.hasQualifiers() && !isa(BaseType)) { + auto Quals = + BaseType.getQualifiers().getAsString(Context.getPrintingPolicy()); + Diag(BaseLoc, diag::warn_qual_base_type) + << Quals << std::count(Quals.begin(), Quals.end(), ' ') + 1 + << BaseType; + Diag(BaseLoc, diag::note_base_class_specified_here) << BaseType; +} + // For the MS ABI, propagate DLL attributes to base class templates. if (Context.getTargetInfo().getCXXABI().isMicrosoft() || Context.getTargetInfo().getTriple().isPS()) { diff --git a/clang/test/SemaCXX/warn-base-type-qualifiers.cpp b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp new file mode 100644 index 00..a5af7ec7415bf5 --- /dev/null +++ b/clang/test/SemaCXX/warn-base-type-qualifiers.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -verify + +class A { }; + +typedef const A A_Const; +class B : public A_Const { }; // expected-warning {{'const' qualifier on base class type 'A_Const' (aka 'const A') have no effect}} \ + // expected-note {{base class 'A_Const' (aka 'const A') specified here}} + +typedef const volatile A A_Const_Volatile; +class C : public A_Const_Volatile { }; // expected-warning {{'const volatile' qualifiers on base class type 'A_Const_Volatile' (aka 'const volatile A') have no effect}} \ + // expected-note {{base class 'A_Const_Volatile' (aka 'const volatile A') specified here}} + +struct D { + D(int); +}; +template struct E : T { + using T::T; + E(int &) : E(0) {} +}; +E e(1); >From 397097340707dbefe5f4b07357523ff7ad515304 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Thu, 2 Jan 2025 17:06:05 +0200 Subject: [PATCH 2/5] use explicit variable type --- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index b82ca1541ba249..c4ec7fa4742bdf 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2656,7 +2656,7 @@ CXXBaseSpecifier *Sema::CheckBaseSpecifier(CXXRecordDecl *Class, } if (BaseType.hasQualifiers() && !isa(BaseType)) { - auto Quals = + std::string Quals = BaseType.getQualifiers().getAsString(Context.getPrintingPolicy()); Diag(BaseLoc, diag::warn_qual_base_type) << Quals << std::count(Quals.begin(), Quals.end(), ' ') + 1 >From 3129f7521984c68969f3dd0140d6001b25ab1a28 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Fri, 3 Jan 2025 00:47:47 +0200 Subject: [PATCH 3/5] eliminate template type constraint and add additional tests --- clang/lib/Sema/SemaDeclCXX.cpp
[clang] [clang][DebugInfo] Emit DW_AT_object_pointer on function definitions with explicit `this` (PR #122897)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/122897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] codegen support for masked combined construct parallel masked taskloop simd. (PR #121746)
https://github.com/chandraghale closed https://github.com/llvm/llvm-project/pull/121746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
https://github.com/VitaNuo edited https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Emit DW_AT_object_pointer on function definitions with explicit `this` (PR #122897)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Michael Buch (Michael137) Changes We currently don't emit `DW_AT_object_pointer` on function declarations or definitions. GCC suffers from the same issue: https://godbolt.org/z/h4jeT54G5 If I interpreted the DWARFv5 spec correctly, it doesn't mandate this attribute be present *only* for implicit object parameters: ``` If the member function entry describes a non-static member function, then that entry has a DW_AT_object_pointer attribute whose value is a reference to the formal parameter entry that corresponds to the object for which the function is called. That parameter also has a DW_AT_artificial attribute whose value is true. ``` This patch attaches the `DW_AT_object_pointer` for function *defintions*. The declarations will be handled in a separate patch. The part about `DW_AT_artificial` seems overly restrictive, and not true for explicit object parameters. We probably should relax this part of the DWARF spec. This will help LLDB identify static vs. non-static member functions (see https://github.com/llvm/llvm-project/issues/120856). Partially fixes https://github.com/llvm/llvm-project/issues/120974 --- Full diff: https://github.com/llvm/llvm-project/pull/122897.diff 2 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+3) - (added) clang/test/CodeGenCXX/debug-info-object-pointer.cpp (+29) ``diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index d7e5e95b7873a0..f9cba414dcfe2c 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4829,6 +4829,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, if (IPD->getParameterKind() == ImplicitParamKind::CXXThis || IPD->getParameterKind() == ImplicitParamKind::ObjCSelf) Flags |= llvm::DINode::FlagObjectPointer; + } else if (const auto *PVD = dyn_cast(VD)) { +if (PVD->isExplicitObjectParameter()) + Flags |= llvm::DINode::FlagObjectPointer; } // Note: Older versions of clang used to emit byval references with an extra diff --git a/clang/test/CodeGenCXX/debug-info-object-pointer.cpp b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp new file mode 100644 index 00..594d4da791ee84 --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-object-pointer.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -x c++ -std=c++23 -debug-info-kind=limited -emit-llvm < %s | FileCheck %s + +// CHECK: !DISubprogram(name: "bar", +// CHECK-SAME: flags: DIFlagPrototyped +// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type +// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer +// +// // FIXME: DIFlagObjectPointer not attached to the explicit object +// // argument in the subprogram declaration. +// CHECK: !DISubprogram(name: "explicit_this", +// flags: DIFlagPrototyped +// CHECK-NOT: DIFlagObjectPointer +// CHECK-NOT: DIFlagArtificial +// +// CHECK: !DILocalVariable(name: "this", arg: 1 +// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer +// +// CHECK-NOT: DIFlagArtificial +// CHECK: !DILocalVariable(arg: 1, {{.*}}, flags: DIFlagObjectPointer) + +struct Foo { + void bar() {} + void explicit_this(this Foo &&) {} +}; + +void f() { + Foo{}.bar(); + Foo{}.explicit_this(); +} `` https://github.com/llvm/llvm-project/pull/122897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Emit DW_AT_object_pointer on function definitions with explicit `this` (PR #122897)
Michael137 wrote: @dwblaikie @adrian-prantl any thoughts on adjusting the DWARF spec to allow explicit `this` parameters to be non-artificial but still be valid `DW_AT_object_pointer`s? https://github.com/llvm/llvm-project/pull/122897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] Preliminary support for -ftime-report (PR #122894)
https://github.com/tarunprabhu commented: Do you intend to make the behavior consistent with clang (by printing timing information for LLVM passes) in a separate PR? https://github.com/llvm/llvm-project/pull/122894 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 30f9a4f - [OpenMP] codegen support for masked combined construct parallel masked taskloop simd. (#121746)
Author: CHANDRA GHALE Date: 2025-01-14T18:26:46+05:30 New Revision: 30f9a4f75412850d603fde29b59d27dd9d31f380 URL: https://github.com/llvm/llvm-project/commit/30f9a4f75412850d603fde29b59d27dd9d31f380 DIFF: https://github.com/llvm/llvm-project/commit/30f9a4f75412850d603fde29b59d27dd9d31f380.diff LOG: [OpenMP] codegen support for masked combined construct parallel masked taskloop simd. (#121746) Added codegen support for combined masked constructs `Parallel masked taskloop simd`. Added implementation for `EmitOMPParallelMaskedTaskLoopSimdDirective`. Co-authored-by: Chandra Ghale Added: clang/test/OpenMP/parallel_masked_taskloop_simd_codegen.c Modified: clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenFunction.h Removed: diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 4ba8ee1ca17d4e..10d44e9c90b27e 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -355,8 +355,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef Attrs) { cast(*S)); break; case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass: -llvm_unreachable( -"parallel masked taskloop simd directive not supported yet."); +EmitOMPParallelMaskedTaskLoopSimdDirective( +cast(*S)); break; case Stmt::OMPDistributeDirectiveClass: EmitOMPDistributeDirective(cast(*S)); diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 2b4ca65e169a6e..8e694b95dc7e73 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -8072,6 +8072,24 @@ void CodeGenFunction::EmitOMPParallelMasterTaskLoopSimdDirective( emitEmptyBoundParameters); } +void CodeGenFunction::EmitOMPParallelMaskedTaskLoopSimdDirective( +const OMPParallelMaskedTaskLoopSimdDirective &S) { + auto &&CodeGen = [this, &S](CodeGenFunction &CGF, PrePostActionTy &Action) { +auto &&TaskLoopCodeGen = [&S](CodeGenFunction &CGF, + PrePostActionTy &Action) { + Action.Enter(CGF); + CGF.EmitOMPTaskLoopBasedDirective(S); +}; +OMPLexicalScope Scope(CGF, S, OMPD_parallel, /*EmitPreInitStmt=*/false); +CGM.getOpenMPRuntime().emitMaskedRegion(CGF, TaskLoopCodeGen, +S.getBeginLoc()); + }; + auto LPCRegion = + CGOpenMPRuntime::LastprivateConditionalRAII::disable(*this, S); + emitCommonOMPParallelDirective(*this, S, OMPD_masked_taskloop_simd, CodeGen, + emitEmptyBoundParameters); +} + // Generate the instructions for '#pragma omp target update' directive. void CodeGenFunction::EmitOMPTargetUpdateDirective( const OMPTargetUpdateDirective &S) { diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index b115c15bf01a95..ba8ed040477cc9 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -3885,6 +3885,8 @@ class CodeGenFunction : public CodeGenTypeCache { const OMPParallelMaskedTaskLoopDirective &S); void EmitOMPParallelMasterTaskLoopSimdDirective( const OMPParallelMasterTaskLoopSimdDirective &S); + void EmitOMPParallelMaskedTaskLoopSimdDirective( + const OMPParallelMaskedTaskLoopSimdDirective &S); void EmitOMPDistributeDirective(const OMPDistributeDirective &S); void EmitOMPDistributeParallelForDirective( const OMPDistributeParallelForDirective &S); diff --git a/clang/test/OpenMP/parallel_masked_taskloop_simd_codegen.c b/clang/test/OpenMP/parallel_masked_taskloop_simd_codegen.c new file mode 100644 index 00..0b51b302f9fcda --- /dev/null +++ b/clang/test/OpenMP/parallel_masked_taskloop_simd_codegen.c @@ -0,0 +1,62 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --prefix-filecheck-ir-name _ --version 5 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -fopenmp-version=52 -x c -emit-llvm %s -o - | FileCheck %s +// expected-no-diagnostics +#define N 100 +void parallel_masked_taskloop_simd(){ + #pragma omp parallel masked taskloop simd + for( int i = 0; i < N; i++) + ; + +} + +int main() +{ + parallel_masked_taskloop_simd(); +} +// CHECK-LABEL: define dso_local void @parallel_masked_taskloop_simd( +// CHECK-SAME: ) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT:call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1:[0-9]+]], i32 0, ptr @parallel_masked_taskloop_simd.omp_outlined) +// CHECK-NEXT:ret void +// +// +// CHECK-LABEL: define internal void @parallel_masked_taskloop_simd.omp_outlined( +// CHECK-SAME: ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]]) #[[ATTR1:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +//
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
https://github.com/VitaNuo updated https://github.com/llvm/llvm-project/pull/122726 >From b61110999596363bafdc94904356840febfcfaa5 Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Tue, 14 Jan 2025 14:00:48 +0100 Subject: [PATCH] [WIP][Modules] Delay deserialization of preferred_name attribute at record level. --- clang/include/clang/Serialization/ASTReader.h | 18 .../clang/Serialization/ASTRecordReader.h | 10 ++ clang/lib/Serialization/ASTReader.cpp | 5 + clang/lib/Serialization/ASTReaderDecl.cpp | 91 ++- clang/lib/Serialization/ASTWriter.cpp | 19 +++- clang/test/Modules/preferred_name.cppm| 12 ++- 6 files changed, 142 insertions(+), 13 deletions(-) diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 9f978762a6fb6b..4fd51eabe701ba 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -1205,6 +1205,23 @@ class ASTReader /// been completed. std::deque PendingDeclContextInfos; + /// Deserialization of some attributes must be deferred since they refer + /// to themselves in their type (e.g., preferred_name attribute refers to the + /// typedef that refers back to the template specialization of the template + /// that the attribute is attached to). + /// More attributes that store TypeSourceInfo might be potentially affected, + /// see https://github.com/llvm/llvm-project/issues/56490 for details. + struct DeferredAttribute { +uint64_t RecordIdx; +// Decl to attach a deferred attribute to. +Decl *ParentDecl; + }; + + /// The collection of Decls that have been loaded but some of their attributes + /// have been deferred, paired with the index inside the record pointing + /// at the skipped attribute. + SmallVector PendingDeferredAttributes; + template using DuplicateObjCDecls = std::pair; @@ -1551,6 +1568,7 @@ class ASTReader void loadPendingDeclChain(Decl *D, uint64_t LocalOffset); void loadObjCCategories(GlobalDeclID ID, ObjCInterfaceDecl *D, unsigned PreviousGeneration = 0); + void loadDeferredAttribute(const DeferredAttribute &DA); RecordLocation getLocalBitOffset(uint64_t GlobalOffset); uint64_t getGlobalBitOffset(ModuleFile &M, uint64_t LocalOffset); diff --git a/clang/include/clang/Serialization/ASTRecordReader.h b/clang/include/clang/Serialization/ASTRecordReader.h index 2561418b78ca7f..b1572ecef9028c 100644 --- a/clang/include/clang/Serialization/ASTRecordReader.h +++ b/clang/include/clang/Serialization/ASTRecordReader.h @@ -337,6 +337,12 @@ class ASTRecordReader /// Reads attributes from the current stream position, advancing Idx. void readAttributes(AttrVec &Attrs); + /// Reads one attribute from the current stream position, advancing Idx. + Attr *readOrDeferAttr(Decl *D); + + /// Reads attributes from the current stream position, advancing Idx. + void readOrDeferAttributes(AttrVec &Attrs, Decl *D); + /// Read an BTFTypeTagAttr object. BTFTypeTagAttr *readBTFTypeTagAttr() { return cast(readAttr()); @@ -355,6 +361,10 @@ class ASTRecordReader SwitchCase *getSwitchCaseWithID(unsigned ID) { return Reader->getSwitchCaseWithID(ID); } + +private: + Attr *readOrDeferAttrImpl(Decl *D); + void readOrDeferAttributesImpl(AttrVec &Attrs, Decl *D); }; /// Helper class that saves the current stream position and diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index b53f99732cacce..57d1d4d696290d 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -10079,6 +10079,11 @@ void ASTReader::finishPendingActions() { } PendingDeducedVarTypes.clear(); +// Load the delayed preferred name attributes. +for (unsigned I = 0; I != PendingDeferredAttributes.size(); ++I) + loadDeferredAttribute(PendingDeferredAttributes[I]); +PendingDeferredAttributes.clear(); + // For each decl chain that we wanted to complete while deserializing, mark // it as "still needs to be completed". for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) { diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index dee5169ae5723a..043bed8dc7f382 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -612,7 +612,7 @@ void ASTDeclReader::VisitDecl(Decl *D) { if (HasAttrs) { AttrVec Attrs; -Record.readAttributes(Attrs); +Record.readOrDeferAttributes(Attrs, D); // Avoid calling setAttrs() directly because it uses Decl::getASTContext() // internally which is unsafe during derialization. D->setAttrsImpl(Attrs, Reader.getContext()); @@ -3118,13 +3118,18 @@ class AttrReader { return Reader.readVersionTuple(); } + void skipInts(unsigned N) { Reader.skipInts(N); } + + un
[clang] [flang] [llvm] [mlir] [Flang][OpenMP] Lowering of host-evaluated clauses (PR #116219)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/116219 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Modules] Delay deserialization of preferred_name attribute at r… (PR #122726)
@@ -3159,13 +3175,27 @@ Attr *ASTRecordReader::readAttr() { return New; } -/// Reads attributes from the current stream position. -void ASTRecordReader::readAttributes(AttrVec &Attrs) { +void ASTRecordReader::readAttributesImpl(AttrVec &Attrs, Decl *D) { for (unsigned I = 0, E = readInt(); I != E; ++I) -if (auto *A = readAttr()) +if (auto *A = readAttr(D)) Attrs.push_back(A); } +Attr *ASTRecordReader::readAttr() { return readAttrImpl(nullptr); } + +/// Reads attributes from the current stream position. +void ASTRecordReader::readAttributes(AttrVec &Attrs) { + readAttributesImpl(Attrs, nullptr); +} + +/// Reads one attribute from the current stream position, advancing Idx. +Attr *ASTRecordReader::readAttr(Decl *D) { return readAttrImpl(D); } ilya-biryukov wrote: The behavior of this funciton is drastically different from `readAttr`, could we use a different name and document that it delays reading of some attributes? Same for `readAttributes` https://github.com/llvm/llvm-project/pull/122726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] [Modules] Delay reading type source info of the preferred_name attribute. (PR #122250)
VitaNuo wrote: > The code in https://github.com/llvm/llvm-project/pull/122726 looks better. I > didn't do detailed review since it is marked WIP. Thanks for the feedback. I will then try to generalize https://github.com/llvm/llvm-project/pull/122726 to delay all/multiple attributes. Depending on how that plays out, I will then send out https://github.com/llvm/llvm-project/pull/122726 for proper review. https://github.com/llvm/llvm-project/pull/122250 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not allow unorderable features in [[gnu::target{,_clones}]] (PR #98426)
DanShaders wrote: I do, thanks! https://github.com/llvm/llvm-project/pull/98426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Change the way we do init chains (PR #122871)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` running on `doug-worker-5` while building `clang` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/12782 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll' FAILED Exit Code: 2 Command Output (stderr): -- RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll + /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll + /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll #0 0x0001057569c0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100e9a9c0) #1 0x000105754a44 llvm::sys::RunSignalHandlers() (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100e98a44) #2 0x00010575707c SignalHandler(int) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100e9b07c) #3 0x000184806584 (/usr/lib/system/libsystem_platform.dylib+0x18047a584) #4 0x8101845e93c8 #5 0x000105306fd8 llvm::DenseMap, llvm::detail::DenseMapPair>, llvm::DenseMapInfo, llvm::detail::DenseMapPair, llvm::detail::DenseMapPair>>>::~DenseMap() (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100a4afd8) #6 0x00010537a324 (anonymous namespace)::GenericLLVMIRPlatformSupport::deinitialize(llvm::orc::JITDylib&) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x100abe324) #7 0x0001048c5d78 runOrcJIT(char const*) (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x19d78) #8 0x0001048c14a4 main (/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/lli+0x154a4) #9 0x00018444b154 FileCheck error: '' is empty. FileCheck command line: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll -- ``` https://github.com/llvm/llvm-project/pull/122871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] document that by default FP turned off for ARM baremetal (PR #122881)
@@ -1076,6 +1076,8 @@ Arm and AArch64 Support in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding the ``-momit-leaf-frame-pointer`` option. +- For ARM baremetal targets, the frame pointer (FP) is now turned off by default. DavidSpickett wrote: I would move this before the one above and add to this "To enable the frame pointer use the `-fno-omit-frame-pointer` option. I know it's stated again in the second one, but it answers the "how do I get the old way" question more obviously. If I am not someone who ever cared to disable FP, I won't understand / care to understand what the leaf function stuff means. https://github.com/llvm/llvm-project/pull/122881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [C++20] [Modules] Support module level lookup (PR #122887)
https://github.com/ChuanqiXu9 created https://github.com/llvm/llvm-project/pull/122887 Close https://github.com/llvm/llvm-project/issues/90154 This patch is also an optimization to the lookup process to utilize the information provided by `export` keyword. Previously, in the lookup process, the `export` keyword only takes part in the check part, it doesn't get involved in the lookup process. That said, previously, in a name lookup for 'name', we would load all of declarations with the name 'name' and check if these declarations are valid or not. It works well. But it is inefficient since it may load declarations that may not be wanted. Note that this patch actually did a trick in the lookup process instead of bring module information to DeclarationName or considering module information when deciding if two declarations are the same. So it may not be a surprise to me if there are missing cases. But it is not a regression. It should be already the case. Issue reports are welcomed. In this patch, I tried to split the big lookup table into a lookup table as before and a module local lookup table, which takes a combination of the ID of the DeclContext and hash value of the primary module name as the key. And refactored `DeclContext::lookup()` method to take the module information. So that a lookup in a DeclContext won't load declarations that are local to **other** modules. And also I think it is already beneficial to split the big lookup table since it may reduce the conflicts during lookups in the hash table. BTW, this patch introduced a **regression** for a reachability rule in C++20 but it was false-negative. See 'clang/test/CXX/module/module.interface/p7.cpp' for details. This patch is not expected to introduce any other regressions for non-c++20-modules users since the module local lookup table should be empty for them. >From 01dae6621b6225e71f2a8c2e695f51fcf74e6b68 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 26 Dec 2024 16:00:51 +0800 Subject: [PATCH] [C++20] [Modules] Support module level lookup Close https://github.com/llvm/llvm-project/issues/90154 This patch is also an optimization to the lookup process to utilize the information provided by `export` keyword. Previously, in the lookup process, the `export` keyword only takes part in the check part, it doesn't get involved in the lookup process. That said, previously, in a name lookup for 'name', we would load all of declarations with the name 'name' and check if these declarations are valid or not. It works well. But it is inefficient since it may load declarations that may not be wanted. Note that this patch actually did a trick in the lookup process instead of bring module information to DeclarationName or considering module information when deciding if two declarations are the same. So it may not be a surprise to me if there are missing cases. But it is not a regression. It should be already the case. Issue reports are welcomed. In this patch, I tried to split the big lookup table into a lookup table as before and a module local lookup table, which takes a combination of the ID of the DeclContext and hash value of the primary module name as the key. And refactored `DeclContext::lookup()` method to take the module information. So that a lookup in a DeclContext won't load declarations that are local to **other** modules. And also I think it is already beneficial to split the big lookup table since it may reduce the conflicts during lookups in the hash table. BTW, this patch introduced a **regression** for a reachability rule in C++20 but it was false-negative. See 'clang/test/CXX/module/module.interface/p7.cpp' for details. This patch is not expected to introduce any other regressions for non-c++20-modules users since the module local lookup table should be empty for them. --- clang/docs/ReleaseNotes.rst | 2 + clang/include/clang/AST/DeclBase.h| 10 + clang/include/clang/AST/ExternalASTMerger.h | 3 +- clang/include/clang/AST/ExternalASTSource.h | 10 +- .../clang/Sema/MultiplexExternalSemaSource.h | 3 +- .../include/clang/Serialization/ASTBitCodes.h | 6 + clang/include/clang/Serialization/ASTReader.h | 32 +- clang/include/clang/Serialization/ASTWriter.h | 16 +- clang/lib/AST/DeclBase.cpp| 23 +- clang/lib/AST/ExternalASTMerger.cpp | 3 +- clang/lib/AST/ExternalASTSource.cpp | 6 +- clang/lib/Interpreter/CodeCompletion.cpp | 6 +- .../lib/Sema/MultiplexExternalSemaSource.cpp | 7 +- clang/lib/Serialization/ASTReader.cpp | 195 ++--- clang/lib/Serialization/ASTReaderDecl.cpp | 69 +++-- clang/lib/Serialization/ASTReaderInternals.h | 72 - clang/lib/Serialization/ASTWriter.cpp | 273 ++ clang/lib/Serialization/ASTWriterDecl.cpp | 13 +- .../basic.scope/basic.scope.namespace/p2.cpp | 4 +- .../test/CXX/module/basic/basic.link/p2.cppm | 3 +
[clang] [lldb] [C++20] [Modules] Support module level lookup (PR #122887)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: Chuanqi Xu (ChuanqiXu9) Changes Close https://github.com/llvm/llvm-project/issues/90154 This patch is also an optimization to the lookup process to utilize the information provided by `export` keyword. Previously, in the lookup process, the `export` keyword only takes part in the check part, it doesn't get involved in the lookup process. That said, previously, in a name lookup for 'name', we would load all of declarations with the name 'name' and check if these declarations are valid or not. It works well. But it is inefficient since it may load declarations that may not be wanted. Note that this patch actually did a trick in the lookup process instead of bring module information to DeclarationName or considering module information when deciding if two declarations are the same. So it may not be a surprise to me if there are missing cases. But it is not a regression. It should be already the case. Issue reports are welcomed. In this patch, I tried to split the big lookup table into a lookup table as before and a module local lookup table, which takes a combination of the ID of the DeclContext and hash value of the primary module name as the key. And refactored `DeclContext::lookup()` method to take the module information. So that a lookup in a DeclContext won't load declarations that are local to **other** modules. And also I think it is already beneficial to split the big lookup table since it may reduce the conflicts during lookups in the hash table. BTW, this patch introduced a **regression** for a reachability rule in C++20 but it was false-negative. See 'clang/test/CXX/module/module.interface/p7.cpp' for details. This patch is not expected to introduce any other regressions for non-c++20-modules users since the module local lookup table should be empty for them. --- Patch is 76.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122887.diff 35 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+2) - (modified) clang/include/clang/AST/DeclBase.h (+10) - (modified) clang/include/clang/AST/ExternalASTMerger.h (+2-1) - (modified) clang/include/clang/AST/ExternalASTSource.h (+8-2) - (modified) clang/include/clang/Sema/MultiplexExternalSemaSource.h (+2-1) - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+6) - (modified) clang/include/clang/Serialization/ASTReader.h (+28-4) - (modified) clang/include/clang/Serialization/ASTWriter.h (+13-3) - (modified) clang/lib/AST/DeclBase.cpp (+19-4) - (modified) clang/lib/AST/ExternalASTMerger.cpp (+2-1) - (modified) clang/lib/AST/ExternalASTSource.cpp (+3-3) - (modified) clang/lib/Interpreter/CodeCompletion.cpp (+4-2) - (modified) clang/lib/Sema/MultiplexExternalSemaSource.cpp (+4-3) - (modified) clang/lib/Serialization/ASTReader.cpp (+158-37) - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+52-17) - (modified) clang/lib/Serialization/ASTReaderInternals.h (+56-16) - (modified) clang/lib/Serialization/ASTWriter.cpp (+213-60) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+11-2) - (modified) clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp (+2-2) - (modified) clang/test/CXX/module/basic/basic.link/p2.cppm (+1-2) - (modified) clang/test/CXX/module/module.import/p2.cpp (+2-8) - (modified) clang/test/CXX/module/module.interface/p7.cpp (+4-6) - (modified) clang/test/CXX/module/module.reach/p5.cpp (+1-2) - (modified) clang/test/Modules/Reachability-template-default-arg.cpp (+1-2) - (modified) clang/test/Modules/cxx20-10-1-ex2.cpp (+1-2) - (modified) clang/test/Modules/deduction-guide3.cppm (+1-3) - (added) clang/test/Modules/module-local-with-templates.cppm (+68) - (added) clang/test/Modules/pr90154.cppm (+25) - (modified) clang/unittests/AST/ExternalASTSourceTest.cpp (+2-1) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h (+6-4) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp (+2-1) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h (+5-3) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp (+2-1) - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h (+2-1) - (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp (+2-1) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9eeb872aa57d79..142ed6e19b0a79 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -316,6 +316,8 @@ C++23 Feature Support C++20 Feature Support ^ +- Implemented module level lookup for C++20 modules. (#GH90154) + Resolutions to C++ Defect Reports ^ diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 77abd8b657a616..b999ae6724e3cd 100644 -