[clang] [clang][ASTImporter] add processing of SubstNonTypeTemplateParmExpr in isAncestorDeclContextOf (PR #74991)

2023-12-19 Thread Balázs Kéri via cfe-commits

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


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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2023-12-19 Thread Chuanqi Xu via cfe-commits


@@ -0,0 +1,50 @@
+// REQUIRES: !system-windows
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \
+// RUN: -emit-module-interface -o %t/foo-layer1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple  \
+// RUN: -emit-module-interface -fmodule-file=foo:layer1=%t/foo-layer1.pcm \
+// RUN: -o %t/foo-layer2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer1.pcm -S -emit-llvm -o - | FileCheck 
%t/layer1.cppm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer2.pcm -S -emit-llvm -o - \
+// RUN: -fmodule-file=foo:layer1=%t/foo-layer1.pcm | FileCheck 
%t/layer2.cppm
+
+//--- layer1.cppm
+export module foo:layer1;
+struct Fruit {
+virtual ~Fruit() = default;
+virtual void eval() = 0;
+};
+struct Banana : public Fruit {
+Banana() {}
+void eval() override;
+};
+
+// CHECK-DAG: @_ZTVW3foo6Banana = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo6Banana = constant
+// CHECK-DAG: @_ZTIW3foo6Banana = constant
+//
+// CHECK-DAG: @_ZTVW3foo5Fruit = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo5Fruit = constant
+// CHECK-DAG: @_ZTIW3foo5Fruit = constant
+
+//--- layer2.cppm
+export module foo:layer2;
+import :layer1;
+export void layer2_fun() {
+Banana *b = new Banana();
+b->eval();
+}
+void Banana::eval() {
+}
+

ChuanqiXu9 wrote:

Done

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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2023-12-19 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/75912

>From 908a0287e092ce7ac1865de32370ec3114b104ad Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Tue, 19 Dec 2023 17:00:59 +0800
Subject: [PATCH] [C++20] [Modules] [Itanium ABI] Generate the vtable in the
 module unit of dynamic classes

Close https://github.com/llvm/llvm-project/issues/70585 and reflect
https://github.com/itanium-cxx-abi/cxx-abi/issues/170.

The significant change of the patch is: for dynamic classes attached to
module units, we generate the vtable to the attached module units
directly and the key functions for such classes is meaningless.
---
 clang/lib/CodeGen/CGVTables.cpp   | 32 +++---
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  6 +++
 clang/test/CodeGenCXX/modules-vtable.cppm | 27 +++-
 clang/test/CodeGenCXX/pr70585.cppm| 54 +++
 4 files changed, 102 insertions(+), 17 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/pr70585.cppm

diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 27a2cab4f75319..8324c38ff94feb 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -1046,6 +1046,15 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) 
{
   if (!RD->isExternallyVisible())
 return llvm::GlobalVariable::InternalLinkage;
 
+  // Previously we'll decide the linkage of the vtable by the linkage
+  // of the key function. But within modules, the concept of key functions
+  // becomes meaningless. So the linkage of the vtable should always be
+  // external if the class is externally visible.
+  //
+  // TODO: How about the case of AppleKext, DLLExportAttr and DLLImportAttr.
+  if (Module *M = RD->getOwningModule(); M && M->isNamedModule())
+return llvm::GlobalVariable::ExternalLinkage;
+
   // We're at the end of the translation unit, so the current key
   // function is fully correct.
   const CXXMethodDecl *keyFunction = Context.getCurrentKeyFunction(RD);
@@ -1180,6 +1189,21 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
   TSK == TSK_ExplicitInstantiationDefinition)
 return false;
 
+  // Itanium C++ ABI [5.2.3]:
+  // Virtual tables for dynamic classes are emitted as follows:
+  //
+  // - If the class is templated, the tables are emitted in every object that
+  // references any of them.
+  // - Otherwise, if the class is attached to a module, the tables are uniquely
+  // emitted in the object for the module unit in which it is defined.
+  // - Otherwise, if the class has a key function (see below), the tables are
+  // emitted in the object for the translation unit containing the definition 
of
+  // the key function. This is unique if the key function is not inline.
+  // - Otherwise, the tables are emitted in every object that references any of
+  // them.
+  if (Module *M = RD->getOwningModule(); M && M->isNamedModule())
+return M != CGM.getContext().getCurrentNamedModule();
+
   // Otherwise, if the class doesn't have a key function (possibly
   // anymore), the vtable must be defined here.
   const CXXMethodDecl *keyFunction = 
CGM.getContext().getCurrentKeyFunction(RD);
@@ -1189,13 +1213,7 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
   const FunctionDecl *Def;
   // Otherwise, if we don't have a definition of the key function, the
   // vtable must be defined somewhere else.
-  if (!keyFunction->hasBody(Def))
-return true;
-
-  assert(Def && "The body of the key function is not assigned to Def?");
-  // If the non-inline key function comes from another module unit, the vtable
-  // must be defined there.
-  return Def->isInAnotherModuleUnit() && !Def->isInlineSpecified();
+  return !keyFunction->hasBody(Def);
 }
 
 /// Given that we're currently at the end of the translation unit, and
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index d173806ec8ce53..e80270c231e19f 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1801,6 +1801,12 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables 
,
   if (VTable->hasInitializer())
 return;
 
+  // If the class are attached to a C++ named module other than the one
+  // we're currently compiling, the vtable should be defined there.
+  if (Module *M = RD->getOwningModule();
+  M && M->isNamedModule() && M != CGM.getContext().getCurrentNamedModule())
+return;
+
   ItaniumVTableContext  = CGM.getItaniumVTableContext();
   const VTableLayout  = VTContext.getVTableLayout(RD);
   llvm::GlobalVariable::LinkageTypes Linkage = CGM.getVTableLinkage(RD);
diff --git a/clang/test/CodeGenCXX/modules-vtable.cppm 
b/clang/test/CodeGenCXX/modules-vtable.cppm
index fb179b1de4880b..abbbc403ace243 100644
--- a/clang/test/CodeGenCXX/modules-vtable.cppm
+++ b/clang/test/CodeGenCXX/modules-vtable.cppm
@@ -24,6 +24,8 @@
 // RUN: %t/M-A.cppm -o %t/M-A.pcm
 // RUN: 

[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vladimir Vereschaka via cfe-commits

vvereschaka wrote:

not a problem, I'll land this patch,

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

If all good, would you mind landing it? I need to disappear for couple of 
hours. 

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vladimir Vereschaka via cfe-commits

vvereschaka wrote:

I would like to do a full rebuild just in case. I'll let you know about the 
results.


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


[clang] [clang-format] Add an fnmatch-like function for .clang-format-ignore (PR #76021)

2023-12-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

This is needed because Windows doesn't have anything equivalent to the POSIX 
fnmatch() function.

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


5 Files Affected:

- (modified) clang/lib/Format/CMakeLists.txt (+1) 
- (added) clang/lib/Format/MatchFilePath.cpp (+112) 
- (added) clang/lib/Format/MatchFilePath.h (+22) 
- (modified) clang/unittests/Format/CMakeLists.txt (+1) 
- (added) clang/unittests/Format/MatchFilePathTest.cpp (+156) 


``diff
diff --git a/clang/lib/Format/CMakeLists.txt b/clang/lib/Format/CMakeLists.txt
index 015ec7c0cc84e3..84a3c136f650a8 100644
--- a/clang/lib/Format/CMakeLists.txt
+++ b/clang/lib/Format/CMakeLists.txt
@@ -11,6 +11,7 @@ add_clang_library(clangFormat
   IntegerLiteralSeparatorFixer.cpp
   MacroCallReconstructor.cpp
   MacroExpander.cpp
+  MatchFilePath.cpp
   NamespaceEndCommentsFixer.cpp
   ObjCPropertyAttributeOrderFixer.cpp
   QualifierAlignmentFixer.cpp
diff --git a/clang/lib/Format/MatchFilePath.cpp 
b/clang/lib/Format/MatchFilePath.cpp
new file mode 100644
index 00..203a900e3d3bdd
--- /dev/null
+++ b/clang/lib/Format/MatchFilePath.cpp
@@ -0,0 +1,112 @@
+//===--- MatchFilePath.cpp - Match file path with pattern ---*- 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
+//
+//===--===//
+///
+/// \file
+/// This file implements the functionality of matching a file path name to
+/// a pattern, similar to the POSIX fnmatch() function.
+///
+//===--===//
+
+#include "MatchFilePath.h"
+
+using namespace llvm;
+
+namespace clang {
+namespace format {
+
+// Check whether `FilePath` matches `Pattern` based on POSIX Section 2.13.
+bool matchFilePath(StringRef Pattern, StringRef FilePath) {
+  assert(!Pattern.empty());
+  assert(!FilePath.empty());
+
+  constexpr auto Separator = '/';
+  const auto EOP = Pattern.size();  // End of `Pattern`.
+  const auto End = FilePath.size(); // End of `FilePath`.
+  unsigned I = 0;   // Index to `Pattern`.
+
+  // No match if `Pattern` ends with a non-meta character not equal to the last
+  // character of `FilePath`.
+  if (const auto C = Pattern.back(); !strchr("?*]", C) && C != FilePath.back())
+return false;
+
+  for (const auto  : FilePath) {
+if (I == EOP)
+  return false;
+
+switch (Pattern[I]) {
+case '\\':
+  if (++I == EOP || F != Pattern[I])
+return false;
+  ++I;
+  break;
+case '?':
+  if (F == Separator)
+return false;
+  ++I;
+  break;
+case '*': {
+  unsigned J =  - FilePath.data(); // Index of `F`.
+  // Skip consecutive stars.
+  do {
+if (++I == EOP)
+  return FilePath.find(Separator, J + 1) == StringRef::npos;
+  } while (Pattern[I] == '*');
+  while (FilePath[J] != Separator) {
+if (matchFilePath(Pattern.substr(I), FilePath.substr(J)))
+  return true;
+if (++J == End)
+  return false;
+  }
+  break;
+}
+case '[':
+  // Skip e.g. `[!]`.
+  if (I + 3 < EOP || (I + 3 == EOP && Pattern[I + 1] != '!')) {
+// Skip unpaired `[`, brackets containing slashes, and `[]`.
+if (const auto J = Pattern.find_first_of("]/", I + 1);
+J != StringRef::npos && Pattern[J] == ']' && J > I + 1) {
+  if (F == Separator)
+return false;
+  ++I; // After the `[`.
+  bool Negated = false;
+  if (Pattern[I] == '!') {
+Negated = true;
+++I; // After the `!`.
+  }
+  bool Match = false;
+  do {
+if (I + 2 < J && Pattern[I + 1] == '-') {
+  Match = Pattern[I] <= F && F <= Pattern[I + 2];
+  I += 3; // After the range, e.g. `A-Z`.
+} else {
+  Match = F == Pattern[I++];
+}
+  } while (!Match && I < J);
+  if (Negated ? Match : !Match)
+return false;
+  I = J + 1; // After the `]`.
+  break;
+}
+  }
+  [[fallthrough]]; // Match `[` literally.
+default:
+  if (F != Pattern[I])
+return false;
+  ++I;
+}
+  }
+
+  // Match trailing stars with null strings.
+  while (I < EOP && Pattern[I] == '*')
+++I;
+
+  return I == EOP;
+}
+
+} // namespace format
+} // namespace clang
diff --git a/clang/lib/Format/MatchFilePath.h b/clang/lib/Format/MatchFilePath.h
new file mode 100644
index 00..482dab7c748e51
--- /dev/null
+++ b/clang/lib/Format/MatchFilePath.h
@@ -0,0 +1,22 @@
+//===--- MatchFilePath.h *- C++ 
-*-===//
+//
+// Part 

[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vladimir Vereschaka via cfe-commits

vvereschaka wrote:

@vgvassilev thank you. This patch looks promising, the tests have been passed 
successfully with it

```
-- Testing: 21 of 19608 tests, 21 workers --
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/8/21 (1 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/3/21 (2 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/5/21 (3 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/1/21 (4 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/7/21 (5 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/4/21 (6 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/0/21 (7 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/6/21 (8 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/12/21 (9 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/2/21 (10 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/9/21 (11 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/11/21 (12 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/10/21 (13 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/17/21 (14 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/18/21 (15 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/16/21 (16 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/15/21 (17 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/19/21 (18 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/20/21 (19 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/14/21 (20 of 21)
PASS: Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/13/21 (21 of 21)
```

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


[clang] [clang-format] Add an fnmatch-like function for .clang-format-ignore (PR #76021)

2023-12-19 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/76021

This is needed because Windows doesn't have anything equivalent to the POSIX 
fnmatch() function.

>From b53c8b6c6d34857168d868d99c8d7ea7a69621eb Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 19 Dec 2023 23:25:57 -0800
Subject: [PATCH] [clang-format] Add an fnmatch-like function for
 .clang-format-ignore

This is needed because Windows doesn't have anything equivalent to the POSIX
fnmatch() function.
---
 clang/lib/Format/CMakeLists.txt  |   1 +
 clang/lib/Format/MatchFilePath.cpp   | 112 +
 clang/lib/Format/MatchFilePath.h |  22 +++
 clang/unittests/Format/CMakeLists.txt|   1 +
 clang/unittests/Format/MatchFilePathTest.cpp | 156 +++
 5 files changed, 292 insertions(+)
 create mode 100644 clang/lib/Format/MatchFilePath.cpp
 create mode 100644 clang/lib/Format/MatchFilePath.h
 create mode 100644 clang/unittests/Format/MatchFilePathTest.cpp

diff --git a/clang/lib/Format/CMakeLists.txt b/clang/lib/Format/CMakeLists.txt
index 015ec7c0cc84e3..84a3c136f650a8 100644
--- a/clang/lib/Format/CMakeLists.txt
+++ b/clang/lib/Format/CMakeLists.txt
@@ -11,6 +11,7 @@ add_clang_library(clangFormat
   IntegerLiteralSeparatorFixer.cpp
   MacroCallReconstructor.cpp
   MacroExpander.cpp
+  MatchFilePath.cpp
   NamespaceEndCommentsFixer.cpp
   ObjCPropertyAttributeOrderFixer.cpp
   QualifierAlignmentFixer.cpp
diff --git a/clang/lib/Format/MatchFilePath.cpp 
b/clang/lib/Format/MatchFilePath.cpp
new file mode 100644
index 00..203a900e3d3bdd
--- /dev/null
+++ b/clang/lib/Format/MatchFilePath.cpp
@@ -0,0 +1,112 @@
+//===--- MatchFilePath.cpp - Match file path with pattern ---*- 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
+//
+//===--===//
+///
+/// \file
+/// This file implements the functionality of matching a file path name to
+/// a pattern, similar to the POSIX fnmatch() function.
+///
+//===--===//
+
+#include "MatchFilePath.h"
+
+using namespace llvm;
+
+namespace clang {
+namespace format {
+
+// Check whether `FilePath` matches `Pattern` based on POSIX Section 2.13.
+bool matchFilePath(StringRef Pattern, StringRef FilePath) {
+  assert(!Pattern.empty());
+  assert(!FilePath.empty());
+
+  constexpr auto Separator = '/';
+  const auto EOP = Pattern.size();  // End of `Pattern`.
+  const auto End = FilePath.size(); // End of `FilePath`.
+  unsigned I = 0;   // Index to `Pattern`.
+
+  // No match if `Pattern` ends with a non-meta character not equal to the last
+  // character of `FilePath`.
+  if (const auto C = Pattern.back(); !strchr("?*]", C) && C != FilePath.back())
+return false;
+
+  for (const auto  : FilePath) {
+if (I == EOP)
+  return false;
+
+switch (Pattern[I]) {
+case '\\':
+  if (++I == EOP || F != Pattern[I])
+return false;
+  ++I;
+  break;
+case '?':
+  if (F == Separator)
+return false;
+  ++I;
+  break;
+case '*': {
+  unsigned J =  - FilePath.data(); // Index of `F`.
+  // Skip consecutive stars.
+  do {
+if (++I == EOP)
+  return FilePath.find(Separator, J + 1) == StringRef::npos;
+  } while (Pattern[I] == '*');
+  while (FilePath[J] != Separator) {
+if (matchFilePath(Pattern.substr(I), FilePath.substr(J)))
+  return true;
+if (++J == End)
+  return false;
+  }
+  break;
+}
+case '[':
+  // Skip e.g. `[!]`.
+  if (I + 3 < EOP || (I + 3 == EOP && Pattern[I + 1] != '!')) {
+// Skip unpaired `[`, brackets containing slashes, and `[]`.
+if (const auto J = Pattern.find_first_of("]/", I + 1);
+J != StringRef::npos && Pattern[J] == ']' && J > I + 1) {
+  if (F == Separator)
+return false;
+  ++I; // After the `[`.
+  bool Negated = false;
+  if (Pattern[I] == '!') {
+Negated = true;
+++I; // After the `!`.
+  }
+  bool Match = false;
+  do {
+if (I + 2 < J && Pattern[I + 1] == '-') {
+  Match = Pattern[I] <= F && F <= Pattern[I + 2];
+  I += 3; // After the range, e.g. `A-Z`.
+} else {
+  Match = F == Pattern[I++];
+}
+  } while (!Match && I < J);
+  if (Negated ? Match : !Match)
+return false;
+  I = J + 1; // After the `]`.
+  break;
+}
+  }
+  [[fallthrough]]; // Match `[` literally.
+default:
+  if (F != Pattern[I])
+return false;
+  ++I;
+}
+  }
+
+  // Match trailing stars with 

[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread via cfe-commits

https://github.com/hstk30-hw updated 
https://github.com/llvm/llvm-project/pull/76007

>From 2991e9b990702b22f67b1d7a146605b1388cec87 Mon Sep 17 00:00:00 2001
From: hstk30-hw 
Date: Wed, 20 Dec 2023 12:26:15 +0800
Subject: [PATCH] [Clang][Sema] Fix Wswitch-default bad warning in template

[#73077] added Wswitch-default diagnostic but it produced false
positives in templates. This PR address it.
---
 clang/lib/Sema/SemaStmt.cpp|  4 +--
 clang/test/Sema/switch-default.c   | 28 
 clang/test/Sema/switch-default.cpp | 53 ++
 3 files changed, 54 insertions(+), 31 deletions(-)
 delete mode 100644 clang/test/Sema/switch-default.c
 create mode 100644 clang/test/Sema/switch-default.cpp

diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 63348d27a8c94a..adc2055ec4e659 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,9 +1327,6 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
-  if (!TheDefaultStmt)
-Diag(SwitchLoc, diag::warn_switch_default);
-
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
@@ -1344,6 +1341,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
   assert(!HasConstantCond ||
  (ConstantCondValue.getBitWidth() == CondWidth &&
   ConstantCondValue.isSigned() == CondIsSigned));
+  Diag(SwitchLoc, diag::warn_switch_default);
 }
 bool ShouldCheckConstantCond = HasConstantCond;
 
diff --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
deleted file mode 100644
index 342a97ee68b1e2..00
--- a/clang/test/Sema/switch-default.c
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
-
-int f1(int a) {
-  switch (a) {// expected-warning {{'switch' missing 'default' 
label}}
-case 1: a++; break;
-case 2: a += 2; break;
-  }
-  return a;
-}
-
-int f2(int a) {
-  switch (a) {// no-warning
-default:
-  ;
-  }
-  return a;
-}
-
-// Warn even completely covered Enum cases(GCC compatibility).
-enum E { A, B };
-enum E check_enum(enum E e) {
-  switch (e) {// expected-warning {{'switch' missing 'default' 
label}}
-case A: break;
-case B: break;
-  }
-  return e;
-}
-
diff --git a/clang/test/Sema/switch-default.cpp 
b/clang/test/Sema/switch-default.cpp
new file mode 100644
index 00..32d03dae882733
--- /dev/null
+++ b/clang/test/Sema/switch-default.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wswitch-default %s
+
+int f1(int a) {
+  switch (a) {// expected-warning {{'switch' missing 'default' 
label}}
+case 1: a++; break;
+case 2: a += 2; break;
+  }
+  return a;
+}
+
+int f2(int a) {
+  switch (a) {// no-warning
+default:
+  ;
+  }
+  return a;
+}
+
+// Warn even completely covered Enum cases(GCC compatibility).
+enum E { A, B };
+enum E check_enum(enum E e) {
+  switch (e) {// expected-warning {{'switch' missing 'default' 
label}}
+case A: break;
+case B: break;
+  }
+  return e;
+}
+
+template
+int t1(Index i)
+{
+  switch (i) {  // expected-warning {{'switch' missing 'default' 
label}}
+case 0: return 0;
+case 1: return 1;
+  }
+  return 0;
+}
+
+template
+int t2(Index i)
+{
+  switch (i) {// no-warning
+case 0: return 0;
+case 1: return 1;
+default: return 2;
+  }
+  return 0;
+}
+
+int main() {
+  return t1(1);   // expected-note {{in instantiation of function template 
specialization 't1' requested here}}
+}
+

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

Can you try this one:

```diff
diff --git a/clang/unittests/Interpreter/CodeCompletionTest.cpp 
b/clang/unittests/Interpreter/CodeCompletionTest.cpp
index cd7fdfa588a5..873fbda32f05 100644
--- a/clang/unittests/Interpreter/CodeCompletionTest.cpp
+++ b/clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -50,16 +50,9 @@ static std::vector runComp(clang::Interpreter 
,
   return Comps;
 }
 
-#ifdef _AIX
-TEST(CodeCompletionTest, DISABLED_Sanity) {
-#else
 TEST(CodeCompletionTest, Sanity) {
-#endif
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int foo = 12;"));
   auto Err = llvm::Error::success();
   auto comps = runComp(*Interp, "f", Err);
   EXPECT_EQ((size_t)2, comps.size()); // float and foo
@@ -68,36 +61,19 @@ TEST(CodeCompletionTest, Sanity) {
   EXPECT_EQ((bool)Err, false);
 }
 
-#ifdef _AIX
-TEST(CodeCompletionTest, DISABLED_SanityNoneValid) {
-#else
 TEST(CodeCompletionTest, SanityNoneValid) {
-#endif
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int foo = 12;"));
   auto Err = llvm::Error::success();
   auto comps = runComp(*Interp, "babanana", Err);
   EXPECT_EQ((size_t)0, comps.size()); // foo and float
   EXPECT_EQ((bool)Err, false);
 }
 
-#ifdef _AIX
-TEST(CodeCompletionTest, DISABLED_TwoDecls) {
-#else
 TEST(CodeCompletionTest, TwoDecls) {
-#endif
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int application = 12;"));
+  cantFail(Interp->Parse("int apple = 12;"));
   auto Err = llvm::Error::success();
   auto comps = runComp(*Interp, "app", Err);
   EXPECT_EQ((size_t)2, comps.size());
@@ -113,18 +89,9 @@ TEST(CodeCompletionTest, CompFunDeclsNoError) {
 
 TEST(CodeCompletionTest, TypedDirected) {
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("char apple = '2';")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("void add(int ){}")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int application = 12;"));
+  cantFail(Interp->Parse("char apple = '2';"));
+  cantFail(Interp->Parse("void add(int ){}"));
   {
 auto Err = llvm::Error::success();
 auto comps = runComp(*Interp, std::string("add("), Err);
@@ -132,10 +99,7 @@ TEST(CodeCompletionTest, TypedDirected) {
 EXPECT_EQ((bool)Err, false);
   }
 
-  if (auto R = Interp->ParseAndExecute("int banana = 42;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int banana = 42;"));
 
   {
 auto Err = llvm::Error::success();
@@ -157,22 +121,10 @@ TEST(CodeCompletionTest, TypedDirected) {
 
 TEST(CodeCompletionTest, SanityClasses) {
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("struct Apple{};")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("void takeApple(Apple ){}")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("Apple a1;")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("void takeAppleCopy(Apple a1){}")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("struct Apple{};"));
+  cantFail(Interp->Parse("void takeApple(Apple ){}"));
+  cantFail(Interp->Parse("Apple a1;"));
+  cantFail(Interp->Parse("void takeAppleCopy(Apple a1){}"));
 
   {
 auto Err = llvm::Error::success();
@@ -192,26 +144,11 @@ TEST(CodeCompletionTest, SanityClasses) {
 
 TEST(CodeCompletionTest, SubClassing) {
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("struct Fruit {};")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("struct Apple : Fruit{};")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("void takeFruit(Fruit ){}")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("Apple a1;")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("Fruit f1;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("struct Fruit {};"));
+  cantFail(Interp->Parse("struct Apple : Fruit{};"));
+  cantFail(Interp->Parse("void takeFruit(Fruit ){}"));
+  cantFail(Interp->Parse("Apple a1;"));
+  cantFail(Interp->Parse("Fruit f1;"));
   auto Err = llvm::Error::success();
   auto 

[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

I am testing a fix/workaround. Will send a diff shortly...

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vladimir Vereschaka via cfe-commits

vvereschaka wrote:

I also didn't noticed any related changes with the triple in these commits, but 
they were the only related with the interpreter in the failed build. I just 
tried to revert them and run these tests again.

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


[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

thanks for correcting this.

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


[clang] [llvm] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp approved this pull request.

LGTM.

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vladimir Vereschaka via cfe-commits

vvereschaka wrote:

I tried to revert this commit and two next ones with the warning fixes (they 
are related) locally on the builder. The tests have passed successfully after 
reverting
These commits have been reverted
* 8c296d58c50902e367f64417948d6e2d43828f36
* 8dd77fa5ae2c20cce903501e9090c663bf97d144
* 35b366ace73d0ede3cdeeb4d09150a9945750b7f

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


[libcxx] [clang-tools-extra] [libc] [lldb] [flang] [lld] [clang] [llvm] [compiler-rt] [Legalizer] Expand fmaximum and fminimum (PR #67301)

2023-12-19 Thread Qiu Chaofan via cfe-commits

ecnelises wrote:

> Is there any existing vector test coverage?

Yes, there are vector tests in PowerPC's fminimum-fmaximum.ll.

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


[clang-tools-extra] [clang] [libcxx] [lld] [libc] [llvm] [flang] [lldb] [compiler-rt] [Legalizer] Expand fmaximum and fminimum (PR #67301)

2023-12-19 Thread Qiu Chaofan via cfe-commits


@@ -8262,6 +8262,64 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode 
*Node,
   return SDValue();
 }
 
+SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
+SelectionDAG ) const {
+  SDLoc DL(N);
+  SDValue LHS = N->getOperand(0);
+  SDValue RHS = N->getOperand(1);
+  unsigned Opc = N->getOpcode();
+  EVT VT = N->getValueType(0);
+  EVT CCVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
+  bool IsMax = Opc == ISD::FMAXIMUM;
+
+  if (VT.isVector() &&
+  isOperationLegalOrCustomOrPromote(Opc, VT.getScalarType()))
+return SDValue();
+
+  // First, implement comparison not propagating NaN. If no native fmin or fmax
+  // available, use plain select with setcc instead.
+  SDValue MinMax;
+  if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE,
+   VT)) {
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE, DL, VT,
+ LHS, RHS);
+  } else if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM : ISD::FMINNUM,
+  VT)) {
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM : ISD::FMINNUM, DL, VT, LHS, 
RHS);
+  } else {
+SDValue Compare =
+DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT);

ecnelises wrote:

Yes here it assumes no NaN exists (if either operand is NaN, it will be 
propagated in following code)

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


[clang-tools-extra] [clang] [libcxx] [lld] [libc] [llvm] [flang] [lldb] [compiler-rt] [Legalizer] Expand fmaximum and fminimum (PR #67301)

2023-12-19 Thread Qiu Chaofan via cfe-commits


@@ -8262,6 +8262,64 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode 
*Node,
   return SDValue();
 }
 
+SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
+SelectionDAG ) const {
+  SDLoc DL(N);
+  SDValue LHS = N->getOperand(0);
+  SDValue RHS = N->getOperand(1);
+  unsigned Opc = N->getOpcode();
+  EVT VT = N->getValueType(0);
+  EVT CCVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
+  bool IsMax = Opc == ISD::FMAXIMUM;
+
+  if (VT.isVector() &&
+  isOperationLegalOrCustomOrPromote(Opc, VT.getScalarType()))
+return SDValue();
+
+  // First, implement comparison not propagating NaN. If no native fmin or fmax
+  // available, use plain select with setcc instead.
+  SDValue MinMax;
+  if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE,
+   VT)) {
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE, DL, VT,
+ LHS, RHS);
+  } else if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM : ISD::FMINNUM,
+  VT)) {
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM : ISD::FMINNUM, DL, VT, LHS, 
RHS);
+  } else {
+SDValue Compare =
+DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT);
+MinMax = DAG.getSelect(DL, VT, Compare, LHS, RHS);
+  }
+
+  // Propagate any NaN of both operands
+  if (!N->getFlags().hasNoNaNs() &&
+  (!DAG.isKnownNeverNaN(LHS) || !DAG.isKnownNeverNaN(RHS))) {
+ConstantFP *FPNaN = ConstantFP::get(
+*DAG.getContext(), APFloat::getNaN(DAG.EVTToAPFloatSemantics(VT)));
+MinMax = DAG.getSelect(DL, VT, DAG.getSetCC(DL, CCVT, LHS, RHS, 
ISD::SETUO),
+   DAG.getConstantFP(*FPNaN, DL, VT), MinMax);
+  }
+
+  // fminimum/fmaximum requires -0.0 less than +0.0
+  if (!N->getFlags().hasNoSignedZeros() && !DAG.isKnownNeverZeroFloat(LHS) &&
+  !DAG.isKnownNeverZeroFloat(RHS)) {
+SDValue IsZero = DAG.getSetCC(DL, CCVT, MinMax,
+  DAG.getConstantFP(0.0, DL, VT), ISD::SETEQ);
+SDValue TestZero =
+DAG.getTargetConstant(IsMax ? fcPosZero : fcNegZero, DL, MVT::i32);
+SDValue LCmp = DAG.getSelect(
+DL, VT, DAG.getNode(ISD::IS_FPCLASS, DL, CCVT, LHS, TestZero), LHS,
+MinMax);
+SDValue RCmp = DAG.getSelect(
+DL, VT, DAG.getNode(ISD::IS_FPCLASS, DL, CCVT, RHS, TestZero), RHS,
+LCmp);
+MinMax = DAG.getSelect(DL, VT, IsZero, RCmp, MinMax);

ecnelises wrote:

We still need isfpclass to know which is negative/positive zero and whether 
both are zeros, I think.

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@vvereschaka, would reverting this PR fix the problem? The error seems 
unrelated to the code changes. IIUC it says that we fail to pass the correct 
target triple to be able to execute code...

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


[clang-tools-extra] [clang] [libcxx] [lld] [libc] [llvm] [flang] [lldb] [compiler-rt] [Legalizer] Expand fmaximum and fminimum (PR #67301)

2023-12-19 Thread Qiu Chaofan via cfe-commits

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

>From 92abb76631594dfc2ca586c46c38031610be0548 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Mon, 25 Sep 2023 17:08:59 +0800
Subject: [PATCH 1/5] [Legalizer] Expand fmaximum and fminimum

According to langref, llvm.maximum/minimum has -0.0 < +0.0 semantics and
propagates NaN.

Expand the nodes on targets not supporting the operation, by adding
extra check for NaN and using is_fpclass to check zero signs.
---
 llvm/include/llvm/CodeGen/TargetLowering.h|   3 +
 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp |   6 +
 .../SelectionDAG/LegalizeVectorOps.cpp|   7 +
 .../CodeGen/SelectionDAG/TargetLowering.cpp   |  58 ++
 llvm/lib/Target/ARM/ARMISelLowering.cpp   |  14 +-
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp   |  10 +-
 .../CodeGen/ARM/minnum-maxnum-intrinsics.ll   |  28 +-
 .../CodeGen/PowerPC/fminimum-fmaximum-f128.ll |  97 ++
 .../test/CodeGen/PowerPC/fminimum-fmaximum.ll | 847 ++
 9 files changed, 1039 insertions(+), 31 deletions(-)
 create mode 100644 llvm/test/CodeGen/PowerPC/fminimum-fmaximum-f128.ll
 create mode 100644 llvm/test/CodeGen/PowerPC/fminimum-fmaximum.ll

diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index c6a7aa17146dd4..429cfd72af2e6e 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -5089,6 +5089,9 @@ class TargetLowering : public TargetLoweringBase {
   /// Expand fminnum/fmaxnum into fminnum_ieee/fmaxnum_ieee with quieted 
inputs.
   SDValue expandFMINNUM_FMAXNUM(SDNode *N, SelectionDAG ) const;
 
+  /// Expand fminimum/fmaximum into multiple comparison with selects.
+  SDValue expandFMINIMUM_FMAXIMUM(SDNode *N, SelectionDAG ) const;
+
   /// Expand FP_TO_[US]INT_SAT into FP_TO_[US]INT and selects or min/max.
   /// \param N Node to expand
   /// \returns The expansion result
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index f19beea3a3ed8b..33f6354d558454 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3540,6 +3540,12 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
   Results.push_back(Expanded);
 break;
   }
+  case ISD::FMINIMUM:
+  case ISD::FMAXIMUM: {
+if (SDValue Expanded = TLI.expandFMINIMUM_FMAXIMUM(Node, DAG))
+  Results.push_back(Expanded);
+break;
+  }
   case ISD::FSIN:
   case ISD::FCOS: {
 EVT VT = Node->getValueType(0);
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
index dec81475f3a88f..db132035adcf29 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
@@ -949,6 +949,13 @@ void VectorLegalizer::Expand(SDNode *Node, 
SmallVectorImpl ) {
   return;
 }
 break;
+  case ISD::FMINIMUM:
+  case ISD::FMAXIMUM:
+if (SDValue Expanded = TLI.expandFMINIMUM_FMAXIMUM(Node, DAG)) {
+  Results.push_back(Expanded);
+  return;
+}
+break;
   case ISD::SMIN:
   case ISD::SMAX:
   case ISD::UMIN:
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 39489e0bf142eb..23de9829b5e9ff 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -8177,6 +8177,64 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode 
*Node,
   return SDValue();
 }
 
+SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
+SelectionDAG ) const {
+  SDLoc DL(N);
+  SDValue LHS = N->getOperand(0);
+  SDValue RHS = N->getOperand(1);
+  unsigned Opc = N->getOpcode();
+  EVT VT = N->getValueType(0);
+  EVT CCVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
+  bool NoNaN = (N->getFlags().hasNoNaNs() ||
+(DAG.isKnownNeverNaN(LHS) && DAG.isKnownNeverNaN(RHS)));
+  bool NoZeroSign =
+  (N->getFlags().hasNoSignedZeros() || DAG.isKnownNeverZeroFloat(LHS) ||
+   DAG.isKnownNeverZeroFloat(RHS));
+  bool IsMax = Opc == ISD::FMAXIMUM;
+
+  if (VT.isVector() &&
+  isOperationLegalOrCustomOrPromote(Opc, VT.getScalarType()))
+return SDValue();
+
+  SDValue MinMax;
+  if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE,
+   VT))
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE, DL, VT,
+ LHS, RHS);
+  else if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM : ISD::FMINNUM, VT))
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM : ISD::FMINNUM, DL, VT, LHS, 
RHS);
+  else
+MinMax = DAG.getSelect(
+DL, VT,
+DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT), LHS,
+RHS);
+
+  // Propagate any NaN of both 

[clang-tools-extra] [llvm] [AMDGPU] Quit PromoteAllocaToVector if intrinsic is used (PR #68744)

2023-12-19 Thread Mariusz Sikora via cfe-commits

https://github.com/mariusz-sikora-at-amd closed 
https://github.com/llvm/llvm-project/pull/68744
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Craig Topper via cfe-commits


@@ -216,6 +216,25 @@ def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", 
SiFive7Model,
   [TuneSiFive7,
TuneDLenFactor2]>;
 
+def SIFIVE_P450 : RISCVProcessorModel<"sifive-p450", NoSchedModel,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtZicbop,
+   FeatureStdExtZicbom,
+   FeatureStdExtZicboz,
+   FeatureStdExtZihintntl,
+   FeatureStdExtZihintpause,
+   FeatureStdExtZihpm,
+   FeatureStdExtZba,
+   FeatureStdExtZbb,
+   FeatureStdExtZbs,
+   FeatureStdExtZfhmin]>;
+

topperc wrote:

Zfhmin is correct. Its the minimum required for RVA22/RVA23 profiles.

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


[clang] Recommit [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain (#73765) (PR #75890)

2023-12-19 Thread Brandon Wu via cfe-commits

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


[clang] 379d32d - Recommit [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain (#73765) (#75890)

2023-12-19 Thread via cfe-commits

Author: Brandon Wu
Date: 2023-12-20T14:42:11+08:00
New Revision: 379d32dab812731dc8883eff48477fd5cc7c8a17

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

LOG: Recommit [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal 
toolchain (#73765) (#75890)

Extend the multi-lib re-use selection mechanism for RISC-V.
This funciton will try to re-use multi-lib if they are compatible.
Definition of compatible:
  - ABI must be the same.
  - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
is a subset of march=rv32imc.
  - march that contains atomic extension can't reuse multi-lib that
doesn't has atomic, vice versa. e.g. multi-lib=march=rv32im and
march=rv32ima are not compatible, because software and hardware
atomic operation can't work together correctly.

Added: 
clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c

Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 835215a83c4037..38361d6889a1c8 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
 #include 
@@ -1715,6 +1716,129 @@ static void findCSKYMultilibs(const Driver , const 
llvm::Triple ,
 Result.Multilibs = CSKYMultilibs;
 }
 
+/// Extend the multi-lib re-use selection mechanism for RISC-V.
+/// This function will try to re-use multi-lib if they are compatible.
+/// Definition of compatible:
+///   - ABI must be the same.
+///   - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
+/// is a subset of march=rv32imc.
+///   - march that contains atomic extension can't reuse multi-lib that
+/// doesn't have atomic, vice versa. e.g. multi-lib=march=rv32im and
+/// march=rv32ima are not compatible, because software and hardware
+/// atomic operation can't work together correctly.
+static bool
+selectRISCVMultilib(const MultilibSet , StringRef Arch,
+const Multilib::flags_list ,
+llvm::SmallVectorImpl ) {
+  // Try to find the perfect matching multi-lib first.
+  if (RISCVMultilibSet.select(Flags, SelectedMultilibs))
+return true;
+
+  Multilib::flags_list NewFlags;
+  std::vector NewMultilibs;
+
+  llvm::Expected> ParseResult =
+  llvm::RISCVISAInfo::parseArchString(
+  Arch, /*EnableExperimentalExtension=*/true,
+  /*ExperimentalExtensionVersionCheck=*/false);
+  if (!ParseResult) {
+// Ignore any error here, we assume it will be handled in another place.
+consumeError(ParseResult.takeError());
+return false;
+  }
+
+  auto  = *ParseResult;
+
+  addMultilibFlag(ISAInfo->getXLen() == 32, "-m32", NewFlags);
+  addMultilibFlag(ISAInfo->getXLen() == 64, "-m64", NewFlags);
+
+  // Collect all flags except march=*
+  for (StringRef Flag : Flags) {
+if (Flag.starts_with("!march=") || Flag.starts_with("-march="))
+  continue;
+
+NewFlags.push_back(Flag.str());
+  }
+
+  llvm::StringSet<> AllArchExts;
+  // Reconstruct multi-lib list, and break march option into separated
+  // extension. e.g. march=rv32im -> +i +m
+  for (const auto  : RISCVMultilibSet) {
+bool Skip = false;
+
+MultilibBuilder NewMultilib =
+MultilibBuilder(M.gccSuffix(), M.osSuffix(), M.includeSuffix());
+for (StringRef Flag : M.flags()) {
+  // Add back all flags except -march.
+  if (!Flag.consume_front("-march=")) {
+NewMultilib.flag(Flag);
+continue;
+  }
+
+  // Break down -march into individual extension.
+  llvm::Expected> MLConfigParseResult =
+  llvm::RISCVISAInfo::parseArchString(
+  Flag, /*EnableExperimentalExtension=*/true,
+  /*ExperimentalExtensionVersionCheck=*/false);
+  if (!MLConfigParseResult) {
+// Ignore any error here, we assume it will handled in another place.
+llvm::consumeError(MLConfigParseResult.takeError());
+
+// We might get a parsing error if rv32e in the list, we could just 
skip
+// that and process the rest of multi-lib configs.
+Skip = true;
+continue;
+  }
+  auto  = *MLConfigParseResult;
+
+  const llvm::RISCVISAInfo::OrderedExtensionMap  =
+  MLConfigISAInfo->getExtensions();
+  for (auto MLConfigArchExt : MLConfigArchExts) {
+auto ExtName = MLConfigArchExt.first;
+NewMultilib.flag(Twine("-", ExtName).str());
+
+if (AllArchExts.insert(ExtName).second) {
+  

[clang] Recommit [RISCV] Implement multi-lib reuse rule for RISC-V bare-metal toolchain (#73765) (PR #75890)

2023-12-19 Thread Brandon Wu via cfe-commits

https://github.com/4vtomat updated 
https://github.com/llvm/llvm-project/pull/75890

>From 3f4a4f10ed75cb0b0f937129b2372184ac34849d Mon Sep 17 00:00:00 2001
From: Brandon Wu 
Date: Mon, 18 Dec 2023 15:52:14 +0800
Subject: [PATCH 1/2] Recommit [RISCV] Implement multi-lib reuse rule for
 RISC-V bare-metal toolchain (#73765)

Extend the multi-lib re-use selection mechanism for RISC-V.
This funciton will try to re-use multi-lib if they are compatible.
Definition of compatible:
  - ABI must be the same.
  - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
is a subset of march=rv32imc.
  - march that contains atomic extension can't reuse multi-lib that
doesn't has atomic, vice versa. e.g. multi-lib=march=rv32im and
march=rv32ima are not compatible, because software and hardware
atomic operation can't work together correctly.
---
 clang/lib/Driver/ToolChains/Gnu.cpp   | 127 +-
 .../riscv-toolchain-gcc-multilib-reuse.c  |  81 +++
 2 files changed, 207 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Driver/riscv-toolchain-gcc-multilib-reuse.c

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 835215a83c4037..7e70626faf8cce 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
 #include 
@@ -1715,6 +1716,129 @@ static void findCSKYMultilibs(const Driver , const 
llvm::Triple ,
 Result.Multilibs = CSKYMultilibs;
 }
 
+/// Extend the multi-lib re-use selection mechanism for RISC-V.
+/// This function will try to re-use multi-lib if they are compatible.
+/// Definition of compatible:
+///   - ABI must be the same.
+///   - multi-lib is a subset of current arch, e.g. multi-lib=march=rv32im
+/// is a subset of march=rv32imc.
+///   - march that contains atomic extension can't reuse multi-lib that
+/// doesn't have atomic, vice versa. e.g. multi-lib=march=rv32im and
+/// march=rv32ima are not compatible, because software and hardware
+/// atomic operation can't work together correctly.
+static bool
+selectRISCVMultilib(const MultilibSet , StringRef Arch,
+const Multilib::flags_list ,
+llvm::SmallVectorImpl ) {
+  // Try to find the perfect matching multi-lib first.
+  if (RISCVMultilibSet.select(Flags, SelectedMultilibs))
+return true;
+
+  Multilib::flags_list NewFlags;
+  std::vector NewMultilibs;
+
+  llvm::Expected> ParseResult =
+  llvm::RISCVISAInfo::parseArchString(
+  Arch, /*EnableExperimentalExtension=*/true,
+  /*ExperimentalExtensionVersionCheck=*/false);
+  if (!ParseResult) {
+// Ignore any error here, we assume it will be handled in another place.
+consumeError(ParseResult.takeError());
+return false;
+  }
+
+  auto  = *ParseResult;
+
+  addMultilibFlag(ISAInfo->getXLen() == 32, "-m32", NewFlags);
+  addMultilibFlag(ISAInfo->getXLen() == 64, "-m64", NewFlags);
+
+  // Collect all flags except march=*
+  for (StringRef Flag : Flags) {
+if (Flag.starts_with("!march=") || Flag.starts_with("-march="))
+  continue;
+
+NewFlags.push_back(Flag.str());
+  }
+
+  llvm::StringSet<> AllArchExts;
+  // Reconstruct multi-lib list, and break march option into separated
+  // extension. e.g. march=rv32im -> +i +m
+  for (const auto  : RISCVMultilibSet) {
+bool Skip = false;
+
+MultilibBuilder NewMultilib =
+MultilibBuilder(M.gccSuffix(), M.osSuffix(), M.includeSuffix());
+for (StringRef Flag : M.flags()) {
+  // Add back all flags except -march.
+  if (!Flag.consume_front("-march=")) {
+NewMultilib.flag(Flag);
+continue;
+  }
+
+  // Break down -march into individual extension.
+  llvm::Expected> MLConfigParseResult =
+  llvm::RISCVISAInfo::parseArchString(
+  Flag, /*EnableExperimentalExtension=*/true,
+  /*ExperimentalExtensionVersionCheck=*/false);
+  if (!MLConfigParseResult) {
+// Ignore any error here, we assume it will handled in another place.
+llvm::consumeError(MLConfigParseResult.takeError());
+
+// We might get a parsing error if rv32e in the list, we could just 
skip
+// that and process the rest of multi-lib configs.
+Skip = true;
+continue;
+  }
+  auto  = *MLConfigParseResult;
+
+  const llvm::RISCVISAInfo::OrderedExtensionMap  =
+  MLConfigISAInfo->getExtensions();
+  for (auto MLConfigArchExt : MLConfigArchExts) {
+auto ExtName = MLConfigArchExt.first;
+NewMultilib.flag(Twine("-", ExtName).str());
+
+if (AllArchExts.insert(ExtName).second) {
+  addMultilibFlag(ISAInfo->hasExtension(ExtName),
+

[clang] [Clang] Fix a crash when incorrectly calling an explicit object member function template (PR #75913)

2023-12-19 Thread via cfe-commits

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


[clang] c853676 - [Clang] Fix a crash when incorrectly calling an explicit object member function template (#75913)

2023-12-19 Thread via cfe-commits

Author: cor3ntin
Date: 2023-12-20T07:41:24+01:00
New Revision: c8536760612785e8ee97a5261c20d22c6712b4b2

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

LOG: [Clang] Fix a crash when incorrectly calling an explicit object member 
function template (#75913)

Fixes #75732

Added: 


Modified: 
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaCXX/cxx2b-deducing-this.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 473eea55bb6b19..2abec3d86a27d9 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -253,7 +253,9 @@ static void diagnoseInstanceReference(Sema ,
 SemaRef.Diag(Loc, diag::err_member_call_without_object)
 << Range << /*static*/ 0;
   else {
-const auto *Callee = dyn_cast(Rep);
+if (const auto *Tpl = dyn_cast(Rep))
+  Rep = Tpl->getTemplatedDecl();
+const auto *Callee = cast(Rep);
 auto Diag = SemaRef.Diag(Loc, diag::err_member_call_without_object)
 << Range << Callee->isExplicitObjectMemberFunction();
 if (!Replacement.empty())

diff  --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 0033541fa322dc..aab35828096a8e 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -626,3 +626,13 @@ void test() {
 }
 
 }
+
+
+namespace GH75732 {
+auto serialize(auto&& archive, auto&& c){ }
+struct D {
+auto serialize(this auto&& self, auto&& archive) {
+serialize(archive, self); // expected-error {{call to explicit member 
function without an object argument}}
+}
+};
+}



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


[clang] [llvm] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Wang Pengcheng via cfe-commits


@@ -216,6 +216,25 @@ def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", 
SiFive7Model,
   [TuneSiFive7,
TuneDLenFactor2]>;
 
+def SIFIVE_P450 : RISCVProcessorModel<"sifive-p450", NoSchedModel,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtZicbop,
+   FeatureStdExtZicbom,
+   FeatureStdExtZicboz,
+   FeatureStdExtZihintntl,
+   FeatureStdExtZihintpause,
+   FeatureStdExtZihpm,
+   FeatureStdExtZba,
+   FeatureStdExtZbb,
+   FeatureStdExtZbs,
+   FeatureStdExtZfhmin]>;
+

wangpc-pp wrote:

I don't find the supported ISA description in datasheet, so I wonder if it's 
true that only `Zfhmin` is implemented. Should it be `Zfh`?

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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2023-12-19 Thread Chuanqi Xu via cfe-commits


@@ -0,0 +1,50 @@
+// REQUIRES: !system-windows
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \
+// RUN: -emit-module-interface -o %t/foo-layer1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple  \
+// RUN: -emit-module-interface -fmodule-file=foo:layer1=%t/foo-layer1.pcm \
+// RUN: -o %t/foo-layer2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer1.pcm -S -emit-llvm -o - | FileCheck 
%t/layer1.cppm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer2.pcm -S -emit-llvm -o - \
+// RUN: -fmodule-file=foo:layer1=%t/foo-layer1.pcm | FileCheck 
%t/layer2.cppm
+
+//--- layer1.cppm
+export module foo:layer1;
+struct Fruit {
+virtual ~Fruit() = default;
+virtual void eval() = 0;
+};
+struct Banana : public Fruit {
+Banana() {}
+void eval() override;
+};
+
+// CHECK-DAG: @_ZTVW3foo6Banana = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo6Banana = constant
+// CHECK-DAG: @_ZTIW3foo6Banana = constant
+//
+// CHECK-DAG: @_ZTVW3foo5Fruit = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo5Fruit = constant
+// CHECK-DAG: @_ZTIW3foo5Fruit = constant
+
+//--- layer2.cppm
+export module foo:layer2;
+import :layer1;
+export void layer2_fun() {
+Banana *b = new Banana();
+b->eval();
+}
+void Banana::eval() {
+}
+

ChuanqiXu9 wrote:

We're testing:
(1) The use of virtual functions won't produce the vtable.
(2) The definition of key functions won't produce the vtable.

I'll try to add a comment here.

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


[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread via cfe-commits

https://github.com/hstk30-hw updated 
https://github.com/llvm/llvm-project/pull/76007

>From 7b8c1c758c77550536b9d16027b2e51090e365be Mon Sep 17 00:00:00 2001
From: hstk-hw 
Date: Wed, 20 Dec 2023 12:26:15 +0800
Subject: [PATCH]in templates. This PR will address that.

---
 clang/lib/Sema/SemaStmt.cpp|  4 +--
 clang/test/Sema/switch-default.c   | 28 
 clang/test/Sema/switch-default.cpp | 53 ++
 3 files changed, 54 insertions(+), 31 deletions(-)
 delete mode 100644 clang/test/Sema/switch-default.c
 create mode 100644 clang/test/Sema/switch-default.cpp

diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 63348d27a8c94a..adc2055ec4e659 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,9 +1327,6 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
-  if (!TheDefaultStmt)
-Diag(SwitchLoc, diag::warn_switch_default);
-
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
@@ -1344,6 +1341,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
   assert(!HasConstantCond ||
  (ConstantCondValue.getBitWidth() == CondWidth &&
   ConstantCondValue.isSigned() == CondIsSigned));
+  Diag(SwitchLoc, diag::warn_switch_default);
 }
 bool ShouldCheckConstantCond = HasConstantCond;
 
diff --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
deleted file mode 100644
index 342a97ee68b1e2..00
--- a/clang/test/Sema/switch-default.c
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
-
-int f1(int a) {
-  switch (a) {// expected-warning {{'switch' missing 'default' 
label}}
-case 1: a++; break;
-case 2: a += 2; break;
-  }
-  return a;
-}
-
-int f2(int a) {
-  switch (a) {// no-warning
-default:
-  ;
-  }
-  return a;
-}
-
-// Warn even completely covered Enum cases(GCC compatibility).
-enum E { A, B };
-enum E check_enum(enum E e) {
-  switch (e) {// expected-warning {{'switch' missing 'default' 
label}}
-case A: break;
-case B: break;
-  }
-  return e;
-}
-
diff --git a/clang/test/Sema/switch-default.cpp 
b/clang/test/Sema/switch-default.cpp
new file mode 100644
index 00..32d03dae882733
--- /dev/null
+++ b/clang/test/Sema/switch-default.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wswitch-default %s
+
+int f1(int a) {
+  switch (a) {// expected-warning {{'switch' missing 'default' 
label}}
+case 1: a++; break;
+case 2: a += 2; break;
+  }
+  return a;
+}
+
+int f2(int a) {
+  switch (a) {// no-warning
+default:
+  ;
+  }
+  return a;
+}
+
+// Warn even completely covered Enum cases(GCC compatibility).
+enum E { A, B };
+enum E check_enum(enum E e) {
+  switch (e) {// expected-warning {{'switch' missing 'default' 
label}}
+case A: break;
+case B: break;
+  }
+  return e;
+}
+
+template
+int t1(Index i)
+{
+  switch (i) {  // expected-warning {{'switch' missing 'default' 
label}}
+case 0: return 0;
+case 1: return 1;
+  }
+  return 0;
+}
+
+template
+int t2(Index i)
+{
+  switch (i) {// no-warning
+case 0: return 0;
+case 1: return 1;
+default: return 2;
+  }
+  return 0;
+}
+
+int main() {
+  return t1(1);   // expected-note {{in instantiation of function template 
specialization 't1' requested here}}
+}
+

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


[clang] [Clang][Parser] Fix crash of clang when using C++ constructs like :: in C code (PR #74926)

2023-12-19 Thread via cfe-commits

ChipsSpectre wrote:

The Fork is now rebased on main, so the conflict in `ReleaseNotes.rst` is 
resolved.

@tbaederr Do you think it is ready to be merged now?

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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2023-12-19 Thread Chuanqi Xu via cfe-commits


@@ -0,0 +1,50 @@
+// REQUIRES: !system-windows
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \
+// RUN: -emit-module-interface -o %t/foo-layer1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple  \
+// RUN: -emit-module-interface -fmodule-file=foo:layer1=%t/foo-layer1.pcm \
+// RUN: -o %t/foo-layer2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer1.pcm -S -emit-llvm -o - | FileCheck 
%t/layer1.cppm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer2.pcm -S -emit-llvm -o - \
+// RUN: -fmodule-file=foo:layer1=%t/foo-layer1.pcm | FileCheck 
%t/layer2.cppm
+
+//--- layer1.cppm
+export module foo:layer1;
+struct Fruit {
+virtual ~Fruit() = default;
+virtual void eval() = 0;
+};
+struct Banana : public Fruit {
+Banana() {}
+void eval() override;
+};
+
+// CHECK-DAG: @_ZTVW3foo6Banana = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo6Banana = constant
+// CHECK-DAG: @_ZTIW3foo6Banana = constant
+//
+// CHECK-DAG: @_ZTVW3foo5Fruit = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo5Fruit = constant
+// CHECK-DAG: @_ZTIW3foo5Fruit = constant
+
+//--- layer2.cppm
+export module foo:layer2;
+import :layer1;
+export void layer2_fun() {
+Banana *b = new Banana();
+b->eval();
+}
+void Banana::eval() {
+}
+
+// CHECK-NOT: @_ZTVW3foo6Banana
+// CHECK-NOT: @_ZTSW3foo6Banana
+// CHECK-NOT: @_ZTIW3foo6Banana
+// CHECK-NOT: @_ZTVW3foo5Fruit
+// CHECK-NOT: @_ZTSW3foo5Fruit
+// CHECK-NOT: @_ZTIW3foo5Fruit

ChuanqiXu9 wrote:

I prefer the current pattern so that other developers can understand what we're 
testing by `llvm-cxxfilt`.

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


[clang] [Clang][Parser] Fix crash of clang when using C++ constructs like :: in C code (PR #74926)

2023-12-19 Thread via cfe-commits

https://github.com/ChipsSpectre updated 
https://github.com/llvm/llvm-project/pull/74926

>From a08d9029445087b78d19715991c426106d9b0ca6 Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Wed, 20 Dec 2023 07:33:20 +0100
Subject: [PATCH] [clang][Parse] `TryAnnotateCXXScopeToken` to be called only
 when parsing C++

Assume `TryAnnotateCXXScopeToken` to be parsing C++ code in all of its paths.

Fixes: https://github.com/llvm/llvm-project/issues/73559.
---
 clang/docs/ReleaseNotes.rst  | 2 ++
 clang/lib/Parse/ParseDecl.cpp| 3 ++-
 clang/lib/Parse/ParseDeclCXX.cpp | 2 ++
 clang/test/Parser/cxx-in-c.c | 3 +++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 39b9176865fc04..a83c102b320df3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -688,6 +688,8 @@ Bug Fixes in This Version
   Fixes (#69987 `_)
 - Fix an issue where CTAD fails for explicit type conversion.
   Fixes (#64347 `_)
+- Fix crash when using C++ only tokens like ``::`` in C compiler clang.
+  Fixes (`#73559 https://github.com/llvm/llvm-project/issues/73559`_)
 
 
 Bug Fixes to Compiler Builtins
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ed006f9d67de45..b60ae293ef8c20 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3483,7 +3483,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 case tok::coloncolon: // ::foo::bar
   // C++ scope specifier.  Annotate and loop, or bail out on error.
-  if (TryAnnotateCXXScopeToken(EnteringContext)) {
+  if (getLangOpts().CPlusPlus &&
+  TryAnnotateCXXScopeToken(EnteringContext)) {
 if (!DS.hasTypeSpecifier())
   DS.SetTypeSpecError();
 goto DoneWithDeclSpec;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 910112ecae964c..1cf16a752cfcdc 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2679,6 +2679,8 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes ,
const ParsedTemplateInfo ,
ParsingDeclRAIIObject *TemplateDiags) {
+  assert(getLangOpts().CPlusPlus &&
+ "Call sites of this function should be guarded by checking for C++");
   if (Tok.is(tok::at)) {
 if (getLangOpts().ObjC && NextToken().isObjCAtKeyword(tok::objc_defs))
   Diag(Tok, diag::err_at_defs_cxx);
diff --git a/clang/test/Parser/cxx-in-c.c b/clang/test/Parser/cxx-in-c.c
index f5fa39bd0cb99b..034a44cdf12bfa 100644
--- a/clang/test/Parser/cxx-in-c.c
+++ b/clang/test/Parser/cxx-in-c.c
@@ -3,3 +3,6 @@
 // PR9137
 void f0(int x) : {}; // expected-error{{expected function body after function 
declarator}}
 void f1(int x) try {}; // expected-error{{expected function body after 
function declarator}}
+
+// GH73559
+::; // expected-error{{expected identifier or '('}}

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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2023-12-19 Thread Chuanqi Xu via cfe-commits


@@ -0,0 +1,50 @@
+// REQUIRES: !system-windows
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \
+// RUN: -emit-module-interface -o %t/foo-layer1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple  \
+// RUN: -emit-module-interface -fmodule-file=foo:layer1=%t/foo-layer1.pcm \
+// RUN: -o %t/foo-layer2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer1.pcm -S -emit-llvm -o - | FileCheck 
%t/layer1.cppm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer2.pcm -S -emit-llvm -o - \
+// RUN: -fmodule-file=foo:layer1=%t/foo-layer1.pcm | FileCheck 
%t/layer2.cppm
+
+//--- layer1.cppm
+export module foo:layer1;
+struct Fruit {
+virtual ~Fruit() = default;
+virtual void eval() = 0;
+};
+struct Banana : public Fruit {
+Banana() {}
+void eval() override;
+};
+
+// CHECK-DAG: @_ZTVW3foo6Banana = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo6Banana = constant
+// CHECK-DAG: @_ZTIW3foo6Banana = constant
+//
+// CHECK-DAG: @_ZTVW3foo5Fruit = unnamed_addr constant
+// CHECK-DAG: @_ZTSW3foo5Fruit = constant
+// CHECK-DAG: @_ZTIW3foo5Fruit = constant
+

ChuanqiXu9 wrote:

Yeah, the linkage is already tested. Currently we're checking the linkage is 
`external` (default linkage). For example, if the linkage is `linkonce_odr`, 
the output will be something like: `// CHECK-DAG: @_ZTSW3foo5Fruit = 
linkonce_odr constant`

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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2023-12-19 Thread Chuanqi Xu via cfe-commits


@@ -0,0 +1,50 @@
+// REQUIRES: !system-windows
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \
+// RUN: -emit-module-interface -o %t/foo-layer1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple  \
+// RUN: -emit-module-interface -fmodule-file=foo:layer1=%t/foo-layer1.pcm \
+// RUN: -o %t/foo-layer2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer1.pcm -S -emit-llvm -o - | FileCheck 
%t/layer1.cppm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer2.pcm -S -emit-llvm -o - \
+// RUN: -fmodule-file=foo:layer1=%t/foo-layer1.pcm | FileCheck 
%t/layer2.cppm
+
+//--- layer1.cppm
+export module foo:layer1;
+struct Fruit {
+virtual ~Fruit() = default;
+virtual void eval() = 0;
+};
+struct Banana : public Fruit {
+Banana() {}
+void eval() override;
+};
+

ChuanqiXu9 wrote:

This comes from the original reproducer while the base class is a pure virtual 
class that can't be instantiated. While it may be sufficient to reduce them to 
a single class, I feel slightly better to keep the form since it is not complex.

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


[clang] [Clang][Parser] Fix crash of clang when using C++ constructs like :: in C code (PR #74926)

2023-12-19 Thread via cfe-commits

https://github.com/ChipsSpectre updated 
https://github.com/llvm/llvm-project/pull/74926

>From 28a5e6ffab5ec5fef7edce58c4dbdebffcfaabe3 Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Tue, 19 Dec 2023 05:14:06 +0100
Subject: [PATCH] [clang][Parse] `TryAnnotateCXXScopeToken` to be called only
 when parsing C++

Assume `TryAnnotateCXXScopeToken` to be parsing C++ code in all of its paths.

Fixes: https://github.com/llvm/llvm-project/issues/73559.
---
 clang/docs/ReleaseNotes.rst  | 3 ++-
 clang/lib/Parse/ParseDecl.cpp| 3 ++-
 clang/lib/Parse/ParseDeclCXX.cpp | 2 ++
 clang/test/Parser/cxx-in-c.c | 3 +++
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 39b9176865fc04..dd945f3eca4629 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -688,7 +688,8 @@ Bug Fixes in This Version
   Fixes (#69987 `_)
 - Fix an issue where CTAD fails for explicit type conversion.
   Fixes (#64347 `_)
-
+- Fix crash when using C++ only tokens like ``::`` in C compiler clang.
+  Fixes (`#73559 https://github.com/llvm/llvm-project/issues/73559`_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ed006f9d67de45..b60ae293ef8c20 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3483,7 +3483,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 case tok::coloncolon: // ::foo::bar
   // C++ scope specifier.  Annotate and loop, or bail out on error.
-  if (TryAnnotateCXXScopeToken(EnteringContext)) {
+  if (getLangOpts().CPlusPlus &&
+  TryAnnotateCXXScopeToken(EnteringContext)) {
 if (!DS.hasTypeSpecifier())
   DS.SetTypeSpecError();
 goto DoneWithDeclSpec;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 910112ecae964c..1cf16a752cfcdc 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2679,6 +2679,8 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes ,
const ParsedTemplateInfo ,
ParsingDeclRAIIObject *TemplateDiags) {
+  assert(getLangOpts().CPlusPlus &&
+ "Call sites of this function should be guarded by checking for C++");
   if (Tok.is(tok::at)) {
 if (getLangOpts().ObjC && NextToken().isObjCAtKeyword(tok::objc_defs))
   Diag(Tok, diag::err_at_defs_cxx);
diff --git a/clang/test/Parser/cxx-in-c.c b/clang/test/Parser/cxx-in-c.c
index f5fa39bd0cb99b..034a44cdf12bfa 100644
--- a/clang/test/Parser/cxx-in-c.c
+++ b/clang/test/Parser/cxx-in-c.c
@@ -3,3 +3,6 @@
 // PR9137
 void f0(int x) : {}; // expected-error{{expected function body after function 
declarator}}
 void f1(int x) try {}; // expected-error{{expected function body after 
function declarator}}
+
+// GH73559
+::; // expected-error{{expected identifier or '('}}

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


[llvm] [clang] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Craig Topper via cfe-commits

https://github.com/topperc updated 
https://github.com/llvm/llvm-project/pull/75760

>From 22fd20164e9d061a451555c5158f0a8ecb73f77e Mon Sep 17 00:00:00 2001
From: Craig Topper 
Date: Sun, 17 Dec 2023 18:18:43 -0800
Subject: [PATCH 1/3] [RISCV] Add sifive-p450 CPU.

This is an out of order core with no vector unit. More information:
https://www.sifive.com/cores/performance-p450-470

Scheduler model and other tuning will come in separate patches.
---
 clang/test/Misc/target-invalid-cpu-note.c |  4 ++--
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 19 +++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index e840a9208f5a45..48e9f05d9b03de 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, 
sifive-x280, veyron-v1, xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, veyron-v1, xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, veyron-v1, xiangshan-nanhu, generic, rocket, 
sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-p450, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, veyron-v1, xiangshan-nanhu, generic, 
rocket, sifive-7-series{{$}}
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 58989fd716fa0e..16c79519fcacc1 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -216,6 +216,25 @@ def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", 
SiFive7Model,
   [TuneSiFive7,
TuneDLenFactor2]>;
 
+def SIFIVE_P450 : RISCVProcessorModel<"sifive-p450", NoSchedModel,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtZicbop,
+   FeatureStdExtZicbom,
+   FeatureStdExtZicboz,
+   FeatureStdExtZihintntl,
+   FeatureStdExtZihintpause,
+   FeatureStdExtZihpm,
+   FeatureStdExtZba,
+   FeatureStdExtZbb,
+   FeatureStdExtZbs,
+   FeatureStdExtZfhmin]>;
+
 def SYNTACORE_SCR1_BASE : RISCVProcessorModel<"syntacore-scr1-base",
   SyntacoreSCR1Model,
   [Feature32Bit,

>From 11323f0d835931624dc5aa42fdef6b1199107716 Mon Sep 17 00:00:00 2001
From: Craig Topper 
Date: Tue, 19 Dec 2023 16:04:35 -0800
Subject: [PATCH 2/3] fixup! Add test to riscv-cpus.

---
 clang/test/Driver/riscv-cpus.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index d7fa7c9854a48f..424e57cc7a3b3d 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -222,6 +222,11 @@
 // MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
 // MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-p450 | FileCheck 
-check-prefix=MCPU-SIFIVE-P450 %s
+// MCPU-SIFIVE-P450: "-nostdsysteminc" "-target-cpu" "sifive-p450"
+// MCPU-SIFIVE-P450-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" 

[openmp] [clang-tools-extra] [clang] [libcxx] [libc] [mlir] [llvm] [flang] [lldb] [compiler-rt] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-19 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/17] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// 

[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread via cfe-commits

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@vvereschaka, thanks for the ping. Will look into this shortly. Feel free to 
revert. 

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

Thanks @MaxEW707 ! I don't have other comments now. Do you need help to merge 
it for you?

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


[clang-tools-extra] [llvm] [libcxx] [clang] [libcxx] adds ranges::fold_left_with_iter and ranges::fold_left (PR #75259)

2023-12-19 Thread Christopher Di Bella via cfe-commits

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


[clang-tools-extra] [llvm] [libcxx] [clang] [libcxx] adds ranges::fold_left_with_iter and ranges::fold_left (PR #75259)

2023-12-19 Thread Christopher Di Bella via cfe-commits

cjdb wrote:

Merging, with the promise to diligently resolve post-commit feedback in early 
January. Anything that's specific to this patch will be actioned before 
starting work on the remaining fold algorithms, and anything that's generalised 
to `std::ranges` will be actioned after finishing them.

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


[llvm] [clang-tools-extra] [clang] [ISel] Add pattern matching for depositing subreg value (PR #75978)

2023-12-19 Thread Shengchen Kan via cfe-commits

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

LGTM

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


[clang] [llvm] DiagnosticHandler: refactor error checking (PR #75889)

2023-12-19 Thread Fangrui Song via cfe-commits

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


[clang] 207cbbd - DiagnosticHandler: refactor error checking (#75889)

2023-12-19 Thread via cfe-commits

Author: Fangrui Song
Date: 2023-12-19T21:51:26-08:00
New Revision: 207cbbd71009090768c63004b967eddfab0f1d2e

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

LOG: DiagnosticHandler: refactor error checking (#75889)

In LLVMContext::diagnose, set `HasErrors` for `DS_Error` so that all
derived `DiagnosticHandler` have correct `HasErrors` information.

An alternative is to set `HasErrors` in
`DiagnosticHandler::handleDiagnostics`, but all derived
`handleDiagnostics` would have to call the base function.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenAction.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/tools/llc/llc.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 4121a3709bc3af..753a8fd74fa696 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -418,8 +418,6 @@ void BackendConsumer::anchor() { }
 } // namespace clang
 
 bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo ) {
-  if (DI.getSeverity() == DS_Error)
-HasErrors = true;
   BackendCon->DiagnosticHandlerImpl(DI);
   return true;
 }

diff  --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 8ddf51537ec1af..57077e786efc26 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -256,10 +256,13 @@ void LLVMContext::diagnose(const DiagnosticInfo ) {
   RS->emit(*OptDiagBase);
 
   // If there is a report handler, use it.
-  if (pImpl->DiagHandler &&
-  (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) &&
-  pImpl->DiagHandler->handleDiagnostics(DI))
-return;
+  if (pImpl->DiagHandler) {
+if (DI.getSeverity() == DS_Error)
+  pImpl->DiagHandler->HasErrors = true;
+if ((!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) &&
+pImpl->DiagHandler->handleDiagnostics(DI))
+  return;
+  }
 
   if (!isDiagnosticEnabled(DI))
 return;

diff  --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 8d906cf372878f..4a1957588a2243 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -307,16 +307,12 @@ static std::unique_ptr 
GetOutputStream(const char *TargetName,
 }
 
 struct LLCDiagnosticHandler : public DiagnosticHandler {
-  bool *HasError;
-  LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
   bool handleDiagnostics(const DiagnosticInfo ) override {
+DiagnosticHandler::handleDiagnostics(DI);
 if (DI.getKind() == llvm::DK_SrcMgr) {
   const auto  = cast(DI);
   const SMDiagnostic  = DISM.getSMDiag();
 
-  if (SMD.getKind() == SourceMgr::DK_Error)
-*HasError = true;
-
   SMD.print(nullptr, errs());
 
   // For testing purposes, we print the LocCookie here.
@@ -326,9 +322,6 @@ struct LLCDiagnosticHandler : public DiagnosticHandler {
   return true;
 }
 
-if (DI.getSeverity() == DS_Error)
-  *HasError = true;
-
 if (auto *Remark = dyn_cast())
   if (!Remark->isEnabled())
 return true;
@@ -413,9 +406,7 @@ int main(int argc, char **argv) {
   Context.setDiscardValueNames(DiscardValueNames);
 
   // Set a diagnostic handler that doesn't exit on the first error
-  bool HasError = false;
-  Context.setDiagnosticHandler(
-  std::make_unique());
+  Context.setDiagnosticHandler(std::make_unique());
 
   Expected> RemarksFileOrErr =
   setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
@@ -757,9 +748,7 @@ static int compileModule(char **argv, LLVMContext ) 
{
 
 PM.run(*M);
 
-auto HasError =
-((const LLCDiagnosticHandler 
*)(Context.getDiagHandlerPtr()))->HasError;
-if (*HasError)
+if (Context.getDiagHandlerPtr()->HasErrors)
   return 1;
 
 // Compare the two outputs and make sure they're the same



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


[libunwind] [libunwind] Bump to CXX_STANDARD 17 (PR #75986)

2023-12-19 Thread Fangrui Song via cfe-commits

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


[libunwind] 47413bb - [libunwind] Bump to CXX_STANDARD 17 (#75986)

2023-12-19 Thread via cfe-commits

Author: Fangrui Song
Date: 2023-12-19T21:51:05-08:00
New Revision: 47413bb2760e63a3302871ea770d6c0f5a742036

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

LOG: [libunwind] Bump to CXX_STANDARD 17 (#75986)

libunwind uses C-style and low-level C++, so the language standard
doesn't matter that much, but bumping to C++17 aligns with the rest of
LLVM and enables some features that would cause pedantic warnings in
C++11 (e.g. -Wc++17-attribute-extensions for [[fallthrough]]/
[[nodiscard]]/[[maybe_unused]]). (Contributors might use these features
unaware of the pedantic warnings).

Suggested-by: Christopher Di Bella 

Added: 


Modified: 
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 570824260465d6..9c6f5d908b0945 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -154,7 +154,7 @@ target_link_libraries(unwind_shared_objects PUBLIC 
"${LIBUNWIND_ADDITIONAL_LIBRA
 set_target_properties(unwind_shared_objects
   PROPERTIES
 CXX_EXTENSIONS OFF
-CXX_STANDARD 11
+CXX_STANDARD 17
 CXX_STANDARD_REQUIRED ON
 COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
 )
@@ -194,7 +194,7 @@ target_link_libraries(unwind_static_objects PUBLIC 
"${LIBUNWIND_ADDITIONAL_LIBRA
 set_target_properties(unwind_static_objects
   PROPERTIES
 CXX_EXTENSIONS OFF
-CXX_STANDARD 11
+CXX_STANDARD 17
 CXX_STANDARD_REQUIRED ON
 COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
 )



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


[llvm] [clang] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Wang Pengcheng via cfe-commits


@@ -222,6 +222,11 @@
 // MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
 // MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-p450 | FileCheck 
-check-prefix=MCPU-SIFIVE-P450 %s
+// MCPU-SIFIVE-P450: "-nostdsysteminc" "-target-cpu" "sifive-p450"
+// MCPU-SIFIVE-P450-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+c" 
"-target-feature" "+zicbom" "-target-feature" "+zicbop" "-target-feature" 
"+zicboz" "-target-feature" "+zicsr" "-target-feature" "+zifencei" 
"-target-feature" "+zihintntl" "-target-feature" "+zihintpause" 
"-target-feature" "+zihpm" "-target-feature" "+zfhmin" "-target-feature" "+zba" 
"-target-feature" "+zbb" "-target-feature" "+zbs" "-target-feature" "-

wangpc-pp wrote:

I prefer to the form of `veyron-v1` test that there is exactly one line for one 
feature. We can just test features specified in `RISCVProcessorModel` 
definitions in `RISCVProcessors.td`. As for implied features, we can ignore 
them as there are test coverage in other tests and this is not the purpose of 
`riscv-cpus.c` I think.

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vladimir Vereschaka via cfe-commits

vvereschaka wrote:

Looks like these changes break the`ClangReplInterpreterTests` unit tests 
* https://lab.llvm.org/buildbot/#/builders/119/builds/16346
* https://lab.llvm.org/buildbot/#/builders/60/builds/15188

* Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/17/21
* Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/18/21
* Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/20/21
* Clang-Unit :: Interpreter/./ClangReplInterpreterTests.exe/19/21

**No available targets are compatible with triple 
"x86_64-pc-windows-msvc19.37.32825**

The builders are ARM/Aarch64 only.

```
No available targets are compatible with triple 
"x86_64-pc-windows-msvc19.37.32825"
UNREACHABLE executed at 
C:\buildbot\temp\llvm-project\llvm\include\llvm/Support/Error.h:759!
Exception Code: 0x8003
 #0 0x7ff755428595 setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x618595)
 #1 0x7ff75912bc46 clang::Value::printData(class llvm::raw_ostream &) const 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x431bc46)
 #2 0x7ff75911d9dc clang::Value::printData(class llvm::raw_ostream &) const 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x430d9dc)
 #3 0x7ff755398b16 setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x588b16)
 #4 0x7ff754e99976 clang::Value::setUShort(unsigned short) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x89976)
 #5 0x7ff754e9c819 setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x8c819)
 #6 0x7ff75546437b setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x65437b)
 #7 0x7ff75548ae64 setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x67ae64)
 #8 0x7ff75548b316 setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x67b316)
 #9 0x7ff75548bd24 setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x67bd24)
#10 0x7ff7554643bb setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x6543bb)
#11 0x7ff75548b668 setGlobal(int) 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x67b668)
#12 0x7ff7592023c5 clang::Value::printData(class llvm::raw_ostream &) const 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x43f23c5)
#13 0x7ff759116640 clang::Value::printData(class llvm::raw_ostream &) const 
(C:\buildbot\temp\build\tools\clang\unittests\Interpreter\ClangReplInterpreterTests.exe+0x4306640)
#14 0x7ffea7ef7ac4 (C:\WINDOWS\System32\KERNEL32.DLL+0x17ac4)
#15 0x7ffea855a4e1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x5a4e1)
```

Would you take care of it?

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


[compiler-rt] [libc] [mlir] [llvm] [clang] [clang-tools-extra] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/76003

>From 860a2f794bdf12ff1f08d4802570757e805264b0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Mon, 18 Dec 2023 15:53:41 -0600
Subject: [PATCH 1/8] [mlir][Linalg] Support dynamic sizes in `lower_pack`
 transform

---
 .../Linalg/TransformOps/LinalgTransformOps.td |  3 +-
 .../Dialect/Linalg/Transforms/Transforms.h|  2 +-
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 69 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 20 ++
 4 files changed, 70 insertions(+), 24 deletions(-)

diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 77ed9db5e71bd1..4abd3740b57105 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -498,7 +498,8 @@ def LowerPackOp : Op:$target);
   let results = (outs Transform_ConcreteOpType<"tensor.pad">:$pad_op,
-  
Transform_ConcreteOpType<"tensor.expand_shape">:$expand_shape_op,
+  
Type.predicate,
+   
Transform_ConcreteOpType<"tensor.reshape">.predicate]>>:$expand_shape_op,
   
Transform_ConcreteOpType<"linalg.transpose">:$transpose_op);
   let assemblyFormat = [{
 $target attr-dict `:` functional-type(operands, results)
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index a848d12fbbb50e..344e801835ccc9 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;
   linalg::TransposeOp transposeOp;
 };
 
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 9d230e2c2e5749..359274866748fc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -218,21 +218,11 @@ struct PackedOperandsDimList {
 
 FailureOr linalg::lowerPack(RewriterBase ,
  tensor::PackOp packOp) {
-  // 1. Filter out NYI cases.
-  auto packedTensorType =
-  cast(packOp->getResultTypes().front());
-  if (llvm::any_of(packOp.getStaticInnerTiles(),
-   [](int64_t size) { return ShapedType::isDynamic(size); })) {
-return rewriter.notifyMatchFailure(
-packOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
-
   Location loc = packOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(packOp);
 
-  // 2. Compute the permutation vector to shuffle packed shape into the shape
+  // 1. Compute the permutation vector to shuffle packed shape into the shape.
   // before any outer or inner permutations have been applied. The permutation
   // can be obtained from two permutations:
   //   a) Compute the permutation vector to move the last `numPackedDims` into
@@ -240,6 +230,8 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   //   b) Compute the permutation vector to move outer dims if the pack op
   //  has outer_dims_perm.
   // Apply (b) permutation on (a) permutation to get the final permutation.
+  auto packedTensorType =
+  cast(packOp->getResultTypes().front());
   int64_t numPackedDims = packOp.getInnerDimsPos().size();
   int64_t packedRank = packedTensorType.getRank();
   auto lastDims = llvm::to_vector(
@@ -259,12 +251,12 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   SmallVector packedToStripMinedShapePerm = innerPositionsPerm;
   applyPermutationToVector(packedToStripMinedShapePerm, outerPositionPerm);
 
-  // 3. Compute the stripMinedShape: this is the packed shape before any outer
+  // 2. Compute the stripMinedShape: this is the packed shape before any outer.
   // or inner permutations have been applied.
   SmallVector stripMinedShape(packedTensorType.getShape());
   applyPermutationToVector(stripMinedShape, packedToStripMinedShapePerm);
 
-  // 4. Pad the source of packOp to a shape we can expand into stripMinedShape.
+  // 3. Pad the source of packOp to a shape we can expand into stripMinedShape.
   SmallVector lows(packOp.getSourceRank(),
  rewriter.getIndexAttr(0));
   SmallVector highs(packOp.getSourceRank(),
@@ -351,24 +343,57 @@ FailureOr linalg::lowerPack(RewriterBase 
,
  /*transposeOp=*/nullptr};
 }
   }
-  // 5. Expand from the padded result to the stripMinedShape.
-  auto reshapeOp = rewriter.create(
-  loc,
-  RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape),
-  padOp.getResult(), 

[compiler-rt] [libc] [mlir] [llvm] [clang] [clang-tools-extra] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

srcarroll wrote:

The current implementation will emit a `tensor.reshape` op if any of the dims 
of the input are not factorable (require more than one dynamic dim in the 
expansion). However, I could instead only emit reshapes for the dims that need 
it, and then a `tensor.expand_shape` on the rest of the dims. Whichever is 
preferable to the reviewer(s).

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


[clang] [clang][sema] make sure arguments of __atomic_exchange complete type (PR #75135)

2023-12-19 Thread Shafik Yaghmour via cfe-commits

https://github.com/shafik commented:

We should add a release note for this change.

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


[compiler-rt] [libc] [mlir] [llvm] [clang] [clang-tools-extra] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

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


[compiler-rt] [libc] [mlir] [llvm] [clang] [clang-tools-extra] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/76003

>From 860a2f794bdf12ff1f08d4802570757e805264b0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Mon, 18 Dec 2023 15:53:41 -0600
Subject: [PATCH 1/7] [mlir][Linalg] Support dynamic sizes in `lower_pack`
 transform

---
 .../Linalg/TransformOps/LinalgTransformOps.td |  3 +-
 .../Dialect/Linalg/Transforms/Transforms.h|  2 +-
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 69 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 20 ++
 4 files changed, 70 insertions(+), 24 deletions(-)

diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 77ed9db5e71bd1..4abd3740b57105 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -498,7 +498,8 @@ def LowerPackOp : Op:$target);
   let results = (outs Transform_ConcreteOpType<"tensor.pad">:$pad_op,
-  
Transform_ConcreteOpType<"tensor.expand_shape">:$expand_shape_op,
+  
Type.predicate,
+   
Transform_ConcreteOpType<"tensor.reshape">.predicate]>>:$expand_shape_op,
   
Transform_ConcreteOpType<"linalg.transpose">:$transpose_op);
   let assemblyFormat = [{
 $target attr-dict `:` functional-type(operands, results)
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index a848d12fbbb50e..344e801835ccc9 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;
   linalg::TransposeOp transposeOp;
 };
 
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 9d230e2c2e5749..359274866748fc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -218,21 +218,11 @@ struct PackedOperandsDimList {
 
 FailureOr linalg::lowerPack(RewriterBase ,
  tensor::PackOp packOp) {
-  // 1. Filter out NYI cases.
-  auto packedTensorType =
-  cast(packOp->getResultTypes().front());
-  if (llvm::any_of(packOp.getStaticInnerTiles(),
-   [](int64_t size) { return ShapedType::isDynamic(size); })) {
-return rewriter.notifyMatchFailure(
-packOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
-
   Location loc = packOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(packOp);
 
-  // 2. Compute the permutation vector to shuffle packed shape into the shape
+  // 1. Compute the permutation vector to shuffle packed shape into the shape.
   // before any outer or inner permutations have been applied. The permutation
   // can be obtained from two permutations:
   //   a) Compute the permutation vector to move the last `numPackedDims` into
@@ -240,6 +230,8 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   //   b) Compute the permutation vector to move outer dims if the pack op
   //  has outer_dims_perm.
   // Apply (b) permutation on (a) permutation to get the final permutation.
+  auto packedTensorType =
+  cast(packOp->getResultTypes().front());
   int64_t numPackedDims = packOp.getInnerDimsPos().size();
   int64_t packedRank = packedTensorType.getRank();
   auto lastDims = llvm::to_vector(
@@ -259,12 +251,12 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   SmallVector packedToStripMinedShapePerm = innerPositionsPerm;
   applyPermutationToVector(packedToStripMinedShapePerm, outerPositionPerm);
 
-  // 3. Compute the stripMinedShape: this is the packed shape before any outer
+  // 2. Compute the stripMinedShape: this is the packed shape before any outer.
   // or inner permutations have been applied.
   SmallVector stripMinedShape(packedTensorType.getShape());
   applyPermutationToVector(stripMinedShape, packedToStripMinedShapePerm);
 
-  // 4. Pad the source of packOp to a shape we can expand into stripMinedShape.
+  // 3. Pad the source of packOp to a shape we can expand into stripMinedShape.
   SmallVector lows(packOp.getSourceRank(),
  rewriter.getIndexAttr(0));
   SmallVector highs(packOp.getSourceRank(),
@@ -351,24 +343,57 @@ FailureOr linalg::lowerPack(RewriterBase 
,
  /*transposeOp=*/nullptr};
 }
   }
-  // 5. Expand from the padded result to the stripMinedShape.
-  auto reshapeOp = rewriter.create(
-  loc,
-  RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape),
-  padOp.getResult(), 

[clang] [clang-tools-extra] [compiler-rt] [libc] [llvm] [mlir] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

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


[clang] [clang-tools-extra] [compiler-rt] [libc] [llvm] [mlir] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

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


[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread Shafik Yaghmour via cfe-commits


@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wswitch-default %s

shafik wrote:

I think we can add these test to `clang/test/Sema/switch-default.c`

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


[clang] [clang-tools-extra] [compiler-rt] [libc] [llvm] [mlir] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/76003

>From 860a2f794bdf12ff1f08d4802570757e805264b0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Mon, 18 Dec 2023 15:53:41 -0600
Subject: [PATCH 1/7] [mlir][Linalg] Support dynamic sizes in `lower_pack`
 transform

---
 .../Linalg/TransformOps/LinalgTransformOps.td |  3 +-
 .../Dialect/Linalg/Transforms/Transforms.h|  2 +-
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 69 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 20 ++
 4 files changed, 70 insertions(+), 24 deletions(-)

diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 77ed9db5e71bd1..4abd3740b57105 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -498,7 +498,8 @@ def LowerPackOp : Op:$target);
   let results = (outs Transform_ConcreteOpType<"tensor.pad">:$pad_op,
-  
Transform_ConcreteOpType<"tensor.expand_shape">:$expand_shape_op,
+  
Type.predicate,
+   
Transform_ConcreteOpType<"tensor.reshape">.predicate]>>:$expand_shape_op,
   
Transform_ConcreteOpType<"linalg.transpose">:$transpose_op);
   let assemblyFormat = [{
 $target attr-dict `:` functional-type(operands, results)
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index a848d12fbbb50e..344e801835ccc9 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;
   linalg::TransposeOp transposeOp;
 };
 
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 9d230e2c2e5749..359274866748fc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -218,21 +218,11 @@ struct PackedOperandsDimList {
 
 FailureOr linalg::lowerPack(RewriterBase ,
  tensor::PackOp packOp) {
-  // 1. Filter out NYI cases.
-  auto packedTensorType =
-  cast(packOp->getResultTypes().front());
-  if (llvm::any_of(packOp.getStaticInnerTiles(),
-   [](int64_t size) { return ShapedType::isDynamic(size); })) {
-return rewriter.notifyMatchFailure(
-packOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
-
   Location loc = packOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(packOp);
 
-  // 2. Compute the permutation vector to shuffle packed shape into the shape
+  // 1. Compute the permutation vector to shuffle packed shape into the shape.
   // before any outer or inner permutations have been applied. The permutation
   // can be obtained from two permutations:
   //   a) Compute the permutation vector to move the last `numPackedDims` into
@@ -240,6 +230,8 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   //   b) Compute the permutation vector to move outer dims if the pack op
   //  has outer_dims_perm.
   // Apply (b) permutation on (a) permutation to get the final permutation.
+  auto packedTensorType =
+  cast(packOp->getResultTypes().front());
   int64_t numPackedDims = packOp.getInnerDimsPos().size();
   int64_t packedRank = packedTensorType.getRank();
   auto lastDims = llvm::to_vector(
@@ -259,12 +251,12 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   SmallVector packedToStripMinedShapePerm = innerPositionsPerm;
   applyPermutationToVector(packedToStripMinedShapePerm, outerPositionPerm);
 
-  // 3. Compute the stripMinedShape: this is the packed shape before any outer
+  // 2. Compute the stripMinedShape: this is the packed shape before any outer.
   // or inner permutations have been applied.
   SmallVector stripMinedShape(packedTensorType.getShape());
   applyPermutationToVector(stripMinedShape, packedToStripMinedShapePerm);
 
-  // 4. Pad the source of packOp to a shape we can expand into stripMinedShape.
+  // 3. Pad the source of packOp to a shape we can expand into stripMinedShape.
   SmallVector lows(packOp.getSourceRank(),
  rewriter.getIndexAttr(0));
   SmallVector highs(packOp.getSourceRank(),
@@ -351,24 +343,57 @@ FailureOr linalg::lowerPack(RewriterBase 
,
  /*transposeOp=*/nullptr};
 }
   }
-  // 5. Expand from the padded result to the stripMinedShape.
-  auto reshapeOp = rewriter.create(
-  loc,
-  RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape),
-  padOp.getResult(), 

[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread Shafik Yaghmour via cfe-commits

shafik wrote:

Can you add more details to you summary 
"https://github.com/llvm/llvm-project/pull/73077 added -Wswitch-default 
diagnostic but it produced false positives in templates. This PR will address 
that issue" 


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


[clang] [clang-tools-extra] [compiler-rt] [libc] [llvm] [mlir] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/76003

>From 860a2f794bdf12ff1f08d4802570757e805264b0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Mon, 18 Dec 2023 15:53:41 -0600
Subject: [PATCH 1/7] [mlir][Linalg] Support dynamic sizes in `lower_pack`
 transform

---
 .../Linalg/TransformOps/LinalgTransformOps.td |  3 +-
 .../Dialect/Linalg/Transforms/Transforms.h|  2 +-
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 69 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 20 ++
 4 files changed, 70 insertions(+), 24 deletions(-)

diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 77ed9db5e71bd1..4abd3740b57105 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -498,7 +498,8 @@ def LowerPackOp : Op:$target);
   let results = (outs Transform_ConcreteOpType<"tensor.pad">:$pad_op,
-  
Transform_ConcreteOpType<"tensor.expand_shape">:$expand_shape_op,
+  
Type.predicate,
+   
Transform_ConcreteOpType<"tensor.reshape">.predicate]>>:$expand_shape_op,
   
Transform_ConcreteOpType<"linalg.transpose">:$transpose_op);
   let assemblyFormat = [{
 $target attr-dict `:` functional-type(operands, results)
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index a848d12fbbb50e..344e801835ccc9 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;
   linalg::TransposeOp transposeOp;
 };
 
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 9d230e2c2e5749..359274866748fc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -218,21 +218,11 @@ struct PackedOperandsDimList {
 
 FailureOr linalg::lowerPack(RewriterBase ,
  tensor::PackOp packOp) {
-  // 1. Filter out NYI cases.
-  auto packedTensorType =
-  cast(packOp->getResultTypes().front());
-  if (llvm::any_of(packOp.getStaticInnerTiles(),
-   [](int64_t size) { return ShapedType::isDynamic(size); })) {
-return rewriter.notifyMatchFailure(
-packOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
-
   Location loc = packOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(packOp);
 
-  // 2. Compute the permutation vector to shuffle packed shape into the shape
+  // 1. Compute the permutation vector to shuffle packed shape into the shape.
   // before any outer or inner permutations have been applied. The permutation
   // can be obtained from two permutations:
   //   a) Compute the permutation vector to move the last `numPackedDims` into
@@ -240,6 +230,8 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   //   b) Compute the permutation vector to move outer dims if the pack op
   //  has outer_dims_perm.
   // Apply (b) permutation on (a) permutation to get the final permutation.
+  auto packedTensorType =
+  cast(packOp->getResultTypes().front());
   int64_t numPackedDims = packOp.getInnerDimsPos().size();
   int64_t packedRank = packedTensorType.getRank();
   auto lastDims = llvm::to_vector(
@@ -259,12 +251,12 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   SmallVector packedToStripMinedShapePerm = innerPositionsPerm;
   applyPermutationToVector(packedToStripMinedShapePerm, outerPositionPerm);
 
-  // 3. Compute the stripMinedShape: this is the packed shape before any outer
+  // 2. Compute the stripMinedShape: this is the packed shape before any outer.
   // or inner permutations have been applied.
   SmallVector stripMinedShape(packedTensorType.getShape());
   applyPermutationToVector(stripMinedShape, packedToStripMinedShapePerm);
 
-  // 4. Pad the source of packOp to a shape we can expand into stripMinedShape.
+  // 3. Pad the source of packOp to a shape we can expand into stripMinedShape.
   SmallVector lows(packOp.getSourceRank(),
  rewriter.getIndexAttr(0));
   SmallVector highs(packOp.getSourceRank(),
@@ -351,24 +343,57 @@ FailureOr linalg::lowerPack(RewriterBase 
,
  /*transposeOp=*/nullptr};
 }
   }
-  // 5. Expand from the padded result to the stripMinedShape.
-  auto reshapeOp = rewriter.create(
-  loc,
-  RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape),
-  padOp.getResult(), 

[clang] [clang-tools-extra] [compiler-rt] [libc] [llvm] [mlir] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits


@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;

srcarroll wrote:

Not actually sure what would be appropriate here.  Alternatively, we could have 
two separate fields for the `ExpandShapeOp` and `ReshapeOp`, but I haven't 
looked into the implications of this yet.  I welcome suggestions.

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


[clang] [clang-tools-extra] [Sema][clangd] add noexcept to override functions during code completion (PR #75937)

2023-12-19 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

> Maybe this deserves a new issue for clang Sema?

Sounds reasonable to me. Feel free to put up a PR / issue for this if you are 
interested.

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


[llvm] [clang] [clang-tools-extra] [ISel] Add pattern matching for depositing subreg value (PR #75978)

2023-12-19 Thread David Li via cfe-commits


@@ -1515,6 +1515,15 @@ def : Pat<(X86add_flag_nocf GR32:$src1, 128),
 def : Pat<(X86add_flag_nocf GR64:$src1, 128),
   (SUB64ri32 GR64:$src1, -128)>;
 
+// Depositing value to 8/16 bit subreg:
+def : Pat<(or (and GR64:$dst, -256), 
+  (i64 (zextloadi8 addr:$src))),
+  (INSERT_SUBREG (i64 (COPY $dst)), (MOV8rm  i8mem:$src), sub_8bit)>; 

david-xl wrote:

done

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


[llvm] [clang] [clang-tools-extra] [ISel] Add pattern matching for depositing subreg value (PR #75978)

2023-12-19 Thread David Li via cfe-commits


@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+;RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s 
--check-prefixes=X64
+
+define i64 @sub8(i64 noundef %res, ptr %byte) {
+; X64-LABEL: sub8:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:movq %rdi, %rax
+; X64-NEXT:movb (%rsi), %al
+; X64-NEXT:retq
+entry:
+  %and = and i64 %res, -256
+  %d = load i8, ptr %byte, align 1
+  %conv2 = zext i8 %d to i64
+  %or = or i64 %and, %conv2
+  ret i64 %or
+}
+
+define i64 @sub16(i64 noundef %res, ptr %byte) {
+; X64-LABEL: sub16:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:movq %rdi, %rax
+; X64-NEXT:movw (%rsi), %ax
+; X64-NEXT:retq
+entry:
+  %and = and i64 %res, -65536
+  %d = load i16, ptr %byte, align 1
+  %conv2 = zext i16 %d to i64
+  %or = or i64 %and, %conv2
+  ret i64 %or
+}
+
+
+
+

david-xl wrote:

done

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


[llvm] [clang] [clang-tools-extra] [ISel] Add pattern matching for depositing subreg value (PR #75978)

2023-12-19 Thread David Li via cfe-commits


@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+;RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s 
--check-prefixes=X64

david-xl wrote:

Done.

x64 is used elsewhere too. Anyway change it to x86_64 and I386 for clarity.

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


[mlir] [llvm] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/76003

>From 860a2f794bdf12ff1f08d4802570757e805264b0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Mon, 18 Dec 2023 15:53:41 -0600
Subject: [PATCH 1/6] [mlir][Linalg] Support dynamic sizes in `lower_pack`
 transform

---
 .../Linalg/TransformOps/LinalgTransformOps.td |  3 +-
 .../Dialect/Linalg/Transforms/Transforms.h|  2 +-
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 69 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 20 ++
 4 files changed, 70 insertions(+), 24 deletions(-)

diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 77ed9db5e71bd1..4abd3740b57105 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -498,7 +498,8 @@ def LowerPackOp : Op:$target);
   let results = (outs Transform_ConcreteOpType<"tensor.pad">:$pad_op,
-  
Transform_ConcreteOpType<"tensor.expand_shape">:$expand_shape_op,
+  
Type.predicate,
+   
Transform_ConcreteOpType<"tensor.reshape">.predicate]>>:$expand_shape_op,
   
Transform_ConcreteOpType<"linalg.transpose">:$transpose_op);
   let assemblyFormat = [{
 $target attr-dict `:` functional-type(operands, results)
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index a848d12fbbb50e..344e801835ccc9 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;
   linalg::TransposeOp transposeOp;
 };
 
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 9d230e2c2e5749..359274866748fc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -218,21 +218,11 @@ struct PackedOperandsDimList {
 
 FailureOr linalg::lowerPack(RewriterBase ,
  tensor::PackOp packOp) {
-  // 1. Filter out NYI cases.
-  auto packedTensorType =
-  cast(packOp->getResultTypes().front());
-  if (llvm::any_of(packOp.getStaticInnerTiles(),
-   [](int64_t size) { return ShapedType::isDynamic(size); })) {
-return rewriter.notifyMatchFailure(
-packOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
-
   Location loc = packOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(packOp);
 
-  // 2. Compute the permutation vector to shuffle packed shape into the shape
+  // 1. Compute the permutation vector to shuffle packed shape into the shape.
   // before any outer or inner permutations have been applied. The permutation
   // can be obtained from two permutations:
   //   a) Compute the permutation vector to move the last `numPackedDims` into
@@ -240,6 +230,8 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   //   b) Compute the permutation vector to move outer dims if the pack op
   //  has outer_dims_perm.
   // Apply (b) permutation on (a) permutation to get the final permutation.
+  auto packedTensorType =
+  cast(packOp->getResultTypes().front());
   int64_t numPackedDims = packOp.getInnerDimsPos().size();
   int64_t packedRank = packedTensorType.getRank();
   auto lastDims = llvm::to_vector(
@@ -259,12 +251,12 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   SmallVector packedToStripMinedShapePerm = innerPositionsPerm;
   applyPermutationToVector(packedToStripMinedShapePerm, outerPositionPerm);
 
-  // 3. Compute the stripMinedShape: this is the packed shape before any outer
+  // 2. Compute the stripMinedShape: this is the packed shape before any outer.
   // or inner permutations have been applied.
   SmallVector stripMinedShape(packedTensorType.getShape());
   applyPermutationToVector(stripMinedShape, packedToStripMinedShapePerm);
 
-  // 4. Pad the source of packOp to a shape we can expand into stripMinedShape.
+  // 3. Pad the source of packOp to a shape we can expand into stripMinedShape.
   SmallVector lows(packOp.getSourceRank(),
  rewriter.getIndexAttr(0));
   SmallVector highs(packOp.getSourceRank(),
@@ -351,24 +343,57 @@ FailureOr linalg::lowerPack(RewriterBase 
,
  /*transposeOp=*/nullptr};
 }
   }
-  // 5. Expand from the padded result to the stripMinedShape.
-  auto reshapeOp = rewriter.create(
-  loc,
-  RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape),
-  padOp.getResult(), 

[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (hstk30-hw)


Changes

Fix https://github.com/llvm/llvm-project/issues/75943

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaStmt.cpp (+1-3) 
- (added) clang/test/Sema/switch-default-template.cpp (+27) 


``diff
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 63348d27a8c94a..adc2055ec4e659 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,9 +1327,6 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
-  if (!TheDefaultStmt)
-Diag(SwitchLoc, diag::warn_switch_default);
-
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
@@ -1344,6 +1341,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
   assert(!HasConstantCond ||
  (ConstantCondValue.getBitWidth() == CondWidth &&
   ConstantCondValue.isSigned() == CondIsSigned));
+  Diag(SwitchLoc, diag::warn_switch_default);
 }
 bool ShouldCheckConstantCond = HasConstantCond;
 
diff --git a/clang/test/Sema/switch-default-template.cpp 
b/clang/test/Sema/switch-default-template.cpp
new file mode 100644
index 00..c671164bd785b0
--- /dev/null
+++ b/clang/test/Sema/switch-default-template.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wswitch-default %s
+
+template
+int f1(Index i)
+{
+  switch (i) {  // expected-warning {{'switch' missing 'default' 
label}}
+case 0: return 0;
+case 1: return 1;
+  }
+  return 0;
+}
+
+template
+int f2(Index i)
+{
+  switch (i) {// no-warning
+case 0: return 0;
+case 1: return 1;
+default: return 2;
+  }
+  return 0;
+}
+
+int main() {
+  return f1(1);   // expected-note {{in instantiation of function template 
specialization 'f1' requested here}}
+}
+

``




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


[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread via cfe-commits

https://github.com/hstk30-hw created 
https://github.com/llvm/llvm-project/pull/76007

Fix https://github.com/llvm/llvm-project/issues/75943

>From c3d5ac42726c49fd7036972042eb70d3e5dc01a6 Mon Sep 17 00:00:00 2001
From: hstk-hw 
Date: Wed, 20 Dec 2023 12:26:15 +0800
Subject: [PATCH] fix: fix Wswitch-default bad warning in template

---
 clang/lib/Sema/SemaStmt.cpp |  4 +--
 clang/test/Sema/switch-default-template.cpp | 27 +
 2 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/switch-default-template.cpp

diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 63348d27a8c94a..adc2055ec4e659 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,9 +1327,6 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
-  if (!TheDefaultStmt)
-Diag(SwitchLoc, diag::warn_switch_default);
-
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
@@ -1344,6 +1341,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
   assert(!HasConstantCond ||
  (ConstantCondValue.getBitWidth() == CondWidth &&
   ConstantCondValue.isSigned() == CondIsSigned));
+  Diag(SwitchLoc, diag::warn_switch_default);
 }
 bool ShouldCheckConstantCond = HasConstantCond;
 
diff --git a/clang/test/Sema/switch-default-template.cpp 
b/clang/test/Sema/switch-default-template.cpp
new file mode 100644
index 00..c671164bd785b0
--- /dev/null
+++ b/clang/test/Sema/switch-default-template.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wswitch-default %s
+
+template
+int f1(Index i)
+{
+  switch (i) {  // expected-warning {{'switch' missing 'default' 
label}}
+case 0: return 0;
+case 1: return 1;
+  }
+  return 0;
+}
+
+template
+int f2(Index i)
+{
+  switch (i) {// no-warning
+case 0: return 0;
+case 1: return 1;
+default: return 2;
+  }
+  return 0;
+}
+
+int main() {
+  return f1(1);   // expected-note {{in instantiation of function template 
specialization 'f1' requested here}}
+}
+

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


[mlir] [llvm] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/76003

>From 860a2f794bdf12ff1f08d4802570757e805264b0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Mon, 18 Dec 2023 15:53:41 -0600
Subject: [PATCH 1/5] [mlir][Linalg] Support dynamic sizes in `lower_pack`
 transform

---
 .../Linalg/TransformOps/LinalgTransformOps.td |  3 +-
 .../Dialect/Linalg/Transforms/Transforms.h|  2 +-
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 69 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 20 ++
 4 files changed, 70 insertions(+), 24 deletions(-)

diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 77ed9db5e71bd1..4abd3740b57105 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -498,7 +498,8 @@ def LowerPackOp : Op:$target);
   let results = (outs Transform_ConcreteOpType<"tensor.pad">:$pad_op,
-  
Transform_ConcreteOpType<"tensor.expand_shape">:$expand_shape_op,
+  
Type.predicate,
+   
Transform_ConcreteOpType<"tensor.reshape">.predicate]>>:$expand_shape_op,
   
Transform_ConcreteOpType<"linalg.transpose">:$transpose_op);
   let assemblyFormat = [{
 $target attr-dict `:` functional-type(operands, results)
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index a848d12fbbb50e..344e801835ccc9 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;
   linalg::TransposeOp transposeOp;
 };
 
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 9d230e2c2e5749..359274866748fc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -218,21 +218,11 @@ struct PackedOperandsDimList {
 
 FailureOr linalg::lowerPack(RewriterBase ,
  tensor::PackOp packOp) {
-  // 1. Filter out NYI cases.
-  auto packedTensorType =
-  cast(packOp->getResultTypes().front());
-  if (llvm::any_of(packOp.getStaticInnerTiles(),
-   [](int64_t size) { return ShapedType::isDynamic(size); })) {
-return rewriter.notifyMatchFailure(
-packOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
-
   Location loc = packOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(packOp);
 
-  // 2. Compute the permutation vector to shuffle packed shape into the shape
+  // 1. Compute the permutation vector to shuffle packed shape into the shape.
   // before any outer or inner permutations have been applied. The permutation
   // can be obtained from two permutations:
   //   a) Compute the permutation vector to move the last `numPackedDims` into
@@ -240,6 +230,8 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   //   b) Compute the permutation vector to move outer dims if the pack op
   //  has outer_dims_perm.
   // Apply (b) permutation on (a) permutation to get the final permutation.
+  auto packedTensorType =
+  cast(packOp->getResultTypes().front());
   int64_t numPackedDims = packOp.getInnerDimsPos().size();
   int64_t packedRank = packedTensorType.getRank();
   auto lastDims = llvm::to_vector(
@@ -259,12 +251,12 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   SmallVector packedToStripMinedShapePerm = innerPositionsPerm;
   applyPermutationToVector(packedToStripMinedShapePerm, outerPositionPerm);
 
-  // 3. Compute the stripMinedShape: this is the packed shape before any outer
+  // 2. Compute the stripMinedShape: this is the packed shape before any outer.
   // or inner permutations have been applied.
   SmallVector stripMinedShape(packedTensorType.getShape());
   applyPermutationToVector(stripMinedShape, packedToStripMinedShapePerm);
 
-  // 4. Pad the source of packOp to a shape we can expand into stripMinedShape.
+  // 3. Pad the source of packOp to a shape we can expand into stripMinedShape.
   SmallVector lows(packOp.getSourceRank(),
  rewriter.getIndexAttr(0));
   SmallVector highs(packOp.getSourceRank(),
@@ -351,24 +343,57 @@ FailureOr linalg::lowerPack(RewriterBase 
,
  /*transposeOp=*/nullptr};
 }
   }
-  // 5. Expand from the padded result to the stripMinedShape.
-  auto reshapeOp = rewriter.create(
-  loc,
-  RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape),
-  padOp.getResult(), 

[libunwind] [lldb] [llvm] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] Reland the reland "[PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-

2023-12-19 Thread Mingming Liu via cfe-commits

minglotus-6 wrote:

And pushed https://github.com/llvm/llvm-project/pull/76005 to require 64-bit 
systems for IR test. Raw profile reader swaps byte orders properly so 
`REQUIRES: host-byteorder-little-endian` looks actually unnecessary but will 
keep it fwiw for now.

I feel sorry for dance around but figured fix forwards of test requirements is 
much faster than getting various machines and setting up environments there.. 
Will monitor the build-bots .

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


[llvm] [clang] Recommit [RISCV] Update the interface of sifive vqmaccqoq (#74284) (PR #75768)

2023-12-19 Thread Brandon Wu via cfe-commits


@@ -121,38 +121,36 @@ entry:
 declare  
@llvm.riscv.sf.vqmaccus.4x8x4.nxv16i32.nxv8i8.nxv64i8(
   ,
   ,
-  ,
+  ,
   iXLen, iXLen);
 
-define  @intrinsic_vqmaccus_4x8x4_tu_i32m8( %0,  %1,  %2, iXLen %3) nounwind {
+define  @intrinsic_vqmaccus_4x8x4_tu_i32m8( %0,  %1,  %2, iXLen %3) nounwind {
 ; CHECK-LABEL: intrinsic_vqmaccus_4x8x4_tu_i32m8:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:vl8r.v v24, (a0)
-; CHECK-NEXT:vsetvli zero, a1, e8, m1, tu, ma
-; CHECK-NEXT:sf.vqmaccus.4x8x4 v8, v16, v24
+; CHECK-NEXT:vsetvli zero, a0, e8, m1, tu, ma
+; CHECK-NEXT:sf.vqmaccus.4x8x4 v8, v16, v20
 ; CHECK-NEXT:ret
 entry:
   %a = call  
@llvm.riscv.sf.vqmaccus.4x8x4.nxv16i32.nxv8i8.nxv64i8(
  %0,
  %1,
- %2,
+ %2,
 iXLen %3, iXLen 2)
 
   ret  %a
 }
 
-define  @intrinsic_vqmaccus_4x8x4_ta_i32m8( %0,  %1,  %2, iXLen %3) nounwind {
+define  @intrinsic_vqmaccus_4x8x4_ta_i32m8( %0,  %1,  %2, iXLen %3) nounwind {
 ; CHECK-LABEL: intrinsic_vqmaccus_4x8x4_ta_i32m8:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:vl8r.v v24, (a0)
-; CHECK-NEXT:vsetvli zero, a1, e8, m1, ta, ma
-; CHECK-NEXT:sf.vqmaccus.4x8x4 v8, v16, v24
+; CHECK-NEXT:vsetvli zero, a0, e8, m1, ta, ma

4vtomat wrote:

Updated in this [commit](https://github.com/llvm/llvm-project/pull/76006)!

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


[llvm] [clang] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Craig Topper via cfe-commits

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


[llvm] [clang] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Craig Topper via cfe-commits

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


[llvm] [clang] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Craig Topper via cfe-commits

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


[llvm] [clang] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Craig Topper via cfe-commits

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


[clang] [llvm] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Craig Topper via cfe-commits


@@ -222,6 +222,11 @@
 // MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
 // MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-p450 | FileCheck 
-check-prefix=MCPU-SIFIVE-P450 %s
+// MCPU-SIFIVE-P450: "-nostdsysteminc" "-target-cpu" "sifive-p450"
+// MCPU-SIFIVE-P450-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+c" 
"-target-feature" "+zicbom" "-target-feature" "+zicbop" "-target-feature" 
"+zicboz" "-target-feature" "+zicsr" "-target-feature" "+zifencei" 
"-target-feature" "+zihintntl" "-target-feature" "+zihintpause" 
"-target-feature" "+zihpm" "-target-feature" "+zfhmin" "-target-feature" "+zba" 
"-target-feature" "+zbb" "-target-feature" "+zbs" "-target-feature" "-

topperc wrote:

The `"-"` is to make sure we test every positive feature. There are only 
negative features from there on.

I don't know how to add line breaks while making sure there are no 
target-features in the output that aren't being checked. The -SAME checks used 
on other CPUs allow things to be missed.

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


[clang] [lldb] [libunwind] [libc] [clang-tools-extra] [compiler-rt] [llvm] [flang] Reland the reland "[PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-

2023-12-19 Thread Mingming Liu via cfe-commits

minglotus-6 wrote:

> I'm seeing spurious failures from big-endian systems. I'll revert and 
> investigate a fix.

I ended up sending a fix forward in 
https://github.com/llvm/llvm-project/pull/76001 . Will monitor the build-bots.

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


[clang] [libc] [clang-tools-extra] [compiler-rt] [llvm] [mlir] [flang] [mlir][Linalg] Support dynamic shapes in `lower_pack` transform (PR #76003)

2023-12-19 Thread via cfe-commits

https://github.com/srcarroll created 
https://github.com/llvm/llvm-project/pull/76003

When an expanded dim is not factorable, emit a `tensor.reshape` instead of a 
`tensor.expand_shape`

>From 860a2f794bdf12ff1f08d4802570757e805264b0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Mon, 18 Dec 2023 15:53:41 -0600
Subject: [PATCH 1/4] [mlir][Linalg] Support dynamic sizes in `lower_pack`
 transform

---
 .../Linalg/TransformOps/LinalgTransformOps.td |  3 +-
 .../Dialect/Linalg/Transforms/Transforms.h|  2 +-
 .../Dialect/Linalg/Transforms/Transforms.cpp  | 69 +--
 .../Dialect/Linalg/transform-lower-pack.mlir  | 20 ++
 4 files changed, 70 insertions(+), 24 deletions(-)

diff --git 
a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 77ed9db5e71bd1..4abd3740b57105 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -498,7 +498,8 @@ def LowerPackOp : Op:$target);
   let results = (outs Transform_ConcreteOpType<"tensor.pad">:$pad_op,
-  
Transform_ConcreteOpType<"tensor.expand_shape">:$expand_shape_op,
+  
Type.predicate,
+   
Transform_ConcreteOpType<"tensor.reshape">.predicate]>>:$expand_shape_op,
   
Transform_ConcreteOpType<"linalg.transpose">:$transpose_op);
   let assemblyFormat = [{
 $target attr-dict `:` functional-type(operands, results)
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index a848d12fbbb50e..344e801835ccc9 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -1089,7 +1089,7 @@ collapseOpIterationDims(LinalgType op,
 
 struct LowerPackResult {
   tensor::PadOp padOp;
-  tensor::ExpandShapeOp expandShapeOp;
+  Operation *expandShapeOp;
   linalg::TransposeOp transposeOp;
 };
 
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 9d230e2c2e5749..359274866748fc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -218,21 +218,11 @@ struct PackedOperandsDimList {
 
 FailureOr linalg::lowerPack(RewriterBase ,
  tensor::PackOp packOp) {
-  // 1. Filter out NYI cases.
-  auto packedTensorType =
-  cast(packOp->getResultTypes().front());
-  if (llvm::any_of(packOp.getStaticInnerTiles(),
-   [](int64_t size) { return ShapedType::isDynamic(size); })) {
-return rewriter.notifyMatchFailure(
-packOp,
-"non-static shape NYI, needs a more powerful tensor.expand_shape op");
-  }
-
   Location loc = packOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(packOp);
 
-  // 2. Compute the permutation vector to shuffle packed shape into the shape
+  // 1. Compute the permutation vector to shuffle packed shape into the shape.
   // before any outer or inner permutations have been applied. The permutation
   // can be obtained from two permutations:
   //   a) Compute the permutation vector to move the last `numPackedDims` into
@@ -240,6 +230,8 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   //   b) Compute the permutation vector to move outer dims if the pack op
   //  has outer_dims_perm.
   // Apply (b) permutation on (a) permutation to get the final permutation.
+  auto packedTensorType =
+  cast(packOp->getResultTypes().front());
   int64_t numPackedDims = packOp.getInnerDimsPos().size();
   int64_t packedRank = packedTensorType.getRank();
   auto lastDims = llvm::to_vector(
@@ -259,12 +251,12 @@ FailureOr linalg::lowerPack(RewriterBase 
,
   SmallVector packedToStripMinedShapePerm = innerPositionsPerm;
   applyPermutationToVector(packedToStripMinedShapePerm, outerPositionPerm);
 
-  // 3. Compute the stripMinedShape: this is the packed shape before any outer
+  // 2. Compute the stripMinedShape: this is the packed shape before any outer.
   // or inner permutations have been applied.
   SmallVector stripMinedShape(packedTensorType.getShape());
   applyPermutationToVector(stripMinedShape, packedToStripMinedShapePerm);
 
-  // 4. Pad the source of packOp to a shape we can expand into stripMinedShape.
+  // 3. Pad the source of packOp to a shape we can expand into stripMinedShape.
   SmallVector lows(packOp.getSourceRank(),
  rewriter.getIndexAttr(0));
   SmallVector highs(packOp.getSourceRank(),
@@ -351,24 +343,57 @@ FailureOr linalg::lowerPack(RewriterBase 
,
  /*transposeOp=*/nullptr};
 }
   }
-  // 5. Expand from the padded result to the stripMinedShape.
-  auto reshapeOp = rewriter.create(
-  loc,
-  

[clang] [Flang] Add fortran runtime libraries to AIX driver (PR #75921)

2023-12-19 Thread via cfe-commits

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

LG.

Please wait for a day or two to see if other reviewers have any comments. 
Thanks.

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


[clang] [clang-tools-extra] [Sema][clangd] add noexcept to override functions during code completion (PR #75937)

2023-12-19 Thread Sirui Mu via cfe-commits

Lancern wrote:

> The place you're patching is not only specific to "completing override 
> functions", but handles all completion strings involving function 
> declarations.

OK. I'll move the changes to the 
`CodeCompletionResult::createCodeCompletionStringForOverride` function which 
seems like a more appropriate place for this patch to me.

> Bonus: It appears that neither gcc nor clang implements a provision change 
> from [CWG1351](https://cplusplus.github.io/CWG/issues/1351.html),

Maybe this deserves a new issue for clang Sema?

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


[clang] [Sema] Provide `-fno-/-fvisibility-global-new-delete` option (PR #75364)

2023-12-19 Thread Roland McGrath via cfe-commits

frobtech wrote:

The meaning that we want to make clear is that this toggles the special 
behavior of forcing the visibility of these symbols despite all the other 
mechanisms that usually control visibility for all other symbols.  So perhaps 
`-fforced-global-new-delete-visibility` (or even 
`-fforced-global-new-delete-visibility=default`) describes the status quo ante, 
and `-fno-forced-global-new-delete-visibility` describes the new opt-in wherein 
these symbols are not treated differently than others. (The `=...` variant of 
the positive form would permit forcing to a different visibility than 
`default`, though I'm not sure there's a real need for that capability since in 
`-fno-forced-...` state the usual pragmas et al can arrange for that.)



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


[clang] [libc] [flang] [lldb] [clang-tools-extra] [libunwind] [llvm] [compiler-rt] Reland the reland "[PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-

2023-12-19 Thread Mingming Liu via cfe-commits

minglotus-6 wrote:

I'm seeing spurious failures from big-endian systems. I'll revert and 
investigate a fix.

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


[llvm] [flang] [lldb] [clang] [libunwind] [compiler-rt] [libcxx] [libc] [lld] Remove wrong float-128 extension for CLang (PR #75909)

2023-12-19 Thread Igor Popov via cfe-commits

https://github.com/silver-popov updated 
https://github.com/llvm/llvm-project/pull/75909

>From 00edd52687d6e15f3453912b5dbf236714a386f9 Mon Sep 17 00:00:00 2001
From: Igor Popov 
Date: Tue, 19 Dec 2023 11:43:45 +0300
Subject: [PATCH] Remove wrong float-128 extension for CLang

---
 libc/src/__support/macros/properties/float.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libc/src/__support/macros/properties/float.h 
b/libc/src/__support/macros/properties/float.h
index 756579024cad8b..1953a6b6ef6250 100644
--- a/libc/src/__support/macros/properties/float.h
+++ b/libc/src/__support/macros/properties/float.h
@@ -59,11 +59,6 @@ using float16 = _Float16;
  defined(LIBC_TARGET_ARCH_IS_X86_64))
 #define LIBC_COMPILER_HAS_C23_FLOAT128
 #endif
-#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 500)) &&  
\
-(defined(LIBC_TARGET_ARCH_IS_X86_64) &&
\
- !defined(LIBC_TARGET_OS_IS_FUCHSIA))
-#define LIBC_COMPILER_HAS_FLOAT128_EXTENSION
-#endif
 
 #if defined(LIBC_COMPILER_HAS_C23_FLOAT128)
 using float128 = _Float128;

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


[llvm] [clang] [clang-tools-extra] [ISel] Add pattern matching for depositing subreg value (PR #75978)

2023-12-19 Thread David Li via cfe-commits


@@ -561,6 +561,16 @@ def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins 
i64mem:$src),
  [(set GR64:$dst, (load addr:$src))]>;
 }
 
+def : Pat<(or (and GR64:$dst, -256), 

david-xl wrote:

Sorry I misunderstood. Fixed now.

Also updated the test. Note that sub16_32 case does not yet produce the 
optimized code for i386 because the pattern change (due to arg passing).

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


[clang] [llvm] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Wang Pengcheng via cfe-commits


@@ -222,6 +222,11 @@
 // MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
 // MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-p450 | FileCheck 
-check-prefix=MCPU-SIFIVE-P450 %s
+// MCPU-SIFIVE-P450: "-nostdsysteminc" "-target-cpu" "sifive-p450"
+// MCPU-SIFIVE-P450-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+c" 
"-target-feature" "+zicbom" "-target-feature" "+zicbop" "-target-feature" 
"+zicboz" "-target-feature" "+zicsr" "-target-feature" "+zifencei" 
"-target-feature" "+zihintntl" "-target-feature" "+zihintpause" 
"-target-feature" "+zihpm" "-target-feature" "+zfhmin" "-target-feature" "+zba" 
"-target-feature" "+zbb" "-target-feature" "+zbs" "-target-feature" "-

wangpc-pp wrote:

Why does this line end with `"-`? Copy/paste mistake?
And this line is too long, please add some line breaks.

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


[llvm] [clang] [RISCV] Add sifive-p450 CPU. (PR #75760)

2023-12-19 Thread Wang Pengcheng via cfe-commits


@@ -222,6 +222,11 @@
 // MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
 // MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-p450 | FileCheck 
-check-prefix=MCPU-SIFIVE-P450 %s

wangpc-pp wrote:

Are there any `experimental` extensions?

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Max Winkler via cfe-commits

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Max Winkler via cfe-commits


@@ -580,8 +580,7 @@ _storebe_i64(void * __P, long long __D) {
 #include 
 #endif
 
-/* Some intrinsics inside adxintrin.h are available only on processors with 
ADX,
- * whereas others are also available at all times. */

MaxEW707 wrote:

Confirmed that Intel ADX is supported on Ryzen.

I checked the Sony PS5 compiler on my work pc and confirmed that `__ADX__` is 
defined to `1` as expected for the PS5 Ryzen chips so we won't break them.
I check the Sony PS4 compiler on my work pc and confirmed that `__ADX__` is not 
defined as expected for the PS4 Jaguar chips.

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


[clang] [clang-tools-extra] [Sema][clangd] add noexcept to override functions during code completion (PR #75937)

2023-12-19 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Bonus: It appears that neither gcc nor clang implements a provision change from 
[CWG1351](https://cplusplus.github.io/CWG/issues/1351.html),

> [except.spec]p4
> ..., **unless the overriding function is defined as deleted.**

giving errors on the following code.

```cpp
struct B {
  virtual void h() noexcept = delete;
};

struct D: B {
  void h() = delete;// Should be OK
};

int main() {
  D();
}
```
https://cpp2.godbolt.org/z/zvY17G6jr

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Max Winkler via cfe-commits

https://github.com/MaxEW707 updated 
https://github.com/llvm/llvm-project/pull/75992

>From b6ea2ffe22f414ec79cd9ccd7e47c7b063583bcc Mon Sep 17 00:00:00 2001
From: MaxEW707 <82551778+maxew...@users.noreply.github.com>
Date: Tue, 19 Dec 2023 19:55:21 -0500
Subject: [PATCH 1/4] Move Intel ADC instrinsics into a separate file

---
 clang/lib/Headers/CMakeLists.txt |   1 +
 clang/lib/Headers/adcintrin.h| 160 +++
 clang/lib/Headers/adxintrin.h| 127 +---
 clang/lib/Headers/immintrin.h|   3 +-
 4 files changed, 163 insertions(+), 128 deletions(-)
 create mode 100644 clang/lib/Headers/adcintrin.h

diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index f8fdd402777e48..735e4e4e3be89b 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -139,6 +139,7 @@ set(webassembly_files
 
 set(x86_files
 # Intrinsics
+  adcintrin.h
   adxintrin.h
   ammintrin.h
   amxcomplexintrin.h
diff --git a/clang/lib/Headers/adcintrin.h b/clang/lib/Headers/adcintrin.h
new file mode 100644
index 00..b43322f22297d7
--- /dev/null
+++ b/clang/lib/Headers/adcintrin.h
@@ -0,0 +1,160 @@
+/*=== adxintrin.h - ADX intrinsics -===
+ *
+ * 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 __ADCINTRIN_H
+#define __ADCINTRIN_H
+
+#if !defined(__i386__) && !defined(__x86_64__)
+#error "This header is only meant to be used on x86 and x64 architecture"
+#endif
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+/* Use C++ inline semantics in C++, GNU inline for C mode. */
+#if defined(__cplusplus)
+#define __INLINE __inline
+#else
+#define __INLINE static __inline
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated
+///by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory
+///at \a __p, and returns the 8-bit carry-out (carry flag).
+///
+/// \code{.operation}
+/// temp := (__cf == 0) ? 0 : 1
+/// Store32(__p, __x + __y + temp)
+/// result := CF
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c ADC instruction.
+///
+/// \param __cf
+///The 8-bit unsigned carry flag; any non-zero value indicates carry.
+/// \param __x
+///A 32-bit unsigned addend.
+/// \param __y
+///A 32-bit unsigned addend.
+/// \param __p
+///Pointer to memory for storing the sum.
+/// \returns The 8-bit unsigned carry-out value.
+__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarry_u32(unsigned char __cf,
+unsigned int __x,
+unsigned int __y,
+unsigned int *__p) {
+  return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
+}
+
+/// Adds unsigned 32-bit integer \a __y to 0 or 1 as indicated by the carry
+///flag \a __cf, and subtracts the result from unsigned 32-bit integer
+///\a __x. Stores the unsigned 32-bit difference in the memory at \a __p,
+///and returns the 8-bit carry-out (carry or overflow flag).
+///
+/// \code{.operation}
+/// temp := (__cf == 0) ? 0 : 1
+/// Store32(__p, __x - (__y + temp))
+/// result := CF
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c SBB instruction.
+///
+/// \param __cf
+///The 8-bit unsigned carry flag; any non-zero value indicates carry.
+/// \param __x
+///The 32-bit unsigned minuend.
+/// \param __y
+///The 32-bit unsigned subtrahend.
+/// \param __p
+///Pointer to memory for storing the difference.
+/// \returns The 8-bit unsigned carry-out value.
+__INLINE unsigned char __DEFAULT_FN_ATTRS _subborrow_u32(unsigned char __cf,
+ unsigned int __x,
+ unsigned int __y,
+ unsigned int *__p) {
+  return __builtin_ia32_subborrow_u32(__cf, __x, __y, __p);
+}
+
+#ifdef __x86_64__
+/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated
+///by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory
+///at \a __p, and returns the 8-bit carry-out (carry flag).
+///
+/// \code{.operation}
+/// temp := (__cf == 0) ? 0 : 1
+/// Store64(__p, __x + __y + temp)
+/// result := CF
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c ADC instruction.
+///
+/// \param __cf
+///The 8-bit unsigned carry flag; any 

[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Phoebe Wang via cfe-commits


@@ -580,8 +580,7 @@ _storebe_i64(void * __P, long long __D) {
 #include 
 #endif
 
-/* Some intrinsics inside adxintrin.h are available only on processors with 
ADX,
- * whereas others are also available at all times. */

phoebewang wrote:

I think comment is good. Without it, people may wonder anything special here.
For ADX, I guess the reason is it mixed with adc intrinsics previously, so 
cannot be guarded. And we should be free to do it now.

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Max Winkler via cfe-commits

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


[clang] [Clang][Wswitch-default] Warning for enum even completely covered the cases (PR #75900)

2023-12-19 Thread dong jianqiang via cfe-commits

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


[clang] e5eef6e - [Clang][Wswitch-default] Warning for enum even completely covered the cases (#75900)

2023-12-19 Thread via cfe-commits

Author: hstk30-hw
Date: 2023-12-20T10:26:27+08:00
New Revision: e5eef6e24f06dfffc77cffc6963e8543f9d223bd

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

LOG: [Clang][Wswitch-default] Warning for enum even completely covered the 
cases (#75900)

 Adding a test case that this warns even for completely covered switches.

Added: 


Modified: 
clang/test/Sema/switch-default.c

Removed: 




diff  --git a/clang/test/Sema/switch-default.c 
b/clang/test/Sema/switch-default.c
index 854b561b37c48e..342a97ee68b1e2 100644
--- a/clang/test/Sema/switch-default.c
+++ b/clang/test/Sema/switch-default.c
@@ -15,3 +15,14 @@ int f2(int a) {
   }
   return a;
 }
+
+// Warn even completely covered Enum cases(GCC compatibility).
+enum E { A, B };
+enum E check_enum(enum E e) {
+  switch (e) {// expected-warning {{'switch' missing 'default' 
label}}
+case A: break;
+case B: break;
+  }
+  return e;
+}
+



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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-12-19 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

Yeah, it'll be much better if we had that feature.

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Max Winkler via cfe-commits

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Max Winkler via cfe-commits

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


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-19 Thread Max Winkler via cfe-commits

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


  1   2   3   4   5   >