[PATCH] D135026: [clang-format] Handle C# interpolated verbatim string prefix @$

2022-10-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135026

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


[PATCH] D135027: [Clang][MinGW][cygwin] Fix __declspec with -fdeclspec enabled

2022-10-03 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd90633a74bef: [Clang][MinGW][cygwin] Fix __declspec with 
-fdeclspec enabled (authored by alvinhochun, committed by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135027

Files:
  clang/lib/Basic/Targets.cpp
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1368,9 +1368,12 @@
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-sie-ps5 < 
/dev/null | FileCheck --match-full-lines --check-prefix PS4-CXX %s
 // PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL
 //
-// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix X86-64-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
-// X86-64-DECLSPEC: #define __declspec{{.*}}
+// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix X86-64-DECLSPEC-GNU %s
+// X86-64-DECLSPEC-GNU: #define __declspec{{.*}} __attribute__{{.*}}
+//
+// RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fdeclspec -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC-MS %s
+// X86-64-DECLSPEC-MS: #define __declspec{{.*}} __declspec{{.*}}
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null 
| FileCheck -match-full-lines -check-prefix SPARCV9 %s
 // SPARCV9:#define __BIGGEST_ALIGNMENT__ 16
Index: clang/test/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -587,11 +587,15 @@
 // I386-NETBSD:#define __i386__ 1
 // I386-NETBSD:#define i386 1
 
-// RUN: %clang_cc1 -E -dM -triple=i686-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-pc-mingw32 < /dev/null 
| FileCheck -match-full-lines -check-prefix I386-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -triple=i686-unknown-cygwin < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-unknown-cygwin < 
/dev/null | FileCheck -match-full-lines -check-prefix I386-DECLSPEC %s
-// I386-DECLSPEC: #define __declspec{{.*}}
+// RUN: %clang_cc1 -E -dM -triple=i686-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC-GNU %s
+// RUN: %clang_cc1 -E -dM -triple=i686-unknown-cygwin < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC-GNU %s
+// I386-DECLSPEC-GNU: #define __declspec{{.*}} __attribute__{{.*}}
+
+// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-pc-mingw32 < /dev/null 
| FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fdeclspec -triple=i686-pc-mingw32 < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-unknown-cygwin < 
/dev/null | FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fdeclspec -triple=i686-unknown-cygwin < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// I386-DECLSPEC-MS: #define __declspec{{.*}} __declspec{{.*}}
 
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=x86_64-none-none < /dev/null | FileCheck -match-full-lines 
-check-prefix X86_64 %s
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -81,9 +81,10 @@
 
 void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
   // Mingw and cygwin define __declspec(a) to __attribute__((a)).  Clang
-  // supports __declspec natively under -fms-extensions, but we define a no-op
-  // __declspec macro anyway for pre-processor compatibility.
-  if (Opts.MicrosoftExt)
+  // supports __declspec natively under -fdeclspec (also enabled with
+  // -fms-extensions), but we define a no-op __declspec macro anyway for
+  // pre-processor compatibility.
+  if (Opts.DeclSpecKeyword)
 Builder.defineMacro("__declspec", "__declspec");
   else
 Builder.defineMacro("__declspec(a)", "__attribute__((a))");


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1368,9 +1368,12 @@
 // RU

[clang] d90633a - [Clang][MinGW][cygwin] Fix __declspec with -fdeclspec enabled

2022-10-03 Thread Martin Storsjö via cfe-commits

Author: Alvin Wong
Date: 2022-10-03T10:58:45+03:00
New Revision: d90633a74befa257f8617c4784d74a27fd287720

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

LOG: [Clang][MinGW][cygwin] Fix __declspec with -fdeclspec enabled

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

Reviewed By: rnk

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

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/test/Preprocessor/init-x86.c
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 38244800219ac..8400774db93da 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -81,9 +81,10 @@ void defineCPUMacros(MacroBuilder &Builder, StringRef 
CPUName, bool Tuning) {
 
 void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
   // Mingw and cygwin define __declspec(a) to __attribute__((a)).  Clang
-  // supports __declspec natively under -fms-extensions, but we define a no-op
-  // __declspec macro anyway for pre-processor compatibility.
-  if (Opts.MicrosoftExt)
+  // supports __declspec natively under -fdeclspec (also enabled with
+  // -fms-extensions), but we define a no-op __declspec macro anyway for
+  // pre-processor compatibility.
+  if (Opts.DeclSpecKeyword)
 Builder.defineMacro("__declspec", "__declspec");
   else
 Builder.defineMacro("__declspec(a)", "__attribute__((a))");

diff  --git a/clang/test/Preprocessor/init-x86.c 
b/clang/test/Preprocessor/init-x86.c
index 9c4e328bdf79d..eb7759c0da119 100644
--- a/clang/test/Preprocessor/init-x86.c
+++ b/clang/test/Preprocessor/init-x86.c
@@ -587,11 +587,15 @@
 // I386-NETBSD:#define __i386__ 1
 // I386-NETBSD:#define i386 1
 
-// RUN: %clang_cc1 -E -dM -triple=i686-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-pc-mingw32 < /dev/null 
| FileCheck -match-full-lines -check-prefix I386-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -triple=i686-unknown-cygwin < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-unknown-cygwin < 
/dev/null | FileCheck -match-full-lines -check-prefix I386-DECLSPEC %s
-// I386-DECLSPEC: #define __declspec{{.*}}
+// RUN: %clang_cc1 -E -dM -triple=i686-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC-GNU %s
+// RUN: %clang_cc1 -E -dM -triple=i686-unknown-cygwin < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-DECLSPEC-GNU %s
+// I386-DECLSPEC-GNU: #define __declspec{{.*}} __attribute__{{.*}}
+
+// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-pc-mingw32 < /dev/null 
| FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fdeclspec -triple=i686-pc-mingw32 < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fms-extensions -triple=i686-unknown-cygwin < 
/dev/null | FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fdeclspec -triple=i686-unknown-cygwin < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-DECLSPEC-MS %s
+// I386-DECLSPEC-MS: #define __declspec{{.*}} __declspec{{.*}}
 
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=x86_64-none-none < /dev/null | FileCheck -match-full-lines 
-check-prefix X86_64 %s

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 8e3c87e7675f3..ee6976b625b97 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1368,9 +1368,12 @@
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-sie-ps5 < 
/dev/null | FileCheck --match-full-lines --check-prefix PS4-CXX %s
 // PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL
 //
-// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix X86-64-DECLSPEC %s
-// RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s
-// X86-64-DECLSPEC: #define __declspec{{.*}}
+// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck 
-match-full-lines -check-prefix X86-64-DECLSPEC-GNU %s
+// X86-64-DECLSPEC-GNU: #define __declspec{{.*}} __attribute__{{.*}}
+//
+// RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC-MS %s
+// RUN: %clang_cc1 -E -dM -fdeclspec -triple=x86_64-unknown-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC-MS %s
+// X86-64-DECLSPEC-MS: #define __declspec{{.*}} __declspec{{.*}

[PATCH] D135062: [clang-tools-extra] [clangd] Respect llvm_shlib_dir in tests

2022-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: sammccall, kadircet, hokein, ilya-biryukov, kbobyrev, 
MaskRay, thesamesam.
Herald added subscribers: StephenFan, arphaman.
Herald added a project: All.
mgorny requested review of this revision.
Herald added a project: clang-tools-extra.

Add llvm_shlib_dir to variables used in clangd test suite, consistently
to how it is used in the test suites of clang, clang-tools-extra
and a few other components.  This is necessary to ensure that
the correct shared libraries are used when building clang standalone --
otherwise, use_clang() sets LD_LIBRARY_PATH to the directory containing
the earlier system installation of clang rather than the just-built
library.

(I'd also like to backport this to 15.x)


https://reviews.llvm.org/D135062

Files:
  clang-tools-extra/clangd/test/lit.site.cfg.py.in


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -10,6 +10,7 @@
 config.clang_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@")
 config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
 config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
+config.llvm_shlib_dir = "@SHLIBDIR@"
 
 config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."


Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -10,6 +10,7 @@
 config.clang_tools_dir = lit_config.substitute("@CURRENT_TOOLS_DIR@")
 config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
 config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
+config.llvm_shlib_dir = "@SHLIBDIR@"
 
 config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134788: [ARM64EC][clang-cl] Add /arm64EC flag

2022-10-03 Thread chenglin.bi via Phabricator via cfe-commits
bcl5980 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:1384
+  TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec) {
+if (UArgs->hasArg(options::OPT__SLASH_arm64EC)) {
+  getDiags().Report(clang::diag::warn_target_override_arm64ec)

DavidSpickett wrote:
> DavidSpickett wrote:
> > This would read better to me if you put them all in one and put the most 
> > important check first like:
> > ```
> > if ( UArgs->hasArg(options::OPT__SLASH_arm64EC) &&
> > ( (TC.getTriple().getArch() != llvm::Triple::aarch64 ||
> >   TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec)) 
> > {
> > ```
> This is good but I didn't emphasise one bit. Putting the arm64ec option check 
> first saves reading the rest if the reader knows it's not relevant.
I believe the condition `UArgs->hasArg(options::OPT__SLASH_arm64EC)` should be 
much heavier than 
`(TC.getTriple().getArch() != llvm::Triple::aarch64 || 
TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec)`.
So I put the Arch and SubArch check first here. I don't understand why we 
should put the hasArg check first.


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

https://reviews.llvm.org/D134788

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


[PATCH] D135025: [clang][Interp] Support base class constructors

2022-10-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 464618.

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

https://reviews.llvm.org/D135025

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -1,9 +1,6 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -verify=ref %s
 
-// ref-no-diagnostics
-// expected-no-diagnostics
-
 struct BoolPair {
   bool first;
   bool second;
@@ -157,3 +154,24 @@
 static_assert(LT2.v[0].second == false, "");
 static_assert(LT2.v[2].first == true, "");
 static_assert(LT2.v[2].second == false, "");
+
+class Base {
+public:
+  int i;
+  constexpr Base() : i(10) {}
+  constexpr Base(int i) : i(i) {}
+};
+
+class A : public Base {
+public:
+  constexpr A() : Base(100) {}
+  constexpr A(int a) : Base(a) {}
+};
+constexpr A a{};
+static_assert(a.i == 100, "");
+constexpr A a2{12};
+static_assert(a2.i == 12, "");
+static_assert(a2.i == 200, ""); // ref-error {{static assertion failed}} \
+// ref-note {{evaluates to '12 == 200'}} \
+// expected-error {{static assertion failed}} \
+// expected-note {{evaluates to '12 == 200'}}
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -100,31 +100,45 @@
 const Record *R = this->getRecord(RD);
 
 for (const auto *Init : Ctor->inits()) {
-  const FieldDecl *Member = Init->getMember();
   const Expr *InitExpr = Init->getInit();
-  const Record::Field *F = R->getField(Member);
-
-  if (Optional T = this->classify(InitExpr->getType())) {
-if (!this->emitThis(InitExpr))
-  return false;
-
-if (!this->visit(InitExpr))
-  return false;
-
-if (!this->emitInitField(*T, F->Offset, InitExpr))
+  if (const FieldDecl *Member = Init->getMember()) {
+const Record::Field *F = R->getField(Member);
+
+if (Optional T = this->classify(InitExpr->getType())) {
+  if (!this->emitThis(InitExpr))
+return false;
+
+  if (!this->visit(InitExpr))
+return false;
+
+  if (!this->emitInitField(*T, F->Offset, InitExpr))
+return false;
+} else {
+  // Non-primitive case. Get a pointer to the field-to-initialize
+  // on the stack and call visitInitialzer() for it.
+  if (!this->emitThis(InitExpr))
+return false;
+
+  if (!this->emitGetPtrField(F->Offset, InitExpr))
+return false;
+
+  if (!this->visitInitializer(InitExpr))
+return false;
+
+  if (!this->emitPopPtr(InitExpr))
+return false;
+}
+  } else if (const Type *Base = Init->getBaseClass()) {
+// Base class initializer.
+// Get This Base and call initializer on it.
+auto *BaseDecl = Base->getAsCXXRecordDecl();
+assert(F);
+const Record::Base *B = R->getBase(BaseDecl);
+assert(B);
+if (!this->emitGetPtrThisBase(B->Offset, InitExpr))
   return false;
-  } else {
-// Non-primitive case. Get a pointer to the field-to-initialize
-// on the stack and call visitInitialzer() for it.
-if (!this->emitThis(InitExpr))
-  return false;
-
-if (!this->emitGetPtrField(F->Offset, InitExpr))
-  return false;
-
 if (!this->visitInitializer(InitExpr))
   return false;
-
 if (!this->emitPopPtr(InitExpr))
   return false;
   }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -107,6 +107,20 @@
 });
   }
 
+  case CK_UncheckedDerivedToBase: {
+if (!this->visit(SubExpr))
+  return false;
+const CXXRecordDecl *FromDecl = SubExpr->getType()->getAsCXXRecordDecl();
+assert(FromDecl);
+const CXXRecordDecl *ToDecl = CE->getType()->getAsCXXRecordDecl();
+assert(ToDecl);
+const Record *R = getRecord(FromDecl);
+const Record::Base *ToBase = R->getBase(ToDecl);
+assert(ToBase);
+
+return this->emitGetPtrBase(ToBase->Offset, CE);
+  }
+
   case CK_ArrayToPointerDecay:
   case CK_AtomicToNonAtomic:
   case CK_ConstructorConversion:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125944: Template instantiation error recovery

2022-10-03 Thread Purva Chaudhari via Phabricator via cfe-commits
Purva-Chaudhari updated this revision to Diff 464623.
Purva-Chaudhari added a comment.

fix test and clang format


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

https://reviews.llvm.org/D125944

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/test/Interpreter/template-recovery.cpp


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9719,6 +9719,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S) : S(S) {}
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };  
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -150,6 +150,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, 
/*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);



Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,17 @@
+// clang-format off
+// RUN: clang-repl "template T f() { return T(); };" \
+// RUN: "auto ptu2 = f(); err;" "auto ptu2 = f();" 
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+
+template T f() { return T(); };
+auto ptu2 = f();
+
+%quit


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9719,6 +9719,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S) : S(S) {}
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };  
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -150,6 +150,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, /*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);



Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,17 @@
+// clang-format off
+// RUN: clang-repl "template T f() { return T(); };" \
+// RUN: "auto ptu2 = f(); err;" "auto ptu2 = f();" 
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+
+template T f() { return T(); };
+auto ptu2 = f();
+
+%quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125944: Template instantiation error recovery

2022-10-03 Thread Purva Chaudhari via Phabricator via cfe-commits
Purva-Chaudhari updated this revision to Diff 464628.
Purva-Chaudhari added a comment.

remove white space


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

https://reviews.llvm.org/D125944

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/test/Interpreter/template-recovery.cpp


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9719,6 +9719,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S) : S(S) {}
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };  
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -150,6 +150,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, 
/*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 


Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,17 @@
+// clang-format off
+// RUN: clang-repl "template T f() { return T(); };" \
+// RUN: "auto ptu2 = f(); err;" "auto ptu2 = f();"
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+
+template T f() { return T(); };
+auto ptu2 = f();
+
+%quit


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9719,6 +9719,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S) : S(S) {}
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };  
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -150,6 +150,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, /*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);
 


Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,17 @@
+// clang-format off
+// RUN: clang-repl "template T f() { return T(); };" \
+// RUN: "auto ptu2 = f(); err;" "auto ptu2 = f();"
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+
+template T f() { return T(); };
+auto ptu2 = f();
+
+%quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134788: [ARM64EC][clang-cl] Add /arm64EC flag

2022-10-03 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

This looks fine as is, all comments addressed as far as I can see.




Comment at: clang/lib/Driver/Driver.cpp:1384
+  TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec) {
+if (UArgs->hasArg(options::OPT__SLASH_arm64EC)) {
+  getDiags().Report(clang::diag::warn_target_override_arm64ec)

bcl5980 wrote:
> DavidSpickett wrote:
> > DavidSpickett wrote:
> > > This would read better to me if you put them all in one and put the most 
> > > important check first like:
> > > ```
> > > if ( UArgs->hasArg(options::OPT__SLASH_arm64EC) &&
> > > ( (TC.getTriple().getArch() != llvm::Triple::aarch64 ||
> > >   TC.getTriple().getSubArch() != 
> > > llvm::Triple::AArch64SubArch_arm64ec)) {
> > > ```
> > This is good but I didn't emphasise one bit. Putting the arm64ec option 
> > check first saves reading the rest if the reader knows it's not relevant.
> I believe the condition `UArgs->hasArg(options::OPT__SLASH_arm64EC)` should 
> be much heavier than 
> `(TC.getTriple().getArch() != llvm::Triple::aarch64 || 
> TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec)`.
> So I put the Arch and SubArch check first here. I don't understand why we 
> should put the hasArg check first.
If the cost of the check is higher then this is fine keep it as is.

The reason that I personally would reorder them (if costs were equal) is this.

Imagine this didn't have 3 conditions it had 100.
```
if ((A or B or C or D or E...
 
) && some_option_used)
```

Why did I, the reader, have to parse 99 seemingly random conditions (which have 
to live in my short term memory) only to find that oh, this is all predicated 
on that one option being passed. If I don't actually care about that one 
option, I just wasted my time.

And ok, the average if doesn't have 100 conditions but if you keep this in mind 
even for smaller checks it adds up over time.

Code is going to be read more than it is written.

This applies to early returns too. Imagine I care about the !=10 case:
```
void foo(int i) {
  if (i == 10) {
// 500 lines of code you don't care about 50% of the time
  } else {
// what you were actually looking for
return;
  }
```

That situation does happen a lot, and the same principle can be applied.

```
void foo(int i) {
  if (i != 10)
 return;

  // 500 lines of code you can read if you actually need to
}
```


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

https://reviews.llvm.org/D134788

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


[PATCH] D134454: [Driver][Distro] Fix ArchLinux sysroot detection

2022-10-03 Thread Adrian Ratiu via Phabricator via cfe-commits
10ne1 added a comment.

@MaskRay and @nickdesaulniers Can you please work together to reach a consensus 
on what is the best path forward? I am ok either way, just need to know what 
the next steps are. :) Thank you.


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

https://reviews.llvm.org/D134454

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


[PATCH] D133119: [clang-tidy] Add checker 'bugprone-suspicious-realloc-usage'.

2022-10-03 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

In D133119#3827432 , @balazske wrote:

> I added a simple detection of create a copy of `p` before `p = realloc(p, 
> ...)`. This can remove the warning at very obvious cases when a copy of `p` 
> is created (but even if the copy is made inside an `if` branch for example).

Okay, I am comfortable with this update, even though the recognition of the 
assignment cannot be fully precise. So, still looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133119

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


[PATCH] D133578: [OpenMP][OMPIRBuilder] Add generation of SIMD align assumptions to OMPIRBuilder

2022-10-03 Thread Dominik Adamski via Phabricator via cfe-commits
domada updated this revision to Diff 464640.
domada marked an inline comment as done.
domada retitled this revision from "[OpenMP] Add generation of SIMD align 
assumptions to  OMPIRBuilder" to "[OpenMP][OMPIRBuilder] Add generation of SIMD 
align assumptions to  OMPIRBuilder".
domada added a comment.
Herald added a reviewer: nicolasvasilache.
Herald added a subscriber: zero9178.

Patch rebased.


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

https://reviews.llvm.org/D133578

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -996,7 +996,8 @@
   if (llvm::Optional safelenVar = loop.getSafelen())
 safelen = builder.getInt64(safelenVar.value());
 
-  ompBuilder->applySimd(loopInfo,
+  llvm::DenseMap alignedVars;
+  ompBuilder->applySimd(loopInfo, alignedVars,
 loop.getIfExpr()
 ? moduleTranslation.lookupValue(loop.getIfExpr())
 : nullptr,
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1767,11 +1767,59 @@
 
 TEST_F(OpenMPIRBuilderTest, ApplySimd) {
   OpenMPIRBuilder OMPBuilder(*M);
+  DenseMap AlignedVars;
+  CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
+
+  // Simd-ize the loop.
+  OMPBuilder.applySimd(CLI, AlignedVars,
+   /* IfCond */ nullptr, /* Simdlen */ nullptr,
+   /* Safelen */ nullptr);
+
+  OMPBuilder.finalize();
+  EXPECT_FALSE(verifyModule(*M, &errs()));
+
+  PassBuilder PB;
+  FunctionAnalysisManager FAM;
+  PB.registerFunctionAnalyses(FAM);
+  LoopInfo &LI = FAM.getResult(*F);
+
+  const std::vector &TopLvl = LI.getTopLevelLoops();
+  EXPECT_EQ(TopLvl.size(), 1u);
+
+  Loop *L = TopLvl.front();
+  EXPECT_TRUE(findStringMetadataForLoop(L, "llvm.loop.parallel_accesses"));
+  EXPECT_TRUE(getBooleanLoopAttribute(L, "llvm.loop.vectorize.enable"));
+
+  // Check for llvm.access.group metadata attached to the printf
+  // function in the loop body.
+  BasicBlock *LoopBody = CLI->getBody();
+  EXPECT_TRUE(any_of(*LoopBody, [](Instruction &I) {
+return I.getMetadata("llvm.access.group") != nullptr;
+  }));
+}
+
+TEST_F(OpenMPIRBuilderTest, ApplySimdiDefaultAligned) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  IRBuilder<> Builder(BB);
+  AllocaInst *Alloc1 =
+  Builder.CreateAlloca(Builder.getInt8PtrTy(), Builder.getInt64(1));
+  AllocaInst *Alloc2 = Builder.CreateAlloca(
+  ArrayType::get(Builder.getInt32Ty(), 10), Builder.getInt64(1));
+  DenseMap AlignedVars;
+  auto Int8Ty = Builder.getInt8Ty();
+  Instruction *MallocInstr = CallInst::CreateMalloc(
+  Alloc2, Builder.getInt64Ty(), Int8Ty, ConstantExpr::getSizeOf(Int8Ty),
+  Builder.getInt64(400), nullptr, "");
+  Builder.CreateStore(MallocInstr, Alloc1);
+
+  AlignedVars.insert({Alloc1, nullptr});
+  AlignedVars.insert({Alloc2, nullptr});
 
   CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
 
   // Simd-ize the loop.
-  OMPBuilder.applySimd(CLI, /* IfCond */ nullptr, /* Simdlen */ nullptr,
+  OMPBuilder.applySimd(CLI, AlignedVars,
+   /* IfCond */ nullptr, /* Simdlen */ nullptr,
/* Safelen */ nullptr);
 
   OMPBuilder.finalize();
@@ -1795,15 +1843,92 @@
   EXPECT_TRUE(any_of(*LoopBody, [](Instruction &I) {
 return I.getMetadata("llvm.access.group") != nullptr;
   }));
+
+  // Check if number of assumption instructions is equal to number of aligned
+  // variables
+  BasicBlock *LoopPreheader = CLI->getPreheader();
+  size_t NumAssummptionCallsInPreheader = count_if(
+  *LoopPreheader, [](Instruction &I) { return isa(I); });
+  EXPECT_EQ(NumAssummptionCallsInPreheader, AlignedVars.size());
 }
 
-TEST_F(OpenMPIRBuilderTest, ApplySimdlen) {
+TEST_F(OpenMPIRBuilderTest, ApplySimdiCustomAligned) {
   OpenMPIRBuilder OMPBuilder(*M);
+  IRBuilder<> Builder(BB);
+  const int AlignmentValue = 32;
+  AllocaInst *Alloc1 =
+  Builder.CreateAlloca(Builder.getInt8PtrTy(), Builder.getInt64(1));
+  AllocaInst *Alloc2 = Builder.CreateAlloca(
+  ArrayType::get(Builder.getInt32Ty(), 10), Builder.getInt64(1));
+  DenseMap AlignedVars;
+  auto Int8Ty = Builder.getInt8Ty();
+  Instruction *MallocInstr = CallInst::CreateMalloc(
+  Alloc2, Builder.getInt64Ty(), Int8Ty, ConstantExpr::getSizeOf(Int8Ty),
+  Builder.getInt64(400), nullpt

[PATCH] D134046: [OpenMP][OMPIRBuilder] Add support for order(concurrent) to OMPIRBuilder for SIMD directive

2022-10-03 Thread Dominik Adamski via Phabricator via cfe-commits
domada updated this revision to Diff 464648.
domada retitled this revision from "[OpenMP] Add support for order(concurrent) 
to OMPIRBuilder for SIMD directive" to "[OpenMP][OMPIRBuilder] Add support for 
order(concurrent) to OMPIRBuilder for SIMD directive".
domada added a comment.
Herald added a subscriber: zero9178.

Patch rebased


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

https://reviews.llvm.org/D134046

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -996,11 +996,12 @@
   if (llvm::Optional safelenVar = loop.getSafelen())
 safelen = builder.getInt64(safelenVar.value());
 
-  ompBuilder->applySimd(loopInfo,
-loop.getIfExpr()
-? moduleTranslation.lookupValue(loop.getIfExpr())
-: nullptr,
-simdlen, safelen);
+  ompBuilder->applySimd(
+  loopInfo,
+  loop.getIfExpr() ? moduleTranslation.lookupValue(loop.getIfExpr())
+   : nullptr,
+  llvm::OpenMPIRBuilder::OMPOrderClauseValue::NotSpecified, simdlen,
+  safelen);
 
   builder.restoreIP(afterIP);
   return success();
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1771,7 +1771,9 @@
   CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
 
   // Simd-ize the loop.
-  OMPBuilder.applySimd(CLI, /* IfCond */ nullptr, /* Simdlen */ nullptr,
+  OMPBuilder.applySimd(CLI, /* IfCond */ nullptr,
+   OpenMPIRBuilder::OMPOrderClauseValue::NotSpecified,
+   /* Simdlen */ nullptr,
/* Safelen */ nullptr);
 
   OMPBuilder.finalize();
@@ -1804,6 +1806,7 @@
 
   // Simd-ize the loop.
   OMPBuilder.applySimd(CLI, /* IfCond */ nullptr,
+   OpenMPIRBuilder::OMPOrderClauseValue::NotSpecified,
ConstantInt::get(Type::getInt32Ty(Ctx), 3),
/* Safelen */ nullptr);
 
@@ -1831,6 +1834,43 @@
   }));
 }
 
+TEST_F(OpenMPIRBuilderTest, ApplySafelenOrderConcurrent) {
+  OpenMPIRBuilder OMPBuilder(*M);
+
+  CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
+
+  // Simd-ize the loop.
+  OMPBuilder.applySimd(CLI, /* IfCond */ nullptr,
+   OpenMPIRBuilder::OMPOrderClauseValue::Concurrent,
+   /* Simdlen */ nullptr,
+   ConstantInt::get(Type::getInt32Ty(Ctx), 3));
+
+  OMPBuilder.finalize();
+  EXPECT_FALSE(verifyModule(*M, &errs()));
+
+  PassBuilder PB;
+  FunctionAnalysisManager FAM;
+  PB.registerFunctionAnalyses(FAM);
+  LoopInfo &LI = FAM.getResult(*F);
+
+  const std::vector &TopLvl = LI.getTopLevelLoops();
+  EXPECT_EQ(TopLvl.size(), 1u);
+
+  Loop *L = TopLvl.front();
+  // Parallel metadata shoudl be attached because of presence of
+  // the order(concurrent) OpenMP clause
+  EXPECT_TRUE(findStringMetadataForLoop(L, "llvm.loop.parallel_accesses"));
+  EXPECT_TRUE(getBooleanLoopAttribute(L, "llvm.loop.vectorize.enable"));
+  EXPECT_EQ(getIntLoopAttribute(L, "llvm.loop.vectorize.width"), 3);
+
+  // Check for llvm.access.group metadata attached to the printf
+  // function in the loop body.
+  BasicBlock *LoopBody = CLI->getBody();
+  EXPECT_TRUE(any_of(*LoopBody, [](Instruction &I) {
+return I.getMetadata("llvm.access.group") != nullptr;
+  }));
+}
+
 TEST_F(OpenMPIRBuilderTest, ApplySafelen) {
   OpenMPIRBuilder OMPBuilder(*M);
 
@@ -1838,6 +1878,7 @@
 
   // Simd-ize the loop.
   OMPBuilder.applySimd(CLI, /* IfCond */ nullptr,
+   OpenMPIRBuilder::OMPOrderClauseValue::NotSpecified,
/* Simdlen */ nullptr,
ConstantInt::get(Type::getInt32Ty(Ctx), 3));
 
@@ -1872,6 +1913,7 @@
 
   // Simd-ize the loop.
   OMPBuilder.applySimd(CLI, /* IfCond */ nullptr,
+   OpenMPIRBuilder::OMPOrderClauseValue::NotSpecified,
ConstantInt::get(Type::getInt32Ty(Ctx), 2),
ConstantInt::get(Type::getInt32Ty(Ctx), 3));
 
@@ -1916,7 +1958,9 @@
   CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
 
   // Simd-ize the loop with if condition
-  OMPBuilder.applySimd(CLI, IfCmp, ConstantInt::get(Type::getInt32Ty(Ctx), 3),
+  OMPBuilder.appl

[PATCH] D125944: Template instantiation error recovery

2022-10-03 Thread Purva Chaudhari via Phabricator via cfe-commits
Purva-Chaudhari updated this revision to Diff 464649.
Purva-Chaudhari added a comment.

check


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

https://reviews.llvm.org/D125944

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/test/Interpreter/template-recovery.cpp


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9719,6 +9719,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S) : S(S) {}
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };  
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -150,6 +150,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, 
/*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);



Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,17 @@
+// clang-format off
+// RUN: clang-repl "template T f() { return T(); };" \
+// RUN: "auto ptu2 = f(); err;" "auto ptu2 = f();"
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+
+template T f() { return T(); };
+auto ptu2 = f();
+
+%quit


Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9719,6 +9719,19 @@
 SavedPendingLocalImplicitInstantiations;
   };
 
+  class PerformPendingInstantiationsRAII {
+  public:
+PerformPendingInstantiationsRAII(Sema &S) : S(S) {}
+
+~PerformPendingInstantiationsRAII() {
+  S.PerformPendingInstantiations();
+  assert(S.PendingInstantiations.empty() &&
+ "there shouldn't be any pending instantiations");
+}
+  private:
+Sema &S;
+  };  
+
   /// A helper class for building up ExtParameterInfos.
   class ExtParameterInfoBuilder {
 SmallVector Infos;
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -150,6 +150,7 @@
   llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(&S);
   Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, /*Enabled=*/true);
   Sema::LocalEagerInstantiationScope LocalInstantiations(S);
+  Sema::PerformPendingInstantiationsRAII PerformPendingInstantiations(S);



Index: clang/test/Interpreter/template-recovery.cpp
===
--- /dev/null
+++ clang/test/Interpreter/template-recovery.cpp
@@ -0,0 +1,17 @@
+// clang-format off
+// RUN: clang-repl "template T f() { return T(); };" \
+// RUN: "auto ptu2 = f(); err;" "auto ptu2 = f();"
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+int i = 10;
+auto r1 = printf("i = %d\n", i);
+// CHECK: i = 10
+
+template T f() { return T(); };
+auto ptu2 = f();
+
+%quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

2022-10-03 Thread Liming Liu via Phabricator via cfe-commits
lime added a comment.

I'm wondering whether classes like `TemplateArgumentLoc` could refer to the 
template head of the `TemplateArgument`, so the comparison of parameter 
mappings could be modified, and then the refered variable could be accepted.




Comment at: clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp:43
+
+S4 s41;
+S4 s42;

This variable was rejected after rebasing the patch on D126907. The reason is 
that the atomic constraint generated from `S4` is not considered to subsume the 
one generated from `X`. And the difference between two atomic constraints is 
mainly the template arguments. If the concept `C` was like `template  
concept C = true`, this variable would be accepted.

A reasonable behavior might be either accepting the variable regardless of 
whether the constraint expression depends on template arguments, or rejecting 
the variable as the template heads of `S4` and `X` are not equivalent. Both GCC 
and MSVC accept the variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134128

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


[PATCH] D134941: [analyzer][NFC] Add tests for D132236

2022-10-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thank you! Increasing coverage in tests is always great.




Comment at: clang/test/Analysis/NewDeleteLeaks.cpp:196
+
+namespace symbol_reaper_lifetime {
+struct Nested {

Could you please add some explanation for the test case? Thinking of the 
related patch, something like this could be a good explanation:
```
Check that memory leak is reported against a symbol if the last place it's 
mentioned is a base region of a lazy compound value, as the program cannot 
possibly free that memory. 
```
And below, we should mention that `p` is that symbol and `p->data` is the lazy 
compound value.



Comment at: clang/test/Analysis/symbol-reaper-lambda.cpp:8
+
+int strange(Dummy param) {
+  Dummy local_pre_lambda;

Maybe it is just me, but this test case is a bit hard to follow. I guess it is 
a result of creduce. But still, could you please elaborate the following:


  # What is the lazy compound value? (My weak guess is `param`)
  # What is the base region?
  # Which symbol is being reaped and where?





Comment at: clang/test/Analysis/symbol-reaper-lambda.cpp:14
+escape(param, local_pre_lambda);
+return ref_captured; // no-warning: The value is not garbage.
+  };

Did D132236 produce an FP warning for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134941

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


[PATCH] D134941: [analyzer][NFC] Add tests for D132236

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 464657.
tomasz-kaminski-sonarsource added a comment.

Added requested comment for the example.
Included additional false-positive test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134941

Files:
  clang/test/Analysis/NewDeleteLeaks.cpp
  clang/test/Analysis/symbol-reaper-lambda.cpp
  clang/test/Analysis/trivial-copy-struct.cpp

Index: clang/test/Analysis/trivial-copy-struct.cpp
===
--- clang/test/Analysis/trivial-copy-struct.cpp
+++ clang/test/Analysis/trivial-copy-struct.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
 
 template  void clang_analyzer_dump(T);
+template  void clang_analyzer_value(T);
 void clang_analyzer_warnIfReached();
 
 struct Node { int* ptr; };
@@ -34,3 +35,25 @@
   (void)(n1->ptr);
   (void)(n2->ptr);
 }
+
+struct List {
+  List* next;
+  int value;
+  int padding;
+};
+
+void deadCode(List orig) {
+  List c = orig;
+  clang_analyzer_dump(c.value);
+  // expected-warning-re@-1 {{reg_${{[0-9]+
+  if (c.value == 42)
+return;
+  clang_analyzer_value(c.value);
+  // expected-warning@-1 {{32s:{ [-2147483648, 2147483647] }}}
+  // The symbol was garbage collected too early, hence we lose the constraints.
+  if (c.value != 42)
+return;
+
+  // Dead code should be unreachable
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
Index: clang/test/Analysis/symbol-reaper-lambda.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-reaper-lambda.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+template 
+void escape(Ts&...);
+struct Dummy {};
+
+int strange(Dummy param) {
+  Dummy local_pre_lambda;
+  int ref_captured = 0;
+
+  // LambdaExpr is modeled as lazyCompoundVal of tempRegion, that contains
+  // all captures. In this instance, this region contains a pointer/reference
+  // to ref_captured variable.
+  auto fn = [&] {
+escape(param, local_pre_lambda);
+return ref_captured; // no-warning: The value is not garbage.
+  };
+
+  int local_defined_after_lambda; // Unused, but necessary! Important that it's before the call.
+
+  // The ref_captured binding should not be pruned at this point, as it is still
+  // accessed via reference captured in operator() of fn.
+  return fn();
+}
+
Index: clang/test/Analysis/NewDeleteLeaks.cpp
===
--- clang/test/Analysis/NewDeleteLeaks.cpp
+++ clang/test/Analysis/NewDeleteLeaks.cpp
@@ -192,3 +192,29 @@
 // expected-note@-1 {{Potential leak of memory pointed to by 'v'}}
 
 } // namespace refkind_from_unoallocated_to_allocated
+
+// Check that memory leak is reported against a symbol if the last place it's
+// mentioned is a base region of a lazy compound value, as the program cannot
+// possibly free that memory.
+namespace symbol_reaper_lifetime {
+struct Nested {
+  int buf[2];
+};
+struct Wrapping {
+  Nested data;
+};
+
+Nested allocateWrappingAndReturnNested() {
+  // expected-note@+1 {{Memory is allocated}}
+  Wrapping const* p = new Wrapping();
+  // expected-warning@+2 {{Potential leak of memory pointed to by 'p'}}
+  // expected-note@+1{{Potential leak of memory pointed to by 'p'}}
+  return p->data;
+}
+
+void caller() {
+  // expected-note@+1 {{Calling 'allocateWrappingAndReturnNested'}}
+  Nested n = allocateWrappingAndReturnNested();
+  (void)n;
+} // no-warning: No potential memory leak here, because that's been already reported.
+} // namespace symbol_reaper_lifetime
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134941: [analyzer][NFC] Add tests for D132236

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource marked 2 inline comments as done.
tomasz-kaminski-sonarsource added inline comments.



Comment at: clang/test/Analysis/symbol-reaper-lambda.cpp:14
+escape(param, local_pre_lambda);
+return ref_captured; // no-warning: The value is not garbage.
+  };

martong wrote:
> Did D132236 produce an FP warning for this?
Yes, it created false-positive for `ref_capture` load producing initialized 
value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134941

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


[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I like the approach of this patch and I think this is somewhat aligned with 
@NoQ's ideas about

> a list of explicitly-live compound values

and

> "weak region roots" that aren't necessarily live themselves but anything 
> derived from them ... is live

Coupled with the new tests for regression cases in D134941 
, I think this is really good.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:586
+  RegionSetTy LiveRegionRoots;
+  RegionSetTy LazilyCopiedRegionRoots;
 

Could you please incorporate the definition of //lazily copied locations 
(regions)// from the summary to here as a comment?



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:653
+  bool isLazilyCopiedRegion(const MemRegion *region) const;
+  bool isReadableRegion(const MemRegion *region);
+

Could you please incorporate the definition of //readable locations (regions)// 
from the summary to here as a comment?



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2841-2842
   V.getAs()) {
+// TODO: Make regions referred to by `lazyCompoundVals` that are bound to
+// subregions of the `LCS.getRegion()` also lazily copied.
+if (const MemRegion *R = LCS->getRegion())

Just a nit, I wonder if you might have a test case for this (which should fail 
for now).



Comment at: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp:461
+bool SymbolReaper::isLazilyCopiedRegion(const MemRegion *MR) const {
+  // TODO: See comment in isLiveRegion.
+  return LazilyCopiedRegionRoots.count(MR->getBaseRegion());

Just out of curiosity, do you have plans to tackle this todo sometime?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

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


[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 464659.
tomasz-kaminski-sonarsource added a comment.

Included additional tests that corresponds to TODO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/trivial-copy-struct.cpp

Index: clang/test/Analysis/trivial-copy-struct.cpp
===
--- clang/test/Analysis/trivial-copy-struct.cpp
+++ clang/test/Analysis/trivial-copy-struct.cpp
@@ -56,4 +56,47 @@
 
   // Dead code should be unreachable
   clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+};
+
+void ptr1(List* n) {
+  List* n2 = new List(*n); // cctor
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+void ptr2(List* n) {
+  List* n2 = new List(); // ctor
+  *n2 = *n; // assignment
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+struct Wrapper {
+  List head;
+  int count;
+};
+
+void nestedLazyCompoundVal(List* n) {
+  Wrapper* w = 0;
+  {
+ Wrapper lw;
+ lw.head = *n;
+ w = new Wrapper(lw);
+  }
+  if (!n->next) {
+if (w->head.next) {
+  // Unreachable, w->head is a copy of *n, therefore
+  // w->head.next and n->next are equal
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+  }
+  delete w;
 }
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -411,10 +411,14 @@
 }
 
 void SymbolReaper::markLive(const MemRegion *region) {
-  RegionRoots.insert(region->getBaseRegion());
+  LiveRegionRoots.insert(region->getBaseRegion());
   markElementIndicesLive(region);
 }
 
+void SymbolReaper::markLazilyCopied(const clang::ento::MemRegion *region) {
+  LazilyCopiedRegionRoots.insert(region->getBaseRegion());
+}
+
 void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
   for (auto SR = dyn_cast(region); SR;
SR = dyn_cast(SR->getSuperRegion())) {
@@ -437,8 +441,7 @@
   // is not used later in the path, we can diagnose a leak of a value within
   // that field earlier than, say, the variable that contains the field dies.
   MR = MR->getBaseRegion();
-
-  if (RegionRoots.count(MR))
+  if (LiveRegionRoots.count(MR))
 return true;
 
   if (const auto *SR = dyn_cast(MR))
@@ -454,6 +457,15 @@
   return isa(MR);
 }
 
+bool SymbolReaper::isLazilyCopiedRegion(const MemRegion *MR) const {
+  // TODO: See comment in isLiveRegion.
+  return LazilyCopiedRegionRoots.count(MR->getBaseRegion());
+}
+
+bool SymbolReaper::isReadableRegion(const MemRegion *MR) {
+  return isLiveRegion(MR) || isLazilyCopiedRegion(MR);
+}
+
 bool SymbolReaper::isLive(SymbolRef sym) {
   if (TheLiving.count(sym)) {
 markDependentsLive(sym);
@@ -464,7 +476,7 @@
 
   switch (sym->getKind()) {
   case SymExpr::SymbolRegionValueKind:
-KnownLive = isLiveRegion(cast(sym)->getRegion());
+KnownLive = isReadableRegion(cast(sym)->getRegion());
 break;
   case SymExpr::SymbolConjuredKind:
 KnownLive = false;
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2838,6 +2838,10 @@
   // Is it a LazyCompoundVal?  All referenced regions are live as well.
   if (Optional LCS =
   V.getAs()) {
+// TODO: Make regions referred to by `lazyCompoundVals` that are bound to
+// subregions of the `LCS.getRegion()` also lazily copied.
+if (const MemRegion *R = LCS->getRegion())
+  SymReaper.markLazilyCopied(R);
 
 const RegionStoreManager::SValListTy &Vals = RM.getInterestingValues(*LCS);
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -582,7 +582,8 @@
   SymbolMapTy TheLiving;
   SymbolSetTy MetadataInUse;
 
-  RegionSetTy RegionRoots;
+  RegionSetTy LiveRegionRoots;
+  RegionSetTy LazilyCopiedRegionRoots;
 
   const StackFrameContext *LCtx;
   const Stmt *Loc;
@@ -628,8 +629,8 @@
 
   using region_iterator = RegionSetTy::const_iterator;
 
-  region_iterator region_begin() const { return RegionRoots.begin(); }
-  region_iterator region_end() const { return RegionRoots.end(); }
+  region_iterator region_begin() const { return LiveRegionRoots.

[PATCH] D134941: [analyzer][NFC] Add tests for D132236

2022-10-03 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks for the update! LGTM.




Comment at: clang/test/Analysis/trivial-copy-struct.cpp:57
+
+  // Dead code should be unreachable
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134941

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


[PATCH] D134788: [ARM64EC][clang-cl] Add /arm64EC flag

2022-10-03 Thread chenglin.bi via Phabricator via cfe-commits
bcl5980 marked 4 inline comments as done.
bcl5980 added a comment.

Thanks for the detail explaination. I agree that if the cost is the same hasArg 
is better to move to the first.


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

https://reviews.llvm.org/D134788

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


[clang] b0fff3d - [ARM64EC][clang-cl] Add /arm64EC flag

2022-10-03 Thread via cfe-commits

Author: chenglin.bi
Date: 2022-10-03T21:20:51+08:00
New Revision: b0fff3db6ada11e42a28389bb2b0c48181e2f719

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

LOG: [ARM64EC][clang-cl] Add /arm64EC flag

Reviewed By: DavidSpickett

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 282ecdbed4ce..e8a301ee6018 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -655,6 +655,10 @@ def warn_drv_fjmc_for_elf_only : Warning<
   "-fjmc works only for ELF; option ignored">,
   InGroup;
 
+def warn_target_override_arm64ec : Warning<
+  "/arm64EC has been overridden by specified target: %0; option ignored">,
+  InGroup;
+
 def err_drv_target_variant_invalid : Error<
   "unsupported '%0' value '%1'; use 'ios-macabi' instead">;
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f7744a109f9a..fb3bc378a44d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6695,6 +6695,8 @@ def _SLASH_tune : CLCompileJoined<"tune:">,
 def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">,
   HelpText<"Align branches within 32-byte boundaries to mitigate the 
performance impact of the Intel JCC erratum.">,
   Alias;
+def _SLASH_arm64EC : CLFlag<"arm64EC">,
+  HelpText<"Set build target to arm64ec">;
 
 // Non-aliases:
 

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a4bd2ded3c17..be62ce5de4b3 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1256,6 +1256,8 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 T.setVendor(llvm::Triple::PC);
 T.setEnvironment(llvm::Triple::MSVC);
 T.setObjectFormat(llvm::Triple::COFF);
+if (Args.hasArg(options::OPT__SLASH_arm64EC))
+  T.setArch(llvm::Triple::aarch64, llvm::Triple::AArch64SubArch_arm64ec);
 TargetTriple = T.str();
   } else if (IsDXCMode()) {
 // Build TargetTriple from target_profile option for clang-dxc.
@@ -1380,6 +1382,14 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   const ToolChain &TC = getToolChain(
   *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));
 
+  // Report warning when arm64EC option is overridden by specified target
+  if ((TC.getTriple().getArch() != llvm::Triple::aarch64 ||
+   TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec) &&
+  UArgs->hasArg(options::OPT__SLASH_arm64EC)) {
+getDiags().Report(clang::diag::warn_target_override_arm64ec)
+<< TC.getTriple().str();
+  }
+
   // The compilation takes ownership of Args.
   Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs,
ContainsError);

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 3d4a154af59f..6c768fbb7100 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -782,4 +782,8 @@
 // EXTERNAL_W0: "-Wno-system-headers"
 // EXTERNAL_Wn: "-Wsystem-headers"
 
+// RUN: %clang_cl -vctoolsdir "" /arm64EC /c -### -- %s 2>&1 | FileCheck %s 
--check-prefix ARM64EC
+// ARM64EC: "-triple" "arm64ec-pc-windows-msvc19.20.0"
+// ARM64EC-NOT: /arm64EC has been overridden by specified target
+
 void f(void) { }



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


[PATCH] D134788: [ARM64EC][clang-cl] Add /arm64EC flag

2022-10-03 Thread chenglin.bi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb0fff3db6ada: [ARM64EC][clang-cl] Add /arm64EC flag 
(authored by bcl5980).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134788

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -782,4 +782,8 @@
 // EXTERNAL_W0: "-Wno-system-headers"
 // EXTERNAL_Wn: "-Wsystem-headers"
 
+// RUN: %clang_cl -vctoolsdir "" /arm64EC /c -### -- %s 2>&1 | FileCheck %s 
--check-prefix ARM64EC
+// ARM64EC: "-triple" "arm64ec-pc-windows-msvc19.20.0"
+// ARM64EC-NOT: /arm64EC has been overridden by specified target
+
 void f(void) { }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1256,6 +1256,8 @@
 T.setVendor(llvm::Triple::PC);
 T.setEnvironment(llvm::Triple::MSVC);
 T.setObjectFormat(llvm::Triple::COFF);
+if (Args.hasArg(options::OPT__SLASH_arm64EC))
+  T.setArch(llvm::Triple::aarch64, llvm::Triple::AArch64SubArch_arm64ec);
 TargetTriple = T.str();
   } else if (IsDXCMode()) {
 // Build TargetTriple from target_profile option for clang-dxc.
@@ -1380,6 +1382,14 @@
   const ToolChain &TC = getToolChain(
   *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));
 
+  // Report warning when arm64EC option is overridden by specified target
+  if ((TC.getTriple().getArch() != llvm::Triple::aarch64 ||
+   TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec) &&
+  UArgs->hasArg(options::OPT__SLASH_arm64EC)) {
+getDiags().Report(clang::diag::warn_target_override_arm64ec)
+<< TC.getTriple().str();
+  }
+
   // The compilation takes ownership of Args.
   Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs,
ContainsError);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6695,6 +6695,8 @@
 def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">,
   HelpText<"Align branches within 32-byte boundaries to mitigate the 
performance impact of the Intel JCC erratum.">,
   Alias;
+def _SLASH_arm64EC : CLFlag<"arm64EC">,
+  HelpText<"Set build target to arm64ec">;
 
 // Non-aliases:
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -655,6 +655,10 @@
   "-fjmc works only for ELF; option ignored">,
   InGroup;
 
+def warn_target_override_arm64ec : Warning<
+  "/arm64EC has been overridden by specified target: %0; option ignored">,
+  InGroup;
+
 def err_drv_target_variant_invalid : Error<
   "unsupported '%0' value '%1'; use 'ios-macabi' instead">;
 


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -782,4 +782,8 @@
 // EXTERNAL_W0: "-Wno-system-headers"
 // EXTERNAL_Wn: "-Wsystem-headers"
 
+// RUN: %clang_cl -vctoolsdir "" /arm64EC /c -### -- %s 2>&1 | FileCheck %s --check-prefix ARM64EC
+// ARM64EC: "-triple" "arm64ec-pc-windows-msvc19.20.0"
+// ARM64EC-NOT: /arm64EC has been overridden by specified target
+
 void f(void) { }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1256,6 +1256,8 @@
 T.setVendor(llvm::Triple::PC);
 T.setEnvironment(llvm::Triple::MSVC);
 T.setObjectFormat(llvm::Triple::COFF);
+if (Args.hasArg(options::OPT__SLASH_arm64EC))
+  T.setArch(llvm::Triple::aarch64, llvm::Triple::AArch64SubArch_arm64ec);
 TargetTriple = T.str();
   } else if (IsDXCMode()) {
 // Build TargetTriple from target_profile option for clang-dxc.
@@ -1380,6 +1382,14 @@
   const ToolChain &TC = getToolChain(
   *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));
 
+  // Report warning when arm64EC option is overridden by specified target
+  if ((TC.getTriple().getArch() != llvm::Triple::aarch64 ||
+   TC.getTriple().getSubArch() != llvm::Triple::AArch64SubArch_arm64ec) &&
+  UArgs->hasArg(options::OPT__SLASH_arm64EC)) {
+getDiags().Report(clang::diag::warn_target_override_arm64ec)
+<< TC.getTriple().str();
+  }
+
   // The compilation takes ownership of Args.
   Compilation *C = new Compilation(

[PATCH] D133578: [OpenMP][OMPIRBuilder] Add generation of SIMD align assumptions to OMPIRBuilder

2022-10-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2976
 
+  const int DefaultAlignment = 16;
+

domada wrote:
> jdoerfert wrote:
> > This doesn't work. Use the data layout for any default values please.
> I have used pointer ABI alignment as the default value. Is it ok?
> Clang has separate method to calculate OpenMP default alignment defined in 
> TargetInfo class ( [[ 
> https://clang.llvm.org/doxygen/classclang_1_1TargetInfo.html#af0c75e3288adc13601732329c44db147
>  |  link ]])
> Unfortunately, there is no simple replacement of this function in 
> OMPIRBuilder or in Flang driver. There are some requests to expose TargetInfo 
> data in Clang-independent manner: [[ 
> https://discourse.llvm.org/t/rfc-targetinfo-library/64342 | RFC1 ]], 
> [[https://discourse.llvm.org/t/complex-to-libm-conversion-abi-issues/65131 
> |RFC2]] , but this issue is not solved.
Let's step back:
1) User tells us the alignment via `aligned(X:64)`. This should populate the 
map in Clang, I would assume.
2) User tells us the alignment "implicitly" via `align(Y)`. Again, clang should 
populate the map with the default/preferred alignment of the type. You can use 
the function you linked, or use the data layout API to get the preferred 
alignment.
3) User tells us nothing. We should pick the default or, don't annotate 
anything. If we go with defaults, you need to look up the default for the 
address space but I don't know why we would annotate anything not provided by 
the user.




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

https://reviews.llvm.org/D133578

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


[PATCH] D134941: [analyzer][NFC] Add tests for D132236

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
tomasz-kaminski-sonarsource marked an inline comment as done.
Closed by commit rG73716baa30eb: [analyzer][NFC] Add tests for D132236 
(authored by tomasz-kaminski-sonarsource).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134941

Files:
  clang/test/Analysis/NewDeleteLeaks.cpp
  clang/test/Analysis/symbol-reaper-lambda.cpp
  clang/test/Analysis/trivial-copy-struct.cpp

Index: clang/test/Analysis/trivial-copy-struct.cpp
===
--- clang/test/Analysis/trivial-copy-struct.cpp
+++ clang/test/Analysis/trivial-copy-struct.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
 
 template  void clang_analyzer_dump(T);
+template  void clang_analyzer_value(T);
 void clang_analyzer_warnIfReached();
 
 struct Node { int* ptr; };
@@ -34,3 +35,25 @@
   (void)(n1->ptr);
   (void)(n2->ptr);
 }
+
+struct List {
+  List* next;
+  int value;
+  int padding;
+};
+
+void deadCode(List orig) {
+  List c = orig;
+  clang_analyzer_dump(c.value);
+  // expected-warning-re@-1 {{reg_${{[0-9]+
+  if (c.value == 42)
+return;
+  clang_analyzer_value(c.value);
+  // expected-warning@-1 {{32s:{ [-2147483648, 2147483647] }}}
+  // The symbol was garbage collected too early, hence we lose the constraints.
+  if (c.value != 42)
+return;
+
+  // Dead code should be unreachable
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
Index: clang/test/Analysis/symbol-reaper-lambda.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-reaper-lambda.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+template 
+void escape(Ts&...);
+struct Dummy {};
+
+int strange(Dummy param) {
+  Dummy local_pre_lambda;
+  int ref_captured = 0;
+
+  // LambdaExpr is modeled as lazyCompoundVal of tempRegion, that contains
+  // all captures. In this instance, this region contains a pointer/reference
+  // to ref_captured variable.
+  auto fn = [&] {
+escape(param, local_pre_lambda);
+return ref_captured; // no-warning: The value is not garbage.
+  };
+
+  int local_defined_after_lambda; // Unused, but necessary! Important that it's before the call.
+
+  // The ref_captured binding should not be pruned at this point, as it is still
+  // accessed via reference captured in operator() of fn.
+  return fn();
+}
+
Index: clang/test/Analysis/NewDeleteLeaks.cpp
===
--- clang/test/Analysis/NewDeleteLeaks.cpp
+++ clang/test/Analysis/NewDeleteLeaks.cpp
@@ -192,3 +192,29 @@
 // expected-note@-1 {{Potential leak of memory pointed to by 'v'}}
 
 } // namespace refkind_from_unoallocated_to_allocated
+
+// Check that memory leak is reported against a symbol if the last place it's
+// mentioned is a base region of a lazy compound value, as the program cannot
+// possibly free that memory.
+namespace symbol_reaper_lifetime {
+struct Nested {
+  int buf[2];
+};
+struct Wrapping {
+  Nested data;
+};
+
+Nested allocateWrappingAndReturnNested() {
+  // expected-note@+1 {{Memory is allocated}}
+  Wrapping const* p = new Wrapping();
+  // expected-warning@+2 {{Potential leak of memory pointed to by 'p'}}
+  // expected-note@+1{{Potential leak of memory pointed to by 'p'}}
+  return p->data;
+}
+
+void caller() {
+  // expected-note@+1 {{Calling 'allocateWrappingAndReturnNested'}}
+  Nested n = allocateWrappingAndReturnNested();
+  (void)n;
+} // no-warning: No potential memory leak here, because that's been already reported.
+} // namespace symbol_reaper_lifetime
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 73716ba - [analyzer][NFC] Add tests for D132236

2022-10-03 Thread Tomasz Kamiński via cfe-commits

Author: Tomasz Kamiński
Date: 2022-10-03T15:42:38+02:00
New Revision: 73716baa30ebc75783d2902e12accea35dec193a

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

LOG: [analyzer][NFC] Add tests for D132236

D132236 would have introduced regressions in the symbol lifetime
handling. However, the testsuite did not catch this, so here we have
some tests, which would have break if D132236 had landed.

This patch addresses the comment https://reviews.llvm.org/D132236#3753238

Co-authored-by: Balazs Benics 

Reviewed By: martong

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

Added: 
clang/test/Analysis/symbol-reaper-lambda.cpp

Modified: 
clang/test/Analysis/NewDeleteLeaks.cpp
clang/test/Analysis/trivial-copy-struct.cpp

Removed: 




diff  --git a/clang/test/Analysis/NewDeleteLeaks.cpp 
b/clang/test/Analysis/NewDeleteLeaks.cpp
index 19a6aff7833be..b2bad7e76fad0 100644
--- a/clang/test/Analysis/NewDeleteLeaks.cpp
+++ b/clang/test/Analysis/NewDeleteLeaks.cpp
@@ -192,3 +192,29 @@ void use_ret() {
 // expected-note@-1 {{Potential leak of memory pointed to by 'v'}}
 
 } // namespace refkind_from_unoallocated_to_allocated
+
+// Check that memory leak is reported against a symbol if the last place it's
+// mentioned is a base region of a lazy compound value, as the program cannot
+// possibly free that memory.
+namespace symbol_reaper_lifetime {
+struct Nested {
+  int buf[2];
+};
+struct Wrapping {
+  Nested data;
+};
+
+Nested allocateWrappingAndReturnNested() {
+  // expected-note@+1 {{Memory is allocated}}
+  Wrapping const* p = new Wrapping();
+  // expected-warning@+2 {{Potential leak of memory pointed to by 'p'}}
+  // expected-note@+1{{Potential leak of memory pointed to by 'p'}}
+  return p->data;
+}
+
+void caller() {
+  // expected-note@+1 {{Calling 'allocateWrappingAndReturnNested'}}
+  Nested n = allocateWrappingAndReturnNested();
+  (void)n;
+} // no-warning: No potential memory leak here, because that's been already 
reported.
+} // namespace symbol_reaper_lifetime

diff  --git a/clang/test/Analysis/symbol-reaper-lambda.cpp 
b/clang/test/Analysis/symbol-reaper-lambda.cpp
new file mode 100644
index 0..c63562b4d430b
--- /dev/null
+++ b/clang/test/Analysis/symbol-reaper-lambda.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+template 
+void escape(Ts&...);
+struct Dummy {};
+
+int strange(Dummy param) {
+  Dummy local_pre_lambda;
+  int ref_captured = 0;
+
+  // LambdaExpr is modeled as lazyCompoundVal of tempRegion, that contains
+  // all captures. In this instance, this region contains a pointer/reference
+  // to ref_captured variable.
+  auto fn = [&] {
+escape(param, local_pre_lambda);
+return ref_captured; // no-warning: The value is not garbage.
+  };
+
+  int local_defined_after_lambda; // Unused, but necessary! Important that 
it's before the call.
+
+  // The ref_captured binding should not be pruned at this point, as it is 
still
+  // accessed via reference captured in operator() of fn.
+  return fn();
+}
+

diff  --git a/clang/test/Analysis/trivial-copy-struct.cpp 
b/clang/test/Analysis/trivial-copy-struct.cpp
index b9a2b1d9b201d..cd9cfde3ee9dc 100644
--- a/clang/test/Analysis/trivial-copy-struct.cpp
+++ b/clang/test/Analysis/trivial-copy-struct.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
 
 template  void clang_analyzer_dump(T);
+template  void clang_analyzer_value(T);
 void clang_analyzer_warnIfReached();
 
 struct Node { int* ptr; };
@@ -34,3 +35,25 @@ void copy_on_heap(Node* n1) {
   (void)(n1->ptr);
   (void)(n2->ptr);
 }
+
+struct List {
+  List* next;
+  int value;
+  int padding;
+};
+
+void deadCode(List orig) {
+  List c = orig;
+  clang_analyzer_dump(c.value);
+  // expected-warning-re@-1 {{reg_${{[0-9]+
+  if (c.value == 42)
+return;
+  clang_analyzer_value(c.value);
+  // expected-warning@-1 {{32s:{ [-2147483648, 2147483647] }}}
+  // The symbol was garbage collected too early, hence we lose the constraints.
+  if (c.value != 42)
+return;
+
+  // Dead code should be unreachable
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}



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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D134046: [OpenMP][OMPIRBuilder] Add support for order(concurrent) to OMPIRBuilder for SIMD directive

2022-10-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I think the rest looks good.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:213
 
+  enum class OMPOrderClauseValue { NotSpecified, Concurrent };
+

I think this belongs into `llvm/include/llvm/Frontend/OpenMP/OMPConstants.h` 
either explicitly or via the `llvm/Frontend/OpenMP/OMPKinds.def` logic.


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

https://reviews.llvm.org/D134046

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


[PATCH] D133499: [clang]: Add DeclContext::dumpAsDecl().

2022-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Please see the two comments, otherwise this LGTM.  Feel free to fix the below 
as a part of the commit process.




Comment at: clang/lib/AST/ASTDumper.cpp:240
+  // the innerworkings of dyn_cast() do assert that to be the case! Alas,
+  // strange and unfortunate things do occasionally occur that lead to folk
+  // like yourself, dear reader, running a debugger and feeling extraordinarily

This gets a little overly coy for our comments...



Comment at: clang/lib/AST/ASTDumper.cpp:250
+  if (hasValidDeclKind()) {
+const auto *D = dyn_cast(this);
+D->dump();

This can now just be 'cast'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133499

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


[PATCH] D134650: [runtimes] Remove all traces of the legacy testing configuration system

2022-10-03 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In case anyone else runs into this: It appears this change somehow broke 
incremental builds with `-DLLVM_ENABLE_RUNTIMES=libunwind` (even after deleting 
CMakeCache.txt in the main build dir):

  -- Using libunwind testing configuration: 
/home/alexrichardson/cheri/upstream-llvm-project/libunwind/test/lit.site.cfg.in
  CMake Error: File 
/home/alexrichardson/cheri/upstream-llvm-project/libunwind/test/lit.site.cfg.in 
does not exist.
  CMake Error at 
/home/alexrichardson/cheri/upstream-llvm-project/llvm/cmake/modules/AddLLVM.cmake:1793
 (configure_file):
configure_file Problem configuring file
  Call Stack (most recent call first):

/home/alexrichardson/cheri/upstream-llvm-project/libunwind/test/CMakeLists.txt:45
 (configure_lit_site_cfg)
  
  
  -- Configuring incomplete, errors occurred!

Fortunately this is quite easy to fix: `rm -rf /runtimes` and then 
run `ninja` again.
I'm not sure if this would help (and I don't have a broken build dir anymore), 
but it might be possible to avoid this problem by touching CMakeLists.txt in 
llvm/runtimes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134650

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


[PATCH] D86844: [LoopDeletion] Allows deletion of possibly infinite side-effect free loops

2022-10-03 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.
Herald added a project: All.

I wrote
 https://github.com/llvm/llvm-project/issues/58123
about a crash that I bisected to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86844

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


[PATCH] D133500: [clang] Correct handling of lambdas in lambda default arguments in dependent contexts.

2022-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I'm OK with it as-is, and the refactor to move the replicated code would be 
acceptable in an NFC followup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133500

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


[PATCH] D44604: Make stdarg.h compatible with FreeBSD

2022-10-03 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson abandoned this revision.
arichardson added a comment.
Herald added a subscriber: jrtc27.
Herald added a project: All.

Hopefully no longer required.


Repository:
  rC Clang

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

https://reviews.llvm.org/D44604

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, tra, yaxunl, 
tianshilei1992, MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently all of the flags beginning with `--offload` such as
`--offload-arch` or `--offload-device-only` require the double-dash
form. However, if a user uses a single dash it will instead name a file
'ffload-arch' for example. This has been the cause of a lot of user
confusion. This patch changes these options to also accept a single
dash. This is similar to many other driver arguments beginning with
`-o`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135076

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -827,7 +827,7 @@
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
-def offload_link : Flag<["--"], "offload-link">, Group,
+def offload_link : Flag<["--", "-"], "offload-link">, Group,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
@@ -926,7 +926,7 @@
   HelpText<"Include PTX for the following GPU architecture (e.g. sm_35) or 
'all'. May be specified more than once.">;
 def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, 
Flags<[NoXarchOption]>,
   HelpText<"Do not include PTX for the following GPU architecture (e.g. sm_35) 
or 'all'. May be specified more than once.">;
-def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>,
+def offload_arch_EQ : Joined<["--", "-"], "offload-arch=">, 
Flags<[NoXarchOption]>,
   HelpText<"CUDA offloading device architecture (e.g. sm_35), or HIP 
offloading target ID in the form of a "
"device architecture followed by target ID features delimited by a 
colon. Each target ID feature "
"is a pre-defined string followed by a plus or minus sign (e.g. 
gfx908:xnack+:sramecc-).  May be "
@@ -938,7 +938,7 @@
   HelpText<"Link clang-offload-bundler bundles for HIP">;
 def no_hip_rt: Flag<["-"], "no-hip-rt">,
   HelpText<"Do not link against HIP runtime libraries">;
-def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
+def no_offload_arch_EQ : Joined<["--", "-"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
   HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, 
gfx906) from the list of devices to compile for. "
"'all' resets the list to its default value.">;
 def emit_static_lib : Flag<["--"], "emit-static-lib">,
@@ -1180,7 +1180,7 @@
 // In the future this option will be supported by other offloading
 // languages and accept other values such as CPU/GPU architectures,
 // offload kinds and target aliases.
-def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
+def offload_EQ : CommaJoined<["--", "-"], "offload=">, Flags<[NoXarchOption]>,
   HelpText<"Specify comma-separated list of offloading target triples (CUDA 
and HIP only)">;
 
 // C++ Coroutines TS
@@ -2619,15 +2619,15 @@
   PosFlag, NegFlag, 
BothFlags<[NoArgumentUnused, HelpHidden]>>;
 def static_openmp: Flag<["-"], "static-openmp">,
   HelpText<"Use the static host OpenMP runtime while linking.">;
-def offload_new_driver : Flag<["--"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def offload_new_driver : Flag<["--", "-"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
   MarshallingInfoFlag>, HelpText<"Use the new 
driver for offloading compilation.">;
-def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def no_offload_new_driver : Flag<["--", "-"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
   HelpText<"Don't Use the new driver for offloading compilation.">;
-def offload_device_only : Flag<["--"], "offload-device-only">,
+def offload_device_only : Flag<["--", "-"], "offload-device-only">,
   HelpText<"Only compile for the offloading device.">;
-def offload_host_only : Flag<["--"], "offload-host-only">,
+def offload_host_only : Flag<["--", "-"], "offload-host-only">,
   HelpText<"Only compile for the offloading host.">;
-def offload_host_device : Flag<["--"], "offload-host-device">,
+def offload_host_device : Flag<["--", "-"], "offload-host-device">,
   HelpText<"Only compile for the offloading host.">;
 def cuda_device_only : Flag<["--"], "cuda-device-only">, 
Alias,
   HelpText<"Compile CUDA code for device only">;


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/cla

[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 464673.
tomasz-kaminski-sonarsource marked 3 inline comments as done.
tomasz-kaminski-sonarsource added a comment.

Applied review suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/trivial-copy-struct.cpp

Index: clang/test/Analysis/trivial-copy-struct.cpp
===
--- clang/test/Analysis/trivial-copy-struct.cpp
+++ clang/test/Analysis/trivial-copy-struct.cpp
@@ -49,11 +49,53 @@
   if (c.value == 42)
 return;
   clang_analyzer_value(c.value);
-  // expected-warning@-1 {{32s:{ [-2147483648, 2147483647] }}}
-  // The symbol was garbage collected too early, hence we lose the constraints.
+  // expected-warning@-1 {{32s:{ [-2147483648, 41], [43, 2147483647] }}}
+  // Before symbol was garbage collected too early, and we lost the constraints.
   if (c.value != 42)
 return;
 
-  // Dead code should be unreachable
-  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning: Dead code.
+};
+
+void ptr1(List* n) {
+  List* n2 = new List(*n); // cctor
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+void ptr2(List* n) {
+  List* n2 = new List(); // ctor
+  *n2 = *n; // assignment
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+struct Wrapper {
+  List head;
+  int count;
+};
+
+void nestedLazyCompoundVal(List* n) {
+  Wrapper* w = 0;
+  {
+ Wrapper lw;
+ lw.head = *n;
+ w = new Wrapper(lw);
+  }
+  if (!n->next) {
+if (w->head.next) {
+  // Unreachable, w->head is a copy of *n, therefore
+  // w->head.next and n->next are equal
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+  }
+  delete w;
 }
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -411,10 +411,14 @@
 }
 
 void SymbolReaper::markLive(const MemRegion *region) {
-  RegionRoots.insert(region->getBaseRegion());
+  LiveRegionRoots.insert(region->getBaseRegion());
   markElementIndicesLive(region);
 }
 
+void SymbolReaper::markLazilyCopied(const clang::ento::MemRegion *region) {
+  LazilyCopiedRegionRoots.insert(region->getBaseRegion());
+}
+
 void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
   for (auto SR = dyn_cast(region); SR;
SR = dyn_cast(SR->getSuperRegion())) {
@@ -437,8 +441,7 @@
   // is not used later in the path, we can diagnose a leak of a value within
   // that field earlier than, say, the variable that contains the field dies.
   MR = MR->getBaseRegion();
-
-  if (RegionRoots.count(MR))
+  if (LiveRegionRoots.count(MR))
 return true;
 
   if (const auto *SR = dyn_cast(MR))
@@ -454,6 +457,15 @@
   return isa(MR);
 }
 
+bool SymbolReaper::isLazilyCopiedRegion(const MemRegion *MR) const {
+  // TODO: See comment in isLiveRegion.
+  return LazilyCopiedRegionRoots.count(MR->getBaseRegion());
+}
+
+bool SymbolReaper::isReadableRegion(const MemRegion *MR) {
+  return isLiveRegion(MR) || isLazilyCopiedRegion(MR);
+}
+
 bool SymbolReaper::isLive(SymbolRef sym) {
   if (TheLiving.count(sym)) {
 markDependentsLive(sym);
@@ -464,7 +476,7 @@
 
   switch (sym->getKind()) {
   case SymExpr::SymbolRegionValueKind:
-KnownLive = isLiveRegion(cast(sym)->getRegion());
+KnownLive = isReadableRegion(cast(sym)->getRegion());
 break;
   case SymExpr::SymbolConjuredKind:
 KnownLive = false;
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2838,6 +2838,10 @@
   // Is it a LazyCompoundVal?  All referenced regions are live as well.
   if (Optional LCS =
   V.getAs()) {
+// TODO: Make regions referred to by `lazyCompoundVals` that are bound to
+// subregions of the `LCS.getRegion()` also lazily copied.
+if (const MemRegion *R = LCS->getRegion())
+  SymReaper.markLazilyCopied(R);
 
 const RegionStoreManager::SValListTy &Vals = RM.getInterestingValues(*LCS);
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -582,7 +582

[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource added a comment.

Applied all review suggestions.




Comment at: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp:461
+bool SymbolReaper::isLazilyCopiedRegion(const MemRegion *MR) const {
+  // TODO: See comment in isLiveRegion.
+  return LazilyCopiedRegionRoots.count(MR->getBaseRegion());

martong wrote:
> Just out of curiosity, do you have plans to tackle this todo sometime?
We do not plan to takle it in near future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Like that a lot, good quality of life improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 464677.
tomasz-kaminski-sonarsource added a comment.
Herald added subscribers: openmp-commits, zero9178, bzcheeseman, sdasgup3, 
wenzhicui, wrengr, cota, mravishankar, teijeong, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, 
aartbik, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, 
rriddle, mehdi_amini, MaskRay.
Herald added a reviewer: nicolasvasilache.
Herald added projects: OpenMP, MLIR, lld-macho.
Herald added a reviewer: lld-macho.

Updated diff to be mergable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/Driver/Driver.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/NewDeleteLeaks.cpp
  clang/test/Analysis/symbol-reaper-lambda.cpp
  clang/test/Analysis/trivial-copy-struct.cpp
  clang/test/Driver/cl-options.c
  lld/MachO/SymbolTable.cpp
  mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
  openmp/runtime/src/kmp_sched.cpp

Index: openmp/runtime/src/kmp_sched.cpp
===
--- openmp/runtime/src/kmp_sched.cpp
+++ openmp/runtime/src/kmp_sched.cpp
@@ -83,6 +83,9 @@
   KMP_PUSH_PARTITIONED_TIMER(OMP_loop_static);
   KMP_PUSH_PARTITIONED_TIMER(OMP_loop_static_scheduling);
 
+  // Clear monotonic/nonmonotonic bits (ignore it)
+  schedtype = SCHEDULE_WITHOUT_MODIFIERS(schedtype);
+
   typedef typename traits_t::unsigned_t UT;
   typedef typename traits_t::signed_t ST;
   /*  this all has to be changed back to TID and such.. */
Index: mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
===
--- mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -705,14 +705,14 @@
   - the new scf.foreach_thread op,
   - the tiled op that implements TilingInterface.
 
-### Example using `num_threads`
+ Example using `num_threads`
 
 ```
 %0 = pdl_match @match_matmul in %arg1
 %3:2 = transform.structured.tile_to_foreach_thread_op %0 num_threads [10, 20]
 ```
 
-### Example using `tile_sizes`
+ Example using `tile_sizes`
 
 ```
 %0 = pdl_match @match_matmul in %arg1
Index: lld/MachO/SymbolTable.cpp
===
--- lld/MachO/SymbolTable.cpp
+++ lld/MachO/SymbolTable.cpp
@@ -392,53 +392,53 @@
   }
 }
 
-void macho::reportPendingUndefinedSymbols() {
-  for (const auto &undef : undefs) {
-const UndefinedDiag &locations = undef.second;
-
-std::string message = "undefined symbol";
-if (config->archMultiple)
-  message += (" for arch " + getArchitectureName(config->arch())).str();
-message += ": " + toString(*undef.first);
-
-const size_t maxUndefinedReferences = 3;
-size_t i = 0;
-for (const std::string &loc : locations.otherReferences) {
-  if (i >= maxUndefinedReferences)
-break;
-  message += "\n>>> referenced by " + loc;
-  ++i;
-}
-
-for (const UndefinedDiag::SectionAndOffset &loc :
- locations.codeReferences) {
-  if (i >= maxUndefinedReferences)
-break;
-  message += "\n>>> referenced by ";
-  std::string src = loc.isec->getSourceLocation(loc.offset);
-  if (!src.empty())
-message += src + "\n>>>   ";
-  message += loc.isec->getLocation(loc.offset);
-  ++i;
-}
+static void reportUndefinedSymbol(const Undefined &sym,
+  const UndefinedDiag &locations) {
+  std::string message = "undefined symbol";
+  if (config->archMultiple)
+message += (" for arch " + getArchitectureName(config->arch())).str();
+  message += ": " + toString(sym);
+
+  const size_t maxUndefinedReferences = 3;
+  size_t i = 0;
+  for (const std::string &loc : locations.otherReferences) {
+if (i >= maxUndefinedReferences)
+  break;
+message += "\n>>> referenced by " + loc;
+++i;
+  }
 
-size_t totalReferences =
-locations.otherReferences.size() + locations.codeReferences.size();
-if (totalReferences > i)
-  message +=
-  ("\n>>> referenced " + Twine(totalReferences - i) + " more times")
-  .str();
-
-if (config->undefinedSymbolTreatment == UndefinedSymbolTreatment::error)
-  error(message);
-else if (config->undefinedSymbolTreatment ==
- UndefinedSymbolTreatment::warning)
-  warn(message);
-else
-  assert(false &&
- "diagnostics make sense for -undefined error|warning only"

[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 464678.
tomasz-kaminski-sonarsource added a comment.

Fighting with arcanist.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/trivial-copy-struct.cpp

Index: clang/test/Analysis/trivial-copy-struct.cpp
===
--- clang/test/Analysis/trivial-copy-struct.cpp
+++ clang/test/Analysis/trivial-copy-struct.cpp
@@ -49,11 +49,53 @@
   if (c.value == 42)
 return;
   clang_analyzer_value(c.value);
-  // expected-warning@-1 {{32s:{ [-2147483648, 2147483647] }}}
-  // The symbol was garbage collected too early, hence we lose the constraints.
+  // expected-warning@-1 {{32s:{ [-2147483648, 41], [43, 2147483647] }}}
+  // Before symbol was garbage collected too early, and we lost the constraints.
   if (c.value != 42)
 return;
 
-  // Dead code should be unreachable
-  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning: Dead code.
+};
+
+void ptr1(List* n) {
+  List* n2 = new List(*n); // cctor
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+void ptr2(List* n) {
+  List* n2 = new List(); // ctor
+  *n2 = *n; // assignment
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+struct Wrapper {
+  List head;
+  int count;
+};
+
+void nestedLazyCompoundVal(List* n) {
+  Wrapper* w = 0;
+  {
+ Wrapper lw;
+ lw.head = *n;
+ w = new Wrapper(lw);
+  }
+  if (!n->next) {
+if (w->head.next) {
+  // Unreachable, w->head is a copy of *n, therefore
+  // w->head.next and n->next are equal
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+  }
+  delete w;
 }
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -411,10 +411,14 @@
 }
 
 void SymbolReaper::markLive(const MemRegion *region) {
-  RegionRoots.insert(region->getBaseRegion());
+  LiveRegionRoots.insert(region->getBaseRegion());
   markElementIndicesLive(region);
 }
 
+void SymbolReaper::markLazilyCopied(const clang::ento::MemRegion *region) {
+  LazilyCopiedRegionRoots.insert(region->getBaseRegion());
+}
+
 void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
   for (auto SR = dyn_cast(region); SR;
SR = dyn_cast(SR->getSuperRegion())) {
@@ -437,8 +441,7 @@
   // is not used later in the path, we can diagnose a leak of a value within
   // that field earlier than, say, the variable that contains the field dies.
   MR = MR->getBaseRegion();
-
-  if (RegionRoots.count(MR))
+  if (LiveRegionRoots.count(MR))
 return true;
 
   if (const auto *SR = dyn_cast(MR))
@@ -454,6 +457,15 @@
   return isa(MR);
 }
 
+bool SymbolReaper::isLazilyCopiedRegion(const MemRegion *MR) const {
+  // TODO: See comment in isLiveRegion.
+  return LazilyCopiedRegionRoots.count(MR->getBaseRegion());
+}
+
+bool SymbolReaper::isReadableRegion(const MemRegion *MR) {
+  return isLiveRegion(MR) || isLazilyCopiedRegion(MR);
+}
+
 bool SymbolReaper::isLive(SymbolRef sym) {
   if (TheLiving.count(sym)) {
 markDependentsLive(sym);
@@ -464,7 +476,7 @@
 
   switch (sym->getKind()) {
   case SymExpr::SymbolRegionValueKind:
-KnownLive = isLiveRegion(cast(sym)->getRegion());
+KnownLive = isReadableRegion(cast(sym)->getRegion());
 break;
   case SymExpr::SymbolConjuredKind:
 KnownLive = false;
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2838,6 +2838,10 @@
   // Is it a LazyCompoundVal?  All referenced regions are live as well.
   if (Optional LCS =
   V.getAs()) {
+// TODO: Make regions referred to by `lazyCompoundVals` that are bound to
+// subregions of the `LCS.getRegion()` also lazily copied.
+if (const MemRegion *R = LCS->getRegion())
+  SymReaper.markLazilyCopied(R);
 
 const RegionStoreManager::SValListTy &Vals = RM.getInterestingValues(*LCS);
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -582,7 +582,12 @@
   SymbolMapTy TheLiving;
   SymbolSetTy MetadataInUse;
 
-

[clang] 4987ae8 - [ARM][AArch64] Dont use macros for half instrinsics in NeonEmitter

2022-10-03 Thread David Green via cfe-commits

Author: David Green
Date: 2022-10-03T15:27:23+01:00
New Revision: 4987ae84622b804e72c405aacbe297f0e5e247c7

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

LOG: [ARM][AArch64] Dont use macros for half instrinsics in NeonEmitter

We don't require arm_neon.h fp16 intrinsics to be treated as macros any
more.

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

Added: 


Modified: 
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c 
b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
index c9e4b6ea6090d..984324a9113b3 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1486,18 +1486,18 @@ float16x4_t test_vfma_n_f16(float16x4_t a, float16x4_t 
b, float16_t c) {
 // CHECK-LABEL: define {{[^@]+}}@test_vfmaq_n_f16
 // CHECK-SAME: (<8 x half> noundef [[A:%.*]], <8 x half> noundef [[B:%.*]], 
half noundef [[C:%.*]]) #[[ATTR1]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[VECINIT:%.*]] = insertelement <8 x half> undef, half 
[[C]], i32 0
-// CHECK-NEXT:[[VECINIT1:%.*]] = insertelement <8 x half> [[VECINIT]], 
half [[C]], i32 1
-// CHECK-NEXT:[[VECINIT2:%.*]] = insertelement <8 x half> [[VECINIT1]], 
half [[C]], i32 2
-// CHECK-NEXT:[[VECINIT3:%.*]] = insertelement <8 x half> [[VECINIT2]], 
half [[C]], i32 3
-// CHECK-NEXT:[[VECINIT4:%.*]] = insertelement <8 x half> [[VECINIT3]], 
half [[C]], i32 4
-// CHECK-NEXT:[[VECINIT5:%.*]] = insertelement <8 x half> [[VECINIT4]], 
half [[C]], i32 5
-// CHECK-NEXT:[[VECINIT6:%.*]] = insertelement <8 x half> [[VECINIT5]], 
half [[C]], i32 6
-// CHECK-NEXT:[[VECINIT7:%.*]] = insertelement <8 x half> [[VECINIT6]], 
half [[C]], i32 7
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <8 x half> undef, half 
[[C]], i32 0
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <8 x half> [[VECINIT_I]], 
half [[C]], i32 1
+// CHECK-NEXT:[[VECINIT2_I:%.*]] = insertelement <8 x half> 
[[VECINIT1_I]], half [[C]], i32 2
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <8 x half> 
[[VECINIT2_I]], half [[C]], i32 3
+// CHECK-NEXT:[[VECINIT4_I:%.*]] = insertelement <8 x half> 
[[VECINIT3_I]], half [[C]], i32 4
+// CHECK-NEXT:[[VECINIT5_I:%.*]] = insertelement <8 x half> 
[[VECINIT4_I]], half [[C]], i32 5
+// CHECK-NEXT:[[VECINIT6_I:%.*]] = insertelement <8 x half> 
[[VECINIT5_I]], half [[C]], i32 6
+// CHECK-NEXT:[[VECINIT7_I:%.*]] = insertelement <8 x half> 
[[VECINIT6_I]], half [[C]], i32 7
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x half> [[A]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x half> [[B]] to <16 x i8>
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x half> [[VECINIT7]] to <16 x i8>
-// CHECK-NEXT:[[TMP3:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> 
[[B]], <8 x half> [[VECINIT7]], <8 x half> [[A]])
+// CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x half> [[VECINIT7_I]] to <16 x i8>
+// CHECK-NEXT:[[TMP3:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> 
[[B]], <8 x half> [[VECINIT7_I]], <8 x half> [[A]])
 // CHECK-NEXT:ret <8 x half> [[TMP3]]
 //
 float16x8_t test_vfmaq_n_f16(float16x8_t a, float16x8_t b, float16_t c) {
@@ -1601,15 +1601,15 @@ float16x8_t test_vfmsq_laneq_f16(float16x8_t a, 
float16x8_t b, float16x8_t c) {
 // CHECK-LABEL: define {{[^@]+}}@test_vfms_n_f16
 // CHECK-SAME: (<4 x half> noundef [[A:%.*]], <4 x half> noundef [[B:%.*]], 
half noundef [[C:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[FNEG:%.*]] = fneg <4 x half> [[B]]
-// CHECK-NEXT:[[VECINIT:%.*]] = insertelement <4 x half> undef, half 
[[C]], i32 0
-// CHECK-NEXT:[[VECINIT1:%.*]] = insertelement <4 x half> [[VECINIT]], 
half [[C]], i32 1
-// CHECK-NEXT:[[VECINIT2:%.*]] = insertelement <4 x half> [[VECINIT1]], 
half [[C]], i32 2
-// CHECK-NEXT:[[VECINIT3:%.*]] = insertelement <4 x half> [[VECINIT2]], 
half [[C]], i32 3
+// CHECK-NEXT:[[FNEG_I:%.*]] = fneg <4 x half> [[B]]
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <4 x half> undef, half 
[[C]], i32 0
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <4 x half> [[VECINIT_I]], 
half [[C]], i32 1
+// CHECK-NEXT:[[VECINIT2_I:%.*]] = insertelement <4 x half> 
[[VECINIT1_I]], half [[C]], i32 2
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <4 x half> 
[[VECINIT2_I]], half [[C]], i32 3
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x half> [[A]] to <8 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = bitcast <4 x half> [[FNEG]] to <8 x i8>
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <4 x half> [[VECINIT3]] to <8 x i8>
-// CHECK-NEXT:[[TMP3:%.*]] = call <4 x half> @llvm.fma.v4f16(<4 x half> 
[[FN

[PATCH] D131504: [ARM][AArch64] Dont use macros for half instrinsics in NeonEmitter

2022-10-03 Thread Dave Green via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4987ae84622b: [ARM][AArch64] Dont use macros for half 
instrinsics in NeonEmitter (authored by dmgreen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131504

Files:
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -395,11 +395,7 @@
 
   // Pointer arguments need to use macros to avoid hiding aligned attributes
   // from the pointer type.
-
-  // It is not permitted to pass or return an __fp16 by value, so intrinsics
-  // taking a scalar float16_t must be implemented as macros.
-  if (Type.isImmediate() || Type.isPointer() ||
-  (Type.isScalar() && Type.isHalf()))
+  if (Type.isImmediate() || Type.isPointer())
 UseMacro = true;
 }
   }
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1486,18 +1486,18 @@
 // CHECK-LABEL: define {{[^@]+}}@test_vfmaq_n_f16
 // CHECK-SAME: (<8 x half> noundef [[A:%.*]], <8 x half> noundef [[B:%.*]], half noundef [[C:%.*]]) #[[ATTR1]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[VECINIT:%.*]] = insertelement <8 x half> undef, half [[C]], i32 0
-// CHECK-NEXT:[[VECINIT1:%.*]] = insertelement <8 x half> [[VECINIT]], half [[C]], i32 1
-// CHECK-NEXT:[[VECINIT2:%.*]] = insertelement <8 x half> [[VECINIT1]], half [[C]], i32 2
-// CHECK-NEXT:[[VECINIT3:%.*]] = insertelement <8 x half> [[VECINIT2]], half [[C]], i32 3
-// CHECK-NEXT:[[VECINIT4:%.*]] = insertelement <8 x half> [[VECINIT3]], half [[C]], i32 4
-// CHECK-NEXT:[[VECINIT5:%.*]] = insertelement <8 x half> [[VECINIT4]], half [[C]], i32 5
-// CHECK-NEXT:[[VECINIT6:%.*]] = insertelement <8 x half> [[VECINIT5]], half [[C]], i32 6
-// CHECK-NEXT:[[VECINIT7:%.*]] = insertelement <8 x half> [[VECINIT6]], half [[C]], i32 7
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <8 x half> undef, half [[C]], i32 0
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <8 x half> [[VECINIT_I]], half [[C]], i32 1
+// CHECK-NEXT:[[VECINIT2_I:%.*]] = insertelement <8 x half> [[VECINIT1_I]], half [[C]], i32 2
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <8 x half> [[VECINIT2_I]], half [[C]], i32 3
+// CHECK-NEXT:[[VECINIT4_I:%.*]] = insertelement <8 x half> [[VECINIT3_I]], half [[C]], i32 4
+// CHECK-NEXT:[[VECINIT5_I:%.*]] = insertelement <8 x half> [[VECINIT4_I]], half [[C]], i32 5
+// CHECK-NEXT:[[VECINIT6_I:%.*]] = insertelement <8 x half> [[VECINIT5_I]], half [[C]], i32 6
+// CHECK-NEXT:[[VECINIT7_I:%.*]] = insertelement <8 x half> [[VECINIT6_I]], half [[C]], i32 7
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x half> [[A]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x half> [[B]] to <16 x i8>
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x half> [[VECINIT7]] to <16 x i8>
-// CHECK-NEXT:[[TMP3:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> [[B]], <8 x half> [[VECINIT7]], <8 x half> [[A]])
+// CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x half> [[VECINIT7_I]] to <16 x i8>
+// CHECK-NEXT:[[TMP3:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> [[B]], <8 x half> [[VECINIT7_I]], <8 x half> [[A]])
 // CHECK-NEXT:ret <8 x half> [[TMP3]]
 //
 float16x8_t test_vfmaq_n_f16(float16x8_t a, float16x8_t b, float16_t c) {
@@ -1601,15 +1601,15 @@
 // CHECK-LABEL: define {{[^@]+}}@test_vfms_n_f16
 // CHECK-SAME: (<4 x half> noundef [[A:%.*]], <4 x half> noundef [[B:%.*]], half noundef [[C:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[FNEG:%.*]] = fneg <4 x half> [[B]]
-// CHECK-NEXT:[[VECINIT:%.*]] = insertelement <4 x half> undef, half [[C]], i32 0
-// CHECK-NEXT:[[VECINIT1:%.*]] = insertelement <4 x half> [[VECINIT]], half [[C]], i32 1
-// CHECK-NEXT:[[VECINIT2:%.*]] = insertelement <4 x half> [[VECINIT1]], half [[C]], i32 2
-// CHECK-NEXT:[[VECINIT3:%.*]] = insertelement <4 x half> [[VECINIT2]], half [[C]], i32 3
+// CHECK-NEXT:[[FNEG_I:%.*]] = fneg <4 x half> [[B]]
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <4 x half> undef, half [[C]], i32 0
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <4 x half> [[VECINIT_I]], half [[C]], i32 1
+// CHECK-NEXT:[[VECINIT2_I:%.*]] = insertelement <4 x half> [[VECINIT1_I]], half [[C]], i32 2
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <4 x half> [[VECINIT2_I]], half [[C]], i32 3
 // CHECK-NEXT: 

[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks for the updates. I am okay with it now. LGTM. But please wait for NoQ's 
approval. So, this is a gentle ping for you @NoQ :)




Comment at: clang/test/Analysis/trivial-copy-struct.cpp:61
+void ptr1(List* n) {
+  List* n2 = new List(*n); // cctor
+  if (!n->next) {





Comment at: clang/test/Analysis/trivial-copy-struct.cpp:98
+  // w->head.next and n->next are equal
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

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


[PATCH] D134820: [LTO][clang] Teaching Clang to Pass Plugin Options to the AIX Linker

2022-10-03 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 464683.
qiongsiwu1 added a comment.

Address a code review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134820

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/test/Driver/lto-aix.c

Index: clang/test/Driver/lto-aix.c
===
--- /dev/null
+++ clang/test/Driver/lto-aix.c
@@ -0,0 +1,6 @@
+// Test LTO path, mcpu and opt level options
+// RUN: %clang --target=powerpc-ibm-aix -### %s -flto -fuse-ld=ld -O3 2>&1 \
+// RUN:   | FileCheck -check-prefixes=LTOPATH,MCPUOPTLEVEL %s
+//
+// LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
+// MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -190,7 +190,8 @@
  Multilib::flags_list &Flags);
 
 void addX86AlignBranchArgs(const Driver &D, const llvm::opt::ArgList &Args,
-   llvm::opt::ArgStringList &CmdArgs, bool IsLTO);
+   llvm::opt::ArgStringList &CmdArgs, bool IsLTO,
+   const StringRef PluginOptPrefix = "");
 
 void checkAMDGPUCodeObjectVersion(const Driver &D,
   const llvm::opt::ArgList &Args);
@@ -203,7 +204,8 @@
 
 void addMachineOutlinerArgs(const Driver &D, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
-const llvm::Triple &Triple, bool IsLTO);
+const llvm::Triple &Triple, bool IsLTO,
+const StringRef PluginOptPrefix = "");
 
 void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -65,24 +65,28 @@
 using namespace clang;
 using namespace llvm::opt;
 
-static void renderRpassOptions(const ArgList &Args, ArgStringList &CmdArgs) {
+static void renderRpassOptions(const ArgList &Args, ArgStringList &CmdArgs,
+   const StringRef PluginOptPrefix) {
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_EQ))
-CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=-pass-remarks=") +
- A->getValue()));
+CmdArgs.push_back(Args.MakeArgString(
+Twine(PluginOptPrefix) + Twine("-pass-remarks=") + A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_missed_EQ))
-CmdArgs.push_back(Args.MakeArgString(
-Twine("-plugin-opt=-pass-remarks-missed=") + A->getValue()));
+CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) +
+ Twine("-pass-remarks-missed=") +
+ A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
-CmdArgs.push_back(Args.MakeArgString(
-Twine("-plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) +
+ Twine("-pass-remarks-analysis=") +
+ A->getValue()));
 }
 
 static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
  const llvm::Triple &Triple,
  const InputInfo &Input,
- const InputInfo &Output) {
+ const InputInfo &Output,
+ const StringRef PluginOptPrefix) {
   StringRef Format = "yaml";
   if (const Arg *A = Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
 Format = A->getValue();
@@ -96,29 +100,32 @@
 
   assert(!F.empty() && "Cannot determine remarks output name.");
   // Append "opt.ld." to the end of the file name.
-  CmdArgs.push_back(
-  Args.MakeArgString(Twine("-plugin-opt=opt-remarks-filename=") + F +
- Twine(".opt.ld.") + Format));
+  CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) +
+   Twine("opt-remarks-filename=") + F +
+   Twine(".opt.ld.") + Format));
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_foptimization_record_passes_EQ))
 CmdArgs.push_back(Args.MakeArgString(
-Twine("-plugin-opt=opt-remarks-passes=") + A->getValue()));
+ 

[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:2-3
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--global-value-regex "__oclc_daz_opt"
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-emit-llvm-bc -o %t.bc -DLIBRARY %s
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-mlink-builtin-bitcode %t.bc -S -emit-llvm -o - %s | FileCheck %s
+

This is compiling HIP as host. Please add -fcuda-is-device.



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:7
+
+extern unsigned char [[clang::address_space(5)]] __oclc_daz_opt;
+

use `__constant__` instead



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:9
+
+int foo(void) {
+  return __oclc_daz_opt ? 1 : 0;

add `__device__`



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:15
+
+extern int foo(void);
+

add `__device__`



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:17
+
+void bar(void) {
+  foo();

add `__device__`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D133578: [OpenMP][OMPIRBuilder] Add generation of SIMD align assumptions to OMPIRBuilder

2022-10-03 Thread Dominik Adamski via Phabricator via cfe-commits
domada added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2976
 
+  const int DefaultAlignment = 16;
+

jdoerfert wrote:
> domada wrote:
> > jdoerfert wrote:
> > > This doesn't work. Use the data layout for any default values please.
> > I have used pointer ABI alignment as the default value. Is it ok?
> > Clang has separate method to calculate OpenMP default alignment defined in 
> > TargetInfo class ( [[ 
> > https://clang.llvm.org/doxygen/classclang_1_1TargetInfo.html#af0c75e3288adc13601732329c44db147
> >  |  link ]])
> > Unfortunately, there is no simple replacement of this function in 
> > OMPIRBuilder or in Flang driver. There are some requests to expose 
> > TargetInfo data in Clang-independent manner: [[ 
> > https://discourse.llvm.org/t/rfc-targetinfo-library/64342 | RFC1 ]], 
> > [[https://discourse.llvm.org/t/complex-to-libm-conversion-abi-issues/65131 
> > |RFC2]] , but this issue is not solved.
> Let's step back:
> 1) User tells us the alignment via `aligned(X:64)`. This should populate the 
> map in Clang, I would assume.
> 2) User tells us the alignment "implicitly" via `align(Y)`. Again, clang 
> should populate the map with the default/preferred alignment of the type. You 
> can use the function you linked, or use the data layout API to get the 
> preferred alignment.
> 3) User tells us nothing. We should pick the default or, don't annotate 
> anything. If we go with defaults, you need to look up the default for the 
> address space but I don't know why we would annotate anything not provided by 
> the user.
> 
> 
Ad 1) Agree
Ad 2) OK, I will add assertion to ensure that the map is correctly populated 
with the default/preferred alignment if the user specifies only: `align(Y)`.

I was thinking that OMPIRBuilder should pick the default value if the user 
specifies `align(Y)`. Thanks for clarification. 

Ad 3)  I assume that if the user tells us nothing we should not annotate 
anything. I will expect empty map and no generated annotations. Currently we do 
not generate any annotations if there is no align clause.


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

https://reviews.llvm.org/D133578

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


[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 464684.
tomasz-kaminski-sonarsource added a comment.

Applied suggested comment updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/trivial-copy-struct.cpp

Index: clang/test/Analysis/trivial-copy-struct.cpp
===
--- clang/test/Analysis/trivial-copy-struct.cpp
+++ clang/test/Analysis/trivial-copy-struct.cpp
@@ -49,11 +49,53 @@
   if (c.value == 42)
 return;
   clang_analyzer_value(c.value);
-  // expected-warning@-1 {{32s:{ [-2147483648, 2147483647] }}}
-  // The symbol was garbage collected too early, hence we lose the constraints.
+  // expected-warning@-1 {{32s:{ [-2147483648, 41], [43, 2147483647] }}}
+  // Before symbol was garbage collected too early, and we lost the constraints.
   if (c.value != 42)
 return;
 
-  // Dead code should be unreachable
-  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning: Dead code.
+};
+
+void ptr1(List* n) {
+  List* n2 = new List(*n); // ctor
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+void ptr2(List* n) {
+  List* n2 = new List(); // ctor
+  *n2 = *n; // assignment
+  if (!n->next) {
+if (n2->next) {
+  clang_analyzer_warnIfReached(); // unreachable
+}
+  }
+  delete n2;
+}
+
+struct Wrapper {
+  List head;
+  int count;
+};
+
+void nestedLazyCompoundVal(List* n) {
+  Wrapper* w = 0;
+  {
+ Wrapper lw;
+ lw.head = *n;
+ w = new Wrapper(lw);
+  }
+  if (!n->next) {
+if (w->head.next) {
+  // FIXME: Unreachable, w->head is a copy of *n, therefore
+  // w->head.next and n->next are equal
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+  }
+  delete w;
 }
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -411,10 +411,14 @@
 }
 
 void SymbolReaper::markLive(const MemRegion *region) {
-  RegionRoots.insert(region->getBaseRegion());
+  LiveRegionRoots.insert(region->getBaseRegion());
   markElementIndicesLive(region);
 }
 
+void SymbolReaper::markLazilyCopied(const clang::ento::MemRegion *region) {
+  LazilyCopiedRegionRoots.insert(region->getBaseRegion());
+}
+
 void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
   for (auto SR = dyn_cast(region); SR;
SR = dyn_cast(SR->getSuperRegion())) {
@@ -437,8 +441,7 @@
   // is not used later in the path, we can diagnose a leak of a value within
   // that field earlier than, say, the variable that contains the field dies.
   MR = MR->getBaseRegion();
-
-  if (RegionRoots.count(MR))
+  if (LiveRegionRoots.count(MR))
 return true;
 
   if (const auto *SR = dyn_cast(MR))
@@ -454,6 +457,15 @@
   return isa(MR);
 }
 
+bool SymbolReaper::isLazilyCopiedRegion(const MemRegion *MR) const {
+  // TODO: See comment in isLiveRegion.
+  return LazilyCopiedRegionRoots.count(MR->getBaseRegion());
+}
+
+bool SymbolReaper::isReadableRegion(const MemRegion *MR) {
+  return isLiveRegion(MR) || isLazilyCopiedRegion(MR);
+}
+
 bool SymbolReaper::isLive(SymbolRef sym) {
   if (TheLiving.count(sym)) {
 markDependentsLive(sym);
@@ -464,7 +476,7 @@
 
   switch (sym->getKind()) {
   case SymExpr::SymbolRegionValueKind:
-KnownLive = isLiveRegion(cast(sym)->getRegion());
+KnownLive = isReadableRegion(cast(sym)->getRegion());
 break;
   case SymExpr::SymbolConjuredKind:
 KnownLive = false;
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2838,6 +2838,10 @@
   // Is it a LazyCompoundVal?  All referenced regions are live as well.
   if (Optional LCS =
   V.getAs()) {
+// TODO: Make regions referred to by `lazyCompoundVals` that are bound to
+// subregions of the `LCS.getRegion()` also lazily copied.
+if (const MemRegion *R = LCS->getRegion())
+  SymReaper.markLazilyCopied(R);
 
 const RegionStoreManager::SValListTy &Vals = RM.getInterestingValues(*LCS);
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -582,7 +582,12 @@
   SymbolMapTy TheLiving;
   SymbolSetTy M

[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:2-3
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--global-value-regex "__oclc_daz_opt"
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-emit-llvm-bc -o %t.bc -DLIBRARY %s
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-mlink-builtin-bitcode %t.bc -S -emit-llvm -o - %s | FileCheck %s
+

yaxunl wrote:
> This is compiling HIP as host. Please add -fcuda-is-device.
This test should only require that the triple is `amdgcn`. I could potentially 
make the generation of the constants require HIP or OpenMPDevice, or OpenCL is 
enabled if you think that's bad.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:2-3
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--global-value-regex "__oclc_daz_opt"
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-emit-llvm-bc -o %t.bc -DLIBRARY %s
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-mlink-builtin-bitcode %t.bc -S -emit-llvm -o - %s | FileCheck %s
+

jhuber6 wrote:
> yaxunl wrote:
> > This is compiling HIP as host. Please add -fcuda-is-device.
> This test should only require that the triple is `amdgcn`. I could 
> potentially make the generation of the constants require HIP or OpenMPDevice, 
> or OpenCL is enabled if you think that's bad.
I can also change it to just `-x c` if the HIP is the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-10-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D130096#3816149 , @arsenm wrote:

> I'd prefer to avoid spreading special treatment of the device libraries into 
> the backend. The contract is poorly defined and spread around too much as it 
> is






Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:2-3
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--global-value-regex "__oclc_daz_opt"
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-emit-llvm-bc -o %t.bc -DLIBRARY %s
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-mlink-builtin-bitcode %t.bc -S -emit-llvm -o - %s | FileCheck %s
+

jhuber6 wrote:
> jhuber6 wrote:
> > yaxunl wrote:
> > > This is compiling HIP as host. Please add -fcuda-is-device.
> > This test should only require that the triple is `amdgcn`. I could 
> > potentially make the generation of the constants require HIP or 
> > OpenMPDevice, or OpenCL is enabled if you think that's bad.
> I can also change it to just `-x c` if the HIP is the problem.
We probably want these magic constants for C++ code as well, so keying it off 
the triple (at least triple + that we're using rocm / compute stuff, which I 
think is adequately indicated by hsa in the triple) is better. And likewise 
don't want to emit these constants for non-gpu code, e.g. x64 host hip doesn't 
need the daz_opt constant, which also suggests triple is the right hook.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11adae50892e: [Clang] Make offloading flags accept 
'-' and '--' (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -833,7 +833,7 @@
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
-def offload_link : Flag<["--"], "offload-link">, Group,
+def offload_link : Flag<["--", "-"], "offload-link">, Group,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
@@ -933,7 +933,7 @@
   HelpText<"Include PTX for the following GPU architecture (e.g. sm_35) or 
'all'. May be specified more than once.">;
 def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, 
Flags<[NoXarchOption]>,
   HelpText<"Do not include PTX for the following GPU architecture (e.g. sm_35) 
or 'all'. May be specified more than once.">;
-def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>,
+def offload_arch_EQ : Joined<["--", "-"], "offload-arch=">, 
Flags<[NoXarchOption]>,
   HelpText<"CUDA offloading device architecture (e.g. sm_35), or HIP 
offloading target ID in the form of a "
"device architecture followed by target ID features delimited by a 
colon. Each target ID feature "
"is a pre-defined string followed by a plus or minus sign (e.g. 
gfx908:xnack+:sramecc-).  May be "
@@ -945,7 +945,7 @@
   HelpText<"Link clang-offload-bundler bundles for HIP">;
 def no_hip_rt: Flag<["-"], "no-hip-rt">,
   HelpText<"Do not link against HIP runtime libraries">;
-def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
+def no_offload_arch_EQ : Joined<["--", "-"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
   HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, 
gfx906) from the list of devices to compile for. "
"'all' resets the list to its default value.">;
 def emit_static_lib : Flag<["--"], "emit-static-lib">,
@@ -1187,7 +1187,7 @@
 // In the future this option will be supported by other offloading
 // languages and accept other values such as CPU/GPU architectures,
 // offload kinds and target aliases.
-def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
+def offload_EQ : CommaJoined<["--", "-"], "offload=">, Flags<[NoXarchOption]>,
   HelpText<"Specify comma-separated list of offloading target triples (CUDA 
and HIP only)">;
 
 // C++ Coroutines TS
@@ -2626,15 +2626,15 @@
   PosFlag, NegFlag, 
BothFlags<[NoArgumentUnused, HelpHidden]>>;
 def static_openmp: Flag<["-"], "static-openmp">,
   HelpText<"Use the static host OpenMP runtime while linking.">;
-def offload_new_driver : Flag<["--"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def offload_new_driver : Flag<["--", "-"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
   MarshallingInfoFlag>, HelpText<"Use the new 
driver for offloading compilation.">;
-def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def no_offload_new_driver : Flag<["--", "-"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
   HelpText<"Don't Use the new driver for offloading compilation.">;
-def offload_device_only : Flag<["--"], "offload-device-only">,
+def offload_device_only : Flag<["--", "-"], "offload-device-only">,
   HelpText<"Only compile for the offloading device.">;
-def offload_host_only : Flag<["--"], "offload-host-only">,
+def offload_host_only : Flag<["--", "-"], "offload-host-only">,
   HelpText<"Only compile for the offloading host.">;
-def offload_host_device : Flag<["--"], "offload-host-device">,
+def offload_host_device : Flag<["--", "-"], "offload-host-device">,
   HelpText<"Only compile for the offloading host.">;
 def cuda_device_only : Flag<["--"], "cuda-device-only">, 
Alias,
   HelpText<"Compile CUDA code for device only">;


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -833,7 +833,7 @@
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
-def offload_link : Flag<["--"], "offload-link">, Group,
+def offload_link : Flag<["--", "-"], "offload-link">, Group,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, R

[clang] 11adae5 - [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-10-03T10:35:51-05:00
New Revision: 11adae50892e6e94f10ce41bc738a9823a6b3251

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

LOG: [Clang] Make offloading flags accept '-' and '--'

Currently all of the flags beginning with `--offload` such as
`--offload-arch` or `--offload-device-only` require the double-dash
form. However, if a user uses a single dash it will instead name a file
'ffload-arch' for example. This has been the cause of a lot of user
confusion. This patch changes these options to also accept a single
dash. This is similar to many other driver arguments beginning with
`-o`.

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fb3bc378a44d..fb8c4dd9b314 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -833,7 +833,7 @@ def Xopenmp_target_EQ : JoinedAndSeparate<["-"], 
"Xopenmp-target=">, Group, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
-def offload_link : Flag<["--"], "offload-link">, Group,
+def offload_link : Flag<["--", "-"], "offload-link">, Group,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
@@ -933,7 +933,7 @@ def cuda_include_ptx_EQ : Joined<["--"], 
"cuda-include-ptx=">, Flags<[NoXarchOpt
   HelpText<"Include PTX for the following GPU architecture (e.g. sm_35) or 
'all'. May be specified more than once.">;
 def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, 
Flags<[NoXarchOption]>,
   HelpText<"Do not include PTX for the following GPU architecture (e.g. sm_35) 
or 'all'. May be specified more than once.">;
-def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>,
+def offload_arch_EQ : Joined<["--", "-"], "offload-arch=">, 
Flags<[NoXarchOption]>,
   HelpText<"CUDA offloading device architecture (e.g. sm_35), or HIP 
offloading target ID in the form of a "
"device architecture followed by target ID features delimited by a 
colon. Each target ID feature "
"is a pre-defined string followed by a plus or minus sign (e.g. 
gfx908:xnack+:sramecc-).  May be "
@@ -945,7 +945,7 @@ def hip_link : Flag<["--"], "hip-link">,
   HelpText<"Link clang-offload-bundler bundles for HIP">;
 def no_hip_rt: Flag<["-"], "no-hip-rt">,
   HelpText<"Do not link against HIP runtime libraries">;
-def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
+def no_offload_arch_EQ : Joined<["--", "-"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
   HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, 
gfx906) from the list of devices to compile for. "
"'all' resets the list to its default value.">;
 def emit_static_lib : Flag<["--"], "emit-static-lib">,
@@ -1187,7 +1187,7 @@ defm autolink : BoolFOption<"autolink",
 // In the future this option will be supported by other offloading
 // languages and accept other values such as CPU/GPU architectures,
 // offload kinds and target aliases.
-def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
+def offload_EQ : CommaJoined<["--", "-"], "offload=">, Flags<[NoXarchOption]>,
   HelpText<"Specify comma-separated list of offloading target triples (CUDA 
and HIP only)">;
 
 // C++ Coroutines TS
@@ -2626,15 +2626,15 @@ defm openmp_optimistic_collapse : 
BoolFOption<"openmp-optimistic-collapse",
   PosFlag, NegFlag, 
BothFlags<[NoArgumentUnused, HelpHidden]>>;
 def static_openmp: Flag<["-"], "static-openmp">,
   HelpText<"Use the static host OpenMP runtime while linking.">;
-def offload_new_driver : Flag<["--"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def offload_new_driver : Flag<["--", "-"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
   MarshallingInfoFlag>, HelpText<"Use the new 
driver for offloading compilation.">;
-def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def no_offload_new_driver : Flag<["--", "-"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
   HelpText<"Don't Use the new driver for offloading compilation.">;
-def offload_device_only : Flag<["--"], "offload-device-only">,
+def offload_device_only : Flag<["--", "-"], "offload-device-only">,
   HelpText<"Only compile for the offloading device.">;
-def offload_host_only : Flag<["--"], "offload-host-only">,
+def offload_host_only : Flag<["--", "-"], "offload-host-only">,
   H

[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/test/CodeGen/amdgcn-link-control-constants.c:2-3
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--global-value-regex "__oclc_daz_opt"
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-emit-llvm-bc -o %t.bc -DLIBRARY %s
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a 
-mlink-builtin-bitcode %t.bc -S -emit-llvm -o - %s | FileCheck %s
+

JonChesterfield wrote:
> jhuber6 wrote:
> > jhuber6 wrote:
> > > yaxunl wrote:
> > > > This is compiling HIP as host. Please add -fcuda-is-device.
> > > This test should only require that the triple is `amdgcn`. I could 
> > > potentially make the generation of the constants require HIP or 
> > > OpenMPDevice, or OpenCL is enabled if you think that's bad.
> > I can also change it to just `-x c` if the HIP is the problem.
> We probably want these magic constants for C++ code as well, so keying it off 
> the triple (at least triple + that we're using rocm / compute stuff, which I 
> think is adequately indicated by hsa in the triple) is better. And likewise 
> don't want to emit these constants for non-gpu code, e.g. x64 host hip 
> doesn't need the daz_opt constant, which also suggests triple is the right 
> hook.
We don't officially support C on amdgcn but we officially support HIP. I would 
suggest move this to CodeGenCUDA and compile it as HIP, and use HIP syntax.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Single-dash long options starting with `-o` conflict with the short option `-o` 
so I am unsure I like this direction.

> This is similar to many other driver arguments beginning with -o.

What options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think this should be reverted. It's moving in the backward direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D135076#3830914 , @MaskRay wrote:

> Single-dash long options starting with `-o` conflict with the short option 
> `-o` so I am unsure I like this direction.
>
>> However, if a user uses a single dash it will instead name a file 
>> 'ffload-arch' for example.
>
> That's intended. A user should be able to specify an output name 
> `ffload-arch` with `-offload-arch`.

I made this patch primarily because I've gotten tired of getting messages from 
users wondering why their code wasn't offloading to the correct architecture 
only when they used `-offload-arch=`. This is something that's not clearly 
obvious to users and I think it's highly unlikely that a user would want a file 
named `-ffload-arch`.

>> This is similar to many other driver arguments beginning with -o.
>
> What options?

There were just a few I saw after running `clang --help 2>&1 | grep -e '^\ 
*-o`. It was just a handful but I figured having anything more than `-o` meant 
this would be uncontroversial.

In D135076#3830931 , @MaskRay wrote:

> I think this should be reverted. It's moving in the backward direction.

That's fine if you think that this is unacceptable with the existing semantics. 
Maybe an alternative route would be to re-parse `-o` options and give a warning 
if it matches a recognized option? I feel like using `-o` without a space is 
uncommon enough to warrant it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D135076#3830914 , @MaskRay wrote:

> Single-dash long options starting with `-o` conflict with the short option 
> `-o` so I am unsure I like this direction.
>
>> However, if a user uses a single dash it will instead name a file 
>> 'ffload-arch' for example.
>
> That's intended. A user should be able to specify an output name 
> `ffload-arch` with `-offload-arch`.
>
>> This is similar to many other driver arguments beginning with -o.
>
> What options?



  ./bin/clang --help-hidden | grep "  \-o"
-objcmt-allowlist-dir-path=
-objcmt-atomic-property Make migration to 'atomic' properties
-objcmt-migrate-all Enable migration to modern ObjC
-objcmt-migrate-annotation
-objcmt-migrate-designated-init
-objcmt-migrate-instancetype
-objcmt-migrate-literals
-objcmt-migrate-ns-macros
-objcmt-migrate-property-dot-syntax
-objcmt-migrate-property
-objcmt-migrate-protocol-conformance
-objcmt-migrate-readonly-property
-objcmt-migrate-readwrite-property
-objcmt-migrate-subscripting
-objcmt-ns-nonatomic-iosonly
-objcmt-returns-innerpointer-property
-objcmt-whitelist-dir-path=
-object-file-name=
-oWrite output to 

The alternative is to at least warn if users write `-offload...` rather than 
`--offlaod...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D134671: [Driver] Prevent Mips specific code from claiming -mabi argument on other targets.

2022-10-03 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

In D134671#3828197 , @craig.topper 
wrote:

> In D134671#3824644 , 
> @nickdesaulniers wrote:
>
>> I don't think it's an issue for us to work around downstream, but this did 
>> regress support for `-mabi=ms` used in UEFI related build scripts.
>> https://github.com/ClangBuiltLinux/linux/issues/1725
>> Noting it in case others find their way here via bisection. Thanks to 
>> @nathanchance for the report.
>
> Is there an expectation that we honor -mabi=ms and something that matches 
> gcc? The original bug report I was fixing was that we silently ignored it.

No, I don't think so. The kernel was checking `-mabi=ms` to check for the 
existence of `__attribute__((ms_abi))`, which is not as accurate of a check as 
it could have been, since the kernel has the ability to run small programs 
during configuration time, which could have just checked for 
`__attribute__((ms_abi))` directly. The kernel does not use `-mabi=ms` as part 
of its compiler flags anywhere, it only uses the attribute, so I don't think 
there is any value to trying to support `-mabi=ms` unless there is another use 
case for it. We are just going to clean up the `-mabi=ms` check and backport 
it: https://lore.kernel.org/20220929152010.835906-1-nat...@kernel.org/

> I appears clang 7 did warn for this. clang 8 stopped warning, maybe that's 
> when the Mips code was added. If it was, I don't think it was intentional.

Right, I would agree with that assessment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134671

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

There are traditionally some single-dash long options (perhaps classical Mac OS 
style) which conflict with short options. I think nowadays we try to avoid such 
single-dash short options.
(For example, GNU ld now requires all new long options to use two-dashes, after 
knowing the problem with `-omagic`.)

I can make a patch to make cc1 `-o` `Separate` instead of `JoinedOrSeparate`, 
which will hopefully solve your pain of specifying a misspelled `-offloat*` cc1 
option without good diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D134788: [ARM64EC][clang-cl] Add /arm64EC flag

2022-10-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Missing testcase for the case where the warning is triggered?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134788

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D135076#3830972 , @MaskRay wrote:

> There are traditionally some single-dash long options (perhaps classical Mac 
> OS style) which conflict with short options. I think nowadays we try to avoid 
> such single-dash short options.
> (For example, GNU ld now requires all new long options to use two-dashes, 
> after knowing the problem with `-omagic`.)
>
> I can make a patch to make cc1 `-o` `Separate` instead of `JoinedOrSeparate`, 
> which will hopefully solve your pain of specifying a misspelled `-offloat*` 
> cc1 option without good diagnostics.

If that's possible, then that would be a good solution. I figured that allowing 
`-ofoo` was set in stone and this was the less controversial option. Just for 
reference, the problem I commonly encounter with users is the following 
situation

  clang foo.cu -offload-arch=sm_80 -o foo // No offload arch, the  first -o 
isn't observed as its replaced by the second one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

If we end up going with this approach, I wonder if it would be a great time to 
update some of the docs here: 
https://clang.llvm.org/docs/analyzer/developer-docs/RegionStore.html
Usually, we are not doing a great job keeping these documentations up to date. 
I think the logic to determine which symbols and regions are live and how that 
logic interacts with the different types of memory regions might be important 
enough to have some documentation on it.

(Also, I think we should add link to the SA talks at the LLVM Dev Conf., but 
that is completely unrelated to this change.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

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


[PATCH] D134947: [analyzer] Fix liveness of Symbols for values in regions reffered by LazyCompoundVal

2022-10-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

I also like the approach, but wait for @NoQ, he has the most experience in this 
area :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134947

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


[PATCH] D135088: [Clang] make canonical AutoType constraints-free

2022-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: mizvekov, rsmith, erichkeane, aaron.ballman.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As @mizvekov suggested in D134772 . This 
works great for D128750  when
dealing with AutoType's.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135088

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp

Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -82,18 +82,12 @@
   template  class A {};
 
   template  C auto e(A) { return 0; }
-
-  // FIXME: The error here does not make sense.
   template auto e<>(A<>);
-  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
-  // expected-note@-5  {{candidate template ignored: failed template argument deduction}}
-
-  // FIXME: Should be able to instantiate this with no errors.
-  template C auto e(A);
-  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
-  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
-  
-  template C<> auto e<>(A<>);
+  template auto e(A);
+
+  template  C auto d(A) { return 0; }
+  template C<> auto d<>(A<>);
+  template C auto d(A);
 
   template  A c(Ts...);
   int f = e(c(1, 2));
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -7933,12 +7933,26 @@
  : Kind),
 TemplateArgLoc))
   return false;
-  } else if (Kind != Sema::TPL_TemplateTemplateArgumentMatch) {
+  }
+
+  if (Kind != Sema::TPL_TemplateTemplateArgumentMatch &&
+  !isa(Old)) {
 const Expr *NewC = nullptr, *OldC = nullptr;
-if (const auto *TC = cast(New)->getTypeConstraint())
-  NewC = TC->getImmediatelyDeclaredConstraint();
-if (const auto *TC = cast(Old)->getTypeConstraint())
-  OldC = TC->getImmediatelyDeclaredConstraint();
+
+if (isa(New)) {
+  if (const auto *TC = cast(New)->getTypeConstraint())
+NewC = TC->getImmediatelyDeclaredConstraint();
+  if (const auto *TC = cast(Old)->getTypeConstraint())
+OldC = TC->getImmediatelyDeclaredConstraint();
+} else if (isa(New)) {
+  if (const Expr *E = cast(New)
+  ->getPlaceholderTypeConstraint())
+NewC = E;
+  if (const Expr *E = cast(Old)
+  ->getPlaceholderTypeConstraint())
+OldC = E;
+} else
+  llvm_unreachable("unexpected template parameter type");
 
 auto Diagnose = [&] {
   S.Diag(NewC ? NewC->getBeginLoc() : New->getBeginLoc(),
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -8661,10 +8661,11 @@
   // C++2a [class.spaceship]p2 [P2002R0]:
   //   Let R be the declared return type [...]. If R is auto, [...]. Otherwise,
   //   R shall not contain a placeholder type.
-  if (DCK == DefaultedComparisonKind::ThreeWay &&
-  FD->getDeclaredReturnType()->getContainedDeducedType() &&
-  !Context.hasSameType(FD->getDeclaredReturnType(),
-   Context.getAutoDeductType())) {
+  if (QualType RT = FD->getDeclaredReturnType();
+  DCK == DefaultedComparisonKind::ThreeWay &&
+  RT->getContainedDeducedType() &&
+  (!Context.hasSameType(RT, Context.getAutoDeductType()) ||
+   RT->getContainedAutoType()->isConstrained())) {
 Diag(FD->getLocation(),
  diag::err_defaulted_comparison_deduced_return_type_not_auto)
 << (int)DCK << FD->getDeclaredReturnType() << Context.AutoDeductTy
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -529,6 +529,9 @@
   ID.AddInteger(0);
   ID.AddBoolean(NTTP->isParameterPack());
   NTTP->getType().getCanonicalType().Profile(ID);
+  ID.AddBoolean(NTTP->hasPlaceholderTypeConstraint());
+  if (const Expr *E = NTTP->getPlaceholderTypeConstraint())
+E->Profile(ID, C, /*Canonical=*/true);
   continue;
 }
 if (const auto *TTP = dyn_cast(D)) {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -696,7 +696,11 @@
 if (const auto *NTTP = dy

[PATCH] D135088: [Clang] make canonical AutoType constraints-free

2022-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This looks right enough to me with the 1 nit, but let Matheus take a look 
before committing.




Comment at: clang/lib/AST/ASTContext.cpp:699
   ID.AddBoolean(NTTP->isParameterPack());
+  const Expr *Exp = NTTP->getPlaceholderTypeConstraint();
+  ID.AddBoolean(Exp != nullptr);

As a nit, I'd probably just call this `TC` or `TypeConstr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135088

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


[PATCH] D135011: Add sin and cos llvm intrinsics

2022-10-03 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 464730.
bob80905 added a comment.

run git clang-format on changes rather than whole document


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135011

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -59,3 +59,17 @@
   static_assert(!is_const::value);
   static_assert(!is_const::value);
 }
+
+void test_builtin_elementwise_cos() {
+  const float a = 42.0;
+  float b = 42.3;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
+
+void test_builtin_elementwise_sin() {
+  const float a = 42.0;
+  float b = 42.3;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
\ No newline at end of file
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -280,6 +280,27 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_cos(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_cos();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_cos(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_cos(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_cos(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_cos(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
 void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_floor(f);
@@ -322,6 +343,27 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_sin(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_sin();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_sin(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_sin(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_sin(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_sin(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
 void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_trunc(f);
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -333,6 +333,22 @@
   vf2 = __builtin_elementwise_ceil(vf1);
 }
 
+void test_builtin_elementwise_cos(float f1, float f2, double d1, double d2,
+  float4 vf1, float4 vf2) {
+  // CHECK-LABEL: define void @test_builtin_elementwise_cos(
+  // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
+  // CHECK-NEXT:  call float @llvm.cos.f32(float [[F1]])
+  f2 = __builtin_elementwise_cos(f1);
+
+  // CHECK:  [[D1:%.+]] = load double, double* %d1.addr, align 8
+  // CHECK-NEXT: call double @llvm.cos.f64(double [[D1]])
+  d2 = __builtin_elementwise_cos(d1);
+
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call <4 x float> @llvm.cos.v4f32(<4 x float> [[VF1]])
+  vf2 = __builtin_elementwise_cos(vf1);
+}
+
 void test_builtin_elementwise_floor(float f1, float f2, double d1, double d2,
 

[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D135076#3830989 , @jhuber6 wrote:

> In D135076#3830972 , @MaskRay wrote:
>
>> There are traditionally some single-dash long options (perhaps classical Mac 
>> OS style) which conflict with short options. I think nowadays we try to 
>> avoid such single-dash short options.
>> (For example, GNU ld now requires all new long options to use two-dashes, 
>> after knowing the problem with `-omagic`.)
>>
>> I can make a patch to make cc1 `-o` `Separate` instead of 
>> `JoinedOrSeparate`, which will hopefully solve your pain of specifying a 
>> misspelled `-offloat*` cc1 option without good diagnostics.
>
> If that's possible, then that would be a good solution. I figured that 
> allowing `-ofoo` was set in stone and this was the less controversial option. 
> Just for reference, the problem I commonly encounter with users is the 
> following situation

A cc1 specific `Separate` `-o` only helps misspelled `-offload-*`...

>   clang foo.cu -offload-arch=sm_80 -o foo // No offload arch, the  first -o 
> isn't observed as its replaced by the second one.

I think these users have to accept that `-offload-arch=sm_80` means `-o 
ffload-arch=sm_80`.
There are a number of unfortunate `Separate` short options. `-o` is among them 
the most used. Long options have to avoid conflicts with `-o` by not having the 
single-dash form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D134478: BareMetal: detect usr/include/c++/v1 path in sysroot

2022-10-03 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

friendly ping for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134478

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


[PATCH] D135011: Add sin and cos llvm intrinsics

2022-10-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Could you update the title to make it clear this adds new Clang builtins, not 
intrinsics (they are lowered to LLVM intrinsics). The behavior of the new 
builtins should be specified in `LanguageExtensions.rst` 
(https://clang.llvm.org/docs/LanguageExtensions.html#vector-builtins)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135011

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


[PATCH] D135088: [Clang] make canonical AutoType constraints-free

2022-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 464731.
ychen added a comment.

- address @erichkeane's comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135088

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp

Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -82,18 +82,12 @@
   template  class A {};
 
   template  C auto e(A) { return 0; }
-
-  // FIXME: The error here does not make sense.
   template auto e<>(A<>);
-  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
-  // expected-note@-5  {{candidate template ignored: failed template argument deduction}}
-
-  // FIXME: Should be able to instantiate this with no errors.
-  template C auto e(A);
-  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
-  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
-  
-  template C<> auto e<>(A<>);
+  template auto e(A);
+
+  template  C auto d(A) { return 0; }
+  template C<> auto d<>(A<>);
+  template C auto d(A);
 
   template  A c(Ts...);
   int f = e(c(1, 2));
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -7933,12 +7933,26 @@
  : Kind),
 TemplateArgLoc))
   return false;
-  } else if (Kind != Sema::TPL_TemplateTemplateArgumentMatch) {
+  }
+
+  if (Kind != Sema::TPL_TemplateTemplateArgumentMatch &&
+  !isa(Old)) {
 const Expr *NewC = nullptr, *OldC = nullptr;
-if (const auto *TC = cast(New)->getTypeConstraint())
-  NewC = TC->getImmediatelyDeclaredConstraint();
-if (const auto *TC = cast(Old)->getTypeConstraint())
-  OldC = TC->getImmediatelyDeclaredConstraint();
+
+if (isa(New)) {
+  if (const auto *TC = cast(New)->getTypeConstraint())
+NewC = TC->getImmediatelyDeclaredConstraint();
+  if (const auto *TC = cast(Old)->getTypeConstraint())
+OldC = TC->getImmediatelyDeclaredConstraint();
+} else if (isa(New)) {
+  if (const Expr *E = cast(New)
+  ->getPlaceholderTypeConstraint())
+NewC = E;
+  if (const Expr *E = cast(Old)
+  ->getPlaceholderTypeConstraint())
+OldC = E;
+} else
+  llvm_unreachable("unexpected template parameter type");
 
 auto Diagnose = [&] {
   S.Diag(NewC ? NewC->getBeginLoc() : New->getBeginLoc(),
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -8661,10 +8661,11 @@
   // C++2a [class.spaceship]p2 [P2002R0]:
   //   Let R be the declared return type [...]. If R is auto, [...]. Otherwise,
   //   R shall not contain a placeholder type.
-  if (DCK == DefaultedComparisonKind::ThreeWay &&
-  FD->getDeclaredReturnType()->getContainedDeducedType() &&
-  !Context.hasSameType(FD->getDeclaredReturnType(),
-   Context.getAutoDeductType())) {
+  if (QualType RT = FD->getDeclaredReturnType();
+  DCK == DefaultedComparisonKind::ThreeWay &&
+  RT->getContainedDeducedType() &&
+  (!Context.hasSameType(RT, Context.getAutoDeductType()) ||
+   RT->getContainedAutoType()->isConstrained())) {
 Diag(FD->getLocation(),
  diag::err_defaulted_comparison_deduced_return_type_not_auto)
 << (int)DCK << FD->getDeclaredReturnType() << Context.AutoDeductTy
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -529,6 +529,9 @@
   ID.AddInteger(0);
   ID.AddBoolean(NTTP->isParameterPack());
   NTTP->getType().getCanonicalType().Profile(ID);
+  ID.AddBoolean(NTTP->hasPlaceholderTypeConstraint());
+  if (const Expr *E = NTTP->getPlaceholderTypeConstraint())
+E->Profile(ID, C, /*Canonical=*/true);
   continue;
 }
 if (const auto *TTP = dyn_cast(D)) {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -696,7 +696,11 @@
 if (const auto *NTTP = dyn_cast(*P)) {
   ID.AddInteger(1);
   ID.AddBoolean(NTTP->isParameterPack());
+  const Expr *TC = NTTP->getPlaceholderTypeConstraint();
+  ID.AddBoolean(TC != nullptr);
   ID.AddPointer(NTTP->getType().getCanonicalTy

[PATCH] D135088: [Clang] make canonical AutoType constraints-free

2022-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked an inline comment as done.
ychen added a comment.

In D135088#3831183 , @erichkeane 
wrote:

> This looks right enough to me with the 1 nit, but let Matheus take a look 
> before committing.

Thanks for the quick review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135088

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


[PATCH] D135011: Add sin and cos llvm builtins

2022-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Please clarify the commit message (review description) to better explain what 
it is you're doing here, the purpose/etc as well as the documentation requested 
by @fhahn

This also needs release notes.




Comment at: clang/test/SemaCXX/builtins-elementwise-math.cpp:76
+}
\ No newline at end of file


Nit: please make sure this newline is present.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135011

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


[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-10-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:14539
 LangOptions LO = S.getLangOpts();
-if (LO.CPlusPlus || !(LO.C99 && IsAfterAmp))
+if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext(
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)

Sorry, I should have asked more about this subexpresssion.

Our CI is still red for older branches of the Linux kernel ("stable" branches) 
because the kernel only recently started using `-std=gnu11` from `-std=gnu89`.

Why is this considered an error for `-std=gnu89`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

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


[PATCH] D135090: [Clang] fix -Wvoid-ptr-dereference for gnu89

2022-10-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: aaron.ballman, junaire.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Follow up to D134702 ; it looks like we were 
still warning for gnu89
mode.

Link: https://reviews.llvm.org/D134702
Link: 
https://github.com/ClangBuiltLinux/linux/issues/1720#issuecomment-1265738778
Signed-off-by: Nick Desaulniers 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135090

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/no-warn-void-ptr-uneval.c


Index: clang/test/Sema/no-warn-void-ptr-uneval.c
===
--- clang/test/Sema/no-warn-void-ptr-uneval.c
+++ clang/test/Sema/no-warn-void-ptr-uneval.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=gnu89 %s
 
 // expected-no-diagnostics
 void foo(void *vp) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14536,7 +14536,7 @@
 //   [...] the expression to which [the unary * operator] is applied shall
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
-if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext(
+if (LO.CPlusPlus || (!(LO.C99 && IsAfterAmp) && !S.isUnevaluatedContext()))
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
   << LO.CPlusPlus << OpTy << Op->getSourceRange();
   }


Index: clang/test/Sema/no-warn-void-ptr-uneval.c
===
--- clang/test/Sema/no-warn-void-ptr-uneval.c
+++ clang/test/Sema/no-warn-void-ptr-uneval.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=gnu89 %s
 
 // expected-no-diagnostics
 void foo(void *vp) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14536,7 +14536,7 @@
 //   [...] the expression to which [the unary * operator] is applied shall
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
-if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext(
+if (LO.CPlusPlus || (!(LO.C99 && IsAfterAmp) && !S.isUnevaluatedContext()))
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
   << LO.CPlusPlus << OpTy << Op->getSourceRange();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-03 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 464738.
ayzhao edited the summary of this revision.
ayzhao added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  clang/test/CodeGen/P0960R3.cpp
  clang/test/SemaCXX/P0960R3.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp

Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify -Wno-c++2a-extensions
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify=expected,pre20 -Wno-c++2a-extensions
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify=expected,pro20
 
 template  struct enable_ifv {};
 
@@ -20,7 +20,7 @@
 
 template
 struct A {
-// expected-note@-1+ {{candidate constructor}}
+// pre20-note@-1+ {{candidate constructor}}
   explicit(1 << a)
 // expected-note@-1 {{negative shift count -1}}
 // expected-error@-2 {{explicit specifier argument is not a constant expression}}
@@ -28,8 +28,9 @@
 };
 
 A<-1> a(0);
-// expected-error@-1 {{no matching constructor}}
-// expected-note@-2 {{in instantiation of template class}}
+// pre20-error@-1 {{no matching constructor}}
+// pro20-error@-2 {{excess elements in struct initializer}}
+// expected-note@-3 {{in instantiation of template class}}
 
 template
 struct B {
Index: clang/test/SemaCXX/P0960R3.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/P0960R3.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 4{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b[20];
+  int &&c; // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 2{{candidate constructor}}
+  A a;
+  int b[20];
+};
+
+struct D : public C, public A {
+  int a;
+};
+
+void foo() {
+  A a(1954, 9, 21);
+  // expected-error@-1 {{excess elements in struct initializer}}
+  A b(2.1);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A e(-1.2, 9.8);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A s = static_cast(1.1);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A h = (A)3.1;
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+  A i = A(8.7);
+  // expected-warning@-1 {{implicit conversion from 'double' to 'char'}}
+
+  B n(2022, {7, 8});
+  // expected-error@-1 {{no viable conversion from 'int' to 'A'}}
+  B z(A(1), {}, 1);
+  // expected-error@-1 {{reference member 'c' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
+
+  C o(A(1), 1, 2, 3, 4);
+  // expected-error@-1 {{excess elements in struct initializer}}
+  D R(1);
+  // expected-error@-1 {{no viable conversion from 'int' to 'C'}}
+  D I(C(1));
+  // expected-error@-1 {{functional-style cast from 'int' to 'C' is not allowed}}
+  D P(C(A(1)), 1);
+  // expected-error@-1 {{no viable conversion from 'int' to 'A'}}
+
+  int arr1[](0, 1, 2, A(1));
+  // expected-error@-1 {{no viable conversion from 'A' to 'int'}}
+  int arr2[2](0, 1, 2);
+  // expected-error@-1 {{excess elements in array initializer}}
+}
Index: clang/test/CodeGen/P0960R3.cpp
===
--- /dev/null
+++ clang/test/CodeGen/P0960R3.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o - | FileCheck %s
+
+struct A {
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b;
+};
+
+struct C : public B, public A {};
+
+// CHECK-LABEL:   entry:
+// CHECK-NEXT:[[A1:%.*]] = alloca [[STRUCT_A:%.*]], align 8
+// CHECK-NEXT:[[B1:%.*]] = alloca [[

[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-10-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:14539
 LangOptions LO = S.getLangOpts();
-if (LO.CPlusPlus || !(LO.C99 && IsAfterAmp))
+if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext(
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)

nickdesaulniers wrote:
> Sorry, I should have asked more about this subexpresssion.
> 
> Our CI is still red for older branches of the Linux kernel ("stable" 
> branches) because the kernel only recently started using `-std=gnu11` from 
> `-std=gnu89`.
> 
> Why is this considered an error for `-std=gnu89`?
https://reviews.llvm.org/D135090


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

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


[PATCH] D135011: Add sin and cos llvm builtins

2022-10-03 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 464739.
bob80905 added a comment.

- add docs, add new line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135011

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -59,3 +59,17 @@
   static_assert(!is_const::value);
   static_assert(!is_const::value);
 }
+
+void test_builtin_elementwise_cos() {
+  const float a = 42.0;
+  float b = 42.3;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
+
+void test_builtin_elementwise_sin() {
+  const float a = 42.0;
+  float b = 42.3;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -280,6 +280,27 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_cos(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_cos();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_cos(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_cos(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_cos(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_cos(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
 void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_floor(f);
@@ -322,6 +343,27 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_sin(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_sin();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_sin(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_sin(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_sin(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_sin(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
 void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_trunc(f);
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -333,6 +333,22 @@
   vf2 = __builtin_elementwise_ceil(vf1);
 }
 
+void test_builtin_elementwise_cos(float f1, float f2, double d1, double d2,
+  float4 vf1, float4 vf2) {
+  // CHECK-LABEL: define void @test_builtin_elementwise_cos(
+  // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
+  // CHECK-NEXT:  call float @llvm.cos.f32(float [[F1]])
+  f2 = __builtin_elementwise_cos(f1);
+
+  // CHECK:  [[D1:%.+]] = load double, double* %d1.addr, align 8
+  // CHECK-NEXT: call double @llvm.cos.f64(double [[D1]])
+  d2 = __builtin_elementwise_cos(d1);
+
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call <4 x float> @llvm.cos.v4f32(<4 x float> [[VF1]])
+  vf2 = __builtin_elementwise_cos(vf1);
+}
+
 void test_builtin_elementwise_floor(float f1, float f2, double d1, double d2,
   

[clang] 1721404 - [Driver] Remove unneeded RenderAsInput flag

2022-10-03 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-10-03T10:58:34-07:00
New Revision: 1721404b542a7eb120c2aa64c80cb83463291bcd

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

LOG: [Driver] Remove unneeded RenderAsInput flag

RenderAsInput is for -Wa,/-Wl, style options which forward their values
as used by llvm::opt::Arg::renderAsInput. These short options don't use 
RenderAsInput.

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fb8c4dd9b314..655bf0d58d8e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -830,7 +830,7 @@ def Xopenmp_target : Separate<["-"], "Xopenmp-target">, 
Group
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">, 
Group,
   HelpText<"Pass  to the target offloading toolchain identified by 
.">,
   MetaVarName<" ">;
-def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
+def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
 def offload_link : Flag<["--", "-"], "offload-link">, Group,
@@ -855,8 +855,8 @@ def autocomplete : Joined<["--"], "autocomplete=">;
 def bind__at__load : Flag<["-"], "bind_at_load">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
-def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>,
-  HelpText<"Pass -b  to the linker on AIX (only).">, MetaVarName<"">,
+def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput]>,
+  HelpText<"Pass -b  to the linker on AIX">, MetaVarName<"">,
   Group;
 // OpenCL-only Options
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
@@ -4065,7 +4065,7 @@ def nostdincxx : Flag<["-"], "nostdinc++">, 
Flags<[CC1Option]>,
 def nostdlib : Flag<["-"], "nostdlib">, Group;
 def nostdlibxx : Flag<["-"], "nostdlib++">;
 def object : Flag<["-"], "object">;
-def o : JoinedOrSeparate<["-"], "o">, Flags<[NoXarchOption, RenderAsInput,
+def o : JoinedOrSeparate<["-"], "o">, Flags<[NoXarchOption,
   CC1Option, CC1AsOption, FC1Option, FlangOption]>,
   HelpText<"Write output to ">, MetaVarName<"">,
   MarshallingInfoString>;



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


[PATCH] D135011: Add sin and cos llvm builtins

2022-10-03 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 464744.
bob80905 edited the summary of this revision.
bob80905 added a comment.

- add release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135011

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -59,3 +59,17 @@
   static_assert(!is_const::value);
   static_assert(!is_const::value);
 }
+
+void test_builtin_elementwise_cos() {
+  const float a = 42.0;
+  float b = 42.3;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
+
+void test_builtin_elementwise_sin() {
+  const float a = 42.0;
+  float b = 42.3;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -280,6 +280,27 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_cos(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_cos();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_cos(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_cos(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_cos(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_cos(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
 void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_floor(f);
@@ -322,6 +343,27 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_sin(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_sin();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_sin(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_sin(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_sin(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_sin(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
 void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_trunc(f);
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -333,6 +333,22 @@
   vf2 = __builtin_elementwise_ceil(vf1);
 }
 
+void test_builtin_elementwise_cos(float f1, float f2, double d1, double d2,
+  float4 vf1, float4 vf2) {
+  // CHECK-LABEL: define void @test_builtin_elementwise_cos(
+  // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
+  // CHECK-NEXT:  call float @llvm.cos.f32(float [[F1]])
+  f2 = __builtin_elementwise_cos(f1);
+
+  // CHECK:  [[D1:%.+]] = load double, double* %d1.addr, align 8
+  // CHECK-NEXT: call double @llvm.cos.f64(double [[D1]])
+  d2 = __builtin_elementwise_cos(d1);
+
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call <4 x float> @llvm.cos.v4f32(<4 x float> [[VF1]])
+  vf2 = __builtin_elementwise_cos(vf1);
+}
+
 void test_builtin_elementwise_floor(float f

[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

We really want these `--offload-*` users to stick with one canonical form, not 
`-offload-*` in some places while `--offload-*` in other places.

Another angle is that people find `-offload-*` working with a new clang may try 
`-offload-*` on an old clang and get `-o ffload-*`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D135076#3831298 , @MaskRay wrote:

> We really want these `--offload-*` users to stick with one canonical form, 
> not `-offload-*` in some places while `--offload-*` in other places.
>
> Another angle is that people find `-offload-*` working with a new clang may 
> try `-offload-*` on an old clang and get `-o ffload-*`.
>
> And `-offload-*` doesn't help misspelled options.

This is fine, as long as users get more distinct feedback that `-offload-arch` 
isn't doing what they think it does. Normally we'd get some error and a helpful 
suggestion if the option is misspelled, but with `-o` options we don't get 
anything. My only qualm with the current state is that it's not obvious that 
`-offload-arch` is actually `-o ffload-arch` for most cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135091: Load the `_cmd` selector for generated getters/setters of `direct` Objective-C properties.

2022-10-03 Thread Michael Wyman via Phabricator via cfe-commits
mwyman created this revision.
mwyman added reviewers: ahatanak, plotfi, dmaclach.
mwyman added a project: clang.
Herald added a project: All.
mwyman requested review of this revision.
Herald added a subscriber: cfe-commits.

This fixes a bug from https://reviews.llvm.org/D131424 that removed the 
implicit `_cmd` parameter as an argument to `objc_direct` method 
implementations. In many cases the generated getter/setter will call 
`objc_getProperty` or `objc_setProperty`, both of which require the selector of 
the getter/setter; since `_cmd` didn't automatically have backing storage, 
attempting to load the address asserted.

This adds an explicit load of the selector, similar to if it's referenced in an 
`objc_direct` method body; since the getter/setter is entirely synthesized, 
there's no reason to preemptively load the selector and store it locally, so 
the value is directly loaded and no additional storage is created for it.

Added a test that triggers the assert prior to the implementation code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135091

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/direct-method.m


Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -14,6 +14,7 @@
 - (int)getInt __attribute__((objc_direct));
 @property(direct, readonly) int intProperty;
 @property(direct, readonly) int intProperty2;
+@property(direct, readonly) id objectProperty;
 @end
 
 @implementation Root
@@ -167,6 +168,14 @@
 @end
 // CHECK-LABEL: define hidden i32 @"\01-[Root intProperty]"
 
+// Check the synthesized objectProperty calls objc_getProperty(); this also
+// checks that the synthesized method accesses _cmd (or rather loads the
+// selector, as it is an argument to objc_getProperty).
+// CHECK-LABEL: define hidden i8* @"\01-[Root objectProperty]"(
+// CHECK-LABEL: objc_direct_method.cont:
+// CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
+// CHECK: call i8* @objc_getProperty({{.*}})
+
 @interface Foo : Root {
   id __strong _cause_cxx_destruct;
 }
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -1189,8 +1189,17 @@
 // Return (ivar-type) objc_getProperty((id) self, _cmd, offset, true).
 // FIXME: Can't this be simpler? This might even be worse than the
 // corresponding gcc code.
-llvm::Value *cmd =
-  Builder.CreateLoad(GetAddrOfLocalVar(getterMethod->getCmdDecl()), "cmd");
+llvm::Value *cmd;
+if (getterMethod->isDirectMethod()) {
+  // Direct methods do not have the `_cmd` parameter; the selector must be
+  // loaded explicitly. Since it is not otherwise used in the getter, there
+  // is no reason to create a local variable for it.
+  cmd =
+  CGM.getObjCRuntime().GetSelector(*this, getterMethod->getSelector());
+} else {
+  cmd = Builder.CreateLoad(GetAddrOfLocalVar(getterMethod->getCmdDecl()),
+   "cmd");
+}
 llvm::Value *self = Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
   EmitIvarOffset(classImpl->getClassInterface(), ivar);
@@ -1475,10 +1484,18 @@
 
 // Emit objc_setProperty((id) self, _cmd, offset, arg,
 //   , ).
-llvm::Value *cmd =
-  Builder.CreateLoad(GetAddrOfLocalVar(setterMethod->getCmdDecl()));
-llvm::Value *self =
-  Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
+llvm::Value *cmd;
+if (setterMethod->isDirectMethod()) {
+  // Direct methods do not have the `_cmd` parameter; the selector must be
+  // loaded explicitly. Since it is not otherwise used in the setter, there
+  // is no reason to create a local variable for it.
+  cmd =
+  CGM.getObjCRuntime().GetSelector(*this, setterMethod->getSelector());
+} else {
+  cmd = Builder.CreateLoad(GetAddrOfLocalVar(setterMethod->getCmdDecl()),
+   "cmd");
+}
+llvm::Value *self = Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
   EmitIvarOffset(classImpl->getClassInterface(), ivar);
 Address argAddr = GetAddrOfLocalVar(*setterMethod->param_begin());


Index: clang/test/CodeGenObjC/direct-method.m
===
--- clang/test/CodeGenObjC/direct-method.m
+++ clang/test/CodeGenObjC/direct-method.m
@@ -14,6 +14,7 @@
 - (int)getInt __attribute__((objc_direct));
 @property(direct, readonly) int intProperty;
 @property(direct, readonly) int intProperty2;
+@property(direct, readonly) id objectProperty;
 @end
 
 @implementation Root
@@ -167,6 +168,14 @@
 @end
 // CHECK-LABEL: define hidden i32 @"\01-[Root intProperty]"
 
+// Check the synthesized objectProperty calls objc_getProperty(); th

[PATCH] D131424: Remove the unused/undefined _cmd parameter to objc_direct methods.

2022-10-03 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D131424#3828656 , @mwyman wrote:

> In D131424#3828647 , @ahatanak 
> wrote:
>
>> `-fobjc-arc` is needed to see the assertion fail.
>
> Oops, yep I'll send a patch.

Sent https://reviews.llvm.org/D135091


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131424

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D135076#3831307 , @jhuber6 wrote:

> In D135076#3831298 , @MaskRay wrote:
>
>> We really want these `--offload-*` users to stick with one canonical form, 
>> not `-offload-*` in some places while `--offload-*` in other places.
>>
>> Another angle is that people find `-offload-*` working with a new clang may 
>> try `-offload-*` on an old clang and get `-o ffload-*`.
>>
>> And `-offload-*` doesn't help misspelled options.
>
> This is fine, as long as users get more distinct feedback that 
> `-offload-arch` isn't doing what they think it does. Normally we'd get some 
> error and a helpful suggestion if the option is misspelled, but with `-o` 
> options we don't get anything.
> My only qualm with the current state is that it's not obvious that 
> `-offload-arch` is actually `-o ffload-arch` for most cases.

You can make `-oxxx` an error if offloading is used (`-o xxx` is still 
allowed). Then no `--offload-*` needs a `-offload-*` form.

This patch probably provides some convenience but regresses other aspects, and 
I think it should be reverted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D135076#3831340 , @MaskRay wrote:

> In D135076#3831307 , @jhuber6 wrote:
>
>> In D135076#3831298 , @MaskRay 
>> wrote:
>>
>>> We really want these `--offload-*` users to stick with one canonical form, 
>>> not `-offload-*` in some places while `--offload-*` in other places.
>>>
>>> Another angle is that people find `-offload-*` working with a new clang may 
>>> try `-offload-*` on an old clang and get `-o ffload-*`.
>>>
>>> And `-offload-*` doesn't help misspelled options.
>>
>> This is fine, as long as users get more distinct feedback that 
>> `-offload-arch` isn't doing what they think it does. Normally we'd get some 
>> error and a helpful suggestion if the option is misspelled, but with `-o` 
>> options we don't get anything.
>> My only qualm with the current state is that it's not obvious that 
>> `-offload-arch` is actually `-o ffload-arch` for most cases.
>
> You can make `-oxxx` an error if offloading is used (`-o xxx` is still 
> allowed). Then no `--offload-*` needs a `-offload-*` form.

The problem here is that the `--offload-*` options are used to enable the 
offloading toolchain for some targets (e.g. OpenMP). Would a check on `-o' that 
emits a warning if it matches closely a known option work? E.g. `-offload-arch` 
would warn that the user may mean `--offload-arch`.

> This patch probably provides some convenience but regresses other aspects, 
> and I think it should be reverted.

If you think this should be reverted then I'm fine with it. I would like to see 
some kind of solution to this problem however, as I have dealt with this 
problem many times when working with users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D134928: [Sema] Don't treat a non-null template argument as if it were null.

2022-10-03 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp:31
 IP<&tl> ip7; // expected-error{{non-type template argument of type 'int *' is 
not a constant expression}}
+IP<(int*)1> ip8; // expected-error {{non-type template argument does not refer 
to any declaration}}
 

rsmith wrote:
> efriedma wrote:
> > erichkeane wrote:
> > > shafik wrote:
> > > > shafik wrote:
> > > > > It looks like in C++17 mode we catch this case: 
> > > > > https://godbolt.org/z/s43oE5qWE
> > > > Another case to check for:
> > > > 
> > > > ```
> > > > IP<(int*)(1-1)> ip9;
> > > > ```
> > > > 
> > > > In C++11 the wording use to allow `integer constant expressions`
> > > The new diagnostic here is unfortunate.  That 'does not refer to any 
> > > declaration' doesn't really let me know that it is illegal because that 
> > > isn't a NPE.  
> > > 
> > > The 'treat it as a null ptr' here is obviously awful, but I find myself 
> > > wondering if we can do better on this diagnostic trivially enough?
> > It's easy enough to use a different message; we just need to detect the 
> > particular case we're considering, print an error, and return NPV_Error.  
> > But I'm not sure what a better diagnostic looks like.   "standard C++ does 
> > not allow using '(int*)1' as a non-type template argument"?  (The fact that 
> > null is allowed isn't really relevant here.)
> > It looks like in C++17 mode we catch this case: 
> > https://godbolt.org/z/s43oE5qWE
> 
> That's diagnosing the cast, not the template argument value. You can get 
> around the cast diagnostic by forcing constant folding with a 
> `__builtin_constant_p` conditional 
> ([example](https://godbolt.org/z/8f8WWTGeM)). Then we diagnose as
> > :7:4: error: non-type template argument refers to subobject '(int 
> > *)1'
> ... which seems like a worse diagnostic than the C++11 one, because it's not 
> even true.

> That's diagnosing the cast, not the template argument value. You can get 
> around the cast diagnostic by forcing constant folding with a 
> `__builtin_constant_p` conditional 
> ([example](https://godbolt.org/z/8f8WWTGeM)). Then we diagnose as
> > :7:4: error: non-type template argument refers to subobject '(int 
> > *)1'
> ... which seems like a worse diagnostic than the C++11 one, because it's not 
> even true.

Great point, I missed that earlier.

My point was that if we are catching this in C++17 mode maybe we can reuse the 
machinery to catch this other modes as well and fix the diagnostic quality as 
well. Although I realize that may not be easy but worth at least understanding. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134928

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D135076#3831347 , @jhuber6 wrote:

> In D135076#3831340 , @MaskRay wrote:
>
>> In D135076#3831307 , @jhuber6 
>> wrote:
>>
>>> In D135076#3831298 , @MaskRay 
>>> wrote:
>>>
 We really want these `--offload-*` users to stick with one canonical form, 
 not `-offload-*` in some places while `--offload-*` in other places.

 Another angle is that people find `-offload-*` working with a new clang 
 may try `-offload-*` on an old clang and get `-o ffload-*`.

 And `-offload-*` doesn't help misspelled options.
>>>
>>> This is fine, as long as users get more distinct feedback that 
>>> `-offload-arch` isn't doing what they think it does. Normally we'd get some 
>>> error and a helpful suggestion if the option is misspelled, but with `-o` 
>>> options we don't get anything.
>>> My only qualm with the current state is that it's not obvious that 
>>> `-offload-arch` is actually `-o ffload-arch` for most cases.
>>
>> You can make `-oxxx` an error if offloading is used (`-o xxx` is still 
>> allowed). Then no `--offload-*` needs a `-offload-*` form.
>
> The problem here is that the `--offload-*` options are used to enable the 
> offloading toolchain for some targets (e.g. OpenMP). Would a check on `-o' 
> that emits a warning if it matches closely a known option work? E.g. 
> `-offload-arch` would warn that the user may mean `--offload-arch`.

If we don't have `Joined` `-o`, we won't have the option collision problem. But 
we have `Joined` `-o`, and we should not introduce new aliases to collide with 
`-o`.
I am fine if `Joined` `-o` can go away but there are too many uses so such a 
change would be destructive.

My idea is to just disallow `Joined` `-o` when targeting a specific environment 
(e.g. when offloading toolchain is used).

>> This patch probably provides some convenience but regresses other aspects, 
>> and I think it should be reverted.
>
> If you think this should be reverted then I'm fine with it. I would like to 
> see some kind of solution to this problem however, as I have dealt with this 
> problem many times when working with users.

As mentioned, making users stick with more forms instead of all using the 
canonical form will do harm in other aspects.
I have explained these aspects in my previous comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D135076#3831363 , @MaskRay wrote:

> My idea is to just disallow `Joined` `-o` when targeting a specific 
> environment (e.g. when offloading toolchain is used).

This seems difficult as we only know which offloading toolchains are active 
after we fully construct the `Compilation` in the driver. We could potentially 
re-parse some options afterwards to do some static checks like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

2022-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

The Windows premerge failure looks relevant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135045

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


[PATCH] D135093: Revert D135076 "[Clang] Make offloading flags accept '-' and '--'"

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: jhuber6, jdoerfert, JonChesterfield.
Herald added a subscriber: StephenFan.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit 11adae50892e6e94f10ce41bc738a9823a6b3251 
.
There are multiple aspects this change is not appealing.

- They conflict with JoinedOrSeparate `-o`. The old exception `-objc-*` should 
not be used an excuse.
- We generally want new options to be more rigid and avoid multiple spellings.
- A misspelled `--offload-*` option still gets passed as `-o ffloat-*` without 
being detected.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135093

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -833,7 +833,7 @@
 def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
-def offload_link : Flag<["--", "-"], "offload-link">, Group,
+def offload_link : Flag<["--"], "offload-link">, Group,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
@@ -933,7 +933,7 @@
   HelpText<"Include PTX for the following GPU architecture (e.g. sm_35) or 
'all'. May be specified more than once.">;
 def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, 
Flags<[NoXarchOption]>,
   HelpText<"Do not include PTX for the following GPU architecture (e.g. sm_35) 
or 'all'. May be specified more than once.">;
-def offload_arch_EQ : Joined<["--", "-"], "offload-arch=">, 
Flags<[NoXarchOption]>,
+def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>,
   HelpText<"CUDA offloading device architecture (e.g. sm_35), or HIP 
offloading target ID in the form of a "
"device architecture followed by target ID features delimited by a 
colon. Each target ID feature "
"is a pre-defined string followed by a plus or minus sign (e.g. 
gfx908:xnack+:sramecc-).  May be "
@@ -945,7 +945,7 @@
   HelpText<"Link clang-offload-bundler bundles for HIP">;
 def no_hip_rt: Flag<["-"], "no-hip-rt">,
   HelpText<"Do not link against HIP runtime libraries">;
-def no_offload_arch_EQ : Joined<["--", "-"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
+def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, 
Flags<[NoXarchOption]>,
   HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, 
gfx906) from the list of devices to compile for. "
"'all' resets the list to its default value.">;
 def emit_static_lib : Flag<["--"], "emit-static-lib">,
@@ -1187,7 +1187,7 @@
 // In the future this option will be supported by other offloading
 // languages and accept other values such as CPU/GPU architectures,
 // offload kinds and target aliases.
-def offload_EQ : CommaJoined<["--", "-"], "offload=">, Flags<[NoXarchOption]>,
+def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
   HelpText<"Specify comma-separated list of offloading target triples (CUDA 
and HIP only)">;
 
 // C++ Coroutines TS
@@ -2626,15 +2626,15 @@
   PosFlag, NegFlag, 
BothFlags<[NoArgumentUnused, HelpHidden]>>;
 def static_openmp: Flag<["-"], "static-openmp">,
   HelpText<"Use the static host OpenMP runtime while linking.">;
-def offload_new_driver : Flag<["--", "-"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def offload_new_driver : Flag<["--"], "offload-new-driver">, 
Flags<[CC1Option]>, Group,
   MarshallingInfoFlag>, HelpText<"Use the new 
driver for offloading compilation.">;
-def no_offload_new_driver : Flag<["--", "-"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
+def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, 
Flags<[CC1Option]>, Group,
   HelpText<"Don't Use the new driver for offloading compilation.">;
-def offload_device_only : Flag<["--", "-"], "offload-device-only">,
+def offload_device_only : Flag<["--"], "offload-device-only">,
   HelpText<"Only compile for the offloading device.">;
-def offload_host_only : Flag<["--", "-"], "offload-host-only">,
+def offload_host_only : Flag<["--"], "offload-host-only">,
   HelpText<"Only compile for the offloading host.">;
-def offload_host_device : Flag<["--", "-"], "offload-host-device">,
+def offload_host_device : Flag<["--"], "offload-host-device">,
   HelpText<"Only compile for the offloading host.">;
 def cuda_device_only : Flag<["--"], "cuda-device-only">, 
Alias,
   HelpText<"Compile CUDA code for device only">;


Index: clang/include/clang/Driver/Options.td
===
--- clang

[PATCH] D135011: Add sin and cos llvm builtins

2022-10-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Does these support scalable vector types from ARM SVE or RISC-V? I can't 
remember what the rest of the __builtin_elementwise do. I ask because the 
backends will probably crash for them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135011

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


[PATCH] D134874: [Concepts] Fix Concepts on generic lambda in a VarTemplateSpecDecl

2022-10-03 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

I think this looks good. I took more time to compare with the current code and 
it looks to me like behavioral consistency is maintained where desired.

I added one comments requesting a change to a comment (to be made when 
committing the changes) and another comment with a question asked to improve my 
own understanding (that might also indicate that some additional comments would 
be helpful).




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:75-77
+// Add template arguments from a variable template instantiation. For a
+// class-scope explicit specialization, there are no template arguments
+// at this level, but there may be enclosing template arguments.

I think the selected portion of this comment would be better placed inside the 
function before the call to `isClassScopeExplicitSpecialization`.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:255-258
+/// \param ForConstraintInstantiation when collecting arguments,
+/// ForConstraintInstantiation indicates we should continue looking when
+/// encountering a lambda generic call operator, and continue looking for
+/// arguments on an enclosing class template.

More a question than a review comment: why is `ForConstraintInstantiation` 
needed? The behavior it enables seems to me like the behavior that would always 
be desired. When would template arguments for such enclosing templates not be 
wanted?


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

https://reviews.llvm.org/D134874

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


[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping.

To avoid confusion, note that this and D128745 
 are not about C++20 or newer language 
versions. They are implementing DRs which should apply to all language versions 
>= C++11 since the variadic template is involved.

ClangABICompat is used here and in a few other places by D128745 
. If an alternative method is needed, I could 
switch them over all at once in another patch. How about we land this first and 
see how far this goes if it is bad, confusing, etc., feel free to leave a 
comment here or in a bug report, I could address it promptly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-10-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 464767.
jhuber6 added a comment.

Moving test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/amdgcn-control-constants.c
  clang/test/CodeGenCUDA/amdgcn-control-constants.hip

Index: clang/test/CodeGenCUDA/amdgcn-control-constants.hip
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgcn-control-constants.hip
@@ -0,0 +1,46 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-globals --include-generated-funcs --global-value-regex "__oclc_daz_opt"
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -target-cpu gfx90a -emit-llvm-bc -o %t.bc -DLIBRARY %s
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -target-cpu gfx90a -mlink-builtin-bitcode %t.bc -S -emit-llvm -o - %s | FileCheck %s
+
+// REQUIRES: amdgpu-registered-target
+
+#include "Inputs/cuda.h"
+
+#ifdef LIBRARY
+
+extern unsigned char __constant__ __oclc_daz_opt;
+
+__device__ int foo(void) {
+  return __oclc_daz_opt ? 1 : 0;
+}
+
+#else
+
+extern __device__ int foo(void);
+
+__device__ void bar(void) {
+  foo();
+}
+
+#endif
+//.
+// CHECK: @__oclc_daz_opt = internal local_unnamed_addr addrspace(4) constant i8 0, align 1
+//.
+// CHECK-LABEL: define {{[^@]+}}@_Z3barv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = call noundef i32 @_Z3foov() #[[ATTR1:[0-9]+]]
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
+// CHECK-NEXT:[[TMP0:%.*]] = load i8, ptr addrspacecast (ptr addrspace(4) @__oclc_daz_opt to ptr), align 1
+// CHECK-NEXT:[[TOBOOL:%.*]] = icmp ne i8 [[TMP0]], 0
+// CHECK-NEXT:[[TMP1:%.*]] = zext i1 [[TOBOOL]] to i64
+// CHECK-NEXT:[[COND:%.*]] = select i1 [[TOBOOL]], i32 1, i32 0
+// CHECK-NEXT:ret i32 [[COND]]
+//
Index: clang/test/CodeGen/amdgcn-control-constants.c
===
--- /dev/null
+++ clang/test/CodeGen/amdgcn-control-constants.c
@@ -0,0 +1,49 @@
+// Check that we generate all the expected default features for the target.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX90A
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX1030
+
+// GFX90A: @__oclc_daz_opt = linkonce hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_finite_only_opt = linkonce hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_unsafe_math_opt = linkonce hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_correctly_rounded_sqrt32 = linkonce hidden local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_wavefrontsize64 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_ISA_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 9010
+// GFX90A: @__oclc_ABI_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 400
+
+// GFX1030: @__oclc_daz_opt = linkonce hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_finite_only_opt = linkonce hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_unsafe_math_opt = linkonce hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_correctly_rounded_sqrt32 = linkonce hidden local_unnamed_addr addrspace(4) constant i8 1
+// GFX1030: @__oclc_wavefrontsize64 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_ISA_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 10048
+// GFX1030: @__oclc_ABI_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 400
+
+// Check that we can override the wavefront features.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -target-feature +wavefrontsize64 \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=WAVEFRONT
+// WAVEFRONT: @__oclc_wavefrontsize64 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can enable denormalization at zero.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -fdenormal-fp-math-f32=preserve-sign,preserve-sign \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DENORM-AT-ZERO
+// DENORM-AT-ZERO: @_

[PATCH] D134874: [Concepts] Fix Concepts on generic lambda in a VarTemplateSpecDecl

2022-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:255-258
+/// \param ForConstraintInstantiation when collecting arguments,
+/// ForConstraintInstantiation indicates we should continue looking when
+/// encountering a lambda generic call operator, and continue looking for
+/// arguments on an enclosing class template.

tahonermann wrote:
> More a question than a review comment: why is `ForConstraintInstantiation` 
> needed? The behavior it enables seems to me like the behavior that would 
> always be desired. When would template arguments for such enclosing templates 
> not be wanted?
Apparently we DONT always want the full depth.  It is the intent to only get as 
far back as 'needed' in some cases, and ForConstraintInstantiation causes us to 
go 'all the way to the TU' as far as I can tell.  TBH, I'm not super clear on 
it.  I tried at one point just modifying it, and it broke a ton of tests.


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

https://reviews.llvm.org/D134874

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


[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D135076#3831371 , @jhuber6 wrote:

> In D135076#3831363 , @MaskRay wrote:
>
>> My idea is to just disallow `Joined` `-o` when targeting a specific 
>> environment (e.g. when offloading toolchain is used).
>
> This seems difficult as we only know which offloading toolchains are active 
> after we fully construct the `Compilation` in the driver. We could 
> potentially re-parse some options afterwards to do some static checks like 
> this.

I think I'm fine if you want to warning for every Joined `-o` use of 
`ffloading-*`. Created D135093  to revert 
this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D133468: [clang] Implement divergence for TypedefType and UsingType

2022-10-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 464774.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133468

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/sugar-common-types.cpp

Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -112,3 +112,22 @@
 C2 auto t26_3 = (::SB1){};
 N t26 = 0 ? t26_1 : t26_2; // expected-error {{from 'SB1' (aka 'SS1')}}
 N t27 = 0 ? t26_1 : t26_3; // expected-error {{from 'SB1' (aka 'SS1')}}
+
+using RPB1 = X1*;
+using RPX1 = RPB1;
+using RPB1 = Y1*; // redeclared
+using RPY1 = RPB1;
+N t28 = *(RPB1){}; // expected-error {{lvalue of type 'Y1' (aka 'int')}}
+auto t29 = 0 ? (RPX1){} : (RPY1){};
+N t30 = t29;  // expected-error {{lvalue of type 'RPB1' (aka 'int *')}}
+N t31 = *t29; // expected-error {{lvalue of type 'B1' (aka 'int')}}
+
+namespace A { using type1 = X1*; };
+namespace C { using A::type1; };
+using UPX1 = C::type1;
+namespace A { using type1 = Y1*; };  // redeclared
+namespace C { using A::type1; }; // redeclared
+using UPY1 = C::type1;
+auto t32 = 0 ? (UPX1){} : (UPY1){};
+N t33 = t32;  // expected-error {{lvalue of type 'C::type1' (aka 'int *')}}
+N t34 = *t32; // expected-error {{lvalue of type 'B1' (aka 'int')}}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3434,25 +3434,34 @@
 }
 
 TypedefType::TypedefType(TypeClass tc, const TypedefNameDecl *D,
- QualType underlying, QualType can)
-: Type(tc, can, toSemanticDependence(underlying->getDependence())),
+ QualType Underlying, QualType can)
+: Type(tc, can, toSemanticDependence(can->getDependence())),
   Decl(const_cast(D)) {
   assert(!isa(can) && "Invalid canonical type");
+  TypedefBits.hasTypeDifferentFromDecl = !Underlying.isNull();
+  if (!typeMatchesDecl())
+*getTrailingObjects() = Underlying;
 }
 
 QualType TypedefType::desugar() const {
-  return getDecl()->getUnderlyingType();
+  return typeMatchesDecl() ? Decl->getUnderlyingType()
+   : *getTrailingObjects();
 }
 
 UsingType::UsingType(const UsingShadowDecl *Found, QualType Underlying,
  QualType Canon)
-: Type(Using, Canon, toSemanticDependence(Underlying->getDependence())),
+: Type(Using, Canon, toSemanticDependence(Canon->getDependence())),
   Found(const_cast(Found)) {
-  assert(Underlying == getUnderlyingType());
+  UsingBits.hasTypeDifferentFromDecl = !Underlying.isNull();
+  if (!typeMatchesDecl())
+*getTrailingObjects() = Underlying;
 }
 
 QualType UsingType::getUnderlyingType() const {
-  return QualType(cast(Found->getTargetDecl())->getTypeForDecl(), 0);
+  return typeMatchesDecl()
+ ? QualType(
+   cast(Found->getTargetDecl())->getTypeForDecl(), 0)
+ : *getTrailingObjects();
 }
 
 QualType MacroQualifiedType::desugar() const { return getUnderlyingType(); }
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -1543,10 +1543,14 @@
 
 void TextNodeDumper::VisitUsingType(const UsingType *T) {
   dumpDeclRef(T->getFoundDecl());
+  if (!T->typeMatchesDecl())
+OS << " divergent";
 }
 
 void TextNodeDumper::VisitTypedefType(const TypedefType *T) {
   dumpDeclRef(T->getDecl());
+  if (!T->typeMatchesDecl())
+OS << " divergent";
 }
 
 void TextNodeDumper::VisitUnaryTransformType(const UnaryTransformType *T) {
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -530,6 +530,14 @@
 
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
+  if (!TT->typeMatchesDecl())
+JOS.attribute("type", createQualType(TT->desugar()));
+}
+
+void JSONNodeDumper::VisitUsingType(const UsingType *TT) {
+  JOS.attribute("decl", createBareDeclRef(TT->getFoundDecl()));
+  if (!TT->typeMatchesDecl())
+JOS.attribute("type", createQualType(TT->desugar()));
 }
 
 void JSONNodeDumper::VisitFunctionType(const FunctionType *T) {
Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ cla

[PATCH] D135076: [Clang] Make offloading flags accept '-' and '--'

2022-10-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Another idea is to reject multiple `-o` if some are used as the `Joined` form. 
Note: multiple `Separate` `-o` should be allowed.
It will not catch `-offload-*` when `-o output` is not specified, but is 
probably useful enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135076

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


[PATCH] D134791: [clang] Unify Sema and CodeGen implementation of isFlexibleArrayMemberExpr

2022-10-03 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@aaron.ballman : gentle ping :-)


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

https://reviews.llvm.org/D134791

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


[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-10-03 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@martong

> So, the intersection should be empty in the above mentioned ambiguous case, 
> shouldn't' it?

No. My current implementation doesn't contain this check in ConstraintAssignor 
in favor of the solution simplification. It'll be added in the next patches.

But still I think, this solution is not accomplished. Consider next. Say, 
symbol `(char)(int x)` is associated to the range `[42, 42]`, and can be 
simplified to constant `42 of char`. And `(int x)` is associated to the range 
`[43, 43]` Your patch will omit looking into the symbol itself and unwrap it 
starting visiting the operand instead. Thus, it will return the constant 43 for 
`(int x)`.
Moreover, if `(int x)` is 43, it will contradict to 42 (aka infeasible state). 
We also have no decision what to return in this case.

For me, this is really uncertain patch that I'm not 100% sure in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126481

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


  1   2   >