[clang] [RISCV] Support __riscv_v_fixed_vlen for vbool types. (PR #76551)

2024-01-14 Thread Craig Topper via cfe-commits


@@ -2415,7 +2415,10 @@ only be a power of 2 between 64 and 65536.
 For types where LMUL!=1, ``__riscv_v_fixed_vlen`` needs to be scaled by the 
LMUL
 of the type before passing to the attribute.
 
-``vbool*_t`` types are not supported at this time.
+For ``vbool*_t`` types, ``__riscv_v_fixed_vlen`` needs to be divided by the
+number from the type name. For example, ``vbool8_t`` needs to use

topperc wrote:

It could, but the intention was that the value passed to the attribute should 
be the size of the type. That's the way LMUL is handled. LMUL 2 needs to pass 
2*__riscv_v_fixed_vlen.

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Brandon Wu via cfe-commits

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Brandon Wu via cfe-commits


@@ -416,8 +416,10 @@ class RVVIntrinsic {
   RVVTypePtr getOutputType() const { return OutputType; }
   const RVVTypes () const { return InputTypes; }
   llvm::StringRef getBuiltinName() const { return BuiltinName; }
-  llvm::StringRef getName() const { return Name; }
-  llvm::StringRef getOverloadedName() const { return OverloadedName; }
+  llvm::StringRef getName() const { return "__riscv_" + Name; }

4vtomat wrote:

Isn't it returning *this?
https://cplusplus.com/reference/string/string/operator+=/

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Brandon Wu via cfe-commits


@@ -463,7 +464,7 @@ void 
RISCVIntrinsicManagerImpl::CreateRVVIntrinsicDecl(LookupResult ,
 bool RISCVIntrinsicManagerImpl::CreateIntrinsicIfFound(LookupResult ,
IdentifierInfo *II,
Preprocessor ) {
-  StringRef Name = II->getName();
+  StringRef Name = II->getName().substr(8);

4vtomat wrote:

Yes, if it doesn't match, it won't create the intrinsic.

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Craig Topper via cfe-commits


@@ -463,7 +464,7 @@ void 
RISCVIntrinsicManagerImpl::CreateRVVIntrinsicDecl(LookupResult ,
 bool RISCVIntrinsicManagerImpl::CreateIntrinsicIfFound(LookupResult ,
IdentifierInfo *II,
Preprocessor ) {
-  StringRef Name = II->getName();
+  StringRef Name = II->getName().substr(8);

topperc wrote:

Or are you assuming that if the string doesn't start with "__riscv" then we'll 
produce a garbage string that won't match something in `OverloadIntrinsics`?

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Craig Topper via cfe-commits


@@ -463,7 +464,7 @@ void 
RISCVIntrinsicManagerImpl::CreateRVVIntrinsicDecl(LookupResult ,
 bool RISCVIntrinsicManagerImpl::CreateIntrinsicIfFound(LookupResult ,
IdentifierInfo *II,
Preprocessor ) {
-  StringRef Name = II->getName();
+  StringRef Name = II->getName().substr(8);

topperc wrote:

I don't follow. If the name can start with things other than "__riscv_" why is 
the substr(8) ok?

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Brandon Wu via cfe-commits


@@ -380,14 +380,14 @@ void RISCVIntrinsicManagerImpl::InitRVVIntrinsic(
 OverloadedName += "_" + OverloadedSuffixStr.str();
 
   // clang built-in function name, e.g. __builtin_rvv_vadd.
-  std::string BuiltinName = "__builtin_rvv_" + std::string(Record.Name);
+  std::string BuiltinName = std::string(Record.Name);
 
   RVVIntrinsic::updateNamesAndPolicy(IsMasked, HasPolicy, Name, BuiltinName,
  OverloadedName, PolicyAttrs,
  Record.HasFRMRoundModeOp);
 
   // Put into IntrinsicList.
-  uint32_t Index = IntrinsicList.size();
+  uint16_t Index = IntrinsicList.size();

4vtomat wrote:

Currently we have 54848 RVV intrinsics.

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Craig Topper via cfe-commits


@@ -416,8 +416,10 @@ class RVVIntrinsic {
   RVVTypePtr getOutputType() const { return OutputType; }
   const RVVTypes () const { return InputTypes; }
   llvm::StringRef getBuiltinName() const { return BuiltinName; }
-  llvm::StringRef getName() const { return Name; }
-  llvm::StringRef getOverloadedName() const { return OverloadedName; }
+  llvm::StringRef getName() const { return "__riscv_" + Name; }

topperc wrote:

`Name` is a std::string. The addition creates a new temporary std::string. That 
only has a lifetime of the body of the function. The StringRef points to the 
temporary std::string.

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


[clang-tools-extra] [clang-tid]fix modernize-use-auto incorrect fix hints for pointer (PR #77943)

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


@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy -check-suffix=REMOVE %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: {modernize-use-auto.RemoveStars: 'true', 
modernize-use-auto.MinTypeNameLength: '0'}}"
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: {modernize-use-auto.RemoveStars: 'false', 
modernize-use-auto.MinTypeNameLength: '0'}}"
+
+void pointerToFunction() {
+  void (*(*(f1)))() = static_cast(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing
+  // CHECK-FIXES-REMOVE: auto f1 =
+  // CHECK-FIXES: auto *f1 =
+}
+
+void pointerToArray() {
+  int(*a1)[2] = new int[10][2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing
+  // CHECK-FIXES-REMOVE: auto a1 =
+  // CHECK-FIXES: auto *a1 =
+}

PiotrZSL wrote:

Add test with member function pointer.

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


[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)

2024-01-14 Thread Rishabh Bali via cfe-commits

https://github.com/Ris-Bali updated 
https://github.com/llvm/llvm-project/pull/71220

>From 0948e11b508e3f978f76a639f27101c8825250c7 Mon Sep 17 00:00:00 2001
From: Rishabh Bali 
Date: Sun, 14 Jan 2024 22:50:06 +0530
Subject: [PATCH 1/4] Port Atomicexpandpass to new PM

---
 llvm/include/llvm/CodeGen/AtomicExpandUtils.h |   4 +-
 llvm/include/llvm/CodeGen/ExpandAtomic.h  |  30 
 .../llvm/CodeGen/MachinePassRegistry.def  |   2 +-
 llvm/include/llvm/CodeGen/Passes.h|   8 +-
 .../llvm/CodeGen/TargetSubtargetInfo.h|   2 +-
 llvm/include/llvm/InitializePasses.h  |   2 +-
 llvm/lib/CodeGen/CMakeLists.txt   |   2 +-
 llvm/lib/CodeGen/CodeGen.cpp  |   2 +-
 ...micExpandPass.cpp => ExpandAtomicPass.cpp} | 149 +++---
 llvm/lib/CodeGen/TargetSubtargetInfo.cpp  |   2 +-
 llvm/lib/Passes/PassBuilder.cpp   |   1 +
 llvm/lib/Passes/PassRegistry.def  |   1 +
 .../Target/AArch64/AArch64TargetMachine.cpp   |   2 +-
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp |   2 +-
 llvm/lib/Target/ARC/ARCTargetMachine.cpp  |   2 +-
 llvm/lib/Target/ARM/ARMTargetMachine.cpp  |   2 +-
 llvm/lib/Target/BPF/BPFTargetMachine.cpp  |   2 +-
 llvm/lib/Target/CSKY/CSKYTargetMachine.cpp|   2 +-
 .../Target/Hexagon/HexagonTargetMachine.cpp   |   2 +-
 llvm/lib/Target/Lanai/LanaiTargetMachine.cpp  |   2 +-
 .../LoongArch/LoongArchTargetMachine.cpp  |   2 +-
 llvm/lib/Target/M68k/M68kTargetMachine.cpp|   2 +-
 .../lib/Target/MSP430/MSP430TargetMachine.cpp |   2 +-
 llvm/lib/Target/Mips/MipsTargetMachine.cpp|   2 +-
 llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp  |   2 +-
 .../PowerPC/PPCExpandAtomicPseudoInsts.cpp|   2 +-
 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp  |   2 +-
 llvm/lib/Target/RISCV/RISCVTargetMachine.cpp  |   2 +-
 llvm/lib/Target/Sparc/SparcTargetMachine.cpp  |   2 +-
 .../Target/SystemZ/SystemZTargetMachine.cpp   |   2 +-
 llvm/lib/Target/VE/VETargetMachine.cpp|   2 +-
 .../WebAssembly/WebAssemblySubtarget.cpp  |   2 +-
 .../Target/WebAssembly/WebAssemblySubtarget.h |   2 +-
 .../WebAssembly/WebAssemblyTargetMachine.cpp  |   2 +-
 llvm/lib/Target/X86/X86TargetMachine.cpp  |   2 +-
 llvm/lib/Target/XCore/XCoreTargetMachine.cpp  |   2 +-
 .../test/CodeGen/AMDGPU/idemponent-atomics.ll |   2 +-
 .../CodeGen/AMDGPU/private-memory-atomics.ll  |   2 +-
 .../AtomicExpand/AArch64/atomicrmw-fp.ll  |   2 +-
 .../AArch64/expand-atomicrmw-xchg-fp.ll   |   4 +-
 .../AtomicExpand/AArch64/pcsections.ll|   2 +-
 .../AMDGPU/expand-atomic-i16-system.ll|   2 +-
 .../AtomicExpand/AMDGPU/expand-atomic-i16.ll  |   4 +-
 .../AMDGPU/expand-atomic-i8-system.ll |   2 +-
 .../AtomicExpand/AMDGPU/expand-atomic-i8.ll   |   4 +-
 ...and-atomic-rmw-fadd-flat-specialization.ll |   8 +-
 .../AMDGPU/expand-atomic-rmw-fadd.ll  |  12 +-
 .../AMDGPU/expand-atomic-rmw-fmax.ll  |   4 +-
 .../AMDGPU/expand-atomic-rmw-fmin.ll  |   4 +-
 .../AMDGPU/expand-atomic-rmw-fsub.ll  |   4 +-
 .../AMDGPU/expand-atomic-rmw-nand.ll  |   4 +-
 .../expand-atomic-simplify-cfg-CAS-block.ll   |   2 +-
 .../AtomicExpand/AMDGPU/unaligned-atomic.ll   |   2 +-
 .../AtomicExpand/ARM/atomic-expansion-v7.ll   |   2 +-
 .../AtomicExpand/ARM/atomic-expansion-v8.ll   |   2 +-
 .../AtomicExpand/ARM/atomicrmw-fp.ll  |   2 +-
 .../AtomicExpand/ARM/cmpxchg-weak.ll  |   2 +-
 .../AtomicExpand/Hexagon/atomicrmw-fp.ll  |   2 +-
 .../AtomicExpand/LoongArch/atomicrmw-fp.ll|   2 +-
 .../LoongArch/load-store-atomic.ll|   4 +-
 .../AtomicExpand/Mips/atomicrmw-fp.ll |   2 +-
 .../AtomicExpand/PowerPC/atomicrmw-fp.ll  |   2 +-
 .../AtomicExpand/PowerPC/cfence-double.ll |   4 +-
 .../AtomicExpand/PowerPC/cfence-float.ll  |   4 +-
 .../AtomicExpand/PowerPC/cmpxchg.ll   |   4 +-
 .../AtomicExpand/PowerPC/issue55983.ll|   4 +-
 .../AtomicExpand/RISCV/atomicrmw-fp.ll|   2 +-
 .../Transforms/AtomicExpand/SPARC/libcalls.ll |   2 +-
 .../Transforms/AtomicExpand/SPARC/partword.ll |   2 +-
 .../AtomicExpand/X86/expand-atomic-libcall.ll |   2 +-
 .../X86/expand-atomic-non-integer.ll  |   2 +-
 .../AtomicExpand/X86/expand-atomic-rmw-fp.ll  |   2 +-
 .../X86/expand-atomic-rmw-initial-load.ll |   2 +-
 .../AtomicExpand/X86/expand-atomic-xchg-fp.ll |   2 +-
 llvm/tools/opt/opt.cpp|   2 -
 .../gn/secondary/llvm/lib/CodeGen/BUILD.gn|   2 +-
 76 files changed, 219 insertions(+), 154 deletions(-)
 create mode 100644 llvm/include/llvm/CodeGen/ExpandAtomic.h
 rename llvm/lib/CodeGen/{AtomicExpandPass.cpp => ExpandAtomicPass.cpp} (95%)

diff --git a/llvm/include/llvm/CodeGen/AtomicExpandUtils.h 
b/llvm/include/llvm/CodeGen/AtomicExpandUtils.h
index 1cb410a0c31c69..851492678aeba5 100644
--- a/llvm/include/llvm/CodeGen/AtomicExpandUtils.h
+++ b/llvm/include/llvm/CodeGen/AtomicExpandUtils.h

[lldb] [libcxx] [clang-tools-extra] [llvm] [compiler-rt] [clang] [mlir] [flang] [lld] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)

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


@@ -224,6 +224,11 @@ New checks
   Recommends the smallest possible underlying type for an ``enum`` or ``enum``
   class based on the range of its enumerators.
 
+- New :doc:`readability-avoid-nested-conditional-operator
+  ` check.
+
+  Finds nested conditional operator.

PiotrZSL wrote:

// Identifies instances of nested conditional operators in the code.

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


[compiler-rt] [clang] [flang] [libcxx] [lldb] [mlir] [lld] [clang-tools-extra] [llvm] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)

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

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


[libcxx] [flang] [clang-tools-extra] [lld] [mlir] [llvm] [compiler-rt] [lldb] [clang] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)

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

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

LGTM.
Sync first line of release notes, doc, doxygen and could land.

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


[clang] Fix crash with modules and constexpr destructor (PR #69076)

2024-01-14 Thread Jonas Hahnfeld via cfe-commits

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


[clang] 844f833 - Fix crash with modules and constexpr destructor (#69076)

2024-01-14 Thread via cfe-commits

Author: Jonas Hahnfeld
Date: 2024-01-15T08:40:26+01:00
New Revision: 844f8335f211da19ae4b375761013909a3394d9a

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

LOG: Fix crash with modules and constexpr destructor (#69076)

With modules, serialization might omit the outer ExprWithCleanups
as it calls ParmVarDecl::getDefaultArg(). Complementary to fixing
this in a separate change, make the code more robust by adding a
FullExpressionRAII and avoid the llvm_unreachable in the added test
clang/test/Modules/pr68702.cpp.

Closes https://github.com/llvm/llvm-project/issues/68702

Added: 
clang/test/Modules/pr68702.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dc8a6fe506bce6..7e130304c5c08f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -958,6 +958,8 @@ Miscellaneous Clang Crashes Fixed
 - Fixed a crash when a lambda marked as ``static`` referenced a captured
   variable in an expression.
   `Issue 74608 `_
+- Fixed a crash with modules and a ``constexpr`` destructor.
+  `Issue 68702 `_
 
 
 OpenACC Specific Changes

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f6aeee1a4e935d..f20850d14c0c86 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15754,10 +15754,22 @@ bool Expr::EvaluateAsInitializer(APValue , 
const ASTContext ,
 LValue LVal;
 LVal.set(VD);
 
-if (!EvaluateInPlace(Value, Info, LVal, this,
- /*AllowNonLiteralTypes=*/true) ||
-EStatus.HasSideEffects)
-  return false;
+{
+  // C++23 [intro.execution]/p5
+  // A full-expression is ... an init-declarator ([dcl.decl]) or a
+  // mem-initializer.
+  // So we need to make sure temporary objects are destroyed after having
+  // evaluated the expression (per C++23 [class.temporary]/p4).
+  //
+  // FIXME: Otherwise this may break test/Modules/pr68702.cpp because the
+  // serialization code calls ParmVarDecl::getDefaultArg() which strips the
+  // outermost FullExpr, such as ExprWithCleanups.
+  FullExpressionRAII Scope(Info);
+  if (!EvaluateInPlace(Value, Info, LVal, this,
+   /*AllowNonLiteralTypes=*/true) ||
+  EStatus.HasSideEffects)
+return false;
+}
 
 // At this point, any lifetime-extended temporaries are completely
 // initialized.

diff  --git a/clang/test/Modules/pr68702.cpp b/clang/test/Modules/pr68702.cpp
new file mode 100644
index 00..d32f946910f4fb
--- /dev/null
+++ b/clang/test/Modules/pr68702.cpp
@@ -0,0 +1,65 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %t/main.cpp -o %t/main.o
+
+//--- V.h
+#ifndef V_H
+#define V_H
+
+class A {
+public:
+  constexpr A() { }
+  constexpr ~A() { }
+};
+
+template 
+class V {
+public:
+  V() = default;
+
+  constexpr V(int n, const A& a = A()) {}
+};
+
+#endif
+
+//--- inst1.h
+#include "V.h"
+
+static void inst1() {
+  V v;
+}
+
+//--- inst2.h
+#include "V.h"
+
+static void inst2() {
+  V v(100);
+}
+
+//--- module.modulemap
+module "M" {
+  export *
+  module "V.h" {
+export *
+header "V.h"
+  }
+  module "inst1.h" {
+export *
+header "inst1.h"
+  }
+}
+
+module "inst2.h" {
+  export *
+  header "inst2.h"
+}
+
+//--- main.cpp
+#include "V.h"
+#include "inst2.h"
+
+static void m() {
+  static V v(100);
+}



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


[llvm] [clang] [RISCV] Add Zicfiss support to the shadow call stack implementation. (PR #68075)

2024-01-14 Thread Yeting Kuo via cfe-commits

yetingk wrote:

Ping.

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Brandon Wu via cfe-commits


@@ -463,7 +464,7 @@ void 
RISCVIntrinsicManagerImpl::CreateRVVIntrinsicDecl(LookupResult ,
 bool RISCVIntrinsicManagerImpl::CreateIntrinsicIfFound(LookupResult ,
IdentifierInfo *II,
Preprocessor ) {
-  StringRef Name = II->getName();
+  StringRef Name = II->getName().substr(8);

4vtomat wrote:

We can't add an assertion since other tokens go through this function too, or 
can we filter out the token?

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


[clang] [RISCV] Support __riscv_v_fixed_vlen for vbool types. (PR #76551)

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

https://github.com/wangpc-pp commented:

Please add a release note.

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


[clang] [RISCV] Support __riscv_v_fixed_vlen for vbool types. (PR #76551)

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


@@ -2415,7 +2415,10 @@ only be a power of 2 between 64 and 65536.
 For types where LMUL!=1, ``__riscv_v_fixed_vlen`` needs to be scaled by the 
LMUL
 of the type before passing to the attribute.
 
-``vbool*_t`` types are not supported at this time.
+For ``vbool*_t`` types, ``__riscv_v_fixed_vlen`` needs to be divided by the
+number from the type name. For example, ``vbool8_t`` needs to use

wangpc-pp wrote:

> ``__riscv_v_fixed_vlen`` needs to be divided by the number from the type name.

Can this be done by compiler?

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


[clang] [RISCV] Support __riscv_v_fixed_vlen for vbool types. (PR #76551)

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

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


[clang] [RISCV][clang] Optimize memory usage of intrinsic lookup table (PR #77487)

2024-01-14 Thread Brandon Wu via cfe-commits


@@ -416,8 +416,10 @@ class RVVIntrinsic {
   RVVTypePtr getOutputType() const { return OutputType; }
   const RVVTypes () const { return InputTypes; }
   llvm::StringRef getBuiltinName() const { return BuiltinName; }
-  llvm::StringRef getName() const { return Name; }
-  llvm::StringRef getOverloadedName() const { return OverloadedName; }
+  llvm::StringRef getName() const { return "__riscv_" + Name; }

4vtomat wrote:

String literal is placed in data segment so its lifetime is the lifetime of the 
program. StringRef doesn't take the ownership, but string literal is alive 
until the whole program ends, so I guess it's ok for referencing it?

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


[flang] [lldb] [compiler-rt] [clang-tools-extra] [lld] [libcxx] [llvm] [mlir] [clang] [clang-format] Add ShortReturnTypeLength option. (PR #78011)

2024-01-14 Thread via cfe-commits

https://github.com/rmarker updated 
https://github.com/llvm/llvm-project/pull/78011

>From c4d28f82e108f9f12ccd0375e2a3502025b8c1e8 Mon Sep 17 00:00:00 2001
From: rmarker 
Date: Thu, 11 Jan 2024 15:01:18 +1030
Subject: [PATCH 1/3] [clang-format] Add ShortReturnTypeLength option.

---
 clang/docs/ClangFormatStyleOptions.rst |  8 
 clang/docs/ReleaseNotes.rst|  1 +
 clang/include/clang/Format/Format.h|  8 
 clang/lib/Format/ContinuationIndenter.cpp  |  3 +-
 clang/lib/Format/Format.cpp|  2 +
 clang/unittests/Format/ConfigParseTest.cpp |  1 +
 clang/unittests/Format/FormatTest.cpp  | 44 ++
 7 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ac9a0b70ed5daa..3255ceb0aba75b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4994,6 +4994,14 @@ the configuration (without a prefix: ``Auto``).
int bar;   int bar;
  } // namespace b   } // namespace b
 
+.. _ShortReturnTypeLength:
+
+**ShortReturnTypeLength** (``Unsigned``) :versionbadge:`clang-format 18` 
:ref:`¶ `
+  When AlwaysBreakAfterReturnType is None, line breaks are prevented after
+  short return types. This configures the character limit for a type to be
+  regarded as short. Note that this isn't the length of the type itself,
+  but the column where it finishes. I.e. it includes indentation, etc.
+
 .. _SortIncludes:
 
 **SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 3.8` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3cbce1be159437..04bf5cd4e768f3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1131,6 +1131,7 @@ clang-format
 - Add ``BreakAdjacentStringLiterals`` option.
 - Add ``ObjCPropertyAttributeOrder`` which can be used to sort ObjC property
   attributes (like ``nonatomic, strong, nullable``).
+- Add ``ShortReturnTypeLength`` option.
 - Add ``.clang-format-ignore`` files.
 - Add ``AlignFunctionPointers`` sub-option for 
``AlignConsecutiveDeclarations``.
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 5ffd63ee73fc36..f94d68f2cf2a85 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3928,6 +3928,13 @@ struct FormatStyle {
   /// \version 13
   unsigned ShortNamespaceLines;
 
+  /// When AlwaysBreakAfterReturnType is None, line breaks are prevented after
+  /// short return types. This configures the character limit for a type to be
+  /// regarded as short. Note that this isn't the length of the type itself,
+  /// but the column where it finishes. I.e. it includes indentation, etc.
+  /// \version 18
+  unsigned ShortReturnTypeLength;
+
   /// Include sorting options.
   enum SortIncludesOptions : int8_t {
 /// Includes are never sorted.
@@ -4890,6 +4897,7 @@ struct FormatStyle {
RequiresExpressionIndentation == R.RequiresExpressionIndentation &&
SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
ShortNamespaceLines == R.ShortNamespaceLines &&
+   ShortReturnTypeLength == R.ShortReturnTypeLength &&
SortIncludes == R.SortIncludes &&
SortJavaStaticImport == R.SortJavaStaticImport &&
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 102504182c4505..bc0748ec52e676 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -328,7 +328,8 @@ bool ContinuationIndenter::canBreak(const LineState ) 
{
 
   // Don't break after very short return types (e.g. "void") as that is often
   // unexpected.
-  if (Current.is(TT_FunctionDeclarationName) && State.Column < 6) {
+  if (Current.is(TT_FunctionDeclarationName) &&
+  State.Column <= Style.ShortReturnTypeLength) {
 if (Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None)
   return false;
   }
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ff5ed6c306f383..20ffbeef7e9a6e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1083,6 +1083,7 @@ template <> struct MappingTraits {
Style.RequiresExpressionIndentation);
 IO.mapOptional("SeparateDefinitionBlocks", Style.SeparateDefinitionBlocks);
 IO.mapOptional("ShortNamespaceLines", Style.ShortNamespaceLines);
+IO.mapOptional("ShortReturnTypeLength", Style.ShortReturnTypeLength);
 IO.mapOptional("SortIncludes", Style.SortIncludes);
 IO.mapOptional("SortJavaStaticImport", Style.SortJavaStaticImport);
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
@@ -1554,6 +1555,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   

[llvm] [clang-tools-extra] [libcxx] [libunwind] [flang] [mlir] [lldb] [clang] [libunwind] fix dynamic .eh_frame registration (PR #77185)

2024-01-14 Thread via cfe-commits

lhames wrote:

Hi @SihangZhu. Sorry for the delay — will try to review this tomorrow.

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


[llvm] [clang] [TargetParser] Define AEK_FCMA and AEK_JSCVT for tsv110 (PR #75516)

2024-01-14 Thread Bryan Chan via cfe-commits

https://github.com/bryanpkc updated 
https://github.com/llvm/llvm-project/pull/75516

>From a39cd3fba9cd8fb6757bfd297d57f6ab98b36405 Mon Sep 17 00:00:00 2001
From: Qi Hu 
Date: Thu, 14 Dec 2023 13:35:52 -0500
Subject: [PATCH] [TargetParser] Define AEK_FCMA and AEK_JSCVT for tsv110

We define AEK_JSCVT and AEK_FCMA for CPU features FEAT_JSCVT and FEAT_FCMA
respectively, and add them to the CpuInfo of tsv110.
---
 clang/test/CodeGen/aarch64-targetattr.c   |  12 +-
 .../Preprocessor/aarch64-target-features.c|  10 +-
 .../llvm/TargetParser/AArch64TargetParser.h   |  11 +-
 llvm/lib/Target/AArch64/AArch64.td|   3 +-
 .../TargetParser/TargetParserTest.cpp | 106 ++
 5 files changed, 82 insertions(+), 60 deletions(-)

diff --git a/clang/test/CodeGen/aarch64-targetattr.c 
b/clang/test/CodeGen/aarch64-targetattr.c
index 5f557532a4b4a7..02da18264da0a3 100644
--- a/clang/test/CodeGen/aarch64-targetattr.c
+++ b/clang/test/CodeGen/aarch64-targetattr.c
@@ -97,19 +97,19 @@ void minusarch() {}
 // CHECK: attributes #0 = { {{.*}} 
"target-features"="+crc,+fp-armv8,+lse,+neon,+ras,+rdm,+v8.1a,+v8.2a,+v8a" }
 // CHECK: attributes #1 = { {{.*}} 
"target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+v8.1a,+v8.2a,+v8a"
 }
 // CHECK: attributes #2 = { {{.*}} 
"target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+sve2,+v8.1a,+v8.2a,+v8a"
 }
-// CHECK: attributes #3 = { {{.*}} 
"target-features"="+bf16,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+lse,+neon,+ras,+rcpc,+rdm,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 }
-// CHECK: attributes #4 = { {{.*}} "target-cpu"="cortex-a710" 
"target-features"="+bf16,+crc,+dotprod,+flagm,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+lse,+mte,+neon,+pauth,+ras,+rcpc,+rdm,+sb,+sve,+sve2,+sve2-bitperm"
 }
+// CHECK: attributes #3 = { {{.*}} 
"target-features"="+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+ras,+rcpc,+rdm,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 }
+// CHECK: attributes #4 = { {{.*}} "target-cpu"="cortex-a710" 
"target-features"="+bf16,+complxnum,+crc,+dotprod,+flagm,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+mte,+neon,+pauth,+ras,+rcpc,+rdm,+sb,+sve,+sve2,+sve2-bitperm"
 }
 // CHECK: attributes #5 = { {{.*}} "tune-cpu"="cortex-a710" }
 // CHECK: attributes #6 = { {{.*}} "target-cpu"="generic" }
 // CHECK: attributes #7 = { {{.*}} "tune-cpu"="generic" }
 // CHECK: attributes #8 = { {{.*}} "target-cpu"="neoverse-n1" 
"target-features"="+aes,+crc,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs"
 "tune-cpu"="cortex-a710" }
 // CHECK: attributes #9 = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve" "tune-cpu"="cortex-a710" }
-// CHECK: attributes #10 = { {{.*}} "target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+lse,+neon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+sve,+sve2"
 }
-// CHECK: attributes #11 = { {{.*}} "target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+lse,+neon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,-sve"
 }
+// CHECK: attributes #10 = { {{.*}} "target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+sve,+sve2"
 }
+// CHECK: attributes #11 = { {{.*}} "target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,-sve"
 }
 // CHECK: attributes #12 = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve" }
 // CHECK: attributes #13 = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+neon,+sve,-sve2" }
 // CHECK: attributes #14 = { {{.*}} "target-features"="+fullfp16" }
-// CHECK: attributes #15 = { {{.*}} "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
-// CHECK: attributes #16 = { {{.*}} "branch-target-enforcement"="true" 
"guarded-control-stack"="true" {{.*}} 
"target-features"="+aes,+bf16,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
+// CHECK: attributes #15 = { {{.*}} "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
+// CHECK: attributes #16 = { {{.*}} "branch-target-enforcement"="true" 
"guarded-control-stack"="true" {{.*}} 

[mlir] [libcxx] [libunwind] [flang] [llvm] [clang-tools-extra] [lldb] [clang] [libunwind] fix dynamic .eh_frame registration (PR #77185)

2024-01-14 Thread via cfe-commits

https://github.com/SihangZhu updated 
https://github.com/llvm/llvm-project/pull/77185

>From ed0a694dbf7cb8e6775b53f3553f4ec7d1fdbee2 Mon Sep 17 00:00:00 2001
From: SihangZhu 
Date: Sat, 6 Jan 2024 15:43:41 +0800
Subject: [PATCH] [libunwind] fix dynamic .eh_frame registration

---
 libunwind/src/libunwind.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp
index cd610377b63de8..723c8ceb5c8c94 100644
--- a/libunwind/src/libunwind.cpp
+++ b/libunwind/src/libunwind.cpp
@@ -324,7 +324,7 @@ void __unw_add_dynamic_eh_frame_section(unw_word_t 
eh_frame_start) {
   CFI_Parser::CIE_Info cieInfo;
   CFI_Parser::FDE_Info fdeInfo;
   auto p = (LocalAddressSpace::pint_t)eh_frame_start;
-  while (true) {
+  while (LocalAddressSpace::sThisAddressSpace.get32(p)) {
 if (CFI_Parser::decodeFDE(
 LocalAddressSpace::sThisAddressSpace, p, , ,
 true) == NULL) {

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


[clang-tools-extra] [llvm] [MLGO] Upstream the corpus extraction tooling (PR #72319)

2024-01-14 Thread Aiden Grossman via cfe-commits

boomanaiden154 wrote:

After this lands, my plan is to work on getting CI up and running, both to run 
testing and also to publish the package.

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


[llvm] [clang] [coverage] skipping code coverage for 'if constexpr' and 'if consteval' [WIP] (PR #78033)

2024-01-14 Thread Jessica Paquette via cfe-commits
Hana =?utf-8?q?Dusíková?= 
Message-ID:
In-Reply-To: 


ornata wrote:

I think that skipping whitespace-only regions in llvm-cov intuitively makes 
sense. In general, showing coverage information about empty spaces doesn't give 
the user any useful information.

I think I'd do that part in a separate patch though.

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


[clang-tools-extra] [llvm] [MLGO] Upstream the corpus extraction tooling (PR #72319)

2024-01-14 Thread Aiden Grossman via cfe-commits

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


[clang-tools-extra] [llvm] [MLGO] Upstream the corpus extraction tooling (PR #72319)

2024-01-14 Thread Aiden Grossman via cfe-commits

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


[llvm] [clang] riscv vector cc (PR #77560)

2024-01-14 Thread Brandon Wu via cfe-commits


@@ -24,6 +24,19 @@ def CSR_ILP32D_LP64D
 : CalleeSavedRegs<(add CSR_ILP32_LP64,
F8_D, F9_D, (sequence "F%u_D", 18, 27))>;
 
+defvar CSR_V = (add (sequence "V%u", 1, 7), (sequence "V%u", 24, 31),
+ V2M2, V4M2, V6M2, V24M2, V26M2, V28M2, V30M2,

4vtomat wrote:

If I don't list all of LMUL variations, it would use LMUL 1 for all 
saved/restored registers, I'm not sure if we have any mechanism to auto-combine 
them?

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


[llvm] [clang] [libc] [Libc] Give more functions restrict qualifiers (PR #78061)

2024-01-14 Thread via cfe-commits

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


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


[clang] [llvm] [libc] [Libc] Give more functions restrict qualifiers (PR #78061)

2024-01-14 Thread via cfe-commits

AtariDreams wrote:

@lntue Do you think this PR is acceptable? 

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


[clang] [RISCV] Overwrite cpu target features for full arch string in target attribute (PR #77426)

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

https://github.com/lukel97 updated 
https://github.com/llvm/llvm-project/pull/77426

>From 0fadce20076015fbb28d449a2b3086f2e4261604 Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Tue, 9 Jan 2024 15:32:15 +0700
Subject: [PATCH 1/2] [RISCV] Overwrite cpu target features for full arch
 string in target attribute

This patch reworks RISCVTargetInfo::initFeatureMap to fix the issue described
in https://github.com/llvm/llvm-project/pull/74889#pullrequestreview-1773445559
(and is an alternative to #75804)

When a full arch string is specified, a "full" list of extensions is now passed
after the __RISCV_TargetAttrNeedOverride marker feature, which includes any
negative features that disable ISA extensions.

In initFeatureMap, there are now two code paths:

1. If the arch string was overriden, use the "full" list of override features,
only adding back any non-isa features that were specified.

Using the full list of positive and negative features will mean that the
target-cpu will have no effect on the final arch, e.g.
__attribute__((target("arch=rv64i"))) with -mcpu=sifive-x280 will have the
features for rv64i, not a mix of both.

2. Otherwise, parse and *append* the list of implied features. By appending, we
turn back on any features that might have been disabled by a negative
extension, i.e. this handles the case fixed in #74889.
---
 clang/lib/Basic/Targets/RISCV.cpp | 78 +++
 .../CodeGen/RISCV/riscv-func-attr-target.c|  8 +-
 2 files changed, 30 insertions(+), 56 deletions(-)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index daaa8639ae8358..b56c1d465ad77a 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -235,39 +235,6 @@ ArrayRef 
RISCVTargetInfo::getTargetBuiltins() const {
 clang::RISCV::LastTSBuiltin - Builtin::FirstTSBuiltin);
 }
 
-static std::vector
-collectNonISAExtFeature(ArrayRef FeaturesNeedOverride, int XLen) {
-  std::vector NonISAExtFeatureVec;
-
-  auto IsNonISAExtFeature = [](const std::string ) {
-assert(Feature.size() > 1 && (Feature[0] == '+' || Feature[0] == '-'));
-StringRef Ext = StringRef(Feature).drop_front(); // drop the +/-
-return !llvm::RISCVISAInfo::isSupportedExtensionFeature(Ext);
-  };
-  llvm::copy_if(FeaturesNeedOverride, std::back_inserter(NonISAExtFeatureVec),
-IsNonISAExtFeature);
-
-  return NonISAExtFeatureVec;
-}
-
-static std::vector
-resolveTargetAttrOverride(const std::vector ,
-  int XLen) {
-  auto I = llvm::find(FeaturesVec, "__RISCV_TargetAttrNeedOverride");
-  if (I == FeaturesVec.end())
-return FeaturesVec;
-
-  ArrayRef FeaturesNeedOverride(&*FeaturesVec.begin(), &*I);
-  std::vector NonISAExtFeature =
-  collectNonISAExtFeature(FeaturesNeedOverride, XLen);
-
-  std::vector ResolvedFeature(++I, FeaturesVec.end());
-  ResolvedFeature.insert(ResolvedFeature.end(), NonISAExtFeature.begin(),
- NonISAExtFeature.end());
-
-  return ResolvedFeature;
-}
-
 bool RISCVTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) const {
@@ -281,10 +248,27 @@ bool RISCVTargetInfo::initFeatureMap(
 Features["32bit"] = true;
   }
 
-  std::vector NewFeaturesVec =
-  resolveTargetAttrOverride(FeaturesVec, XLen);
+  // If a target attribute specified a full arch string, override all the ISA
+  // extension target features.
+  const auto I = llvm::find(FeaturesVec, "__RISCV_TargetAttrNeedOverride");
+  if (I != FeaturesVec.end()) {
+std::vector OverrideFeatures = std::vector(std::next(I), 
FeaturesVec.end());
+
+// Add back any non ISA extension features, e.g. +relax.
+auto IsNonISAExtFeature = [](const std::string ) {
+  assert(Feature.size() > 1 && (Feature[0] == '+' || Feature[0] == '-'));
+  std::string Ext = Feature.substr(1); // drop the +/-
+  return !llvm::RISCVISAInfo::isSupportedExtensionFeature(Ext);
+};
+llvm::copy_if(llvm::make_range(FeaturesVec.begin(), I),
+  std::back_inserter(OverrideFeatures), IsNonISAExtFeature);
 
-  auto ParseResult = llvm::RISCVISAInfo::parseFeatures(XLen, NewFeaturesVec);
+return TargetInfo::initFeatureMap(Features, Diags, CPU, OverrideFeatures);
+  }
+
+  // Otherwise, parse the features and add any implied extensions.
+  std::vector AllFeatures = FeaturesVec;
+  auto ParseResult = llvm::RISCVISAInfo::parseFeatures(XLen, FeaturesVec);
   if (!ParseResult) {
 std::string Buffer;
 llvm::raw_string_ostream OutputErrMsg(Buffer);
@@ -295,21 +279,9 @@ bool RISCVTargetInfo::initFeatureMap(
 return false;
   }
 
-  // RISCVISAInfo makes implications for ISA features
-  std::vector ImpliedFeatures = (*ParseResult)->toFeatures();
-
-  // parseFeatures normalizes the feature set by dropping any explicit
-  // negatives, and non-extension features.  We need to preserve the later
-  // for correctness and want 

[clang] [clang][docs] Improve "Obtaining Clang" section (PR #71313)

2024-01-14 Thread Jessica Clarke via cfe-commits

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


[clang] [clang][docs] Improve "Obtaining Clang" section (PR #71313)

2024-01-14 Thread Jessica Clarke via cfe-commits


@@ -22,8 +22,8 @@ started guide `_.
 
 .. code-block:: console
 
-  cd ~/clang-llvm
-  git clone https://github.com/llvm/llvm-project.git
+  mkdir ~/clang-llvm && cd ~/clang-llvm
+  git clone https://github.com/llvm/llvm-project.git .

jrtc27 wrote:

Given the:
```
  cd ~/clang-llvm
  git clone git://cmake.org/stage/cmake.git
```
this isn't a good idea. Better to clone it to an llvm-project subdirectory 
(i.e. drop the .) and alter later steps.

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


[clang-tools-extra] [llvm] [MLGO] Upstream the corpus extraction tooling (PR #72319)

2024-01-14 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/72319

>From c3f723c8a975cc5e075d56350645b0be486f3cda Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Tue, 14 Nov 2023 14:20:24 -0800
Subject: [PATCH 1/2] [MLGO] Upstream the corpus extraction tooling

---
 llvm/py/Pyproject.toml|   1 +
 llvm/py/src/mlgo/combine_training_corpus.py   |  55 +++
 .../src/mlgo/combine_training_corpus_lib.py   |  50 +++
 .../src/mlgo/combine_training_corpus_test.py  | 104 +
 llvm/py/src/mlgo/extract_ir.py| 142 +++
 llvm/py/src/mlgo/extract_ir_lib.py| 373 ++
 llvm/py/src/mlgo/extract_ir_test.py   | 231 +++
 llvm/py/src/mlgo/make_corpus.py   |  58 +++
 llvm/py/src/mlgo/make_corpus_lib.py   |  90 +
 llvm/py/src/mlgo/make_corpus_test.py  |  66 
 10 files changed, 1170 insertions(+)
 create mode 100644 llvm/py/Pyproject.toml
 create mode 100644 llvm/py/src/mlgo/combine_training_corpus.py
 create mode 100644 llvm/py/src/mlgo/combine_training_corpus_lib.py
 create mode 100644 llvm/py/src/mlgo/combine_training_corpus_test.py
 create mode 100644 llvm/py/src/mlgo/extract_ir.py
 create mode 100644 llvm/py/src/mlgo/extract_ir_lib.py
 create mode 100644 llvm/py/src/mlgo/extract_ir_test.py
 create mode 100644 llvm/py/src/mlgo/make_corpus.py
 create mode 100644 llvm/py/src/mlgo/make_corpus_lib.py
 create mode 100644 llvm/py/src/mlgo/make_corpus_test.py

diff --git a/llvm/py/Pyproject.toml b/llvm/py/Pyproject.toml
new file mode 100644
index 00..dcf2c804da5e19
--- /dev/null
+++ b/llvm/py/Pyproject.toml
@@ -0,0 +1 @@
+# Placeholder
diff --git a/llvm/py/src/mlgo/combine_training_corpus.py 
b/llvm/py/src/mlgo/combine_training_corpus.py
new file mode 100644
index 00..94ee1cbac9cea4
--- /dev/null
+++ b/llvm/py/src/mlgo/combine_training_corpus.py
@@ -0,0 +1,55 @@
+# coding=utf-8
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+r"""Combine multiple training corpus into a single training corpus.
+
+Currently only support the case that multiple corpus share the same
+configurables except the "modules" field.
+
+Usage: we'd like to combine training corpus corpus1 and corpus2 into
+combinedcorpus; we first structure the files as follows:
+
+combinedcorpus
+combinedcorpus/corpus1
+combinedcorpus/corpus2
+
+Running this script with
+
+python3 \
+compiler_opt/tools/combine_training_corpus.py \
+  --root_dir=$PATH_TO_combinedcorpus
+
+generates combinedcorpus/corpus_description.json file. In this way corpus1
+and corpus2 are combined into combinedcorpus.
+"""
+
+from absl import app
+from absl import flags
+
+from compiler_opt.tools import combine_training_corpus_lib
+
+flags.DEFINE_string('root_dir', '', 'root dir of module paths to combine.')
+
+FLAGS = flags.FLAGS
+
+
+def main(argv):
+  if len(argv) > 1:
+raise app.UsageError('Too many command-line arguments.')
+
+  combine_training_corpus_lib.combine_corpus(FLAGS.root_dir)
+
+
+if __name__ == '__main__':
+  app.run(main)
diff --git a/llvm/py/src/mlgo/combine_training_corpus_lib.py 
b/llvm/py/src/mlgo/combine_training_corpus_lib.py
new file mode 100644
index 00..0359961266a240
--- /dev/null
+++ b/llvm/py/src/mlgo/combine_training_corpus_lib.py
@@ -0,0 +1,50 @@
+# coding=utf-8
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Library for combining training corpora."""
+
+import os
+import json
+
+from absl import logging
+
+import tensorflow as tf
+
+_FILE_NAME = 'corpus_description.json'
+
+
+def combine_corpus(root_dir: str) -> None:
+  module_names = []
+  output_corpus_description = {}
+
+  corpus_description_glob = os.path.join(root_dir, '*/' + _FILE_NAME)
+  for corpus_description_path in tf.io.gfile.glob(corpus_description_glob):
+logging.info('processing %s', corpus_description_path)
+
+with 

[clang-tools-extra] [llvm] [MLGO] Upstream the corpus extraction tooling (PR #72319)

2024-01-14 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/72319

>From c3f723c8a975cc5e075d56350645b0be486f3cda Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Tue, 14 Nov 2023 14:20:24 -0800
Subject: [PATCH] [MLGO] Upstream the corpus extraction tooling

---
 llvm/py/Pyproject.toml|   1 +
 llvm/py/src/mlgo/combine_training_corpus.py   |  55 +++
 .../src/mlgo/combine_training_corpus_lib.py   |  50 +++
 .../src/mlgo/combine_training_corpus_test.py  | 104 +
 llvm/py/src/mlgo/extract_ir.py| 142 +++
 llvm/py/src/mlgo/extract_ir_lib.py| 373 ++
 llvm/py/src/mlgo/extract_ir_test.py   | 231 +++
 llvm/py/src/mlgo/make_corpus.py   |  58 +++
 llvm/py/src/mlgo/make_corpus_lib.py   |  90 +
 llvm/py/src/mlgo/make_corpus_test.py  |  66 
 10 files changed, 1170 insertions(+)
 create mode 100644 llvm/py/Pyproject.toml
 create mode 100644 llvm/py/src/mlgo/combine_training_corpus.py
 create mode 100644 llvm/py/src/mlgo/combine_training_corpus_lib.py
 create mode 100644 llvm/py/src/mlgo/combine_training_corpus_test.py
 create mode 100644 llvm/py/src/mlgo/extract_ir.py
 create mode 100644 llvm/py/src/mlgo/extract_ir_lib.py
 create mode 100644 llvm/py/src/mlgo/extract_ir_test.py
 create mode 100644 llvm/py/src/mlgo/make_corpus.py
 create mode 100644 llvm/py/src/mlgo/make_corpus_lib.py
 create mode 100644 llvm/py/src/mlgo/make_corpus_test.py

diff --git a/llvm/py/Pyproject.toml b/llvm/py/Pyproject.toml
new file mode 100644
index 00..dcf2c804da5e19
--- /dev/null
+++ b/llvm/py/Pyproject.toml
@@ -0,0 +1 @@
+# Placeholder
diff --git a/llvm/py/src/mlgo/combine_training_corpus.py 
b/llvm/py/src/mlgo/combine_training_corpus.py
new file mode 100644
index 00..94ee1cbac9cea4
--- /dev/null
+++ b/llvm/py/src/mlgo/combine_training_corpus.py
@@ -0,0 +1,55 @@
+# coding=utf-8
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+r"""Combine multiple training corpus into a single training corpus.
+
+Currently only support the case that multiple corpus share the same
+configurables except the "modules" field.
+
+Usage: we'd like to combine training corpus corpus1 and corpus2 into
+combinedcorpus; we first structure the files as follows:
+
+combinedcorpus
+combinedcorpus/corpus1
+combinedcorpus/corpus2
+
+Running this script with
+
+python3 \
+compiler_opt/tools/combine_training_corpus.py \
+  --root_dir=$PATH_TO_combinedcorpus
+
+generates combinedcorpus/corpus_description.json file. In this way corpus1
+and corpus2 are combined into combinedcorpus.
+"""
+
+from absl import app
+from absl import flags
+
+from compiler_opt.tools import combine_training_corpus_lib
+
+flags.DEFINE_string('root_dir', '', 'root dir of module paths to combine.')
+
+FLAGS = flags.FLAGS
+
+
+def main(argv):
+  if len(argv) > 1:
+raise app.UsageError('Too many command-line arguments.')
+
+  combine_training_corpus_lib.combine_corpus(FLAGS.root_dir)
+
+
+if __name__ == '__main__':
+  app.run(main)
diff --git a/llvm/py/src/mlgo/combine_training_corpus_lib.py 
b/llvm/py/src/mlgo/combine_training_corpus_lib.py
new file mode 100644
index 00..0359961266a240
--- /dev/null
+++ b/llvm/py/src/mlgo/combine_training_corpus_lib.py
@@ -0,0 +1,50 @@
+# coding=utf-8
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Library for combining training corpora."""
+
+import os
+import json
+
+from absl import logging
+
+import tensorflow as tf
+
+_FILE_NAME = 'corpus_description.json'
+
+
+def combine_corpus(root_dir: str) -> None:
+  module_names = []
+  output_corpus_description = {}
+
+  corpus_description_glob = os.path.join(root_dir, '*/' + _FILE_NAME)
+  for corpus_description_path in tf.io.gfile.glob(corpus_description_glob):
+logging.info('processing %s', corpus_description_path)
+
+with 

[llvm] [clang] [RISCV] Relax march string order constraint (PR #78120)

2024-01-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-support

Author: Piyou Chen (BeMg)


Changes

Address the https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14

This patch relax the `-march` string for accept any order. 

1. single-letter extension can be arbitrary order
- march=rv32iamdf 
2. single-letter extension and multi-letter extension can be mixed
- march=rv32i_zihintntl_m_a_f_d_svinval
3. multi-letter extension need seperate the following extension by underscore, 
otherwise it will be intreprete as one extension.
- march=rv32i_zbam - i,zbam
- march=rv32i_zba_m - i,zba,m


---

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


3 Files Affected:

- (modified) clang/test/Driver/riscv-arch.c (+6-8) 
- (modified) llvm/lib/Support/RISCVISAInfo.cpp (+149-148) 
- (modified) llvm/unittests/Support/RISCVISAInfoTest.cpp (+71-20) 


``diff
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 0ac81ea982f1b6..38de95e4fbf7aa 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -156,9 +156,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32L %s
 // RV32L: error: invalid arch name 'rv32l'
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32imadf -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32IMADF %s
-// RV32IMADF: error: invalid arch name 'rv32imadf'
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imadf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32imm -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32IMM %s
@@ -184,9 +183,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64L %s
 // RV64L: error: invalid arch name 'rv64l'
 
-// RUN: not %clang --target=riscv64-unknown-elf -march=rv64imadf -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64IMADF %s
-// RV64IMADF: error: invalid arch name 'rv64imadf'
+// RUN: %clang --target=riscv64-unknown-elf -march=rv64imadf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: not %clang --target=riscv64-unknown-elf -march=rv64imm -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64IMM %s
@@ -216,7 +214,7 @@
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32imcq -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ORDER %s
 // RV32-ORDER: error: invalid arch name 'rv32imcq',
-// RV32-ORDER: standard user-level extension not given in canonical order 'q'
+// RV32-ORDER: unsupported standard user-level extension 'q'
 
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32izvl64b -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVL64B-ER %s
@@ -318,7 +316,7 @@
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32ixabc_a -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-PREFIX %s
 // RV32-PREFIX: error: invalid arch name 'rv32ixabc_a',
-// RV32-PREFIX: invalid extension prefix 'a'
+// RV32-PREFIX: unsupported non-standard user-level extension 'xabc'
 
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32ixdef_sabc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-X-ORDER %s
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 390d950486a795..865ca48aeb90d1 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -695,6 +695,106 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
   return std::move(ISAInfo);
 }
 
+static Error splitExtsByUnderscore(StringRef Exts,
+   std::vector ) {
+  SmallVector Split;
+  if (Exts.empty())
+return Error::success();
+
+  Exts.split(Split, "_");
+
+  for (auto Ext : Split) {
+if (Ext.empty())
+  return createStringError(errc::invalid_argument,
+   "extension name missing after separator '_'");
+
+SplitedExts.push_back(Ext.str());
+  }
+  return Error::success();
+}
+
+static Error processMultiLetterExtension(
+StringRef RawExt, SmallVector ,
+SmallVector ,
+bool IgnoreUnknown, bool EnableExperimentalExtension,
+bool ExperimentalExtensionVersionCheck) {
+  StringRef Type = getExtensionType(RawExt);
+  StringRef Desc = getExtensionTypeDesc(RawExt);
+  auto Pos = findLastNonVersionCharacter(RawExt) + 1;
+  StringRef Name(RawExt.substr(0, Pos));
+  StringRef Vers(RawExt.substr(Pos));
+
+  if (Type.empty()) {
+if (IgnoreUnknown)
+  return Error::success();
+return createStringError(errc::invalid_argument,
+ "invalid extension prefix '" + RawExt + "'");
+  }
+
+  if (!IgnoreUnknown && Name.size() == Type.size())
+return createStringError(errc::invalid_argument,
+ "%s name missing after '%s'", Desc.str().c_str(),
+ 

[llvm] [clang] [RISCV] Relax march string order constraint (PR #78120)

2024-01-14 Thread Piyou Chen via cfe-commits

https://github.com/BeMg created https://github.com/llvm/llvm-project/pull/78120

Address the https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14

This patch relax the `-march` string for accept any order. 

1. single-letter extension can be arbitrary order
- march=rv32iamdf 
2. single-letter extension and multi-letter extension can be mixed
- march=rv32i_zihintntl_m_a_f_d_svinval
3. multi-letter extension need seperate the following extension by underscore, 
otherwise it will be intreprete as one extension.
- march=rv32i_zbam -> i,zbam
- march=rv32i_zba_m -> i,zba,m


>From 88eef23588b545f29f3fe62a702ed2121b53c7cd Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Sun, 14 Jan 2024 19:41:59 -0800
Subject: [PATCH] [RISCV] Relax march string order constraint

---
 clang/test/Driver/riscv-arch.c  |  14 +-
 llvm/lib/Support/RISCVISAInfo.cpp   | 297 ++--
 llvm/unittests/Support/RISCVISAInfoTest.cpp |  91 --
 3 files changed, 226 insertions(+), 176 deletions(-)

diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 0ac81ea982f1b6..38de95e4fbf7aa 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -156,9 +156,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32L %s
 // RV32L: error: invalid arch name 'rv32l'
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32imadf -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32IMADF %s
-// RV32IMADF: error: invalid arch name 'rv32imadf'
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imadf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32imm -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32IMM %s
@@ -184,9 +183,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64L %s
 // RV64L: error: invalid arch name 'rv64l'
 
-// RUN: not %clang --target=riscv64-unknown-elf -march=rv64imadf -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64IMADF %s
-// RV64IMADF: error: invalid arch name 'rv64imadf'
+// RUN: %clang --target=riscv64-unknown-elf -march=rv64imadf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: not %clang --target=riscv64-unknown-elf -march=rv64imm -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64IMM %s
@@ -216,7 +214,7 @@
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32imcq -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ORDER %s
 // RV32-ORDER: error: invalid arch name 'rv32imcq',
-// RV32-ORDER: standard user-level extension not given in canonical order 'q'
+// RV32-ORDER: unsupported standard user-level extension 'q'
 
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32izvl64b -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVL64B-ER %s
@@ -318,7 +316,7 @@
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32ixabc_a -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-PREFIX %s
 // RV32-PREFIX: error: invalid arch name 'rv32ixabc_a',
-// RV32-PREFIX: invalid extension prefix 'a'
+// RV32-PREFIX: unsupported non-standard user-level extension 'xabc'
 
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32ixdef_sabc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-X-ORDER %s
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 390d950486a795..865ca48aeb90d1 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -695,6 +695,106 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
   return std::move(ISAInfo);
 }
 
+static Error splitExtsByUnderscore(StringRef Exts,
+   std::vector ) {
+  SmallVector Split;
+  if (Exts.empty())
+return Error::success();
+
+  Exts.split(Split, "_");
+
+  for (auto Ext : Split) {
+if (Ext.empty())
+  return createStringError(errc::invalid_argument,
+   "extension name missing after separator '_'");
+
+SplitedExts.push_back(Ext.str());
+  }
+  return Error::success();
+}
+
+static Error processMultiLetterExtension(
+StringRef RawExt, SmallVector ,
+SmallVector ,
+bool IgnoreUnknown, bool EnableExperimentalExtension,
+bool ExperimentalExtensionVersionCheck) {
+  StringRef Type = getExtensionType(RawExt);
+  StringRef Desc = getExtensionTypeDesc(RawExt);
+  auto Pos = findLastNonVersionCharacter(RawExt) + 1;
+  StringRef Name(RawExt.substr(0, Pos));
+  StringRef Vers(RawExt.substr(Pos));
+
+  if (Type.empty()) {
+if (IgnoreUnknown)
+  return Error::success();
+return createStringError(errc::invalid_argument,
+ "invalid extension prefix '" + RawExt + "'");
+  }
+
+  if (!IgnoreUnknown && Name.size() == Type.size())
+return createStringError(errc::invalid_argument,
+ "%s name 

[clang] [clang] [SemaCXX] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)

2024-01-14 Thread A. Jiang via cfe-commits

frederick-vs-ja wrote:

> Should this be a SFINAE-able error before C++23? (It isn't currently)

I believe this should (in C++11 and later modes).

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


[clang] [llvm] [X86] Use vXi1 for `k` constraint in inline asm (PR #77733)

2024-01-14 Thread Shengchen Kan via cfe-commits


@@ -57046,17 +57046,17 @@ X86TargetLowering::getRegForInlineAsmConstraint(const 
TargetRegisterInfo *TRI,
   // in the normal allocation?
 case 'k':
   if (Subtarget.hasAVX512()) {
-if (VT == MVT::i1)
+if (VT == MVT::v1i1 || VT == MVT::i1)
   return std::make_pair(0U, ::VK1RegClass);
-if (VT == MVT::i8)
+if (VT == MVT::v8i1 || VT == MVT::i8)
   return std::make_pair(0U, ::VK8RegClass);
-if (VT == MVT::i16)
+if (VT == MVT::v16i1 || VT == MVT::i16)
   return std::make_pair(0U, ::VK16RegClass);
   }
   if (Subtarget.hasBWI()) {
-if (VT == MVT::i32)
+if (VT == MVT::v32i1 || VT == MVT::i32)
   return std::make_pair(0U, ::VK32RegClass);
-if (VT == MVT::i64)
+if (VT == MVT::v64i1 || VT == MVT::i64)
   return std::make_pair(0U, ::VK64RegClass);

KanRobert wrote:

Never mind. I see your comment.

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


[clang] [llvm] [X86] Use vXi1 for `k` constraint in inline asm (PR #77733)

2024-01-14 Thread Shengchen Kan via cfe-commits


@@ -57046,17 +57046,17 @@ X86TargetLowering::getRegForInlineAsmConstraint(const 
TargetRegisterInfo *TRI,
   // in the normal allocation?
 case 'k':
   if (Subtarget.hasAVX512()) {
-if (VT == MVT::i1)
+if (VT == MVT::v1i1 || VT == MVT::i1)
   return std::make_pair(0U, ::VK1RegClass);
-if (VT == MVT::i8)
+if (VT == MVT::v8i1 || VT == MVT::i8)
   return std::make_pair(0U, ::VK8RegClass);
-if (VT == MVT::i16)
+if (VT == MVT::v16i1 || VT == MVT::i16)
   return std::make_pair(0U, ::VK16RegClass);
   }
   if (Subtarget.hasBWI()) {
-if (VT == MVT::i32)
+if (VT == MVT::v32i1 || VT == MVT::i32)
   return std::make_pair(0U, ::VK32RegClass);
-if (VT == MVT::i64)
+if (VT == MVT::v64i1 || VT == MVT::i64)
   return std::make_pair(0U, ::VK64RegClass);

KanRobert wrote:

i1, i8, i16 is kept for what? backward compatibility of IR?

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


[clang] [clang][docs] Improve "Obtaining Clang" section (PR #71313)

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

Endilll wrote:

LGTM, but wair for other reviewers. 

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


[clang] [clang][modules] Print library module manifest path. (PR #76451)

2024-01-14 Thread Chuanqi Xu via cfe-commits

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


[clang] [clang][modules] Print library module manifest path. (PR #76451)

2024-01-14 Thread Chuanqi Xu via cfe-commits

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


[clang] [coroutines][coro_lifetimebound] Detect lifetime issues with lambda captures (PR #77066)

2024-01-14 Thread Chuanqi Xu via cfe-commits


@@ -33,6 +34,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Casting.h"

ChuanqiXu9 wrote:

Maybe we don't need this?

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


[clang] [coroutines][coro_lifetimebound] Detect lifetime issues with lambda captures (PR #77066)

2024-01-14 Thread Chuanqi Xu via cfe-commits


@@ -15845,8 +15845,10 @@ void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
   RecordDecl *RD = FD->getReturnType()->getAsRecordDecl();
   if (!RD || !RD->getUnderlyingDecl()->hasAttr())
 return;
-  // Allow `get_return_object()`.
-  if (FD->getDeclName().isIdentifier() &&
+  // Allow some_promise_type::get_return_object().
+  // Since we are still in the promise definition, we can only do this
+  // heuristically as the promise may not be yet associated to a coroutine.
+  if (isa(FD) && FD->getDeclName().isIdentifier() &&
   FD->getName().equals("get_return_object") && FD->param_empty())
 return;

ChuanqiXu9 wrote:

Can we return directly if it has `CoroDisableLifetimeBoundAttr`? (Maybe we need 
to edit the semantics of `CoroDisableLifetimeBoundAttr` a little bit)

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


[clang] [coroutines][coro_lifetimebound] Detect lifetime issues with lambda captures (PR #77066)

2024-01-14 Thread Chuanqi Xu via cfe-commits


@@ -1796,6 +1797,32 @@ bool CoroutineStmtBuilder::makeOnException() {
   return true;
 }
 
+// Adds [[clang::coro_wrapper]] and [[clang::coro_disable_lifetimebound]]
+// attributes to the function `get_return_object`.

ChuanqiXu9 wrote:

```suggestion
// attributes to the function `get_return_object` if its return type is marked 
with `[[clang::coro_return_type]]` to avoid false-positive diagnostic for 
`get_return_object`.
```

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


[clang] [coroutines][coro_lifetimebound] Detect lifetime issues with lambda captures (PR #77066)

2024-01-14 Thread Chuanqi Xu via cfe-commits


@@ -1796,6 +1797,32 @@ bool CoroutineStmtBuilder::makeOnException() {
   return true;
 }
 
+// Adds [[clang::coro_wrapper]] and [[clang::coro_disable_lifetimebound]]
+// attributes to the function `get_return_object`.
+static void handleGetReturnObject(Sema , Expr *E) {
+  if (auto *TE = dyn_cast(E))
+E = TE->getSubExpr();
+  auto *CE = dyn_cast(E);
+  assert(CE);

ChuanqiXu9 wrote:

```suggestion
  auto *CE = cast(E);
```

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


[clang] [clang][modules] Print library module manifest path. (PR #76451)

2024-01-14 Thread Chuanqi Xu via cfe-commits

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

LGTM.

While we need to delete 
`clang/test/Driver/Inputs/cxx23_modules/usr/lib/x86_64-linux-gnu/libc++.so` and 
`clang/test/Driver/Inputs/cxx23_modules/usr/lib/x86_64-linux-gnu/modules.json`.

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


[llvm] [clang] [X86] Use vXi1 for `k` constraint in inline asm (PR #77733)

2024-01-14 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> > > Why not return `i32` for 64-bit mask in 32-bit mode?
> > 
> > 
> > You mean in two `i32` registers? The problem is the inline asm constraint 
> > has 1:1 map with physical register except corner cases. And represent a `k` 
> > constraint into two GPR registers is inefficient.
> 
> Is it represented by i64 x 1 in 32-bit mode after this patch?

Yes.

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


[llvm] [clang] [clang-tools-extra] [PowerPC] Implement fence builtin (PR #76495)

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

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


[clang] 85071a3 - [PowerPC] Implement fence builtin (#76495)

2024-01-14 Thread via cfe-commits

Author: Qiu Chaofan
Date: 2024-01-15T11:19:16+08:00
New Revision: 85071a3c74f531ade3709351638c1380c4503d2c

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

LOG: [PowerPC] Implement fence builtin (#76495)

Added: 
llvm/test/CodeGen/PowerPC/fence.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Basic/Targets/PPC.cpp
clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
llvm/lib/Target/PowerPC/PPCInstrInfo.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index a35488ed3dfa56..88ae0ce940852e 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -110,6 +110,10 @@ BUILTIN(__builtin_ppc_fctiw, "dd", "")
 BUILTIN(__builtin_ppc_fctiwz, "dd", "")
 BUILTIN(__builtin_ppc_fctudz, "dd", "")
 BUILTIN(__builtin_ppc_fctuwz, "dd", "")
+
+// fence builtin prevents all instructions moved across it
+BUILTIN(__builtin_ppc_fence, "v", "")
+
 BUILTIN(__builtin_ppc_swdiv_nochk, "ddd", "")
 BUILTIN(__builtin_ppc_swdivs_nochk, "fff", "")
 BUILTIN(__builtin_ppc_alignx, "vIivC*", "nc")

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 045c273f03c7a0..41935abfb65d3b 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -212,6 +212,7 @@ static void defineXLCompatMacros(MacroBuilder ) {
   Builder.defineMacro("__darn_32", "__builtin_darn_32");
   Builder.defineMacro("__darn_raw", "__builtin_darn_raw");
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
+  Builder.defineMacro("__fence", "__builtin_ppc_fence");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
   Builder.defineMacro("__abs", "__builtin_abs");

diff  --git a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
index 9187bb855dac22..a5cc97161c56ac 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
@@ -194,6 +194,18 @@ void test_dcbz() {
   __dcbz(c);
 }
 
+// CHECK-LABEL: @test_fence(
+// CHECK: call void @llvm.ppc.fence()
+// CHECK-NEXT:ret void
+//
+// CHECK-32-LABEL: @test_fence(
+// CHECK-32: call void @llvm.ppc.fence()
+// CHECK-32-NEXT:ret void
+//
+void test_fence() {
+  __fence();
+}
+
 // CHECK-LABEL: @test_builtin_ppc_popcntb(
 // CHECK:[[TMP0:%.*]] = load i64, ptr @a, align 8
 // CHECK-NEXT:[[POPCNTB:%.*]] = call i64 @llvm.ppc.popcntb.i64.i64(i64 
[[TMP0]])
@@ -375,3 +387,15 @@ void test_builtin_ppc_dcbtst() {
 void test_builtin_ppc_dcbz() {
   __builtin_ppc_dcbz(c);
 }
+
+// CHECK-LABEL: @test_builtin_ppc_fence(
+// CHECK: call void @llvm.ppc.fence()
+// CHECK-NEXT:ret void
+//
+// CHECK-32-LABEL: @test_builtin_ppc_fence(
+// CHECK-32: call void @llvm.ppc.fence()
+// CHECK-32-NEXT:ret void
+//
+void test_builtin_ppc_fence() {
+  __builtin_ppc_fence();
+}

diff  --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 3ede2a3736bf30..6d1e8eb47405dd 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -29,6 +29,11 @@ let TargetPrefix = "ppc" in {  // All intrinsics start with 
"llvm.ppc.".
 [IntrArgMemOnly, NoCapture>, ImmArg>]>;
   def int_ppc_dcbzl : Intrinsic<[], [llvm_ptr_ty], []>;
 
+  // Emit pseudo instruction as fence of instruction motion
+  def int_ppc_fence : ClangBuiltin<"__builtin_ppc_fence">,
+  DefaultAttrsIntrinsic<[], [],
+[IntrNoMerge, IntrHasSideEffects]>;
+
   // Get content from current FPSCR register
   def int_ppc_readflm : ClangBuiltin<"__builtin_readflm">,
 DefaultAttrsIntrinsic<[llvm_double_ty], [],

diff  --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index aaced58defe603..538e0e6b3d420c 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2155,11 +2155,17 @@ bool PPCInstrInfo::isPredicated(const MachineInstr ) 
const {
 bool PPCInstrInfo::isSchedulingBoundary(const MachineInstr ,
 const MachineBasicBlock *MBB,
 const MachineFunction ) const {
+  switch (MI.getOpcode()) {
+  default:
+break;
   // Set MFFS and MTFSF as scheduling boundary to avoid unexpected code motion
   // across them, since some FP operations may change content of FPSCR.
   // TODO: Model FPSCR in PPC instruction 

[llvm] [clang] [PGO]Add `-fdiagnostics-show-profile-count` option to show real loop count from instr-profile (PR #75021)

2024-01-14 Thread Elvis Wang via cfe-commits

ElvisWang123 wrote:

Gentle ping

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


[clang] [clang-format] Stop aligning the to continuation lines (PR #76378)

2024-01-14 Thread via cfe-commits

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


[clang] e3acfbc - [clang-format] Stop aligning the to continuation lines (#76378)

2024-01-14 Thread via cfe-commits

Author: sstwcw
Date: 2024-01-15T03:04:42Z
New Revision: e3acfbc471ac74425c2a4b54546b322b42c4cf00

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

LOG: [clang-format] Stop aligning the to continuation lines (#76378)

Some unwrapped lines are marked as continuations of the previous lines,
for example the ports in a Verilog module header. Previously, if the
first line following the ports line was changed, and git-clang-format
was run, the changed line would be indented by an extra continuation
indentation.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTestCSharp.cpp
clang/unittests/Format/FormatTestVerilog.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 27983a330ac40a..adeb072434873f 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -95,7 +95,7 @@ class LevelIndentTracker {
   /// level to the same indent.
   /// Note that \c nextLine must have been called before this method.
   void adjustToUnmodifiedLine(const AnnotatedLine ) {
-if (Line.InPPDirective)
+if (Line.InPPDirective || Line.IsContinuation)
   return;
 assert(Line.Level < IndentForLevel.size());
 if (Line.First->is(tok::comment) && IndentForLevel[Line.Level] != -1)

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 4a0840d32341e8..6f5e1e41ef7e0b 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -1304,6 +1304,18 @@ TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) {
"}",
Style);
 
+  // When the "where" line is not to be formatted, following lines should not
+  // take on its indentation.
+  verifyFormat("class ItemFactory\n"
+   "where T : new() {\n"
+   "  int f() {}\n"
+   "}",
+   "class ItemFactory\n"
+   "where T : new() {\n"
+   "  int f() {}\n"
+   "}",
+   Style, {tooling::Range(43, 13)});
+
   verifyFormat("class Dictionary\n"
"where TKey : IComparable\n"
"where TVal : IMyInterface {\n"

diff  --git a/clang/unittests/Format/FormatTestVerilog.cpp 
b/clang/unittests/Format/FormatTestVerilog.cpp
index fcda05df182687..abebf9f7d4c785 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -613,6 +613,17 @@ TEST_F(FormatTestVerilog, Headers) {
"  (input var x aaa``x, \\\n"
"   b);",
Style);
+  // When the ports line is not to be formatted, following lines should not 
take
+  // on its indentation.
+  verifyFormat("module x\n"
+   "(output x);\n"
+   "  assign x = 0;\n"
+   "endmodule",
+   "module x\n"
+   "(output x);\n"
+   "assign x = 0;\n"
+   "endmodule",
+   getDefaultStyle(), {tooling::Range(25, 18)});
 }
 
 TEST_F(FormatTestVerilog, Hierarchy) {



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


[llvm] [clang] [X86] Use vXi1 for `k` constraint in inline asm (PR #77733)

2024-01-14 Thread Shengchen Kan via cfe-commits

KanRobert wrote:

> > Why not return `i32` for 64-bit mask in 32-bit mode?
> 
> You mean in two `i32` registers? The problem is the inline asm constraint has 
> 1:1 map with physical register except corner cases. And represent a `k` 
> constraint into two GPR registers is inefficient.

Is it represented by i64 x 1 in 32-bit mode after this patch?

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


[clang] [libclang/python] Bump minimum compatibility to Python 3.6 (PR #77228)

2024-01-14 Thread Craig Hesling via cfe-commits

linux4life798 wrote:

> This should just bump to 3.8 IMO. Anything below that is end-of-life and a 
> waste of time to support.

I agree and my personal plan is still to bump the version to 3.7 or 3.8, but it 
was more important to me to make progress towards adding any usable type 
annotations than it is to raise the min python version across llvm or just 
within libclang. I figured this incremental change was safe, couldn't be 
blocked based on min version, and doesn't introduce any syntax that has been 
obsoleted in later python.

Let me know if you think there is something I could do to help progress the 
transition to python min version 3.8 (or 3.7).

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


[clang] [X86_64] fix empty structure vaarg in c++ (PR #77907)

2024-01-14 Thread Longsheng Mou via cfe-commits

CoTinker wrote:

> I checked it locally, the patch doesn't fix the reported problem:
> 
> ```
> $ clang pr77036.cpp && ./a.out
> -nan
> Fail
> ```

It seems that `struct S14{}` is empty record, but  `struct S14 { union{}a;}` is 
not.

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


[clang] [llvm] [X86] Use vXi1 for `k` constraint in inline asm (PR #77733)

2024-01-14 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> Why not return `i32` for 64-bit mask in 32-bit mode?

You mean in two `i32` registers? The problem is the inline asm constraint has 
1:1 map with physical register except corner cases. And represent a `k` 
constraint into two GPR registers is inefficient.

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


[clang] [llvm] [mlir] [mlir][gpu] Add the `OffloadEmbeddingAttr` offloading translation attr (PR #78117)

2024-01-14 Thread Fabian Mora via cfe-commits

https://github.com/fabianmcg created 
https://github.com/llvm/llvm-project/pull/78117

This patch adds the offloading translation attribute. This attribute uses LLVM
offloading infrastructure to embed GPU binaries in the IR. At the program start,
the LLVM offloading mechanism registers kernels and variables with the runtime
library: CUDA RT, HIP RT, or LibOMPTarget.

The offloading mechanism relies on the runtime library to dispatch the correct
kernel based on the registered symbols.

This patch is 3/4 on introducing the `OffloadEmbeddingAttr` GPU translation
attribute.

Note: Ignore the base commits; those are being reviewed in PRs #78057, #78098,
and #78073.


>From 61c8809698b66cf3b4686e9908fb11773ecf0eb6 Mon Sep 17 00:00:00 2001
From: Fabian Mora 
Date: Sat, 13 Jan 2024 23:45:57 +
Subject: [PATCH 1/4] [mlir][interfaces] Add the `TargetInfo` attribute
 interface

This patch adds the TargetInfo attribute interface to the set of DLTI
interfaces. Target information attributes provide essential information on the
compilation target. This information includes the target triple identifier, the
target chip identifier, and a string representation of the target features.

This patch also adds this new interface to the NVVM and ROCDL GPU target
attributes.
---
 .../include/mlir/Dialect/LLVMIR/NVVMDialect.h |  1 +
 mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td   |  5 ++-
 .../mlir/Dialect/LLVMIR/ROCDLDialect.h|  1 +
 mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td  |  6 ++--
 .../mlir/Interfaces/DataLayoutInterfaces.td   | 33 +++
 mlir/lib/Dialect/LLVMIR/CMakeLists.txt|  2 ++
 mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp|  8 +
 mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp   |  8 +
 8 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h 
b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h
index 08019e77ae6af8..1a55d08be9edc2 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h
@@ -19,6 +19,7 @@
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Dialect.h"
 #include "mlir/IR/OpDefinition.h"
+#include "mlir/Interfaces/DataLayoutInterfaces.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
index c5f68a2ebe3952..0bbbde6270cd69 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
@@ -17,6 +17,7 @@ include "mlir/IR/EnumAttr.td"
 include "mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td"
 include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
+include "mlir/Interfaces/DataLayoutInterfaces.td"
 include "mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.td"
 
 def LLVM_PointerGlobal : LLVM_PointerInAddressSpace<1>;
@@ -1894,7 +1895,9 @@ def NVVM_WgmmaMmaAsyncOp : NVVM_Op<"wgmma.mma_async",
 // NVVM target attribute.
 
//===--===//
 
-def NVVM_TargettAttr : NVVM_Attr<"NVVMTarget", "target"> {
+def NVVM_TargettAttr : NVVM_Attr<"NVVMTarget", "target", [
+DeclareAttrInterfaceMethods
+  ]> {
   let description = [{
 GPU target attribute for controlling compilation of NVIDIA targets. All
 parameters decay into default values if not present.
diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h 
b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h
index c2a82ffc1c43cf..fa1131a463e1ab 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h
@@ -26,6 +26,7 @@
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/IR/Dialect.h"
 #include "mlir/IR/OpDefinition.h"
+#include "mlir/Interfaces/DataLayoutInterfaces.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
 
 / Ops /
diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
index 48b830ae34f292..a492709c299544 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -15,6 +15,7 @@
 
 include "mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td"
 include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
+include "mlir/Interfaces/DataLayoutInterfaces.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 
//===--===//
@@ -608,8 +609,9 @@ def ROCDL_CvtSrFp8F32Op :
 // ROCDL target attribute.
 
//===--===//
 
-def ROCDL_TargettAttr :
-ROCDL_Attr<"ROCDLTarget", "target"> {
+def ROCDL_TargettAttr : ROCDL_Attr<"ROCDLTarget", "target", [
+DeclareAttrInterfaceMethods
+  ]> {
   let description = [{
 ROCDL target attribute for controlling compilation of AMDGPU targets. All
 parameters decay 

[llvm] [clang] [X86] Use vXi1 for `k` constraint in inline asm (PR #77733)

2024-01-14 Thread Shengchen Kan via cfe-commits

KanRobert wrote:

Why not return `i32` for 64-bit mask in 32-bit mode?

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


[clang] Fix crash with modules and constexpr destructor (PR #69076)

2024-01-14 Thread Chuanqi Xu via cfe-commits

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

LGTM. Thanks for your patience.

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


[clang] [AVX10][Doc] Add documentation about AVX10 options and their attentions (PR #77925)

2024-01-14 Thread Shengchen Kan via cfe-commits

KanRobert wrote:

Thanks for this!

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


[clang] [Clang][Sema] fix crash of attribute transform (PR #78088)

2024-01-14 Thread Qizhi Hu via cfe-commits

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


[flang] [clang] [clang-tools-extra] [llvm] [compiler-rt] [mlir] [lld] [libcxx] [lldb] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)

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

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/78022

>From 0988bb25a35e5d50b44bf53d459098777280c3e5 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Sat, 13 Jan 2024 16:00:16 +0800
Subject: [PATCH 1/2] [clang-tidy]Add new check
 readability-avoid-nested-conditional-operator Finds nested conditional
 operator. Nested conditional operators lead code hard to understand, so they
 should be splited as several statement and stored in temporary varibale.

---
 .../AvoidNestedConditionalOperatorCheck.cpp   | 56 +++
 .../AvoidNestedConditionalOperatorCheck.h | 33 +++
 .../clang-tidy/readability/CMakeLists.txt |  1 +
 .../readability/ReadabilityTidyModule.cpp |  3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../avoid-nested-conditional-operator.rst | 20 +++
 .../avoid-nested-conditional-operator.cpp | 23 
 8 files changed, 142 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp

diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
new file mode 100644
index 00..a0278c3ae32fa7
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
@@ -0,0 +1,56 @@
+//===--- AvoidNestedConditionalOperatorCheck.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 "AvoidNestedConditionalOperatorCheck.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/DiagnosticIDs.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+constexpr const char *Description = "don't use nested conditional operator";
+constexpr const char *OutSideConditionalOperatorNote =
+"outside conditional operator here";
+} // namespace
+
+void AvoidNestedConditionalOperatorCheck::registerMatchers(
+MatchFinder *Finder) {
+  Finder->addMatcher(
+  conditionalOperator(
+  anyOf(
+  hasCondition(ignoringParenCasts(
+  conditionalOperator().bind("nested-conditional-operator"))),
+  hasTrueExpression(ignoringParenCasts(
+  conditionalOperator().bind("nested-conditional-operator"))),
+  hasFalseExpression(ignoringParenCasts(
+  conditionalOperator().bind("nested-conditional-operator")
+  .bind("conditional-operator"),
+  this);
+}
+
+void AvoidNestedConditionalOperatorCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto *CO =
+  Result.Nodes.getNodeAs("conditional-operator");
+  const auto *NCO = Result.Nodes.getNodeAs(
+  "nested-conditional-operator");
+  assert(CO);
+  assert(NCO);
+
+  if (CO->getBeginLoc().isMacroID() || NCO->getBeginLoc().isMacroID())
+return;
+
+  diag(NCO->getBeginLoc(), Description);
+  diag(CO->getBeginLoc(), OutSideConditionalOperatorNote, DiagnosticIDs::Note);
+}
+
+} // namespace clang::tidy::readability
diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
new file mode 100644
index 00..2f82ea86cd849d
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
@@ -0,0 +1,33 @@
+//===--- AvoidNestedConditionalOperatorCheck.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_AVOIDNestedConditionalOperatorCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::readability {
+
+/// Finds nested conditional operator.
+///
+/// For the user-facing documentation see:
+/// 

[clang] [Clang][Sema] fix crash of attribute transform (PR #78088)

2024-01-14 Thread Qizhi Hu via cfe-commits

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


[clang] [Clang][Sema] fix crash of attribute transform (PR #78088)

2024-01-14 Thread Qizhi Hu via cfe-commits

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


[clang] [Clang][Sema] fix crash of attribute transform (PR #78088)

2024-01-14 Thread Qizhi Hu via cfe-commits

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


[clang-tools-extra] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)

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

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/78022

>From 0988bb25a35e5d50b44bf53d459098777280c3e5 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Sat, 13 Jan 2024 16:00:16 +0800
Subject: [PATCH 1/2] [clang-tidy]Add new check
 readability-avoid-nested-conditional-operator Finds nested conditional
 operator. Nested conditional operators lead code hard to understand, so they
 should be splited as several statement and stored in temporary varibale.

---
 .../AvoidNestedConditionalOperatorCheck.cpp   | 56 +++
 .../AvoidNestedConditionalOperatorCheck.h | 33 +++
 .../clang-tidy/readability/CMakeLists.txt |  1 +
 .../readability/ReadabilityTidyModule.cpp |  3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../avoid-nested-conditional-operator.rst | 20 +++
 .../avoid-nested-conditional-operator.cpp | 23 
 8 files changed, 142 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp

diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
new file mode 100644
index 00..a0278c3ae32fa7
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp
@@ -0,0 +1,56 @@
+//===--- AvoidNestedConditionalOperatorCheck.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 "AvoidNestedConditionalOperatorCheck.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/DiagnosticIDs.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+constexpr const char *Description = "don't use nested conditional operator";
+constexpr const char *OutSideConditionalOperatorNote =
+"outside conditional operator here";
+} // namespace
+
+void AvoidNestedConditionalOperatorCheck::registerMatchers(
+MatchFinder *Finder) {
+  Finder->addMatcher(
+  conditionalOperator(
+  anyOf(
+  hasCondition(ignoringParenCasts(
+  conditionalOperator().bind("nested-conditional-operator"))),
+  hasTrueExpression(ignoringParenCasts(
+  conditionalOperator().bind("nested-conditional-operator"))),
+  hasFalseExpression(ignoringParenCasts(
+  conditionalOperator().bind("nested-conditional-operator")
+  .bind("conditional-operator"),
+  this);
+}
+
+void AvoidNestedConditionalOperatorCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto *CO =
+  Result.Nodes.getNodeAs("conditional-operator");
+  const auto *NCO = Result.Nodes.getNodeAs(
+  "nested-conditional-operator");
+  assert(CO);
+  assert(NCO);
+
+  if (CO->getBeginLoc().isMacroID() || NCO->getBeginLoc().isMacroID())
+return;
+
+  diag(NCO->getBeginLoc(), Description);
+  diag(CO->getBeginLoc(), OutSideConditionalOperatorNote, DiagnosticIDs::Note);
+}
+
+} // namespace clang::tidy::readability
diff --git 
a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
new file mode 100644
index 00..2f82ea86cd849d
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h
@@ -0,0 +1,33 @@
+//===--- AvoidNestedConditionalOperatorCheck.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_AVOIDNestedConditionalOperatorCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::readability {
+
+/// Finds nested conditional operator.
+///
+/// For the user-facing documentation see:
+/// 

[clang] [llvm] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Samuel Thibault via cfe-commits

https://github.com/sthibaul updated 
https://github.com/llvm/llvm-project/pull/78065

>From fefe6175fa21c668f58d69b0acc9abb89af981ab Mon Sep 17 00:00:00 2001
From: Samuel Thibault 
Date: Sun, 14 Jan 2024 19:01:52 +0100
Subject: [PATCH 1/3] hurd: Fix indent

---
 clang/test/Driver/hurd.cpp | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/test/Driver/hurd.cpp b/clang/test/Driver/hurd.cpp
index 1c4ba16af063d7..8934997b107aed 100644
--- a/clang/test/Driver/hurd.cpp
+++ b/clang/test/Driver/hurd.cpp
@@ -2,8 +2,8 @@
 
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   --stdlib=platform 2>&1 | FileCheck --check-prefix=CHECK %s
-// CHECK: "-cc1"
-// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK:  "-cc1"
+// CHECK:  "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
@@ -29,9 +29,9 @@
 
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   --stdlib=platform -static 2>&1 | FileCheck 
--check-prefix=CHECK-STATIC %s
-// CHECK-STATIC: "-cc1"
-// CHECK-STATIC: "-static-define"
-// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC:  "-cc1"
+// CHECK-STATIC:  "-static-define"
+// CHECK-STATIC:  "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-STATIC-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
@@ -57,9 +57,9 @@
 
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   -shared 2>&1 | FileCheck --check-prefix=CHECK-SHARED %s
-// CHECK-SHARED: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbeginS.o"
-// CHECK-SHARED: "-L
+// CHECK-SHARED:  "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-SHARED:  "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbeginS.o"
+// CHECK-SHARED:  "-L
 // CHECK-SHARED-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/10"
 // CHECK-SHARED-SAME: {{^}} 
"-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../lib32"
 // CHECK-SHARED-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"

>From 9f03f0ad3d9fdf20070664dcf68006fbeedd1f72 Mon Sep 17 00:00:00 2001
From: Samuel Thibault 
Date: Sun, 14 Jan 2024 19:02:30 +0100
Subject: [PATCH 2/3] hurd: Strengthen test

---
 clang/test/Driver/hurd.cpp | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/clang/test/Driver/hurd.cpp b/clang/test/Driver/hurd.cpp
index 8934997b107aed..da7f5526822e37 100644
--- a/clang/test/Driver/hurd.cpp
+++ b/clang/test/Driver/hurd.cpp
@@ -3,21 +3,21 @@
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   --stdlib=platform 2>&1 | FileCheck --check-prefix=CHECK %s
 // CHECK:  "-cc1"
-// CHECK:  "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
 /// Debian specific - the path component after 'include' is i386-gnu even
 /// though the installation is i686-gnu.
 // CHECK-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/i386-gnu/c++/10"
 // CHECK-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10/backward"
 // CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
-// CHECK:  "-internal-externc-isystem"
+// CHECK-SAME: "-internal-externc-isystem"
 // CHECK-SAME: {{^}} "[[SYSROOT]]/usr/include/i386-gnu"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK:  "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK:  "-dynamic-linker" "/lib/ld.so"
-// CHECK:  "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbegin.o"
-// CHECK:  "-L
+// CHECK-SAME: "-dynamic-linker" "/lib/ld.so"
+// CHECK-SAME: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbegin.o"
+// CHECK-SAME: "-L
 // CHECK-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/10"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../lib32"
 // CHECK-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
@@ -30,22 +30,22 @@
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   --stdlib=platform -static 2>&1 | FileCheck 
--check-prefix=CHECK-STATIC %s
 // CHECK-STATIC:  "-cc1"
-// CHECK-STATIC:  "-static-define"
-// CHECK-STATIC:  "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC-SAME: "-static-define"
+// CHECK-STATIC-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-STATIC-SAME: {{^}} "-internal-isystem" 

[clang] [llvm] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Samuel Thibault via cfe-commits

sthibaul wrote:

> Could you add some descriptions?

What kind of description, where?

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


[clang] [libclang/python] Bump minimum compatibility to Python 3.6 (PR #77228)

2024-01-14 Thread via cfe-commits

h-vetinari wrote:

This should just bump to 3.8 IMO. Anything below that is end-of-life and a 
waste of time to support. 

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


[clang] [X86_64] fix empty structure vaarg in c++ (PR #77907)

2024-01-14 Thread Longsheng Mou via cfe-commits

CoTinker wrote:

> I checked it locally, the patch doesn't fix the reported problem:
> 
> ```
> $ clang pr77036.cpp && ./a.out
> -nan
> Fail
> ```

isEmptyRecord return false here, I am checking it.

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


[clang] [CLANG][NFC] Modify test cases to suit assigned default sysroot path (PR #77075)

2024-01-14 Thread Brad Smith via cfe-commits

brad0 wrote:

@MaskRay Wasn't it you that mentioned this?

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


[clang] [llvm] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Samuel Thibault via cfe-commits


@@ -2652,6 +2652,31 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 return;
   }
 
+  if (TargetTriple.isOSHurd()) {
+static const char *const X86_64HurdTriples[] = {"x86_64-gnu"};

sthibaul wrote:

But then also `BiarchTripleAliases.push_back("x86_64-gnu");` ?

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


[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)

2024-01-14 Thread Yuanfang Chen via cfe-commits

yuanfang-chen wrote:

ping?

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


[clang-tools-extra] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)

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


@@ -0,0 +1,56 @@
+//===--- AvoidNestedConditionalOperatorCheck.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 "AvoidNestedConditionalOperatorCheck.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/DiagnosticIDs.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+constexpr const char *Description = "don't use nested conditional operator";
+constexpr const char *OutSideConditionalOperatorNote =
+"outside conditional operator here";
+} // namespace
+
+void AvoidNestedConditionalOperatorCheck::registerMatchers(
+MatchFinder *Finder) {
+  Finder->addMatcher(
+  conditionalOperator(

HerrCai0907 wrote:

`BinaryConditionalOperator` is a GNU extension and I don't find any code guide 
to rule its usage.
And it is a binary operator, like other normal binary operator, It's not worth 
being limited. 

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


[llvm] [clang] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits

MaskRay wrote:

Thanks for the patch. It's in a very good shape and I did not need to make many 
nitpicky comments like I had to do for other "support a new target triple" 
driver patch:)

Could you add some descriptions?

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


[llvm] [clang] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits


@@ -78,3 +78,82 @@
 // CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/../../../../i686-gnu/bin/ld"
 {{.*}} "-m" "elf_i386"
 // CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o"
 // CHECK-CROSS: 
"-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/../../../../i686-gnu/lib"
+
+// RUN: %clang -### %s --target=x86_64-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
+// RUN:   --stdlib=platform 2>&1 | FileCheck --check-prefix=CHECK-64 %s
+// CHECK-64:  "-cc1"
+// CHECK-64:  "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-64-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/c++/10"
+/// Debian specific - the path component after 'include' is x86_64-gnu even
+/// though the installation is x86_64-gnu.
+// CHECK-64-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/x86_64-gnu/c++/10"
+// CHECK-64-SAME: {{^}} "-internal-isystem" 
"[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/c++/10/backward"
+// CHECK-64-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-64:  "-internal-externc-isystem"
+// CHECK-64-SAME: {{^}} "[[SYSROOT]]/usr/include/x86_64-gnu"
+// CHECK-64-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-64-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-64:  "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64:  "-dynamic-linker" "/lib/ld-x86-64.so.1"

MaskRay wrote:

Use `-SAME`

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


[llvm] [clang] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits


@@ -2,8 +2,8 @@
 
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   --stdlib=platform 2>&1 | FileCheck --check-prefix=CHECK %s
-// CHECK: "-cc1"
-// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK:  "-cc1"
+// CHECK:  "-isysroot" "[[SYSROOT:[^"]+]]"

MaskRay wrote:

Use `-SAME`

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


[clang] [llvm] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits


@@ -29,9 +29,9 @@
 
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   --stdlib=platform -static 2>&1 | FileCheck 
--check-prefix=CHECK-STATIC %s
-// CHECK-STATIC: "-cc1"
-// CHECK-STATIC: "-static-define"
-// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC:  "-cc1"
+// CHECK-STATIC:  "-static-define"

MaskRay wrote:

Use `-SAME`

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


[llvm] [clang] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits


@@ -78,3 +78,82 @@
 // CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/../../../../i686-gnu/bin/ld"
 {{.*}} "-m" "elf_i386"
 // CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o"
 // CHECK-CROSS: 
"-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/../../../../i686-gnu/lib"
+

MaskRay wrote:

I have checked, but can you try another build with 
`-DCLANG_DEFAULT_RTLIB=compiler-rt -DCLANG_DEFAULT_UNWINDLIB=libunwind 
-DCLANG_DEFAULT_CXX_STDLIB=libc++` and see whether the test still passes?

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


[clang] [llvm] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits

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


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


[llvm] [clang] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits


@@ -57,9 +57,9 @@
 
 // RUN: %clang -### %s --target=i686-pc-hurd-gnu 
--sysroot=%S/Inputs/basic_hurd_tree \
 // RUN:   -shared 2>&1 | FileCheck --check-prefix=CHECK-SHARED %s
-// CHECK-SHARED: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbeginS.o"
-// CHECK-SHARED: "-L
+// CHECK-SHARED:  "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-SHARED:  "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbeginS.o"

MaskRay wrote:

Use `-SAME`

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


[llvm] [clang] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits

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


[clang-tools-extra] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)

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


@@ -0,0 +1,56 @@
+//===--- AvoidNestedConditionalOperatorCheck.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 "AvoidNestedConditionalOperatorCheck.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/DiagnosticIDs.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+constexpr const char *Description = "don't use nested conditional operator";
+constexpr const char *OutSideConditionalOperatorNote =
+"outside conditional operator here";
+} // namespace
+
+void AvoidNestedConditionalOperatorCheck::registerMatchers(
+MatchFinder *Finder) {
+  Finder->addMatcher(
+  conditionalOperator(
+  anyOf(
+  hasCondition(ignoringParenCasts(

HerrCai0907 wrote:

Yes, It want to ignore the `ParenExpr` because this check want to detect `A ? B 
: (C ? D : E)` also.

```c++
/// Matches expressions that match InnerMatcher after parentheses and
/// casts are stripped off.
///
/// Implicit and non-C Style casts are also discarded.
/// Given
/// \code
///   int a = 0;
///   char b = (0);
///   void* c = reinterpret_cast(0);
///   char d = char(0);
/// \endcode
/// The matcher
///varDecl(hasInitializer(ignoringParenCasts(integerLiteral(
/// would match the declarations for a, b, c, and d.
/// while
///varDecl(hasInitializer(integerLiteral()))
/// only match the declaration for a.
AST_MATCHER_P(Expr, ignoringParenCasts, internal::Matcher, InnerMatcher) {
  return InnerMatcher.matches(*Node.IgnoreParenCasts(), Finder, Builder);
}
```

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


[clang] [llvm] Hurd: Add x86_64 support (PR #78065)

2024-01-14 Thread Fangrui Song via cfe-commits


@@ -2652,6 +2652,31 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 return;
   }
 
+  if (TargetTriple.isOSHurd()) {
+static const char *const X86_64HurdTriples[] = {"x86_64-gnu"};

MaskRay wrote:

Since there is just one, `TripleAliases.push_back("x86_64-gnu")` will be 
clearer and less verbose.

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


[clang] [llvm] [GitHub] Add python 3.7 to libclang python test (PR #77219)

2024-01-14 Thread Craig Hesling via cfe-commits


@@ -30,10 +30,15 @@ jobs:
   check-clang-python:
 # Build libclang and then run the libclang Python binding's unit tests.
 name: Build and run Python unit tests
+strategy:
+  fail-fast: false
+  matrix:
+python-version: ["3.7", "3.11"]

linux4life798 wrote:

* I added a note in the libclang python top level README about needing Python 
version 3.7.
https://github.com/llvm/llvm-project/pull/77219/commits/58bb2caa0fc4f3bc6b2cd187e524b9cc791355dd
* I also tried to spark a conversation in the RFC to bump python version across 
LLVM.
https://discourse.llvm.org/t/type-annotations-for-libclang-python-bindings/70644/14

Regardless, testing this library with an older version goes a long way towards 
ensuring backward compatibility.

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


[clang-tools-extra] [clang-tidy]fix readability-implicit-bool-conversion false-positives when comparison bool bitfield (PR #77878)

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

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


[clang-tools-extra] 332be17 - [clang-tidy]fix readability-implicit-bool-conversion false-positives when comparison bool bitfield (#77878)

2024-01-14 Thread via cfe-commits

Author: Congcong Cai
Date: 2024-01-15T09:11:16+08:00
New Revision: 332be179e13df924971f752236f5cf3c6483b588

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

LOG: [clang-tidy]fix readability-implicit-bool-conversion false-positives when 
comparison bool bitfield (#77878)

Fixes: #76817
For ignoring comparison and xor operator, it needs
to use `ImplicitCastFromBool` without ignoring
exception cases.
This patch splits ignoring exception cases logic
from `ImplicitCastFromBool` and only applies
it during matching targeted AST.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index f0fca30de3b3c4..672f28721114c9 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -274,8 +274,7 @@ void 
ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
 allOf(anyOf(hasCastKind(CK_NullToPointer),
 hasCastKind(CK_NullToMemberPointer)),
   hasSourceExpression(cxxBoolLiteral(,
-  hasSourceExpression(expr(hasType(booleanType(,
-  unless(ExceptionCases));
+  hasSourceExpression(expr(hasType(booleanType();
   auto BoolXor =
   binaryOperator(hasOperatorName("^"), hasLHS(ImplicitCastFromBool),
  hasRHS(ImplicitCastFromBool));
@@ -315,7 +314,7 @@ void 
ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
   traverse(
   TK_AsIs,
   implicitCastExpr(
-  ImplicitCastFromBool,
+  ImplicitCastFromBool, unless(ExceptionCases),
   // Exclude comparisons of bools, as they are always cast to
   // integers in such context:
   //   bool_expr_a == bool_expr_b

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index b7007a71d94c0e..344a7ed5798835 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -493,7 +493,8 @@ Changes in existing checks
   ` check to take
   do-while loops into account for the `AllowIntegerConditions` and
   `AllowPointerConditions` options. It also now provides more consistent
-  suggestions when parentheses are added to the return value.
+  suggestions when parentheses are added to the return value. It also ignores
+  false-positives for comparison containing bool bitfield.
 
 - Improved :doc:`readability-misleading-indentation
   ` check to ignore

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
index e393e297140cbd..48984d29322872 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -12,6 +12,7 @@ int* functionReturningPointer();
 struct Struct {
   int member;
   unsigned bitfield : 1;
+  bool boolfield : 1;
 };
 
 
@@ -28,6 +29,8 @@ void implicitConversionIntegerToBoolInConditionalsIsAllowed() 
{
   if (!s.member) {}
   if (s.bitfield) {}
   if (!s.bitfield) {}
+  if (s.boolfield == true) {}
+  if (s.boolfield != true) {}
   if (functionReturningInt()) {}
   if (!functionReturningInt()) {}
   if (functionReturningInt() && functionReturningPointer()) {}



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


[clang] [llvm] [GitHub] Add python 3.7 to libclang python test (PR #77219)

2024-01-14 Thread Craig Hesling via cfe-commits

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


[llvm] [clang] [GitHub] Add python 3.7 to libclang python test (PR #77219)

2024-01-14 Thread Craig Hesling via cfe-commits

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


[llvm] [clang] [GitHub] Add python 3.7 to libclang python test (PR #77219)

2024-01-14 Thread Craig Hesling via cfe-commits

https://github.com/linux4life798 updated 
https://github.com/llvm/llvm-project/pull/77219

>From 34492a5aea953be59cf84450862143cbcf53ea6e Mon Sep 17 00:00:00 2001
From: Craig Hesling 
Date: Sat, 30 Dec 2023 01:17:57 -0500
Subject: [PATCH 1/3] [GitHub] Add python_version input to
 llvm-project-test.yml

This will be used for testing the libclang Python binding
against different versions of Python.

Issue #76664.
Issue #76601.
---
 .github/workflows/llvm-project-tests.yml | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/llvm-project-tests.yml 
b/.github/workflows/llvm-project-tests.yml
index fadaea129e5088..a1404e1f1efa95 100644
--- a/.github/workflows/llvm-project-tests.yml
+++ b/.github/workflows/llvm-project-tests.yml
@@ -15,6 +15,10 @@ on:
   os_list:
 required: false
 default: '["ubuntu-latest", "windows-2019", "macOS-11"]'
+  python_version:
+required: false
+type: string
+default: '3.11'
   workflow_call:
 inputs:
   build_target:
@@ -38,6 +42,11 @@ on:
 # https://github.com/actions/virtual-environments/issues/5900
 default: '["ubuntu-latest", "windows-2019", "macOS-11"]'
 
+  python_version:
+required: false
+type: string
+default: '3.11'
+
 concurrency:
   # Skip intermediate builds: always.
   # Cancel intermediate builds: only if it is a pull request build.
@@ -67,7 +76,7 @@ jobs:
   - name: Setup Python
 uses: actions/setup-python@v4
 with:
-  python-version: '3.11'
+  python-version: ${{ inputs.python_version }}
   - name: Install Ninja
 uses: llvm/actions/install-ninja@main
   # actions/checkout deletes any existing files in the new git directory,

>From 58bb2caa0fc4f3bc6b2cd187e524b9cc791355dd Mon Sep 17 00:00:00 2001
From: Craig Hesling 
Date: Sun, 14 Jan 2024 16:42:53 -0800
Subject: [PATCH 2/3] [libclang/python] Add note about min python version

Issue #76664.
Issue #76601.
---
 clang/bindings/python/README.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/bindings/python/README.txt b/clang/bindings/python/README.txt
index 44c715e5de56f7..57994418af1e1e 100644
--- a/clang/bindings/python/README.txt
+++ b/clang/bindings/python/README.txt
@@ -4,6 +4,8 @@
 
 This directory implements Python bindings for Clang.
 
+The bindings library requires at least Python version 3.7.
+
 You may need to set CLANG_LIBRARY_PATH so that the Clang library can be
 found. The unit tests are designed to be run with any standard test
 runner. For example:

>From b34f420bcbcb18a41eedb5b3f761048d7bc2f2a1 Mon Sep 17 00:00:00 2001
From: Craig Hesling 
Date: Tue, 2 Jan 2024 19:01:49 -0500
Subject: [PATCH 3/3] [GitHub] Add python 3.7 to libclang python test

This enables the libclang python binding test to check
the oldest version of Python supported in addition
to the normal python version.

It is important to check this for issue #76664, since
many new mainstream python type annotation features
and best practices are not compatible with older
versions of python.

Additionally, frustration around ever increasing
platform dependencies and versions has been raised.
This will help ensure that python maintains reasonable
backwards compatibility.

Adding this additional build step will increase the
run time, but this should always be minimal, since
the additional libclang compilation should see 100%
cache hit rate.

Issue #76664.
Fixes #76601.
---
 .github/workflows/libclang-python-tests.yml | 5 +
 1 file changed, 5 insertions(+)

diff --git a/.github/workflows/libclang-python-tests.yml 
b/.github/workflows/libclang-python-tests.yml
index 73edb6cf3bad26..e12acbc0f6ce8c 100644
--- a/.github/workflows/libclang-python-tests.yml
+++ b/.github/workflows/libclang-python-tests.yml
@@ -30,6 +30,10 @@ jobs:
   check-clang-python:
 # Build libclang and then run the libclang Python binding's unit tests.
 name: Build and run Python unit tests
+strategy:
+  fail-fast: false
+  matrix:
+python-version: ["3.7", "3.11"]
 uses: ./.github/workflows/llvm-project-tests.yml
 with:
   build_target: check-clang-python
@@ -37,3 +41,4 @@ jobs:
   # There is an issue running on "windows-2019".
   # See 
https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
   os_list: '["ubuntu-latest"]'
+  python_version: ${{ matrix.python-version }}

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


[clang] [llvm] [llvm][frontend][offloading] Move clang-linker-wrapper/OffloadWrapper.* to llvm/Frontend/Offloading (PR #78057)

2024-01-14 Thread Fabian Mora via cfe-commits


@@ -568,32 +590,45 @@ void createRegisterFatbinFunction(Module , 
GlobalVariable *FatbinDesc,
 
 } // namespace
 
-Error wrapOpenMPBinaries(Module , ArrayRef> Images) {
-  GlobalVariable *Desc = createBinDesc(M, Images);
+Error OffloadWrapper::wrapOpenMPBinaries(
+Module , ArrayRef> Images,
+std::optional EntryArray) const {
+  GlobalVariable *Desc = createBinDesc(
+  M, Images,
+  EntryArray
+  ? *EntryArray
+  : offloading::getOffloadEntryArray(M, "omp_offloading_entries"),

fabianmcg wrote:

I see what you mean, first some broader context, this patch is also part of a 
patch series that will add GPU compilation for OMP operations in MLIR without 
the need for `flang` or `clang`, which is not currently possible. This series 
also enables to JIT OMP operations in MLIR. The goal of the series is to make 
OMP target functional in MLIR as a standalone.

I allow the passage of a custom entry array because ORC JIT doesn't fully 
support `__start`, `__stop` symbols for grouping section data.  My solution was 
allowing the custom entry array, so in MLIR I build the full entry array and 
never rely on sections, this applies to OMP, CUDA and HIP.
Thus we have that the following MLIR:
```
module attributes {gpu.container_module} {
  gpu.binary @binary <#gpu.offload_embedding> [#gpu.object<#nvvm.target, 
bin = "BLOB">]
  llvm.func @func() {
%1 = llvm.mlir.constant(1 : index) : i64
gpu.launch_func  @binary::@hello blocks in (%1, %1, %1) threads in (%1, %1, 
%1) : i64
gpu.launch_func  @binary::@world blocks in (%1, %1, %1) threads in (%1, %1, 
%1) : i64
llvm.return
  }
}
```
Produces:
```
@__begin_offload_binary = internal constant [2 x %struct.__tgt_offload_entry] 
[%struct.__tgt_offload_entry { ptr @binary_Khello, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, %struct.__tgt_offload_entry 
{ ptr @binary_Kworld, ptr @.omp_offloading.entry_name.2, i64 0, i32 0, i32 0 }]
@__end_offload_binary = internal constant ptr getelementptr inbounds 
(%struct.__tgt_offload_entry, ptr @__begin_offload_binary, i64 2)
@.fatbin_image.binary = internal constant [4 x i8] c"BLOB", section ".nv_fatbin"
@.fatbin_wrapper.binary = internal constant %fatbin_wrapper { i32 1180844977, 
i32 1, ptr @.fatbin_image.binary, ptr null }, section ".nvFatBinSegment", align 
8
@.cuda.binary_handle.binary = internal global ptr null
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr 
} { i32 1, ptr @.cuda.fatbin_reg.binary, ptr null }]
@binary_Khello = weak constant i8 0
@.omp_offloading.entry_name = internal unnamed_addr constant [6 x i8] 
c"hello\00"
@binary_Kworld = weak constant i8 0
@.omp_offloading.entry_name.2 = internal unnamed_addr constant [6 x i8] 
c"world\00"
...
```
And this works.

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


[llvm] [libc] [clang] [Libc] Give more functions restrict qualifiers (PR #78061)

2024-01-14 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/78061

>From a2c6ba0fe4c681f73f06337b270f7bcf8acc512b Mon Sep 17 00:00:00 2001
From: Rose <83477269+ataridre...@users.noreply.github.com>
Date: Sat, 13 Jan 2024 14:09:17 -0500
Subject: [PATCH] [Libc] Give more functions restrict qualifiers

strsep has restrict qualifiers, as well as strtok_r.
Add the restrict qualifiers to them.

Source: https://man7.org/linux/man-pages/man3/strsep.3.html
---
 clang/lib/Headers/llvm_libc_wrappers/string.h |  4 +-
 ...ystem-header-simulator-for-simple-stream.h |  4 +-
 .../Analysis/Inputs/system-header-simulator.h |  6 +--
 clang/test/Analysis/bsd-string.c  |  4 +-
 clang/test/Analysis/string.c  |  4 +-
 libc/spec/bsd_ext.td  |  4 +-
 libc/src/string/strsep.cpp|  3 +-
 libc/src/string/strsep.h  |  2 +-
 llvm/lib/Support/regex_impl.h |  3 +-
 llvm/lib/Support/regstrlcpy.c | 41 +--
 10 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/clang/lib/Headers/llvm_libc_wrappers/string.h 
b/clang/lib/Headers/llvm_libc_wrappers/string.h
index b4fbf17c7e421f..0ea49cb137606c 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/string.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -51,13 +51,13 @@ char *strcpy(char *__restrict, const char *__restrict) 
__LIBC_ATTRS;
 size_t strcspn(const char *, const char *) __LIBC_ATTRS;
 char *strdup(const char *) __LIBC_ATTRS;
 size_t strlen(const char *) __LIBC_ATTRS;
-char *strncat(char *, const char *, size_t) __LIBC_ATTRS;
+char *strncat(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
 int strncmp(const char *, const char *, size_t) __LIBC_ATTRS;
 char *strncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
 char *strndup(const char *, size_t) __LIBC_ATTRS;
 size_t strnlen(const char *, size_t) __LIBC_ATTRS;
 size_t strspn(const char *, const char *) __LIBC_ATTRS;
-char *strtok(char *__restrict, const char *) __LIBC_ATTRS;
+char *strtok(char *__restrict, const char *__restrict) __LIBC_ATTRS;
 char *strtok_r(char *__restrict, const char *__restrict,
char **__restrict) __LIBC_ATTRS;
 size_t strxfrm(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
diff --git 
a/clang/test/Analysis/Inputs/system-header-simulator-for-simple-stream.h 
b/clang/test/Analysis/Inputs/system-header-simulator-for-simple-stream.h
index b65b7a6b0e7b02..098a2208fecbe9 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator-for-simple-stream.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator-for-simple-stream.h
@@ -8,9 +8,9 @@
 typedef struct __sFILE {
   unsigned char *_p;
 } FILE;
-FILE *fopen(const char * restrict, const char * restrict) __asm("_" "fopen" );
+FILE *fopen(const char *restrict, const char *restrict) __asm("_" "fopen" );
 int fputc(int, FILE *);
-int fputs(const char * restrict, FILE * restrict) __asm("_" "fputs" );
+int fputs(const char *restrict, FILE *restrict) __asm("_" "fputs" );
 int fclose(FILE *);
 void exit(int);
 
diff --git a/clang/test/Analysis/Inputs/system-header-simulator.h 
b/clang/test/Analysis/Inputs/system-header-simulator.h
index cd7ac616bcc67f..f8e3e546a7aed5 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator.h
@@ -71,9 +71,9 @@ int fflush(FILE *stream);
 size_t strlen(const char *);
 
 char *strcpy(char *restrict, const char *restrict);
-char *strncpy(char *dst, const char *src, size_t n);
-char *strsep(char **stringp, const char *delim);
-void *memcpy(void *dst, const void *src, size_t n);
+char *strncpy(char *restrict dst, const char *restrict src, size_t n);
+char *strsep(char **restrict stringp, const char *restrict delim);
+void *memcpy(void *restrict dst, const void *restrict src, size_t n);
 void *memset(void *s, int c, size_t n);
 
 typedef unsigned long __darwin_pthread_key_t;
diff --git a/clang/test/Analysis/bsd-string.c b/clang/test/Analysis/bsd-string.c
index 1c7b28198dff26..ad5fee7da914bd 100644
--- a/clang/test/Analysis/bsd-string.c
+++ b/clang/test/Analysis/bsd-string.c
@@ -7,8 +7,8 @@
 #define NULL ((void *)0)
 
 typedef __typeof(sizeof(int)) size_t;
-size_t strlcpy(char *dst, const char *src, size_t n);
-size_t strlcat(char *dst, const char *src, size_t n);
+size_t strlcpy(char * restrict dst, const char * restrict src, size_t n);
+size_t strlcat(char *restrict dst, const char *restrict src, size_t n);
 size_t strlen(const char *s);
 void clang_analyzer_eval(int);
 
diff --git a/clang/test/Analysis/string.c b/clang/test/Analysis/string.c
index d47de9db8228e5..85232624160c06 100644
--- a/clang/test/Analysis/string.c
+++ b/clang/test/Analysis/string.c
@@ -71,7 +71,7 @@ void clang_analyzer_eval(int);
 int scanf(const char *restrict format, ...);
 void *malloc(size_t);
 void free(void *);
-void *memcpy(void *dest, const void *src, size_t 

[llvm] [libc] [clang] [Libc] Give more functions restrict qualifiers (PR #78061)

2024-01-14 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/78061

>From c76bc8254724e313191d402ec2f8b65a09daaeb3 Mon Sep 17 00:00:00 2001
From: Rose <83477269+ataridre...@users.noreply.github.com>
Date: Sat, 13 Jan 2024 14:09:17 -0500
Subject: [PATCH] [Libc] Give more functions restrict qualifiers

strsep has restrict qualifiers, as well as strtok_r.
Add the restrict qualifiers to them.

Source: https://man7.org/linux/man-pages/man3/strsep.3.html
---
 clang/lib/Headers/llvm_libc_wrappers/string.h |  4 +-
 .../Analysis/Inputs/system-header-simulator.h |  6 +--
 clang/test/Analysis/bsd-string.c  |  4 +-
 clang/test/Analysis/cstring-syntax-weird.c|  2 +-
 clang/test/Analysis/cstring-syntax-weird2.c   |  2 +-
 clang/test/Analysis/cstring-syntax.c  |  6 +--
 clang/test/Analysis/string.c  |  4 +-
 libc/spec/bsd_ext.td  |  4 +-
 libc/src/string/strsep.cpp|  3 +-
 libc/src/string/strsep.h  |  2 +-
 llvm/lib/Support/regex_impl.h |  3 +-
 llvm/lib/Support/regstrlcpy.c | 41 +--
 12 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/clang/lib/Headers/llvm_libc_wrappers/string.h 
b/clang/lib/Headers/llvm_libc_wrappers/string.h
index b4fbf17c7e421f..0ea49cb137606c 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/string.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -51,13 +51,13 @@ char *strcpy(char *__restrict, const char *__restrict) 
__LIBC_ATTRS;
 size_t strcspn(const char *, const char *) __LIBC_ATTRS;
 char *strdup(const char *) __LIBC_ATTRS;
 size_t strlen(const char *) __LIBC_ATTRS;
-char *strncat(char *, const char *, size_t) __LIBC_ATTRS;
+char *strncat(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
 int strncmp(const char *, const char *, size_t) __LIBC_ATTRS;
 char *strncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
 char *strndup(const char *, size_t) __LIBC_ATTRS;
 size_t strnlen(const char *, size_t) __LIBC_ATTRS;
 size_t strspn(const char *, const char *) __LIBC_ATTRS;
-char *strtok(char *__restrict, const char *) __LIBC_ATTRS;
+char *strtok(char *__restrict, const char *__restrict) __LIBC_ATTRS;
 char *strtok_r(char *__restrict, const char *__restrict,
char **__restrict) __LIBC_ATTRS;
 size_t strxfrm(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
diff --git a/clang/test/Analysis/Inputs/system-header-simulator.h 
b/clang/test/Analysis/Inputs/system-header-simulator.h
index cd7ac616bcc67f..5f969adfdd92cd 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator.h
@@ -71,9 +71,9 @@ int fflush(FILE *stream);
 size_t strlen(const char *);
 
 char *strcpy(char *restrict, const char *restrict);
-char *strncpy(char *dst, const char *src, size_t n);
-char *strsep(char **stringp, const char *delim);
-void *memcpy(void *dst, const void *src, size_t n);
+char *strncpy(char *restrict dst, const char * restrict src, size_t n);
+char *strsep(char ** restrict stringp, const char * restrict delim);
+void *memcpy(void * restrict dst, const void * restrict src, size_t n);
 void *memset(void *s, int c, size_t n);
 
 typedef unsigned long __darwin_pthread_key_t;
diff --git a/clang/test/Analysis/bsd-string.c b/clang/test/Analysis/bsd-string.c
index 1c7b28198dff26..ad5fee7da914bd 100644
--- a/clang/test/Analysis/bsd-string.c
+++ b/clang/test/Analysis/bsd-string.c
@@ -7,8 +7,8 @@
 #define NULL ((void *)0)
 
 typedef __typeof(sizeof(int)) size_t;
-size_t strlcpy(char *dst, const char *src, size_t n);
-size_t strlcat(char *dst, const char *src, size_t n);
+size_t strlcpy(char * restrict dst, const char * restrict src, size_t n);
+size_t strlcat(char *restrict dst, const char *restrict src, size_t n);
 size_t strlen(const char *s);
 void clang_analyzer_eval(int);
 
diff --git a/clang/test/Analysis/cstring-syntax-weird.c 
b/clang/test/Analysis/cstring-syntax-weird.c
index 9a58f1609f7ae0..d736a08842fc5b 100644
--- a/clang/test/Analysis/cstring-syntax-weird.c
+++ b/clang/test/Analysis/cstring-syntax-weird.c
@@ -6,7 +6,7 @@
 typedef __SIZE_TYPE__ size_t;
 // The last parameter is normally size_t but the test is about the abnormal
 // situation when it's not a size_t.
-size_t strlcpy(char *, const char *, int);
+size_t strlcpy(char * restrict, const char *restrict, int);
 
 enum WeirdDecl {
   AStrangeWayToSpecifyStringLengthCorrectly = 10UL,
diff --git a/clang/test/Analysis/cstring-syntax-weird2.c 
b/clang/test/Analysis/cstring-syntax-weird2.c
index 0250d69d994ef5..3fe0d63f76130c 100644
--- a/clang/test/Analysis/cstring-syntax-weird2.c
+++ b/clang/test/Analysis/cstring-syntax-weird2.c
@@ -6,7 +6,7 @@
 typedef __SIZE_TYPE__ size_t;
 // The last parameter is normally size_t but the test is about the abnormal
 // situation when it's not a size_t.
-size_t strlcpy(char *, const char *, void (*)(void));

[llvm] [clang] [llvm][frontend][offloading] Move clang-linker-wrapper/OffloadWrapper.* to llvm/Frontend/Offloading (PR #78057)

2024-01-14 Thread Joseph Huber via cfe-commits


@@ -568,32 +590,45 @@ void createRegisterFatbinFunction(Module , 
GlobalVariable *FatbinDesc,
 
 } // namespace
 
-Error wrapOpenMPBinaries(Module , ArrayRef> Images) {
-  GlobalVariable *Desc = createBinDesc(M, Images);
+Error OffloadWrapper::wrapOpenMPBinaries(
+Module , ArrayRef> Images,
+std::optional EntryArray) const {
+  GlobalVariable *Desc = createBinDesc(
+  M, Images,
+  EntryArray
+  ? *EntryArray
+  : offloading::getOffloadEntryArray(M, "omp_offloading_entries"),

jhuber6 wrote:

Think it should be fine to just call this with 
`offloading::getOffloadEntryArray(M, "xxx_offloading_entries")` at the 
callsite. `std::optional` makes it a little weird here.

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


[llvm] [libc] [clang] [Libc] Give more functions restrict qualifiers (PR #78061)

2024-01-14 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/78061

>From f69879bb309609d33f75bb7ac525abeb2141aa1f Mon Sep 17 00:00:00 2001
From: Rose <83477269+ataridre...@users.noreply.github.com>
Date: Sat, 13 Jan 2024 14:09:17 -0500
Subject: [PATCH] [Libc] Give more functions restrict qualifiers

strsep has restrict qualifiers, as well as strtok_r.
Add the restrict qualifiers to them.

Source: https://man7.org/linux/man-pages/man3/strsep.3.html
---
 clang/lib/Headers/llvm_libc_wrappers/string.h| 4 ++--
 clang/test/Analysis/Inputs/system-header-simulator.h | 6 +++---
 clang/test/Analysis/bsd-string.c | 4 ++--
 clang/test/Analysis/cstring-syntax-weird.c   | 2 +-
 clang/test/Analysis/cstring-syntax-weird2.c  | 2 +-
 clang/test/Analysis/cstring-syntax.c | 6 +++---
 clang/test/Analysis/string.c | 4 ++--
 libc/spec/bsd_ext.td | 4 ++--
 libc/src/string/strsep.cpp   | 3 ++-
 libc/src/string/strsep.h | 2 +-
 llvm/lib/Support/regex_impl.h| 2 +-
 llvm/lib/Support/regstrlcpy.c| 2 +-
 12 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/clang/lib/Headers/llvm_libc_wrappers/string.h 
b/clang/lib/Headers/llvm_libc_wrappers/string.h
index b4fbf17c7e421f..0ea49cb137606c 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/string.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -51,13 +51,13 @@ char *strcpy(char *__restrict, const char *__restrict) 
__LIBC_ATTRS;
 size_t strcspn(const char *, const char *) __LIBC_ATTRS;
 char *strdup(const char *) __LIBC_ATTRS;
 size_t strlen(const char *) __LIBC_ATTRS;
-char *strncat(char *, const char *, size_t) __LIBC_ATTRS;
+char *strncat(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
 int strncmp(const char *, const char *, size_t) __LIBC_ATTRS;
 char *strncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
 char *strndup(const char *, size_t) __LIBC_ATTRS;
 size_t strnlen(const char *, size_t) __LIBC_ATTRS;
 size_t strspn(const char *, const char *) __LIBC_ATTRS;
-char *strtok(char *__restrict, const char *) __LIBC_ATTRS;
+char *strtok(char *__restrict, const char *__restrict) __LIBC_ATTRS;
 char *strtok_r(char *__restrict, const char *__restrict,
char **__restrict) __LIBC_ATTRS;
 size_t strxfrm(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
diff --git a/clang/test/Analysis/Inputs/system-header-simulator.h 
b/clang/test/Analysis/Inputs/system-header-simulator.h
index cd7ac616bcc67f..5f969adfdd92cd 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator.h
@@ -71,9 +71,9 @@ int fflush(FILE *stream);
 size_t strlen(const char *);
 
 char *strcpy(char *restrict, const char *restrict);
-char *strncpy(char *dst, const char *src, size_t n);
-char *strsep(char **stringp, const char *delim);
-void *memcpy(void *dst, const void *src, size_t n);
+char *strncpy(char *restrict dst, const char * restrict src, size_t n);
+char *strsep(char ** restrict stringp, const char * restrict delim);
+void *memcpy(void * restrict dst, const void * restrict src, size_t n);
 void *memset(void *s, int c, size_t n);
 
 typedef unsigned long __darwin_pthread_key_t;
diff --git a/clang/test/Analysis/bsd-string.c b/clang/test/Analysis/bsd-string.c
index 1c7b28198dff26..ad5fee7da914bd 100644
--- a/clang/test/Analysis/bsd-string.c
+++ b/clang/test/Analysis/bsd-string.c
@@ -7,8 +7,8 @@
 #define NULL ((void *)0)
 
 typedef __typeof(sizeof(int)) size_t;
-size_t strlcpy(char *dst, const char *src, size_t n);
-size_t strlcat(char *dst, const char *src, size_t n);
+size_t strlcpy(char * restrict dst, const char * restrict src, size_t n);
+size_t strlcat(char *restrict dst, const char *restrict src, size_t n);
 size_t strlen(const char *s);
 void clang_analyzer_eval(int);
 
diff --git a/clang/test/Analysis/cstring-syntax-weird.c 
b/clang/test/Analysis/cstring-syntax-weird.c
index 9a58f1609f7ae0..d736a08842fc5b 100644
--- a/clang/test/Analysis/cstring-syntax-weird.c
+++ b/clang/test/Analysis/cstring-syntax-weird.c
@@ -6,7 +6,7 @@
 typedef __SIZE_TYPE__ size_t;
 // The last parameter is normally size_t but the test is about the abnormal
 // situation when it's not a size_t.
-size_t strlcpy(char *, const char *, int);
+size_t strlcpy(char * restrict, const char *restrict, int);
 
 enum WeirdDecl {
   AStrangeWayToSpecifyStringLengthCorrectly = 10UL,
diff --git a/clang/test/Analysis/cstring-syntax-weird2.c 
b/clang/test/Analysis/cstring-syntax-weird2.c
index 0250d69d994ef5..3fe0d63f76130c 100644
--- a/clang/test/Analysis/cstring-syntax-weird2.c
+++ b/clang/test/Analysis/cstring-syntax-weird2.c
@@ -6,7 +6,7 @@
 typedef __SIZE_TYPE__ size_t;
 // The last parameter is normally size_t but the test is about the abnormal
 // situation when it's not a 

[clang] [clang-bindings] Add strict typing to clang Python bindings (#76664) (PR #78114)

2024-01-14 Thread Jannick Kremer via cfe-commits

DeinAlptraum wrote:

@AaronBallman could you review this or recommend reviewers? I didn't see any 
category in `clang/CodeOwners.rst` that seems to cover the bindings.

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


  1   2   3   >