[PATCH] D140895: [1/7][Clang][RISCV] Remove default tail-undisturbed for vector reduction intrinsics

2023-01-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140895/new/

https://reviews.llvm.org/D140895

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


[PATCH] D141215: [clang-repl][WIP] Implement pretty printing

2023-01-12 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 488502.
junaire added a comment.

Introduce `Value` class


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141215/new/

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/PrettyPrint.cpp
  clang/lib/Interpreter/Value.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Interpreter/pretty-print.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -18,6 +19,8 @@
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h" // llvm_shutdown
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
@@ -65,6 +68,18 @@
   return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
+static void DeclareMagicFunctions(clang::Interpreter &Interp) {
+  llvm::ArrayRef MagicFunctions = {
+  "void __InterpreterPrettyPrint(void*, char);",
+  "void __InterpreterPrettyPrint(void*, int);",
+  "void __InterpreterPrettyPrint(void*, float);",
+  "void __InterpreterPrettyPrint(void*, double);",
+  };
+  for (llvm::StringRef Function : MagicFunctions) {
+llvm::cantFail(Interp.ParseAndExecute(Function));
+  }
+}
+
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
@@ -109,13 +124,18 @@
 
   bool HasError = false;
 
+  DeclareMagicFunctions(*Interp);
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
 while (llvm::Optional Line = LE.readLine()) {
-  if (*Line == R"(%quit)")
+  llvm::StringRef Code = *Line;
+  if (Code.empty()) {
+continue;
+  }
+  if (Code == R"(%quit)")
 break;
-  if (*Line == R"(%undo)") {
+  if (Code == R"(%undo)") {
 if (auto Err = Interp->Undo()) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   HasError = true;
@@ -123,7 +143,7 @@
 continue;
   }
 
-  if (auto Err = Interp->ParseAndExecute(*Line)) {
+  if (auto Err = Interp->ParseAndExecute(Code)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 HasError = true;
   }
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -12,6 +12,7 @@
   )
 
 clang_target_link_libraries(clang-repl PRIVATE
+  clangAST
   clangBasic
   clangFrontend
   clangInterpreter
Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+int x = 42;
+x
+// CHECK: [int]: 42
+x + 42
+// CHECK-NEXT: [int]: 84
+%quit
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -153,10 +153,20 @@
   return true;
 }
 
-bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed) {
+bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed,
+  bool IsTopExpr) {
   if (TryConsumeToken(tok::semi))
 return false;
 
+  // If this is in the incremental C++ mode, then it means we need to pretty
+  // print this expression. Thus, let's pretend we have this semi and continue
+  // parsing.
+  if (PP.isIncrementalProcessingEnabled() && IsTopExpr &&
+  DiagID == diag::err_expected_semi_after_expr) {
+setPrettyPrintMode();
+return false;
+  }
+
   if (Tok.is(tok::code_completion)) {
 handleUnexpectedCodeCompletionToken();
 return false;
Index: clang/lib/Parse/ParseStmt.cpp
=

[PATCH] D141572: [C++] [Coroutines] Deprecates the '-fcoroutines-ts' flag

2023-01-12 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: aaron.ballman, ldionne.
ChuanqiXu added a project: clang-language-wg.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

According to the discussion of 
https://github.com/llvm/llvm-project/issues/59110, we should deprecate the use 
of `-fcoroutines-ts` in LLVM16 and remove it in LLVM17.

I've tested this with libcxx and it is fine since we disabled all the warnings 
for the test of . See 
https://github.com/llvm/llvm-project/blob/cefa5cefdce2d5090002c3116403f7e5ca5700b9/libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg#L7-L8


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141572

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/coroutines.cpp


Index: clang/test/Driver/coroutines.cpp
===
--- clang/test/Driver/coroutines.cpp
+++ clang/test/Driver/coroutines.cpp
@@ -5,5 +5,6 @@
 
 // RUN: %clang -fcoroutines-ts -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-HAS-CORO  %s
 // RUN: %clang -fno-coroutines-ts -fcoroutines-ts -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-HAS-CORO %s
+// CHECK-HAS-CORO: the "-fcoroutines-ts" flag is deprecated and it will be 
removed in LLVM17; use C++20 Coroutines instead
 // CHECK-HAS-CORO: -fcoroutines-ts
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6449,6 +6449,7 @@
   if (Args.hasFlag(options::OPT_fcoroutines_ts, options::OPT_fno_coroutines_ts,
false) &&
   types::isCXX(InputType)) {
+D.Diag(diag::warn_deperecated_fcoroutines_ts_flag);
 CmdArgs.push_back("-fcoroutines-ts");
   }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -627,6 +627,11 @@
   "command line to use the libc++ standard library instead">,
   InGroup>;
 
+def warn_deperecated_fcoroutines_ts_flag : Warning<
+  "the \"-fcoroutines-ts\" flag is deprecated and it will be removed in 
LLVM17; "
+  "use C++20 Coroutines instead">,
+  InGroup;
+
 def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -543,6 +543,8 @@
 ---
 - Clang now permits specifying ``--config=`` multiple times, to load multiple
   configuration files.
+- Clang now deprecates the ``-fcoroutines-ts`` flag and the flag will be
+  removed in LLVM17. Please use C++20 Coroutines instead.
 
 Removed Compiler Flags
 -


Index: clang/test/Driver/coroutines.cpp
===
--- clang/test/Driver/coroutines.cpp
+++ clang/test/Driver/coroutines.cpp
@@ -5,5 +5,6 @@
 
 // RUN: %clang -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CORO  %s
 // RUN: %clang -fno-coroutines-ts -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CORO %s
+// CHECK-HAS-CORO: the "-fcoroutines-ts" flag is deprecated and it will be removed in LLVM17; use C++20 Coroutines instead
 // CHECK-HAS-CORO: -fcoroutines-ts
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6449,6 +6449,7 @@
   if (Args.hasFlag(options::OPT_fcoroutines_ts, options::OPT_fno_coroutines_ts,
false) &&
   types::isCXX(InputType)) {
+D.Diag(diag::warn_deperecated_fcoroutines_ts_flag);
 CmdArgs.push_back("-fcoroutines-ts");
   }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -627,6 +627,11 @@
   "command line to use the libc++ standard library instead">,
   InGroup>;
 
+def warn_deperecated_fcoroutines_ts_flag : Warning<
+  "the \"-fcoroutines-ts\" flag is deprecated and it will be removed in LLVM17; "
+  "use C++20 Coroutines instead">,
+  InGroup;
+
 def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -543

[PATCH] D140936: [2/7][Clang][RISCV] Remove default tail-undisturbed for vslideup intrinsics

2023-01-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140936/new/

https://reviews.llvm.org/D140936

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


[PATCH] D141509: [include-mapping] Fix parsing of html_book_20190607.zip (https://en.cppreference.com/w/File:html_book_20190607.zip). Skip entries that have been added to the index (C++20 symbols), bu

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/tools/include-mapping/cppreference_parser.py:117
 def _ReadSymbolPage(path, name):
-  with open(path) as f:
-return _ParseSymbolPage(f.read(), name)
+  try:
+f = open(path)

so the input path can be invalid, pointing to a non-existing file, I'd just 
check it in the caller side, see my other comment.



Comment at: clang/tools/include-mapping/cppreference_parser.py:153
 continue
   path = os.path.join(root_dir, symbol_page_path)
   results.append((symbol_name,

I think just adding a file-existing check would work:

```
if os.path.isfile(path):
   results.append((symbol_name,
  pool.apply_async(_ReadSymbolPage, (path, symbol_name
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141509/new/

https://reviews.llvm.org/D141509

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


[PATCH] D141092: Optionally install clang-tblgen to aid cross-compiling

2023-01-12 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG706881825b24: [cmake] Optionally install clang-tblgen to aid 
cross-compiling (authored by chewi, committed by nikic).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141092/new/

https://reviews.llvm.org/D141092

Files:
  llvm/cmake/modules/TableGen.cmake


Index: llvm/cmake/modules/TableGen.cmake
===
--- llvm/cmake/modules/TableGen.cmake
+++ llvm/cmake/modules/TableGen.cmake
@@ -190,7 +190,8 @@
 endif()
   endif()
 
-  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND 
LLVM_BUILD_UTILS)
+  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND
+  (LLVM_BUILD_UTILS OR ${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS))
 set(export_arg)
 if(ADD_TABLEGEN_EXPORT)
   get_target_export_arg(${target} ${ADD_TABLEGEN_EXPORT} export_arg)


Index: llvm/cmake/modules/TableGen.cmake
===
--- llvm/cmake/modules/TableGen.cmake
+++ llvm/cmake/modules/TableGen.cmake
@@ -190,7 +190,8 @@
 endif()
   endif()
 
-  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
+  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND
+  (LLVM_BUILD_UTILS OR ${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS))
 set(export_arg)
 if(ADD_TABLEGEN_EXPORT)
   get_target_export_arg(${target} ${ADD_TABLEGEN_EXPORT} export_arg)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140809: [clang][Interp] Implement logical and/or operators

2023-01-12 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:376
+this->emitLabel(LabelTrue);
+this->emitConstBool(true, E);
+this->fallthrough(LabelEnd);

aaron.ballman wrote:
> Am I correct in understanding that the reason we don't need to emit a const 
> bool for `false` is because visiting the RHS already pushes either `true` or 
> `false` onto the stack because it's already been converted to a bool result?
Both LHS and RHS push a bool result to the stack, but the `jumpTrue`will 
`pop()` the result of the LHS, so we need to push a true again if we want to 
use it later as the result of the binary operator. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140809/new/

https://reviews.llvm.org/D140809

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


[PATCH] D141573: [WIP][1/N][Clang][RISCV][NFC] Extract common utility to RISCVVIntrinsicUtils

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141573

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -528,12 +528,8 @@
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
 
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);
 
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -980,6 +980,12 @@
   return NewPrototype;
 }
 
+llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
+  return {
+  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
+  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+}
+
 llvm::SmallVector
 RVVIntrinsic::getSupportedMaskedPolicies(bool HasTailPolicy,
  bool HasMaskPolicy) {
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -204,13 +204,9 @@
 
 bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
 bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
-llvm::SmallVector SupportedMaskedPolicies =
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
+SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(Record.HasTailPolicy,
  Record.HasMaskPolicy);
 
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -475,6 +475,8 @@
   bool IsMasked, bool HasMaskedOffOperand, bool HasVL,
   unsigned NF, PolicyScheme DefaultScheme,
   Policy PolicyAttrs);
+
+  static llvm::SmallVector getSupportedUnMaskedPolicies();
   static llvm::SmallVector
   getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy);
 


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -528,12 +528,8 @@
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
 
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);

[PATCH] D141574: [WIP][2/N][Clang][RISCV][NFC] Rename Policy::IsPolicyNone to IsUnspecifed

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The original naming is inaccurate. An RVV intrinsic always comes with
a corresponding policy behavior. When the policy is unspecified for an
intrinsic, its policy behavior should be it's default assumption.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141574

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,9 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isPolicyNonePolicy()) {
+  if (PolicyAttrs.isUnspecified()) {
 if (!IsMasked) {
-  PolicyAttrs.PolicyNone = false;
+  PolicyAttrs.IsUnspecified = false;
   PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
 }
   }
@@ -1022,8 +1022,8 @@
 OverloadedName += suffix;
   };
 
-  if (PolicyAttrs.isPolicyNonePolicy()) {
-PolicyAttrs.PolicyNone = false;
+  if (PolicyAttrs.isUnspecified()) {
+PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   // FIXME: Currently _m default policy implementation is different with
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -93,7 +93,7 @@
 };
 
 struct Policy {
-  bool PolicyNone = false;
+  bool IsUnspecified = false;
   enum PolicyType {
 Undisturbed,
 Agnostic,
@@ -102,7 +102,7 @@
   PolicyType TailPolicy = Omit;
   PolicyType MaskPolicy = Omit;
   bool IntrinsicWithoutMU = false;
-  Policy() : PolicyNone(true) {}
+  Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy,
  bool _IntrinsicWithoutMU = false)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy),
@@ -150,11 +150,11 @@
 return MaskPolicy == Undisturbed && TailPolicy == Omit;
   }
 
-  bool isPolicyNonePolicy() const { return PolicyNone; }
+  bool isUnspecified() const { return IsUnspecified; }
 
   bool operator==(const Policy &Other) const {
-return PolicyNone == Other.PolicyNone && TailPolicy == Other.TailPolicy &&
-   MaskPolicy == Other.MaskPolicy &&
+return IsUnspecified == Other.IsUnspecified &&
+   TailPolicy == Other.TailPolicy && MaskPolicy == Other.MaskPolicy &&
IntrinsicWithoutMU == Other.IntrinsicWithoutMU;
   }
 
@@ -434,7 +434,7 @@
 return IntrinsicTypes;
   }
   Policy getPolicyAttrs() const {
-assert(PolicyAttrs.PolicyNone == false);
+assert(PolicyAttrs.IsUnspecified == false);
 return PolicyAttrs;
   }
   unsigned getPolicyAttrsBits() const {
@@ -444,7 +444,7 @@
 // constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3;
 // FIXME: how about value 2
 // int PolicyAttrs = TAIL_UNDISTURBED;
-assert(PolicyAttrs.PolicyNone == false);
+assert(PolicyAttrs.IsUnspecified == false);
 
 if (PolicyAttrs.isTUMAPolicy())
   return 2;


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,9 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isPolicyNonePolicy()) {
+  if (PolicyAttrs.isUnspecified()) {
 if (!IsMasked) {
-  PolicyAttrs.PolicyNone = false;
+  PolicyAttrs.IsUnspecified = false;
   PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
 }
   }
@@ -1022,8 +1022,8 @@
 OverloadedName += suffix;
   };
 
-  if (PolicyAttrs.isPolicyNonePolicy()) {
-PolicyAttrs.PolicyNone = false;
+  if (PolicyAttrs.isUnspecified()) {
+PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   // FIXME: Currently _m default policy implementation is different with
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ cla

[PATCH] D139774: [libclang] Add API to set temporary directory location

2023-01-12 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy added a subscriber: milianw.
vedgy added a comment.

In D139774#4045361 , @dblaikie wrote:

> 1. Should clang be doing something better with these temp files anyway, no 
> matter the directory they go in? (setting them for cleanup at process exit or 
> the like - I think we have such a filesystem abstraction, maybe that only 
> works on Windows? I'm not sure)

That'd be great, but appears unfeasible on GNU/Linux in case of a crash: 
https://stackoverflow.com/questions/471344/guaranteed-file-deletion-upon-program-termination-c-c

> 2. If there isn't a better general way to avoid creating temp trash that's a 
> problem, I'd have thought that KDevelop/other tools would have issues with 
> other temp files too, and want a more general solution (I'd have thought 
> changing the process's temp directory, and changing it back for user process 
> launches, would be sufficient - so it can cleanup after itself for all files, 
> not just these particular clang-created ones)

I do plan to put other temporary files KDevelop generates in the same 
session-specific temporary directory and clean it on start. But modifying 
KDevelop's temporary directory environment variable has been rejected during 
code review for good reason. As the bug this review aims to fix 
 puts it:

> setting the environment variables is problematic, because they are inherited 
> by the IDE's code and all child processes it spawns (compiler, build system 
> and user-provided executables). The IDE must then remove the temporary 
> directory environment variable from each child process where it can cause 
> undesirable behavior.



In D139774#4045460 , @MaskRay wrote:

> libclang functions like `clang_reparseTranslationUnit_Impl` call 
> `clang/lib/Frontend/ASTUnit.cpp:1397` and build the preamble with 
> `/*StoreInMemory=*/false`.
> If `StoreInMemory` is configurable (true), then you can avoid the temporary 
> file `preamble-*.pch`.
>
> `clang/lib/Frontend/ASTUnit.cpp` is used by `clang/lib/Tooling/Tooling.cpp` 
> and libclang. Personally I think an unconditional `/*StoreInMemory=*/true` is 
> fine. (The concern is slightly memory usage increase).

This is a simple and promising solution. But maybe it should be configurable. 
The `StoreInMemory` option was introduced for the benefit of //clangd//, and 
//clangd// still stores the preambles on disk by default. See D39843 
. I'm pinging another KDevelop developer who 
may know better how this should work in KDevelop: @milianw


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139774/new/

https://reviews.llvm.org/D139774

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


[PATCH] D141575: [WIP][3/N][Clang][RISCV][NFC] Clarify edge cases of RVVIntrinsic::getSupportedMaskedPolicies for clarity

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141575

Files:
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -998,16 +999,18 @@
Policy::PolicyType::Undisturbed), // TUMU
 Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // TAMU
-
-  if (HasTailPolicy)
+  if (HasTailPolicy && !HasMaskPolicy)
 return {Policy(Policy::PolicyType::Undisturbed,
Policy::PolicyType::Agnostic, true), // TUM
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
true)}; // TAM
-
-  return {
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed)}; // MU
+  if (!HasTailPolicy && HasMaskPolicy)
+return {
+Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Omit,
+   Policy::PolicyType::Undisturbed)}; // MU
+  llvm_unreachable("An RVV instruction should not be without both tail policy "
+   "and mask policy");
 }
 
 void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -998,16 +999,18 @@
Policy::PolicyType::Undisturbed), // TUMU
 Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // TAMU
-
-  if (HasTailPolicy)
+  if (HasTailPolicy && !HasMaskPolicy)
 return {Policy(Policy::PolicyType::Undisturbed,
Policy::PolicyType::Agnostic, true), // TUM
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
true)}; // TAM
-
-  return {
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed)}; // MU
+  if (!HasTailPolicy && HasMaskPolicy)
+return {
+Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Omit,
+   Policy::PolicyType::Undisturbed)}; // MU
+  llvm_unreachable("An RVV instruction should not be without both tail policy "
+   "and mask policy");
 }
 
 void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141577: [WIP][4/N][Clang][RISCV][NFC] Remove unnecessary logic under RVVIntrinsic::computeBuiltinTypes

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The logic that relies upon PolicyAttrs::IsUnspecified, which happens
both under RVV::Intrinsic::computeBuiltInTypes and
RVVIntrinsic::updateNamesAndPolicy may give the misperception that these
two functions are coupled together, but in fact they don't.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141577

Files:
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -918,12 +918,6 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isUnspecified()) {
-if (!IsMasked) {
-  PolicyAttrs.IsUnspecified = false;
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
-}
-  }
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -918,12 +918,6 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isUnspecified()) {
-if (!IsMasked) {
-  PolicyAttrs.IsUnspecified = false;
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
-}
-  }
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0a11a1b - [OpenMP] Fix a test that fails when 'libgomp' is the default library

2023-01-12 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2023-01-12T09:54:42+01:00
New Revision: 0a11a1b1868dd2ab183c4313ccbfbe126e91ca08

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

LOG: [OpenMP] Fix a test that fails when 'libgomp' is the default library

We can't do offloading with libgomp, thus the test fails. This change
explicitly chooses an OpenMP runtime library that is capable of
offloading.

This change is similar to
https://github.com/llvm/llvm-project/commit/a5098e5f27badc3ba16533418accd2e17641e4e4.

Added: 


Modified: 
clang/test/Driver/openmp-system-arch.c

Removed: 




diff  --git a/clang/test/Driver/openmp-system-arch.c 
b/clang/test/Driver/openmp-system-arch.c
index c9219234ede5..b99522269902 100644
--- a/clang/test/Driver/openmp-system-arch.c
+++ b/clang/test/Driver/openmp-system-arch.c
@@ -19,41 +19,41 @@
 // RUN: chmod +x %t/nvptx_arch_empty
 
 // case when nvptx-arch and amdgpu-arch return nothing or fails
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch=native \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch=native \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail 
--amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch=native \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch=native \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_empty 
--amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch= \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch= \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail 
--amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch= \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch= \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_empty 
--amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
 // NO-OUTPUT-ERROR: error: failed to deduce triple for target architecture 
'native'; specify the triple using '-fopenmp-targets' and '-Xopenmp-target' 
instead.
 
 // case when amdgpu-arch succeeds.
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch=native \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch=native \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_fail 
--amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=ARCH-GFX906
 // ARCH-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx906"
 
 // case when nvptx-arch succeeds.
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch=native \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch=native \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 
--amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=ARCH-SM_70
 // ARCH-SM_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" 
"sm_70"
 
 // case when both nvptx-arch and amdgpu-arch succeed.
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch=native \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch=native \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 
--amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=ARCH-SM_70-GFX906
 // ARCH-SM_70-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx906"
 // ARCH-SM_70-GFX906: "-cc1" "-triple" 
"nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
 
 // case when both nvptx-arch and amdgpu-arch succeed with other archs.
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp 
--offload-arch=native,sm_75,gfx1030 \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
-fopenmp=libomp --offload-arch=native,sm_75,gfx1030 \
 // RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 
--amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=ARCH-MULTIPLE
 // ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx1030"



___
cfe-commits mailing list
cfe-commits@lists.llvm.or

[PATCH] D140699: [OptTable] Make ValuesCode initialisation of Options constexpr

2023-01-12 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140699/new/

https://reviews.llvm.org/D140699

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


[PATCH] D141056: [SVE][CGBuiltins] Remove need for instcombine from ACLE tests.

2023-01-12 Thread David Sherwood via Phabricator via cfe-commits
david-arm accepted this revision.
david-arm added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for making the changes @paulwalker-arm. :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141056/new/

https://reviews.llvm.org/D141056

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


[PATCH] D141105: [OpenMP] Add support for '--offload-arch=native' to OpenMP offloading

2023-01-12 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

FYI: I fixed the problem in 
https://github.com/llvm/llvm-project/commit/0a11a1b1868dd2ab183c4313ccbfbe126e91ca08.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141105/new/

https://reviews.llvm.org/D141105

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


[clang] 0285656 - [Clang] Emit noundef metadata next to range metadata

2023-01-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-01-12T10:03:05+01:00
New Revision: 02856565ac12e21f14f2af64ce1135ecc3c2021f

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

LOG: [Clang] Emit noundef metadata next to range metadata

To preserve the previous semantics after D141386, adjust places
that currently emit !range metadata to also emit !noundef metadata.
This retains range violation as immediate undefined behavior,
rather than just poison.

Differential Revision: https://reviews.llvm.org/D141494

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp
clang/test/CodeGenCXX/pr12251.cpp
clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 430b5f43cdd5a..479e24245df4d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -687,6 +687,8 @@ static Value *emitRangedBuiltin(CodeGenFunction &CGF,
 Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
 llvm::Instruction *Call = CGF.Builder.CreateCall(F);
 Call->setMetadata(llvm::LLVMContext::MD_range, RNode);
+Call->setMetadata(llvm::LLVMContext::MD_noundef,
+  llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
 return Call;
 }
 
@@ -16785,6 +16787,8 @@ Value *EmitAMDGPUWorkGroupSize(CodeGenFunction &CGF, 
unsigned Index) {
   llvm::MDNode *RNode = MDHelper.createRange(APInt(16, 1),
   APInt(16, CGF.getTarget().getMaxOpenCLWorkGroupSize() + 1));
   LD->setMetadata(llvm::LLVMContext::MD_range, RNode);
+  LD->setMetadata(llvm::LLVMContext::MD_noundef,
+  llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
   LD->setMetadata(llvm::LLVMContext::MD_invariant_load,
   llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
   return LD;

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6d5e729b1eea9..34974c63984e6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1751,8 +1751,11 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address 
Addr, bool Volatile,
 // In order to prevent the optimizer from throwing away the check, don't
 // attach range metadata to the load.
   } else if (CGM.getCodeGenOpts().OptimizationLevel > 0)
-if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty))
+if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty)) {
   Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo);
+  Load->setMetadata(llvm::LLVMContext::MD_noundef,
+llvm::MDNode::get(getLLVMContext(), std::nullopt));
+}
 
   return EmitFromMemory(Load, Ty);
 }

diff  --git a/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu 
b/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
index e506b875b6748..c098917a0a0e2 100644
--- a/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
@@ -12,20 +12,20 @@
 // PRECOV5-LABEL: test_get_workgroup_size
 // PRECOV5: call align 4 dereferenceable(64) ptr addrspace(4) 
@llvm.amdgcn.dispatch.ptr()
 // PRECOV5: getelementptr i8, ptr addrspace(4) %{{.*}}, i32 4
-// PRECOV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load
+// PRECOV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
 // PRECOV5: getelementptr i8, ptr addrspace(4) %{{.*}}, i32 6
-// PRECOV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load
+// PRECOV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
 // PRECOV5: getelementptr i8, ptr addrspace(4) %{{.*}}, i32 8
-// PRECOV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load
+// PRECOV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
 
 // COV5-LABEL: test_get_workgroup_size
 // COV5: call align 8 dereferenceable(256) ptr addrspace(4) 
@llvm.amdgcn.implicitarg.ptr()
 // COV5: getelementptr i8, ptr addrspace(4) %{{.*}}, i32 12
-// COV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load
+// COV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
 // COV5: getelementptr i8, ptr addrspace(4) %{{.*}}, i32 14
-// COV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load
+// COV5: load i16, ptr addrspace(4) %{{.*}}, align 2, !range 
[[$WS_RANGE:![0-9]*]], !invariant.load{{.*}

[PATCH] D141494: [Clang] Emit noundef metadata next to range metadata

2023-01-12 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02856565ac12: [Clang] Emit noundef metadata next to range 
metadata (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141494/new/

https://reviews.llvm.org/D141494

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
  clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp
  clang/test/CodeGenCXX/pr12251.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -569,9 +569,9 @@
 }
 
 // CHECK-LABEL: @test_get_local_id(
-// CHECK: tail call i32 @llvm.amdgcn.workitem.id.x(), !range [[$WI_RANGE:![0-9]*]]
-// CHECK: tail call i32 @llvm.amdgcn.workitem.id.y(), !range [[$WI_RANGE]]
-// CHECK: tail call i32 @llvm.amdgcn.workitem.id.z(), !range [[$WI_RANGE]]
+// CHECK: tail call i32 @llvm.amdgcn.workitem.id.x(), !range [[$WI_RANGE:![0-9]*]], !noundef
+// CHECK: tail call i32 @llvm.amdgcn.workitem.id.y(), !range [[$WI_RANGE]], !noundef
+// CHECK: tail call i32 @llvm.amdgcn.workitem.id.z(), !range [[$WI_RANGE]], !noundef
 void test_get_local_id(int d, global int *out)
 {
 	switch (d) {
@@ -585,11 +585,11 @@
 // CHECK-LABEL: @test_get_workgroup_size(
 // CHECK: call align 4 dereferenceable(64) ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 4
-// CHECK: load i16, ptr addrspace(4) %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+// CHECK: load i16, ptr addrspace(4) %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 6
-// CHECK: load i16, ptr addrspace(4) %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+// CHECK: load i16, ptr addrspace(4) %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 8
-// CHECK: load i16, ptr addrspace(4) %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+// CHECK: load i16, ptr addrspace(4) %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
 void test_get_workgroup_size(int d, global int *out)
 {
 	switch (d) {
Index: clang/test/CodeGenCXX/pr12251.cpp
===
--- clang/test/CodeGenCXX/pr12251.cpp
+++ clang/test/CodeGenCXX/pr12251.cpp
@@ -5,7 +5,7 @@
   return *x;
 }
 // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1fPb
-// CHECK: load i8, ptr %{{[^ ]*}}, align 1, !range [[RANGE_i8_0_2:![^ ]*]]
+// CHECK: load i8, ptr %{{[^ ]*}}, align 1, !range [[RANGE_i8_0_2:![0-9]+]], !noundef [[NOUNDEF:![0-9]+]]
 
 // Only enum-tests follow. Ensure that after the bool test, no further range
 // metadata shows up when strict enums are disabled.
@@ -32,63 +32,63 @@
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g3P2e3
-// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_0_32:![^ ]*]]
+// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_0_32:![0-9]+]], !noundef [[NOUNDEF]]
 
 enum e4 { e4_a = -16};
 e4 g4(e4 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g4P2e4
-// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m16_16:![^ ]*]]
+// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m16_16:![0-9]+]], !noundef [[NOUNDEF]]
 
 enum e5 { e5_a = -16, e5_b = 16};
 e5 g5(e5 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g5P2e5
-// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m32_32:![^ ]*]]
+// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m32_32:![0-9]+]], !noundef [[NOUNDEF]]
 
 enum e6 { e6_a = -1 };
 e6 g6(e6 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g6P2e6
-// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m1_1:![^ ]*]]
+// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m1_1:![0-9]+]], !noundef [[NOUNDEF]]
 
 enum e7 { e7_a = -16, e7_b = 2};
 e7 g7(e7 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g7P2e7
-// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m16_16]]
+// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m16_16]], !noundef [[NOUNDEF]]
 
 enum e8 { e8_a = -17};
 e8 g8(e8 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g8P2e8
-// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m32_32:![^ ]*]]
+// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_m32_32:![0-9]+]], !noundef [[NOUNDEF]]
 
 enum e9 { e9_a = 17};
 e9 g9(e9 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g9P2e9
-// CHECK: load i32, ptr %x, align 4, !range [[RANGE_i32_0_32]]
+//

[PATCH] D141580: [clang] Don't consider a nullptr returned from ActOnTag() as a valid result in ParseClassSpecifier.

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang.

This is revealed in https://reviews.llvm.org/D141280


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141580

Files:
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/cxx-undeclared-identifier.cpp
  clang/test/Parser/recovery.cpp
  clang/test/SemaCXX/invalid-template-params.cpp
  clang/test/SemaCXX/rdar42746401.cpp


Index: clang/test/SemaCXX/rdar42746401.cpp
===
--- clang/test/SemaCXX/rdar42746401.cpp
+++ clang/test/SemaCXX/rdar42746401.cpp
@@ -4,4 +4,4 @@
 class b;
 class c; // expected-note{{forward declaration}}
 
-::b<0> struct c::d // expected-error{{incomplete type}} expected-error{{cannot 
combine}} expected-error{{expected unqualified-id}}
+::b<0> struct c::d // expected-error{{incomplete type}} 
expected-error{{expected unqualified-id}}
Index: clang/test/SemaCXX/invalid-template-params.cpp
===
--- clang/test/SemaCXX/invalid-template-params.cpp
+++ clang/test/SemaCXX/invalid-template-params.cpp
@@ -15,9 +15,8 @@
 public:
   template' in 
template-parameter-list}}
-// expected-error@-3 {{declaration does not declare anything}}
+// expected-error@-1 {{expected ',' or '>' in 
template-parameter-list}}
+// expected-error@-2 {{declaration does not declare anything}}
   C0() : m(new S0) {} // expected-error {{expected '(' for function-style 
cast or type construction}}
// expected-error@-1 {{expected expression}}
   S0 *m; // expected-error {{expected member name or ';' after 
declaration specifiers}}
Index: clang/test/Parser/recovery.cpp
===
--- clang/test/Parser/recovery.cpp
+++ clang/test/Parser/recovery.cpp
@@ -212,6 +212,6 @@
 enum ::, enum ::; // expected-error 2 {{expected identifier}}
 struct ::__super, struct ::__super; // expected-error 2 {{expected 
identifier}} expected-error 2 {{expected '::' after '__super'}}
 struct ::template foo, struct ::template bar; // expected-error 2 {{expected 
identifier}} expected-error 2 {{declaration of anonymous struct must be a 
definition}} expected-warning {{declaration does not declare anything}}
-struct ::foo struct::; // expected-error {{no struct named 'foo' in the global 
namespace}} expected-error {{expected identifier}} expected-error {{declaration 
of anonymous struct must be a definition}}
+struct ::foo struct::; // expected-error {{no struct named 'foo' in the global 
namespace}} expected-error {{expected identifier}}
 class :: : {} a;  // expected-error {{expected identifier}} expected-error 
{{expected class name}}
 }
Index: clang/test/Parser/cxx-undeclared-identifier.cpp
===
--- clang/test/Parser/cxx-undeclared-identifier.cpp
+++ clang/test/Parser/cxx-undeclared-identifier.cpp
@@ -15,5 +15,5 @@
 // PR7180
 int f(a::b::c); // expected-error {{use of undeclared identifier 'a'}}
 
-class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} \
- // expected-error {{expected ';' after class}}
+class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}}
+ // expected-error {{expected unqualified-id}}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2066,14 +2066,16 @@
 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
 
 // Declaration or definition of a class type
-TagOrTempResult = Actions.ActOnTag(
-getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
-DS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
-SourceLocation(), false, clang::TypeResult(),
-DSC == DeclSpecContext::DSC_type_specifier,
-DSC == DeclSpecContext::DSC_template_param ||
-DSC == DeclSpecContext::DSC_template_type_arg,
-&SkipBody);
+if (auto *TagDecl = Actions.ActOnTag(
+getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, 
AS,
+DS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
+SourceLocation(), false, clang::TypeResult(),
+DSC == DeclSpecContext::DSC_type_specifier,
+DSC == DeclSpecContext::DSC_template_param ||
+DSC == DeclSpecContext::DSC_template_type_arg,
+&SkipBody)) {
+  TagOrTempResult = TagDecl;
+}
 
 // If ActOnTag said the type was dependent, try again with the
 // less common call.


Index: clang/test/SemaCXX/rdar42746401.cpp
===
--- clang/test/SemaCXX/rdar42746401.cpp
+++ clang

[PATCH] D141580: [clang] Don't consider a nullptr returned from ActOnTag() as a valid result in ParseClassSpecifier.

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

I think the diagnostic changes are improvements.




Comment at: clang/test/SemaCXX/rdar42746401.cpp:7
 
-::b<0> struct c::d // expected-error{{incomplete type}} expected-error{{cannot 
combine}} expected-error{{expected unqualified-id}}

The removed diagnostic is "cannot combine with previous 'type-name' declaration 
specifier" which is bogus.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141580/new/

https://reviews.llvm.org/D141580

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


[clang] d78a7c5 - [ODRHash] Handle `Integral` and `NullPtr` template parameters in `ODRHash`

2023-01-12 Thread via cfe-commits

Author: isuckatcs
Date: 2023-01-12T10:24:50+01:00
New Revision: d78a7c5012c7ae6ec9991fb22fcd6d06a42dc1cc

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

LOG: [ODRHash] Handle `Integral` and `NullPtr` template parameters in `ODRHash`

Before this patch the parameters mentioned in the title weren't
handled by ODRHash, when a hash was generated for a template
specialization. This patch adds these parameters to the hash,
so that different template specializations will get different
hashes in every case.

Differential Revision: https://reviews.llvm.org/D141224

Added: 


Modified: 
clang/lib/AST/ODRHash.cpp
clang/test/Modules/odr_hash.cpp

Removed: 




diff  --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index fee47881a1835..1a24bb24d59f6 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -172,8 +172,14 @@ void ODRHash::AddTemplateArgument(TemplateArgument TA) {
   AddDecl(TA.getAsDecl());
   break;
 case TemplateArgument::NullPtr:
-case TemplateArgument::Integral:
+  ID.AddPointer(nullptr);
   break;
+case TemplateArgument::Integral: {
+  // There are integrals (e.g.: _BitInt(128)) that cannot be represented as
+  // any builtin integral type, so we use the hash of APSInt instead.
+  TA.getAsIntegral().Profile(ID);
+  break;
+}
 case TemplateArgument::Template:
 case TemplateArgument::TemplateExpansion:
   AddTemplateName(TA.getAsTemplateOrTemplatePattern());

diff  --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp
index fb756013bc9bb..fffac5e318f5d 100644
--- a/clang/test/Modules/odr_hash.cpp
+++ b/clang/test/Modules/odr_hash.cpp
@@ -1939,6 +1939,164 @@ S11 s11;
 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 2 
template arguments}}
 #endif
 
+#if defined(FIRST)
+struct S12 {
+  template  void f(){};
+  template <> void f<1>(){};
+};
+#elif defined(SECOND)
+struct S12 {
+  template  void f(){};
+  template <> void f<2>(){};
+};
+#else
+S12 s12;
+// expected-error@second.h:* {{'TemplateArgument::S12' has 
diff erent definitions in 
diff erent modules; first 
diff erence is definition in module 'SecondModule' found method 'f' with 2 for 
1st template argument}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 1 for 
1st template argument}}
+#endif
+
+#if defined(FIRST)
+struct S13 {
+  template  void f(){};
+  template <> void f<10>(){};
+};
+#elif defined(SECOND)
+struct S13 {
+  template  void f(){};
+  template <> void f<10>(){};
+};
+#else
+S13 s13;
+#endif
+
+#if defined(FIRST)
+struct S14 {
+  template  void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S14 {
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S14 s14;
+// expected-error@second.h:* {{'TemplateArgument::S14' has 
diff erent definitions in 
diff erent modules; first 
diff erence is definition in module 'SecondModule' found method 'f' with 0 for 
1st template argument}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 1 for 
1st template argument}}
+#endif
+
+#if defined(FIRST)
+struct S15 {
+  template  void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S15 {
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S15 s15;
+#endif
+
+#if defined(FIRST)
+struct S16 {
+  template  void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S16 {
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S16 s16;
+#endif
+
+#if defined(FIRST)
+struct S17 {
+  static int x;
+  template  void f(){};
+  template <> void f<&x>(){};
+};
+#elif defined(SECOND)
+struct S17 {
+  static int x;
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S17 s17;
+// expected-error@second.h:* {{'TemplateArgument::S17' has 
diff erent definitions in 
diff erent modules; first 
diff erence is definition in module 'SecondModule' found method 'f' with 
nullptr for 1st template argument}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 'x' 
for 1st template argument}}
+#endif
+
+#if defined(FIRST)
+struct S18 {
+  static int x;
+  template  void f(){};
+  template <> void f<&x>(){};
+};
+#elif defined(SECOND)
+struct S18 {
+  static int x;
+  template  void f(){};
+  template <> void f<&x>(){};
+};
+#else
+S18 s18;
+#endif
+
+#if defined(FIRST)
+struct S19 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long 
long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S19 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long 
long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f(){};
+};
+#else
+S19 

[PATCH] D141224: [ODRHash] Handle `Integral` and `NullPtr` template parameters in `ODRHash`

2023-01-12 Thread Domján Dániel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd78a7c5012c7: [ODRHash] Handle `Integral` and `NullPtr` 
template parameters in `ODRHash` (authored by isuckatcs).
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141224/new/

https://reviews.llvm.org/D141224

Files:
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/odr_hash.cpp

Index: clang/test/Modules/odr_hash.cpp
===
--- clang/test/Modules/odr_hash.cpp
+++ clang/test/Modules/odr_hash.cpp
@@ -1939,6 +1939,164 @@
 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 2 template arguments}}
 #endif
 
+#if defined(FIRST)
+struct S12 {
+  template  void f(){};
+  template <> void f<1>(){};
+};
+#elif defined(SECOND)
+struct S12 {
+  template  void f(){};
+  template <> void f<2>(){};
+};
+#else
+S12 s12;
+// expected-error@second.h:* {{'TemplateArgument::S12' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with 2 for 1st template argument}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 1 for 1st template argument}}
+#endif
+
+#if defined(FIRST)
+struct S13 {
+  template  void f(){};
+  template <> void f<10>(){};
+};
+#elif defined(SECOND)
+struct S13 {
+  template  void f(){};
+  template <> void f<10>(){};
+};
+#else
+S13 s13;
+#endif
+
+#if defined(FIRST)
+struct S14 {
+  template  void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S14 {
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S14 s14;
+// expected-error@second.h:* {{'TemplateArgument::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with 0 for 1st template argument}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 1 for 1st template argument}}
+#endif
+
+#if defined(FIRST)
+struct S15 {
+  template  void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S15 {
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S15 s15;
+#endif
+
+#if defined(FIRST)
+struct S16 {
+  template  void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S16 {
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S16 s16;
+#endif
+
+#if defined(FIRST)
+struct S17 {
+  static int x;
+  template  void f(){};
+  template <> void f<&x>(){};
+};
+#elif defined(SECOND)
+struct S17 {
+  static int x;
+  template  void f(){};
+  template <> void f(){};
+};
+#else
+S17 s17;
+// expected-error@second.h:* {{'TemplateArgument::S17' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with nullptr for 1st template argument}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 'x' for 1st template argument}}
+#endif
+
+#if defined(FIRST)
+struct S18 {
+  static int x;
+  template  void f(){};
+  template <> void f<&x>(){};
+};
+#elif defined(SECOND)
+struct S18 {
+  static int x;
+  template  void f(){};
+  template <> void f<&x>(){};
+};
+#else
+S18 s18;
+#endif
+
+#if defined(FIRST)
+struct S19 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S19 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f(){};
+};
+#else
+S19 s19;
+#endif
+
+#if defined(FIRST)
+struct S20 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S20 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f(){};
+};
+#else
+S20 s20;
+// expected-error@second.h:* {{'TemplateArgument::S20' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with 18446744073709551615 for 1st template argument}}
+// expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 36893488147419103230 for 1st template argument}}
+#endif
+
+#if defined(FIRST)
+struct S21 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f(){};
+};
+#elif defined(SECOND)
+struct S21 {
+  static constexpr _BitInt(128) x = static_cast<_BitInt(128)>((unsigned long long)-1);
+  template <_BitInt(128)> void f(){};
+  template <> void f<(unsigned long long)-1>(){};
+};
+#else
+S21 s21;
+#endif
+
 #define DECLS   \
   OneClass a;  \
   OneInt<1> b; 

[PATCH] D141134: [NFC] Only expose getXXXSize functions in TypeSize

2023-01-12 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet closed this revision.
gchatelet added a comment.

So i've submitted the following patches which remove the usage of 
`TypeSize::getFixedSize()` and `TypeSize::getKnownMinSize()`

- rG6916ebd02650 
: 
[clang][NFC] Use the TypeSize::getXXXValue() instead of 
TypeSize::getXXXSize).Wed, Jan 11, 5:08 PM
- rGca8485578652 
: 
[mlir][NFC] Use TypeSize::getFixedValue() instead of 
TypeSize::getFixedSize().Wed, Jan 11, 5:22 PM
- rGfbd207fd6f6b 
: [NFC] 
Use TypeSize::getKnownMinValue() instead of TypeSize::getKnownMinSize().Wed, 
Jan 11, 5:29 PM
- rG48f5d77eeed4 
: [NFC] 
Use TypeSize::getKnownMinValue() instead of TypeSize::getKnownMinSize().Wed, 
Jan 11, 5:37 PM
- rG8fd5558b2976 
: [NFC] 
Use TypeSize::geFixedValue() instead of TypeSize::getFixedSize().Wed, Jan 11, 
5:49 PM

I've also marked the functions deprecated so downstream users can fix their 
codebase.

- rG1dcaa2bdf230 
: Marking 
TypeSize getFixedSize() and getKnownMinSize() deprecated.

I'm marking this patch as closed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141134/new/

https://reviews.llvm.org/D141134

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


[PATCH] D141467: [clang][Driver][CUDA] Get rid of unused LibPath

2023-01-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D141467#4045190 , @tra wrote:

> Given that it's indeed unused, I'm fine with removing it.
>
> That said, it's somewhat odd that in your setup clang was able to find 
> everything but the library directory. You generally would need to have 
> `--cuda-path=` among compiler options and that should be pointing to a valid 
> CUDA installation.
>
> Can you elaborate on where/how clang manages to find CUDA headers in your 
> case?

We actually use a pipeline that runs compilations by recording & replaying past 
snapshots of our codebase. The record logic we have don't retain access to 
directories in its required inputs set, as clang stats lots of directories when 
performing include search etc, which are not ~never needed for the compilation 
(apart from the one that contains the actual files).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141467/new/

https://reviews.llvm.org/D141467

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


[clang] 4921b0a - [clang][Driver][CUDA] Get rid of unused LibPath

2023-01-12 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2023-01-12T10:36:43+01:00
New Revision: 4921b0a285ace77b7a3d5b9502b8602134daee0d

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

LOG: [clang][Driver][CUDA] Get rid of unused LibPath

LibPath discovered during InstallationDetection wasn't used anywhere.
Moreover it actually resulted in discarding installations that don't have any
`/lib` directory.

This is causing troubles for our pipelines downstream, that want to perform
syntax-only analysis on the sources.

Differential Revision: https://reviews.llvm.org/D141467

Added: 


Modified: 
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/Cuda.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 5b4ed08b82144..76f4da2a704d0 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -194,19 +194,6 @@ CudaInstallationDetector::CudaInstallationDetector(
 if (CheckLibDevice && !FS.exists(LibDevicePath))
   continue;
 
-// On Linux, we have both lib and lib64 directories, and we need to choose
-// based on our triple.  On MacOS, we have only a lib directory.
-//
-// It's sufficient for our purposes to be flexible: If both lib and lib64
-// exist, we choose whichever one matches our triple.  Otherwise, if only
-// lib exists, we use it.
-if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
-  LibPath = InstallPath + "/lib64";
-else if (FS.exists(InstallPath + "/lib"))
-  LibPath = InstallPath + "/lib";
-else
-  continue;
-
 Version = CudaVersion::UNKNOWN;
 if (auto CudaHFile = FS.getBufferForFile(InstallPath + "/include/cuda.h"))
   Version = parseCudaHFile((*CudaHFile)->getBuffer());

diff  --git a/clang/lib/Driver/ToolChains/Cuda.h 
b/clang/lib/Driver/ToolChains/Cuda.h
index b4770d2a0e440..8ee99d4a3786b 100644
--- a/clang/lib/Driver/ToolChains/Cuda.h
+++ b/clang/lib/Driver/ToolChains/Cuda.h
@@ -31,7 +31,6 @@ class CudaInstallationDetector {
   CudaVersion Version = CudaVersion::UNKNOWN;
   std::string InstallPath;
   std::string BinPath;
-  std::string LibPath;
   std::string LibDevicePath;
   std::string IncludePath;
   llvm::StringMap LibDeviceMap;
@@ -69,8 +68,6 @@ class CudaInstallationDetector {
   StringRef getBinPath() const { return BinPath; }
   /// Get the detected Cuda Include path.
   StringRef getIncludePath() const { return IncludePath; }
-  /// Get the detected Cuda library path.
-  StringRef getLibPath() const { return LibPath; }
   /// Get the detected Cuda device library path.
   StringRef getLibDevicePath() const { return LibDevicePath; }
   /// Get libdevice file for given architecture



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


[PATCH] D141467: [clang][Driver][CUDA] Get rid of unused LibPath

2023-01-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4921b0a285ac: [clang][Driver][CUDA] Get rid of unused 
LibPath (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141467/new/

https://reviews.llvm.org/D141467

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h


Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -31,7 +31,6 @@
   CudaVersion Version = CudaVersion::UNKNOWN;
   std::string InstallPath;
   std::string BinPath;
-  std::string LibPath;
   std::string LibDevicePath;
   std::string IncludePath;
   llvm::StringMap LibDeviceMap;
@@ -69,8 +68,6 @@
   StringRef getBinPath() const { return BinPath; }
   /// Get the detected Cuda Include path.
   StringRef getIncludePath() const { return IncludePath; }
-  /// Get the detected Cuda library path.
-  StringRef getLibPath() const { return LibPath; }
   /// Get the detected Cuda device library path.
   StringRef getLibDevicePath() const { return LibDevicePath; }
   /// Get libdevice file for given architecture
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -194,19 +194,6 @@
 if (CheckLibDevice && !FS.exists(LibDevicePath))
   continue;
 
-// On Linux, we have both lib and lib64 directories, and we need to choose
-// based on our triple.  On MacOS, we have only a lib directory.
-//
-// It's sufficient for our purposes to be flexible: If both lib and lib64
-// exist, we choose whichever one matches our triple.  Otherwise, if only
-// lib exists, we use it.
-if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
-  LibPath = InstallPath + "/lib64";
-else if (FS.exists(InstallPath + "/lib"))
-  LibPath = InstallPath + "/lib";
-else
-  continue;
-
 Version = CudaVersion::UNKNOWN;
 if (auto CudaHFile = FS.getBufferForFile(InstallPath + "/include/cuda.h"))
   Version = parseCudaHFile((*CudaHFile)->getBuffer());


Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -31,7 +31,6 @@
   CudaVersion Version = CudaVersion::UNKNOWN;
   std::string InstallPath;
   std::string BinPath;
-  std::string LibPath;
   std::string LibDevicePath;
   std::string IncludePath;
   llvm::StringMap LibDeviceMap;
@@ -69,8 +68,6 @@
   StringRef getBinPath() const { return BinPath; }
   /// Get the detected Cuda Include path.
   StringRef getIncludePath() const { return IncludePath; }
-  /// Get the detected Cuda library path.
-  StringRef getLibPath() const { return LibPath; }
   /// Get the detected Cuda device library path.
   StringRef getLibDevicePath() const { return LibDevicePath; }
   /// Get libdevice file for given architecture
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -194,19 +194,6 @@
 if (CheckLibDevice && !FS.exists(LibDevicePath))
   continue;
 
-// On Linux, we have both lib and lib64 directories, and we need to choose
-// based on our triple.  On MacOS, we have only a lib directory.
-//
-// It's sufficient for our purposes to be flexible: If both lib and lib64
-// exist, we choose whichever one matches our triple.  Otherwise, if only
-// lib exists, we use it.
-if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
-  LibPath = InstallPath + "/lib64";
-else if (FS.exists(InstallPath + "/lib"))
-  LibPath = InstallPath + "/lib";
-else
-  continue;
-
 Version = CudaVersion::UNKNOWN;
 if (auto CudaHFile = FS.getBufferForFile(InstallPath + "/include/cuda.h"))
   Version = parseCudaHFile((*CudaHFile)->getBuffer());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141509: [include-mapping] Fix parsing of html_book_20190607.zip (https://en.cppreference.com/w/File:html_book_20190607.zip). Skip entries that have been added to the index (C++20 symbols), bu

2023-01-12 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 488539.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141509/new/

https://reviews.llvm.org/D141509

Files:
  clang/tools/include-mapping/cppreference_parser.py


Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -142,7 +142,8 @@
   if variant and variant not in variants_for_symbol:
 continue
   path = os.path.join(root_dir, symbol_page_path)
-  results.append((symbol_name,
+  if os.path.isfile(path):
+results.append((symbol_name,
   pool.apply_async(_ReadSymbolPage, (path, symbol_name
 
 # Build map from symbol name to a set of headers.


Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -142,7 +142,8 @@
   if variant and variant not in variants_for_symbol:
 continue
   path = os.path.join(root_dir, symbol_page_path)
-  results.append((symbol_name,
+  if os.path.isfile(path):
+results.append((symbol_name,
   pool.apply_async(_ReadSymbolPage, (path, symbol_name
 
 # Build map from symbol name to a set of headers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141509: [include-mapping] Fix parsing of html_book_20190607.zip (https://en.cppreference.com/w/File:html_book_20190607.zip). Skip entries that have been added to the index (C++20 symbols), bu

2023-01-12 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Thanks for the review!




Comment at: clang/tools/include-mapping/cppreference_parser.py:117
 def _ReadSymbolPage(path, name):
-  with open(path) as f:
-return _ParseSymbolPage(f.read(), name)
+  try:
+f = open(path)

hokein wrote:
> so the input path can be invalid, pointing to a non-existing file, I'd just 
> check it in the caller side, see my other comment.
good idea!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141509/new/

https://reviews.llvm.org/D141509

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


[clang] 840edd8 - [analyzer] Don't escape local static memregions on bind

2023-01-12 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2023-01-12T10:42:57+01:00
New Revision: 840edd8ab2620a52e9acbef7de037c9f465dfce7

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

LOG: [analyzer] Don't escape local static memregions on bind

When the engine processes a store to a variable, it will eventually call
`ExprEngine::processPointerEscapedOnBind()`. This function is supposed to
invalidate (put the given locations to an escape list) the locations
which we cannot reason about.

Unfortunately, local static variables are also put into this list.

This patch relaxes the guard condition, so that beyond stack variables,
static local variables are also ignored.

Differential Revision: https://reviews.llvm.org/D139534

Added: 
clang/test/Analysis/malloc-static-storage.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 87a95d46f2987..0b8800294c453 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3461,7 +3461,8 @@ ProgramStateRef ExprEngine::processPointerEscapedOnBind(
   for (const std::pair &LocAndVal : LocAndVals) {
 // Cases (1) and (2).
 const MemRegion *MR = LocAndVal.first.getAsRegion();
-if (!MR || !MR->hasStackStorage()) {
+if (!MR ||
+!isa(MR->getMemorySpace())) 
{
   Escaped.push_back(LocAndVal.second);
   continue;
 }

diff  --git a/clang/test/Analysis/malloc-static-storage.cpp 
b/clang/test/Analysis/malloc-static-storage.cpp
new file mode 100644
index 0..4eeabab41209b
--- /dev/null
+++ b/clang/test/Analysis/malloc-static-storage.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void* malloc(size_t size);
+void *calloc(size_t num, size_t size);
+void free(void * ptr);
+
+void escape(void *);
+void next_statement();
+
+void conditional_malloc(bool coin) {
+  static int *p;
+
+  if (coin) {
+p = (int *)malloc(sizeof(int));
+  }
+  p = 0; // Pointee of 'p' dies, which is recognized at the next statement.
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+void malloc_twice() {
+  static int *p;
+  p = (int *)malloc(sizeof(int));
+  next_statement();
+  p = (int *)malloc(sizeof(int));
+  next_statement(); // expected-warning {{Potential memory leak}}
+  p = 0;
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+void malloc_escape() {
+  static int *p;
+  p = (int *)malloc(sizeof(int));
+  escape(p); // no-leak
+  p = 0; // no-leak
+}
+
+void free_whatever_escaped();
+void malloc_escape_reversed() {
+  static int *p;
+  escape(&p);
+  p = (int *)malloc(sizeof(int));
+  free_whatever_escaped();
+  p = 0; // FIXME: We should not report a leak here.
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+int *malloc_return_static() {
+  static int *p = (int *)malloc(sizeof(int));
+  return p; // no-leak
+}
+
+int malloc_unreachable(int rng) {
+  // 'p' does not escape and never freed :(
+  static int *p;
+
+  // For the second invocation of this function, we leak the previous pointer.
+  // FIXME: We should catch this at some point.
+  p = (int *)malloc(sizeof(int));
+  *p = 0;
+
+  if (rng > 0)
+*p = rng;
+
+  return *p; // FIXME: We just leaked 'p'. We should warn about this.
+}
+
+void malloc_cond(bool cond) {
+  static int *p;
+  if (cond) {
+p = (int*)malloc(sizeof(int));
+free_whatever_escaped();
+p = 0; // FIXME: We should not report a leak here.
+next_statement(); // expected-warning {{Potential memory leak}}
+  }
+  escape(&p);
+}



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


[PATCH] D139534: [analyzer] Don't escape local static memregions on bind

2023-01-12 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG840edd8ab262: [analyzer] Don't escape local static 
memregions on bind (authored by steakhal).

Changed prior to commit:
  https://reviews.llvm.org/D139534?vs=484600&id=488546#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139534/new/

https://reviews.llvm.org/D139534

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/malloc-static-storage.cpp


Index: clang/test/Analysis/malloc-static-storage.cpp
===
--- /dev/null
+++ clang/test/Analysis/malloc-static-storage.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void* malloc(size_t size);
+void *calloc(size_t num, size_t size);
+void free(void * ptr);
+
+void escape(void *);
+void next_statement();
+
+void conditional_malloc(bool coin) {
+  static int *p;
+
+  if (coin) {
+p = (int *)malloc(sizeof(int));
+  }
+  p = 0; // Pointee of 'p' dies, which is recognized at the next statement.
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+void malloc_twice() {
+  static int *p;
+  p = (int *)malloc(sizeof(int));
+  next_statement();
+  p = (int *)malloc(sizeof(int));
+  next_statement(); // expected-warning {{Potential memory leak}}
+  p = 0;
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+void malloc_escape() {
+  static int *p;
+  p = (int *)malloc(sizeof(int));
+  escape(p); // no-leak
+  p = 0; // no-leak
+}
+
+void free_whatever_escaped();
+void malloc_escape_reversed() {
+  static int *p;
+  escape(&p);
+  p = (int *)malloc(sizeof(int));
+  free_whatever_escaped();
+  p = 0; // FIXME: We should not report a leak here.
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+int *malloc_return_static() {
+  static int *p = (int *)malloc(sizeof(int));
+  return p; // no-leak
+}
+
+int malloc_unreachable(int rng) {
+  // 'p' does not escape and never freed :(
+  static int *p;
+
+  // For the second invocation of this function, we leak the previous pointer.
+  // FIXME: We should catch this at some point.
+  p = (int *)malloc(sizeof(int));
+  *p = 0;
+
+  if (rng > 0)
+*p = rng;
+
+  return *p; // FIXME: We just leaked 'p'. We should warn about this.
+}
+
+void malloc_cond(bool cond) {
+  static int *p;
+  if (cond) {
+p = (int*)malloc(sizeof(int));
+free_whatever_escaped();
+p = 0; // FIXME: We should not report a leak here.
+next_statement(); // expected-warning {{Potential memory leak}}
+  }
+  escape(&p);
+}
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3461,7 +3461,8 @@
   for (const std::pair &LocAndVal : LocAndVals) {
 // Cases (1) and (2).
 const MemRegion *MR = LocAndVal.first.getAsRegion();
-if (!MR || !MR->hasStackStorage()) {
+if (!MR ||
+!isa(MR->getMemorySpace())) 
{
   Escaped.push_back(LocAndVal.second);
   continue;
 }


Index: clang/test/Analysis/malloc-static-storage.cpp
===
--- /dev/null
+++ clang/test/Analysis/malloc-static-storage.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void* malloc(size_t size);
+void *calloc(size_t num, size_t size);
+void free(void * ptr);
+
+void escape(void *);
+void next_statement();
+
+void conditional_malloc(bool coin) {
+  static int *p;
+
+  if (coin) {
+p = (int *)malloc(sizeof(int));
+  }
+  p = 0; // Pointee of 'p' dies, which is recognized at the next statement.
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+void malloc_twice() {
+  static int *p;
+  p = (int *)malloc(sizeof(int));
+  next_statement();
+  p = (int *)malloc(sizeof(int));
+  next_statement(); // expected-warning {{Potential memory leak}}
+  p = 0;
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+void malloc_escape() {
+  static int *p;
+  p = (int *)malloc(sizeof(int));
+  escape(p); // no-leak
+  p = 0; // no-leak
+}
+
+void free_whatever_escaped();
+void malloc_escape_reversed() {
+  static int *p;
+  escape(&p);
+  p = (int *)malloc(sizeof(int));
+  free_whatever_escaped();
+  p = 0; // FIXME: We should not report a leak here.
+  next_statement(); // expected-warning {{Potential memory leak}}
+}
+
+int *malloc_return_static() {
+  static int *p = (int *)malloc(sizeof(int));
+  return p; // no-leak
+}
+
+int malloc_unreachable(int rng) {
+  // 'p' does not escape and never freed :(
+  static int *p;
+
+  // For the second invocation of this function, we leak the previous pointer.
+  // FIXME: We should catch this at some p

[PATCH] D141280: [clang] Build UsingType for elaborated type specifiers.

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:2134
+// FIXME: !! TagOrTempResult.get() can be a nullptr here, this looks
+// suspicious.
 Result = DS.SetTypeSpecType(

Addressing it in https://reviews.llvm.org/D141580.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141280/new/

https://reviews.llvm.org/D141280

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


[clang] 301123c - [include-mapping] Fix parsing of html_book_20190607.zip (https://en.cppreference.com/w/File:html_book_20190607.zip). Skip entries that have been added to the index (C++20 symbols), b

2023-01-12 Thread Viktoriia Bakalova via cfe-commits

Author: Viktoriia Bakalova
Date: 2023-01-12T09:48:27Z
New Revision: 301123c7a8b5f5dd415e336ff933576279b0e868

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

LOG: [include-mapping] Fix parsing of html_book_20190607.zip 
(https://en.cppreference.com/w/File:html_book_20190607.zip). Skip entries that 
have been added to the index (C++20 symbols), but the corresponding pages for 
which have not been created yet.

Differential Revision: https://reviews.llvm.org/D141509

Added: 


Modified: 
clang/tools/include-mapping/cppreference_parser.py

Removed: 




diff  --git a/clang/tools/include-mapping/cppreference_parser.py 
b/clang/tools/include-mapping/cppreference_parser.py
index e56c8a5f1331a..137d310491bd1 100644
--- a/clang/tools/include-mapping/cppreference_parser.py
+++ b/clang/tools/include-mapping/cppreference_parser.py
@@ -142,7 +142,8 @@ def _GetSymbols(pool, root_dir, index_page_name, namespace, 
variants_to_accept):
   if variant and variant not in variants_for_symbol:
 continue
   path = os.path.join(root_dir, symbol_page_path)
-  results.append((symbol_name,
+  if os.path.isfile(path):
+results.append((symbol_name,
   pool.apply_async(_ReadSymbolPage, (path, symbol_name
 
 # Build map from symbol name to a set of headers.



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


[PATCH] D141509: [include-mapping] Fix parsing of html_book_20190607.zip (https://en.cppreference.com/w/File:html_book_20190607.zip). Skip entries that have been added to the index (C++20 symbols), bu

2023-01-12 Thread Viktoriia Bakalova via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG301123c7a8b5: [include-mapping] Fix parsing of 
html_book_20190607.zip (https://en. (authored by VitaNuo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141509/new/

https://reviews.llvm.org/D141509

Files:
  clang/tools/include-mapping/cppreference_parser.py


Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -142,7 +142,8 @@
   if variant and variant not in variants_for_symbol:
 continue
   path = os.path.join(root_dir, symbol_page_path)
-  results.append((symbol_name,
+  if os.path.isfile(path):
+results.append((symbol_name,
   pool.apply_async(_ReadSymbolPage, (path, symbol_name
 
 # Build map from symbol name to a set of headers.


Index: clang/tools/include-mapping/cppreference_parser.py
===
--- clang/tools/include-mapping/cppreference_parser.py
+++ clang/tools/include-mapping/cppreference_parser.py
@@ -142,7 +142,8 @@
   if variant and variant not in variants_for_symbol:
 continue
   path = os.path.join(root_dir, symbol_page_path)
-  results.append((symbol_name,
+  if os.path.isfile(path):
+results.append((symbol_name,
   pool.apply_async(_ReadSymbolPage, (path, symbol_name
 
 # Build map from symbol name to a set of headers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-12 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added a reviewer: jrtc27.
Herald added subscribers: luismarques, s.egerton, kadircet, PkmX, arphaman, 
simoncook, arichardson.
Herald added a project: All.
fpetrogalli requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay, ilya-biryukov.
Herald added a project: clang.

The header file `llvm/include/llvm/Targetparser/RISCVTargetParser.h`
relies on the auto-generated *.inc file associated to the tablegen
target `RISCVTargetParserTableGen`.

Both clangBasic and clangDriver include `RISCVTargetParser.h`,
therefore we need to make sure that the *.inc file is avaiable to
avoid compilation errors like the following:

  FAILED: 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o
  /usr/bin/c++  [bunch of non interesting stuff]  -c 
/llvm-project/clang/lib/Basic/Targets/RISCV.cpp
  In file included from 
/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:19:
  
/llvm-project/llvm/include/llvm/TargetParser/RISCVTargetParser.h:29:10:
 fatal error: llvm/TargetParser/RISCVTargetParserDef.inc: No such file or 
directory
29 | #include "llvm/TargetParser/RISCVTargetParserDef.inc"
   |  ^~~~


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141581

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/CMakeLists.txt


Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -93,7 +93,7 @@
 
   DEPENDS
   ClangDriverOptions
-  RISCVTargetParserTableGen
+  LLVMTargetParser
 
   LINK_LIBS
   clangBasic
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -110,7 +110,7 @@
 
   DEPENDS
   omp_gen
-  RISCVTargetParserTableGen
+  LLVMTargetParser
   )
 
 target_link_libraries(clangBasic


Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -93,7 +93,7 @@
 
   DEPENDS
   ClangDriverOptions
-  RISCVTargetParserTableGen
+  LLVMTargetParser
 
   LINK_LIBS
   clangBasic
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -110,7 +110,7 @@
 
   DEPENDS
   omp_gen
-  RISCVTargetParserTableGen
+  LLVMTargetParser
   )
 
 target_link_libraries(clangBasic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-12 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a subscriber: craig.topper.
fpetrogalli added a comment.

@jrtc27, @thakis, @craig.topper  - is this a better solution to the issue 
raised in https://reviews.llvm.org/D137517?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141581/new/

https://reviews.llvm.org/D141581

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


[PATCH] D140800: [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM

In D140800#4044983 , 
@serge-sans-paille wrote:

> In D140800#4043723 , @nikic wrote:
>
>> Just to check, this isn't going to cause some warning spew about all those 
>> OptTable implementations being non-final?
>
> nope. Why would there be?

Something about missing virtual destructors on a non-final class? Not sure when 
exactly that warning applies.




Comment at: llvm/unittests/Option/OptionParsingTest.cpp:327
 
-TEST(DISABLED_Option, FindNearestFIXME) {
-  TestOptTable T;

serge-sans-paille wrote:
> @nikic: the `DISABLED_` prefix seems to be a gtest convention, see 
> https://github.com/google/googletest/blob/main/docs/advanced.md#temporarily-disabling-tests
Huh, TIL.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140800/new/

https://reviews.llvm.org/D140800

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


[PATCH] D141583: [clang-tidy][doc] Deprecate the AnalyzeTemporaryDtors option

2023-01-12 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp created this revision.
Herald added a subscriber: xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
carlosgalvezp requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

It's not used anywhere, and we should not keep it
for eternity. Document it as deprecated and announce
its removal 2 releases later, so people have time
to update their .clang-tidy files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141583

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -102,6 +102,9 @@
 - Fix a minor bug in `add_new_check.py` to only traverse subdirectories
   when updating the list of checks in the documentation.
 
+- Deprecate the global configuration file option `AnalyzeTemporaryDtors`,
+  which is no longer in use. The option will be fully removed in clang-tidy 18.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -124,7 +124,7 @@
 IO.mapOptional("Checks", Options.Checks);
 IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
-IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // legacy compatibility
+IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // deprecated
 IO.mapOptional("FormatStyle", Options.FormatStyle);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", Options.CheckOptions);


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -102,6 +102,9 @@
 - Fix a minor bug in `add_new_check.py` to only traverse subdirectories
   when updating the list of checks in the documentation.
 
+- Deprecate the global configuration file option `AnalyzeTemporaryDtors`,
+  which is no longer in use. The option will be fully removed in clang-tidy 18.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -124,7 +124,7 @@
 IO.mapOptional("Checks", Options.Checks);
 IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
-IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // legacy compatibility
+IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // deprecated
 IO.mapOptional("FormatStyle", Options.FormatStyle);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", Options.CheckOptions);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141230: [clang-format-diff.py] give clang-format-diff a job pool (10x speed)

2023-01-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Can you add an option e.g. `-j N` where `N` is a positive integer and defaults 
to 1? Also, can you include a use case in which we can see the ~10x improvement 
on runtime?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141230/new/

https://reviews.llvm.org/D141230

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2023-01-12 Thread Sebastian Neubauer via Phabricator via cfe-commits
sebastian-ne added a comment.

FYI, the CMake file should use `PROJECT_SOURCE_DIR` instead of 
`CMAKE_SOURCE_DIR`, otherwise it breaks builds that use CMake’s 
add_subdirectory. I put up D141521  to fix 
that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137517/new/

https://reviews.llvm.org/D137517

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


[PATCH] D141586: [include-mapping] Replace the stdlib symbol maps with the newest official version from https://en.cppreference.com/w/File:html_book_20190607.zip.

2023-01-12 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
VitaNuo added a reviewer: hokein.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141586

Files:
  clang/include/clang/Tooling/Inclusions/CSymbolMap.inc
  clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc

Index: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
===
--- clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
+++ clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc
@@ -6,7 +6,7 @@
 // This file was generated automatically by
 // clang/tools/include-mapping/gen_std.py, DO NOT EDIT!
 //
-// Generated from cppreference offline HTML book (modified on 2018-10-28).
+// Generated from cppreference offline HTML book (modified on 2019-06-07).
 //===--===//
 
 SYMBOL(Assignable, std::, )
@@ -44,7 +44,11 @@
 SYMBOL(_Exit, std::, )
 SYMBOL(accumulate, std::, )
 SYMBOL(acos, std::, )
+SYMBOL(acosf, std::, )
 SYMBOL(acosh, std::, )
+SYMBOL(acoshf, std::, )
+SYMBOL(acoshl, std::, )
+SYMBOL(acosl, std::, )
 SYMBOL(add_const, std::, )
 SYMBOL(add_const_t, std::, )
 SYMBOL(add_cv, std::, )
@@ -74,6 +78,7 @@
 SYMBOL(alignment_of_v, std::, )
 SYMBOL(all_of, std::, )
 SYMBOL(allocate_shared, std::, )
+SYMBOL(allocate_shared_default_init, std::, )
 SYMBOL(allocator, std::, )
 SYMBOL(allocator_arg, std::, )
 SYMBOL(allocator_arg_t, std::, )
@@ -86,12 +91,23 @@
 SYMBOL(as_const, std::, )
 SYMBOL(asctime, std::, )
 SYMBOL(asin, std::, )
+SYMBOL(asinf, std::, )
 SYMBOL(asinh, std::, )
+SYMBOL(asinhf, std::, )
+SYMBOL(asinhl, std::, )
+SYMBOL(asinl, std::, )
+SYMBOL(assume_aligned, std::, )
 SYMBOL(async, std::, )
 SYMBOL(at_quick_exit, std::, )
 SYMBOL(atan, std::, )
 SYMBOL(atan2, std::, )
+SYMBOL(atan2f, std::, )
+SYMBOL(atan2l, std::, )
+SYMBOL(atanf, std::, )
 SYMBOL(atanh, std::, )
+SYMBOL(atanhf, std::, )
+SYMBOL(atanhl, std::, )
+SYMBOL(atanl, std::, )
 SYMBOL(atexit, std::, )
 SYMBOL(atof, std::, )
 SYMBOL(atoi, std::, )
@@ -128,7 +144,6 @@
 SYMBOL(atomic_store_explicit, std::, )
 SYMBOL(atomic_thread_fence, std::, )
 SYMBOL(atto, std::, )
-SYMBOL(auto_ptr, std::, )
 SYMBOL(back_insert_iterator, std::, )
 SYMBOL(back_inserter, std::, )
 SYMBOL(bad_alloc, std::, )
@@ -165,6 +180,7 @@
 SYMBOL(bidirectional_iterator_tag, std::, )
 SYMBOL(binary_search, std::, )
 SYMBOL(bind, std::, )
+SYMBOL(bind_front, std::, )
 SYMBOL(binomial_distribution, std::, )
 SYMBOL(bit_and, std::, )
 SYMBOL(bit_cast, std::, )
@@ -181,13 +197,18 @@
 SYMBOL(byte, std::, )
 SYMBOL(c16rtomb, std::, )
 SYMBOL(c32rtomb, std::, )
+SYMBOL(c8rtomb, std::, )
 SYMBOL(call_once, std::, )
 SYMBOL(calloc, std::, )
 SYMBOL(cauchy_distribution, std::, )
 SYMBOL(cbegin, std::, )
 SYMBOL(cbrt, std::, )
+SYMBOL(cbrtf, std::, )
+SYMBOL(cbrtl, std::, )
 SYMBOL(ceil, std::, )
 SYMBOL(ceil2, std::, )
+SYMBOL(ceilf, std::, )
+SYMBOL(ceill, std::, )
 SYMBOL(cend, std::, )
 SYMBOL(centi, std::, )
 SYMBOL(cerr, std::, )
@@ -226,14 +247,21 @@
 SYMBOL(conjunction, std::, )
 SYMBOL(conjunction_v, std::, )
 SYMBOL(const_pointer_cast, std::, )
+SYMBOL(contiguous_iterator_tag, std::, )
 SYMBOL(contract_violation, std::, )
 SYMBOL(copy, std::, )
 SYMBOL(copy_backward, std::, )
 SYMBOL(copy_if, std::, )
 SYMBOL(copy_n, std::, )
 SYMBOL(copysign, std::, )
+SYMBOL(copysignf, std::, )
+SYMBOL(copysignl, std::, )
 SYMBOL(cos, std::, )
+SYMBOL(cosf, std::, )
 SYMBOL(cosh, std::, )
+SYMBOL(coshf, std::, )
+SYMBOL(coshl, std::, )
+SYMBOL(cosl, std::, )
 SYMBOL(count, std::, )
 SYMBOL(count_if, std::, )
 SYMBOL(cout, std::, )
@@ -297,8 +325,14 @@
 SYMBOL(equal, std::, )
 SYMBOL(equal_range, std::, )
 SYMBOL(equal_to, std::, )
+SYMBOL(erase, std::, )
+SYMBOL(erase_if, std::, )
 SYMBOL(erf, std::, )
 SYMBOL(erfc, std::, )
+SYMBOL(erfcf, std::, )
+SYMBOL(erfcl, std::, )
+SYMBOL(erff, std::, )
+SYMBOL(erfl, std::, )
 SYMBOL(errc, std::, )
 SYMBOL(error_category, std::, )
 SYMBOL(error_code, std::, )
@@ -311,14 +345,25 @@
 SYMBOL(exit, std::, )
 SYMBOL(exp, std::, )
 SYMBOL(exp2, std::, )
+SYMBOL(exp2f, std::, )
+SYMBOL(exp2l, std::, )
+SYMBOL(expf, std::, )
+SYMBOL(expl, std::, )
 SYMBOL(expm1, std::, )
+SYMBOL(expm1f, std::, )
+SYMBOL(expm1l, std::, )
 SYMBOL(exponential_distribution, std::, )
 SYMBOL(extent, std::, )
 SYMBOL(extent_v, std::, )
 SYMBOL(extreme_value_distribution, std::, )
+SYMBOL(fabs, std::, )
+SYMBOL(fabsf, std::, )
+SYMBOL(fabsl, std::, )
 SYMBOL(false_type, std::, )
 SYMBOL(fclose, std::, )
 SYMBOL(fdim, std::, )
+SYMBOL(fdimf, std::, )
+SYMBOL(fdiml, std::, )
 SYMBOL(feclearexcept, std::, )
 SYMBOL(fegetenv, std::, )
 SYMBOL(fegetexceptflag, std::, )
@@ -356,12 +401,22 @@
 SYMBOL(float_t, std::, )
 SYMBOL(floor, std::, )
 SYMBOL(floor2, std::, )
+SYMBOL(floorf, std::, )
+SYMBOL(floorl, std::, )
 SYMBOL(flush, std::, )
 SYMBO

[PATCH] D140011: [clang][compiler-rt] Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR on Arm Linux and BSD

2023-01-12 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

I will wait until after the 16 branch happens to land this. The release build 
already has some issues and I won't have time to do the fixups in the next few 
weeks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140011/new/

https://reviews.llvm.org/D140011

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


[PATCH] D141280: [clang] Build UsingType for elaborated type specifiers.

2023-01-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Sema/DeclSpec.h:510
+  // Returns the underlying decl, if any.
   Decl *getRepAsDecl() const {
+auto *D = getRepAsFoundDecl();

urgh, this function is now misnamed, because the decl we're returning isn't the 
representation.
But changing it seems like a lot of unneccesary churn and confusion.
So no action required, I'm just making a face :-S


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141280/new/

https://reviews.llvm.org/D141280

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


[PATCH] D140941: [4/7][Clang][RISCV] Remove default tail-undisturbed for multiply-add intrinsics

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488571.
eopXD added a comment.

Rebase upon updated version of [3/N]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140941/new/

https://reviews.llvm.org/D140941

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccsu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccus.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccsu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccus.c

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


[PATCH] D141583: [clang-tidy][doc] Deprecate the AnalyzeTemporaryDtors option

2023-01-12 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

If we could get this in before 24th of January (release cut) it would be great, 
then we don't need to remove it in clang-tidy 19 :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141583/new/

https://reviews.llvm.org/D141583

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


[PATCH] D140942: [5/7][Clang][RISCV] Remove default tail-undisturbed for vcompress intrinsics

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488572.
eopXD added a comment.

Rebase upon update of [3/N]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140942/new/

https://reviews.llvm.org/D140942

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
@@ -9,532 +9,532 @@
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf4_t test_vcompress_vm_f16mf4(vbool64_t mask, vfloat16mf4_t dest, vfloat16mf4_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16mf4_t test_vcompress_vm_f16mf4(vbool64_t mask, vfloat16mf4_t src, size_t vl) {
+  return vcompress(mask, src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv2f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf2_t test_vcompress_vm_f16mf2(vbool32_t mask, vfloat16mf2_t dest, vfloat16mf2_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16mf2_t test_vcompress_vm_f16mf2(vbool32_t mask, vfloat16mf2_t src, size_t vl) {
+  return vcompress(mask, src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv4f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m1_t test_vcompress_vm_f16m1(vbool16_t mask, vfloat16m1_t dest, vfloat16m1_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m1_t test_vcompress_vm_f16m1(vbool16_t mask, vfloat16m1_t src, size_t vl) {
+  return vcompress(mask, src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv8f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m2_t test_vcompress_vm_f16m2(vbool8_t mask, vfloat16m2_t dest, vfloat16m2_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m2_t test_vcompress_vm_f16m2(vbool8_t mask, vfloat16m2_t src, size_t vl) {
+  return vcompress(mask, src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv16f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m4_t test_vcompress_vm_f16m4(vbool4_t mask, vfloat16m4_t dest, vfloat16m4_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m4_t test_vcompress_vm_f16m4(vbool4_t mask, vfloat16m4_t src, size_t vl) {
+  return vcompress(mask, src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m8(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv32f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv32f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m8_t test_vcompress_vm_f16m8(vbool2_t mask, vfloat16m8_t dest, vfloat16m8_t src, size_t vl) {
-  return vcompress(mask, dest, src, vl);
+vfloat16m8_t test_vcompress_vm_f16m8(vbool2_t mask, vfloat16m8_t src, size_t vl) {
+  return vcompress(mask, src, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f32mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f32.i64( [[DE

[PATCH] D140947: [6/7][Clang][RISCV] Remove default tail-undisturbed for vmv_s_x and vfmv_s_f intrinsics

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488573.
eopXD added a comment.

Rebase upon update of [3/N]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140947/new/

https://reviews.llvm.org/D140947

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
@@ -547,15 +547,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf8(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv1i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf8_t test_vmv_s_x_i8mf8(vint8mf8_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8mf4_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv2i8( [[SRC:%.*]])
@@ -565,15 +556,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv2i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf4_t test_vmv_s_x_i8mf4(vint8mf4_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8mf2_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv4i8( [[SRC:%.*]])
@@ -583,15 +565,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf2(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv4i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf2_t test_vmv_s_x_i8mf2(vint8mf2_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m1_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv8i8( [[SRC:%.*]])
@@ -601,15 +574,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m1(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv8i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m1_t test_vmv_s_x_i8m1(vint8m1_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m2_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv16i8( [[SRC:%.*]])
@@ -619,15 +583,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m2(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv16i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m2_t test_vmv_s_x_i8m2(vint8m2_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m4_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv32i8( [[SRC:%.*]])
@@ -637,15 +592,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv32i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m4_t test_vmv_s_x_i8m4(vint8m4_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m8_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv64i8( [[SRC:%.*]])
@@ -655,15 +601,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m8(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv64i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m8_t test_vmv_s_x_i8m8(vint8m8_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i16mf4_i16(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i16 @llvm.riscv.vmv.x.s.nxv1i16( [[SRC:%.*]])
@@ -673,15 +610,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i16mf4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV6

[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2023-01-12 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli marked an inline comment as done.
fpetrogalli added inline comments.



Comment at: llvm/include/llvm/TargetParser/CMakeLists.txt:3
+tablegen(LLVM RISCVTargetParserDef.inc -gen-riscv-target-def -I 
${CMAKE_SOURCE_DIR}/lib/Target/RISCV/)
+add_public_tablegen_target(RISCVTargetParserTableGen)
+

craig.topper wrote:
> fpetrogalli wrote:
> > thakis wrote:
> > > All other target tablegen'ing for all other targets (also for RISCV for 
> > > other .td changes) happen in llvm/lib/Target, not in llvm/TargetParser. 
> > > Is there any way this could be structured that way too? As-is, the 
> > > layering looks pretty unusual. (And your reland had to teach clang about 
> > > tablegen targets for that reason.)
> > Thanks for the feedback.
> > 
> > I can think of two possible solutions:
> > 
> > 1. Move the RISCV-only part of `llvm/lib/TargetParser` into 
> > `llvm/lib/Target`
> > 2. Move the whole TargetParser inside Target
> > 
> > However, I am not really sure if these are less unusual than the current 
> > state of things (or even technically possible).
> > 
> >  I am open for suggestions, and even more open to review a solution that 
> > fixes the unusual layering ;).
> > 
> I could be wrong, but I don't think clang depends on the LLVM's Target 
> libraries today.
@thakis - is D141581 a less unusual solution?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137517/new/

https://reviews.llvm.org/D137517

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


[PATCH] D140954: [7/7][Clang][RISCV][NFC] Remove attribute `IsPrototypeDefaultTU`

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488574.
eopXD added a comment.

Rebase upon update of [3/N]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140954/new/

https://reviews.llvm.org/D140954

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -66,7 +66,6 @@
   bool HasMasked :1;
   bool HasVL :1;
   bool HasMaskedOffOperand :1;
-  bool IsPrototypeDefaultTU : 1;
   bool HasTailPolicy : 1;
   bool HasMaskPolicy : 1;
   uint8_t UnMaskedPolicyScheme : 2;
@@ -518,7 +517,6 @@
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
 bool HasTailPolicy = R->getValueAsBit("HasTailPolicy");
 bool HasMaskPolicy = R->getValueAsBit("HasMaskPolicy");
-bool IsPrototypeDefaultTU = R->getValueAsBit("IsPrototypeDefaultTU");
 bool SupportOverloading = R->getValueAsBit("SupportOverloading");
 bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
@@ -549,13 +547,13 @@
 parsePrototypes(OverloadedSuffixProto);
 
 // Compute Builtin types
-auto Prototype = RVVIntrinsic::computeBuiltinTypes(
-BasicPrototype, /*IsMasked=*/false,
-/*HasMaskedOffOperand=*/false, HasVL, NF, IsPrototypeDefaultTU,
-UnMaskedPolicyScheme, Policy());
+auto Prototype =
+RVVIntrinsic::computeBuiltinTypes(BasicPrototype, /*IsMasked=*/false,
+  /*HasMaskedOffOperand=*/false, HasVL,
+  NF, UnMaskedPolicyScheme, Policy());
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-IsPrototypeDefaultTU, MaskedPolicyScheme, Policy());
+MaskedPolicyScheme, Policy());
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -577,22 +575,22 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-Policy(), IsPrototypeDefaultTU));
+Policy()));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
 RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF,
-IsPrototypeDefaultTU, UnMaskedPolicyScheme, P);
+UnMaskedPolicyScheme, P);
 std::optional PolicyTypes =
 TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-ManualCodegen, *PolicyTypes, IntrinsicTypes,
-RequiredFeatures, NF, P, IsPrototypeDefaultTU));
+ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
+NF, P));
   }
 if (!HasMasked)
   continue;
@@ -602,24 +600,23 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, ManualCodegen,
-*MaskTypes, IntrinsicTypes, RequiredFeatures, NF,
-Policy(), IsPrototypeDefaultTU));
+SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
+IntrinsicTypes, RequiredFeatures, NF, Policy()));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
   SmallVector PolicyPrototype =
   RVVIntrinsic::computeBuiltinTypes(
   BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  NF, IsPrototypeDefaultTU, MaskedPolicyScheme, P);
+  NF, MaskedPolicyScheme, P);
   std::optional PolicyTypes =
   TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
   Out.push_back(std::make_unique(
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   

[clang] bbe463d - [OptTable] Make ValuesCode initialisation of Options constexpr

2023-01-12 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-01-12T12:08:01+01:00
New Revision: bbe463d6ba268a2bfc45d539314b70cfd72d2360

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

LOG: [OptTable] Make ValuesCode initialisation of Options constexpr

Current implementation requires a copy of the initialization array to a
vector to be able to modify their Values field.

This is inefficient: it requires a large copy to update a value, while
TableGen has all information to avoid this overwrite.

Modify TableGen to emit the Values code and use it to perform the
initialisation.

The impact on performance is not amazing compared to the actual
compilation, but still noticeable:

https://llvm-compile-time-tracker.com/compare.php?from=d9ab3e82f30d646deff054230b0c742704a1cf26&to=f2b37fb65d5149f70b43d1801beb5239285a2a20&stat=instructions:u

Differential Revision: https://reviews.llvm.org/D140699

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/DriverOptions.cpp
llvm/include/llvm/Option/OptTable.h
llvm/lib/Option/OptTable.cpp
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3fcf9ddc29ea0..6cee51f72702f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4252,7 +4252,7 @@ def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   Group, HelpText<"Language standard to compile for">,
   ValuesCode<[{
-const char *Values =
+static constexpr const char VALUES_CODE [] =
 #define LANGSTANDARD(id, name, lang, desc, features) name ","
 #define LANGSTANDARD_ALIAS(id, alias) alias ","
 #include "clang/Basic/LangStandards.def"
@@ -5263,7 +5263,7 @@ def analyzer_stats : Flag<["-"], "analyzer-stats">,
 def analyzer_checker : Separate<["-"], "analyzer-checker">,
   HelpText<"Choose analyzer checkers to enable">,
   ValuesCode<[{
-const char *Values =
+static constexpr const char VALUES_CODE [] =
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, HT, DOC_URI, IS_HIDDEN)  FULLNAME ","
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"

diff  --git a/clang/lib/Driver/DriverOptions.cpp 
b/clang/lib/Driver/DriverOptions.cpp
index 197fa0a2eb69b..0a14749bc1106 100644
--- a/clang/lib/Driver/DriverOptions.cpp
+++ b/clang/lib/Driver/DriverOptions.cpp
@@ -16,6 +16,10 @@ using namespace clang::driver;
 using namespace clang::driver::options;
 using namespace llvm::opt;
 
+#define OPTTABLE_VALUES_CODE
+#include "clang/Driver/Options.inc"
+#undef OPTTABLE_VALUES_CODE
+
 #define PREFIX(NAME, VALUE)
\
   static constexpr llvm::StringLiteral NAME##_init[] = VALUE;  
\
   static constexpr llvm::ArrayRef NAME(   
\
@@ -43,16 +47,6 @@ class DriverOptTable : public OptTable {
 }
 
 const llvm::opt::OptTable &clang::driver::getDriverOptTable() {
-  static const DriverOptTable *Table = []() {
-auto Result = std::make_unique();
-// Options.inc is included in DriverOptions.cpp, and calls OptTable's
-// addValues function.
-// Opt is a variable used in the code fragment in Options.inc.
-OptTable &Opt = *Result;
-#define OPTTABLE_ARG_INIT
-#include "clang/Driver/Options.inc"
-#undef OPTTABLE_ARG_INIT
-return Result.release();
-  }();
-  return *Table;
+  static DriverOptTable Table;
+  return Table;
 }

diff  --git a/llvm/include/llvm/Option/OptTable.h 
b/llvm/include/llvm/Option/OptTable.h
index 52354eb954559..4933116968e66 100644
--- a/llvm/include/llvm/Option/OptTable.h
+++ b/llvm/include/llvm/Option/OptTable.h
@@ -60,7 +60,7 @@ class OptTable {
 
 private:
   /// The option information table.
-  std::vector OptionInfos;
+  ArrayRef OptionInfos;
   bool IgnoreCase;
   bool GroupedShortOptions = false;
   const char *EnvVar = nullptr;
@@ -174,17 +174,6 @@ class OptTable {
unsigned FlagsToInclude = 0, unsigned FlagsToExclude = 
0,
unsigned MinimumLength = 4) const;
 
-  /// Add Values to Option's Values class
-  ///
-  /// \param [in] Option - Prefix + Name of the flag which Values will be
-  ///  changed. For example, "-analyzer-checker".
-  /// \param [in] Values - String of Values seperated by ",", such as
-  ///  "foo, bar..", where foo and bar is the argument which the Option flag
-  ///  takes
-  ///
-  /// \return true in success, and false in fail.
-  bool addValues(StringRef Option, const char *Values);
-
   /// Parse a single argument; returning the new argument and
   /// updating Index.
   ///

diff  --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTabl

[PATCH] D140699: [OptTable] Make ValuesCode initialisation of Options constexpr

2023-01-12 Thread serge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbe463d6ba26: [OptTable] Make ValuesCode initialisation of 
Options constexpr (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140699/new/

https://reviews.llvm.org/D140699

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/DriverOptions.cpp
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/Option/OptTable.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -259,6 +259,21 @@
   OS << "#undef COMMA\n";
   OS << "#endif // PREFIX\n\n";
 
+  OS << "/\n";
+  OS << "// ValuesCode\n\n";
+  OS << "#ifdef OPTTABLE_VALUES_CODE\n";
+  for (const Record &R : llvm::make_pointee_range(Opts)) {
+// The option values, if any;
+if (!isa(R.getValueInit("ValuesCode"))) {
+  assert(isa(R.getValueInit("Values")) &&
+ "Cannot choose between Values and ValuesCode");
+  OS << "#define VALUES_CODE " << getOptionName(R) << "_Values\n";
+  OS << R.getValueAsString("ValuesCode") << "\n";
+  OS << "#undef VALUES_CODE\n";
+}
+  }
+  OS << "#endif\n";
+
   OS << "/\n";
   OS << "// Groups\n\n";
   OS << "#ifdef OPTION\n";
@@ -388,6 +403,9 @@
 OS << ", ";
 if (!isa(R.getValueInit("Values")))
   write_cstring(OS, R.getValueAsString("Values"));
+else if (!isa(R.getValueInit("ValuesCode"))) {
+  OS << getOptionName(R) << "_Values";
+}
 else
   OS << "nullptr";
   };
@@ -460,29 +478,5 @@
   OS << "\n";
 
   OS << "\n";
-  OS << "#ifdef OPTTABLE_ARG_INIT\n";
-  OS << "//\n";
-  OS << "// Option Values\n\n";
-  for (const Record &R : llvm::make_pointee_range(Opts)) {
-if (isa(R.getValueInit("ValuesCode")))
-  continue;
-OS << "{\n";
-OS << "bool ValuesWereAdded;\n";
-OS << R.getValueAsString("ValuesCode");
-OS << "\n";
-for (StringRef Prefix : R.getValueAsListOfStrings("Prefixes")) {
-  OS << "ValuesWereAdded = Opt.addValues(";
-  std::string S(Prefix);
-  S += R.getValueAsString("Name");
-  write_cstring(OS, S);
-  OS << ", Values);\n";
-  OS << "(void)ValuesWereAdded;\n";
-  OS << "assert(ValuesWereAdded && \"Couldn't add values to "
-"OptTable!\");\n";
-}
-OS << "}\n";
-  }
-  OS << "\n";
-  OS << "#endif // OPTTABLE_ARG_INIT\n";
 }
 } // end namespace llvm
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -300,17 +300,6 @@
   return BestDistance;
 }
 
-bool OptTable::addValues(StringRef Option, const char *Values) {
-  for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
-Info &In = OptionInfos[I];
-if (optionMatches(In, Option)) {
-  In.Values = Values;
-  return true;
-}
-  }
-  return false;
-}
-
 // Parse a single argument, return the new argument, and update Index. If
 // GroupedShortOptions is true, -a matches "-abc" and the argument in Args will
 // be updated to "-bc". This overload does not support
Index: llvm/include/llvm/Option/OptTable.h
===
--- llvm/include/llvm/Option/OptTable.h
+++ llvm/include/llvm/Option/OptTable.h
@@ -60,7 +60,7 @@
 
 private:
   /// The option information table.
-  std::vector OptionInfos;
+  ArrayRef OptionInfos;
   bool IgnoreCase;
   bool GroupedShortOptions = false;
   const char *EnvVar = nullptr;
@@ -174,17 +174,6 @@
unsigned FlagsToInclude = 0, unsigned FlagsToExclude = 0,
unsigned MinimumLength = 4) const;
 
-  /// Add Values to Option's Values class
-  ///
-  /// \param [in] Option - Prefix + Name of the flag which Values will be
-  ///  changed. For example, "-analyzer-checker".
-  /// \param [in] Values - String of Values seperated by ",", such as
-  ///  "foo, bar..", where foo and bar is the argument which the Option flag
-  ///  takes
-  ///
-  /// \return true in success, and false in fail.
-  bool addValues(StringRef Option, const char *Values);
-
   /// Parse a single argument; returning the new argument and
   /// updating Index.
   ///
Index: clang/lib/Driver/DriverOptions.cpp
===
--- clang/lib/Driver/DriverOptions.cpp
+++ clang/lib/Driver/DriverOptions.cpp
@@ -16,6 +16,10 @@
 using namespace clang::driver::options;
 using namespace llvm::opt;
 
+#define OPTTABLE_VALUES_CODE
+#include "clang/Driver/Options.inc"
+#undef OPTTABLE_VALUES_CODE
+
 #define PREFIX(NAME, VALUE)\
   static constexpr 

[clang] 07bb29d - [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-01-12T12:08:06+01:00
New Revision: 07bb29d8ffc3b82d5a7bb1217d93e8fa86e6969a

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

LOG: [OptTable] Precompute OptTable prefixes union table through tablegen

This avoid rediscovering this table when reading each options, providing
a sensible 2% speedup when processing and empty file, and a measurable
speedup on typical workloads, see:

This is optional, the legacy, on-the-fly, approach can still be used
through the GenericOptTable class, while the new one is used through
PrecomputedOptTable.

https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u

Differential Revision: https://reviews.llvm.org/D140800

Added: 


Modified: 
clang/lib/Driver/DriverOptions.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
lld/COFF/Driver.h
lld/COFF/DriverUtils.cpp
lld/ELF/Driver.h
lld/ELF/DriverUtils.cpp
lld/MachO/Driver.h
lld/MachO/DriverUtils.cpp
lld/MinGW/Driver.cpp
lld/wasm/Driver.cpp
lldb/tools/driver/Driver.cpp
lldb/tools/lldb-server/lldb-gdbserver.cpp
lldb/tools/lldb-vscode/lldb-vscode.cpp
llvm/include/llvm/Option/OptTable.h
llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
llvm/lib/Option/OptTable.cpp
llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-cvtres/llvm-cvtres.cpp
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/tools/llvm-ml/llvm-ml.cpp
llvm/tools/llvm-mt/llvm-mt.cpp
llvm/tools/llvm-nm/llvm-nm.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-rc/llvm-rc.cpp
llvm/tools/llvm-readobj/llvm-readobj.cpp
llvm/tools/llvm-size/llvm-size.cpp
llvm/tools/llvm-strings/llvm-strings.cpp
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
llvm/unittests/Option/OptionParsingTest.cpp
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/lib/Driver/DriverOptions.cpp 
b/clang/lib/Driver/DriverOptions.cpp
index 0a14749bc1106..2a6868d179159 100644
--- a/clang/lib/Driver/DriverOptions.cpp
+++ b/clang/lib/Driver/DriverOptions.cpp
@@ -27,6 +27,14 @@ using namespace llvm::opt;
 #include "clang/Driver/Options.inc"
 #undef PREFIX
 
+static constexpr const llvm::StringLiteral PrefixTable_init[] =
+#define PREFIX_UNION(VALUES) VALUES
+#include "clang/Driver/Options.inc"
+#undef PREFIX_UNION
+;
+static constexpr const llvm::ArrayRef
+PrefixTable(PrefixTable_init, std::size(PrefixTable_init) - 1);
+
 static constexpr OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  
\
HELPTEXT, METAVAR, VALUES)  
\
@@ -38,12 +46,10 @@ static constexpr OptTable::Info InfoTable[] = {
 
 namespace {
 
-class DriverOptTable : public OptTable {
+class DriverOptTable : public PrecomputedOptTable {
 public:
-  DriverOptTable()
-: OptTable(InfoTable) {}
+  DriverOptTable() : PrecomputedOptTable(InfoTable, PrefixTable) {}
 };
-
 }
 
 const llvm::opt::OptTable &clang::driver::getDriverOptTable() {

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index e64bf70a06e8d..4f23403166543 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -23,6 +23,7 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index ad942efb352e8..a6e127c34034f 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -138,9 +138,9 @@ static constexpr OptTable::Info InfoTable[] = {
 #undef OPTION
 };
 
-class WrapperOptTable : public opt::OptTable {
+class WrapperOptTable : public opt::GenericOptTable {
 public:
-  WrapperOptTable() : OptTable(InfoTable) {}
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
 };
 
 const OptTable &getOptTable() {

diff  --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h
index 28bf2cc81ef37..8ec3bb464206e 100644
--- a/lld/COFF/Driver.h
+++ b/lld/COFF

[PATCH] D140800: [OptTable] Precompute OptTable prefixes union table through tablegen

2023-01-12 Thread serge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG07bb29d8ffc3: [OptTable] Precompute OptTable prefixes union 
table through tablegen (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140800/new/

https://reviews.llvm.org/D140800

Files:
  clang/lib/Driver/DriverOptions.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llvm/include/llvm/Option/OptTable.h
  llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
  llvm/lib/Option/OptTable.cpp
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -237,8 +237,14 @@
   CurPrefix = NewPrefix;
   }
 
-  // Dump prefixes.
+  DenseSet PrefixesUnionSet;
+  for (const auto &Prefix : Prefixes)
+PrefixesUnionSet.insert(Prefix.first.begin(), Prefix.first.end());
+  SmallVector PrefixesUnion(PrefixesUnionSet.begin(),
+   PrefixesUnionSet.end());
+  array_pod_sort(PrefixesUnion.begin(), PrefixesUnion.end());
 
+  // Dump prefixes.
   OS << "/\n";
   OS << "// Prefixes\n\n";
   OS << "#ifdef PREFIX\n";
@@ -259,6 +265,20 @@
   OS << "#undef COMMA\n";
   OS << "#endif // PREFIX\n\n";
 
+  // Dump prefix unions.
+  OS << "/\n";
+  OS << "// Prefix Union\n\n";
+  OS << "#ifdef PREFIX_UNION\n";
+  OS << "#define COMMA ,\n";
+  OS << "PREFIX_UNION({\n";
+  for (const auto &Prefix : PrefixesUnion) {
+OS << "llvm::StringLiteral(\"" << Prefix << "\") COMMA ";
+  }
+  OS << "llvm::StringLiteral(\"\")})\n";
+  OS << "#undef COMMA\n";
+  OS << "#endif // PREFIX_UNION\n\n";
+
+  // Dump groups.
   OS << "/\n";
   OS << "// ValuesCode\n\n";
   OS << "#ifdef OPTTABLE_VALUES_CODE\n";
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -32,6 +32,14 @@
 #include "Opts.inc"
 #undef PREFIX
 
+static constexpr const StringLiteral PrefixTable_init[] =
+#define PREFIX_UNION(VALUES) VALUES
+#include "Opts.inc"
+#undef PREFIX_UNION
+;
+static constexpr const ArrayRef
+PrefixTable(PrefixTable_init, std::size(PrefixTable_init) - 1);
+
 enum OptionFlags {
   OptFlag1 = (1 << 4),
   OptFlag2 = (1 << 5),
@@ -48,10 +56,16 @@
 };
 
 namespace {
-class TestOptTable : public OptTable {
+class TestOptTable : public GenericOptTable {
 public:
   TestOptTable(bool IgnoreCase = false)
-: OptTable(InfoTable, IgnoreCase) {}
+  : GenericOptTable(InfoTable, IgnoreCase) {}
+};
+
+class TestPrecomputedOptTable : public PrecomputedOptTable {
+public:
+  TestPrecomputedOptTable(bool IgnoreCase = false)
+  : PrecomputedOptTable(InfoTable, PrefixTable, IgnoreCase) {}
 };
 }
 
@@ -67,8 +81,20 @@
   "-Gchuu", "2"
   };
 
-TEST(Option, OptionParsing) {
-  TestOptTable T;
+// Test fixture
+template  class OptTableTest : public ::testing::Test {};
+
+template  class DISABLED_OptTableTest : public ::testing::Test {};
+
+// Test both precomputed and computed OptTables with the same suite of tests.
+using OptTableTestTypes =
+::testing::Types;
+
+TYPED_TEST_SUITE(OptTableTest, OptTableTestTypes, );
+TYPED_TEST_SUITE(DISABLED_OptTableTest, OptTableTestTypes, );
+
+TYPED_TEST(OptTableTest, OptionParsing) {
+  TypeParam T;
   unsigned MAI, MAC;
   InputArgList AL = T.ParseArgs(Args, MAI, MAC);
 
@@ -114,8 +140,8 @@
   EXPECT_EQ("desu", StringRef(ASL[1]));
 }
 
-TEST(Option, ParseWithFlagExclusions) {
-  TestOptTable T;
+TYPED_TEST(OptTableTest, P

[PATCH] D141573: [WIP][1/N][Clang][RISCV][NFC] Extract common utility to RISCVVIntrinsicUtils

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488578.
eopXD added a comment.

Bump CI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141573/new/

https://reviews.llvm.org/D141573

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -528,12 +528,8 @@
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
 
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);
 
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -980,6 +980,12 @@
   return NewPrototype;
 }
 
+llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
+  return {
+  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
+  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+}
+
 llvm::SmallVector
 RVVIntrinsic::getSupportedMaskedPolicies(bool HasTailPolicy,
  bool HasMaskPolicy) {
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -204,13 +204,9 @@
 
 bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
 bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
-llvm::SmallVector SupportedMaskedPolicies =
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
+SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(Record.HasTailPolicy,
  Record.HasMaskPolicy);
 
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -475,6 +475,8 @@
   bool IsMasked, bool HasMaskedOffOperand, bool HasVL,
   unsigned NF, PolicyScheme DefaultScheme,
   Policy PolicyAttrs);
+
+  static llvm::SmallVector getSupportedUnMaskedPolicies();
   static llvm::SmallVector
   getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy);
 


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -528,12 +528,8 @@
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
 
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);
 
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -980,6 +980,12 @@
   return NewPrototype;
 }
 
+llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
+  return {
+  Policy(Policy::PolicyTy

[PATCH] D141574: [WIP][2/N][Clang][RISCV][NFC] Rename Policy::IsPolicyNone to IsUnspecifed

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488579.
eopXD added a comment.

Bump CI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141574/new/

https://reviews.llvm.org/D141574

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,9 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isPolicyNonePolicy()) {
+  if (PolicyAttrs.isUnspecified()) {
 if (!IsMasked) {
-  PolicyAttrs.PolicyNone = false;
+  PolicyAttrs.IsUnspecified = false;
   PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
 }
   }
@@ -1022,8 +1022,8 @@
 OverloadedName += suffix;
   };
 
-  if (PolicyAttrs.isPolicyNonePolicy()) {
-PolicyAttrs.PolicyNone = false;
+  if (PolicyAttrs.isUnspecified()) {
+PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   // FIXME: Currently _m default policy implementation is different with
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -93,7 +93,7 @@
 };
 
 struct Policy {
-  bool PolicyNone = false;
+  bool IsUnspecified = false;
   enum PolicyType {
 Undisturbed,
 Agnostic,
@@ -102,7 +102,7 @@
   PolicyType TailPolicy = Omit;
   PolicyType MaskPolicy = Omit;
   bool IntrinsicWithoutMU = false;
-  Policy() : PolicyNone(true) {}
+  Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy,
  bool _IntrinsicWithoutMU = false)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy),
@@ -150,11 +150,11 @@
 return MaskPolicy == Undisturbed && TailPolicy == Omit;
   }
 
-  bool isPolicyNonePolicy() const { return PolicyNone; }
+  bool isUnspecified() const { return IsUnspecified; }
 
   bool operator==(const Policy &Other) const {
-return PolicyNone == Other.PolicyNone && TailPolicy == Other.TailPolicy &&
-   MaskPolicy == Other.MaskPolicy &&
+return IsUnspecified == Other.IsUnspecified &&
+   TailPolicy == Other.TailPolicy && MaskPolicy == Other.MaskPolicy &&
IntrinsicWithoutMU == Other.IntrinsicWithoutMU;
   }
 
@@ -434,7 +434,7 @@
 return IntrinsicTypes;
   }
   Policy getPolicyAttrs() const {
-assert(PolicyAttrs.PolicyNone == false);
+assert(PolicyAttrs.IsUnspecified == false);
 return PolicyAttrs;
   }
   unsigned getPolicyAttrsBits() const {
@@ -444,7 +444,7 @@
 // constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3;
 // FIXME: how about value 2
 // int PolicyAttrs = TAIL_UNDISTURBED;
-assert(PolicyAttrs.PolicyNone == false);
+assert(PolicyAttrs.IsUnspecified == false);
 
 if (PolicyAttrs.isTUMAPolicy())
   return 2;


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,9 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isPolicyNonePolicy()) {
+  if (PolicyAttrs.isUnspecified()) {
 if (!IsMasked) {
-  PolicyAttrs.PolicyNone = false;
+  PolicyAttrs.IsUnspecified = false;
   PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
 }
   }
@@ -1022,8 +1022,8 @@
 OverloadedName += suffix;
   };
 
-  if (PolicyAttrs.isPolicyNonePolicy()) {
-PolicyAttrs.PolicyNone = false;
+  if (PolicyAttrs.isUnspecified()) {
+PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   // FIXME: Currently _m default policy implementation is different with
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -93,7 +93,7 @@
 };
 
 struct Policy {
-  bool PolicyNone = false;
+  bool IsUnspecified = false;
   enum PolicyType {
 Undisturbed,
 Agnostic,
@@ -102,7 +102,7 @@
   PolicyType TailPolicy = Omit;
   PolicyType MaskPolicy = Omit;
   bool IntrinsicWithoutMU = false;
-  Policy() : PolicyNone(true) {}
+  Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy,
  bool _IntrinsicWithoutMU = false)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy),
@@ -150,11 +150,11 @@
   

[PATCH] D141575: [WIP][3/N][Clang][RISCV][NFC] Clarify edge cases of RVVIntrinsic::getSupportedMaskedPolicies for clarity

2023-01-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 488580.
eopXD added a comment.

Bump CI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141575/new/

https://reviews.llvm.org/D141575

Files:
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -998,16 +999,18 @@
Policy::PolicyType::Undisturbed), // TUMU
 Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // TAMU
-
-  if (HasTailPolicy)
+  if (HasTailPolicy && !HasMaskPolicy)
 return {Policy(Policy::PolicyType::Undisturbed,
Policy::PolicyType::Agnostic, true), // TUM
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
true)}; // TAM
-
-  return {
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed)}; // MU
+  if (!HasTailPolicy && HasMaskPolicy)
+return {
+Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Omit,
+   Policy::PolicyType::Undisturbed)}; // MU
+  llvm_unreachable("An RVV instruction should not be without both tail policy "
+   "and mask policy");
 }
 
 void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -998,16 +999,18 @@
Policy::PolicyType::Undisturbed), // TUMU
 Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // TAMU
-
-  if (HasTailPolicy)
+  if (HasTailPolicy && !HasMaskPolicy)
 return {Policy(Policy::PolicyType::Undisturbed,
Policy::PolicyType::Agnostic, true), // TUM
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
true)}; // TAM
-
-  return {
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed)}; // MU
+  if (!HasTailPolicy && HasMaskPolicy)
+return {
+Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Omit,
+   Policy::PolicyType::Undisturbed)}; // MU
+  llvm_unreachable("An RVV instruction should not be without both tail policy "
+   "and mask policy");
 }
 
 void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141050: [standalone-build] outsource, simplify and unify repetitive CMake code

2023-01-12 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 488582.
kwk added a comment.

- both, build tree and install method support find_package by setting different 
LLVM_CMAKE_DIR


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141050/new/

https://reviews.llvm.org/D141050

Files:
  clang/CMakeLists.txt
  cmake/Modules/StandaloneBuildHelpers.cmake
  lld/CMakeLists.txt

Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -23,23 +23,16 @@
 # Must go below project(..)
 include(GNUInstallDirs)
 
-if(LLD_BUILT_STANDALONE)
-  set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
-  set(CMAKE_CXX_STANDARD_REQUIRED YES)
-  set(CMAKE_CXX_EXTENSIONS NO)
-
-  set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
-
-  # Turn into CACHE PATHs for overwritting
-  set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
-  set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree")
+# Make sure that our source directory is on the current cmake module path so that
+# we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
 
-  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
-NO_DEFAULT_PATH)
+if(LLD_BUILT_STANDALONE)
+  include(StandaloneBuildHelpers)
+  require_llvm_utility_binary_path("llvm-tblgen" LLVM_TABLEGEN_EXE)
 
   # They are used as destination of target generators.
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
@@ -59,53 +52,17 @@
   if(LLVM_INCLUDE_TESTS)
 find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
   COMPONENTS Interpreter)
-
-# Check prebuilt llvm/utils.
-if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
-AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/not${CMAKE_EXECUTABLE_SUFFIX})
-  set(LLVM_UTILS_PROVIDED ON)
-endif()
-
-if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
-  # Note: path not really used, except for checking if lit was found
-  set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
-  if(NOT LLVM_UTILS_PROVIDED)
-add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
-add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/not utils/not)
-set(LLVM_UTILS_PROVIDED ON)
-set(LLD_TEST_DEPS FileCheck not)
-  endif()
-  set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest)
-  if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
-  AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
-  AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
-add_subdirectory(${UNITTEST_DIR} third-party/unittest)
-  endif()
-else()
-  # Seek installed Lit.
-  find_program(LLVM_LIT
-   NAMES llvm-lit lit.py lit
-   PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
-   DOC "Path to lit.py")
-endif()
-
-if(LLVM_LIT)
-  # Define the default arguments to use with 'lit', and an option for the user
-  # to override.
-  set(LIT_ARGS_DEFAULT "-sv")
-  if (MSVC OR XCODE)
-set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
-  endif()
-  set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
-
-  get_errc_messages(LLVM_LIT_ERRC_MESSAGES)
-
-  # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
-  if(WIN32 AND NOT CYGWIN)
-set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
-  endif()
-else()
-  set(LLVM_INCLUDE_TESTS OFF)
+find_external_lit()
+set_lit_defaults()
+require_llvm_utility_binary_path("FileCheck")
+require_llvm_utility_binary_path("count")
+require_llvm_utility_binary_path("not")
+
+set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest)
+if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
+AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
+AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
+  add_subdirectory(${UNITTEST_DIR} third-party/unittest)
 endif()
   endif()
 
@@ -153,12 +110,6 @@
 "`CMakeFiles'. Please delete them.")
 endif()
 
-# Add path for custom modules.
-list(INSERT CMAKE_MODULE_PATH 0
-  "${LLD_SOURCE_DIR}/cmake/modules"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-  )
-
 include(AddLLD)
 
 option(LLD_USE_VTUNE
Index: cmake/Modules/StandaloneBuildHelpers.cmake
===
--- /dev/null
+++ cmake/Modules/StandaloneBuildHel

[PATCH] D141591: [clang][Interp] Properly identify not-yet-defined functions

2023-01-12 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  Since we now handle functions without a body as well, we can't just use
  getHasBody() anymore. Funtions that haven't been defined yet are those
  that don't have a body *and* aren't valid.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141591

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Function.h
  clang/test/AST/Interp/functions.cpp


Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -154,3 +154,12 @@
 }
 
 }
+
+struct F {
+  constexpr bool ok() const {
+return okRecurse();
+  }
+  constexpr bool okRecurse() const {
+return true;
+  }
+};
Index: clang/lib/AST/Interp/Function.h
===
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -157,7 +157,7 @@
 SrcMap = std::move(NewSrcMap);
 Scopes = std::move(NewScopes);
 IsValid = true;
-HasBody = true;
+HasBody = NewCode.size() > 0;
   }
 
   void setIsFullyCompiled(bool FC) { IsFullyCompiled = FC; }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1484,7 +1484,7 @@
   assert(FD);
   const Function *Func = P.getFunction(FD);
   bool IsBeingCompiled = Func && !Func->isFullyCompiled();
-  bool WasNotDefined = Func && !Func->hasBody();
+  bool WasNotDefined = Func && !Func->isConstexpr() && !Func->hasBody();
 
   if (IsBeingCompiled)
 return Func;


Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -154,3 +154,12 @@
 }
 
 }
+
+struct F {
+  constexpr bool ok() const {
+return okRecurse();
+  }
+  constexpr bool okRecurse() const {
+return true;
+  }
+};
Index: clang/lib/AST/Interp/Function.h
===
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -157,7 +157,7 @@
 SrcMap = std::move(NewSrcMap);
 Scopes = std::move(NewScopes);
 IsValid = true;
-HasBody = true;
+HasBody = NewCode.size() > 0;
   }
 
   void setIsFullyCompiled(bool FC) { IsFullyCompiled = FC; }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1484,7 +1484,7 @@
   assert(FD);
   const Function *Func = P.getFunction(FD);
   bool IsBeingCompiled = Func && !Func->isFullyCompiled();
-  bool WasNotDefined = Func && !Func->hasBody();
+  bool WasNotDefined = Func && !Func->isConstexpr() && !Func->hasBody();
 
   if (IsBeingCompiled)
 return Func;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141592: [include-cleaner] Treat a constructor call as a use of the class type.

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

Per the discussion in https://github.com/llvm/llvm-project/issues/59916.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141592

Files:
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -240,9 +240,10 @@
 
 TEST(WalkAST, ConstructExprs) {
   testWalk("struct $implicit^S {};", "S ^t;");
-  testWalk("struct S { $implicit^S(); };", "S ^t;");
-  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");
-  testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
+  testWalk("struct $implicit^S { S(); };", "S ^t;");
+  testWalk("struct $explicit^S { S(int); };", "S ^t(42);");
+  testWalk("struct $implicit^S { S(int); };", "S t = ^42;");
+  testWalk("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;");
 }
 
 TEST(WalkAST, Operator) {
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -104,7 +104,7 @@
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
-report(E->getLocation(), E->getConstructor(),
+report(E->getLocation(), getMemberProvider(E->getType()),
E->getParenOrBraceRange().isValid() ? RefType::Explicit
: RefType::Implicit);
 return true;


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -240,9 +240,10 @@
 
 TEST(WalkAST, ConstructExprs) {
   testWalk("struct $implicit^S {};", "S ^t;");
-  testWalk("struct S { $implicit^S(); };", "S ^t;");
-  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");
-  testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
+  testWalk("struct $implicit^S { S(); };", "S ^t;");
+  testWalk("struct $explicit^S { S(int); };", "S ^t(42);");
+  testWalk("struct $implicit^S { S(int); };", "S t = ^42;");
+  testWalk("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;");
 }
 
 TEST(WalkAST, Operator) {
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -104,7 +104,7 @@
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
-report(E->getLocation(), E->getConstructor(),
+report(E->getLocation(), getMemberProvider(E->getType()),
E->getParenOrBraceRange().isValid() ? RefType::Explicit
: RefType::Implicit);
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137487: [clang][Interp] Start implementing builtin functions

2023-01-12 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked 2 inline comments as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:1315
+  if (InterpretBuiltin(S, PC, Func->getBuiltinID())) {
+NewFrame.release();
+return true;

shafik wrote:
> We don't have to update `S.Current`?
Nope, `Ret` does that.



Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:20
+template ::T>
+static bool Ret(InterpState &S, CodePtr &PC) {
+  S.CallStackDepth--;

shafik wrote:
> Why not just factor out `Ret` now?
The two implementations are slightly different now and I wanted to see if they 
diverge more int he future. But I've factored them together as part of 
https://reviews.llvm.org/D141193


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137487/new/

https://reviews.llvm.org/D137487

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


[PATCH] D140711: [clang] Fix unused variable warning in SemaConcept.cpp

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:1348
   bool &Result) {
   if (const auto *FD1 = dyn_cast(D1)) {
 auto IsExpectedEntity = [](const FunctionDecl *FD) {

cor3ntin wrote:
> 
we still need the FD1 as there is a `IsExpectedEntity(FD1)` call in the assert 
on L1358.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140711/new/

https://reviews.llvm.org/D140711

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


[clang] d0a98ef - [clang] Fix unused variable warning in SemaConcept.cpp

2023-01-12 Thread Haojian Wu via cfe-commits

Author: Victor Komarov
Date: 2023-01-12T12:55:34+01:00
New Revision: d0a98efb6819182138fab2e4028ab77d30f8b278

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

LOG: [clang] Fix unused variable warning in SemaConcept.cpp

Issue is described here: https://github.com/llvm/llvm-project/issues/59696

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D140711

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index af920693859e..3ab93827cd31 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1354,6 +1354,7 @@ bool Sema::IsAtLeastAsConstrained(NamedDecl *D1,
 };
 const auto *FD2 = dyn_cast(D2);
 (void)IsExpectedEntity;
+(void)FD1;
 (void)FD2;
 assert(IsExpectedEntity(FD1) && FD2 && IsExpectedEntity(FD2) &&
"use non-instantiated function declaration for constraints partial "



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


[PATCH] D140711: [clang] Fix unused variable warning in SemaConcept.cpp

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0a98efb6819: [clang] Fix unused variable warning in 
SemaConcept.cpp (authored by Victor Komarov , committed by 
hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140711/new/

https://reviews.llvm.org/D140711

Files:
  clang/lib/Sema/SemaConcept.cpp


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -1354,6 +1354,7 @@
 };
 const auto *FD2 = dyn_cast(D2);
 (void)IsExpectedEntity;
+(void)FD1;
 (void)FD2;
 assert(IsExpectedEntity(FD1) && FD2 && IsExpectedEntity(FD2) &&
"use non-instantiated function declaration for constraints partial "


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -1354,6 +1354,7 @@
 };
 const auto *FD2 = dyn_cast(D2);
 (void)IsExpectedEntity;
+(void)FD1;
 (void)FD2;
 assert(IsExpectedEntity(FD1) && FD2 && IsExpectedEntity(FD2) &&
"use non-instantiated function declaration for constraints partial "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140711: [clang] Fix unused variable warning in SemaConcept.cpp

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> Hey @hokein, thanks for the accept. I don't have commit rights, can you 
> please land this?

Done. Sorry for the late response (I totally missed this).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140711/new/

https://reviews.llvm.org/D140711

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


[PATCH] D141596: [Driver] Add crtfastmath.o on Solaris if appropriate

2023-01-12 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added a reviewer: MaskRay.
ro added a project: clang.
Herald added subscribers: jrtc27, fedor.sergeev, jyknight.
Herald added a project: All.
ro requested review of this revision.

`Flang :: Driver/fast_math.f90` `FAIL`s on Solaris because `crtfastmath.o` is 
missing from the link line.

This patch adds it as appropriate.

Tested on `amd64-pc-solaris2.11`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141596

Files:
  clang/lib/Driver/ToolChains/Solaris.cpp
  
clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
  
clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
  
clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
  
clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
  clang/test/Driver/solaris-ld.c


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -114,3 +114,57 @@
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
 // CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o
+
+// Check that crtfastmath.o is linked with -ffast-math.
+
+// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC32 %s
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
+// CHECK-CRTFASTMATH-SPARC32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC32: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC32-NOT: crtfastmath.o
+
+// Check sparc-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC64 %s
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC64 %s
+// CHECK-CRTFASTMATH-SPARC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC64: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC64-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 32bit
+// RUN: %clang --target=i386-pc-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X32 %s
+// RUN: %clang --target=i386-pc-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-X32 %s
+// CHECK-CRTFASTMATH-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-X32: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-X32-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X64 %s
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-X64 %s
+// CHECK-CRTFASTMATH-X64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-X64: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-X64-NOT: crtfastmath.o
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -115,6 +115,8 @@
 Args.MakeArgString(getToolChain().GetFilePath(values_xpg)));
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
+// Add crtfastmath.o if available and fast math is enabled.
+getToolChain().addFastMathRuntimeIfAvailable(Args, CmdArgs);
   }
 
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/tes

[PATCH] D141598: [clang] Redefine some AVR specific macros

2023-01-12 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: aykevl, Miss_Grape.
Herald added subscribers: Jim, dylanmckay.
Herald added a project: All.
benshi001 requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141598

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4320,6 +4320,22 @@
 // CHECK_R600_FP64-DAG: #define __R600__ 1
 // CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
 
+// Begin avr tests 
+
+// RUN: %clang --target=avr -mmcu=atmega328 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR0
+// CHECK-AVR0: #define __AVR_ARCH__ 5
+// CHECK-AVR0: #define __AVR_ATmega328__ 1
+// CHECK-AVR0: #define __flash __attribute__((__address_space__(1)))
+// RUN: %clang --target=avr -mmcu=atmega2560 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR1
+// CHECK-AVR1: #define __AVR_ARCH__ 6
+// CHECK-AVR1: #define __AVR_ATmega2560__ 1
+// CHECK-AVR1: #define __flash  __attribute__((__address_space__(1)))
+// CHECK-AVR1: #define __flash1 __attribute__((__address_space__(2)))
+// CHECK-AVR1: #define __flash2 __attribute__((__address_space__(3)))
+// CHECK-AVR1: #define __flash3 __attribute__((__address_space__(4)))
+
 // Begin M68k tests 
 
 // RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -468,15 +468,15 @@
   }
 
   if (NumFlashBanks >= 1)
-Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
+Builder.defineMacro("__flash", "__attribute__((__address_space__(1)))");
   if (NumFlashBanks >= 2)
-Builder.defineMacro("__flash1", "__attribute__((address_space(2)))");
+Builder.defineMacro("__flash1", "__attribute__((__address_space__(2)))");
   if (NumFlashBanks >= 3)
-Builder.defineMacro("__flash2", "__attribute__((address_space(3)))");
+Builder.defineMacro("__flash2", "__attribute__((__address_space__(3)))");
   if (NumFlashBanks >= 4)
-Builder.defineMacro("__flash3", "__attribute__((address_space(4)))");
+Builder.defineMacro("__flash3", "__attribute__((__address_space__(4)))");
   if (NumFlashBanks >= 5)
-Builder.defineMacro("__flash4", "__attribute__((address_space(5)))");
+Builder.defineMacro("__flash4", "__attribute__((__address_space__(5)))");
   if (NumFlashBanks >= 6)
-Builder.defineMacro("__flash5", "__attribute__((address_space(6)))");
+Builder.defineMacro("__flash5", "__attribute__((__address_space__(6)))");
 }


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4320,6 +4320,22 @@
 // CHECK_R600_FP64-DAG: #define __R600__ 1
 // CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
 
+// Begin avr tests 
+
+// RUN: %clang --target=avr -mmcu=atmega328 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR0
+// CHECK-AVR0: #define __AVR_ARCH__ 5
+// CHECK-AVR0: #define __AVR_ATmega328__ 1
+// CHECK-AVR0: #define __flash __attribute__((__address_space__(1)))
+// RUN: %clang --target=avr -mmcu=atmega2560 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR1
+// CHECK-AVR1: #define __AVR_ARCH__ 6
+// CHECK-AVR1: #define __AVR_ATmega2560__ 1
+// CHECK-AVR1: #define __flash  __attribute__((__address_space__(1)))
+// CHECK-AVR1: #define __flash1 __attribute__((__address_space__(2)))
+// CHECK-AVR1: #define __flash2 __attribute__((__address_space__(3)))
+// CHECK-AVR1: #define __flash3 __attribute__((__address_space__(4)))
+
 // Begin M68k tests 
 
 // RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -468,15 +468,15 @@
   }
 
   if (NumFlashBanks >= 1)
-Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
+Builder.defineMacro("__flash", "__attribute__((__address_space__(1)))");
   if (NumFlashBanks >= 2)
-Builder.defineMacro("__flash1", "__attribute__((address_space(2)))");
+Builder.defineMacro("__flash1", "__attribute__((__address_space__(2)))");
   if (NumFlashBanks >= 3)
-Builder.defineMacro("__flash2", "__attribute__((address_space(3)))");
+Builder.defineMacro("__flash2", "__

[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 2 inline comments as done.
pmatos added a comment.

Addressed a few comments downstream. Will upload new patch next.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

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


[PATCH] D139686: [lsan] Add lsan support for loongarch64

2023-01-12 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

LGTM. Is there any objection?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139686/new/

https://reviews.llvm.org/D139686

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


[PATCH] D141592: [include-cleaner] Treat a constructor call as a use of the class type.

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22db1fb10b83: [include-cleaner] Treat a constructor call as 
a use of the class type. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141592/new/

https://reviews.llvm.org/D141592

Files:
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -240,9 +240,10 @@
 
 TEST(WalkAST, ConstructExprs) {
   testWalk("struct $implicit^S {};", "S ^t;");
-  testWalk("struct S { $implicit^S(); };", "S ^t;");
-  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");
-  testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
+  testWalk("struct $implicit^S { S(); };", "S ^t;");
+  testWalk("struct $explicit^S { S(int); };", "S ^t(42);");
+  testWalk("struct $implicit^S { S(int); };", "S t = ^42;");
+  testWalk("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;");
 }
 
 TEST(WalkAST, Operator) {
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -104,7 +104,7 @@
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
-report(E->getLocation(), E->getConstructor(),
+report(E->getLocation(), getMemberProvider(E->getType()),
E->getParenOrBraceRange().isValid() ? RefType::Explicit
: RefType::Implicit);
 return true;


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -240,9 +240,10 @@
 
 TEST(WalkAST, ConstructExprs) {
   testWalk("struct $implicit^S {};", "S ^t;");
-  testWalk("struct S { $implicit^S(); };", "S ^t;");
-  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");
-  testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
+  testWalk("struct $implicit^S { S(); };", "S ^t;");
+  testWalk("struct $explicit^S { S(int); };", "S ^t(42);");
+  testWalk("struct $implicit^S { S(int); };", "S t = ^42;");
+  testWalk("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;");
 }
 
 TEST(WalkAST, Operator) {
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -104,7 +104,7 @@
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
-report(E->getLocation(), E->getConstructor(),
+report(E->getLocation(), getMemberProvider(E->getType()),
E->getParenOrBraceRange().isValid() ? RefType::Explicit
: RefType::Implicit);
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 22db1fb - [include-cleaner] Treat a constructor call as a use of the class type.

2023-01-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-01-12T13:12:14+01:00
New Revision: 22db1fb10b8384907b43408f5d2703f96f806bc2

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

LOG: [include-cleaner] Treat a constructor call as a use of the class type.

Per the discussion in https://github.com/llvm/llvm-project/issues/59916.

Differential Revision: https://reviews.llvm.org/D141592

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/WalkAST.cpp
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp 
b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index 18e6d5e21df07..6a5594e3d6d35 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -104,7 +104,7 @@ class ASTWalker : public RecursiveASTVisitor {
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
-report(E->getLocation(), E->getConstructor(),
+report(E->getLocation(), getMemberProvider(E->getType()),
E->getParenOrBraceRange().isValid() ? RefType::Explicit
: RefType::Implicit);
 return true;

diff  --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index c8959e7eb6735..af7e155b58fb3 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -240,9 +240,10 @@ TEST(WalkAST, MemberExprs) {
 
 TEST(WalkAST, ConstructExprs) {
   testWalk("struct $implicit^S {};", "S ^t;");
-  testWalk("struct S { $implicit^S(); };", "S ^t;");
-  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");
-  testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
+  testWalk("struct $implicit^S { S(); };", "S ^t;");
+  testWalk("struct $explicit^S { S(int); };", "S ^t(42);");
+  testWalk("struct $implicit^S { S(int); };", "S t = ^42;");
+  testWalk("namespace ns { struct S{}; } using ns::$implicit^S;", "S ^t;");
 }
 
 TEST(WalkAST, Operator) {



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


[PATCH] D141547: Fix format for `case` in .proto files

2023-01-12 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clang/test/Format/case.proto:15
+repeated int32 fizz = 1;
+}

could you please turn this into an unit test here instead > 
https://github.com/llvm/llvm-project/blob/main/clang/unittests/Format/FormatTestProto.cpp.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141547/new/

https://reviews.llvm.org/D141547

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


[clang-tools-extra] bb1b0e6 - [clangd] Tag clang-tidy diagnostics: modernize-*=deprecated, misc-unused-*=unneccesary

2023-01-12 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-01-12T13:22:21+01:00
New Revision: bb1b0e61cda66cb9f06bc4f1dc21e03bb1744d22

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

LOG: [clangd] Tag clang-tidy diagnostics: modernize-*=deprecated, 
misc-unused-*=unneccesary

Differential Revision: https://reviews.llvm.org/D141537

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 6cf8db724e259..652e9e13b6e22 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -374,7 +374,12 @@ void setTags(clangd::Diag &D) {
   } else if (UnusedDiags->contains(D.ID)) {
 D.Tags.push_back(DiagnosticTag::Unnecessary);
   }
-  // FIXME: Set tags for tidy-based diagnostics too.
+  if (D.Source == Diag::ClangTidy) {
+if (llvm::StringRef(D.Name).starts_with("misc-unused-"))
+  D.Tags.push_back(DiagnosticTag::Unnecessary);
+if (llvm::StringRef(D.Name).starts_with("modernize-"))
+  D.Tags.push_back(DiagnosticTag::Deprecated);
+  }
 }
 } // namespace
 
@@ -566,7 +571,6 @@ std::vector StoreDiags::take(const 
clang::tidy::ClangTidyContext *Tidy) {
 
   // Fill in name/source now that we have all the context needed to map them.
   for (auto &Diag : Output) {
-setTags(Diag);
 if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
   // Warnings controlled by -Wfoo are better recognized by that name.
   StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID);
@@ -580,9 +584,7 @@ std::vector StoreDiags::take(const 
clang::tidy::ClangTidyContext *Tidy) {
 Diag.Name = std::string(Name);
   }
   Diag.Source = Diag::Clang;
-  continue;
-}
-if (Tidy != nullptr) {
+} else if (Tidy != nullptr) {
   std::string TidyDiag = Tidy->getCheckName(Diag.ID);
   if (!TidyDiag.empty()) {
 Diag.Name = std::move(TidyDiag);
@@ -600,9 +602,9 @@ std::vector StoreDiags::take(const 
clang::tidy::ClangTidyContext *Tidy) {
   CleanMessage(Note.Message);
 for (auto &Fix : Diag.Fixes)
   CleanMessage(Fix.Message);
-continue;
   }
 }
+setTags(Diag);
   }
   // Deduplicate clang-tidy diagnostics -- some clang-tidy checks may emit
   // duplicated messages due to various reasons (e.g. the check doesn't handle

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 824756a970211..47f844f77eb4e 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1851,6 +1851,17 @@ TEST(Diagnostics, Tags) {
 withTag(DiagnosticTag::Unnecessary)),
   AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
 withTag(DiagnosticTag::Deprecated;
+
+  Test = Annotations(R"cpp(
+$typedef[[typedef int INT]];
+  )cpp");
+  TU.Code = Test.code();
+  TU.ClangTidyProvider = addTidyChecks("modernize-use-using");
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("typedef"), "use 'using' instead of 
'typedef'"),
+withTag(DiagnosticTag::Deprecated;
 }
 
 TEST(DiagnosticsTest, IncludeCleaner) {



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


[PATCH] D141537: [clangd] Tag clang-tidy diagnostics: modernize-*=deprecated, misc-unused-*=unneccesary

2023-01-12 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb1b0e61cda6: [clangd] Tag clang-tidy diagnostics: 
modernize-*=deprecated, misc-unused… (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141537/new/

https://reviews.llvm.org/D141537

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1851,6 +1851,17 @@
 withTag(DiagnosticTag::Unnecessary)),
   AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
 withTag(DiagnosticTag::Deprecated;
+
+  Test = Annotations(R"cpp(
+$typedef[[typedef int INT]];
+  )cpp");
+  TU.Code = Test.code();
+  TU.ClangTidyProvider = addTidyChecks("modernize-use-using");
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("typedef"), "use 'using' instead of 
'typedef'"),
+withTag(DiagnosticTag::Deprecated;
 }
 
 TEST(DiagnosticsTest, IncludeCleaner) {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -374,7 +374,12 @@
   } else if (UnusedDiags->contains(D.ID)) {
 D.Tags.push_back(DiagnosticTag::Unnecessary);
   }
-  // FIXME: Set tags for tidy-based diagnostics too.
+  if (D.Source == Diag::ClangTidy) {
+if (llvm::StringRef(D.Name).starts_with("misc-unused-"))
+  D.Tags.push_back(DiagnosticTag::Unnecessary);
+if (llvm::StringRef(D.Name).starts_with("modernize-"))
+  D.Tags.push_back(DiagnosticTag::Deprecated);
+  }
 }
 } // namespace
 
@@ -566,7 +571,6 @@
 
   // Fill in name/source now that we have all the context needed to map them.
   for (auto &Diag : Output) {
-setTags(Diag);
 if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
   // Warnings controlled by -Wfoo are better recognized by that name.
   StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID);
@@ -580,9 +584,7 @@
 Diag.Name = std::string(Name);
   }
   Diag.Source = Diag::Clang;
-  continue;
-}
-if (Tidy != nullptr) {
+} else if (Tidy != nullptr) {
   std::string TidyDiag = Tidy->getCheckName(Diag.ID);
   if (!TidyDiag.empty()) {
 Diag.Name = std::move(TidyDiag);
@@ -600,9 +602,9 @@
   CleanMessage(Note.Message);
 for (auto &Fix : Diag.Fixes)
   CleanMessage(Fix.Message);
-continue;
   }
 }
+setTags(Diag);
   }
   // Deduplicate clang-tidy diagnostics -- some clang-tidy checks may emit
   // duplicated messages due to various reasons (e.g. the check doesn't handle


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1851,6 +1851,17 @@
 withTag(DiagnosticTag::Unnecessary)),
   AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
 withTag(DiagnosticTag::Deprecated;
+
+  Test = Annotations(R"cpp(
+$typedef[[typedef int INT]];
+  )cpp");
+  TU.Code = Test.code();
+  TU.ClangTidyProvider = addTidyChecks("modernize-use-using");
+  EXPECT_THAT(
+  *TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("typedef"), "use 'using' instead of 'typedef'"),
+withTag(DiagnosticTag::Deprecated;
 }
 
 TEST(DiagnosticsTest, IncludeCleaner) {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -374,7 +374,12 @@
   } else if (UnusedDiags->contains(D.ID)) {
 D.Tags.push_back(DiagnosticTag::Unnecessary);
   }
-  // FIXME: Set tags for tidy-based diagnostics too.
+  if (D.Source == Diag::ClangTidy) {
+if (llvm::StringRef(D.Name).starts_with("misc-unused-"))
+  D.Tags.push_back(DiagnosticTag::Unnecessary);
+if (llvm::StringRef(D.Name).starts_with("modernize-"))
+  D.Tags.push_back(DiagnosticTag::Deprecated);
+  }
 }
 } // namespace
 
@@ -566,7 +571,6 @@
 
   // Fill in name/source now that we have all the context needed to map them.
   for (auto &Diag : Output) {
-setTags(Diag);
 if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
   // Warnings controlled by -Wfoo are better recognized by that name.
   StringRef Warning = Diagnosti

[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 488598.
pmatos added a comment.

Address a couple of comments by @aaron.ballman


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function &F) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree &DT = getAnalysis().getDomTree();
@@ -96,6 +100,7 @@
 AU.addRequired();
 AU.setPreservesCFG();
   }
+
 };
 
 } // end anonymous namespace
@@ -111,6 +116,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,14 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM = static_cast(TM);
+  const WebAssemblySubtarget *Subtarget = WasmTM
+->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if(Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(L

[PATCH] D141297: [OpenCL] Allow undefining header-only features

2023-01-12 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D141297#4043122 , @Anastasia wrote:

> Btw I wonder if in the future we could add some error or warning in case 
> someone uses the same approach for frontend specific features, i.e.
>
>   #ifdef __undef___opencl_c_generic_address_space
>   #error "Feature __opencl_c_generic_address_space can only be disabled via 
> -cl-ext flag"
>   #endif

Interesting idea, but I'm a bit hesitant of doing so:
It increases the size of `opencl-c-base.h` so it will take longer to parse, 
which will affect every OpenCL compilation. Luckily we can avoid that cost if 
we keep the `__undef_` mechanism an internal solution, which it will be once we 
let `-cl-ext=-feature` generate `__undef_` macros for extensions that are not 
in `OpenCLExtensions.def`. So longer term users will never have to pass 
`__undef_` macros.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141297/new/

https://reviews.llvm.org/D141297

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 5 inline comments as done.
pmatos added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:4012-4018
+  if (Target->getTriple().isWasm() && Target->hasFeature("reference-types")) {
+#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS)  
\
+  if (BuiltinType::Id == BuiltinType::WasmExternRef)   
\
+return SingletonId;
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
+  }
+  return QualType();

aaron.ballman wrote:
> Rather than returning a null type, should we assert we're in a wasm triple? 
> We shouldn't be trying to form the type outside of a wasm target, right?
asserting false with message rather than llvm_unreachable is the right way, 
correct?



Comment at: clang/lib/AST/ItaniumMangle.cpp:3147
+type_name = MangledName;   
\
+Out << (type_name == InternalName ? "u" : "") << type_name.size()  
\
+<< type_name;  
\

aaron.ballman wrote:
> aaron.ballman wrote:
> > tlively wrote:
> > > Our `MangledName` is not the same as our `InternalName`, so it looks like 
> > > this condition will never be true. Should be follow the simpler pattern 
> > > from the previous two targets instead?
> > I'm not an Itanium mangling expert, but doesn't this *have* to use the `u` 
> > marking per 
> > https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.builtin-type 
> > because this is definitely a vendor extension type.
> Still wondering about this, pinging @rjmccall for Itanium ABI expertise
I think what you both are saying makes sense.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

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


[clang] 0d0dab4 - Fix the Clang sphinx bot again

2023-01-12 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-01-12T07:59:07-05:00
New Revision: 0d0dab4e5fbec4efb31de6b877574d0d278f6809

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

LOG: Fix the Clang sphinx bot again

The changes to fix the bot yesterday got reverted in a subsequent
commit, so this adds those changes back again.

Fixes the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/38593

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 6d0df7b35894..302069e96572 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3222,7 +3222,7 @@ the configuration (without a prefix: ``Auto``).
 
   * ``int8_t Binary`` Format separators in binary literals.
 
-.. code-block:: c++
+.. code-block:: text
 
   /* -1: */ b = 0b10001101;
   /*  0: */ b = 0b10011'11'0110'1;
@@ -3231,7 +3231,7 @@ the configuration (without a prefix: ``Auto``).
 
   * ``int8_t Decimal`` Format separators in decimal literals.
 
-.. code-block:: c++
+.. code-block:: text
 
   /* -1: */ d = 18446744073709550592ull;
   /*  0: */ d = 184467'440737'0'95505'92ull;
@@ -3239,7 +3239,7 @@ the configuration (without a prefix: ``Auto``).
 
   * ``int8_t Hex`` Format separators in hexadecimal literals.
 
-.. code-block:: c++
+.. code-block:: text
 
   /* -1: */ h = 0xDEADBEEFDEADBEEFuz;
   /*  0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f2efe820f36c..0ca2430a3efd 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2501,7 +2501,7 @@ struct FormatStyle {
   /// \endcode
   struct IntegerLiteralSeparatorStyle {
 /// Format separators in binary literals.
-/// \code
+/// \code{.text}
 ///   /* -1: */ b = 0b10001101;
 ///   /*  0: */ b = 0b10011'11'0110'1;
 ///   /*  3: */ b = 0b100'111'101'101;
@@ -2509,14 +2509,14 @@ struct FormatStyle {
 /// \endcode
 int8_t Binary;
 /// Format separators in decimal literals.
-/// \code
+/// \code{.text}
 ///   /* -1: */ d = 18446744073709550592ull;
 ///   /*  0: */ d = 184467'440737'0'95505'92ull;
 ///   /*  3: */ d = 18'446'744'073'709'550'592ull;
 /// \endcode
 int8_t Decimal;
 /// Format separators in hexadecimal literals.
-/// \code
+/// \code{.text}
 ///   /* -1: */ h = 0xDEADBEEFDEADBEEFuz;
 ///   /*  0: */ h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;
 ///   /*  2: */ h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;



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


[PATCH] D141206: [clang] [MinGW] Avoid adding /include and /lib when cross compiling

2023-01-12 Thread Alvin Wong via Phabricator via cfe-commits
alvinhochun added inline comments.



Comment at: clang/test/Driver/mingw-sysroot.cpp:25-38
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 
2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE:[^"]+]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}backward"
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10.2-posix"
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10.2"
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10"

I think this only verifies that the include path is not present after the last 
`CHECK_TESTROOT_GCC` match. The [[ 
https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-filecheck-implicit-check-not
 | --implicit-check-not ]] option should be used to check that the pattern is 
not present anywhere in the output.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141206/new/

https://reviews.llvm.org/D141206

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 488609.
pmatos marked an inline comment as done.
pmatos added a comment.

Deal with Itanium Mangle and assert false outside Wasm triple.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function &F) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree &DT = getAnalysis().getDomTree();
@@ -96,6 +100,7 @@
 AU.addRequired();
 AU.setPreservesCFG();
   }
+
 };
 
 } // end anonymous namespace
@@ -111,6 +116,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,14 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM = static_cast(TM);
+  const WebAssemblySubtarget *Subtarget = WasmTM
+->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if(Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->

[clang] a74bc43 - Add a warning comment that this file is generated

2023-01-12 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-01-12T08:10:57-05:00
New Revision: a74bc436703057ab0f53ad78ab3f84227a45e37f

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

LOG: Add a warning comment that this file is generated

This file is partially generated by a Python script in the
clang/docs/tools directory, but it's not obvious for people making
drive-by fixes. This comment hopefully helps people avoid making
changes that are later overwritten by the script.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 302069e96572..4bcf3bd0cb8e 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1,3 +1,9 @@
+..
+  NOTE
+  This file is automatically generated, in part. Do not edit the style options
+  in this file directly. Instead, modify them in include/clang/Format/Format.h
+  and run the docs/tools/dump_format_style.py script to update this file.
+
 .. raw:: html
 
   

[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2480-2481
 #include "clang/Basic/RISCVVTypes.def"
+#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
   case BuiltinType::ShortAccum:

aaron.ballman wrote:
> aaron.ballman wrote:
> > Is it reasonable that this simply cannot mangle in Microsoft ABI mode?
> Still wondering about this
@aaron.ballman Why wouldn't externref_t be able to mangle in Microsoft ABI 
mode? Quite clueless when it comes to ABIs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

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


[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-12 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve updated this revision to Diff 488611.
fdeazeve added a comment.

Address review comments:

- Remove unncesarry `const` qualifier from function declaration.
- Add an item in Clang's release notes.

I surveyed Clang's release notes in all major releases from 12.0 and couldn't
find anything similar to this, so I used my best judgement on where/how to
write it. Please let me know if you have suggestions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141381/new/

https://reviews.llvm.org/D141381

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGen/aarch64-ls64.c
  clang/test/CodeGen/atomic-arm64.c
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/debug-info.cpp
  clang/test/CodeGenCXX/derived-to-base-conv.cpp
  clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-params.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

Index: clang/test/OpenMP/teams_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/teams_firstprivate_codegen.cpp
+++ clang/test/OpenMP/teams_firstprivate_codegen.cpp
@@ -557,8 +557,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
 // CHECK9-NEXT:call void @_ZN1SIfEC2ERKS0_2St(ptr nonnull align 4 dereferenceable(4) [[THIS1]], ptr nonnull align 4 dereferenceable(4) [[TMP0]], ptr [[T]])
@@ -784,8 +786,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[THIS1]], i32 0, i32 0
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
@@ -932,8 +936,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
 // CHECK9-NEXT:call void @_ZN1SIiEC2ERKS0_2St(ptr nonnull align 4 dereferenceable(4) [[THIS1]], ptr nonnull align 4 dereferenceable(4) [[TMP0]], ptr [[T]])
@@ -1012,8 +1018,10 @@
 // CHECK9-NEXT:  entry:
 // CHECK9-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:[[S_ADDR:%.*]] = alloca ptr, align 8
+// CHECK9-NEXT:[[T_INDIRECT_ADDR:%.*]] = alloca ptr, align 8
 // CHECK9-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:store ptr [[S]], ptr [[S_ADDR]], align 8
+// CHECK9-NEXT:store ptr [[T]], ptr [[T_INDIRECT_ADDR]], align 8
 // CHECK9-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
 // CHECK9-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_S_0:%.*]], ptr [[THIS1]], i32 0, i32 0
 // CHECK9-NEXT:[[TMP0:%.*]] = load ptr, ptr [[S_ADDR]], align 8
@@ -1318,8 +1326,10 @@
 // CHECK11-NEXT:  entry:
 // CHECK11-NEXT:[[THIS_ADDR:%.*]] = alloca ptr,

[PATCH] D141105: [OpenMP] Add support for '--offload-arch=native' to OpenMP offloading

2023-01-12 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D141105#4046400 , @gribozavr2 
wrote:

> FYI: I fixed the problem in 
> https://github.com/llvm/llvm-project/commit/0a11a1b1868dd2ab183c4313ccbfbe126e91ca08.

Thanks, I forgot to update that test after fixing a similar problem before.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141105/new/

https://reviews.llvm.org/D141105

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


[clang] 278d6f0 - [Clang] Clean up some offloading driver tests

2023-01-12 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-12T07:54:55-06:00
New Revision: 278d6f065a63930d33d10785ec3de03ce6c3bc3c

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

LOG: [Clang] Clean up some offloading driver tests

Summary:
These tests used an external `dummy.o` and `dummy.bc` files instead of
just generating them. This should be cleaner and less error prone.

Added: 


Modified: 
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c
clang/test/Driver/offload-packager.c

Removed: 
clang/test/Driver/Inputs/dummy-bc.bc
clang/test/Driver/Inputs/dummy-elf.o



diff  --git a/clang/test/Driver/Inputs/dummy-bc.bc 
b/clang/test/Driver/Inputs/dummy-bc.bc
deleted file mode 100644
index 11129ed391af3..0
Binary files a/clang/test/Driver/Inputs/dummy-bc.bc and /dev/null 
diff er

diff  --git a/clang/test/Driver/Inputs/dummy-elf.o 
b/clang/test/Driver/Inputs/dummy-elf.o
deleted file mode 100644
index 48161b2aad073..0
Binary files a/clang/test/Driver/Inputs/dummy-elf.o and /dev/null 
diff er

diff  --git a/clang/test/Driver/linker-wrapper-image.c 
b/clang/test/Driver/linker-wrapper-image.c
index abf41d386d2de..83e7db6a49a6b 100644
--- a/clang/test/Driver/linker-wrapper-image.c
+++ b/clang/test/Driver/linker-wrapper-image.c
@@ -2,7 +2,9 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN: clang-offload-packager -o %t.out 
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
+
+// RUN: clang-offload-packager -o %t.out 
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   -fembed-offload-object=%t.out
 // RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu \
@@ -29,7 +31,7 @@
 // OPENMP-NEXT:   ret void
 // OPENMP-NEXT: }
 
-// RUN: clang-offload-packager -o %t.out 
--image=file=%S/Inputs/dummy-elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN: clang-offload-packager -o %t.out 
--image=file=%t.elf.o,kind=cuda,triple=nvptx64-nvidia-cuda,arch=sm_70
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   -fembed-offload-object=%t.out
 // RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu \
@@ -111,7 +113,7 @@
 // CUDA-NEXT:   ret void
 // CUDA-NEXT: }
 
-// RUN: clang-offload-packager -o %t.out 
--image=file=%S/Inputs/dummy-elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx908
+// RUN: clang-offload-packager -o %t.out 
--image=file=%t.elf.o,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx908
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
 // RUN:   -fembed-offload-object=%t.out
 // RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu \

diff  --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 7d958301f727b..a455c2cfba285 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -2,27 +2,31 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
+// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.bc
+// RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -o %t.amdgpu.bc
+
 // RUN: clang-offload-packager -o %t.out \
-// RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
-// RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
 // RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
-// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX_LINK
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX-LINK
 
-// NVPTX_LINK: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
+// NVPTX-LINK: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
 
 // RUN: clang-offload-packager -o %t.out \
-// RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
-// RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN:   
--image=file=%t.elf.o,kind=op

[PATCH] D141546: [clang] Reland parenthesized aggregate init patches

2023-01-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM, mostly based on the previous review.
I have not noticed any significant changes, so have not looked too cautiously. 
Let me know if there are any particular places that you someone to take a look 
at before landing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141546/new/

https://reviews.llvm.org/D141546

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


[PATCH] D141608: [include-cleaner] Don't consider the underlying type of Decltype MemberProvider as a use

2023-01-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

For this case, the argument of `decltype` is the provider.

This fixes the sample in 
https://github.com/llvm/llvm-project/issues/59916#issuecomment-1377214667


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141608

Files:
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -229,6 +229,7 @@
   namespace ns { template struct Foo { int a; }; }
   using ns::$implicit^Foo;)cpp",
"void k(Foo b) { b.^a; }");
+  testWalk("struct Foo { int a; };", "void test(decltype(Foo()) b) { b.^a; }");
   // Test the dependent-type case (CXXDependentScopeMemberExpr)
   testWalk("template struct $implicit^Base { void method(); };",
"template void k(Base t) { t.^method(); }");
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -51,6 +51,10 @@
   return TT->getDecl();
 if (const auto *UT = dyn_cast(Base))
   return UT->getFoundDecl();
+// Don't consider the underlying type of the decltype as a use (generally
+// the argument of decltype should provide them).
+if (const auto *DT = dyn_cast(Base))
+  return nullptr;
 // A heuristic: to resolve a template type to **only** its template name.
 // We're only using this method for the base type of MemberExpr, in general
 // the template provides the member, and the critical case 
`unique_ptr`


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -229,6 +229,7 @@
   namespace ns { template struct Foo { int a; }; }
   using ns::$implicit^Foo;)cpp",
"void k(Foo b) { b.^a; }");
+  testWalk("struct Foo { int a; };", "void test(decltype(Foo()) b) { b.^a; }");
   // Test the dependent-type case (CXXDependentScopeMemberExpr)
   testWalk("template struct $implicit^Base { void method(); };",
"template void k(Base t) { t.^method(); }");
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -51,6 +51,10 @@
   return TT->getDecl();
 if (const auto *UT = dyn_cast(Base))
   return UT->getFoundDecl();
+// Don't consider the underlying type of the decltype as a use (generally
+// the argument of decltype should provide them).
+if (const auto *DT = dyn_cast(Base))
+  return nullptr;
 // A heuristic: to resolve a template type to **only** its template name.
 // We're only using this method for the base type of MemberExpr, in general
 // the template provides the member, and the critical case `unique_ptr`
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141206: [clang] [MinGW] Avoid adding /include and /lib when cross compiling

2023-01-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/test/Driver/mingw-sysroot.cpp:25-38
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 
2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE:[^"]+]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}backward"
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10.2-posix"
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10.2"
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10"

alvinhochun wrote:
> I think this only verifies that the include path is not present after the 
> last `CHECK_TESTROOT_GCC` match. The [[ 
> https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-filecheck-implicit-check-not
>  | --implicit-check-not ]] option should be used to check that the pattern is 
> not present anywhere in the output.
Right - that's true (although this is the spot where the entry did appear 
before - I checked that the test did fail before applying the functional 
change).

I tried adding `--implicit-check-not` here, but the quoting/escaping of the 
regexes seems tricky - even getting it to recognize the literal quotes 
surrounding the string.

I tried with 
`--implicit-check-not="\"{{.*}}/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include\""`,
 but that's not working (i.e. it's not detecting anything even when I remove 
the functional change of the patch). With a trivial reduction of it, into 
`--implicit-check-not="testroot-gcc/x86_64-w64-mingw32/include"`, it's 
detecting things as expected (but that quote gets handled by the shell, so this 
would match any substring, such as `.../include/subdir` too. But even 
`--implicit-check-not="testroot-gcc/x86_64-w64-mingw32/include\""` does not 
match correctly.

The documentation says that the `--implicit-check-not` option does take a 
pattern, but it doesn't really say what's allowed in that pattern - apparently 
not the full syntax used in normal `CHECK` lines at least...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141206/new/

https://reviews.llvm.org/D141206

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


[clang] a5c9a51 - [mips][clang] Do not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for MIPS-I

2023-01-12 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-01-12T09:08:05-05:00
New Revision: a5c9a51bf456a505386660d9be4c641fc804b7fe

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

LOG: [mips][clang] Do not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for 
MIPS-I

Do not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for MIPS-I

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D141182

Added: 


Modified: 
clang/lib/Basic/Targets/Mips.cpp
clang/test/Preprocessor/predefined-macros.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/Mips.cpp 
b/clang/lib/Basic/Targets/Mips.cpp
index 2fc7572309d59..01b2e4e57a1c2 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -195,11 +195,11 @@ void MipsTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (StringRef(CPU).startswith("octeon"))
 Builder.defineMacro("__OCTEON__");
 
-  // These shouldn't be defined for MIPS-I but there's no need to check
-  // for that since MIPS-I isn't supported.
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  if (CPU != "mips1") {
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  }
 
   // 32-bit MIPS processors don't have the necessary lld/scd instructions
   // found in 64-bit processors. In the case of O32 on a 64-bit processor,

diff  --git a/clang/test/Preprocessor/predefined-macros.c 
b/clang/test/Preprocessor/predefined-macros.c
index 897145516c52c..d77b699674af4 100644
--- a/clang/test/Preprocessor/predefined-macros.c
+++ b/clang/test/Preprocessor/predefined-macros.c
@@ -118,12 +118,15 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_ARMv6
 // CHECK-SYNC_CAS_ARMv6-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
 //
+// RUN: %clang_cc1 %s -E -dM -o - -triple mips -target-cpu mips1 \
+// RUN:   | FileCheck -match-full-lines %s 
--check-prefix=CHECK-SYNC_CAS_MIPS32_MIPS1
 // RUN: %clang_cc1 %s -E -dM -o - -triple mips -target-cpu mips2 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_MIPS \
 // RUN: --check-prefix=CHECK-SYNC_CAS_MIPS32
 // RUN: %clang_cc1 %s -E -dM -o - -triple mips64 -target-cpu mips3 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_MIPS \
 // RUN: --check-prefix=CHECK-SYNC_CAS_MIPS64
+// CHECK-SYNC_CAS_MIPS32_MIPS1-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1



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


[PATCH] D141182: [mips][clang] Do not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for MIPS-I

2023-01-12 Thread Brad Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5c9a51bf456: [mips][clang] Do not define 
__GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for MIPS-I (authored by brad).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141182/new/

https://reviews.llvm.org/D141182

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -118,12 +118,15 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_ARMv6
 // CHECK-SYNC_CAS_ARMv6-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
 //
+// RUN: %clang_cc1 %s -E -dM -o - -triple mips -target-cpu mips1 \
+// RUN:   | FileCheck -match-full-lines %s 
--check-prefix=CHECK-SYNC_CAS_MIPS32_MIPS1
 // RUN: %clang_cc1 %s -E -dM -o - -triple mips -target-cpu mips2 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_MIPS \
 // RUN: --check-prefix=CHECK-SYNC_CAS_MIPS32
 // RUN: %clang_cc1 %s -E -dM -o - -triple mips64 -target-cpu mips3 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_MIPS \
 // RUN: --check-prefix=CHECK-SYNC_CAS_MIPS64
+// CHECK-SYNC_CAS_MIPS32_MIPS1-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -195,11 +195,11 @@
   if (StringRef(CPU).startswith("octeon"))
 Builder.defineMacro("__OCTEON__");
 
-  // These shouldn't be defined for MIPS-I but there's no need to check
-  // for that since MIPS-I isn't supported.
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  if (CPU != "mips1") {
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  }
 
   // 32-bit MIPS processors don't have the necessary lld/scd instructions
   // found in 64-bit processors. In the case of O32 on a 64-bit processor,


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -118,12 +118,15 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_ARMv6
 // CHECK-SYNC_CAS_ARMv6-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
 //
+// RUN: %clang_cc1 %s -E -dM -o - -triple mips -target-cpu mips1 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_MIPS32_MIPS1
 // RUN: %clang_cc1 %s -E -dM -o - -triple mips -target-cpu mips2 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_MIPS \
 // RUN: --check-prefix=CHECK-SYNC_CAS_MIPS32
 // RUN: %clang_cc1 %s -E -dM -o - -triple mips64 -target-cpu mips3 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SYNC_CAS_MIPS \
 // RUN: --check-prefix=CHECK-SYNC_CAS_MIPS64
+// CHECK-SYNC_CAS_MIPS32_MIPS1-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -195,11 +195,11 @@
   if (StringRef(CPU).startswith("octeon"))
 Builder.defineMacro("__OCTEON__");
 
-  // These shouldn't be defined for MIPS-I but there's no need to check
-  // for that since MIPS-I isn't supported.
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
-  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  if (CPU != "mips1") {
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  }
 
   // 32-bit MIPS processors don't have the necessary lld/scd instructions
   // found in 64-bit processors. In the case of O32 on a 64-bit processor,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139114: [Clang][Sema] Enabled implicit conversion warning for CompoundAssignment operator.

2023-01-12 Thread Fahad Nayyar via Phabricator via cfe-commits
fahadnayyar updated this revision to Diff 488632.
fahadnayyar marked an inline comment as done.
fahadnayyar added a comment.

Refactoring.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139114/new/

https://reviews.llvm.org/D139114

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conversion-64-32.c

Index: clang/test/Sema/conversion-64-32.c
===
--- clang/test/Sema/conversion-64-32.c
+++ clang/test/Sema/conversion-64-32.c
@@ -17,3 +17,36 @@
 int test2(long v) {
   return v / 2; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
 }
+
+// rdar://10466193
+void test3(int i, long long ll) {
+  i += ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= ll; // expected-warning {{implicit conversion loses integer precision}}
+  i *= ll; // expected-warning {{implicit conversion loses integer precision}}
+  i /= ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+void test4(int i, long long ll) {
+  i += i-ll; // expected-warning {{implicit conversion loses integer precision}}
+  i += i+ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= i-ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= i+ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+void test5(int i, int j, long long ll) {
+  i += (i-j)*ll; // expected-warning {{implicit conversion loses integer precision}}
+  i += (i+j)*ll; // expected-warning {{implicit conversion loses integer precision}}
+  i -= ll/(i-j); // expected-warning {{implicit conversion loses integer precision}}
+  i -= ll/(i-j); // expected-warning {{implicit conversion loses integer precision}}
+}
+
+void test6(char c) {
+  c <<= 99; // expected-warning {{shift count >= width of type}} \
+  // cxx17-warning {{shift count >= width of type}} \
+  // ref-warning {{shift count >= width of type}} \
+  // ref-cxx17-warning {{shift count >= width of type}}
+  c >>= 99; // expected-warning {{shift count >= width of type}} \
+  // cxx17-warning {{shift count >= width of type}} \
+  // ref-warning {{shift count >= width of type}} \
+  // ref-cxx17-warning {{shift count >= width of type}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13508,8 +13508,13 @@
   }
 }
 
+static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
+SourceLocation CC,
+bool *ICContext = nullptr,
+bool IsListInit = false);
+
 /// Analyze the given compound assignment for the possible losing of
-/// floating-point precision.
+/// floating-point precision and for implicit conversions for integral operands.
 static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
   assert(isa(E) &&
  "Must be compound assignment operation");
@@ -13526,8 +13531,17 @@
 ->getComputationResultType()
 ->getAs();
 
+  // Check for implicit conversions for compound assignment statements with
+  // intergral operands.
+  // FIXME: should this handle floating-point as well?
+  if (E->getLHS()->getType()->isIntegerType() &&
+  E->getRHS()->getType()->isIntegerType() && !E->isShiftAssignOp())
+CheckImplicitConversion(S, E->getRHS(), E->getType(),
+E->getRHS()->getExprLoc());
+
   // The below checks assume source is floating point.
-  if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
+  if (!ResultBT || !RBT || !RBT->isFloatingPoint())
+return;
 
   // If source is floating point but target is an integer.
   if (ResultBT->isInteger())
@@ -13816,9 +13830,8 @@
 }
 
 static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
-SourceLocation CC,
-bool *ICContext = nullptr,
-bool IsListInit = false) {
+SourceLocation CC, bool *ICContext,
+bool IsListInit) {
   if (E->isTypeDependent() || E->isValueDependent()) return;
 
   const Type *Source = S.Context.getCanonicalType(E->getType()).getTypePtr();
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -351,6 +351,9 @@
 
 Improvements to Clang's diagnostics
 ^^^
+- Clang now supports implicit conversion warnings (``-Wsign-conversion``,
+  ``Wshorten-64-to-32``, etc) for compound assignment operators (li

[PATCH] D138446: [clang-format][docs] Add ability to link to specific config options

2023-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

In D138446#3942006 , @rymiel wrote:

> I consulted a little bit with a friend who has a little bit of experience 
> with sphinx and they suggested making a simple custom extension for this. But 
> given that there is no custom sphinx logic right now at all, I don't feel 
> great adding something that novel to the whole of clang docs just for this 
> page of clang-format

Unless the custom extension is something that is committed to version control, 
fetched alongside the rest of the repo, and "just works" for folks without 
setup, I think it's best to avoid it. Otherwise we'll have to update the sphinx 
build bots, downstreams will have to react to it, and users will have a harder 
time building the docs locally. It's not that we can't do it if it's the right 
solution; it's that it's better to avoid something requiring manual 
intervention if we can.

As best I know, the way you've done things in this patch is the way Sphinx is 
expected to work for arbitrary anchors (despite being pretty janky IMO), so 
this LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138446/new/

https://reviews.llvm.org/D138446

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:4012-4018
+  if (Target->getTriple().isWasm() && Target->hasFeature("reference-types")) {
+#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS)  
\
+  if (BuiltinType::Id == BuiltinType::WasmExternRef)   
\
+return SingletonId;
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
+  }
+  return QualType();

pmatos wrote:
> aaron.ballman wrote:
> > Rather than returning a null type, should we assert we're in a wasm triple? 
> > We shouldn't be trying to form the type outside of a wasm target, right?
> asserting false with message rather than llvm_unreachable is the right way, 
> correct?
I'd recommend something like:
```
assert(Target->getTriple().isWasm() && Target->hasFeature("reference-types") && 
"shouldn't try to generate type externref outsid of WebAssembly target");
#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS)  \
  if (BuiltinType::Id == BuiltinType::WasmExternRef)   \
return SingletonId;
#include "clang/Basic/WebAssemblyReferenceTypes.def"
  }
llvm_unreachable("couldn't find the externref type?");
```
so it's clear that you shouldn't call this outside of a wasm target and that 
it's not an option to not find the type.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2480-2481
 #include "clang/Basic/RISCVVTypes.def"
+#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
   case BuiltinType::ShortAccum:

pmatos wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > Is it reasonable that this simply cannot mangle in Microsoft ABI mode?
> > Still wondering about this
> @aaron.ballman Why wouldn't externref_t be able to mangle in Microsoft ABI 
> mode? Quite clueless when it comes to ABIs.
Including the wasm types here means that in Microsoft mode, use of those types 
in a context which requires mangling will diagnose (see this snippet just 
below):
```
unsigned DiagID = Diags.getCustomDiagID(
DiagnosticsEngine::Error, "cannot mangle this built-in %0 type yet");
Diags.Report(Range.getBegin(), DiagID)
<< T->getName(Context.getASTContext().getPrintingPolicy()) << Range;
```
So I'm wondering whether you consider that to be reasonable behavior or not. If 
you don't want the diagnostic, then you should add a vendor extension mangling 
for the type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked an inline comment as done.
pmatos added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:806-807
+  SingletonId =
\
+  DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,   
\
+ MangledName, TheCU, TheCU->getFile(), 0); 
\
+return SingletonId;
\

tlively wrote:
> How did you choose this?
This is the creation of the debug info for an opaque structure type, although I 
guess we could use other representations for externref, do you have any 
suggestions?



Comment at: clang/test/CodeGen/WebAssembly/wasm-externref.c:11-13
+externref_t get_null() {
+  return __builtin_wasm_ref_null_extern();
+}

tlively wrote:
> Do we need this here since the builtin is also tested in builtins-wasm.c? Are 
> there more ways to use `externref_t` that we should test here?
Not at the moment. There's not much you can do with externref without using 
tables for example which is in another patch. Happy to remove this test as we 
have something similar indeed in builtins-wasm.c.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 488634.
pmatos marked an inline comment as done.
pmatos added a comment.

Address all comments except a couple of issues related to ABI and mangling.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function &F) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree &DT = getAnalysis().getDomTree();
@@ -96,6 +100,7 @@
 AU.addRequired();
 AU.setPreservesCFG();
   }
+
 };
 
 } // end anonymous namespace
@@ -111,6 +116,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,14 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM = static_cast(TM);
+  const WebAssemblySubtarget *Subtarget = WasmTM
+->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if(Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return ge

[PATCH] D140809: [clang][Interp] Implement logical and/or operators

2023-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:376
+this->emitLabel(LabelTrue);
+this->emitConstBool(true, E);
+this->fallthrough(LabelEnd);

tbaeder wrote:
> aaron.ballman wrote:
> > Am I correct in understanding that the reason we don't need to emit a const 
> > bool for `false` is because visiting the RHS already pushes either `true` 
> > or `false` onto the stack because it's already been converted to a bool 
> > result?
> Both LHS and RHS push a bool result to the stack, but the `jumpTrue`will 
> `pop()` the result of the LHS, so we need to push a true again if we want to 
> use it later as the result of the binary operator. 
Thank you for the confirmation, that makes sense to me. LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140809/new/

https://reviews.llvm.org/D140809

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


[PATCH] D141572: [C++] [Coroutines] Deprecates the '-fcoroutines-ts' flag

2023-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: libc++.
aaron.ballman added a comment.

Thank you for working on this! I think the Debian CI failure is unrelated, but 
the libc++ one looks plausibly related:

  
/home/libcxx-builder/.buildkite-agent/builds/e6f11fd202bc-1/llvm-project/libcxx-ci/build/generic-cxx03/include/c++/v1/module.modulemap:773:10:
 error: module 'std.coroutine' requires feature 'coroutines'
module coroutine {
   ^
  
/home/libcxx-builder/.buildkite-agent/builds/e6f11fd202bc-1/llvm-project/libcxx-ci/libcxx/test/libcxx/modules_include.sh.cpp:158:10:
 note: submodule of top-level module 'std' implicitly imported here
  #include 
   ^
  1 error generated.

adding the libc++ reviewers for awareness.




Comment at: clang/docs/ReleaseNotes.rst:547
+- Clang now deprecates the ``-fcoroutines-ts`` flag and the flag will be
+  removed in LLVM17. Please use C++20 Coroutines instead.
 





Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:630-633
+def warn_deperecated_fcoroutines_ts_flag : Warning<
+  "the \"-fcoroutines-ts\" flag is deprecated and it will be removed in 
LLVM17; "
+  "use C++20 Coroutines instead">,
+  InGroup;

Slight rewording for style.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141572/new/

https://reviews.llvm.org/D141572

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


[PATCH] D141404: [AArch64][Clang] Adjust default features for v8.9-A/v9.4-A in clang driver

2023-01-12 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

I agree the approach in D141518  makes more 
sense


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141404/new/

https://reviews.llvm.org/D141404

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-12 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked an inline comment as done.
pmatos added a comment.

@aaron.ballman many thanks for the thorough reviews on the patches. Happy to 
see this moving in the right direction.




Comment at: clang/lib/AST/MicrosoftMangle.cpp:2480-2481
 #include "clang/Basic/RISCVVTypes.def"
+#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
   case BuiltinType::ShortAccum:

aaron.ballman wrote:
> pmatos wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > Is it reasonable that this simply cannot mangle in Microsoft ABI mode?
> > > Still wondering about this
> > @aaron.ballman Why wouldn't externref_t be able to mangle in Microsoft ABI 
> > mode? Quite clueless when it comes to ABIs.
> Including the wasm types here means that in Microsoft mode, use of those 
> types in a context which requires mangling will diagnose (see this snippet 
> just below):
> ```
> unsigned DiagID = Diags.getCustomDiagID(
> DiagnosticsEngine::Error, "cannot mangle this built-in %0 type yet");
> Diags.Report(Range.getBegin(), DiagID)
> << T->getName(Context.getASTContext().getPrintingPolicy()) << Range;
> ```
> So I'm wondering whether you consider that to be reasonable behavior or not. 
> If you don't want the diagnostic, then you should add a vendor extension 
> mangling for the type.
Oh - now I understand your point. I had forgotten I had initially written this 
'workaround' to worry with later. Yes, let me add a vendor extension mangling 
for Microsoft ABI.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

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


[PATCH] D141447: clang/OpenCL: Don't use a Function for the block type

2023-01-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 488638.
arsenm added a comment.

Fix patch split. update_cc_test_checks misses the calling convention, so I'm 
going to precommit a test which verifies those are correct


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141447/new/

https://reviews.llvm.org/D141447

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGOpenCLRuntime.cpp
  clang/lib/CodeGen/CGOpenCLRuntime.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -339,7 +339,7 @@
   /// convention and ABI as an OpenCL kernel. The wrapper function accepts
   /// block context and block arguments in target-specific way and calls
   /// the original block invoke function.
-  virtual llvm::Function *
+  virtual llvm::Value *
   createEnqueuedBlockKernel(CodeGenFunction &CGF,
 llvm::Function *BlockInvokeFunc,
 llvm::Type *BlockTy) const;
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9424,10 +9424,9 @@
  SyncScope Scope,
  llvm::AtomicOrdering Ordering,
  llvm::LLVMContext &Ctx) const override;
-  llvm::Function *
-  createEnqueuedBlockKernel(CodeGenFunction &CGF,
-llvm::Function *BlockInvokeFunc,
-llvm::Type *BlockTy) const override;
+  llvm::Value *createEnqueuedBlockKernel(CodeGenFunction &CGF,
+ llvm::Function *BlockInvokeFunc,
+ llvm::Type *BlockTy) const override;
   bool shouldEmitStaticExternCAliases() const override;
   void setCUDAKernelCallingConvention(const FunctionType *&FT) const override;
 };
@@ -12403,10 +12402,8 @@
 /// The kernel has the same function type as the block invoke function. Its
 /// name is the name of the block invoke function postfixed with "_kernel".
 /// It simply calls the block invoke function then returns.
-llvm::Function *
-TargetCodeGenInfo::createEnqueuedBlockKernel(CodeGenFunction &CGF,
- llvm::Function *Invoke,
- llvm::Type *BlockTy) const {
+llvm::Value *TargetCodeGenInfo::createEnqueuedBlockKernel(
+CodeGenFunction &CGF, llvm::Function *Invoke, llvm::Type *BlockTy) const {
   auto *InvokeFT = Invoke->getFunctionType();
   auto &C = CGF.getLLVMContext();
   std::string Name = Invoke->getName().str() + "_kernel";
@@ -12414,13 +12411,21 @@
  InvokeFT->params(), false);
   auto *F = llvm::Function::Create(FT, llvm::GlobalValue::ExternalLinkage, Name,
&CGF.CGM.getModule());
+  llvm::CallingConv::ID KernelCC =
+  CGF.getTypes().ClangCallConvToLLVMCallConv(CallingConv::CC_OpenCLKernel);
+  F->setCallingConv(KernelCC);
+
   auto IP = CGF.Builder.saveIP();
   auto *BB = llvm::BasicBlock::Create(C, "entry", F);
   auto &Builder = CGF.Builder;
   Builder.SetInsertPoint(BB);
   llvm::SmallVector Args(llvm::make_pointer_range(F->args()));
-  llvm::CallInst *call = Builder.CreateCall(Invoke, Args);
-  call->setCallingConv(Invoke->getCallingConv());
+  llvm::CallInst *Call = Builder.CreateCall(Invoke, Args);
+  Call->setCallingConv(Invoke->getCallingConv());
+
+  // FIXME: Apply default attributes
+  F->addFnAttr(llvm::Attribute::NoUnwind);
+
   Builder.CreateRetVoid();
   Builder.restoreIP(IP);
   return F;
@@ -12434,9 +12439,8 @@
 /// allocates the same type of struct on stack and stores the block literal
 /// to it and passes its pointer to the block invoke function. The kernel
 /// has "enqueued-block" function attribute and kernel argument metadata.
-llvm::Function *AMDGPUTargetCodeGenInfo::createEnqueuedBlockKernel(
-CodeGenFunction &CGF, llvm::Function *Invoke,
-llvm::Type *BlockTy) const {
+llvm::Value *AMDGPUTargetCodeGenInfo::createEnqueuedBlockKernel(
+CodeGenFunction &CGF, llvm::Function *Invoke, llvm::Type *BlockTy) const {
   auto &Builder = CGF.Builder;
   auto &C = CGF.getLLVMContext();
 
@@ -12470,7 +12474,12 @@
   auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(C), ArgTys, false);
   auto *F = llvm::Function::Create(FT, llvm::GlobalValue::InternalLinkage, Name,
&CGF.CGM.getModule());
+  F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
+
+  // FIXME: Apply default attributes
+  F->addFnAttr(llvm::Attribute::NoUnwind);
   F->addFnAttr("enqueued-block");
+
   auto IP = CGF.Builder.saveIP();
   auto *BB = llvm::BasicBlock::Create(C, "entry", F);
   Builder.SetInsertPoint(BB);
Index: clang/lib/Cod

[PATCH] D136031: [DirectX backend] support ConstantBuffer to DXILResource.h

2023-01-12 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136031/new/

https://reviews.llvm.org/D136031

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


[PATCH] D141583: [clang-tidy][doc] Deprecate the AnalyzeTemporaryDtors option

2023-01-12 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:106
+- Deprecate the global configuration file option `AnalyzeTemporaryDtors`,
+  which is no longer in use. The option will be fully removed in clang-tidy 18.
+

`Clang-tidy`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141583/new/

https://reviews.llvm.org/D141583

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


  1   2   3   4   >