[compiler-rt] [libc] [clang] [llvm] [clang-tools-extra] [flang] [libcxx] [openmp] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-08 Thread via cfe-commits

https://github.com/pizzud updated 
https://github.com/llvm/llvm-project/pull/67467

>From 6d5d35e1273f595e8a0382053d5183cbce7a9d8a Mon Sep 17 00:00:00 2001
From: David Pizzuto 
Date: Tue, 26 Sep 2023 10:45:42 -0700
Subject: [PATCH 1/5] [clang-tidy] Add bugprone-move-shared-pointer-contents
 check.

This check detects moves of the contents of a shared pointer rather than the
pointer itself. Other code with a reference to the shared pointer is probably
not expecting the move.

The set of shared pointer classes is configurable via options to allow 
individual
projects to cover additional types.
---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  2 +
 .../MoveSharedPointerContentsCheck.cpp| 60 
 .../bugprone/MoveSharedPointerContentsCheck.h | 37 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  6 ++
 .../bugprone/move-shared-pointer-contents.rst | 17 +
 .../docs/clang-tidy/checks/list.rst   |  2 +
 .../bugprone/move-shared-pointer-contents.cpp | 68 +++
 8 files changed, 195 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/move-shared-pointer-contents.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/move-shared-pointer-contents.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index a67a91eedd1048..7f4a504f9930f1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -39,6 +39,7 @@
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
+#include "MoveSharedPointerContentsCheck.h"
 #include "MultiLevelImplicitPointerConversionCheck.h"
 #include "MultipleNewInOneExpressionCheck.h"
 #include "MultipleStatementMacroCheck.h"
@@ -125,6 +126,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-move-shared-pointer-contents");
 CheckFactories.registerCheck(
 "bugprone-switch-missing-default-case");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 3c768021feb150..c017f0c0cc5202 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -23,6 +23,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  MoveSharedPointerContentsCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
   IncDecInConditionsCheck.cpp
   IncorrectRoundingsCheck.cpp
@@ -35,6 +36,7 @@ add_clang_library(clangTidyBugproneModule
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
+  MoveSharedPointerContentsCheck.cpp
   MultiLevelImplicitPointerConversionCheck.cpp
   MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
new file mode 100644
index 00..b4a393b7f2f200
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
@@ -0,0 +1,60 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))) {}
+
+MoveSharedPointerContentsCheck::~MoveSharedPointerContentsCheck() = default;
+
+bool MoveSharedPointerContentsCheck::isLanguageVersionSupported(
+const LangOptions ) const {
+  return 

[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-08 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH] [Clang][Sema] Check the number of lambda non-concept tempate
 parameters Check that the number of non-concept template parameters is
 greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..a140bbbc0c43d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-08 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/2] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..a140bbbc0c43d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From db02522026418a1a0ac2b34e24a29596dae05f9f Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 06:56:06 +0800
Subject: [PATCH 2/2] fix ut

---
 clang/lib/Sema/TreeTransform.h | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d5..fa0b9a0ca7d69f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,21 +13662,21 @@ 
TreeTransform::TransformLambdaExpr(LambdaExpr *E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
+  // // Check the number of the Concept template parameters
+  // size_t conceptParams = 0;
+  // for (auto P : *E->getTemplateParameterList()) {
+  //   const TemplateTypeParmDecl *CD = dyn_cast(P);
+  //   if (CD && CD->hasTypeConstraint()) {
+  // conceptParams++;
+  //   }
+  // }
+
+  // if (conceptParams > 0 &&
+  // conceptParams == E->getTemplateParameterList()->size()) {
+  //   getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+  //  diag::err_expected_non_concept_template_parameter);
+  //   return ExprError();
+  // }
 
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives

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


[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan created 
https://github.com/llvm/llvm-project/pull/74893

An 8 bit bitfield with preferred bool type? Seems confused.

>From f7cac332123f6ea6c78dcffbcac2d58f356b6396 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Fri, 8 Dec 2023 17:43:22 -0500
Subject: [PATCH] [clang] Adjust TargetInfo bitfield

An 8 bit bitfield with preferred bool type? Seems confused.
---
 clang/include/clang/Basic/TargetInfo.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 41f3c2e403cbe..ec0189627dfbd 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -266,7 +266,6 @@ class TargetInfo : public TransferrableTargetInfo,
   LLVM_PREFERRED_TYPE(bool)
   unsigned AllowAMDGPUUnsafeFPAtomics : 1;
 
-  LLVM_PREFERRED_TYPE(bool)
   unsigned ARMCDECoprocMask : 8;
 
   unsigned MaxOpenCLWorkGroupSize;

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-08 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH] [Clang][Sema] Check the number of lambda non-concept tempate
 parameters Check that the number of non-concept template parameters is
 greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..a140bbbc0c43d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

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


[clang-tools-extra] [llvm] [compiler-rt] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

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

david-xl wrote:

> > > . For IR PGO, there is basically no need to do so as the instrumentation 
> > > and profile-use should be in-sync. For front-end instrumentation, there 
> > > seem to be some use cases to use out of sync profile: 
> > > https://reviews.llvm.org/D51240.
> > 
> > 
> > Thanks for double checking. I noticed the ICP and stale profile tolerance 
> > discussions when read the Phab history; it's good Phab review history are 
> > still available nowadays.
> > IRPGO profiles could be used along with supplementary sample-pgo profiles. 
> > I'll probably read relevant code in llvm-profdata to understand how these 
> > interact in theory mostly for my own curiosity (hopefully no rough edges as 
> > long as `llvm-profdata` uses the same pgo name format used by latest 
> > compiler)
> 
> For irpgo with supplementary profiles, this line to build a map (
> 
> https://github.com/llvm/llvm-project/blob/44dc1e0baae7c4b8a02ba06dcf396d3d452aa873/llvm/tools/llvm-profdata/llvm-profdata.cpp#L982
> 
> ) needs an update. Will do it together with the test 
> [update](https://github.com/llvm/llvm-project/pull/74008#discussion_r1421018997)
>  in this pull request.

A follow up patch to fix the tool is fine too (or may be better).

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


[clang] [clang] NFCI: Make `ModuleFile::File` non-optional (PR #74892)

2023-12-08 Thread Jan Svoboda via cfe-commits

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


[clang] [clang] NFCI: Make `ModuleFile::File` non-optional (PR #74892)

2023-12-08 Thread Jan Svoboda via cfe-commits


@@ -441,22 +434,19 @@ void 
ModuleManager::visit(llvm::function_ref Visitor,
 bool ModuleManager::lookupModuleFile(StringRef FileName, off_t ExpectedSize,
  time_t ExpectedModTime,
  OptionalFileEntryRef ) {
-  File = std::nullopt;
-  if (FileName == "-")
+  if (FileName == "-") {
+File = expectedToOptional(FileMgr.getSTDIN());
 return false;
+  }
 
   // Open the file immediately to ensure there is no race between stat'ing and
   // opening the file.
-  OptionalFileEntryRef FileOrErr =
-  expectedToOptional(FileMgr.getFileRef(FileName, /*OpenFile=*/true,
-/*CacheFailure=*/false));
-  if (!FileOrErr)
-return false;
-
-  File = *FileOrErr;
+  File = expectedToOptional(FileMgr.getFileRef(FileName, /*OpenFile=*/true,

jansvoboda11 wrote:

I guess I could've replace this with `getOptionalFileRef()` while I'm touching 
the line.

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


[clang-tools-extra] [llvm] [compiler-rt] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

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

minglotus-6 wrote:

> > . For IR PGO, there is basically no need to do so as the instrumentation 
> > and profile-use should be in-sync. For front-end instrumentation, there 
> > seem to be some use cases to use out of sync profile: 
> > https://reviews.llvm.org/D51240.
> 
> Thanks for double checking. I noticed the ICP and stale profile tolerance 
> discussions when read the Phab history; it's good Phab review history are 
> still available nowadays.
> 
> IRPGO profiles could be used along with supplementary sample-pgo profiles. 
> I'll probably read relevant code in llvm-profdata to understand how these 
> interact in theory mostly for my own curiosity (hopefully no rough edges as 
> long as `llvm-profdata` uses the same pgo name format used by latest compiler)

For irpgo with supplementary profiles, this line to build a map 
(https://github.com/llvm/llvm-project/blob/44dc1e0baae7c4b8a02ba06dcf396d3d452aa873/llvm/tools/llvm-profdata/llvm-profdata.cpp#L982)
 needs an update. Will do it together with the test 
[update](https://github.com/llvm/llvm-project/pull/74008#discussion_r1421018997)
 in this pull request.

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


[clang] [clang] NFCI: Make `ModuleFile::File` non-optional (PR #74892)

2023-12-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)


Changes

AFAICT, `ModuleFile::File` can be `std::nullopt` only for PCM files loaded from 
the standard input. This patch starts setting that variable to 
`FileManager::getSTDIN()` in that case, which makes it possible to remove the 
optionality, and also simplifies code that actually reads the file.

This is part of an effort to get rid of 
`Optional{File,Directory}EntryRefDegradesTo{File,Directory}EntryPtr`.

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


5 Files Affected:

- (modified) clang/include/clang/Serialization/ModuleFile.h (+3-3) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1) 
- (modified) clang/lib/Serialization/GlobalModuleIndex.cpp (+2-2) 
- (modified) clang/lib/Serialization/ModuleManager.cpp (+22-32) 


``diff
diff --git a/clang/include/clang/Serialization/ModuleFile.h 
b/clang/include/clang/Serialization/ModuleFile.h
index 48be8676cc26a4..70ab61dec8b6bf 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -123,8 +123,8 @@ class InputFile {
 /// other modules.
 class ModuleFile {
 public:
-  ModuleFile(ModuleKind Kind, unsigned Generation)
-  : Kind(Kind), Generation(Generation) {}
+  ModuleFile(ModuleKind Kind, FileEntryRef File, unsigned Generation)
+  : Kind(Kind), File(File), Generation(Generation) {}
   ~ModuleFile();
 
   // === General information ===
@@ -176,7 +176,7 @@ class ModuleFile {
   bool DidReadTopLevelSubmodule = false;
 
   /// The file entry for the module file.
-  OptionalFileEntryRefDegradesToFileEntryPtr File;
+  FileEntryRef File;
 
   /// The signature of the module file, which may be used instead of the size
   /// and modification time to identify this particular file.
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index f22da838424b41..49f25d6648c801 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5786,7 +5786,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile ,
 PartialDiagnostic(diag::err_module_file_conflict,
   ContextObj->DiagAllocator)
 << CurrentModule->getTopLevelModuleName() << CurFile->getName()
-<< F.File->getName();
+<< F.File.getName();
 return DiagnosticError::create(CurrentImportLoc, ConflictError);
   }
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 6df815234e235f..38e8b8ccbe058d 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1413,7 +1413,7 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
 
   // If we have calculated signature, there is no need to store
   // the size or timestamp.
-  Record.push_back(M.Signature ? 0 : M.File->getSize());
+  Record.push_back(M.Signature ? 0 : M.File.getSize());
   Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
 
   llvm::append_range(Record, M.Signature);
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index fb80a1998d0efe..dd4fc3e009050f 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -342,8 +342,8 @@ bool GlobalModuleIndex::loadedModuleFile(ModuleFile *File) {
   //  If the size and modification time match what we expected, record this
   // module file.
   bool Failed = true;
-  if (File->File->getSize() == Info.Size &&
-  File->File->getModificationTime() == Info.ModTime) {
+  if (File->File.getSize() == Info.Size &&
+  File->File.getModificationTime() == Info.ModTime) {
 Info.File = File;
 ModulesByFile[File] = Known->second;
 
diff --git a/clang/lib/Serialization/ModuleManager.cpp 
b/clang/lib/Serialization/ModuleManager.cpp
index de4cd3d05853ac..7cf97125b8ef03 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -108,7 +108,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind 
Type,
 
   // Look for the file entry. This only fails if the expected size or
   // modification time differ.
-  OptionalFileEntryRefDegradesToFileEntryPtr Entry;
+  OptionalFileEntryRef Entry;
   if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
 // If we're not expecting to pull this file out of the module cache, it
 // might have a different mtime due to being moved across filesystems in
@@ -123,7 +123,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind 
Type,
 return OutOfDate;
   }
 
-  if (!Entry && FileName != "-") {
+  if (!Entry) {
 ErrorStr = "module file not found";
 return Missing;
   }
@@ -150,7 +150,7 @@ ModuleManager::addModule(StringRef 

[clang] [clang] NFCI: Make `ModuleFile::File` non-optional (PR #74892)

2023-12-08 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 created 
https://github.com/llvm/llvm-project/pull/74892

AFAICT, `ModuleFile::File` can be `std::nullopt` only for PCM files loaded from 
the standard input. This patch starts setting that variable to 
`FileManager::getSTDIN()` in that case, which makes it possible to remove the 
optionality, and also simplifies code that actually reads the file.

This is part of an effort to get rid of 
`Optional{File,Directory}EntryRefDegradesTo{File,Directory}EntryPtr`.

>From fb5c8c9fe856aaa2a314effa26486d5fbf019140 Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Thu, 7 Dec 2023 14:04:35 -0800
Subject: [PATCH] [clang] NFCI: Make `ModuleFile::File` non-optional

---
 .../include/clang/Serialization/ModuleFile.h  |  6 +--
 clang/lib/Serialization/ASTReader.cpp |  2 +-
 clang/lib/Serialization/ASTWriter.cpp |  2 +-
 clang/lib/Serialization/GlobalModuleIndex.cpp |  4 +-
 clang/lib/Serialization/ModuleManager.cpp | 54 ---
 5 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/clang/include/clang/Serialization/ModuleFile.h 
b/clang/include/clang/Serialization/ModuleFile.h
index 48be8676cc26a4..70ab61dec8b6bf 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -123,8 +123,8 @@ class InputFile {
 /// other modules.
 class ModuleFile {
 public:
-  ModuleFile(ModuleKind Kind, unsigned Generation)
-  : Kind(Kind), Generation(Generation) {}
+  ModuleFile(ModuleKind Kind, FileEntryRef File, unsigned Generation)
+  : Kind(Kind), File(File), Generation(Generation) {}
   ~ModuleFile();
 
   // === General information ===
@@ -176,7 +176,7 @@ class ModuleFile {
   bool DidReadTopLevelSubmodule = false;
 
   /// The file entry for the module file.
-  OptionalFileEntryRefDegradesToFileEntryPtr File;
+  FileEntryRef File;
 
   /// The signature of the module file, which may be used instead of the size
   /// and modification time to identify this particular file.
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index f22da838424b41..49f25d6648c801 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5786,7 +5786,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile ,
 PartialDiagnostic(diag::err_module_file_conflict,
   ContextObj->DiagAllocator)
 << CurrentModule->getTopLevelModuleName() << CurFile->getName()
-<< F.File->getName();
+<< F.File.getName();
 return DiagnosticError::create(CurrentImportLoc, ConflictError);
   }
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 6df815234e235f..38e8b8ccbe058d 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1413,7 +1413,7 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
 
   // If we have calculated signature, there is no need to store
   // the size or timestamp.
-  Record.push_back(M.Signature ? 0 : M.File->getSize());
+  Record.push_back(M.Signature ? 0 : M.File.getSize());
   Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
 
   llvm::append_range(Record, M.Signature);
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index fb80a1998d0efe..dd4fc3e009050f 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -342,8 +342,8 @@ bool GlobalModuleIndex::loadedModuleFile(ModuleFile *File) {
   //  If the size and modification time match what we expected, record this
   // module file.
   bool Failed = true;
-  if (File->File->getSize() == Info.Size &&
-  File->File->getModificationTime() == Info.ModTime) {
+  if (File->File.getSize() == Info.Size &&
+  File->File.getModificationTime() == Info.ModTime) {
 Info.File = File;
 ModulesByFile[File] = Known->second;
 
diff --git a/clang/lib/Serialization/ModuleManager.cpp 
b/clang/lib/Serialization/ModuleManager.cpp
index de4cd3d05853ac..7cf97125b8ef03 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -108,7 +108,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind 
Type,
 
   // Look for the file entry. This only fails if the expected size or
   // modification time differ.
-  OptionalFileEntryRefDegradesToFileEntryPtr Entry;
+  OptionalFileEntryRef Entry;
   if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
 // If we're not expecting to pull this file out of the module cache, it
 // might have a different mtime due to being moved across filesystems in
@@ -123,7 +123,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind 
Type,
 return OutOfDate;
   }
 
-  if (!Entry && FileName != "-") {
+  if (!Entry) {
   

[libunwind] [libunwind] Replace process_vm_readv with pipe (PR #74791)

2023-12-08 Thread Jordan R AW via cfe-commits


@@ -2822,13 +2825,18 @@ bool UnwindCursor::setInfoForSigReturn(Registers_s390x &) {
   // onto the stack.
   const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
   // The PC might contain an invalid address if the unwind info is bad, so
-  // directly accessing it could cause a segfault. Use process_vm_readv to
+  // directly accessing it could cause a segfault. Use pipe/write/read to
   // read the memory safely instead.
   uint16_t inst;

ajordanr-google wrote:

Fixed.

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


[libunwind] [libunwind] Replace process_vm_readv with pipe (PR #74791)

2023-12-08 Thread Jordan R AW via cfe-commits

https://github.com/ajordanr-google updated 
https://github.com/llvm/llvm-project/pull/74791

>From 1f4df1b82970c95684eed93c8f6bcaa6d6507b88 Mon Sep 17 00:00:00 2001
From: Jordan R Abrahams-Whitehead 
Date: Fri, 8 Dec 2023 00:09:59 +
Subject: [PATCH 1/2] [libunwind] Replace process_vm_readv with pipe

process_vm_readv is generally considered dangerous from a syscall
perspective, and is frequently blanket banned in seccomp filters such as
those in Chromium and ChromiumOS. We can get the same behaviour during
the invalid PC address case with pipes and write/read.

Testing to ensure that process_vm_readv does not appear, I ran the
output of check-unwind on an ARM64 device under strace. Previously,
bad_unwind_info in particular would use process_vm_readv, but with this
commit, it now uses pipe2:

```
strace test/Output/bad_unwind_info.pass.cpp.dir/t.tmp.exe \
  |& grep process_vm_readv
strace test/Output/bad_unwind_info.pass.cpp.dir/t.tmp.exe \
  |& grep pipe2
```
---
 libunwind/src/UnwindCursor.hpp | 50 --
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 647a5a9c9d92d..5e4e376220daa 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -33,6 +33,7 @@
 #if defined(_LIBUNWIND_TARGET_LINUX) &&
\
 (defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_RISCV) || 
\
  defined(_LIBUNWIND_TARGET_S390X))
+#include 
 #include 
 #include 
 #include 
@@ -2700,19 +2701,18 @@ bool UnwindCursor::setInfoForSigReturn(Registers_arm64 &) {
   // [1] 
https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vdso/sigreturn.S
   const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
   // The PC might contain an invalid address if the unwind info is bad, so
-  // directly accessing it could cause a segfault. Use process_vm_readv to read
-  // the memory safely instead. process_vm_readv was added in Linux 3.2, and
-  // AArch64 supported was added in Linux 3.7, so the syscall is guaranteed to
-  // be present. Unfortunately, there are Linux AArch64 environments where the
-  // libc wrapper for the syscall might not be present (e.g. Android 5), so 
call
-  // the syscall directly instead.
+  // directly accessing it could cause a segfault. Use pipe/write/read to read
+  // the memory safely instead.
+  int pipefd[2];
+  if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1)
+return false;
   uint32_t instructions[2];
-  struct iovec local_iov = {, sizeof instructions};
-  struct iovec remote_iov = {reinterpret_cast(pc), sizeof 
instructions};
-  long bytesRead =
-  syscall(SYS_process_vm_readv, getpid(), _iov, 1, _iov, 1, 
0);
+  const auto bufferSize = sizeof instructions;
+  if (write(pipefd[1], reinterpret_cast(pc), bufferSize) != bufferSize)
+return false;
+  const auto bytesRead = read(pipefd[0], instructions, bufferSize);
   // Look for instructions: mov x8, #0x8b; svc #0x0
-  if (bytesRead != sizeof instructions || instructions[0] != 0xd2801168 ||
+  if (bytesRead != bufferSize || instructions[0] != 0xd2801168 ||
   instructions[1] != 0xd401)
 return false;
 
@@ -2762,17 +2762,20 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
 template 
 bool UnwindCursor::setInfoForSigReturn(Registers_riscv &) {
   const pint_t pc = static_cast(getReg(UNW_REG_IP));
+  int pipefd[2];
+  if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1)
+return false;
   uint32_t instructions[2];
-  struct iovec local_iov = {, sizeof instructions};
-  struct iovec remote_iov = {reinterpret_cast(pc), sizeof 
instructions};
-  long bytesRead =
-  syscall(SYS_process_vm_readv, getpid(), _iov, 1, _iov, 1, 
0);
+  const auto bufferSize = sizeof instructions;
+  if (write(pipefd[1], reinterpret_cast(pc), bufferSize) != bufferSize)
+return false;
+  const auto bytesRead = read(pipefd[0], instructions, bufferSize);
   // Look for the two instructions used in the sigreturn trampoline
   // __vdso_rt_sigreturn:
   //
   // 0x08b00893 li a7,0x8b
   // 0x0073 ecall
-  if (bytesRead != sizeof instructions || instructions[0] != 0x08b00893 ||
+  if (bytesRead != bufferSize || instructions[0] != 0x08b00893 ||
   instructions[1] != 0x0073)
 return false;
 
@@ -2822,13 +2825,18 @@ bool UnwindCursor::setInfoForSigReturn(Registers_s390x &) {
   // onto the stack.
   const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
   // The PC might contain an invalid address if the unwind info is bad, so
-  // directly accessing it could cause a segfault. Use process_vm_readv to
+  // directly accessing it could cause a segfault. Use pipe/write/read to
   // read the memory safely instead.
   uint16_t inst;
-  struct iovec local_iov = {, sizeof inst};
-  struct iovec remote_iov = {reinterpret_cast(pc), sizeof inst};
-  long bytesRead = process_vm_readv(getpid(), _iov, 1, _iov, 1, 
0);
-  if (bytesRead == sizeof 

[flang] [clang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-08 Thread Andrzej Warzyński via cfe-commits

https://github.com/banach-space updated 
https://github.com/llvm/llvm-project/pull/74377

From 1eefb9136ea042e44ada4be66a18b4bf69c18fe3 Mon Sep 17 00:00:00 2001
From: Andrzej Warzynski 
Date: Sat, 2 Dec 2023 14:01:02 +
Subject: [PATCH 1/3] [flang][driver] Rename `flang-new` as `flang`

This patch renames `flang-new` as `flang`. Similarly to Clang, Flang's
driver executable will be called:

  * `flang-`

A symlink called `flang` pointing at `flang-` will be
created at build time. This is consistent with Clang.

For backwards compatibility, a symlink `flang-new` pointing to
`flang-` is also created. This will be removed in the
future.
---
 clang/lib/Driver/Driver.cpp   |  2 +-
 clang/lib/Driver/ToolChain.cpp|  3 +
 clang/lib/Driver/ToolChains/Flang.cpp | 10 +--
 clang/test/Driver/flang/flang.f90 |  2 +-
 clang/test/Driver/flang/flang_ucase.F90   |  2 +-
 .../Driver/flang/multiple-inputs-mixed.f90|  2 +-
 clang/test/Driver/flang/multiple-inputs.f90   |  4 +-
 flang/docs/FlangDriver.md | 70 +--
 flang/docs/ImplementingASemanticCheck.md  |  4 +-
 flang/docs/Overview.md| 12 ++--
 .../FlangOmpReport/FlangOmpReport.cpp |  2 +-
 .../ExecuteCompilerInvocation.cpp |  3 +-
 flang/test/CMakeLists.txt |  2 +-
 flang/test/Driver/compiler-options.f90|  2 +-
 .../test/Driver/disable-ext-name-interop.f90  |  2 +-
 flang/test/Driver/driver-help-hidden.f90  |  6 +-
 flang/test/Driver/driver-version.f90  |  4 +-
 flang/test/Driver/escaped-backslash.f90   |  4 +-
 flang/test/Driver/fdefault.f90| 28 
 flang/test/Driver/flarge-sizes.f90| 20 +++---
 flang/test/Driver/frontend-forwarding.f90 |  4 +-
 flang/test/Driver/intrinsic-module-path.f90   |  2 +-
 flang/test/Driver/lto-flags.f90   |  2 +-
 flang/test/Driver/macro-def-undef.F90 |  4 +-
 flang/test/Driver/missing-input.f90   | 14 ++--
 flang/test/Driver/multiple-input-files.f90|  2 +-
 flang/test/Driver/omp-driver-offload.f90  | 52 +++---
 .../predefined-macros-compiler-version.F90|  4 +-
 flang/test/Driver/std2018-wrong.f90   |  2 +-
 flang/test/Driver/std2018.f90 |  2 +-
 .../Driver/supported-suffices/f03-suffix.f03  |  2 +-
 .../Driver/supported-suffices/f08-suffix.f08  |  2 +-
 flang/test/Driver/use-module-error.f90|  4 +-
 flang/test/Driver/use-module.f90  |  4 +-
 flang/test/Driver/version-loops.f90   | 18 ++---
 .../Intrinsics/command_argument_count.f90 |  4 +-
 flang/test/Lower/Intrinsics/exit.f90  |  2 +-
 .../test/Lower/Intrinsics/ieee_is_normal.f90  |  2 +-
 .../OpenMP/Todo/omp-declarative-allocate.f90  |  2 +-
 .../OpenMP/Todo/omp-declare-reduction.f90 |  2 +-
 .../Lower/OpenMP/Todo/omp-declare-simd.f90|  2 +-
 flang/test/lit.cfg.py |  4 +-
 flang/tools/f18/CMakeLists.txt|  6 +-
 flang/tools/flang-driver/CMakeLists.txt   | 22 --
 flang/tools/flang-driver/driver.cpp   |  7 +-
 45 files changed, 185 insertions(+), 170 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082ee..e72ea0e427fc70 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1948,7 +1948,7 @@ void Driver::PrintHelp(bool ShowHidden) const {
 
 void Driver::PrintVersion(const Compilation , raw_ostream ) const {
   if (IsFlangMode()) {
-OS << getClangToolFullVersion("flang-new") << '\n';
+OS << getClangToolFullVersion("flang") << '\n';
   } else {
 // FIXME: The following handlers should use a callback mechanism, we don't
 // know what the client would like to do.
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ab19166f18c2dc..eb5bd8d033bb47 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -310,6 +310,9 @@ static const DriverSuffix *FindDriverSuffix(StringRef 
ProgName, size_t ) {
   {"cl", "--driver-mode=cl"},
   {"++", "--driver-mode=g++"},
   {"flang", "--driver-mode=flang"},
+  // For backwards compatibility, we create a symlink for `flang` called
+  // `flang-new`. This will be removed in the future.
+  {"flang-new", "--driver-mode=flang"},
   {"clang-dxc", "--driver-mode=dxc"},
   };
 
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 9b21fe952af7a8..a885dd759c831b 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -762,14 +762,16 @@ void Flang::ConstructJob(Compilation , const JobAction 
,
 
   CmdArgs.push_back(Input.getFilename());
 
-  // TODO: Replace flang-new with flang once the new driver replaces the
-  // throwaway driver
-  const char *Exec = Args.MakeArgString(D.GetProgramPath("flang-new", TC));
+  // Get 

[clang-tools-extra] [llvm] [clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-08 Thread Bill Wendling via cfe-commits


@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const 
ArraySubscriptExpr *E,
   ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true);
 else
   ArrayLV = EmitLValue(Array);
+
 auto *Idx = EmitIdxAfterBase(/*Promote*/true);
 
+if (SanOpts.has(SanitizerKind::ArrayBounds)) {

bwendling wrote:

Responding to your comment about emitting the base twice, this seems to be, if 
not common, at least not unusual. Given the proximity of the array subscript 
expr and the counted by checks, any duplicate base pointer loads are elided.

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


[lld] [llvm] [mlir] [lldb] [flang] [clang] [openmp] [clang-tools-extra] [libcxx] [libcxxabi] [compiler-rt] [libc] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-08 Thread Jon Roelofs via cfe-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73686

>From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Tue, 28 Nov 2023 10:39:44 -0800
Subject: [PATCH 01/11] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?=
 =?UTF-8?q?initial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/docs/LangRef.rst |   7 +-
 llvm/include/llvm/CodeGen/AsmPrinter.h|   6 +-
 llvm/lib/CodeGen/GlobalISel/CallLowering.cpp  |   7 +-
 llvm/lib/IR/Verifier.cpp  |  12 +-
 llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |  28 ++
 llvm/lib/Target/X86/X86AsmPrinter.h   |   1 +
 .../AArch64/GlobalISel/call-lowering-ifunc.ll |  37 +++
 llvm/test/CodeGen/AArch64/addrsig-macho.ll|   4 +-
 llvm/test/CodeGen/AArch64/ifunc-asm.ll|  82 +
 llvm/test/CodeGen/X86/ifunc-asm.ll|  28 +-
 llvm/test/Verifier/ifunc-macho.ll |  42 +++
 12 files changed, 539 insertions(+), 23 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll
 create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll
 create mode 100644 llvm/test/Verifier/ifunc-macho.ll

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index e448c5ed5c5d94..cb222e979db29d 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -934,10 +934,11 @@ IFuncs
 ---
 
 IFuncs, like as aliases, don't create any new data or func. They are just a new
-symbol that dynamic linker resolves at runtime by calling a resolver function.
+symbol that is resolved at runtime by calling a resolver function.
 
-IFuncs have a name and a resolver that is a function called by dynamic linker
-that returns address of another function associated with the name.
+On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On
+MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which
+lazily resolve the callee the first time they are called.
 
 IFunc may have an optional :ref:`linkage type ` and an optional
 :ref:`visibility style `.
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h 
b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 2731ef452c79cb..48fa6c478464c7 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass {
 
   GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy );
   void emitGlobalAlias(Module , const GlobalAlias );
-  void emitGlobalIFunc(Module , const GlobalIFunc );
+
+protected:
+  virtual void emitGlobalIFunc(Module , const GlobalIFunc );
+
+private:
 
   /// This method decides whether the specified basic block requires a label.
   bool shouldEmitLabelForBasicBlock(const MachineBasicBlock ) const;
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp 
b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 2527b143128967..e0080b145d4f99 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder , 
const CallBase ,
   // Try looking through a bitcast from one function type to another.
   // Commonly happens with calls to objc_msgSend().
   const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts();
-  if (const Function *F = dyn_cast(CalleeV))
+  if (const GlobalIFunc *IF = dyn_cast(CalleeV);
+  IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) {
+// ld64 requires that .symbol_resolvers to be called via a stub, so these
+// must always be a diret call.
+Info.Callee = MachineOperand::CreateGA(IF, 0);
+  } else if (const Function *F = dyn_cast(CalleeV))
 Info.Callee = MachineOperand::CreateGA(F, 0);
   else
 Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false);
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 5560c037aa3ee6..94e76a43bf38d6 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc ) {
   GlobalIFunc::getResolverFunctionType(GI.getValueType());
   Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()),
 "IFunc resolver has incorrect type", );
+
 }
 
 void Verifier::visitNamedMDNode(const NamedMDNode ) {
@@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, 
AttributeList Attrs,
   }
 
   // Check EVEX512 feature.
-  if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) {
-Triple T(M.getTargetTriple());
-if (T.isX86()) {
-  StringRef TF = Attrs.getFnAttr("target-features").getValueAsString();
-  Check(!TF.contains("+avx512f") || !TF.contains("-evex512"),
-"512-bit vector arguments require 'evex512' for AVX512", V);
- 

[clang-tools-extra] [clang-tidy] Fix missing parentheses in readability-implicit-bool-conversion fixes (PR #74891)

2023-12-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Piotr Zegar (PiotrZSL)


Changes

Check now more properly add missing parentheses to code like this: 'bool bar = 
true ? 1 : 0 != 0;'.

Closes #71867

---

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


7 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
(+6-29) 
- (modified) clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp (+34) 
- (modified) clang-tools-extra/clang-tidy/utils/FixItHintUtils.h (+4) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
 (+3-3) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-cxx98.cpp
 (+6-6) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
 (+85-69) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index f0fca30de3b3c..e011598cc7c9f 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "ImplicitBoolConversionCheck.h"
+#include "../utils/FixItHintUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
@@ -61,31 +62,6 @@ bool isUnaryLogicalNotOperator(const Stmt *Statement) {
   return UnaryOperatorExpr && UnaryOperatorExpr->getOpcode() == UO_LNot;
 }
 
-bool areParensNeededForOverloadedOperator(OverloadedOperatorKind OperatorKind) 
{
-  switch (OperatorKind) {
-  case OO_New:
-  case OO_Delete: // Fall-through on purpose.
-  case OO_Array_New:
-  case OO_Array_Delete:
-  case OO_ArrowStar:
-  case OO_Arrow:
-  case OO_Call:
-  case OO_Subscript:
-return false;
-
-  default:
-return true;
-  }
-}
-
-bool areParensNeededForStatement(const Stmt *Statement) {
-  if (const auto *OperatorCall = dyn_cast(Statement)) {
-return areParensNeededForOverloadedOperator(OperatorCall->getOperator());
-  }
-
-  return isa(Statement) || isa(Statement);
-}
-
 void fixGenericExprCastToBool(DiagnosticBuilder ,
   const ImplicitCastExpr *Cast, const Stmt *Parent,
   ASTContext ) {
@@ -105,9 +81,10 @@ void fixGenericExprCastToBool(DiagnosticBuilder ,
 
   const Expr *SubExpr = Cast->getSubExpr();
 
-  bool NeedInnerParens = areParensNeededForStatement(SubExpr);
+  bool NeedInnerParens =
+  SubExpr != nullptr && 
utils::fixit::areParensNeededForStatement(*SubExpr);
   bool NeedOuterParens =
-  Parent != nullptr && areParensNeededForStatement(Parent);
+  Parent != nullptr && utils::fixit::areParensNeededForStatement(*Parent);
 
   std::string StartLocInsertion;
 
@@ -365,7 +342,7 @@ void ImplicitBoolConversionCheck::handleCastToBool(const 
ImplicitCastExpr *Cast,
 return;
   }
 
-  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion %0 -> bool")
+  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion %0 -> 'bool'")
   << Cast->getSubExpr()->getType();
 
   StringRef EquivalentLiteral =
@@ -382,7 +359,7 @@ void ImplicitBoolConversionCheck::handleCastFromBool(
 ASTContext ) {
   QualType DestType =
   NextImplicitCast ? NextImplicitCast->getType() : Cast->getType();
-  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion bool -> %0")
+  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion 'bool' -> %0")
   << DestType;
 
   if (const auto *BoolLiteral =
diff --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
index 226dd60b5bf5f..bbdd4326b0bac 100644
--- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -224,6 +224,40 @@ std::optional addQualifierToVarDecl(const 
VarDecl ,
   return std::nullopt;
 }
 
+bool areParensNeededForStatement(const Stmt ) {
+  if (isa())
+return false;
+
+  if (isa() || isa())
+return true;
+
+  if (isa() ||
+  isa())
+return true;
+
+  if (const auto *Op = dyn_cast()) {
+switch (Op->getOperator()) {
+case OO_PlusPlus:
+  [[fallthrough]];
+case OO_MinusMinus:
+  return Op->getNumArgs() != 2;
+case OO_Call:
+  [[fallthrough]];
+case OO_Subscript:
+  [[fallthrough]];
+case OO_Arrow:
+  return false;
+default:
+  return true;
+};
+  }
+
+  if (isa())
+return true;
+
+  return false;
+}
+
 // Return true if expr needs to be put in parens when it is an argument of a
 // prefix unary operator, e.g. when it is a 

[clang-tools-extra] [clang-tidy] Fix missing parentheses in readability-implicit-bool-conversion fixes (PR #74891)

2023-12-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL created 
https://github.com/llvm/llvm-project/pull/74891

Check now more properly add missing parentheses to code like this: 'bool bar = 
true ? 1 : 0 != 0;'.

Closes #71867

>From 8c3b797f1f34d18c1e9211898f7d1a5697251317 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Fri, 8 Dec 2023 22:01:23 +
Subject: [PATCH] [clang-tidy] Fix missing parentheses in
 readability-implicit-bool-conversion fixes

Check now more properly add missing parentheses to
code like this: 'bool bar = true ? 1 : 0 != 0;'.
---
 .../ImplicitBoolConversionCheck.cpp   |  35 +---
 .../clang-tidy/utils/FixItHintUtils.cpp   |  34 
 .../clang-tidy/utils/FixItHintUtils.h |   4 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   2 +-
 ...it-bool-conversion-allow-in-conditions.cpp |   6 +-
 .../implicit-bool-conversion-cxx98.cpp|  12 +-
 .../readability/implicit-bool-conversion.cpp  | 154 ++
 7 files changed, 139 insertions(+), 108 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index f0fca30de3b3c4..e011598cc7c9f9 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "ImplicitBoolConversionCheck.h"
+#include "../utils/FixItHintUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
@@ -61,31 +62,6 @@ bool isUnaryLogicalNotOperator(const Stmt *Statement) {
   return UnaryOperatorExpr && UnaryOperatorExpr->getOpcode() == UO_LNot;
 }
 
-bool areParensNeededForOverloadedOperator(OverloadedOperatorKind OperatorKind) 
{
-  switch (OperatorKind) {
-  case OO_New:
-  case OO_Delete: // Fall-through on purpose.
-  case OO_Array_New:
-  case OO_Array_Delete:
-  case OO_ArrowStar:
-  case OO_Arrow:
-  case OO_Call:
-  case OO_Subscript:
-return false;
-
-  default:
-return true;
-  }
-}
-
-bool areParensNeededForStatement(const Stmt *Statement) {
-  if (const auto *OperatorCall = dyn_cast(Statement)) {
-return areParensNeededForOverloadedOperator(OperatorCall->getOperator());
-  }
-
-  return isa(Statement) || isa(Statement);
-}
-
 void fixGenericExprCastToBool(DiagnosticBuilder ,
   const ImplicitCastExpr *Cast, const Stmt *Parent,
   ASTContext ) {
@@ -105,9 +81,10 @@ void fixGenericExprCastToBool(DiagnosticBuilder ,
 
   const Expr *SubExpr = Cast->getSubExpr();
 
-  bool NeedInnerParens = areParensNeededForStatement(SubExpr);
+  bool NeedInnerParens =
+  SubExpr != nullptr && 
utils::fixit::areParensNeededForStatement(*SubExpr);
   bool NeedOuterParens =
-  Parent != nullptr && areParensNeededForStatement(Parent);
+  Parent != nullptr && utils::fixit::areParensNeededForStatement(*Parent);
 
   std::string StartLocInsertion;
 
@@ -365,7 +342,7 @@ void ImplicitBoolConversionCheck::handleCastToBool(const 
ImplicitCastExpr *Cast,
 return;
   }
 
-  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion %0 -> bool")
+  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion %0 -> 'bool'")
   << Cast->getSubExpr()->getType();
 
   StringRef EquivalentLiteral =
@@ -382,7 +359,7 @@ void ImplicitBoolConversionCheck::handleCastFromBool(
 ASTContext ) {
   QualType DestType =
   NextImplicitCast ? NextImplicitCast->getType() : Cast->getType();
-  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion bool -> %0")
+  auto Diag = diag(Cast->getBeginLoc(), "implicit conversion 'bool' -> %0")
   << DestType;
 
   if (const auto *BoolLiteral =
diff --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
index 226dd60b5bf5f5..bbdd4326b0bac2 100644
--- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -224,6 +224,40 @@ std::optional addQualifierToVarDecl(const 
VarDecl ,
   return std::nullopt;
 }
 
+bool areParensNeededForStatement(const Stmt ) {
+  if (isa())
+return false;
+
+  if (isa() || isa())
+return true;
+
+  if (isa() ||
+  isa())
+return true;
+
+  if (const auto *Op = dyn_cast()) {
+switch (Op->getOperator()) {
+case OO_PlusPlus:
+  [[fallthrough]];
+case OO_MinusMinus:
+  return Op->getNumArgs() != 2;
+case OO_Call:
+  [[fallthrough]];
+case OO_Subscript:
+  [[fallthrough]];
+case OO_Arrow:
+  return false;
+default:
+  return true;
+};
+  }
+
+  if (isa())
+return true;
+
+  return false;
+}
+
 // Return true if expr needs to be put in parens when it is an argument of a
 // prefix unary operator, e.g. when it is a binary or ternary 

[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-08 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 4b5f4c6a15e84a9c3025a241cc5e11ad768dfdda Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH] [Clang][Sema] Check the number of lambda non-concept tempate
 parameters Check that the number of non-concept template parameters is
 greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 clang/include/clang/Basic/DiagnosticParseKinds.td |  2 ++
 clang/lib/Sema/TreeTransform.h| 15 +++
 2 files changed, 17 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab..e46fa69d013b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0..b22f8af3b12c2 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,21 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created

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


[llvm] [clang] [SpecialCaseList] Use glob by default (PR #74809)

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

MaskRay wrote:

> > > Probably would be good to introduce the `-v1` version and require it 
> > > first, then eventually change the default - so people don't get a silent 
> > > behavior change? Even the existing users only using `*` and `.` need to 
> > > change their syntax to migrate to v2, right? They'll need to change `.*` 
> > > to `*` and `.` to `?` and if they don't, their matches will start 
> > > behaving strangely without a specific/actionable error message?
> > 
> > 
> > Since `#!special-case-list-v1` is just a comment and `v1` is the default 
> > before this change, users can actually add it to the first line today and 
> > the behavior won't change until Clang 19.
> 
> Right, but they wouldn't know to do that in advance of the behavior change, 
> would they? If they do nothing/don't read any release notes, they'd get a 
> silent behavior change, I think/if I'm understanding this correctly?

It will be silent but the main idea is that almost all special case lists are 
unaffected by this transition
https://discourse.llvm.org/t/use-glob-instead-of-regex-for-specialcaselists/71666
 and my first comment are to demonstrate this.

I have checked CodeSearch (and ignorelist.txt uses in projects such as 
blue/v8/chromiumos) and actually haven't found any non-glob metacharacters uses 
(`(` `{` etc).

This is understandable: `src:` and `fun:` are the most common entries. `fun:` 
is almost always an exact function name or a glob with a leading/trailing `*`.
Many people tend to think `src:` uses globs and do not escape `.`. We have 
envisioned `src:a.(c|cpp)` (though I haven't seen such a use case) which can be 
satisfied by the glob brace expansion `src:a.{c,cpp}`.

Going forward, glob is the only supported format and we do not want users to 
annotate their ignore list with `#!special-case-list-v2` or `#!glob`.
Enforcing a `#!` header comment (by issuing a warning if not seen) would likely 
cause more disruption.


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


[clang] [clang][lex] Fix non-portability diagnostics with absolute path (PR #74782)

2023-12-08 Thread Jan Svoboda via cfe-commits

jansvoboda11 wrote:

My first version of the test put backslashes into the source file (i.e. 
`#include "C:\foo\bar"`) which doesn't really work, because Clang treats those 
as string escape sequences. Instead of trying to replace `\` with `\\` in the 
test, I chose to use forward slashes, which should be fine.

Interestingly, that prevented Clang to diagnose the case mismatch. That's 
because in `trySimplifyPath()`, any path component that differs from the "real 
path" component in anything else that case prevents the diagnostic. 
Importantly, this also applies to mismatching separators (e.g. 'C:/' in source, 
'C:\' in real path). I don't think that's intended or reasonable, so I pushed a 
fix that allows the diagnostic to be emitted regardless of separator 
differences.

Note that the diagnostic won't suggest fixing up the separators themselves, 
since those get inherited from the in-source spelling, not from the real path.

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


[clang] [RISCV] Enable target attribute when invoked through clang driver (PR #74889)

2023-12-08 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 05420a17547e495f5748e9662150d6eb931e2c28 
65707b837a8bb7283896d2c9d4933a17e02a20b9 -- clang/lib/Basic/Targets/RISCV.cpp 
clang/test/CodeGen/RISCV/riscv-func-attr-target.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 184176c05d..1cce8fe5b2 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -309,12 +309,12 @@ bool RISCVTargetInfo::initFeatureMap(
   // negatives, and non-extension features.  We need to preserve the later
   // for correctness and want to preserve the former for consistency.
   for (auto  : NewFeaturesVec) {
- StringRef ExtName = Feature;
- assert(ExtName.size() > 1 && (ExtName[0] == '+' || ExtName[0] == '-'));
- ExtName = ExtName.drop_front(1); // Drop '+' or '-'
- if (!llvm::is_contained(ImpliedFeatures, ("+" + ExtName).str()) &&
- !llvm::is_contained(ImpliedFeatures, ("-" + ExtName).str()))
-   ImpliedFeatures.push_back(Feature);
+StringRef ExtName = Feature;
+assert(ExtName.size() > 1 && (ExtName[0] == '+' || ExtName[0] == '-'));
+ExtName = ExtName.drop_front(1); // Drop '+' or '-'
+if (!llvm::is_contained(ImpliedFeatures, ("+" + ExtName).str()) &&
+!llvm::is_contained(ImpliedFeatures, ("-" + ExtName).str()))
+  ImpliedFeatures.push_back(Feature);
   }
   return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures);
 }

``




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


[clang] [RISCV] Enable target attribute when invoked through clang driver (PR #74889)

2023-12-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Philip Reames (preames)


Changes

d80e46d added support for the target function attribute.  However, it turns out 
that commit has a nasty bug/oversight.  As the tests in that revision show, 
everything works if clang -cc1 is directly invoked.  I was suprised to learn 
this morning that compiling with clang (i.e. the typical user workflow) did not 
work.

The bug is that if a set of explicit negative extensions is passed to cc1 at 
the command line (as the clang driver always does), we were copying these 
negative extensions to the end of the rewritten extension list.  When this was 
later parsed, this had the effect of turning back off any extension that the 
target attribute had enabled.

This patch updates the logic to only propagate the features from the input 
which don't appear in the rewritten form in either positive or negative form.

Note that this code structure is still highly suspect.  In particular I'm 
fairly sure that mixing extension versions with this code will result in odd 
results.  However, I figure its better to have something which mostly works 
than something which doesn't work at all.

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


2 Files Affected:

- (modified) clang/lib/Basic/Targets/RISCV.cpp (+11-4) 
- (modified) clang/test/CodeGen/RISCV/riscv-func-attr-target.c (+11-10) 


``diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 13f934e994721..184176c05da23 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -304,11 +304,18 @@ bool RISCVTargetInfo::initFeatureMap(
 
   // RISCVISAInfo makes implications for ISA features
   std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector();
-  // Add non-ISA features like `relax` and `save-restore` back
-  for (const std::string  : NewFeaturesVec)
-if (!llvm::is_contained(ImpliedFeatures, Feature))
-  ImpliedFeatures.push_back(Feature);
 
+  // parseFeatures normalizes the feature set by dropping any explicit
+  // negatives, and non-extension features.  We need to preserve the later
+  // for correctness and want to preserve the former for consistency.
+  for (auto  : NewFeaturesVec) {
+ StringRef ExtName = Feature;
+ assert(ExtName.size() > 1 && (ExtName[0] == '+' || ExtName[0] == '-'));
+ ExtName = ExtName.drop_front(1); // Drop '+' or '-'
+ if (!llvm::is_contained(ImpliedFeatures, ("+" + ExtName).str()) &&
+ !llvm::is_contained(ImpliedFeatures, ("-" + ExtName).str()))
+   ImpliedFeatures.push_back(Feature);
+  }
   return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures);
 }
 
diff --git a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c 
b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
index 74bc5f2ac7049..506acaba68741 100644
--- a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
+++ b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
@@ -1,6 +1,7 @@
 // REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv64 -target-feature +zifencei -target-feature 
+m \
-// RUN:  -target-feature +a -target-feature +save-restore \
+// RUN:  -target-feature +a -target-feature +save-restore -target-feature -zbb 
\
+// RUN:  -target-feature -relax -target-feature -zfa \
 // RUN:  -emit-llvm %s -o - | FileCheck %s
 
 // CHECK-LABEL: define dso_local void @testDefault
@@ -35,12 +36,12 @@ testAttrFullArchAndAttrCpu() {}
 __attribute__((target("cpu=sifive-u54"))) void testAttrCpuOnly() {}
 
 //.
-// CHECK: attributes #0 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zifencei" }
-// CHECK: attributes #1 = { {{.*}}"target-cpu"="rocket-rv64" 
"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b"
 "tune-cpu"="generic-rv64" }
-// CHECK: attributes #2 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zbb,+zifencei" }
-// CHECK: attributes #3 = { 
{{.*}}"target-features"="+64bit,+a,+d,+experimental-zicond,+f,+m,+save-restore,+v,+zbb,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b"
 }
-// CHECK: attributes #4 = { 
{{.*}}"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zbb,+zicsr,+zifencei"
 }
-// CHECK: attributes #5 = { {{.*}}"target-features"="+64bit,+m,+save-restore" }
-// CHECK: attributes #6 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+m,+save-restore,+zbb,+zifencei" }
-// CHECK: attributes #7 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+m,+save-restore" }
-// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zicsr,+zifencei" }
+// CHECK: attributes #0 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zifencei,-relax,-zbb,-zfa" 
}
+// CHECK: attributes #1 = { {{.*}}"target-cpu"="rocket-rv64" 

[clang] [RISCV] Enable target attribute when invoked through clang driver (PR #74889)

2023-12-08 Thread Philip Reames via cfe-commits

https://github.com/preames created 
https://github.com/llvm/llvm-project/pull/74889

d80e46d added support for the target function attribute.  However, it turns out 
that commit has a nasty bug/oversight.  As the tests in that revision show, 
everything works if clang -cc1 is directly invoked.  I was suprised to learn 
this morning that compiling with clang (i.e. the typical user workflow) did not 
work.

The bug is that if a set of explicit negative extensions is passed to cc1 at 
the command line (as the clang driver always does), we were copying these 
negative extensions to the end of the rewritten extension list.  When this was 
later parsed, this had the effect of turning back off any extension that the 
target attribute had enabled.

This patch updates the logic to only propagate the features from the input 
which don't appear in the rewritten form in either positive or negative form.

Note that this code structure is still highly suspect.  In particular I'm 
fairly sure that mixing extension versions with this code will result in odd 
results.  However, I figure its better to have something which mostly works 
than something which doesn't work at all.

>From 65707b837a8bb7283896d2c9d4933a17e02a20b9 Mon Sep 17 00:00:00 2001
From: Philip Reames 
Date: Fri, 8 Dec 2023 12:49:58 -0800
Subject: [PATCH] [RISCV] Enable target attribute when invoked through clang
 driver

d80e46d added support for the target function attribute.  However,
it turns out that commit has a nasty bug/oversight.  As the tests
in that revision show, everything works if clang -cc1 is directly
invoked.  I was suprised to learn this morning that compiling with
clang (i.e. the typical user workflow) did not work.

The bug is that if a set of explicit negative extensions is passed
to cc1 at the command line (as the clang driver always does), we
were copying these negative extensions to the end of the rewritten
extension list.  When this was later parsed, this had the effect of
turning back off any extension that the target attribute had enabled.

This patch updates the logic to only propagate the features from
the input which don't appear in the rewritten form in either
positive or negative form.

Note that this code structure is still highly suspect.  In particular
I'm fairly sure that mixing extension versions with this code will
result in odd results.  However, I figure its better to have something
which mostly works than something which doesn't work at all.
---
 clang/lib/Basic/Targets/RISCV.cpp | 15 +
 .../CodeGen/RISCV/riscv-func-attr-target.c| 21 ++-
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 13f934e9947212..184176c05da23b 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -304,11 +304,18 @@ bool RISCVTargetInfo::initFeatureMap(
 
   // RISCVISAInfo makes implications for ISA features
   std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector();
-  // Add non-ISA features like `relax` and `save-restore` back
-  for (const std::string  : NewFeaturesVec)
-if (!llvm::is_contained(ImpliedFeatures, Feature))
-  ImpliedFeatures.push_back(Feature);
 
+  // parseFeatures normalizes the feature set by dropping any explicit
+  // negatives, and non-extension features.  We need to preserve the later
+  // for correctness and want to preserve the former for consistency.
+  for (auto  : NewFeaturesVec) {
+ StringRef ExtName = Feature;
+ assert(ExtName.size() > 1 && (ExtName[0] == '+' || ExtName[0] == '-'));
+ ExtName = ExtName.drop_front(1); // Drop '+' or '-'
+ if (!llvm::is_contained(ImpliedFeatures, ("+" + ExtName).str()) &&
+ !llvm::is_contained(ImpliedFeatures, ("-" + ExtName).str()))
+   ImpliedFeatures.push_back(Feature);
+  }
   return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures);
 }
 
diff --git a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c 
b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
index 74bc5f2ac70492..506acaba687417 100644
--- a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
+++ b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
@@ -1,6 +1,7 @@
 // REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv64 -target-feature +zifencei -target-feature 
+m \
-// RUN:  -target-feature +a -target-feature +save-restore \
+// RUN:  -target-feature +a -target-feature +save-restore -target-feature -zbb 
\
+// RUN:  -target-feature -relax -target-feature -zfa \
 // RUN:  -emit-llvm %s -o - | FileCheck %s
 
 // CHECK-LABEL: define dso_local void @testDefault
@@ -35,12 +36,12 @@ testAttrFullArchAndAttrCpu() {}
 __attribute__((target("cpu=sifive-u54"))) void testAttrCpuOnly() {}
 
 //.
-// CHECK: attributes #0 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zifencei" }
-// CHECK: attributes #1 = { {{.*}}"target-cpu"="rocket-rv64" 

[clang] [clang][lex] Fix non-portability diagnostics with absolute path (PR #74782)

2023-12-08 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/74782

>From 6ab18edae7b86ca216848b7fcaff5e58fb3e186c Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Thu, 7 Dec 2023 15:15:16 -0800
Subject: [PATCH 1/4] [clang][lex] Fix non-portability diagnostics with
 absolute path

The existing code incorrectly assumes that `Path` can be empty. It can't, it 
always contains at least `<` or `"`. On Unix, this patch fixes an incorrect 
diagnostics that instead of `"/Users/blah"` suggested `"Userss/blah"`. In 
assert builds, this would outright crash.

rdar://91172342
---
 clang/lib/Lex/PPDirectives.cpp| 22 ---
 .../Lexer/case-insensitive-include-absolute.c | 13 +++
 2 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/Lexer/case-insensitive-include-absolute.c

diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 956e2276f25b7..576b3c5925353 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2466,15 +2466,21 @@ Preprocessor::ImportAction 
Preprocessor::HandleHeaderIncludeOrImport(
 // The drive letter is optional for absolute paths on Windows, but
 // clang currently cannot process absolute paths in #include lines that
 // don't have a drive.
-// If the first entry in Components is a directory separator,
-// then the code at the bottom of this loop that keeps the original
-// directory separator style copies it. If the second entry is
-// a directory separator (the C:\ case), then that separator already
-// got copied when the C: was processed and we want to skip that entry.
-if (!(Component.size() == 1 && IsSep(Component[0])))
+if (Component.size() == 1 && IsSep(Component[0])) {
+  // Note: Path always contains at least '<' or '"'.
+  if (Path.size() == 1) {
+// If the first entry in Components is a directory separator,
+// then the code at the bottom of this loop that keeps the original
+// directory separator style copies it.
+  } else {
+// If the second entry is a directory separator (the C:\ case),
+// then that separator already got copied when the C: was processed
+// and we want to skip that entry.
+continue;
+  }
+} else {
   Path.append(Component);
-else if (!Path.empty())
-  continue;
+}
 
 // Append the separator(s) the user used, or the close quote
 if (Path.size() > NameWithoriginalSlashes.size()) {
diff --git a/clang/test/Lexer/case-insensitive-include-absolute.c 
b/clang/test/Lexer/case-insensitive-include-absolute.c
new file mode 100644
index 0..48f3d59421bd2
--- /dev/null
+++ b/clang/test/Lexer/case-insensitive-include-absolute.c
@@ -0,0 +1,13 @@
+// REQUIRES: case-insensitive-filesystem
+
+// RUN: rm -rf %t && split-file %s %t
+// RUN: sed "s|DIR|%/t|g" %t/tu.c.in > %t/tu.c
+// RUN: %clang_cc1 -fsyntax-only %t/tu.c 2>&1 | FileCheck %s --DPREFIX=%t
+
+//--- header.h
+//--- tu.c.in
+#import "DIR/Header.h"
+// CHECK:  tu.c:1:9: warning: non-portable path to file 
'"[[PREFIX]]/header.h"'; specified path differs in case from file name on disk 
[-Wnonportable-include-path]
+// CHECK-NEXT:1 | #import "[[PREFIX]]/Header.h"
+// CHECK-NEXT:  | ^
+// CHECK-NEXT:  | "[[PREFIX]]/header.h"

>From 7437975205d4b6642d0439f6d5fa35204a88f67c Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Thu, 7 Dec 2023 21:43:55 -0800
Subject: [PATCH 2/4] Fix test on Windows

---
 clang/test/Lexer/case-insensitive-include-absolute.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/test/Lexer/case-insensitive-include-absolute.c 
b/clang/test/Lexer/case-insensitive-include-absolute.c
index 48f3d59421bd2..da6de6acfb07c 100644
--- a/clang/test/Lexer/case-insensitive-include-absolute.c
+++ b/clang/test/Lexer/case-insensitive-include-absolute.c
@@ -1,13 +1,13 @@
 // REQUIRES: case-insensitive-filesystem
 
 // RUN: rm -rf %t && split-file %s %t
-// RUN: sed "s|DIR|%/t|g" %t/tu.c.in > %t/tu.c
-// RUN: %clang_cc1 -fsyntax-only %t/tu.c 2>&1 | FileCheck %s --DPREFIX=%t
+// RUN: sed "s|DIR|%t|g" %t/tu.c.in > %t/tu.c
+// RUN: %clang_cc1 -fsyntax-only %t/tu.c 2>&1 | FileCheck %s --DDIR=%t
 
 //--- header.h
 //--- tu.c.in
 #import "DIR/Header.h"
-// CHECK:  tu.c:1:9: warning: non-portable path to file 
'"[[PREFIX]]/header.h"'; specified path differs in case from file name on disk 
[-Wnonportable-include-path]
-// CHECK-NEXT:1 | #import "[[PREFIX]]/Header.h"
-// CHECK-NEXT:  | ^
-// CHECK-NEXT:  | "[[PREFIX]]/header.h"
+// CHECK:  tu.c:1:9: warning: non-portable path to file 
'"[[DIR]]/header.h"'; specified path differs in case from file name on disk 
[-Wnonportable-include-path]

[clang-tools-extra] [compiler-rt] [clang] [flang] [libc] [lld] [openmp] [mlir] [lldb] [libcxxabi] [llvm] [libcxx] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-08 Thread Jon Roelofs via cfe-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73686

>From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Tue, 28 Nov 2023 10:39:44 -0800
Subject: [PATCH 01/10] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?=
 =?UTF-8?q?initial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/docs/LangRef.rst |   7 +-
 llvm/include/llvm/CodeGen/AsmPrinter.h|   6 +-
 llvm/lib/CodeGen/GlobalISel/CallLowering.cpp  |   7 +-
 llvm/lib/IR/Verifier.cpp  |  12 +-
 llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |  28 ++
 llvm/lib/Target/X86/X86AsmPrinter.h   |   1 +
 .../AArch64/GlobalISel/call-lowering-ifunc.ll |  37 +++
 llvm/test/CodeGen/AArch64/addrsig-macho.ll|   4 +-
 llvm/test/CodeGen/AArch64/ifunc-asm.ll|  82 +
 llvm/test/CodeGen/X86/ifunc-asm.ll|  28 +-
 llvm/test/Verifier/ifunc-macho.ll |  42 +++
 12 files changed, 539 insertions(+), 23 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll
 create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll
 create mode 100644 llvm/test/Verifier/ifunc-macho.ll

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index e448c5ed5c5d9..cb222e979db29 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -934,10 +934,11 @@ IFuncs
 ---
 
 IFuncs, like as aliases, don't create any new data or func. They are just a new
-symbol that dynamic linker resolves at runtime by calling a resolver function.
+symbol that is resolved at runtime by calling a resolver function.
 
-IFuncs have a name and a resolver that is a function called by dynamic linker
-that returns address of another function associated with the name.
+On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On
+MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which
+lazily resolve the callee the first time they are called.
 
 IFunc may have an optional :ref:`linkage type ` and an optional
 :ref:`visibility style `.
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h 
b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 2731ef452c79c..48fa6c478464c 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass {
 
   GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy );
   void emitGlobalAlias(Module , const GlobalAlias );
-  void emitGlobalIFunc(Module , const GlobalIFunc );
+
+protected:
+  virtual void emitGlobalIFunc(Module , const GlobalIFunc );
+
+private:
 
   /// This method decides whether the specified basic block requires a label.
   bool shouldEmitLabelForBasicBlock(const MachineBasicBlock ) const;
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp 
b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 2527b14312896..e0080b145d4f9 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder , 
const CallBase ,
   // Try looking through a bitcast from one function type to another.
   // Commonly happens with calls to objc_msgSend().
   const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts();
-  if (const Function *F = dyn_cast(CalleeV))
+  if (const GlobalIFunc *IF = dyn_cast(CalleeV);
+  IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) {
+// ld64 requires that .symbol_resolvers to be called via a stub, so these
+// must always be a diret call.
+Info.Callee = MachineOperand::CreateGA(IF, 0);
+  } else if (const Function *F = dyn_cast(CalleeV))
 Info.Callee = MachineOperand::CreateGA(F, 0);
   else
 Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false);
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 5560c037aa3ee..94e76a43bf38d 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc ) {
   GlobalIFunc::getResolverFunctionType(GI.getValueType());
   Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()),
 "IFunc resolver has incorrect type", );
+
 }
 
 void Verifier::visitNamedMDNode(const NamedMDNode ) {
@@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, 
AttributeList Attrs,
   }
 
   // Check EVEX512 feature.
-  if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) {
-Triple T(M.getTargetTriple());
-if (T.isX86()) {
-  StringRef TF = Attrs.getFnAttr("target-features").getValueAsString();
-  Check(!TF.contains("+avx512f") || !TF.contains("-evex512"),
-"512-bit vector arguments require 'evex512' for AVX512", V);
-}
+  

[clang] [flang] [llvm] [lld] [libcxxabi] [libc] [lldb] [openmp] [compiler-rt] [libcxx] [clang-tools-extra] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-08 Thread Jon Roelofs via cfe-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/73686

>From bc152095691b32d1ad8539dfd60f5089df5eed8d Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Tue, 28 Nov 2023 10:39:44 -0800
Subject: [PATCH 01/10] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?=
 =?UTF-8?q?initial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/docs/LangRef.rst |   7 +-
 llvm/include/llvm/CodeGen/AsmPrinter.h|   6 +-
 llvm/lib/CodeGen/GlobalISel/CallLowering.cpp  |   7 +-
 llvm/lib/IR/Verifier.cpp  |  12 +-
 llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 308 ++
 llvm/lib/Target/X86/X86AsmPrinter.cpp |  28 ++
 llvm/lib/Target/X86/X86AsmPrinter.h   |   1 +
 .../AArch64/GlobalISel/call-lowering-ifunc.ll |  37 +++
 llvm/test/CodeGen/AArch64/addrsig-macho.ll|   4 +-
 llvm/test/CodeGen/AArch64/ifunc-asm.ll|  82 +
 llvm/test/CodeGen/X86/ifunc-asm.ll|  28 +-
 llvm/test/Verifier/ifunc-macho.ll |  42 +++
 12 files changed, 539 insertions(+), 23 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-ifunc.ll
 create mode 100644 llvm/test/CodeGen/AArch64/ifunc-asm.ll
 create mode 100644 llvm/test/Verifier/ifunc-macho.ll

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index e448c5ed5c5d9..cb222e979db29 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -934,10 +934,11 @@ IFuncs
 ---
 
 IFuncs, like as aliases, don't create any new data or func. They are just a new
-symbol that dynamic linker resolves at runtime by calling a resolver function.
+symbol that is resolved at runtime by calling a resolver function.
 
-IFuncs have a name and a resolver that is a function called by dynamic linker
-that returns address of another function associated with the name.
+On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On
+MachO platforms, they are lowered in terms of ``.symbol_resolver``s, which
+lazily resolve the callee the first time they are called.
 
 IFunc may have an optional :ref:`linkage type ` and an optional
 :ref:`visibility style `.
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h 
b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 2731ef452c79c..48fa6c478464c 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -882,7 +882,11 @@ class AsmPrinter : public MachineFunctionPass {
 
   GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy );
   void emitGlobalAlias(Module , const GlobalAlias );
-  void emitGlobalIFunc(Module , const GlobalIFunc );
+
+protected:
+  virtual void emitGlobalIFunc(Module , const GlobalIFunc );
+
+private:
 
   /// This method decides whether the specified basic block requires a label.
   bool shouldEmitLabelForBasicBlock(const MachineBasicBlock ) const;
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp 
b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 2527b14312896..e0080b145d4f9 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder , 
const CallBase ,
   // Try looking through a bitcast from one function type to another.
   // Commonly happens with calls to objc_msgSend().
   const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts();
-  if (const Function *F = dyn_cast(CalleeV))
+  if (const GlobalIFunc *IF = dyn_cast(CalleeV);
+  IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) {
+// ld64 requires that .symbol_resolvers to be called via a stub, so these
+// must always be a diret call.
+Info.Callee = MachineOperand::CreateGA(IF, 0);
+  } else if (const Function *F = dyn_cast(CalleeV))
 Info.Callee = MachineOperand::CreateGA(F, 0);
   else
 Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false);
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 5560c037aa3ee..94e76a43bf38d 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -959,6 +959,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc ) {
   GlobalIFunc::getResolverFunctionType(GI.getValueType());
   Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()),
 "IFunc resolver has incorrect type", );
+
 }
 
 void Verifier::visitNamedMDNode(const NamedMDNode ) {
@@ -2239,13 +2240,10 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, 
AttributeList Attrs,
   }
 
   // Check EVEX512 feature.
-  if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features")) {
-Triple T(M.getTargetTriple());
-if (T.isX86()) {
-  StringRef TF = Attrs.getFnAttr("target-features").getValueAsString();
-  Check(!TF.contains("+avx512f") || !TF.contains("-evex512"),
-"512-bit vector arguments require 'evex512' for AVX512", V);
-}
+  

[clang] [Fix] Disable fdefine-target-os-macros for now (PR #74886)

2023-12-08 Thread Zixu Wang via cfe-commits

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


[clang] c9b4bb9 - [Fix] Disable fdefine-target-os-macros for now (#74886)

2023-12-08 Thread via cfe-commits

Author: Zixu Wang
Date: 2023-12-08T13:07:29-08:00
New Revision: c9b4bb9ff9b65a741c558bfb93719df95272c2e1

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

LOG: [Fix] Disable fdefine-target-os-macros for now (#74886)

https://github.com/llvm/llvm-project/pull/74676 landed the work to
implement `-fdefine-target-os-macros` and enabled the extension for the
Darwin driver. However it is breaking some test builds. Leave the
extension disabled for now until we can fix/workaround the build
failures.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/fdefine-target-os-macros.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index d3005d69e92bbf..f09bc27d7d2c0e 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2916,10 +2916,6 @@ void Darwin::addClangTargetOptions(const 
llvm::opt::ArgList ,
   // to fix the same problem with C++ headers, and is generally fragile.
   if (!sdkSupportsBuiltinModules(TargetPlatform, SDKInfo))
 CC1Args.push_back("-fbuiltin-headers-in-system-modules");
-
-  if (!DriverArgs.hasArgNoClaim(options::OPT_fdefine_target_os_macros,
-options::OPT_fno_define_target_os_macros))
-CC1Args.push_back("-fdefine-target-os-macros");
 }
 
 void Darwin::addClangCC1ASTargetOptions(

diff  --git a/clang/test/Driver/fdefine-target-os-macros.c 
b/clang/test/Driver/fdefine-target-os-macros.c
index d7379dd3d5396b..030d4ce34cb282 100644
--- a/clang/test/Driver/fdefine-target-os-macros.c
+++ b/clang/test/Driver/fdefine-target-os-macros.c
@@ -1,11 +1,12 @@
 // RUN: %clang -### --target=arm64-apple-darwin %s 2>&1 | FileCheck %s 
--check-prefix=DARWIN-DEFAULT
-// DARWIN-DEFAULT: "-fdefine-target-os-macros"
+// DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
 
 // RUN: %clang -### --target=arm-none-linux-gnu %s 2>&1 | FileCheck %s 
--check-prefix=NON-DARWIN-DEFAULT
 // RUN: %clang -### --target=x86_64-pc-win32 %s 2>&1 | FileCheck %s 
--check-prefix=NON-DARWIN-DEFAULT
 // NON-DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
 
-// RUN: %clang -dM -E --target=arm64-apple-macos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-macos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=1 \
 // RUN:-DIPHONE=0  \
@@ -20,7 +21,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -35,7 +37,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios-macabi %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios-macabi \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -50,7 +53,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios-simulator %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios-simulator \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -65,7 +69,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-tvos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-tvos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -80,7 +85,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -95,7 +101,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-watchos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-watchos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1 

[clang] [Fix] Disable fdefine-target-os-macros for now (PR #74886)

2023-12-08 Thread Ian Anderson via cfe-commits

https://github.com/ian-twilightcoder approved this pull request.


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


[clang] [Fix] Disable fdefine-target-os-macros for now (PR #74886)

2023-12-08 Thread Jon Roelofs via cfe-commits

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


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


[clang] [Fix] Disable fdefine-target-os-macros for now (PR #74886)

2023-12-08 Thread Florian Hahn via cfe-commits

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

LGTM, thanks!

For reference, this is breaking llvm-test-suite builds, e.g. see 
https://green.lab.llvm.org/green/job/lnt-ctmark-aarch64-Os/15893/console

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: flyingcat  (knightXun)


Changes

Check that the number of non-concept template parameters is greater than zero 
during lambda template instantiation to aviod panic Fix issue: 
https://github.com/llvm/llvm-project/issues/70601

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


2 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2) 
- (modified) clang/lib/Sema/TreeTransform.h (+14) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..110024a377128b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,20 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created

``




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


[clang] [Fix] Disable fdefine-target-os-macros for now (PR #74886)

2023-12-08 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Zixu Wang (zixu-w)


Changes

https://github.com/llvm/llvm-project/pull/74676 landed the work to implement 
`-fdefine-target-os-macros` and enabled the extension for the Darwin driver. 
However it is breaking some test builds. Leave the extension disabled for now 
until we can fix/workaround the build failures.

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Darwin.cpp (-4) 
- (modified) clang/test/Driver/fdefine-target-os-macros.c (+19-10) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index d3005d69e92bb..f09bc27d7d2c0 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2916,10 +2916,6 @@ void Darwin::addClangTargetOptions(const 
llvm::opt::ArgList ,
   // to fix the same problem with C++ headers, and is generally fragile.
   if (!sdkSupportsBuiltinModules(TargetPlatform, SDKInfo))
 CC1Args.push_back("-fbuiltin-headers-in-system-modules");
-
-  if (!DriverArgs.hasArgNoClaim(options::OPT_fdefine_target_os_macros,
-options::OPT_fno_define_target_os_macros))
-CC1Args.push_back("-fdefine-target-os-macros");
 }
 
 void Darwin::addClangCC1ASTargetOptions(
diff --git a/clang/test/Driver/fdefine-target-os-macros.c 
b/clang/test/Driver/fdefine-target-os-macros.c
index d7379dd3d5396..030d4ce34cb28 100644
--- a/clang/test/Driver/fdefine-target-os-macros.c
+++ b/clang/test/Driver/fdefine-target-os-macros.c
@@ -1,11 +1,12 @@
 // RUN: %clang -### --target=arm64-apple-darwin %s 2>&1 | FileCheck %s 
--check-prefix=DARWIN-DEFAULT
-// DARWIN-DEFAULT: "-fdefine-target-os-macros"
+// DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
 
 // RUN: %clang -### --target=arm-none-linux-gnu %s 2>&1 | FileCheck %s 
--check-prefix=NON-DARWIN-DEFAULT
 // RUN: %clang -### --target=x86_64-pc-win32 %s 2>&1 | FileCheck %s 
--check-prefix=NON-DARWIN-DEFAULT
 // NON-DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
 
-// RUN: %clang -dM -E --target=arm64-apple-macos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-macos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=1 \
 // RUN:-DIPHONE=0  \
@@ -20,7 +21,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -35,7 +37,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios-macabi %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios-macabi \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -50,7 +53,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios-simulator %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios-simulator \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -65,7 +69,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-tvos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-tvos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -80,7 +85,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -95,7 +101,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-watchos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-watchos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -110,7 +117,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-watchos-simulator %s 2>&1 \
+// RUN: %clang -dM -E 

[clang] [Fix] Disable fdefine-target-os-macros for now (PR #74886)

2023-12-08 Thread Zixu Wang via cfe-commits

https://github.com/zixu-w created 
https://github.com/llvm/llvm-project/pull/74886

https://github.com/llvm/llvm-project/pull/74676 landed the work to implement 
`-fdefine-target-os-macros` and enabled the extension for the Darwin driver. 
However it is breaking some test builds. Leave the extension disabled for now 
until we can fix/workaround the build failures.

>From 63be986f612c175559efffed9daebcb944fa5cea Mon Sep 17 00:00:00 2001
From: Zixu Wang 
Date: Fri, 8 Dec 2023 12:58:15 -0800
Subject: [PATCH] [Fix] Disable fdefine-target-os-macros for now

https://github.com/llvm/llvm-project/pull/74676 landed the work to
implement `-fdefine-target-os-macros` and enabled the extension for
the Darwin driver. However it is breaking some test builds.
Leave the extension disabled for now until we can fix/workaround the
build failures.
---
 clang/lib/Driver/ToolChains/Darwin.cpp   |  4 ---
 clang/test/Driver/fdefine-target-os-macros.c | 29 +---
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index d3005d69e92bbf..f09bc27d7d2c0e 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2916,10 +2916,6 @@ void Darwin::addClangTargetOptions(const 
llvm::opt::ArgList ,
   // to fix the same problem with C++ headers, and is generally fragile.
   if (!sdkSupportsBuiltinModules(TargetPlatform, SDKInfo))
 CC1Args.push_back("-fbuiltin-headers-in-system-modules");
-
-  if (!DriverArgs.hasArgNoClaim(options::OPT_fdefine_target_os_macros,
-options::OPT_fno_define_target_os_macros))
-CC1Args.push_back("-fdefine-target-os-macros");
 }
 
 void Darwin::addClangCC1ASTargetOptions(
diff --git a/clang/test/Driver/fdefine-target-os-macros.c 
b/clang/test/Driver/fdefine-target-os-macros.c
index d7379dd3d5396b..030d4ce34cb282 100644
--- a/clang/test/Driver/fdefine-target-os-macros.c
+++ b/clang/test/Driver/fdefine-target-os-macros.c
@@ -1,11 +1,12 @@
 // RUN: %clang -### --target=arm64-apple-darwin %s 2>&1 | FileCheck %s 
--check-prefix=DARWIN-DEFAULT
-// DARWIN-DEFAULT: "-fdefine-target-os-macros"
+// DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
 
 // RUN: %clang -### --target=arm-none-linux-gnu %s 2>&1 | FileCheck %s 
--check-prefix=NON-DARWIN-DEFAULT
 // RUN: %clang -### --target=x86_64-pc-win32 %s 2>&1 | FileCheck %s 
--check-prefix=NON-DARWIN-DEFAULT
 // NON-DARWIN-DEFAULT-NOT: "-fdefine-target-os-macros"
 
-// RUN: %clang -dM -E --target=arm64-apple-macos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-macos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=1 \
 // RUN:-DIPHONE=0  \
@@ -20,7 +21,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -35,7 +37,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios-macabi %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios-macabi \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -50,7 +53,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-ios-simulator %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-ios-simulator \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -65,7 +69,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-tvos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-tvos \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -80,7 +85,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-tvos-simulator \
+// RUN:-fdefine-target-os-macros %s 2>&1 \
 // RUN: | FileCheck %s -DMAC=1 \
 // RUN:-DOSX=0 \
 // RUN:-DIPHONE=1  \
@@ -95,7 +101,8 @@
 // RUN:-DLINUX=0   \
 // RUN:-DUNIX=0
 
-// RUN: %clang -dM -E --target=arm64-apple-watchos %s 2>&1 \
+// RUN: %clang -dM -E --target=arm64-apple-watchos \
+// 

[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-08 Thread via cfe-commits

https://github.com/knightXun created 
https://github.com/llvm/llvm-project/pull/74885

Check that the number of non-concept template parameters is greater than zero 
during lambda template instantiation to aviod panic Fix issue: 
https://github.com/llvm/llvm-project/issues/70601

>From 05588ae4cd3e0a55f946c9d109470afbfd91c1be Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH] [Clang][Sema] Check the number of lambda non-concept tempate
 parameters Check that the number of non-concept template parameters is
 greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 clang/include/clang/Basic/DiagnosticParseKinds.td |  2 ++
 clang/lib/Sema/TreeTransform.h| 14 ++
 2 files changed, 16 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab..e46fa69d013b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0..110024a377128 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,20 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created

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


[clang] [compiler-rt] [clang-tools-extra] [llvm] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

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


@@ -1,39 +1,45 @@
-; Do setup work for all below tests: generate bitcode and combined index
-; RUN: opt -module-summary %s -o %t.bc
-; RUN: opt -module-summary %p/Inputs/thinlto_indirect_call_promotion.ll -o 
%t2.bc
+; The raw profiles and reduced IR inputs are generated from 
Inputs/update_icall_promotion_inputs.sh

minglotus-6 wrote:

I'm currently making attempt to have a single test under compiler-rt/test 
(i.e., removing thinlto_indirect_call_promotion.ll from IR test directory if 
the attempt works out). Will update back.

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


[clang] [clang][PP] Add extension to predefine target OS macros (PR #74676)

2023-12-08 Thread Florian Hahn via cfe-commits

fhahn wrote:

Please also see the failures on GreenDragon: 
https://green.lab.llvm.org/green/job/lnt-ctmark-aarch64-Os/15893/console

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


[clang] [clang][PP] Add extension to predefine target OS macros (PR #74676)

2023-12-08 Thread Florian Hahn via cfe-commits

fhahn wrote:

It looks like this breaks building at least `MultiSource` from 
https://github.com/llvm/llvm-test-suite/. The first failure I see is when 
building `llvm-test-suite/MultiSource/Applications/ClamAV/zlib_zutil.c`

```
In file included from 
/llvm-test-suite/MultiSource/Applications/ClamAV/zlib_zutil.c:10:
In file included from 
test-suites/llvm-test-suite/MultiSource/Applications/ClamAV/zlib/gzguts.h:21:
../usr/include/stdio.h:220:7: error: expected identifier or '('
  220 | FILE*fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, 
__IPHONE_2_0, __DARWIN_ALIAS(fdopen));
  |  ^
llvm-test-suite/MultiSource/Applications/ClamAV/zlib/zutil.h:140:33: note: 
expanded from macro 'fdopen'
  140 | #define fdopen(fd,mode) NULL /* No fdopen() */
  | ^
llvm-project/builds/release-with-assertions/ccache-stage1/lib/clang/18/include/__stddef_null.h:26:16:
 note: expanded from macro 'NULL'
   26 | #define NULL ((void*)0)
  |^
```

I think it also breaks building PovRay from SPEC2017.

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Richard Dzenis via cfe-commits

RIscRIpt wrote:

Thank you!

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Richard Dzenis via cfe-commits


@@ -2884,6 +2884,12 @@ def warn_cxx11_compat_constexpr_body_multiple_return : 
Warning<
   InGroup, DefaultIgnore;
 def note_constexpr_body_previous_return : Note<
   "previous return statement is here">;
+def err_ms_constexpr_not_distinct : Error<
+  "[[msvc::constexpr]] cannot be applied to a %select{constexpr|consteval}0 
function %1">;

RIscRIpt wrote:

tl;dr afterall I would keep it as-is.

Sorry, I overestimated this possibility.

> attribute 'msvc::constexpr' cannot be applied to the virtual function %1

This could be replaced with existing diagnostic
```
def err_constexpr_virtual : Error<"virtual function cannot be constexpr">;
```

However, two other variants of this new diagnostic:

> attribute 'msvc::constexpr' cannot be applied to the constexpr function %1
> attribute 'msvc::constexpr' cannot be applied to the consteval function %1

Are not easily replaceable. The most similar diagnostic I was able to find was:

```
def err_invalid_decl_spec_combination : Error<
  "cannot combine with previous '%0' declaration specifier">;
```

But, using this diagnostic, warnings are not consistent:

```
/home/richard/projects/llvm-project/clang/test/SemaCXX/ms-constexpr-invalid.cpp:10:3:
 error: cannot combine with previous 'constexpr' declaration specifier
   10 | [[msvc::constexpr]] constexpr void f1() {}
  |   ^~~~
```

`constexpr` comes after `[[msvc::constexpr]]`, but the message implies that 
`constexpr` came first.

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


[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-08 Thread John McCall via cfe-commits


@@ -6,14 +7,80 @@ float z();
 #pragma float_control(except, on)
 class ON {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN2ONC2Ev{{.*}}
-  // CHECK: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 ON on;
 #pragma float_control(except, off)
 class OFF {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN3OFFC2Ev{{.*}}
-  // CHECK-NOT: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 OFF off;
+// CHECK-LABEL: define internal void @__cxx_global_var_init(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] section ".text.startup" {

rjmccall wrote:

1. Are all of these checks necessary?  If so, please explain why in the test so 
that maintainers will understand what you're testing for.
2. Do you need to be checking the actual content of the attributes here?

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


[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-08 Thread John McCall via cfe-commits


@@ -5587,10 +5593,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   !isa_and_nonnull(TargetDecl))
 EmitKCFIOperandBundle(ConcreteCallee, BundleList);
 
+#if 0 // XXX Why is this here? Duplicate!
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())
   // All calls within a strictfp function are marked strictfp
   Attrs = Attrs.addFnAttribute(getLLVMContext(), 
llvm::Attribute::StrictFP);
+#endif

rjmccall wrote:

Please remove this instead of `#if 0`ing it.

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


[llvm] [flang] [clang-tools-extra] [clang] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2023-12-08 Thread Yi Wu via cfe-commits


@@ -6,6 +6,37 @@
 //
 
//===--===//
 
+// character.h

yi-wu-arm wrote:

Replaced by a comment

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


[llvm] [flang] [clang-tools-extra] [clang] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2023-12-08 Thread Yi Wu via cfe-commits


@@ -37,5 +77,30 @@ void FORTRAN_PROCEDURE_NAME(getarg)(
   (void)RTNAME(GetCommandArgument)(
   n, , nullptr, nullptr, __FILE__, __LINE__);
 }
+
+// CALL GETLOG(USRNAME)
+void FORTRAN_PROCEDURE_NAME(getlog)(std::int8_t *arg, std::int64_t length) {

yi-wu-arm wrote:

Done. Thanks for pointing this out.

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


[flang] [clang] [clang-tools-extra] [llvm] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2023-12-08 Thread Yi Wu via cfe-commits

https://github.com/yi-wu-arm updated 
https://github.com/llvm/llvm-project/pull/74628

>From 0e98aa7ca15b05b91813eaeeb6ae1305e5f5384d Mon Sep 17 00:00:00 2001
From: Yi Wu 
Date: Mon, 6 Nov 2023 19:49:13 +
Subject: [PATCH 01/26] GETLOG runtime and extension implementation: get login
 username

Get login username, ussage:
CHARACTER(32) :: login
CALL getlog(login)
WRITE(*,*) login
---
 flang/docs/Intrinsics.md  |  2 +-
 .../Optimizer/Builder/Runtime/RTBuilder.h |  8 
 flang/include/flang/Runtime/command.h |  6 +++
 flang/include/flang/Runtime/extensions.h  |  2 +
 flang/runtime/command.cpp | 40 +++
 flang/runtime/extensions.cpp  |  6 +++
 flang/unittests/Runtime/CommandTest.cpp   | 15 ++-
 7 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md
index ab0a940e53e553..cfe5dcd141e982 100644
--- a/flang/docs/Intrinsics.md
+++ b/flang/docs/Intrinsics.md
@@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures 
listed above but the
 | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, 
EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
 | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, 
MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
 | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, 
SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, 
KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, 
RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, 
IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, 
INT_PTR_KIND, ISNAN, MALLOC |
-| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
+| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, GETLOG, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, 
RANDOM_SEED, SYSTEM_CLOCK |
 | Atomic intrinsic subroutines | ATOMIC_ADD |
 | Collective intrinsic subroutines | CO_REDUCE |
 
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h 
b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index b2774263e7a31a..830df7ad006b54 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -62,6 +62,14 @@ using FuncTypeBuilderFunc = mlir::FunctionType 
(*)(mlir::MLIRContext *);
 /// standard type `i32` when `sizeof(int)` is 4.
 template 
 static constexpr TypeBuilderFunc getModel();
+
+template <>
+constexpr TypeBuilderFunc getModel() {
+  return [](mlir::MLIRContext *context) -> mlir::Type {
+return mlir::IntegerType::get(context, 8 * sizeof(unsigned int));
+  };
+}
+
 template <>
 constexpr TypeBuilderFunc getModel() {
   return [](mlir::MLIRContext *context) -> mlir::Type {
diff --git a/flang/include/flang/Runtime/command.h 
b/flang/include/flang/Runtime/command.h
index ec628939054547..1c212ef61697cd 100644
--- a/flang/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -47,6 +47,12 @@ std::int32_t RTNAME(GetEnvVariable)(const Descriptor ,
 bool trim_name = true, const Descriptor *errmsg = nullptr,
 const char *sourceFile = nullptr, int line = 0);
 }
+
+// Try to get the name of current user
+// Returns a STATUS as described in the standard.
+std::int32_t RTNAME(GetLog)(
+const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr);
+
 } // namespace Fortran::runtime
 
 #endif // FORTRAN_RUNTIME_COMMAND_H_
diff --git a/flang/include/flang/Runtime/extensions.h 
b/flang/include/flang/Runtime/extensions.h
index ad592814e5acb7..d199d5e387b864 100644
--- a/flang/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -28,5 +28,7 @@ std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
 void FORTRAN_PROCEDURE_NAME(getarg)(
 std::int32_t , std::int8_t *arg, std::int64_t length);
 
+void FORTRAN_PROCEDURE_NAME(getlog)(std::int8_t *name, std::int64_t length);
+
 } // extern "C"
 #endif // FORTRAN_RUNTIME_EXTENSIONS_H_
diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp
index b81a0791c5e571..6b2f313e227a19 100644
--- a/flang/runtime/command.cpp
+++ b/flang/runtime/command.cpp
@@ -15,6 +15,30 @@
 #include 
 #include 
 
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+
+#include  // UNLEN=256
+
+inline char *getlogin() {
+  char *username = NULL;
+  DWORD size = UNLEN + 1; // Constant for the maximum username length
+  username = (char *)malloc(size);
+
+  if (GetUserName(username, )) {
+// Username 

[clang] [clang-tools-extra] [llvm] [flang] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2023-12-08 Thread Yi Wu via cfe-commits


@@ -6,6 +6,37 @@
 //
 
//===--===//
 
+// character.h

yi-wu-arm wrote:

It actually meant to match the `CHARCHTER_H` in the end of `#endif`, but I 
guess that create a confusion and should be removed.

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


[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kevin P. Neal (kpneal)


Changes

Some C++ constructors require the strictfp attribute on all function calls but 
don't get it because the comstructor lacks a FunctionDecl. Use the IRBuilder's 
strictfp mode to communicate that the strictfp attribute is required. Note that 
the function calls that were missing the attribute were getting it from the 
IRBuilder but it then was getting lost when CGCall.cpp replaced all the 
attributes for the function call.

Verified with "https://reviews.llvm.org/D146845;.

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


4 Files Affected:

- (modified) clang/include/clang/AST/ExprCXX.h (+4) 
- (modified) clang/lib/CodeGen/CGCall.cpp (+8) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+5) 
- (modified) clang/test/CodeGen/fp-floatcontrol-class.cpp (+71-4) 


``diff
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 24278016431837..f9269082c32475 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1698,6 +1698,10 @@ class CXXConstructExpr : public Expr {
   SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
   void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
 
+  /// Determine whether the function was declared in source context
+  /// that requires constrained FP intrinsics
+  bool UsesFPIntrin() const { return Constructor->UsesFPIntrin(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXConstructExprClass ||
T->getStmtClass() == CXXTemporaryObjectExprClass;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a24aeea7ae32bf..7d1bb4dc75ab45 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5520,6 +5520,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   CGM.AdjustMemoryAttribute(CalleePtr->getName(), Callee.getAbstractInfo(),
 Attrs);
   }
+  // We may not have a FunctionDecl*, but we still need to support strictfp.
+  if (Builder.getIsFPConstrained()) {
+// All calls within a strictfp function are marked strictfp
+Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::StrictFP);
+  }
+
   // Add call-site nomerge attribute if exists.
   if (InNoMergeAttributedStmt)
 Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoMerge);
@@ -5587,10 +5593,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   !isa_and_nonnull(TargetDecl))
 EmitKCFIOperandBundle(ConcreteCallee, BundleList);
 
+#if 0 // XXX Why is this here? Duplicate!
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())
   // All calls within a strictfp function are marked strictfp
   Attrs = Attrs.addFnAttribute(getLLVMContext(), 
llvm::Attribute::StrictFP);
+#endif
 
   AssumeAlignedAttrEmitter AssumeAlignedAttrEmitter(*this, TargetDecl);
   Attrs = AssumeAlignedAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e08a1e5f42df20..5700b7fcb49d32 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1012,6 +1012,11 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   CurEHLocation = D->getBeginLoc();
 
+  if (const auto *CE = dyn_cast(D->getInit())) {
+if (CE->UsesFPIntrin())
+  Builder.setIsFPConstrained(true);
+  }
+
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
 FunctionArgList());
diff --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index 83a27cb206eb82..c9953119fd3a22 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --version 4
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 
@@ -6,14 +7,80 @@ float z();
 #pragma float_control(except, on)
 class ON {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN2ONC2Ev{{.*}}
-  // CHECK: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 ON on;
 #pragma float_control(except, off)
 class OFF {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN3OFFC2Ev{{.*}}
-  // CHECK-NOT: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 OFF off;
+// CHECK-LABEL: define internal void @__cxx_global_var_init(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] section ".text.startup" {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:call void @_ZN2ONC1Ev(ptr noundef nonnull align 4 

[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-08 Thread Kevin P. Neal via cfe-commits

https://github.com/kpneal created 
https://github.com/llvm/llvm-project/pull/74883

Some C++ constructors require the strictfp attribute on all function calls but 
don't get it because the comstructor lacks a FunctionDecl. Use the IRBuilder's 
strictfp mode to communicate that the strictfp attribute is required. Note that 
the function calls that were missing the attribute were getting it from the 
IRBuilder but it then was getting lost when CGCall.cpp replaced all the 
attributes for the function call.

Verified with "https://reviews.llvm.org/D146845;.

>From eb43ba5adbf57988fdd5f490a74dc59d72f495e5 Mon Sep 17 00:00:00 2001
From: "Kevin P. Neal" 
Date: Fri, 8 Dec 2023 14:43:50 -0500
Subject: [PATCH] [FPEnv] Add strictfp in some C++ constructors lacking a
 FunctionDecl.

Some C++ constructors require the strictfp attribute on all function calls
but don't get it because the comstructor lacks a FunctionDecl. Use the
IRBuilder's strictfp mode to communicate that the strictfp attribute is
required. Note that the function calls that were missing the attribute
were getting it from the IRBuilder but it then was getting lost when
CGCall.cpp replaced all the attributes for the function call.

Verified with "https://reviews.llvm.org/D146845;.
---
 clang/include/clang/AST/ExprCXX.h|  4 ++
 clang/lib/CodeGen/CGCall.cpp |  8 +++
 clang/lib/CodeGen/CGDeclCXX.cpp  |  5 ++
 clang/test/CodeGen/fp-floatcontrol-class.cpp | 75 ++--
 4 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 2427801643183..f9269082c3247 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1698,6 +1698,10 @@ class CXXConstructExpr : public Expr {
   SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
   void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
 
+  /// Determine whether the function was declared in source context
+  /// that requires constrained FP intrinsics
+  bool UsesFPIntrin() const { return Constructor->UsesFPIntrin(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXConstructExprClass ||
T->getStmtClass() == CXXTemporaryObjectExprClass;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a24aeea7ae32b..7d1bb4dc75ab4 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5520,6 +5520,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   CGM.AdjustMemoryAttribute(CalleePtr->getName(), Callee.getAbstractInfo(),
 Attrs);
   }
+  // We may not have a FunctionDecl*, but we still need to support strictfp.
+  if (Builder.getIsFPConstrained()) {
+// All calls within a strictfp function are marked strictfp
+Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::StrictFP);
+  }
+
   // Add call-site nomerge attribute if exists.
   if (InNoMergeAttributedStmt)
 Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoMerge);
@@ -5587,10 +5593,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   !isa_and_nonnull(TargetDecl))
 EmitKCFIOperandBundle(ConcreteCallee, BundleList);
 
+#if 0 // XXX Why is this here? Duplicate!
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())
   // All calls within a strictfp function are marked strictfp
   Attrs = Attrs.addFnAttribute(getLLVMContext(), 
llvm::Attribute::StrictFP);
+#endif
 
   AssumeAlignedAttrEmitter AssumeAlignedAttrEmitter(*this, TargetDecl);
   Attrs = AssumeAlignedAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e08a1e5f42df2..5700b7fcb49d3 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1012,6 +1012,11 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   CurEHLocation = D->getBeginLoc();
 
+  if (const auto *CE = dyn_cast(D->getInit())) {
+if (CE->UsesFPIntrin())
+  Builder.setIsFPConstrained(true);
+  }
+
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
 FunctionArgList());
diff --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index 83a27cb206eb8..c9953119fd3a2 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --version 4
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 
@@ -6,14 +7,80 @@ float z();
 #pragma 

[llvm] [flang] [clang-tools-extra] [clang] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2023-12-08 Thread Yi Wu via cfe-commits


@@ -10,10 +10,50 @@
 // extensions that will eventually be implemented in Fortran.
 
 #include "flang/Runtime/extensions.h"
+#include "flang/Runtime/character.h"
 #include "flang/Runtime/command.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
 
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+
+#include  // wcstombs_s
+#include  // UNLEN=256
+#include  // wchar_t cast to LPWSTR
+#pragma comment(lib, "Advapi32.lib") // Link Advapi32.lib for GetUserName

yi-wu-arm wrote:

avoidable, Windows environment variable for username is `USERNAME`.

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


[llvm] [flang] [clang-tools-extra] [clang] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2023-12-08 Thread Yi Wu via cfe-commits

https://github.com/yi-wu-arm updated 
https://github.com/llvm/llvm-project/pull/74628

>From 0e98aa7ca15b05b91813eaeeb6ae1305e5f5384d Mon Sep 17 00:00:00 2001
From: Yi Wu 
Date: Mon, 6 Nov 2023 19:49:13 +
Subject: [PATCH 01/25] GETLOG runtime and extension implementation: get login
 username

Get login username, ussage:
CHARACTER(32) :: login
CALL getlog(login)
WRITE(*,*) login
---
 flang/docs/Intrinsics.md  |  2 +-
 .../Optimizer/Builder/Runtime/RTBuilder.h |  8 
 flang/include/flang/Runtime/command.h |  6 +++
 flang/include/flang/Runtime/extensions.h  |  2 +
 flang/runtime/command.cpp | 40 +++
 flang/runtime/extensions.cpp  |  6 +++
 flang/unittests/Runtime/CommandTest.cpp   | 15 ++-
 7 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md
index ab0a940e53e55..cfe5dcd141e98 100644
--- a/flang/docs/Intrinsics.md
+++ b/flang/docs/Intrinsics.md
@@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures 
listed above but the
 | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, 
EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
 | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, 
MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
 | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, 
SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, 
KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, 
RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, 
IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, 
INT_PTR_KIND, ISNAN, MALLOC |
-| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
+| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, GETLOG, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, 
RANDOM_SEED, SYSTEM_CLOCK |
 | Atomic intrinsic subroutines | ATOMIC_ADD |
 | Collective intrinsic subroutines | CO_REDUCE |
 
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h 
b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index b2774263e7a31..830df7ad006b5 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -62,6 +62,14 @@ using FuncTypeBuilderFunc = mlir::FunctionType 
(*)(mlir::MLIRContext *);
 /// standard type `i32` when `sizeof(int)` is 4.
 template 
 static constexpr TypeBuilderFunc getModel();
+
+template <>
+constexpr TypeBuilderFunc getModel() {
+  return [](mlir::MLIRContext *context) -> mlir::Type {
+return mlir::IntegerType::get(context, 8 * sizeof(unsigned int));
+  };
+}
+
 template <>
 constexpr TypeBuilderFunc getModel() {
   return [](mlir::MLIRContext *context) -> mlir::Type {
diff --git a/flang/include/flang/Runtime/command.h 
b/flang/include/flang/Runtime/command.h
index ec62893905454..1c212ef61697c 100644
--- a/flang/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -47,6 +47,12 @@ std::int32_t RTNAME(GetEnvVariable)(const Descriptor ,
 bool trim_name = true, const Descriptor *errmsg = nullptr,
 const char *sourceFile = nullptr, int line = 0);
 }
+
+// Try to get the name of current user
+// Returns a STATUS as described in the standard.
+std::int32_t RTNAME(GetLog)(
+const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr);
+
 } // namespace Fortran::runtime
 
 #endif // FORTRAN_RUNTIME_COMMAND_H_
diff --git a/flang/include/flang/Runtime/extensions.h 
b/flang/include/flang/Runtime/extensions.h
index ad592814e5acb..d199d5e387b86 100644
--- a/flang/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -28,5 +28,7 @@ std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
 void FORTRAN_PROCEDURE_NAME(getarg)(
 std::int32_t , std::int8_t *arg, std::int64_t length);
 
+void FORTRAN_PROCEDURE_NAME(getlog)(std::int8_t *name, std::int64_t length);
+
 } // extern "C"
 #endif // FORTRAN_RUNTIME_EXTENSIONS_H_
diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp
index b81a0791c5e57..6b2f313e227a1 100644
--- a/flang/runtime/command.cpp
+++ b/flang/runtime/command.cpp
@@ -15,6 +15,30 @@
 #include 
 #include 
 
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+
+#include  // UNLEN=256
+
+inline char *getlogin() {
+  char *username = NULL;
+  DWORD size = UNLEN + 1; // Constant for the maximum username length
+  username = (char *)malloc(size);
+
+  if (GetUserName(username, )) {
+// Username retrieved 

[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Erich Keane via cfe-commits

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


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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Richard Dzenis via cfe-commits


@@ -3657,6 +3657,21 @@ an error:
 }];
 }
 
+def MSConstexprDocs : Documentation {
+  let Category = DocCatStmt;
+  let Content = [{
+The ``[[msvc::constexpr]]`` attribute can be applied only to a function
+definition or a ``return`` statement. It does not impact function declarations.
+A ``[[msvc::constexpr]]`` function cannot be ``constexpr`` or ``consteval``.
+A ``[[msvc::constexpr]]`` function is treated as if it were a ``constexpr`` 
function
+if it is evaluated in a constant context of ``[[msvc::constexpr]] return`` 
statement.
+Otherwise, it is treated as a regular function.
+
+Semantics of this attribute is enabled only under MSVC compatibility

RIscRIpt wrote:

Adjusted manually.

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Richard Dzenis via cfe-commits


@@ -5546,11 +5563,14 @@ static EvalStmtResult EvaluateStmt(StmtResult , 
EvalInfo ,
   case Stmt::LabelStmtClass:
 return EvaluateStmt(Result, Info, cast(S)->getSubStmt(), Case);
 
-  case Stmt::AttributedStmtClass:
-// As a general principle, C++11 attributes can be ignored without
-// any semantic impact.
-return EvaluateStmt(Result, Info, cast(S)->getSubStmt(),
-Case);
+  case Stmt::AttributedStmtClass: {
+const auto *AS = cast(S);
+const auto *SS = AS->getSubStmt();
+MSConstexprContextRAII msConstexprContext(

RIscRIpt wrote:

Adjusted manually.

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Richard Dzenis via cfe-commits


@@ -235,6 +235,7 @@ Non-comprehensive list of changes in this release
   except that it returns the size of a type ignoring tail padding.
 * ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the 
return value ``18``
   and vector types as return value ``19``, to match GCC 14's behavior.
+* Since MSVC 19.33 added undocumented attribute ``[[msvc::constexpr]]``, this 
release adds the attribute as well.

RIscRIpt wrote:

Added back.

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Richard Dzenis via cfe-commits

RIscRIpt wrote:

> Also, please don't 'force-push', just push an additional commit to your 
> review. It erases history and makes reviewing it about 3x harder since 
> history/context gets lost.

Sorry. I did this, because I am used to such workflow and reviewing 
[range-diff](https://github.com/llvm/llvm-project/compare/c700d21baf395aafbeea88778d13188650ed0c21..1af977ae49616ee00a64f50302f4cd88f9a51881);
 but to make it work one have to follow strict rule of pushing changes and 
rebased branch separately (which I failed to do previous time).

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-08 Thread Richard Dzenis via cfe-commits

https://github.com/RIscRIpt updated 
https://github.com/llvm/llvm-project/pull/71300

>From 3be36c6100801195f8f1f5167bdaa289bc8cb175 Mon Sep 17 00:00:00 2001
From: Richard Dzenis 
Date: Thu, 20 Jul 2023 00:18:50 +0300
Subject: [PATCH 1/4] [clang-cl] Add support for [[msvc::constexpr]] C++11
 attribute

Differential Revision: https://reviews.llvm.org/D134475
---
 clang/include/clang/Basic/Attr.td |  8 +++
 clang/include/clang/Basic/AttrDocs.td | 15 ++
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Basic/LangOptions.h   |  1 +
 clang/lib/AST/ExprConstant.cpp| 34 +---
 clang/lib/Basic/Targets/OSTargets.cpp |  3 ++
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaDeclAttr.cpp   | 25 +
 clang/lib/Sema/SemaStmtAttr.cpp   | 12 +
 clang/test/AST/ms-constexpr.cpp   | 28 ++
 ...a-attribute-supported-attributes-list.test |  1 +
 clang/test/SemaCXX/ms-constexpr-invalid.cpp   | 52 +++
 clang/test/SemaCXX/ms-constexpr-new.cpp   | 16 ++
 clang/test/SemaCXX/ms-constexpr.cpp   | 37 +
 14 files changed, 231 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/AST/ms-constexpr.cpp
 create mode 100644 clang/test/SemaCXX/ms-constexpr-invalid.cpp
 create mode 100644 clang/test/SemaCXX/ms-constexpr-new.cpp
 create mode 100644 clang/test/SemaCXX/ms-constexpr.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 121ed203829cec..b0a8ef10c500a7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3646,6 +3646,14 @@ def : MutualExclusions<[Owner, Pointer]>;
 
 // Microsoft-related attributes
 
+def MSConstexpr : InheritableAttr {
+  let LangOpts = [MicrosoftExt];
+  let Spellings = [CXX11<"msvc", "constexpr">];
+  let Subjects = SubjectList<[Function, ReturnStmt], ErrorDiag,
+ "functions and return statements">;
+  let Documentation = [MSConstexprDocs];
+}
+
 def MSNoVTable : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"novtable">];
   let Subjects = SubjectList<[CXXRecord]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 88f7c65e6e847b..9dc6a909f07d09 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3657,6 +3657,21 @@ an error:
 }];
 }
 
+def MSConstexprDocs : Documentation {
+  let Category = DocCatStmt;
+  let Content = [{
+The ``[[msvc::constexpr]]`` attribute can be applied only to a function
+definition or a ``return`` statement. It does not impact function declarations.
+A ``[[msvc::constexpr]]`` function cannot be ``constexpr`` or ``consteval``.
+A ``[[msvc::constexpr]]`` function is treated as if it were a ``constexpr`` 
function
+if it is evaluated in a constant context of ``[[msvc::constexpr]] return`` 
statement.
+Otherwise, it is treated as a regular function.
+
+Semantics of this attribute is enabled only under MSVC compatibility
+(``-fms-compatibility-version``) 19.33 and later.
+  }];
+}
+
 def MSNoVTableDocs : Documentation {
   let Category = DocCatDecl;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ea08fa84d022cd..28d95ca9b13893 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2884,6 +2884,8 @@ def warn_cxx11_compat_constexpr_body_multiple_return : 
Warning<
   InGroup, DefaultIgnore;
 def note_constexpr_body_previous_return : Note<
   "previous return statement is here">;
+def err_ms_constexpr_cannot_be_applied : Error<
+  "attribute 'msvc::constexpr' cannot be applied to the 
%select{constexpr|consteval|virtual}0 function %1">;
 
 // C++20 function try blocks in constexpr
 def ext_constexpr_function_try_block_cxx20 : ExtWarn<
diff --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 2d167dd2bdf128..c4979b9a38c0cf 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -152,6 +152,7 @@ class LangOptions : public LangOptionsBase {
 MSVC2019 = 1920,
 MSVC2019_5 = 1925,
 MSVC2019_8 = 1928,
+MSVC2022_3 = 1933,
   };
 
   enum SYCLMajorVersion {
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 986302e1fd225f..90cc0b84f0439c 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -641,6 +641,10 @@ namespace {
   return false;
 }
 
+/// Whether we're in a context where [[msvc::constexpr]] evaluation is
+/// permitted. See MSConstexprDocs for description of permitted contexts.
+bool CanEvalMSConstexpr = false;
+
   private:
 APValue (APValue::LValueBase Base, const void *Key, QualType T,
  ScopeKind 

[compiler-rt] [clang-tools-extra] [llvm] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-08 Thread Teresa Johnson via cfe-commits


@@ -1,39 +1,45 @@
-; Do setup work for all below tests: generate bitcode and combined index
-; RUN: opt -module-summary %s -o %t.bc
-; RUN: opt -module-summary %p/Inputs/thinlto_indirect_call_promotion.ll -o 
%t2.bc
+; The raw profiles and reduced IR inputs are generated from 
Inputs/update_icall_promotion_inputs.sh

teresajohnson wrote:

The reason for having this in a single test this way is specifically to detect 
mismatches in the separator used in the PGO name and in the ThinLTO index. For 
this we need to convert from raw profile and feed it through ThinLTO+ICP. 

Having separate tests would not do this. I.e. with the change from ':' to ';', 
the compiler-rt test would presumably have failed and would be updated, but the 
test using the proftext input would not fail. The lack of testing these pieces 
together led to the prior separator rename not updating all the necessary 
compiler bits.

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


[clang] [clang-format][NFC] Clean up the driver and getStyle() in Format.cpp (PR #74794)

2023-12-08 Thread Björn Schäpers via cfe-commits

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


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


[clang] [clang][Sema] Always clear UndefinedButUsed (PR #73955)

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

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

I'm okay landing these changes without test coverage, though tests are always 
preferred. LGTM

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


[llvm] [compiler-rt] [clang-tools-extra] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-08 Thread Ellis Hoag via cfe-commits


@@ -1,39 +1,45 @@
-; Do setup work for all below tests: generate bitcode and combined index
-; RUN: opt -module-summary %s -o %t.bc
-; RUN: opt -module-summary %p/Inputs/thinlto_indirect_call_promotion.ll -o 
%t2.bc
+; The raw profiles and reduced IR inputs are generated from 
Inputs/update_icall_promotion_inputs.sh

ellishg wrote:

I don't think there should be any sharing between `llvm/test` and 
`compiler-rt/test`. As you can see in `instrprof-basic.c`, it generates raw 
profiles and then generates and checks the IR to make sure profile data is 
consumed.

`compiler-rt/test` is useful if we need to run code, but it doesn't run on all 
platforms. If you only need to check IR, it is better to put the test in 
`llvm/test`. That being said, I wonder if it makes sense to split this into two 
tests. One in `compiler-rt/test` to make sure raw profiles are generated and 
consumed correctly, and verifying some IR. The other in `llvm/test` to make 
sure that IR is correct using a `.proftext` file, which can be tested quickly.

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


[clang] [clang][Driver] Support -fms-volatile as equivalent to /volatile:ms (PR #74790)

2023-12-08 Thread Reid Kleckner via cfe-commits

https://github.com/rnk commented:

> I assume that /volatile:ms is a legacy behavior that non-Windows OSes likely 
> don't want to adopt.

That is correct, it is legacy behavior. However, I think this flag has 
potential porting applications, similar to `-fshort-wchar`. I also think 
operating systems don't really have a say or control over what command line 
flags developers use. I think the more relevant question is, does the Clang 
project want to encourage folks to use this flag, thereby increasing our long 
term support burden? If this is a legacy compatibility mode, do we think we 
will be able to sunset it at some point, similar to 
`-fdelayed-template-parsing`?

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


[llvm] [compiler-rt] [clang-tools-extra] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

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


@@ -1,39 +1,45 @@
-; Do setup work for all below tests: generate bitcode and combined index
-; RUN: opt -module-summary %s -o %t.bc
-; RUN: opt -module-summary %p/Inputs/thinlto_indirect_call_promotion.ll -o 
%t2.bc
+; The raw profiles and reduced IR inputs are generated from 
Inputs/update_icall_promotion_inputs.sh

minglotus-6 wrote:

The script and c++ source is provided for on-demand update (e.g., version bump, 
etc). IIUC the goal of a `compiler-rt` test is to generate raw profiles from 
C++ source for each run of the IR test 
(`Transforms/PGOProfile/thinlto_indirect_call_promotion.ll`) (i.e.,the IR test 
would use the the output from the `compiler-rt` test). 

Practically, is there a way to run two tests one after the other so one could 
make use of the output of the other? Or shall the `compiler-rt` test verify the 
content of (raw or indexed) profile content?   (I'm assuming the IR test itself 
stays in `llvm/test/Transforms/PGOProfile` directory makes more sense here)



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


[libunwind] [libunwind] Replace process_vm_readv with pipe (PR #74791)

2023-12-08 Thread Jordan R AW via cfe-commits

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


[llvm] [clang] [SpecialCaseList] Use glob by default (PR #74809)

2023-12-08 Thread David Blaikie via cfe-commits

dwblaikie wrote:

> > Probably would be good to introduce the `-v1` version and require it first, 
> > then eventually change the default - so people don't get a silent behavior 
> > change? Even the existing users only using `*` and `.` need to change their 
> > syntax to migrate to v2, right? They'll need to change `.*` to `*` and `.` 
> > to `?` and if they don't, their matches will start behaving strangely 
> > without a specific/actionable error message?
> 
> Since `#!special-case-list-v1` is just a comment and `v1` is the default 
> before this change, users can actually add it to the first line today and the 
> behavior won't change until Clang 19.

Right, but they wouldn't know to do that in advance of the behavior change, 
would they? If they do nothing/don't read any release notes, they'd get a 
silent behavior change, I think/if I'm understanding this correctly?

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


[flang] [compiler-rt] [lldb] [libc] [openmp] [libcxx] [llvm] [libcxxabi] [clang-tools-extra] [mlir] [lld] [clang] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

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


@@ -8,10 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// sentinel() = default;
-// constexpr explicit sentinel(sentinel_t end);
-// constexpr sentinel(sentinel s)
-//   requires Const && convertible_to, sentinel_t>;
+// constexpr sentinel_t base() const;

Zingam wrote:

Maybe that's already encoded in the parent directory as all other tests use 
just "sentinel" and "iterator"

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


[llvm] [clang] [SpecialCaseList] Use glob by default (PR #74809)

2023-12-08 Thread Ellis Hoag via cfe-commits

ellishg wrote:

> Probably would be good to introduce the `-v1` version and require it first, 
> then eventually change the default - so people don't get a silent behavior 
> change? Even the existing users only using `*` and `.` need to change their 
> syntax to migrate to v2, right? They'll need to change `.*` to `*` and `.` to 
> `?` and if they don't, their matches will start behaving strangely without a 
> specific/actionable error message?

Since `#!special-case-list-v1` is just a comment and `v1` is the default before 
this change, users can actually add it to the first line today and the behavior 
won't change until Clang 19.

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


[compiler-rt] [openmp] [lldb] [polly] [mlir] [lld] [llvm] [clang] [flang] [VPlan] Initial modeling of VF * UF as VPValue. (PR #74761)

2023-12-08 Thread Florian Hahn via cfe-commits

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


[llvm] [clang] [SpecialCaseList] Use glob by default (PR #74809)

2023-12-08 Thread Petr Hosek via cfe-commits

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


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


[clang] Thread safety analysis: Fix a bug in handling temporary constructors (PR #74020)

2023-12-08 Thread Ziqing Luo via cfe-commits

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


[clang] a341e17 - Thread safety analysis: Fix a bug in handling temporary constructors (#74020)

2023-12-08 Thread via cfe-commits

Author: Ziqing Luo
Date: 2023-12-08T10:29:37-08:00
New Revision: a341e177cea1cee800793d357264f6f46a3b4979

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

LOG: Thread safety analysis: Fix a bug in handling temporary constructors 
(#74020)

Extends the lifetime of the map `ConstructedObjects` to be of the
whole CFG so that the map can connect temporary Ctor and Dtor in
different CFG blocks.

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 7fdf22c2f3919..e25b843c9bf83 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1010,6 +1010,8 @@ class ThreadSafetyAnalyzer {
   ThreadSafetyHandler 
   const FunctionDecl *CurrentFunction;
   LocalVariableMap LocalVarMap;
+  // Maps constructed objects to `this` placeholder prior to initialization.
+  llvm::SmallDenseMap ConstructedObjects;
   FactManager FactMan;
   std::vector BlockInfo;
 
@@ -1543,8 +1545,6 @@ class BuildLockset : public 
ConstStmtVisitor {
   FactSet FSet;
   // The fact set for the function on exit.
   const FactSet 
-  /// Maps constructed objects to `this` placeholder prior to initialization.
-  llvm::SmallDenseMap ConstructedObjects;
   LocalVariableMap::Context LVarCtx;
   unsigned CtxIndex;
 
@@ -1808,7 +1808,7 @@ void BuildLockset::handleCall(const Expr *Exp, const 
NamedDecl *D,
   std::pair Placeholder =
   Analyzer->SxBuilder.createThisPlaceholder(Exp);
   [[maybe_unused]] auto inserted =
-  ConstructedObjects.insert({Exp, Placeholder.first});
+  Analyzer->ConstructedObjects.insert({Exp, Placeholder.first});
   assert(inserted.second && "Are we visiting the same expression again?");
   if (isa(Exp))
 Self = Placeholder.first;
@@ -2128,10 +2128,10 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
 E = EWC->getSubExpr()->IgnoreParens();
   E = UnpackConstruction(E);
 
-  if (auto Object = ConstructedObjects.find(E);
-  Object != ConstructedObjects.end()) {
+  if (auto Object = Analyzer->ConstructedObjects.find(E);
+  Object != Analyzer->ConstructedObjects.end()) {
 Object->second->setClangDecl(VD);
-ConstructedObjects.erase(Object);
+Analyzer->ConstructedObjects.erase(Object);
   }
 }
   }
@@ -2140,11 +2140,11 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
 void BuildLockset::VisitMaterializeTemporaryExpr(
 const MaterializeTemporaryExpr *Exp) {
   if (const ValueDecl *ExtD = Exp->getExtendingDecl()) {
-if (auto Object =
-ConstructedObjects.find(UnpackConstruction(Exp->getSubExpr()));
-Object != ConstructedObjects.end()) {
+if (auto Object = Analyzer->ConstructedObjects.find(
+UnpackConstruction(Exp->getSubExpr()));
+Object != Analyzer->ConstructedObjects.end()) {
   Object->second->setClangDecl(ExtD);
-  ConstructedObjects.erase(Object);
+  Analyzer->ConstructedObjects.erase(Object);
 }
   }
 }
@@ -2487,15 +2487,15 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext ) {
 
   // Clean up constructed object even if there are no attributes to
   // keep the number of objects in limbo as small as possible.
-  if (auto Object = LocksetBuilder.ConstructedObjects.find(
+  if (auto Object = ConstructedObjects.find(
   TD.getBindTemporaryExpr()->getSubExpr());
-  Object != LocksetBuilder.ConstructedObjects.end()) {
+  Object != ConstructedObjects.end()) {
 const auto *DD = TD.getDestructorDecl(AC.getASTContext());
 if (DD->hasAttrs())
   // TODO: the location here isn't quite correct.
   LocksetBuilder.handleCall(nullptr, DD, Object->second,
 
TD.getBindTemporaryExpr()->getEndLoc());
-LocksetBuilder.ConstructedObjects.erase(Object);
+ConstructedObjects.erase(Object);
   }
   break;
 }

diff  --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp 
b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
index 205cfa284f6c9..dfb966d3b5902 100644
--- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1702,6 +1702,8 @@ struct TestScopedLockable {
 
   bool getBool();
 
+  bool lock2Bool(MutexLock);
+
   void foo1() {
 MutexLock mulock();
 a = 5;
@@ -1718,6 +1720,12 @@ struct TestScopedLockable {
 MutexLock{}, a = 5;
   }
 
+  void temporary_cfg(int x) {
+// test the case where a pair of temporary Ctor and Dtor is in 

[llvm] [clang] [SpecialCaseList] Use glob by default (PR #74809)

2023-12-08 Thread David Blaikie via cfe-commits

dwblaikie wrote:

Probably would be good to introduce the `-v1` version and require it first, 
then eventually change the default - so people don't get a silent behavior 
change? Even the existing users only using `*` and `.` need to change their 
syntax to migrate to v2, right? They'll need to change `.*` to `*` and `.` to 
`?` and if they don't, their matches will start behaving strangely without a 
specific/actionable error message?

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


[compiler-rt] [libcxx] [lldb] [libcxxabi] [clang-tools-extra] [lld] [llvm] [clang] [flang] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

2023-12-08 Thread Stanislav Mekhanoshin via cfe-commits


@@ -959,6 +967,32 @@ def : GCNPat <
 }
 } // let OtherPredicates = [HasShaderCyclesRegister]
 
+def SIMM24bitPtr : ImmLeaf (Imm);}]
+>;
+
+multiclass SMPrefetchPat {
+  def : GCNPat <
+(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, (i32 
cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, $offset, (i32 
SGPR_NULL), (i8 0))
+  >;
+
+  def : GCNPat <
+(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, 0, (i32 SGPR_NULL), 
(i8 0))
+  >;
+
+  def : GCNPat <
+(prefetch SIMM24bitPtr:$offset, timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type#"_PC_REL") (as_i32timm 
$offset), (i32 SGPR_NULL), (i8 0))
+  > {
+let AddedComplexity = 10;
+  }

rampitec wrote:

I do not think we need to use PC_REL form to prefetch on a function's address. 
The instruction can take full 64-bit address, so one can just use this address. 
 My understanding that PC_REL form can be useful if you expect something like a 
huge loop or a local branch and want to prefetch something like 1K from the PC. 
I am not sure though how useful this can be at a high language level or even in 
IR.

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


[libunwind] [libunwind] Replace process_vm_readv with pipe (PR #74791)

2023-12-08 Thread Jordan R AW via cfe-commits


@@ -2700,19 +2701,18 @@ bool UnwindCursor::setInfoForSigReturn(Registers_arm64 &) {
   // [1] 
https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vdso/sigreturn.S
   const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
   // The PC might contain an invalid address if the unwind info is bad, so
-  // directly accessing it could cause a segfault. Use process_vm_readv to read
-  // the memory safely instead. process_vm_readv was added in Linux 3.2, and
-  // AArch64 supported was added in Linux 3.7, so the syscall is guaranteed to
-  // be present. Unfortunately, there are Linux AArch64 environments where the
-  // libc wrapper for the syscall might not be present (e.g. Android 5), so 
call
-  // the syscall directly instead.
+  // directly accessing it could cause a segfault. Use pipe/write/read to read
+  // the memory safely instead.
+  int pipefd[2];
+  if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1)
+return false;
   uint32_t instructions[2];
-  struct iovec local_iov = {, sizeof instructions};
-  struct iovec remote_iov = {reinterpret_cast(pc), sizeof 
instructions};
-  long bytesRead =
-  syscall(SYS_process_vm_readv, getpid(), _iov, 1, _iov, 1, 
0);
+  const auto bufferSize = sizeof instructions;
+  if (write(pipefd[1], reinterpret_cast(pc), bufferSize) != bufferSize)
+return false;
+  const auto bytesRead = read(pipefd[0], instructions, bufferSize);

ajordanr-google wrote:

This is interesting, thanks.

I definitely could, though I'm mildly hesitant for two reasons. The first is 
because of the [comment from 
address_is_readable.cc](https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+/HEAD/absl/debugging/internal/address_is_readable.cc#74)

```c++
// This strategy depends on Linux implementation details,
// so we rely on the test to alert us if it stops working.
```

The other is whether the check will span the full set of instructions we want 
to read. The Abseil implimentation checks 8 bytes, which I think should just 
about fit everything we need if it weren't for that 8 byte alignment:

```c++
// Align address on 8-byte boundary. On aarch64, checking last
// byte before inaccessible page returned unexpected EFAULT.
const uintptr_t u_addr = reinterpret_cast(addr) & ~uintptr_t{7};
```

I'm not familiar with the alignment requirements for a (potentially broken) PC. 
You'd have more context than I do as to whether we'd need to check for both 
instructions with `rt_sigprocmask`?

I notice in the comments that pipe was a discarded method, but it doesn't 
really explain why. Performance reasons perhaps?

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


[clang] [clang] Better bitfield access units (PR #65742)

2023-12-08 Thread Nathan Sidwell via cfe-commits

urnathan wrote:

> I'm planning to take a closer look at this when I have more time. Sorry I 
> haven't been more responsive here.

When might that be?


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


[clang] 94c8373 - [NFC] A few whitespace changes.

2023-12-08 Thread Paul Walker via cfe-commits

Author: Paul Walker
Date: 2023-12-08T18:01:12Z
New Revision: 94c837345c27e173284a85471d4efda19eded08e

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

LOG: [NFC] A few whitespace changes.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 715e0c0dc8fa84..568000106a84dc 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -80,6 +80,7 @@ def remark_fe_backend_optimization_remark_analysis_aliasing : 
Remark<"%0; "
 "the '__restrict__' qualifier with the independent array arguments. "
 "Erroneous results will occur if these options are incorrectly applied!">,
 BackendInfo, InGroup;
+
 def warn_fe_backend_optimization_failure : Warning<"%0">, BackendInfo,
 InGroup, DefaultWarn;
 def note_fe_backend_invalid_loc : Note<"could "

diff  --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h 
b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 8635bdd470ee69..fb6f3287e3d262 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -2376,12 +2376,12 @@ class TargetTransformInfo::Model final : public 
TargetTransformInfo::Concept {
bool IsZeroCmp) const override {
 return Impl.enableMemCmpExpansion(OptSize, IsZeroCmp);
   }
-  bool enableInterleavedAccessVectorization() override {
-return Impl.enableInterleavedAccessVectorization();
-  }
   bool enableSelectOptimize() override {
 return Impl.enableSelectOptimize();
   }
+  bool enableInterleavedAccessVectorization() override {
+return Impl.enableInterleavedAccessVectorization();
+  }
   bool enableMaskedInterleavedAccessVectorization() override {
 return Impl.enableMaskedInterleavedAccessVectorization();
   }

diff  --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h 
b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index fa4c93d5f77a19..0b220069a388b6 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -291,6 +291,7 @@ class AArch64TTIImpl : public 
BasicTTIImplBase {
   bool isLegalMaskedGather(Type *DataType, Align Alignment) const {
 return isLegalMaskedGatherScatter(DataType);
   }
+
   bool isLegalMaskedScatter(Type *DataType, Align Alignment) const {
 return isLegalMaskedGatherScatter(DataType);
   }



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


[clang] [clang][Interp] Handle std::move etc. builtins (PR #70772)

2023-12-08 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= 
Message-ID:
In-Reply-To: 


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

LGTM assuming no surprises come up from the additional test coverage.

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


[clang] [clang][Interp] Handle std::move etc. builtins (PR #70772)

2023-12-08 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -378,3 +378,92 @@ namespace Packs {
   static_assert(foo() == 2, "");
   static_assert(foo<>() == 0, "");
 }
+
+namespace std {
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+template 
+constexpr typename std::remove_reference::type&& move(T &) noexcept {
+  return static_cast::type &&>(t);
+}
+}
+/// The std::move declaration above gets translated to a builtin function.
+namespace Move {

AaronBallman wrote:

I'd like to see test coverage involving a move constructor, a move assignment 
operator, a direct call to __builtin_move, and some testing for `std::as_const` 
and `std::forward`. Of special interest would be times when there's UB in the 
move constructor/move assignment that should be caught or a non-copyable object 
where move semantics are the only thing that should work.

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


[clang] [clang][Interp] Diagnose reads from non-const global variables (PR #71919)

2023-12-08 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -1005,12 +1008,23 @@ bool SetThisField(InterpState , CodePtr OpPC, 
uint32_t I) {
 template ::T>
 bool GetGlobal(InterpState , CodePtr OpPC, uint32_t I) {
   const Block *B = S.P.getGlobal(I);
+
+  if (!CheckConstant(S, OpPC, B->getDescriptor()))
+return false;
   if (B->isExtern())
 return false;
   S.Stk.push(B->deref());
   return true;
 }
 
+/// Same as GetGlobal, but without the checks.
+template ::T>
+bool GetGlobalUnchecked(InterpState , CodePtr OpPC, uint32_t I) {
+  auto *B = S.P.getGlobal(I);
+  S.Stk.push(B->deref());
+  return true;
+}
+

AaronBallman wrote:

Would it be reasonable to implement `GetGlobal` in terms of 
`GetGlobalUnchecked` so we can share code, or is that not feasible because 
`GetGlobalUnchecked` will push something to the stack that the checks may then 
reject?

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


[clang] bbb8a0d - [Clang] Fix ResolveConstructorOverload to not select a conversion function if we are going use copy elision

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

Author: Shafik Yaghmour
Date: 2023-12-08T09:38:59-08:00
New Revision: bbb8a0df7367068e1cf2fc54edd376beb976b430

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

LOG: [Clang] Fix ResolveConstructorOverload to not select a conversion function 
if we are going use copy elision

ResolveConstructorOverload needs to check properly if we are going to use copy
elision we can't use a conversion function.

This fixes:

https://github.com/llvm/llvm-project/issues/39319
https://github.com/llvm/llvm-project/issues/60182
https://github.com/llvm/llvm-project/issues/62157
https://github.com/llvm/llvm-project/issues/64885
https://github.com/llvm/llvm-project/issues/65568

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaCXX/cxx1z-copy-omission.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 626585c146914c..28f9393e28437d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -669,6 +669,12 @@ Bug Fixes in This Version
   Fixes (`#64467 `_)
 - Clang's ``-Wchar-subscripts`` no longer warns on chars whose values are 
known non-negative constants.
   Fixes (`#18763 `_)
+- Fix crash due to incorrectly allowing conversion functions in copy elision.
+  Fixes (`#39319 `_) and
+  (`#60182 `_) and
+  (`#62157 `_) and
+  (`#64885 `_) and
+  (`#65568 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 042ca61abe44d5..5ca6b232df66a5 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4085,16 +4085,13 @@ static bool hasCopyOrMoveCtorParam(ASTContext ,
   return Ctx.hasSameUnqualifiedType(ParmT, ClassT);
 }
 
-static OverloadingResult
-ResolveConstructorOverload(Sema , SourceLocation DeclLoc,
-   MultiExprArg Args,
-   OverloadCandidateSet ,
-   QualType DestType,
-   DeclContext::lookup_result Ctors,
-   OverloadCandidateSet::iterator ,
-   bool CopyInitializing, bool AllowExplicit,
-   bool OnlyListConstructors, bool IsListInit,
-   bool SecondStepOfCopyInit = false) {
+static OverloadingResult ResolveConstructorOverload(
+Sema , SourceLocation DeclLoc, MultiExprArg Args,
+OverloadCandidateSet , QualType DestType,
+DeclContext::lookup_result Ctors, OverloadCandidateSet::iterator ,
+bool CopyInitializing, bool AllowExplicit, bool OnlyListConstructors,
+bool IsListInit, bool RequireActualConstructor,
+bool SecondStepOfCopyInit = false) {
   CandidateSet.clear(OverloadCandidateSet::CSK_InitByConstructor);
   CandidateSet.setDestAS(DestType.getQualifiers().getAddressSpace());
 
@@ -4157,7 +4154,7 @@ ResolveConstructorOverload(Sema , SourceLocation 
DeclLoc,
   // Note: SecondStepOfCopyInit is only ever true in this case when
   // evaluating whether to produce a C++98 compatibility warning.
   if (S.getLangOpts().CPlusPlus17 && Args.size() == 1 &&
-  !SecondStepOfCopyInit) {
+  !RequireActualConstructor && !SecondStepOfCopyInit) {
 Expr *Initializer = Args[0];
 auto *SourceRD = Initializer->getType()->getAsCXXRecordDecl();
 if (SourceRD && S.isCompleteType(DeclLoc, Initializer->getType())) {
@@ -4225,6 +4222,12 @@ static void TryConstructorInitialization(Sema ,
 return;
   }
 
+  bool RequireActualConstructor =
+  !(Entity.getKind() != InitializedEntity::EK_Base &&
+Entity.getKind() != InitializedEntity::EK_Delegating &&
+Entity.getKind() !=
+InitializedEntity::EK_LambdaToBlockConversionBlockElement);
+
   // C++17 [dcl.init]p17:
   // - If the initializer expression is a prvalue and the cv-unqualified
   //   version of the source type is the same class as the class of the
@@ -4234,11 +4237,7 @@ static void TryConstructorInitialization(Sema ,
   // class or delegating to another constructor from a mem-initializer.
   // ObjC++: Lambda captured by the block in the lambda to block conversion
   // should avoid copy elision.
-  if (S.getLangOpts().CPlusPlus17 &&
-  Entity.getKind() != InitializedEntity::EK_Base &&
-  Entity.getKind() 

[clang] [clang][Interp] Decay arrays to the first element (PR #72660)

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

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

LGTM with a testing nit

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


[clang] [clang][Interp] Decay arrays to the first element (PR #72660)

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


@@ -27,6 +27,9 @@ static_assert(foo[2][3] == , "");
 static_assert(foo[2][4] == nullptr, "");
 
 
+const int SomeInt[] = {1};
+int getSomeInt() { return *SomeInt; }

AaronBallman wrote:

```suggestion
constexpr int SomeInt[] = {1};
constexpr int getSomeInt() { return *SomeInt; }

static_assert(getSomeInt() == 1);
```
so we're testing the decayed pointer.

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


[clang] [clang][Interp] Decay arrays to the first element (PR #72660)

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

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


[clang] [clang][Interp] Fix float->int casts overflowing (PR #72658)

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

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

LGTM!

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


[clang-tools-extra] [llvm] [clang] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)

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

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

LGTM, but please wait until sometime mid-next week to land in case Richard has 
concerns.

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


[clang] 731361c - [OpenACC] Fix bug with directive name being a 'special token'

2023-12-08 Thread via cfe-commits

Author: erichkeane
Date: 2023-12-08T09:32:49-08:00
New Revision: 731361cd1540d0e729633833e6f3a670443c4b84

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

LOG: [OpenACC] Fix bug with directive name being a 'special token'

If the 'directive name' is a special token instead of an identifier, we
end up asserting.  This fixes that.

Added: 


Modified: 
clang/lib/Parse/ParseOpenACC.cpp
clang/test/ParserOpenACC/parse-constructs.c

Removed: 




diff  --git a/clang/lib/Parse/ParseOpenACC.cpp 
b/clang/lib/Parse/ParseOpenACC.cpp
index 83a91d44f73fa..f7f096762e91a 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -206,7 +206,7 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser ) {
 
   // Just #pragma acc can get us immediately to the end, make sure we don't
   // introspect on the spelling before then.
-  if (FirstTok.isAnnotation()) {
+  if (FirstTok.isNot(tok::identifier)) {
 P.Diag(FirstTok, diag::err_acc_missing_directive);
 return OpenACCDirectiveKind::Invalid;
   }
@@ -224,11 +224,8 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser ) {
   if (ExDirKind >= OpenACCDirectiveKindEx::Invalid) {
 switch (ExDirKind) {
 case OpenACCDirectiveKindEx::Invalid: {
-  if (!FirstTok.is(tok::identifier))
-P.Diag(FirstTok, diag::err_expected) << tok::identifier;
-  else
-P.Diag(FirstTok, diag::err_acc_invalid_directive)
-<< 0 << FirstTok.getIdentifierInfo();
+  P.Diag(FirstTok, diag::err_acc_invalid_directive)
+  << 0 << FirstTok.getIdentifierInfo();
   return OpenACCDirectiveKind::Invalid;
 }
 case OpenACCDirectiveKindEx::Enter:

diff  --git a/clang/test/ParserOpenACC/parse-constructs.c 
b/clang/test/ParserOpenACC/parse-constructs.c
index b745f54bd715c..83d9bd6070d41 100644
--- a/clang/test/ParserOpenACC/parse-constructs.c
+++ b/clang/test/ParserOpenACC/parse-constructs.c
@@ -7,6 +7,17 @@ void func() {
 #pragma acc
   for(;;){}
 
+  // expected-error@+4{{expected OpenACC directive}}
+  // expected-error@+3{{expected clause-list or newline in OpenACC directive}}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc(whatever) routine
+
+  // expected-error@+3{{expected OpenACC directive}}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc) routine
+
   // expected-error@+2{{invalid OpenACC directive 'invalid'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
 #pragma acc invalid



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


[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)

2023-12-08 Thread Sam Tebbs via cfe-commits


@@ -500,6 +506,12 @@ bool ClangTableGenMain(raw_ostream , RecordKeeper 
) {
   case GenArmSmeRangeChecks:
 EmitSmeRangeChecks(Records, OS);
 break;
+  case GenArmSmeStreamingAttrs:

SamTebbs33 wrote:

Done

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


[clang] [llvm] [clang-tools-extra] [Clang][AArch64] Add fix vector types to header into SVE (PR #73258)

2023-12-08 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/73258

>From e0f245e8d6a395afac5de471b55358c7b730a170 Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Wed, 22 Nov 2023 10:03:50 +
Subject: [PATCH 1/8] [Clang][AArch64] Add  fix vector types to header into SVE

This patch is needed for the reduction instructions in sve2.1

It add ta new header to sve with all the fixed vector types.
The new types are only added if neon is not declared.
---
 clang/include/clang/Basic/arm_vector_type.td  |  13 ++
 clang/lib/Headers/CMakeLists.txt  |   3 +
 .../CodeGen/arm-vector_type-params-returns.c  | 113 ++
 clang/utils/TableGen/NeonEmitter.cpp  |  44 +++
 clang/utils/TableGen/SveEmitter.cpp   |   2 +
 clang/utils/TableGen/TableGen.cpp |  15 ++-
 clang/utils/TableGen/TableGenBackends.h   |   1 +
 7 files changed, 188 insertions(+), 3 deletions(-)
 create mode 100644 clang/include/clang/Basic/arm_vector_type.td
 create mode 100644 clang/test/CodeGen/arm-vector_type-params-returns.c

diff --git a/clang/include/clang/Basic/arm_vector_type.td 
b/clang/include/clang/Basic/arm_vector_type.td
new file mode 100644
index 0..5018b0cdfc137
--- /dev/null
+++ b/clang/include/clang/Basic/arm_vector_type.td
@@ -0,0 +1,13 @@
+//===--- arm_vector_type.td - ARM Fixed vector types compiler interface 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines the TableGen definitions from which the ARM BF16 header
+//  file will be generated.
+//
+//===--===//
+include "arm_neon_incl.td"
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index 8b1e2bc4afa4d..0beb6ade42920 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -385,6 +385,8 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST 
LLVM_TARGETS_TO_BUILD)
   clang_generate_header(-gen-arm-mve-header arm_mve.td arm_mve.h)
   # Generate arm_cde.h
   clang_generate_header(-gen-arm-cde-header arm_cde.td arm_cde.h)
+  # Generate arm_vector_type.h
+  clang_generate_header(-gen-arm-vector-type arm_vector_type.td 
arm_vector_type.h)
 
   # Add headers to target specific lists
   list(APPEND arm_common_generated_files
@@ -401,6 +403,7 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST 
LLVM_TARGETS_TO_BUILD)
 "${CMAKE_CURRENT_BINARY_DIR}/arm_sve.h"
 "${CMAKE_CURRENT_BINARY_DIR}/arm_sme_draft_spec_subject_to_change.h"
 "${CMAKE_CURRENT_BINARY_DIR}/arm_bf16.h"
+"${CMAKE_CURRENT_BINARY_DIR}/arm_vector_type.h"
 )
 endif()
 if(RISCV IN_LIST LLVM_TARGETS_TO_BUILD)
diff --git a/clang/test/CodeGen/arm-vector_type-params-returns.c 
b/clang/test/CodeGen/arm-vector_type-params-returns.c
new file mode 100644
index 0..48c19d01b6257
--- /dev/null
+++ b/clang/test/CodeGen/arm-vector_type-params-returns.c
@@ -0,0 +1,113 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s 
| opt -S -passes=mem2reg,sroa | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S 
-disable-O0-optnone -Werror -Wall -o - /dev/null %s
+#include 
+
+// function return types
+// CHECK-LABEL: define dso_local <8 x half> @test_ret_v8f16(
+// CHECK-SAME: <8 x half> noundef returned [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret <8 x half> [[V]]
+//
+float16x8_t test_ret_v8f16(float16x8_t v) {
+  return v;
+}
+
+// CHECK-LABEL: define dso_local <4 x float> @test_ret_v4f32(
+// CHECK-SAME: <4 x float> noundef returned [[V:%.*]]) local_unnamed_addr 
#[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret <4 x float> [[V]]
+//
+float32x4_t test_ret_v4f32(float32x4_t v) {
+  return v;
+}
+
+// CHECK-LABEL: define dso_local <2 x double> @test_ret_v2f64(
+// CHECK-SAME: <2 x double> noundef returned [[V:%.*]]) local_unnamed_addr 
#[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret <2 x double> [[V]]
+//
+float64x2_t test_ret_v2f64(float64x2_t v) {
+  return v;
+}
+
+// CHECK-LABEL: define dso_local <8 x bfloat> @test_ret_v8bf16(
+// CHECK-SAME: <8 x bfloat> noundef returned [[V:%.*]]) local_unnamed_addr 
#[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret <8 x bfloat> [[V]]
+//
+bfloat16x8_t test_ret_v8bf16(bfloat16x8_t v) {
+  return v;
+}
+
+// CHECK-LABEL: define dso_local <16 x i8> @test_ret_v16s8(
+// CHECK-SAME: <16 x i8> noundef returned [[V:%.*]]) local_unnamed_addr 
#[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret <16 x i8> 

[clang] Fix test rocm-detect.hip (PR #74872)

2023-12-08 Thread Yaxun Liu via cfe-commits

yxsamliu wrote:

It seems that is the only HIP test that still uses %T.

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


[clang] Fix test rocm-detect.hip (PR #74872)

2023-12-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yaxun (Sam) Liu (yxsamliu)


Changes

Replace %T with %t since %T is deprecated.

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


1 Files Affected:

- (modified) clang/test/Driver/rocm-detect.hip (+17-17) 


``diff
diff --git a/clang/test/Driver/rocm-detect.hip 
b/clang/test/Driver/rocm-detect.hip
index 947c4f995be17..3644f215a345b 100644
--- a/clang/test/Driver/rocm-detect.hip
+++ b/clang/test/Driver/rocm-detect.hip
@@ -78,39 +78,39 @@
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test detecting latest /opt/rocm-{release} directory.
-// RUN: rm -rf %T/opt
-// RUN: mkdir -p %T/opt
-// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
-// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
-// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 
--sysroot=%T \
+// RUN: rm -rf %t/opt
+// RUN: mkdir -p %t/opt
+// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234
+// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.10.0
+// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 
--sysroot=%t \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-REL %s
 
-// Test ROCm installation built by SPACK by invoke clang at 
%T/rocm-spack/llvm-amdgpu-*
+// Test ROCm installation built by SPACK by invoke clang at 
%t/rocm-spack/llvm-amdgpu-*
 // directory through a soft link.
 
-// RUN: rm -rf %T/rocm-spack
-// RUN: cp -r %S/Inputs/rocm-spack %T
-// RUN: ln -fs %clang 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
-// RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   
-resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 \
+// RUN: rm -rf %t/rocm-spack
+// RUN: cp -r %S/Inputs/rocm-spack %t
+// RUN: ln -fs %clang 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
+// RUN: 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
+// RUN:   
-resource-dir=%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 
--print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
 // Test SPACK installation with multiple hip and rocm-device-libs packages of 
the same
 // ROCm release. --hip-path and --rocm-device-lib-path can be used to specify 
them.
 
-// RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
-// RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
+// RUN: cp -r %t/rocm-spack/hip-* %t/rocm-spack/hip-4.0.0-abcd
+// RUN: 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \
-// RUN:   --hip-path=%T/rocm-spack/hip-4.0.0-abcd \
+// RUN:   --hip-path=%t/rocm-spack/hip-4.0.0-abcd \
 // RUN:%s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s
 
 // Test invalid SPACK ROCm installation missing hip and rocm-device-libs 
packages.
 
-// RUN: rm -rf %T/rocm-spack/hip-*
-// RUN: rm -rf 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
-// RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang 
--version 2>&1 \
+// RUN: rm -rf %t/rocm-spack/hip-*
+// RUN: rm -rf 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
+// RUN: 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang 
--version 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK-MISS-SILENT %s
 
 // GFX902-DEFAULTLIBS: error: cannot find ROCm device library for gfx902; 
provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass 
'-nogpulib' to build without ROCm device library

``




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


[clang] Fix test rocm-detect.hip (PR #74872)

2023-12-08 Thread Yaxun Liu via cfe-commits

https://github.com/yxsamliu created 
https://github.com/llvm/llvm-project/pull/74872

Replace %T with %t since %T is deprecated.

>From 91160285c17ef9ba2b35e6e8c4a8eb433ec5ad8a Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" 
Date: Fri, 8 Dec 2023 12:24:19 -0500
Subject: [PATCH] Fix test rocm-detect.hip

Replace %T with %t since %T is deprecated.
---
 clang/test/Driver/rocm-detect.hip | 34 +++
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/clang/test/Driver/rocm-detect.hip 
b/clang/test/Driver/rocm-detect.hip
index 947c4f995be17..3644f215a345b 100644
--- a/clang/test/Driver/rocm-detect.hip
+++ b/clang/test/Driver/rocm-detect.hip
@@ -78,39 +78,39 @@
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test detecting latest /opt/rocm-{release} directory.
-// RUN: rm -rf %T/opt
-// RUN: mkdir -p %T/opt
-// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
-// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
-// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 
--sysroot=%T \
+// RUN: rm -rf %t/opt
+// RUN: mkdir -p %t/opt
+// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234
+// RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.10.0
+// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 
--sysroot=%t \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-REL %s
 
-// Test ROCm installation built by SPACK by invoke clang at 
%T/rocm-spack/llvm-amdgpu-*
+// Test ROCm installation built by SPACK by invoke clang at 
%t/rocm-spack/llvm-amdgpu-*
 // directory through a soft link.
 
-// RUN: rm -rf %T/rocm-spack
-// RUN: cp -r %S/Inputs/rocm-spack %T
-// RUN: ln -fs %clang 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
-// RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   
-resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 \
+// RUN: rm -rf %t/rocm-spack
+// RUN: cp -r %S/Inputs/rocm-spack %t
+// RUN: ln -fs %clang 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
+// RUN: 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
+// RUN:   
-resource-dir=%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
 \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 
--print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
 // Test SPACK installation with multiple hip and rocm-device-libs packages of 
the same
 // ROCm release. --hip-path and --rocm-device-lib-path can be used to specify 
them.
 
-// RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
-// RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
+// RUN: cp -r %t/rocm-spack/hip-* %t/rocm-spack/hip-4.0.0-abcd
+// RUN: 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \
-// RUN:   --hip-path=%T/rocm-spack/hip-4.0.0-abcd \
+// RUN:   --hip-path=%t/rocm-spack/hip-4.0.0-abcd \
 // RUN:%s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s
 
 // Test invalid SPACK ROCm installation missing hip and rocm-device-libs 
packages.
 
-// RUN: rm -rf %T/rocm-spack/hip-*
-// RUN: rm -rf 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
-// RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang 
--version 2>&1 \
+// RUN: rm -rf %t/rocm-spack/hip-*
+// RUN: rm -rf 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
+// RUN: 
%t/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang 
--version 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK-MISS-SILENT %s
 
 // GFX902-DEFAULTLIBS: error: cannot find ROCm device library for gfx902; 
provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass 
'-nogpulib' to build without ROCm device library

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


[clang] [llvm] [SpecialCaseList] Use glob by default (PR #74809)

2023-12-08 Thread Ellis Hoag via cfe-commits

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

Looks good to me. Thanks for following up!

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


[clang] [llvm] [clang][RISCV] Change default abi with f extension but without d extension (PR #73489)

2023-12-08 Thread Alex Bradbury via cfe-commits

asb wrote:

> > I think the conclusion from the LLVM sync-up call was that everyone happy 
> > to move in this direction, so please add the release note and we can do a 
> > final review. Thanks!
> 
> Done, added release note.

Thanks! Sorry I wasn't specific about this, but we need a Clang release note as 
well.

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


[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)

2023-12-08 Thread Sam Tebbs via cfe-commits


@@ -20,3 +21,23 @@ int16x8_t incompat_neon_smc(int16x8_t splat) 
__arm_streaming_compatible {
   // expected-warning@+1 {{builtin call has undefined behaviour when called 
from a streaming compatible function}}
   return (int16x8_t)__builtin_neon_vqaddq_v((int8x16_t)splat, 
(int8x16_t)splat, 33);
 }
+
+void incompat_sme_norm(svbool_t pg, void const *ptr) __arm_shared_za {
+  // expected-warning@+1 {{builtin call has undefined behaviour when called 
from a non-streaming function}}
+  return __builtin_sme_svld1_hor_za128(0, 0, pg, ptr);

SamTebbs33 wrote:

I removed this test since, as you said, it wasn't testing anything different 
and after adding the SVE changes we have tests for SVE builtins anyway.

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


[clang] [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (PR #74064)

2023-12-08 Thread Sam Tebbs via cfe-commits


@@ -3168,11 +3168,70 @@ static void checkArmStreamingBuiltin(Sema , CallExpr 
*TheCall,
 << TheCall->getSourceRange() << "streaming compatible";
 return;
   }
+
+  if (FnType == ArmNonStreaming && BuiltinType == ArmStreaming) {
+S.Diag(TheCall->getBeginLoc(), 
diag::warn_attribute_arm_sm_incompat_builtin)
+<< TheCall->getSourceRange() << "non-streaming";
+  }
+}

SamTebbs33 wrote:

I've removed the ZA state changes and added the SVE changes. Let me know what 
you think.

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


[clang] Fix tests hip-offload-compress-zlib/zstd.hip (PR #74783)

2023-12-08 Thread Yaxun Liu via cfe-commits

yxsamliu wrote:

> %T is deprecated in lit. You may want to migrate other `%T` related to AMDGPU.

Thanks. I will try cleaning them up.

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


[clang] [Cygwin] Cygwin basic support (PR #74868)

2023-12-08 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74868

From 680b2b48925d52c006eee5f26b1173856dfcf376 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 00:59:00 +0800
Subject: [PATCH 1/2] [Cygwin] Cygwin basic support

---
 clang/lib/Basic/Targets/X86.h | 5 -
 clang/lib/Driver/ToolChains/Clang.cpp | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 0ab1c10833db2..e77e1e690cfc0 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -905,7 +905,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : 
public X86_64TargetInfo {
   CygwinX86_64TargetInfo(const llvm::Triple , const TargetOptions )
   : X86_64TargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedShort;
-TLSSupported = false;
   }
 
   void getTargetDefines(const LangOptions ,
@@ -919,6 +918,10 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : 
public X86_64TargetInfo {
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
   }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::CharPtrBuiltinVaList;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinX86_64TargetInfo
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb26bfade47b7..8b38c9e386d76 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,9 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX()
+  && !RawTriple.isWindowsGNUEnvironment()
+  && !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From cf424f825752c1f33e5d83f872e94e43a1a35e6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 01:08:20 +0800
Subject: [PATCH 2/2] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8b38c9e386d76..df062ccc9021f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,9 +6656,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX()
-  && !RawTriple.isWindowsGNUEnvironment()
-  && !RawTriple.isWindowsMSVCEnvironment() &&
+  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
+  !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

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


[clang] Fix tests hip-offload-compress-zlib/zstd.hip (PR #74783)

2023-12-08 Thread Yaxun Liu via cfe-commits

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


[clang] b842b1b - Fix tests hip-offload-compress-zlib/zstd.hip (#74783)

2023-12-08 Thread via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-12-08T12:04:01-05:00
New Revision: b842b1b65aab3bff2c3dbf439054aa8fe63f8400

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

LOG: Fix tests hip-offload-compress-zlib/zstd.hip (#74783)

Use %t in output file name as %T is non-unique.

Added: 


Modified: 
clang/test/Driver/hip-offload-compress-zlib.hip
clang/test/Driver/hip-offload-compress-zstd.hip

Removed: 




diff  --git a/clang/test/Driver/hip-offload-compress-zlib.hip 
b/clang/test/Driver/hip-offload-compress-zlib.hip
index a29b6d037350d..7557fdde8786c 100644
--- a/clang/test/Driver/hip-offload-compress-zlib.hip
+++ b/clang/test/Driver/hip-offload-compress-zlib.hip
@@ -4,13 +4,13 @@
 
 // Test compress bundled bitcode.
 
-// RUN: rm -rf %T/a.bc
+// RUN: rm -rf %t.bc
 // RUN: %clang -c -v --target=x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx1100 --offload-arch=gfx1101 \
 // RUN:   -fgpu-rdc -nogpuinc -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN:   --offload-compress --offload-device-only --gpu-bundle-output \
-// RUN:   -o %T/a.bc \
+// RUN:   -o %t.bc \
 // RUN: 2>&1 | FileCheck %s
 
 // CHECK: clang-offload-bundler{{.*}} -type=bc
@@ -23,7 +23,7 @@
 // RUN: %clang --hip-link -### -v --target=x86_64-linux-gnu \
 // RUN:   --offload-arch=gfx1100 --offload-arch=gfx1101 \
 // RUN:   -fgpu-rdc -nogpulib \
-// RUN:   %T/a.bc --offload-device-only \
+// RUN:   %t.bc --offload-device-only \
 // RUN: 2>&1 | FileCheck -check-prefix=UNBUNDLE %s
 
 // UNBUNDLE: clang-offload-bundler{{.*}} "-type=bc"

diff  --git a/clang/test/Driver/hip-offload-compress-zstd.hip 
b/clang/test/Driver/hip-offload-compress-zstd.hip
index 688c2c85329c1..3680ae47974a6 100644
--- a/clang/test/Driver/hip-offload-compress-zstd.hip
+++ b/clang/test/Driver/hip-offload-compress-zstd.hip
@@ -4,13 +4,13 @@
 
 // Test compress bundled bitcode.
 
-// RUN: rm -rf %T/a.bc
+// RUN: rm -rf %t.bc
 // RUN: %clang -c -v --target=x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx1100 --offload-arch=gfx1101 \
 // RUN:   -fgpu-rdc -nogpuinc -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN:   --offload-compress --offload-device-only --gpu-bundle-output \
-// RUN:   -o %T/a.bc \
+// RUN:   -o %t.bc \
 // RUN: 2>&1 | FileCheck %s
 
 // CHECK: clang-offload-bundler{{.*}} -type=bc
@@ -23,7 +23,7 @@
 // RUN: %clang --hip-link -### -v --target=x86_64-linux-gnu \
 // RUN:   --offload-arch=gfx1100 --offload-arch=gfx1101 \
 // RUN:   -fgpu-rdc -nogpulib \
-// RUN:   %T/a.bc --offload-device-only \
+// RUN:   %t.bc --offload-device-only \
 // RUN: 2>&1 | FileCheck -check-prefix=UNBUNDLE %s
 
 // UNBUNDLE: clang-offload-bundler{{.*}} "-type=bc"



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


[clang] [Cygwin] Cygwin basic support (PR #74868)

2023-12-08 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 49b27b150b97c190dedf8b45bf991c4b811ed953 
680b2b48925d52c006eee5f26b1173856dfcf376 -- clang/lib/Basic/Targets/X86.h 
clang/lib/Driver/ToolChains/Clang.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8b38c9e386..df062ccc90 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,9 +6656,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX()
-  && !RawTriple.isWindowsGNUEnvironment()
-  && !RawTriple.isWindowsMSVCEnvironment() &&
+  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
+  !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

``




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


<    1   2   3   4   >