[PATCH] D109950: [Clang] Enable IC/IF mode for __ibm128

2021-09-17 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: nemanjai, hubert.reinterpretcast, rjmccall, PowerPC, 
aaron.ballman.
qiucf requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As for 128-bit floating points on PPC, compiler should have three machine modes:

- IFmode, Always IBM extended double
- KFmode, Always IEEE 754R 128-bit floating point (implemented in D80374 
)
- TFmode, Matches the default for long double
  - If -mabi=ieeelongdouble, TFmode is IEEE 754R 128-bit floating point, and 
the L/l suffixes produces IEEE 754R constants
  - If -mabi=ibmlongdouble, TFmode is IBM extended double, and the L/l suffixes 
produces IBM extended double constants


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109950

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-mode.c

Index: clang/test/Sema/attr-mode.c
===
--- clang/test/Sema/attr-mode.c
+++ clang/test/Sema/attr-mode.c
@@ -92,6 +92,12 @@
 void f_ft128_complex_arg(_Complex long double *x);
 void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
 void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
+typedef float w128ibm __attribute__((mode(IF)));
+typedef _Complex float cw128ibm __attribute__((mode(IC)));
+void f_ibm128_arg(__ibm128 *x);
+void f_ibm128_complex_arg(_Complex __ibm128 *x);
+void test_IFtype(w128ibm *a) { f_ibm128_arg(a); }
+void test_ICtype(cw128ibm *a) { f_ibm128_complex_arg(a); }
 #elif TEST_F128_PPC64
 typedef int invalid_7 __attribute((mode(KF))); // expected-error{{type of machine mode does not match type of base type}}
 typedef int invalid_8 __attribute((mode(KI))); // expected-error{{unknown machine mode}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4203,9 +4203,10 @@
 /// attribute.
 static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth,
  bool &IntegerMode, bool &ComplexMode,
- bool &ExplicitIEEE) {
+ TargetInfo::RealType &ExplicitType) {
   IntegerMode = true;
   ComplexMode = false;
+  ExplicitType = TargetInfo::NoFloat;
   switch (Str.size()) {
   case 2:
 switch (Str[0]) {
@@ -4225,13 +4226,17 @@
   DestWidth = 96;
   break;
 case 'K': // KFmode - IEEE quad precision (__float128)
-  ExplicitIEEE = true;
+  ExplicitType = TargetInfo::Float128;
   DestWidth = Str[1] == 'I' ? 0 : 128;
   break;
 case 'T':
-  ExplicitIEEE = false;
+  ExplicitType = TargetInfo::LongDouble;
   DestWidth = 128;
   break;
+case 'I':
+  ExplicitType = TargetInfo::Ibm128;
+  DestWidth = Str[1] == 'I' ? 0 : 128;
+  break;
 }
 if (Str[1] == 'F') {
   IntegerMode = false;
@@ -4290,7 +4295,7 @@
   unsigned DestWidth = 0;
   bool IntegerMode = true;
   bool ComplexMode = false;
-  bool ExplicitIEEE = false;
+  TargetInfo::RealType ExplicitType = TargetInfo::NoFloat;
   llvm::APInt VectorSize(64, 0);
   if (Str.size() >= 4 && Str[0] == 'V') {
 // Minimal length of vector mode is 4: 'V' + NUMBER(>=1) + TYPE(>=2).
@@ -4303,7 +4308,7 @@
 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
 VectorSize.isPowerOf2()) {
   parseModeAttrArg(*this, Str.substr(VectorStringLength + 1), DestWidth,
-   IntegerMode, ComplexMode, ExplicitIEEE);
+   IntegerMode, ComplexMode, ExplicitType);
   // Avoid duplicate warning from template instantiation.
   if (!InInstantiation)
 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
@@ -4314,7 +4319,7 @@
 
   if (!VectorSize)
 parseModeAttrArg(*this, Str, DestWidth, IntegerMode, ComplexMode,
- ExplicitIEEE);
+ ExplicitType);
 
   // FIXME: Sync this with InitializePredefinedMacros; we need to match int8_t
   // and friends, at least with glibc.
@@ -4380,7 +4385,7 @@
 NewElemTy = Context.getIntTypeForBitwidth(DestWidth,
   OldElemTy->isSignedIntegerType());
   else
-NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitIEEE);
+NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
 
   if (NewElemTy.isNull()) {
 Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -279,8 +279,8 @@
   return NoInt;
 }
 
-TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth,
-  

[PATCH] D109517: [Clang][ARM][AArch64] Add support for Armv9-A, Armv9.1-A and Armv9.2-A

2021-09-17 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks, looks reasonable to me.




Comment at: llvm/unittests/Support/TargetParserTest.cpp:495
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(
+  testARMArch("armv9-a", "generic", "v9a",

vhscampos wrote:
> SjoerdMeijer wrote:
> > I haven't looked, but in these target parser tests, do we also not need to 
> > check the architecture descriptions?
> > Copied this for example from the target parser def file:
> > 
> >  (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
> >   ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS |
> >   ARM::AEK_DOTPROD)
> If I understand it correctly, we only check architecture extensions for CPUs, 
> not for the architectures themselves.
Ah yeah, I confused it with that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109517

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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Josh Learn via Phabricator via cfe-commits
guitard0g created this revision.
guitard0g requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently constructor initializer lists sometimes format incorrectly
when there is a preprocessor directive in the middle of the list.
This patch fixes the issue when parsing the initilizer list by
ignoring the preprocessor directive when checking if a block is
part of an initializer list.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109951

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,38 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int &i) { i.~int(); }");
   verifyFormat("void F(int &i) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -459,6 +459,17 @@
   ++ReadTokens;
 } while (NextTok->is(tok::comment));
 
+// Skip over preprocessor lines, otherwise we may not
+// properly diagnose the block as a braced intializer
+// if the comma separator appears after the pp directive.
+if (NextTok->is(tok::hash)) {
+  ScopedMacroState MacroState(*Line, Tokens, NextTok);
+  do {
+NextTok = Tokens->getNextToken();
+++ReadTokens;
+  } while (NextTok->isNot(tok::eof));
+}
+
 switch (Tok->Tok.getKind()) {
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,38 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int &i) { i.~int(); }");
   verifyFormat("void F(int &i) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -459,6 +459,17 @@
   ++ReadTokens;
 } while (NextTok->is(tok::comment));
 
+// Skip over preprocessor lines, otherwise we may not
+// properly diagnose the block as a braced intializer
+// if the comma separator appears after the pp directive.
+if (NextTok->is(tok::hash)) {
+  ScopedMacroState MacroState(*Line, Tokens, NextTok);
+  do {
+ 

[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

was there a bug report against this? what was it doing before?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[clang] 0195f86 - [Clang] Fix long double availability check

2021-09-17 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2021-09-17T15:24:06+08:00
New Revision: 0195f8621f1814967f9cd3ef51ee61117e914299

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

LOG: [Clang] Fix long double availability check

fae0dfa changed code to check 128-bit float availability, since it
introduced a new 128-bit double type on PowerPC. However, there're other
long float types besides IEEE float128 and PPC double-double requiring
this feature.

Reviewed By: ronlieb

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

Added: 
clang/test/OpenMP/amdgcn_ldbl_check.cpp

Modified: 
clang/lib/Sema/Sema.cpp

Removed: 




diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a9867697a4c31..0b936d60fc5ee 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@ void Sema::checkDeviceDecl(ValueDecl *D, SourceLocation 
Loc) {
 bool LongDoubleMismatched = false;
 if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
   const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(Ty);
-  if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-  &Sem != &Context.getTargetInfo().getLongDoubleFormat())
+  if ((&Sem != &llvm::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
+  (&Sem == &llvm::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasIbm128Type()))
 LongDoubleMismatched = true;
 }
 

diff  --git a/clang/test/OpenMP/amdgcn_ldbl_check.cpp 
b/clang/test/OpenMP/amdgcn_ldbl_check.cpp
new file mode 100644
index 0..8971da779c12a
--- /dev/null
+++ b/clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 
-fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device 
-fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+   return (double)a;
+}
+
+int main()
+{
+   auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+   {
+#pragma omp teams num_teams(1) thread_limit(4)
+   {
+   a += 1._X;
+   }
+   }
+  print(a);
+   return 0;
+}



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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Josh Learn via Phabricator via cfe-commits
guitard0g added a comment.

@MyDeveloperDay This is an issue a coworker pointed out to me. Previously this 
code:

  Foo::Foo(int x)
  : _x { x }
  #if DEBUG
  , _y { 0 }
  #endif
  {
  }

would format into the following:

  Foo::Foo(int x)
  : _x
  {
  x
  }
  #if DEBUG
  , _y
  {
  0
  }
  #endif
  {
  }

whereas this code without the preprocessor directive:

  Foo::Foo(int x)
  : _x { x }
  , _y { 0 }
  {
  }

Is properly formatted with no changes made by clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Josh Learn via Phabricator via cfe-commits
guitard0g updated this revision to Diff 373158.
guitard0g added a comment.

Removing useless line from test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,37 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int &i) { i.~int(); }");
   verifyFormat("void F(int &i) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -459,6 +459,17 @@
   ++ReadTokens;
 } while (NextTok->is(tok::comment));
 
+// Skip over preprocessor lines, otherwise we may not
+// properly diagnose the block as a braced intializer
+// if the comma separator appears after the pp directive.
+if (NextTok->is(tok::hash)) {
+  ScopedMacroState MacroState(*Line, Tokens, NextTok);
+  do {
+NextTok = Tokens->getNextToken();
+++ReadTokens;
+  } while (NextTok->isNot(tok::eof));
+}
+
 switch (Tok->Tok.getKind()) {
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,37 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int &i) { i.~int(); }");
   verifyFormat("void F(int &i) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -459,6 +459,17 @@
   ++ReadTokens;
 } while (NextTok->is(tok::comment));
 
+// Skip over preprocessor lines, otherwise we may not
+// properly diagnose the block as a braced intializer
+// if the comma separator appears after the pp directive.
+if (NextTok->is(tok::hash)) {
+  ScopedMacroState MacroState(*Line, Tokens, NextTok);
+  do {
+NextTok = Tokens->getNextToken();
+++ReadTokens;
+  } while (NextTok->isNot(tok::eof));
+}
+
 switch (Tok->Tok.getKind()) {
 case tok::l_brace:
   if (Style.Language == FormatStyle::LK_JavaScript && PrevTok) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-

[PATCH] D109799: [RISCV] add Half-precision test for load/store

2021-09-17 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 373161.
achieveartificialintelligence added a comment.

add more Half-precision tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109799

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vcompress.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfabs.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfclass.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfirst.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfncvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfneg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfnmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfrdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfrec7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfrsqrt7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfsgnj.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfsqrt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredosum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vid.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/viota.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vleff.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmclr.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfeq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmflt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmnand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmnor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsbf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmseq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmset.c
  clang/test/Code

[PATCH] D109894: [clangd] Bail-out when an empty compile flag is encountered

2021-09-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> I do half wonder whether we're going to get 3 steps further and then crash 
> again when we call Command.front() :-)

I actually couldn't find any other places this could happen today (we seem to 
check for non-emptiness of compile commands most of the time). But I hadn't 
look into clang, apparently `createInvocationFromCommandLine` also assumes that.
Adding an assert and pushing the check to callers, as in theory they should 
probably check for it long before since many tools perform some sort of command 
line mangling. LMK if the check should reside in the callee instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109894

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


[PATCH] D109894: [clangd] Bail-out when an empty compile flag is encountered

2021-09-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 373163.
kadircet added a comment.
Herald added a project: clang.

- Also handle OOB access while creating compiler invocation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109894

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang-tools-extra/clangd/unittests/CompilerTests.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp

Index: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -30,6 +30,7 @@
 ArrayRef ArgList, IntrusiveRefCntPtr Diags,
 IntrusiveRefCntPtr VFS, bool ShouldRecoverOnErorrs,
 std::vector *CC1Args) {
+  assert(!ArgList.empty());
   if (!Diags.get()) {
 // No diagnostics engine was provided, so create our own diagnostics object
 // with the default options.
Index: clang-tools-extra/clangd/unittests/CompilerTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompilerTests.cpp
+++ clang-tools-extra/clangd/unittests/CompilerTests.cpp
@@ -102,6 +102,17 @@
   EXPECT_EQ(Opts.ProgramAction, frontend::ActionKind::ParseSyntaxOnly);
   EXPECT_TRUE(Opts.ActionName.empty());
 }
+
+TEST(BuildCompilerInvocation, EmptyArgs) {
+  MockFS FS;
+  IgnoreDiagnostics Diags;
+  TestTU TU;
+  auto Inputs = TU.inputs(FS);
+  Inputs.CompileCommand.CommandLine.clear();
+
+  // No crash.
+  EXPECT_EQ(buildCompilerInvocation(Inputs, Diags), nullptr);
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -396,6 +396,13 @@
   llvm::count_if(Args, [](llvm::StringRef Arg) { return Arg == "-arch"; }),
   1);
 }
+
+TEST(CommandMangler, EmptyArgs) {
+  const auto Mangler = CommandMangler::forTests();
+  std::vector Args = {};
+  // Make sure we don't crash.
+  Mangler.adjust(Args, "foo.cc");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -83,6 +83,8 @@
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
 std::vector *CC1Args) {
+  if (Inputs.CompileCommand.CommandLine.empty())
+return nullptr;
   std::vector ArgStrs;
   for (const auto &S : Inputs.CompileCommand.CommandLine)
 ArgStrs.push_back(S.c_str());
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -198,22 +198,26 @@
 void CommandMangler::adjust(std::vector &Cmd,
 llvm::StringRef File) const {
   trace::Span S("AdjustCompileFlags");
+  // Most of the modifications below assumes the Cmd starts with a driver name.
+  // We might consider injecting a generic driver name like "cc" or "c++", but
+  // a Cmd missing the driver is probably rare enough in practice and errnous.
+  if (Cmd.empty())
+return;
   auto &OptTable = clang::driver::getDriverOptTable();
   // OriginalArgs needs to outlive ArgList.
   llvm::SmallVector OriginalArgs;
   OriginalArgs.reserve(Cmd.size());
   for (const auto &S : Cmd)
 OriginalArgs.push_back(S.c_str());
-  bool IsCLMode =
-  !OriginalArgs.empty() &&
-  driver::IsClangCL(driver::getDriverMode(
-  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
+  bool IsCLMode = driver::IsClangCL(driver::getDriverMode(
+  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
   // ParseArgs propagates missig arg/opt counts on error, but preserves
   // everything it could parse in ArgList. So we just ignore those counts.
   unsigned IgnoredCount;
   // Drop the executable name, as ParseArgs doesn't expect it. This means
   // indices are actually of by one between ArgList and OriginalArgs.
-  auto ArgList = OptTable.ParseArgs(
+  llvm::opt::InputArgList ArgList;
+  ArgList = OptTable.ParseArgs(
   llvm::makeArrayRef(OriginalArgs).drop_front(), IgnoredCount, IgnoredCount,
   /*FlagsToInclude=*/
   IsCLMode ? (driver::options::CLOption | driver::options::CoreOption)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-comm

[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Josh Learn via Phabricator via cfe-commits
guitard0g updated this revision to Diff 373167.
guitard0g added a comment.

Fix failing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,37 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int &i) { i.~int(); }");
   verifyFormat("void F(int &i) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -489,6 +489,17 @@
 if (Style.Language == FormatStyle::LK_Proto) {
   ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
 } else {
+  // Skip NextTok over preprocessor lines, otherwise we may not
+  // properly diagnose the block as a braced intializer
+  // if the comma separator appears after the pp directive.
+  if (NextTok->is(tok::hash)) {
+ScopedMacroState MacroState(*Line, Tokens, NextTok);
+do {
+  NextTok = Tokens->getNextToken();
+  ++ReadTokens;
+} while (NextTok->isNot(tok::eof));
+  }
+
   // Using OriginalColumn to distinguish between ObjC methods and
   // binary operators is a bit hacky.
   bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,37 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int &i) { i.~int(); }");
   verifyFormat("void F(int &i) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -489,6 +489,17 @@
 if (Style.Language == FormatStyle::LK_Proto) {
   ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
 } else {
+  // Skip NextTok over preprocessor lines, otherwise we may not
+  // properly diagnose the block as a braced intializer
+  // if the comma separator appears after the pp directive.
+  if (NextTok->is(tok::hash)) {
+ScopedMacroState MacroState(*Line, Tokens, NextTok);
+do {
+  NextTok = Tokens->getNextToken();
+

[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-09-17 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 373170.
achieveartificialintelligence added a comment.

fix CI error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZdinx.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZhinx.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-valid.s
  llvm/test/MC/RISCV/rv32zfinx-invalid.s
  llvm/test/MC/RISCV/rv32zfinx-valid.s
  llvm/test/MC/RISCV/rv32zhinx-invalid.s
  llvm/test/MC/RISCV/rv32zhinx-valid.s
  llvm/test/MC/RISCV/rv32zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv32zhinxmin-valid.s
  llvm/test/MC/RISCV/rv64zdinx-invalid.s
  llvm/test/MC/RISCV/rv64zdinx-valid.s
  llvm/test/MC/RISCV/rv64zfinx-invalid.s
  llvm/test/MC/RISCV/rv64zfinx-valid.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinx-valid.s
  llvm/test/MC/RISCV/rv64zhinxmin-valid.s
  llvm/test/MC/RISCV/rvzdinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzhinx-aliases-valid.s

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,83 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
+##===--===##
+
+# CHECK-INST: fsgnjx.h s1, s2, s2
+# CHECK-ALIAS: fabs.h s1, s2
+fabs.h s1, s2
+# CHECK-INST: fsgnjn.h s2, s3, s3
+# CHECK-ALIAS: fneg.h s2, s3
+fneg.h s2, s3
+
+# CHECK-INST: flt.h tp, s6, s5
+# CHECK-ALIAS: flt.h tp, s6, s5
+fgt.h x4, s5, s6
+# CHECK-INST: fle.h t2, s1, s0
+# CHECK-ALIAS: fle.h t2, s1, s0
+fge.h x7, x8, x9
+
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3{{[[:space:]]}}
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7{{[[:space:]]}}
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5{{[[:space:]]}}
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9{{[[:space:]]}}
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3{{[[:space:]]}}
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6{{[[:space:]]}}
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2{{[[:space:]]}}
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5{{[[:space:]]}}
+fdiv.h s3, s4, s5
+# CHECK-INST: fsqrt.h s6, s7, dyn
+# CHECK-ALIAS: fsqrt.h s6, s7{{[[:space:]]}}
+fsqrt.h s6, s7
+# CHECK-INST: fcvt.w.h a0, s5, dyn
+# CHECK-ALIAS: fcvt.w.h a0, s5{{[[:space:]]}}
+fcvt.w.h a0, s5
+# CHECK-INST: fcvt.wu.h a1, s6, dyn
+# CHECK-ALIAS: fcvt.wu.h a1, s6{{[[:space:]]}}
+fcvt.wu.h a1, s6

[clang] 37cdc7e - [OpenCL] Supports optional pipe types in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-17T09:56:20+01:00
New Revision: 37cdc7ebd9a373100cbbe39f5b9be7a4e4f7813d

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

LOG: [OpenCL] Supports optional pipe types in C++ for OpenCL 2021

Adds support for a feature macro `__opencl_c_pipes` in C++ for
OpenCL 2021 enabling a respective optional core feature from
OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

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

Added: 


Modified: 
clang/lib/Basic/TargetInfo.cpp
clang/test/CodeGenOpenCL/address-spaces-mangling.cl
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/pipe_types.cl
clang/test/CodeGenOpenCL/pipe_types_mangling.cl
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Removed: 




diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 133391b0d20c4..a70abd1c9243b 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -413,9 +413,8 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, 
LangOptions &Opts) {
   const auto &OpenCLFeaturesMap = getSupportedOpenCLOpts();
   Opts.OpenCLGenericAddressSpace = hasFeatureEnabled(
   OpenCLFeaturesMap, "__opencl_c_generic_address_space");
-  if (Opts.OpenCLVersion == 300)
-Opts.OpenCLPipes =
-hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
+  Opts.OpenCLPipes =
+  hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
 }
   }
 

diff  --git a/clang/test/CodeGenOpenCL/address-spaces-mangling.cl 
b/clang/test/CodeGenOpenCL/address-spaces-mangling.cl
index 7699c6f5d459c..32ba5d4c3a186 100644
--- a/clang/test/CodeGenOpenCL/address-spaces-mangling.cl
+++ b/clang/test/CodeGenOpenCL/address-spaces-mangling.cl
@@ -10,6 +10,8 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -emit-llvm -o 
- | FileCheck -check-prefix=OCL-12 %s
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL3.0 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck 
-check-prefix=OCL-20 %s
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL3.0 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -emit-llvm -o - | 
FileCheck -check-prefix=OCL-12 %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++2021 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck 
-check-prefix=OCL-20 %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -emit-llvm -o - | 
FileCheck -check-prefix=OCL-12 %s
 
 // We can't name this f as private is equivalent to default
 // no specifier given address space so we get multiple definition

diff  --git a/clang/test/CodeGenOpenCL/address-spaces.cl 
b/clang/test/CodeGenOpenCL/address-spaces.cl
index 97236ffcd7734..b1c73561ade84 100644
--- a/clang/test/CodeGenOpenCL/address-spaces.cl
+++ b/clang/test/CodeGenOpenCL/address-spaces.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,SPIR
 // RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes 
-ffake-address-space-map -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,SPIR
+// RUN: %clang_cc1 %s -O0 -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes 
-ffake-address-space-map -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,SPIR
 // RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map 
-emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20SPIR
 // RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -emit-llvm -o - | 
FileCheck --check-prefixes=CHECK,AMDGCN %s
 // RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 -emit-llvm 
-o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
@@ -91,13 +92,13 @@ void f(int *arg) {
 
 typedef int int_td;
 typedef int *intp_td;
-// SPIR: define {{(dso_local )?}}void @test_typedef(i32 addrspace(1)* %x, i32 
addrspace(2)* %y, i32* %z)
+// SPIR: define {{(dso_local )?}}void @{{.*}}test_typedef{{.*}}(i32 
addrspace(1)* %x, i32 addrspace(2)* %y, i32* %z)
 void test_typedef(global int_td *x, constant int_td *y, intp_td z) {
   *x = *y;
   *z = 0;
 }
 
-// SPIR: define {{(dso_local )?}}void @test_struct()
+// SPIR: define {{(dso_local )?}}void @{{.*}}test_struct{{.*}}()
 void test_struct() {
   // SPIR: %ps = alloca %struct.S*
   // CL20SPIR: %ps = alloca %struct.S addrspace(4)*
@@ -111,11 +112,11 @@ void test_struct() {
 #endif
 }
 
-// SPIR-LABEL: define {{(dso_local )?}}void @test

[PATCH] D109306: [OpenCL] Supports optional pipe types in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas 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 rG37cdc7ebd9a3: [OpenCL] Supports optional pipe types in C++ 
for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109306

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,13 +1,15 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
 extern pipe write_only int get_pipe(); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_program_scope_global_variables))
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_program_scope_global_variables))
 // expected-error-re@-2{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
 #else
 // FIXME: '__private' here makes no sense since program scope variables feature is not supported, should diagnose as '__global' probably
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,14 +1,18 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
 
 void foo(read_only pipe int p);
 #if __OPENCL_C_VERSION__ > 120
 // expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
 // expected-error@-3 {{access qualifier can only be used for pipe and image type}}
-#else
-// expected-warning@-5 {{type specifier missing, defaults to 'int'}}
+#elif defined(__OPENCL_CPP_VERSION__)
+// expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}}
 // expected-error@-6 {{access qualifier can only be used for pipe and image type}}
-// expected-error@-7 {{expected ')'}} expected-note@-7 {{to match this '('}}
+#else
+// expected-warning@-8 {{type specifier missing, defaults to 'int'}}
+// expected-error@-9 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-10 {{expected ')'}} expected-note@-10 {{to match this '('}}
 #endif
 
 // 'pipe' should be accepted as an identifier.
@@ -16,8 +20,16 @@
 #if __OPENCL_C_VERSION__ > 120
 // expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
 // expected-warning@-3 {{typedef requires a name}}
+#elif defined(__OPENCL_CPP_VERSION__)
+// expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}}
+// expected-warning@-6 {{typedef requires a name}}
 #endif
 
 void bar() {
- reserve_id_t r; // expected-error {{use of undeclared identifier 'reserve_id_t'}}
+ reserve_id_t r;
+#if defined(__OPENCL_C_VERSION__)
+// expected-error@-2 {{use of

[PATCH] D108832: [Builtins] Support ext_vector_type args for __builtin_fminf.

2021-09-17 Thread Florian Hahn via Phabricator via cfe-commits
fhahn planned changes to this revision.
fhahn added a comment.

In D108832#2969538 , @erichkeane 
wrote:

> Codewise I'm ok, but I don't feel comfortable making the direction decision.  
> I'd like to see some level of 'state of things' on the vector types (like, 
> under what conditions does GCC support this, and under what types??), but 
> even then I'm not sure I'm the right one to approve this.

Thanks! I'm preparing a proposal for cfe-dev at the moment. In addition to 
supporting element wise min/max/round & co I think we should also make sure the 
proposal also allows adding reduction versions in a consistent manner. I don't 
think that would be possible when overloading the existing builtins, so I am 
exploring a different direction at the moment.

Marking as changes planned for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108832

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


[PATCH] D109956: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: gregmiller, tejohnson, davide, danielcdh.
Herald added subscribers: ormris, wenlei, steven_wu, hiraditya, inglorion.
thopre requested review of this revision.
Herald added a project: clang.

Re-add -fexperimental-new-pass-manager to
Clang::CodeGen/pgo-sample-thinlto-summary.c for the test to work on
builds that still default to the old pass manager.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109956

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
 // RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +39,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
 // RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +39,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D109234#3004253 , @gregmiller 
wrote:

> Hello, 
> We are maintaining a downstream version of the monorepo based on the LLVM 
> main branch. We have not transitioned to the new PM yet. In a recent attempt 
> to merge the latest upstream commits into our monorepo we came across the 
> following test failures after your commit.

Sorry about that, it's my fault for asking Sherwin to remove the 
-fexperimental-new-pass-manager flag. I've created 
https://reviews.llvm.org/D109956


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

2021-09-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

> I'd like to test cases where the very same function call gets a different 
> note message depending on the BugType:

These tests are doing this:

  void check_indeterminate_notes_fseek_no_feof_no_ferror() {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is 
non-null}}
  return;
fseek(F, 1, SEEK_SET);  // expected-note {{Assuming this stream 
operation fails and leaves the file position indeterminate}}
if (!ferror(F) && !feof(F)) // expected-note {{The error flag is not set on 
the stream}} expected-note {{The end-of-file flag is not set on the stream}}
// expected-note@-1 {{Taking true branch}} 
expected-note@-1 {{Left side of '&&' is true}}
  fread(Buf, 1, 1, F);  // expected-warning{{File position of the 
stream might be 'indeterminate' after a failed operation. Can cause undefined 
behavior}}
// expected-note@-1{{File position of the stream might be 'indeterminate' 
after a failed operation. Can cause undefined behavior}}
fclose(F);
  }
  
  void check_feof_notes_fseek() {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is 
non-null}}
  return;
fseek(F, 1, SEEK_SET); // expected-note {{Assuming stream reaches 
end-of-file here}}
if (feof(F))   // expected-note{{The end-of-file flag is set on the 
stream}} expected-note {{Taking true branch}}
  fread(Buf, 1, 1, F); // expected-warning {{Read function called when 
stream is in EOF state. Function has no effect}}
// expected-note@-1 {{Read function called when stream is in EOF state. 
Function has no effect}}
fclose(F);
  }

Why is the last test not sufficient and I should use instead this test?

  void check_notes_fseek_caused_feof() {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
if (!F) // expected-note {{Taking false branch}} expected-note {{'F' is 
non-null}}
  return;
fseek(F, 1, SEEK_SET); // expected-note {{Assuming stream reaches 
end-of-file here}}
if (ferror(F)) { // expected-note {{The error flag is not set on the 
stream}}
   // expected-note@-1 {{Taking false branch}}
  fclose(F);
  return;
}
StreamTesterChecker_clear_indeterminate_file_position(F);
fread(Buf, 1, 1, F); // expected-warning{{Read function called when stream 
is in EOF state. Function has no effect}}
// expected-note@-1{{Read function called when stream is in EOF state. 
Function has no effect}}
fclose(F);
  }

In the first case before the `fread` the EOF bit is on. In the second there are 
2 possibilities, one is when `fseek` did not fail at all, other when it failed 
and then EOF is on. This are really 3 execution paths: `fseek` did not fail, 
`fseek` failed with EOF, and `fseek` failed without FEOF or FERROR but leaves 
indeterminate position (that is cleared, so we get the same state as after 
success).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-17 Thread Gabor Marton via Phabricator via cfe-commits
martong added a reviewer: steakhal.
martong added a subscriber: steakhal.
martong added a comment.

@steakhal, could you please take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109608

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


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-09-17 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev updated this revision to Diff 373179.

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

https://reviews.llvm.org/D106876

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
  clang/test/Modules/add-remove-irrelevant-mobile-map.m
  clang/test/SemaCXX/Inputs/compare.modulemap
  clang/test/SemaCXX/compare-modules-cxx2a.cpp

Index: clang/test/SemaCXX/compare-modules-cxx2a.cpp
===
--- clang/test/SemaCXX/compare-modules-cxx2a.cpp
+++ clang/test/SemaCXX/compare-modules-cxx2a.cpp
@@ -1,15 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
 
-#pragma clang module build compare
-module compare {
-  explicit module cmp {}
-  explicit module other {}
-}
-#pragma clang module contents
-#pragma clang module begin compare.cmp
-#include "std-compare.h"
-#pragma clang module end
-#pragma clang module endbuild
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery -fmodule-map-file=%S/Inputs/compare.modulemap
 
 struct CC { CC(...); };
 
@@ -24,10 +16,10 @@
 
 // expected-note@std-compare.h:* 2+{{not reachable}}
 
-void b() { void(0 <=> 0); } // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+void b() { void(0 <=> 0); } // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 
 struct B {
-  CC operator<=>(const B&) const = default; // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+  CC operator<=>(const B&) const = default; // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 };
 auto vb = B() <=> B(); // expected-note {{required here}}
 
Index: clang/test/SemaCXX/Inputs/compare.modulemap
===
--- /dev/null
+++ clang/test/SemaCXX/Inputs/compare.modulemap
@@ -0,0 +1,6 @@
+module compare {
+  explicit module cmp {
+header "std-compare.h"
+  }
+  explicit module other {}
+}
Index: clang/test/Modules/add-remove-irrelevant-mobile-map.m
===
--- /dev/null
+++ clang/test/Modules/add-remove-irrelevant-mobile-map.m
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
+
+// Build without b.modulemap
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap %s -verify
+// RUN: cp %t.mcp/a.pcm %t/a.pcm
+
+// Build with b.modulemap
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap %s -verify
+// RUN: not diff %t.mcp/a.pcm %t/a.pcm
+
+// expected-no-diagnostics
+
+@import a;
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
@@ -0,0 +1 @@
+module b { }
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
@@ -0,0 +1 @@
+module a { }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -149,6 +149,59 @@
 
 namespace {
 
+std::set GetAllModuleMaps(const HeaderSearch &HS,
+ Module *RootModule) {
+  std::set ModuleMaps{};
+  std::set ProcessedModules;
+  SmallVector ModulesToProcess{RootModule};
+
+  SmallVector FilesByUID;
+  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+
+  if (FilesByUID.size() > HS.header_file_size())
+FilesByUID.resize(HS.header_file_size());
+
+  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
+const FileEntry *File = FilesByUID[UID];
+if (!File)
+  continue;
+
+const HeaderFileInfo *HFI =
+HS.getExistingFileInfo(File, /*WantExternal*/ false);
+if (!HFI)
+  continue;
+
+const auto KnownHeaders = HS.findAllModulesForHeader(File);
+for (const auto &KH : KnownHeaders) {
+  if (!KH.getModule())
+con

[PATCH] D109943: [Clang] Fix long double availability check

2021-09-17 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb accepted this revision.
ronlieb added a comment.
This revision is now accepted and ready to land.

thank you for the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109943

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


[PATCH] D109943: [Clang] Fix long double availability check

2021-09-17 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0195f8621f18: [Clang] Fix long double availability check 
(authored by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109943

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp


Index: clang/test/OpenMP/amdgcn_ldbl_check.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 
-fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device 
-fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+   return (double)a;
+}
+
+int main()
+{
+   auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+   {
+#pragma omp teams num_teams(1) thread_limit(4)
+   {
+   a += 1._X;
+   }
+   }
+  print(a);
+   return 0;
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@
 bool LongDoubleMismatched = false;
 if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
   const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(Ty);
-  if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-  &Sem != &Context.getTargetInfo().getLongDoubleFormat())
+  if ((&Sem != &llvm::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
+  (&Sem == &llvm::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasIbm128Type()))
 LongDoubleMismatched = true;
 }
 


Index: clang/test/OpenMP/amdgcn_ldbl_check.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 -fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+	return (double)a;
+}
+
+int main()
+{
+	auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+	{
+#pragma omp teams num_teams(1) thread_limit(4)
+		{
+			a += 1._X;
+		}
+	}
+  print(a);
+	return 0;
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@
 bool LongDoubleMismatched = false;
 if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
   const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(Ty);
-  if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-  &Sem != &Context.getTargetInfo().getLongDoubleFormat())
+  if ((&Sem != &llvm::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
+  (&Sem == &llvm::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasIbm128Type()))
 LongDoubleMismatched = true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: DavidSpickett, simon_tatham.
Herald added subscribers: kristof.beyls, dschuff.
mstorsjo requested review of this revision.
Herald added a project: clang.

Windows on armv7 is as alignment tolerant as Linux.

The alignment considerations in the Windows on ARM ABI are documented
at 
https://docs.microsoft.com/en-us/cpp/build/overview-of-arm-abi-conventions?view=msvc-160#alignment.

The document doesn't explicitly say in which state the OS configures
the SCTLR.A register (and it's not accessible from user space to
inspect), but in practice, unaligned loads/stores do work and seem
to be as fast as aligned loads and stores. (Unaligned strd also does
seem to work, contrary to Linux, but significantly slower, as they're
handled by the kernel - exactly as the document describes.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109960

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-alignment.c


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -775,7 +775,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -775,7 +775,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I see, let me add some other prominent reviewers

I do see what you mean

  SomeClass::Constructor()
  : x {
x
  }
  #if DEBUG
  , y { 0 }
  #endif
  {}
  
  SomeClass::Constructor()
  : x{x}
  , y{0} {}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19299
+   ", d{d} {\n}",
+   Style);
+}

I think its good to add what you expect without the CONDITION too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I like the adapter layer idea. However, I agree with @martong that it should be 
more 'abstract' ~ terse.
It's remarkable how compact the test is. Good job.




Comment at: clang/lib/AST/ASTImporter.cpp:8417-8418
+template  struct AttrArgImporter {
+  AttrArgImporter(const AttrArgImporter &) = delete;
+  AttrArgImporter(AttrArgImporter &&) = default;
+

What about the rest of the special member functions like assignment operators?

All the rest of the code mentions this template parameter using the `AT` name.  
Could you please consolidate this? It would make it more readable.



Comment at: clang/lib/AST/ASTImporter.cpp:8425
+
+  const T &value() { return To; }
+};

So, the `value()` sometimes returns const ref, and other times it returns a 
mutable raw pointer...

I suspect, attribute constructors expect simple reference arguments and 
pointers for lists. And this is why it behaves like this. Am I right about this?



Comment at: clang/lib/AST/ASTImporter.cpp:8439
+  return;
+} else {
+  To.reserve(ArraySize);

Please fix this.



Comment at: clang/lib/AST/ASTImporter.cpp:8460-8462
+  template 
+  AttrArgArrayImporter
+  importArrayArg(const llvm::iterator_range &From, unsigned ArraySize) {

The name `AT` suggests to me that you expect the template type parameter to be 
a subtype of `class Attr`. However, I suspect it's not always the case.
For example in case of the `OwnershipAttr` the `args()` returns a sequence of 
`ParamIdx*` objects. So, in that sense, the `AT` name is not properly justified.

Restricting template parameter types makes the code cleaner, so I would suggest 
introducing a metafunction, that you could use in a `static_assert` that you 
could use to check this requirement as the first instruction in the function.

```lang=C++
template 
constexpr static bool AttrOrParamIdx = std::is_base_of::value || 
std::is_same_v;

static_assert(AttrOrParamIdx);
```



Comment at: clang/lib/AST/ASTImporter.cpp:8466
+
+  template 
+  Expected createImportedAttr(const T *FromAttr, Arg &&...ImportedArg) 
{

I think you should be consistently using `typename` or `class`. I'm generally 
in favor of using `typename` though.



Comment at: clang/lib/AST/ASTImporter.cpp:8467
+  template 
+  Expected createImportedAttr(const T *FromAttr, Arg &&...ImportedArg) 
{
+const IdentifierInfo *ToAttrName;

So, this accepts universal references, shouldn't we `std::forward` when we 
consume them?
If not, why do you use `&&` ?



Comment at: clang/lib/AST/ASTImporter.cpp:8473-8474
+
+ToAttrName = Importer.Import(FromAttr->getAttrName());
+ToScopeName = Importer.Import(FromAttr->getScopeName());
+ToAttrRange = NImporter.importChecked(Err, FromAttr->getRange());

balazske wrote:
> martong wrote:
> > Why can't we use `importChecked` here?
> For `Identifier*` no error is possible and `importChecked` does not work 
> (could be added to have uniform code).
Why don't you initialize the variables directly? Same for the other variables. 
This way they could be const as well.



Comment at: clang/lib/AST/ASTImporter.cpp:8547-8548
+Expected ToAttrOrErr = AI.createImportedAttr(
+From, AI.importArrayArg(From->args(), From->args_size()).value(),
+From->args_size());
+if (ToAttrOrErr)

balazske wrote:
> martong wrote:
> > Could we hide these arguments?
> > I mean we probably need a higher abstraction, something like
> > ```
> > Expected ToAttrOrErr = AI.createImportedAttr(From);
> > ```
> > should be sufficient, isn't it. We do want to import all arguments of all 
> > kind of attributes, don't we?
> It should be possible to pass every kind of needed arguments (after it is 
> imported) to the constructor of the newly created `Attr` object. The problem 
> is solved here by the `AttrArgImporter` that imports the object and can store 
> it in a temporary value until it is passed to the constructor. The temporary 
> value is important if an array is imported. To import the array the size must 
> be passed to the array importer before, and the size must be passed to the 
> constructor of the `Attr` too, therefore it exists 2 times in the code. An 
> `AttrArgImporter` can provide only one value to the constructor of the new 
> `Attr` object. (Probably other solution is possible with `std::tuple` and 
> `std::apply` but not sure if it is better.)
What about having two implementations. One for any T that has `args()` and one 
for anything else and using SFINAE choosing the right one.
In this context, we should have the appropriate dynamic type, so by using 
template type deduction on `From` could achieve this dispatch.

Internally it could do the `AI.importArrayArg(From->args(), 
From->args_size()).value()` for the `

[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19299
+   ", d{d} {\n}",
+   Style);
+}

MyDeveloperDay wrote:
> I think its good to add what you expect without the CONDITION too!
Can you add doubly nested test

```
SomeClass::Constructor()
: x {
  x
}
#if WINDOWS
#if DEBUG
, y { 0 }
#else
, y { 1 }
#endif
#else
#if DEBUG
, y { 2 }
#else
, y { 3 }
#endif
#endif
{}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-09-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thanks!


Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

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


[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-09-17 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rTb983131b7e46: [test-suite] Add tests for FP classification 
intrinsics (authored by sepavloff).

Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

Files:
  SingleSource/UnitTests/CMakeLists.txt
  SingleSource/UnitTests/Float/CMakeLists.txt
  SingleSource/UnitTests/Float/Makefile
  SingleSource/UnitTests/Float/check-helper.h
  SingleSource/UnitTests/Float/classify-f32.h
  SingleSource/UnitTests/Float/classify-f64.h
  SingleSource/UnitTests/Float/classify-ldouble.h
  SingleSource/UnitTests/Float/classify.c
  SingleSource/UnitTests/Float/classify.reference_output
  SingleSource/UnitTests/Float/fformat.h

Index: SingleSource/UnitTests/Float/fformat.h
===
--- /dev/null
+++ SingleSource/UnitTests/Float/fformat.h
@@ -0,0 +1,65 @@
+//===--- fformat.h - Descriptions of floating point formats ---*- C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This header file contains some macro definitions useful for working with bit
+// accurate floating point representations.
+//
+//===--===//
+#ifndef _FFORMAT_H_
+#define _FFORMAT_H_
+
+#define F32_SIGN_BIT0x8000U
+#define F32_EXP_MASK0x7F80U
+#define F32_MANTISSA_MASK   0x007FU
+#define F32_MANTISSA_MSB0x0040U
+#define F32_QNAN_BITF32_MANTISSA_MSB
+#define F32_PAYLOAD_MASK(F32_MANTISSA_MASK & ~F32_QNAN_BIT)
+#define F32_SIGN_SHIFT  31
+#define F32_EXP_SHIFT   23
+#define F32_EXP_SIZE(F32_SIGN_SHIFT - F32_EXP_SHIFT)
+#define F32_MANTISSA_SIZE   F32_EXP_SHIFT
+#define F32_EXP_BIAS127
+#define F32_EXP_MIN (-126)
+#define F32_EXP_MAX 127
+#define F32_EXP(e)  (((e) + F32_EXP_BIAS) << F32_EXP_SHIFT)
+#define F32_MANTISSA(b1, b2, b3)   \
+(((b1) ? F32_MANTISSA_MSB : 0) |   \
+ ((b2) ? (F32_MANTISSA_MSB >> 1) : 0) |\
+ ((b3) ? (F32_MANTISSA_MSB >> 2) : 0))
+#define F32_MAKE(s, e, m)  \
+(((s) ? F32_SIGN_BIT : 0) |\
+ ((e) & F32_EXP_MASK) |\
+ ((m) & F32_MANTISSA_MASK))
+#define F32_NORMAL(s, e, m) F32_MAKE((s), F32_EXP(e), (m))
+
+
+#define F64_SIGN_BIT0x8000ULL
+#define F64_EXP_MASK0x7FF0ULL
+#define F64_MANTISSA_MASK   0x000FULL
+#define F64_MANTISSA_MSB0x0008ULL
+#define F64_QNAN_BITF64_MANTISSA_MSB
+#define F64_PAYLOAD_MASK(F64_MANTISSA_MASK & ~F64_QNAN_BIT)
+#define F64_SIGN_SHIFT  63
+#define F64_EXP_SHIFT   52
+#define F64_EXP_SIZE(F64_SIGN_SHIFT - F64_EXP_SHIFT)
+#define F64_MANTISSA_SIZE   F64_EXP_SHIFT
+#define F64_EXP_BIAS1023
+#define F64_EXP_MIN (-1022)
+#define F64_EXP_MAX 1023
+#define F64_EXP(e)  (((uint64_t)(e) + F64_EXP_BIAS) << F64_EXP_SHIFT)
+#define F64_MANTISSA(b1, b2, b3)   \
+(((b1) ? F64_MANTISSA_MSB : 0) |   \
+ ((b2) ? (F64_MANTISSA_MSB >> 1) : 0) |\
+ ((b3) ? (F64_MANTISSA_MSB >> 2) : 0))
+#define F64_MAKE(s, e, m)  \
+(((s) ? F64_SIGN_BIT : 0) |\
+ ((e) & F64_EXP_MASK) |\
+ ((m) & F64_MANTISSA_MASK))
+#define F64_NORMAL(s, e, m) F64_MAKE((s), F64_EXP(e), (m))
+
+#endif
Index: SingleSource/UnitTests/Float/classify.reference_output
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.reference_output
@@ -0,0 +1 @@
+exit 0
Index: SingleSource/UnitTests/Float/classify.c
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.c
@@ -0,0 +1,26 @@
+//===--- classify.cpp - Tess for FP classification intrinsics ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is a general test for floating poi

[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM with the comment updated.




Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:771
 // Linux targets support unaligned accesses. The same goes for NaCl.
 //
 // The above behavior is consistent with GCC.

Might as well update this comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109960

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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-17 Thread greg miller via Phabricator via cfe-commits
gregmiller added a comment.

The test patch worked and test is now passing again.  Thanks for the quick help 
on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[clang] e3b1052 - Make multiversioning work with internal linkage

2021-09-17 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-09-17T05:56:38-07:00
New Revision: e3b10525b489b604d6a1e540be78bda80afb5868

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

LOG: Make multiversioning work with internal linkage

We previously made all multiversioning resolvers/ifuncs have weak
ODR linkage in IR, since we NEED to emit the whole resolver every time
we see a call, but it is not necessarily the place where all the
definitions live.

HOWEVER, when doing so, we neglected the case where the versions have
internal linkage.  This patch ensures we do this, so you don't get weird
behavior with static functions.

Added: 
clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/unique-internal-linkage-names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index b274edb8470c..9715657b4c6e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3258,6 +3258,19 @@ TargetMVPriority(const TargetInfo &TI,
   return Priority;
 }
 
+// Multiversion functions should be at most 'WeakODRLinkage' so that a 
diff erent
+// TU can forward declare the function without causing problems.  Particularly
+// in the cases of CPUDispatch, this causes issues. This also makes sure we
+// work with internal linkage functions, so that the same function name can be
+// used with internal linkage in multiple TUs.
+llvm::GlobalValue::LinkageTypes getMultiversionLinkage(CodeGenModule &CGM,
+   GlobalDecl GD) {
+  const FunctionDecl *FD = cast(GD.getDecl());
+  if (FD->getFormalLinkage() == InternalLinkage)
+return llvm::GlobalValue::InternalLinkage;
+  return llvm::GlobalValue::WeakODRLinkage;
+}
+
 void CodeGenModule::emitMultiVersionFunctions() {
   std::vector MVFuncsToEmit;
   MultiVersionFuncs.swap(MVFuncsToEmit);
@@ -3298,7 +3311,7 @@ void CodeGenModule::emitMultiVersionFunctions() {
 if (TI.supportsIFunc() || FD->isTargetMultiVersion()) {
   ResolverFunc = cast(
   GetGlobalValue((getMangledName(GD) + ".resolver").str()));
-  ResolverFunc->setLinkage(llvm::Function::WeakODRLinkage);
+  ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
 } else {
   ResolverFunc = cast(GetGlobalValue(getMangledName(GD)));
 }
@@ -3356,7 +3369,7 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl 
GD) {
 
   auto *ResolverFunc = cast(GetOrCreateLLVMFunction(
   ResolverName, ResolverType, ResolverGD, /*ForVTable=*/false));
-  ResolverFunc->setLinkage(llvm::Function::WeakODRLinkage);
+  ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
   if (supportsCOMDAT())
 ResolverFunc->setComdat(
 getModule().getOrInsertComdat(ResolverFunc->getName()));
@@ -3433,9 +3446,9 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl 
GD) {
   auto *IFunc = cast(GetOrCreateLLVMFunction(
   AliasName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/true,
   /*IsThunk=*/false, llvm::AttributeList(), NotForDefinition));
-  auto *GA = llvm::GlobalAlias::create(
- DeclTy, 0, getFunctionLinkage(GD), AliasName, IFunc, &getModule());
-  GA->setLinkage(llvm::Function::WeakODRLinkage);
+  auto *GA = llvm::GlobalAlias::create(DeclTy, 0,
+   getMultiversionLinkage(*this, GD),
+   AliasName, IFunc, &getModule());
   SetCommonAttributes(GD, GA);
 }
   }
@@ -3474,8 +3487,9 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(
 llvm::Constant *Resolver = GetOrCreateLLVMFunction(
 MangledName + ".resolver", ResolverType, GlobalDecl{},
 /*ForVTable=*/false);
-llvm::GlobalIFunc *GIF = llvm::GlobalIFunc::create(
-DeclTy, 0, llvm::Function::WeakODRLinkage, "", Resolver, &getModule());
+llvm::GlobalIFunc *GIF =
+llvm::GlobalIFunc::create(DeclTy, 0, getMultiversionLinkage(*this, GD),
+  "", Resolver, &getModule());
 GIF->setName(ResolverName);
 SetCommonAttributes(FD, GIF);
 

diff  --git a/clang/test/CodeGen/unique-internal-linkage-names.cpp 
b/clang/test/CodeGen/unique-internal-linkage-names.cpp
index 95591de308d3..65069c049b63 100644
--- a/clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ b/clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -59,7 +59,7 @@ void test() {
 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
 // PLAIN: define internal i32 @_ZL3foov()
 // PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
-// PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
+// PLAIN: define internal i32 ()* @_ZL4mverv.resolver(

[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 373201.
mstorsjo added a comment.

Updated the comment too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109960

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-alignment.c


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -767,7 +767,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -775,7 +776,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -767,7 +767,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -775,7 +776,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b7e9d20 - [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-17T14:14:31+01:00
New Revision: b7e9d203c6793873f72dd3ffaf7c9365ce03007e

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

LOG: [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 
2021

Adds support for a feature macro `__opencl_c_read_write_images` in
C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/access-qualifier.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 35c32043e377..8092aeb21ada 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7552,18 +7552,17 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
   // OpenCL v3.0 s6.8 - For OpenCL C 2.0, or with the
   // __opencl_c_read_write_images feature, image objects specified as arguments
   // to a kernel can additionally be declared to be read-write.
-  // C++ for OpenCL inherits rule from OpenCL C v2.0.
+  // C++ for OpenCL 1.0 inherits rule from OpenCL C v2.0.
+  // C++ for OpenCL 2021 inherits rule from OpenCL C v3.0.
   if (const auto *PDecl = dyn_cast(D)) {
 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
 if (AL.getAttrName()->getName().find("read_write") != StringRef::npos) {
-  bool ReadWriteImagesUnsupportedForOCLC =
-  (S.getLangOpts().OpenCLVersion < 200) ||
-  (S.getLangOpts().OpenCLVersion == 300 &&
+  bool ReadWriteImagesUnsupported =
+  (S.getLangOpts().getOpenCLCompatibleVersion() < 200) ||
+  (S.getLangOpts().getOpenCLCompatibleVersion() == 300 &&
!S.getOpenCLOptions().isSupported("__opencl_c_read_write_images",
  S.getLangOpts()));
-  if ((!S.getLangOpts().OpenCLCPlusPlus &&
-   ReadWriteImagesUnsupportedForOCLC) ||
-  DeclTy->isPipeType()) {
+  if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) {
 S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write)
 << AL << PDecl->getType() << DeclTy->isImageType();
 D->setInvalidDecl(true);

diff  --git a/clang/test/Misc/opencl-c-3.0.incorrect_options.cl 
b/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
index 3ce0f325ce91..6232806c5c6d 100644
--- a/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ b/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -3,6 +3,7 @@
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=-__opencl_c_fp64,+cl_khr_fp64 %s 2>&1 | FileCheck 
-check-prefix=CHECK-FP64 %s
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_fp64,-cl_khr_fp64 %s 2>&1 | FileCheck 
-check-prefix=CHECK-FP64 %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_read_write_images,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-READ-WRITE-IMAGES %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_read_write_images,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-READ-WRITE-IMAGES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s

diff  --git a/clang/test/SemaOpenCL/access-qualifier.cl 
b/clang/test/SemaOpenCL/access-qualifier.cl
index fc6ad750e717..726253c0b1a2 100644
--- a/clang/test/SemaOpenCL/access-qualifier.cl
+++ b/clang/test/SemaOpenCL/access-qualifier.cl
@@ -2,24 +2,38 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL2.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL3.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=clc++2021 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=clc++2021 %s -cl-ex

[PATCH] D109307: [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas 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 rGb7e9d203c679: [OpenCL] Supports optional same image reads 
and writes in C++ for OpenCL 2021 (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109307?vs=370855&id=373203#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109307

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/access-qualifier.cl

Index: clang/test/SemaOpenCL/access-qualifier.cl
===
--- clang/test/SemaOpenCL/access-qualifier.cl
+++ clang/test/SemaOpenCL/access-qualifier.cl
@@ -2,24 +2,38 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s -cl-ext=-__opencl_c_read_write_images
 
 typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
 
 typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}}
 typedef read_only image1d_t img1d_ro;
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 typedef read_write image1d_t img1d_rw;
 #endif
 
 typedef int Int;
 typedef read_only int IntRO; // expected-error {{access qualifier can only be used for pipe and image type}}
 
+void myWrite(write_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+// expected-note@-3 {{passing argument to parameter here}}
+#else
+// expected-note@-5 {{candidate function not viable: no known conversion from '__private img1d_ro' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+// expected-note@-6 {{candidate function not viable: no known conversion from '__private img1d_ro_default' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+#endif
 
-void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passing argument to parameter here}}
-void myRead(read_only image1d_t); // expected-note {{passing argument to parameter here}}
+void myRead(read_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+#else
+// expected-note@-4 {{candidate function not viable: no known conversion from '__private img1d_wo' (aka '__private __write_only image1d_t') to '__private __read_only image1d_t' for 1st argument}}
+#endif
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 void myReadWrite(read_write image1d_t);
 #else
 void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}}
@@ -27,25 +41,40 @@
 
 
 kernel void k1(img1d_wo img) {
-  myRead(img); // expected-error {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+  myRead(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myRead'}}
+#endif
 }
 
 kernel void k2(img1d_ro img) {
-  myWrite(img); // expected-error {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+  myWrite(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myWrite'}}
+#endif
 }
 
 kernel void k3(img1d_wo img) {
   myWrite(img);
 }
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_

[clang] 197a3d1 - Fix test failure from e3b10525b489b604d6a1e540be78bda80afb5868

2021-09-17 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-09-17T06:21:55-07:00
New Revision: 197a3d183b8b2a8452d816a1b0fcfc1093ef76ab

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

LOG: Fix test failure from e3b10525b489b604d6a1e540be78bda80afb5868

Seemingly, names in anonymous namespaces are ALWAYS given the unique
internal linkage name on windows, and I was not aware of this when I put
the names in my test!  Replaced them with a wildcard.

Added: 


Modified: 
clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp 
b/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp
index 246599a591a7..c835a8f1624b 100644
--- a/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp
+++ b/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp
@@ -42,8 +42,8 @@ int usage() {
 // LINUX: define internal i32 ()* @_ZL15static_dispatchv.resolver()
 // WINDOWS: define internal i32 @"?static_dispatch@@YAHXZ"()
 // LINUX: define internal i32 ()* 
@_ZN12_GLOBAL__N_113anon_dispatchEv.resolver()
-// WINDOWS: define internal i32 @"?anon_dispatch@?A0x7F72A7FB@@YAHXZ"()
+// WINDOWS: define internal i32 @"?anon_dispatch{{.*}}@@YAHXZ"()
 // LINUX: define internal i32 ()* @_ZL13static_targetv.resolver()
 // WINDOWS: define internal i32 @"?static_target@@YAHXZ.resolver"()
 // LINUX: define internal i32 ()* @_ZN12_GLOBAL__N_111anon_targetEv.resolver()
-// WINDOWS: define internal i32 @"?anon_target@?A0x7F72A7FB@@YAHXZ.resolver"()
+// WINDOWS: define internal i32 @"?anon_target{{.*}}@@YAHXZ.resolver"()



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


[PATCH] D105516: [clang][PassManager] Add -falways-mem2reg CC1 flag to run mem2reg at -O0

2021-09-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

@rjmccall Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105516

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


[PATCH] D109956: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm. And I just was informed in a recent review of one of my patches that we 
are now removing old PM tests, so if you want you could also go ahead and 
remove the first 2 lines here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109956

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


[PATCH] D109956: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre updated this revision to Diff 373214.
thopre added a comment.

Remove old PM tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109956

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109956: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Thomas Preud'homme 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 rG8a7a28075b7f: Fix CodeGen/pgo-sample-thinlto-summary.c with 
old PM (authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109956

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8a7a280 - Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-09-17T15:21:22+01:00
New Revision: 8a7a28075b7fa70d56b131c10a4d1add777d5830

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

LOG: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

Re-add -fexperimental-new-pass-manager to
Clang::CodeGen/pgo-sample-thinlto-summary.c for the test to work on
builds that still default to the old pass manager.

Reviewed By: tejohnson

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

Added: 


Modified: 
clang/test/CodeGen/pgo-sample-thinlto-summary.c

Removed: 




diff  --git a/clang/test/CodeGen/pgo-sample-thinlto-summary.c 
b/clang/test/CodeGen/pgo-sample-thinlto-summary.c
index 1de2298320e5..9eee0f6df457 100644
--- a/clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ b/clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@ void foo(int n) {
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}



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


[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 373218.
olestrohm added a comment.

I made the implicit destructor always be created in __generic address space.

I couldn't manage to properly figure a case that would trigger 
`LookupSpecialMember`,
so I couldn't figure out how or if address spaces are handled there.

re: @keryell 
This might work, though I have no idea how that `SomeAPIReturningAddrSpace` 
would work, since at this point the variable would likely be cast to be in 
__generic addrspace.
Also I'm not sure how that would interact with deleted destructors.


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

https://reviews.llvm.org/D109609

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp

Index: clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+// CHECK: CXXDestructorDecl {{.*}} used ~ExactDtor 'void () __private noexcept'
+struct ExactDtor {
+ ~ExactDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~OverloadedDtor 'void () __generic'
+// CHECK: CXXDestructorDecl {{.*}} used ~OverloadedDtor 'void () __private noexcept'
+struct OverloadedDtor {
+ ~OverloadedDtor() __generic;
+ ~OverloadedDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~ImplicitDtor 'void () __global'
+// CHECK: CXXDestructorDecl {{.*}} implicit used ~ImplicitDtor 'void () __generic noexcept'
+struct ImplicitDtor {
+~ImplicitDtor() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~Templated 'void () __generic noexcept'
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~Templated 'void () __global'
+template 
+struct Templated {
+~Templated() __generic;
+~Templated() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __private noexcept'
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __global noexcept'
+struct BothUsed {
+~BothUsed() __private;
+~BothUsed() __global;
+};
+
+__global BothUsed g_inheriting;
+
+kernel void k() {
+__private ExactDtor exact;
+__private OverloadedDtor overloaded;
+__private ImplicitDtor implicit;
+__private Templated templated;
+__private BothUsed inheriting;
+}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3054,13 +3054,10 @@
   Functions.append(Operators.begin(), Operators.end());
 }
 
-Sema::SpecialMemberOverloadResult Sema::LookupSpecialMember(CXXRecordDecl *RD,
-   CXXSpecialMember SM,
-   bool ConstArg,
-   bool VolatileArg,
-   bool RValueThis,
-   bool ConstThis,
-   bool VolatileThis) {
+Sema::SpecialMemberOverloadResult
+Sema::LookupSpecialMember(CXXRecordDecl *RD, CXXSpecialMember SM, bool ConstArg,
+  bool VolatileArg, bool RValueThis, bool ConstThis,
+  bool VolatileThis, LangAS AS) {
   assert(CanDeclareSpecialMemberFunction(RD) &&
  "doing special member lookup into record that isn't fully complete");
   RD = RD->getDefinition();
@@ -3082,6 +3079,7 @@
   ID.AddInteger(RValueThis);
   ID.AddInteger(ConstThis);
   ID.AddInteger(VolatileThis);
+  ID.AddInteger((unsigned)AS);
 
   void *InsertPoint;
   SpecialMemberOverloadResultEntry *Result =
@@ -3096,12 +3094,12 @@
   SpecialMemberCache.InsertNode(Result, InsertPoint);
 
   if (SM == CXXDestructor) {
-if (RD->needsImplicitDestructor()) {
+if (RD->needsImplicitDestructor(AS)) {
   runWithSufficientStackSpace(RD->getLocation(), [&] {
 DeclareImplicitDestructor(RD);
   });
 }
-CXXDestructorDecl *DD = RD->getDestructor();
+CXXDestructorDecl *DD = RD->getDestructor(AS);
 Result->setMethod(DD);
 Result->setKind(DD && !DD->isDeleted()
 ? SpecialMemberOverloadResult::Success
@@ -3362,10 +3360,11 @@
 /// CXXRecordDecl::getDestructor().
 ///
 /// \returns The destructor for this class.
-CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class) {
+CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class, LangAS AS) {
   return cast(LookupSpecialMember(Class, CXXDestructor,
- false, false, false,
- 

[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm marked 2 inline comments as done.
olestrohm added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:3082
   ID.AddInteger(VolatileThis);
+  ID.AddInteger((unsigned)AS);
 

Anastasia wrote:
> Btw ctors and assignments don't seem to need this but they seem to work fine 
> though... 
> 
> 
> For example here the right assignment overload with `__local` address space 
> is selected
> https://godbolt.org/z/aYKj4W6rc
> or ctor overload with `__global` is selected here correctly:
> https://godbolt.org/z/1frheezE5
> 
> So it seems like there is some other logic to handle address spaces for 
> special members elsewhere? Although it is very strange and rather confusing.
Yes, it seems other special members are handled somewhere else according to my 
preliminary investigations, so that might explain why address spaces where 
never introduced into this function.


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

https://reviews.llvm.org/D109609

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


[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 373225.

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

https://reviews.llvm.org/D109609

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp

Index: clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+// CHECK: CXXDestructorDecl {{.*}} used ~ExactDtor 'void () __private noexcept'
+struct ExactDtor {
+ ~ExactDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~OverloadedDtor 'void () __generic'
+// CHECK: CXXDestructorDecl {{.*}} used ~OverloadedDtor 'void () __private noexcept'
+struct OverloadedDtor {
+ ~OverloadedDtor() __generic;
+ ~OverloadedDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~ImplicitDtor 'void () __global'
+// CHECK: CXXDestructorDecl {{.*}} implicit used ~ImplicitDtor 'void () __generic noexcept'
+struct ImplicitDtor {
+~ImplicitDtor() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~Templated 'void () __generic noexcept'
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~Templated 'void () __global'
+template 
+struct Templated {
+~Templated() __generic;
+~Templated() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __private noexcept'
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __global noexcept'
+struct BothUsed {
+~BothUsed() __private;
+~BothUsed() __global;
+};
+
+__global BothUsed g_inheriting;
+
+kernel void k() {
+__private ExactDtor exact;
+__private OverloadedDtor overloaded;
+__private ImplicitDtor implicit;
+__private Templated templated;
+__private BothUsed inheriting;
+}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3054,13 +3054,10 @@
   Functions.append(Operators.begin(), Operators.end());
 }
 
-Sema::SpecialMemberOverloadResult Sema::LookupSpecialMember(CXXRecordDecl *RD,
-   CXXSpecialMember SM,
-   bool ConstArg,
-   bool VolatileArg,
-   bool RValueThis,
-   bool ConstThis,
-   bool VolatileThis) {
+Sema::SpecialMemberOverloadResult
+Sema::LookupSpecialMember(CXXRecordDecl *RD, CXXSpecialMember SM, bool ConstArg,
+  bool VolatileArg, bool RValueThis, bool ConstThis,
+  bool VolatileThis, LangAS ASThis) {
   assert(CanDeclareSpecialMemberFunction(RD) &&
  "doing special member lookup into record that isn't fully complete");
   RD = RD->getDefinition();
@@ -3082,6 +3079,7 @@
   ID.AddInteger(RValueThis);
   ID.AddInteger(ConstThis);
   ID.AddInteger(VolatileThis);
+  ID.AddInteger((unsigned)ASThis);
 
   void *InsertPoint;
   SpecialMemberOverloadResultEntry *Result =
@@ -3096,12 +3094,12 @@
   SpecialMemberCache.InsertNode(Result, InsertPoint);
 
   if (SM == CXXDestructor) {
-if (RD->needsImplicitDestructor()) {
+if (RD->needsImplicitDestructor(ASThis)) {
   runWithSufficientStackSpace(RD->getLocation(), [&] {
 DeclareImplicitDestructor(RD);
   });
 }
-CXXDestructorDecl *DD = RD->getDestructor();
+CXXDestructorDecl *DD = RD->getDestructor(ASThis);
 Result->setMethod(DD);
 Result->setKind(DD && !DD->isDeleted()
 ? SpecialMemberOverloadResult::Success
@@ -3362,10 +3360,11 @@
 /// CXXRecordDecl::getDestructor().
 ///
 /// \returns The destructor for this class.
-CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class) {
+CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class, LangAS AS) {
   return cast(LookupSpecialMember(Class, CXXDestructor,
- false, false, false,
- false, false).getMethod());
+ false, false, false, false,
+ false, AS)
+ .getMethod());
 }
 
 /// LookupLiteralOperator - Determine which literal operator should be used for
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/Se

[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: rnk, nickdesaulniers, efriedma.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is a common practice in glibc header to provide an inline redefinition of an
existing function. It is especially the case for fortified function.

Clang currently has an imperfect approach to the problem, using a combination of
trivially recursive function detection and noinline attribute.

Simplify the logic by suffixing these functions by `.inline` during codegen, so
that they are not recognized as builtin by llvm.

After that patch, clang passes all tests from:

  https://github.com/serge-sans-paille/fortify-test-suite


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109967

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/memcpy-inline-builtin.c
  clang/test/CodeGen/memcpy-no-nobuiltin-if-not-emitted.c
  clang/test/CodeGen/memcpy-nobuiltin.c
  clang/test/CodeGen/pr9614.c

Index: clang/test/CodeGen/pr9614.c
===
--- clang/test/CodeGen/pr9614.c
+++ clang/test/CodeGen/pr9614.c
@@ -32,14 +32,14 @@
 
 // CHECK-LABEL: define{{.*}} void @f()
 // CHECK: call void @foo()
-// CHECK: call i32 @abs(i32 0)
+// CHECK: call i32 @abs(i32 %0)
 // CHECK: call i8* @strrchr(
 // CHECK: call void @llvm.prefetch.p0i8(
 // CHECK: call i8* @memchr(
 // CHECK: ret void
 
 // CHECK: declare void @foo()
-// CHECK: declare i32 @abs(i32
 // CHECK: declare i8* @strrchr(i8*, i32)
 // CHECK: declare i8* @memchr(
+// CHECK: declare i32 @abs(i32
 // CHECK: declare void @llvm.prefetch.p0i8(
Index: clang/test/CodeGen/memcpy-nobuiltin.c
===
--- clang/test/CodeGen/memcpy-nobuiltin.c
+++ clang/test/CodeGen/memcpy-nobuiltin.c
@@ -4,7 +4,8 @@
 //
 // CHECK-WITH-DECL-NOT: @llvm.memcpy
 // CHECK-NO-DECL: @llvm.memcpy
-// CHECK-SELF-REF-DECL: @llvm.memcpy
+// CHECK-SELF-REF-DECL-LABEL: define dso_local i8* @memcpy.inline
+// CHECK-SELF-REF-DECL:   @memcpy(
 //
 #include 
 void test(void *dest, void const *from, size_t n) {
Index: clang/test/CodeGen/memcpy-no-nobuiltin-if-not-emitted.c
===
--- clang/test/CodeGen/memcpy-no-nobuiltin-if-not-emitted.c
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
-//
-// Verifies that clang doesn't mark an inline builtin definition as `nobuiltin`
-// if the builtin isn't emittable.
-
-typedef unsigned long size_t;
-
-// always_inline is used so clang will emit this body. Otherwise, we need >=
-// -O1.
-#define AVAILABLE_EXTERNALLY extern inline __attribute__((always_inline)) \
-__attribute__((gnu_inline))
-
-AVAILABLE_EXTERNALLY void *memcpy(void *a, const void *b, size_t c) {
-  return __builtin_memcpy(a, b, c);
-}
-
-// CHECK-LABEL: define{{.*}} void @foo
-void foo(void *a, const void *b, size_t c) {
-  // Clang will always _emit_ this as memcpy. LLVM turns it into @llvm.memcpy
-  // later on if optimizations are enabled.
-  // CHECK: call i8* @memcpy
-  memcpy(a, b, c);
-}
-
-// CHECK-NOT: nobuiltin
Index: clang/test/CodeGen/memcpy-inline-builtin.c
===
--- /dev/null
+++ clang/test/CodeGen/memcpy-inline-builtin.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - %s -disable-llvm-passes | FileCheck %s
+//
+// Verifies that clang detects memcpy inline version and use it correctly.
+
+typedef unsigned long size_t;
+
+// always_inline is used so clang will emit this body. Otherwise, we need >= -O1.
+#define AVAILABLE_EXTERNALLY extern inline __attribute__((always_inline)) \
+__attribute__((gnu_inline))
+
+// Clang recognizes an inline builtin and renames it to prevent conflict with
+// builtins.
+
+AVAILABLE_EXTERNALLY void *memcpy(void *a, const void *b, size_t c) {
+  return __builtin_memcpy(a, b, c);
+}
+
+// CHECK-LABEL: define{{.*}} void @foo
+void foo(void *a, const void *b, size_t c) {
+  // CHECK: call i8* @memcpy.inline
+  memcpy(a, b, c);
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1293,8 +1293,10 @@
   case MultiVersionKind::None:
 llvm_unreachable("None multiversion type isn't valid here");
   }
+
 }
 
+
   // Make unique name for device side static file-scope variable for HIP.
   if (CGM.getContext().shouldExternalizeStaticVar(ND) &&
   CGM.getLangOpts().GPURelocatableDeviceCode &&
@@ -3146,6 +3148,7 @@
   if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage)
 return true;
   const auto *F = cast(GD.getDecl());
+
   if (CodeGenOpts.Opti

[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ronan Keryell via Phabricator via cfe-commits
keryell added a comment.

In D109609#3006225 , @olestrohm wrote:

> 



> re: @keryell 
> This might work, though I have no idea how that `SomeAPIReturningAddrSpace` 
> would work, since at this point the variable would likely be cast to be in 
> __generic addrspace.
> Also I'm not sure how that would interact with deleted destructors.

You mean for example say that the constructor in `global` address-space would 
have some definition but the constructor in `constant` is deleted?
Ouch. You are killing my suggestion. :-)


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

https://reviews.llvm.org/D109609

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


[PATCH] D109862: Don't diagnose unused but set when the Cleanup attribute is used.

2021-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109862

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


[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/DataFlowSanitizer.rst:141
+For instrumented functions, the ABI list supports a ``force_zero_labels``
+category, which will make all shadow stores and label for return values set
+zero labels. Functions should never be labelled with both ``force_zero_labels``




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

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


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Markus Böck via Phabricator via cfe-commits
zero9178 created this revision.
zero9178 added reviewers: phosek, hans, MaskRay, compnerd.
Herald added subscribers: arphaman, mgorny.
zero9178 requested review of this revision.
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Linking against the LibXml2::LibXml2 target has the advantage of not only 
importing the library, but also adding the include path as well as any 
definitions the library requires. In case of a static build of libxml2, eg. a 
define is set on Windows to remove any DLL imports and export.

LLVM already makes use of the target, but c-index-test and lldb were still 
linking against the library only.

The workaround for Mac OS-X that I removed seems to have also been made 
redundant since https://reviews.llvm.org/D84563 I believe


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109975

Files:
  clang/tools/c-index-test/CMakeLists.txt
  lldb/source/Host/CMakeLists.txt


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-17 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

@yaxunl I think we have two ways to go from here:

1. If appropriate, reset the maximum number of scalar registers allowed in 
`@kernel3` (inline-calls.ll) to fix the test.
2. Determine a stronger condition for inlining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-17 Thread Kees Cook via Phabricator via cfe-commits
kees added a comment.

Does this address https://bugs.llvm.org/show_bug.cgi?id=50322 ? (I assume this 
is a new version of https://reviews.llvm.org/D92657 ?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109967

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-17 Thread Richard Howell via Phabricator via cfe-commits
rmaz added a comment.

In D109632#3005512 , @vsapsai wrote:

> Thanks for the explanation! I'm still curious to reproduce the problem 
> locally and have created a test case generator 
> https://gist.github.com/vsapsai/f9d3603dde95eebd23248da4d7b4f5ec It creates a 
> chain of .m -> Synthesized9 -> Synthesized8 -> Synthesized7 ->... Does it 
> represent the structure of the code you are dealing with?

The case we have is more like:

  .m   -> A -> long list of partially shared deps -> Foundation
   -> B -> long list of partially shared deps -> Foundation
   -> C -> long list of partially shared deps -> Foundation
    * a few hundred

So we have a file that imports a lot of modules, in the hundreds. Each of those 
modules has multiple ObjC interfaces with `-(id)init NS_UNAVAILABLE` and 
imports Foundation, UIKit and also a large number of libraries that are shared 
across the top level imports. This will result in A.pcm, B.pcm and C.pcm 
including hundreds or thousands of init decls that are the same, from system 
frameworks or whatever modules are shared between the top level imports.

IIUC the code currently serializes the entire ObjCMethodList for a module for 
every declared method, including the methods that are not part of that module. 
When deserializing we don't descend into module dependencies as the entire 
method list would already be deserialized, but that doesn't help for modules 
that aren't directly dependent. Is this right? If so it seems another approach 
could be to only serialize the methods declared in that module itself, and 
during deserialization we would have to load the methods from all dependent 
modules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

There were a few behavioral changes to tests that I had questions about. Also, 
can you add an additional test case that shows the behavior when the left 
operand of the comma expression is volatile (or do we already have that covered 
and I missed it)? e.g.,

  int func() {
volatile int *ip = (volatile int *)0xFEEDFACE;
return (*ip, 1);
  }

(In this case, we shouldn't diagnose that the left operand has no effect 
because reading a volatile variable is an operation with a side effect.)




Comment at: clang/test/CodeCompletion/pragma-macro-token-caching.c:15
 Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a 
parenthesized string literal}}
-param; // expected-warning {{expression result unused}}
 }

Why did we lose this diagnostic?



Comment at: clang/test/Sema/exprs.c:19
   if (0) {
-0 / (0 ? 1 : 0); // expected-warning {{expression result unused}}
   }

Why did we lose this diagnostic (and the above comment about not changing the 
test)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: leonardchan, phosek, MaskRay, compnerd, mehdi_amini.
Herald added subscribers: rupprecht, mgorny.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
beanz requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

This patch adds an llvm-driver multicall tool that can combine multiple
LLVM-based tools. The build infrastructure is enabled for a tool by
adding the `GENERATE_DRIVER` option to the `add_llvm_executable` CMake
call, and changing the tool's `main` function to a canonicalized
`tool_name_main` format (i.e. llvm_ar_main, clang_main, etc...).

As currently implemented llvm-driver contains dsymutil, llvm-ar,
llvm-cxxfilt, llvm-objcopy, and clang (if clang is included in the
build).

llvm-driver can be disabled from builds by setting
LLVM_TOOL_LLVM_DRIVER_BUILD=Off.

There are several limitations in the current implementation, which can
be addressed in subsequent patches:

(1) the multicall binary cannot currently properly handle
multi-dispatch tools. This means symlinking llvm-ranlib to llvm-driver
will not properly result in llvm-ar's main being called.
(2) the multicall binary cannot be comprised of tools containing
conflicting cl::opt options as the global cl::opt option list cannot
contain duplicates.

These limitations can be addressed in subsequent patches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/cmake/driver-template.cpp
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -401,7 +401,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -43,6 +43,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,61 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry) int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+// This function handles the case of not recognizing the tool requested, or if
+// --help or --version are passed directly to llvm-driver.
+int UnknownMain(int Argc, char **Argv) {
+  cl::OptionCategory LLVMDriverCategory("llvm-driver options");
+#define LLVM_DRIVER_TOOL(tool, entry)  \
+  cl::SubCommand entry##Subcommand(tool, tool);
+#include "LLVMDriverTools.def"
+
+  cl::HideUnrelatedOptions(LLVMDriverCategory);
+  cl::ParseCommandLineOptions(Argc, Argv, "llvm compiler driver\n");
+  llvm_unreachable("We should never get here, parsing should always exit.");
+  return 1;
+}
+
+int main(int Argc, char **Argv) {
+  llvm::StringRef LaunchedTool = sys::path::stem(Argv[0]);
+  // If the driver is launched directly.
+  int PassThroughArgC = Argc;
+  char **PassThroughArgV = Argv;
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm-driver") {

[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.
Herald added a subscriber: JDevlieghere.

Serendipitously, I just yesterday upgraded from OSX 10.14 to 10.15, and have 
been unable to build clang because, even with a totally-empty-and-brand-new 
build directory, CMake says:

  CMake Error in lib/WindowsManifest/CMakeLists.txt:
Imported target "LibXml2::LibXml2" includes non-existent path
  
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2"
in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
  -- Generating done
  CMake Generate step failed.  Build files cannot be regenerated correctly.

Do you think this PR would fix that issue on OSX 10.15?
(IMHO it's also weird that OSX would even be trying to build anything with 
`Windows` in the name.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-17 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D109707#3004869 , @gandhi21299 
wrote:

> Internal linkage detection works great for our purposes but it causes a 
> failure in llvm/test/CodeGen/AMDGPU/inline-calls.ll due to `@func_alias` 
> unable to be casted into a `Function`. If we pass through that, the 
> `@kernel3` causes the error: `scalar registers (98) exceeds limit (96) in 
> function 'kernel3'`.

That almost sounds like using the wrong subtarget for the alias




Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:694
 if (EarlyInlineAll && !EnableFunctionCalls)
-  PM.addPass(AMDGPUAlwaysInlinePass());
+  PM.addPass(AMDGPUAlwaysInlinePass(false));
   });

This needs a backend test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-17 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 373257.
gandhi21299 marked an inline comment as done.
gandhi21299 added a comment.

- Prevent removing alias if the GlobalAlias does not have internal linkage


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
  llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -93,6 +93,8 @@
 
   for (GlobalAlias &A : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (!A.hasInternalLinkage())
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back(&A);
 }
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S 
-o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), 
void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -93,6 +93,8 @@
 
   for (GlobalAlias &A : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (!A.hasInternalLinkage())
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back(&A);
 }
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109979: [Clang] [Fix] Clang build fails when build directory contains space character

2021-09-17 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, t.p.northover.
Herald added a subscriber: mgorny.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang build fails when build directory contains space character.

Error messages:

[ 95%] Linking CXX executable ../../../../bin/clang
clang: error: no such file or directory: 
'Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'
make[2]: *** [bin/clang-14] Error 1
make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs

The path name is actually:

  'Dev Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'

Bugzilla issue - https://bugs.llvm.org/show_bug.cgi?id=51884
Reporter and patch author - Brain Swift 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109979

Files:
  clang/tools/driver/CMakeLists.txt


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-17 Thread Richard Howell via Phabricator via cfe-commits
rmaz added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1434-1436
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}

dexonsmith wrote:
> Hmm, I was imagining that the set would be more encapsulated than this, not 
> just stored in the same place.
> 
> I'm wondering if the following could be done in a prep commit:
> 
> - Change Sema::addMethodToGlobalList to a private member function of 
> GlobalMethodPool.
> - Make GlobalMethodPool::insert private
> - Add `GlobalMethodPool::addMethod(ObjCMethodDecl*,bool,bool)`, which does 
> the second half of Sema::AddMethodToGlobalPool (the parts that don't need 
> Sema's other fields), and change the latter to call the former.
> 
> WDYT?
Definitely neater, will take a look at this later today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D109975#3006580 , @Quuxplusone 
wrote:

> Serendipitously, I just yesterday upgraded from OSX 10.14 to 10.15, and have 
> been unable to build clang because, even with a totally-empty-and-brand-new 
> build directory, CMake says:
>
>   CMake Error in lib/WindowsManifest/CMakeLists.txt:
> Imported target "LibXml2::LibXml2" includes non-existent path
>   
> "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2"
> in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
> * The path was deleted, renamed, or moved to another location.
> * An install or uninstall procedure did not complete successfully.
> * The installation package was faulty and references files it does not
> provide.
>   -- Generating done
>   CMake Generate step failed.  Build files cannot be regenerated correctly.
>
> Do you think this PR would fix that issue on OSX 10.15?
> (IMHO it's also weird that OSX would even be trying to build anything with 
> `Windows` in the name.)

Since there is nothing platform specific in the code of WindowsManifest it'd 
make sense to build it on any OS; At the very least for cross compile setups.

I sadly am not very accustomed to Macs so I don't know the details, but I don't 
think this patch would change anything about your situation.

Could it maybe be related to the `CMAKE_OSX_SYSROOT` variable somehow? CMake 
seems to use it to lookup packages from the platform SDK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

That's pretty nice! Have you thought about looking into a lit option (triggered 
by a cmake flag maybe) that would change the substitution for the tools that 
are enabled by llvm-driver to use the latter instead when running the tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@kees this does fix https://bugs.llvm.org/show_bug.cgi?id=50322  , but only if 
the memcpy "inline definition" is flagged as a `__attribute__((always_inline))`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109967

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


[PATCH] D109981: [Diagnostics] Don't drop a statically set NoWarningAsError flag during option processing

2021-09-17 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp created this revision.
wolfgangp added a reviewer: dexonsmith.
wolfgangp requested review of this revision.

Fixes PR 51837.

When a -W option is given on the command line, and the corresponding 
diangostic has the NoWarnOnError flag set, the flag is dropped when the 
severity is reevaluated, possibly as a result of a pragma or of command line 
processing.


https://reviews.llvm.org/D109981

Files:
  clang/lib/Basic/Diagnostic.cpp
  clang/test/Lexer/pragma-message.c


Index: clang/test/Lexer/pragma-message.c
===
--- clang/test/Lexer/pragma-message.c
+++ clang/test/Lexer/pragma-message.c
@@ -8,24 +8,25 @@
 // #pragma message messagestring
 //
 // RUN: %clang_cc1 -fsyntax-only -verify -Werror %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror -W#pragma-messages %s
 #define STRING2(x) #x
 #define STRING(x) STRING2(x)
-#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 13}}
-#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning 
{{:O gcc accepts this! 14}}
+#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 14}}
+#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning 
{{:O gcc accepts this! 15}}
 
 #pragma message(invalid) // expected-error {{expected string literal in pragma 
message}}
 
 // GCC supports a similar pragma, #pragma GCC warning (which generates a 
warning
 // message) and #pragma GCC error (which generates an error message).
 
-#pragma GCC warning(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 21}}
-#pragma GCC warning ":O gcc accepts this! " STRING(__LINE__) // 
expected-warning {{:O gcc accepts this! 22}}
+#pragma GCC warning(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 22}}
+#pragma GCC warning ":O gcc accepts this! " STRING(__LINE__) // 
expected-warning {{:O gcc accepts this! 23}}
 
-#pragma GCC error(":O I'm a message! " STRING(__LINE__)) // expected-error 
{{:O I'm a message! 24}}
-#pragma GCC error ":O gcc accepts this! " STRING(__LINE__) // expected-error 
{{:O gcc accepts this! 25}}
+#pragma GCC error(":O I'm a message! " STRING(__LINE__)) // expected-error 
{{:O I'm a message! 25}}
+#pragma GCC error ":O gcc accepts this! " STRING(__LINE__) // expected-error 
{{:O gcc accepts this! 26}}
 
 #define COMPILE_ERROR(x) _Pragma(STRING2(GCC error(x)))
-COMPILE_ERROR("Compile error at line " STRING(__LINE__) "!"); // 
expected-error {{Compile error at line 28!}}
+COMPILE_ERROR("Compile error at line " STRING(__LINE__) "!"); // 
expected-error {{Compile error at line 29!}}
 
 #pragma message // expected-error {{pragma message requires parenthesized 
string}}
 #pragma GCC warning("" // expected-error {{pragma warning requires 
parenthesized string}}
Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -374,6 +374,12 @@
   DiagnosticMapping Mapping = makeUserMapping(Map, L);
   Mapping.setUpgradedFromWarning(WasUpgradedFromWarning);
 
+  // Make sure we propagate the NoWarningAsError flag from an existing
+  // mapping (which may be the default mapping).
+  DiagnosticMapping &Info = GetCurDiagState()->getOrAddMapping(Diag);
+  Mapping.setNoWarningAsError(Info.hasNoWarningAsError() ||
+  Mapping.hasNoWarningAsError());
+
   // Common case; setting all the diagnostics of a group in one place.
   if ((L.isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
   DiagStatesByLoc.getCurDiagState()) {


Index: clang/test/Lexer/pragma-message.c
===
--- clang/test/Lexer/pragma-message.c
+++ clang/test/Lexer/pragma-message.c
@@ -8,24 +8,25 @@
 // #pragma message messagestring
 //
 // RUN: %clang_cc1 -fsyntax-only -verify -Werror %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror -W#pragma-messages %s
 #define STRING2(x) #x
 #define STRING(x) STRING2(x)
-#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 13}}
-#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 14}}
+#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 14}}
+#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 15}}
 
 #pragma message(invalid) // expected-error {{expected string literal in pragma message}}
 
 // GCC supports a similar pragma, #pragma GCC warning (which generates a warning
 // message) and #pragma GCC error (which generates an error message).
 
-#pragma GCC warning(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 21}}
-#pragma GCC warning ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this

[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 373271.
browneee added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/test/dfsan/Inputs/flags_abilist.txt
  compiler-rt/test/dfsan/force_zero.c
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
  llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s -DSHADOW_XOR_MASK=87960930222080
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+define i32 @function_to_force_zero(i32 %0, i32* %1) {
+  ; CHECK-LABEL: define i32 @function_to_force_zero.dfsan
+  ; CHECK: %[[#SHADOW_XOR:]] = xor i64 {{.*}}, [[SHADOW_XOR_MASK]]
+  ; CHECK: %[[#SHADOW_PTR:]] = inttoptr i64 %[[#SHADOW_XOR]] to i8*
+  ; CHECK: %[[#SHADOW_BITCAST:]] = bitcast i8* %[[#SHADOW_PTR]] to i32*
+  ; CHECK: store i32 0, i32* %[[#SHADOW_BITCAST]]
+  ; CHECK: store i32 %{{.*}}
+  store i32 %0, i32* %1, align 4
+  ; CHECK: store i8 0, {{.*}}@__dfsan_retval_tls
+  ; CHECK: ret i32
+  ret i32 %0
+}
Index: llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===
--- llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -8,3 +8,5 @@
 fun:custom*=custom
 
 fun:uninstrumented*=uninstrumented
+
+fun:function_to_force_zero=force_zero_labels
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -144,8 +144,17 @@
 // to the "native" (i.e. unsanitized) ABI.  Unless the ABI list contains
 // additional annotations for those functions, a call to one of those functions
 // will produce a warning message, as the labelling behaviour of the function is
-// unknown.  The other supported annotations are "functional" and "discard",
-// which are described below under DataFlowSanitizer::WrapperKind.
+// unknown. The other supported annotations for uninstrumented functions are
+// "functional" and "discard", which are described below under
+// DataFlowSanitizer::WrapperKind.
+// Functions will often be labelled with both "uninstrumented" and one of
+// "functional" or "discard". This will leave the function unchanged by this
+// pass, and create a wrapper function with that will call the original.
+//
+// Instrumented functions can also be annotated as "force_zero_labels", which
+// will make all shadow stores and label for return values set zero labels.
+// Functions should never be labelled with both "force_zero_labels" and
+// "uninstrumented" or any of the unistrumented wrapper kinds.
 static cl::list ClABIListFiles(
 "dfsan-abilist",
 cl::desc("File listing native ABI functions and how the pass treats them"),
@@ -469,6 +478,7 @@
   getShadowOriginAddress(Value *Addr, Align InstAlignment, Instruction *Pos);
   bool isInstrumented(const Function *F);
   bool isInstrumented(const GlobalAlias *GA);
+  bool isForceZeroLabels(const Function *F);
   FunctionType *getArgsFunctionType(FunctionType *T);
   FunctionType *getTrampolineFunctionType(FunctionType *T);
   TransformedFunction getCustomFunctionType(FunctionType *T);
@@ -541,6 +551,7 @@
   DominatorTree DT;
   DataFlowSanitizer::InstrumentedABI IA;
   bool IsNativeABI;
+  bool IsForceZeroLabels;
   AllocaInst *LabelReturnAlloca = nullptr;
   AllocaInst *OriginReturnAlloca = nullptr;
   DenseMap ValShadowMap;
@@ -571,8 +582,10 @@
   DenseMap CachedCollapsedShadows;
   DenseMap> ShadowElements;
 
-  DFSanFunction(DataFlowSanitizer &DFS, Function *F, bool IsNativeABI)
-  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI) {
+  DFSanFunction(DataFlowSanitizer &DFS, Function *F, bool IsNativeABI,
+bool IsForceZeroLabels)
+  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI),
+IsForceZeroLabels(IsForceZeroLabels) {
 DT.recalculate(*F);
   }
 
@@ -1107,6 +1120,10 @@
   return !ABIList.isIn(*GA, "uninstrumented");
 }
 
+bool DataFlowSanitizer::isForceZeroLabels(const Function *F) {
+  return ABIList.isIn(*F, "force_zero_labels");
+}
+
 DataFlowSanitizer::InstrumentedABI DataFlowSanitizer::getInstrumentedABI() {
   return ClArgsABI ? IA_Args : IA_TLS;
 }
@@ -1197,7 +1214,8 @@
 
 // F is called by a wrapped custom function with

[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 373274.
browneee marked 3 inline comments as done.
browneee added a comment.

Update comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/test/dfsan/Inputs/flags_abilist.txt
  compiler-rt/test/dfsan/force_zero.c
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
  llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s -DSHADOW_XOR_MASK=87960930222080
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+define i32 @function_to_force_zero(i32 %0, i32* %1) {
+  ; CHECK-LABEL: define i32 @function_to_force_zero.dfsan
+  ; CHECK: %[[#SHADOW_XOR:]] = xor i64 {{.*}}, [[SHADOW_XOR_MASK]]
+  ; CHECK: %[[#SHADOW_PTR:]] = inttoptr i64 %[[#SHADOW_XOR]] to i8*
+  ; CHECK: %[[#SHADOW_BITCAST:]] = bitcast i8* %[[#SHADOW_PTR]] to i32*
+  ; CHECK: store i32 0, i32* %[[#SHADOW_BITCAST]]
+  ; CHECK: store i32 %{{.*}}
+  store i32 %0, i32* %1, align 4
+  ; CHECK: store i8 0, {{.*}}@__dfsan_retval_tls
+  ; CHECK: ret i32
+  ret i32 %0
+}
Index: llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===
--- llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -8,3 +8,5 @@
 fun:custom*=custom
 
 fun:uninstrumented*=uninstrumented
+
+fun:function_to_force_zero=force_zero_labels
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -144,8 +144,17 @@
 // to the "native" (i.e. unsanitized) ABI.  Unless the ABI list contains
 // additional annotations for those functions, a call to one of those functions
 // will produce a warning message, as the labelling behaviour of the function is
-// unknown.  The other supported annotations are "functional" and "discard",
-// which are described below under DataFlowSanitizer::WrapperKind.
+// unknown. The other supported annotations for uninstrumented functions are
+// "functional" and "discard", which are described below under
+// DataFlowSanitizer::WrapperKind.
+// Functions will often be labelled with both "uninstrumented" and one of
+// "functional" or "discard". This will leave the function unchanged by this
+// pass, and create a wrapper function that will call the original.
+//
+// Instrumented functions can also be annotated as "force_zero_labels", which
+// will make all shadow and return values set zero labels.
+// Functions should never be labelled with both "force_zero_labels" and
+// "uninstrumented" or any of the unistrumented wrapper kinds.
 static cl::list ClABIListFiles(
 "dfsan-abilist",
 cl::desc("File listing native ABI functions and how the pass treats them"),
@@ -469,6 +478,7 @@
   getShadowOriginAddress(Value *Addr, Align InstAlignment, Instruction *Pos);
   bool isInstrumented(const Function *F);
   bool isInstrumented(const GlobalAlias *GA);
+  bool isForceZeroLabels(const Function *F);
   FunctionType *getArgsFunctionType(FunctionType *T);
   FunctionType *getTrampolineFunctionType(FunctionType *T);
   TransformedFunction getCustomFunctionType(FunctionType *T);
@@ -541,6 +551,7 @@
   DominatorTree DT;
   DataFlowSanitizer::InstrumentedABI IA;
   bool IsNativeABI;
+  bool IsForceZeroLabels;
   AllocaInst *LabelReturnAlloca = nullptr;
   AllocaInst *OriginReturnAlloca = nullptr;
   DenseMap ValShadowMap;
@@ -571,8 +582,10 @@
   DenseMap CachedCollapsedShadows;
   DenseMap> ShadowElements;
 
-  DFSanFunction(DataFlowSanitizer &DFS, Function *F, bool IsNativeABI)
-  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI) {
+  DFSanFunction(DataFlowSanitizer &DFS, Function *F, bool IsNativeABI,
+bool IsForceZeroLabels)
+  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI),
+IsForceZeroLabels(IsForceZeroLabels) {
 DT.recalculate(*F);
   }
 
@@ -1107,6 +1120,10 @@
   return !ABIList.isIn(*GA, "uninstrumented");
 }
 
+bool DataFlowSanitizer::isForceZeroLabels(const Function *F) {
+  return ABIList.isIn(*F, "force_zero_labels");
+}
+
 DataFlowSanitizer::InstrumentedABI DataFlowSanitizer::getInstrumentedABI() {
   return ClArgsABI ? IA_Args : IA_TLS;
 }
@@ -1197,7 +1214,8 @@
 
 // F is called by

[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: llvm/tools/llvm-driver/CMakeLists.txt:17
+
+add_llvm_tool(llvm-driver
+  llvm-driver.cpp

As was already suggested on D104686, I'd prefer naming this just `llvm` so you 
can invoke tools with `llvm name` which doesn't require any additional typing 
compared to `llvm-name`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

2021-09-17 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.
Herald added a subscriber: ctetreau.

Just to mention, 'llvm.experimental.constrained.powi' uses i32. Probably not a 
big deal, just small inconsistency with llvm.powi.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99439

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 373277.
cchen added a comment.

Fix tests for Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1701,6 +1702,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1322,6 +1322,7 @@
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
+CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

1. Make it private, please
2. Var names must start from capital letter `stmt`->`S`



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2389
+
+int idx = 0;
+// In OpenMP 5.0 metadirective is either replaced by another directive or

Please, fix var names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

I was inspired to dig down and find the `LLVM_ENABLE_LIBXML2` option (which is 
on by default) and turn it off, so now I can build clang with the following 
commands:

  cmake -G Ninja -DLLVM_ENABLE_LIBXML2=0 -DDEFAULT_SYSROOT="$(xcrun 
--show-sdk-path)" -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" 
-DCMAKE_BUILD_TYPE=Release ../llvm
  ninja clang

I suspect that my `/usr/lib/libxml2.2.dylib` is simply outdated/has been borked 
by my OS upgrade; unfortunately I still haven't figured out how to install a 
newer version of it.
Anyway, never mind me, then. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

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


[clang] 101c3de - Add information about C99 to the C status page.

2021-09-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-09-17T13:49:17-04:00
New Revision: 101c3de39fbcdd7d47b25aaf6d972e435f017077

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

LOG: Add information about C99 to the C status page.

Added: 


Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 4fb3764233fda..386859125a82a 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -84,8 +84,251 @@ C89 implementation status
 C99 implementation status
 
 Clang implements a significant portion of the ISO 9899:1999 (C99) standard, 
but the status of individual proposals is still under investigation.
+Note, the list of C99 features comes from the C99 committee draft. A list 
of N-numbered documents for these features does not appear in either the 
standard or in any available editor's report, so this section does not track 
document numbers currently.
 You can use Clang in C99 mode with the -std=c99 option.
 
+
+List of features and minimum Clang version with support
+
+
+ 
+Language Feature
+
+Available in Clang?
+ 
+
+  restricted character set support via digraphs and 

+
+  Unknown
+
+
+  more precise aliasing rules via effective type
+
+  Unknown
+
+
+  restricted pointers
+
+  Unknown
+
+
+  variable length arrays
+
+  Yes
+
+
+  flexible array members
+
+  Yes
+
+
+  static and type qualifiers in parameter array declarators
+
+  Yes
+
+
+  more precise aliasing rules via effective type
+
+  Unknown
+
+
+  complex and imaginary support in 
+
+  Unknown
+
+
+  type-generic math macros in 
+
+  Yes
+
+
+  the long long int type
+
+  Yes
+
+
+  increase minimum translation limits
+
+  Unknown
+
+
+  additional floating-point characteristics in 
+
+  Unknown
+
+
+  remove implicit int
+
+  Unknown
+
+
+  reliable integer division
+
+  Unknown
+
+
+  universal character names (\u and \U)
+
+  Yes
+
+
+  extended identifiers
+
+  Unknown
+
+
+  hexadecimal floating-point constants
+
+  Yes
+
+
+  compound literals
+
+  Yes
+
+
+  designated initializers
+
+  Yes
+
+
+  // comments
+
+  Yes
+
+
+  extended integer types and library functions in  
and 
+
+  Yes
+
+
+  remove implicit function declaration
+
+  Unknown
+
+
+  preprocessor arithmetic done in intmax_t/uintmax_t
+
+  Unknown
+
+
+  mixed declarations and code
+
+  Yes
+
+
+  new block scopes for selection and iteration statements
+
+  Unknown
+
+
+  integer constant type rules
+
+  Unknown
+
+
+  integer promotion rules
+
+  Unknown
+
+
+  macros with a variable number of arguments
+
+  Yes
+
+
+  IEC 60559 support
+
+  Unknown
+
+
+  trailing comma allowed in enum declaration
+
+  Yes
+
+
+  inline functions
+
+  Yes
+
+
+  boolean type in 
+
+  Yes
+
+
+  idempotent type qualifiers
+
+  Unknown
+
+
+  empty macro arguments
+
+  Unknown
+
+
+  new structure type compatibility (tag compatibility)
+
+  Unknown
+
+
+  additional predefined macro names
+
+  Unknown
+
+
+  _Pragma preprocessing operator
+
+  Yes
+
+
+  standard pragmas
+
+  Unknown
+
+
+  __func__ predefined identifier
+
+  Yes
+
+
+  va_copy macro
+
+  Yes
+
+
+  LIA compatibility annex
+
+  No
+
+
+  remove deprecation of aliased array parameters
+
+  Unknown
+
+
+  conversion of array to pointer not limited to lvalues
+
+  Unknown
+
+
+  relaxed constraints on aggregate and union initialization
+
+  Unknown
+
+
+  relaxed restrictions on portable header names
+
+  Unknown
+
+
+  return without an expression not permitted in function that returns 
a value
+
+  Yes
+
+
+
+
 C11 implementation status
 
 Clang implements a significant portion of the ISO 9899:2011 (C11) standard, 
but the status of individual proposals is still under investigation.



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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D109977#3006687 , @mehdi_amini 
wrote:

> That's pretty nice! Have you thought about looking into a lit option 
> (triggered by a cmake flag maybe) that would change the substitution for the 
> tools that are enabled by llvm-driver to use the latter instead when running 
> the tests?

That's an awesome idea. I had been thinking about having a CMake option to 
generate symlinks instead of the tools, but you could totally bake this into 
the lit substitutions. I'll take a look at that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: llvm/tools/llvm-driver/CMakeLists.txt:17
+
+add_llvm_tool(llvm-driver
+  llvm-driver.cpp

phosek wrote:
> As was already suggested on D104686, I'd prefer naming this just `llvm` so 
> you can invoke tools with `llvm name` which doesn't require any additional 
> typing compared to `llvm-name`.
Can do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D102449: [WIP][Clang][OpenMP] Add the support for compare clause in atomic directive

2021-09-17 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli added a comment.

In D102449#2977711 , @tianshilei1992 
wrote:

> Another thing is how we deal with a corner case. Say the OpenMP code is 
> written in the following way:
>
>   #pragma omp atomic compare
> x = e < x ? e : x;
>
> That's how OpenMP spec defines the atomic operation. `x` is always in "else 
> statement" of a conditional statement.
>
> Now we need to lower it to LLVM IR, which is `atomicrmw` operation. Based on 
> the LLVM IR reference, it only supports the atomic operations that `x` is in 
> the "then statement". For example: `x = x > e ? x : e`. See the `x` here is 
> before `:`. In order to lower the OpenMP statement, we have to do a 
> transformation. In order to swap `e` and `x`, we need to transform it to `x = 
> e >= x : x : e`, a.k.a. `x = x <= e : x : e`. However, we don't have an 
> atomic operation for `<=`. We only have `<`. So if `x != e`, the result is 
> good.
>
> The incorrectness happens if `x == e`. Recall at the OpenMP statement, when 
> `x == e`, the result should be `x = x`. But if we look at our lowered LLVM 
> IR, `x = x < e : x : e`, when `x == e`, it becomes `x = e`, which doesn't 
> conform with OpenMP spec.
>
> What should we do here?

There seems to be an imbalance in the OpenMP specs, where I would have written 
something like the followin (page 268 or 5.1 spec's):

> x = expr ordop x ? expr : x;
> x = x ordop expr ? **x : expr**;

I tried thinking about a compact solution to your problem, including trying to 
take advantage of the fact that when x == e we don't need to actually do the 
assignment (page 272 line 17 of 5.1 spec's and see below), but I was 
unsuccessful.
Did you consider special casing this transforming it into the equivalent:
#pragma omp critical
{ if (x > e) x = e; }
?

Remember:

> For forms where statement is cond-expr-stmt, if the result of the condition 
> implies that the value of x
> does not change then the update may not occur.

The right thing to do would be to fix the spec's, but that can't happen until 
5.2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102449

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


[PATCH] D109437: [PowerPC] FP compare and test XL compat builtins.

2021-09-17 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:3490
+   SemaBuiltinConstantArgRange(TheCall, 1, 0, 127) ||
+   CheckPPCTestDataClassType(TheCall);
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \

If you're making a function anyways, it may be a good idea to just have a 
function with all the sema checking in it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109437

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-17 Thread Richard Howell via Phabricator via cfe-commits
rmaz added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1434-1436
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}

rmaz wrote:
> dexonsmith wrote:
> > Hmm, I was imagining that the set would be more encapsulated than this, not 
> > just stored in the same place.
> > 
> > I'm wondering if the following could be done in a prep commit:
> > 
> > - Change Sema::addMethodToGlobalList to a private member function of 
> > GlobalMethodPool.
> > - Make GlobalMethodPool::insert private
> > - Add `GlobalMethodPool::addMethod(ObjCMethodDecl*,bool,bool)`, which does 
> > the second half of Sema::AddMethodToGlobalPool (the parts that don't need 
> > Sema's other fields), and change the latter to call the former.
> > 
> > WDYT?
> Definitely neater, will take a look at this later today.
This might need a slightly different approach, as for the insert use case we 
have:

```lang=cxx
Sema &S = *getSema();
  Sema::GlobalMethodPool::iterator Pos =
  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
  .first;

  Pos->second.first.setBits(Visitor.getInstanceBits());
  Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
  Pos->second.second.setBits(Visitor.getFactoryBits());
  Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());

  // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
  // when building a module we keep every method individually and may need to
  // update hasMoreThanOneDecl as we add the methods.
  addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
  addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
```

At the moment we fetch a method list, modify its state and then start inserting 
the methods. If we move to something like `MethodPool.addMethod(ObjCMethodDecl 
*)` we will have to look up the method list for each insert, and we would need 
extra methods to set the state first on the method list. How about something 
like `MethodPool.addMethods(ArrayRef methods, unsigned 
instanceBits, bool hasMoreThanOneDecl)`? Then we only need two list lookups per 
selector as before and we can handle the list state update before insert.
 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[clang] d13d9da - [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-09-17T21:39:25+03:00
New Revision: d13d9da1fbe1a750f9c4fc3f4da31c9d16a530d3

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

LOG: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

Windows on armv7 is as alignment tolerant as Linux.

The alignment considerations in the Windows on ARM ABI are documented
at 
https://docs.microsoft.com/en-us/cpp/build/overview-of-arm-abi-conventions?view=msvc-160#alignment.

The document doesn't explicitly say in which state the OS configures
the SCTLR.A register (and it's not accessible from user space to
inspect), but in practice, unaligned loads/stores do work and seem
to be as fast as aligned loads and stores. (Unaligned strd also does
seem to work, contrary to Linux, but significantly slower, as they're
handled by the kernel - exactly as the document describes.)

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/arm-alignment.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index a64fc30858748..05d83c91ba0ef 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -779,7 +779,8 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -787,7 +788,8 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else

diff  --git a/clang/test/Driver/arm-alignment.c 
b/clang/test/Driver/arm-alignment.c
index b2bc8a35dfc6f..41dbb35b1c2c2 100644
--- a/clang/test/Driver/arm-alignment.c
+++ b/clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 



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


[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd13d9da1fbe1: [clang] [ARM] Don't set the strict 
alignment flag for armv7 on Windows (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109960

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-alignment.c


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -779,7 +779,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -787,7 +788,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -779,7 +779,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -787,7 +788,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109990: [OpenMP][Docs] Update clang support based on community discussion

2021-09-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: ABataev, grokos, JonChesterfield, gregrodgers, ronl, 
RaviNarayanaswamy, dreachem.
Herald added subscribers: guansong, bollu, yaxunl.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

In the last meeting nobody could tell what was problematic for some of
the points so we mark them as done until we realize otherwise.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109990

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -187,7 +187,7 @@
 
+--+--+--+---+
 | device extension | omp_get_device_num()  
   | :part:`worked on`| D54342  
  |
 
+--+--+--+---+
-| device extension | structure mapping of references   
   | :none:`unclaimed`| 
  |
+| device extension | structure mapping of references   
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | device extension | nested target declare 
   | :good:`done` | D51378  
  |
 
+--+--+--+---+
@@ -201,13 +201,13 @@
 
+--+--+--+---+
 | device extension | clause: unified_address   
   | :part:`partial`  | 
  |
 
+--+--+--+---+
-| device extension | clause: reverse_offload   
   | :none:`unclaimed parts`  | D52780  
  |
+| device extension | clause: reverse_offload   
   | :part:`unclaimed parts`  | D52780  
  |
 
+--+--+--+---+
 | device extension | clause: atomic_default_mem_order  
   | :good:`done` | D53513  
  |
 
+--+--+--+---+
 | device extension | clause: dynamic_allocators
   | :part:`unclaimed parts`  | D53079  
  |
 
+--+--+--+---+
-| device extension | user-defined mappers  
   | :part:`worked on`| 
D56326,D58638,D58523,D58074,D60972,D59474 |
+| device extension | user-defined mappers  
   | :good:`done` | 
D56326,D58638,D58523,D58074,D60972,D59474 |
 
+--+--+--+---+
 | device extension | mapping lambda expression   

[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19271
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();

From the name I would expect also to check
```SomeClass::SomeClass()
  : a{a},
b{b}
...
```
With and without the PP directive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 373300.
beanz added a comment.

Renaming llvm-driver binary to llvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -401,7 +401,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -43,6 +43,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,61 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry) int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+// This function handles the case of not recognizing the tool requested, or if
+// --help or --version are passed directly to the llvm driver.
+int UnknownMain(int Argc, char **Argv) {
+  cl::OptionCategory LLVMDriverCategory("llvm options");
+#define LLVM_DRIVER_TOOL(tool, entry)  \
+  cl::SubCommand entry##Subcommand(tool, tool);
+#include "LLVMDriverTools.def"
+
+  cl::HideUnrelatedOptions(LLVMDriverCategory);
+  cl::ParseCommandLineOptions(Argc, Argv, "llvm compiler driver\n");
+  llvm_unreachable("We should never get here, parsing should always exit.");
+  return 1;
+}
+
+int main(int Argc, char **Argv) {
+  llvm::StringRef LaunchedTool = sys::path::stem(Argv[0]);
+  // If the driver is launched directly.
+  int PassThroughArgC = Argc;
+  char **PassThroughArgV = Argv;
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+LaunchedTool = Argv[1];
+ConsumeFirstArg = true;
+  }
+
+  // if it is launched through a symlink that is the tool name.
+  typedef int (*MainFunction)(int, char **);
+  MainFunction Func = StringSwitch(LaunchedTool)
+
+#define LLVM_DRIVER_TOOL(tool, entry) .Case(tool, entry##_main)
+#include "LLVMDriverTools.def"
+  .Default(UnknownMain);
+  // If the main function is unknown we don't consume any args, so that we can
+  // print the appropriate help spew.
+  if (Func != UnknownMain && ConsumeFirstArg) {
+--PassThroughArgC;
+++PassThroughArgV;
+  }
+
+  return Func(PassThroughArgC, PassThroughArgV);
+}
Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- /dev/null
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -0,0 +1,28 @@
+get_property(LLVM_COMMON_DEPENDS GLOBAL PROPERTY LLVM_DRIVER_DEPS)
+get_property(LLVM_DRIVER_OBJLIBS GLOBAL PROPERTY LLVM_DRIVER_OBJLIBS)
+
+get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
+
+foreach(tool ${LLVM_DRIVER_TOOLS})
+  string(REPLACE "-" "_" tool_entry ${tool})
+  set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry})\n")
+endforeach()
+
+file(WRITE
+  "${CMAKE_CURRENT_BINARY_DIR}/LLVMDriverTools.def"
+  "${def_decl}#undef LLVM_DRIVER_TO

[PATCH] D109990: [OpenMP][Docs] Update clang support based on community discussion

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109990

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


[clang] 80d6299 - [clang][darwin] Add support for --emit-static-lib

2021-09-17 Thread Keith Smiley via cfe-commits

Author: Keith Smiley
Date: 2021-09-17T12:11:05-07:00
New Revision: 80d62993d0720bc36523e39e64cc36da6e445e64

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

LOG: [clang][darwin] Add support for --emit-static-lib

This uses darwin's default libtool since llvm-ar isn't normally
available.

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

Added: 
clang/test/Driver/darwin-static-lib.c

Modified: 
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/test/Driver/bindings.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 6c1b88141c45..7272cc29cc7c 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -618,6 +618,8 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
 
 std::string ToolChain::GetStaticLibToolPath() const {
   // TODO: Add support for static lib archiving on Windows
+  if (Triple.isOSDarwin())
+return GetProgramPath("libtool");
   return GetProgramPath("llvm-ar");
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 15c885fa6507..8f3b6336d59d 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -729,6 +729,54 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   C.addCommand(std::move(Cmd));
 }
 
+void darwin::StaticLibTool::ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
+  const Driver &D = getToolChain().getDriver();
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and "clang -emit-llvm foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_emit_llvm);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
+  // libtool   
+  ArgStringList CmdArgs;
+  // Create and insert file members with a deterministic index.
+  CmdArgs.push_back("-static");
+  CmdArgs.push_back("-D");
+  CmdArgs.push_back("-no_warning_for_no_symbols");
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs) {
+if (II.isFilename()) {
+  CmdArgs.push_back(II.getFilename());
+}
+  }
+
+  // Delete old output archive file if it already exists before generating a 
new
+  // archive file.
+  const auto *OutputFileName = Output.getFilename();
+  if (Output.isFilename() && llvm::sys::fs::exists(OutputFileName)) {
+if (std::error_code EC = llvm::sys::fs::remove(OutputFileName)) {
+  D.Diag(diag::err_drv_unable_to_remove_file) << EC.message();
+  return;
+}
+  }
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetStaticLibToolPath());
+  C.addCommand(std::make_unique(JA, *this,
+ ResponseFileSupport::AtFileUTF8(),
+ Exec, CmdArgs, Inputs, Output));
+}
+
 void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output,
 const InputInfoList &Inputs,
@@ -982,6 +1030,10 @@ Tool *MachO::getTool(Action::ActionClass AC) const {
 
 Tool *MachO::buildLinker() const { return new tools::darwin::Linker(*this); }
 
+Tool *MachO::buildStaticLibTool() const {
+  return new tools::darwin::StaticLibTool(*this);
+}
+
 Tool *MachO::buildAssembler() const {
   return new tools::darwin::Assembler(*this);
 }

diff  --git a/clang/lib/Driver/ToolChains/Darwin.h 
b/clang/lib/Driver/ToolChains/Darwin.h
index 4de122c8d513..e46ff52a23a9 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -78,6 +78,20 @@ class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
 const char *LinkingOutput) const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY StaticLibTool : public MachOTool {
+public:
+  StaticLibTool(const ToolChain &TC)
+  : MachOTool("darwin::StaticLibTool", "static-lib-linker", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+ 

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

ABataev wrote:
> 1. Make it private, please
> 2. Var names must start from capital letter `stmt`->`S`
I'm going to fix it. By the way, do you know how to fix those failing Windows 
tests? I tried to fix it by adding `ifndef HEADER` to test files and also 
replace var names with regex, but those Windows tests still fail. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D109461: [clang][darwin] Add support for --emit-static-lib

2021-09-17 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80d62993d072: [clang][darwin] Add support for 
--emit-static-lib (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109461

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/bindings.c
  clang/test/Driver/darwin-static-lib.c

Index: clang/test/Driver/darwin-static-lib.c
===
--- /dev/null
+++ clang/test/Driver/darwin-static-lib.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target i386-apple-darwin9 %s -### --emit-static-lib 2>&1 | FileCheck %s
+// CHECK: "{{.*}}libtool" "-static" "-D" "-no_warning_for_no_symbols" "-o" "a.out" "{{.*o}}"
+
+// RUN: %clang -target i386-apple-darwin9 %s -### --emit-static-lib -o libfoo.a 2>&1 | FileCheck %s --check-prefix=OUTPUT
+// OUTPUT: "{{.*}}libtool" "-static" "-D" "-no_warning_for_no_symbols" "-o" "libfoo.a" "{{.*o}}"
Index: clang/test/Driver/bindings.c
===
--- clang/test/Driver/bindings.c
+++ clang/test/Driver/bindings.c
@@ -27,3 +27,7 @@
 // GNU StaticLibTool binding
 // RUN: %clang -target x86_64-linux-gnu -ccc-print-bindings --emit-static-lib %s 2>&1 | FileCheck %s --check-prefix=CHECK15
 // CHECK15: "x86_64-unknown-linux-gnu" - "GNU::StaticLibTool", inputs: ["{{.*}}.o"], output: "a.out"
+
+// Darwin StaticLibTool binding
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-bindings --emit-static-lib %s 2>&1 | FileCheck %s --check-prefix=CHECK16
+// CHECK16: "i386-apple-darwin9" - "darwin::StaticLibTool", inputs: ["{{.*}}.o"], output: "a.out"
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -78,6 +78,20 @@
 const char *LinkingOutput) const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY StaticLibTool : public MachOTool {
+public:
+  StaticLibTool(const ToolChain &TC)
+  : MachOTool("darwin::StaticLibTool", "static-lib-linker", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY Lipo : public MachOTool {
 public:
   Lipo(const ToolChain &TC) : MachOTool("darwin::Lipo", "lipo", TC) {}
@@ -125,6 +139,7 @@
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
+  Tool *buildStaticLibTool() const override;
   Tool *getTool(Action::ActionClass AC) const override;
 
 private:
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -729,6 +729,54 @@
   C.addCommand(std::move(Cmd));
 }
 
+void darwin::StaticLibTool::ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
+  const Driver &D = getToolChain().getDriver();
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and "clang -emit-llvm foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_emit_llvm);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
+  // libtool   
+  ArgStringList CmdArgs;
+  // Create and insert file members with a deterministic index.
+  CmdArgs.push_back("-static");
+  CmdArgs.push_back("-D");
+  CmdArgs.push_back("-no_warning_for_no_symbols");
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs) {
+if (II.isFilename()) {
+  CmdArgs.push_back(II.getFilename());
+}
+  }
+
+  // Delete old output archive file if it already exists before generating a new
+  // archive file.
+  const auto *OutputFileName = Output.getFilename();
+  if (Output.isFilename() && llvm::sys::fs::exists(OutputFileName)) {
+if (std::error_code EC = llvm::sys::fs::remove(OutputFileName)) {
+  D.Diag(diag::err_drv_unable_to_remove_file) << EC.message();
+  return;
+}
+  }
+
+  const char *Exec = Args.MakeArgString(getToolChain().Get

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

cchen wrote:
> ABataev wrote:
> > 1. Make it private, please
> > 2. Var names must start from capital letter `stmt`->`S`
> I'm going to fix it. By the way, do you know how to fix those failing Windows 
> tests? I tried to fix it by adding `ifndef HEADER` to test files and also 
> replace var names with regex, but those Windows tests still fail. Thanks
No idea. Need a bit of context (I mean, would be good to see the test log etc.).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

ABataev wrote:
> cchen wrote:
> > ABataev wrote:
> > > 1. Make it private, please
> > > 2. Var names must start from capital letter `stmt`->`S`
> > I'm going to fix it. By the way, do you know how to fix those failing 
> > Windows tests? I tried to fix it by adding `ifndef HEADER` to test files 
> > and also replace var names with regex, but those Windows tests still fail. 
> > Thanks
> No idea. Need a bit of context (I mean, would be good to see the test log 
> etc.).
I think the run line might be so general, I update it and see if that helps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

cchen wrote:
> ABataev wrote:
> > cchen wrote:
> > > ABataev wrote:
> > > > 1. Make it private, please
> > > > 2. Var names must start from capital letter `stmt`->`S`
> > > I'm going to fix it. By the way, do you know how to fix those failing 
> > > Windows tests? I tried to fix it by adding `ifndef HEADER` to test files 
> > > and also replace var names with regex, but those Windows tests still 
> > > fail. Thanks
> > No idea. Need a bit of context (I mean, would be good to see the test log 
> > etc.).
> I think the run line might be so general, I update it and see if that helps.
Just provide target triple in all test runs commands for linux and make a 
separate test for windows (if required), it should fix the issue with the 
testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 373312.
cchen added a comment.

Fix tests and coding style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1703,6 +1704,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1391,6 +1391,7 @@
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
+CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector option

[PATCH] D109996: [PowerPC] Fix signature of lxvp and stxvp builtins

2021-09-17 Thread Quinn Pham via Phabricator via cfe-commits
quinnp created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
quinnp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch changes the signature of the load and store vector pair
builtins to match their documentation. The type of the `signed long long`
argument is changed to `signed long`. This patch also changes existing testcases
to match the signature change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109996

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-pair-mma-types.c

Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -322,16 +322,16 @@
 }
 
 void testBuiltinTypes1(const __vector_pair *vpp, const __vector_pair *vp2, float f) {
-  __vector_pair vp = __builtin_vsx_lxvp(f, vpp); // expected-error {{passing 'float' to parameter of incompatible type 'long long'}}
-  __builtin_vsx_stxvp(vp, 32799, vp2);   // expected-error {{passing 'int' to parameter of incompatible type 'long long'}}
+  __vector_pair vp = __builtin_vsx_lxvp(f, vpp); // expected-error {{passing 'float' to parameter of incompatible type 'long'}}
+  __builtin_vsx_stxvp(vp, 32799, vp2);   // expected-error {{passing 'int' to parameter of incompatible type 'long'}}
 }
 
 void testBuiltinTypes2(__vector_pair *vpp, const __vector_pair *vp2, unsigned char c) {
-  __vector_pair vp = __builtin_vsx_lxvp(6LL, vpp); // expected-error {{passing '__vector_pair *' to parameter of incompatible type 'const __vector_pair *'}}
-  __builtin_vsx_stxvp(vp, c, vp2); // expected-error {{passing 'unsigned char' to parameter of incompatible type 'long long'}}
+  __vector_pair vp = __builtin_vsx_lxvp(6L, vpp); // expected-error {{passing '__vector_pair *' to parameter of incompatible type 'const __vector_pair *'}}
+  __builtin_vsx_stxvp(vp, c, vp2);// expected-error {{passing 'unsigned char' to parameter of incompatible type 'long'}}
 }
 
-void testBuiltinTypes3(vector int v, __vector_pair *vp2, signed long long ll, unsigned short s) {
-  __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
-  __builtin_vsx_stxvp(vp, ll, s);   // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
+void testBuiltinTypes3(vector int v, __vector_pair *vp2, signed long l, unsigned short s) {
+  __vector_pair vp = __builtin_vsx_lxvp(l, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
+  __builtin_vsx_stxvp(vp, l, s);   // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
 }
Index: clang/test/CodeGen/builtins-ppc-pair-mma.c
===
--- clang/test/CodeGen/builtins-ppc-pair-mma.c
+++ clang/test/CodeGen/builtins-ppc-pair-mma.c
@@ -1049,8 +1049,8 @@
 // CHECK-NEXT:ret void
 //
 void test66(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(0LL, vpp);
-  __builtin_vsx_stxvp(vp, 0LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(0L, vpp);
+  __builtin_vsx_stxvp(vp, 0L, vp2);
 }
 
 // CHECK-LABEL: @test67(
@@ -1063,7 +1063,7 @@
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP2]], i8* [[TMP4]])
 // CHECK-NEXT:ret void
 //
-void test67(const __vector_pair *vpp, signed long long offset, const __vector_pair *vp2) {
+void test67(const __vector_pair *vpp, signed long offset, const __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(offset, vpp);
   __builtin_vsx_stxvp(vp, offset, vp2);
 }
@@ -1079,8 +1079,8 @@
 // CHECK-NEXT:ret void
 //
 void test68(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(18LL, vpp);
-  __builtin_vsx_stxvp(vp, 18LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(18L, vpp);
+  __builtin_vsx_stxvp(vp, 18L, vp2);
 }
 
 // CHECK-LABEL: @test69(
@@ -1094,8 +1094,8 @@
 // CHECK-NEXT:ret void
 //
 void test69(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(1LL, vpp);
-  __builtin_vsx_stxvp(vp, 1LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(1L, vpp);
+  __builtin_vsx_stxvp(vp, 1L, vp2);
 }
 
 // CHECK-LABEL: @test70(
@@ -1109,8 +1109,8 @@
 // CHECK-NEXT:ret void
 //
 void test70(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(42LL, vpp);
-  __builtin_vsx_stxvp(vp, 42LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(42L, vpp);
+  __builtin_vsx_stxvp(vp, 42L, vp2);
 }
 
 // CHECK-LABEL: 

[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D109800#3004288 , @Quuxplusone 
wrote:

> Getting rid of that extra bool parameter throughout //looks// awesome, 
> though. :)

It will come back later, this patch is just a quick thing we need in order to 
ship clang-13.
But perhaps we bring it back in enum class form? :)

> I do think it might be a good idea to include one or two tests that actually 
> run all the way through codegen, e.g. https://godbolt.org/z/54eTrj54M

I think in that case, if we pursue that direction, what we would want is to 
have these tests that only go until LLVM IR, and then another set of tests that 
go from IR to arch specific LL, or perhaps just to optimized IR.
To be frank, I don't see how anything interesting here would happen after clang 
CodeGen (except in UB cases), but I am not very familiar with that side of the 
project.

> The scary failure mode here (if you are like me and don't really understand 
> why this is impossible ;)) would be if the compiler somehow elided one of the 
> implicit conversions without eliding the other one (like how compiler bugs 
> have in the past led to eliding a constructor without eliding the matching 
> destructor).

Right, when we get to that point where we can elide that double conversion 
sequence, we got to add tests, but I suspect they don't need to go further than 
clang CodeGen.

> Also, is it worth testing anything in constexpr functions? My understanding 
> is that constexpr functions never do copy elision, although maybe(?) they're 
> permitted to?

We do have analogous situation to CodeGen there, we step over a 
MaterializeTemporary in the isElidable case, and if we improve in this area to 
support double conversions, that has to be fixed too.
But this patch should not be changing anything in the rvalue path, only the 
NRVO one, which again I could not find anything that uses it anywhere in LLVM 
tree.
I will add an assert and FIXME there though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


[PATCH] D109997: [OpenMP] Change debugging symbol to weak_odr linkage

2021-09-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: guansong, hiraditya, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

The new device runtime uses an internal variable to set debugging. This
variable was originally privately linked because every module will have
a copy of it. This caused problems with merging the device bitcode
library because it would get renamed and there was not a way to refer to
an external, private symbol. This changes the symbol to weak_odr so it
can be defined multiply, but will not be renamed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109997

Files:
  clang/test/OpenMP/target_debug_codegen.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -249,11 +249,9 @@
   IntegerType *I32Ty = Type::getInt32Ty(M.getContext());
   auto *GV = new GlobalVariable(
   M, I32Ty,
-  /* isConstant = */ true, GlobalValue::PrivateLinkage,
+  /* isConstant = */ true, GlobalValue::WeakODRLinkage,
   ConstantInt::get(I32Ty, DebugKind), "__omp_rtl_debug_kind");
 
-  llvm::appendToUsed(M, {GV});
-
   return GV;
 }
 
Index: clang/test/OpenMP/target_debug_codegen.cpp
===
--- clang/test/OpenMP/target_debug_codegen.cpp
+++ clang/test/OpenMP/target_debug_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex 
"(__omp_rtl_debug_kind|llvm\.used)"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "__omp_rtl_debug_kind"
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-target-new-runtime 
-fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path 
%t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK
@@ -10,14 +10,11 @@
 #define HEADER
 
 //.
-// CHECK: @__omp_rtl_debug_kind = private constant i32 1
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK: @__omp_rtl_debug_kind = weak_odr constant i32 1
 //.
-// CHECK-EQ: @__omp_rtl_debug_kind = private constant i32 111
-// CHECK-EQ: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-EQ: @__omp_rtl_debug_kind = weak_odr constant i32 111
 //.
-// CHECK-DEFAULT: @__omp_rtl_debug_kind = private constant i32 0
-// CHECK-DEFAULT: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-DEFAULT: @__omp_rtl_debug_kind = weak_odr constant i32 0
 //.
 void foo() {
 #pragma omp target


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -249,11 +249,9 @@
   IntegerType *I32Ty = Type::getInt32Ty(M.getContext());
   auto *GV = new GlobalVariable(
   M, I32Ty,
-  /* isConstant = */ true, GlobalValue::PrivateLinkage,
+  /* isConstant = */ true, GlobalValue::WeakODRLinkage,
   ConstantInt::get(I32Ty, DebugKind), "__omp_rtl_debug_kind");
 
-  llvm::appendToUsed(M, {GV});
-
   return GV;
 }
 
Index: clang/test/OpenMP/target_debug_codegen.cpp
===
--- clang/test/OpenMP/target_debug_codegen.cpp
+++ clang/test/OpenMP/target_debug_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --global-value-regex "(__omp_rtl_debug_kind|llvm\.used)"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --global-value-regex "__omp_rtl_debug_kind"
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-target-new-runtime -fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK
@@ -10,14 +10,11 @@
 #define HEADER
 
 //.
-// CH

[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Andrew 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 rGc533b88a6dc9: [DFSan] Add force_zero_label abilist option to 
DFSan. This can be used as a… (authored by browneee).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/test/dfsan/Inputs/flags_abilist.txt
  compiler-rt/test/dfsan/force_zero.c
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
  llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s -DSHADOW_XOR_MASK=87960930222080
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+define i32 @function_to_force_zero(i32 %0, i32* %1) {
+  ; CHECK-LABEL: define i32 @function_to_force_zero.dfsan
+  ; CHECK: %[[#SHADOW_XOR:]] = xor i64 {{.*}}, [[SHADOW_XOR_MASK]]
+  ; CHECK: %[[#SHADOW_PTR:]] = inttoptr i64 %[[#SHADOW_XOR]] to i8*
+  ; CHECK: %[[#SHADOW_BITCAST:]] = bitcast i8* %[[#SHADOW_PTR]] to i32*
+  ; CHECK: store i32 0, i32* %[[#SHADOW_BITCAST]]
+  ; CHECK: store i32 %{{.*}}
+  store i32 %0, i32* %1, align 4
+  ; CHECK: store i8 0, {{.*}}@__dfsan_retval_tls
+  ; CHECK: ret i32
+  ret i32 %0
+}
Index: llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===
--- llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -8,3 +8,5 @@
 fun:custom*=custom
 
 fun:uninstrumented*=uninstrumented
+
+fun:function_to_force_zero=force_zero_labels
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -144,8 +144,17 @@
 // to the "native" (i.e. unsanitized) ABI.  Unless the ABI list contains
 // additional annotations for those functions, a call to one of those functions
 // will produce a warning message, as the labelling behaviour of the function is
-// unknown.  The other supported annotations are "functional" and "discard",
-// which are described below under DataFlowSanitizer::WrapperKind.
+// unknown. The other supported annotations for uninstrumented functions are
+// "functional" and "discard", which are described below under
+// DataFlowSanitizer::WrapperKind.
+// Functions will often be labelled with both "uninstrumented" and one of
+// "functional" or "discard". This will leave the function unchanged by this
+// pass, and create a wrapper function that will call the original.
+//
+// Instrumented functions can also be annotated as "force_zero_labels", which
+// will make all shadow and return values set zero labels.
+// Functions should never be labelled with both "force_zero_labels" and
+// "uninstrumented" or any of the unistrumented wrapper kinds.
 static cl::list ClABIListFiles(
 "dfsan-abilist",
 cl::desc("File listing native ABI functions and how the pass treats them"),
@@ -469,6 +478,7 @@
   getShadowOriginAddress(Value *Addr, Align InstAlignment, Instruction *Pos);
   bool isInstrumented(const Function *F);
   bool isInstrumented(const GlobalAlias *GA);
+  bool isForceZeroLabels(const Function *F);
   FunctionType *getArgsFunctionType(FunctionType *T);
   FunctionType *getTrampolineFunctionType(FunctionType *T);
   TransformedFunction getCustomFunctionType(FunctionType *T);
@@ -541,6 +551,7 @@
   DominatorTree DT;
   DataFlowSanitizer::InstrumentedABI IA;
   bool IsNativeABI;
+  bool IsForceZeroLabels;
   AllocaInst *LabelReturnAlloca = nullptr;
   AllocaInst *OriginReturnAlloca = nullptr;
   DenseMap ValShadowMap;
@@ -571,8 +582,10 @@
   DenseMap CachedCollapsedShadows;
   DenseMap> ShadowElements;
 
-  DFSanFunction(DataFlowSanitizer &DFS, Function *F, bool IsNativeABI)
-  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI) {
+  DFSanFunction(DataFlowSanitizer &DFS, Function *F, bool IsNativeABI,
+bool IsForceZeroLabels)
+  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI),
+IsForceZeroLabels(IsForceZeroLabels) {
 DT.recalculate(*F);
   }
 
@@ -1107,6 +1120,10 @@
   return !ABIList.isIn(*GA, "uninstrumented");
 }
 
+bool DataFlowSanitizer::isForceZeroLabels(const Function *F) {
+  return ABIList.isIn(*F, "force_zero_labels");
+}
+
 DataFlowSanitizer::InstrumentedABI D

[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

This is really a great change, thanks @beanz!




Comment at: llvm/tools/llvm-objcopy/llvm-objcopy.cpp:404
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);

Shouldn't we say:
```
int objcopy_main(int argc, char **argv) {
```
here and the other places + all supporting code, if we want `llvm objcopy` 
(without the dash) like @phosek suggests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 373323.
mizvekov edited the summary of this revision.
mizvekov added a comment.

add a couple more FIXMEs and a couple of asserts in the constexpr path for 
rvalue copy elision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/CodeGenCXX/copy-elision.cpp

Index: clang/test/CodeGenCXX/copy-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/copy-elision.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
+
+template  T test() {
+  return T();
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1AET_v
+// CHECK:   call void @_ZN1AC1Ev
+// CHECK-NEXT:  call i32 @_ZN1AcviEv
+// CHECK-NEXT:  call void @_ZN1AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1BET_v
+// CHECK:   call void @_ZN1BC1Ev
+// CHECK:   call void @_ZN1BC1ERK4BSub
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/S

[PATCH] D109997: [OpenMP] Change debugging symbol to weak_odr linkage

2021-09-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

You checked that this works with the usage in the RT, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109997

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


[clang] 2908fc0 - [OpenMP] Use irbuilder as default for masked and master construct

2021-09-17 Thread via cfe-commits

Author: cchen
Date: 2021-09-17T15:54:11-05:00
New Revision: 2908fc0d3f16f873b5019f1c62a24482c2b75e36

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

LOG: [OpenMP] Use irbuilder as default for masked and master construct

Use irbuilder as default and remove redundant Clang codegen for masked 
construct and master construct.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/masked_codegen.cpp
clang/test/OpenMP/master_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 55c4822387d0e..fa198335f2c84 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4030,82 +4030,56 @@ static void emitMaster(CodeGenFunction &CGF, const 
OMPExecutableDirective &S) {
 }
 
 void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
-  if (CGM.getLangOpts().OpenMPIRBuilder) {
-llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt();
+  llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
+  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
-auto FiniCB = [this](InsertPointTy IP) {
-  OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
-};
+  const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt();
 
-auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
-  InsertPointTy CodeGenIP,
-  llvm::BasicBlock &FiniBB) {
-  OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB);
-  OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt,
- CodeGenIP, FiniBB);
-};
+  auto FiniCB = [this](InsertPointTy IP) {
+OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
+  };
 
-LexicalScope Scope(*this, S.getSourceRange());
-EmitStopPoint(&S);
-Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB));
+  auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
+InsertPointTy CodeGenIP,
+llvm::BasicBlock &FiniBB) {
+OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB);
+OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt,
+   CodeGenIP, FiniBB);
+  };
 
-return;
-  }
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(&S);
-  emitMaster(*this, S);
-}
-
-static void emitMasked(CodeGenFunction &CGF, const OMPExecutableDirective &S) {
-  auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
-Action.Enter(CGF);
-CGF.EmitStmt(S.getRawStmt());
-  };
-  Expr *Filter = nullptr;
-  if (const auto *FilterClause = S.getSingleClause())
-Filter = FilterClause->getThreadID();
-  CGF.CGM.getOpenMPRuntime().emitMaskedRegion(CGF, CodeGen, S.getBeginLoc(),
-  Filter);
+  Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB));
 }
 
 void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective &S) {
-  if (CGM.getLangOpts().OpenMPIRBuilder) {
-llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt();
-const Expr *Filter = nullptr;
-if (const auto *FilterClause = S.getSingleClause())
-  Filter = FilterClause->getThreadID();
-llvm::Value *FilterVal = Filter
- ? EmitScalarExpr(Filter, CGM.Int32Ty)
- : llvm::ConstantInt::get(CGM.Int32Ty, 
/*V=*/0);
+  llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
+  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
-auto FiniCB = [this](InsertPointTy IP) {
-  OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
-};
+  const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt();
+  const Expr *Filter = nullptr;
+  if (const auto *FilterClause = S.getSingleClause())
+Filter = FilterClause->getThreadID();
+  llvm::Value *FilterVal = Filter
+   ? EmitScalarExpr(Filter, CGM.Int32Ty)
+   : llvm::ConstantInt::get(CGM.Int32Ty, /*V=*/0);
 
-auto BodyGenCB = [MaskedRegionBodyStmt, this](InsertPointTy AllocaIP,
-  

[PATCH] D100874: [OpenMP] Use irbuilder as default for masked and master construct

2021-09-17 Thread Chi Chun Chen 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 rG2908fc0d3f16: [OpenMP] Use irbuilder as default for masked 
and master construct (authored by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100874

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/masked_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp

Index: clang/test/OpenMP/master_codegen.cpp
===
--- clang/test/OpenMP/master_codegen.cpp
+++ clang/test/OpenMP/master_codegen.cpp
@@ -1,10 +1,7 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,NORMAL
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,NORMAL
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
-// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
@@ -15,53 +12,52 @@
 #ifndef HEADER
 #define HEADER
 
-// ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
 
-// ALL:   define {{.*}}void [[FOO:@.+]]()
+// CHECK:   define {{.*}}void [[FOO:@.+]]()
 
 void foo() { extern void mayThrow(); mayThrow(); }
 
-// ALL-LABEL: @main
+// CHECK-LABEL: @main
 // TERM_DEBUG-LABEL: @main
 int main() {
-  // ALL:  			[[A_ADDR:%.+]] = alloca i8
+  // CHECK:  			[[A_ADDR:%.+]] = alloca i8
   char a;
 
-// ALL:   			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
-// ALL:   			[[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			[[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
-// ALL-NEXT:  			br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
-// ALL:   			[[THEN]]
-// ALL-NEXT:  			store i8 2, i8* [[A_ADDR]]
-// ALL-NEXT:  			call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			br label {{%?}}[[EXIT]]
-// ALL:   			[[EXIT]]
+// CHECK:   			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
+// CHECK:   			[[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
+// CHECK-NEXT:  			[[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK-NEXT:  			br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
+// CHECK:   			[[THEN]]
+// CHECK-NEXT:  			store i8 2, i8* [[A_ADDR]]
+// CHECK-NEXT:  			call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
+// CHECK-NEXT:  			br label {{%?}}[[EXIT]]
+// CHECK:   			[[EXIT]]
 #pragma omp master
   a = 2;
-// IRBUILDER: 			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
-// ALL:   			[[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			[[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
-// ALL-NEXT:  			br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
-// ALL:   			[[THEN]]
-// IRBUILDER-NEXT:  call {{.*}}void [[FOO]]()
-// NORMAL-NEXT:  		invoke {{.*}}void [[FOO]]()
-// ALL:   			call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			br label {{%?}}[[EXIT]]
-// ALL:   			[[EXIT]]
+// CHECK: 			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_th

[clang] c7d7b98 - OpenMP 5.0 metadirective

2021-09-17 Thread via cfe-commits

Author: cchen
Date: 2021-09-17T16:03:13-05:00
New Revision: c7d7b98e5263472f05b2f3cb767b5d16e1349e9a

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

LOG: OpenMP 5.0 metadirective

This patch supports OpenMP 5.0 metadirective features.
It is implemented keeping the OpenMP 5.1 features like dynamic user condition 
in mind.

A new function, getBestWhenMatchForContext, is defined in 
llvm/Frontend/OpenMP/OMPContext.h

Currently this function return the index of the when clause with the highest 
score from the ones applicable in the Context.
But this function is declared with an array which can be used in OpenMP 5.1 
implementation to select all the valid when clauses which can be resolved in 
runtime. Currently this array is set to null by default and its implementation 
is left for future.

Reviewed By: jdoerfert

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

Added: 
clang/test/OpenMP/metadirective_ast_print.c
clang/test/OpenMP/metadirective_device_kind_codegen.c
clang/test/OpenMP/metadirective_device_kind_codegen.cpp
clang/test/OpenMP/metadirective_empty.cpp
clang/test/OpenMP/metadirective_implementation_codegen.c
clang/test/OpenMP/metadirective_implementation_codegen.cpp
clang/test/OpenMP/metadirective_messages.cpp

Modified: 
clang/include/clang-c/Index.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/StmtOpenMP.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtOpenMP.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 8afd4c9ff1d05..b49acf6b58543 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2592,7 +2592,11 @@ enum CXCursorKind {
*/
   CXCursor_OMPUnrollDirective = 293,
 
-  CXCursor_LastStmt = CXCursor_OMPUnrollDirective,
+  /** OpenMP metadirective directive.
+   */
+  CXCursor_OMPMetaDirective = 294,
+
+  CXCursor_LastStmt = CXCursor_OMPMetaDirective,
 
   /**
* Cursor that represents the translation unit itself.

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 9bfa5b9c23260..9b261e8540dac 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2842,6 +2842,9 @@ 
RecursiveASTVisitor::TraverseOMPLoopDirective(OMPLoopDirective *S) {
   return TraverseOMPExecutableDirective(S);
 }
 
+DEF_TRAVERSE_STMT(OMPMetaDirective,
+  { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
 DEF_TRAVERSE_STMT(OMPParallelDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 

diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index cd5fa2b94c317..f028c3b323986 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -5379,6 +5379,44 @@ class OMPMaskedDirective final : public 
OMPExecutableDirective {
   }
 };
 
+/// This represents '#pragma omp metadirective' directive.
+///
+/// \code
+/// #pragma omp metadirective when(user={condition(N>10)}: parallel for)
+/// \endcode
+/// In this example directive '#pragma omp metadirective' has clauses 'when'
+/// with a dynamic user condition to check if a variable 'N > 10'
+///
+class OMPMetaDirective final : public OMPExecutableDirective {
+  friend class ASTStmtReader;
+  friend class OMPExecutableDirective;
+  Stmt *IfStmt;
+
+  OMPMetaDirective(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPExecutableDirective(OMPMetaDirectiveClass,
+   llvm::omp::OMPD_metadirective, StartLoc,
+   EndLoc) {}
+  explicit OMPMetaDirective()
+  : OMPExecutableDirective(OMPMetaDirectiveClass,
+   llvm::omp::OMPD_metadirective, SourceL

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc7d7b98e5263: OpenMP 5.0 metadirective (authored by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1703,6 +1704,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1391,6 +1391,7 @@
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
+CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; s

  1   2   >