[clang] [SPIR-V] strengthen some lit tests (PR #111636)
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/111636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)
abhina-sree wrote: > The default is set to OF_Text instead of OF_None, this change in value does > not affect any other platforms other than z/OS. Setting this parameter > correctly is required to open files on z/OS in the correct encoding. The > IsText parameter is based on the context of where we open files, for example, > the embed directive requires that files always be opened in binary even > though they might be tagged as text. Thanks for your patience. I've put up this PR https://github.com/llvm/llvm-project/pull/111723 to implement your suggestion. I kept the IsText parameter in the getBufferForFile, getBufferForFileImpl because it already has other attributes like IsVolatile, RequiresNullTerminator but created a new virtual function for openFileForReadBinary which greatly reduces the number of files touched compared to this PR. The current `#embed` lit tests seem to work without additional changes but I will experiment with creating a testcase with inputs that are non-ascii to expose any issues https://github.com/llvm/llvm-project/pull/110661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)
https://github.com/inbelic updated https://github.com/llvm/llvm-project/pull/111010 >From 70089645ec5cf62b491a56df96ec46f4328fbc11 Mon Sep 17 00:00:00 2001 From: Finn Plummer Date: Thu, 3 Oct 2024 11:43:51 -0700 Subject: [PATCH 01/11] [HLSL] Implement `WaveReadLaneAt` intrinsic - create a clang built-in in Builtins.td - add semantic checking in SemaHLSL.cpp - link the WaveReadLaneAt api in hlsl_intrinsics.h - add lowering to spirv backend op GroupNonUniformShuffle with Scope = 2 (Group) in SPIRVInstructionSelector.cpp - add tests for HLSL intrinsic lowering to spirv intrinsic in WaveReadLaneAt.hlsl - add tests for sema checks in WaveReadLaneAt-errors.hlsl - add spir-v backend tests in WaveReadLaneAt.ll --- clang/include/clang/Basic/Builtins.td | 6 +++ clang/lib/CodeGen/CGBuiltin.cpp | 16 clang/lib/CodeGen/CGHLSLRuntime.h | 1 + clang/lib/Headers/hlsl/hlsl_intrinsics.h | 7 clang/lib/Sema/SemaHLSL.cpp | 20 ++ .../CodeGenHLSL/builtins/WaveReadLaneAt.hlsl | 40 +++ .../BuiltIns/WaveReadLaneAt-errors.hlsl | 21 ++ llvm/include/llvm/IR/IntrinsicsSPIRV.td | 1 + .../Target/SPIRV/SPIRVInstructionSelector.cpp | 15 +++ .../SPIRV/hlsl-intrinsics/WaveReadLaneAt.ll | 28 + 10 files changed, 155 insertions(+) create mode 100644 clang/test/CodeGenHLSL/builtins/WaveReadLaneAt.hlsl create mode 100644 clang/test/SemaHLSL/BuiltIns/WaveReadLaneAt-errors.hlsl create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveReadLaneAt.ll diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 8090119e512fbb..eec9acd4d27d7d 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -4703,6 +4703,12 @@ def HLSLWaveIsFirstLane : LangBuiltin<"HLSL_LANG"> { let Prototype = "bool()"; } +def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_wave_read_lane_at"]; + let Attributes = [NoThrow, Const]; + let Prototype = "void(...)"; +} + def HLSLClamp : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_elementwise_clamp"]; let Attributes = [NoThrow, Const]; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index da3eca73bfb575..dff56af9282e9d 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18835,6 +18835,22 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic(); return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID)); } + case Builtin::BI__builtin_hlsl_wave_read_lane_at: { +// Due to the use of variadic arguments we must explicitly retreive them and +// create our function type. +Value *OpExpr = EmitScalarExpr(E->getArg(0)); +Value *OpIndex = EmitScalarExpr(E->getArg(1)); +llvm::FunctionType *FT = llvm::FunctionType::get( +OpExpr->getType(), ArrayRef{OpExpr->getType(), OpIndex->getType()}, +false); + +// Get overloaded name +std::string name = +Intrinsic::getName(CGM.getHLSLRuntime().getWaveReadLaneAtIntrinsic(), + ArrayRef{OpExpr->getType()}, &CGM.getModule()); +return EmitRuntimeCall(CGM.CreateRuntimeFunction(FT, name, {}, false, true), + ArrayRef{OpExpr, OpIndex}, "hlsl.wave.read.lane.at"); + } case Builtin::BI__builtin_hlsl_elementwise_sign: { Value *Op0 = EmitScalarExpr(E->getArg(0)); llvm::Type *Xty = Op0->getType(); diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h b/clang/lib/CodeGen/CGHLSLRuntime.h index a8aabca7348ffb..a639ce2d784f4a 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.h +++ b/clang/lib/CodeGen/CGHLSLRuntime.h @@ -87,6 +87,7 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot) GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot) GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane) + GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_read_lane_at) //===--===// // End of reserved area for HLSL intrinsic getters. diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h index 810a16d75f0228..a7bdc353ae71bf 100644 --- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -2015,6 +2015,13 @@ _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane) __attribute__((convergent)) bool WaveIsFirstLane(); +// \brief Returns the value of the expression for the given lane index within +// the specified wave. +template +_HLSL_AVAILABILITY(shadermodel, 6.0) +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at) +__attribute__((convergent)) T WaveReadLaneAt(T, int32_t); + //===-
[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)
@@ -87,6 +87,7 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot) GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot) GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane) + GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, waveReadLaneAt) inbelic wrote: Updated to `wave_readlaneat`. https://github.com/llvm/llvm-project/pull/111010 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add explicit visibility symbol macros (PR #108276)
@@ -0,0 +1,67 @@ +//===-- clang/Support/Compiler.h - Compiler abstraction support -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines explicit visibility macros used to export symbols from +// clang-cpp +// +//===--===// + +#ifndef CLANG_SUPPORT_COMPILER_H +#define CLANG_SUPPORT_COMPILER_H + +#include "llvm/Support/Compiler.h" + +/// CLANG_ABI is the main export/visibility macro to mark something as +/// explicitly exported when clang is built as a shared library with everything +/// else that is unannotated will have internal visibility. +/// +/// CLANG_EXPORT_TEMPLATE is used on explicit template instantiations in source +/// files that were declared extern in a header. This macro is only set as a +/// compiler export attribute on windows, on other platforms it does nothing. +/// +/// CLANG_TEMPLATE_ABI is for annotating extern template declarations in headers +/// for both functions and classes. On windows its turned in to dllimport for +/// library consumers, for other platforms its a default visibility attribute. +#ifndef CLANG_ABI_GENERATING_ANNOTATIONS +// Marker to add to classes or functions in public headers that should not have +// export macros added to them by the clang tool AaronBallman wrote: Hmmm, are we close enough to the limit we should be worried now, or are we far enough away from the limit that we can worry in the future if/when we hit it? CC @rnk @compnerd @zmodem for extra opinions on whether we need to think about this more before landing https://github.com/llvm/llvm-project/pull/108276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL][DXIL] Implement WaveGetLaneIndex Intrinsic (PR #111576)
@@ -18827,9 +18827,21 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { ArrayRef{Op0, Op1}, nullptr, "hlsl.step"); } case Builtin::BI__builtin_hlsl_wave_get_lane_index: { -return EmitRuntimeCall(CGM.CreateRuntimeFunction( -llvm::FunctionType::get(IntTy, {}, false), "__hlsl_wave_get_lane_index", -{}, false, true)); +// Since we don't define a SPIR-V intrinsic for the SPIR-V built-in from +// SPIRVBuiltins.td, manually get the matching name for the DirectX +// intrinsic and the demangled builtin name inbelic wrote: The SPIR-V side has already been implemented using a builtin defined in `SPIRVBuiltins.td`. I will improve the comment to be more clear. https://github.com/llvm/llvm-project/pull/111576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL][DXIL] Implement WaveGetLaneIndex Intrinsic (PR #111576)
https://github.com/inbelic updated https://github.com/llvm/llvm-project/pull/111576 >From 167718e352554e167c4690a4962234ba782bceff Mon Sep 17 00:00:00 2001 From: Finn Plummer Date: Tue, 8 Oct 2024 09:28:43 -0700 Subject: [PATCH 1/3] [HLSL][DXIL] Implement WaveGetLaneIndex - add additional lowering for directx backend in CGBuiltin.cpp - add directx intrinsic to IntrinscsDirectX.td - add semantic check of arguments in SemaHLSL.cpp - add mapping to DXIL op in DXIL.td - add testing of semantics in WaveGetLaneIndex-errors.hlsl - add testing of dxil lowering in WaveGetLaneIndex.ll --- clang/lib/CodeGen/CGBuiltin.cpp | 15 +++--- clang/lib/Sema/SemaHLSL.cpp | 5 + .../builtins/wave_get_lane_index_simple.hlsl | 20 +-- .../BuiltIns/WaveGetLaneIndex-errors.hlsl | 6 ++ llvm/include/llvm/IR/IntrinsicsDirectX.td | 1 + llvm/lib/Target/DirectX/DXIL.td | 9 + llvm/test/CodeGen/DirectX/WaveGetLaneIndex.ll | 10 ++ 7 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 clang/test/SemaHLSL/BuiltIns/WaveGetLaneIndex-errors.hlsl create mode 100644 llvm/test/CodeGen/DirectX/WaveGetLaneIndex.ll diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index da3eca73bfb575..c83b2c5a2ca047 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18827,9 +18827,18 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { ArrayRef{Op0, Op1}, nullptr, "hlsl.step"); } case Builtin::BI__builtin_hlsl_wave_get_lane_index: { -return EmitRuntimeCall(CGM.CreateRuntimeFunction( -llvm::FunctionType::get(IntTy, {}, false), "__hlsl_wave_get_lane_index", -{}, false, true)); +switch (CGM.getTarget().getTriple().getArch()) { +case llvm::Triple::dxil: + return EmitRuntimeCall(Intrinsic::getDeclaration( + &CGM.getModule(), Intrinsic::dx_waveGetLaneIndex)); +case llvm::Triple::spirv: + return EmitRuntimeCall(CGM.CreateRuntimeFunction( + llvm::FunctionType::get(IntTy, {}, false), + "__hlsl_wave_get_lane_index", {}, false, true)); +default: + llvm_unreachable( + "Intrinsic WaveGetLaneIndex not supported by target architecture"); +} } case Builtin::BI__builtin_hlsl_wave_is_first_lane: { Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic(); diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 43cc6c81ae5cb0..7d93f41bb2d7a0 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -1956,6 +1956,11 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_wave_get_lane_index: { +if (SemaRef.checkArgCount(TheCall, 0)) + return true; +break; + } case Builtin::BI__builtin_elementwise_acos: case Builtin::BI__builtin_elementwise_asin: case Builtin::BI__builtin_elementwise_atan: diff --git a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl index 8f52d81091c180..e76d35a86e512a 100644 --- a/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl +++ b/clang/test/CodeGenHLSL/builtins/wave_get_lane_index_simple.hlsl @@ -1,14 +1,22 @@ // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ -// RUN: spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s +// RUN: spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,CHECK-SPIRV +// RUN: %clang_cc1 -finclude-default-header \ +// RUN: -triple dxil-pc-shadermodel6.3-library %s \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,CHECK-DXIL -// CHECK: define spir_func noundef i32 @_Z6test_1v() [[A0:#[0-9]+]] { -// CHECK: %[[CI:[0-9]+]] = call token @llvm.experimental.convergence.entry() -// CHECK: call i32 @__hlsl_wave_get_lane_index() [ "convergencectrl"(token %[[CI]]) ] -uint test_1() { +// CHECK-SPIRV: define spir_func noundef i32 @{{.*test_1.*}}() [[A0:#[0-9]+]] { +// CHECK-DXIL: define noundef i32 @{{.*test_1.*}}() [[A0:#[0-9]+]] { +// CHECK-SPIRV: %[[CI:[0-9]+]] = call token @llvm.experimental.convergence.entry() +// CHECK-SPIRV: call i32 @__hlsl_wave_get_lane_index() [ "convergencectrl"(token %[[CI]]) ] +// CHECK-DXIL: call i32 @llvm.dx.waveGetLaneIndex() +int test_1() { return WaveGetLaneIndex(); } -// CHECK: declare i32 @__hlsl_wave_get_lane_index() [[A1:#[0-9]+]] +// CHECK-SPIRV: declare i32 @__hlsl_wave_get_lane_index() [[A1:#[0-9]+]] +// CHECK-DXIL: declare i32 @llvm.dx.waveGetLaneIndex() [[A1:#[0-9]+]] // CHECK-DAG: attributes [[A0]] = { {{.*}}convergent{{.*}} } // CHECK-DAG: attributes [[A1]] = { {{.*}}convergent{{.*}} } diff --git a/clang/test/SemaHL
[clang] [llvm] [HLSL][DXIL] Implement WaveGetLaneIndex Intrinsic (PR #111576)
@@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected inbelic wrote: The flag was not needed, so have removed it. https://github.com/llvm/llvm-project/pull/111576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][frontend] Add support for attribute plugins for statement attributes (PR #110334)
@@ -2125,6 +2126,19 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E, Arg, PackIndex); } +const AnnotateAttr * +TemplateInstantiator::TransformAnnotateAttr(const AnnotateAttr *AA) { + SmallVector Args; + for (Expr *Arg : AA->args()) { +ExprResult Res = getDerived().TransformExpr(Arg); +if (!Res.isUsable()) + return AA; +Args.push_back(Res.get()); + } + return AnnotateAttr::CreateImplicit(getSema().Context, AA->getAnnotation(), ericastor wrote: I think `StringArgument` only handles `StringRef`s? I don't see a way it could be given a dependent value. https://github.com/llvm/llvm-project/pull/110334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang should have a warning to disallow re-externs (PR #109714)
AaronBallman wrote: I appreciate the idea, but I don't think it's a diagnostic we'd want to accept in Clang itself. We typically don't want to add new default-off diagnostics because there's plenty of evidence that they aren't enabled often enough to warrant having them. But also, this is really something that's better left to a tool other than the compiler. For example, Clang's static analyzer has cross-translation unit analysis support (https://clang.llvm.org/docs/analyzer/user-docs/CrossTranslationUnit.html) which seems like it would be a better fit. https://github.com/llvm/llvm-project/pull/109714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Switch DirectX Target to use the Itanium ABI (PR #111632)
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/111632 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CUDA/HIP] fix propagate -cuid to a host-only compilation. (PR #111650)
Artem-B wrote: > This does not seem to be the right fix. I tends to think the test > https://github.com/ROCm/hip-tests/tree/amd-staging/samples/2_Cookbook/16_assembly_to_executable > needs fix. Since it does not expect host-only compilation to use CUID, it > should add `-fuse-cuid=none` to the host-only compilation. I agree. The reason I did the change is that we have builds where we do host and per-GPU sub-compilations separately, but they all need to be in sync. Another way to look at it is that sub-compilation of the same TU file, with the same options should produce the same results if they were done as part of a combined compilation or partial compilation done with `--cuda-host-only`/`--cuda-device-only`. Not setting/propagating CUID for the host-only compilation makes the host build inconsistent. https://github.com/llvm/llvm-project/pull/111650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -324,6 +330,17 @@ ErrorOr RealFileSystem::status(const Twine &Path) { ErrorOr> RealFileSystem::openFileForRead(const Twine &Name) { + SmallString<256> RealName, Storage; perry-ca wrote: Can you put this code into a static function or even a private member function so you can avoid the duplication of code. https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -117,8 +117,12 @@ FileSystem::~FileSystem() = default; ErrorOr> FileSystem::getBufferForFile(const llvm::Twine &Name, int64_t FileSize, - bool RequiresNullTerminator, bool IsVolatile) { - auto F = openFileForRead(Name); + bool RequiresNullTerminator, bool IsVolatile, + bool IsText) { + auto openFileFunctionPointer = &FileSystem::openFileForRead; + if (!IsText) +openFileFunctionPointer = &FileSystem::openFileForReadBinary; perry-ca wrote: ```suggestion auto F = IsText ?openFileForRead(Name) : openFileForReadBinary(Name); ``` https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Allow `ConditionalOperator` fast-math flags to be overridden by `pragma float_control` (PR #105912)
echesakov wrote: > I made an alternative PR, which does not need changes in ConditionalOperator: > https://github.com/llvm/llvm-project/pull/111654. Thank you @spavloff , closing in favor of #111654 https://github.com/llvm/llvm-project/pull/105912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)
yronglin wrote: I plan to merge in 24 hours if there are no further comments. https://github.com/llvm/llvm-project/pull/86960 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (PR #111173)
sdkrystian wrote: > Do you think you'll have a fix within a couple of hours @mstorsjo I think so. If not, I'll revert. https://github.com/llvm/llvm-project/pull/73 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase { SourceLocation *ArgLocation = nullptr); /// Determine if type T is a valid subject for a nonnull and similar - /// attributes. By default, we look through references (the behavior used by - /// nonnull), but if the second parameter is true, then we treat a reference - /// type as valid. + /// attributes. By default, we skip dependence and look through references AmrDeveloper wrote: Thank you, all comments addressed https://github.com/llvm/llvm-project/pull/111573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[clang] Track function template instantiation from definition (#110387)" (PR #111764)
https://github.com/sdkrystian created https://github.com/llvm/llvm-project/pull/111764 This reverts commit 4336f00f2156970cc0af2816331387a0a4039317. >From 79468220ab383f24a86a3c52e0bf02a829992c5f Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Wed, 9 Oct 2024 17:42:58 -0400 Subject: [PATCH] Revert "[clang] Track function template instantiation from definition (#110387)" This reverts commit 4336f00f2156970cc0af2816331387a0a4039317. --- clang/docs/ReleaseNotes.rst | 1 - clang/include/clang/AST/Decl.h| 7 -- clang/include/clang/AST/DeclBase.h| 10 +- clang/include/clang/AST/DeclTemplate.h| 9 -- clang/include/clang/Sema/Sema.h | 6 -- clang/lib/AST/Decl.cpp| 1 - clang/lib/Sema/SemaTemplateDeduction.cpp | 17 ++- clang/lib/Sema/SemaTemplateInstantiate.cpp| 17 +-- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 22 +--- clang/lib/Serialization/ASTReaderDecl.cpp | 1 - clang/lib/Serialization/ASTWriterDecl.cpp | 3 +- clang/test/SemaTemplate/GH55509.cpp | 101 -- 12 files changed, 26 insertions(+), 169 deletions(-) delete mode 100644 clang/test/SemaTemplate/GH55509.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a4bb303a2bc42b..29b9fe07f545f9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -468,7 +468,6 @@ Bug Fixes to C++ Support - Fixed an assertion failure in debug mode, and potential crashes in release mode, when diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326) -- Clang is now better at keeping track of friend function template instance contexts. (#GH55509) - Fixed an issue deducing non-type template arguments of reference type. (#GH73460) - Fixed an issue in constraint evaluation, where type constraints on the lambda expression containing outer unexpanded parameters were not correctly expanded. (#GH101754) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 6afc86710a8137..7ff35d73df5997 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -2299,13 +2299,6 @@ class FunctionDecl : public DeclaratorDecl, FunctionDeclBits.IsLateTemplateParsed = ILT; } - bool isInstantiatedFromMemberTemplate() const { -return FunctionDeclBits.IsInstantiatedFromMemberTemplate; - } - void setInstantiatedFromMemberTemplate(bool Val = true) { -FunctionDeclBits.IsInstantiatedFromMemberTemplate = Val; - } - /// Whether this function is "trivial" in some specialized C++ senses. /// Can only be true for default constructors, copy constructors, /// copy assignment operators, and destructors. Not meaningful until diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index eb67dc03157e64..ee662ed73d7e0e 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -1763,8 +1763,6 @@ class DeclContext { uint64_t HasImplicitReturnZero : 1; LLVM_PREFERRED_TYPE(bool) uint64_t IsLateTemplateParsed : 1; -LLVM_PREFERRED_TYPE(bool) -uint64_t IsInstantiatedFromMemberTemplate : 1; /// Kind of contexpr specifier as defined by ConstexprSpecKind. LLVM_PREFERRED_TYPE(ConstexprSpecKind) @@ -1815,7 +1813,7 @@ class DeclContext { }; /// Number of inherited and non-inherited bits in FunctionDeclBitfields. - enum { NumFunctionDeclBits = NumDeclContextBits + 32 }; + enum { NumFunctionDeclBits = NumDeclContextBits + 31 }; /// Stores the bits used by CXXConstructorDecl. If modified /// NumCXXConstructorDeclBits and the accessor @@ -1826,12 +1824,12 @@ class DeclContext { LLVM_PREFERRED_TYPE(FunctionDeclBitfields) uint64_t : NumFunctionDeclBits; -/// 19 bits to fit in the remaining available space. +/// 20 bits to fit in the remaining available space. /// Note that this makes CXXConstructorDeclBitfields take /// exactly 64 bits and thus the width of NumCtorInitializers /// will need to be shrunk if some bit is added to NumDeclContextBitfields, /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields. -uint64_t NumCtorInitializers : 16; +uint64_t NumCtorInitializers : 17; LLVM_PREFERRED_TYPE(bool) uint64_t IsInheritingConstructor : 1; @@ -1845,7 +1843,7 @@ class DeclContext { }; /// Number of inherited and non-inherited bits in CXXConstructorDeclBitfields. - enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 19 }; + enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 20 }; /// Stores the bits used by ObjCMethodDecl. /// If modified NumObjCMethodDeclBits and the accessor diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTempla
[clang] [Clang] prevent recovery call expression from proceeding with explicit attributes and undeclared templates (PR #107786)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/107786 >From e9948a1004cc2b486a0422d83e88392754e9f7e9 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Mon, 23 Sep 2024 17:17:30 +0300 Subject: [PATCH 1/2] [Clang] prevent recovery call expression from proceeding with explicit attributes and undeclared templates --- clang/docs/ReleaseNotes.rst | 2 ++ clang/include/clang/Sema/Sema.h | 4 ++- clang/lib/Sema/SemaExpr.cpp | 12 +-- clang/lib/Sema/SemaOverload.cpp | 2 +- .../SemaTemplate/recovery-crash-cxx20.cpp | 32 +++ 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 clang/test/SemaTemplate/recovery-crash-cxx20.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b47e06cb0c5d68..110f75d739c072 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -424,6 +424,8 @@ Bug Fixes to C++ Support - Fixed an assertion failure in debug mode, and potential crashes in release mode, when diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326) +- Fixed an assertion failure when invoking recovery call expressions with explicit attributes + and undeclared templates. (#GH107047, #GH49093) Bug Fixes to AST Handling ^ diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index e1c3a99cfa167e..b2eefdbd1c56d1 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -6753,7 +6753,9 @@ class Sema final : public SemaBase { /// /// Return \c true if the error is unrecoverable, or \c false if the caller /// should attempt to recover using these lookup results. - bool DiagnoseDependentMemberLookup(const LookupResult &R); + bool DiagnoseDependentMemberLookup( + const LookupResult &R, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); /// Diagnose an empty lookup. /// diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 66df9c969256a2..a5770ae8848517 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2385,7 +2385,15 @@ static void emitEmptyLookupTypoDiagnostic( SemaRef.PDiag(NoteID)); } -bool Sema::DiagnoseDependentMemberLookup(const LookupResult &R) { +bool Sema::DiagnoseDependentMemberLookup( +const LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs) { + auto IsTemplated = [](NamedDecl *D) { return D->isTemplated(); }; + if (ExplicitTemplateArgs && !llvm::all_of(R, IsTemplated)) { +Diag(R.getNameLoc(), diag::err_non_template_in_template_id) +<< R.getLookupName(); +return true; + } + // During a default argument instantiation the CurContext points // to a CXXMethodDecl; but we can't apply a this-> fixit inside a // function parameter list, hence add an explicit check. @@ -2487,7 +2495,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, R.resolveKind(); } -return DiagnoseDependentMemberLookup(R); +return DiagnoseDependentMemberLookup(R, ExplicitTemplateArgs); } R.clear(); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index d304f322aced64..fe9b16e1890c16 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -13860,7 +13860,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, // enclosing class. // FIXME: We should also explain why the candidates found by name lookup // were not viable. -if (SemaRef.DiagnoseDependentMemberLookup(R)) +if (SemaRef.DiagnoseDependentMemberLookup(R, ExplicitTemplateArgs)) return ExprError(); } else { // We had viable candidates and couldn't recover; let the caller diagnose diff --git a/clang/test/SemaTemplate/recovery-crash-cxx20.cpp b/clang/test/SemaTemplate/recovery-crash-cxx20.cpp new file mode 100644 index 00..3651b986dfd989 --- /dev/null +++ b/clang/test/SemaTemplate/recovery-crash-cxx20.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s + +namespace GH49093 { + class B { + public: +static int a() { return 0; } +decltype(a< 0 >(0)) test; // expected-error {{'a' does not name a template but is followed by template arguments}} + }; + + struct C { + static int a() { return 0; } + decltype(a < 0 > (0)) test; // expected-error {{'a' does not name a template but is followed by template arguments}} + }; + + void test_is_bool(bool t) {} + void test_is_bool(int t) {} + + int main() { +B b; +test_is_bool(b.test); + +C c; +test_is_bool(c.test); + } +} + +namespace GH107047 { + struct A { +static constexpr auto test() { return 1; } +
[clang] 91dd4ec - Revert "[clang] Track function template instantiation from definition (#110387)" (#111764)
Author: Krystian Stasiowski Date: 2024-10-09T17:43:55-04:00 New Revision: 91dd4ec20e8371ea5e920f5493688e13306a67d2 URL: https://github.com/llvm/llvm-project/commit/91dd4ec20e8371ea5e920f5493688e13306a67d2 DIFF: https://github.com/llvm/llvm-project/commit/91dd4ec20e8371ea5e920f5493688e13306a67d2.diff LOG: Revert "[clang] Track function template instantiation from definition (#110387)" (#111764) This reverts commit 4336f00f2156970cc0af2816331387a0a4039317. Added: Modified: clang/docs/ReleaseNotes.rst clang/include/clang/AST/Decl.h clang/include/clang/AST/DeclBase.h clang/include/clang/AST/DeclTemplate.h clang/include/clang/Sema/Sema.h clang/lib/AST/Decl.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp Removed: clang/test/SemaTemplate/GH55509.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a4bb303a2bc42b..29b9fe07f545f9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -468,7 +468,6 @@ Bug Fixes to C++ Support - Fixed an assertion failure in debug mode, and potential crashes in release mode, when diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326) -- Clang is now better at keeping track of friend function template instance contexts. (#GH55509) - Fixed an issue deducing non-type template arguments of reference type. (#GH73460) - Fixed an issue in constraint evaluation, where type constraints on the lambda expression containing outer unexpanded parameters were not correctly expanded. (#GH101754) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 6afc86710a8137..7ff35d73df5997 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -2299,13 +2299,6 @@ class FunctionDecl : public DeclaratorDecl, FunctionDeclBits.IsLateTemplateParsed = ILT; } - bool isInstantiatedFromMemberTemplate() const { -return FunctionDeclBits.IsInstantiatedFromMemberTemplate; - } - void setInstantiatedFromMemberTemplate(bool Val = true) { -FunctionDeclBits.IsInstantiatedFromMemberTemplate = Val; - } - /// Whether this function is "trivial" in some specialized C++ senses. /// Can only be true for default constructors, copy constructors, /// copy assignment operators, and destructors. Not meaningful until diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index eb67dc03157e64..ee662ed73d7e0e 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -1763,8 +1763,6 @@ class DeclContext { uint64_t HasImplicitReturnZero : 1; LLVM_PREFERRED_TYPE(bool) uint64_t IsLateTemplateParsed : 1; -LLVM_PREFERRED_TYPE(bool) -uint64_t IsInstantiatedFromMemberTemplate : 1; /// Kind of contexpr specifier as defined by ConstexprSpecKind. LLVM_PREFERRED_TYPE(ConstexprSpecKind) @@ -1815,7 +1813,7 @@ class DeclContext { }; /// Number of inherited and non-inherited bits in FunctionDeclBitfields. - enum { NumFunctionDeclBits = NumDeclContextBits + 32 }; + enum { NumFunctionDeclBits = NumDeclContextBits + 31 }; /// Stores the bits used by CXXConstructorDecl. If modified /// NumCXXConstructorDeclBits and the accessor @@ -1826,12 +1824,12 @@ class DeclContext { LLVM_PREFERRED_TYPE(FunctionDeclBitfields) uint64_t : NumFunctionDeclBits; -/// 19 bits to fit in the remaining available space. +/// 20 bits to fit in the remaining available space. /// Note that this makes CXXConstructorDeclBitfields take /// exactly 64 bits and thus the width of NumCtorInitializers /// will need to be shrunk if some bit is added to NumDeclContextBitfields, /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields. -uint64_t NumCtorInitializers : 16; +uint64_t NumCtorInitializers : 17; LLVM_PREFERRED_TYPE(bool) uint64_t IsInheritingConstructor : 1; @@ -1845,7 +1843,7 @@ class DeclContext { }; /// Number of inherited and non-inherited bits in CXXConstructorDeclBitfields. - enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 19 }; + enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 20 }; /// Stores the bits used by ObjCMethodDecl. /// If modified NumObjCMethodDeclBits and the accessor diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 2fb49ec1aea0d0..05739f39d2a496 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1008,15 +1008,6 @@ class Functio
[clang] Revert "[clang] Track function template instantiation from definition (#110387)" (PR #111764)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: Krystian Stasiowski (sdkrystian) Changes This reverts commit 4336f00f2156970cc0af2816331387a0a4039317. --- Full diff: https://github.com/llvm/llvm-project/pull/111764.diff 12 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (-1) - (modified) clang/include/clang/AST/Decl.h (-7) - (modified) clang/include/clang/AST/DeclBase.h (+4-6) - (modified) clang/include/clang/AST/DeclTemplate.h (-9) - (modified) clang/include/clang/Sema/Sema.h (-6) - (modified) clang/lib/AST/Decl.cpp (-1) - (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+16-1) - (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+3-14) - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+2-20) - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (-1) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+1-2) - (removed) clang/test/SemaTemplate/GH55509.cpp (-101) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a4bb303a2bc42b..29b9fe07f545f9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -468,7 +468,6 @@ Bug Fixes to C++ Support - Fixed an assertion failure in debug mode, and potential crashes in release mode, when diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326) -- Clang is now better at keeping track of friend function template instance contexts. (#GH55509) - Fixed an issue deducing non-type template arguments of reference type. (#GH73460) - Fixed an issue in constraint evaluation, where type constraints on the lambda expression containing outer unexpanded parameters were not correctly expanded. (#GH101754) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 6afc86710a8137..7ff35d73df5997 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -2299,13 +2299,6 @@ class FunctionDecl : public DeclaratorDecl, FunctionDeclBits.IsLateTemplateParsed = ILT; } - bool isInstantiatedFromMemberTemplate() const { -return FunctionDeclBits.IsInstantiatedFromMemberTemplate; - } - void setInstantiatedFromMemberTemplate(bool Val = true) { -FunctionDeclBits.IsInstantiatedFromMemberTemplate = Val; - } - /// Whether this function is "trivial" in some specialized C++ senses. /// Can only be true for default constructors, copy constructors, /// copy assignment operators, and destructors. Not meaningful until diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index eb67dc03157e64..ee662ed73d7e0e 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -1763,8 +1763,6 @@ class DeclContext { uint64_t HasImplicitReturnZero : 1; LLVM_PREFERRED_TYPE(bool) uint64_t IsLateTemplateParsed : 1; -LLVM_PREFERRED_TYPE(bool) -uint64_t IsInstantiatedFromMemberTemplate : 1; /// Kind of contexpr specifier as defined by ConstexprSpecKind. LLVM_PREFERRED_TYPE(ConstexprSpecKind) @@ -1815,7 +1813,7 @@ class DeclContext { }; /// Number of inherited and non-inherited bits in FunctionDeclBitfields. - enum { NumFunctionDeclBits = NumDeclContextBits + 32 }; + enum { NumFunctionDeclBits = NumDeclContextBits + 31 }; /// Stores the bits used by CXXConstructorDecl. If modified /// NumCXXConstructorDeclBits and the accessor @@ -1826,12 +1824,12 @@ class DeclContext { LLVM_PREFERRED_TYPE(FunctionDeclBitfields) uint64_t : NumFunctionDeclBits; -/// 19 bits to fit in the remaining available space. +/// 20 bits to fit in the remaining available space. /// Note that this makes CXXConstructorDeclBitfields take /// exactly 64 bits and thus the width of NumCtorInitializers /// will need to be shrunk if some bit is added to NumDeclContextBitfields, /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields. -uint64_t NumCtorInitializers : 16; +uint64_t NumCtorInitializers : 17; LLVM_PREFERRED_TYPE(bool) uint64_t IsInheritingConstructor : 1; @@ -1845,7 +1843,7 @@ class DeclContext { }; /// Number of inherited and non-inherited bits in CXXConstructorDeclBitfields. - enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 19 }; + enum { NumCXXConstructorDeclBits = NumFunctionDeclBits + 20 }; /// Stores the bits used by ObjCMethodDecl. /// If modified NumObjCMethodDeclBits and the accessor diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 2fb49ec1aea0d0..05739f39d2a496 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1008,15 +1008,6 @@ class FunctionTemplateDecl : public RedeclarableTemplateDecl { return getTemplatedDecl()->isThisDeclarationADefinition(); }
[clang] [llvm] [CGData][ThinLTO] Global Outlining with Two-CodeGen Rounds (PR #90933)
https://github.com/teresajohnson approved this pull request. lgtm https://github.com/llvm/llvm-project/pull/90933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[clang] Track function template instantiation from definition (#110387)" (PR #111764)
https://github.com/sdkrystian closed https://github.com/llvm/llvm-project/pull/111764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (#111173)" (PR #111766)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Krystian Stasiowski (sdkrystian) Changes This reverts commit 4da8ac34f76e707ab94380b94f616457cfd2cb83. --- Patch is 103.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/111766.diff 20 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (-3) - (modified) clang/include/clang/AST/DeclTemplate.h (+39-27) - (modified) clang/include/clang/Sema/Sema.h (+19-6) - (modified) clang/lib/AST/Decl.cpp (+19-30) - (modified) clang/lib/AST/DeclCXX.cpp (+6-14) - (modified) clang/lib/AST/DeclTemplate.cpp (+16-14) - (modified) clang/lib/Sema/SemaConcept.cpp (+17-12) - (modified) clang/lib/Sema/SemaDecl.cpp (+17-14) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+2-2) - (modified) clang/lib/Sema/SemaTemplate.cpp (+94-85) - (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+30-3) - (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+29-16) - (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+382-370) - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+9-37) - (modified) clang/lib/Serialization/ASTReader.cpp (+1-2) - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+9-9) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+10-7) - (removed) clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp (-175) - (removed) clang/test/CXX/temp/temp.spec/temp.expl.spec/p7.cpp (-178) - (modified) clang/test/Modules/cxx-templates.cpp (+3-1) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 29b9fe07f545f9..16e6a230ef428e 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -477,9 +477,6 @@ Bug Fixes to C++ Support in certain friend declarations. (#GH93099) - Clang now instantiates the correct lambda call operator when a lambda's class type is merged across modules. (#GH110401) -- Clang now uses the correct set of template argument lists when comparing the constraints of - out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of - a class template. (#GH102320) - Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460) Bug Fixes to AST Handling diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 05739f39d2a496..687715a22e9fd3 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -781,11 +781,15 @@ class RedeclarableTemplateDecl : public TemplateDecl, EntryType *Entry, void *InsertPos); struct CommonBase { -CommonBase() {} +CommonBase() : InstantiatedFromMember(nullptr, false) {} /// The template from which this was most /// directly instantiated (or null). -RedeclarableTemplateDecl *InstantiatedFromMember = nullptr; +/// +/// The boolean value indicates whether this template +/// was explicitly specialized. +llvm::PointerIntPair + InstantiatedFromMember; /// If non-null, points to an array of specializations (including /// partial specializations) known only by their external declaration IDs. @@ -805,19 +809,14 @@ class RedeclarableTemplateDecl : public TemplateDecl, }; /// Pointer to the common data shared by all declarations of this - /// template, and a flag indicating if the template is a member - /// specialization. - mutable llvm::PointerIntPair Common; - - CommonBase *getCommonPtrInternal() const { return Common.getPointer(); } + /// template. + mutable CommonBase *Common = nullptr; /// Retrieves the "common" pointer shared by all (re-)declarations of /// the same template. Calling this routine may implicitly allocate memory /// for the common pointer. CommonBase *getCommonPtr() const; - void setCommonPtr(CommonBase *C) const { Common.setPointer(C); } - virtual CommonBase *newCommon(ASTContext &C) const = 0; // Construct a template decl with name, parameters, and templated element. @@ -858,12 +857,15 @@ class RedeclarableTemplateDecl : public TemplateDecl, /// template<> template /// struct X::Inner { /* ... */ }; /// \endcode - bool isMemberSpecialization() const { return Common.getInt(); } + bool isMemberSpecialization() const { +return getCommonPtr()->InstantiatedFromMember.getInt(); + } /// Note that this member template is a specialization. void setMemberSpecialization() { -assert(!isMemberSpecialization() && "already a member specialization"); -Common.setInt(true); +assert(getCommonPtr()->InstantiatedFromMember.getPointer() && + "Only member templates can be member template specializations"); +getCommonPtr()->InstantiatedFromMember.setInt(true); } /// Retrieve the member template from which this template was @@ -903,12 +905,12 @@ class RedeclarableTemplateDecl : public TemplateDecl, /// void X::f(T, U); /// \endcode Redecl
[clang] [Clang][perf-training] Do build of libLLVMSupport for perf training (PR #111625)
https://github.com/tstellar edited https://github.com/llvm/llvm-project/pull/111625 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (#111173)" (PR #111766)
https://github.com/sdkrystian closed https://github.com/llvm/llvm-project/pull/111766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][deps] Serialize JSON without creating intermediate objects (PR #111734)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/111734 >From c4c5b9cd372707a53cfe1948ab3881a8a64001a3 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Tue, 8 Oct 2024 16:21:40 -0700 Subject: [PATCH 1/2] [clang][deps] Serialize JSON without creating intermediate objects The dependency scanner uses the `llvm::json` library for outputting the dependency information. Until now, it created an in-memory representation of the dependency graph using the `llvm::json::Object` hierarchy. This not only creates unnecessary copies of the data, but also forces lexicographical ordering of attributes in the output, both of which I'd like to avoid. This patch adopts the `llvm::json::OStream` API instead and reorders the attribute printing logic such that the existing lexicographical ordering is preserved (for now). --- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 159 ++ 1 file changed, 87 insertions(+), 72 deletions(-) diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index b642a37c79e980..0c1774e60e7cc2 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -330,38 +330,46 @@ handleMakeDependencyToolResult(const std::string &Input, return false; } -static llvm::json::Array toJSONSorted(const llvm::StringSet<> &Set) { - std::vector Strings; - for (auto &&I : Set) -Strings.push_back(I.getKey()); +template +static auto toJSONStrings(llvm::json::OStream &JOS, Container &&Strings) { + return [&JOS, Strings = std::forward(Strings)]() { +for (StringRef Str : Strings) + JOS.value(Str); + }; +} + +static auto toJSONSorted(llvm::json::OStream &JOS, + const llvm::StringSet<> &Set) { + SmallVector Strings(Set.keys()); llvm::sort(Strings); - return llvm::json::Array(Strings); + return toJSONStrings(JOS, std::move(Strings)); } // Technically, we don't need to sort the dependency list to get determinism. // Leaving these be will simply preserve the import order. -static llvm::json::Array toJSONSorted(std::vector V) { +static auto toJSONSorted(llvm::json::OStream &JOS, std::vector V) { llvm::sort(V); - - llvm::json::Array Ret; - for (const ModuleID &MID : V) -Ret.push_back(llvm::json::Object( -{{"module-name", MID.ModuleName}, {"context-hash", MID.ContextHash}})); - return Ret; + return [&JOS, V = std::move(V)]() { +for (const ModuleID &MID : V) + JOS.object([&]() { +JOS.attribute("context-hash", StringRef(MID.ContextHash)); +JOS.attribute("module-name", StringRef(MID.ModuleName)); + }); + }; } -static llvm::json::Array -toJSONSorted(llvm::SmallVector &LinkLibs) { - llvm::sort(LinkLibs, [](const Module::LinkLibrary &lhs, - const Module::LinkLibrary &rhs) { -return lhs.Library < rhs.Library; +static auto toJSONSorted(llvm::json::OStream &JOS, + SmallVector LinkLibs) { + llvm::sort(LinkLibs, [](const auto &LHS, const auto &RHS) { +return LHS.Library < RHS.Library; }); - - llvm::json::Array Ret; - for (const Module::LinkLibrary &LL : LinkLibs) -Ret.push_back(llvm::json::Object( -{{"link-name", LL.Library}, {"isFramework", LL.IsFramework}})); - return Ret; + return [&JOS, LinkLibs = std::move(LinkLibs)]() { +for (const auto &LL : LinkLibs) + JOS.object([&]() { +JOS.attribute("isFramework", LL.IsFramework); +JOS.attribute("link-name", StringRef(LL.Library)); + }); + }; } // Thread safe. @@ -450,58 +458,65 @@ class FullDeps { ModuleIDs.push_back(M.first); llvm::sort(ModuleIDs); -using namespace llvm::json; - -Array OutModules; -for (auto &&ModID : ModuleIDs) { - auto &MD = Modules[ModID]; - Object O{{"name", MD.ID.ModuleName}, - {"context-hash", MD.ID.ContextHash}, - {"file-deps", toJSONSorted(MD.FileDeps)}, - {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)}, - {"clang-modulemap-file", MD.ClangModuleMapFile}, - {"command-line", MD.getBuildArguments()}, - {"link-libraries", toJSONSorted(MD.LinkLibraries)}}; - OutModules.push_back(std::move(O)); -} - -Array TUs; -for (auto &&I : Inputs) { - Array Commands; - if (I.DriverCommandLine.empty()) { -for (const auto &Cmd : I.Commands) { - Object O{ - {"input-file", I.FileName}, - {"clang-context-hash", I.ContextHash}, - {"file-deps", I.FileDeps}, - {"clang-module-deps", toJSONSorted(I.ModuleDeps)}, - {"executable", Cmd.Executable}, - {"command-line", Cmd.Arguments}, - }; - Commands.push_back(std::move(O)); +llvm::json::OStream JOS(OS, /*IndentSize=*/2); + +JOS.object([&]() { + JOS.attributeArray("modules", [&]() { +fo
[clang] c55d68f - [clang][deps] Serialize JSON without creating intermediate objects (#111734)
Author: Jan Svoboda Date: 2024-10-09T14:49:09-07:00 New Revision: c55d68fcc67d70235d6e4b75fe3879ab4d24a6b6 URL: https://github.com/llvm/llvm-project/commit/c55d68fcc67d70235d6e4b75fe3879ab4d24a6b6 DIFF: https://github.com/llvm/llvm-project/commit/c55d68fcc67d70235d6e4b75fe3879ab4d24a6b6.diff LOG: [clang][deps] Serialize JSON without creating intermediate objects (#111734) The dependency scanner uses the `llvm::json` library for outputting the dependency information. Until now, it created an in-memory representation of the dependency graph using the `llvm::json::Object` hierarchy. This not only creates unnecessary copies of the data, but also forces lexicographical ordering of attributes in the output, both of which I'd like to avoid. This patch adopts the `llvm::json::OStream` API instead and reorders the attribute printing logic such that the existing lexicographical ordering is preserved (for now). Added: Modified: clang/tools/clang-scan-deps/ClangScanDeps.cpp Removed: diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index b642a37c79e980..7d36cee7a22b39 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -330,38 +330,46 @@ handleMakeDependencyToolResult(const std::string &Input, return false; } -static llvm::json::Array toJSONSorted(const llvm::StringSet<> &Set) { - std::vector Strings; - for (auto &&I : Set) -Strings.push_back(I.getKey()); +template +static auto toJSONStrings(llvm::json::OStream &JOS, Container &&Strings) { + return [&JOS, Strings = std::forward(Strings)] { +for (StringRef Str : Strings) + JOS.value(Str); + }; +} + +static auto toJSONSorted(llvm::json::OStream &JOS, + const llvm::StringSet<> &Set) { + SmallVector Strings(Set.keys()); llvm::sort(Strings); - return llvm::json::Array(Strings); + return toJSONStrings(JOS, std::move(Strings)); } // Technically, we don't need to sort the dependency list to get determinism. // Leaving these be will simply preserve the import order. -static llvm::json::Array toJSONSorted(std::vector V) { +static auto toJSONSorted(llvm::json::OStream &JOS, std::vector V) { llvm::sort(V); - - llvm::json::Array Ret; - for (const ModuleID &MID : V) -Ret.push_back(llvm::json::Object( -{{"module-name", MID.ModuleName}, {"context-hash", MID.ContextHash}})); - return Ret; + return [&JOS, V = std::move(V)] { +for (const ModuleID &MID : V) + JOS.object([&] { +JOS.attribute("context-hash", StringRef(MID.ContextHash)); +JOS.attribute("module-name", StringRef(MID.ModuleName)); + }); + }; } -static llvm::json::Array -toJSONSorted(llvm::SmallVector &LinkLibs) { - llvm::sort(LinkLibs, [](const Module::LinkLibrary &lhs, - const Module::LinkLibrary &rhs) { -return lhs.Library < rhs.Library; +static auto toJSONSorted(llvm::json::OStream &JOS, + SmallVector LinkLibs) { + llvm::sort(LinkLibs, [](const auto &LHS, const auto &RHS) { +return LHS.Library < RHS.Library; }); - - llvm::json::Array Ret; - for (const Module::LinkLibrary &LL : LinkLibs) -Ret.push_back(llvm::json::Object( -{{"link-name", LL.Library}, {"isFramework", LL.IsFramework}})); - return Ret; + return [&JOS, LinkLibs = std::move(LinkLibs)] { +for (const auto &LL : LinkLibs) + JOS.object([&] { +JOS.attribute("isFramework", LL.IsFramework); +JOS.attribute("link-name", StringRef(LL.Library)); + }); + }; } // Thread safe. @@ -450,58 +458,65 @@ class FullDeps { ModuleIDs.push_back(M.first); llvm::sort(ModuleIDs); -using namespace llvm::json; - -Array OutModules; -for (auto &&ModID : ModuleIDs) { - auto &MD = Modules[ModID]; - Object O{{"name", MD.ID.ModuleName}, - {"context-hash", MD.ID.ContextHash}, - {"file-deps", toJSONSorted(MD.FileDeps)}, - {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)}, - {"clang-modulemap-file", MD.ClangModuleMapFile}, - {"command-line", MD.getBuildArguments()}, - {"link-libraries", toJSONSorted(MD.LinkLibraries)}}; - OutModules.push_back(std::move(O)); -} - -Array TUs; -for (auto &&I : Inputs) { - Array Commands; - if (I.DriverCommandLine.empty()) { -for (const auto &Cmd : I.Commands) { - Object O{ - {"input-file", I.FileName}, - {"clang-context-hash", I.ContextHash}, - {"file-deps", I.FileDeps}, - {"clang-module-deps", toJSONSorted(I.ModuleDeps)}, - {"executable", Cmd.Executable}, - {"command-line", Cmd.Arguments}, - }; - Commands.push_back(std::move(O)); +llvm::json::OStream JOS(OS
[clang] [clang][deps] Serialize JSON without creating intermediate objects (PR #111734)
https://github.com/jansvoboda11 closed https://github.com/llvm/llvm-project/pull/111734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][perf-training] Do build of libLLVMSupport for perf training (PR #111625)
tstellar wrote: > I'm assuming you used instrumented BOLT here? Also, do you have numbers on > how long the perf training took? Yes, it was instrumented BOLT. I've added the perf training times to the commit summary. https://github.com/llvm/llvm-project/pull/111625 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[clang] Track function template instantiation from definition (#110387)" (PR #111764)
sdkrystian wrote: @mizvekov Sorry, will do so in the future! https://github.com/llvm/llvm-project/pull/111764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (#111173)" (PR #111766)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 91dd4ec20e8371ea5e920f5493688e13306a67d2 88925f844c22b9c8b4f0bfce1ebc467d24a8854d --extensions cpp,h -- clang/include/clang/AST/DeclTemplate.h clang/include/clang/Sema/Sema.h clang/lib/AST/Decl.cpp clang/lib/AST/DeclCXX.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/Sema/SemaConcept.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateDeductionGuide.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/Modules/cxx-templates.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 687715a22e..379bd085b3 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -788,8 +788,8 @@ protected: /// /// The boolean value indicates whether this template /// was explicitly specialized. -llvm::PointerIntPair - InstantiatedFromMember; +llvm::PointerIntPair +InstantiatedFromMember; /// If non-null, points to an array of specializations (including /// partial specializations) known only by their external declaration IDs. @@ -2268,9 +2268,7 @@ protected: return static_cast(RedeclarableTemplateDecl::getCommonPtr()); } - void setCommonPtr(Common *C) { -RedeclarableTemplateDecl::Common = C; - } + void setCommonPtr(Common *C) { RedeclarableTemplateDecl::Common = C; } public: diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 998a148a7d..74fa4f6d28 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -586,7 +586,7 @@ static bool CheckConstraintSatisfaction( ArrayRef TemplateArgs = TemplateArgsLists.getNumSubstitutedLevels() > 0 ? TemplateArgsLists.getOutermost() - : ArrayRef {}; + : ArrayRef{}; Sema::InstantiatingTemplate Inst(S, TemplateIDRange.getBegin(), Sema::InstantiatingTemplate::ConstraintsCheck{}, const_cast(Template), TemplateArgs, TemplateIDRange); diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index c7d48b81bc..6163e40619 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -8467,15 +8467,12 @@ DeclResult Sema::ActOnClassTemplateSpecialization( Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template) << /*class template*/ 0 << (TUK == TagUseKind::Definition) << FixItHint::CreateRemoval(SourceRange(LAngleLoc, RAngleLoc)); - return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS, -ClassTemplate->getIdentifier(), -TemplateNameLoc, -Attr, -TemplateParams, -AS_none, /*ModulePrivateLoc=*/SourceLocation(), -/*FriendLoc*/SourceLocation(), -TemplateParameterLists.size() - 1, -TemplateParameterLists.data()); + return CheckClassTemplate( + S, TagSpec, TUK, KWLoc, SS, ClassTemplate->getIdentifier(), + TemplateNameLoc, Attr, TemplateParams, AS_none, + /*ModulePrivateLoc=*/SourceLocation(), + /*FriendLoc*/ SourceLocation(), TemplateParameterLists.size() - 1, + TemplateParameterLists.data()); } // Create a new class template partial specialization declaration node. diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 7d42cf6b8c..3287a8ba46 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -229,7 +229,7 @@ Response HandlePartialClassTemplateSpec( const ClassTemplatePartialSpecializationDecl *PartialClassTemplSpec, MultiLevelTemplateArgumentList &Result, bool SkipForSpecialization) { if (!SkipForSpecialization) - Result.addOuterRetainedLevels(PartialClassTemplSpec->getTemplateDepth()); +Result.addOuterRetainedLevels(PartialClassTemplSpec->getTemplateDepth()); return Response::Done(); } @@ -260,9 +260,11 @@ HandleClassTemplateSpec(const ClassTemplateSpecializationDecl *ClassTemplSpec, // to get the next level of declaration context from the partial // specialization, as the ClassTemplateSpecializationDecl's // DeclContext/LexicalDeclContext will be for the primary template. -if (auto *InstFromPartialTempl = ClassT
[clang] Revert "[clang] Track function template instantiation from definition (#110387)" (PR #111764)
mizvekov wrote: FIY you should include revert reason on the commit message/ PR description. https://github.com/llvm/llvm-project/pull/111764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][perf-training] Do build of libLLVMSupport for perf training (PR #111625)
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/111625 >From 40efbcf0fd348625c892453d915eb7601adda917 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sat, 5 Oct 2024 17:17:33 + Subject: [PATCH 1/2] [Clang][perf-training] Do build of libLLVMSupport for perf training This adds a build of the libLLVMSupport to the lit suite that is used for generating profile data. This helps to improve both PGO and BOLT optimization of clang over the existing hello world training program. I considered building all of LLVM instead of just libLLVMSupport, but there is only a marginal increase in performance for PGO only builds when training with a build of all of LLVM, and I didn't think it was enough to justify the increased build times given that it is the default configuration. The benchmark[1] I did showed that using libLLVMSupport for training gives a 1.35 +- 0.02 speed up for clang optimized with PGO + BOLT vs just 1.05 +- 0.01 speed up when training with hello world. For comparison, training with a full LLVM build gave a speed up of 1.35 +- 0.1. Raw data: | PGO Training | BOLT Training | Speed Up | Error Range | | | - | | --- | | LLVM Support | LLVM Support | 1.35 | 0.02| | LLVM All | LLVM All | 1.34 | 0.01| | LLVM Support | Hello World | 1.29 | 0.02| | LLVM All | PGO-ONLY | 1.27 | 0.02| | LLVM Support | PGO-ONLY | 1.22 | 0.02| | Hello World | Hello World | 1.05 | 0.01| | Hello World | PGO-ONLY | 1.03 | 0.01| [1] Benchmark was compiling SemaDecl.cpp --- clang/utils/perf-training/bolt.lit.cfg| 3 +++ clang/utils/perf-training/bolt.lit.site.cfg.in| 3 +++ clang/utils/perf-training/lit.cfg | 6 +- clang/utils/perf-training/lit.site.cfg.in | 3 +++ clang/utils/perf-training/llvm-support/build.test | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 clang/utils/perf-training/llvm-support/build.test diff --git a/clang/utils/perf-training/bolt.lit.cfg b/clang/utils/perf-training/bolt.lit.cfg index 0e81a5501e9fcf..1d0cf9a8a17a8e 100644 --- a/clang/utils/perf-training/bolt.lit.cfg +++ b/clang/utils/perf-training/bolt.lit.cfg @@ -49,3 +49,6 @@ config.substitutions.append(("%clang_cpp", f" {config.clang} --driver-mode=g++ " config.substitutions.append(("%clang_skip_driver", config.clang)) config.substitutions.append(("%clang", config.clang)) config.substitutions.append(("%test_root", config.test_exec_root)) +config.substitutions.append(('%cmake_generator', config.cmake_generator)) +config.substitutions.append(('%cmake', config.cmake_exe)) +config.substitutions.append(('%llvm_src_dir', config.llvm_src_dir)) diff --git a/clang/utils/perf-training/bolt.lit.site.cfg.in b/clang/utils/perf-training/bolt.lit.site.cfg.in index 54de12701c1ae9..3de5026e4792ae 100644 --- a/clang/utils/perf-training/bolt.lit.site.cfg.in +++ b/clang/utils/perf-training/bolt.lit.site.cfg.in @@ -11,6 +11,9 @@ config.python_exe = "@Python3_EXECUTABLE@" config.clang_obj_root = path(r"@CLANG_BINARY_DIR@") config.clang_bolt_mode = "@CLANG_BOLT@" config.clang_bolt_name = "@CLANG_BOLT_INSTRUMENTED@" +config.cmake_exe = "@CMAKE_COMMAND@" +config.llvm_src_dir ="@CMAKE_SOURCE_DIR@" +config.cmake_generator ="@CMAKE_GENERATOR@" # Let the main config do the real work. lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/bolt.lit.cfg") diff --git a/clang/utils/perf-training/lit.cfg b/clang/utils/perf-training/lit.cfg index 0bd06c0d44f650..b4527c602fc484 100644 --- a/clang/utils/perf-training/lit.cfg +++ b/clang/utils/perf-training/lit.cfg @@ -34,8 +34,12 @@ config.test_format = lit.formats.ShTest(use_lit_shell == "0") config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags))) config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % (config.clang, sysroot_flags))) config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags))) -config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, sysroot_flags) ) ) +config.substitutions.append( ('%clang', '%s %s ' % (config.clang, sysroot_flags) ) ) config.substitutions.append( ('%test_root', config.test_exec_root ) ) +config.substitutions.append( ('%cmake_generator', config.cmake_generator ) ) +config.substitutions.append( ('%cmake', config.cmake_exe ) ) +config.substitutions.append( ('%llvm_src_dir', config.llvm_src_dir ) ) +print(config.substitutions) config.environment['LLVM_PROFILE_FILE'] = 'perf-training-%4m.profraw' diff --git a/clang/utils/perf-training/lit.site.cfg.in b/clang/utils/perf-training/lit.site.cfg.in index fae93065a4edf2..9d279d552919ac 100644 --- a/clang/utils/perf-training/lit.site.cfg.in +++ b/clang/utils/perf-training/lit.site.cfg.in @@ -8,6 +8,9 @@ config.test_e
[clang] [clang][deps] Serialize JSON without creating intermediate objects (PR #111734)
@@ -450,58 +458,65 @@ class FullDeps { ModuleIDs.push_back(M.first); llvm::sort(ModuleIDs); -using namespace llvm::json; - -Array OutModules; -for (auto &&ModID : ModuleIDs) { - auto &MD = Modules[ModID]; - Object O{{"name", MD.ID.ModuleName}, - {"context-hash", MD.ID.ContextHash}, - {"file-deps", toJSONSorted(MD.FileDeps)}, - {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)}, - {"clang-modulemap-file", MD.ClangModuleMapFile}, - {"command-line", MD.getBuildArguments()}, - {"link-libraries", toJSONSorted(MD.LinkLibraries)}}; - OutModules.push_back(std::move(O)); -} - -Array TUs; -for (auto &&I : Inputs) { - Array Commands; - if (I.DriverCommandLine.empty()) { -for (const auto &Cmd : I.Commands) { - Object O{ - {"input-file", I.FileName}, - {"clang-context-hash", I.ContextHash}, - {"file-deps", I.FileDeps}, - {"clang-module-deps", toJSONSorted(I.ModuleDeps)}, - {"executable", Cmd.Executable}, - {"command-line", Cmd.Arguments}, - }; - Commands.push_back(std::move(O)); +llvm::json::OStream JOS(OS, /*IndentSize=*/2); + +JOS.object([&]() { jansvoboda11 wrote: Thanks! I got confused by my IDE telling me that `"Lambda without a parameter clause is a C++23 extension"`. Now that I'm testing this, that's only true if you also specify it as `noexcept`, `mutable` or similar. https://github.com/llvm/llvm-project/pull/111734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Reland: [clang] Finish implementation of P0522 (PR #111711)
mizvekov wrote: No difference at all. It's just that the PR which will take care of the problem is not small, so I want to keep them separate and merge them all in one go. https://github.com/llvm/llvm-project/pull/111711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][perf-training] Do build of libLLVMSupport for perf training (PR #111625)
@@ -0,0 +1,2 @@ +RUN: %cmake -G %cmake_generator -B %t -S %llvm_src_dir -DCMAKE_C_COMPILER=%clang -DCMAKE_CXX_COMPILER=%clang -DCMAKE_CXX_FLAGS="--driver-mode=g++" -DCMAKE_BUILD_TYPE=Release tstellar wrote: The current bolt.lit.cfg substitutes `%clang_cpp` to `clang --driver-mode=g++` because there is no clang++ symlink to the instrumented bolt binary. So this option is required in order to use `clang` as a c++ compiler. The other alternative solution would be to add the clang++ symlink. https://github.com/llvm/llvm-project/pull/111625 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -264,6 +265,31 @@ class OpLowerer { return lowerToBindAndAnnotateHandle(F); } + Error replaceSplitDoubleCallUsages(CallInst *Intrin, CallInst *Op) { +IRBuilder<> &IRB = OpBuilder.getIRB(); + +for (Use &U : make_early_inc_range(Intrin->uses())) { + if (auto *EVI = dyn_cast(U.getUser())) { + +assert(EVI->getNumIndices() == 1 && + "splitdouble result should be indexed individually."); +if (EVI->getNumIndices() != 1) + return make_error( + "splitdouble result should be indexed individually.", + inconvertibleErrorCode()); + +unsigned int IndexVal = EVI->getIndices()[0]; + +auto *OpEVI = IRB.CreateExtractValue(Op, IndexVal); joaosaffran wrote: Sure, done that https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NvlinkWrapper] Use `-plugin-opt=mattr=` instead of a custom feature (PR #111712)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Joseph Huber (jhuber6) Changes Summary: We don't need a custom flag for this, LLVM had a way to get the features which are forwarded via `plugin-opt`. --- Full diff: https://github.com/llvm/llvm-project/pull/111712.diff 4 Files Affected: - (modified) clang/lib/Driver/ToolChains/Cuda.cpp (+2-2) - (modified) clang/test/Driver/cuda-cross-compiling.c (+1-1) - (modified) clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp (+1-1) - (modified) clang/tools/clang-nvlink-wrapper/NVLinkOpts.td (-3) ``diff diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index 509cd87b28c37e..dfcd20a73f1d54 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -632,8 +632,8 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA, std::vector Features; getNVPTXTargetFeatures(C.getDriver(), getToolChain().getTriple(), Args, Features); - for (StringRef Feature : Features) -CmdArgs.append({"--feature", Args.MakeArgString(Feature)}); + CmdArgs.push_back( + Args.MakeArgString("--plugin-opt=mattr=" + llvm::join(Features, ","))); // Add paths for the default clang library path. SmallString<256> DefaultLibPath = diff --git a/clang/test/Driver/cuda-cross-compiling.c b/clang/test/Driver/cuda-cross-compiling.c index 5f24e7a5accb08..54c291fac66ffd 100644 --- a/clang/test/Driver/cuda-cross-compiling.c +++ b/clang/test/Driver/cuda-cross-compiling.c @@ -104,4 +104,4 @@ // RUN: %clang -target nvptx64-nvidia-cuda --cuda-feature=+ptx63 -march=sm_52 -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=FEATURE %s -// FEATURE: clang-nvlink-wrapper{{.*}}"--feature" "+ptx63" +// FEATURE: clang-nvlink-wrapper{{.*}}"--plugin-opt=mattr=+ptx63" diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp index b4b376fe0d114e..b9767a7a03d0b5 100644 --- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp +++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp @@ -344,7 +344,7 @@ Expected> createLTO(const ArgList &Args) { Conf.RemarksHotnessThreshold = RemarksHotnessThreshold; Conf.RemarksFormat = RemarksFormat; - Conf.MAttrs = {Args.getLastArgValue(OPT_feature, "").str()}; + Conf.MAttrs = llvm::codegen::getMAttrs(); std::optional CGOptLevelOrNone = CodeGenOpt::parseLevel(Args.getLastArgValue(OPT_O, "2")[0]); assert(CGOptLevelOrNone && "Invalid optimization level"); diff --git a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td index eeb9d1a6228240..a80c5937b42992 100644 --- a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td +++ b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td @@ -47,9 +47,6 @@ def arch : Separate<["--", "-"], "arch">, def : Joined<["--", "-"], "plugin-opt=mcpu=">, Flags<[HelpHidden, WrapperOnlyOption]>, Alias; -def feature : Separate<["--", "-"], "feature">, Flags<[WrapperOnlyOption]>, - HelpText<"Specify the '+ptx' freature to use for LTO.">; - def g : Flag<["-"], "g">, HelpText<"Specify that this was a debug compile.">; def debug : Flag<["--"], "debug">, Alias; `` https://github.com/llvm/llvm-project/pull/111712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)
https://github.com/nicovank commented: I like Mustache! Just took a quick look at this following your Discourse post. Do the custom allocators make any significant performance difference (measure)? Wouldn't want to prematurely optimize. They're the kind of thing that make maintenance annoying and can be hard to remove later. Same with `SmallString<0>` / `SmallVector`, in some places `std::string` may be sufficient. I think this first implementation can afford to be as simple as possible, specific implementation optimizations can be added later. Should `Token` and `ASTNode` be present in the `Mustache.h` header at all? https://github.com/llvm/llvm-project/pull/105893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Add Smrnmi extension (PR #111668)
github-actions[bot] wrote: ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information. https://github.com/llvm/llvm-project/pull/111668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions (PR #110435)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/110435 >From c52634882631a71fad956a70179b480abf13006a Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 29 Sep 2024 22:01:38 +0300 Subject: [PATCH 1/3] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions --- clang/docs/ReleaseNotes.rst| 1 + clang/lib/Sema/SemaOverload.cpp| 3 +++ clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++ 3 files changed, 11 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 28c759538f7df6..1bec2838765dab 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -447,6 +447,7 @@ Bug Fixes to C++ Support - Fixed an assertion failure in debug mode, and potential crashes in release mode, when diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326) +- Fixed overload handling for object parameters with top-level cv-qualifiers in explicit member functions (#GH100394) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 0c1e054f7c30a4..7c40bab70bbe9d 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1511,6 +1511,9 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, auto NewObjectType = New->getFunctionObjectParameterReferenceType(); auto OldObjectType = Old->getFunctionObjectParameterReferenceType(); + if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified()) +return false; + auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) { return F->getRefQualifier() == RQ_None && !F->isExplicitObjectMemberFunction(); diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp index 63bf92e8d5edd3..5fd02502ce6df4 100644 --- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp +++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp @@ -1073,3 +1073,10 @@ int main() { return foo[]; // expected-error {{no viable overloaded operator[] for type 'Foo'}} } } + +namespace GH100394 { +struct C { + void f(this const C); + void f() const ; // ok +}; +} >From d377c01f46acf28f1dc74103c6a26df6c0c2e376 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 6 Oct 2024 11:52:48 +0300 Subject: [PATCH 2/3] adjust overload resolution for volatile qualifiers --- clang/lib/Sema/SemaOverload.cpp| 7 +-- clang/test/SemaCXX/cxx2b-deducing-this.cpp | 12 +--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 7c40bab70bbe9d..56705971517cc3 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1511,8 +1511,11 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, auto NewObjectType = New->getFunctionObjectParameterReferenceType(); auto OldObjectType = Old->getFunctionObjectParameterReferenceType(); - if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified()) -return false; + if (Old->isExplicitObjectMemberFunction() && + OldObjectType.getQualifiers() != NewObjectType.getQualifiers()) +return OldObjectType.isConstQualified() && + (NewObjectType.isConstQualified() || +NewObjectType.isVolatileQualified()); auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) { return F->getRefQualifier() == RQ_None && diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp index 5fd02502ce6df4..7dcd63a587c708 100644 --- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp +++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp @@ -1075,8 +1075,14 @@ int main() { } namespace GH100394 { -struct C { - void f(this const C); - void f() const ; // ok +struct C1 { + void f(this const C1); + void f() const;// ok +}; + +struct C2 { + void f(this const C2);// expected-note {{previous declaration is here}} + void f(this volatile C2); // expected-error {{class member cannot be redeclared}} \ +// expected-warning {{volatile-qualified parameter type 'volatile C2' is deprecated}} }; } >From d524f7c0556fa08bd93a48f1ac6edd754a12926a Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 9 Oct 2024 02:46:48 +0300 Subject: [PATCH 3/3] adjust qualifier restrictions for overriding explicit object members --- clang/lib/Sema/SemaOverload.cpp| 31 ++ clang/test/SemaCXX/cxx2b-deducing-this.cpp | 21 +++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/clang/lib/Sema/SemaOverload.cp
[clang] [llvm] Add Smrnmi extension (PR #111668)
asb wrote: Welcome to the project @dong-miao! I'm not sure why the auto-labeler didn't kick in to attach the backend:RISC-V label (this is used to help ping the right people), but I've added that now. Just two quick comments as it's end of day here so I can't review properly right now: * We try to make the PR title and description match the intended commit. For a something like this, we'd typically name it something like "[RISCV][MC] Add support for the Smrnmi extension" * Please add a release note to the RISC-V section in llvm/docs/ReleaseNotes.md. e.g. "Support was added for the Smrnmi extension." https://github.com/llvm/llvm-project/pull/111668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)
@@ -1891,6 +1914,12 @@ static bool skipPGOGen(const Function &F) { return true; if (F.getInstructionCount() < PGOFunctionSizeThreshold) return true; + if (InstrumentColdFunctionCoverage) { +if (!F.getEntryCount()) + return InstrumentColdFunctionCoverageMode == + InstrColdFuncCovMode::Conservative; +return F.getEntryCount()->getCount() > ColdFuncCoverageMaxEntryCount; ellishg wrote: ```suggestion if (auto EntryCount = F.getEntryCount()) return EntryCount->getCount() > ColdFuncCoverageMaxEntryCount; return InstrumentColdFunctionCoverageMode == InstrColdFuncCovMode::Conservative; ``` https://github.com/llvm/llvm-project/pull/109837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -302,6 +305,17 @@ class RealFileSystem : public FileSystem { return Storage; } + ErrorOr> openFileForRead(const Twine &Name, perry-ca wrote: np. I was misreading the diff. I didn't see it was a private member function. It looked like a file scope function. I was thinking file scope static, not static member. https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
https://github.com/farzonl approved this pull request. https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -302,6 +305,17 @@ class RealFileSystem : public FileSystem { return Storage; } + ErrorOr> openFileForRead(const Twine &Name, abhina-sree wrote: I don't think I'm able to mark it static because it calls adjustPath which is non-static https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -18901,6 +18901,160 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdouble: { + +assert((E->getArg(0)->getType()->hasFloatingRepresentation() && +E->getArg(1)->getType()->hasUnsignedIntegerRepresentation() && +E->getArg(2)->getType()->hasUnsignedIntegerRepresentation()) && + "asuint operands types mismatch"); +Value *Op0 = EmitScalarExpr(E->getArg(0)); +const auto *OutArg1 = dyn_cast(E->getArg(1)); +const auto *OutArg2 = dyn_cast(E->getArg(2)); + +CallArgList Args; +auto [Op1BaseLValue, Op1TmpLValue] = +EmitHLSLOutArgExpr(OutArg1, Args, OutArg1->getType()); +auto [Op2BaseLValue, Op2TmpLValue] = +EmitHLSLOutArgExpr(OutArg2, Args, OutArg2->getType()); + +if (CGM.getTarget().getTriple().isDXIL()) { + + llvm::StructType *RetType = nullptr; + + if (Op0->getType()->isVectorTy()) { +auto *Op0VecTy = E->getArg(0)->getType()->getAs(); + +llvm::VectorType *i32VecTy = llvm::VectorType::get( +Int32Ty, ElementCount::getFixed(Op0VecTy->getNumElements())); +RetType = llvm::StructType::get(i32VecTy, i32VecTy); + } else { +RetType = llvm::StructType::get(Int32Ty, Int32Ty); + } + + CallInst *CI = + Builder.CreateIntrinsic(RetType, Intrinsic::dx_splitdouble, {Op0}, + nullptr, "hlsl.splitdouble"); + + Value *Arg0 = Builder.CreateExtractValue(CI, 0); + Value *Arg1 = Builder.CreateExtractValue(CI, 1); + + Builder.CreateStore(Arg0, Op1TmpLValue.getAddress()); + auto *s = Builder.CreateStore(Arg1, Op2TmpLValue.getAddress()); + + EmitWritebacks(*this, Args); + return s; +} + +assert(!CGM.getTarget().getTriple().isDXIL() && joaosaffran wrote: This assert came as a suggestion in [another comment](https://github.com/llvm/llvm-project/pull/109331#discussion_r1792006593) for this PR. The intention is to alert other developers about the behaviour for clang when compiling non DXIL targets. Let me know if you have a better approach for this. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -489,6 +542,9 @@ class OpLowerer { case Intrinsic::dx_typedBufferStore: HasErrors |= lowerTypedBufferStore(F); break; + case Intrinsic::dx_splitdouble: joaosaffran wrote: I will resolve this conversation, since that is a topic we will need further discussion that is out of the scope for this PR. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 0aaac4f - [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (#111472)
Author: Nicolas van Kempen Date: 2024-10-09T18:16:43-04:00 New Revision: 0aaac4fe194ae2249e1a01f9d6f5eac0d75c5bb2 URL: https://github.com/llvm/llvm-project/commit/0aaac4fe194ae2249e1a01f9d6f5eac0d75c5bb2 DIFF: https://github.com/llvm/llvm-project/commit/0aaac4fe194ae2249e1a01f9d6f5eac0d75c5bb2.diff LOG: [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (#111472) Fix #111450. Added: Modified: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/test/clang-tidy/checkers/performance/move-const-arg.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp index d29b9e91f2e35d..421ce003975bc9 100644 --- a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp @@ -209,8 +209,9 @@ void MoveConstArgCheck::check(const MatchFinder::MatchResult &Result) { } if (const CXXRecordDecl *RecordDecl = ArgType->getAsCXXRecordDecl(); -RecordDecl && !(RecordDecl->hasMoveConstructor() && -RecordDecl->hasMoveAssignment())) { +RecordDecl && RecordDecl->hasDefinition() && +!(RecordDecl->hasMoveConstructor() && + RecordDecl->hasMoveAssignment())) { const bool MissingMoveAssignment = !RecordDecl->hasMoveAssignment(); const bool MissingMoveConstructor = !RecordDecl->hasMoveConstructor(); const bool MissingBoth = MissingMoveAssignment && MissingMoveConstructor; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 51100286724588..3c4652e3c23774 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -210,6 +210,10 @@ Changes in existing checks ` check to use ``std::endl`` as placeholder when lexer cannot get source text. +- Improved :doc:`performance-move-const-arg + ` check to fix a crash when + an argument type is declared but not defined. + - Improved :doc:`readability-container-contains ` check to let it work on any class that has a ``contains`` method. diff --git a/clang-tools-extra/test/clang-tidy/checkers/performance/move-const-arg.cpp b/clang-tools-extra/test/clang-tidy/checkers/performance/move-const-arg.cpp index 4505eef6df24bd..8e325b0ae6ca30 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/performance/move-const-arg.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/performance/move-const-arg.cpp @@ -546,3 +546,17 @@ void testAlsoNonMoveable() { } } // namespace issue_62550 + +namespace GH111450 { +struct Status; + +struct Error { +Error(const Status& S); +}; + +struct Result { + Error E; + Result(Status&& S) : E(std::move(S)) {} + // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg] +}; +} // namespace GH111450 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy][performance-move-const-arg] Fix crash when argument type has no definition (PR #111472)
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/111472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [NFC][clang-tidy] Add type annotations to rename_check.py (PR #108443)
https://github.com/nicovank closed https://github.com/llvm/llvm-project/pull/108443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -461,6 +479,27 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerSplitDouble(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(CI); + + Value *Arg0 = CI->getArgOperand(0); + + Type *NewRetTy = OpBuilder.getResSplitDoubleType(M.getContext()); + + std::array Args{Arg0}; + Expected OpCall = OpBuilder.tryCreateOp( farzonl wrote: could you explain how this line and DXIL.td work together? You are `specifying `OpCode::SplitDouble` in the createOp and on line 531 you are mapping the `Intrinsic::dx_splitdouble:` intrinsic to this lowering behavior. Does that mean DXIL.td isn't used at all? https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 4aba20f - [NFC][clang-tidy] Add type annotations to rename_check.py (#108443)
Author: Nicolas van Kempen Date: 2024-10-09T18:19:57-04:00 New Revision: 4aba20fecaa09089132afe451aa04a22cd3794ca URL: https://github.com/llvm/llvm-project/commit/4aba20fecaa09089132afe451aa04a22cd3794ca DIFF: https://github.com/llvm/llvm-project/commit/4aba20fecaa09089132afe451aa04a22cd3794ca.diff LOG: [NFC][clang-tidy] Add type annotations to rename_check.py (#108443) ``` > python3 -m mypy --strict clang-tools-extra/clang-tidy/rename_check.py Success: no issues found in 1 source file ``` Added: Modified: clang-tools-extra/clang-tidy/rename_check.py Removed: diff --git a/clang-tools-extra/clang-tidy/rename_check.py b/clang-tools-extra/clang-tidy/rename_check.py index bf9c886699cb25..5f3295b23ba72f 100755 --- a/clang-tools-extra/clang-tidy/rename_check.py +++ b/clang-tools-extra/clang-tidy/rename_check.py @@ -8,16 +8,16 @@ # # ===---===# -from __future__ import unicode_literals - import argparse import glob import io import os import re +import sys +from typing import List -def replaceInFileRegex(fileName, sFrom, sTo): +def replaceInFileRegex(fileName: str, sFrom: str, sTo: str) -> None: if sFrom == sTo: return @@ -35,7 +35,7 @@ def replaceInFileRegex(fileName, sFrom, sTo): f.write(txt) -def replaceInFile(fileName, sFrom, sTo): +def replaceInFile(fileName: str, sFrom: str, sTo: str) -> None: if sFrom == sTo: return txt = None @@ -51,7 +51,7 @@ def replaceInFile(fileName, sFrom, sTo): f.write(txt) -def generateCommentLineHeader(filename): +def generateCommentLineHeader(filename: str) -> str: return "".join( [ "//===--- ", @@ -63,7 +63,7 @@ def generateCommentLineHeader(filename): ) -def generateCommentLineSource(filename): +def generateCommentLineSource(filename: str) -> str: return "".join( [ "//===--- ", @@ -75,7 +75,7 @@ def generateCommentLineSource(filename): ) -def fileRename(fileName, sFrom, sTo): +def fileRename(fileName: str, sFrom: str, sTo: str) -> str: if sFrom not in fileName or sFrom == sTo: return fileName newFileName = fileName.replace(sFrom, sTo) @@ -84,7 +84,7 @@ def fileRename(fileName, sFrom, sTo): return newFileName -def deleteMatchingLines(fileName, pattern): +def deleteMatchingLines(fileName: str, pattern: str) -> bool: lines = None with io.open(fileName, "r", encoding="utf8") as f: lines = f.readlines() @@ -101,7 +101,7 @@ def deleteMatchingLines(fileName, pattern): return True -def getListOfFiles(clang_tidy_path): +def getListOfFiles(clang_tidy_path: str) -> List[str]: files = glob.glob(os.path.join(clang_tidy_path, "**"), recursive=True) files += [ os.path.normpath(os.path.join(clang_tidy_path, "../docs/ReleaseNotes.rst")) @@ -124,7 +124,7 @@ def getListOfFiles(clang_tidy_path): # Adapts the module's CMakelist file. Returns 'True' if it could add a new # entry and 'False' if the entry already existed. -def adapt_cmake(module_path, check_name_camel): +def adapt_cmake(module_path: str, check_name_camel: str) -> bool: filename = os.path.join(module_path, "CMakeLists.txt") with io.open(filename, "r", encoding="utf8") as f: lines = f.readlines() @@ -153,7 +153,9 @@ def adapt_cmake(module_path, check_name_camel): # Modifies the module to include the new check. -def adapt_module(module_path, module, check_name, check_name_camel): +def adapt_module( +module_path: str, module: str, check_name: str, check_name_camel: str +) -> None: modulecpp = next( iter( filter( @@ -204,7 +206,9 @@ def adapt_module(module_path, module, check_name, check_name_camel): # Adds a release notes entry. -def add_release_notes(clang_tidy_path, old_check_name, new_check_name): +def add_release_notes( +clang_tidy_path: str, old_check_name: str, new_check_name: str +) -> None: filename = os.path.normpath( os.path.join(clang_tidy_path, "../docs/ReleaseNotes.rst") ) @@ -262,7 +266,7 @@ def add_release_notes(clang_tidy_path, old_check_name, new_check_name): f.write(line) -def main(): +def main() -> None: parser = argparse.ArgumentParser(description="Rename clang-tidy check.") parser.add_argument("old_check_name", type=str, help="Old check name.") parser.add_argument("new_check_name", type=str, help="New check name.") @@ -311,7 +315,7 @@ def main(): "Check name '%s' not found in %s. Exiting." % (check_name_camel, cmake_lists) ) -return 1 +sys.exit(1) modulecpp = next( iter( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -18901,6 +18901,160 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdouble: { + +assert((E->getArg(0)->getType()->hasFloatingRepresentation() && +E->getArg(1)->getType()->hasUnsignedIntegerRepresentation() && +E->getArg(2)->getType()->hasUnsignedIntegerRepresentation()) && + "asuint operands types mismatch"); +Value *Op0 = EmitScalarExpr(E->getArg(0)); +const auto *OutArg1 = dyn_cast(E->getArg(1)); +const auto *OutArg2 = dyn_cast(E->getArg(2)); + +CallArgList Args; +auto [Op1BaseLValue, Op1TmpLValue] = +EmitHLSLOutArgExpr(OutArg1, Args, OutArg1->getType()); +auto [Op2BaseLValue, Op2TmpLValue] = +EmitHLSLOutArgExpr(OutArg2, Args, OutArg2->getType()); + +if (CGM.getTarget().getTriple().isDXIL()) { + + llvm::StructType *RetType = nullptr; + + if (Op0->getType()->isVectorTy()) { +auto *Op0VecTy = E->getArg(0)->getType()->getAs(); + +llvm::VectorType *i32VecTy = llvm::VectorType::get( +Int32Ty, ElementCount::getFixed(Op0VecTy->getNumElements())); +RetType = llvm::StructType::get(i32VecTy, i32VecTy); + } else { +RetType = llvm::StructType::get(Int32Ty, Int32Ty); + } + + CallInst *CI = + Builder.CreateIntrinsic(RetType, Intrinsic::dx_splitdouble, {Op0}, + nullptr, "hlsl.splitdouble"); + + Value *Arg0 = Builder.CreateExtractValue(CI, 0); + Value *Arg1 = Builder.CreateExtractValue(CI, 1); + + Builder.CreateStore(Arg0, Op1TmpLValue.getAddress()); + auto *s = Builder.CreateStore(Arg1, Op2TmpLValue.getAddress()); + + EmitWritebacks(*this, Args); + return s; +} + +assert(!CGM.getTarget().getTriple().isDXIL() && farzonl wrote: I mean the simple suggestion would be to just have an else statement. But if others want an assert then fine. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -461,6 +479,27 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerSplitDouble(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(CI); + + Value *Arg0 = CI->getArgOperand(0); + + Type *NewRetTy = OpBuilder.getResSplitDoubleType(M.getContext()); + + std::array Args{Arg0}; + Expected OpCall = OpBuilder.tryCreateOp( joaosaffran wrote: `DXIL.td`, is defining the OpCode call signature, like it's arguments, return type, shader stages where it is available, etc. First, the `OpCode` is generated from `DXIL.td`, so the Op codes defined in there will be made available through the `OpCode` class. Finally, when we call `tryCreateOp` it will check the values specified within `DXIL.td` in order to make sure the call is valid. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CGData][ThinLTO] Global Outlining with Two-CodeGen Rounds (PR #90933)
kyulee-com wrote: @teresajohnson Thank you for your review and valuable feedback! https://github.com/llvm/llvm-project/pull/90933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] dc85d52 - [CGData][ThinLTO] Global Outlining with Two-CodeGen Rounds (#90933)
Author: Kyungwoo Lee Date: 2024-10-09T15:37:41-07:00 New Revision: dc85d5263ed5e416cb4ddf405611472f4ef12fd3 URL: https://github.com/llvm/llvm-project/commit/dc85d5263ed5e416cb4ddf405611472f4ef12fd3 DIFF: https://github.com/llvm/llvm-project/commit/dc85d5263ed5e416cb4ddf405611472f4ef12fd3.diff LOG: [CGData][ThinLTO] Global Outlining with Two-CodeGen Rounds (#90933) This feature is enabled by `-codegen-data-thinlto-two-rounds`, which effectively runs the `-codegen-data-generate` and `-codegen-data-use` in two rounds to enable global outlining with ThinLTO. 1. The first round: Run both optimization + codegen with a scratch output. Before running codegen, we serialize the optimized bitcode modules to a temporary path. 2. From the scratch object files, we merge them into the codegen data. 3. The second round: Read the optimized bitcode modules and start the codegen only this time. Using the codegen data, the machine outliner effectively performs the global outlining. Depends on #90934, #110461 and #110463. This is a patch for https://discourse.llvm.org/t/rfc-enhanced-machine-outliner-part-2-thinlto-nolto/78753. Added: llvm/test/ThinLTO/AArch64/cgdata-two-rounds-caching.ll llvm/test/ThinLTO/AArch64/cgdata-two-rounds.ll llvm/test/ThinLTO/AArch64/lit.local.cfg Modified: clang/lib/CodeGen/BackendUtil.cpp llvm/include/llvm/CGData/CodeGenData.h llvm/include/llvm/CGData/CodeGenDataReader.h llvm/include/llvm/LTO/LTO.h llvm/include/llvm/LTO/LTOBackend.h llvm/lib/CGData/CMakeLists.txt llvm/lib/CGData/CodeGenData.cpp llvm/lib/CGData/CodeGenDataReader.cpp llvm/lib/LTO/CMakeLists.txt llvm/lib/LTO/LTO.cpp llvm/lib/LTO/LTOBackend.cpp Removed: diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index abc936f2c686dd..f018130807519d 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1321,10 +1321,11 @@ static void runThinLTOBackend( Conf.CGFileType = getCodeGenFileType(Action); break; } - if (Error E = thinBackend( - Conf, -1, AddStream, *M, *CombinedIndex, ImportList, - ModuleToDefinedGVSummaries[M->getModuleIdentifier()], - /* ModuleMap */ nullptr, Conf.CodeGenOnly, CGOpts.CmdArgs)) { + if (Error E = + thinBackend(Conf, -1, AddStream, *M, *CombinedIndex, ImportList, + ModuleToDefinedGVSummaries[M->getModuleIdentifier()], + /*ModuleMap=*/nullptr, Conf.CodeGenOnly, + /*IRAddStream=*/nullptr, CGOpts.CmdArgs)) { handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) { errs() << "Error running ThinLTO backend: " << EIB.message() << '\n'; }); diff --git a/llvm/include/llvm/CGData/CodeGenData.h b/llvm/include/llvm/CGData/CodeGenData.h index 84133a433170fe..53550beeae1f83 100644 --- a/llvm/include/llvm/CGData/CodeGenData.h +++ b/llvm/include/llvm/CGData/CodeGenData.h @@ -15,11 +15,13 @@ #define LLVM_CGDATA_CODEGENDATA_H #include "llvm/ADT/BitmaskEnum.h" +#include "llvm/ADT/StableHashing.h" #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/CGData/OutlinedHashTree.h" #include "llvm/CGData/OutlinedHashTreeRecord.h" #include "llvm/IR/Module.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Support/Caching.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/TargetParser/Triple.h" #include @@ -164,6 +166,74 @@ publishOutlinedHashTree(std::unique_ptr HashTree) { CodeGenData::getInstance().publishOutlinedHashTree(std::move(HashTree)); } +struct StreamCacheData { + /// Backing buffer for serialized data stream. + SmallVector> Outputs; + /// Callback function to add serialized data to the stream. + AddStreamFn AddStream; + /// Backing buffer for cached data. + SmallVector> Files; + /// Cache mechanism for storing data. + FileCache Cache; + + StreamCacheData(unsigned Size, const FileCache &OrigCache, + const Twine &CachePrefix) + : Outputs(Size), Files(Size) { +AddStream = [&](size_t Task, const Twine &ModuleName) { + return std::make_unique( + std::make_unique(Outputs[Task])); +}; + +if (OrigCache.isValid()) { + auto CGCacheOrErr = + localCache("ThinLTO", CachePrefix, OrigCache.getCacheDirectoryPath(), + [&](size_t Task, const Twine &ModuleName, + std::unique_ptr MB) { + Files[Task] = std::move(MB); + }); + if (Error Err = CGCacheOrErr.takeError()) +report_fatal_error(std::move(Err)); + Cache = std::move(*CGCacheOrErr); +} + } + StreamCacheData() = delete; + + /// Retrieve results from either the cache or the stream. + std::unique_ptr> getResult() { +unsigned NumOutputs = Outputs.size(); +auto Result = std::make_unique>(NumOutputs); +for (unsigned I = 0; I <
[clang] [llvm] [CGData][ThinLTO] Global Outlining with Two-CodeGen Rounds (PR #90933)
https://github.com/kyulee-com closed https://github.com/llvm/llvm-project/pull/90933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -461,6 +479,27 @@ class OpLowerer { }); } + [[nodiscard]] bool lowerSplitDouble(Function &F) { +IRBuilder<> &IRB = OpBuilder.getIRB(); +return replaceFunction(F, [&](CallInst *CI) -> Error { + IRB.SetInsertPoint(CI); + + Value *Arg0 = CI->getArgOperand(0); + + Type *NewRetTy = OpBuilder.getResSplitDoubleType(M.getContext()); + + std::array Args{Arg0}; + Expected OpCall = OpBuilder.tryCreateOp( farzonl wrote: so what im wondering is it possible to just something that looks like: ``` case Intrinsic::dx_splitdouble: replaceSplitDoubleCallUsages(...); replaceFunctionWithOp(F, OpCode); ``` instead of writing our own intrinsic to op code lowering as a one off. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Cuda] Handle -fcuda-short-ptr even with -nocudalib (PR #111682)
jhuber6 wrote: > I'm not sure why we would ever want the current default if this is an option. > I'm trying to see it, but I can't work out a case where a 64bit pointer would > make sense, since the even tens-of-thousands of money supercomputer cards > have less than 256KiB of addressable shared memory. > > It might be a bit of an intrusive change (albeit a relatively mechanical > one), but until we see a GPU come to market that has >4GiB addressable shared > memory, I think we should use the "short pointer" datalayout as default It also applies to constant and private / local address spaces. I don't think those hit 4 GiB yet but it's more feasible than shared. Making address space 3 32-bit by default would make sense to me. https://github.com/llvm/llvm-project/pull/111682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Support BasedOnStyle referencing an arbitrary file (PR #110634)
https://github.com/jediry updated https://github.com/llvm/llvm-project/pull/110634 >From 82160d1e6de3f197c847bf8ed21ea1fc314b3cf4 Mon Sep 17 00:00:00 2001 From: Ryan Saunders Date: Tue, 1 Oct 2024 00:03:50 -0700 Subject: [PATCH 1/3] Support BasedOnStyle: file:blah.clang-format --- clang/include/clang/Format/Format.h | 22 ++- clang/lib/Format/Format.cpp | 207 +--- 2 files changed, 174 insertions(+), 55 deletions(-) diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index d8b62c7652a0f6..1b833256500431 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -53,10 +53,24 @@ std::error_code make_error_code(ParseError e); /// The ``FormatStyle`` is used to configure the formatting to follow /// specific guidelines. struct FormatStyle { - // If the BasedOn: was InheritParentConfig and this style needs the file from - // the parent directories. It is not part of the actual style for formatting. - // Thus the // instead of ///. - bool InheritsParentConfig; + // If the BasedOnStyle: was InheritParentConfig, this is the string + // "", indicating to search upwards until a _clang-format or + // .clang-format file is found. + // + // Else, if the BasedOnStyle: was an explicit "file:" reference, this is + // that reference, verbatim, including the "file:" prefix. The string + // after "file:" may start with $(CLANG_FORMAT_DIR), in which case the value + // of the CLANG_FORMAT_DIR environment variable (which must be defined) is + // substituted; otherwise, the string after "file:" is interpreted as a + // path relative to the current config file. (Absolute paths are not + // permitted, for security reasons.) + // + // Else (i.e., if the BasedOnStyle is omitted or a predefined style), this is + // the empty string. + // + // This field is not part of the actual style for formatting, thus the // + // instead of ///. + std::string InheritsConfig; /// The extra indent or outdent of access modifiers, e.g. ``public:``. /// \version 3.3 diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index d2463b892fbb96..bfca01d1a67230 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1543,7 +1543,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.IndentRequiresClause = true; LLVMStyle.IndentWidth = 2; LLVMStyle.IndentWrappedFunctionNames = false; - LLVMStyle.InheritsParentConfig = false; + LLVMStyle.InheritsConfig.clear(); LLVMStyle.InsertBraces = false; LLVMStyle.InsertNewlineAtEOF = false; LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None; @@ -1992,7 +1992,9 @@ bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language, else if (Name.equals_insensitive("none")) *Style = getNoStyle(); else if (Name.equals_insensitive("inheritparentconfig")) -Style->InheritsParentConfig = true; +Style->InheritsConfig = ""; + else if (Name.starts_with_insensitive("file:")) +Style->InheritsConfig = Name; else return false; @@ -4004,6 +4006,45 @@ loadAndParseConfigFile(StringRef ConfigFile, llvm::vfs::FileSystem *FS, return Text; } +// Resolves an explicit file: reference in a BasedOnStyle directive to a +// canonical, absolute path, substituting the value of the CLANG_FORMAT_DIR +// environment variable if the path starts with $(CLANG_FORMAT_DIR), or treating +// BasedOnFile as relative to the current ConfigFile otherwise. +static Expected> +resolveExplicitParentConfigFile(StringRef ConfigFile, StringRef BasedOnFile, +llvm::vfs::FileSystem *FS) { + constexpr const char *EnvVar = "CLANG_FORMAT_DIR"; + constexpr const char *EnvVarExpansion = "$(CLANG_FORMAT_DIR)"; + if (BasedOnFile.starts_with(EnvVarExpansion)) { +const char *ClangFormatDir = getenv(EnvVar); +if (ClangFormatDir == nullptr) { + return make_string_error(ConfigFile + ": 'BasedOnStyle: " + BasedOnFile + + "' uses " + EnvVarExpansion + ", but the " + + EnvVar + " environment variable is not defined"); +} else { + auto Status = FS->status(ClangFormatDir); + if (!Status || + Status->getType() != llvm::sys::fs::file_type::directory_file) { +return make_string_error( +StringRef("Environment variable ") + EnvVar + " = " + +ClangFormatDir + "does not refer to a valid, readable directory"); + } + + SmallString<128> FileName{ClangFormatDir}; + llvm::sys::path::append(FileName, + BasedOnFile.substr(strlen(EnvVarExpansion))); + ; + llvm::sys::path::remove_dots(FileName, true /*remove_dot_dot*/); + return FileName; +} + } else { +SmallString<128> FileName = llvm::sys::path::parent_path(ConfigFile); +llvm::sys::path::append(FileName, BasedOnFile); +llvm::sys::path::re
[clang] [llvm] [AArch64] Introduce new armv9.6 features (PR #111677)
@@ -522,6 +522,39 @@ def FeatureTLBIW : ExtensionWithMArch<"tlbiw", "TLBIW", "FEAT_TLBIW", // Armv9.6 Architecture Extensions //===--===// +def FeatureCMPBR : ExtensionWithMArch<"cmpbr", "CMPBR", "FEAT_CMPBR", + "Enable A64 base compare and branch instructions">; + +def FeatureF8F32MM: ExtensionWithMArch<"f8f32mm", "F8F32MM", "FEAT_F8F32MM", + "Enable FP8 to Single-Precision Matrix Multiplication", [FeatureFP8DOT4]>; + +def FeatureF8F16MM: ExtensionWithMArch<"f8f16mm", "F8F16MM", "FEAT_F8F16MM", + "Enable FP8 to Half-Precision Matrix Multiplication", [FeatureFP8DOT2, FeatureF8F32MM]>; + +def FeatureFPRCVT: ExtensionWithMArch<"fprcvt", "FPRCVT", "FEAT_FPRCVT", + "Enable A64 base convert instructions for SIMD&FP scalar register operands of" + " different input and output sizes", [FeatureFPARMv8]>; + +def FeatureLSFE : ExtensionWithMArch<"lsfe", "LSFE", "FEAT_LSFE", + "Enable A64 base Atomic floating-point in-memory instructions", [FeatureFPARMv8]>; jthackray wrote: Can we mention "Large System Float Extension" so it's obvious what the extension stands for? Perhaps "Enable Armv9.6-A Large System Float Extension (Atomic floating-point in-memory instructions)" ? https://github.com/llvm/llvm-project/pull/111677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Allow `ConditionalOperator` fast-math flags to be overridden by `pragma float_control` (PR #105912)
https://github.com/echesakov closed https://github.com/llvm/llvm-project/pull/105912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions (PR #110435)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/110435 >From c52634882631a71fad956a70179b480abf13006a Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 29 Sep 2024 22:01:38 +0300 Subject: [PATCH 1/3] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions --- clang/docs/ReleaseNotes.rst| 1 + clang/lib/Sema/SemaOverload.cpp| 3 +++ clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++ 3 files changed, 11 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 28c759538f7df6..1bec2838765dab 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -447,6 +447,7 @@ Bug Fixes to C++ Support - Fixed an assertion failure in debug mode, and potential crashes in release mode, when diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. - Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326) +- Fixed overload handling for object parameters with top-level cv-qualifiers in explicit member functions (#GH100394) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 0c1e054f7c30a4..7c40bab70bbe9d 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1511,6 +1511,9 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, auto NewObjectType = New->getFunctionObjectParameterReferenceType(); auto OldObjectType = Old->getFunctionObjectParameterReferenceType(); + if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified()) +return false; + auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) { return F->getRefQualifier() == RQ_None && !F->isExplicitObjectMemberFunction(); diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp index 63bf92e8d5edd3..5fd02502ce6df4 100644 --- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp +++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp @@ -1073,3 +1073,10 @@ int main() { return foo[]; // expected-error {{no viable overloaded operator[] for type 'Foo'}} } } + +namespace GH100394 { +struct C { + void f(this const C); + void f() const ; // ok +}; +} >From d377c01f46acf28f1dc74103c6a26df6c0c2e376 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 6 Oct 2024 11:52:48 +0300 Subject: [PATCH 2/3] adjust overload resolution for volatile qualifiers --- clang/lib/Sema/SemaOverload.cpp| 7 +-- clang/test/SemaCXX/cxx2b-deducing-this.cpp | 12 +--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 7c40bab70bbe9d..56705971517cc3 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1511,8 +1511,11 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, auto NewObjectType = New->getFunctionObjectParameterReferenceType(); auto OldObjectType = Old->getFunctionObjectParameterReferenceType(); - if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified()) -return false; + if (Old->isExplicitObjectMemberFunction() && + OldObjectType.getQualifiers() != NewObjectType.getQualifiers()) +return OldObjectType.isConstQualified() && + (NewObjectType.isConstQualified() || +NewObjectType.isVolatileQualified()); auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) { return F->getRefQualifier() == RQ_None && diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp index 5fd02502ce6df4..7dcd63a587c708 100644 --- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp +++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp @@ -1075,8 +1075,14 @@ int main() { } namespace GH100394 { -struct C { - void f(this const C); - void f() const ; // ok +struct C1 { + void f(this const C1); + void f() const;// ok +}; + +struct C2 { + void f(this const C2);// expected-note {{previous declaration is here}} + void f(this volatile C2); // expected-error {{class member cannot be redeclared}} \ +// expected-warning {{volatile-qualified parameter type 'volatile C2' is deprecated}} }; } >From d524f7c0556fa08bd93a48f1ac6edd754a12926a Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 9 Oct 2024 02:46:48 +0300 Subject: [PATCH 3/3] adjust qualifier restrictions for overriding explicit object members --- clang/lib/Sema/SemaOverload.cpp| 31 ++ clang/test/SemaCXX/cxx2b-deducing-this.cpp | 21 +++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/clang/lib/Sema/SemaOverload.cp
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
https://github.com/AmrDeveloper edited https://github.com/llvm/llvm-project/pull/111573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang should have a warning to disallow re-externs (PR #109714)
https://github.com/jchcrsp updated https://github.com/llvm/llvm-project/pull/109714 >From 8f512e2a8ad110b1a74c4283f81d4e28555e7567 Mon Sep 17 00:00:00 2001 From: Jeffrey Crowell Date: Mon, 23 Sep 2024 16:17:32 -0400 Subject: [PATCH] clang should have a warning to disallow re-externs clang should have a warning to disallow re-externs from the main C translation unit for example, it would be helpful to warn programmers in this situation ```c // file1.c extern int func(int a, int b); int some_func() { func(1,2); } ``` ```c // file2.c int func(int a, int b, char *c, int d) { // function body } ``` --- clang/include/clang/Basic/DiagnosticGroups.td | 3 ++ .../clang/Basic/DiagnosticSemaKinds.td| 6 clang/include/clang/Sema/Sema.h | 9 + clang/lib/Sema/Sema.cpp | 2 ++ clang/lib/Sema/SemaDecl.cpp | 34 +++ .../Sema/warn-extern-func-not-in-header.c | 13 +++ 6 files changed, 67 insertions(+) create mode 100644 clang/test/Sema/warn-extern-func-not-in-header.c diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 7d81bdf827ea0c..9e8bd587094423 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -1582,3 +1582,6 @@ def ExtractAPIMisuse : DiagGroup<"extractapi-misuse">; // Warnings about using the non-standard extension having an explicit specialization // with a storage class specifier. def ExplicitSpecializationStorageClass : DiagGroup<"explicit-specialization-storage-class">; + +// Warnings about extern functions not in header files. +def ExternalDeclaration : DiagGroup<"external-declaration">; \ No newline at end of file diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index e4e04bff8b5120..16529dab1e245d 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12614,4 +12614,10 @@ def err_acc_loop_spec_conflict // AMDGCN builtins diagnostics def err_amdgcn_global_load_lds_size_invalid_value : Error<"invalid size value">; def note_amdgcn_global_load_lds_size_valid_value : Note<"size must be 1, 2, or 4">; + +// SemaExternWarning diagnostics +def warn_extern_func_not_in_header : Warning< + "extern function '%0' declared in main file '%1' instead of a header">, + InGroup, DefaultIgnore; + } // end of sema component. diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index e1c3a99cfa167e..76a9f4c84f47f7 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4390,6 +4390,15 @@ class Sema final : public SemaBase { // linkage or not. static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD); + ///@} + /// \name CheckExternFunction + ///@{ +public: + void CheckExternDecl(Decl *D); + void CheckDeferredExternDecls(); + +private: + std::vector ExternFuncDecls; ///@} // diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 6d7a57d7b5a41a..4a4aefcd38e4c7 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1177,6 +1177,8 @@ void Sema::ActOnEndOfTranslationUnit() { if (PP.isCodeCompletionEnabled()) return; + CheckDeferredExternDecls(); + // Complete translation units and modules define vtables and perform implicit // instantiations. PCH files do not. if (TUKind != TU_Prefix) { diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 31bf50a32a83c3..e2dbf9521aec6c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6058,6 +6058,10 @@ Decl *Sema::ActOnDeclarator(Scope *S, Declarator &D) { Dcl && Dcl->getDeclContext()->isFileContext()) Dcl->setTopLevelDeclInObjCContainer(); + if (Dcl) { +CheckExternDecl(Dcl); + } + if (!Bases.empty()) OpenMP().ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope(Dcl, Bases); @@ -20354,3 +20358,33 @@ bool Sema::diagnoseConflictingFunctionEffect( return false; } + +void Sema::CheckExternDecl(Decl *D) { + if (FunctionDecl *FD = dyn_cast(D)) { +SourceLocation Loc = FD->getLocation(); +SourceManager &SM = Context.getSourceManager(); + +// Only consider extern function declarations (not definitions) in the main +// file +if (FD->isExternC() && !FD->isImplicit() && !FD->getBuiltinID() && +!FD->hasBody() && !FD->isThisDeclarationADefinition() && +FD->isFirstDecl() && SM.isInMainFile(Loc)) { + // Defer the warning check until the end of the translation unit + ExternFuncDecls.push_back(FD); +} + } +} + +void Sema::CheckDeferredExternDecls() { + SourceManager &SM = Context.getSourceManager(); + for (FunctionDecl *FD : ExternFuncDecls) { +// Check if there's a definition in the same fi
[clang] [Sema] Support negation/parens with __builtin_available (PR #111439)
gburgessiv wrote: (...Or a reviewer will find me - thank you!) https://github.com/llvm/llvm-project/pull/111439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Support negation/parens with __builtin_available (PR #111439)
https://github.com/gburgessiv closed https://github.com/llvm/llvm-project/pull/111439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1553cb5 - [Sema] Support negation/parens with __builtin_available (#111439)
Author: George Burgess IV Date: 2024-10-09T10:40:53-06:00 New Revision: 1553cb5d3b14a0516c2796c295a3b32d147d13d0 URL: https://github.com/llvm/llvm-project/commit/1553cb5d3b14a0516c2796c295a3b32d147d13d0 DIFF: https://github.com/llvm/llvm-project/commit/1553cb5d3b14a0516c2796c295a3b32d147d13d0.diff LOG: [Sema] Support negation/parens with __builtin_available (#111439) At present, `__builtin_available` is really restrictive with its use. Overall, this seems like a good thing, since the analyses behind it are not very expensive. That said, it's very straightforward to support these two cases: ``` if ((__builtin_available(foo, *))) { // ... } ``` and ``` if (!__builtin_available(foo, *)) { // ... } else { // ... } ``` Seems nice to do so. Added: Modified: clang/lib/Sema/SemaAvailability.cpp clang/test/Sema/attr-availability.c Removed: diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp index e04cbeec165552..798cabaa31a476 100644 --- a/clang/lib/Sema/SemaAvailability.cpp +++ b/clang/lib/Sema/SemaAvailability.cpp @@ -1005,25 +1005,54 @@ bool DiagnoseUnguardedAvailability::VisitTypeLoc(TypeLoc Ty) { return true; } +struct ExtractedAvailabilityExpr { + const ObjCAvailabilityCheckExpr *E = nullptr; + bool isNegated = false; +}; + +ExtractedAvailabilityExpr extractAvailabilityExpr(const Expr *IfCond) { + const auto *E = IfCond; + bool IsNegated = false; + while (true) { +E = E->IgnoreParens(); +if (const auto *AE = dyn_cast(E)) { + return ExtractedAvailabilityExpr{AE, IsNegated}; +} + +const auto *UO = dyn_cast(E); +if (!UO || UO->getOpcode() != UO_LNot) { + return ExtractedAvailabilityExpr{}; +} +E = UO->getSubExpr(); +IsNegated = !IsNegated; + } +} + bool DiagnoseUnguardedAvailability::TraverseIfStmt(IfStmt *If) { - VersionTuple CondVersion; - if (auto *E = dyn_cast(If->getCond())) { -CondVersion = E->getVersion(); - -// If we're using the '*' case here or if this check is redundant, then we -// use the enclosing version to check both branches. -if (CondVersion.empty() || CondVersion <= AvailabilityStack.back()) - return TraverseStmt(If->getThen()) && TraverseStmt(If->getElse()); - } else { + ExtractedAvailabilityExpr IfCond = extractAvailabilityExpr(If->getCond()); + if (!IfCond.E) { // This isn't an availability checking 'if', we can just continue. return Base::TraverseIfStmt(If); } + VersionTuple CondVersion = IfCond.E->getVersion(); + // If we're using the '*' case here or if this check is redundant, then we + // use the enclosing version to check both branches. + if (CondVersion.empty() || CondVersion <= AvailabilityStack.back()) { +return TraverseStmt(If->getThen()) && TraverseStmt(If->getElse()); + } + + auto *Guarded = If->getThen(); + auto *Unguarded = If->getElse(); + if (IfCond.isNegated) { +std::swap(Guarded, Unguarded); + } + AvailabilityStack.push_back(CondVersion); - bool ShouldContinue = TraverseStmt(If->getThen()); + bool ShouldContinue = TraverseStmt(Guarded); AvailabilityStack.pop_back(); - return ShouldContinue && TraverseStmt(If->getElse()); + return ShouldContinue && TraverseStmt(Unguarded); } } // end anonymous namespace diff --git a/clang/test/Sema/attr-availability.c b/clang/test/Sema/attr-availability.c index a5cc602a8fa9d4..a496c5271f2a3d 100644 --- a/clang/test/Sema/attr-availability.c +++ b/clang/test/Sema/attr-availability.c @@ -40,7 +40,7 @@ void test_10095131(void) { #ifdef WARN_PARTIAL // FIXME: This note should point to the declaration with the availability // attribute. -// expected-note@+2 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}} +// expected-note@+2 5 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}} #endif extern void PartiallyAvailable(void) ; void with_redeclaration(void) { @@ -53,6 +53,29 @@ void with_redeclaration(void) { enum PartialEnum p = kPartialEnumConstant; } +#ifdef WARN_PARTIAL +void conditional_warnings() { + if (__builtin_available(macos 10.8, *)) { +PartiallyAvailable(); + } else { +PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}} + } + if (!__builtin_available(macos 10.8, *)) { +PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}} + } else { +PartiallyAvailable(); + } + if (!!!(!__builtin_available(macos 10.8, *))) { +PartiallyAvailable(); + } else { +PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}} + } + if (~__builtin_available(macos
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
AmrDeveloper wrote: > > This part in ObjectiveC tests conflict with the current solution, any > > suggestion how we can go around it right now until to be handled later > > https://github.com/llvm/llvm-project/blob/18952bdcd6f987620e6396261c2bb444e428e07e/clang/test/SemaObjCXX/noescape.mm#L202-L205 > > > > @erichkeane @AaronBallman > > Doesn't the fixme above that say it was diagnosing unintentionally? If so, > that fixme likely needs to be removed, and this is 'correct' now. Yes but still got `call to deleted constructor of 'S6'` and `'S6' has been explicitly marked deleted here` errors on CI and local https://github.com/llvm/llvm-project/pull/111573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase { SourceLocation *ArgLocation = nullptr); /// Determine if type T is a valid subject for a nonnull and similar - /// attributes. By default, we look through references (the behavior used by - /// nonnull), but if the second parameter is true, then we treat a reference - /// type as valid. + /// attributes. We skip dependence By default, we look through references AmrDeveloper wrote: Yes, i think i was planning to make it like `We skip dependence and By default,` https://github.com/llvm/llvm-project/pull/111573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
https://github.com/AmrDeveloper edited https://github.com/llvm/llvm-project/pull/111573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
https://github.com/AmrDeveloper edited https://github.com/llvm/llvm-project/pull/111573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -18901,6 +18901,160 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL farzonl wrote: This comment seems old and maybe should be moved to line 18921. SPIRV implementation is on 18952. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -18901,6 +18901,160 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdouble: { + +assert((E->getArg(0)->getType()->hasFloatingRepresentation() && +E->getArg(1)->getType()->hasUnsignedIntegerRepresentation() && +E->getArg(2)->getType()->hasUnsignedIntegerRepresentation()) && + "asuint operands types mismatch"); +Value *Op0 = EmitScalarExpr(E->getArg(0)); +const auto *OutArg1 = dyn_cast(E->getArg(1)); +const auto *OutArg2 = dyn_cast(E->getArg(2)); + +CallArgList Args; +auto [Op1BaseLValue, Op1TmpLValue] = +EmitHLSLOutArgExpr(OutArg1, Args, OutArg1->getType()); +auto [Op2BaseLValue, Op2TmpLValue] = +EmitHLSLOutArgExpr(OutArg2, Args, OutArg2->getType()); + +if (CGM.getTarget().getTriple().isDXIL()) { + + llvm::StructType *RetType = nullptr; + + if (Op0->getType()->isVectorTy()) { +auto *Op0VecTy = E->getArg(0)->getType()->getAs(); + +llvm::VectorType *i32VecTy = llvm::VectorType::get( +Int32Ty, ElementCount::getFixed(Op0VecTy->getNumElements())); +RetType = llvm::StructType::get(i32VecTy, i32VecTy); + } else { +RetType = llvm::StructType::get(Int32Ty, Int32Ty); + } + + CallInst *CI = + Builder.CreateIntrinsic(RetType, Intrinsic::dx_splitdouble, {Op0}, + nullptr, "hlsl.splitdouble"); + + Value *Arg0 = Builder.CreateExtractValue(CI, 0); + Value *Arg1 = Builder.CreateExtractValue(CI, 1); + + Builder.CreateStore(Arg0, Op1TmpLValue.getAddress()); + auto *s = Builder.CreateStore(Arg1, Op2TmpLValue.getAddress()); + + EmitWritebacks(*this, Args); + return s; +} + +assert(!CGM.getTarget().getTriple().isDXIL() && farzonl wrote: This assert will always be true. line 18921 conditional doesn't have any fall through cases. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang should have a warning to disallow re-externs (PR #109714)
jchcrsp wrote: Ping fixed merge conflict https://github.com/llvm/llvm-project/pull/109714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/111573 >From 3e83fd9e73520bfeefd5a39da6daad172cfb2512 Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Tue, 8 Oct 2024 20:12:45 +0200 Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent return type --- clang/include/clang/Sema/Sema.h| 6 +++--- clang/lib/Sema/SemaDeclAttr.cpp| 7 --- clang/test/SemaCXX/alloc-align-attr.cpp| 3 +++ clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++ clang/test/SemaCXX/noescape-attr.cpp | 7 +++ clang/test/SemaObjCXX/noescape.mm | 2 +- 6 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 clang/test/SemaCXX/noescape-attr.cpp diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 7ff9c2754a6fe0..d0f8d4b417f2c6 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4453,9 +4453,9 @@ class Sema final : public SemaBase { SourceLocation *ArgLocation = nullptr); /// Determine if type T is a valid subject for a nonnull and similar - /// attributes. By default, we look through references (the behavior used by - /// nonnull), but if the second parameter is true, then we treat a reference - /// type as valid. + /// attributes. We skip dependence then By default, we look through references + /// (the behavior used by nonnull), but if the second parameter is true, then + /// we treat a reference type as valid.. bool isValidPointerAttrType(QualType T, bool RefOkay = false); /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index af983349a89b58..e2174ba926f17f 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) { } bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) { + if (T->isDependentType()) +return true; if (RefOkay) { if (T->isReferenceType()) return true; @@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { for (unsigned I = 0, E = getFunctionOrMethodNumParams(D); I != E && !AnyPointers; ++I) { QualType T = getFunctionOrMethodParamType(D, I); - if (T->isDependentType() || S.isValidPointerAttrType(T)) + if (S.isValidPointerAttrType(T)) AnyPointers = true; } @@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, AllocAlignAttr TmpAttr(Context, CI, ParamIdx()); SourceLocation AttrLoc = CI.getLoc(); - if (!ResultType->isDependentType() && - !isValidPointerAttrType(ResultType, /* RefOkay */ true)) { + if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) { Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only) << &TmpAttr << CI.getRange() << getFunctionOrMethodResultSourceRange(D); return; diff --git a/clang/test/SemaCXX/alloc-align-attr.cpp b/clang/test/SemaCXX/alloc-align-attr.cpp index 79095f8d985147..5a40e8d8fb6b56 100644 --- a/clang/test/SemaCXX/alloc-align-attr.cpp +++ b/clang/test/SemaCXX/alloc-align-attr.cpp @@ -23,6 +23,9 @@ void* dependent_param_func(T param) __attribute__((alloc_align(1)));// expected- template void* illegal_align_param(int p) __attribute__((alloc_align(T))); // expected-error {{'alloc_align' attribute requires parameter 1 to be an integer constant}} +template +T dependent_return_type(int p) __attribute__((alloc_align(1))); + void dependent_impl(int align) { dependent_ret a; // expected-note {{in instantiation of template class 'dependent_ret' requested here}} a.Foo(1); diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp index 61b85557d6b294..e709c936735c74 100644 --- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp +++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp @@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // expected-error {{requeste template T *atest4() __attribute__((assume_aligned(32, o))); +template +T atest5(int) __attribute__((assume_aligned(2))); + +// expected-warning@+1 {{'assume_aligned' attribute only applies to return values that are pointers or references}} +int atest6(int) __attribute__((assume_aligned(2))); + void test22() { atest3(); atest4(); diff --git a/clang/test/SemaCXX/noescape-attr.cpp b/clang/test/SemaCXX/noescape-attr.cpp new file mode 100644 index 00..78dc4f07ffef87 --- /dev/null +++ b/clang/test/SemaCXX/noescape-attr.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template +void test1(T __attribute__((noescape)) arr, int size); + +// expected-warning@+1 {{'noescape' attribute only applie
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
@@ -18901,6 +18901,160 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdouble: { + +assert((E->getArg(0)->getType()->hasFloatingRepresentation() && +E->getArg(1)->getType()->hasUnsignedIntegerRepresentation() && +E->getArg(2)->getType()->hasUnsignedIntegerRepresentation()) && + "asuint operands types mismatch"); +Value *Op0 = EmitScalarExpr(E->getArg(0)); +const auto *OutArg1 = dyn_cast(E->getArg(1)); +const auto *OutArg2 = dyn_cast(E->getArg(2)); + +CallArgList Args; +auto [Op1BaseLValue, Op1TmpLValue] = +EmitHLSLOutArgExpr(OutArg1, Args, OutArg1->getType()); +auto [Op2BaseLValue, Op2TmpLValue] = +EmitHLSLOutArgExpr(OutArg2, Args, OutArg2->getType()); + +if (CGM.getTarget().getTriple().isDXIL()) { + + llvm::StructType *RetType = nullptr; + + if (Op0->getType()->isVectorTy()) { +auto *Op0VecTy = E->getArg(0)->getType()->getAs(); + +llvm::VectorType *i32VecTy = llvm::VectorType::get( +Int32Ty, ElementCount::getFixed(Op0VecTy->getNumElements())); +RetType = llvm::StructType::get(i32VecTy, i32VecTy); + } else { +RetType = llvm::StructType::get(Int32Ty, Int32Ty); + } + + CallInst *CI = + Builder.CreateIntrinsic(RetType, Intrinsic::dx_splitdouble, {Op0}, + nullptr, "hlsl.splitdouble"); + + Value *Arg0 = Builder.CreateExtractValue(CI, 0); + Value *Arg1 = Builder.CreateExtractValue(CI, 1); + + Builder.CreateStore(Arg0, Op1TmpLValue.getAddress()); + auto *s = Builder.CreateStore(Arg1, Op2TmpLValue.getAddress()); + + EmitWritebacks(*this, Args); + return s; +} + +assert(!CGM.getTarget().getTriple().isDXIL() && + "For non-DXIL targets we generate the instructions"); + +if (!Op0->getType()->isVectorTy()) { + FixedVectorType *DestTy = FixedVectorType::get(Int32Ty, 2); + Value *Bitcast = Builder.CreateBitCast(Op0, DestTy); + + Value *Arg0 = Builder.CreateExtractElement(Bitcast, 0.0); + Value *Arg1 = Builder.CreateExtractElement(Bitcast, 1.0); + + Builder.CreateStore(Arg0, Op1TmpLValue.getAddress()); + auto *s = Builder.CreateStore(Arg1, Op2TmpLValue.getAddress()); + + EmitWritebacks(*this, Args); + return s; +} + +auto emitVectorCode = +[](Value *Op, CGBuilderTy *Builder, + FixedVectorType *DestTy) -> std::pair { + Value *bitcast = Builder->CreateBitCast(Op, DestTy); + + SmallVector LowbitsIndex; + SmallVector HighbitsIndex; + + for (unsigned int idx = 0; idx < DestTy->getNumElements(); idx += 2) { farzonl wrote: The clang style is for variables to be capital. so this would be `Idx`. The line above would be `EmitVectorCode`. https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding splitdouble HLSL function (PR #109331)
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/109331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Reland: [clang] Finish implementation of P0522 (PR #111711)
https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/111711 This finishes the clang implementation of P0522, getting rid of the fallback to the old, pre-P0522 rules. Before this patch, when partial ordering template template parameters, we would perform, in order: * If the old rules would match, we would accept it. Otherwise, don't generate diagnostics yet. * If the new rules would match, just accept it. Otherwise, don't generate any diagnostics yet again. * Apply the old rules again, this time with diagnostics. This situation was far from ideal, as we would sometimes: * Accept some things we shouldn't. * Reject some things we shouldn't. * Only diagnose rejection in terms of the old rules. With this patch, we apply the P0522 rules throughout. This needed to extend template argument deduction in order to accept the historial rule for TTP matching pack parameter to non-pack arguments. This change also makes us accept some combinations of historical and P0522 allowances we wouldn't before. It also fixes a bunch of bugs that were documented in the test suite, which I am not sure there are issues already created for them. This causes a lot of changes to the way these failures are diagnosed, with related test suite churn. The problem here is that the old rules were very simple and non-recursive, making it easy to provide customized diagnostics, and to keep them consistent with each other. The new rules are a lot more complex and rely on template argument deduction, substitutions, and they are recursive. The approach taken here is to mostly rely on existing diagnostics, and create a new instantiation context that keeps track of this context. So for example when a substitution failure occurs, we use the error produced there unmodified, and just attach notes to it explaining that it occurred in the context of partial ordering this template argument against that template parameter. This diverges from the old diagnostics, which would lead with an error pointing to the template argument, explain the problem in subsequent notes, and produce a final note pointing to the parameter. >From 439394d9d61f4642ee000674aebbf37ef7f4cab6 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 17 Jun 2024 21:39:08 -0300 Subject: [PATCH] [clang] Finish implementation of P0522 This finishes the clang implementation of P0522, getting rid of the fallback to the old, pre-P0522 rules. Before this patch, when partial ordering template template parameters, we would perform, in order: * If the old rules would match, we would accept it. Otherwise, don't generate diagnostics yet. * If the new rules would match, just accept it. Otherwise, don't generate any diagnostics yet again. * Apply the old rules again, this time with diagnostics. This situation was far from ideal, as we would sometimes: * Accept some things we shouldn't. * Reject some things we shouldn't. * Only diagnose rejection in terms of the old rules. With this patch, we apply the P0522 rules throughout. This needed to extend template argument deduction in order to accept the historial rule for TTP matching pack parameter to non-pack arguments. This change also makes us accept some combinations of historical and P0522 allowances we wouldn't before. It also fixes a bunch of bugs that were documented in the test suite, which I am not sure there are issues already created for them. This causes a lot of changes to the way these failures are diagnosed, with related test suite churn. The problem here is that the old rules were very simple and non-recursive, making it easy to provide customized diagnostics, and to keep them consistent with each other. The new rules are a lot more complex and rely on template argument deduction, substitutions, and they are recursive. The approach taken here is to mostly rely on existing diagnostics, and create a new instantiation context that keeps track of this context. So for example when a substitution failure occurs, we use the error produced there unmodified, and just attach notes to it explaining that it occurred in the context of partial ordering this template argument against that template parameter. This diverges from the old diagnostics, which would lead with an error pointing to the template argument, explain the problem in subsequent notes, and produce a final note pointing to the parameter. --- clang/docs/ReleaseNotes.rst | 10 + .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Sema/Sema.h | 14 +- clang/lib/Frontend/FrontendActions.cpp| 2 + clang/lib/Sema/SemaTemplate.cpp | 94 ++--- clang/lib/Sema/SemaTemplateDeduction.cpp | 353 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 15 + .../temp/temp.arg/temp.arg.template/p3-0x.cpp | 31 +- clang/test/CXX/temp/temp.param/p12.cpp| 21 +- clang/test/Modules/cxx-templates.cpp | 15 +- clang/tes
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/111573 >From d3f853895e806ebe2370dafdc628a21d0d4184a6 Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Tue, 8 Oct 2024 20:12:45 +0200 Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent return type --- clang/include/clang/Sema/Sema.h| 6 +++--- clang/lib/Sema/SemaDeclAttr.cpp| 7 --- clang/test/SemaCXX/alloc-align-attr.cpp| 3 +++ clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++ clang/test/SemaCXX/noescape-attr.cpp | 7 +++ clang/test/SemaObjCXX/noescape.mm | 7 +++ 6 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 clang/test/SemaCXX/noescape-attr.cpp diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 7ff9c2754a6fe0..d0f8d4b417f2c6 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4453,9 +4453,9 @@ class Sema final : public SemaBase { SourceLocation *ArgLocation = nullptr); /// Determine if type T is a valid subject for a nonnull and similar - /// attributes. By default, we look through references (the behavior used by - /// nonnull), but if the second parameter is true, then we treat a reference - /// type as valid. + /// attributes. We skip dependence then By default, we look through references + /// (the behavior used by nonnull), but if the second parameter is true, then + /// we treat a reference type as valid.. bool isValidPointerAttrType(QualType T, bool RefOkay = false); /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index af983349a89b58..e2174ba926f17f 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) { } bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) { + if (T->isDependentType()) +return true; if (RefOkay) { if (T->isReferenceType()) return true; @@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { for (unsigned I = 0, E = getFunctionOrMethodNumParams(D); I != E && !AnyPointers; ++I) { QualType T = getFunctionOrMethodParamType(D, I); - if (T->isDependentType() || S.isValidPointerAttrType(T)) + if (S.isValidPointerAttrType(T)) AnyPointers = true; } @@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, AllocAlignAttr TmpAttr(Context, CI, ParamIdx()); SourceLocation AttrLoc = CI.getLoc(); - if (!ResultType->isDependentType() && - !isValidPointerAttrType(ResultType, /* RefOkay */ true)) { + if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) { Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only) << &TmpAttr << CI.getRange() << getFunctionOrMethodResultSourceRange(D); return; diff --git a/clang/test/SemaCXX/alloc-align-attr.cpp b/clang/test/SemaCXX/alloc-align-attr.cpp index 79095f8d985147..5a40e8d8fb6b56 100644 --- a/clang/test/SemaCXX/alloc-align-attr.cpp +++ b/clang/test/SemaCXX/alloc-align-attr.cpp @@ -23,6 +23,9 @@ void* dependent_param_func(T param) __attribute__((alloc_align(1)));// expected- template void* illegal_align_param(int p) __attribute__((alloc_align(T))); // expected-error {{'alloc_align' attribute requires parameter 1 to be an integer constant}} +template +T dependent_return_type(int p) __attribute__((alloc_align(1))); + void dependent_impl(int align) { dependent_ret a; // expected-note {{in instantiation of template class 'dependent_ret' requested here}} a.Foo(1); diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp index 61b85557d6b294..e709c936735c74 100644 --- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp +++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp @@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // expected-error {{requeste template T *atest4() __attribute__((assume_aligned(32, o))); +template +T atest5(int) __attribute__((assume_aligned(2))); + +// expected-warning@+1 {{'assume_aligned' attribute only applies to return values that are pointers or references}} +int atest6(int) __attribute__((assume_aligned(2))); + void test22() { atest3(); atest4(); diff --git a/clang/test/SemaCXX/noescape-attr.cpp b/clang/test/SemaCXX/noescape-attr.cpp new file mode 100644 index 00..78dc4f07ffef87 --- /dev/null +++ b/clang/test/SemaCXX/noescape-attr.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template +void test1(T __attribute__((noescape)) arr, int size); + +// expected-warning@+1 {{'noescape' attribute only
[clang] [llvm] Update llvm::Registry to work for LLVM shared library builds on windows (PR #109024)
fsfod wrote: > These changes LGTM but precommit CI was unable to run, so it would be nice if > that could be re-run to ensure it comes back green before landing. It won't be able to pass until https://github.com/llvm/llvm-project/pull/108276 is merged. https://github.com/llvm/llvm-project/pull/109024 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Modernize FuchsiaHandleChecker (PR #111588)
https://github.com/pskrgag edited https://github.com/llvm/llvm-project/pull/111588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Add Smrnmi extension (PR #111668)
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v Author: None (dong-miao) Changes This commit has completed the Extension for Resumable Non Maskable Interrupts, adding four CRSs and one Trap-Return instruction. Specification link:["Smrnmi" Extension](https://github.com/riscv/riscv-isa-manual/blob/main/src/rnmi.adoc) --- Full diff: https://github.com/llvm/llvm-project/pull/111668.diff 11 Files Affected: - (modified) clang/test/Preprocessor/riscv-target-features.c (+9) - (modified) llvm/docs/RISCVUsage.rst (+1) - (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+4) - (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+9) - (modified) llvm/lib/Target/RISCV/RISCVSystemOperands.td (+8) - (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) - (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) - (modified) llvm/test/MC/RISCV/machine-csr-names.s (+60) - (modified) llvm/test/MC/RISCV/priv-invalid.s (+2) - (modified) llvm/test/MC/RISCV/priv-valid.s (+4) - (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) ``diff diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index 05a8534ba13da1..9e986f0143aefa 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -30,6 +30,7 @@ // CHECK-NOT: __riscv_smcdeleg {{.*$}} // CHECK-NOT: __riscv_smcsrind {{.*$}} // CHECK-NOT: __riscv_smepmp {{.*$}} +// CHECK-NOT: __riscv_smrnmi {{.*$}} // CHECK-NOT: __riscv_smstateen {{.*$}} // CHECK-NOT: __riscv_ssaia {{.*$}} // CHECK-NOT: __riscv_ssccfg {{.*$}} @@ -1449,6 +1450,14 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-SMEPMP-EXT %s // CHECK-SMEPMP-EXT: __riscv_smepmp 100{{$}} +// RUN: %clang --target=riscv32 \ +// RUN: -march=rv32ismrnmi1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-SMRNMI-EXT %s +// RUN: %clang --target=riscv64 \ +// RUN: -march=rv64ismrnmi1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-SMRNMI-EXT %s +// CHECK-SMRNMI-EXT: __riscv_smrnmi 100{{$}} + // RUN: %clang --target=riscv32-unknown-linux-gnu \ // RUN: -march=rv32izfa -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZFA-EXT %s diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst index 5736f3807f131b..a7ea36191283a3 100644 --- a/llvm/docs/RISCVUsage.rst +++ b/llvm/docs/RISCVUsage.rst @@ -129,6 +129,7 @@ on support follow. ``Smcdeleg`` Supported ``Smcsrind`` Supported ``Smepmp``Supported + ``Smrnmi``Supported ``Smstateen`` Assembly Support ``Ssaia`` Supported ``Ssccfg``Supported diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 3d0e1dae801d39..10b18e33f2abb2 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -931,6 +931,10 @@ def FeatureStdExtSmepmp : RISCVExtension<"smepmp", 1, 0, "'Smepmp' (Enhanced Physical Memory Protection)">; +def FeatureStdExtSmrnmi +: RISCVExtension<"smrnmi", 1, 0, + "'Smrnmi' (Extension for Resumable Non-Maskable Interrupts)">; + def FeatureStdExtSmcdeleg : RISCVExtension<"smcdeleg", 1, 0, "'Smcdeleg' (Counter Delegation Machine Level)">; diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td index 5d329dceac6519..485fe386187c53 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -66,6 +66,8 @@ def riscv_sret_glue : SDNode<"RISCVISD::SRET_GLUE", SDTNone, [SDNPHasChain, SDNPOptInGlue]>; def riscv_mret_glue : SDNode<"RISCVISD::MRET_GLUE", SDTNone, [SDNPHasChain, SDNPOptInGlue]>; +def riscv_mnret_glue : SDNode<"RISCVISD::MNRET_GLUE", SDTNone, + [SDNPHasChain, SDNPOptInGlue]>; def riscv_selectcc : SDNode<"RISCVISD::SELECT_CC", SDT_RISCVSelectCC>; def riscv_brcc : SDNode<"RISCVISD::BR_CC", SDT_RISCVBrCC, [SDNPHasChain]>; @@ -813,6 +815,12 @@ def MRET : Priv<"mret", 0b0011000>, Sched<[]> { let rs1 = 0; let rs2 = 0b00010; } + +def MNRET : Priv<"mnret", 0b0111000>, Sched<[]> { + let rd = 0; + let rs1 = 0; + let rs2 = 0b00010; +} } // isBarrier = 1, isReturn = 1, isTerminator = 1 def WFI : Priv<"wfi", 0b0001000>, Sched<[]> { @@ -1581,6 +1589,7 @@ def : Pat<(riscv_call texternalsym:$func), (PseudoCALL texternalsym:$func)>; def : Pat<(riscv_sret_glue), (SRET)>; def : Pat<(riscv_mret_glue), (MRET)>; +def : Pat<(riscv_mnret_glue), (MNRET)>; let isCall = 1, Defs = [X1] in { let Predicates = [NoStdExtZicfilp] in diff --git a/llvm/lib/Target/RISCV/RISCVSystemOperands.td b/llvm/lib/Target/RISCV/RISCVSystemOperands.td index d85b4a9cf77b33..faec8d0b5bc003 100644 --- a/llvm/lib/Target/RISCV/RISCVSys
[clang] Reland: [clang] Finish implementation of P0522 (PR #111711)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-modules Author: Matheus Izvekov (mizvekov) Changes This finishes the clang implementation of P0522, getting rid of the fallback to the old, pre-P0522 rules. Before this patch, when partial ordering template template parameters, we would perform, in order: * If the old rules would match, we would accept it. Otherwise, don't generate diagnostics yet. * If the new rules would match, just accept it. Otherwise, don't generate any diagnostics yet again. * Apply the old rules again, this time with diagnostics. This situation was far from ideal, as we would sometimes: * Accept some things we shouldn't. * Reject some things we shouldn't. * Only diagnose rejection in terms of the old rules. With this patch, we apply the P0522 rules throughout. This needed to extend template argument deduction in order to accept the historial rule for TTP matching pack parameter to non-pack arguments. This change also makes us accept some combinations of historical and P0522 allowances we wouldn't before. It also fixes a bunch of bugs that were documented in the test suite, which I am not sure there are issues already created for them. This causes a lot of changes to the way these failures are diagnosed, with related test suite churn. The problem here is that the old rules were very simple and non-recursive, making it easy to provide customized diagnostics, and to keep them consistent with each other. The new rules are a lot more complex and rely on template argument deduction, substitutions, and they are recursive. The approach taken here is to mostly rely on existing diagnostics, and create a new instantiation context that keeps track of this context. So for example when a substitution failure occurs, we use the error produced there unmodified, and just attach notes to it explaining that it occurred in the context of partial ordering this template argument against that template parameter. This diverges from the old diagnostics, which would lead with an error pointing to the template argument, explain the problem in subsequent notes, and produce a final note pointing to the parameter. --- Patch is 73.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/111711.diff 17 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+10) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+7) - (modified) clang/include/clang/Sema/Sema.h (+12-2) - (modified) clang/lib/Frontend/FrontendActions.cpp (+2) - (modified) clang/lib/Sema/SemaTemplate.cpp (+38-56) - (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+250-103) - (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+15) - (modified) clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp (+18-13) - (modified) clang/test/CXX/temp/temp.param/p12.cpp (+11-10) - (modified) clang/test/Modules/cxx-templates.cpp (+3-12) - (modified) clang/test/SemaCXX/make_integer_seq.cpp (+2-3) - (modified) clang/test/SemaTemplate/cwg2398.cpp (+156-4) - (modified) clang/test/SemaTemplate/temp_arg_nontype.cpp (+18-8) - (modified) clang/test/SemaTemplate/temp_arg_template.cpp (+23-15) - (modified) clang/test/SemaTemplate/temp_arg_template_p0522.cpp (+52-30) - (modified) clang/test/Templight/templight-empty-entries-fix.cpp (+12) - (modified) clang/test/Templight/templight-prior-template-arg.cpp (+23-10) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a4bb303a2bc42b..7270e6898dbc7f 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -174,6 +174,10 @@ C++23 Feature Support C++20 Feature Support ^ +C++17 Feature Support +^ +- The implementation of the relaxed template template argument matching rules is + more complete and reliable, and should provide more accurate diagnostics. Resolutions to C++ Defect Reports ^ @@ -331,6 +335,10 @@ Improvements to Clang's diagnostics - Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391. +- Clang now properly explains the reason a template template argument failed to + match a template template parameter, in terms of the C++17 relaxed matching rules + instead of the old ones. + - Don't emit duplicated dangling diagnostics. (#GH93386). - Improved diagnostic when trying to befriend a concept. (#GH45182). @@ -440,6 +448,8 @@ Bug Fixes to C++ Support - Correctly check constraints of explicit instantiations of member functions. (#GH46029) - When performing partial ordering of function templates, clang now checks that the deduction was consistent. Fixes (#GH18291). +- Fixes to several issues in partial ordering of template template parameters, which + were documented in the test suite. - Fixed an assertion failure about a constraint of a friend function template refer
[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)
AmrDeveloper wrote: > > This part in ObjectiveC tests conflict with the current solution, any > > suggestion how we can go around it right now until to be handled later > > https://github.com/llvm/llvm-project/blob/18952bdcd6f987620e6396261c2bb444e428e07e/clang/test/SemaObjCXX/noescape.mm#L202-L205 > > > > @erichkeane @AaronBallman > > Doesn't the fixme above that say it was diagnosing unintentionally? If so, > that fixme likely needs to be removed, and this is 'correct' now. I handled it, i didn't know that `// expected-note n` is the number of expected notes, Thank you https://github.com/llvm/llvm-project/pull/111573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Create bugprone-bitwise-pointer-cast check (PR #108083)
Carlos =?utf-8?q?Gálvez?= Message-ID: In-Reply-To: llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-s390x-linux-multistage` running on `systemz-1` while building `clang-tools-extra` at step 5 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/98/builds/478 Here is the relevant piece of the build log for the reference ``` Step 5 (ninja check 1) failure: stage 1 checked (failure) TEST 'libFuzzer-s390x-default-Linux :: fuzzer-timeout.test' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 1: /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest + /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest RUN: at line 2: /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest + /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest RUN: at line 3: not /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 2>&1 | FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=TimeoutTest + not /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 + FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=TimeoutTest RUN: at line 12: not /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/hi.txt 2>&1 | FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=SingleInputTimeoutTest + not /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/hi.txt + FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=SingleInputTimeoutTest RUN: at line 16: /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 -timeout_exitcode=0 + /home/uweigand/sandb
[clang] [NvlinkWrapper] Use `-plugin-opt=mattr=` instead of a custom feature (PR #111712)
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/111712 Summary: We don't need a custom flag for this, LLVM had a way to get the features which are forwarded via `plugin-opt`. >From 6135a70a45801783a770252e765773905f18313d Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Wed, 9 Oct 2024 11:42:55 -0500 Subject: [PATCH] [NvlinkWrapper] Use `-plugin-opt=mattr=` instead of a custom feature Summary: We don't need a custom flag for this, LLVM had a way to get the features which are forwarded via `plugin-opt`. --- clang/lib/Driver/ToolChains/Cuda.cpp| 4 ++-- clang/test/Driver/cuda-cross-compiling.c| 2 +- clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp | 2 +- clang/tools/clang-nvlink-wrapper/NVLinkOpts.td | 3 --- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index 509cd87b28c37e..dfcd20a73f1d54 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -632,8 +632,8 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA, std::vector Features; getNVPTXTargetFeatures(C.getDriver(), getToolChain().getTriple(), Args, Features); - for (StringRef Feature : Features) -CmdArgs.append({"--feature", Args.MakeArgString(Feature)}); + CmdArgs.push_back( + Args.MakeArgString("--plugin-opt=mattr=" + llvm::join(Features, ","))); // Add paths for the default clang library path. SmallString<256> DefaultLibPath = diff --git a/clang/test/Driver/cuda-cross-compiling.c b/clang/test/Driver/cuda-cross-compiling.c index 5f24e7a5accb08..54c291fac66ffd 100644 --- a/clang/test/Driver/cuda-cross-compiling.c +++ b/clang/test/Driver/cuda-cross-compiling.c @@ -104,4 +104,4 @@ // RUN: %clang -target nvptx64-nvidia-cuda --cuda-feature=+ptx63 -march=sm_52 -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=FEATURE %s -// FEATURE: clang-nvlink-wrapper{{.*}}"--feature" "+ptx63" +// FEATURE: clang-nvlink-wrapper{{.*}}"--plugin-opt=mattr=+ptx63" diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp index b4b376fe0d114e..b9767a7a03d0b5 100644 --- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp +++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp @@ -344,7 +344,7 @@ Expected> createLTO(const ArgList &Args) { Conf.RemarksHotnessThreshold = RemarksHotnessThreshold; Conf.RemarksFormat = RemarksFormat; - Conf.MAttrs = {Args.getLastArgValue(OPT_feature, "").str()}; + Conf.MAttrs = llvm::codegen::getMAttrs(); std::optional CGOptLevelOrNone = CodeGenOpt::parseLevel(Args.getLastArgValue(OPT_O, "2")[0]); assert(CGOptLevelOrNone && "Invalid optimization level"); diff --git a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td index eeb9d1a6228240..a80c5937b42992 100644 --- a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td +++ b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td @@ -47,9 +47,6 @@ def arch : Separate<["--", "-"], "arch">, def : Joined<["--", "-"], "plugin-opt=mcpu=">, Flags<[HelpHidden, WrapperOnlyOption]>, Alias; -def feature : Separate<["--", "-"], "feature">, Flags<[WrapperOnlyOption]>, - HelpText<"Specify the '+ptx' freature to use for LTO.">; - def g : Flag<["-"], "g">, HelpText<"Specify that this was a debug compile.">; def debug : Flag<["--"], "debug">, Alias; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CGData][ThinLTO] Global Outlining with Two-CodeGen Rounds (PR #90933)
@@ -1513,6 +1522,171 @@ class InProcessThinBackend : public ThinBackendProc { return Error::success(); } }; + +/// This backend is utilized in the first round of a two-codegen round process. +/// It first saves optimized bitcode files to disk before the codegen process +/// begins. After codegen, it stores the resulting object files in a scratch +/// buffer. Note the codegen data stored in the scratch buffer will be extracted +/// and merged in the subsequent step. +class FirstRoundThinBackend : public InProcessThinBackend { + AddStreamFn IRAddStream; + FileCache IRCache; + +public: + FirstRoundThinBackend( + const Config &Conf, ModuleSummaryIndex &CombinedIndex, + ThreadPoolStrategy ThinLTOParallelism, + const DenseMap &ModuleToDefinedGVSummaries, + AddStreamFn CGAddStream, FileCache CGCache, AddStreamFn IRAddStream, + FileCache IRCache) + : InProcessThinBackend(Conf, CombinedIndex, ThinLTOParallelism, + ModuleToDefinedGVSummaries, std::move(CGAddStream), + std::move(CGCache), /*OnWrite=*/nullptr, + /*ShouldEmitIndexFiles=*/false, + /*ShouldEmitImportsFiles=*/false), +IRAddStream(std::move(IRAddStream)), IRCache(std::move(IRCache)) {} + + Error runThinLTOBackendThread( + AddStreamFn CGAddStream, FileCache CGCache, unsigned Task, + BitcodeModule BM, ModuleSummaryIndex &CombinedIndex, + const FunctionImporter::ImportMapTy &ImportList, + const FunctionImporter::ExportSetTy &ExportList, + const std::map &ResolvedODR, + const GVSummaryMapTy &DefinedGlobals, + MapVector &ModuleMap) override { +auto RunThinBackend = [&](AddStreamFn CGAddStream, + AddStreamFn IRAddStream) { + LTOLLVMContext BackendContext(Conf); + Expected> MOrErr = BM.parseModule(BackendContext); + if (!MOrErr) +return MOrErr.takeError(); + + return thinBackend(Conf, Task, CGAddStream, **MOrErr, CombinedIndex, + ImportList, DefinedGlobals, &ModuleMap, + Conf.CodeGenOnly, IRAddStream); +}; + +auto ModuleID = BM.getModuleIdentifier(); +// Like InProcessThinBackend, we produce index files as needed for +// FirstRoundThinBackend. However, these files are not generated for +// SecondRoundThinBackend. +if (ShouldEmitIndexFiles) { + if (auto E = emitFiles(ImportList, ModuleID, ModuleID.str())) +return E; +} + +assert((CGCache.isValid() == IRCache.isValid()) && + "Both caches for CG and IR should have matching availability"); +if (!CGCache.isValid() || !CombinedIndex.modulePaths().count(ModuleID) || +all_of(CombinedIndex.getModuleHash(ModuleID), + [](uint32_t V) { return V == 0; })) + // Cache disabled or no entry for this module in the combined index or + // no module hash. + return RunThinBackend(CGAddStream, IRAddStream); + +// Get CGKey for caching object in CGCache. +std::string CGKey = computeLTOCacheKey( +Conf, CombinedIndex, ModuleID, ImportList, ExportList, ResolvedODR, +DefinedGlobals, CfiFunctionDefs, CfiFunctionDecls); +Expected CacheCGAddStreamOrErr = +CGCache(Task, CGKey, ModuleID); +if (Error Err = CacheCGAddStreamOrErr.takeError()) + return Err; +AddStreamFn &CacheCGAddStream = *CacheCGAddStreamOrErr; + +// Get IRKey for caching (optimized) IR in IRCache with an extra ID. +std::string IRKey = computeLTOCacheKey( +Conf, CombinedIndex, ModuleID, ImportList, ExportList, ResolvedODR, +DefinedGlobals, CfiFunctionDefs, CfiFunctionDecls, /*ExtraID=*/"IR"); +Expected CacheIRAddStreamOrErr = +IRCache(Task, IRKey, ModuleID); +if (Error Err = CacheIRAddStreamOrErr.takeError()) + return Err; +AddStreamFn &CacheIRAddStream = *CacheIRAddStreamOrErr; + +assert((CacheCGAddStream == nullptr) == (CacheIRAddStream == nullptr) && + "Both CG and IR caching should be matched"); +if (CacheIRAddStream) { + LLVM_DEBUG(dbgs() << "[FirstRound] Cache Miss for " +<< BM.getModuleIdentifier() << "\n"); + return RunThinBackend(CacheCGAddStream, CacheIRAddStream); +} + +return Error::success(); + } +}; + +/// This backend operates in the second round of a two-codegen round process. +/// It starts by reading the optimized bitcode files that were saved during the +/// first round. The backend then executes the codegen only to further optimize +/// the code, utilizing the codegen data merged from the first round. Finally, +/// it writes the resulting object files as usual. +class SecondRoundThinBackend : public InProcessThinBackend { + std::unique_ptr> IRFiles; + stable_hash CombinedCGDataHash; + +public: + SecondRoundThinBackend( + const Config &Conf, ModuleSummaryIndex &CombinedIndex, +
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
@@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,NATIVE_HALF \ +// RUN: -DFNATTRS=noundef -DTARGET=dx +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \ +// RUN: -DFNATTRS=noundef -DTARGET=dx +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ +// RUN: --check-prefixes=CHECK,NATIVE_HALF \ +// RUN: -DFNATTRS="spir_func noundef" -DTARGET=spv +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \ +// RUN: -DFNATTRS="spir_func noundef" -DTARGET=spv pow2clk wrote: I have a personal vendetta against `-x hlsl` as it's unnecessary and it bullied me in high school. https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected pow2clk wrote: I'll copy my comment from elsewhere here: Are you getting unexpected diagnostics? If so, I'd like to understand them. If not, I don't think `-verify-ignore-unexpected` is needed. If anything, we should limit it to the type of diagnostic that is being produced e.g. `-verify-ignore-unexpected=note` https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
@@ -0,0 +1,68 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "GLSL.std.450" + +; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 +; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 +; CHECK-DAG: %[[#float_64:]] = OpTypeFloat 64 + +; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 +; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 +; CHECK-DAG: %[[#vec4_float_64:]] = OpTypeVector %[[#float_64]] 4 + +define noundef float @degrees_float(float noundef %a) { +entry: pow2clk wrote: It's not essential, but separating these with some `CHECK-LABEL`s for the function definitions even if they are nothing more than `; CHECK: define{{.*}} degrees_float` would help with potential future failures particularly if the only initial information is an automated testing failure. https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
@@ -0,0 +1,54 @@ +; RUN: opt -S -dxil-intrinsic-expansion -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s + +; Make sure dxil op function calls for degrees are expanded and lowered as fmul for float and half. + +define noundef half @degrees_half(half noundef %a) { +; CHECK-LABEL: define noundef half @degrees_half( +; CHECK-SAME: half noundef [[A:%.*]]) { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT:[[DX_DEGREES1:%.*]] = fmul half [[A]], 0xH5329 +; CHECK-NEXT:ret half [[DX_DEGREES1]] +; +entry: + %dx.degrees = call half @llvm.dx.degrees.f16(half %a) + ret half %dx.degrees +} + +define noundef float @degrees_float(float noundef %a) #0 { +; CHECK-LABEL: define noundef float @degrees_float( +; CHECK-SAME: float noundef [[A:%.*]]) { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT:[[DX_DEGREES1:%.*]] = fmul float [[A]], 0x404CA5DC2000 +; CHECK-NEXT:ret float [[DX_DEGREES1]] +; +entry: + %dx.degrees = call float @llvm.dx.degrees.f32(float %a) + ret float %dx.degrees +} + +define noundef <4 x float> @degrees_float4(<4 x float> noundef %a) #0 { +; CHECK-LABEL: define noundef <4 x float> @degrees_float4( +; CHECK-SAME: <4 x float> noundef [[A:%.*]]) { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT:[[A_I0:%.*]] = extractelement <4 x float> [[A]], i64 0 +; CHECK-NEXT:[[DOTI04:%.*]] = fmul float [[A_I0]], 0x404CA5DC2000 +; CHECK-NEXT:[[A_I1:%.*]] = extractelement <4 x float> [[A]], i64 1 +; CHECK-NEXT:[[DOTI13:%.*]] = fmul float [[A_I1]], 0x404CA5DC2000 +; CHECK-NEXT:[[A_I2:%.*]] = extractelement <4 x float> [[A]], i64 2 +; CHECK-NEXT:[[DOTI22:%.*]] = fmul float [[A_I2]], 0x404CA5DC2000 +; CHECK-NEXT:[[A_I3:%.*]] = extractelement <4 x float> [[A]], i64 3 +; CHECK-NEXT:[[DOTI31:%.*]] = fmul float [[A_I3]], 0x404CA5DC2000 +; CHECK-NEXT:[[DOTUPTO0:%.*]] = insertelement <4 x float> poison, float [[DOTI04]], i64 0 +; CHECK-NEXT:[[DOTUPTO1:%.*]] = insertelement <4 x float> [[DOTUPTO0]], float [[DOTI13]], i64 1 +; CHECK-NEXT:[[DOTUPTO2:%.*]] = insertelement <4 x float> [[DOTUPTO1]], float [[DOTI22]], i64 2 +; CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x float> [[DOTUPTO2]], float [[DOTI31]], i64 3 pow2clk wrote: I don't know what any of these DOTI## variables refer to. It's not harmful, just confusing to read. https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
https://github.com/pow2clk commented: None of my suggestions are essential, but I'll give you a chance to consider them even if you reject them all before I approve. https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Implement the `degrees` intrinsic (PR #111209)
@@ -0,0 +1,54 @@ +; RUN: opt -S -dxil-intrinsic-expansion -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s + +; Make sure dxil op function calls for degrees are expanded and lowered as fmul for float and half. + +define noundef half @degrees_half(half noundef %a) { +; CHECK-LABEL: define noundef half @degrees_half( +; CHECK-SAME: half noundef [[A:%.*]]) { +; CHECK-NEXT: [[ENTRY:.*:]] pow2clk wrote: I see a similar issue with the existing tests that this may have used as a template, but this check and the corresponding checks below do nothing except accept a line that can really only be `entry:`. It accepts anything ending in `:` and saves it to a variable that is never used. I wonder if perhaps it was the result of an overzealous search and replace at one point. ```suggestion ; CHECK-NEXT: entry: ``` https://github.com/llvm/llvm-project/pull/111209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits