[clang] [llvm] [HLSL][SPIR-V] Implement vk::ext_builtin_input attribute (PR #138530)
https://github.com/Keenuts updated https://github.com/llvm/llvm-project/pull/138530 From 085154ddedf3b0789a3908231d04f997e9e66ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= Date: Wed, 30 Apr 2025 11:06:55 +0200 Subject: [PATCH 1/7] [HLSL] Implement vk::ext_builtin_input attribute This variable attribute is used in HLSL to add Vulkan specific builtins in a shader. The attribute is documented here: https://github.com/microsoft/hlsl-specs/blob/17727e88fd1cb09013cb3a144110826af05f4dd5/proposals/0011-inline-spirv.md Those variable, even if marked as `static` are externally initialized by the pipeline/driver/GPU. This is handled by moving them to a specific address space `hlsl_input`, also added by this commit. The design for input variables in Clang can be found here: https://github.com/llvm/wg-hlsl/blob/355771361ef69259fef39a65caef8bff9cb4046d/proposals/0019-spirv-input-builtin.md Related to #136920 --- clang/include/clang/Basic/AddressSpaces.h | 1 + clang/include/clang/Basic/Attr.td | 13 +++ clang/include/clang/Basic/AttrDocs.td | 22 +++ .../include/clang/Basic/AttributeCommonInfo.h | 2 +- clang/include/clang/Sema/SemaHLSL.h | 2 ++ clang/lib/AST/Type.cpp| 1 + clang/lib/AST/TypePrinter.cpp | 2 ++ clang/lib/Basic/Attributes.cpp| 1 + clang/lib/Basic/TargetInfo.cpp| 2 ++ clang/lib/Basic/Targets/AArch64.h | 1 + clang/lib/Basic/Targets/AMDGPU.cpp| 2 ++ clang/lib/Basic/Targets/DirectX.h | 1 + clang/lib/Basic/Targets/NVPTX.h | 1 + clang/lib/Basic/Targets/SPIR.h| 2 ++ clang/lib/Basic/Targets/SystemZ.h | 1 + clang/lib/Basic/Targets/TCE.h | 1 + clang/lib/Basic/Targets/WebAssembly.h | 1 + clang/lib/Basic/Targets/X86.h | 1 + clang/lib/CodeGen/CGHLSLRuntime.cpp | 11 ++ clang/lib/CodeGen/CGHLSLRuntime.h | 1 + clang/lib/CodeGen/CodeGenModule.cpp | 17 ++ clang/lib/Sema/SemaDecl.cpp | 6 + clang/lib/Sema/SemaDeclAttr.cpp | 3 +++ clang/lib/Sema/SemaHLSL.cpp | 14 clang/test/CodeGenHLSL/vk-input-builtin.hlsl | 14 .../SemaTemplate/address_space-dependent.cpp | 4 ++-- 26 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 clang/test/CodeGenHLSL/vk-input-builtin.hlsl diff --git a/clang/include/clang/Basic/AddressSpaces.h b/clang/include/clang/Basic/AddressSpaces.h index 519d959bb636c..48e4a1c61fe02 100644 --- a/clang/include/clang/Basic/AddressSpaces.h +++ b/clang/include/clang/Basic/AddressSpaces.h @@ -61,6 +61,7 @@ enum class LangAS : unsigned { hlsl_constant, hlsl_private, hlsl_device, + hlsl_input, // Wasm specific address spaces. wasm_funcref, diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index df7bba094fce6..6b043160bd3bc 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -140,6 +140,11 @@ def SharedVar : SubsetSubjecthasGlobalStorage() && !S->getTLSKind()}], "global variables">; +def HLSLInputBuiltin : SubsetSubjecthasGlobalStorage() && +S->getStorageClass()==StorageClass::SC_Static && +S->getType().isConstQualified()}], + "input builtin">; + def GlobalVar : SubsetSubjecthasGlobalStorage()}], "global variables">; @@ -4908,6 +4913,14 @@ def HLSLWaveSize: InheritableAttr { let Documentation = [WaveSizeDocs]; } +def HLSLVkExtBuiltinInput : InheritableAttr { + let Spellings = [CXX11<"vk", "ext_builtin_input">]; + let Args = [IntArgument<"BuiltIn">]; + let Subjects = SubjectList<[HLSLInputBuiltin], ErrorDiag>; + let LangOpts = [HLSL]; + let Documentation = [HLSLVkExtBuiltinInputDocs]; +} + def RandomizeLayout : InheritableAttr { let Spellings = [GCC<"randomize_layout">]; let Subjects = SubjectList<[Record]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index cbb397cb31dfb..9fc5ee24bf02f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -8497,6 +8497,28 @@ and copied back to the argument after the callee returns. }]; } +def HLSLVkExtBuiltinInputDocs : Documentation { + let Category = DocCatVariable; + let Content = [{ +Vulkan shaders have `Input` builtins. Those variables are externally +initialized by the driver/pipeline, but each copy is private to the current +lane. + +Those builtins can be declared using the `[[vk::ext_builtin_input]]` attribute +like follows: + +.. code-block:: c++ + [[vk::ext_builtin_input(/* WorkgroupId */ 26)]] + static const uint3 groupid; + +This variable will be lowered into a module-level variable, with the `Input
[clang] [llvm] [LLVM][VecLib] Refactor LIBMVEC integration to be target neutral. (PR #138262)
@@ -1360,8 +1360,15 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib( addVectorizableFunctions(VecFuncs_DarwinLibSystemM); break; } - case LIBMVEC_X86: { -addVectorizableFunctions(VecFuncs_LIBMVEC_X86); + case LIBMVEC: { +switch (TargetTriple.getArch()) { +default: + break; +case llvm::Triple::x86: +case llvm::Triple::x86_64: + addVectorizableFunctions(VecFuncs_LIBMVEC_X86); + break; +} paulwalker-arm wrote: This PR is prep work for adding support for the AArch64 build of libmvec. We'll want this layout then anyway so I'm going to reject this suggestion. https://github.com/llvm/llvm-project/pull/138262 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExprConstant] Bail out on invalid lambda capture inits (PR #138832)
https://github.com/cor3ntin approved this pull request. Missing changelog entry. Otherwise LGTM https://github.com/llvm/llvm-project/pull/138832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL][AMDGPU] OpenCL Kernel stubs should be assigned alwaysinline attribute (PR #137769)
https://github.com/lalaniket8 closed https://github.com/llvm/llvm-project/pull/137769 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Correctly annotate ObjC `* __autoreleasing *` (PR #138799)
https://github.com/kadircet approved this pull request. thanks! https://github.com/llvm/llvm-project/pull/138799 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From 56bacf47c53aca276ae4fa6aa2972b7eda152ddd Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 01/12] Reapply "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (#122130) This reverts commit 3972ed57088f6515b787d7d38dec03dc74e51827. --- clang/include/clang/Sema/Sema.h | 22 +++- clang/include/clang/Sema/Template.h | 6 + clang/lib/Sema/SemaConcept.cpp| 47 ++- clang/lib/Sema/SemaTemplateDeduction.cpp | 49 +--- clang/lib/Sema/SemaTemplateDeductionGuide.cpp | 8 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 -- clang/lib/Sema/TreeTransform.h| 2 +- clang/test/CXX/drs/cwg23xx.cpp| 29 + clang/test/CXX/drs/cwg26xx.cpp| 2 +- clang/test/CXX/drs/cwg27xx.cpp| 20 +++ .../expr.prim.req/nested-requirement.cpp | 2 +- .../constrant-satisfaction-conversions.cpp| 6 +- .../SemaCXX/concept-crash-on-diagnostic.cpp | 2 +- clang/test/SemaCXX/cxx20-ctad-type-alias.cpp | 2 +- clang/test/SemaCXX/cxx23-assume.cpp | 6 +- clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 2 +- clang/test/SemaCXX/lambda-unevaluated.cpp | 4 +- .../SemaTemplate/concepts-recursive-inst.cpp | 4 +- .../SemaTemplate/cxx2a-constraint-exprs.cpp | 2 +- .../nested-implicit-deduction-guides.cpp | 8 +- clang/www/cxx_dr_status.html | 8 +- 21 files changed, 289 insertions(+), 57 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 96d81e618494a..3b1f4d3234ea9 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13303,6 +13303,7 @@ class Sema final : public SemaBase { /// /// \param SkipForSpecialization when specified, any template specializations /// in a traversal would be ignored. + /// /// \param ForDefaultArgumentSubstitution indicates we should continue looking /// when encountering a specialized member function template, rather than /// returning immediately. @@ -13314,6 +13315,17 @@ class Sema final : public SemaBase { bool SkipForSpecialization = false, bool ForDefaultArgumentSubstitution = false); + /// Apart from storing the result to \p Result, this behaves the same as + /// another overload. + void getTemplateInstantiationArgs( + MultiLevelTemplateArgumentList &Result, const NamedDecl *D, + const DeclContext *DC = nullptr, bool Final = false, + std::optional> Innermost = std::nullopt, + bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr, + bool ForConstraintInstantiation = false, + bool SkipForSpecialization = false, + bool ForDefaultArgumentSubstitution = false); + /// RAII object to handle the state changes required to synthesize /// a function body. class SynthesizedFunctionScope { @@ -13590,7 +13602,7 @@ class Sema final : public SemaBase { ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); - // Unlike the above, this does not evaluates constraints. + // Unlike the above, this does not evaluate constraints. ExprResult SubstConstraintExprWithoutSatisfaction( Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -14732,10 +14744,10 @@ class Sema final : public SemaBase { const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange); - bool CheckInstantiatedFunctionTemplateConstraints( - SourceLocation PointOfInstantiation, FunctionDecl *Decl, - ArrayRef TemplateArgs, - ConstraintSatisfaction &Satisfaction); + bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation, +FunctionDecl *Decl, +ArrayRef TemplateArgs, +ConstraintSatisfaction &Satisfaction); /// \brief Emit diagnostics explaining why a constraint expression was deemed /// unsatisfied. diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index f9a10cfafb1f7..39f0cf225e673 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char { llvm::PointerUnion * findInstantiationOf(const Decl *D); +/// Similar to \p findInstantiationOf(), but it wouldn't assert if the +/// instantiation was not found within the current instantiation scope. This +/// is helpful for on-demand declaration instantiation. +llvm::PointerUnion * +findInstantiationUnsafe(const Decl *D); + void InstantiatedLocal(const Decl *D, Decl *Inst); void InstantiatedLocalPackArg(const Decl *D, VarD
[clang] [CIR] Upstream extract op for VectorType (PR #138413)
xlauko wrote: > > Overall looks good. While here, can you please implement a folder for this > > operation? It should kick-in if both idx and input vector are constants. > > @bcardosolopes I implement it like this snippet > > ``` > OpFoldResult cir::VecExtractOp::fold(FoldAdaptor adaptor) { > const auto vectorAttr = > llvm::dyn_cast_if_present(adaptor.getVec()); > if (!vectorAttr) > return {}; > > const auto indexAttr = > llvm::dyn_cast_if_present(adaptor.getIndex()); > if (!indexAttr) > return {}; > > const mlir::ArrayAttr elements = vectorAttr.getElts(); > const int64_t index = indexAttr.getSInt(); > return elements[index]; > } > ``` > > But I am thinking, is there a case that codegen will perform extractOp > directly from ConstVec, not on load or get_global? I see a similar > implementation in MLIR Vector Dialect 🤔 I will try to come up with a test > case for testing I think no need for dyn_casts here, those gets should already reaturn `cir::ConstVectorAttr` and `cir::IntAttr`. https://github.com/llvm/llvm-project/pull/138413 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
https://github.com/Sirraide commented: > The LLVM cleanup was more surprising: I discovered that we have an [old > policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers) > about including out-of-line virtual functions in every class with a vtable, > even final ones. This means our codebase has many virtual "anchor" functions > which do nothing except control where the vtable is emitted, and which > trigger the warning. I looked into alternatives to satisfy the policy, such > as using destructors instead of introducing a new function, but it wasn't > clear if they had larger implications. I wonder if we could somehow add an escape hatch for this somehow—maybe don’t fire the warning on the first virtual function that is declared out-of-line if there’s an easy way of doing that, but that feels like a hack. We could also add an attribute instead to surpress the warning, but is adding an attribute for a single diagnostic really worth it? Alternatively, we could ‘fix’ our codebase instead by introducing an `LLVM_VIRTUAL_ANCHOR` macro or sth like that which disables the diagnostic for that one declaration—I guess this probably depends how common this pattern is elsewhere; if there are a lot of people who do this then the attribute might be easier to use. https://github.com/llvm/llvm-project/pull/138741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
@@ -16,6 +16,7 @@ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare") _LIBCPP_BEGIN_NAMESPACE_STD namespace { +// Whitespace change DO NOT MERGE Sirraide wrote: 👀 https://github.com/llvm/llvm-project/pull/138741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/138741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
@@ -16,6 +16,7 @@ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare") _LIBCPP_BEGIN_NAMESPACE_STD namespace { +// Whitespace change DO NOT MERGE Sirraide wrote: > This should probably work. To make sure you can make a simple change in the > libcxx/ subdirectory to trigger the libc++ pre-commit CI (which should of > course be removed again before actually committing). Ah, I see https://github.com/llvm/llvm-project/pull/138741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/138741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] diagnose unknown attribute namespaces (PR #138519)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/138519 >From cbbca4d26b8d00eb103f110c2341fab2e4a2e40d Mon Sep 17 00:00:00 2001 From: Oleksandr Tarasiuk Date: Mon, 5 May 2025 15:30:14 +0300 Subject: [PATCH 1/2] [Clang] diagnose unknown attribute namespaces --- clang/docs/ReleaseNotes.rst | 2 ++ clang/include/clang/Basic/AttributeCommonInfo.h | 1 + clang/lib/Basic/Attributes.cpp | 4 clang/lib/Sema/SemaDeclAttr.cpp | 17 ++--- clang/test/CXX/module/module.interface/p3.cpp | 2 +- clang/test/OpenMP/openmp_attribute_parsing.cpp | 10 +- clang/test/Parser/c2x-attributes.c | 2 +- clang/test/Parser/cxx0x-attributes.cpp | 6 +++--- .../test/Sema/patchable-function-entry-attr.cpp | 2 +- clang/test/Sema/unknown-attributes.c| 12 .../test/SemaCXX/cxx2a-ms-no-unique-address.cpp | 4 ++-- 11 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 clang/test/Sema/unknown-attributes.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a80fedebf8f89..fba357afede74 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -385,6 +385,8 @@ related warnings within the method body. - Clang now disallows the use of attributes applied before an ``extern template`` declaration (#GH79893). +- Clang now diagnoses unknown attribute namespaces. + Improvements to Clang's diagnostics --- diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h b/clang/include/clang/Basic/AttributeCommonInfo.h index 4af5a8fd1852c..6db7b53317e7d 100644 --- a/clang/include/clang/Basic/AttributeCommonInfo.h +++ b/clang/include/clang/Basic/AttributeCommonInfo.h @@ -196,6 +196,7 @@ class AttributeCommonInfo { /// with surrounding underscores removed as appropriate (e.g. /// __gnu__::__attr__ will be normalized to gnu::attr). std::string getNormalizedFullName() const; + SourceRange getNormalizedRange() const; bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; } bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; } diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp index 6a070a99c8d96..8ff5cc54ccc93 100644 --- a/clang/lib/Basic/Attributes.cpp +++ b/clang/lib/Basic/Attributes.cpp @@ -181,6 +181,10 @@ std::string AttributeCommonInfo::getNormalizedFullName() const { normalizeName(getAttrName(), getScopeName(), getSyntax())); } +SourceRange AttributeCommonInfo::getNormalizedRange() const { + return hasScope() ? SourceRange(ScopeLoc, AttrRange.getEnd()) : AttrRange; +} + static AttributeCommonInfo::Scope getScopeFromNormalizedScopeName(StringRef ScopeName) { return llvm::StringSwitch(ScopeName) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index bfb3ee9dcbd16..c481c338b27d6 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6861,13 +6861,16 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, // though they were unknown attributes. if (AL.getKind() == ParsedAttr::UnknownAttribute || !AL.existsInTarget(S.Context.getTargetInfo())) { -S.Diag(AL.getLoc(), - AL.isRegularKeywordAttribute() - ? (unsigned)diag::err_keyword_not_supported_on_target - : AL.isDeclspecAttribute() - ? (unsigned)diag::warn_unhandled_ms_attribute_ignored - : (unsigned)diag::warn_unknown_attribute_ignored) -<< AL << AL.getRange(); +if (AL.isRegularKeywordAttribute() || AL.isDeclspecAttribute()) { + S.Diag(AL.getLoc(), AL.isRegularKeywordAttribute() + ? diag::err_keyword_not_supported_on_target + : diag::warn_unhandled_ms_attribute_ignored) + << AL.getAttrName() << AL.getRange(); +} else { + S.Diag(AL.getNormalizedRange().getBegin(), + diag::warn_unknown_attribute_ignored) + << "'" + AL.getNormalizedFullName() + "'" << AL.getNormalizedRange(); +} return; } diff --git a/clang/test/CXX/module/module.interface/p3.cpp b/clang/test/CXX/module/module.interface/p3.cpp index 32819b2dccb11..0b61eb783dcd0 100644 --- a/clang/test/CXX/module/module.interface/p3.cpp +++ b/clang/test/CXX/module/module.interface/p3.cpp @@ -40,7 +40,7 @@ export { // No diagnostic after P2615R1 DR extern "C++" {} // No diagnostic after P2615R1 DR } export [[]]; // No diagnostic after P2615R1 DR -export [[example::attr]]; // expected-warning {{unknown attribute 'attr'}} +export [[example::attr]]; // expected-warning {{unknown attribute 'example::attr' ignored}} // [...] shall not declare a name with internal linkage export static int a; // expected-error {{declaration of 'a' with internal linkage cannot be exported}} diff --git a/clang/test/OpenMP/o
[clang] [llvm] [clang][OpenMP] New OpenMP 6.0 threadset clause (PR #135807)
@@ -3691,6 +3691,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, DestructorsFlag = 0x8, PriorityFlag = 0x20, DetachableFlag = 0x40, +PoolFlag = 0x80, dreachem wrote: For the runtime change in this PR, is it sufficient that we update `kmp_tasking_flags_t` with the corresponding flag we will be passing in for when `threadset(omp_pool)` is present? The spec allows for this flag to be essentially ignored in a compliant implementation, but it will allow someone else to pick it up and implement it in a subsequent patch. https://github.com/llvm/llvm-project/pull/135807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] Fix crash with invalid concept requirement (PR #138877)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes We were previously recovering a bit too hard; consumeClose() would skip to a recovery point, then we would call skipToEnd() to skip to another recovery point. Needless to say, the follow-on diagnostics were not great. But also, follow-on diagnostics were crashing due to unexpected null constraint expressions. Now we only recover once. Fixes #138820 --- Full diff: https://github.com/llvm/llvm-project/pull/138877.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+2) - (modified) clang/lib/Parse/ParseExprCXX.cpp (+3-1) - (modified) clang/test/SemaCXX/concept-crash-on-diagnostic.cpp (+12) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 55f774f5a672e..350244e3054cf 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -660,6 +660,8 @@ Bug Fixes to C++ Support - Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852) - No longer crashes when instantiating invalid variable template specialization whose type depends on itself. (#GH51347), (#GH55872) +- Improved parser recovery of invalid requirement expressions. In turn, this + fixes crashes from follow-on processing of the invalid requirement. (#GH138820) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 32b08a12a3bb6..546c228a30513 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -3706,8 +3706,10 @@ ExprResult Parser::ParseRequiresExpression() { SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch); break; } +// If there's an error consuming the closing bracket, consumeClose() +// will handle skipping to the nearest recovery point for us. if (ExprBraces.consumeClose()) - ExprBraces.skipToEnd(); + break; concepts::Requirement *Req = nullptr; SourceLocation NoexceptLoc; diff --git a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp index c38f075de..1efed72522fef 100644 --- a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp +++ b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp @@ -48,3 +48,15 @@ concept is_foo_concept = __is_same(foo::bar, T); // expected-error@-1 {{'bar' is a private member of 'GH131530::foo'}} } + +namespace GH138820 { +int a; +template +concept atomicish = requires() { + {// expected-note {{to match this '{'}} +a + ... // expected-error {{expected '}'}} + }; +}; +atomicish f(); // expected-error {{expected 'auto' or 'decltype(auto)' after concept name}} +} // namespace GH138820 `` https://github.com/llvm/llvm-project/pull/138877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
Sirraide wrote: > This seems like a good way to do it, since it clearly documents what's going > on. LLVM is the only project I've seen with such a policy; across all of > chromium's dependencies, the extra `virtual` specifiers we flagged were > indeed mistakes. The issue with libc++ was more to do with infrastructure > than the warning itself, IIUC. Alright, in that case I’d say it would be nice to do that in a follow-up pr so we can stop disabling the warning. https://github.com/llvm/llvm-project/pull/138741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang][OpenMP] New OpenMP 6.0 threadset clause (PR #135807)
@@ -3691,6 +3691,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, DestructorsFlag = 0x8, PriorityFlag = 0x20, DetachableFlag = 0x40, +PoolFlag = 0x80, alexey-bataev wrote: The runtime change is better to implement in a separate PR and post an RFC (maybe?) before. Many flags can be ignored, just need to be sure that we do not break anything else here and most of the consumers/users are agree with this change https://github.com/llvm/llvm-project/pull/135807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] Fix crash with invalid concept requirement (PR #138877)
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/138877 We were previously recovering a bit too hard; consumeClose() would skip to a recovery point, then we would call skipToEnd() to skip to another recovery point. Needless to say, the follow-on diagnostics were not great. But also, follow-on diagnostics were crashing due to unexpected null constraint expressions. Now we only recover once. Fixes #138820 >From 2f2f9ba95a1a633a0262ce15a64d6b0d7e14b600 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 7 May 2025 09:55:43 -0400 Subject: [PATCH] [C++20] Fix crash with invalid concept requirement We were previously recovering a bit too hard; consumeClose() would skip to a recovery point, then we would call skipToEnd() to skip to another recovery point. Needless to say, the follow-on diagnostics were not great. But also, follow-on diagnostics were crashing due to unexpected null constraint expressions. Now we only recover once. Fixes #138820 --- clang/docs/ReleaseNotes.rst| 2 ++ clang/lib/Parse/ParseExprCXX.cpp | 4 +++- clang/test/SemaCXX/concept-crash-on-diagnostic.cpp | 12 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 55f774f5a672e..350244e3054cf 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -660,6 +660,8 @@ Bug Fixes to C++ Support - Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852) - No longer crashes when instantiating invalid variable template specialization whose type depends on itself. (#GH51347), (#GH55872) +- Improved parser recovery of invalid requirement expressions. In turn, this + fixes crashes from follow-on processing of the invalid requirement. (#GH138820) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 32b08a12a3bb6..546c228a30513 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -3706,8 +3706,10 @@ ExprResult Parser::ParseRequiresExpression() { SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch); break; } +// If there's an error consuming the closing bracket, consumeClose() +// will handle skipping to the nearest recovery point for us. if (ExprBraces.consumeClose()) - ExprBraces.skipToEnd(); + break; concepts::Requirement *Req = nullptr; SourceLocation NoexceptLoc; diff --git a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp index c38f075de..1efed72522fef 100644 --- a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp +++ b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp @@ -48,3 +48,15 @@ concept is_foo_concept = __is_same(foo::bar, T); // expected-error@-1 {{'bar' is a private member of 'GH131530::foo'}} } + +namespace GH138820 { +int a; +template +concept atomicish = requires() { + {// expected-note {{to match this '{'}} +a + ... // expected-error {{expected '}'}} + }; +}; +atomicish f(); // expected-error {{expected 'auto' or 'decltype(auto)' after concept name}} +} // namespace GH138820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix the warning group of several compatibilty diagnostics (PR #138872)
https://github.com/Endilll commented: Changes to DR tests look good https://github.com/llvm/llvm-project/pull/138872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/138752 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExprConst] Check for array size of initlists (PR #138673)
https://github.com/Sirraide approved this pull request. https://github.com/llvm/llvm-project/pull/138673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] Fix crash with invalid concept requirement (PR #138877)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/138877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix the warning group of several compatibilty diagnostics (PR #138872)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/138872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Add flag to specify an alternative to std::forward (PR #138755)
https://github.com/DimitrijeDobrota updated https://github.com/llvm/llvm-project/pull/138755 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Slightly optimize integral casts of literals (PR #138879)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes We often see initializers like unsigned a = 10; which take an integer literal and immediately cast it to another type. Recognize this pattern and omit the cast, simply emitting the value as a different type directly. This reduces the instruction count by up to 0.13%: http://llvm-compile-time-tracker.com/compare.php?from=303436c6d16518b35288d63a859506ffcc1681e4&to=648f5202f906d1606390b2d1081e4502dc74acc2&stat=instructions:u --- Full diff: https://github.com/llvm/llvm-project/pull/138879.diff 1 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+15-6) ``diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index ae6574cf99159..524473ea17a03 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -486,9 +486,24 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { std::optional FromT = classify(SubExpr->getType()); std::optional ToT = classify(CE->getType()); +auto maybeNegate = [&]() -> bool { + if (CE->getCastKind() == CK_BooleanToSignedIntegral) +return this->emitNeg(*ToT, CE); + return true; +}; + if (!FromT || !ToT) return false; +// Small performance optimization: If the integral cast just casts the +// value of an IntegerLiteral, do that directly. Initializers often +// contain large quantities of these. +if (ToT != PT_IntAP && ToT != PT_IntAPS && +!CE->getType()->isEnumeralType()) { + if (const auto *IL = dyn_cast(SubExpr)) +return this->emitConst(IL->getValue(), CE) && maybeNegate(); +} + if (!this->visit(SubExpr)) return false; @@ -502,12 +517,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { } } -auto maybeNegate = [&]() -> bool { - if (CE->getCastKind() == CK_BooleanToSignedIntegral) -return this->emitNeg(*ToT, CE); - return true; -}; - if (ToT == PT_IntAP) return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE) && maybeNegate(); `` https://github.com/llvm/llvm-project/pull/138879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b59ab70 - [C] Handle comma operator for implicit int->enum conversions (#138752)
Author: Aaron Ballman Date: 2025-05-07T10:05:00-04:00 New Revision: b59ab701e94cce455a53358cbe5082a3efb58fbf URL: https://github.com/llvm/llvm-project/commit/b59ab701e94cce455a53358cbe5082a3efb58fbf DIFF: https://github.com/llvm/llvm-project/commit/b59ab701e94cce455a53358cbe5082a3efb58fbf.diff LOG: [C] Handle comma operator for implicit int->enum conversions (#138752) In C++, the type of an enumerator is the type of the enumeration, whereas in C, the type of the enumerator is 'int'. The type of a comma operator is the type of the right-hand operand, which means you can get an implicit conversion with this code in C but not in C++: ``` enum E { Zero }; enum E foo() { return ((void)0, Zero); } ``` We were previously incorrectly diagnosing this code as being incompatible with C++ because the type of the paren expression would be 'int' there, whereas in C++ the type is 'E'. So now we handle the comma operator with special logic when analyzing implicit conversions in C. When analyzing the left-hand operand of a comma operator, we do not need to check for that operand causing an implicit conversion for the entire comma expression. So we only check for that case with the right-hand operand. This addresses a concern brought up post-commit: https://github.com/llvm/llvm-project/pull/137658#issuecomment-2854525259 Added: Modified: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/implicit-cast.c clang/test/Sema/implicit-int-enum-conversion.c Removed: diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 7f45533713bae..a5e0094f7eeb8 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -11647,6 +11647,15 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } } +static void CheckCommaOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, + bool ExtraCheckForImplicitConversion) { + E = E->IgnoreParenImpCasts(); + AnalyzeImplicitConversions(S, E, CC); + + if (ExtraCheckForImplicitConversion && E->getType() != T) +S.CheckImplicitConversion(E, T, CC); +} + /// Analyze the given compound assignment for the possible losing of /// floating-point precision. static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { @@ -12464,7 +12473,7 @@ static void AnalyzeImplicitConversions( << OrigE->getSourceRange() << T->isBooleanType() << FixItHint::CreateReplacement(UO->getBeginLoc(), "!"); - if (const auto *BO = dyn_cast(SourceExpr)) + if (auto *BO = dyn_cast(SourceExpr)) if ((BO->getOpcode() == BO_And || BO->getOpcode() == BO_Or) && BO->getLHS()->isKnownToHaveBooleanValue() && BO->getRHS()->isKnownToHaveBooleanValue() && @@ -12490,6 +12499,19 @@ static void AnalyzeImplicitConversions( (BO->getOpcode() == BO_And ? "&&" : "||")); S.Diag(BO->getBeginLoc(), diag::note_cast_operand_to_int); } +} else if (BO->isCommaOp() && !S.getLangOpts().CPlusPlus) { + /// Analyze the given comma operator. The basic idea behind the analysis + /// is to analyze the left and right operands slightly diff erently. The + /// left operand needs to check whether the operand itself has an implicit + /// conversion, but not whether the left operand induces an implicit + /// conversion for the entire comma expression itself. This is similar to + /// how CheckConditionalOperand behaves; it's as-if the correct operand + /// were directly used for the implicit conversion check. + CheckCommaOperand(S, BO->getLHS(), T, BO->getOperatorLoc(), +/*ExtraCheckForImplicitConversion=*/false); + CheckCommaOperand(S, BO->getRHS(), T, BO->getOperatorLoc(), +/*ExtraCheckForImplicitConversion=*/true); + return; } // For conditional operators, we analyze the arguments as if they diff --git a/clang/test/Sema/implicit-cast.c b/clang/test/Sema/implicit-cast.c index 088b1958d9b85..4700b7d37a855 100644 --- a/clang/test/Sema/implicit-cast.c +++ b/clang/test/Sema/implicit-cast.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only %s +// RUN: %clang_cc1 -fsyntax-only -verify %s static char *test1(int cf) { return cf ? "abc" : 0; @@ -6,3 +6,8 @@ static char *test1(int cf) { static char *test2(int cf) { return cf ? 0 : "abc"; } + +int baz(void) { + int f; + return ((void)0, f = 1.4f); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.4 to 1}} +} diff --git a/clang/test/Sema/implicit-int-enum-conversion.c b/clang/test/Sema/implicit-int-enum-conversion.c index 13afb5d297aba..36717f36dd083 100644 --- a/clang/test/Sema/implicit-int-enum-conversion.c +++ b/clang/test/Sema/implicit-int-enum-conversion.c @@ -50,3 +50,25 @@ enum E1 quux(void) { return E2_Zero; // expected-warning {{imp
[clang] [analyzer] Workaround for slowdown spikes (unintended scope increase) (PR #136720)
Xazax-hun wrote: `inline-functions-with-ambiguous-loops` sounds good to me. I don't think it makes sense to have `legacy` in the name of an on by default setting. https://github.com/llvm/llvm-project/pull/136720 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Add flag to specify an alternative to std::move (PR #138757)
https://github.com/DimitrijeDobrota updated https://github.com/llvm/llvm-project/pull/138757 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Slightly optimize integral casts of literals (PR #138879)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/138879 We often see initializers like unsigned a = 10; which take an integer literal and immediately cast it to another type. Recognize this pattern and omit the cast, simply emitting the value as a different type directly. This reduces the instruction count by up to 0.13%: http://llvm-compile-time-tracker.com/compare.php?from=303436c6d16518b35288d63a859506ffcc1681e4&to=648f5202f906d1606390b2d1081e4502dc74acc2&stat=instructions:u Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/138752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)
@@ -12490,6 +12499,17 @@ static void AnalyzeImplicitConversions( (BO->getOpcode() == BO_And ? "&&" : "||")); S.Diag(BO->getBeginLoc(), diag::note_cast_operand_to_int); } +} else if (BO->isCommaOp() && !S.getLangOpts().CPlusPlus) { + /// Analyze the given comma operator. The basic idea behind the analysis + /// is to analyze the left and right operands slightly differently. The + /// left operand needs to check whether the operand itself has an implicit + /// conversion, but not whether the left operand induces an implicit + /// conversion for the entire comma expression itself. This is similar to + /// how CheckConditionalOperand behaves; it's as-if the correct operand + /// were directly used for the implicit conversion check. + CheckCommaOperand(S, BO->getLHS(), T, BO->getOperatorLoc(), false); + CheckCommaOperand(S, BO->getRHS(), T, BO->getOperatorLoc(), true); erichkeane wrote: ```suggestion CheckCommaOperand(S, BO->getRHS(), T, BO->getOperatorLoc(), /*ExtraCheckForImplicitConversion=*/true); ``` https://github.com/llvm/llvm-project/pull/138752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)
@@ -4899,6 +4899,234 @@ void CGOpenMPRuntime::emitSingleReductionCombiner(CodeGenFunction &CGF, } } +void CGOpenMPRuntime::emitPrivateReduction( +CodeGenFunction &CGF, SourceLocation Loc, ArrayRef Privates, +ArrayRef LHSExprs, ArrayRef RHSExprs, +ArrayRef ReductionOps) { + if (LHSExprs.empty() || Privates.empty() || ReductionOps.empty()) +return; + + if (LHSExprs.size() != Privates.size() || + LHSExprs.size() != ReductionOps.size()) +return; + + // Create a shared global variable (__shared_reduction_var) to accumulate the + // final result. + // + // Call __kmpc_barrier to synchronize threads before initialization. + // + // The master thread (thread_id == 0) initializes __shared_reduction_var + //with the identity value or initializer. + // + // Call __kmpc_barrier to synchronize before combining. + // For each i: + //- Thread enters critical section. + //- Reads its private value from LHSExprs[i]. + //- Updates __shared_reduction_var[i] = RedOp_i(__shared_reduction_var[i], + //LHSExprs[i]). + //- Exits critical section. + // + // Call __kmpc_barrier after combining. + // + // Each thread copies __shared_reduction_var[i] back to LHSExprs[i]. + // + // Final __kmpc_barrier to synchronize after broadcasting + QualType PrivateType = Privates[0]->getType(); + llvm::Type *LLVMType = CGF.ConvertTypeForMem(PrivateType); + + llvm::Constant *InitVal = nullptr; + const OMPDeclareReductionDecl *UDR = getReductionInit(ReductionOps[0]); + // Determine the initial value for the shared reduction variable + if (!UDR) { +InitVal = llvm::Constant::getNullValue(LLVMType); +if (const auto *DRE = dyn_cast(Privates[0])) { + if (const auto *VD = dyn_cast(DRE->getDecl())) { +const Expr *InitExpr = VD->getInit(); +if (InitExpr && !PrivateType->isAggregateType() && +!PrivateType->isAnyComplexType()) { + Expr::EvalResult Result; + if (InitExpr->EvaluateAsRValue(Result, CGF.getContext())) { +APValue &InitValue = Result.Val; +if (InitValue.isInt()) + InitVal = llvm::ConstantInt::get(LLVMType, InitValue.getInt()); + } +} + } +} + } else { +InitVal = llvm::Constant::getNullValue(LLVMType); chandraghale wrote: Thanks !! I have handled this now via EmitSharedInit. https://github.com/llvm/llvm-project/pull/134709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS (PR #138587)
https://github.com/jeremyd2019 updated https://github.com/llvm/llvm-project/pull/138587 >From 0c380bb4f2f41679ef32db2b9358cf127257d1fb Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Tue, 6 May 2025 16:54:24 -0700 Subject: [PATCH 1/2] [Clang][CMake] use CMakePushCheckState The previous approach of using list(REMOVE ...) would remove *all* occurences of the given item, not just the one appended above. --- clang/CMakeLists.txt | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c3f30e2a8e9c0..f12712f55fb96 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -183,18 +183,17 @@ check_include_file(sys/resource.h CLANG_HAVE_RLIMITS) # This check requires _GNU_SOURCE on linux check_include_file(dlfcn.h CLANG_HAVE_DLFCN_H) if( CLANG_HAVE_DLFCN_H ) + include(CMakePushCheckState) include(CheckLibraryExists) include(CheckSymbolExists) check_library_exists(dl dlopen "" HAVE_LIBDL) + cmake_push_check_state() if( HAVE_LIBDL ) list(APPEND CMAKE_REQUIRED_LIBRARIES dl) endif() list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) check_symbol_exists(dladdr dlfcn.h CLANG_HAVE_DLADDR) - list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) - if( HAVE_LIBDL ) -list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl) - endif() + cmake_pop_check_state() endif() set(CLANG_RESOURCE_DIR "" CACHE STRING >From b145528362ea4a8ecc0e50bd6c140cbf39f663a0 Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Mon, 5 May 2025 14:11:44 -0700 Subject: [PATCH 2/2] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS In #138329, _GNU_SOURCE was added for Cygwin, but when building Clang standalone against an installed LLVM this definition was not picked up, resulting in undefined strnlen. Follow the documentation in https://llvm.org/docs/CMake.html#developing-llvm-passes-out-of-source and add the LLVM_DEFINITIONS in standalone projects' cmakes. --- clang/CMakeLists.txt | 4 1 file changed, 4 insertions(+) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f12712f55fb96..ab2ac9bc6b9ad 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -68,6 +68,10 @@ if(CLANG_BUILT_STANDALONE) option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF) option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON) + separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS}) + add_definitions(${LLVM_DEFINITIONS_LIST}) + list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST}) + include(AddLLVM) include(TableGen) include(HandleLLVMOptions) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS (PR #138587)
https://github.com/jeremyd2019 edited https://github.com/llvm/llvm-project/pull/138587 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG] Allow parsing arbitrary order of attributes for declarations (PR #133107)
AaronBallman wrote: > What do we think @AaronBallman ? I think the diagnostic column is as best > effort as we are going to get, so I'm OK with this as-is. WE could perhaps > improve that, but I don't think doing that here is worth the effort. > > I'll approve, but I want to make sure Aaron has a chance to say otherwise > before merging. Yeah, I think I can live with this. I think not supporting the arbitrary order is more annoying to users than a slight degradation in source location reporting. https://github.com/llvm/llvm-project/pull/133107 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS (PR #138587)
https://github.com/jeremyd2019 edited https://github.com/llvm/llvm-project/pull/138587 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS (PR #138587)
jeremyd2019 wrote: I rebased this on top of #138783 and adjusted the title and description. Now it should be in a good state to push cmake changes for other projects. https://github.com/llvm/llvm-project/pull/138587 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)
@@ -238,3 +246,69 @@ void f(Scoped1 S1, Scoped2 S2) { } #endif + +#if __cplusplus >= 202000L +class my_string { + char *data; + unsigned size; + +public: + template + constexpr my_string(const char (&literal)[N]) { +data = new char[N+1]; +for (size = 0; size < N; ++size) { + data[size] = literal[size]; + if (data[size] == 0) +break; +} +data[size] = 0; + } + + my_string(const my_string &) = delete; + + constexpr my_string(my_string &&that) { +data = that.data; +size = that.size; +that.data = nullptr; +that.size = 0; + } + + constexpr ~my_string() { +delete[] data; + } + + template + constexpr void append(const char (&literal)[N]) { +char *cat = new char[size + N + 1]; +char *tmp = cat; +for (unsigned i = 0; i < size; ++i) { + *tmp++ = data[i]; +} +for (unsigned i = 0; i < N; ++i) { + *tmp = literal[i]; + if (*tmp == 0) +break; + ++tmp; +} +*tmp = 0; +delete[] data; +size = tmp - cat; +data = cat; + } + + constexpr const char *c_str() const { +return data; + } +}; + +constexpr my_string const_string() { + my_string str("hello %s"); + str.append(", %d"); + return str; +} + +void test_constexpr_string() { + printf(const_string().c_str(), "hello", 123); // no-warning + printf(const_string().c_str(), 123, 456); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}} +} +#endif hubert-reinterpretcast wrote: The context of the expression being evaluated during computation for the format string determines whether we can get a false positive/negative if we insist on getting a format string computation result. We know whether or not `if consteval` should return true or false if the context is: - in a manifestly constant-evaluated context or - outside of a manifestly constant-evaluated context and not "in" - a default member initializer, or - a constexpr function or the default arguments thereof. For such cases, I think we should get the correct format string computation. For the other cases, I think (at least in the long term) we should (by default) fail the format string computation attempt when `if consteval` is encountered. https://github.com/llvm/llvm-project/pull/135864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/OpenCL: Add baseline test showing broken codegen (PR #138862)
@@ -109,3 +109,48 @@ void func2(void) { void func3(void) { float a[16][1] = {{0.}}; } + +// CL12-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca( +// CL12-SAME: ) #[[ATTR0]] { +// CL12-NEXT: [[ENTRY:.*:]] +// CL12-NEXT:[[PLONG:%.*]] = alloca i64, align 8, addrspace(5) +// CL12-NEXT:[[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL12-NEXT:[[GLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL12-NEXT:store i64 5, ptr addrspace(5) [[PLONG]], align 8 +// CL12-NEXT:store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[PLONGP]], align 4 +// CL12-NEXT:[[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[PLONGP]], align 4 +// CL12-NEXT:store i64 8, ptr addrspace(5) [[TMP0]], align 8 +// CL12-NEXT:store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[GLONGP]], align 4 +// CL12-NEXT:[[TMP1:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[GLONGP]], align 4 +// CL12-NEXT:store i64 9, ptr addrspace(5) [[TMP1]], align 8 +// CL12-NEXT:ret void +// +// CL20-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca( +// CL20-SAME: ) #[[ATTR0]] { +// CL20-NEXT: [[ENTRY:.*:]] +// CL20-NEXT:[[PLONG:%.*]] = alloca i64, align 8, addrspace(5) +// CL20-NEXT:[[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL20-NEXT:[[GLONGP:%.*]] = alloca ptr, align 8, addrspace(5) +// CL20-NEXT:[[PLONG_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONG]] to ptr +// CL20-NEXT:[[PLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONGP]] to ptr +// CL20-NEXT:[[GLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[GLONGP]] to ptr +// CL20-NEXT:store i64 5, ptr [[PLONG_ASCAST]], align 8 +// CL20-NEXT:store ptr [[PLONG_ASCAST]], ptr [[PLONGP_ASCAST]], align 4 +// CL20-NEXT:[[TMP0:%.*]] = load ptr addrspace(5), ptr [[PLONGP_ASCAST]], align 4 +// CL20-NEXT:store i64 8, ptr addrspace(5) [[TMP0]], align 8 +// CL20-NEXT:store ptr [[PLONG_ASCAST]], ptr [[GLONGP_ASCAST]], align 8 +// CL20-NEXT:[[TMP1:%.*]] = load ptr, ptr [[GLONGP_ASCAST]], align 8 +// CL20-NEXT:store i64 9, ptr [[TMP1]], align 8 +// CL20-NEXT:ret void +// +void wrong_store_type_private_pointer_alloca() { + long plong = 5; + + // This needs to write an addrspace(5) pointer to the temporary alloca + __private long *plongp = &plong; + *plongp = 8; + + // This needs to write an addrspace(0) pointer to the temporary alloca in CL2.0 + long *glongp = &plong; + *glongp = 9; Artem-B wrote: I'd split it into two separate tests -- one for generic pointer, and one for private. That is, unless the issue is when both pointers are needed to reproduce the issue. Right now the checks have way too many `[PG]LONGP?` that require an effort to keep track of. It may be the case where semantically sensible naming in the source code that uses prefix/suffix makes things harder to read when it comes to the test checks. It's a nit. If the test in the current shape works for you I'm OK with it. I just found it to be not quite "painfully obvious". How about something like this: ``` long data = 5; // This needs to write an addrspace(5) pointer to the temporary alloca __private long *pvtp = &data; *pvtp = 8; long *genp = &data; *genp = 9; ``` Maybe, also make genp and pvtp static, so their own allocas do not clutter the test checks. In the checks themselves, I'd also rename generic `_ASCAST` so it reflects the AS we cast to. E.g. `_GEN` or `_PVT`, so the reader does not have to back-track to where the value is captured. https://github.com/llvm/llvm-project/pull/138862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL][RootSignature] Add parsing for empty RootConstants (PR #137999)
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/137999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/OpenCL: Add baseline test showing broken codegen (PR #138862)
@@ -109,3 +109,48 @@ void func2(void) { void func3(void) { float a[16][1] = {{0.}}; } + +// CL12-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca( +// CL12-SAME: ) #[[ATTR0]] { +// CL12-NEXT: [[ENTRY:.*:]] +// CL12-NEXT:[[PLONG:%.*]] = alloca i64, align 8, addrspace(5) +// CL12-NEXT:[[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL12-NEXT:[[GLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL12-NEXT:store i64 5, ptr addrspace(5) [[PLONG]], align 8 +// CL12-NEXT:store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[PLONGP]], align 4 +// CL12-NEXT:[[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[PLONGP]], align 4 +// CL12-NEXT:store i64 8, ptr addrspace(5) [[TMP0]], align 8 +// CL12-NEXT:store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[GLONGP]], align 4 +// CL12-NEXT:[[TMP1:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[GLONGP]], align 4 +// CL12-NEXT:store i64 9, ptr addrspace(5) [[TMP1]], align 8 +// CL12-NEXT:ret void +// +// CL20-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca( +// CL20-SAME: ) #[[ATTR0]] { +// CL20-NEXT: [[ENTRY:.*:]] +// CL20-NEXT:[[PLONG:%.*]] = alloca i64, align 8, addrspace(5) +// CL20-NEXT:[[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL20-NEXT:[[GLONGP:%.*]] = alloca ptr, align 8, addrspace(5) +// CL20-NEXT:[[PLONG_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONG]] to ptr +// CL20-NEXT:[[PLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONGP]] to ptr +// CL20-NEXT:[[GLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[GLONGP]] to ptr +// CL20-NEXT:store i64 5, ptr [[PLONG_ASCAST]], align 8 +// CL20-NEXT:store ptr [[PLONG_ASCAST]], ptr [[PLONGP_ASCAST]], align 4 +// CL20-NEXT:[[TMP0:%.*]] = load ptr addrspace(5), ptr [[PLONGP_ASCAST]], align 4 +// CL20-NEXT:store i64 8, ptr addrspace(5) [[TMP0]], align 8 +// CL20-NEXT:store ptr [[PLONG_ASCAST]], ptr [[GLONGP_ASCAST]], align 8 +// CL20-NEXT:[[TMP1:%.*]] = load ptr, ptr [[GLONGP_ASCAST]], align 8 +// CL20-NEXT:store i64 9, ptr [[TMP1]], align 8 +// CL20-NEXT:ret void +// +void wrong_store_type_private_pointer_alloca() { + long plong = 5; + + // This needs to write an addrspace(5) pointer to the temporary alloca + __private long *plongp = &plong; + *plongp = 8; + + // This needs to write an addrspace(0) pointer to the temporary alloca in CL2.0 Artem-B wrote: It would be useful to mention what we're currently doing wrong, as a FIXME/TODO. One could dig through the IR checks, but it's much easier when one knows what to look for, specifically. https://github.com/llvm/llvm-project/pull/138862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [clang] Add support for `__ptrauth` being applied to integer types (PR #137580)
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/137580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Add flag to specify an alternative to std::move (PR #138757)
https://github.com/HerrCai0907 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/138757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Add flag to specify an alternative to std::move (PR #138757)
HerrCai0907 wrote: > Since :: are specified before std::move, I am not entirely sure whether it > would be required for the custom function. In my testing it worked both with > and without ::. with :: means is a full name including namespace, without :: means only match function name. https://github.com/llvm/llvm-project/pull/138757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Add flag to specify an alternative to std::move (PR #138757)
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/138757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Darwin] Remove legacy framework search path logic in the frontend (PR #138234)
ian-twilightcoder wrote: > LGTM. > > I would remove the newly added commented `/* static */` Alright well it's going to bother me that they don't match the other ones, so I'll get rid of them all. https://github.com/llvm/llvm-project/pull/138234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Darwin] Remove legacy framework search path logic in the frontend (PR #138234)
https://github.com/ian-twilightcoder updated https://github.com/llvm/llvm-project/pull/138234 >From ba40d11f56248850e07eb41b9bdebd407b09f83f Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Thu, 1 May 2025 22:44:52 -0700 Subject: [PATCH] [clang][Darwin] Remove legacy framework search path logic in the frontend Move the Darwin framework search path logic from InitHeaderSearch::AddDefaultIncludePaths to DarwinClang::AddClangSystemIncludeArgs. Add a new -internal-iframework cc1 argument to support the tool chain adding these paths. Now that the tool chain is adding search paths via cc1 flag, they're only added if they exist, so the Preprocessor/cuda-macos-includes.cu test is no longer relevant. Change Driver/driverkit-path.c and Driver/darwin-subframeworks.c to do -### style testing similar to the darwin-header-search and darwin-embedded-search-paths tests. Rename darwin-subframeworks.c to darwin-framework-search-paths.c and have it test all framework search paths, not just SubFrameworks. Add a unit test to validate that the myriad of search path flags result in the expected search path list. Fixes https://github.com/llvm/llvm-project/issues/75638 --- clang/include/clang/Driver/Options.td | 5 + clang/include/clang/Driver/ToolChain.h| 6 + clang/lib/Driver/Job.cpp | 17 +- clang/lib/Driver/ToolChain.cpp| 40 +++-- clang/lib/Driver/ToolChains/Darwin.cpp| 21 +++ clang/lib/Driver/ToolChains/Darwin.h | 4 + clang/lib/Frontend/CompilerInvocation.cpp | 4 + clang/lib/Lex/InitHeaderSearch.cpp| 19 +-- .../System/Library/SubFrameworks/.keep| 0 .../MacOSX15.1.sdk/Library/Frameworks/.keep | 0 .../System/Library/Frameworks/.keep | 0 .../System/Library/SubFrameworks/.keep| 0 .../Driver/darwin-framework-search-paths.c| 23 +++ clang/test/Driver/darwin-subframeworks.c | 18 -- clang/test/Driver/driverkit-path.c| 16 +- .../test/Preprocessor/cuda-macos-includes.cu | 13 -- clang/unittests/Frontend/CMakeLists.txt | 1 + clang/unittests/Frontend/SearchPathTest.cpp | 157 ++ 18 files changed, 270 insertions(+), 74 deletions(-) create mode 100644 clang/test/Driver/Inputs/DriverKit19.0.sdk/System/DriverKit/System/Library/SubFrameworks/.keep create mode 100644 clang/test/Driver/Inputs/MacOSX15.1.sdk/Library/Frameworks/.keep create mode 100644 clang/test/Driver/Inputs/MacOSX15.1.sdk/System/Library/Frameworks/.keep create mode 100644 clang/test/Driver/Inputs/MacOSX15.1.sdk/System/Library/SubFrameworks/.keep create mode 100644 clang/test/Driver/darwin-framework-search-paths.c delete mode 100644 clang/test/Driver/darwin-subframeworks.c delete mode 100644 clang/test/Preprocessor/cuda-macos-includes.cu create mode 100644 clang/unittests/Frontend/SearchPathTest.cpp diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 351e1ad4e1b03..6f9cccbbeca12 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8451,6 +8451,11 @@ def objc_isystem : Separate<["-"], "objc-isystem">, def objcxx_isystem : Separate<["-"], "objcxx-isystem">, MetaVarName<"">, HelpText<"Add directory to the ObjC++ SYSTEM include search path">; +def internal_iframework : Separate<["-"], "internal-iframework">, + MetaVarName<"">, + HelpText<"Add directory to the internal system framework search path; these " + "are assumed to not be user-provided and are used to model system " + "and standard frameworks' paths.">; def internal_isystem : Separate<["-"], "internal-isystem">, MetaVarName<"">, HelpText<"Add directory to the internal system include search path; these " diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index d0059673d6a67..58edf2b3887b0 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -226,6 +226,9 @@ class ToolChain { /// \name Utilities for implementing subclasses. ///@{ + static void addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs, +llvm::opt::ArgStringList &CC1Args, +const Twine &Path); static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path); @@ -236,6 +239,9 @@ class ToolChain { addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path); + static void addSystemFrameworkIncludes(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + ArrayRef Path
[clang] [lld] [llvm] Adding Matching and Inference Functionality to Propeller (PR #139008)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: None (wdx727) Changes We would like to add the matching and inference functionality to Propeller to address the issue that Propeller has zero tolerance for changes in source code and compilation parameters. The complete RFC can be found at the following URL: https://discourse.llvm.org/t/rfc-adding-matching-and-inference-functionality-to-propeller/86238/1. --- Patch is 110.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/139008.diff 53 Files Affected: - (modified) clang/include/clang/Basic/CodeGenOptions.h (+3) - (modified) clang/include/clang/Driver/Options.td (+5) - (modified) clang/lib/CodeGen/BackendUtil.cpp (+21-7) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+12) - (modified) lld/ELF/Config.h (+1) - (modified) lld/ELF/Driver.cpp (+77) - (modified) lld/ELF/LTO.cpp (+1) - (modified) lld/ELF/Options.td (+3) - (added) llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h (+64) - (added) llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h (+51) - (added) llvm/include/llvm/CodeGen/MachineBlockHashInfo.h (+108) - (modified) llvm/include/llvm/CodeGen/Passes.h (+4) - (modified) llvm/include/llvm/InitializePasses.h (+3) - (modified) llvm/include/llvm/LTO/Config.h (+3) - (modified) llvm/include/llvm/Object/ELFTypes.h (+3-2) - (modified) llvm/include/llvm/ObjectYAML/ELFYAML.h (+1) - (modified) llvm/include/llvm/Support/PGOOptions.h (+2) - (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+6) - (modified) llvm/lib/CodeGen/BasicBlockSections.cpp (+43-4) - (modified) llvm/lib/CodeGen/CMakeLists.txt (+3) - (modified) llvm/lib/CodeGen/CodeGen.cpp (+3) - (added) llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp (+123) - (added) llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp (+202) - (added) llvm/lib/CodeGen/MachineBlockHashInfo.cpp (+104) - (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+12-1) - (modified) llvm/lib/LTO/LTOBackend.cpp (+15-9) - (modified) llvm/lib/Object/ELF.cpp (+2-1) - (modified) llvm/lib/ObjectYAML/ELFEmitter.cpp (+1) - (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) - (modified) llvm/lib/Support/PGOOptions.cpp (+6-4) - (modified) llvm/test/CodeGen/AArch64/O0-pipeline.ll (+1) - (modified) llvm/test/CodeGen/AArch64/O3-pipeline.ll (+1) - (modified) llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll (+2) - (modified) llvm/test/CodeGen/X86/O0-pipeline.ll (+1) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll (+6) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-with-basic-block-sections.ll (+4-1) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-with-mfs.ll (+3) - (modified) llvm/test/CodeGen/X86/basic-block-address-map.ll (+7-1) - (modified) llvm/test/CodeGen/X86/opt-pipeline.ll (+1) - (modified) llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml (+18) - (modified) llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-symbolize-relocatable.yaml (+7-3) - (modified) llvm/test/tools/llvm-objdump/X86/elf-pgoanalysismap.yaml (+9) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map-pgo-analysis-map.test (+13-3) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map-relocatable.test (+10-1) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test (+12-2) - (modified) llvm/test/tools/obj2yaml/ELF/bb-addr-map-pgo-analysis-map.yaml (+10) - (modified) llvm/test/tools/obj2yaml/ELF/bb-addr-map.yaml (+10) - (modified) llvm/test/tools/yaml2obj/ELF/bb-addr-map-pgo-analysis-map.yaml (+6-3) - (modified) llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml (+6-3) - (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) - (modified) llvm/tools/obj2yaml/elf2yaml.cpp (+2-1) - (modified) llvm/tools/opt/NewPMDriver.cpp (+15-8) - (modified) llvm/unittests/Object/ELFObjectFileTest.cpp (+58-29) ``diff diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index e3fa6a55e7608..46ea2ba3a4c56 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -288,6 +288,9 @@ class CodeGenOptions : public CodeGenOptionsBase { /// Name of the profile file to use with -fprofile-sample-use. std::string SampleProfileFile; + /// Name of the profile file to use with -fpropeller-profile-use. + std::string PropellerProfileFile; + /// Name of the profile file to use as output for with -fmemory-profile. std::string MemoryProfileOutput; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 351e1ad4e1b03..add5ecc506fa1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1688,6 +1688,11 @@ def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">, as cold. Otherwise, treat callsites without profile samples as if
[clang] [lld] [llvm] Adding Matching and Inference Functionality to Propeller (PR #139008)
llvmbot wrote: @llvm/pr-subscribers-lld-elf Author: None (wdx727) Changes We would like to add the matching and inference functionality to Propeller to address the issue that Propeller has zero tolerance for changes in source code and compilation parameters. The complete RFC can be found at the following URL: https://discourse.llvm.org/t/rfc-adding-matching-and-inference-functionality-to-propeller/86238/1. --- Patch is 110.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/139008.diff 53 Files Affected: - (modified) clang/include/clang/Basic/CodeGenOptions.h (+3) - (modified) clang/include/clang/Driver/Options.td (+5) - (modified) clang/lib/CodeGen/BackendUtil.cpp (+21-7) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+12) - (modified) lld/ELF/Config.h (+1) - (modified) lld/ELF/Driver.cpp (+77) - (modified) lld/ELF/LTO.cpp (+1) - (modified) lld/ELF/Options.td (+3) - (added) llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h (+64) - (added) llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h (+51) - (added) llvm/include/llvm/CodeGen/MachineBlockHashInfo.h (+108) - (modified) llvm/include/llvm/CodeGen/Passes.h (+4) - (modified) llvm/include/llvm/InitializePasses.h (+3) - (modified) llvm/include/llvm/LTO/Config.h (+3) - (modified) llvm/include/llvm/Object/ELFTypes.h (+3-2) - (modified) llvm/include/llvm/ObjectYAML/ELFYAML.h (+1) - (modified) llvm/include/llvm/Support/PGOOptions.h (+2) - (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+6) - (modified) llvm/lib/CodeGen/BasicBlockSections.cpp (+43-4) - (modified) llvm/lib/CodeGen/CMakeLists.txt (+3) - (modified) llvm/lib/CodeGen/CodeGen.cpp (+3) - (added) llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp (+123) - (added) llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp (+202) - (added) llvm/lib/CodeGen/MachineBlockHashInfo.cpp (+104) - (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+12-1) - (modified) llvm/lib/LTO/LTOBackend.cpp (+15-9) - (modified) llvm/lib/Object/ELF.cpp (+2-1) - (modified) llvm/lib/ObjectYAML/ELFEmitter.cpp (+1) - (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) - (modified) llvm/lib/Support/PGOOptions.cpp (+6-4) - (modified) llvm/test/CodeGen/AArch64/O0-pipeline.ll (+1) - (modified) llvm/test/CodeGen/AArch64/O3-pipeline.ll (+1) - (modified) llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll (+2) - (modified) llvm/test/CodeGen/X86/O0-pipeline.ll (+1) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll (+6) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-with-basic-block-sections.ll (+4-1) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-with-mfs.ll (+3) - (modified) llvm/test/CodeGen/X86/basic-block-address-map.ll (+7-1) - (modified) llvm/test/CodeGen/X86/opt-pipeline.ll (+1) - (modified) llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml (+18) - (modified) llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-symbolize-relocatable.yaml (+7-3) - (modified) llvm/test/tools/llvm-objdump/X86/elf-pgoanalysismap.yaml (+9) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map-pgo-analysis-map.test (+13-3) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map-relocatable.test (+10-1) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test (+12-2) - (modified) llvm/test/tools/obj2yaml/ELF/bb-addr-map-pgo-analysis-map.yaml (+10) - (modified) llvm/test/tools/obj2yaml/ELF/bb-addr-map.yaml (+10) - (modified) llvm/test/tools/yaml2obj/ELF/bb-addr-map-pgo-analysis-map.yaml (+6-3) - (modified) llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml (+6-3) - (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) - (modified) llvm/tools/obj2yaml/elf2yaml.cpp (+2-1) - (modified) llvm/tools/opt/NewPMDriver.cpp (+15-8) - (modified) llvm/unittests/Object/ELFObjectFileTest.cpp (+58-29) ``diff diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index e3fa6a55e7608..46ea2ba3a4c56 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -288,6 +288,9 @@ class CodeGenOptions : public CodeGenOptionsBase { /// Name of the profile file to use with -fprofile-sample-use. std::string SampleProfileFile; + /// Name of the profile file to use with -fpropeller-profile-use. + std::string PropellerProfileFile; + /// Name of the profile file to use as output for with -fmemory-profile. std::string MemoryProfileOutput; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 351e1ad4e1b03..add5ecc506fa1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1688,6 +1688,11 @@ def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">, as cold. Otherwise, treat callsites without profile samples as if
[clang] [lld] [llvm] Adding Matching and Inference Functionality to Propeller (PR #139008)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: None (wdx727) Changes We would like to add the matching and inference functionality to Propeller to address the issue that Propeller has zero tolerance for changes in source code and compilation parameters. The complete RFC can be found at the following URL: https://discourse.llvm.org/t/rfc-adding-matching-and-inference-functionality-to-propeller/86238/1. --- Patch is 110.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/139008.diff 53 Files Affected: - (modified) clang/include/clang/Basic/CodeGenOptions.h (+3) - (modified) clang/include/clang/Driver/Options.td (+5) - (modified) clang/lib/CodeGen/BackendUtil.cpp (+21-7) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+12) - (modified) lld/ELF/Config.h (+1) - (modified) lld/ELF/Driver.cpp (+77) - (modified) lld/ELF/LTO.cpp (+1) - (modified) lld/ELF/Options.td (+3) - (added) llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h (+64) - (added) llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h (+51) - (added) llvm/include/llvm/CodeGen/MachineBlockHashInfo.h (+108) - (modified) llvm/include/llvm/CodeGen/Passes.h (+4) - (modified) llvm/include/llvm/InitializePasses.h (+3) - (modified) llvm/include/llvm/LTO/Config.h (+3) - (modified) llvm/include/llvm/Object/ELFTypes.h (+3-2) - (modified) llvm/include/llvm/ObjectYAML/ELFYAML.h (+1) - (modified) llvm/include/llvm/Support/PGOOptions.h (+2) - (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+6) - (modified) llvm/lib/CodeGen/BasicBlockSections.cpp (+43-4) - (modified) llvm/lib/CodeGen/CMakeLists.txt (+3) - (modified) llvm/lib/CodeGen/CodeGen.cpp (+3) - (added) llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp (+123) - (added) llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp (+202) - (added) llvm/lib/CodeGen/MachineBlockHashInfo.cpp (+104) - (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+12-1) - (modified) llvm/lib/LTO/LTOBackend.cpp (+15-9) - (modified) llvm/lib/Object/ELF.cpp (+2-1) - (modified) llvm/lib/ObjectYAML/ELFEmitter.cpp (+1) - (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) - (modified) llvm/lib/Support/PGOOptions.cpp (+6-4) - (modified) llvm/test/CodeGen/AArch64/O0-pipeline.ll (+1) - (modified) llvm/test/CodeGen/AArch64/O3-pipeline.ll (+1) - (modified) llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll (+2) - (modified) llvm/test/CodeGen/X86/O0-pipeline.ll (+1) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll (+6) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-with-basic-block-sections.ll (+4-1) - (modified) llvm/test/CodeGen/X86/basic-block-address-map-with-mfs.ll (+3) - (modified) llvm/test/CodeGen/X86/basic-block-address-map.ll (+7-1) - (modified) llvm/test/CodeGen/X86/opt-pipeline.ll (+1) - (modified) llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml (+18) - (modified) llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-symbolize-relocatable.yaml (+7-3) - (modified) llvm/test/tools/llvm-objdump/X86/elf-pgoanalysismap.yaml (+9) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map-pgo-analysis-map.test (+13-3) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map-relocatable.test (+10-1) - (modified) llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test (+12-2) - (modified) llvm/test/tools/obj2yaml/ELF/bb-addr-map-pgo-analysis-map.yaml (+10) - (modified) llvm/test/tools/obj2yaml/ELF/bb-addr-map.yaml (+10) - (modified) llvm/test/tools/yaml2obj/ELF/bb-addr-map-pgo-analysis-map.yaml (+6-3) - (modified) llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml (+6-3) - (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) - (modified) llvm/tools/obj2yaml/elf2yaml.cpp (+2-1) - (modified) llvm/tools/opt/NewPMDriver.cpp (+15-8) - (modified) llvm/unittests/Object/ELFObjectFileTest.cpp (+58-29) ``diff diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index e3fa6a55e7608..46ea2ba3a4c56 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -288,6 +288,9 @@ class CodeGenOptions : public CodeGenOptionsBase { /// Name of the profile file to use with -fprofile-sample-use. std::string SampleProfileFile; + /// Name of the profile file to use with -fpropeller-profile-use. + std::string PropellerProfileFile; + /// Name of the profile file to use as output for with -fmemory-profile. std::string MemoryProfileOutput; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 351e1ad4e1b03..add5ecc506fa1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1688,6 +1688,11 @@ def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">, as cold. Otherwise, treat callsites without profile samples as if
[clang] [lld] [llvm] Adding Matching and Inference Functionality to Propeller (PR #139008)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/139008 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Support ASan on WASI (PR #139014)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Yuta Saito (kateinoigakukun) Changes I'm working on porting ASan to Wasm/WASI targets, and this is the first part of the change sets. I'll post runtime changes separately. This change makes `-fsanitize=address` available for WASI target by replicating what we do for Emscripten because they share the same memory model. --- Full diff: https://github.com/llvm/llvm-project/pull/139014.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (+6-1) - (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+4-4) ``diff diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp index cd12f2ae5a6de..9fcc33728c1ad 100644 --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -545,8 +545,13 @@ void WebAssembly::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, SanitizerMask WebAssembly::getSupportedSanitizers() const { SanitizerMask Res = ToolChain::getSupportedSanitizers(); if (getTriple().isOSEmscripten()) { -Res |= SanitizerKind::Vptr | SanitizerKind::Leak | SanitizerKind::Address; +Res |= SanitizerKind::Vptr | SanitizerKind::Leak; } + + if (getTriple().isOSEmscripten() || getTriple().isOSWASI()) { +Res |= SanitizerKind::Address; + } + // -fsanitize=function places two words before the function label, which are // -unsupported. Res &= ~SanitizerKind::Function; diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index c1dba77c3532b..840a5e3f31dfd 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -118,7 +118,7 @@ static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46; static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff9000; static const uint64_t kPS_ShadowOffset64 = 1ULL << 40; static const uint64_t kWindowsShadowOffset32 = 3ULL << 28; -static const uint64_t kEmscriptenShadowOffset = 0; +static const uint64_t kWebAssemblyShadowOffset = 0; // The shadow memory space is dynamically allocated. static const uint64_t kWindowsShadowOffset64 = kDynamicShadowSentinel; @@ -499,9 +499,9 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, bool IsRISCV64 = TargetTriple.getArch() == Triple::riscv64; bool IsWindows = TargetTriple.isOSWindows(); bool IsFuchsia = TargetTriple.isOSFuchsia(); - bool IsEmscripten = TargetTriple.isOSEmscripten(); bool IsAMDGPU = TargetTriple.isAMDGPU(); bool IsHaiku = TargetTriple.isOSHaiku(); + bool IsWasm = TargetTriple.isWasm(); ShadowMapping Mapping; @@ -525,8 +525,8 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, Mapping.Offset = kDynamicShadowSentinel; else if (IsWindows) Mapping.Offset = kWindowsShadowOffset32; -else if (IsEmscripten) - Mapping.Offset = kEmscriptenShadowOffset; +else if (IsWasm) + Mapping.Offset = kWebAssemblyShadowOffset; else Mapping.Offset = kDefaultShadowOffset32; } else { // LongSize == 64 `` https://github.com/llvm/llvm-project/pull/139014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Support ASan on WASI (PR #139014)
https://github.com/kateinoigakukun created https://github.com/llvm/llvm-project/pull/139014 I'm working on porting ASan to Wasm/WASI targets, and this is the first part of the change sets. I'll post runtime changes later. This change makes `-fsanitize=address` available for WASI target by replicating what we do for Emscripten because they share the same memory model. >From d7f0e0bc05a00c2ea5c8a85a641d5f7fa9c410ee Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 29 Apr 2025 02:15:48 + Subject: [PATCH] [clang] Support ASan on WASI This change makes `-fsanitize=address` available for WASI target by replicating what we do for Emscripten because they share the same memory model. --- clang/lib/Driver/ToolChains/WebAssembly.cpp | 7 ++- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 8 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp index cd12f2ae5a6de..9fcc33728c1ad 100644 --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -545,8 +545,13 @@ void WebAssembly::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, SanitizerMask WebAssembly::getSupportedSanitizers() const { SanitizerMask Res = ToolChain::getSupportedSanitizers(); if (getTriple().isOSEmscripten()) { -Res |= SanitizerKind::Vptr | SanitizerKind::Leak | SanitizerKind::Address; +Res |= SanitizerKind::Vptr | SanitizerKind::Leak; } + + if (getTriple().isOSEmscripten() || getTriple().isOSWASI()) { +Res |= SanitizerKind::Address; + } + // -fsanitize=function places two words before the function label, which are // -unsupported. Res &= ~SanitizerKind::Function; diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index c1dba77c3532b..840a5e3f31dfd 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -118,7 +118,7 @@ static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46; static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff9000; static const uint64_t kPS_ShadowOffset64 = 1ULL << 40; static const uint64_t kWindowsShadowOffset32 = 3ULL << 28; -static const uint64_t kEmscriptenShadowOffset = 0; +static const uint64_t kWebAssemblyShadowOffset = 0; // The shadow memory space is dynamically allocated. static const uint64_t kWindowsShadowOffset64 = kDynamicShadowSentinel; @@ -499,9 +499,9 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, bool IsRISCV64 = TargetTriple.getArch() == Triple::riscv64; bool IsWindows = TargetTriple.isOSWindows(); bool IsFuchsia = TargetTriple.isOSFuchsia(); - bool IsEmscripten = TargetTriple.isOSEmscripten(); bool IsAMDGPU = TargetTriple.isAMDGPU(); bool IsHaiku = TargetTriple.isOSHaiku(); + bool IsWasm = TargetTriple.isWasm(); ShadowMapping Mapping; @@ -525,8 +525,8 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, Mapping.Offset = kDynamicShadowSentinel; else if (IsWindows) Mapping.Offset = kWindowsShadowOffset32; -else if (IsEmscripten) - Mapping.Offset = kEmscriptenShadowOffset; +else if (IsWasm) + Mapping.Offset = kWebAssemblyShadowOffset; else Mapping.Offset = kDefaultShadowOffset32; } else { // LongSize == 64 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Support ASan on WASI (PR #139014)
https://github.com/kateinoigakukun edited https://github.com/llvm/llvm-project/pull/139014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Make it a noop when initializing a field of empty record (PR #138594)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` running on `gribozavr4` while building `clang` at step 6 "test-build-unified-tree-check-clang". Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/26748 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-clang) failure: test (failure) TEST 'Clang :: Analysis/ctor.mm' FAILED Exit Code: 134 Command Output (stderr): -- /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 -internal-isystem /b/1/llvm-x86_64-debian-dylib/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -triple i386-apple-darwin10 -DI386 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify -analyzer-config eagerly-assume=false /b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Analysis/ctor.mm # RUN: at line 1 + /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 -internal-isystem /b/1/llvm-x86_64-debian-dylib/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -triple i386-apple-darwin10 -DI386 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify -analyzer-config eagerly-assume=false /b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Analysis/ctor.mm clang: /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl::doit(const From *) [To = clang::CXXRecordDecl, From = const clang::RecordDecl *]: Assertion `Val && "isa<> used on a null pointer"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 -internal-isystem /b/1/llvm-x86_64-debian-dylib/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -triple i386-apple-darwin10 -DI386 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify -analyzer-config eagerly-assume=false /b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Analysis/ctor.mm 1. parser at end of file 2. While analyzing stack: #0 Calling ZeroInitialization::testArrayNew() 3. /b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Analysis/ctor.mm:580:23: Error evaluating statement 4. /b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Analysis/ctor.mm:580:23: Error evaluating statement #0 0x7f2700e515f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/b/1/llvm-x86_64-debian-dylib/build/lib/libLLVM.so.21.0git+0xfd85f7) #1 0x7f2700e4f0ae llvm::sys::RunSignalHandlers() (/b/1/llvm-x86_64-debian-dylib/build/lib/libLLVM.so.21.0git+0xfd60ae) #2 0x7f2700e51cca SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0 #3 0x7f270edc2140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13140) #4 0x7f26ff9b0d61 raise (/lib/x86_64-linux-gnu/libc.so.6+0x38d61) #5 0x7f26ff99a537 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22537) #6 0x7f26ff99a40f (/lib/x86_64-linux-gnu/libc.so.6+0x2240f) #7 0x7f26ff9a96e2 (/lib/x86_64-linux-gnu/libc.so.6+0x316e2) #8 0x7f270d6f159f clang::ento::ExprEngine::handleConstructor(clang::Expr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/b/1/llvm-x86_64-debian-dylib/build/lib/libclang-cpp.so.21.0git+0x32a359f) #9 0x7f270d6cc8ed clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/b/1/llvm-x86_64-debian-dylib/build/lib/libclang-cpp.so.21.0git+0x327e8ed) #10 0x7f270d6c9a76 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) (/b/1/llvm-x86_64-debian-dylib/build/lib/libclang-cpp.so.21.0git+0x327ba76) #11 0x7f270d6c9789 clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) (/b/1/llvm-x86_64-debian-dylib/build/lib/libclang-cpp.so.21.0git+0x327b789) #12 0x7f270d6a69b0 clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) (/b/1/llvm-x86_64-debian-dylib/build/lib/libclang-cpp.so.21.0git+0x32589b0) #13 0x7f270d6a5e32 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) (/b/1/llvm-x86_64-debian-dylib/build/lib/libclang-cpp.so.21.0git+0x3257e32) #14 0x7f270d6a54ad clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr) (/b/1/llvm
[clang] [Clang] Deprecate `__is_trivially_relocatable` (PR #138835)
dyung wrote: > LLVM Buildbot has detected a new failure on builder > `llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while > building `clang` at step 6 "test-build-unified-tree-check-all". > > Full details are available at: > https://lab.llvm.org/buildbot/#/builders/144/builds/24541 > > Here is the relevant piece of the build log for the reference @cor3ntin can you take a look at this failure or revert to get the bot back to green? https://github.com/llvm/llvm-project/pull/138835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c16297c - [CUDA][HIP] Fix host/device attribute of builtin (#138162)
Author: Yaxun (Sam) Liu Date: 2025-05-07T22:03:33-04:00 New Revision: c16297cd3f0ed9d036e9cf16fb6885aa3c72d5d3 URL: https://github.com/llvm/llvm-project/commit/c16297cd3f0ed9d036e9cf16fb6885aa3c72d5d3 DIFF: https://github.com/llvm/llvm-project/commit/c16297cd3f0ed9d036e9cf16fb6885aa3c72d5d3.diff LOG: [CUDA][HIP] Fix host/device attribute of builtin (#138162) When a builtin function is passed a pointer with a different address space, clang creates an overloaded builtin function but does not copy the host/device attribute. This causes error when the builtin is called by device functions since CUDA/HIP relies on the host/device attribute to treat a builtin function as callable on both host and device sides. Fixed by copying the host/device attribute of the original builtin function to the created overloaded builtin function. Added: clang/test/SemaCUDA/overloaded-builtin.cu Modified: clang/lib/Sema/SemaExpr.cpp Removed: diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index c3ef5a70d5f6d..57135adf714ce 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6362,6 +6362,14 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, Params.push_back(Parm); } OverloadDecl->setParams(Params); + // We cannot merge host/device attributes of redeclarations. They have to + // be consistent when created. + if (Sema->LangOpts.CUDA) { +if (FDecl->hasAttr()) + OverloadDecl->addAttr(CUDAHostAttr::CreateImplicit(Context)); +if (FDecl->hasAttr()) + OverloadDecl->addAttr(CUDADeviceAttr::CreateImplicit(Context)); + } Sema->mergeDeclAttributes(OverloadDecl, FDecl); return OverloadDecl; } diff --git a/clang/test/SemaCUDA/overloaded-builtin.cu b/clang/test/SemaCUDA/overloaded-builtin.cu new file mode 100644 index 0..c60c27e7f8627 --- /dev/null +++ b/clang/test/SemaCUDA/overloaded-builtin.cu @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple amdgcn-amd-amdhsa -fsyntax-only -verify=host -xhip %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fsyntax-only -fcuda-is-device -verify=dev -xhip %s + +// dev-no-diagnostics + +#include "Inputs/cuda.h" + +__global__ void kernel() { + __attribute__((address_space(0))) void *mem_ptr; + (void)__builtin_amdgcn_is_shared(mem_ptr); +} + +template +__global__ void template_kernel(T *p) { + __attribute__((address_space(0))) void *mem_ptr; + (void)__builtin_amdgcn_is_shared(mem_ptr); +} + +void hfun() { + __attribute__((address_space(0))) void *mem_ptr; + (void)__builtin_amdgcn_is_shared(mem_ptr); // host-error {{reference to __device__ function '__builtin_amdgcn_is_shared' in __host__ function}} +} + +template +void template_hfun(T *p) { + __attribute__((address_space(0))) void *mem_ptr; + (void)__builtin_amdgcn_is_shared(mem_ptr); // host-error {{reference to __device__ function '__builtin_amdgcn_is_shared' in __host__ function}} +} + + +int main() { + int *p; + kernel<<<1,1>>>(); + template_kernel<<<1,1>>>(p); + template_hfun(p); // host-note {{called by 'main'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA][HIP] Fix host/device attribute of builtin (PR #138162)
https://github.com/yxsamliu closed https://github.com/llvm/llvm-project/pull/138162 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add Andes XAndesVPackFPH (Andes Vector Packed FP16) extension. (PR #138827)
https://github.com/tclin914 updated https://github.com/llvm/llvm-project/pull/138827 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [TargetVerifier][AMDGPU] Add TargetVerifier. (PR #123609)
https://github.com/jofrn updated https://github.com/llvm/llvm-project/pull/123609 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add flag to specify an alternative to std::move in cppcoreguidelines-rvalue-reference-param-not-moved (PR #138757)
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/138757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Add flag to specify an alternative to std::forward (PR #138755)
https://github.com/HerrCai0907 approved this pull request. LGTM. It looks similar as https://github.com/llvm/llvm-project/pull/138757. could you add a test for both PR. https://github.com/llvm/llvm-project/pull/138755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang: Fix broken implicit cast to generic address space (PR #138863)
https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/138863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/OpenCL: Add baseline test showing broken codegen (PR #138862)
https://github.com/arsenm closed https://github.com/llvm/llvm-project/pull/138862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang: Fix broken implicit cast to generic address space (PR #138863)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/138863 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang: Fix broken implicit cast to generic address space (PR #138863)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/138863 >From 8593c30aaa9ec9841ffd7172ef8c32e72f9bad4b Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 7 May 2025 08:34:40 +0200 Subject: [PATCH] clang: Fix broken implicit cast to generic address space This fixes emitting undefined behavior where a 64-bit generic pointer is written to a 32-bit slot allocated for a private pointer. This can be seen in test/CodeGenOpenCL/amdgcn-automatic-variable.cl's wrong_pointer_alloca. --- clang/lib/CodeGen/CGDecl.cpp | 3 +- clang/lib/CodeGen/CGExpr.cpp | 17 ++-- clang/lib/CodeGen/CodeGenFunction.h | 20 - .../CodeGenOpenCL/addr-space-struct-arg.cl| 5 +- .../amdgcn-automatic-variable.cl | 45 -- .../amdgpu-abi-struct-arg-byref.cl| 5 +- .../CodeGenOpenCL/amdgpu-enqueue-kernel.cl| 90 --- clang/test/CodeGenOpenCL/amdgpu-nullptr.cl| 28 +++--- clang/test/CodeGenOpenCL/blocks.cl| 6 +- clang/test/CodeGenOpenCL/builtins-alloca.cl | 48 -- .../CodeGenOpenCL/builtins-amdgcn-gfx12.cl| 10 +-- ...plicit-addrspacecast-function-parameter.cl | 7 +- clang/test/Index/pipe-size.cl | 2 +- 13 files changed, 129 insertions(+), 157 deletions(-) diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index db34e2738b4cf..1e54e55c5abbb 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1588,7 +1588,8 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { // Create the alloca. Note that we set the name separately from // building the instruction so that it's there even in no-asserts // builds. - address = CreateTempAlloca(allocaTy, allocaAlignment, D.getName(), + address = CreateTempAlloca(allocaTy, Ty.getAddressSpace(), + allocaAlignment, D.getName(), /*ArraySize=*/nullptr, &AllocaAddr); // Don't emit lifetime markers for MSVC catch parameters. The lifetime of diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 6f5ead78f2b23..1a835c97decef 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -100,13 +100,11 @@ CodeGenFunction::CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits Align, return RawAddress(Alloca, Ty, Align, KnownNonNull); } -/// CreateTempAlloca - This creates a alloca and inserts it into the entry -/// block. The alloca is casted to default address space if necessary. -RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align, - const Twine &Name, +RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, LangAS DestLangAS, + CharUnits Align, const Twine &Name, llvm::Value *ArraySize, RawAddress *AllocaAddr) { - auto Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize); + RawAddress Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize); if (AllocaAddr) *AllocaAddr = Alloca; llvm::Value *V = Alloca.getPointer(); @@ -114,8 +112,9 @@ RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align, // be different from the type defined by the language. For example, // in C++ the auto variables are in the default address space. Therefore // cast alloca to the default address space when necessary. - if (getASTAllocaAddressSpace() != LangAS::Default) { -auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default); + + unsigned DestAddrSpace = getContext().getTargetAddressSpace(DestLangAS); + if (DestAddrSpace != Alloca.getAddressSpace()) { llvm::IRBuilderBase::InsertPointGuard IPG(Builder); // When ArraySize is nullptr, alloca is inserted at AllocaInsertPt, // otherwise alloca is inserted at the current insertion point of the @@ -123,8 +122,8 @@ RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align, if (!ArraySize) Builder.SetInsertPoint(getPostAllocaInsertPoint()); V = getTargetHooks().performAddrSpaceCast( -*this, V, getASTAllocaAddressSpace(), LangAS::Default, -Builder.getPtrTy(DestAddrSpace), /*non-null*/ true); +*this, V, getASTAllocaAddressSpace(), DestLangAS, +Builder.getPtrTy(DestAddrSpace), /*IsNonNull=*/true); } return RawAddress(V, Ty, Align, KnownNonNull); diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 561f8f6a2a2fb..c0bc3825f0188 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2861,10 +2861,28 @@ class CodeGenFunction : public CodeGenTypeCache { /// more efficient if the caller knows that the address will not be exposed. llvm::AllocaInst
[clang] clang/OpenCL: Add baseline test showing broken codegen (PR #138862)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/138862 >From decbf5b3a2cbb4f8844b9556fbfafec73c117687 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 7 May 2025 08:38:49 +0200 Subject: [PATCH 1/2] clang/OpenCL: Add baseline test showing broken codegen --- .../CodeGenCXX/amdgcn-automatic-variable.cpp | 24 ++ .../amdgcn-automatic-variable.cl | 45 +++ 2 files changed, 69 insertions(+) diff --git a/clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp b/clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp index c1f9310141000..0f425d78c3332 100644 --- a/clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp +++ b/clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp @@ -133,3 +133,27 @@ void func7() { use(&x); } +#define __private __attribute__((opencl_private)) + +// CHECK-LABEL: @_Z34explicit_private_address_space_ptrv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[PLONG:%.*]] = alloca i64, align 8, addrspace(5) +// CHECK-NEXT:[[PLONGP:%.*]] = alloca ptr, align 8, addrspace(5) +// CHECK-NEXT:[[PLONGP_B:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CHECK-NEXT:[[PLONG_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONG]] to ptr +// CHECK-NEXT:[[PLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONGP]] to ptr +// CHECK-NEXT:[[PLONGP_B_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONGP_B]] to ptr +// CHECK-NEXT:store ptr [[PLONG_ASCAST]], ptr [[PLONGP_ASCAST]], align 8 +// CHECK-NEXT:[[PLONG_ASCAST_ASCAST:%.*]] = addrspacecast ptr [[PLONG_ASCAST]] to ptr addrspace(5) +// CHECK-NEXT:store ptr addrspace(5) [[PLONG_ASCAST_ASCAST]], ptr [[PLONGP_B_ASCAST]], align 4 +// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[PLONGP_ASCAST]], align 8 +// CHECK-NEXT:store i64 8, ptr [[TMP0]], align 8 +// CHECK-NEXT:ret void +// +void explicit_private_address_space_ptr() { + long plong; + long *plongp = &plong; + + __private long *plongp_b = (__private long *)&plong; + *plongp = 8; +} diff --git a/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl b/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl index dba6519966eb5..b252f1041d68c 100644 --- a/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl +++ b/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl @@ -109,3 +109,48 @@ void func2(void) { void func3(void) { float a[16][1] = {{0.}}; } + +// CL12-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca( +// CL12-SAME: ) #[[ATTR0]] { +// CL12-NEXT: [[ENTRY:.*:]] +// CL12-NEXT:[[PLONG:%.*]] = alloca i64, align 8, addrspace(5) +// CL12-NEXT:[[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL12-NEXT:[[GLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL12-NEXT:store i64 5, ptr addrspace(5) [[PLONG]], align 8 +// CL12-NEXT:store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[PLONGP]], align 4 +// CL12-NEXT:[[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[PLONGP]], align 4 +// CL12-NEXT:store i64 8, ptr addrspace(5) [[TMP0]], align 8 +// CL12-NEXT:store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[GLONGP]], align 4 +// CL12-NEXT:[[TMP1:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[GLONGP]], align 4 +// CL12-NEXT:store i64 9, ptr addrspace(5) [[TMP1]], align 8 +// CL12-NEXT:ret void +// +// CL20-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca( +// CL20-SAME: ) #[[ATTR0]] { +// CL20-NEXT: [[ENTRY:.*:]] +// CL20-NEXT:[[PLONG:%.*]] = alloca i64, align 8, addrspace(5) +// CL20-NEXT:[[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5) +// CL20-NEXT:[[GLONGP:%.*]] = alloca ptr, align 8, addrspace(5) +// CL20-NEXT:[[PLONG_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONG]] to ptr +// CL20-NEXT:[[PLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONGP]] to ptr +// CL20-NEXT:[[GLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[GLONGP]] to ptr +// CL20-NEXT:store i64 5, ptr [[PLONG_ASCAST]], align 8 +// CL20-NEXT:store ptr [[PLONG_ASCAST]], ptr [[PLONGP_ASCAST]], align 4 +// CL20-NEXT:[[TMP0:%.*]] = load ptr addrspace(5), ptr [[PLONGP_ASCAST]], align 4 +// CL20-NEXT:store i64 8, ptr addrspace(5) [[TMP0]], align 8 +// CL20-NEXT:store ptr [[PLONG_ASCAST]], ptr [[GLONGP_ASCAST]], align 8 +// CL20-NEXT:[[TMP1:%.*]] = load ptr, ptr [[GLONGP_ASCAST]], align 8 +// CL20-NEXT:store i64 9, ptr [[TMP1]], align 8 +// CL20-NEXT:ret void +// +void wrong_store_type_private_pointer_alloca() { + long plong = 5; + + // This needs to write an addrspace(5) pointer to the temporary alloca + __private long *plongp = &plong; + *plongp = 8; + + // This needs to write an addrspace(0) pointer to the temporary alloca in CL2.0 + long *glongp = &plong; + *glongp = 9; +} >From e82e94d968394900b2e0f30294b619ac79cd4162 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 7 M
[clang] 5df01ab - [clang-format] Add SpaceAfterOperatorKeyword option (#137610)
Author: Filip Milosevic Date: 2025-05-07T22:47:56-07:00 New Revision: 5df01abe191ff4f848566e239798a2b4d26e1cf4 URL: https://github.com/llvm/llvm-project/commit/5df01abe191ff4f848566e239798a2b4d26e1cf4 DIFF: https://github.com/llvm/llvm-project/commit/5df01abe191ff4f848566e239798a2b4d26e1cf4.diff LOG: [clang-format] Add SpaceAfterOperatorKeyword option (#137610) Add SpaceAfterOperatorKeyword option to clang-format Added: Modified: clang/docs/ClangFormatStyleOptions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Format/Format.h clang/lib/Format/Format.cpp clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp Removed: diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index b47291599649d..a4c381bf583b6 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -6127,6 +6127,16 @@ the configuration (without a prefix: ``Auto``). true: false: ! someExpression();vs. !someExpression(); +.. _SpaceAfterOperatorKeyword: + +**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ ` + If ``true``, a space will be inserted after the ``operator`` keyword. + + .. code-block:: c++ + + true:false: + bool operator ==(int a); vs. bool operator==(int a); + .. _SpaceAfterTemplateKeyword: **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` :ref:`¶ ` diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e5b463173dcf4..c52e285bde627 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -810,6 +810,7 @@ clang-format - Add ``EnumTrailingComma`` option for inserting/removing commas at the end of ``enum`` enumerator lists. - Add ``OneLineFormatOffRegex`` option for turning formatting off for one line. +- Add ``SpaceAfterOperatorKeyword`` option. libclang diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 7fe41d800ccb3..b86c4bd00eb91 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -4484,6 +4484,14 @@ struct FormatStyle { /// \version 9 bool SpaceAfterLogicalNot; + /// If ``true``, a space will be inserted after the ``operator`` keyword. + /// \code + ///true:false: + ///bool operator ==(int a); vs. bool operator==(int a); + /// \endcode + /// \version 21 + bool SpaceAfterOperatorKeyword; + /// If \c true, a space will be inserted after the ``template`` keyword. /// \code ///true: false: @@ -5454,6 +5462,7 @@ struct FormatStyle { SortJavaStaticImport == R.SortJavaStaticImport && SpaceAfterCStyleCast == R.SpaceAfterCStyleCast && SpaceAfterLogicalNot == R.SpaceAfterLogicalNot && + SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword && SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword && SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators && SpaceBeforeCaseColon == R.SpaceBeforeCaseColon && diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 2f4b64ef4f5fe..20b5352b83a9e 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1152,6 +1152,8 @@ template <> struct MappingTraits { IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations); IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast); IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot); +IO.mapOptional("SpaceAfterOperatorKeyword", + Style.SpaceAfterOperatorKeyword); IO.mapOptional("SpaceAfterTemplateKeyword", Style.SpaceAfterTemplateKeyword); IO.mapOptional("SpaceAroundPointerQualifiers", @@ -1639,6 +1641,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric; LLVMStyle.SpaceAfterCStyleCast = false; LLVMStyle.SpaceAfterLogicalNot = false; + LLVMStyle.SpaceAfterOperatorKeyword = false; LLVMStyle.SpaceAfterTemplateKeyword = true; LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default; LLVMStyle.SpaceBeforeAssignmentOperators = true; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index f0f9207564ab1..542c362ccacae 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -5033,7 +5033,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, } if (Left.is(tok::kw_operator)) - return Right.is(tok
[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/137610 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a11d864 - clang: Fix broken implicit cast to generic address space (#138863)
Author: Matt Arsenault Date: 2025-05-08T07:51:57+02:00 New Revision: a11d86461e7d7d9bce3d04a39ded1cad394239ca URL: https://github.com/llvm/llvm-project/commit/a11d86461e7d7d9bce3d04a39ded1cad394239ca DIFF: https://github.com/llvm/llvm-project/commit/a11d86461e7d7d9bce3d04a39ded1cad394239ca.diff LOG: clang: Fix broken implicit cast to generic address space (#138863) This fixes emitting undefined behavior where a 64-bit generic pointer is written to a 32-bit slot allocated for a private pointer. This can be seen in test/CodeGenOpenCL/amdgcn-automatic-variable.cl's wrong_pointer_alloca. Added: Modified: clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CodeGenFunction.h clang/test/CodeGenOpenCL/addr-space-struct-arg.cl clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl clang/test/CodeGenOpenCL/amdgpu-abi-struct-arg-byref.cl clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl clang/test/CodeGenOpenCL/amdgpu-nullptr.cl clang/test/CodeGenOpenCL/blocks.cl clang/test/CodeGenOpenCL/builtins-alloca.cl clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl clang/test/CodeGenOpenCL/implicit-addrspacecast-function-parameter.cl clang/test/Index/pipe-size.cl Removed: diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index db34e2738b4cf..1e54e55c5abbb 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1588,7 +1588,8 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { // Create the alloca. Note that we set the name separately from // building the instruction so that it's there even in no-asserts // builds. - address = CreateTempAlloca(allocaTy, allocaAlignment, D.getName(), + address = CreateTempAlloca(allocaTy, Ty.getAddressSpace(), + allocaAlignment, D.getName(), /*ArraySize=*/nullptr, &AllocaAddr); // Don't emit lifetime markers for MSVC catch parameters. The lifetime of diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 6f5ead78f2b23..1a835c97decef 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -100,13 +100,11 @@ CodeGenFunction::CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits Align, return RawAddress(Alloca, Ty, Align, KnownNonNull); } -/// CreateTempAlloca - This creates a alloca and inserts it into the entry -/// block. The alloca is casted to default address space if necessary. -RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align, - const Twine &Name, +RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, LangAS DestLangAS, + CharUnits Align, const Twine &Name, llvm::Value *ArraySize, RawAddress *AllocaAddr) { - auto Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize); + RawAddress Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize); if (AllocaAddr) *AllocaAddr = Alloca; llvm::Value *V = Alloca.getPointer(); @@ -114,8 +112,9 @@ RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align, // be diff erent from the type defined by the language. For example, // in C++ the auto variables are in the default address space. Therefore // cast alloca to the default address space when necessary. - if (getASTAllocaAddressSpace() != LangAS::Default) { -auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default); + + unsigned DestAddrSpace = getContext().getTargetAddressSpace(DestLangAS); + if (DestAddrSpace != Alloca.getAddressSpace()) { llvm::IRBuilderBase::InsertPointGuard IPG(Builder); // When ArraySize is nullptr, alloca is inserted at AllocaInsertPt, // otherwise alloca is inserted at the current insertion point of the @@ -123,8 +122,8 @@ RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align, if (!ArraySize) Builder.SetInsertPoint(getPostAllocaInsertPoint()); V = getTargetHooks().performAddrSpaceCast( -*this, V, getASTAllocaAddressSpace(), LangAS::Default, -Builder.getPtrTy(DestAddrSpace), /*non-null*/ true); +*this, V, getASTAllocaAddressSpace(), DestLangAS, +Builder.getPtrTy(DestAddrSpace), /*IsNonNull=*/true); } return RawAddress(V, Ty, Align, KnownNonNull); diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 561f8f6a2a2fb..c0bc3825f0188 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2861,10 +2861,28 @@ class CodeGenFunction : public CodeGenTypeCache { /// more efficient if the caller knows that the address will not be expo
[clang] clang: Fix broken implicit cast to generic address space (PR #138863)
https://github.com/arsenm closed https://github.com/llvm/llvm-project/pull/138863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/OpenCL: Fix special casing OpenCL in call emission (PR #138864)
https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/138864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/OpenCL: Fix special casing OpenCL in call emission (PR #138864)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/138864 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)
github-actions[bot] wrote: @MightyFilipns Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/137610 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Deprecate `__is_trivially_relocatable` (PR #138835)
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/138835 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Define pointer layout for AVR program address space (PR #134254)
jwnrt wrote: Sorry for the long delay. I think you're right that there's no difference to the RTL. I need to test this properly and learn more about address spaces. In particular, I think address space zero has some special casing around it being the generic / fallback address space that interacts here. I hope I didn't waste any of your time here. https://github.com/llvm/llvm-project/pull/134254 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Define pointer layout for AVR program address space (PR #134254)
https://github.com/jwnrt converted_to_draft https://github.com/llvm/llvm-project/pull/134254 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Deprecate `__is_trivially_relocatable` (PR #138835)
@@ -89,15 +96,18 @@ static_assert(!__is_trivially_constructible(S4, const S4&)); static_assert(!__is_trivially_assignable(S4, const S4&)); static_assert(__is_trivially_destructible(S4)); static_assert(!__is_trivially_copyable(S4)); -static_assert(!__is_trivially_relocatable(S4)); +static_assert(!__is_trivially_relocatable(S4)); // expected-warning{{deprecated}} +//FIXME +static_assert(__builtin_is_cpp_trivially_relocatable(S4)); cor3ntin wrote: @ojhunt I think fixing that depends on https://github.com/llvm/llvm-project/pull/138482 https://github.com/llvm/llvm-project/pull/138835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Ast importer visitors (PR #138838)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (ganenkokb-yandex) Changes I've rebased commit from [Evianaive](https://github.com/Evianaive/llvm-project/commits?author=Evianaive) and compiled it. I hope it will speed up fix for #129393. --- Full diff: https://github.com/llvm/llvm-project/pull/138838.diff 1 Files Affected: - (modified) clang/lib/AST/ASTImporter.cpp (+266-1) ``diff diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index b481ad5df667e..cff0050208784 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -564,6 +564,9 @@ namespace clang { ExpectedDecl VisitVarTemplateDecl(VarTemplateDecl *D); ExpectedDecl VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D); ExpectedDecl VisitFunctionTemplateDecl(FunctionTemplateDecl *D); +ExpectedDecl VisitConceptDecl(ConceptDecl* D); +ExpectedDecl VisitRequiresExprBodyDecl(RequiresExprBodyDecl* E); +ExpectedDecl VisitImplicitConceptSpecializationDecl(ImplicitConceptSpecializationDecl* D); // Importing statements ExpectedStmt VisitStmt(Stmt *S); @@ -680,6 +683,8 @@ namespace clang { ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E); ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E); ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E); +ExpectedStmt VisitRequiresExpr(RequiresExpr* E); +ExpectedStmt VisitConceptSpecializationExpr(ConceptSpecializationExpr* E); // Helper for chaining together multiple imports. If an error is detected, // subsequent imports will return default constructed nodes, so that failure @@ -735,6 +740,40 @@ namespace clang { // that type is declared inside the body of the function. // E.g. auto f() { struct X{}; return X(); } bool hasReturnTypeDeclaredInside(FunctionDecl *D); + +Expected FillConstraintSatisfaction(const ASTConstraintSatisfaction& from) { + auto ImportStringRef = [this](const StringRef& FromString) { +char* ToDiagMessage = new (Importer.getToContext()) char[FromString.size()]; +std::copy(FromString.begin(),FromString.end(),ToDiagMessage); +return StringRef(ToDiagMessage,FromString.size()); + }; + ConstraintSatisfaction Satisfaction; + Satisfaction.IsSatisfied = from.IsSatisfied; + Satisfaction.ContainsErrors = from.ContainsErrors; + if (!Satisfaction.IsSatisfied) { +using SubstitutionDiagnostic = std::pair; +for (auto &Record : from) { + if (auto *SubstDiag = Record.dyn_cast()) { +Error Err = Error::success(); + +auto ToPairFirst = import(SubstDiag->first); +if(!ToPairFirst) + return ToPairFirst.takeError(); +StringRef ToPairSecond = ImportStringRef(SubstDiag->second); +Satisfaction.Details.emplace_back(new (Importer.getToContext()) + ConstraintSatisfaction::SubstitutionDiagnostic{ +ToPairFirst.get(), ToPairSecond}); + } else { +const Expr *ConstraintExpr = Record.dyn_cast(); +Expected ToConstraintExpr = import(ConstraintExpr); +if(!ToConstraintExpr) + return ToConstraintExpr.takeError(); +Satisfaction.Details.emplace_back(ToConstraintExpr.get()); + } +} + } + return Satisfaction; +} }; template @@ -1063,6 +1102,142 @@ Expected ASTNodeImporter::import(const LambdaCapture &From) { EllipsisLoc); } +template<> +Expected ASTNodeImporter::import(concepts::Requirement* FromRequire) { + auto ImportStringRef = [this](const StringRef& FromString) { + char* ToDiagMessage = new (Importer.getToContext()) char[FromString.size()]; + std::copy(FromString.begin(),FromString.end(),ToDiagMessage); + return StringRef(ToDiagMessage,FromString.size()); +}; + + auto ImportSubstitutionDiagnos = [this, &ImportStringRef] + (concepts::Requirement::SubstitutionDiagnostic* FromDiagnos, Error& Err)->concepts::Requirement::SubstitutionDiagnostic* { +const auto& ToEntity = ImportStringRef(FromDiagnos->SubstitutedEntity); +Expected ToLoc = import(FromDiagnos->DiagLoc); +if(!ToLoc) { + Err = ToLoc.takeError(); + return nullptr; +} +const auto& ToDiagMessage = ImportStringRef(FromDiagnos->DiagMessage); +return new (Importer.getToContext()) concepts::Requirement::SubstitutionDiagnostic{ + ToEntity, + ToLoc.get(), + ToDiagMessage}; + }; + switch (FromRequire->getKind()) { + case concepts::Requirement::RequirementKind::RK_Type: { +auto *From = cast(FromRequire); +if(From->isSubstitutionFailure()) +{ + // Should we return Error directly if TypeRequirement isSubstitutionFailure? + Error Err = Error::success(); + auto Diagnos = ImportSubstitutionDiagnos(From->getSubstitutionDiagnostic(),Err); + if (Err) +return std::move(Err); + ret
[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)
https://github.com/charan-003 updated https://github.com/llvm/llvm-project/pull/117953 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Propose new ClangIR Maintainers (PR #138870)
https://github.com/AaronBallman approved this pull request. Thank you for proposing this! I think both @andykaylor and @bcardosolopes would be excellent maintainers, so I approve so long as they're willing. https://github.com/llvm/llvm-project/pull/138870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] LLVMIR lowering for cir.call (PR #138873)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Sirui Mu (Lancern) Changes This PR adds LLVMIR lowering support for the `cir.call` operation. --- Full diff: https://github.com/llvm/llvm-project/pull/138873.diff 4 Files Affected: - (modified) clang/include/clang/CIR/MissingFeatures.h (+2) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+45) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+9) - (modified) clang/test/CIR/CodeGen/call.cpp (+24-12) ``diff diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index eb75a073d1817..d49098768ad09 100644 --- a/clang/include/clang/CIR/MissingFeatures.h +++ b/clang/include/clang/CIR/MissingFeatures.h @@ -104,6 +104,8 @@ struct MissingFeatures { static bool opCallExtParameterInfo() { return false; } static bool opCallCIRGenFuncInfoParamInfo() { return false; } static bool opCallCIRGenFuncInfoExtParamInfo() { return false; } + static bool opCallLandingPad() { return false; } + static bool opCallContinueBlock() { return false; } // ScopeOp handling static bool opScopeCleanupRegion() { return false; } diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 6137adb1e9936..8ba079a55f1c5 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -651,6 +651,50 @@ mlir::LogicalResult CIRToLLVMReturnOpLowering::matchAndRewrite( return mlir::LogicalResult::success(); } +static mlir::LogicalResult +rewriteCallOrInvoke(mlir::Operation *op, mlir::ValueRange callOperands, +mlir::ConversionPatternRewriter &rewriter, +const mlir::TypeConverter *converter, +mlir::FlatSymbolRefAttr calleeAttr) { + llvm::SmallVector llvmResults; + auto cirResults = op->getResultTypes(); + + if (converter->convertTypes(cirResults, llvmResults).failed()) +return mlir::failure(); + + assert(!cir::MissingFeatures::opCallCallConv()); + assert(!cir::MissingFeatures::opCallSideEffect()); + + mlir::LLVM::LLVMFunctionType llvmFnTy; + if (calleeAttr) { // direct call +auto fn = +mlir::SymbolTable::lookupNearestSymbolFrom( +op, calleeAttr); +assert(fn && "Did not find function for call"); +llvmFnTy = cast( +converter->convertType(fn.getFunctionType())); + } else { // indirect call +assert(!cir::MissingFeatures::opCallIndirect()); +return op->emitError("Indirect calls are NYI"); + } + + assert(!cir::MissingFeatures::opCallLandingPad()); + assert(!cir::MissingFeatures::opCallContinueBlock()); + assert(!cir::MissingFeatures::opCallCallConv()); + assert(!cir::MissingFeatures::opCallSideEffect()); + + rewriter.replaceOpWithNewOp(op, llvmFnTy, calleeAttr, + callOperands); + return mlir::success(); +} + +mlir::LogicalResult CIRToLLVMCallOpLowering::matchAndRewrite( +cir::CallOp op, OpAdaptor adaptor, +mlir::ConversionPatternRewriter &rewriter) const { + return rewriteCallOrInvoke(op.getOperation(), adaptor.getOperands(), rewriter, + getTypeConverter(), op.getCalleeAttr()); +} + mlir::LogicalResult CIRToLLVMLoadOpLowering::matchAndRewrite( cir::LoadOp op, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const { @@ -1589,6 +1633,7 @@ void ConvertCIRToLLVMPass::runOnOperation() { CIRToLLVMBinOpLowering, CIRToLLVMBrCondOpLowering, CIRToLLVMBrOpLowering, + CIRToLLVMCallOpLowering, CIRToLLVMCmpOpLowering, CIRToLLVMConstantOpLowering, CIRToLLVMFuncOpLowering, diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h index f248ea31e7844..0da4f9ba2c791 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h @@ -64,6 +64,15 @@ class CIRToLLVMReturnOpLowering mlir::ConversionPatternRewriter &) const override; }; +class CIRToLLVMCallOpLowering : public mlir::OpConversionPattern { +public: + using mlir::OpConversionPattern::OpConversionPattern; + + mlir::LogicalResult + matchAndRewrite(cir::CallOp op, OpAdaptor adaptor, + mlir::ConversionPatternRewriter &rewriter) const override; +}; + class CIRToLLVMAllocaOpLowering : public mlir::OpConversionPattern { mlir::DataLayout const &dataLayout; diff --git a/clang/test/CIR/CodeGen/call.cpp b/clang/test/CIR/CodeGen/call.cpp index f6dc5e15933ed..3b1ab8b5fc498 100644 --- a/clang/test/CIR/CodeGen/call.cpp +++ b/clang/test/CIR/CodeGen/call.cpp @@ -1,13 +1,19 @@ -// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - 2>&1 | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linu
[clang] [CIR] LLVMIR lowering for cir.call (PR #138873)
llvmbot wrote: @llvm/pr-subscribers-clangir Author: Sirui Mu (Lancern) Changes This PR adds LLVMIR lowering support for the `cir.call` operation. --- Full diff: https://github.com/llvm/llvm-project/pull/138873.diff 4 Files Affected: - (modified) clang/include/clang/CIR/MissingFeatures.h (+2) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+45) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+9) - (modified) clang/test/CIR/CodeGen/call.cpp (+24-12) ``diff diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index eb75a073d1817..d49098768ad09 100644 --- a/clang/include/clang/CIR/MissingFeatures.h +++ b/clang/include/clang/CIR/MissingFeatures.h @@ -104,6 +104,8 @@ struct MissingFeatures { static bool opCallExtParameterInfo() { return false; } static bool opCallCIRGenFuncInfoParamInfo() { return false; } static bool opCallCIRGenFuncInfoExtParamInfo() { return false; } + static bool opCallLandingPad() { return false; } + static bool opCallContinueBlock() { return false; } // ScopeOp handling static bool opScopeCleanupRegion() { return false; } diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 6137adb1e9936..8ba079a55f1c5 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -651,6 +651,50 @@ mlir::LogicalResult CIRToLLVMReturnOpLowering::matchAndRewrite( return mlir::LogicalResult::success(); } +static mlir::LogicalResult +rewriteCallOrInvoke(mlir::Operation *op, mlir::ValueRange callOperands, +mlir::ConversionPatternRewriter &rewriter, +const mlir::TypeConverter *converter, +mlir::FlatSymbolRefAttr calleeAttr) { + llvm::SmallVector llvmResults; + auto cirResults = op->getResultTypes(); + + if (converter->convertTypes(cirResults, llvmResults).failed()) +return mlir::failure(); + + assert(!cir::MissingFeatures::opCallCallConv()); + assert(!cir::MissingFeatures::opCallSideEffect()); + + mlir::LLVM::LLVMFunctionType llvmFnTy; + if (calleeAttr) { // direct call +auto fn = +mlir::SymbolTable::lookupNearestSymbolFrom( +op, calleeAttr); +assert(fn && "Did not find function for call"); +llvmFnTy = cast( +converter->convertType(fn.getFunctionType())); + } else { // indirect call +assert(!cir::MissingFeatures::opCallIndirect()); +return op->emitError("Indirect calls are NYI"); + } + + assert(!cir::MissingFeatures::opCallLandingPad()); + assert(!cir::MissingFeatures::opCallContinueBlock()); + assert(!cir::MissingFeatures::opCallCallConv()); + assert(!cir::MissingFeatures::opCallSideEffect()); + + rewriter.replaceOpWithNewOp(op, llvmFnTy, calleeAttr, + callOperands); + return mlir::success(); +} + +mlir::LogicalResult CIRToLLVMCallOpLowering::matchAndRewrite( +cir::CallOp op, OpAdaptor adaptor, +mlir::ConversionPatternRewriter &rewriter) const { + return rewriteCallOrInvoke(op.getOperation(), adaptor.getOperands(), rewriter, + getTypeConverter(), op.getCalleeAttr()); +} + mlir::LogicalResult CIRToLLVMLoadOpLowering::matchAndRewrite( cir::LoadOp op, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const { @@ -1589,6 +1633,7 @@ void ConvertCIRToLLVMPass::runOnOperation() { CIRToLLVMBinOpLowering, CIRToLLVMBrCondOpLowering, CIRToLLVMBrOpLowering, + CIRToLLVMCallOpLowering, CIRToLLVMCmpOpLowering, CIRToLLVMConstantOpLowering, CIRToLLVMFuncOpLowering, diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h index f248ea31e7844..0da4f9ba2c791 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h @@ -64,6 +64,15 @@ class CIRToLLVMReturnOpLowering mlir::ConversionPatternRewriter &) const override; }; +class CIRToLLVMCallOpLowering : public mlir::OpConversionPattern { +public: + using mlir::OpConversionPattern::OpConversionPattern; + + mlir::LogicalResult + matchAndRewrite(cir::CallOp op, OpAdaptor adaptor, + mlir::ConversionPatternRewriter &rewriter) const override; +}; + class CIRToLLVMAllocaOpLowering : public mlir::OpConversionPattern { mlir::DataLayout const &dataLayout; diff --git a/clang/test/CIR/CodeGen/call.cpp b/clang/test/CIR/CodeGen/call.cpp index f6dc5e15933ed..3b1ab8b5fc498 100644 --- a/clang/test/CIR/CodeGen/call.cpp +++ b/clang/test/CIR/CodeGen/call.cpp @@ -1,13 +1,19 @@ -// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - 2>&1 | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-li
[clang] [clang][ExprConstant] Bail out on invalid lambda capture inits (PR #138832)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/138832 Fixes https://github.com/llvm/llvm-project/issues/138824 >From 8534038ad80d5de9218f8f9663bef16cbcabd19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 7 May 2025 11:03:28 +0200 Subject: [PATCH] [clang][ExprConstant] Bail out on invalid lambda capture inits Fixes https://github.com/llvm/llvm-project/issues/138824 --- clang/lib/AST/ByteCode/Compiler.cpp | 4 clang/lib/AST/ExprConstant.cpp | 2 +- clang/test/SemaCXX/constant-expression-cxx11.cpp | 9 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index ae6574cf99159..32ec917effdc7 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2932,6 +2932,10 @@ bool Compiler::VisitLambdaExpr(const LambdaExpr *E) { // record with their initializers. for (const Record::Field &F : R->fields()) { const Expr *Init = *CaptureInitIt; + +if (Init->containsErrors()) + return false; + ++CaptureInitIt; if (!Init) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index e5950f461e4b2..500d43accb082 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -11038,7 +11038,7 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) { // If there is no initializer, either this is a VLA or an error has // occurred. -if (!CurFieldInit) +if (!CurFieldInit || CurFieldInit->containsErrors()) return Error(E); LValue Subobject = This; diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index dc8f4bf1666ee..0a135654fab18 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -2598,3 +2598,12 @@ void foo() { constexpr S s[2] = { }; // expected-error {{constexpr variable 's' must be initialized by a constant expression}} } } + +namespace DoubleCapture { + int DC() { + int a = 1000; +static auto f = + [a, &a] { // expected-error {{'a' can appear only once in a capture list}} +}; + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)
https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/138174 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)
jurahul wrote: Thanks @jpienaar. Given I have 2 approvals, will commit it today. https://github.com/llvm/llvm-project/pull/138174 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
https://github.com/DKLoehr updated https://github.com/llvm/llvm-project/pull/138741 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExprConst] Check for array size of initlists (PR #138673)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/138673 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Propose new ClangIR Maintainers (PR #138870)
https://github.com/cor3ntin approved this pull request. Both Bruno and Andy have been involved with CIR for a while, it makes perfect sense! https://github.com/llvm/llvm-project/pull/138870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [llvm] Add unnecessary-virtual-specifier to -Wextra (PR #138741)
DKLoehr wrote: Looks like all the libc++ checks passed, so we should be good. > Alternatively, we could ‘fix’ our codebase instead by introducing an > LLVM_VIRTUAL_ANCHOR macro or sth like that which disables the diagnostic for > that one declaration. This seems like a good way to do it, since it clearly documents what's going on. LLVM is the only project I've seen with such a policy; across all of chromium's dependencies, the extra `virtual` specifiers we flagged were indeed mistakes. The issue with libc++ was more to do with infrastructure than the warning itself, IIUC. https://github.com/llvm/llvm-project/pull/138741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Add flag to specify an alternative to std::move (PR #138757)
@@ -219,6 +219,11 @@ Changes in existing checks tolerating fix-it breaking compilation when functions is used as pointers to avoid matching usage of functions within the current compilation unit. +- Improved :doc:`cppcoreguidelines-rvalue-reference-param-not-moved EugeneZelenko wrote: Please keep alphabetical order (by check name) in this list. https://github.com/llvm/llvm-project/pull/138757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] show attribute namespace in diagnostics (PR #138519)
https://github.com/a-tarasyuk edited https://github.com/llvm/llvm-project/pull/138519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)
@@ -4179,9 +4183,21 @@ Value *CodeGenFunction::EmitSVEMaskedLoad(const CallExpr *E, unsigned IntrinsicID, bool IsZExtReturn) { QualType LangPTy = E->getArg(1)->getType(); - llvm::Type *MemEltTy = CGM.getTypes().ConvertTypeForMem( + llvm::Type *MemEltTy = CGM.getTypes().ConvertType( paulwalker-arm wrote: Is this change necessary? ConvertTypeForMem should now return the same vector type for mfloat8? https://github.com/llvm/llvm-project/pull/128019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)
https://github.com/paulwalker-arm approved this pull request. I've not verified every line of the test files but what I've seen looks good, as do the code changes. Other than a few stylistic suggestions this looks good to me. https://github.com/llvm/llvm-project/pull/128019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)
@@ -4179,9 +4183,21 @@ Value *CodeGenFunction::EmitSVEMaskedLoad(const CallExpr *E, unsigned IntrinsicID, bool IsZExtReturn) { QualType LangPTy = E->getArg(1)->getType(); - llvm::Type *MemEltTy = CGM.getTypes().ConvertTypeForMem( + llvm::Type *MemEltTy = CGM.getTypes().ConvertType( LangPTy->castAs()->getPointeeType()); + // Mfloat8 types is stored as a vector, so extra work + // to extract sclar element type is necessary. + if (MemEltTy->isVectorTy()) { +#ifndef NDEBUG +auto *VecTy = cast(MemEltTy); +ElementCount EC = VecTy->getElementCount(); +assert(EC.isScalar() && VecTy->getElementType() == Int8Ty && + "Only <1 x i8> expected"); +#endif paulwalker-arm wrote: I think `assert(MemEltTy == FixedVectorType::get(Int8Ty, 1) && ` should work here? https://github.com/llvm/llvm-project/pull/128019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)
@@ -4226,9 +4242,21 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const CallExpr *E, SmallVectorImpl &Ops, unsigned IntrinsicID) { QualType LangPTy = E->getArg(1)->getType(); - llvm::Type *MemEltTy = CGM.getTypes().ConvertTypeForMem( + llvm::Type *MemEltTy = CGM.getTypes().ConvertType( LangPTy->castAs()->getPointeeType()); + // Mfloat8 types is stored as a vector, so extra work + // to extract sclar element type is necessary. + if (MemEltTy->isVectorTy()) { +#ifndef NDEBUG +auto *VecTy = cast(MemEltTy); +ElementCount EC = VecTy->getElementCount(); +assert(EC.isScalar() && VecTy->getElementType() == Int8Ty && + "Only <1 x i8> expected"); +#endif paulwalker-arm wrote: As above. https://github.com/llvm/llvm-project/pull/128019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL][AMDGPU] Add tests for optnone attribute assigned to OpenCL Kernels (PR #138849)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/138849 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Regroup declarations in `Parser` (PR #138511)
https://github.com/Sirraide approved this pull request. Very nice. Thanks! > Documentation has been moved from .cpp files to the header. Grammar was > consistently put in \verbatim blocks to render nicely in Doxygen. Especially this part; this has bothered me in the past. ;Þ https://github.com/llvm/llvm-project/pull/138511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][analyzer] replace Stmt* with ConstCFGElement in SymbolConjured (reland) (PR #137355)
steakhal wrote: Sorry about my availability. I barely have any focus time these days. Could you please split your commit into: 1) the original commit we had to later revert, 2) the changes to fix it that would make it on par with what you have here now This would allow me to review the affected parts, saving me precious time. I know you did a diff of the diffs, but that's not really helpful. https://github.com/llvm/llvm-project/pull/137355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] allow implicit completion inside empty template argument list (PR #138846)
@@ -2455,6 +2455,11 @@ bool isIncludeFile(llvm::StringRef Line) { } bool allowImplicitCompletion(llvm::StringRef Content, unsigned Offset) { + // Check if we're inside an empty template argument list + if (Content.size() > 2 && Content[Offset - 1] == '<' && + Content[Offset] == '>') +return true; + zyn0217 wrote: Does it also pop up a completion within a template parameter list? ```cpp template <^> class foo {}; ``` https://github.com/llvm/llvm-project/pull/138846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits