[clang] [clang][Interp] Fix discarded integral and floating casts (PR #77295)

2024-01-10 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/77295
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix behavior of `__is_trivially_relocatable(volatile int)` (PR #77092)

2024-01-10 Thread via cfe-commits

cor3ntin wrote:

@erichkeane @AaronBallman 

https://github.com/llvm/llvm-project/pull/77092
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8f78dd4 - [clang][analyzer] Add function 'ungetc' to StreamChecker. (#77331)

2024-01-10 Thread via cfe-commits

Author: Balázs Kéri
Date: 2024-01-10T09:09:51+01:00
New Revision: 8f78dd4b92b44c490d263a4d161850853874859d

URL: 
https://github.com/llvm/llvm-project/commit/8f78dd4b92b44c490d263a4d161850853874859d
DIFF: 
https://github.com/llvm/llvm-project/commit/8f78dd4b92b44c490d263a4d161850853874859d.diff

LOG: [clang][analyzer] Add function 'ungetc' to StreamChecker. (#77331)

`StdLibraryFunctionsChecker` is updated too with `ungetc`.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
clang/test/Analysis/Inputs/system-header-simulator.h
clang/test/Analysis/stream-error.c
clang/test/Analysis/stream-noopen.c
clang/test/Analysis/stream.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 15479906d22bdd..20872f7ddb81e9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1202,8 +1202,9 @@ Improvements
   (`c3a87ddad62a 
`_,
   `0954dc3fb921 
`_)
 
-- Improved the ``alpha.unix.Stream`` checker by modeling more functions like,
-  ``fflush``, ``fputs``, ``fgetc``, ``fputc``, ``fopen``, ``fdopen``, 
``fgets``, ``tmpfile``.
+- Improved the ``alpha.unix.Stream`` checker by modeling more functions
+  ``fputs``, ``fputc``, ``fgets``, ``fgetc``, ``fdopen``, ``ungetc``, 
``fflush``
+  and no not recognize alternative ``fopen`` and ``tmpfile`` implementations.
   (`#76776 `_,
   `#74296 `_,
   `#73335 `_,
@@ -1211,7 +1212,8 @@ Improvements
   `#71518 `_,
   `#72016 `_,
   `#70540 `_,
-  `#73638 `_)
+  `#73638 `_,
+  `#77331 `_)
 
 - The ``alpha.security.taint.TaintPropagation`` checker no longer propagates
   taint on ``strlen`` and ``strnlen`` calls, unless these are marked

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 034825d88a44de..32a2deab871c79 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2201,6 +2201,25 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   ErrnoNEZeroIrrelevant, GenericFailureMsg)
 .ArgConstraint(NotNull(ArgNo(0;
 
+// int ungetc(int c, FILE *stream);
+addToFunctionSummaryMap(
+"ungetc", Signature(ArgTypes{IntTy, FilePtrTy}, RetType{IntTy}),
+Summary(NoEvalCall)
+.Case({ReturnValueCondition(BO_EQ, ArgNo(0)),
+   ArgumentCondition(0, WithinRange, {{0, UCharRangeMax}})},
+  ErrnoMustNotBeChecked, GenericSuccessMsg)
+.Case({ReturnValueCondition(WithinRange, SingleValue(EOFv)),
+   ArgumentCondition(0, WithinRange, {{EOFv, EOFv}})},
+  ErrnoNEZeroIrrelevant,
+  "Assuming that 'ungetc' fails because EOF was passed as "
+  "character")
+.Case({ReturnValueCondition(WithinRange, SingleValue(EOFv)),
+   ArgumentCondition(0, WithinRange, {{0, UCharRangeMax}})},
+  ErrnoNEZeroIrrelevant, GenericFailureMsg)
+.ArgConstraint(ArgumentCondition(
+0, WithinRange, {{EOFv, EOFv}, {0, UCharRangeMax}}))
+.ArgConstraint(NotNull(ArgNo(1;
+
 // int fseek(FILE *stream, long offset, int whence);
 // FIXME: It can be possible to get the 'SEEK_' values (like EOFv) and use
 // these for condition of arg 2.

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 25da3c18e8519f..fbfa101257d5e1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -263,6 +263,9 @@ class StreamChecker : public Checker(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  const StreamState *OldSS = State->get(StreamSym);
+  if (!OldSS)
+return;
+
+  assertStreamStateOpened(OldSS);
+
+  // Generate a transition for the success state.
+  std::optional PutVal = Call.getArgSVal(0).getAs();
+  if (!PutVal)
+return;
+  ProgramStateRef StateNotFailed =
+  State->BindExpr(CE, C.getLocationContext(), *PutVal);
+  StateNotFailed

[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-10 Thread Balázs Kéri via cfe-commits

https://github.com/balazske closed 
https://github.com/llvm/llvm-project/pull/77331
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-10 Thread Owen Pan via cfe-commits

owenca wrote:

Relanded as b53628a52d19. (See 
[here](https://github.com/llvm/llvm-project/commit/42ec976184acd40436acd7104ad715c60ca3e7ed#commitcomment-136674701)).

https://github.com/llvm/llvm-project/pull/76733
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f443fbc - [Flang][OpenMP][MLIR] Add support for -nogpulib option (#71045)

2024-01-10 Thread via cfe-commits

Author: Dominik Adamski
Date: 2024-01-10T09:38:58+01:00
New Revision: f443fbc49b8914a8453de61aea741221df9648cf

URL: 
https://github.com/llvm/llvm-project/commit/f443fbc49b8914a8453de61aea741221df9648cf
DIFF: 
https://github.com/llvm/llvm-project/commit/f443fbc49b8914a8453de61aea741221df9648cf.diff

LOG: [Flang][OpenMP][MLIR] Add support for -nogpulib option (#71045)

If -nogpulib option is passed by the user, then the OpenMP device
runtime is not used and we should not emit globals to configure
debugging at compile-time for the device runtime.

Link to -nogpulib flag implementation for Clang:
https://reviews.llvm.org/D125314

Added: 
flang/test/Lower/OpenMP/nogpulib.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/LangOptions.def
flang/include/flang/Tools/CrossToolHelpers.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/tools/bbc/bbc.cpp
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Dialect/OpenMP/attr.mlir
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 84648c6d550081..a76e8dcff148bb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5197,7 +5197,7 @@ def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, 
Group,
   HelpText<"Do not include the default HIP wrapper headers and include paths">;
 def : Flag<["-"], "nocudainc">, Alias;
 def nogpulib : Flag<["-"], "nogpulib">, 
MarshallingInfoFlag>,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Do not link device library for CUDA/HIP device compilation">;
 def : Flag<["-"], "nocudalib">, Alias;
 def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, 
FlangOption, FC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 41eaad3bbad0a3..5d2fc6cb028e2a 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -428,6 +428,8 @@ void Flang::addOffloadOptions(Compilation &C, const 
InputInfoList &Inputs,
   CmdArgs.push_back("-fopenmp-assume-no-thread-state");
 if (Args.hasArg(options::OPT_fopenmp_assume_no_nested_parallelism))
   CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism");
+if (Args.hasArg(options::OPT_nogpulib))
+  CmdArgs.push_back("-nogpulib");
   }
 }
 

diff  --git a/flang/include/flang/Frontend/LangOptions.def 
b/flang/include/flang/Frontend/LangOptions.def
index 3a1d44f7fb472d..2bf10826120a8b 100644
--- a/flang/include/flang/Frontend/LangOptions.def
+++ b/flang/include/flang/Frontend/LangOptions.def
@@ -21,6 +21,8 @@ LANGOPT(Name, Bits, Default)
 
 ENUM_LANGOPT(FPContractMode, FPModeKind, 2, FPM_Fast) ///< FP Contract Mode 
(off/fast)
 
+/// Indicate a build without the standard GPU libraries.
+LANGOPT(NoGPULib  , 1, false)
 /// Permit floating point optimization without regard to infinities
 LANGOPT(NoHonorInfs, 1, false)
 /// Permit floating point optimization without regard to NaN

diff  --git a/flang/include/flang/Tools/CrossToolHelpers.h 
b/flang/include/flang/Tools/CrossToolHelpers.h
index b346b30b158aec..b61224ff4f1b3c 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -56,14 +56,16 @@ struct OffloadModuleOpts {
   OffloadModuleOpts(uint32_t OpenMPTargetDebug, bool OpenMPTeamSubscription,
   bool OpenMPThreadSubscription, bool OpenMPNoThreadState,
   bool OpenMPNoNestedParallelism, bool OpenMPIsTargetDevice,
-  bool OpenMPIsGPU, uint32_t OpenMPVersion, std::string OMPHostIRFile = {})
+  bool OpenMPIsGPU, uint32_t OpenMPVersion, std::string OMPHostIRFile = {},
+  bool NoGPULib = false)
   : OpenMPTargetDebug(OpenMPTargetDebug),
 OpenMPTeamSubscription(OpenMPTeamSubscription),
 OpenMPThreadSubscription(OpenMPThreadSubscription),
 OpenMPNoThreadState(OpenMPNoThreadState),
 OpenMPNoNestedParallelism(OpenMPNoNestedParallelism),
 OpenMPIsTargetDevice(OpenMPIsTargetDevice), OpenMPIsGPU(OpenMPIsGPU),
-OpenMPVersion(OpenMPVersion), OMPHostIRFile(OMPHostIRFile) {}
+OpenMPVersion(OpenMPVersion), OMPHostIRFile(OMPHostIRFile),
+NoGPULib(NoGPULib) {}
 
   OffloadModuleOpts(Fortran::frontend::LangOptions &Opts)
   : OpenMPTargetDebug(Opts.OpenMPTargetDebug),
@@ -73,7 +75,7 @@ struct OffloadModuleOpts {
 OpenMPNoNestedParallelism(Opts.OpenMPNoNestedParallelism),
 OpenMPIsTargetDevice(Opts.OpenMPIsTargetDevice),

[flang] [mlir] [clang] [Flang][OpenMP][MLIR] Add support for -nogpulib option (PR #71045)

2024-01-10 Thread Dominik Adamski via cfe-commits

https://github.com/DominikAdamski closed 
https://github.com/llvm/llvm-project/pull/71045
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [Clang][RISCV] Move getVScaleRange logic into libLLVMFrontendDriver. NFC (PR #77327)

2024-01-10 Thread Luke Lau via cfe-commits


@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Support
   TargetParser
   FrontendOpenMP
+  FrontendDriver

lukel97 wrote:

I agree. I think I'm coming around to the opinion that this is a bit overkill 
just to avoid duplicating 16 lines of code.

I'm also thinking that flang and clang don't need to behave exactly the same in 
this regard. So we don't necessarily need to keep the two in sync. Thoughts? cc 
@tschuett 

https://github.com/llvm/llvm-project/pull/77327
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][RISCV] Move getVScaleRange logic into libLLVMFrontendDriver. NFC (PR #77327)

2024-01-10 Thread Thorsten Schütt via cfe-commits


@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Support
   TargetParser
   FrontendOpenMP
+  FrontendDriver

tschuett wrote:

I would prefer putting it into FrontendDriver for style and as a precedence to 
encourage others to put more into the frontend.

https://github.com/llvm/llvm-project/pull/77327
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][RISCV] Move getVScaleRange logic into libLLVMFrontendDriver. NFC (PR #77327)

2024-01-10 Thread Luke Lau via cfe-commits


@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Support
   TargetParser
   FrontendOpenMP
+  FrontendDriver

lukel97 wrote:

I think the issue with llvmFrontendDriver specifically is that this code 
wouldn't be called from any of the drivers, it would be called from clangBasic 
and flangFrontend respectively. Could we create something like 
llvmFrontendSupport or similar?

https://github.com/llvm/llvm-project/pull/77327
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for CWG1800-1804 (PR #77509)

2024-01-10 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/77509
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d0918a2 - [clang] Add tests for CWG1800-1804 (#77509)

2024-01-10 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-01-10T12:51:04+04:00
New Revision: d0918a20d2a85bad3cd0ec48be4b91e873bfe737

URL: 
https://github.com/llvm/llvm-project/commit/d0918a20d2a85bad3cd0ec48be4b91e873bfe737
DIFF: 
https://github.com/llvm/llvm-project/commit/d0918a20d2a85bad3cd0ec48be4b91e873bfe737.diff

LOG: [clang] Add tests for CWG1800-1804 (#77509)

Covers C++ core issues 1800, 1801, 1802, 1803, 1804.

Added: 


Modified: 
clang/test/CXX/drs/dr18xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..1d76804907a5c1 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,16 +1,169 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-14,cxx98 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-14,cxx11-17,since-cxx11 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx17,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus == 199711L
 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
 // cxx98-error@-1 {{variadic macros are a C99 feature}}
 #endif
 
+namespace dr1800 { // dr1800: 2.9
+struct A { union { int n; }; };
+static_assert(__is_same(__decltype(&A::n), int A::*), "");
+} // namespace dr1800
+
+namespace dr1801 { // dr1801: 2.8
+static union {
+  int i;
+};
+
+template  struct S {}; // #dr1801-S
+S V; // #dr1801-S-i
+// cxx98-14-error@-1 {{non-type template argument does not refer to any 
declaration}}
+//   cxx98-14-note@#dr1801-S {{template parameter is declared here}}
+// since-cxx17-error@#dr1801-S-i {{non-type template argument refers to 
subobject '.i'}}
+}
+
+namespace dr1802 { // dr1802: 3.1
+#if __cplusplus >= 201103L
+// Using a Wikipedia example of surrogate pair:
+// https://en.wikipedia.org/wiki/UTF-16#Examples
+constexpr char16_t a[3] = u"\U00010437";
+static_assert(a[0] == 0xD801, "");
+static_assert(a[1] == 0xDC37, "");
+static_assert(a[2] == 0x0, "");
+#endif
+} // namespace dr1802
+
+namespace dr1803 { // dr1803: 2.9
+#if __cplusplus >= 201103L
+struct A {
+  enum E : int;
+  enum E : int {};
+  enum class EC;
+  enum class EC {};
+  enum struct ES;
+  enum struct ES {};
+};
+#endif
+} // namespace dr1803
+
+namespace dr1804 { // dr1804: 2.7
+template 
+struct A {
+  void f1();
+  
+  template 
+  void f2(V);
+
+  class B {
+void f3();
+  };
+
+  template 
+  class C {
+void f4();
+  };
+};
+
+template 
+struct A {
+  void f1();
+  
+  template 
+  voi

[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-01-10 Thread via cfe-commits

https://github.com/NorthBlue333 updated 
https://github.com/llvm/llvm-project/pull/77456

>From 8081b93a021b24c5310bc9a08d00f0d07f1bbfa1 Mon Sep 17 00:00:00 2001
From: NorthBlue333 
Date: Tue, 9 Jan 2024 14:01:14 +0100
Subject: [PATCH] [clang-format] Do not update cursor pos if no includes
 replacement

---
 clang/lib/Format/Format.cpp | 13 +++
 clang/unittests/Format/SortIncludesTest.cpp | 24 +
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f798d555bf9929..2bc336e046aa94 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3119,6 +3119,7 @@ static void sortCppIncludes(const FormatStyle &Style,
 return;
   }
 
+  unsigned NewCursor = UINT_MAX;
   std::string result;
   for (unsigned Index : Indices) {
 if (!result.empty()) {
@@ -3131,13 +3132,10 @@ static void sortCppIncludes(const FormatStyle &Style,
 }
 result += Includes[Index].Text;
 if (Cursor && CursorIndex == Index)
-  *Cursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
+  NewCursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
 CurrentCategory = Includes[Index].Category;
   }
 
-  if (Cursor && *Cursor >= IncludesEndOffset)
-*Cursor += result.size() - IncludesBlockSize;
-
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire range of blocks. Otherwise, no replacement is generated.
   if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
@@ -3145,6 +3143,13 @@ static void sortCppIncludes(const FormatStyle &Style,
 return;
   }
 
+  if (Cursor) {
+if (UINT_MAX != NewCursor)
+  *Cursor = NewCursor;
+else if (*Cursor >= IncludesEndOffset)
+  *Cursor += result.size() - IncludesBlockSize;
+  }
+
   auto Err = Replaces.add(tooling::Replacement(
   FileName, Includes.front().Offset, IncludesBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
diff --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index ec142e03b12854..480da513a47fcb 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -821,6 +821,30 @@ TEST_F(SortIncludesTest, 
CalculatesCorrectCursorPositionWithRegrouping) {
   EXPECT_EQ(27u, newCursor(Code, 28)); // Start of last line
 }
 
+TEST_F(SortIncludesTest, CalculatesCorrectCursorPositionWithRegrouping) {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  FmtStyle.LineEnding = FormatStyle::CRLF;
+  Style.IncludeCategories = {
+  {"^\"aa\"", 1, 0, false},
+  {"^\"b\"", 1, 1, false}
+  {".*", 2, 2, false}};
+  std::string Code = "#include \"aa\"\r\n" // Start of line: 0
+ "\r\n"// Start of line: 15
+ "#include \"b\"\r\n"  // Start of line: 17
+ "\r\n"// Start of line: 31
+ "#include \"c\"\r\n"  // Start of line: 33
+ "\r\n"// Start of line: 47
+ "int i;"; // Start of line: 49
+  EXPECT_EQ(Code, sort(Code));
+  EXPECT_EQ(0u, newCursor(Code, 0));
+  EXPECT_EQ(15u, newCursor(Code, 15));
+  EXPECT_EQ(17u, newCursor(Code, 17));
+  EXPECT_EQ(31u, newCursor(Code, 31));
+  EXPECT_EQ(33u, newCursor(Code, 33));
+  EXPECT_EQ(47u, newCursor(Code, 47));
+  EXPECT_EQ(49u, newCursor(Code, 49));
+}
+
 TEST_F(SortIncludesTest, DeduplicateIncludes) {
   EXPECT_EQ("#include \n"
 "#include \n"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs (PR #76777)

2024-01-10 Thread Jim Lin via cfe-commits


@@ -386,6 +393,11 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   if (llvm::is_contained(Features, "+experimental"))
 HasExperimental = true;
 
+  if (ABI == "ilp32e" && ISAInfo->hasExtension("d")) {
+Diags.Report(diag::err_invalid_feature_combination)
+<< "ILP32E cannot be used with the D ISA extension";
+return false;
+  }

tclin914 wrote:

Does it also need to check ilp32e isn't compatible with zcmp?

https://github.com/llvm/llvm-project/pull/76777
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][coverage] fixing "if constexpr" and "if consteval" coverage report (PR #77214)

2024-01-10 Thread via cfe-commits
Hana =?utf-8?q?Dusi=CC=81kova=CC=81?= 
Message-ID:
In-Reply-To: 


cor3ntin wrote:

Oups, can you rebase?

https://github.com/llvm/llvm-project/pull/77214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c69ec70 - [clang-format][NFC] Don't use clang-format style in config files

2024-01-10 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2024-01-10T00:58:35-08:00
New Revision: c69ec700adec315b3daa55742f2ef655242fa297

URL: 
https://github.com/llvm/llvm-project/commit/c69ec700adec315b3daa55742f2ef655242fa297
DIFF: 
https://github.com/llvm/llvm-project/commit/c69ec700adec315b3daa55742f2ef655242fa297.diff

LOG: [clang-format][NFC] Don't use clang-format style in config files

The current CI doesn't use the latest clang-format and fails most
clang-format patches on the code formatting check. This patch
temporarily removes the clang-format style from the .clang-format
files.

Added: 


Modified: 
clang/include/clang/Format/.clang-format
clang/lib/Format/.clang-format
clang/tools/clang-format/.clang-format
clang/unittests/Format/.clang-format

Removed: 




diff  --git a/clang/include/clang/Format/.clang-format 
b/clang/include/clang/Format/.clang-format
index d7331b3c8cf02e..f95602cab0f7fc 100644
--- a/clang/include/clang/Format/.clang-format
+++ b/clang/include/clang/Format/.clang-format
@@ -1 +1,6 @@
-BasedOnStyle: clang-format
+BasedOnStyle: LLVM
+InsertBraces: true
+InsertNewlineAtEOF: true
+LineEnding: LF
+RemoveBracesLLVM: true
+RemoveParentheses: ReturnStatement

diff  --git a/clang/lib/Format/.clang-format b/clang/lib/Format/.clang-format
index d7331b3c8cf02e..f95602cab0f7fc 100644
--- a/clang/lib/Format/.clang-format
+++ b/clang/lib/Format/.clang-format
@@ -1 +1,6 @@
-BasedOnStyle: clang-format
+BasedOnStyle: LLVM
+InsertBraces: true
+InsertNewlineAtEOF: true
+LineEnding: LF
+RemoveBracesLLVM: true
+RemoveParentheses: ReturnStatement

diff  --git a/clang/tools/clang-format/.clang-format 
b/clang/tools/clang-format/.clang-format
index d7331b3c8cf02e..f95602cab0f7fc 100644
--- a/clang/tools/clang-format/.clang-format
+++ b/clang/tools/clang-format/.clang-format
@@ -1 +1,6 @@
-BasedOnStyle: clang-format
+BasedOnStyle: LLVM
+InsertBraces: true
+InsertNewlineAtEOF: true
+LineEnding: LF
+RemoveBracesLLVM: true
+RemoveParentheses: ReturnStatement

diff  --git a/clang/unittests/Format/.clang-format 
b/clang/unittests/Format/.clang-format
index d7331b3c8cf02e..f95602cab0f7fc 100644
--- a/clang/unittests/Format/.clang-format
+++ b/clang/unittests/Format/.clang-format
@@ -1 +1,6 @@
-BasedOnStyle: clang-format
+BasedOnStyle: LLVM
+InsertBraces: true
+InsertNewlineAtEOF: true
+LineEnding: LF
+RemoveBracesLLVM: true
+RemoveParentheses: ReturnStatement



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs (PR #76777)

2024-01-10 Thread Wang Pengcheng via cfe-commits


@@ -386,6 +393,11 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   if (llvm::is_contained(Features, "+experimental"))
 HasExperimental = true;
 
+  if (ABI == "ilp32e" && ISAInfo->hasExtension("d")) {
+Diags.Report(diag::err_invalid_feature_combination)
+<< "ILP32E cannot be used with the D ISA extension";
+return false;
+  }

wangpc-pp wrote:

Yes, I think we should!
(Sigh...even RISC-V International has forgotten RVE, as many new ISA extensions 
don't even think about impacts on RVE 😞).

https://github.com/llvm/llvm-project/pull/76777
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][coverage] fixing "if constexpr" and "if consteval" coverage report (PR #77214)

2024-01-10 Thread Hana Dusíková via cfe-commits

https://github.com/hanickadot updated 
https://github.com/llvm/llvm-project/pull/77214

From 766df92436569a924ef1c3860b3e1019c2048b53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hana=20Dusi=CC=81kova=CC=81?= 
Date: Wed, 10 Jan 2024 10:00:31 +0100
Subject: [PATCH] [coverage] fix incorrect coverage reporting for "if
 constexpr" and "if consteval"

---
 clang/docs/ReleaseNotes.rst  |   3 +
 clang/include/clang/AST/Stmt.h   |   6 +-
 clang/lib/CodeGen/CoverageMappingGen.cpp |  13 ++-
 clang/lib/Sema/TreeTransform.h   |  13 ++-
 clang/test/CoverageMapping/if.cpp| 108 +++
 5 files changed, 121 insertions(+), 22 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 20872f7ddb81e9..37f8bbc89d8949 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -705,6 +705,9 @@ Bug Fixes in This Version
 - Fix assertion crash due to failed scope restoring caused by too-early VarDecl
   invalidation by invalid initializer Expr.
   Fixes (`#30908 `_)
+- Clang now emits correct source location for code-coverage regions in `if 
constexpr`
+  and `if consteval` branches.
+  Fixes (`#54419 `_)
 
 
 Bug Fixes to Compiler Builtins
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index da7b37ce0e1211..e1fde24e647789 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -1631,8 +1631,10 @@ class CompoundStmt final
   SourceLocation RB);
 
   // Build an empty compound statement with a location.
-  explicit CompoundStmt(SourceLocation Loc)
-  : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(Loc) {
+  explicit CompoundStmt(SourceLocation Loc) : CompoundStmt(Loc, Loc) {}
+
+  CompoundStmt(SourceLocation Loc, SourceLocation EndLoc)
+  : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(EndLoc) {
 CompoundStmtBits.NumStmts = 0;
 CompoundStmtBits.HasFPFeatures = 0;
   }
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index bf227386a71b78..b245abd16c3f4a 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1712,7 +1712,11 @@ struct CounterCoverageMappingBuilder
   extendRegion(S->getCond());
 
 Counter ParentCount = getRegion().getCounter();
-Counter ThenCount = getRegionCounter(S);
+
+// If this is "if !consteval" the then-branch will never be taken, we don't
+// need to change counter
+Counter ThenCount =
+S->isNegatedConsteval() ? ParentCount : getRegionCounter(S);
 
 if (!S->isConsteval()) {
   // Emitting a counter for the condition makes it easier to interpret the
@@ -1729,7 +1733,12 @@ struct CounterCoverageMappingBuilder
 extendRegion(S->getThen());
 Counter OutCount = propagateCounts(ThenCount, S->getThen());
 
-Counter ElseCount = subtractCounters(ParentCount, ThenCount);
+// If this is "if consteval" the else-branch will never be taken, we don't
+// need to change counter
+Counter ElseCount = S->isNonNegatedConsteval()
+? ParentCount
+: subtractCounters(ParentCount, ThenCount);
+
 if (const Stmt *Else = S->getElse()) {
   bool ThenHasTerminateStmt = HasTerminateStmt;
   HasTerminateStmt = false;
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index e7a6550b1c993c..1a1bc87d2b3203 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7739,7 +7739,11 @@ TreeTransform::TransformIfStmt(IfStmt *S) {
 if (Then.isInvalid())
   return StmtError();
   } else {
-Then = new (getSema().Context) NullStmt(S->getThen()->getBeginLoc());
+// Discarded branch is replaced with empty CompoundStmt so we can keep
+// proper source location for start and end of original branch, so
+// subsequent transformations like CoverageMapping work properly
+Then = new (getSema().Context)
+CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
   }
 
   // Transform the "else" branch.
@@ -7748,6 +7752,13 @@ TreeTransform::TransformIfStmt(IfStmt *S) {
 Else = getDerived().TransformStmt(S->getElse());
 if (Else.isInvalid())
   return StmtError();
+  } else if (S->getElse() && ConstexprConditionValue &&
+ *ConstexprConditionValue) {
+// Same thing here as with  branch, we are discarding it, we can't
+// replace it with NULL nor NullStmt as we need to keep for source location
+// range, for CoverageMapping
+Else = new (getSema().Context)
+CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
   }
 
   if (!getDerived().AlwaysRebuild() &&
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 65e3d62df79db4..92d560be01

[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)

2024-01-10 Thread Carl Peto via cfe-commits

carlos4242 wrote:

Sure thing @benshi001 ... I'll create tests. The Swift ABI is documented here: 
https://github.com/apple/swift/blob/main/docs/ABI/CallingConvention.rst

I don't think this change will actually change any ABI. All my code uses the 
normal avr-gcc ABI you referenced.

I'll work out the details with the Apple engineers on a PR in their LLVM fork. 
Once we've got it in a state everyone is happy with, I'll bring it back here. 
That way nothing is blocked and we can take the time we need. Thank you.

https://github.com/llvm/llvm-project/pull/72298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CMake] Deprecate GCC_INSTALL_PREFIX (PR #77537)

2024-01-10 Thread via cfe-commits

zmodem wrote:

Seems okay to me, but it would be good to include an update to the release 
notes, which ideally shows an example of what replacing the cmake flag with a 
config file would look like.

https://github.com/llvm/llvm-project/pull/77537
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs (PR #76777)

2024-01-10 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp edited 
https://github.com/llvm/llvm-project/pull/76777
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-01-10 Thread via cfe-commits

https://github.com/NorthBlue333 updated 
https://github.com/llvm/llvm-project/pull/77456

>From 04258b4ee42e29ec160b7fa4992dd1ad63db77dc Mon Sep 17 00:00:00 2001
From: NorthBlue333 
Date: Tue, 9 Jan 2024 14:01:14 +0100
Subject: [PATCH] [clang-format] Do not update cursor pos if no includes
 replacement

---
 clang/lib/Format/Format.cpp | 13 +++
 clang/unittests/Format/SortIncludesTest.cpp | 24 +
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f798d555bf9929..2bc336e046aa94 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3119,6 +3119,7 @@ static void sortCppIncludes(const FormatStyle &Style,
 return;
   }
 
+  unsigned NewCursor = UINT_MAX;
   std::string result;
   for (unsigned Index : Indices) {
 if (!result.empty()) {
@@ -3131,13 +3132,10 @@ static void sortCppIncludes(const FormatStyle &Style,
 }
 result += Includes[Index].Text;
 if (Cursor && CursorIndex == Index)
-  *Cursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
+  NewCursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
 CurrentCategory = Includes[Index].Category;
   }
 
-  if (Cursor && *Cursor >= IncludesEndOffset)
-*Cursor += result.size() - IncludesBlockSize;
-
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire range of blocks. Otherwise, no replacement is generated.
   if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
@@ -3145,6 +3143,13 @@ static void sortCppIncludes(const FormatStyle &Style,
 return;
   }
 
+  if (Cursor) {
+if (UINT_MAX != NewCursor)
+  *Cursor = NewCursor;
+else if (*Cursor >= IncludesEndOffset)
+  *Cursor += result.size() - IncludesBlockSize;
+  }
+
   auto Err = Replaces.add(tooling::Replacement(
   FileName, Includes.front().Offset, IncludesBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
diff --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index ec142e03b12854..e1fc92bb829246 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -821,6 +821,30 @@ TEST_F(SortIncludesTest, 
CalculatesCorrectCursorPositionWithRegrouping) {
   EXPECT_EQ(27u, newCursor(Code, 28)); // Start of last line
 }
 
+TEST_F(SortIncludesTest, 
CalculatesCorrectCursorPositionWhenNoReplacementsWithRegroupingAndCRLF) {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  FmtStyle.LineEnding = FormatStyle::CRLF;
+  Style.IncludeCategories = {
+  {"^\"aa\"", 1, 0, false},
+  {"^\"b\"", 1, 1, false}
+  {".*", 2, 2, false}};
+  std::string Code = "#include \"aa\"\r\n" // Start of line: 0
+ "\r\n"// Start of line: 15
+ "#include \"b\"\r\n"  // Start of line: 17
+ "\r\n"// Start of line: 31
+ "#include \"c\"\r\n"  // Start of line: 33
+ "\r\n"// Start of line: 47
+ "int i;"; // Start of line: 49
+  EXPECT_EQ(Code, sort(Code));
+  EXPECT_EQ(0u, newCursor(Code, 0));
+  EXPECT_EQ(15u, newCursor(Code, 15));
+  EXPECT_EQ(17u, newCursor(Code, 17));
+  EXPECT_EQ(31u, newCursor(Code, 31));
+  EXPECT_EQ(33u, newCursor(Code, 33));
+  EXPECT_EQ(47u, newCursor(Code, 47));
+  EXPECT_EQ(49u, newCursor(Code, 49));
+}
+
 TEST_F(SortIncludesTest, DeduplicateIncludes) {
   EXPECT_EQ("#include \n"
 "#include \n"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-01-10 Thread via cfe-commits

NorthBlue333 wrote:

The change is done 👍 
Is the code formatting check broken?

https://github.com/llvm/llvm-project/pull/77456
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [flang] [clang-tools-extra] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2024-01-10 Thread via cfe-commits

https://github.com/jeanPerier approved this pull request.

Thanks for the updates @yi-wu-arm, LGTM

https://github.com/llvm/llvm-project/pull/74077
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] be320fd - [libunwind] Convert a few options from CACHE PATH to CACHE STRING (#77534)

2024-01-10 Thread via cfe-commits

Author: Martin Storsjö
Date: 2024-01-10T11:25:17+02:00
New Revision: be320fdf7ba9a94f6970f433ec1402cdc5cfe6b1

URL: 
https://github.com/llvm/llvm-project/commit/be320fdf7ba9a94f6970f433ec1402cdc5cfe6b1
DIFF: 
https://github.com/llvm/llvm-project/commit/be320fdf7ba9a94f6970f433ec1402cdc5cfe6b1.diff

LOG: [libunwind] Convert a few options from CACHE PATH to CACHE STRING (#77534)

This applies the same change as in
760261a3daf98882ccbd177e3133fb4a058f47ad (where they were applied to
libcxxabi and libcxx) to libunwind as well.

These options can reasonably be set either as an absolute or relative
path, but if set as type PATH, they are rewritten from relative into
absolute relative to the build directory, while the relative form is
intended to be relative to the install prefix.

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 248e888619e40b..bb1b052f61d875 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -105,9 +105,9 @@ set(CMAKE_MODULE_PATH
 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
 ${CMAKE_MODULE_PATH})
 
-set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH
+set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE STRING
 "Path where built libunwind headers should be installed.")
-set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
+set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
 "Path where built libunwind runtime libraries should be installed.")
 
 set(LIBUNWIND_SHARED_OUTPUT_NAME "unwind" CACHE STRING "Output name for the 
shared libunwind runtime library.")
@@ -115,7 +115,7 @@ set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind" CACHE STRING 
"Output name for the stat
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
   set(LIBUNWIND_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-  set(LIBUNWIND_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
+  set(LIBUNWIND_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE STRING
   "Path where built libunwind libraries should be installed.")
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})
@@ -127,7 +127,7 @@ else()
   else()
 set(LIBUNWIND_LIBRARY_DIR 
${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX})
   endif()
-  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH
+  set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE STRING
   "Path where built libunwind libraries should be installed.")
 endif()
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind] Convert a few options from CACHE PATH to CACHE STRING (PR #77534)

2024-01-10 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo closed 
https://github.com/llvm/llvm-project/pull/77534
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [Driver] Treat MuslEABIHF as a hardfloat environment wrt multiarch directories (PR #77536)

2024-01-10 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> `bool isEABIHF` from clang/lib/CodeGen/Targets/ARM.cpp can probably be 
> factored.

Yep - any suggestion on where we could move it? Up to the `Triple` class?

https://github.com/llvm/llvm-project/pull/77536
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 65a56a2 - [clang] [Driver] Treat MuslEABIHF as a hardfloat environment wrt multiarch directories (#77536)

2024-01-10 Thread via cfe-commits

Author: Martin Storsjö
Date: 2024-01-10T11:27:46+02:00
New Revision: 65a56a29b6ad3d9df43df1c5a1238b1f870f24f9

URL: 
https://github.com/llvm/llvm-project/commit/65a56a29b6ad3d9df43df1c5a1238b1f870f24f9
DIFF: 
https://github.com/llvm/llvm-project/commit/65a56a29b6ad3d9df43df1c5a1238b1f870f24f9.diff

LOG: [clang] [Driver] Treat MuslEABIHF as a hardfloat environment wrt multiarch 
directories (#77536)

If using multiarch directories with musl, the multiarch directory still
uses *-linux-gnu triples - which may or may not be intentional, while it
is somewhat consistent at least.

However, for musl armhf targets, make sure that this also picks
arm-linux-gnueabihf, rather than arm-linux-gnueabi.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 24681dfdc99c03..771240dac7a83e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2668,7 +2668,9 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   case llvm::Triple::arm:
   case llvm::Triple::thumb:
 LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
-if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
+if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF ||
+TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF ||
+TargetTriple.getEnvironment() == llvm::Triple::EABIHF) {
   TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples));
 } else {
   TripleAliases.append(begin(ARMTriples), end(ARMTriples));
@@ -2677,7 +2679,9 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   case llvm::Triple::armeb:
   case llvm::Triple::thumbeb:
 LibDirs.append(begin(ARMebLibDirs), end(ARMebLibDirs));
-if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
+if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF ||
+TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF ||
+TargetTriple.getEnvironment() == llvm::Triple::EABIHF) {
   TripleAliases.append(begin(ARMebHFTriples), end(ARMebHFTriples));
 } else {
   TripleAliases.append(begin(ARMebTriples), end(ARMebTriples));

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 735af54f114cef..4300a2bdff1791 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -61,12 +61,16 @@ std::string Linux::getMultiarchTriple(const Driver &D,
   case llvm::Triple::thumb:
 if (IsAndroid)
   return "arm-linux-androideabi";
-if (TargetEnvironment == llvm::Triple::GNUEABIHF)
+if (TargetEnvironment == llvm::Triple::GNUEABIHF ||
+TargetEnvironment == llvm::Triple::MuslEABIHF ||
+TargetEnvironment == llvm::Triple::EABIHF)
   return "arm-linux-gnueabihf";
 return "arm-linux-gnueabi";
   case llvm::Triple::armeb:
   case llvm::Triple::thumbeb:
-if (TargetEnvironment == llvm::Triple::GNUEABIHF)
+if (TargetEnvironment == llvm::Triple::GNUEABIHF ||
+TargetEnvironment == llvm::Triple::MuslEABIHF ||
+TargetEnvironment == llvm::Triple::EABIHF)
   return "armeb-linux-gnueabihf";
 return "armeb-linux-gnueabi";
   case llvm::Triple::x86:

diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index 15643d6491ae52..d5cc3103a3a746 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -541,6 +541,15 @@
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM-HF %s
+//
+// Check that musleabihf is treated as a hardfloat config, with respect to
+// multiarch directories.
+//
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: --target=arm-unknown-linux-musleabihf -rtlib=platform 
--unwindlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM-HF %s
 // CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-UBUNTU-12-04-ARM-HF: 
"{{.*}}/usr/lib/arm-linux-gnueabihf{{/|}}crt1.o"
 // CHECK-UBUNTU-12-04-ARM-HF: 
"{{.*}}/usr/lib/arm-linux-gnueabihf{{/|}}crti.o"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang-tools-extra] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-10 Thread Qiu Chaofan via cfe-commits


@@ -8900,6 +8900,82 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {

ecnelises wrote:

Here we want to make sure higher bits are all zeroes. KnownBits and constant 
don't make an difference?

https://github.com/llvm/llvm-project/pull/67302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [Driver] Treat MuslEABIHF as a hardfloat environment wrt multiarch directories (PR #77536)

2024-01-10 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo closed 
https://github.com/llvm/llvm-project/pull/77536
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-10 Thread Qiu Chaofan via cfe-commits

https://github.com/ecnelises updated 
https://github.com/llvm/llvm-project/pull/67302

>From a1567f579531c3abbd1f4e9b7c7edd2f95ead42c Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Mon, 25 Sep 2023 17:10:51 +0800
Subject: [PATCH 1/6] [PowerPC] Implement llvm.set.rounding intrinsic

According to LangRef, llvm.set.rounding sets rounding mode by integer argument:

0 - toward zero
1 - to nearest, ties to even
2 - toward positive infinity
3 - toward negative infinity
4 - to nearest, ties away from zero

While PowerPC ISA says:

0 - to nearest
1 - toward zero
2 - toward positive infinity
3 - toward negative infinity

This patch maps the argument and write into last two bits of FPSCR (rounding 
mode).
---
 llvm/lib/Target/PowerPC/PPCISelLowering.cpp |  80 
 llvm/lib/Target/PowerPC/PPCISelLowering.h   |   1 +
 llvm/test/CodeGen/PowerPC/frounds.ll| 194 +++-
 3 files changed, 274 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index f4e3531980d165..4e5ff0cb716966 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -426,6 +426,7 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine 
&TM,
 setLoadExtAction(ISD::EXTLOAD, MVT::f64, MVT::f32, Expand);
 
   setOperationAction(ISD::GET_ROUNDING, MVT::i32, Custom);
+  setOperationAction(ISD::SET_ROUNDING, MVT::Other, Custom);
 
   // If we're enabling GP optimizations, use hardware square root
   if (!Subtarget.hasFSQRT() &&
@@ -8898,6 +8899,83 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {
+uint64_t Mode = CVal->getZExtValue();
+if (Mode >= 4)
+  llvm_unreachable("Unsupported rounding mode!");
+unsigned InternalRnd = Mode ^ (~(Mode >> 1) & 1);
+SDNode *SetHi = DAG.getMachineNode(
+(InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(30, Dl, MVT::i32, true), Chain});
+SDNode *SetLo = DAG.getMachineNode(
+(InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(31, Dl, MVT::i32, true), SDValue(SetHi, 0)});
+return SDValue(SetLo, 0);
+  }
+
+  // Use x ^ (~(x >> 1) & 1) to transform LLVM rounding mode to Power format.
+  SDValue One = DAG.getConstant(1, Dl, MVT::i32);
+  SDValue SrcFlag = DAG.getNode(ISD::AND, Dl, MVT::i32, Op.getOperand(1),
+DAG.getConstant(3, Dl, MVT::i32));
+  SDValue DstFlag = DAG.getNode(
+  ISD::XOR, Dl, MVT::i32, SrcFlag,
+  DAG.getNode(ISD::AND, Dl, MVT::i32,
+  DAG.getNOT(Dl,
+ DAG.getNode(ISD::SRL, Dl, MVT::i32, SrcFlag, One),
+ MVT::i32),
+  One));
+  SDValue MFFS = DAG.getNode(PPCISD::MFFS, Dl, {MVT::f64, MVT::Other}, Chain);
+  Chain = MFFS.getValue(1);
+  SDValue NewFPSCR;
+  if (isTypeLegal(MVT::i64)) {
+// Set the last two bits (rounding mode) of bitcasted FPSCR.
+NewFPSCR = DAG.getNode(
+ISD::OR, Dl, MVT::i64,
+DAG.getNode(ISD::AND, Dl, MVT::i64,
+DAG.getNode(ISD::BITCAST, Dl, MVT::i64, MFFS),
+DAG.getNOT(Dl, DAG.getConstant(3, Dl, MVT::i64), 
MVT::i64)),
+DAG.getNode(ISD::ZERO_EXTEND, Dl, MVT::i64, DstFlag));
+NewFPSCR = DAG.getNode(ISD::BITCAST, Dl, MVT::f64, NewFPSCR);
+  } else {
+// In 32-bit mode, store f64, load and update the lower half.
+int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false);
+SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT);
+Chain = DAG.getStore(Chain, Dl, MFFS, StackSlot, MachinePointerInfo());
+SDValue Addr;
+if (Subtarget.isLittleEndian())
+  Addr = StackSlot;
+else
+  Addr = DAG.getNode(ISD::ADD, Dl, PtrVT, StackSlot,
+ DAG.getConstant(4, Dl, PtrVT));
+SDValue Tmp = DAG.getLoad(MVT::i32, Dl, Chain, Addr, MachinePointerInfo());
+Chain = Tmp.getValue(1);
+
+Tmp = DAG.getNode(
+ISD::OR, Dl, MVT::i32,
+DAG.getNode(ISD::AND, Dl, MVT::i32, Tmp,
+DAG.getNOT(Dl, DAG.getConstant(3, Dl, MVT::i32), 
MVT::i32)),
+DstFlag);
+
+Chain = DAG.getStore(Chain, Dl, Tmp, Addr, MachinePointerInfo());
+NewFPSCR =
+DAG.getLoad(MVT::f64, Dl, Chain, StackSlot, MachinePointerInfo());
+Chain = NewFPSCR.getValue(1);
+  }
+  SDValue Zero = DAG.getConstant(0, Dl, MVT::i32, true);
+  SDNode *MTFSF = DAG.getMachineNode(
+  PPC::MTFSF, Dl, 

[clang-tools-extra] [llvm] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-10 Thread Qiu Chaofan via cfe-commits

ecnelises wrote:

> Maybe we can do some perf test between this expansion for set rounding mode 
> and the system library's version for fesetround().

They are faster than system `fesetround` on both Linux and AIX. Linux glibc 
optimizes `fesetround` with faster `mffscrn` on P9, I just exploited the 
instruction here.

https://github.com/llvm/llvm-project/pull/67302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-01-10 Thread via cfe-commits

https://github.com/NorthBlue333 updated 
https://github.com/llvm/llvm-project/pull/77456

>From 18163c8cad017274adaf8c4e23c0121dc1f3c844 Mon Sep 17 00:00:00 2001
From: NorthBlue333 
Date: Tue, 9 Jan 2024 14:01:14 +0100
Subject: [PATCH] [clang-format] Do not update cursor pos if no includes
 replacement

---
 clang/lib/Format/Format.cpp | 13 +++
 clang/unittests/Format/SortIncludesTest.cpp | 24 +
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f798d555bf9929..2bc336e046aa94 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3119,6 +3119,7 @@ static void sortCppIncludes(const FormatStyle &Style,
 return;
   }
 
+  unsigned NewCursor = UINT_MAX;
   std::string result;
   for (unsigned Index : Indices) {
 if (!result.empty()) {
@@ -3131,13 +3132,10 @@ static void sortCppIncludes(const FormatStyle &Style,
 }
 result += Includes[Index].Text;
 if (Cursor && CursorIndex == Index)
-  *Cursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
+  NewCursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
 CurrentCategory = Includes[Index].Category;
   }
 
-  if (Cursor && *Cursor >= IncludesEndOffset)
-*Cursor += result.size() - IncludesBlockSize;
-
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire range of blocks. Otherwise, no replacement is generated.
   if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
@@ -3145,6 +3143,13 @@ static void sortCppIncludes(const FormatStyle &Style,
 return;
   }
 
+  if (Cursor) {
+if (UINT_MAX != NewCursor)
+  *Cursor = NewCursor;
+else if (*Cursor >= IncludesEndOffset)
+  *Cursor += result.size() - IncludesBlockSize;
+  }
+
   auto Err = Replaces.add(tooling::Replacement(
   FileName, Includes.front().Offset, IncludesBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
diff --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index ec142e03b12854..dc1fadc61b3f93 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -821,6 +821,30 @@ TEST_F(SortIncludesTest, 
CalculatesCorrectCursorPositionWithRegrouping) {
   EXPECT_EQ(27u, newCursor(Code, 28)); // Start of last line
 }
 
+TEST_F(SortIncludesTest, 
CalculatesCorrectCursorPositionWhenNoReplacementsWithRegroupingAndCRLF) {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  FmtStyle.LineEnding = FormatStyle::LE_CRLF;
+  Style.IncludeCategories = {
+  {"^\"aa\"", 1, 0, false},
+  {"^\"b\"", 1, 1, false},
+  {".*", 2, 2, false}};
+  std::string Code = "#include \"aa\"\r\n" // Start of line: 0
+ "\r\n"// Start of line: 15
+ "#include \"b\"\r\n"  // Start of line: 17
+ "\r\n"// Start of line: 31
+ "#include \"c\"\r\n"  // Start of line: 33
+ "\r\n"// Start of line: 47
+ "int i;"; // Start of line: 49
+  EXPECT_EQ(Code, sort(Code));
+  EXPECT_EQ(0u, newCursor(Code, 0));
+  EXPECT_EQ(15u, newCursor(Code, 15));
+  EXPECT_EQ(17u, newCursor(Code, 17));
+  EXPECT_EQ(31u, newCursor(Code, 31));
+  EXPECT_EQ(33u, newCursor(Code, 33));
+  EXPECT_EQ(47u, newCursor(Code, 47));
+  EXPECT_EQ(49u, newCursor(Code, 49));
+}
+
 TEST_F(SortIncludesTest, DeduplicateIncludes) {
   EXPECT_EQ("#include \n"
 "#include \n"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-01-10 Thread Owen Pan via cfe-commits

owenca wrote:

> The change is done 👍 Is the code formatting check broken?

See 
[here](https://github.com/llvm/llvm-project/pull/76059#issuecomment-1865850011).

https://github.com/llvm/llvm-project/pull/77456
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-10 Thread Qiu Chaofan via cfe-commits


@@ -8900,6 +8900,82 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {
+uint64_t Mode = CVal->getZExtValue();
+assert(Mode < 4 && "Unsupported rounding mode!");
+unsigned InternalRnd = Mode ^ (~(Mode >> 1) & 1);
+SDNode *SetHi = DAG.getMachineNode(
+(InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(30, Dl, MVT::i32, true), Chain});
+SDNode *SetLo = DAG.getMachineNode(
+(InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(31, Dl, MVT::i32, true), SDValue(SetHi, 0)});
+return SDValue(SetLo, 0);
+  }
+
+  // Use x ^ (~(x >> 1) & 1) to transform LLVM rounding mode to Power format.

ecnelises wrote:

I think we are using a at-best-effort approach. The meaning looks 
implementation-defined:

> The `llvm.set.rounding` intrinsic sets the current rounding mode. It is 
> similar to C library function ‘fesetround’, however this intrinsic does not 
> return any value and uses platform-independent representation of IEEE 
> rounding modes.

https://github.com/llvm/llvm-project/pull/67302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [clang-tools-extra] [libcxx] [llvm] [flang] [libc] [compiler-rt] [clang] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-10 Thread via cfe-commits

https://github.com/jeanPerier approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/71222
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P2718R0 "Lifetime extension in range-based for loops" (PR #76361)

2024-01-10 Thread via cfe-commits

yronglin wrote:

ping~

https://github.com/llvm/llvm-project/pull/76361
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [flang] [llvm] [clang] [MLIR][LLVM] Add Continuous Loop Peeling transform to SCF (PR #77328)

2024-01-10 Thread via cfe-commits

muneebkhan85 wrote:

@matthias-springer I had to move the pull request 
https://github.com/llvm/llvm-project/pull/71555 here due to an erroneous force 
push.

I have addressed all the comments you had pointed out in the original review. 
Most importantly 

1) I have re-written the logic for the comment 
https://github.com/llvm/llvm-project/pull/71555#discussion_r1444714750
 so that instead of rewriting ops after running `rewritePeeledMinMaxOp`, I 
instead correct the loop step in the map at the time the new loop is being 
created (by cloning) inside `splitLoopHelper`. This also means that there's no 
need for a change to the return type of `rewritePeeledMinMaxOp `as I had 
committed earlier. If this looks good to you, I can revert the changes to the 
return type of `rewritePeeledMinMaxOp`.

2) I have added a new test case, so that both cases `usePowerSplit = false` and 
`usePowerSplit = true` are tested 
https://github.com/llvm/llvm-project/pull/71555#discussion_r1444699098



https://github.com/llvm/llvm-project/pull/77328
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Set writable and dead_on_unwind attributes on sret arguments (PR #77116)

2024-01-10 Thread Nikita Popov via cfe-commits

nikic wrote:

Some IR for reference: https://clang.godbolt.org/z/qEsP7vozW I believe that on 
unwind, the sret temporary is either entirely unused (if no cleanup landingpad 
is necessary) or we will call lifetime.end on it (which is legal for 
dead_on_unwind). This should be independent of whether copy elision is 
performed or not.

https://github.com/llvm/llvm-project/pull/77116
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add an early-out to `flowConditionImplies()` / `flowConditionAllows()`. (PR #77453)

2024-01-10 Thread via cfe-commits

martinboehme wrote:

This breaks some internal integration tests. Reverting while we investigate.

https://github.com/llvm/llvm-project/pull/77453
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang][dataflow] Add an early-out to `flowConditionImplies()` / `flowConditionAllows()`." (PR #77570)

2024-01-10 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/77570

Reverts llvm/llvm-project#77453

>From 038c85ca9733404a67c0f328f268ca0124cf5b17 Mon Sep 17 00:00:00 2001
From: martinboehme 
Date: Wed, 10 Jan 2024 10:49:45 +0100
Subject: [PATCH] Revert "[clang][dataflow] Add an early-out to
 `flowConditionImplies()` / `flowConditionAllows()`. (#77453)"

This reverts commit 03a0bfa96a6eb09c4bbae344ac3aa062339aa730.
---
 clang/include/clang/Analysis/FlowSensitive/Formula.h| 4 
 .../lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp  | 6 --
 2 files changed, 10 deletions(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/Formula.h 
b/clang/include/clang/Analysis/FlowSensitive/Formula.h
index 0e6352403a832f..982e400c1deff1 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Formula.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Formula.h
@@ -75,10 +75,6 @@ class alignas(const Formula *) Formula {
 return static_cast(Value);
   }
 
-  bool isLiteral(bool b) const {
-return kind() == Literal && static_cast(Value) == b;
-  }
-
   ArrayRef operands() const {
 return ArrayRef(reinterpret_cast(this + 1),
 numOperands(kind()));
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 500fbb39955d20..fa114979c8e326 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -174,9 +174,6 @@ Solver::Result DataflowAnalysisContext::querySolver(
 
 bool DataflowAnalysisContext::flowConditionImplies(Atom Token,
const Formula &F) {
-  if (F.isLiteral(true))
-return true;
-
   // Returns true if and only if truth assignment of the flow condition implies
   // that `F` is also true. We prove whether or not this property holds by
   // reducing the problem to satisfiability checking. In other words, we 
attempt
@@ -191,9 +188,6 @@ bool DataflowAnalysisContext::flowConditionImplies(Atom 
Token,
 
 bool DataflowAnalysisContext::flowConditionAllows(Atom Token,
   const Formula &F) {
-  if (F.isLiteral(true))
-return true;
-
   llvm::SetVector Constraints;
   Constraints.insert(&arena().makeAtomRef(Token));
   Constraints.insert(&F);

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7ce010f - Revert "[clang][dataflow] Add an early-out to `flowConditionImplies()` / `flowConditionAllows()`." (#77570)

2024-01-10 Thread via cfe-commits

Author: martinboehme
Date: 2024-01-10T10:50:16+01:00
New Revision: 7ce010f2fb01341ab253547324e126d81d47f794

URL: 
https://github.com/llvm/llvm-project/commit/7ce010f2fb01341ab253547324e126d81d47f794
DIFF: 
https://github.com/llvm/llvm-project/commit/7ce010f2fb01341ab253547324e126d81d47f794.diff

LOG: Revert "[clang][dataflow] Add an early-out to `flowConditionImplies()` / 
`flowConditionAllows()`." (#77570)

Reverts llvm/llvm-project#77453

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/Formula.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/Formula.h 
b/clang/include/clang/Analysis/FlowSensitive/Formula.h
index 0e6352403a832f..982e400c1deff1 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Formula.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Formula.h
@@ -75,10 +75,6 @@ class alignas(const Formula *) Formula {
 return static_cast(Value);
   }
 
-  bool isLiteral(bool b) const {
-return kind() == Literal && static_cast(Value) == b;
-  }
-
   ArrayRef operands() const {
 return ArrayRef(reinterpret_cast(this + 1),
 numOperands(kind()));

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 500fbb39955d20..fa114979c8e326 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -174,9 +174,6 @@ Solver::Result DataflowAnalysisContext::querySolver(
 
 bool DataflowAnalysisContext::flowConditionImplies(Atom Token,
const Formula &F) {
-  if (F.isLiteral(true))
-return true;
-
   // Returns true if and only if truth assignment of the flow condition implies
   // that `F` is also true. We prove whether or not this property holds by
   // reducing the problem to satisfiability checking. In other words, we 
attempt
@@ -191,9 +188,6 @@ bool DataflowAnalysisContext::flowConditionImplies(Atom 
Token,
 
 bool DataflowAnalysisContext::flowConditionAllows(Atom Token,
   const Formula &F) {
-  if (F.isLiteral(true))
-return true;
-
   llvm::SetVector Constraints;
   Constraints.insert(&arena().makeAtomRef(Token));
   Constraints.insert(&F);



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang][dataflow] Add an early-out to `flowConditionImplies()` / `flowConditionAllows()`." (PR #77570)

2024-01-10 Thread via cfe-commits

https://github.com/martinboehme closed 
https://github.com/llvm/llvm-project/pull/77570
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang][dataflow] Add an early-out to `flowConditionImplies()` / `flowConditionAllows()`." (PR #77570)

2024-01-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (martinboehme)


Changes

Reverts llvm/llvm-project#77453

---
Full diff: https://github.com/llvm/llvm-project/pull/77570.diff


2 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/Formula.h (-4) 
- (modified) clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp (-6) 


``diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/Formula.h 
b/clang/include/clang/Analysis/FlowSensitive/Formula.h
index 0e6352403a832f..982e400c1deff1 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Formula.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Formula.h
@@ -75,10 +75,6 @@ class alignas(const Formula *) Formula {
 return static_cast(Value);
   }
 
-  bool isLiteral(bool b) const {
-return kind() == Literal && static_cast(Value) == b;
-  }
-
   ArrayRef operands() const {
 return ArrayRef(reinterpret_cast(this + 1),
 numOperands(kind()));
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 500fbb39955d20..fa114979c8e326 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -174,9 +174,6 @@ Solver::Result DataflowAnalysisContext::querySolver(
 
 bool DataflowAnalysisContext::flowConditionImplies(Atom Token,
const Formula &F) {
-  if (F.isLiteral(true))
-return true;
-
   // Returns true if and only if truth assignment of the flow condition implies
   // that `F` is also true. We prove whether or not this property holds by
   // reducing the problem to satisfiability checking. In other words, we 
attempt
@@ -191,9 +188,6 @@ bool DataflowAnalysisContext::flowConditionImplies(Atom 
Token,
 
 bool DataflowAnalysisContext::flowConditionAllows(Atom Token,
   const Formula &F) {
-  if (F.isLiteral(true))
-return true;
-
   llvm::SetVector Constraints;
   Constraints.insert(&arena().makeAtomRef(Token));
   Constraints.insert(&F);

``




https://github.com/llvm/llvm-project/pull/77570
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][doc] Add blank line before lists (PR #77573)

2024-01-10 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/77573

The doc is not correctly rendered with missing blank lines.


>From 2d249aefa1bfa91f41a3866c4203eff041415546 Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Wed, 10 Jan 2024 17:54:27 +0800
Subject: [PATCH] [Clang][doc] Add blank line before lists

The doc is not correctly rendered with missing blank lines.
---
 clang/docs/LanguageExtensions.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 23a7f4f5d5b926..c1420079f75118 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -829,6 +829,7 @@ to ``float``; see below for more information on this 
emulation.
   see below.
 
 * ``_Float16`` is supported on the following targets:
+
   * 32-bit ARM (natively on some architecture versions)
   * 64-bit ARM (AArch64) (natively on ARMv8.2a and above)
   * AMDGPU (natively)
@@ -837,6 +838,7 @@ to ``float``; see below for more information on this 
emulation.
   * RISC-V (natively if Zfh or Zhinx is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
+
   * 32-bit ARM
   * 64-bit ARM (AArch64)
   * RISC-V

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][doc] Add blank line before lists (PR #77573)

2024-01-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Wang Pengcheng (wangpc-pp)


Changes

The doc is not correctly rendered with missing blank lines.


---
Full diff: https://github.com/llvm/llvm-project/pull/77573.diff


1 Files Affected:

- (modified) clang/docs/LanguageExtensions.rst (+2) 


``diff
diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 23a7f4f5d5b926..c1420079f75118 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -829,6 +829,7 @@ to ``float``; see below for more information on this 
emulation.
   see below.
 
 * ``_Float16`` is supported on the following targets:
+
   * 32-bit ARM (natively on some architecture versions)
   * 64-bit ARM (AArch64) (natively on ARMv8.2a and above)
   * AMDGPU (natively)
@@ -837,6 +838,7 @@ to ``float``; see below for more information on this 
emulation.
   * RISC-V (natively if Zfh or Zhinx is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
+
   * 32-bit ARM
   * 64-bit ARM (AArch64)
   * RISC-V

``




https://github.com/llvm/llvm-project/pull/77573
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a26cc75 - [clang][coverage] Fix "if constexpr" and "if consteval" coverage report (#77214)

2024-01-10 Thread via cfe-commits

Author: Hana Dusíková
Date: 2024-01-10T11:01:23+01:00
New Revision: a26cc759ae5a8018e2c328cf53173992340b995a

URL: 
https://github.com/llvm/llvm-project/commit/a26cc759ae5a8018e2c328cf53173992340b995a
DIFF: 
https://github.com/llvm/llvm-project/commit/a26cc759ae5a8018e2c328cf53173992340b995a.diff

LOG: [clang][coverage] Fix "if constexpr" and "if consteval" coverage report 
(#77214)

Replace the discarded statement by an empty compound statement so we can keep 
track of the
whole source range we need to skip in coverage

Fixes #54419

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Stmt.h
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CoverageMapping/if.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 20872f7ddb81e9..37f8bbc89d8949 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -705,6 +705,9 @@ Bug Fixes in This Version
 - Fix assertion crash due to failed scope restoring caused by too-early VarDecl
   invalidation by invalid initializer Expr.
   Fixes (`#30908 `_)
+- Clang now emits correct source location for code-coverage regions in `if 
constexpr`
+  and `if consteval` branches.
+  Fixes (`#54419 `_)
 
 
 Bug Fixes to Compiler Builtins

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index da7b37ce0e1211..e1fde24e647789 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -1631,8 +1631,10 @@ class CompoundStmt final
   SourceLocation RB);
 
   // Build an empty compound statement with a location.
-  explicit CompoundStmt(SourceLocation Loc)
-  : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(Loc) {
+  explicit CompoundStmt(SourceLocation Loc) : CompoundStmt(Loc, Loc) {}
+
+  CompoundStmt(SourceLocation Loc, SourceLocation EndLoc)
+  : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(EndLoc) {
 CompoundStmtBits.NumStmts = 0;
 CompoundStmtBits.HasFPFeatures = 0;
   }

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index bf227386a71b78..b245abd16c3f4a 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1712,7 +1712,11 @@ struct CounterCoverageMappingBuilder
   extendRegion(S->getCond());
 
 Counter ParentCount = getRegion().getCounter();
-Counter ThenCount = getRegionCounter(S);
+
+// If this is "if !consteval" the then-branch will never be taken, we don't
+// need to change counter
+Counter ThenCount =
+S->isNegatedConsteval() ? ParentCount : getRegionCounter(S);
 
 if (!S->isConsteval()) {
   // Emitting a counter for the condition makes it easier to interpret the
@@ -1729,7 +1733,12 @@ struct CounterCoverageMappingBuilder
 extendRegion(S->getThen());
 Counter OutCount = propagateCounts(ThenCount, S->getThen());
 
-Counter ElseCount = subtractCounters(ParentCount, ThenCount);
+// If this is "if consteval" the else-branch will never be taken, we don't
+// need to change counter
+Counter ElseCount = S->isNonNegatedConsteval()
+? ParentCount
+: subtractCounters(ParentCount, ThenCount);
+
 if (const Stmt *Else = S->getElse()) {
   bool ThenHasTerminateStmt = HasTerminateStmt;
   HasTerminateStmt = false;

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index e7a6550b1c993c..1a1bc87d2b3203 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7739,7 +7739,11 @@ TreeTransform::TransformIfStmt(IfStmt *S) {
 if (Then.isInvalid())
   return StmtError();
   } else {
-Then = new (getSema().Context) NullStmt(S->getThen()->getBeginLoc());
+// Discarded branch is replaced with empty CompoundStmt so we can keep
+// proper source location for start and end of original branch, so
+// subsequent transformations like CoverageMapping work properly
+Then = new (getSema().Context)
+CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
   }
 
   // Transform the "else" branch.
@@ -7748,6 +7752,13 @@ TreeTransform::TransformIfStmt(IfStmt *S) {
 Else = getDerived().TransformStmt(S->getElse());
 if (Else.isInvalid())
   return StmtError();
+  } else if (S->getElse() && ConstexprConditionValue &&
+ *ConstexprConditionValue) {
+// Same thing here as with  branch, we are discarding it, we can't
+// replace it with NULL nor NullStmt as we need to keep for source location
+// range, for CoverageMapping
+Else = new (getSema().Context)
+CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->

[clang] [clang][coverage] fixing "if constexpr" and "if consteval" coverage report (PR #77214)

2024-01-10 Thread via cfe-commits

https://github.com/cor3ntin closed 
https://github.com/llvm/llvm-project/pull/77214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [flang] [llvm] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2024-01-10 Thread Yi Wu via cfe-commits

https://github.com/yi-wu-arm closed 
https://github.com/llvm/llvm-project/pull/74077
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [flang] [llvm] [clang] [MLIR][LLVM] Add Continuous Loop Peeling transform to SCF (PR #77328)

2024-01-10 Thread Matthias Springer via cfe-commits

matthias-springer wrote:

Can you re-open the old PR and force-push the contents of this PR to the old 
PR? Ideally, we'd keep using the old PR, so that we don't loose the review 
comments.


https://github.com/llvm/llvm-project/pull/77328
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang] [PowerPC] Implement llvm.set.rounding intrinsic (PR #67302)

2024-01-10 Thread Qiu Chaofan via cfe-commits

https://github.com/ecnelises updated 
https://github.com/llvm/llvm-project/pull/67302

>From a1567f579531c3abbd1f4e9b7c7edd2f95ead42c Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Mon, 25 Sep 2023 17:10:51 +0800
Subject: [PATCH 1/7] [PowerPC] Implement llvm.set.rounding intrinsic

According to LangRef, llvm.set.rounding sets rounding mode by integer argument:

0 - toward zero
1 - to nearest, ties to even
2 - toward positive infinity
3 - toward negative infinity
4 - to nearest, ties away from zero

While PowerPC ISA says:

0 - to nearest
1 - toward zero
2 - toward positive infinity
3 - toward negative infinity

This patch maps the argument and write into last two bits of FPSCR (rounding 
mode).
---
 llvm/lib/Target/PowerPC/PPCISelLowering.cpp |  80 
 llvm/lib/Target/PowerPC/PPCISelLowering.h   |   1 +
 llvm/test/CodeGen/PowerPC/frounds.ll| 194 +++-
 3 files changed, 274 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index f4e3531980d165..4e5ff0cb716966 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -426,6 +426,7 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine 
&TM,
 setLoadExtAction(ISD::EXTLOAD, MVT::f64, MVT::f32, Expand);
 
   setOperationAction(ISD::GET_ROUNDING, MVT::i32, Custom);
+  setOperationAction(ISD::SET_ROUNDING, MVT::Other, Custom);
 
   // If we're enabling GP optimizations, use hardware square root
   if (!Subtarget.hasFSQRT() &&
@@ -8898,6 +8899,83 @@ SDValue PPCTargetLowering::LowerINT_TO_FP(SDValue Op,
   return FP;
 }
 
+SDValue PPCTargetLowering::LowerSET_ROUNDING(SDValue Op,
+ SelectionDAG &DAG) const {
+  SDLoc Dl(Op);
+  MachineFunction &MF = DAG.getMachineFunction();
+  EVT PtrVT = getPointerTy(MF.getDataLayout());
+  SDValue Chain = Op.getOperand(0);
+
+  // If requested mode is constant, just use simpler mtfsb.
+  if (auto *CVal = dyn_cast(Op.getOperand(1))) {
+uint64_t Mode = CVal->getZExtValue();
+if (Mode >= 4)
+  llvm_unreachable("Unsupported rounding mode!");
+unsigned InternalRnd = Mode ^ (~(Mode >> 1) & 1);
+SDNode *SetHi = DAG.getMachineNode(
+(InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(30, Dl, MVT::i32, true), Chain});
+SDNode *SetLo = DAG.getMachineNode(
+(InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
+{DAG.getConstant(31, Dl, MVT::i32, true), SDValue(SetHi, 0)});
+return SDValue(SetLo, 0);
+  }
+
+  // Use x ^ (~(x >> 1) & 1) to transform LLVM rounding mode to Power format.
+  SDValue One = DAG.getConstant(1, Dl, MVT::i32);
+  SDValue SrcFlag = DAG.getNode(ISD::AND, Dl, MVT::i32, Op.getOperand(1),
+DAG.getConstant(3, Dl, MVT::i32));
+  SDValue DstFlag = DAG.getNode(
+  ISD::XOR, Dl, MVT::i32, SrcFlag,
+  DAG.getNode(ISD::AND, Dl, MVT::i32,
+  DAG.getNOT(Dl,
+ DAG.getNode(ISD::SRL, Dl, MVT::i32, SrcFlag, One),
+ MVT::i32),
+  One));
+  SDValue MFFS = DAG.getNode(PPCISD::MFFS, Dl, {MVT::f64, MVT::Other}, Chain);
+  Chain = MFFS.getValue(1);
+  SDValue NewFPSCR;
+  if (isTypeLegal(MVT::i64)) {
+// Set the last two bits (rounding mode) of bitcasted FPSCR.
+NewFPSCR = DAG.getNode(
+ISD::OR, Dl, MVT::i64,
+DAG.getNode(ISD::AND, Dl, MVT::i64,
+DAG.getNode(ISD::BITCAST, Dl, MVT::i64, MFFS),
+DAG.getNOT(Dl, DAG.getConstant(3, Dl, MVT::i64), 
MVT::i64)),
+DAG.getNode(ISD::ZERO_EXTEND, Dl, MVT::i64, DstFlag));
+NewFPSCR = DAG.getNode(ISD::BITCAST, Dl, MVT::f64, NewFPSCR);
+  } else {
+// In 32-bit mode, store f64, load and update the lower half.
+int SSFI = MF.getFrameInfo().CreateStackObject(8, Align(8), false);
+SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT);
+Chain = DAG.getStore(Chain, Dl, MFFS, StackSlot, MachinePointerInfo());
+SDValue Addr;
+if (Subtarget.isLittleEndian())
+  Addr = StackSlot;
+else
+  Addr = DAG.getNode(ISD::ADD, Dl, PtrVT, StackSlot,
+ DAG.getConstant(4, Dl, PtrVT));
+SDValue Tmp = DAG.getLoad(MVT::i32, Dl, Chain, Addr, MachinePointerInfo());
+Chain = Tmp.getValue(1);
+
+Tmp = DAG.getNode(
+ISD::OR, Dl, MVT::i32,
+DAG.getNode(ISD::AND, Dl, MVT::i32, Tmp,
+DAG.getNOT(Dl, DAG.getConstant(3, Dl, MVT::i32), 
MVT::i32)),
+DstFlag);
+
+Chain = DAG.getStore(Chain, Dl, Tmp, Addr, MachinePointerInfo());
+NewFPSCR =
+DAG.getLoad(MVT::f64, Dl, Chain, StackSlot, MachinePointerInfo());
+Chain = NewFPSCR.getValue(1);
+  }
+  SDValue Zero = DAG.getConstant(0, Dl, MVT::i32, true);
+  SDNode *MTFSF = DAG.getMachineNode(
+  PPC::MTFSF, Dl, 

[mlir] [flang] [llvm] [clang] [MLIR][LLVM] Add Continuous Loop Peeling transform to SCF (PR #77328)

2024-01-10 Thread Matthias Springer via cfe-commits


@@ -105,6 +106,161 @@ static void specializeForLoopForUnrolling(ForOp op) {
   op.erase();
 }
 
+/// Create a new for loop for the remaining iterations (partialIteration)
+/// after a for loop has been peeled. This is followed by correcting the
+/// loop bounds for both loops given the index (splitBound) where the
+/// iteration space is to be split up. Returns failure if the loop can not
+/// be split and no new partialIteration is created.
+static LogicalResult splitLoopHelper(RewriterBase &b, scf::ForOp forOp,
+ scf::ForOp &partialIteration,
+ Value splitBound) {
+  RewriterBase::InsertionGuard guard(b);
+  auto lbInt = getConstantIntValue(forOp.getLowerBound());
+  auto ubInt = getConstantIntValue(forOp.getUpperBound());
+  auto stepInt = getConstantIntValue(forOp.getStep());
+
+  // No specialization necessary if step already divides upper bound evenly.
+  if (lbInt && ubInt && stepInt && (*ubInt - *lbInt) % *stepInt == 0)
+return failure();
+  // No specialization necessary if step size is 1.
+  if (stepInt == static_cast(1))
+return failure();
+
+  // Create ForOp for partial iteration.
+  b.setInsertionPointAfter(forOp);
+  IRMapping map;
+  auto constStepOp =
+  b.create(forOp.getLoc(), *stepInt / 2);
+  // The new for loop for the remaining iterations has half the step size
+  // as continuous peeling requires the step size to diminish exponentially
+  // across subsequent loops.
+  map.map(forOp.getStep(), constStepOp);

matthias-springer wrote:

I think this won't work. The SSA value of `forOp.getStep()` could be used in 
different ways inside of the loop and you don't want to change that.

E.g.:
```mlir
scf.for ... step %c16 {
  // This op should not be changed as part of loop peeling.
  "test.foo"(%c16) : () -> ()
}
```

What's the purpose of this `map.map`? Is it meant to canonicalize 
`affine.min/max` ops, taking into account the fact that the loop was peeled?


https://github.com/llvm/llvm-project/pull/77328
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [flang] [llvm] [clang] [AMDGPU] Introduce Code Object V6 (PR #76954)

2024-01-10 Thread via cfe-commits

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 40236257ea9d1e451daee5c0938bd23abd5d1450 
df3227d73e03b5d013e14293013e54da120c0b77 -- clang/lib/CodeGen/CGBuiltin.cpp 
clang/lib/Driver/ToolChains/CommonArgs.cpp 
flang/lib/Frontend/CompilerInvocation.cpp lld/ELF/Arch/AMDGPU.cpp 
llvm/include/llvm/BinaryFormat/ELF.h llvm/include/llvm/Support/AMDGPUMetadata.h 
llvm/include/llvm/Support/ScopedPrinter.h 
llvm/include/llvm/Target/TargetOptions.h llvm/lib/ObjectYAML/ELFYAML.cpp 
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp 
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h 
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp 
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.h 
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp 
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h 
llvm/tools/llvm-readobj/ELFDumper.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 7e3426aa8e..ff7151e016 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -621,9 +621,12 @@ void ScalarBitSetTraits::bitset(IO &IO,
   BCase(EF_AMDGPU_FEATURE_SRAMECC_V3);
   break;
 case ELF::ELFABIVERSION_AMDGPU_HSA_V6:
-  for(unsigned K = ELF::EF_AMDGPU_GENERIC_VERSION_MIN; K <= 
ELF::EF_AMDGPU_GENERIC_VERSION_MAX; ++K) {
+  for (unsigned K = ELF::EF_AMDGPU_GENERIC_VERSION_MIN;
+   K <= ELF::EF_AMDGPU_GENERIC_VERSION_MAX; ++K) {
 std::string Key = "EF_AMDGPU_GENERIC_VERSION_V" + std::to_string(K);
-IO.maskedBitSetCase(Value, Key.c_str(), K << 
ELF::EF_AMDGPU_GENERIC_VERSION_OFFSET, ELF::EF_AMDGPU_GENERIC_VERSION);
+IO.maskedBitSetCase(Value, Key.c_str(),
+K << ELF::EF_AMDGPU_GENERIC_VERSION_OFFSET,
+ELF::EF_AMDGPU_GENERIC_VERSION);
   }
   [[fallthrough]];
 case ELF::ELFABIVERSION_AMDGPU_HSA_V4:
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 8f19873de1..88eef3f343 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3641,8 +3641,10 @@ template  void 
GNUELFDumper::printFileHeaders() {
  unsigned(ELF::EF_AMDGPU_FEATURE_XNACK_V4),
  unsigned(ELF::EF_AMDGPU_FEATURE_SRAMECC_V4),
  unsigned(ELF::EF_AMDGPU_GENERIC_VERSION));
-  if(auto GenericV = e.e_flags & ELF::EF_AMDGPU_GENERIC_VERSION) {
-ElfFlags += ", generic_v" + to_string(GenericV >> 
ELF::EF_AMDGPU_GENERIC_VERSION_OFFSET);
+  if (auto GenericV = e.e_flags & ELF::EF_AMDGPU_GENERIC_VERSION) {
+ElfFlags +=
+", generic_v" +
+to_string(GenericV >> ELF::EF_AMDGPU_GENERIC_VERSION_OFFSET);
   }
   break;
 }

``




https://github.com/llvm/llvm-project/pull/76954
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [flang] [llvm] [clang] [AMDGPU] Introduce GFX9/10.1/10.3/11 Generic Targets (PR #76955)

2024-01-10 Thread Pierre van Houtryve via cfe-commits

https://github.com/Pierre-vh edited 
https://github.com/llvm/llvm-project/pull/76955
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] Fix incorrect range of 'ftell' in the StdLibraryFunctionsChecker (PR #77576)

2024-01-10 Thread Ben Shi via cfe-commits

https://github.com/benshi001 created 
https://github.com/llvm/llvm-project/pull/77576

According to https://pubs.opengroup.org/onlinepubs/9699919799/, the return 
value of 'ftell' is not restricted to > 0, and may return 0 in real world.

And the corresponding unit test also show `Ret >= 0` not `Ret > 0`.

https://github.com/llvm/llvm-project/blob/main/clang/test/Analysis/stream-errno.c#L194

>From e33d2bce007ac6009870a4dbd5227b62c3d6ba41 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Wed, 10 Jan 2024 18:28:30 +0800
Subject: [PATCH] [clang][analyzer] Fix incorrect range of 'ftell' in the
 StdLibraryFunctionsChecker

According to https://pubs.opengroup.org/onlinepubs/9699919799/, the return value
of 'ftell' is not restricted to > 0, and may return 0 in real world.
---
 .../lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 32a2deab871c79..3b36565681a7f3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2274,7 +2274,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 addToFunctionSummaryMap(
 "ftell", Signature(ArgTypes{FilePtrTy}, RetType{LongTy}),
 Summary(NoEvalCall)
-.Case({ReturnValueCondition(WithinRange, Range(1, LongMax))},
+.Case({ReturnValueCondition(WithinRange, Range(0, LongMax))},
   ErrnoUnchanged, GenericSuccessMsg)
 .Case(ReturnsMinusOne, ErrnoNEZeroIrrelevant, GenericFailureMsg)
 .ArgConstraint(NotNull(ArgNo(0;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] Fix incorrect range of 'ftell' in the StdLibraryFunctionsChecker (PR #77576)

2024-01-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ben Shi (benshi001)


Changes

According to https://pubs.opengroup.org/onlinepubs/9699919799/, the return 
value of 'ftell' is not restricted to > 0, and may return 0 in real world.

And the corresponding unit test also show `Ret >= 0` not `Ret > 0`.

https://github.com/llvm/llvm-project/blob/main/clang/test/Analysis/stream-errno.c#L194

---
Full diff: https://github.com/llvm/llvm-project/pull/77576.diff


1 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(+1-1) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 32a2deab871c79..3b36565681a7f3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2274,7 +2274,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 addToFunctionSummaryMap(
 "ftell", Signature(ArgTypes{FilePtrTy}, RetType{LongTy}),
 Summary(NoEvalCall)
-.Case({ReturnValueCondition(WithinRange, Range(1, LongMax))},
+.Case({ReturnValueCondition(WithinRange, Range(0, LongMax))},
   ErrnoUnchanged, GenericSuccessMsg)
 .Case(ReturnsMinusOne, ErrnoNEZeroIrrelevant, GenericFailureMsg)
 .ArgConstraint(NotNull(ArgNo(0;

``




https://github.com/llvm/llvm-project/pull/77576
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2024-01-10 Thread via cfe-commits

https://github.com/r4nt updated https://github.com/llvm/llvm-project/pull/76245

>From 52cb11f0279dbd9f65f15e81f44869cfac00d544 Mon Sep 17 00:00:00 2001
From: Manuel Klimek 
Date: Thu, 2 Mar 2023 14:00:35 +
Subject: [PATCH 1/3] [ClangFormat] Fix formatting bugs.

1. There are multiple calls to addFakeParenthesis; move the guard to not
   assign fake parenthesis into the function to make sure we cover all
   calls.
2. MustBreakBefore can be set on a token in two cases: either during
   unwrapped line parsing, or later, during token annotation. We must
   keep the latter, but reset the former.
3. Added a test to document that the intended behavior of preferring not to
   break between a return type and a function identifier.
   For example, with MOCK_METHOD(r, n, a)=r n a, the code
   MOCK_METHOD(void, f, (int a, int b)) should prefer the same breaks as
   the expanded void f(int a, int b).
---
 clang/lib/Format/FormatToken.h| 26 +
 clang/lib/Format/TokenAnnotator.cpp   | 13 +++
 clang/lib/Format/UnwrappedLineFormatter.cpp   | 10 +++--
 clang/lib/Format/UnwrappedLineParser.cpp  |  2 +
 .../Format/FormatTestMacroExpansion.cpp   | 38 +++
 5 files changed, 70 insertions(+), 19 deletions(-)

diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 3f9664f8f78a3e..b1e3ae8ab303d6 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -275,14 +275,15 @@ class AnnotatedLine;
 struct FormatToken {
   FormatToken()
   : HasUnescapedNewline(false), IsMultiline(false), IsFirst(false),
-MustBreakBefore(false), IsUnterminatedLiteral(false),
-CanBreakBefore(false), ClosesTemplateDeclaration(false),
-StartsBinaryExpression(false), EndsBinaryExpression(false),
-PartOfMultiVariableDeclStmt(false), ContinuesLineCommentSection(false),
-Finalized(false), ClosesRequiresClause(false),
-EndsCppAttributeGroup(false), BlockKind(BK_Unknown),
-Decision(FD_Unformatted), PackingKind(PPK_Inconclusive),
-TypeIsFinalized(false), Type(TT_Unknown) {}
+MustBreakBefore(false), MustBreakBeforeFinalized(false),
+IsUnterminatedLiteral(false), CanBreakBefore(false),
+ClosesTemplateDeclaration(false), StartsBinaryExpression(false),
+EndsBinaryExpression(false), PartOfMultiVariableDeclStmt(false),
+ContinuesLineCommentSection(false), Finalized(false),
+ClosesRequiresClause(false), EndsCppAttributeGroup(false),
+BlockKind(BK_Unknown), Decision(FD_Unformatted),
+PackingKind(PPK_Inconclusive), TypeIsFinalized(false),
+Type(TT_Unknown) {}
 
   /// The \c Token.
   Token Tok;
@@ -318,6 +319,10 @@ struct FormatToken {
   /// before the token.
   unsigned MustBreakBefore : 1;
 
+  /// Whether MustBreakBefore is finalized during parsing and must not
+  /// be reset between runs.
+  unsigned MustBreakBeforeFinalized : 1;
+
   /// Set to \c true if this token is an unterminated literal.
   unsigned IsUnterminatedLiteral : 1;
 
@@ -416,10 +421,15 @@ struct FormatToken {
   /// to another one please use overwriteFixedType, or even better remove the
   /// need to reassign the type.
   void setFinalizedType(TokenType T) {
+if (MacroCtx && MacroCtx->Role == MR_UnexpandedArg)
+  return;
+
 Type = T;
 TypeIsFinalized = true;
   }
   void overwriteFixedType(TokenType T) {
+if (MacroCtx && MacroCtx->Role == MR_UnexpandedArg)
+  return;
 TypeIsFinalized = false;
 setType(T);
   }
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f3551af3424396..c26b248a3b2d40 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2769,13 +2769,6 @@ class ExpressionParser {
   // Consume operators with higher precedence.
   parse(Precedence + 1);
 
-  // Do not assign fake parenthesis to tokens that are part of an
-  // unexpanded macro call. The line within the macro call contains
-  // the parenthesis and commas, and we will not find operators within
-  // that structure.
-  if (Current && Current->MacroParent)
-break;
-
   int CurrentPrecedence = getCurrentPrecedence();
 
   if (Precedence == CurrentPrecedence && Current &&
@@ -2919,6 +2912,12 @@ class ExpressionParser {
 
   void addFakeParenthesis(FormatToken *Start, prec::Level Precedence,
   FormatToken *End = nullptr) {
+// Do not assign fake parenthesis to tokens that are part of an
+// unexpanded macro call. The line within the macro call contains
+// the parenthesis and commas, and we will not find operators within
+// that structure.
+if (Start->MacroParent) return;
+
 Start->FakeLParens.push_back(Precedence);
 if (Precedence > prec::Unknown)
   Start->StartsBinaryExpression = true;
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Fo

[clang] [clang][analyzer] Fix incorrect range of 'ftell' in the StdLibraryFunctionsChecker (PR #77576)

2024-01-10 Thread Ben Shi via cfe-commits

https://github.com/benshi001 edited 
https://github.com/llvm/llvm-project/pull/77576
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [flang] [llvm] [clang] [AMDGPU] Introduce Code Object V6 (PR #76954)

2024-01-10 Thread Pierre van Houtryve via cfe-commits

https://github.com/Pierre-vh updated 
https://github.com/llvm/llvm-project/pull/76954

>From 6368d8210e211948b5a03ab326b996695b8d Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Thu, 4 Jan 2024 14:12:00 +0100
Subject: [PATCH] [AMDGPU] Introduce Code Object V6

Introduce Code Object V6 in Clang, LLD, Flang and LLVM.
This is the same as V5 except a new "generic version" flag can be present in 
EFLAGS. This is related to new generic targets that'll be added in a follow-up 
patch. It's also likely V6 will have new changes (possibly new metadata 
entries) added later.

Docs change are not included, I'm planning to do them in a follow-up patch all 
at once (when generic targets land too).
---
 clang/include/clang/Driver/Options.td |   4 +-
 clang/lib/CodeGen/CGBuiltin.cpp   |   6 +-
 clang/lib/Driver/ToolChains/CommonArgs.cpp|   2 +-
 .../amdgpu-code-object-version-linking.cu |  37 +++
 .../CodeGenCUDA/amdgpu-code-object-version.cu |   4 +
 .../test/CodeGenCUDA/amdgpu-workgroup-size.cu |   4 +
 .../amdgcn/bitcode/oclc_abi_version_600.bc|   0
 clang/test/Driver/hip-code-object-version.hip |  12 +
 clang/test/Driver/hip-device-libs.hip |  18 +-
 flang/lib/Frontend/CompilerInvocation.cpp |   2 +
 flang/test/Lower/AMD/code-object-version.f90  |   3 +-
 lld/ELF/Arch/AMDGPU.cpp   |  21 ++
 lld/test/ELF/amdgpu-tid.s |  16 ++
 llvm/include/llvm/BinaryFormat/ELF.h  |   9 +-
 llvm/include/llvm/Support/AMDGPUMetadata.h|   5 +
 llvm/include/llvm/Support/ScopedPrinter.h |   4 +-
 llvm/include/llvm/Target/TargetOptions.h  |   1 +
 llvm/lib/ObjectYAML/ELFYAML.cpp   |   9 +
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |   3 +
 .../AMDGPU/AMDGPUHSAMetadataStreamer.cpp  |  10 +
 .../Target/AMDGPU/AMDGPUHSAMetadataStreamer.h |  11 +-
 .../MCTargetDesc/AMDGPUTargetStreamer.cpp |  27 +++
 .../MCTargetDesc/AMDGPUTargetStreamer.h   |   1 +
 .../Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp|  13 +
 llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h |   5 +-
 ...licit-kernarg-backend-usage-global-isel.ll |   2 +
 .../AMDGPU/call-graph-register-usage.ll   |   1 +
 .../AMDGPU/codegen-internal-only-func.ll  |   2 +
 llvm/test/CodeGen/AMDGPU/elf-header-osabi.ll  |   4 +
 .../enable-scratch-only-dynamic-stack.ll  |   1 +
 .../AMDGPU/implicit-kernarg-backend-usage.ll  |   2 +
 .../AMDGPU/implicitarg-offset-attributes.ll   |  46 
 .../AMDGPU/llvm.amdgcn.implicitarg.ptr.ll |   1 +
 llvm/test/CodeGen/AMDGPU/non-entry-alloca.ll  |   1 +
 llvm/test/CodeGen/AMDGPU/recursion.ll |   1 +
 .../AMDGPU/resource-usage-dead-function.ll|   1 +
 .../AMDGPU/tid-mul-func-xnack-all-any.ll  |   6 +
 .../tid-mul-func-xnack-all-not-supported.ll   |   6 +
 .../AMDGPU/tid-mul-func-xnack-all-off.ll  |   6 +
 .../AMDGPU/tid-mul-func-xnack-all-on.ll   |   6 +
 .../AMDGPU/tid-mul-func-xnack-any-off-1.ll|   6 +
 .../AMDGPU/tid-mul-func-xnack-any-off-2.ll|   6 +
 .../AMDGPU/tid-mul-func-xnack-any-on-1.ll |   6 +
 .../AMDGPU/tid-mul-func-xnack-any-on-2.ll |   6 +
 .../tid-one-func-xnack-not-supported.ll   |   6 +
 .../CodeGen/AMDGPU/tid-one-func-xnack-off.ll  |   6 +
 .../CodeGen/AMDGPU/tid-one-func-xnack-on.ll   |   6 +
 .../MC/AMDGPU/hsa-v5-uses-dynamic-stack.s |   5 +
 .../elf-headers.test} |   0
 .../ELF/AMDGPU/generic_versions.s |  16 ++
 .../ELF/AMDGPU/generic_versions.test  |  26 ++
 llvm/tools/llvm-readobj/ELFDumper.cpp | 224 --
 52 files changed, 491 insertions(+), 135 deletions(-)
 create mode 100644 
clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_abi_version_600.bc
 rename llvm/test/tools/llvm-readobj/ELF/{amdgpu-elf-headers.test => 
AMDGPU/elf-headers.test} (100%)
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/AMDGPU/generic_versions.s
 create mode 100644 
llvm/test/tools/llvm-readobj/ELF/AMDGPU/generic_versions.test

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index bffdddc28aac60..f9381d0706f447 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4761,9 +4761,9 @@ defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
   HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
   Visibility<[ClangOption, FlangOption, CC1Option, FC1Option]>,
-  Values<"none,4,5">,
+  Values<"none,4,5,6">,
   NormalizedValuesScope<"llvm::CodeObjectVersionKind">,
-  NormalizedValues<["COV_None", "COV_4", "COV_5"]>,
+  NormalizedValues<["COV_None", "COV_4", "COV_5", "COV_6"]>,
   MarshallingInfoEnum, "COV_4">;
 
 defm cumode : SimpleMFlag<"cumode",
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f71dbf1729a1d6..be86731ed912ea 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/

[clang] [clang-repl] Enable native CPU detection by default (PR #77491)

2024-01-10 Thread Stefan Gränitz via cfe-commits

weliveindetail wrote:

Thanks for the quick review!

https://github.com/llvm/llvm-project/pull/77491
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [mlir] [llvm] [flang] [MLIR][LLVM] Add Continuous Loop Peeling transform to SCF (PR #77328)

2024-01-10 Thread via cfe-commits


@@ -105,6 +106,161 @@ static void specializeForLoopForUnrolling(ForOp op) {
   op.erase();
 }
 
+/// Create a new for loop for the remaining iterations (partialIteration)
+/// after a for loop has been peeled. This is followed by correcting the
+/// loop bounds for both loops given the index (splitBound) where the
+/// iteration space is to be split up. Returns failure if the loop can not
+/// be split and no new partialIteration is created.
+static LogicalResult splitLoopHelper(RewriterBase &b, scf::ForOp forOp,
+ scf::ForOp &partialIteration,
+ Value splitBound) {
+  RewriterBase::InsertionGuard guard(b);
+  auto lbInt = getConstantIntValue(forOp.getLowerBound());
+  auto ubInt = getConstantIntValue(forOp.getUpperBound());
+  auto stepInt = getConstantIntValue(forOp.getStep());
+
+  // No specialization necessary if step already divides upper bound evenly.
+  if (lbInt && ubInt && stepInt && (*ubInt - *lbInt) % *stepInt == 0)
+return failure();
+  // No specialization necessary if step size is 1.
+  if (stepInt == static_cast(1))
+return failure();
+
+  // Create ForOp for partial iteration.
+  b.setInsertionPointAfter(forOp);
+  IRMapping map;
+  auto constStepOp =
+  b.create(forOp.getLoc(), *stepInt / 2);
+  // The new for loop for the remaining iterations has half the step size
+  // as continuous peeling requires the step size to diminish exponentially
+  // across subsequent loops.
+  map.map(forOp.getStep(), constStepOp);

muneebkhan85 wrote:

Yes, the purpose is to canonicalize min/max ops inside the new loop body. This 
requires the affine.min/max ops to have the correct step given the step size 
has changed (halved) for the partialIteraton loop.

https://github.com/llvm/llvm-project/pull/77328
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5cc0344 - [clang-repl] Enable native CPU detection by default (#77491)

2024-01-10 Thread via cfe-commits

Author: Stefan Gränitz
Date: 2024-01-10T11:49:01+01:00
New Revision: 5cc03442d392693d0d2457f571cc8fa1736bfe5e

URL: 
https://github.com/llvm/llvm-project/commit/5cc03442d392693d0d2457f571cc8fa1736bfe5e
DIFF: 
https://github.com/llvm/llvm-project/commit/5cc03442d392693d0d2457f571cc8fa1736bfe5e.diff

LOG: [clang-repl] Enable native CPU detection by default (#77491)

We can pass `-mcpu=native` to the clang driver to let it consider the
host CPU when choosing the compile target for `clang-repl`. We can
already achieve this behavior with `clang-repl -Xcc -mcpu=native`, but
it seems like a reasonable default actually.

The trade-off between optimizing for a specific CPU and maximum
compatibility often leans towards the latter for static binaries,
because distributing many versions is cumbersome. However, when
compiling at runtime, we know the exact target CPU and we can use that
to optimize the generated code.

This patch makes a difference especially for "scattered" architectures
like ARM. When cross-compiling for a Raspberry Pi for example, we may
use a stock toolchain like arm-linux-gnueabihf-gcc. The resulting binary
will be compatible with all hardware versions. This is handy, but they
will all have `arm-linux-gnueabihf` as their host triple. Previously,
this caused the clang driver to select triple `armv6kz-linux-gnueabihf`
and CPU `arm1176jzf-s` as the REPL target. After this patch the default
triple and CPU on Raspberry Pi 4b will be `armv8a-linux-gnueabihf` and
`cortex-a72` respectively.

With this patch clang-repl matches the host detection in Orc.

Added: 


Modified: 
clang/lib/Interpreter/Interpreter.cpp

Removed: 




diff  --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index c9fcef5b5b5af1..734fe90d0d89b4 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -148,6 +148,7 @@ IncrementalCompilerBuilder::create(std::vector &ClangArgv) {
   // We do C++ by default; append right after argv[0] if no "-x" given
   ClangArgv.insert(ClangArgv.end(), "-Xclang");
   ClangArgv.insert(ClangArgv.end(), "-fincremental-extensions");
+  ClangArgv.insert(ClangArgv.end(), "-mcpu=native");
   ClangArgv.insert(ClangArgv.end(), "-c");
 
   // Put a dummy C++ file on to ensure there's at least one compile job for the



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Enable native CPU detection by default (PR #77491)

2024-01-10 Thread Stefan Gränitz via cfe-commits

https://github.com/weliveindetail closed 
https://github.com/llvm/llvm-project/pull/77491
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [libc] [mlir] [lld] [libcxx] [libclc] [llvm] [clang] [flang] [libunwind] [lldb] [compiler-rt] [AMDGPU] Fix broken sign-extended subword buffer load combine (PR #77470)

2024-01-10 Thread Jay Foad via cfe-commits

https://github.com/jayfoad closed 
https://github.com/llvm/llvm-project/pull/77470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Rename and enable boolean get, set, create and undef for sme2 (PR #77338)

2024-01-10 Thread Kerry McLaughlin via cfe-commits


@@ -1321,12 +1321,17 @@ def SVSET_3_BF16 : SInst<"svset3[_{d}]", "33id", "b", 
MergeNone, "", [IsTupleSet
 def SVSET_4_BF16 : SInst<"svset4[_{d}]", "44id", "b", MergeNone, "", 
[IsTupleSet], [ImmCheck<1, ImmCheck0_3>]>;
 }
 
-let TargetGuard = "sve2p1" in {
-  def SVGET_2_B : SInst<"svget2[_{d}]", "d2i", "Pc", MergeNone, "", 
[IsTupleGet], [ImmCheck<1, ImmCheck0_1>]>;
-  def SVGET_4_B : SInst<"svget4[_{d}]", "d4i", "Pc", MergeNone, "", 
[IsTupleGet], [ImmCheck<1, ImmCheck0_3>]>;
+let TargetGuard = "sve2p1|sme2" in {
+  def SVGET_2_B : SInst<"svget2_b", "d2i", "Pc", MergeNone, "", [IsTupleGet], 
[ImmCheck<1, ImmCheck0_1>]>;
+  def SVGET_4_B : SInst<"svget4_b", "d4i", "Pc", MergeNone, "", [IsTupleGet], 
[ImmCheck<1, ImmCheck0_3>]>;

kmclaughlin-arm wrote:

Does the `_b` still need to be in square brackets? I think this part of the 
name is optional for get, set & create (but not undef).

https://github.com/llvm/llvm-project/pull/77338
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-01-10 Thread via cfe-commits

NorthBlue333 wrote:

Currently fixing the tests.

https://github.com/llvm/llvm-project/pull/77456
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [clang][AArch64] Add a -mbranch-protection option to enable GCS (PR #75486)

2024-01-10 Thread John Brawn via cfe-commits

john-brawn-arm wrote:

Ping.

https://github.com/llvm/llvm-project/pull/75486
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Ben Shi via cfe-commits

https://github.com/benshi001 created 
https://github.com/llvm/llvm-project/pull/77580

None

>From cb79cad6837dba5d33476c65923ec714507a3fef Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Wed, 10 Jan 2024 19:00:27 +0800
Subject: [PATCH] [clang][analyzer] Support 'tello' and 'fseeko' in the
 StreamChecker

---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp |  4 +
 .../Analysis/Inputs/system-header-simulator.h |  3 +
 clang/test/Analysis/stream-error.c| 82 +++
 3 files changed, 89 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index fbfa101257d5e1..f6e6f3122f3aa7 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -268,8 +268,12 @@ class StreamChecker : public Checker= 0)) {
+clang_analyzer_eval(Ret == -1L); // expected-warning {{TRUE}}
+  }
+  fclose(F);
+}
+
+void error_ftello(void) {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  off_t Ret = ftello(F);
+  if (!(Ret == -1)) {
+clang_analyzer_eval(Ret >= 0);   // expected-warning {{TRUE}}
+  }
+  fclose(F);
+}
+
 void error_fflush_after_fclose(void) {
   FILE *F = tmpfile();
   int Ret;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Ben Shi (benshi001)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/77580.diff


3 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (+4) 
- (modified) clang/test/Analysis/Inputs/system-header-simulator.h (+3) 
- (modified) clang/test/Analysis/stream-error.c (+82) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index fbfa101257d5e1..f6e6f3122f3aa7 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -268,8 +268,12 @@ class StreamChecker : public Checker= 0)) {
+clang_analyzer_eval(Ret == -1L); // expected-warning {{TRUE}}
+  }
+  fclose(F);
+}
+
+void error_ftello(void) {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  off_t Ret = ftello(F);
+  if (!(Ret == -1)) {
+clang_analyzer_eval(Ret >= 0);   // expected-warning {{TRUE}}
+  }
+  fclose(F);
+}
+
 void error_fflush_after_fclose(void) {
   FILE *F = tmpfile();
   int Ret;

``




https://github.com/llvm/llvm-project/pull/77580
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [mlir] [llvm] [clang] [MLIR][LLVM] Add Continuous Loop Peeling transform to SCF (PR #77328)

2024-01-10 Thread Matthias Springer via cfe-commits


@@ -105,6 +106,161 @@ static void specializeForLoopForUnrolling(ForOp op) {
   op.erase();
 }
 
+/// Create a new for loop for the remaining iterations (partialIteration)
+/// after a for loop has been peeled. This is followed by correcting the
+/// loop bounds for both loops given the index (splitBound) where the
+/// iteration space is to be split up. Returns failure if the loop can not
+/// be split and no new partialIteration is created.
+static LogicalResult splitLoopHelper(RewriterBase &b, scf::ForOp forOp,
+ scf::ForOp &partialIteration,
+ Value splitBound) {
+  RewriterBase::InsertionGuard guard(b);
+  auto lbInt = getConstantIntValue(forOp.getLowerBound());
+  auto ubInt = getConstantIntValue(forOp.getUpperBound());
+  auto stepInt = getConstantIntValue(forOp.getStep());
+
+  // No specialization necessary if step already divides upper bound evenly.
+  if (lbInt && ubInt && stepInt && (*ubInt - *lbInt) % *stepInt == 0)
+return failure();
+  // No specialization necessary if step size is 1.
+  if (stepInt == static_cast(1))
+return failure();
+
+  // Create ForOp for partial iteration.
+  b.setInsertionPointAfter(forOp);
+  IRMapping map;
+  auto constStepOp =
+  b.create(forOp.getLoc(), *stepInt / 2);
+  // The new for loop for the remaining iterations has half the step size
+  // as continuous peeling requires the step size to diminish exponentially
+  // across subsequent loops.
+  map.map(forOp.getStep(), constStepOp);

matthias-springer wrote:

Generally speaking, for whatever modification you make to the loop body, you 
have to be sure that the loop body is still computing the same thing as before. 
Just blanket replacing all occurrences of the old step size (even if it's just 
in `affine.min/max` ops) with the new step size may change the semantics of the 
loop.

The only safe way of canonicalizing the loop body that we have at the moment is 
`rewritePeeledMinMaxOp`. This function will look for `affine.min/max` ops and 
select one of the provided options if it can prove that doing so would always 
be correct in the peeled or partial loop.



https://github.com/llvm/llvm-project/pull/77328
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libc++][NFC] Refactor `clang/test/SemaCXX/type-traits.cpp` to use modern `static_assert` (PR #77584)

2024-01-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Amirreza Ashouri (AMP999)


Changes



---

Patch is 188.49 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/77584.diff


1 Files Affected:

- (modified) clang/test/SemaCXX/type-traits.cpp (+1672-1683) 


``diff
diff --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index c5d196a2590f8d..a0ba0f781e0d0d 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3,8 +3,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify 
-std=gnu++17 -fblocks -Wno-deprecated-builtins -Wno-defaulted-function-deleted 
%s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify 
-std=gnu++20 -fblocks -Wno-deprecated-builtins -Wno-defaulted-function-deleted 
%s
 
-#define T(b) (b) ? 1 : -1
-#define F(b) (b) ? -1 : 1
 
 struct NonPOD { NonPOD(int); };
 typedef NonPOD NonPODAr[10];
@@ -214,56 +212,56 @@ struct HasVirtBase : virtual ACompleteType {};
 
 void is_pod()
 {
-  { int arr[T(__is_pod(int))]; }
-  { int arr[T(__is_pod(Enum))]; }
-  { int arr[T(__is_pod(POD))]; }
-  { int arr[T(__is_pod(Int))]; }
-  { int arr[T(__is_pod(IntAr))]; }
-  { int arr[T(__is_pod(Statics))]; }
-  { int arr[T(__is_pod(Empty))]; }
-  { int arr[T(__is_pod(EmptyUnion))]; }
-  { int arr[T(__is_pod(Union))]; }
-  { int arr[T(__is_pod(HasFunc))]; }
-  { int arr[T(__is_pod(HasOp))]; }
-  { int arr[T(__is_pod(HasConv))]; }
-  { int arr[T(__is_pod(HasAssign))]; }
-  { int arr[T(__is_pod(IntArNB))]; }
-  { int arr[T(__is_pod(HasAnonymousUnion))]; }
-  { int arr[T(__is_pod(Vector))]; }
-  { int arr[T(__is_pod(VectorExt))]; }
-  { int arr[T(__is_pod(Derives))]; }
-  { int arr[T(__is_pod(DerivesAr))]; }
-  { int arr[T(__is_pod(DerivesArNB))]; }
-  { int arr[T(__is_pod(DerivesEmpty))]; }
-  { int arr[T(__is_pod(HasPriv))]; }
-  { int arr[T(__is_pod(HasProt))]; }
-  { int arr[T(__is_pod(DerivesHasPriv))]; }
-  { int arr[T(__is_pod(DerivesHasProt))]; }
-
-  { int arr[F(__is_pod(HasCons))]; }
-  { int arr[F(__is_pod(HasCopyAssign))]; }
-  { int arr[F(__is_pod(HasMoveAssign))]; }
-  { int arr[F(__is_pod(HasDest))]; }
-  { int arr[F(__is_pod(HasRef))]; }
-  { int arr[F(__is_pod(HasVirt))]; }
-  { int arr[F(__is_pod(DerivesHasCons))]; }
-  { int arr[F(__is_pod(DerivesHasCopyAssign))]; }
-  { int arr[F(__is_pod(DerivesHasMoveAssign))]; }
-  { int arr[F(__is_pod(DerivesHasDest))]; }
-  { int arr[F(__is_pod(DerivesHasRef))]; }
-  { int arr[F(__is_pod(DerivesHasVirt))]; }
-  { int arr[F(__is_pod(NonPOD))]; }
-  { int arr[F(__is_pod(HasNonPOD))]; }
-  { int arr[F(__is_pod(NonPODAr))]; }
-  { int arr[F(__is_pod(NonPODArNB))]; }
-  { int arr[F(__is_pod(void))]; }
-  { int arr[F(__is_pod(cvoid))]; }
-// { int arr[F(__is_pod(NonPODUnion))]; }
-
-  { int arr[T(__is_pod(ACompleteType))]; }
-  { int arr[F(__is_pod(AnIncompleteType))]; } // expected-error {{incomplete 
type}}
-  { int arr[F(__is_pod(AnIncompleteType[]))]; } // expected-error {{incomplete 
type}}
-  { int arr[F(__is_pod(AnIncompleteType[1]))]; } // expected-error 
{{incomplete type}}
+  static_assert(__is_pod(int), "");
+  static_assert(__is_pod(Enum), "");
+  static_assert(__is_pod(POD), "");
+  static_assert(__is_pod(Int), "");
+  static_assert(__is_pod(IntAr), "");
+  static_assert(__is_pod(Statics), "");
+  static_assert(__is_pod(Empty), "");
+  static_assert(__is_pod(EmptyUnion), "");
+  static_assert(__is_pod(Union), "");
+  static_assert(__is_pod(HasFunc), "");
+  static_assert(__is_pod(HasOp), "");
+  static_assert(__is_pod(HasConv), "");
+  static_assert(__is_pod(HasAssign), "");
+  static_assert(__is_pod(IntArNB), "");
+  static_assert(__is_pod(HasAnonymousUnion), "");
+  static_assert(__is_pod(Vector), "");
+  static_assert(__is_pod(VectorExt), "");
+  static_assert(__is_pod(Derives), "");
+  static_assert(__is_pod(DerivesAr), "");
+  static_assert(__is_pod(DerivesArNB), "");
+  static_assert(__is_pod(DerivesEmpty), "");
+  static_assert(__is_pod(HasPriv), "");
+  static_assert(__is_pod(HasProt), "");
+  static_assert(__is_pod(DerivesHasPriv), "");
+  static_assert(__is_pod(DerivesHasProt), "");
+
+  static_assert(!__is_pod(HasCons), "");
+  static_assert(!__is_pod(HasCopyAssign), "");
+  static_assert(!__is_pod(HasMoveAssign), "");
+  static_assert(!__is_pod(HasDest), "");
+  static_assert(!__is_pod(HasRef), "");
+  static_assert(!__is_pod(HasVirt), "");
+  static_assert(!__is_pod(DerivesHasCons), "");
+  static_assert(!__is_pod(DerivesHasCopyAssign), "");
+  static_assert(!__is_pod(DerivesHasMoveAssign), "");
+  static_assert(!__is_pod(DerivesHasDest), "");
+  static_assert(!__is_pod(DerivesHasRef), "");
+  static_assert(!__is_pod(DerivesHasVirt), "");
+  static_assert(!__is_pod(NonPOD), "");
+  static_assert(!__is_pod(HasNonPOD), "");
+  static_assert(!__is_pod(NonPODAr), "");
+  static_assert(!__is_pod(NonPODArNB), "");
+  static_assert(!__is_pod(void), "");
+  static_assert(!__is_pod(cvoid), 

[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread Bhuminjay Soni via cfe-commits

https://github.com/11happy created 
https://github.com/llvm/llvm-project/pull/77586

**Overview:**
This pull request fixes #38469 where the issue proposes a new static analysis 
check in C++ to discourage the explicit return 0; statement at the end of the 
main() function. As C++ automatically assumes a return 0; in this context, 
having the explicit statement is redundant. The suggested change aims to 
enhance code readability by eliminating unnecessary lines in the main() 
function.

**Testing:**
- Tested the updated code.
- Verified that other functionalities remain unaffected.
![Screenshot from 2024-01-10 
16-53-31](https://github.com/llvm/llvm-project/assets/76656712/818d347e-7325-4d4d-aa0c-bcc611f46931)



**Dependencies:**
- No dependencies on other pull requests.

**CC:**
- @kirillbobyrev  , @AaronBallman 


>From bae95013cd7f937a5496cafcd40a77cc563addb0 Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Wed, 10 Jan 2024 16:48:43 +0530
Subject: [PATCH] Added check for redundant return statement

Signed-off-by: 11happy 
---
 .../clang-tidy/readability/CMakeLists.txt |  1 +
 .../readability/DonotreturnzerocheckCheck.cpp | 54 +++
 .../readability/DonotreturnzerocheckCheck.h   | 30 +++
 .../readability/ReadabilityTidyModule.cpp |  3 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  8 +++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../readability/DoNotReturnZeroCheck.rst  | 25 +
 .../readability/DoNotReturnZeroCheck.cpp  |  8 +++
 8 files changed, 130 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/readability/DoNotReturnZeroCheck.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/DoNotReturnZeroCheck.cpp

diff --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 408c822b861c5f..cb7741d6f56ce7 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -14,6 +14,7 @@ add_clang_library(clangTidyReadabilityModule
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp
+  DonotreturnzerocheckCheck.cpp
   DuplicateIncludeCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionCognitiveComplexityCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
new file mode 100644
index 00..66ea29be3c54a8
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
@@ -0,0 +1,54 @@
+//===--- DonotreturnzerocheckCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DonotreturnzerocheckCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+
+
+namespace clang::tidy::readability {
+  bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
+  return LangOpts.CPlusPlus || LangOpts.C99;
+  }
+
+void DonotreturnzerocheckCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(functionDecl(
+isMain(),returns(asString("int"))
+  ).bind("main"), this);
+}
+
+void DonotreturnzerocheckCheck::check(const MatchFinder::MatchResult &Result) {
+  // FIXME: Add callback implementation.
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("main");
+  if(isCPlusPlusOrC99(Result.Context->getLangOpts())){
+SourceLocation ReturnLoc;
+if (MatchedDecl->hasBody()) {
+  const CompoundStmt *Body = 
dyn_cast(MatchedDecl->getBody());
+  if (Body && !Body->body_empty()) {
+const Stmt *LastStmt = Body->body_back();
+if (const auto *Return = dyn_cast(LastStmt)) {
+  ReturnLoc = Return->getReturnLoc();
+}
+  }
+}
+
+if (ReturnLoc.isValid()) {
+  // Suggest removal of the redundant return statement.
+  diag(ReturnLoc, "redundant 'return 0;' at the end of main")
+  << 
FixItHint::CreateRemoval(CharSourceRange::getTokenRange(ReturnLoc));
+}
+
+  }
+
+}
+
+}
\ No newline at end of file
diff --git 
a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h 
b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
new file mode 100644
index 00..1407b8c1831c9d
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
@@ -0,0 +1,30 @@
+//===--- DonotreturnzerocheckCheck

[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Bhuminjay Soni (11happy)


Changes

**Overview:**
This pull request fixes #38469 where the issue proposes a new static 
analysis check in C++ to discourage the explicit return 0; statement at the end 
of the main() function. As C++ automatically assumes a return 0; in this 
context, having the explicit statement is redundant. The suggested change aims 
to enhance code readability by eliminating unnecessary lines in the main() 
function.

**Testing:**
- Tested the updated code.
- Verified that other functionalities remain unaffected.
![Screenshot from 2024-01-10 
16-53-31](https://github.com/llvm/llvm-project/assets/76656712/818d347e-7325-4d4d-aa0c-bcc611f46931)



**Dependencies:**
- No dependencies on other pull requests.

**CC:**
- @kirillbobyrev  , @AaronBallman 


---
Full diff: https://github.com/llvm/llvm-project/pull/77586.diff


8 Files Affected:

- (modified) clang-tools-extra/clang-tidy/readability/CMakeLists.txt (+1) 
- (added) 
clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp (+54) 
- (added) clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h 
(+30) 
- (modified) clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp 
(+3) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+8) 
- (modified) clang-tools-extra/docs/clang-tidy/checks/list.rst (+1) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/readability/DoNotReturnZeroCheck.rst 
(+25) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/readability/DoNotReturnZeroCheck.cpp 
(+8) 


``diff
diff --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 408c822b861c5f..cb7741d6f56ce7 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -14,6 +14,7 @@ add_clang_library(clangTidyReadabilityModule
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp
+  DonotreturnzerocheckCheck.cpp
   DuplicateIncludeCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionCognitiveComplexityCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
new file mode 100644
index 00..66ea29be3c54a8
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
@@ -0,0 +1,54 @@
+//===--- DonotreturnzerocheckCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DonotreturnzerocheckCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+
+
+namespace clang::tidy::readability {
+  bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
+  return LangOpts.CPlusPlus || LangOpts.C99;
+  }
+
+void DonotreturnzerocheckCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(functionDecl(
+isMain(),returns(asString("int"))
+  ).bind("main"), this);
+}
+
+void DonotreturnzerocheckCheck::check(const MatchFinder::MatchResult &Result) {
+  // FIXME: Add callback implementation.
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("main");
+  if(isCPlusPlusOrC99(Result.Context->getLangOpts())){
+SourceLocation ReturnLoc;
+if (MatchedDecl->hasBody()) {
+  const CompoundStmt *Body = 
dyn_cast(MatchedDecl->getBody());
+  if (Body && !Body->body_empty()) {
+const Stmt *LastStmt = Body->body_back();
+if (const auto *Return = dyn_cast(LastStmt)) {
+  ReturnLoc = Return->getReturnLoc();
+}
+  }
+}
+
+if (ReturnLoc.isValid()) {
+  // Suggest removal of the redundant return statement.
+  diag(ReturnLoc, "redundant 'return 0;' at the end of main")
+  << 
FixItHint::CreateRemoval(CharSourceRange::getTokenRange(ReturnLoc));
+}
+
+  }
+
+}
+
+}
\ No newline at end of file
diff --git 
a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h 
b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
new file mode 100644
index 00..1407b8c1831c9d
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
@@ -0,0 +1,30 @@
+//===--- DonotreturnzerocheckCheck.h - clang-tidy ---*- 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
+//
+//===-

[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread Bhuminjay Soni via cfe-commits

https://github.com/11happy updated 
https://github.com/llvm/llvm-project/pull/77586

>From bae95013cd7f937a5496cafcd40a77cc563addb0 Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Wed, 10 Jan 2024 16:48:43 +0530
Subject: [PATCH 1/2] Added check for redundant return statement

Signed-off-by: 11happy 
---
 .../clang-tidy/readability/CMakeLists.txt |  1 +
 .../readability/DonotreturnzerocheckCheck.cpp | 54 +++
 .../readability/DonotreturnzerocheckCheck.h   | 30 +++
 .../readability/ReadabilityTidyModule.cpp |  3 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  8 +++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../readability/DoNotReturnZeroCheck.rst  | 25 +
 .../readability/DoNotReturnZeroCheck.cpp  |  8 +++
 8 files changed, 130 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/readability/DoNotReturnZeroCheck.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/DoNotReturnZeroCheck.cpp

diff --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 408c822b861c5f..cb7741d6f56ce7 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -14,6 +14,7 @@ add_clang_library(clangTidyReadabilityModule
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp
+  DonotreturnzerocheckCheck.cpp
   DuplicateIncludeCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionCognitiveComplexityCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
new file mode 100644
index 00..66ea29be3c54a8
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
@@ -0,0 +1,54 @@
+//===--- DonotreturnzerocheckCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DonotreturnzerocheckCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+
+
+namespace clang::tidy::readability {
+  bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
+  return LangOpts.CPlusPlus || LangOpts.C99;
+  }
+
+void DonotreturnzerocheckCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(functionDecl(
+isMain(),returns(asString("int"))
+  ).bind("main"), this);
+}
+
+void DonotreturnzerocheckCheck::check(const MatchFinder::MatchResult &Result) {
+  // FIXME: Add callback implementation.
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("main");
+  if(isCPlusPlusOrC99(Result.Context->getLangOpts())){
+SourceLocation ReturnLoc;
+if (MatchedDecl->hasBody()) {
+  const CompoundStmt *Body = 
dyn_cast(MatchedDecl->getBody());
+  if (Body && !Body->body_empty()) {
+const Stmt *LastStmt = Body->body_back();
+if (const auto *Return = dyn_cast(LastStmt)) {
+  ReturnLoc = Return->getReturnLoc();
+}
+  }
+}
+
+if (ReturnLoc.isValid()) {
+  // Suggest removal of the redundant return statement.
+  diag(ReturnLoc, "redundant 'return 0;' at the end of main")
+  << 
FixItHint::CreateRemoval(CharSourceRange::getTokenRange(ReturnLoc));
+}
+
+  }
+
+}
+
+}
\ No newline at end of file
diff --git 
a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h 
b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
new file mode 100644
index 00..1407b8c1831c9d
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h
@@ -0,0 +1,30 @@
+//===--- DonotreturnzerocheckCheck.h - clang-tidy ---*- 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
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DONOTRETURNZEROCHECKCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DONOTRETURNZEROCHECKCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::readability {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readabilit

[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread via cfe-commits

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 8f78dd4b92b44c490d263a4d161850853874859d 
bae95013cd7f937a5496cafcd40a77cc563addb0 -- 
clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp 
clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.h 
clang-tools-extra/test/clang-tidy/checkers/readability/DoNotReturnZeroCheck.cpp 
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
index 66ea29be3c..4a741940bf 100644
--- a/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/DonotreturnzerocheckCheck.cpp
@@ -12,24 +12,21 @@
 
 using namespace clang::ast_matchers;
 
-
-
 namespace clang::tidy::readability {
-  bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
+bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
   return LangOpts.CPlusPlus || LangOpts.C99;
-  }
+}
 
 void DonotreturnzerocheckCheck::registerMatchers(MatchFinder *Finder) {
   // FIXME: Add matchers.
-  Finder->addMatcher(functionDecl(
-isMain(),returns(asString("int"))
-  ).bind("main"), this);
+  Finder->addMatcher(
+  functionDecl(isMain(), returns(asString("int"))).bind("main"), this);
 }
 
 void DonotreturnzerocheckCheck::check(const MatchFinder::MatchResult &Result) {
   // FIXME: Add callback implementation.
   const auto *MatchedDecl = Result.Nodes.getNodeAs("main");
-  if(isCPlusPlusOrC99(Result.Context->getLangOpts())){
+  if (isCPlusPlusOrC99(Result.Context->getLangOpts())) {
 SourceLocation ReturnLoc;
 if (MatchedDecl->hasBody()) {
   const CompoundStmt *Body = 
dyn_cast(MatchedDecl->getBody());
@@ -44,11 +41,10 @@ void DonotreturnzerocheckCheck::check(const 
MatchFinder::MatchResult &Result) {
 if (ReturnLoc.isValid()) {
   // Suggest removal of the redundant return statement.
   diag(ReturnLoc, "redundant 'return 0;' at the end of main")
-  << 
FixItHint::CreateRemoval(CharSourceRange::getTokenRange(ReturnLoc));
+  << FixItHint::CreateRemoval(
+ CharSourceRange::getTokenRange(ReturnLoc));
 }
-
   }
-
 }
 
-}
\ No newline at end of file
+} // namespace clang::tidy::readability
\ No newline at end of file

``




https://github.com/llvm/llvm-project/pull/77586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang]not lookup name containing a dependent type (PR #77587)

2024-01-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/77587

Fixes: #77583
bcd51aaaf8bde4b0ae7a4155d9ce3dec78fe2598 fixed part of template instantiation 
dependent name issues but still missing some cases This patch want to enhance 
the dependent name check

>From f6b9afa26fabb5f9dcea5615c92914bed93ef474 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Wed, 10 Jan 2024 19:27:31 +0800
Subject: [PATCH] [clang]not lookup name containing a dependent type

Fixes: #77583
bcd51aaaf8bde4b0ae7a4155d9ce3dec78fe2598 fixed part of template instantiation 
dependent name issues but still missing some cases
This patch want to enhance the dependent name check
---
 clang/lib/Sema/SemaExprMember.cpp  |  3 ++-
 clang/test/SemaCXX/conversion-function.cpp | 14 +++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 2abec3d86a27d9..32998ae60eafe2 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -782,7 +782,8 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType 
BaseType,
const Scope *S,
ActOnMemberAccessExtraArgs *ExtraArgs) {
   if (BaseType->isDependentType() ||
-  (SS.isSet() && isDependentScopeSpecifier(SS)))
+  (SS.isSet() && isDependentScopeSpecifier(SS)) ||
+  NameInfo.getName().isDependentName())
 return ActOnDependentMemberExpr(Base, BaseType,
 IsArrow, OpLoc,
 SS, TemplateKWLoc, FirstQualifierInScope,
diff --git a/clang/test/SemaCXX/conversion-function.cpp 
b/clang/test/SemaCXX/conversion-function.cpp
index b6e6142d179066..220ae78f2d8246 100644
--- a/clang/test/SemaCXX/conversion-function.cpp
+++ b/clang/test/SemaCXX/conversion-function.cpp
@@ -475,13 +475,21 @@ struct S {
 
 #if __cplusplus >= 201103L
 namespace dependent_conversion_function_id_lookup {
-  template struct A {
+  struct A1 {
+operator int();
+  };
+  template struct C {
+template  using Lookup = decltype(T{}.operator U());
+  };
+  C v{};
+
+  template struct A2 {
 operator T();
   };
-  template struct B : A {
+  template struct B : A2 {
 template using Lookup = decltype(&B::operator U);
   };
   using Result = B::Lookup;
-  using Result = int (A::*)();
+  using Result = int (A2::*)();
 }
 #endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang]not lookup name containing a dependent type (PR #77587)

2024-01-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Congcong Cai (HerrCai0907)


Changes

Fixes: #77583
bcd51aaaf8bde4b0ae7a4155d9ce3dec78fe2598 fixed part of template instantiation 
dependent name issues but still missing some cases This patch want to enhance 
the dependent name check

---
Full diff: https://github.com/llvm/llvm-project/pull/77587.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaExprMember.cpp (+2-1) 
- (modified) clang/test/SemaCXX/conversion-function.cpp (+11-3) 


``diff
diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 2abec3d86a27d9..32998ae60eafe2 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -782,7 +782,8 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType 
BaseType,
const Scope *S,
ActOnMemberAccessExtraArgs *ExtraArgs) {
   if (BaseType->isDependentType() ||
-  (SS.isSet() && isDependentScopeSpecifier(SS)))
+  (SS.isSet() && isDependentScopeSpecifier(SS)) ||
+  NameInfo.getName().isDependentName())
 return ActOnDependentMemberExpr(Base, BaseType,
 IsArrow, OpLoc,
 SS, TemplateKWLoc, FirstQualifierInScope,
diff --git a/clang/test/SemaCXX/conversion-function.cpp 
b/clang/test/SemaCXX/conversion-function.cpp
index b6e6142d179066..220ae78f2d8246 100644
--- a/clang/test/SemaCXX/conversion-function.cpp
+++ b/clang/test/SemaCXX/conversion-function.cpp
@@ -475,13 +475,21 @@ struct S {
 
 #if __cplusplus >= 201103L
 namespace dependent_conversion_function_id_lookup {
-  template struct A {
+  struct A1 {
+operator int();
+  };
+  template struct C {
+template  using Lookup = decltype(T{}.operator U());
+  };
+  C v{};
+
+  template struct A2 {
 operator T();
   };
-  template struct B : A {
+  template struct B : A2 {
 template using Lookup = decltype(&B::operator U);
   };
   using Result = B::Lookup;
-  using Result = int (A::*)();
+  using Result = int (A2::*)();
 }
 #endif

``




https://github.com/llvm/llvm-project/pull/77587
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang] Support -mrvv-vector-bits flag (PR #77588)

2024-01-10 Thread Luke Lau via cfe-commits

https://github.com/lukel97 created 
https://github.com/llvm/llvm-project/pull/77588

This patch adds support for the -mrvv-vector-bits flag in the Flang driver, and
translates them to -mvscale-min/-mvscale-max.

The code was copied from the Clang toolchain (similarly to what was done for
AArch64's -msve-vector-bits flag) so it also supports the same
-mrvv-vector-bits=zvl mode.

Note that Flang doesn't yet define the __riscv_v_fixed_vlen macro, so the help
text has been updated to highlight that it's only defined for Clang.


>From 66f47b300afa5f68934c93fed0b16d7a389cf49d Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Wed, 10 Jan 2024 18:22:03 +0700
Subject: [PATCH] [Flang] Support -mrvv-vector-bits flag

This patch adds support for the -mrvv-vector-bits flag in the Flang driver, and
translates them to -mvscale-min/-mvscale-max.

The code was copied from the Clang toolchain (similarly to what was done for
AArch64's -msve-vector-bits flag) so it also supports the same
-mrvv-vector-bits=zvl mode.

Note that Flang doesn't yet define the __riscv_v_fixed_vlen macro, so the help
text has been updated to highlight that it's only defined for Clang.
---
 clang/include/clang/Driver/Options.td   |  6 ++-
 clang/lib/Driver/ToolChains/Flang.cpp   | 51 +
 clang/lib/Driver/ToolChains/Flang.h |  7 +++
 flang/test/Driver/driver-help-hidden.f90|  2 +
 flang/test/Driver/driver-help.f90   |  2 +
 flang/test/Driver/riscv-rvv-vector-bits.f90 | 51 +
 6 files changed, 117 insertions(+), 2 deletions(-)
 create mode 100644 flang/test/Driver/riscv-rvv-vector-bits.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index bffdddc28aac60..4de738ef27ae8b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4585,11 +4585,13 @@ let Flags = [TargetSpecific] in {
 def menable_experimental_extensions : Flag<["-"], 
"menable-experimental-extensions">, Group,
   HelpText<"Enable use of experimental RISC-V extensions.">;
 def mrvv_vector_bits_EQ : Joined<["-"], "mrvv-vector-bits=">, Group,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Specify the size in bits of an RVV vector register. Defaults to "
"the vector length agnostic value of \"scalable\". Accepts power of 
"
"2 values between 64 and 65536. Also accepts \"zvl\" "
-   "to use the value implied by -march/-mcpu. Value will be reflected "
-   "in __riscv_v_fixed_vlen preprocessor define (RISC-V only)">;
+   "to use the value implied by -march/-mcpu. On Clang, value will be "
+   "reflected in __riscv_v_fixed_vlen preprocessor define (RISC-V "
+   "only)">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group,
   HelpText<"Allow memory accesses to be unaligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 41eaad3bbad0a3..ccb9f75e21e558 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Flang.h"
+#include "Arch/RISCV.h"
 #include "CommonArgs.h"
 
 #include "clang/Basic/CodeGenOptions.h"
@@ -14,6 +15,8 @@
 #include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/RISCVISAInfo.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 
 #include 
 
@@ -203,6 +206,51 @@ void Flang::AddAArch64TargetArgs(const ArgList &Args,
   }
 }
 
+void Flang::AddRISCVTargetArgs(const ArgList &Args,
+   ArgStringList &CmdArgs) const {
+  const llvm::Triple &Triple = getToolChain().getTriple();
+  // Handle -mrvv-vector-bits=
+  if (Arg *A = Args.getLastArg(options::OPT_mrvv_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver &D = getToolChain().getDriver();
+
+// Get minimum VLen from march.
+unsigned MinVLen = 0;
+StringRef Arch = riscv::getRISCVArch(Args, Triple);
+auto ISAInfo = llvm::RISCVISAInfo::parseArchString(
+Arch, /*EnableExperimentalExtensions*/ true);
+// Ignore parsing error.
+if (!errorToBool(ISAInfo.takeError()))
+  MinVLen = (*ISAInfo)->getMinVLen();
+
+// If the value is "zvl", use MinVLen from march. Otherwise, try to parse
+// as integer as long as we have a MinVLen.
+unsigned Bits = 0;
+if (Val.equals("zvl") && MinVLen >= llvm::RISCV::RVVBitsPerBlock) {
+  Bits = MinVLen;
+} else if (!Val.getAsInteger(10, Bits)) {
+  // Only accept power of 2 values beteen RVVBitsPerBlock and 65536 that
+  // at least MinVLen.
+  if (Bits < MinVLen || Bits < llvm::RISCV::RVVBitsPerBlock ||
+  Bits > 65536 || !llvm::isPowerOf2_32(Bits))
+Bits = 0;
+}
+
+// If we got a valid value try to use it.
+if 

[clang] [flang] [Flang] Support -mrvv-vector-bits flag (PR #77588)

2024-01-10 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-flang-driver

@llvm/pr-subscribers-clang

Author: Luke Lau (lukel97)


Changes

This patch adds support for the -mrvv-vector-bits flag in the Flang driver, and
translates them to -mvscale-min/-mvscale-max.

The code was copied from the Clang toolchain (similarly to what was done for
AArch64's -msve-vector-bits flag) so it also supports the same
-mrvv-vector-bits=zvl mode.

Note that Flang doesn't yet define the __riscv_v_fixed_vlen macro, so the help
text has been updated to highlight that it's only defined for Clang.


---
Full diff: https://github.com/llvm/llvm-project/pull/77588.diff


6 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+4-2) 
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+51) 
- (modified) clang/lib/Driver/ToolChains/Flang.h (+7) 
- (modified) flang/test/Driver/driver-help-hidden.f90 (+2) 
- (modified) flang/test/Driver/driver-help.f90 (+2) 
- (added) flang/test/Driver/riscv-rvv-vector-bits.f90 (+51) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index bffdddc28aac60..4de738ef27ae8b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4585,11 +4585,13 @@ let Flags = [TargetSpecific] in {
 def menable_experimental_extensions : Flag<["-"], 
"menable-experimental-extensions">, Group,
   HelpText<"Enable use of experimental RISC-V extensions.">;
 def mrvv_vector_bits_EQ : Joined<["-"], "mrvv-vector-bits=">, Group,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Specify the size in bits of an RVV vector register. Defaults to "
"the vector length agnostic value of \"scalable\". Accepts power of 
"
"2 values between 64 and 65536. Also accepts \"zvl\" "
-   "to use the value implied by -march/-mcpu. Value will be reflected "
-   "in __riscv_v_fixed_vlen preprocessor define (RISC-V only)">;
+   "to use the value implied by -march/-mcpu. On Clang, value will be "
+   "reflected in __riscv_v_fixed_vlen preprocessor define (RISC-V "
+   "only)">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group,
   HelpText<"Allow memory accesses to be unaligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 41eaad3bbad0a3..ccb9f75e21e558 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Flang.h"
+#include "Arch/RISCV.h"
 #include "CommonArgs.h"
 
 #include "clang/Basic/CodeGenOptions.h"
@@ -14,6 +15,8 @@
 #include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/RISCVISAInfo.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 
 #include 
 
@@ -203,6 +206,51 @@ void Flang::AddAArch64TargetArgs(const ArgList &Args,
   }
 }
 
+void Flang::AddRISCVTargetArgs(const ArgList &Args,
+   ArgStringList &CmdArgs) const {
+  const llvm::Triple &Triple = getToolChain().getTriple();
+  // Handle -mrvv-vector-bits=
+  if (Arg *A = Args.getLastArg(options::OPT_mrvv_vector_bits_EQ)) {
+StringRef Val = A->getValue();
+const Driver &D = getToolChain().getDriver();
+
+// Get minimum VLen from march.
+unsigned MinVLen = 0;
+StringRef Arch = riscv::getRISCVArch(Args, Triple);
+auto ISAInfo = llvm::RISCVISAInfo::parseArchString(
+Arch, /*EnableExperimentalExtensions*/ true);
+// Ignore parsing error.
+if (!errorToBool(ISAInfo.takeError()))
+  MinVLen = (*ISAInfo)->getMinVLen();
+
+// If the value is "zvl", use MinVLen from march. Otherwise, try to parse
+// as integer as long as we have a MinVLen.
+unsigned Bits = 0;
+if (Val.equals("zvl") && MinVLen >= llvm::RISCV::RVVBitsPerBlock) {
+  Bits = MinVLen;
+} else if (!Val.getAsInteger(10, Bits)) {
+  // Only accept power of 2 values beteen RVVBitsPerBlock and 65536 that
+  // at least MinVLen.
+  if (Bits < MinVLen || Bits < llvm::RISCV::RVVBitsPerBlock ||
+  Bits > 65536 || !llvm::isPowerOf2_32(Bits))
+Bits = 0;
+}
+
+// If we got a valid value try to use it.
+if (Bits != 0) {
+  unsigned VScaleMin = Bits / llvm::RISCV::RVVBitsPerBlock;
+  CmdArgs.push_back(
+  Args.MakeArgString("-mvscale-max=" + llvm::Twine(VScaleMin)));
+  CmdArgs.push_back(
+  Args.MakeArgString("-mvscale-min=" + llvm::Twine(VScaleMin)));
+} else if (!Val.equals("scalable")) {
+  // Handle the unsupported values passed to mrvv-vector-bits.
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getSpelling() << Val;
+}
+  }
+}
+
 static void addVSDefines(const ToolChain &TC, const ArgList &Args,
  ArgStringList &CmdArg

[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-10 Thread Matthew Devereau via cfe-commits


@@ -460,7 +460,7 @@ void test_svmla_single4_u16(uint32_t slice_base, 
svuint16x4_t zn, svuint16_t zm)
 //
 void test_svmla_single4_s16(uint32_t slice_base, svint16x4_t zn, svint16_t zm) 
__arm_streaming __arm_shared_za
 {
-   SVE_ACLE_FUNC(svmla_single_za32,,_s16,,_vg2x4)(slice_base, zn, zm);
+   SVE_ACLE_FUNC(svmla,_single,_za32,_s16,_vg2x4)(slice_base, zn, zm);
 }

MDevereau wrote:

Since `SVE_ACLE_FUNC` is defined as 
`SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED,A5) A1##A3##A5` The svmla_lane test
`SVE_ACLE_FUNC(svmla_lane_za32,,,_s16,_vg2x4)(slice_base, zn, zm, 7);`
is functionally the same as
`SVE_ACLE_FUNC(svmla_lane_za32,_s16,_vg2x4,,,)(slice_base, zn, zm, 7);`
which is why I didn't update these tests earlier. Do we still want the commas 
to be pushed to the back?

https://github.com/llvm/llvm-project/pull/76711
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-10 Thread Matthew Devereau via cfe-commits

https://github.com/MDevereau edited 
https://github.com/llvm/llvm-project/pull/76711
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-10 Thread Matthew Devereau via cfe-commits

https://github.com/MDevereau edited 
https://github.com/llvm/llvm-project/pull/76711
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Refactor `clang/test/SemaCXX/type-traits.cpp` to use modern `static_assert` (PR #77584)

2024-01-10 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 edited https://github.com/llvm/llvm-project/pull/77584
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-10 Thread Matthew Devereau via cfe-commits

https://github.com/MDevereau updated 
https://github.com/llvm/llvm-project/pull/76711

>From 908da224bd01e4758392a98ba2191185d7296c6a Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Tue, 2 Jan 2024 11:36:33 +
Subject: [PATCH 1/4] [AArch64][SME2] Fix SME2 mla/mls tests

The ACLE defines these builtins as svmla[_single]_za32[_f32]_vg1x2,
which means the SVE_ACLE_FUNC macro should test the overloaded forms as

SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x2)

https://github.com/ARM-software/acle/blob/b88cbf7e9c104100bb5016c848763171494dee44/main/acle.md?plain=1#L10170-L10205
---
 .../test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c  | 8 
 .../test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c  | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
index f52edd9888daa9..2679f9cc8dfd0c 100644
--- a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mla.c
@@ -86,7 +86,7 @@ void test_svmla4_f32(uint32_t slice_base, svfloat32x4_t zn, 
svfloat32x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single2_f32(uint32_t slice_base, svfloat32x2_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za32,,_f32,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmla_single4_f32(
@@ -108,7 +108,7 @@ void test_svmla_single2_f32(uint32_t slice_base, 
svfloat32x2_t zn, svfloat32_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single4_f32(uint32_t slice_base, svfloat32x4_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za32,,_f32,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za32,_f32,_vg1x4)(slice_base, zn, zm);
 }
 
 //
@@ -224,7 +224,7 @@ void test_svmla4_f64(uint32_t slice_base, svfloat64x4_t zn, 
svfloat64x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single2_f64(uint32_t slice_base, svfloat64x2_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za64,,_f64,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za64,_f64,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmla_single4_f64(
@@ -246,7 +246,7 @@ void test_svmla_single2_f64(uint32_t slice_base, 
svfloat64x2_t zn, svfloat64_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmla_single4_f64(uint32_t slice_base, svfloat64x4_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmla_single_za64,,_f64,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmla,_single,_za64,_f64,_vg1x4)(slice_base, zn, zm);
 }
 
 //
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
index 6830a399e91d64..bb4cbbd5308c06 100644
--- a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mls.c
@@ -86,7 +86,7 @@ void test_svmls4_f32(uint32_t slice_base, svfloat32x4_t zn, 
svfloat32x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single2_f32(uint32_t slice_base, svfloat32x2_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za32,,_f32,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za32,_f32,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmls_single4_f32(
@@ -108,7 +108,7 @@ void test_svmls_single2_f32(uint32_t slice_base, 
svfloat32x2_t zn, svfloat32_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single4_f32(uint32_t slice_base, svfloat32x4_t zn, svfloat32_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za32,,_f32,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za32,_f32,_vg1x4)(slice_base, zn, zm);
 }
 
 //
@@ -224,7 +224,7 @@ void test_svmls4_f64(uint32_t slice_base, svfloat64x4_t zn, 
svfloat64x4_t zm) __
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single2_f64(uint32_t slice_base, svfloat64x2_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za64,,_f64,,_vg1x2)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za64,_f64,_vg1x2)(slice_base, zn, zm);
 }
 
 // CHECK-LABEL: @test_svmls_single4_f64(
@@ -246,7 +246,7 @@ void test_svmls_single2_f64(uint32_t slice_base, 
svfloat64x2_t zn, svfloat64_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single4_f64(uint32_t slice_base, svfloat64x4_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za64,,_f64,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za64,_f64,_vg1x4)(slice_base, zn, zm);
 }
 
 //

>From e09efe2659db596a60b61f984648fd9fb37b2a9c Mon Sep 17 00:00:00 2001
From: Matt Devereau 
Date: Thu, 4 Jan 2024 16:47:17 +
Subject: [PATCH 2/4] Update acle_sme2_mlal.c, acle_sme2

[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread Congcong Cai via cfe-commits


@@ -0,0 +1,30 @@
+//===--- DonotreturnzerocheckCheck.h - clang-tidy ---*- 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
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DONOTRETURNZEROCHECKCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DONOTRETURNZEROCHECKCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::readability {
+
+/// FIXME: Write a short description.

HerrCai0907 wrote:

Copy description from docs

https://github.com/llvm/llvm-project/pull/77586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread Congcong Cai via cfe-commits


@@ -0,0 +1,50 @@
+//===--- DonotreturnzerocheckCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DonotreturnzerocheckCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
+  return LangOpts.CPlusPlus || LangOpts.C99;
+}
+
+void DonotreturnzerocheckCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(
+  functionDecl(isMain(), returns(asString("int"))).bind("main"), this);
+}
+
+void DonotreturnzerocheckCheck::check(const MatchFinder::MatchResult &Result) {
+  // FIXME: Add callback implementation.

HerrCai0907 wrote:

clean code

https://github.com/llvm/llvm-project/pull/77586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread Congcong Cai via cfe-commits


@@ -0,0 +1,50 @@
+//===--- DonotreturnzerocheckCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DonotreturnzerocheckCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
+  return LangOpts.CPlusPlus || LangOpts.C99;
+}
+
+void DonotreturnzerocheckCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(
+  functionDecl(isMain(), returns(asString("int"))).bind("main"), this);
+}
+
+void DonotreturnzerocheckCheck::check(const MatchFinder::MatchResult &Result) {
+  // FIXME: Add callback implementation.
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("main");
+  if (isCPlusPlusOrC99(Result.Context->getLangOpts())) {

HerrCai0907 wrote:

move it to `bool isLanguageVersionSupported(const LangOptions &LangOpts) const 
override`

https://github.com/llvm/llvm-project/pull/77586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread Congcong Cai via cfe-commits


@@ -0,0 +1,50 @@
+//===--- DonotreturnzerocheckCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DonotreturnzerocheckCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+bool isCPlusPlusOrC99(const LangOptions &LangOpts) {
+  return LangOpts.CPlusPlus || LangOpts.C99;
+}
+
+void DonotreturnzerocheckCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: Add matchers.
+  Finder->addMatcher(
+  functionDecl(isMain(), returns(asString("int"))).bind("main"), this);
+}
+
+void DonotreturnzerocheckCheck::check(const MatchFinder::MatchResult &Result) {
+  // FIXME: Add callback implementation.
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("main");
+  if (isCPlusPlusOrC99(Result.Context->getLangOpts())) {
+SourceLocation ReturnLoc;
+if (MatchedDecl->hasBody()) {
+  const CompoundStmt *Body = 
dyn_cast(MatchedDecl->getBody());
+  if (Body && !Body->body_empty()) {
+const Stmt *LastStmt = Body->body_back();
+if (const auto *Return = dyn_cast(LastStmt)) {
+  ReturnLoc = Return->getReturnLoc();
+}

HerrCai0907 wrote:

redundant brace

https://github.com/llvm/llvm-project/pull/77586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-10 Thread Matthew Devereau via cfe-commits


@@ -460,7 +460,7 @@ void test_svmla_single4_u16(uint32_t slice_base, 
svuint16x4_t zn, svuint16_t zm)
 //
 void test_svmla_single4_s16(uint32_t slice_base, svint16x4_t zn, svint16_t zm) 
__arm_streaming __arm_shared_za
 {
-   SVE_ACLE_FUNC(svmla_single_za32,,_s16,,_vg2x4)(slice_base, zn, zm);
+   SVE_ACLE_FUNC(svmla,_single,_za32,_s16,_vg2x4)(slice_base, zn, zm);
 }

MDevereau wrote:

It was trivial to change them so I just went ahead and did it.

https://github.com/llvm/llvm-project/pull/76711
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-10 Thread Matthew Devereau via cfe-commits


@@ -494,7 +494,7 @@ void test_svmls_lane1_f16(uint32_t slice_base, svfloat16_t 
zn, svfloat16_t zm) _
 //
 void test_svmls_lane1_bf16(uint32_t slice_base, svbfloat16_t zn, svbfloat16_t 
zm) __arm_streaming __arm_shared_za
 {
-   SVE_ACLE_FUNC(svmls_lane_za32,,_bf16,,_vg2x1)(slice_base, zn, zm, 7);
+   SVE_ACLE_FUNC(svmls_lane_za32,_bf16,_vg2x1,,)(slice_base, zn, zm, 7);

MDevereau wrote:

Oops. Fixed.

https://github.com/llvm/llvm-project/pull/76711
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang] [AMDGPU][GFX12] Default component broadcast store (PR #76212)

2024-01-10 Thread Mariusz Sikora via cfe-commits

mariusz-sikora-at-amd wrote:

ping @arsenm 

https://github.com/llvm/llvm-project/pull/76212
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME2] Fix PSEL builtin predicates (PR #77097)

2024-01-10 Thread Dinar Temirbulatov via cfe-commits

dtemirbulatov wrote:

LGTM.

https://github.com/llvm/llvm-project/pull/77097
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [flang][driver] Add support for -isysroot in the frontend (PR #77365)

2024-01-10 Thread Leandro Lupori via cfe-commits

https://github.com/luporl updated 
https://github.com/llvm/llvm-project/pull/77365

>From 01a2a8d315af2edb9fe3f0c9b57b5c74935521f1 Mon Sep 17 00:00:00 2001
From: Leandro Lupori 
Date: Mon, 8 Jan 2024 16:37:54 -0300
Subject: [PATCH 1/7] [flang][driver] Add support for -isysroot in the frontend

If DEFAULT_SYSROOT is not specfied when building flang, then the
-isysroot flag is needed to link binaries against system libraries
on Darwin. It's also needed when linking against a non-default
sysroot.
---
 clang/include/clang/Driver/Options.td|  2 +-
 flang/test/Driver/driver-help-hidden.f90 |  1 +
 flang/test/Driver/driver-help.f90|  1 +
 flang/test/Driver/isysroot.f90   | 12 
 4 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Driver/isysroot.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6aff37f1336871..f42e9c7eb92a67 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4265,7 +4265,7 @@ def iquote : JoinedOrSeparate<["-"], "iquote">, 
Group,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Add directory to QUOTE include search path">, 
MetaVarName<"">;
 def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group,
-  Visibility<[ClangOption, CC1Option]>,
+  Visibility<[ClangOption, CC1Option, FlangOption]>,
   HelpText<"Set the system root directory (usually /)">, MetaVarName<"">,
   MarshallingInfoString, [{"/"}]>;
 def isystem : JoinedOrSeparate<["-"], "isystem">, Group,
diff --git a/flang/test/Driver/driver-help-hidden.f90 
b/flang/test/Driver/driver-help-hidden.f90
index 9a11a7a571ffcc..aca043d0ea 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -111,6 +111,7 @@
 ! CHECK-NEXT: -g  Generate source-level debug information
 ! CHECK-NEXT: --help-hidden   Display help for hidden options
 ! CHECK-NEXT: -help   Display available options
+! CHECK-NEXT: -isysroot  Set the system root directory (usually /)
 ! CHECK-NEXT: -I Add directory to the end of the list of 
include search paths
 ! CHECK-NEXT: -L Add directory to library search path
 ! CHECK-NEXT: -march=  For a list of available architectures 
for the target use '-mcpu=help'
diff --git a/flang/test/Driver/driver-help.f90 
b/flang/test/Driver/driver-help.f90
index e0e74dc56f331e..07189264104592 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -97,6 +97,7 @@
 ! HELP-NEXT: -g  Generate source-level debug information
 ! HELP-NEXT: --help-hidden   Display help for hidden options
 ! HELP-NEXT: -help   Display available options
+! HELP-NEXT: -isysroot  Set the system root directory (usually /)
 ! HELP-NEXT: -I Add directory to the end of the list of 
include search paths
 ! HELP-NEXT: -L Add directory to library search path
 ! HELP-NEXT: -march=  For a list of available architectures for 
the target use '-mcpu=help'
diff --git a/flang/test/Driver/isysroot.f90 b/flang/test/Driver/isysroot.f90
new file mode 100644
index 00..70d2fc0345ce50
--- /dev/null
+++ b/flang/test/Driver/isysroot.f90
@@ -0,0 +1,12 @@
+! Verify that the -isysroot flag is known to the frontend and, on Darwin,
+! is passed on to the linker.
+
+! RUN: %flang -### --target=aarch64-apple-darwin -isysroot /path/to/sysroot \
+! RUN:%s 2>&1 | FileCheck %s --check-prefix=CHECK-DARWIN
+! RUN: %flang -### --target=aarch64-linux-gnu -isysroot /path/to/sysroot \
+! RUN:%s 2>&1 | FileCheck %s --check-prefix=CHECK-LINUX
+
+! CHECK-DARWIN: "{{.*}}/ld" {{.*}}"-syslibroot" "/path/to/sysroot"
+! Unused on Linux.
+! CHECK-LINUX: warning: argument unused during compilation: '-isysroot 
/path/to/sysroot'
+! CHECK-LINUX-NOT: /path/to/sysroot

>From b12c6abdffcdf1972db6b1ec59c910c92eb38f9d Mon Sep 17 00:00:00 2001
From: Leandro Lupori 
Date: Tue, 9 Jan 2024 08:45:10 -0300
Subject: [PATCH 2/7] Fix test on Windows

---
 flang/test/Driver/isysroot.f90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/test/Driver/isysroot.f90 b/flang/test/Driver/isysroot.f90
index 70d2fc0345ce50..b3871b352fcfb2 100644
--- a/flang/test/Driver/isysroot.f90
+++ b/flang/test/Driver/isysroot.f90
@@ -6,7 +6,7 @@
 ! RUN: %flang -### --target=aarch64-linux-gnu -isysroot /path/to/sysroot \
 ! RUN:%s 2>&1 | FileCheck %s --check-prefix=CHECK-LINUX
 
-! CHECK-DARWIN: "{{.*}}/ld" {{.*}}"-syslibroot" "/path/to/sysroot"
+! CHECK-DARWIN: "{{.*[\/]}}ld" {{.*}}"-syslibroot" "/path/to/sysroot"
 ! Unused on Linux.
 ! CHECK-LINUX: warning: argument unused during compilation: '-isysroot 
/path/to/sysroot'
 ! CHECK-LINUX-NOT: /path/to/sysroot

>From c47d15b3e947e4a55de8b7c276dca1eacfa7caa4 Mon Sep 17 00:00:00 2001
From: Leandro Lupori 
Date: Tue, 9 Jan 2024 09:27:

[flang] [clang] [flang][driver] Add support for -isysroot in the frontend (PR #77365)

2024-01-10 Thread Leandro Lupori via cfe-commits

luporl wrote:

Thanks for the review and all the suggestions!

https://github.com/llvm/llvm-project/pull/77365
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix behavior of `__is_trivially_relocatable(volatile int)` (PR #77092)

2024-01-10 Thread Amirreza Ashouri via cfe-commits

https://github.com/AMP999 updated 
https://github.com/llvm/llvm-project/pull/77092

>From 5d8204ef66bea614d614b5c16a2ddf765402f710 Mon Sep 17 00:00:00 2001
From: Amirreza Ashouri 
Date: Wed, 3 Jan 2024 23:23:14 +0330
Subject: [PATCH] [clang] Fix behavior of __is_trivially_relocatable(volatile
 int)

Consistent with `__is_trivially_copyable(volatile int) == true`
and `__is_trivially_relocatable(volatile Trivial) == true`,
`__is_trivially_relocatable(volatile int)` should also be `true`.

Fixes https://github.com/llvm/llvm-project/issues/77091

[clang] [test] New tests for __is_trivially_relocatable(cv-qualified type)
---
 clang/docs/ReleaseNotes.rst|  9 ++---
 clang/lib/AST/Type.cpp |  2 ++
 clang/test/SemaCXX/type-traits.cpp | 31 ++
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 37f8bbc89d8949..0fc10a77a73964 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -664,9 +664,6 @@ Bug Fixes in This Version
 - Fix crash during code generation of C++ coroutine initial suspend when the 
return
   type of await_resume is not trivially destructible.
   Fixes (`#63803 `_)
-- ``__is_trivially_relocatable`` no longer returns true for non-object types
-  such as references and functions.
-  Fixes (`#67498 `_)
 - Fix crash when the object used as a ``static_assert`` message has ``size`` 
or ``data`` members
   which are not member functions.
 - Support UDLs in ``static_assert`` message.
@@ -699,6 +696,12 @@ Bug Fixes in This Version
 - Clang now accepts recursive non-dependent calls to functions with deduced
   return type.
   Fixes (`#71015 `_)
+- ``__is_trivially_relocatable`` no longer returns ``true`` for non-object 
types
+  such as references and functions, and no longer returns ``false`` for 
volatile-qualified types.
+  Fixes (`#67498 `_) and
+  (`#77091 `_)
+
+
 - Fix assertion failure when initializing union containing struct with
   flexible array member using empty initializer list.
   Fixes (`#77085 `_)
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index b419fc8836b032..aa797de099b0c9 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2669,6 +2669,8 @@ bool QualType::isTriviallyRelocatableType(const 
ASTContext &Context) const {
 return false;
   } else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
 return RD->canPassInRegisters();
+  } else if (BaseElementType.isTriviallyCopyableType(Context)) {
+return true;
   } else {
 switch (isNonTrivialToPrimitiveDestructiveMove()) {
 case PCK_Trivial:
diff --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index c5d196a2590f8d..492f08142591a9 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3092,6 +3092,8 @@ namespace is_trivially_relocatable {
 static_assert(!__is_trivially_relocatable(void), "");
 static_assert(__is_trivially_relocatable(int), "");
 static_assert(__is_trivially_relocatable(int[]), "");
+static_assert(__is_trivially_relocatable(const int), "");
+static_assert(__is_trivially_relocatable(volatile int), "");
 
 enum Enum {};
 static_assert(__is_trivially_relocatable(Enum), "");
@@ -3103,7 +3105,28 @@ static_assert(__is_trivially_relocatable(Union[]), "");
 
 struct Trivial {};
 static_assert(__is_trivially_relocatable(Trivial), "");
+static_assert(__is_trivially_relocatable(const Trivial), "");
+static_assert(__is_trivially_relocatable(volatile Trivial), "");
+
 static_assert(__is_trivially_relocatable(Trivial[]), "");
+static_assert(__is_trivially_relocatable(const Trivial[]), "");
+static_assert(__is_trivially_relocatable(volatile Trivial[]), "");
+
+static_assert(__is_trivially_relocatable(int[10]), "");
+static_assert(__is_trivially_relocatable(const int[10]), "");
+static_assert(__is_trivially_relocatable(volatile int[10]), "");
+
+static_assert(__is_trivially_relocatable(int[10][10]), "");
+static_assert(__is_trivially_relocatable(const int[10][10]), "");
+static_assert(__is_trivially_relocatable(volatile int[10][10]), "");
+
+static_assert(__is_trivially_relocatable(int[]), "");
+static_assert(__is_trivially_relocatable(const int[]), "");
+static_assert(__is_trivially_relocatable(volatile int[]), "");
+
+static_assert(__is_trivially_relocatable(int[][10]), "");
+static_assert(__is_trivially_relocatable(const int[][10]), "");
+static_assert(__is_trivially_relocatable(volatile int[][10]), "");
 
 struct Incomplete; // expected-note {{forward declaration of 
'is_trivially_relocatable::Incomplete'}}
 bool unused = __is_trivially_relocatable(Incomplete);

[clang] [Clang][SME2] Fix PSEL builtin predicates (PR #77097)

2024-01-10 Thread Dinar Temirbulatov via cfe-commits

https://github.com/dtemirbulatov approved this pull request.


https://github.com/llvm/llvm-project/pull/77097
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [flang][driver] Add support for -isysroot in the frontend (PR #77365)

2024-01-10 Thread Leandro Lupori via cfe-commits




luporl wrote:

I guess I was so focused on testing executables on Darwin that I forgot this 
test also applies to other targets.
Let's hope it doesn't introduce a failure on any target.

https://github.com/llvm/llvm-project/pull/77365
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add new check: do not return 0; at the end of main() in C++ (PR #77586)

2024-01-10 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

I'm not fan about this check. For me there is no use case for it.
For sure it's not readability, simply because explicit return is more readable, 
and people who do not know that main by default will return 0 may even consider 
this check a bug, as why all functions got return but not this. Other issue is 
that many projects enable all readability checks, and as this one is 
controversial and not common it shouldn't be under readability, more like misc. 
There are many things that aren't needed, for example compiler is able to 
generate destructor, but still rule of 3/5 require it in some cases to be done 
explicitly, same is with return 0, there could be easily a check that could 
enforce explicit return in all functions, and that would also be readability. 

As for the check:
- wrong name
- wrong category, it should be more a 'misc' for me
- in current form it will catch also 'return 1';
I would say that if this check had to exists (i still cannot find use case for 
it), then it should be configurable to enforce 'return 0' or enforce lack of 
'return 0'. And left configured to an most safe/common approach. What if 
someone wanted to do 'return 1', but forget to put return, and compiler didn't 
warn.

https://github.com/llvm/llvm-project/pull/77586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [clang-tools-extra] [mlir] [emacs] Fix Emacs library formatting (PR #76110)

2024-01-10 Thread Benjamin Kramer via cfe-commits

https://github.com/d0k approved this pull request.

I don't know anything about Emacs, but if the version field is required I see 
no harm in adding it.

https://github.com/llvm/llvm-project/pull/76110
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5b4abae - [emacs] Fix Emacs library formatting (#76110)

2024-01-10 Thread via cfe-commits

Author: darkfeline
Date: 2024-01-10T13:14:21+01:00
New Revision: 5b4abae7630572c96a736faa1f09b1a3c37201a2

URL: 
https://github.com/llvm/llvm-project/commit/5b4abae7630572c96a736faa1f09b1a3c37201a2
DIFF: 
https://github.com/llvm/llvm-project/commit/5b4abae7630572c96a736faa1f09b1a3c37201a2.diff

LOG: [emacs] Fix Emacs library formatting (#76110)

This makes it easier to ship/install these using the builtin Emacs
package format (in particular, a Version is required).

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
clang/tools/clang-format/clang-format.el
clang/tools/clang-rename/clang-rename.el
llvm/utils/emacs/tablegen-mode.el
mlir/utils/emacs/mlir-lsp-client.el
mlir/utils/emacs/mlir-mode.el

Removed: 




diff  --git a/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el 
b/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
index 272f282c47f5fc..f3a949f8c1b552 100644
--- a/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
+++ b/clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
@@ -1,5 +1,6 @@
 ;;; clang-include-fixer.el --- Emacs integration of the clang include fixer  
-*- lexical-binding: t; -*-
 
+;; Version: 0.1.0
 ;; Keywords: tools, c
 ;; Package-Requires: ((cl-lib "0.5") (json "1.2") (let-alist "1.0.4"))
 

diff  --git a/clang/tools/clang-format/clang-format.el 
b/clang/tools/clang-format/clang-format.el
index 30ac7501afcb61..f43bf063c62970 100644
--- a/clang/tools/clang-format/clang-format.el
+++ b/clang/tools/clang-format/clang-format.el
@@ -1,5 +1,6 @@
 ;;; clang-format.el --- Format code using clang-format  -*- lexical-binding: 
t; -*-
 
+;; Version: 0.1.0
 ;; Keywords: tools, c
 ;; Package-Requires: ((cl-lib "0.3"))
 ;; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

diff  --git a/clang/tools/clang-rename/clang-rename.el 
b/clang/tools/clang-rename/clang-rename.el
index b6c3ed4c686b76..3f47c11e2c752e 100644
--- a/clang/tools/clang-rename/clang-rename.el
+++ b/clang/tools/clang-rename/clang-rename.el
@@ -1,5 +1,6 @@
 ;;; clang-rename.el --- Renames every occurrence of a symbol found at 
.  -*- lexical-binding: t; -*-
 
+;; Version: 0.1.0
 ;; Keywords: tools, c
 
 ;;; Commentary:

diff  --git a/llvm/utils/emacs/tablegen-mode.el 
b/llvm/utils/emacs/tablegen-mode.el
index 330da465887053..b1cc1cb36c06e5 100644
--- a/llvm/utils/emacs/tablegen-mode.el
+++ b/llvm/utils/emacs/tablegen-mode.el
@@ -1,6 +1,7 @@
 ;;; tablegen-mode.el --- Major mode for TableGen description files (part of 
LLVM project)
 
 ;; Maintainer:  The LLVM team, http://llvm.org/
+;; Version: 1.0
 
 ;;; Commentary:
 ;; A major mode for TableGen description files in LLVM.

diff  --git a/mlir/utils/emacs/mlir-lsp-client.el 
b/mlir/utils/emacs/mlir-lsp-client.el
index 09dfa835deccdc..4397a55e7206ac 100644
--- a/mlir/utils/emacs/mlir-lsp-client.el
+++ b/mlir/utils/emacs/mlir-lsp-client.el
@@ -14,6 +14,8 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 
+;; Version: 0.1.0
+
 ;;; Commentary:
 
 ;; LSP clinet to use with `mlir-mode' that uses `mlir-lsp-server' or any

diff  --git a/mlir/utils/emacs/mlir-mode.el b/mlir/utils/emacs/mlir-mode.el
index 69056ba3620eb8..e5947df03f86c8 100644
--- a/mlir/utils/emacs/mlir-mode.el
+++ b/mlir/utils/emacs/mlir-mode.el
@@ -14,6 +14,8 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 
+;; Version: 0.1.0
+
 ;;; Commentary:
 
 ;; Major mode for editing MLIR files.
@@ -96,5 +98,4 @@
 (add-to-list 'auto-mode-alist (cons "\\.mlirbc\\'" 'mlir-mode))
 
 (provide 'mlir-mode)
-
 ;;; mlir-mode.el ends here



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   >