[PATCH] D107666: [OpenMP] Fix accidental reuse of VLA size

2021-08-06 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfb77364d0be: [OpenMP] Fix accidental reuse of VLA size 
(authored by rogfer01).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107666

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/vla_iterator_cache_bug.c


Index: clang/test/OpenMP/vla_iterator_cache_bug.c
===
--- /dev/null
+++ clang/test/OpenMP/vla_iterator_cache_bug.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+extern int bounds1(int);
+extern int bounds2(int);
+
+extern void fun2(int n, int *a, int *b);
+extern void fun3(int n, int *a, int *b);
+
+void fun1(int n, int *a, int *b)
+{
+#pragma omp task depend(iterator(j = 0 : bounds1(n)), in : a[b[j]])
+  {
+fun2(n, a, b);
+  }
+// CHECK: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA:%.*]], align 16
+
+#pragma omp task depend(iterator(j = 0 : bounds2(n)), in : a[b[j]])
+  {
+fun3(n, a, b);
+  }
+// CHECK-NOT: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA]], align 16
+}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4401,14 +4401,14 @@
 if (NumOfElements) {
   NumOfElements = CGF.Builder.CreateNUWAdd(
   llvm::ConstantInt::get(CGF.SizeTy, NumAffinities), NumOfElements);
-  OpaqueValueExpr OVE(
+  auto *OVE = new (C) OpaqueValueExpr(
   Loc,
   C.getIntTypeForBitwidth(C.getTypeSize(C.getSizeType()), 
/*Signed=*/0),
   VK_PRValue);
-  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, ,
+  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
 
RValue::get(NumOfElements));
   KmpTaskAffinityInfoArrayTy =
-  C.getVariableArrayType(KmpTaskAffinityInfoTy, , 
ArrayType::Normal,
+  C.getVariableArrayType(KmpTaskAffinityInfoTy, OVE, ArrayType::Normal,
  /*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
   // Properly emit variable-sized array.
   auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy,
@@ -4899,13 +4899,13 @@
   NumOfElements =
   CGF.Builder.CreateNUWAdd(NumOfRegularWithIterators, NumOfElements);
 }
-OpaqueValueExpr OVE(Loc,
-C.getIntTypeForBitwidth(/*DestWidth=*/64, 
/*Signed=*/0),
-VK_PRValue);
-CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, ,
+auto *OVE = new (C) OpaqueValueExpr(
+Loc, C.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0),
+VK_PRValue);
+CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
   RValue::get(NumOfElements));
 KmpDependInfoArrayTy =
-C.getVariableArrayType(KmpDependInfoTy, , ArrayType::Normal,
+C.getVariableArrayType(KmpDependInfoTy, OVE, ArrayType::Normal,
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
 // CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy);
 // Properly emit variable-sized array.


Index: clang/test/OpenMP/vla_iterator_cache_bug.c
===
--- /dev/null
+++ clang/test/OpenMP/vla_iterator_cache_bug.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+extern int bounds1(int);
+extern int bounds2(int);
+
+extern void fun2(int n, int *a, int *b);
+extern void fun3(int n, int *a, int *b);
+
+void fun1(int n, int *a, int *b)
+{
+#pragma omp task depend(iterator(j = 0 : bounds1(n)), in : a[b[j]])
+  {
+fun2(n, a, b);
+  }
+// CHECK: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA:%.*]], align 16
+
+#pragma omp task depend(iterator(j = 0 : bounds2(n)), in : a[b[j]])
+  {
+fun3(n, a, b);
+  }
+// CHECK-NOT: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA]], align 16
+}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4401,14 +4401,14 @@
 if (NumOfElements) {
   NumOfElements = CGF.Builder.CreateNUWAdd(
   llvm::ConstantInt::get(CGF.SizeTy, NumAffinities), NumOfElements);
-  OpaqueValueExpr OVE(
+  auto *OVE = new (C) OpaqueValueExpr(
   Loc,
   C.getIntTypeForBitwidth(C.getTypeSize(C.getSizeType()), /*Signed=*/0),
   VK_PRValue);
-  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, ,
+  CodeGenFunction::OpaqueValueMapping 

[clang] bfb7736 - [OpenMP] Fix accidental reuse of VLA size

2021-08-06 Thread Roger Ferrer Ibanez via cfe-commits

Author: Roger Ferrer Ibanez
Date: 2021-08-07T05:55:27Z
New Revision: bfb77364d0be8a5b159cdcf4eaf8e7a720802e89

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

LOG: [OpenMP] Fix accidental reuse of VLA size

We were using an OpaqueValueExpr allocated on the stack to store
the size of a VLA. Because the VLASizeMap in CodegenFunction
uses the address of the expression to avoid recomputing VLAs,
we were accidentally reusing an earlier llvm::Value. This led to
invalid LLVM IR.

This is a temporary solution until VLASizeMap can be pushed and popped
based on the context.

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

Added: 
clang/test/OpenMP/vla_iterator_cache_bug.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index ca98c7a57446..90fcf2232be2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4401,14 +4401,14 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction , 
SourceLocation Loc,
 if (NumOfElements) {
   NumOfElements = CGF.Builder.CreateNUWAdd(
   llvm::ConstantInt::get(CGF.SizeTy, NumAffinities), NumOfElements);
-  OpaqueValueExpr OVE(
+  auto *OVE = new (C) OpaqueValueExpr(
   Loc,
   C.getIntTypeForBitwidth(C.getTypeSize(C.getSizeType()), 
/*Signed=*/0),
   VK_PRValue);
-  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, ,
+  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
 
RValue::get(NumOfElements));
   KmpTaskAffinityInfoArrayTy =
-  C.getVariableArrayType(KmpTaskAffinityInfoTy, , 
ArrayType::Normal,
+  C.getVariableArrayType(KmpTaskAffinityInfoTy, OVE, ArrayType::Normal,
  /*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
   // Properly emit variable-sized array.
   auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy,
@@ -4899,13 +4899,13 @@ std::pair 
CGOpenMPRuntime::emitDependClause(
   NumOfElements =
   CGF.Builder.CreateNUWAdd(NumOfRegularWithIterators, NumOfElements);
 }
-OpaqueValueExpr OVE(Loc,
-C.getIntTypeForBitwidth(/*DestWidth=*/64, 
/*Signed=*/0),
-VK_PRValue);
-CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, ,
+auto *OVE = new (C) OpaqueValueExpr(
+Loc, C.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0),
+VK_PRValue);
+CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
   RValue::get(NumOfElements));
 KmpDependInfoArrayTy =
-C.getVariableArrayType(KmpDependInfoTy, , ArrayType::Normal,
+C.getVariableArrayType(KmpDependInfoTy, OVE, ArrayType::Normal,
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
 // CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy);
 // Properly emit variable-sized array.

diff  --git a/clang/test/OpenMP/vla_iterator_cache_bug.c 
b/clang/test/OpenMP/vla_iterator_cache_bug.c
new file mode 100644
index ..ad5a664346e2
--- /dev/null
+++ b/clang/test/OpenMP/vla_iterator_cache_bug.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+extern int bounds1(int);
+extern int bounds2(int);
+
+extern void fun2(int n, int *a, int *b);
+extern void fun3(int n, int *a, int *b);
+
+void fun1(int n, int *a, int *b)
+{
+#pragma omp task depend(iterator(j = 0 : bounds1(n)), in : a[b[j]])
+  {
+fun2(n, a, b);
+  }
+// CHECK: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA:%.*]], align 16
+
+#pragma omp task depend(iterator(j = 0 : bounds2(n)), in : a[b[j]])
+  {
+fun3(n, a, b);
+  }
+// CHECK-NOT: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA]], align 16
+}



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


[PATCH] D107666: [OpenMP] Fix accidental reuse of VLA size

2021-08-06 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Thanks for the prompt review @ABataev! I'll push this shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107666

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


[PATCH] D107684: [NFC][AVR][clang] Add test for D107672

2021-08-06 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson created this revision.
mhjacobson added reviewers: MaskRay, benshi001.
Herald added subscribers: Jim, dylanmckay.
mhjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add test that ensures that an avr-libc in `$SYSROOT/avr` is found, modeled 
after the similar test checking for `$SYSROOT/usr/lib/avr`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107684

Files:
  clang/test/Driver/Inputs/basic_avr_tree_opt_local/opt/local/avr/include/.keep
  clang/test/Driver/Inputs/basic_avr_tree_opt_local/opt/local/avr/lib/libavr.a
  clang/test/Driver/Inputs/basic_avr_tree_opt_local/opt/local/bin/avr-ld
  
clang/test/Driver/Inputs/basic_avr_tree_opt_local/opt/local/lib/gcc/avr/5.4.0/libgcc.a
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -6,8 +6,11 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target avr --sysroot 
%S/Inputs/basic_avr_tree 2>&1 | FileCheck -check-prefix CC1A %s
 // CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" 
{{".*avr/include"}}
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck -check-prefix CC1B %s
-// CC1B-NOT: "-internal-isystem" {{".*avr/include"}}
+// RUN: %clang %s -### -no-canonical-prefixes -target avr --sysroot 
%S/Inputs/basic_avr_tree_opt_local/opt/local 2>&1 | FileCheck -check-prefix 
CC1B %s
+// CC1B: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" 
{{".*/opt/local/avr/include"}}
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck -check-prefix CC1C %s
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck -check-prefix CC1C %s
 // CC1C-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck -check-prefix CC1D %s
+// CC1D-NOT: "-internal-isystem" {{".*avr/include"}}


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -6,8 +6,11 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | FileCheck -check-prefix CC1A %s
 // CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" {{".*avr/include"}}
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck -check-prefix CC1B %s
-// CC1B-NOT: "-internal-isystem" {{".*avr/include"}}
+// RUN: %clang %s -### -no-canonical-prefixes -target avr --sysroot %S/Inputs/basic_avr_tree_opt_local/opt/local 2>&1 | FileCheck -check-prefix CC1B %s
+// CC1B: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" {{".*/opt/local/avr/include"}}
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck -check-prefix CC1C %s
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck -check-prefix CC1C %s
 // CC1C-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck -check-prefix CC1D %s
+// CC1D-NOT: "-internal-isystem" {{".*avr/include"}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107682: [AVR][clang] Search avr-libc installtion path according to avr-gcc's

2021-08-06 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

There are already test cases

  $llvm/clang/test/Driver/avr-ld.c
  $llvm/clang/test/Driveravr-toolchain.c

and fake avr-gcc inside `$llvm/clang/test/Driver/Inputs/basic_avr_tree` to 
support the above two tests.

So there is no need to add new ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107682

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


[PATCH] D107682: [AVR][clang] Search avr-libc installtion path according to avr-gcc's

2021-08-06 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: MaskRay, dylanmckay.
Herald added a subscriber: Jim.
benshi001 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107682

Files:
  clang/lib/Driver/ToolChains/AVR.cpp


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -297,12 +297,6 @@
   return Optional();
 }
 
-const StringRef PossibleAVRLibcLocations[] = {
-"/avr",
-"/usr/avr",
-"/usr/lib/avr",
-};
-
 } // end anonymous namespace
 
 /// AVR Toolchain
@@ -453,12 +447,9 @@
 }
 
 llvm::Optional AVRToolChain::findAVRLibcInstallation() const {
-  for (StringRef PossiblePath : PossibleAVRLibcLocations) {
-std::string Path = getDriver().SysRoot + PossiblePath.str();
-// Return the first avr-libc installation that exists.
-if (llvm::sys::fs::is_directory(Path))
-  return Optional(Path);
-  }
-
+  std::string GCCRoot(GCCInstallation.getInstallPath());
+  std::string Path(GCCRoot + "/../../../avr");
+  if (llvm::sys::fs::is_directory(Path))
+return Optional(Path);
   return llvm::None;
 }


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -297,12 +297,6 @@
   return Optional();
 }
 
-const StringRef PossibleAVRLibcLocations[] = {
-"/avr",
-"/usr/avr",
-"/usr/lib/avr",
-};
-
 } // end anonymous namespace
 
 /// AVR Toolchain
@@ -453,12 +447,9 @@
 }
 
 llvm::Optional AVRToolChain::findAVRLibcInstallation() const {
-  for (StringRef PossiblePath : PossibleAVRLibcLocations) {
-std::string Path = getDriver().SysRoot + PossiblePath.str();
-// Return the first avr-libc installation that exists.
-if (llvm::sys::fs::is_directory(Path))
-  return Optional(Path);
-  }
-
+  std::string GCCRoot(GCCInstallation.getInstallPath());
+  std::string Path(GCCRoot + "/../../../avr");
+  if (llvm::sys::fs::is_directory(Path))
+return Optional(Path);
   return llvm::None;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson added a comment.

In D107672#2932423 , @MaskRay wrote:

> @benshi001 This was prematurely committed. It has no test and has apparent 
> unaddressed issue. (I revamped many parts in the Linux/Gnu  search paths so 
> am quite confident about my observation.)

I'm working on a test now, and I'll submit a follow-up patch adding it, if 
that's OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-06 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Rather than reverting this commit again, I pushed 62fe3dcf98d1 
 to use 
the same expansion as before (using unordered comparison) for `ppc_fp128`. I am 
not sure if there are other types that suffer from the same problem (perhaps 
the Intel 80-bit long double).




Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:6964
+return DAG.getSetCC(DL, ResultVT, Op, DAG.getConstantFP(0.0, DL, 
OperandVT),
+ISD::SETUO);
+

sepavloff wrote:
> efriedma wrote:
> > Maybe we want to consider falling back to the integer path if SETCC isn't 
> > legal for the given operand type?  We could do that as a followup, though.
> It makes sense, it could be beneficial for targets that have limited set of 
> floating point comparisons. However straightforward check like:
> 
> if (Flags.hasNoFPExcept() && isOperationLegalOrCustom(ISD::SETCC, 
> OperandVT))
> 
> results in worse code, mainly for vector types. It should be more complex 
> check.
>  
Out of curiosity, why was this added when you recognized that it results in 
worse code? This is certainly part of the reason for the regression for 
`ppc_fp128`.

It would appear that before this patch, we would emit a comparison for all 
types that are not IEEE FP types (such as `ppc_fp128`). Those semantics do not 
seem to have carried over.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson added a comment.

In D107672#2932413 , @mhjacobson 
wrote:

> At first glance, I think you're right: avr-gcc does expect avr-libc to be 
> relative to itself.  That seems slightly weird to me (since avr-libc is 
> technically separate from GCC), but OK.

OK, after looking at the GCC source, I see there's nothing specific to 
avr-libc.  It's just that GCC basically tries to look in 
`$PREFIX/[machine/]lib`, where `$PREFIX` is actually the path to GCC, 
dot-dotted up to where it thinks the prefix lives, to allow for the possibility 
that the whole prefix was relocated.

So, @MaskRay, correct me if I'm wrong: it seems like you're suggesting that we 
use something derived from the `GCCInstallationDetector` to find libc?  Is 
there another platform's driver I can look at as an example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

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


[PATCH] D107559: [clang] Fix libclang linking on Solaris

2021-08-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay 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/D107559/new/

https://reviews.llvm.org/D107559

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


[PATCH] D106701: [clang] Implement -falign-loops=N (N is a power of 2) for non-LTO

2021-08-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4749
+  << A->getAsString(Args) << A->getValue();
+else if (Value & Value - 1)
+  TC.getDriver().Diag(diag::err_drv_alignment_not_power_of_two)

craig.topper wrote:
> gcc 5.4 is throwing a -Wparentheses warning here. I'm in the middle of 
> something else in my tree or I would just fix it. Maybe isPowerOf2_32 would 
> be more readable anyway?
maybe just add parens (Value - 1) ... this is probably a quite common pattern. 
And the line below has `err_drv_alignment_not_power_of_two` which is 
self-explanatory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106701: [clang] Implement -falign-loops=N (N is a power of 2) for non-LTO

2021-08-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4749
+  << A->getAsString(Args) << A->getValue();
+else if (Value & Value - 1)
+  TC.getDriver().Diag(diag::err_drv_alignment_not_power_of_two)

gcc 5.4 is throwing a -Wparentheses warning here. I'm in the middle of 
something else in my tree or I would just fix it. Maybe isPowerOf2_32 would be 
more readable anyway?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@benshi001 This was prematurely committed. It has no test and has apparent 
unaddressed issue. (I revamped many parts in the Linux/Gnu  search paths so 
quite confident about my observation.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

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


[PATCH] D106737: [clang] [hexagon] Add resource include dir

2021-08-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Thanks for the test.  linux-cross.cpp has some `-SAME: {{^}} ` and 
`"[[RESOURCE]]/include"` patterns which you may use


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106737

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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson added a comment.

In D107672#2932406 , @MaskRay wrote:

> I know nearly nothing about AVR, but from `avr-gcc a.c '-###'` I doubt this 
> is the GCC behavior. GCC's library path is relative to the GCC installation. 
> `/usr/lib/gcc/avr/5.4.0/../../../avr/lib`
>
> There is a difference between sysroot inferred path and GCC installation 
> inferred path. 
> https://maskray.me/blog/2021-03-28-compiler-driver-and-cross-compilation

Wow, nice write-up!  I'll have to spend some more time to digest it fully.

At first glance, I think you're right: avr-gcc does expect avr-libc to be 
relative to itself.  That seems slightly weird to me (since avr-libc is 
technically separate from GCC), but OK.

clang's driver certainly searches for libgcc and avr-libc separately.  I guess 
you're saying it shouldn't?

Obviously the separate searching isn't something introduced here, so (unless 
you object) I'll file a bug report about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Ben Shi 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 rG71e71067f3fa: [AVR][clang] Add $SYSROOT/avr to 
possible avr-libc locations (authored by mhjacobson, committed by benshi001).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

Files:
  clang/lib/Driver/ToolChains/AVR.cpp


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -298,6 +298,7 @@
 }
 
 const StringRef PossibleAVRLibcLocations[] = {
+"/avr",
 "/usr/avr",
 "/usr/lib/avr",
 };


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -298,6 +298,7 @@
 }
 
 const StringRef PossibleAVRLibcLocations[] = {
+"/avr",
 "/usr/avr",
 "/usr/lib/avr",
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 71e7106 - [AVR][clang] Add '$SYSROOT/avr' to possible avr-libc locations

2021-08-06 Thread Ben Shi via cfe-commits

Author: Matt Jacobson
Date: 2021-08-07T10:24:14+08:00
New Revision: 71e71067f3fa621d961e2607f1c8cea7cdce3f9d

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

LOG: [AVR][clang] Add '$SYSROOT/avr' to possible avr-libc locations

Reviewed by: benshi001

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 18c6f41e22b1a..cebf9d13a4ce0 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -298,6 +298,7 @@ llvm::Optional GetMCUSectionAddressData(StringRef 
MCUName) {
 }
 
 const StringRef PossibleAVRLibcLocations[] = {
+"/avr",
 "/usr/avr",
 "/usr/lib/avr",
 };



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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I know nearly nothing about AVR, but from `avr-gcc a.c '-###'` I doubt this is 
the GCC behavior. GCC's library path is relative to the GCC installation. 
`/usr/lib/gcc/avr/5.4.0/../../../avr/lib`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

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


[PATCH] D107539: [OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images

2021-08-06 Thread Dave Airlie via Phabricator via cfe-commits
airlied updated this revision to Diff 364919.
airlied added a comment.

fixed issues with check-clang, might need some follow up changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107539

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -11,11 +11,11 @@
 
 #include "opencl-c-base.h"
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_images)
 #ifndef cl_khr_depth_images
 #define cl_khr_depth_images
 #endif //cl_khr_depth_images
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_images)
 
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
 #ifdef cl_khr_3d_image_writes
@@ -15255,7 +15255,7 @@
 #endif //cl_khr_fp16
 
 // Image read functions for read_write images
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 float4 __purefn __ovld read_imagef(read_write image1d_t image, int coord);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, int coord);
 uint4 __purefn __ovld read_imageui(read_write image1d_t image, int coord);
@@ -15298,7 +15298,6 @@
 float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, int4 coord, int sample);
 #endif //cl_khr_gl_msaa_sharing
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #ifdef cl_khr_mipmap_image
 float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod);
@@ -15349,7 +15348,6 @@
 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float4 gradientX, float4 gradientY);
 
 #endif //cl_khr_mipmap_image
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
@@ -15360,7 +15358,7 @@
 half4 __purefn __ovld read_imageh(read_write image2d_array_t image, int4 coord);
 half4 __purefn __ovld read_imageh(read_write image1d_buffer_t image, int coord);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_read_write_images
 
 /**
  * Write color value to location specified by coordinate
@@ -15504,7 +15502,7 @@
 #endif //cl_khr_fp16
 
 // Image write functions for read_write images
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 void __ovld write_imagef(read_write image2d_t image, int2 coord, float4 color);
 void __ovld write_imagei(read_write image2d_t image, int2 coord, int4 color);
 void __ovld write_imageui(read_write image2d_t image, int2 coord, uint4 color);
@@ -15536,7 +15534,6 @@
 void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, float color);
 #endif //cl_khr_depth_images
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color);
@@ -15564,7 +15561,6 @@
 #endif //cl_khr_3d_image_writes
 
 #endif //cl_khr_mipmap_image_writes
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15577,7 +15573,7 @@
 void __ovld write_imageh(read_write image2d_array_t image, int4 coord, half4 color);
 void __ovld write_imageh(read_write image1d_buffer_t image, int coord, half4 color);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_read_write_images)
 
 // Note: In OpenCL v1.0/1.1/1.2, image argument of image query builtin functions does not have
 // access qualifier, which by default assume read_only access qualifier. Image query builtin
@@ -15625,7 +15621,7 @@
 int __ovld __cnfn get_image_width(write_only image2d_array_msaa_depth_t image);
 #endif //cl_khr_gl_msaa_sharing
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 int __ovld __cnfn get_image_width(read_write image1d_t image);
 int __ovld __cnfn get_image_width(read_write image1d_buffer_t image);
 int __ovld __cnfn get_image_width(read_write image2d_t image);
@@ -15642,7 +15638,7 @@
 int __ovld __cnfn get_image_width(read_write image2d_array_msaa_t image);
 int __ovld __cnfn get_image_width(read_write image2d_array_msaa_depth_t image);
 #endif //cl_khr_gl_msaa_sharing

[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-08-06 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: llvm/lib/Target/X86/X86InstrAVX512.td:4478
+  let Predicates = [HasFP16] in {
+def VMOVSHZrr_REV: AVX512<0x11, MRMDestReg, (outs VR128X:$dst),
+(ins VR128X:$src1, VR128X:$src2),

pengfei wrote:
> craig.topper wrote:
> > pengfei wrote:
> > > LuoYuanke wrote:
> > > > Sorry, I forgot what REV stand for. Do you know it?
> > > > Is this just encoding difference for register operand compared with 
> > > > VMOVSHZrr? What is it used for?
> > > I think REV is short for revert. Which allows a different encoding when 
> > > operands order are reverted.
> > > Yes. It's used for a different encoding.
> > It is short for "reverse". Meaing the operands are in the reversed order. 
> > There are two valid encodings moving from one register to another. This 
> > happens because there are separate opcodes for moving register to 
> > memory(Store) and moving memory to register(load). The memory operand for 
> > both of those opcodes can be a register as well. The assembler and isel 
> > always uses the register to register version of the load opcode. The 
> > reversed version is only used by the disassembler
> > 
> > There is an exception to that. For VEX encoded AVX/AVX2 instructions, 
> > X86MCInstLowering will use an _REV move if it allows a 2 byte VEX prefix 
> > instead of a 3 byte VEX prefix. This doesn't apply to any AVX512 
> > instructions though. 
> Thanks Craig for the information.
> It is short for "reverse". Meaing the operands are in the reversed order. 
> There are two valid encodings moving from one register to another. This 
> happens because there are separate opcodes for moving register to 
> memory(Store) and moving memory to register(load). The memory operand for 
> both of those opcodes can be a register as well. The assembler and isel 
> always uses the register to register version of the load opcode. The reversed 
> version is only used by the disassembler
> 
> There is an exception to that. For VEX encoded AVX/AVX2 instructions, 
> X86MCInstLowering will use an _REV move if it allows a 2 byte VEX prefix 
> instead of a 3 byte VEX prefix. This doesn't apply to any AVX512 instructions 
> though. 

I understand now. Thanks, Craig and Pengfei.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-08-06 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Target/X86/X86InstrAVX512.td:4478
+  let Predicates = [HasFP16] in {
+def VMOVSHZrr_REV: AVX512<0x11, MRMDestReg, (outs VR128X:$dst),
+(ins VR128X:$src1, VR128X:$src2),

craig.topper wrote:
> pengfei wrote:
> > LuoYuanke wrote:
> > > Sorry, I forgot what REV stand for. Do you know it?
> > > Is this just encoding difference for register operand compared with 
> > > VMOVSHZrr? What is it used for?
> > I think REV is short for revert. Which allows a different encoding when 
> > operands order are reverted.
> > Yes. It's used for a different encoding.
> It is short for "reverse". Meaing the operands are in the reversed order. 
> There are two valid encodings moving from one register to another. This 
> happens because there are separate opcodes for moving register to 
> memory(Store) and moving memory to register(load). The memory operand for 
> both of those opcodes can be a register as well. The assembler and isel 
> always uses the register to register version of the load opcode. The reversed 
> version is only used by the disassembler
> 
> There is an exception to that. For VEX encoded AVX/AVX2 instructions, 
> X86MCInstLowering will use an _REV move if it allows a 2 byte VEX prefix 
> instead of a 3 byte VEX prefix. This doesn't apply to any AVX512 instructions 
> though. 
Thanks Craig for the information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D105858: opencl-c.h: add 3.0 optional extension support for a few more bits

2021-08-06 Thread Dave Airlie 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 rG1854db74c549: opencl-c.h: add 3.0 optional extension support 
for a few more bits (authored by airlied).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105858

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -16011,7 +16011,7 @@
 
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_work_group_collective_functions)
 int __ovld __conv work_group_all(int predicate);
 int __ovld __conv work_group_any(int predicate);
 
@@ -16109,12 +16109,12 @@
 double __ovld __conv work_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif //defined(__opencl_c_work_group_collective_functions)
 
 // OpenCL v2.0 s6.13.16 - Pipe Functions
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_pipes)
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif //defined(__opencl_c_pipes)
 
 
 // OpenCL v2.0 s6.13.17 - Enqueue Kernels
@@ -16151,7 +16151,7 @@
 
 // OpenCL Extension v2.0 s9.17 - Sub-groups
 
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || 
defined(__opencl_c_subgroups)
 // Shared Sub Group Functions
 uint__ovld get_sub_group_size(void);
 uint__ovld get_max_sub_group_size(void);
@@ -16250,7 +16250,7 @@
 double  __ovld __conv sub_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //cl_khr_subgroups cl_intel_subgroups
+#endif //cl_khr_subgroups cl_intel_subgroups __opencl_c_subgroups
 
 #if defined(cl_khr_subgroup_extended_types)
 char __ovld __conv sub_group_broadcast( char value, uint index );
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -333,7 +333,13 @@
   memory_scope_all_devices = memory_scope_all_svm_devices,
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0
 #endif // defined(__opencl_c_atomic_scope_all_devices)
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+/**
+ * Subgroups have different requirements on forward progress, so just test
+ * all the relevant macros.
+ * CL 3.0 sub-groups "they are not guaranteed to make independent forward 
progress"
+ * KHR subgroups "Subgroups within a workgroup are independent, make forward 
progress with respect to each other"
+ */
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || 
defined(__opencl_c_subgroups)
   memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
 #endif
 } memory_scope;


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -16011,7 +16011,7 @@
 
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_work_group_collective_functions)
 int __ovld __conv work_group_all(int predicate);
 int __ovld __conv work_group_any(int predicate);
 
@@ -16109,12 +16109,12 @@
 double __ovld __conv work_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_work_group_collective_functions)
 
 // OpenCL v2.0 s6.13.16 - Pipe Functions
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_pipes)
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_pipes)
 
 
 // OpenCL v2.0 s6.13.17 - Enqueue Kernels
@@ -16151,7 +16151,7 @@
 
 // OpenCL Extension v2.0 s9.17 - Sub-groups
 
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || defined(__opencl_c_subgroups)
 // Shared Sub Group Functions
 uint__ovld get_sub_group_size(void);
 uint__ovld get_max_sub_group_size(void);
@@ -16250,7 +16250,7 @@
 double  __ovld __conv sub_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //cl_khr_subgroups cl_intel_subgroups
+#endif //cl_khr_subgroups cl_intel_subgroups __opencl_c_subgroups
 
 #if defined(cl_khr_subgroup_extended_types)
 char __ovld __conv 

[clang] 1854db7 - opencl-c.h: add 3.0 optional extension support for a few more bits

2021-08-06 Thread Dave Airlie via cfe-commits

Author: Dave Airlie
Date: 2021-08-07T09:25:00+10:00
New Revision: 1854db74c549d952c0282096be1bb93d5d64f81b

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

LOG: opencl-c.h: add 3.0 optional extension support for a few more bits

These 3 are fairly simple, pipes, workgroups and subgroups.

Reviewed By: Anastasia

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

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index a9b2364e7457..ff8b776d03bb 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -333,7 +333,13 @@ typedef enum memory_scope {
   memory_scope_all_devices = memory_scope_all_svm_devices,
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0
 #endif // defined(__opencl_c_atomic_scope_all_devices)
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+/**
+ * Subgroups have 
diff erent requirements on forward progress, so just test
+ * all the relevant macros.
+ * CL 3.0 sub-groups "they are not guaranteed to make independent forward 
progress"
+ * KHR subgroups "Subgroups within a workgroup are independent, make forward 
progress with respect to each other"
+ */
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || 
defined(__opencl_c_subgroups)
   memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
 #endif
 } memory_scope;

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index e348a092f092..501126bf13ec 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -16011,7 +16011,7 @@ int __ovld get_image_num_samples(read_write 
image2d_array_msaa_depth_t image);
 
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_work_group_collective_functions)
 int __ovld __conv work_group_all(int predicate);
 int __ovld __conv work_group_any(int predicate);
 
@@ -16109,12 +16109,12 @@ double __ovld __conv 
work_group_scan_inclusive_min(double x);
 double __ovld __conv work_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif //defined(__opencl_c_work_group_collective_functions)
 
 // OpenCL v2.0 s6.13.16 - Pipe Functions
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_pipes)
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif //defined(__opencl_c_pipes)
 
 
 // OpenCL v2.0 s6.13.17 - Enqueue Kernels
@@ -16151,7 +16151,7 @@ queue_t __ovld get_default_queue(void);
 
 // OpenCL Extension v2.0 s9.17 - Sub-groups
 
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || 
defined(__opencl_c_subgroups)
 // Shared Sub Group Functions
 uint__ovld get_sub_group_size(void);
 uint__ovld get_max_sub_group_size(void);
@@ -16250,7 +16250,7 @@ double  __ovld __conv 
sub_group_scan_inclusive_min(double x);
 double  __ovld __conv sub_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //cl_khr_subgroups cl_intel_subgroups
+#endif //cl_khr_subgroups cl_intel_subgroups __opencl_c_subgroups
 
 #if defined(cl_khr_subgroup_extended_types)
 char __ovld __conv sub_group_broadcast( char value, uint index );



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


[PATCH] D107242: [AIX] Define __HOS_AIX__ macro

2021-08-06 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I'm puzzled by this change. I don't think we have any case so far where the 
compiler behavior changes with the host OS and I don't think it should. What's 
the point / use case of this macro?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107242

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-06 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

In D104854#2932186 , @nemanjai wrote:

> This appears to have caused some failures on PPC buildbots. For example: 
> https://lab.llvm.org/buildbot/#/builders/105/builds/13446
> We are investigating this. Can you please pull this to bring the bots back to 
> green until we track down the reason for the problem and can provide a fix?

Sorry, I just realized you had pulled it just prior to me posting this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson added a comment.

In D107672#2932190 , @mhjacobson 
wrote:

> I'm also tempted to remove `/usr/lib/avr`, because these paths make no sense 
> to me: `$SYSROOT/usr/lib/avr/lib` and `$SYSROOT/usr/lib/avr/include`.

Ah.  According to https://reviews.llvm.org/D54334, that was added because 
that's where Ubuntu installs avr-libc.  OK then!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson added a comment.

I'm also tempted to remove `/usr/lib/avr`, because these paths make no sense to 
me: `$SYSROOT/usr/lib/avr/lib` and `$SYSROOT/usr/lib/avr/include`.

But I haven't done that here, in case there's some reason those paths do make 
sense.  (Also, the files in `clang/test/Driver/Inputs/basic_avr_tree` make use 
of the `/usr/lib/avr/{lib,include}` structure.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107672

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-06 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

This appears to have caused some failures on PPC buildbots. For example: 
https://lab.llvm.org/buildbot/#/builders/105/builds/13446
We are investigating this. Can you please pull this to bring the bots back to 
green until we track down the reason for the problem and can provide a fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D107672: [AVR][clang] Search for avr-libc in $SYSROOT/avr

2021-08-06 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson created this revision.
mhjacobson added reviewers: benshi001, MaskRay, dylanmckay.
Herald added a subscriber: Jim.
mhjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The paths in PossibleAVRLibcLocations are appended with `/lib/` and `/include/` 
to find the binaries and headers, respectively, for avr-libc.

It's common for avr-libc to live at `$SYSROOT/avr/{lib,include}/`, e.g. when 
`$SYSROOT` is, for example, `/opt/local/`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107672

Files:
  clang/lib/Driver/ToolChains/AVR.cpp


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -298,6 +298,7 @@
 }
 
 const StringRef PossibleAVRLibcLocations[] = {
+"/avr",
 "/usr/avr",
 "/usr/lib/avr",
 };


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -298,6 +298,7 @@
 }
 
 const StringRef PossibleAVRLibcLocations[] = {
+"/avr",
 "/usr/avr",
 "/usr/lib/avr",
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11172
 
+def err_attribute_removed_on_redeclaration : Error<
+  "'%0' attribute removed from redeclared variable">;

aaron.ballman wrote:
> This diagnostic is a bit confusing to me -- should this be a warning about 
> the attribute being ignored in this case, rather than an error? 
> Alternatively, should this be re-worded to say that the attribute must appear 
> on the first declaration? If the latter, we have some diagnostics that could 
> maybe be combined into using a `%select` for this: 
> `err_noreturn_missing_on_first_decl` and `err_internal_linkage_redeclaration` 
> are awfully similar to the same thing.
Rebased onto D107613; reusing `diag::err_attribute_missing_on_first_decl` now. 
done.



Comment at: clang/lib/Sema/SemaDecl.cpp:2982
 
+  // If redeclaration removes error or warning attribute...
+  if (auto *EA = New->getAttr())

aaron.ballman wrote:
> The comment doesn't seem to match the code -- this is when the redeclaration 
> *adds* the attribute. And don't we want to silently accept that if the 
> redeclaration adds the same annotation with the same message? e.g.,
> ```
> __attribute__((error("derp"))) void func();
> __attribute__((error("derp"))) void func(); // fine
> __attribute__((error("derp"))) void func() {} // fine
> ```
Rebased onto D107613, so this block was moved from `Sema::mergeDeclAttributes` 
(which should be for `Attributes` on any subclass of `Decl`, which is too 
generic for a `FunctionDecl` only `Attribute`) to `Sema::MergeFunctionDecl` 
(which is only for `FunctionDecl` `Attribute`s).

I had a similar test case already in clang/test/Sema/attr-error.c testing 
`__attribute__((error("foo"), error("foo"))) int good1(void);`, but I will add 
a test to that file for redeclarations with matching attributes. done.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:955
+
+  if (const auto *EA = D->getAttr()) {
+unsigned NewAttrSpellingIndex = AL.getAttributeSpellingListIndex();

aaron.ballman wrote:
> This logic will catch the case where the attributes are processed in a group 
> (e.g., two attributes in one specifier or two attributes on the same 
> declaration) but it won't handle the redeclaration merging case. I think you 
> need to follow the attribute merge pattern used in SemaDecl.cpp.
I'm not sure that I need to change anything here; redeclarations of 
`ErrorAttr`s are checked in `Sema::MergeFunctionDecl`.

But when I was playing around with something else here earlier this week, I 
noticed a pre-existing inconsistency (or maybe just a difference, described 
below) of `handle*Attr` functionns vs `merge*Attr` functions.

`mergeDeclAttribute` in `clang/lib/Sema/SemaDecl.cpp` has a large `if`/`else` 
chain for new attrs, which calls `merge*Attr` methods of `Sema`, but it doesn't 
give your a reference to any "`Old`"/pre-existing attr that may be in conflict. 
 A comment in `mergeDeclAttribute` seems to confirm this.

>> // This function copies an attribute Attr from a previous declaration to the 
>>  
>>   
>> // new declaration D if the new declaration doesn't itself have that 
>> attribute
>>   
>> // yet or if that attribute allows duplicates.

Because we do not allow this `Attribute` to be added on subsequent `Decl`s, I 
_do not think_ we need to follow the attribute merge pattern used in 
SemaDecl.cpp.  But I could be wrong; please triple check.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:964-965
+bool match =
+(EA->isError() && NewAttrSpellingIndex < ErrorAttr::GNU_warning) ||
+(EA->isWarning() && NewAttrSpellingIndex >= ErrorAttr::GNU_warning);
+if (!match) {

aaron.ballman wrote:
> It's a bit tricky for me to tell from the patch -- are the enumerators in the 
> correct order that this logic still works for when the [[]] spelling is used?
For reference, the generated `enum Spelling` looks like:
```
 3611 public:   


 3612   enum Spelling { 


 3613 GNU_error = 0,


 3614 CXX11_gnu_error = 1,  


 3615 C2x_gnu_error = 2, 

[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 364892.
nickdesaulniers marked 8 inline comments as done.
nickdesaulniers added a comment.

- rebase on D107613 , reuse 
diag::err_attribute_missing_on_first_decl
- test matching redeclarations
- remove getSpelling method call for diag
- capitalize Match
- convert an assert to a static_assert
- reword diagnostic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-error.c
  clang/test/CodeGen/attr-warning.c
  clang/test/Frontend/backend-attribute-error-warning-optimize.c
  clang/test/Frontend/backend-attribute-error-warning.c
  clang/test/Frontend/backend-attribute-error-warning.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Misc/serialized-diags-driver.c
  clang/test/Sema/attr-error.c
  clang/test/Sema/attr-warning.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/test/CodeGen/X86/attr-dontcall.ll
  llvm/test/ThinLTO/X86/dontcall.ll

Index: llvm/test/ThinLTO/X86/dontcall.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/dontcall.ll
@@ -0,0 +1,33 @@
+; RUN: split-file %s %t
+; RUN: opt -module-summary %t/a.s -o %t/a.bc
+; RUN: opt -module-summary %t/b.s -o %t/b.bc
+; RUN: not llvm-lto2 run %t/a.bc %t/b.bc -o %t/out -save-temps 2>&1 \
+; RUN:   -r=%t/a.bc,callee,px \
+; RUN:   -r=%t/b.bc,callee,x  \
+; RUN:   -r=%t/b.bc,caller,px
+
+; TODO: As part of LTO, we check that types match, but *we don't yet check that
+; attributes match!!! What should happen if we remove "dontcall" from the
+; definition or declaration of @callee?
+
+; CHECK: call to callee marked "dontcall"
+
+;--- a.s
+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-unknown-linux-gnu"
+
+define i32 @callee() "dontcall" noinline {
+  ret i32 42
+}
+
+;--- b.s
+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-unknown-linux-gnu"
+
+declare i32 @callee() "dontcall"
+
+define i32 @caller() {
+entry:
+  %0 = call i32 @callee()
+  ret i32 %0
+}
Index: llvm/test/CodeGen/X86/attr-dontcall.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/attr-dontcall.ll
@@ -0,0 +1,11 @@
+; RUN: not llc -global-isel=0 -fast-isel=0 -stop-after=finalize-isel %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=0 -fast-isel=1 -stop-after=finalize-isel %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=1 -fast-isel=0 -stop-after=irtranslator %s 2>&1 | FileCheck %s
+
+declare void @foo() "dontcall"
+define void @bar() {
+  call void @foo()
+  ret void
+}
+
+; CHECK: error: call to foo marked "dontcall"
Index: llvm/lib/IR/DiagnosticInfo.cpp
===
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -401,3 +401,7 @@
 
 void OptimizationRemarkAnalysisFPCommute::anchor() {}
 void OptimizationRemarkAnalysisAliasing::anchor() {}
+
+void DiagnosticInfoDontCall::print(DiagnosticPrinter ) const {
+  DP << "call to " << getFunctionName() << " marked \"dontcall\"";
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -69,6 +69,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/InlineAsm.h"
@@ -7948,6 +7949,15 @@
   }
 
   if (Function *F = I.getCalledFunction()) {
+if (F->hasFnAttribute("dontcall")) {
+  unsigned LocCookie = 0;
+  if (MDNode *MD = I.getMetadata("srcloc"))
+LocCookie =
+mdconst::extract(MD->getOperand(0))->getZExtValue();
+  DiagnosticInfoDontCall D(F->getName(), LocCookie);
+  DAG.getContext()->diagnose(D);
+}
+
 if (F->isDeclaration()) {
   // Is this an LLVM intrinsic or a target-specific intrinsic?
   unsigned IID = F->getIntrinsicID();
Index: 

[PATCH] D107649: [OpenMP]Fix PR51349: Remove AlwaysInline for if regions.

2021-08-06 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG41a6b50c2596: [OpenMP]Fix PR51349: Remove AlwaysInline for 
if regions. (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107649

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/parallel_if_codegen_PR51349.cpp


Index: clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
@@ -0,0 +1,38 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --include-generated-funcs
+// RUN: %clang_cc1 -x c++ -O1 -fopenmp-version=45 -disable-llvm-optzns -verify 
-fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+#pragma omp parallel if(0)
+  ;
+}
+
+#endif
+// CHECK: Function Attrs: mustprogress nounwind
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, i32* [[DOTBOUND_ZERO_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:call void @__kmpc_serialized_parallel(%struct.ident_t* 
@[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:store i32 [[TMP0]], i32* [[DOTTHREADID_TEMP_]], align 4, 
!tbaa [[TBAA3:![0-9]+]]
+// CHECK-NEXT:call void @.omp_outlined.(i32* [[DOTTHREADID_TEMP_]], i32* 
[[DOTBOUND_ZERO_ADDR]]) #[[ATTR2:[0-9]+]]
+// CHECK-NEXT:call void @__kmpc_end_serialized_parallel(%struct.ident_t* 
@[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK: Function Attrs: noinline norecurse nounwind
+// CHECK-LABEL: define {{[^@]+}}@.omp_outlined.
+// CHECK-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias 
[[DOTBOUND_TID_:%.*]]) #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK-NEXT:store i32* [[DOTGLOBAL_TID_]], i32** 
[[DOTGLOBAL_TID__ADDR]], align 8, !tbaa [[TBAA7:![0-9]+]]
+// CHECK-NEXT:store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], 
align 8, !tbaa [[TBAA7]]
+// CHECK-NEXT:ret void
+//
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2120,11 +2120,12 @@
 OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
 
 // Ensure we do not inline the function. This is trivially true for the 
ones
-// passed to __kmpc_fork_call but the ones calles in serialized regions
+// passed to __kmpc_fork_call but the ones called in serialized regions
 // could be inlined. This is not a perfect but it is closer to the 
invariant
 // we want, namely, every data environment starts with a new function.
 // TODO: We should pass the if condition to the runtime function and do the
 //   handling there. Much cleaner code.
+OutlinedFn->removeFnAttr(llvm::Attribute::AlwaysInline);
 OutlinedFn->addFnAttr(llvm::Attribute::NoInline);
 RT.emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
 


Index: clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
@@ -0,0 +1,38 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes --include-generated-funcs
+// RUN: %clang_cc1 -x c++ -O1 -fopenmp-version=45 -disable-llvm-optzns -verify -fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+#pragma omp parallel if(0)
+  ;
+}
+
+#endif
+// CHECK: Function Attrs: mustprogress nounwind
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, i32* [[DOTBOUND_ZERO_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:call void @__kmpc_serialized_parallel(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:store i32 [[TMP0]], i32* [[DOTTHREADID_TEMP_]], align 4, !tbaa [[TBAA3:![0-9]+]]
+// 

[clang] 41a6b50 - [OpenMP]Fix PR51349: Remove AlwaysInline for if regions.

2021-08-06 Thread via cfe-commits

Author: Joseph Huber
Date: 2021-08-06T17:53:04-04:00
New Revision: 41a6b50c25961addc04438b567ee1f4ef9e40f98

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

LOG: [OpenMP]Fix PR51349: Remove AlwaysInline for if regions.

After D94315 we add the `NoInline` attribute to the outlined function to handle
data environments in the OpenMP if clause. This conflicted with the 
`AlwaysInline`
attribute added to the outlined function. for better performance in D106799.
The data environments should ideally not require NoInline, but for now this
fixes PR51349.

Reviewed By: mikerice

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

Added: 
clang/test/OpenMP/parallel_if_codegen_PR51349.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index c09797e91b99..ca98c7a57446 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2120,11 +2120,12 @@ void CGOpenMPRuntime::emitParallelCall(CodeGenFunction 
, SourceLocation Loc,
 OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
 
 // Ensure we do not inline the function. This is trivially true for the 
ones
-// passed to __kmpc_fork_call but the ones calles in serialized regions
+// passed to __kmpc_fork_call but the ones called in serialized regions
 // could be inlined. This is not a perfect but it is closer to the 
invariant
 // we want, namely, every data environment starts with a new function.
 // TODO: We should pass the if condition to the runtime function and do the
 //   handling there. Much cleaner code.
+OutlinedFn->removeFnAttr(llvm::Attribute::AlwaysInline);
 OutlinedFn->addFnAttr(llvm::Attribute::NoInline);
 RT.emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
 

diff  --git a/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp 
b/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
new file mode 100644
index ..eee2c4fd38bc
--- /dev/null
+++ b/clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
@@ -0,0 +1,38 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --include-generated-funcs
+// RUN: %clang_cc1 -x c++ -O1 -fopenmp-version=45 -disable-llvm-optzns -verify 
-fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+#pragma omp parallel if(0)
+  ;
+}
+
+#endif
+// CHECK: Function Attrs: mustprogress nounwind
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, i32* [[DOTBOUND_ZERO_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:call void @__kmpc_serialized_parallel(%struct.ident_t* 
@[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:store i32 [[TMP0]], i32* [[DOTTHREADID_TEMP_]], align 4, 
!tbaa [[TBAA3:![0-9]+]]
+// CHECK-NEXT:call void @.omp_outlined.(i32* [[DOTTHREADID_TEMP_]], i32* 
[[DOTBOUND_ZERO_ADDR]]) #[[ATTR2:[0-9]+]]
+// CHECK-NEXT:call void @__kmpc_end_serialized_parallel(%struct.ident_t* 
@[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK: Function Attrs: noinline norecurse nounwind
+// CHECK-LABEL: define {{[^@]+}}@.omp_outlined.
+// CHECK-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias 
[[DOTBOUND_TID_:%.*]]) #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK-NEXT:store i32* [[DOTGLOBAL_TID_]], i32** 
[[DOTGLOBAL_TID__ADDR]], align 8, !tbaa [[TBAA7:![0-9]+]]
+// CHECK-NEXT:store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], 
align 8, !tbaa [[TBAA7]]
+// CHECK-NEXT:ret void
+//



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


[PATCH] D107668: [OpenMP]Fix PR50336: Remove temporary files in the offload bundler tool

2021-08-06 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, ye-luo, JonChesterfield.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Temporary files created by the offloading device toolchain are not removed
after compilation when using a two-step compilation. The offload-bundler uses a
different filename for the device binary than the `.o` file present in the
Job's input list. This is not listed as a temporary file so it is never
removed. This patch explicitly adds the device binary as a temporary file to
consume it. This fixes PR50336.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107668

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7720,8 +7720,11 @@
 assert(CurTC == nullptr && "Expected one dependence!");
 CurTC = TC;
   });
+  UB += C.addTempFile(
+  C.getArgs().MakeArgString(CurTC->getInputFilename(Inputs[I])));
+} else {
+  UB += CurTC->getInputFilename(Inputs[I]);
 }
-UB += CurTC->getInputFilename(Inputs[I]);
   }
   CmdArgs.push_back(TCArgs.MakeArgString(UB));
 


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7720,8 +7720,11 @@
 assert(CurTC == nullptr && "Expected one dependence!");
 CurTC = TC;
   });
+  UB += C.addTempFile(
+  C.getArgs().MakeArgString(CurTC->getInputFilename(Inputs[I])));
+} else {
+  UB += CurTC->getInputFilename(Inputs[I]);
 }
-UB += CurTC->getInputFilename(Inputs[I]);
   }
   CmdArgs.push_back(TCArgs.MakeArgString(UB));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107649: [OpenMP]Fix PR51349: Remove AlwaysInline for if regions.

2021-08-06 Thread Mike Rice via Phabricator via cfe-commits
mikerice accepted this revision.
mikerice added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107649

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


[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd238b6028582: [Clang][DiagnosticSemaKinds] combine 
diagnostic texts (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
  clang/test/Sema/attr-weak.c
  clang/test/Sema/internal_linkage.c
  clang/test/SemaCXX/internal_linkage.cpp

Index: clang/test/SemaCXX/internal_linkage.cpp
===
--- clang/test/SemaCXX/internal_linkage.cpp
+++ clang/test/SemaCXX/internal_linkage.cpp
@@ -10,8 +10,8 @@
   void f1() __attribute__((internal_linkage));
   void f2() __attribute__((internal_linkage)) {}
   static void f3() __attribute__((internal_linkage)) {}
-  void f4(); // expected-note{{previous definition is here}}
-  static int zz; // expected-note{{previous definition is here}}
+  void f4(); // expected-note{{previous declaration is here}}
+  static int zz; // expected-note{{previous declaration is here}}
   A() __attribute__((internal_linkage)) {}
   ~A() __attribute__((internal_linkage)) {}
   A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
@@ -20,9 +20,9 @@
   };
 };
 
-__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'f4'}}
+__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
-__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'zz'}}
+__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
 namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to}}
 }
Index: clang/test/Sema/internal_linkage.c
===
--- clang/test/Sema/internal_linkage.c
+++ clang/test/Sema/internal_linkage.c
@@ -6,9 +6,9 @@
 int var3 __attribute__((common,internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}
 
-int var4 __attribute__((common)); // expected-note{{previous definition is here}} expected-note{{conflicting attribute is here}}
+int var4 __attribute__((common)); // expected-note{{previous declaration is here}} expected-note{{conflicting attribute is here}}
 int var4 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
-// expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'var4'}}
+// expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
 int var5 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}}
 int var5 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}}
Index: clang/test/Sema/attr-weak.c
===
--- clang/test/Sema/attr-weak.c
+++ clang/test/Sema/attr-weak.c
@@ -17,7 +17,7 @@
 static int x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
 
 // rdar://9538608
-int C; // expected-note {{previous definition is here}}
+int C; // expected-note {{previous declaration is here}}
 extern int C __attribute__((weak_import)); // expected-warning {{an already-declared variable is made a weak_import declaration}}
 
 static int pr14946_x;
Index: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
@@ -24,8 +24,8 @@
 
 [[noreturn]] int e() { b2(); } // ok
 
-int f(); // expected-note {{declaration missing '[[noreturn]]' attribute is here}}
-[[noreturn]] int f(); // expected-error {{function declared '[[noreturn]]' after its first declaration}}
+int f(); // expected-note {{previous declaration is here}}
+[[noreturn]] int f(); // expected-error {{'noreturn' attribute does not appear on the first declaration}}
 int f();
 
 [[noreturn]] int g();
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3353,13 +3353,13 @@
 }
   }
 
-  if (New->hasAttr() &&
-  !Old->hasAttr()) {
- 

[clang] d238b60 - [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2021-08-06T13:58:21-07:00
New Revision: d238b60285820691b08bcca3ec510d13ea46a5ed

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

LOG: [Clang][DiagnosticSemaKinds] combine diagnostic texts

The diagnostic texts for warning on attributes that don't appear on the
initial declaration is generally useful.  We'd like to re-use it in
D106030, but first let's combine two that already are very similar so we
may re-use it a third time in that commit.

Also, fix a few places that were using notePreviousDefinition to point
to declarations, to instead use diag::note_previous_declaration.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
clang/test/Sema/attr-weak.c
clang/test/Sema/internal_linkage.c
clang/test/SemaCXX/internal_linkage.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6cfb8b89eb90..bf857f58951b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5571,8 +5571,8 @@ def warn_undefined_inline : Warning<"inline function %q0 
is not defined">,
 def err_undefined_inline_var : Error<"inline variable %q0 is not defined">;
 def note_used_here : Note<"used here">;
 
-def err_internal_linkage_redeclaration : Error<
-  "'internal_linkage' attribute does not appear on the first declaration of 
%0">;
+def err_attribute_missing_on_first_decl : Error<
+  "%0 attribute does not appear on the first declaration">;
 def warn_internal_linkage_local_storage : Warning<
   "'internal_linkage' attribute on a non-static local variable is ignored">,
   InGroup;
@@ -9676,10 +9676,6 @@ def warn_falloff_noreturn_function : Warning<
   InGroup;
 def err_noreturn_block_has_return_expr : Error<
   "block declared 'noreturn' should not return">;
-def err_noreturn_missing_on_first_decl : Error<
-  "function declared '[[noreturn]]' after its first declaration">;
-def note_noreturn_missing_first_decl : Note<
-  "declaration missing '[[noreturn]]' attribute is here">;
 def err_carries_dependency_missing_on_first_decl : Error<
   "%select{function|parameter}0 declared '[[carries_dependency]]' "
   "after its first declaration">;

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3367f0f9744a..eba5141c24c9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3353,13 +3353,13 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, 
NamedDecl *,
 }
   }
 
-  if (New->hasAttr() &&
-  !Old->hasAttr()) {
-Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
-<< New->getDeclName();
-notePreviousDefinition(Old, New->getLocation());
-New->dropAttr();
-  }
+  if (const auto *ILA = New->getAttr())
+if (!Old->hasAttr()) {
+  Diag(New->getLocation(), diag::err_attribute_missing_on_first_decl)
+  << ILA;
+  Diag(Old->getLocation(), diag::note_previous_declaration);
+  New->dropAttr();
+}
 
   if (CheckRedeclarationModuleOwnership(New, Old))
 return true;
@@ -3678,12 +3678,12 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, 
NamedDecl *,
 //   The first declaration of a function shall specify the noreturn
 //   attribute if any declaration of that function specifies the noreturn
 //   attribute.
-const CXX11NoReturnAttr *NRA = New->getAttr();
-if (NRA && !Old->hasAttr()) {
-  Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
-  Diag(Old->getFirstDecl()->getLocation(),
-   diag::note_noreturn_missing_first_decl);
-}
+if (const auto *NRA = New->getAttr())
+  if (!Old->hasAttr()) {
+Diag(NRA->getLocation(), diag::err_attribute_missing_on_first_decl)
+<< NRA;
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
 
 // C++11 [dcl.attr.depend]p2:
 //   The first declaration of a function shall specify the
@@ -4161,18 +4161,18 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult 
) {
   Old->getStorageClass() == SC_None &&
   !Old->hasAttr()) {
 Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName();
-notePreviousDefinition(Old, New->getLocation());
+Diag(Old->getLocation(), diag::note_previous_declaration);
 // Remove weak_import attribute on new declaration.
 New->dropAttr();
   }
 
-  if (New->hasAttr() &&
-  !Old->hasAttr()) {
-Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
-<< New->getDeclName();
-

[PATCH] D107667: [clang/test] Run thinlto-clang-diagnostic-handler-in-be.c on x86

2021-08-06 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: xur, tejohnson, lebedev.ri.
Herald added subscribers: ormris, pengfei, steven_wu, hiraditya, inglorion.
thopre requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang test CodeGen/thinlto-clang-diagnostic-handler-in-be.c fails on
some non x86 targets, e.g. hexagon. Since the test already requires x86
to be available as a target this commit forces the target to x86_64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107667

Files:
  clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c


Index: clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
===
--- clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
+++ clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
@@ -3,11 +3,11 @@
 // REQUIRES: x86-registered-target
 
 // RUN: llvm-profdata merge -o %t1.profdata %S/Inputs/thinlto_expect1.proftext
-// RUN: %clang -O2 -fexperimental-new-pass-manager -flto=thin -g 
-fprofile-use=%t1.profdata -c -o %t1.bo %s
+// RUN: %clang -target x86_64 -O2 -fexperimental-new-pass-manager -flto=thin 
-g -fprofile-use=%t1.profdata -c -o %t1.bo %s
 // RUN: llvm-lto -thinlto -o %t %t1.bo
-// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo 
-fthinlto-index=%t.thinlto.bc -emit-obj -Rpass-analysis=info 2>&1 | FileCheck 
%s -check-prefix=CHECK-REMARK
+// RUN: %clang -cc1 -triple x86_64 -O2 -fexperimental-new-pass-manager -x ir 
%t1.bo -fthinlto-index=%t.thinlto.bc -emit-obj -Rpass-analysis=info 2>&1 | 
FileCheck %s -check-prefix=CHECK-REMARK
 // RUN: llvm-profdata merge -o %t2.profdata %S/Inputs/thinlto_expect2.proftext
-// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo 
-fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata 
-emit-obj 2>&1 | FileCheck %s -allow-empty -check-prefix=CHECK-NOWARNING
+// RUN: %clang -cc1 -triple x86_64 -O2 -fexperimental-new-pass-manager -x ir 
%t1.bo -fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata 
-emit-obj 2>&1 | FileCheck %s -allow-empty -check-prefix=CHECK-NOWARNING
 
 int sum;
 __attribute__((noinline)) void bar() {


Index: clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
===
--- clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
+++ clang/test/CodeGen/thinlto-clang-diagnostic-handler-in-be.c
@@ -3,11 +3,11 @@
 // REQUIRES: x86-registered-target
 
 // RUN: llvm-profdata merge -o %t1.profdata %S/Inputs/thinlto_expect1.proftext
-// RUN: %clang -O2 -fexperimental-new-pass-manager -flto=thin -g -fprofile-use=%t1.profdata -c -o %t1.bo %s
+// RUN: %clang -target x86_64 -O2 -fexperimental-new-pass-manager -flto=thin -g -fprofile-use=%t1.profdata -c -o %t1.bo %s
 // RUN: llvm-lto -thinlto -o %t %t1.bo
-// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -emit-obj -Rpass-analysis=info 2>&1 | FileCheck %s -check-prefix=CHECK-REMARK
+// RUN: %clang -cc1 -triple x86_64 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -emit-obj -Rpass-analysis=info 2>&1 | FileCheck %s -check-prefix=CHECK-REMARK
 // RUN: llvm-profdata merge -o %t2.profdata %S/Inputs/thinlto_expect2.proftext
-// RUN: %clang -cc1 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata -emit-obj 2>&1 | FileCheck %s -allow-empty -check-prefix=CHECK-NOWARNING
+// RUN: %clang -cc1 -triple x86_64 -O2 -fexperimental-new-pass-manager -x ir %t1.bo -fthinlto-index=%t.thinlto.bc -fprofile-instrument-use-path=%t2.profdata -emit-obj 2>&1 | FileCheck %s -allow-empty -check-prefix=CHECK-NOWARNING
 
 int sum;
 __attribute__((noinline)) void bar() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89785: [clangd] Add basic support for attributes (selection, hover)

2021-08-06 Thread Sam McCall 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 rGbb81e7083d25: [clangd] Add basic support for attributes 
(selection, hover) (authored by sammccall).
Herald added a project: clang-tools-extra.

Changed prior to commit:
  https://reviews.llvm.org/D89785?vs=300182=364877#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89785

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -453,7 +453,19 @@
 template  class Container> class A {};
 A<[[V^ector]]> a;
   )cpp",
-   "TemplateArgumentLoc"}};
+   "TemplateArgumentLoc"},
+
+  // Attributes
+  {R"cpp(
+void f(int * __attribute__(([[no^nnull]])) );
+  )cpp",
+   "NonNullAttr"},
+
+  {R"cpp(
+// Digraph syntax for attributes to avoid accidental annotations.
+class <:[gsl::Owner([[in^t]])]:> X{};
+  )cpp",
+   "BuiltinTypeLoc"}};
 
   for (const Case  : Cases) {
 trace::TestTracer Tracer;
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2377,6 +2377,15 @@
  HI.NamespaceScope = "";
  HI.Value = "0";
}},
+  {R"cpp(
+ void foo(int * __attribute__(([[non^null]], noescape)) );
+ )cpp",
+   [](HoverInfo ) {
+ HI.Name = "nonnull";
+ HI.Kind = index::SymbolKind::Unknown; // FIXME: no suitable value
+ HI.Definition = "__attribute__((nonnull))";
+ HI.Documentation = ""; // FIXME
+   }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -11,8 +11,11 @@
 #include "Annotations.h"
 #include "ParsedAST.h"
 #include "TestTU.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/AttrKinds.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
@@ -25,6 +28,8 @@
 namespace clang {
 namespace clangd {
 namespace {
+using testing::Contains;
+using testing::Each;
 
 TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
   struct Test {
@@ -389,6 +394,40 @@
   EXPECT_FALSE(
   isDeeplyNested((AST, "Bar"), /*MaxDepth=*/4));
 }
+
+MATCHER_P(attrKind, K, "") { return arg->getKind() == K; }
+
+MATCHER(implicitAttr, "") { return arg->isImplicit(); }
+
+TEST(ClangdAST, GetAttributes) {
+  const char *Code = R"cpp(
+class X{};
+class [[nodiscard]] Y{};
+void f(int * a, int * __attribute__((nonnull)) b);
+void foo(bool c) {
+  if (c)
+[[unlikely]] return;
+}
+  )cpp";
+  ParsedAST AST = TestTU::withCode(Code).build();
+  auto DeclAttrs = [&](llvm::StringRef Name) {
+return getAttributes(DynTypedNode::create(findUnqualifiedDecl(AST, Name)));
+  };
+  // Implicit attributes may be present (e.g. visibility on windows).
+  ASSERT_THAT(DeclAttrs("X"), Each(implicitAttr()));
+  ASSERT_THAT(DeclAttrs("Y"), Contains(attrKind(attr::WarnUnusedResult)));
+  ASSERT_THAT(DeclAttrs("f"), Each(implicitAttr()));
+  ASSERT_THAT(DeclAttrs("a"), Each(implicitAttr()));
+  ASSERT_THAT(DeclAttrs("b"), Contains(attrKind(attr::NonNull)));
+
+  Stmt *FooBody = cast(findDecl(AST, "foo")).getBody();
+  IfStmt *FooIf = cast(cast(FooBody)->body_front());
+  ASSERT_THAT(getAttributes(DynTypedNode::create(*FooIf)),
+  Each(implicitAttr()));
+  ASSERT_THAT(getAttributes(DynTypedNode::create(*FooIf->getThen())),
+  Contains(attrKind(attr::Unlikely)));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -183,6 +183,12 @@
 if (const SelectionTree::Node *N = ST.commonAncestor()) {
   if (NodeKind)
 *NodeKind = N->ASTNode.getNodeKind();
+  // Attributes don't target 

[clang-tools-extra] bb81e70 - [clangd] Add basic support for attributes (selection, hover)

2021-08-06 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-08-06T22:49:14+02:00
New Revision: bb81e7083d25bfc9bcf2bd69f5431d0c53b86a32

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

LOG: [clangd] Add basic support for attributes (selection, hover)

These aren't terribly common, but we currently mishandle them badly.
Not only do we not recogize the attributes themselves, but we often end up
selecting some node other than the parent (because source ranges aren't accurate
in the presence of attributes).

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/ASTTests.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 778b945c47ca..a47a5a1aab1d 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -20,7 +20,9 @@
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
@@ -481,6 +483,23 @@ llvm::Optional getDeducedType(ASTContext ,
   return V.DeducedType;
 }
 
+std::vector getAttributes(const DynTypedNode ) {
+  std::vector Result;
+  if (const auto *TL = N.get()) {
+for (AttributedTypeLoc ATL = TL->getAs(); !ATL.isNull();
+ ATL = ATL.getModifiedLoc().getAs()) {
+  Result.push_back(ATL.getAttr());
+  assert(!ATL.getModifiedLoc().isNull());
+}
+  }
+  if (const auto *S = N.get())
+for (; S != nullptr; S = dyn_cast(S->getSubStmt()))
+  llvm::copy(S->getAttrs(), std::back_inserter(Result));
+  if (const auto *D = N.get())
+llvm::copy(D->attrs(), std::back_inserter(Result));
+  return Result;
+}
+
 std::string getQualification(ASTContext ,
  const DeclContext *DestContext,
  SourceLocation InsertionPoint,

diff  --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index 7793b6545c0f..53d9f16a4262 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -27,6 +27,7 @@
 namespace clang {
 class SourceManager;
 class Decl;
+class DynTypedNode;
 
 namespace clangd {
 
@@ -121,6 +122,9 @@ QualType declaredType(const TypeDecl *D);
 /// If the type is an undeduced auto, returns the type itself.
 llvm::Optional getDeducedType(ASTContext &, SourceLocation Loc);
 
+/// Return attributes attached directly to a node.
+std::vector getAttributes(const DynTypedNode &);
+
 /// Gets the nested name specifier necessary for spelling \p ND in \p
 /// DestContext, at \p InsertionPoint. It selects the shortest suffix of \p ND
 /// such that it is visible in \p DestContext.

diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index c71a8c40ce94..228cd192e057 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -19,6 +19,7 @@
 #include "support/Markup.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
@@ -720,6 +721,20 @@ llvm::Optional getHoverContents(const Expr *E, 
ParsedAST ,
   return llvm::None;
 }
 
+// Generates hover info for attributes.
+llvm::Optional getHoverContents(const Attr *A, ParsedAST ) {
+  HoverInfo HI;
+  HI.Name = A->getSpelling();
+  if (A->hasScope())
+HI.LocalScope = A->getScopeName()->getName().str();
+  {
+llvm::raw_string_ostream OS(HI.Definition);
+A->printPretty(OS, AST.getASTContext().getPrintingPolicy());
+  }
+  // FIXME: attributes have documentation, can we get at that?
+  return HI;
+}
+
 bool isParagraphBreak(llvm::StringRef Rest) {
   return Rest.ltrim(" \t").startswith("\n");
 }
@@ -960,6 +975,8 @@ llvm::Optional getHover(ParsedAST , Position 
Pos,
 maybeAddCalleeArgInfo(N, *HI, PP);
   } else if (const Expr *E = N->ASTNode.get()) {
 HI = getHoverContents(E, AST, PP, Index);
+  } else if (const Attr *A = N->ASTNode.get()) {
+HI = getHoverContents(A, AST);
   }
   // FIXME: support hovers for other nodes?
   //  - built-in types

diff  --git a/clang-tools-extra/clangd/Selection.cpp 
b/clang-tools-extra/clangd/Selection.cpp
index b4f767fde095..e3a2e3199766 100644

[PATCH] D107666: [OpenMP] Fix accidental reuse of VLA size

2021-08-06 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/D107666/new/

https://reviews.llvm.org/D107666

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


[PATCH] D107666: [OpenMP] Fix accidental reuse of VLA size

2021-08-06 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.
rogfer01 added a reviewer: ABataev.
Herald added subscribers: guansong, yaxunl.
rogfer01 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

We were using an `OpaqueValueExpr` allocated on the stack to store the size of 
a VLA. Because the `VLASizeMap` in `CodegenFunction` uses the address of the 
expression to avoid recomputing VLAs, we were accidentally reusing an earlier 
`llvm::Value`. This led to invalid LLVM IR.

After this change, we allocate the `OpaqueValueExpr` in `ASTContext` rather 
than in the stack. This is a temporary solution until `VLASizeMap` can be 
pushed and popped based on the context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107666

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/vla_iterator_cache_bug.c


Index: clang/test/OpenMP/vla_iterator_cache_bug.c
===
--- /dev/null
+++ clang/test/OpenMP/vla_iterator_cache_bug.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+extern int bounds1(int);
+extern int bounds2(int);
+
+extern void fun2(int n, int *a, int *b);
+extern void fun3(int n, int *a, int *b);
+
+void fun1(int n, int *a, int *b)
+{
+#pragma omp task depend(iterator(j = 0 : bounds1(n)), in : a[b[j]])
+  {
+fun2(n, a, b);
+  }
+// CHECK: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA:%.*]], align 16
+
+#pragma omp task depend(iterator(j = 0 : bounds2(n)), in : a[b[j]])
+  {
+fun3(n, a, b);
+  }
+// CHECK-NOT: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA]], align 16
+}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4400,14 +4400,14 @@
 if (NumOfElements) {
   NumOfElements = CGF.Builder.CreateNUWAdd(
   llvm::ConstantInt::get(CGF.SizeTy, NumAffinities), NumOfElements);
-  OpaqueValueExpr OVE(
+  auto *OVE = new (C) OpaqueValueExpr(
   Loc,
   C.getIntTypeForBitwidth(C.getTypeSize(C.getSizeType()), 
/*Signed=*/0),
   VK_PRValue);
-  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, ,
+  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
 
RValue::get(NumOfElements));
   KmpTaskAffinityInfoArrayTy =
-  C.getVariableArrayType(KmpTaskAffinityInfoTy, , 
ArrayType::Normal,
+  C.getVariableArrayType(KmpTaskAffinityInfoTy, OVE, ArrayType::Normal,
  /*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
   // Properly emit variable-sized array.
   auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy,
@@ -4898,13 +4898,13 @@
   NumOfElements =
   CGF.Builder.CreateNUWAdd(NumOfRegularWithIterators, NumOfElements);
 }
-OpaqueValueExpr OVE(Loc,
-C.getIntTypeForBitwidth(/*DestWidth=*/64, 
/*Signed=*/0),
-VK_PRValue);
-CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, ,
+auto *OVE = new (C) OpaqueValueExpr(
+Loc, C.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0),
+VK_PRValue);
+CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
   RValue::get(NumOfElements));
 KmpDependInfoArrayTy =
-C.getVariableArrayType(KmpDependInfoTy, , ArrayType::Normal,
+C.getVariableArrayType(KmpDependInfoTy, OVE, ArrayType::Normal,
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
 // CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy);
 // Properly emit variable-sized array.


Index: clang/test/OpenMP/vla_iterator_cache_bug.c
===
--- /dev/null
+++ clang/test/OpenMP/vla_iterator_cache_bug.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+extern int bounds1(int);
+extern int bounds2(int);
+
+extern void fun2(int n, int *a, int *b);
+extern void fun3(int n, int *a, int *b);
+
+void fun1(int n, int *a, int *b)
+{
+#pragma omp task depend(iterator(j = 0 : bounds1(n)), in : a[b[j]])
+  {
+fun2(n, a, b);
+  }
+// CHECK: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA:%.*]], align 16
+
+#pragma omp task depend(iterator(j = 0 : bounds2(n)), in : a[b[j]])
+  {
+fun3(n, a, b);
+  }
+// CHECK-NOT: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA]], align 16
+}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ 

[clang] c8f1482 - Reapply "Support Attr in DynTypedNode and ASTMatchers."

2021-08-06 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-08-06T22:30:32+02:00
New Revision: c8f148274f42aa2ae8c18e1420fa28fefec05a53

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

LOG: Reapply "Support Attr in DynTypedNode and ASTMatchers."

This reverts commit 3241680f111ddf3eac37db88cacac199083543f0.
Fixed mangled post-test formatting :-(

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang/docs/LibASTMatchersReference.html
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/ASTMatchers/ASTMatchFinder.h
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/ParentMapContext.cpp
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/AST/ASTTypeTraitsTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index c5ff44c4e50b..59acc29e8ee9 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -442,7 +442,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
hasDeclaration(DeclMatcher),
unless(templateSpecializationType()),
hasParent(nestedNameSpecifierLoc()),
-   hasAncestor(isImplicit()),
+   hasAncestor(decl(isImplicit())),
hasAncestor(UsingShadowDeclInClass),
hasAncestor(functionDecl(isDefaulted(),
   hasAncestor(decl().bind("dc")))
@@ -466,7 +466,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
   hasAncestor(decl(IsInMovedNs).bind("dc")),
   loc(nestedNameSpecifier(
   specifiesType(hasDeclaration(DeclMatcher.bind("from_decl"),
-  unless(anyOf(hasAncestor(isImplicit()),
+  unless(anyOf(hasAncestor(decl(isImplicit())),
hasAncestor(UsingShadowDeclInClass),
hasAncestor(functionDecl(isDefaulted())),
hasAncestor(typeLoc(loc(qualType(hasDeclaration(
@@ -495,7 +495,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
 hasAncestor(cxxRecordDecl(,
hasParent(namespaceDecl()));
   Finder->addMatcher(expr(hasAncestor(decl().bind("dc")), IsInMovedNs,
-  unless(hasAncestor(isImplicit())),
+  unless(hasAncestor(decl(isImplicit(,
   anyOf(callExpr(callee(FuncMatcher)).bind("call"),
 declRefExpr(to(FuncMatcher.bind("func_decl")))
 .bind("func_ref"))),

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
index 450b56135a78..9cbe1fa65c13 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -38,12 +38,12 @@ void ProBoundsConstantArrayIndexCheck::registerPPCallbacks(
 void ProBoundsConstantArrayIndexCheck::registerMatchers(MatchFinder *Finder) {
   // Note: if a struct contains an array member, the compiler-generated
   // constructor has an arraySubscriptExpr.
-  Finder->addMatcher(
-  arraySubscriptExpr(
-  hasBase(ignoringImpCasts(hasType(constantArrayType().bind("type",
-  hasIndex(expr().bind("index")), unless(hasAncestor(isImplicit(
-  .bind("expr"),
-  this);
+  Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType(
+
constantArrayType().bind("type",
+hasIndex(expr().bind("index")),
+
unless(hasAncestor(decl(isImplicit()
+ .bind("expr"),
+ this);
 
   Finder->addMatcher(
   cxxOperatorCallExpr(

diff  --git 

[clang] 3241680 - Revert "Support Attr in DynTypedNode and ASTMatchers."

2021-08-06 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-08-06T22:27:54+02:00
New Revision: 3241680f111ddf3eac37db88cacac199083543f0

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

LOG: Revert "Support Attr in DynTypedNode and ASTMatchers."

This reverts commit a4bdcdadc6ffab250b218bbdae9a0ced05bebfc9.

Fails bots:
https://lab.llvm.org/buildbot/#/builders/109/builds/20231/steps/6/logs/stdio

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang/docs/LibASTMatchersReference.html
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/ASTMatchers/ASTMatchFinder.h
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/ParentMapContext.cpp
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/AST/ASTTypeTraitsTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index 59acc29e8ee9..c5ff44c4e50b 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -442,7 +442,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
hasDeclaration(DeclMatcher),
unless(templateSpecializationType()),
hasParent(nestedNameSpecifierLoc()),
-   hasAncestor(decl(isImplicit())),
+   hasAncestor(isImplicit()),
hasAncestor(UsingShadowDeclInClass),
hasAncestor(functionDecl(isDefaulted(),
   hasAncestor(decl().bind("dc")))
@@ -466,7 +466,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
   hasAncestor(decl(IsInMovedNs).bind("dc")),
   loc(nestedNameSpecifier(
   specifiesType(hasDeclaration(DeclMatcher.bind("from_decl"),
-  unless(anyOf(hasAncestor(decl(isImplicit())),
+  unless(anyOf(hasAncestor(isImplicit()),
hasAncestor(UsingShadowDeclInClass),
hasAncestor(functionDecl(isDefaulted())),
hasAncestor(typeLoc(loc(qualType(hasDeclaration(
@@ -495,7 +495,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
 hasAncestor(cxxRecordDecl(,
hasParent(namespaceDecl()));
   Finder->addMatcher(expr(hasAncestor(decl().bind("dc")), IsInMovedNs,
-  unless(hasAncestor(decl(isImplicit(,
+  unless(hasAncestor(isImplicit())),
   anyOf(callExpr(callee(FuncMatcher)).bind("call"),
 declRefExpr(to(FuncMatcher.bind("func_decl")))
 .bind("func_ref"))),

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
index 9cbe1fa65c13..450b56135a78 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -38,12 +38,12 @@ void ProBoundsConstantArrayIndexCheck::registerPPCallbacks(
 void ProBoundsConstantArrayIndexCheck::registerMatchers(MatchFinder *Finder) {
   // Note: if a struct contains an array member, the compiler-generated
   // constructor has an arraySubscriptExpr.
-  Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType(
-
constantArrayType().bind("type",
-hasIndex(expr().bind("index")),
-
unless(hasAncestor(decl(isImplicit()
- .bind("expr"),
- this);
+  Finder->addMatcher(
+  arraySubscriptExpr(
+  hasBase(ignoringImpCasts(hasType(constantArrayType().bind("type",
+  hasIndex(expr().bind("index")), unless(hasAncestor(isImplicit(
+  .bind("expr"),
+  this);
 
   Finder->addMatcher(
   

[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

2021-08-06 Thread Sam McCall 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 rGa4bdcdadc6ff: Support Attr in DynTypedNode and ASTMatchers. 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D89743?vs=306795=364875#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/AST/ASTFwd.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/ParentMapContext.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/AST/ASTTypeTraitsTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "ASTMatchersTest.h"
+#include "clang/AST/Attrs.inc"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
@@ -2820,7 +2821,7 @@
 auto M = expr(unless(integerLiteral(equals(24.bind("intLit");
 EXPECT_TRUE(matchAndVerifyResultTrue(
 Code, traverse(TK_AsIs, M),
-std::make_unique>("intLit", 7)));
+std::make_unique>("intLit", 6)));
 EXPECT_TRUE(matchAndVerifyResultTrue(
 Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
 std::make_unique>("intLit", 1)));
@@ -2866,7 +2867,7 @@
 auto M = expr().bind("allExprs");
 EXPECT_TRUE(matchAndVerifyResultTrue(
 Code, traverse(TK_AsIs, M),
-std::make_unique>("allExprs", 7)));
+std::make_unique>("allExprs", 6)));
 EXPECT_TRUE(matchAndVerifyResultTrue(
 Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
 std::make_unique>("allExprs", 1)));
@@ -5446,6 +5447,24 @@
 // Nested names: a, a::A and a::A::B.
 std::make_unique>("x", 3)));
 }
+
+TEST(Attr, AttrsAsDescendants) {
+  StringRef Fragment = "namespace a { struct [[clang::warn_unused_result]] "
+   "F{}; [[noreturn]] void foo(); }";
+  EXPECT_TRUE(matches(Fragment, namespaceDecl(hasDescendant(attr();
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Fragment,
+  namespaceDecl(hasName("a"),
+forEachDescendant(attr(unless(isImplicit())).bind("x"))),
+  std::make_unique>("x", 2)));
+}
+
+TEST(Attr, ParentsOfAttrs) {
+  StringRef Fragment =
+  "namespace a { struct [[clang::warn_unused_result]] F{}; }";
+  EXPECT_TRUE(matches(Fragment, attr(hasAncestor(namespaceDecl();
+}
+
 template  class VerifyMatchOnNode : public BoundNodesCallback {
 public:
   VerifyMatchOnNode(StringRef Id, const internal::Matcher ,
Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -298,7 +298,7 @@
   // Some tests use typeof, which is a gnu extension.  Using an explicit
   // unknown-unknown triple is good for a large speedup, because it lets us
   // avoid constructing a full system triple.
-  std::vector Args = {"-std=gnu++98", "-target",
+  std::vector Args = {"-std=gnu++11", "-target",
"i386-unknown-unknown"};
   if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) {
 return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1885,6 +1885,29 @@
  nestedNameSpecifier()));
 }
 
+TEST_P(ASTMatchersTest, Attr) {
+  // Windows adds some implicit attributes.
+  bool AutomaticAttributes = StringRef(GetParam().Target).contains("win32");
+  if (GetParam().isCXX11OrLater()) {
+EXPECT_TRUE(matches("struct [[clang::warn_unused_result]] F{};", attr()));
+
+  // Unknown attributes are not parsed into an AST node.
+if (!AutomaticAttributes)
+  EXPECT_TRUE(notMatches("int x 

[clang-tools-extra] a4bdcda - Support Attr in DynTypedNode and ASTMatchers.

2021-08-06 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-08-06T22:06:04+02:00
New Revision: a4bdcdadc6ffab250b218bbdae9a0ced05bebfc9

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

LOG: Support Attr in DynTypedNode and ASTMatchers.

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

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang/docs/LibASTMatchersReference.html
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/ASTMatchers/ASTMatchFinder.h
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/ParentMapContext.cpp
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/AST/ASTTypeTraitsTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index c5ff44c4e50b6..59acc29e8ee9a 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -442,7 +442,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
hasDeclaration(DeclMatcher),
unless(templateSpecializationType()),
hasParent(nestedNameSpecifierLoc()),
-   hasAncestor(isImplicit()),
+   hasAncestor(decl(isImplicit())),
hasAncestor(UsingShadowDeclInClass),
hasAncestor(functionDecl(isDefaulted(),
   hasAncestor(decl().bind("dc")))
@@ -466,7 +466,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
   hasAncestor(decl(IsInMovedNs).bind("dc")),
   loc(nestedNameSpecifier(
   specifiesType(hasDeclaration(DeclMatcher.bind("from_decl"),
-  unless(anyOf(hasAncestor(isImplicit()),
+  unless(anyOf(hasAncestor(decl(isImplicit())),
hasAncestor(UsingShadowDeclInClass),
hasAncestor(functionDecl(isDefaulted())),
hasAncestor(typeLoc(loc(qualType(hasDeclaration(
@@ -495,7 +495,7 @@ void 
ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
 hasAncestor(cxxRecordDecl(,
hasParent(namespaceDecl()));
   Finder->addMatcher(expr(hasAncestor(decl().bind("dc")), IsInMovedNs,
-  unless(hasAncestor(isImplicit())),
+  unless(hasAncestor(decl(isImplicit(,
   anyOf(callExpr(callee(FuncMatcher)).bind("call"),
 declRefExpr(to(FuncMatcher.bind("func_decl")))
 .bind("func_ref"))),

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
index 450b56135a78b..9cbe1fa65c139 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -38,12 +38,12 @@ void ProBoundsConstantArrayIndexCheck::registerPPCallbacks(
 void ProBoundsConstantArrayIndexCheck::registerMatchers(MatchFinder *Finder) {
   // Note: if a struct contains an array member, the compiler-generated
   // constructor has an arraySubscriptExpr.
-  Finder->addMatcher(
-  arraySubscriptExpr(
-  hasBase(ignoringImpCasts(hasType(constantArrayType().bind("type",
-  hasIndex(expr().bind("index")), unless(hasAncestor(isImplicit(
-  .bind("expr"),
-  this);
+  Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType(
+
constantArrayType().bind("type",
+hasIndex(expr().bind("index")),
+
unless(hasAncestor(decl(isImplicit()
+ .bind("expr"),
+ this);
 
   Finder->addMatcher(
   cxxOperatorCallExpr(

diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html

[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

2021-08-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added a comment.
Herald added a project: clang-tools-extra.

Finally getting around to landing this, sorry for the long delay!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

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


[clang] f8a4495 - [ARC] Add codegen for llvm.ctlz intrinsic for the ARC backend

2021-08-06 Thread Mark Schimmel via cfe-commits

Author: Thomas Johnson
Date: 2021-08-06T12:18:06-07:00
New Revision: f8a449514931bf2b3a0b36328e821365ed8bf5c6

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

LOG: [ARC] Add codegen for llvm.ctlz intrinsic for the ARC backend

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

Added: 
llvm/test/CodeGen/ARC/ctlz.ll

Modified: 
clang/lib/Basic/Targets/ARC.h
llvm/lib/Target/ARC/ARCExpandPseudos.cpp
llvm/lib/Target/ARC/ARCISelLowering.cpp
llvm/lib/Target/ARC/ARCInstrInfo.td

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARC.h b/clang/lib/Basic/Targets/ARC.h
index b314c42be1e94..3c0c5f6df2f4d 100644
--- a/clang/lib/Basic/Targets/ARC.h
+++ b/clang/lib/Basic/Targets/ARC.h
@@ -67,6 +67,8 @@ class LLVM_LIBRARY_VISIBILITY ARCTargetInfo : public 
TargetInfo {
   }
 
   bool hasExtIntType() const override { return true; }
+
+  bool isCLZForZeroUndef() const override { return false; }
 };
 
 } // namespace targets

diff  --git a/llvm/lib/Target/ARC/ARCExpandPseudos.cpp 
b/llvm/lib/Target/ARC/ARCExpandPseudos.cpp
index a1646d17605fe..cef9882909b3f 100644
--- a/llvm/lib/Target/ARC/ARCExpandPseudos.cpp
+++ b/llvm/lib/Target/ARC/ARCExpandPseudos.cpp
@@ -13,6 +13,7 @@
 #include "ARCInstrInfo.h"
 #include "ARCRegisterInfo.h"
 #include "ARCSubtarget.h"
+#include "MCTargetDesc/ARCInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -35,6 +36,7 @@ class ARCExpandPseudos : public MachineFunctionPass {
 
 private:
   void ExpandStore(MachineFunction &, MachineBasicBlock::iterator);
+  void ExpandCTLZ(MachineFunction &, MachineBasicBlock::iterator);
 
   const ARCInstrInfo *TII;
 };
@@ -59,8 +61,8 @@ static unsigned getMappedOp(unsigned PseudoOp) {
 void ARCExpandPseudos::ExpandStore(MachineFunction ,
MachineBasicBlock::iterator SII) {
   MachineInstr  = *SII;
-  unsigned AddrReg = 
MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
-  unsigned AddOpc =
+  Register AddrReg = 
MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+  Register AddOpc =
   isUInt<6>(SI.getOperand(2).getImm()) ? ARC::ADD_rru6 : ARC::ADD_rrlimm;
   BuildMI(*SI.getParent(), SI, SI.getDebugLoc(), TII->get(AddOpc), AddrReg)
   .addReg(SI.getOperand(1).getReg())
@@ -73,10 +75,39 @@ void ARCExpandPseudos::ExpandStore(MachineFunction ,
   SI.eraseFromParent();
 }
 
+void ARCExpandPseudos::ExpandCTLZ(MachineFunction ,
+  MachineBasicBlock::iterator MII) {
+  // Expand:
+  //   %R2 = CTLZ %R0, %STATUS
+  // To:
+  //   %R2 = FLS_f_rr %R0, %STATUS
+  //   %R2 = MOV_cc_ru6 %R2, 32, pred:1, %STATUS
+  //   %R2 = RSUB_cc_rru6 %R2, 31, pred:2, %STATUS
+  MachineInstr  = *MII;
+  const MachineOperand  = MI.getOperand(0);
+  const MachineOperand  = MI.getOperand(1);
+  Register Ra = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+  Register Rb = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+
+  BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(ARC::FLS_f_rr), Ra)
+  .add(Src);
+  BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(ARC::MOV_cc_ru6), Rb)
+  .addImm(32)
+  .addImm(ARCCC::EQ)
+  .addReg(Ra);
+  BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(ARC::RSUB_cc_rru6))
+  .add(Dest)
+  .addImm(31)
+  .addImm(ARCCC::NE)
+  .addReg(Rb);
+
+  MI.eraseFromParent();
+}
+
 bool ARCExpandPseudos::runOnMachineFunction(MachineFunction ) {
   const ARCSubtarget *STI = ();
   TII = STI->getInstrInfo();
-  bool ExpandedStore = false;
+  bool Expanded = false;
   for (auto  : MF) {
 MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end();
 while (MBBI != E) {
@@ -86,7 +117,11 @@ bool ARCExpandPseudos::runOnMachineFunction(MachineFunction 
) {
   case ARC::STH_FAR:
   case ARC::STB_FAR:
 ExpandStore(MF, MBBI);
-ExpandedStore = true;
+Expanded = true;
+break;
+  case ARC::CTLZ:
+ExpandCTLZ(MF, MBBI);
+Expanded = true;
 break;
   default:
 break;
@@ -94,7 +129,7 @@ bool ARCExpandPseudos::runOnMachineFunction(MachineFunction 
) {
   MBBI = NMBBI;
 }
   }
-  return ExpandedStore;
+  return Expanded;
 }
 
 FunctionPass *llvm::createARCExpandPseudosPass() {

diff  --git a/llvm/lib/Target/ARC/ARCISelLowering.cpp 
b/llvm/lib/Target/ARC/ARCISelLowering.cpp
index ca33f52974711..3db132a50b93f 100644
--- a/llvm/lib/Target/ARC/ARCISelLowering.cpp
+++ b/llvm/lib/Target/ARC/ARCISelLowering.cpp
@@ -135,6 +135,10 @@ ARCTargetLowering::ARCTargetLowering(const TargetMachine 
,
 
   // Sign extend inreg
   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Custom);
+
+  // TODO: Predicate with 

Re: [clang] 4389a41 - Revert "[clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on"

2021-08-06 Thread Roman Lebedev via cfe-commits
Reminder to actually explain in the commit message why the particular
change is being reverted.

On Fri, Aug 6, 2021 at 10:02 PM Zahira Ammarguellat via cfe-commits
 wrote:
>
>
> Author: Zahira Ammarguellat
> Date: 2021-08-06T12:01:47-07:00
> New Revision: 4389a413e2129d7d55ee779638b649aa852b6f8a
>
> URL: 
> https://github.com/llvm/llvm-project/commit/4389a413e2129d7d55ee779638b649aa852b6f8a
> DIFF: 
> https://github.com/llvm/llvm-project/commit/4389a413e2129d7d55ee779638b649aa852b6f8a.diff
>
> LOG: Revert "[clang][fpenv][patch] Change clang option -ffp-model=precise to 
> select ffp-contract=on"
>
> This reverts commit 48ad446a0fb2c9b98cb7047e4daf8a84c29cef8f.
>
> Added:
>
>
> Modified:
> clang/docs/UsersManual.rst
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/test/CodeGen/ffp-contract-option.c
> clang/test/CodeGen/ppc-emmintrin.c
> clang/test/CodeGen/ppc-xmmintrin.c
> clang/test/Driver/fp-model.c
>
> Removed:
>
>
>
> 
> diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> index 838669794ea8..980d0ab45975 100644
> --- a/clang/docs/UsersManual.rst
> +++ b/clang/docs/UsersManual.rst
> @@ -1260,50 +1260,8 @@ installed.
>  Controlling Floating Point Behavior
>  ---
>
> -Clang provides a number of ways to control floating point behavior, including
> -with command line options and source pragmas. This section
> -describes the various floating point semantic modes and the corresponding 
> options.
> -
> -.. csv-table:: Floating Point Semantic Modes
> -  :header: "Mode", "Values"
> -  :widths: 15, 30, 30
> -
> -  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
> -  "fenv_access", "{off, on}", "(none)"
> -  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
> "frounding-math"
> -  "contract", "{on, off, fast}", "ffp-contract"
> -  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", 
> "fdenormal-fp-math"
> -  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
> "fdenormal-fp-math-fp32"
> -  "support_math_errno", "{on, off}", "fmath-errno"
> -  "no_honor_nans", "{on, off}", "fhonor-nans"
> -  "no_honor_infinities", "{on, off}", "fhonor-infinities"
> -  "no_signed_zeros", "{on, off}", "fsigned-zeros"
> -  "allow_reciprocal", "{on, off}", "freciprocal-math"
> -  "allow_approximate_fns", "{on, off}", "(none)"
> -  "allow_reassociation", "{on, off}", "fassociative-math"
> -
> -
> -This table describes the option settings that correspond to the three
> -floating point semantic models: precise (the default), strict, and fast.
> -
> -
> -.. csv-table:: Floating Point Models
> -  :header: "Mode", "Precise", "Strict", "Fast"
> -  :widths: 25, 15, 15, 15
> -
> -  "except_behavior", "ignore", "strict", "ignore"
> -  "fenv_access", "off", "on", "off"
> -  "rounding_mode", "tonearest", "dynamic", "tonearest"
> -  "contract", "on", "off", "fast"
> -  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
> -  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
> -  "support_math_errno", "on", "on", "off"
> -  "no_honor_nans", "off", "off", "on"
> -  "no_honor_infinities", "off", "off", "on"
> -  "no_signed_zeros", "off", "off", "on"
> -  "allow_reciprocal", "off", "off", "on"
> -  "allow_approximate_fns", "off", "off", "on"
> -  "allow_reassociation", "off", "off", "on"
> +Clang provides a number of ways to control floating point behavior. The 
> options
> +are listed below.
>
>  .. option:: -ffast-math
>
> @@ -1498,7 +1456,7 @@ Note that floating-point operations performed as part 
> of constant initialization
> and ``fast``.
> Details:
>
> -   * ``precise`` Disables optimizations that are not value-safe on 
> floating-point data, although FP contraction (FMA) is enabled 
> (``-ffp-contract=on``).  This is the default behavior.
> +   * ``precise`` Disables optimizations that are not value-safe on 
> floating-point data, although FP contraction (FMA) is enabled 
> (``-ffp-contract=fast``).  This is the default behavior.
> * ``strict`` Enables ``-frounding-math`` and 
> ``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
> the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: 
> by default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
> ``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
> * ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
> ``ffp-contract=fast``
>
>
> diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
> b/clang/lib/Driver/ToolChains/Clang.cpp
> index 1c79640be80f..96bbc0250126 100644
> --- a/clang/lib/Driver/ToolChains/Clang.cpp
> +++ b/clang/lib/Driver/ToolChains/Clang.cpp
> @@ -2641,7 +2641,7 @@ static void RenderFloatingPointOptions(const ToolChain 
> , const Driver ,
>
>llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
>llvm::DenormalMode 

[clang] 4389a41 - Revert "[clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on"

2021-08-06 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2021-08-06T12:01:47-07:00
New Revision: 4389a413e2129d7d55ee779638b649aa852b6f8a

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

LOG: Revert "[clang][fpenv][patch] Change clang option -ffp-model=precise to 
select ffp-contract=on"

This reverts commit 48ad446a0fb2c9b98cb7047e4daf8a84c29cef8f.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 838669794ea8..980d0ab45975 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,50 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1498,7 +1456,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1c79640be80f..96bbc0250126 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2641,7 +2641,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
 
@@ -2666,7 +2666,7 @@ static void RenderFloatingPointOptions(const ToolChain 
, const Driver ,
   ReciprocalMath = false;
   SignedZeros = true;
   // -fno_fast_math restores default denormal and fpcontract handling
-  FPContract = "on";
+  

[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: clang/lib/Sema/SemaDecl.cpp:3686
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
 

nickdesaulniers wrote:
> should `CXX11NoReturnAttr` be `dropAttr` on `New` like the other cases, too?
I think it's better to leave it -- the user gets an error so they don't get 
object code out of it, but leaving the attribute as-if the user had specified 
everything properly means later diagnostics may behave a bit better. Probably 
doesn't matter all that much in this case, though, so I don't feel strongly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

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


[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:3686
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
 

should `CXX11NoReturnAttr` be `dropAttr` on `New` like the other cases, too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

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


[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 364858.
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

- more use of note_previous_declaration, fix WeakImportAttr, too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
  clang/test/Sema/attr-weak.c
  clang/test/Sema/internal_linkage.c
  clang/test/SemaCXX/internal_linkage.cpp

Index: clang/test/SemaCXX/internal_linkage.cpp
===
--- clang/test/SemaCXX/internal_linkage.cpp
+++ clang/test/SemaCXX/internal_linkage.cpp
@@ -10,8 +10,8 @@
   void f1() __attribute__((internal_linkage));
   void f2() __attribute__((internal_linkage)) {}
   static void f3() __attribute__((internal_linkage)) {}
-  void f4(); // expected-note{{previous definition is here}}
-  static int zz; // expected-note{{previous definition is here}}
+  void f4(); // expected-note{{previous declaration is here}}
+  static int zz; // expected-note{{previous declaration is here}}
   A() __attribute__((internal_linkage)) {}
   ~A() __attribute__((internal_linkage)) {}
   A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
@@ -20,9 +20,9 @@
   };
 };
 
-__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'f4'}}
+__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
-__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'zz'}}
+__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
 namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to}}
 }
Index: clang/test/Sema/internal_linkage.c
===
--- clang/test/Sema/internal_linkage.c
+++ clang/test/Sema/internal_linkage.c
@@ -6,9 +6,9 @@
 int var3 __attribute__((common,internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}
 
-int var4 __attribute__((common)); // expected-note{{previous definition is here}} expected-note{{conflicting attribute is here}}
+int var4 __attribute__((common)); // expected-note{{previous declaration is here}} expected-note{{conflicting attribute is here}}
 int var4 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
-// expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'var4'}}
+// expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
 int var5 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}}
 int var5 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}}
Index: clang/test/Sema/attr-weak.c
===
--- clang/test/Sema/attr-weak.c
+++ clang/test/Sema/attr-weak.c
@@ -17,7 +17,7 @@
 static int x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
 
 // rdar://9538608
-int C; // expected-note {{previous definition is here}}
+int C; // expected-note {{previous declaration is here}}
 extern int C __attribute__((weak_import)); // expected-warning {{an already-declared variable is made a weak_import declaration}}
 
 static int pr14946_x;
Index: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
@@ -24,8 +24,8 @@
 
 [[noreturn]] int e() { b2(); } // ok
 
-int f(); // expected-note {{declaration missing '[[noreturn]]' attribute is here}}
-[[noreturn]] int f(); // expected-error {{function declared '[[noreturn]]' after its first declaration}}
+int f(); // expected-note {{previous declaration is here}}
+[[noreturn]] int f(); // expected-error {{'noreturn' attribute does not appear on the first declaration}}
 int f();
 
 [[noreturn]] int g();
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3353,13 +3353,13 @@

[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-06 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12120
+   OptimizationRemarkEmitter *ORE,
+   OptimizationRemark OptRemark) {
+  ORE->emit([&]() { return OptRemark; });

rampitec wrote:
> gandhi21299 wrote:
> > rampitec wrote:
> > > gandhi21299 wrote:
> > > > rampitec wrote:
> > > > > Why OptRemark and not just StringRef? I really want to see as little 
> > > > > churn as possible at the call site.
> > > > With only StringRef, we would also have to pass in RMW since 
> > > > OptimizationRemark constructor depends on that.
> > > It seems better be a lamda where you can just capture most of the stuff.
> > What would the type be for the following lambda?
> > 
> > ```
> > [&](){
> > return OptimizationRemark(...);
> > }
> > ```
> You need to return TargetLowering::AtomicExpansionKind, not 
> OptimizationRemark.
This is what goes into ORE->emit() as an argument though. I suspect the remark 
won't be emitted if I return AtomicExpansionKind within the lambda.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-06 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 364854.
gandhi21299 added a comment.

created a patch against llvm trunk


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/AMDGPU/fp-atomics-remarks-gfx90a.ll
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -16,15 +16,20 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lazy Branch Probability Analysis
+; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -10,13 +10,18 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lazy Branch Probability Analysis
+; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -44,6 +44,11 @@
 ; GCN-O0-NEXT:Lower OpenCL enqueued blocks
 ; GCN-O0-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O0-NEXT:FunctionPass Manager
+; GCN-O0-NEXT:  Dominator Tree Construction
+; GCN-O0-NEXT:  Natural Loop Information
+; GCN-O0-NEXT:  Lazy Branch Probability Analysis
+; GCN-O0-NEXT:  Lazy Block Frequency Analysis
+; GCN-O0-NEXT:  Optimization Remark Emitter
 ; GCN-O0-NEXT:  Expand Atomic instructions
 ; GCN-O0-NEXT:  Lower constant intrinsics
 ; GCN-O0-NEXT:  Remove unreachable blocks from the CFG
@@ -180,6 +185,11 @@
 ; GCN-O1-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-NEXT:FunctionPass Manager
 ; GCN-O1-NEXT:  Infer address spaces
+; GCN-O1-NEXT:  Dominator Tree Construction
+; GCN-O1-NEXT:  Natural Loop Information
+; GCN-O1-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-NEXT:  Optimization Remark Emitter
 ; GCN-O1-NEXT:  Expand Atomic instructions
 ; GCN-O1-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-NEXT:  Dominator Tree Construction
@@ -431,6 +441,11 @@
 ; GCN-O1-OPTS-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-OPTS-NEXT:FunctionPass Manager
 ; GCN-O1-OPTS-NEXT:  Infer address spaces
+; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
+; GCN-O1-OPTS-NEXT:  Natural Loop Information
+; GCN-O1-OPTS-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-OPTS-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-OPTS-NEXT:  Optimization Remark Emitter
 ; GCN-O1-OPTS-NEXT:  Expand Atomic 

[PATCH] D107611: [ARC] Add codegen for llvm.ctlz intrinsic for the ARC backend

2021-08-06 Thread Mark Schimmel via Phabricator via cfe-commits
marksl accepted this revision.
marksl added a comment.
This revision is now accepted and ready to land.

Looks good


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107611

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


[PATCH] D107611: [ARC] Add codegen for llvm.ctlz intrinsic for the ARC backend

2021-08-06 Thread Thomas Johnson via Phabricator via cfe-commits
thomasjohns updated this revision to Diff 364855.
thomasjohns added a comment.

Thanks for the feedback, Mark.

This change prefers `MI` over `SI` naming, updates instruction writing, and 
makes the test case more precise (the generated code was improved and no longer 
had an unneeded `mov %r1, %r0`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107611

Files:
  clang/lib/Basic/Targets/ARC.h
  llvm/lib/Target/ARC/ARCExpandPseudos.cpp
  llvm/lib/Target/ARC/ARCISelLowering.cpp
  llvm/lib/Target/ARC/ARCInstrInfo.td
  llvm/test/CodeGen/ARC/ctlz.ll

Index: llvm/test/CodeGen/ARC/ctlz.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARC/ctlz.ll
@@ -0,0 +1,14 @@
+; RUN: llc -march=arc < %s | FileCheck %s
+
+target triple = "arc"
+
+declare i32 @llvm.ctlz.i32(i32, i1)
+
+; CHECK-LABEL: clz32:
+; CHECK:   fls.f   %r0, %r0
+; CHECK-NEXT:  mov.eq  %r0, 32
+; CHECK-NEXT:  rsub.ne %r0, %r0, 31
+define i32 @clz32(i32 %x) {
+  %a = call i32 @llvm.ctlz.i32(i32 %x, i1 false)
+  ret i32 %a
+}
Index: llvm/lib/Target/ARC/ARCInstrInfo.td
===
--- llvm/lib/Target/ARC/ARCInstrInfo.td
+++ llvm/lib/Target/ARC/ARCInstrInfo.td
@@ -133,6 +133,14 @@
  "STB_FAR $dst, $addr",
  [(truncstorei8 GPR32:$dst, AddrModeFar:$addr)]>;
 
+// TODO: Add `Requires<[HasBitScan]>` predicate when available.
+def CTLZ : PseudoInstARC<(outs GPR32:$A),
+ (ins GPR32:$B),
+ "error.fls $A, $B",
+ [(set GPR32:$A, (ctlz i32:$B))]> {
+  let Defs = [STATUS32];
+}
+
 //===--===//
 // Instruction Generation multiclasses.
 // Generate many variants of a single instruction with a single defining
Index: llvm/lib/Target/ARC/ARCISelLowering.cpp
===
--- llvm/lib/Target/ARC/ARCISelLowering.cpp
+++ llvm/lib/Target/ARC/ARCISelLowering.cpp
@@ -135,6 +135,10 @@
 
   // Sign extend inreg
   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Custom);
+
+  // TODO: Predicate with `options.hasBitScan() ? Legal : Expand` when
+  //   the HasBitScan predicate is available.
+  setOperationAction(ISD::CTLZ, MVT::i32, Legal);
 }
 
 const char *ARCTargetLowering::getTargetNodeName(unsigned Opcode) const {
Index: llvm/lib/Target/ARC/ARCExpandPseudos.cpp
===
--- llvm/lib/Target/ARC/ARCExpandPseudos.cpp
+++ llvm/lib/Target/ARC/ARCExpandPseudos.cpp
@@ -13,6 +13,7 @@
 #include "ARCInstrInfo.h"
 #include "ARCRegisterInfo.h"
 #include "ARCSubtarget.h"
+#include "MCTargetDesc/ARCInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -35,6 +36,7 @@
 
 private:
   void ExpandStore(MachineFunction &, MachineBasicBlock::iterator);
+  void ExpandCTLZ(MachineFunction &, MachineBasicBlock::iterator);
 
   const ARCInstrInfo *TII;
 };
@@ -59,8 +61,8 @@
 void ARCExpandPseudos::ExpandStore(MachineFunction ,
MachineBasicBlock::iterator SII) {
   MachineInstr  = *SII;
-  unsigned AddrReg = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
-  unsigned AddOpc =
+  Register AddrReg = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+  Register AddOpc =
   isUInt<6>(SI.getOperand(2).getImm()) ? ARC::ADD_rru6 : ARC::ADD_rrlimm;
   BuildMI(*SI.getParent(), SI, SI.getDebugLoc(), TII->get(AddOpc), AddrReg)
   .addReg(SI.getOperand(1).getReg())
@@ -73,10 +75,39 @@
   SI.eraseFromParent();
 }
 
+void ARCExpandPseudos::ExpandCTLZ(MachineFunction ,
+  MachineBasicBlock::iterator MII) {
+  // Expand:
+  //	%R2 = CTLZ %R0, %STATUS
+  // To:
+  //	%R2 = FLS_f_rr %R0, %STATUS
+  //	%R2 = MOV_cc_ru6 %R2, 32, pred:1, %STATUS
+  //	%R2 = RSUB_cc_rru6 %R2, 31, pred:2, %STATUS
+  MachineInstr  = *MII;
+  const MachineOperand  = MI.getOperand(0);
+  const MachineOperand  = MI.getOperand(1);
+  Register Ra = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+  Register Rb = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+
+  BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(ARC::FLS_f_rr), Ra)
+  .add(Src);
+  BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(ARC::MOV_cc_ru6), Rb)
+  .addImm(32)
+  .addImm(ARCCC::EQ)
+  .addReg(Ra);
+  BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(ARC::RSUB_cc_rru6))
+  .add(Dest)
+  .addImm(31)
+  .addImm(ARCCC::NE)
+  .addReg(Rb);
+
+  MI.eraseFromParent();
+}
+
 bool ARCExpandPseudos::runOnMachineFunction(MachineFunction ) {
   const ARCSubtarget *STI = ();
   TII = STI->getInstrInfo();
-  bool ExpandedStore = false;
+  

[PATCH] D107646: [PowerPC] Fix the frame addresss computing return address for `__builtin_return_address`

2021-08-06 Thread Victor Huang via Phabricator via cfe-commits
NeHuang updated this revision to Diff 364856.
NeHuang added a comment.

- Rebased with ToT
- Clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107646

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/2010-05-03-retaddr1.ll
  llvm/test/CodeGen/PowerPC/retaddr_multi_levels.ll

Index: llvm/test/CodeGen/PowerPC/retaddr_multi_levels.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/retaddr_multi_levels.ll
@@ -0,0 +1,174 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-linux -mcpu=pwr8 | FileCheck %s -check-prefix=CHECK-64B-LE
+; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux -mcpu=pwr7 | FileCheck %s -check-prefix=CHECK-64B-BE
+; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-aix -mcpu=pwr7 | FileCheck %s -check-prefix=CHECK-64B-AIX
+; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc-unknown-aix -mcpu=pwr7 | FileCheck %s -check-prefix=CHECK-32B-AIX
+
+declare i8* @llvm.returnaddress(i32) nounwind readnone
+
+define i8* @test0() nounwind readnone {
+; CHECK-64B-LE-LABEL: test0:
+; CHECK-64B-LE:   # %bb.0: # %entry
+; CHECK-64B-LE-NEXT:mflr 0
+; CHECK-64B-LE-NEXT:std 0, 16(1)
+; CHECK-64B-LE-NEXT:stdu 1, -32(1)
+; CHECK-64B-LE-NEXT:ld 3, 48(1)
+; CHECK-64B-LE-NEXT:addi 1, 1, 32
+; CHECK-64B-LE-NEXT:ld 0, 16(1)
+; CHECK-64B-LE-NEXT:mtlr 0
+; CHECK-64B-LE-NEXT:blr
+;
+; CHECK-64B-BE-LABEL: test0:
+; CHECK-64B-BE:   # %bb.0: # %entry
+; CHECK-64B-BE-NEXT:mflr 0
+; CHECK-64B-BE-NEXT:std 0, 16(1)
+; CHECK-64B-BE-NEXT:stdu 1, -48(1)
+; CHECK-64B-BE-NEXT:ld 3, 64(1)
+; CHECK-64B-BE-NEXT:addi 1, 1, 48
+; CHECK-64B-BE-NEXT:ld 0, 16(1)
+; CHECK-64B-BE-NEXT:mtlr 0
+; CHECK-64B-BE-NEXT:blr
+;
+; CHECK-64B-AIX-LABEL: test0:
+; CHECK-64B-AIX:   # %bb.0: # %entry
+; CHECK-64B-AIX-NEXT:mflr 0
+; CHECK-64B-AIX-NEXT:std 0, 16(1)
+; CHECK-64B-AIX-NEXT:stdu 1, -48(1)
+; CHECK-64B-AIX-NEXT:ld 3, 64(1)
+; CHECK-64B-AIX-NEXT:addi 1, 1, 48
+; CHECK-64B-AIX-NEXT:ld 0, 16(1)
+; CHECK-64B-AIX-NEXT:mtlr 0
+; CHECK-64B-AIX-NEXT:blr
+;
+; CHECK-32B-AIX-LABEL: test0:
+; CHECK-32B-AIX:   # %bb.0: # %entry
+; CHECK-32B-AIX-NEXT:mflr 0
+; CHECK-32B-AIX-NEXT:stw 0, 8(1)
+; CHECK-32B-AIX-NEXT:stwu 1, -32(1)
+; CHECK-32B-AIX-NEXT:lwz 3, 40(1)
+; CHECK-32B-AIX-NEXT:addi 1, 1, 32
+; CHECK-32B-AIX-NEXT:lwz 0, 8(1)
+; CHECK-32B-AIX-NEXT:mtlr 0
+; CHECK-32B-AIX-NEXT:blr
+entry:
+  %0 = tail call i8* @llvm.returnaddress(i32 0);
+  ret i8* %0
+}
+
+define i8* @test1() nounwind readnone {
+; CHECK-64B-LE-LABEL: test1:
+; CHECK-64B-LE:   # %bb.0: # %entry
+; CHECK-64B-LE-NEXT:mflr 0
+; CHECK-64B-LE-NEXT:std 0, 16(1)
+; CHECK-64B-LE-NEXT:stdu 1, -32(1)
+; CHECK-64B-LE-NEXT:ld 3, 0(1)
+; CHECK-64B-LE-NEXT:ld 3, 0(3)
+; CHECK-64B-LE-NEXT:ld 3, 16(3)
+; CHECK-64B-LE-NEXT:addi 1, 1, 32
+; CHECK-64B-LE-NEXT:ld 0, 16(1)
+; CHECK-64B-LE-NEXT:mtlr 0
+; CHECK-64B-LE-NEXT:blr
+;
+; CHECK-64B-BE-LABEL: test1:
+; CHECK-64B-BE:   # %bb.0: # %entry
+; CHECK-64B-BE-NEXT:mflr 0
+; CHECK-64B-BE-NEXT:std 0, 16(1)
+; CHECK-64B-BE-NEXT:stdu 1, -48(1)
+; CHECK-64B-BE-NEXT:ld 3, 0(1)
+; CHECK-64B-BE-NEXT:ld 3, 0(3)
+; CHECK-64B-BE-NEXT:ld 3, 16(3)
+; CHECK-64B-BE-NEXT:addi 1, 1, 48
+; CHECK-64B-BE-NEXT:ld 0, 16(1)
+; CHECK-64B-BE-NEXT:mtlr 0
+; CHECK-64B-BE-NEXT:blr
+;
+; CHECK-64B-AIX-LABEL: test1:
+; CHECK-64B-AIX:   # %bb.0: # %entry
+; CHECK-64B-AIX-NEXT:mflr 0
+; CHECK-64B-AIX-NEXT:std 0, 16(1)
+; CHECK-64B-AIX-NEXT:stdu 1, -48(1)
+; CHECK-64B-AIX-NEXT:ld 3, 0(1)
+; CHECK-64B-AIX-NEXT:ld 3, 0(3)
+; CHECK-64B-AIX-NEXT:ld 3, 16(3)
+; CHECK-64B-AIX-NEXT:addi 1, 1, 48
+; CHECK-64B-AIX-NEXT:ld 0, 16(1)
+; CHECK-64B-AIX-NEXT:mtlr 0
+; CHECK-64B-AIX-NEXT:blr
+;
+; CHECK-32B-AIX-LABEL: test1:
+; CHECK-32B-AIX:   # %bb.0: # %entry
+; CHECK-32B-AIX-NEXT:mflr 0
+; CHECK-32B-AIX-NEXT:stw 0, 8(1)
+; CHECK-32B-AIX-NEXT:stwu 1, -32(1)
+; CHECK-32B-AIX-NEXT:lwz 3, 0(1)
+; CHECK-32B-AIX-NEXT:lwz 3, 0(3)
+; CHECK-32B-AIX-NEXT:lwz 3, 8(3)
+; CHECK-32B-AIX-NEXT:addi 1, 1, 32
+; CHECK-32B-AIX-NEXT:lwz 0, 8(1)
+; CHECK-32B-AIX-NEXT:mtlr 0
+; CHECK-32B-AIX-NEXT:blr
+entry:
+  %0 = tail call i8* @llvm.returnaddress(i32 1);
+  ret i8* %0
+}
+
+define i8* @test2() nounwind readnone {
+; CHECK-64B-LE-LABEL: test2:
+; CHECK-64B-LE:   # %bb.0: # %entry
+; CHECK-64B-LE-NEXT:mflr 0
+; CHECK-64B-LE-NEXT:std 0, 16(1)
+; CHECK-64B-LE-NEXT:stdu 1, -32(1)
+; CHECK-64B-LE-NEXT:ld 3, 0(1)
+; CHECK-64B-LE-NEXT:ld 3, 0(3)
+; CHECK-64B-LE-NEXT:

[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-06 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12120
+   OptimizationRemarkEmitter *ORE,
+   OptimizationRemark OptRemark) {
+  ORE->emit([&]() { return OptRemark; });

gandhi21299 wrote:
> rampitec wrote:
> > gandhi21299 wrote:
> > > rampitec wrote:
> > > > Why OptRemark and not just StringRef? I really want to see as little 
> > > > churn as possible at the call site.
> > > With only StringRef, we would also have to pass in RMW since 
> > > OptimizationRemark constructor depends on that.
> > It seems better be a lamda where you can just capture most of the stuff.
> What would the type be for the following lambda?
> 
> ```
> [&](){
> return OptimizationRemark(...);
> }
> ```
You need to return TargetLowering::AtomicExpansionKind, not OptimizationRemark.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

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

- improved code style in AtomicExpand and SIISelLowering


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/AMDGPU/fp-atomics-remarks-gfx90a.ll
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -16,15 +16,20 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lazy Branch Probability Analysis
+; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -10,13 +10,18 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lazy Branch Probability Analysis
+; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -44,6 +44,11 @@
 ; GCN-O0-NEXT:Lower OpenCL enqueued blocks
 ; GCN-O0-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O0-NEXT:FunctionPass Manager
+; GCN-O0-NEXT:  Dominator Tree Construction
+; GCN-O0-NEXT:  Natural Loop Information
+; GCN-O0-NEXT:  Lazy Branch Probability Analysis
+; GCN-O0-NEXT:  Lazy Block Frequency Analysis
+; GCN-O0-NEXT:  Optimization Remark Emitter
 ; GCN-O0-NEXT:  Expand Atomic instructions
 ; GCN-O0-NEXT:  Lower constant intrinsics
 ; GCN-O0-NEXT:  Remove unreachable blocks from the CFG
@@ -180,6 +185,11 @@
 ; GCN-O1-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-NEXT:FunctionPass Manager
 ; GCN-O1-NEXT:  Infer address spaces
+; GCN-O1-NEXT:  Dominator Tree Construction
+; GCN-O1-NEXT:  Natural Loop Information
+; GCN-O1-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-NEXT:  Optimization Remark Emitter
 ; GCN-O1-NEXT:  Expand Atomic instructions
 ; GCN-O1-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-NEXT:  Dominator Tree Construction
@@ -431,6 +441,11 @@
 ; GCN-O1-OPTS-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-OPTS-NEXT:FunctionPass Manager
 ; GCN-O1-OPTS-NEXT:  Infer address spaces
+; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
+; GCN-O1-OPTS-NEXT:  Natural Loop Information
+; GCN-O1-OPTS-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-OPTS-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-OPTS-NEXT:  

[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-06 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 marked 2 inline comments as done.
gandhi21299 added inline comments.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12120
+   OptimizationRemarkEmitter *ORE,
+   OptimizationRemark OptRemark) {
+  ORE->emit([&]() { return OptRemark; });

rampitec wrote:
> gandhi21299 wrote:
> > rampitec wrote:
> > > Why OptRemark and not just StringRef? I really want to see as little 
> > > churn as possible at the call site.
> > With only StringRef, we would also have to pass in RMW since 
> > OptimizationRemark constructor depends on that.
> It seems better be a lamda where you can just capture most of the stuff.
What would the type be for the following lambda?

```
[&](){
return OptimizationRemark(...);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:3685
+<< NRA;
+notePreviousDefinition(Old, New->getLocation());
+  }

aaron.ballman wrote:
> nickdesaulniers wrote:
> > ah, this isn't quite right.  It replaces warning of the first declaration 
> > with warning of the first definition.
> > 
> > This should instead use
> > 
> > `Diag(Old->getLocation(), diag::note_previous_declaration);`
> Good catch! I think we want to use `note_previous_declaration` in all three 
> cases though, don't we? It's a bit weird that we diagnose "attribute not 
> present on first declaration" but then try to note a definition. e.g., 
> https://godbolt.org/z/jd9oG96sT
> 
> I know it's a bit of a drive-by, but I think it's probably worth correcting 
> that as well. WDYT?
Looks like we do that for `WeakImportAttr`, too. Will fix all cases and amend 
description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

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


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-06 Thread Steven Wan via Phabricator via cfe-commits
stevewan planned changes to this revision.
stevewan added a comment.

The query portion has been split out as https://reviews.llvm.org/D107598, which 
needs to be cleaned out from this patch. The record layout part also needs 
update as we uncover more problems with the current implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107394

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


[clang] 6a9cf21 - [CUDA, MemCpyOpt] Add a flag to force-enable memcpyopt and use it for CUDA.

2021-08-06 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2021-08-06T11:13:52-07:00
New Revision: 6a9cf21f5a2dcd02f90075d6d3576a87f1abd8a9

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

LOG: [CUDA, MemCpyOpt] Add a flag to force-enable memcpyopt and use it for CUDA.

Attempt to enable MemCpyOpt unconditionally in D104801 uncovered the fact that
there are users that do not expect LLVM to materialize `memset` intrinsic.

While other passes can do that, too, MemCpyOpt triggers it more frequently and
breaks sanitizers and some downstream users.

For now introduce a flag to force-enable the flag and opt-in only CUDA
compilation with NVPTX back-end.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Cuda.cpp
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/no-libcalls.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index c4d1ebdf6913..37a4da80c03c 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -685,7 +685,8 @@ void CudaToolChain::addClangTargetOptions(
  "Only OpenMP or CUDA offloading kinds are supported for NVIDIA 
GPUs.");
 
   if (DeviceOffloadingKind == Action::OFK_Cuda) {
-CC1Args.push_back("-fcuda-is-device");
+CC1Args.append(
+{"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"});
 
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))

diff  --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp 
b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 0dd0b45cf054..42650f3b6f2e 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -67,6 +67,10 @@ using namespace llvm;
 
 #define DEBUG_TYPE "memcpyopt"
 
+static cl::opt EnableMemCpyOptWithoutLibcalls(
+"enable-memcpyopt-without-libcalls", cl::init(false), cl::Hidden,
+cl::desc("Enable memcpyopt even when libcalls are disabled"));
+
 static cl::opt
 EnableMemorySSA("enable-memcpyopt-memoryssa", cl::init(true), cl::Hidden,
 cl::desc("Use MemorySSA-backed MemCpyOpt."));
@@ -677,8 +681,9 @@ bool MemCpyOptPass::processStore(StoreInst *SI, 
BasicBlock::iterator ) {
   // the corresponding libcalls are not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce intrinsics.
-  if (T->isAggregateType() && TLI->has(LibFunc_memcpy) &&
-  TLI->has(LibFunc_memmove)) {
+  if (T->isAggregateType() &&
+  (EnableMemCpyOptWithoutLibcalls ||
+   (TLI->has(LibFunc_memcpy) && TLI->has(LibFunc_memmove {
 MemoryLocation LoadLoc = MemoryLocation::get(LI);
 
 // We use alias analysis to check if an instruction may store to
@@ -806,7 +811,7 @@ bool MemCpyOptPass::processStore(StoreInst *SI, 
BasicBlock::iterator ) {
   // this if the corresponding libfunc is not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce intrinsics.
-  if (!TLI->has(LibFunc_memset))
+  if (!(TLI->has(LibFunc_memset) || EnableMemCpyOptWithoutLibcalls))
 return false;
 
   // There are two cases that are interesting for this code to handle: memcpy

diff  --git a/llvm/test/Transforms/MemCpyOpt/no-libcalls.ll 
b/llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
index c4d935158435..ac7cfc55ce50 100644
--- a/llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
+++ b/llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -memcpyopt < %s | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 ; RUN: opt -S -memcpyopt -mtriple=amdgcn-- < %s | FileCheck %s 
--check-prefixes=CHECK,NO-LIBCALLS
+; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -enable-memcpyopt-without-libcalls 
< %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 
 ; REQUIRES: amdgpu-registered-target
 



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


[PATCH] D106401: [CUDA, MemCpyOpt] Add a flag to force-enable memcpyopt and use it for CUDA.

2021-08-06 Thread Artem Belevich 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 rG6a9cf21f5a2d: [CUDA, MemCpyOpt] Add a flag to force-enable 
memcpyopt and use it for CUDA. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106401

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
  llvm/test/Transforms/MemCpyOpt/no-libcalls.ll


Index: llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
===
--- llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
+++ llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -memcpyopt < %s | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 ; RUN: opt -S -memcpyopt -mtriple=amdgcn-- < %s | FileCheck %s 
--check-prefixes=CHECK,NO-LIBCALLS
+; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -enable-memcpyopt-without-libcalls 
< %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 
 ; REQUIRES: amdgpu-registered-target
 
Index: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
===
--- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -67,6 +67,10 @@
 
 #define DEBUG_TYPE "memcpyopt"
 
+static cl::opt EnableMemCpyOptWithoutLibcalls(
+"enable-memcpyopt-without-libcalls", cl::init(false), cl::Hidden,
+cl::desc("Enable memcpyopt even when libcalls are disabled"));
+
 static cl::opt
 EnableMemorySSA("enable-memcpyopt-memoryssa", cl::init(true), cl::Hidden,
 cl::desc("Use MemorySSA-backed MemCpyOpt."));
@@ -677,8 +681,9 @@
   // the corresponding libcalls are not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce intrinsics.
-  if (T->isAggregateType() && TLI->has(LibFunc_memcpy) &&
-  TLI->has(LibFunc_memmove)) {
+  if (T->isAggregateType() &&
+  (EnableMemCpyOptWithoutLibcalls ||
+   (TLI->has(LibFunc_memcpy) && TLI->has(LibFunc_memmove {
 MemoryLocation LoadLoc = MemoryLocation::get(LI);
 
 // We use alias analysis to check if an instruction may store to
@@ -806,7 +811,7 @@
   // this if the corresponding libfunc is not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce intrinsics.
-  if (!TLI->has(LibFunc_memset))
+  if (!(TLI->has(LibFunc_memset) || EnableMemCpyOptWithoutLibcalls))
 return false;
 
   // There are two cases that are interesting for this code to handle: memcpy
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -685,7 +685,8 @@
  "Only OpenMP or CUDA offloading kinds are supported for NVIDIA 
GPUs.");
 
   if (DeviceOffloadingKind == Action::OFK_Cuda) {
-CC1Args.push_back("-fcuda-is-device");
+CC1Args.append(
+{"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"});
 
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))


Index: llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
===
--- llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
+++ llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -memcpyopt < %s | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 ; RUN: opt -S -memcpyopt -mtriple=amdgcn-- < %s | FileCheck %s --check-prefixes=CHECK,NO-LIBCALLS
+; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -enable-memcpyopt-without-libcalls < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 
 ; REQUIRES: amdgpu-registered-target
 
Index: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
===
--- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -67,6 +67,10 @@
 
 #define DEBUG_TYPE "memcpyopt"
 
+static cl::opt EnableMemCpyOptWithoutLibcalls(
+"enable-memcpyopt-without-libcalls", cl::init(false), cl::Hidden,
+cl::desc("Enable memcpyopt even when libcalls are disabled"));
+
 static cl::opt
 EnableMemorySSA("enable-memcpyopt-memoryssa", cl::init(true), cl::Hidden,
 cl::desc("Use MemorySSA-backed MemCpyOpt."));
@@ -677,8 +681,9 @@
   // the corresponding libcalls are not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce 

[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:3685
+<< NRA;
+notePreviousDefinition(Old, New->getLocation());
+  }

nickdesaulniers wrote:
> ah, this isn't quite right.  It replaces warning of the first declaration 
> with warning of the first definition.
> 
> This should instead use
> 
> `Diag(Old->getLocation(), diag::note_previous_declaration);`
Good catch! I think we want to use `note_previous_declaration` in all three 
cases though, don't we? It's a bit weird that we diagnose "attribute not 
present on first declaration" but then try to note a definition. e.g., 
https://godbolt.org/z/jd9oG96sT

I know it's a bit of a drive-by, but I think it's probably worth correcting 
that as well. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

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


[PATCH] D106401: [CUDA, MemCpyOpt] Add a flag to force-enable memcpyopt and use it for CUDA.

2021-08-06 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 364847.
tra added a comment.

rebase to HEAD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106401

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
  llvm/test/Transforms/MemCpyOpt/no-libcalls.ll


Index: llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
===
--- llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
+++ llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -memcpyopt < %s | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 ; RUN: opt -S -memcpyopt -mtriple=amdgcn-- < %s | FileCheck %s 
--check-prefixes=CHECK,NO-LIBCALLS
+; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -enable-memcpyopt-without-libcalls 
< %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 
 ; REQUIRES: amdgpu-registered-target
 
Index: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
===
--- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -67,6 +67,10 @@
 
 #define DEBUG_TYPE "memcpyopt"
 
+static cl::opt EnableMemCpyOptWithoutLibcalls(
+"enable-memcpyopt-without-libcalls", cl::init(false), cl::Hidden,
+cl::desc("Enable memcpyopt even when libcalls are disabled"));
+
 static cl::opt
 EnableMemorySSA("enable-memcpyopt-memoryssa", cl::init(true), cl::Hidden,
 cl::desc("Use MemorySSA-backed MemCpyOpt."));
@@ -677,8 +681,9 @@
   // the corresponding libcalls are not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce intrinsics.
-  if (T->isAggregateType() && TLI->has(LibFunc_memcpy) &&
-  TLI->has(LibFunc_memmove)) {
+  if (T->isAggregateType() &&
+  (EnableMemCpyOptWithoutLibcalls ||
+   (TLI->has(LibFunc_memcpy) && TLI->has(LibFunc_memmove {
 MemoryLocation LoadLoc = MemoryLocation::get(LI);
 
 // We use alias analysis to check if an instruction may store to
@@ -806,7 +811,7 @@
   // this if the corresponding libfunc is not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce intrinsics.
-  if (!TLI->has(LibFunc_memset))
+  if (!(TLI->has(LibFunc_memset) || EnableMemCpyOptWithoutLibcalls))
 return false;
 
   // There are two cases that are interesting for this code to handle: memcpy
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -685,7 +685,8 @@
  "Only OpenMP or CUDA offloading kinds are supported for NVIDIA 
GPUs.");
 
   if (DeviceOffloadingKind == Action::OFK_Cuda) {
-CC1Args.push_back("-fcuda-is-device");
+CC1Args.append(
+{"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"});
 
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))


Index: llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
===
--- llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
+++ llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -memcpyopt < %s | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 ; RUN: opt -S -memcpyopt -mtriple=amdgcn-- < %s | FileCheck %s --check-prefixes=CHECK,NO-LIBCALLS
+; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -enable-memcpyopt-without-libcalls < %s \
+; RUN: | FileCheck %s --check-prefixes=CHECK,LIBCALLS
 
 ; REQUIRES: amdgpu-registered-target
 
Index: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
===
--- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -67,6 +67,10 @@
 
 #define DEBUG_TYPE "memcpyopt"
 
+static cl::opt EnableMemCpyOptWithoutLibcalls(
+"enable-memcpyopt-without-libcalls", cl::init(false), cl::Hidden,
+cl::desc("Enable memcpyopt even when libcalls are disabled"));
+
 static cl::opt
 EnableMemorySSA("enable-memcpyopt-memoryssa", cl::init(true), cl::Hidden,
 cl::desc("Use MemorySSA-backed MemCpyOpt."));
@@ -677,8 +681,9 @@
   // the corresponding libcalls are not available.
   // TODO: We should really distinguish between libcall availability and
   // our ability to introduce intrinsics.
-  if (T->isAggregateType() && TLI->has(LibFunc_memcpy) &&
-  TLI->has(LibFunc_memmove)) {
+  if (T->isAggregateType() &&
+  

[PATCH] D101641: [Sema] Preserve invalid CXXCtorInitializers using RecoveryExpr in initializer

2021-08-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Doh, I forgot this never landed :-(




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:4475
   //   name that denotes that base class type.
-  bool Dependent = BaseType->isDependentType() || Init->isTypeDependent();
+  bool Dependent = CurContext->isDependentContext() &&
+   (BaseType->isDependentType() || Init->isTypeDependent());

hokein wrote:
> it is unclear to me why we need a `isDependentContext()` here? looks like 
> this would special-case RecoveryExpr, the following dependent code-path would 
> not be executed for RecoveryExpr case? 
Right, if the init expr is type-dependent because it contains errors, but we're 
not actually in a template, we don't want to take the dependent path.

The reason is that the dependent path produces an "as-written" form of the 
CXXCtorInitializer, which has weaker invariants, because we know we're not 
going to examine it much until template instantiation time.
e.g. an initializer that is actually delegating is stored as a base initializer 
instead. (Thus avoiding the impossible requirement to check whether two 
dependent types are the same).
Later on in Sema::SetCtorInitializers, we check 
`Constructor->isDependentContext()` to decide whether to propagate the 
"as-written" initializers without checking, but of course this is false. So 
then we go and shuffle the initializers into the correct order, build default 
initializers for the uninitialized members etc, and the delegating initializer 
is just... lost in the shuffle. We think it's a base init, so it's put in a map 
of type->init, and then it never gets consumed from there because the type is 
not actually a base class.

I'll try to add a comment that hints at this, without getting into the concrete 
details...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101641

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


[PATCH] D101641: [Sema] Preserve invalid CXXCtorInitializers using RecoveryExpr in initializer

2021-08-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 364846.
sammccall added a comment.

Rebase and add clarifying comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101641

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp

Index: clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
@@ -102,7 +102,9 @@
 struct A { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const A' for 1st argument}} \
 // expected-note{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'A' for 1st argument}} \
 // expected-note{{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
-struct B { };
+struct B { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const B' for 1st argument}} \
+// expected-note{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'B' for 1st argument}} \
+// expected-note{{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
 struct C { };
 struct D { };
 
@@ -123,7 +125,9 @@
 HasMixins::HasMixins(const HasMixins ): Mixins(other)... { }
 
 template
-HasMixins::HasMixins(int i): Mixins(i)... { } // expected-error{{no matching constructor for initialization of 'A'}}
+HasMixins::HasMixins(int i): Mixins(i)... { }
+// expected-error@-1 {{no matching constructor for initialization of 'A'}}
+// expected-error@-2 {{no matching constructor for initialization of 'B'}}
 
 void test_has_mixins() {
   HasMixins ab;
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -606,11 +606,13 @@
 
 namespace dr655 { // dr655: yes
   struct A { A(int); }; // expected-note 2-3{{not viable}}
+// expected-note@-1 {{'dr655::A' declared here}}
   struct B : A {
-A a;
+A a; // expected-note {{member is declared here}}
 B();
 B(int) : B() {} // expected-error 0-1 {{C++11}}
 B(int*) : A() {} // expected-error {{no matching constructor}}
+ // expected-error@-1 {{must explicitly initialize the member 'a'}}
   };
 }
 
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -296,3 +296,54 @@
   // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
   invalid() ? 1 : 2;
 }
+
+void CtorInitializer() {
+  struct S{int m};
+  class MemberInit {
+int x, y;
+S s;
+MemberInit() : x(invalid), y(invalid, invalid), s(1,2) {}
+// CHECK:  CXXConstructorDecl {{.*}} MemberInit 'void ()'
+// CHECK-NEXT: |-CXXCtorInitializer Field {{.*}} 'x' 'int'
+// CHECK-NEXT: | `-ParenListExpr
+// CHECK-NEXT: |   `-RecoveryExpr {{.*}} ''
+// CHECK-NEXT: |-CXXCtorInitializer Field {{.*}} 'y' 'int'
+// CHECK-NEXT: | `-ParenListExpr
+// CHECK-NEXT: |   |-RecoveryExpr {{.*}} ''
+// CHECK-NEXT: |   `-RecoveryExpr {{.*}} ''
+// CHECK-NEXT: |-CXXCtorInitializer Field {{.*}} 's' 'S'
+// CHECK-NEXT: | `-RecoveryExpr {{.*}} 'S' contains-errors
+// CHECK-NEXT: |   |-IntegerLiteral {{.*}} 1
+// CHECK-NEXT: |   `-IntegerLiteral {{.*}} 2
+  };
+  class BaseInit : S {
+BaseInit(float) : S("no match") {}
+// CHECK:  CXXConstructorDecl {{.*}} BaseInit 'void (float)'
+// CHECK-NEXT: |-ParmVarDecl
+// CHECK-NEXT: |-CXXCtorInitializer 'S'
+// CHECK-NEXT: | `-RecoveryExpr {{.*}} 'S'
+// CHECK-NEXT: |   `-StringLiteral
+
+BaseInit(double) : S(invalid) {}
+// CHECK:  CXXConstructorDecl {{.*}} BaseInit 'void (double)'
+// CHECK-NEXT: |-ParmVarDecl
+// CHECK-NEXT: |-CXXCtorInitializer 'S'
+// CHECK-NEXT: | `-ParenListExpr
+// CHECK-NEXT: |   `-RecoveryExpr {{.*}} ''
+  };
+  class DelegatingInit {
+DelegatingInit(float) : DelegatingInit("no match") {}
+// CHECK:  CXXConstructorDecl {{.*}} DelegatingInit 'void (float)'
+// CHECK-NEXT: |-ParmVarDecl
+// CHECK-NEXT: |-CXXCtorInitializer 'DelegatingInit'
+// CHECK-NEXT: | `-RecoveryExpr {{.*}} 'DelegatingInit'
+// CHECK-NEXT: |   `-StringLiteral
+
+DelegatingInit(double) : DelegatingInit(invalid) {}
+// CHECK:  CXXConstructorDecl {{.*}} DelegatingInit 'void (double)'
+// CHECK-NEXT: |-ParmVarDecl
+// CHECK-NEXT: |-CXXCtorInitializer 'DelegatingInit'
+  

[PATCH] D107649: [OpenMP]Fix PR51349: Remove AlwaysInline for if regions.

2021-08-06 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 364844.
jhuber6 added a comment.

Adding test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107649

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/parallel_if_codegen_PR51349.cpp


Index: clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
@@ -0,0 +1,38 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --include-generated-funcs
+// RUN: %clang_cc1 -x c++ -O1 -fopenmp-version=45 -disable-llvm-optzns -verify 
-fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+#pragma omp parallel if(0)
+  ;
+}
+
+#endif
+// CHECK: Function Attrs: mustprogress nounwind
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, i32* [[DOTBOUND_ZERO_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 
@__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:call void @__kmpc_serialized_parallel(%struct.ident_t* 
@[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:store i32 [[TMP0]], i32* [[DOTTHREADID_TEMP_]], align 4, 
!tbaa [[TBAA3:![0-9]+]]
+// CHECK-NEXT:call void @.omp_outlined.(i32* [[DOTTHREADID_TEMP_]], i32* 
[[DOTBOUND_ZERO_ADDR]]) #[[ATTR2:[0-9]+]]
+// CHECK-NEXT:call void @__kmpc_end_serialized_parallel(%struct.ident_t* 
@[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK: Function Attrs: noinline norecurse nounwind
+// CHECK-LABEL: define {{[^@]+}}@.omp_outlined.
+// CHECK-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias 
[[DOTBOUND_TID_:%.*]]) #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK-NEXT:store i32* [[DOTGLOBAL_TID_]], i32** 
[[DOTGLOBAL_TID__ADDR]], align 8, !tbaa [[TBAA7:![0-9]+]]
+// CHECK-NEXT:store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], 
align 8, !tbaa [[TBAA7]]
+// CHECK-NEXT:ret void
+//
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2120,11 +2120,12 @@
 OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
 
 // Ensure we do not inline the function. This is trivially true for the 
ones
-// passed to __kmpc_fork_call but the ones calles in serialized regions
+// passed to __kmpc_fork_call but the ones called in serialized regions
 // could be inlined. This is not a perfect but it is closer to the 
invariant
 // we want, namely, every data environment starts with a new function.
 // TODO: We should pass the if condition to the runtime function and do the
 //   handling there. Much cleaner code.
+OutlinedFn->removeFnAttr(llvm::Attribute::AlwaysInline);
 OutlinedFn->addFnAttr(llvm::Attribute::NoInline);
 RT.emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
 


Index: clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
@@ -0,0 +1,38 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes --include-generated-funcs
+// RUN: %clang_cc1 -x c++ -O1 -fopenmp-version=45 -disable-llvm-optzns -verify -fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+#pragma omp parallel if(0)
+  ;
+}
+
+#endif
+// CHECK: Function Attrs: mustprogress nounwind
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, i32* [[DOTBOUND_ZERO_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:call void @__kmpc_serialized_parallel(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:store i32 [[TMP0]], i32* [[DOTTHREADID_TEMP_]], align 4, !tbaa [[TBAA3:![0-9]+]]
+// CHECK-NEXT:call void @.omp_outlined.(i32* [[DOTTHREADID_TEMP_]], i32* [[DOTBOUND_ZERO_ADDR]]) 

[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:3685
+<< NRA;
+notePreviousDefinition(Old, New->getLocation());
+  }

ah, this isn't quite right.  It replaces warning of the first declaration with 
warning of the first definition.

This should instead use

`Diag(Old->getLocation(), diag::note_previous_declaration);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

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


[clang] dddd524 - Revert "[PowerPC][AIX] Limit attribute aligned to 4096."

2021-08-06 Thread Sean Fertile via cfe-commits

Author: Sean Fertile
Date: 2021-08-06T13:54:50-04:00
New Revision: 524bb8844b225d42c98d381d745d4fd549ea

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

LOG: Revert "[PowerPC][AIX] Limit attribute aligned to 4096."

This reverts commit 5181be344adbf7ba7dffc73526893d4e7750d34c.

Break libcxx type_traits header which uses aligned storage with
alignments greater than 4096. Reverting untill we can fix the header.

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 
clang/test/Sema/aix-attr-aligned-limit.c



diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 5098c3900aeb2..3b3e4a414c78c 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4054,9 +4054,6 @@ void Sema::AddAlignedAttr(Decl *D, const 
AttributeCommonInfo , Expr *E,
   unsigned MaximumAlignment = Sema::MaximumAlignment;
   if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF())
 MaximumAlignment = std::min(MaximumAlignment, 8192u);
-  else if (Context.getTargetInfo().getTriple().isOSAIX())
-MaximumAlignment = std::min(MaximumAlignment, 4096u);
-
   if (AlignVal > MaximumAlignment) {
 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
 << MaximumAlignment << E->getSourceRange();

diff  --git a/clang/test/Sema/aix-attr-aligned-limit.c 
b/clang/test/Sema/aix-attr-aligned-limit.c
deleted file mode 100644
index 3c9a0facf9e54..0
--- a/clang/test/Sema/aix-attr-aligned-limit.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple powerpc64-unknown-aix -fsyntax-only -verify %s
-//
-int a __attribute__((aligned(8192))); // expected-error {{requested alignment 
must be 4096 bytes or smaller}}



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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-06 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec requested changes to this revision.
rampitec added inline comments.
This revision now requires changes to proceed.



Comment at: llvm/lib/CodeGen/AtomicExpandPass.cpp:588
+  Remark
+  << "A hardware CAS loop generated: if the memory is "
+ "known to be coarse-grain allocated then a hardware 
floating-point"

This is target specific. Besides there can be different reasons for a loop.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12123
+OptRemark
+<< "A hardware floating-point atomic instruction generated: "
+   "only safe if the memory is known to be coarse-grain allocated";

This is not the only reason. You cannot use a fixed string here.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12120
+   OptimizationRemarkEmitter *ORE,
+   OptimizationRemark OptRemark) {
+  ORE->emit([&]() { return OptRemark; });

gandhi21299 wrote:
> rampitec wrote:
> > Why OptRemark and not just StringRef? I really want to see as little churn 
> > as possible at the call site.
> With only StringRef, we would also have to pass in RMW since 
> OptimizationRemark constructor depends on that.
It seems better be a lamda where you can just capture most of the stuff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-06 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 364825.
gandhi21299 added a comment.

- changed 'CAS instruction' to 'CAS loop'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/AMDGPU/fp-atomics-remarks-gfx90a.ll
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -16,15 +16,20 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lazy Branch Probability Analysis
+; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -10,13 +10,18 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lazy Branch Probability Analysis
+; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -44,6 +44,11 @@
 ; GCN-O0-NEXT:Lower OpenCL enqueued blocks
 ; GCN-O0-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O0-NEXT:FunctionPass Manager
+; GCN-O0-NEXT:  Dominator Tree Construction
+; GCN-O0-NEXT:  Natural Loop Information
+; GCN-O0-NEXT:  Lazy Branch Probability Analysis
+; GCN-O0-NEXT:  Lazy Block Frequency Analysis
+; GCN-O0-NEXT:  Optimization Remark Emitter
 ; GCN-O0-NEXT:  Expand Atomic instructions
 ; GCN-O0-NEXT:  Lower constant intrinsics
 ; GCN-O0-NEXT:  Remove unreachable blocks from the CFG
@@ -180,6 +185,11 @@
 ; GCN-O1-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-NEXT:FunctionPass Manager
 ; GCN-O1-NEXT:  Infer address spaces
+; GCN-O1-NEXT:  Dominator Tree Construction
+; GCN-O1-NEXT:  Natural Loop Information
+; GCN-O1-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-NEXT:  Optimization Remark Emitter
 ; GCN-O1-NEXT:  Expand Atomic instructions
 ; GCN-O1-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-NEXT:  Dominator Tree Construction
@@ -431,6 +441,11 @@
 ; GCN-O1-OPTS-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-OPTS-NEXT:FunctionPass Manager
 ; GCN-O1-OPTS-NEXT:  Infer address spaces
+; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
+; GCN-O1-OPTS-NEXT:  Natural Loop Information
+; GCN-O1-OPTS-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-OPTS-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-OPTS-NEXT:  Optimization Remark Emitter
 ; GCN-O1-OPTS-NEXT:  Expand 

[PATCH] D107649: [OpenMP]Fix PR51349: Remove AlwaysInline for if regions.

2021-08-06 Thread Mike Rice via Phabricator via cfe-commits
mikerice added a comment.

Works for the test we have.  What about a lit test for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107649

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


[PATCH] D105858: opencl-c.h: add 3.0 optional extension support for a few more bits

2021-08-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105858

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


[PATCH] D105904: [clangd] Support `#pragma mark` in the outline

2021-08-06 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked an inline comment as done.
dgoldman added a comment.

PTAL, also updated the test to no longer check the children's order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105904

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


[PATCH] D105904: [clangd] Support `#pragma mark` in the outline

2021-08-06 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 364840.
dgoldman marked an inline comment as done.
dgoldman added a comment.

Simplify children moving


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105904

Files:
  clang-tools-extra/clangd/CollectMacros.cpp
  clang-tools-extra/clangd/CollectMacros.h
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang/include/clang/Lex/PPCallbacks.h

Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -492,6 +492,11 @@
 Second->PragmaComment(Loc, Kind, Str);
   }
 
+  void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
+First->PragmaMark(Loc, Trivia);
+Second->PragmaMark(Loc, Trivia);
+  }
+
   void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
 StringRef Value) override {
 First->PragmaDetectMismatch(Loc, Name, Value);
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -99,6 +99,8 @@
   return arg.beginOffset() == R.Begin && arg.endOffset() == R.End;
 }
 
+MATCHER_P(PragmaTrivia, P, "") { return arg.Trivia == P; }
+
 MATCHER(EqInc, "") {
   Inclusion Actual = testing::get<0>(arg);
   Inclusion Expected = testing::get<1>(arg);
@@ -886,6 +888,27 @@
   EXPECT_FALSE(mainIsGuarded(AST));
 }
 
+TEST(ParsedASTTest, DiscoversPragmaMarks) {
+  TestTU TU;
+  TU.AdditionalFiles["Header.h"] = R"(
+#pragma mark - Something API
+int something();
+#pragma mark Something else
+  )";
+  TU.Code = R"cpp(
+#include "Header.h"
+#pragma mark In Preamble
+#pragma mark - Something Impl
+int something() { return 1; }
+#pragma mark End
+  )cpp";
+  auto AST = TU.build();
+
+  EXPECT_THAT(AST.getMarks(), ElementsAre(PragmaTrivia(" In Preamble"),
+  PragmaTrivia(" - Something Impl"),
+  PragmaTrivia(" End")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -42,7 +42,7 @@
 MATCHER_P(SymNameRange, Range, "") { return arg.selectionRange == Range; }
 template 
 ::testing::Matcher Children(ChildMatchers... ChildrenM) {
-  return Field(::children, ElementsAre(ChildrenM...));
+  return Field(::children, UnorderedElementsAre(ChildrenM...));
 }
 
 std::vector getSymbols(TestTU , llvm::StringRef Query,
@@ -1027,6 +1027,75 @@
 AllOf(WithName("-pur"), WithKind(SymbolKind::Method));
 }
 
+TEST(DocumentSymbolsTest, PragmaMarkGroups) {
+  TestTU TU;
+  TU.ExtraArgs = {"-xobjective-c++", "-Wno-objc-root-class"};
+  Annotations Main(R"cpp(
+  $DogDef[[@interface Dog
+  @end]]
+
+  $DogImpl[[@implementation Dog
+
+  + (id)sharedDoggo { return 0; }
+
+  #pragma $Overrides[[mark - Overrides
+
+  - (id)init {
+return self;
+  }
+  - (void)bark {}]]
+
+  #pragma $Specifics[[mark - Dog Specifics
+
+  - (int)isAGoodBoy {
+return 1;
+  }]]
+  @]]end  // FIXME: Why doesn't this include the 'end'?
+
+  #pragma $End[[mark - End
+]]
+)cpp");
+  TU.Code = Main.code().str();
+  EXPECT_THAT(
+  getSymbols(TU.build()),
+  UnorderedElementsAre(
+  AllOf(WithName("Dog"), SymRange(Main.range("DogDef"))),
+  AllOf(WithName("Dog"), SymRange(Main.range("DogImpl")),
+Children(AllOf(WithName("+sharedDoggo"),
+   WithKind(SymbolKind::Method)),
+ AllOf(WithName("Overrides"),
+   SymRange(Main.range("Overrides")),
+   Children(AllOf(WithName("-init"),
+  WithKind(SymbolKind::Method)),
+AllOf(WithName("-bark"),
+  WithKind(SymbolKind::Method,
+ AllOf(WithName("Dog Specifics"),
+   SymRange(Main.range("Specifics")),
+   

[PATCH] D107613: [Clang][DiagnosticSemaKinds] combine diagnostic texts

2021-08-06 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 364838.
nickdesaulniers marked 2 inline comments as done.
nickdesaulniers added a comment.

- prefer getAttr to hasAttr+getAttr, remove another diag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107613

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
  clang/test/Sema/internal_linkage.c
  clang/test/SemaCXX/internal_linkage.cpp

Index: clang/test/SemaCXX/internal_linkage.cpp
===
--- clang/test/SemaCXX/internal_linkage.cpp
+++ clang/test/SemaCXX/internal_linkage.cpp
@@ -20,9 +20,9 @@
   };
 };
 
-__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'f4'}}
+__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
-__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'zz'}}
+__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
 namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to}}
 }
Index: clang/test/Sema/internal_linkage.c
===
--- clang/test/Sema/internal_linkage.c
+++ clang/test/Sema/internal_linkage.c
@@ -8,7 +8,7 @@
 
 int var4 __attribute__((common)); // expected-note{{previous definition is here}} expected-note{{conflicting attribute is here}}
 int var4 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
-// expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'var4'}}
+// expected-error{{'internal_linkage' attribute does not appear on the first declaration}}
 
 int var5 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}}
 int var5 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}}
Index: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
@@ -24,8 +24,8 @@
 
 [[noreturn]] int e() { b2(); } // ok
 
-int f(); // expected-note {{declaration missing '[[noreturn]]' attribute is here}}
-[[noreturn]] int f(); // expected-error {{function declared '[[noreturn]]' after its first declaration}}
+int f(); // expected-note {{previous definition is here}}
+[[noreturn]] int f(); // expected-error {{'noreturn' attribute does not appear on the first declaration}}
 int f();
 
 [[noreturn]] int g();
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3353,13 +3353,13 @@
 }
   }
 
-  if (New->hasAttr() &&
-  !Old->hasAttr()) {
-Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
-<< New->getDeclName();
-notePreviousDefinition(Old, New->getLocation());
-New->dropAttr();
-  }
+  if (const auto *ILA = New->getAttr())
+if (!Old->hasAttr()) {
+  Diag(New->getLocation(), diag::err_attribute_missing_on_first_decl)
+  << ILA;
+  notePreviousDefinition(Old, New->getLocation());
+  New->dropAttr();
+}
 
   if (CheckRedeclarationModuleOwnership(New, Old))
 return true;
@@ -3678,12 +3678,12 @@
 //   The first declaration of a function shall specify the noreturn
 //   attribute if any declaration of that function specifies the noreturn
 //   attribute.
-const CXX11NoReturnAttr *NRA = New->getAttr();
-if (NRA && !Old->hasAttr()) {
-  Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
-  Diag(Old->getFirstDecl()->getLocation(),
-   diag::note_noreturn_missing_first_decl);
-}
+if (const auto *NRA = New->getAttr())
+  if (!Old->hasAttr()) {
+Diag(NRA->getLocation(), diag::err_attribute_missing_on_first_decl)
+<< NRA;
+notePreviousDefinition(Old, New->getLocation());
+  }
 
 // C++11 [dcl.attr.depend]p2:
 //   The first declaration of a function shall specify the
@@ -4166,13 +4166,13 @@
 New->dropAttr();
   }
 
-  if (New->hasAttr() &&
-  !Old->hasAttr()) {
-Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
-<< New->getDeclName();
-notePreviousDefinition(Old, New->getLocation());
-

[PATCH] D107624: [clangd] Rename Features.h -> Feature.h to avoid confilct with libstdc++

2021-08-06 Thread Sam McCall 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 rG4ad9ec8a328c: [clangd] Rename Features.h - Feature.h to 
avoid confilct with libstdc++ (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107624

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/Feature.cpp
  clang-tools-extra/clangd/Feature.h
  clang-tools-extra/clangd/Features.cpp
  clang-tools-extra/clangd/Features.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Transport.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -9,8 +9,8 @@
 #include "Annotations.h"
 #include "Config.h"
 #include "Diagnostics.h"
+#include "Feature.h"
 #include "FeatureModule.h"
-#include "Features.h"
 #include "ParsedAST.h"
 #include "Protocol.h"
 #include "SourceCode.h"
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -9,7 +9,7 @@
 #include "Config.h"
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
-#include "Features.h"
+#include "Feature.h"
 #include "TestFS.h"
 #include "clang/Basic/DiagnosticSema.h"
 #include "llvm/ADT/None.h"
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -10,7 +10,7 @@
 #include "CodeComplete.h"
 #include "Config.h"
 #include "ConfigProvider.h"
-#include "Features.h"
+#include "Feature.h"
 #include "PathMapping.h"
 #include "Protocol.h"
 #include "TidyProvider.h"
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#include "Features.h"
+#include "Feature.h"
 #include "Index.pb.h"
 #include "MonitoringService.grpc.pb.h"
 #include "MonitoringService.pb.h"
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -9,7 +9,7 @@
 #include 
 
 #include "Client.h"
-#include "Features.h"
+#include "Feature.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
 #include "marshalling/Marshalling.h"
Index: clang-tools-extra/clangd/Transport.h
===
--- clang-tools-extra/clangd/Transport.h
+++ clang-tools-extra/clangd/Transport.h
@@ -18,7 +18,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
 
-#include "Features.h"
+#include "Feature.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -14,8 +14,8 @@
 #include "Compiler.h"
 #include "Config.h"
 #include "Diagnostics.h"
+#include "Feature.h"
 #include "FeatureModule.h"
-#include "Features.h"
 #include "Headers.h"
 #include "HeuristicResolver.h"
 #include "IncludeFixer.h"
Index: clang-tools-extra/clangd/Feature.h
===
--- clang-tools-extra/clangd/Feature.h
+++ clang-tools-extra/clangd/Feature.h
@@ -1,13 +1,16 @@
-//===--- Features.h - Compile-time configuration --*-C++-*-===//
+//===--- Feature.h - Compile-time configuration --*-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 file is not named "Features.h" because of a 

[clang-tools-extra] 4ad9ec8 - [clangd] Rename Features.h -> Feature.h to avoid confilct with libstdc++

2021-08-06 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-08-06T18:56:41+02:00
New Revision: 4ad9ec8a328ccb3b836c993bba954366f05b2fd4

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

LOG: [clangd] Rename Features.h -> Feature.h to avoid confilct with libstdc++

Fixes https://github.com/clangd/clangd/issues/835

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

Added: 
clang-tools-extra/clangd/Feature.cpp
clang-tools-extra/clangd/Feature.h

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Transport.h
clang-tools-extra/clangd/index/remote/Client.cpp
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 
clang-tools-extra/clangd/Features.cpp
clang-tools-extra/clangd/Features.h



diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 5aee128c9d6b5..476de70654cf9 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -71,7 +71,7 @@ add_clang_library(clangDaemon
   DumpAST.cpp
   ExpectedTypes.cpp
   FeatureModule.cpp
-  Features.cpp
+  Feature.cpp
   FindSymbols.cpp
   FindTarget.cpp
   FileDistance.cpp

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 90d6e1159750a..a9debfd2a6ed5 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -12,7 +12,7 @@
 #include "Diagnostics.h"
 #include "DraftStore.h"
 #include "DumpAST.h"
-#include "Features.h"
+#include "Feature.h"
 #include "GlobalCompilationDatabase.h"
 #include "LSPBinder.h"
 #include "Protocol.h"

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 4eaff343b2290..ad117b3d77be4 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -28,7 +28,7 @@
 #include "ConfigFragment.h"
 #include "ConfigProvider.h"
 #include "Diagnostics.h"
-#include "Features.h"
+#include "Feature.h"
 #include "TidyProvider.h"
 #include "support/Logger.h"
 #include "support/Path.h"

diff  --git a/clang-tools-extra/clangd/Features.cpp 
b/clang-tools-extra/clangd/Feature.cpp
similarity index 93%
rename from clang-tools-extra/clangd/Features.cpp
rename to clang-tools-extra/clangd/Feature.cpp
index d7fba42a3408c..5664a8869bb00 100644
--- a/clang-tools-extra/clangd/Features.cpp
+++ b/clang-tools-extra/clangd/Feature.cpp
@@ -1,4 +1,4 @@
-//===--- Features.cpp - Compile-time configuration 
===//
+//===--- Feature.cpp - Compile-time configuration ===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "Features.h"
+#include "Feature.h"
 #include "clang/Basic/Version.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Host.h"

diff  --git a/clang-tools-extra/clangd/Features.h 
b/clang-tools-extra/clangd/Feature.h
similarity index 68%
rename from clang-tools-extra/clangd/Features.h
rename to clang-tools-extra/clangd/Feature.h
index 1723eb37b3bc1..ba958fc49c020 100644
--- a/clang-tools-extra/clangd/Features.h
+++ b/clang-tools-extra/clangd/Feature.h
@@ -1,13 +1,16 @@
-//===--- Features.h - Compile-time configuration 
--*-C++-*-===//
+//===--- Feature.h - Compile-time configuration --*-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 file is not named "Features.h" because of a conflict with libstdc++:
+// https://github.com/clangd/clangd/issues/835
+//===--===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FEATURES_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FEATURES_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FEATURE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FEATURE_H
 #include 
 
 // Export constants like CLANGD_BUILD_XPC

diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index a60b9b6fe486a..e3fd08afdaa7e 100644
--- 

[PATCH] D107632: [clangd] Avoid "expected one compiler job" by picking the first eligible job.

2021-08-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 364832.
sammccall added a comment.

add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107632

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/UtilsTest.cpp

Index: clang/unittests/Frontend/UtilsTest.cpp
===
--- /dev/null
+++ clang/unittests/Frontend/UtilsTest.cpp
@@ -0,0 +1,37 @@
+//===- unittests/Frontend/UtilsTest.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 "clang/Frontend/Utils.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/TargetOptions.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace {
+
+TEST(BuildCompilerInvocationTest, RecoverMultipleJobs) {
+  // This generates multiple jobs and we recover by using the first.
+  std::vector Args = {"clang", "--target=macho", "-arch",  "i386",
+"-arch", "x86_64", "foo.cpp"};
+  clang::IgnoringDiagConsumer D;
+  llvm::IntrusiveRefCntPtr CommandLineDiagsEngine =
+  clang::CompilerInstance::createDiagnostics(new DiagnosticOptions, ,
+ false);
+  std::unique_ptr CI = createInvocationFromCommandLine(
+  Args, CommandLineDiagsEngine, new llvm::vfs::InMemoryFileSystem(),
+  /*ShouldRecoverOnErrors=*/true);
+  ASSERT_TRUE(CI);
+  EXPECT_THAT(CI->TargetOpts->Triple, testing::StartsWith("i386-"));
+}
+
+} // namespace
+} // namespace clang
Index: clang/unittests/Frontend/CMakeLists.txt
===
--- clang/unittests/Frontend/CMakeLists.txt
+++ clang/unittests/Frontend/CMakeLists.txt
@@ -13,6 +13,7 @@
   PCHPreambleTest.cpp
   OutputStreamTest.cpp
   TextDiagnosticTest.cpp
+  UtilsTest.cpp
   )
 clang_target_link_libraries(FrontendTests
   PRIVATE
Index: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -79,22 +79,24 @@
   }
 }
   }
-  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
-  (Jobs.size() > 1 && !OffloadCompilation)) {
+
+  bool PickFirstOfMany = OffloadCompilation || ShouldRecoverOnErorrs;
+  if (Jobs.size() == 0 || (Jobs.size() > 1 && !PickFirstOfMany)) {
 SmallString<256> Msg;
 llvm::raw_svector_ostream OS(Msg);
 Jobs.Print(OS, "; ", true);
 Diags->Report(diag::err_fe_expected_compiler_job) << OS.str();
 return nullptr;
   }
-
-  const driver::Command  = cast(*Jobs.begin());
-  if (StringRef(Cmd.getCreator().getName()) != "clang") {
+  auto Cmd = llvm::find_if(Jobs, [](const driver::Command ) {
+return StringRef(Cmd.getCreator().getName()) == "clang";
+  });
+  if (Cmd == Jobs.end()) {
 Diags->Report(diag::err_fe_expected_clang_command);
 return nullptr;
   }
 
-  const ArgStringList  = Cmd.getArguments();
+  const ArgStringList  = Cmd->getArguments();
   if (CC1Args)
 *CC1Args = {CCArgs.begin(), CCArgs.end()};
   auto CI = std::make_unique();
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -624,10 +624,8 @@
   ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), );
 
   auto FooCpp = testPath("foo.cpp");
-  // clang cannot create CompilerInvocation if we pass two files in the
-  // CompileCommand. We pass the file in ExtraFlags once and CDB adds another
-  // one in getCompileCommand().
-  CDB.ExtraClangFlags.push_back(FooCpp);
+  // clang cannot create CompilerInvocation in this case.
+  CDB.ExtraClangFlags.push_back("-###");
 
   // Clang can't parse command args in that case, but we shouldn't crash.
   runAddDocument(Server, FooCpp, "int main() {}");
@@ -1080,7 +1078,7 @@
   Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   // This will make compile command broken and preamble absent.
-  CDB.ExtraClangFlags = {"yolo.cc"};
+  CDB.ExtraClangFlags = {"-###"};
   Server.addDocument(FooCpp, Code.code());
   ASSERT_TRUE(Server.blockUntilIdleForTest());
   auto Res = cantFail(runCodeComplete(Server, FooCpp, 

[PATCH] D107632: [clangd] Avoid "expected one compiler job" by picking the first eligible job.

2021-08-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 364829.
sammccall added a comment.
Herald added a subscriber: mgorny.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107632

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
  clang/unittests/Frontend/CMakeLists.txt


Index: clang/unittests/Frontend/CMakeLists.txt
===
--- clang/unittests/Frontend/CMakeLists.txt
+++ clang/unittests/Frontend/CMakeLists.txt
@@ -13,6 +13,7 @@
   PCHPreambleTest.cpp
   OutputStreamTest.cpp
   TextDiagnosticTest.cpp
+  UtilsTest.cpp
   )
 clang_target_link_libraries(FrontendTests
   PRIVATE
Index: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -79,22 +79,24 @@
   }
 }
   }
-  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
-  (Jobs.size() > 1 && !OffloadCompilation)) {
+
+  bool PickFirstOfMany = OffloadCompilation || ShouldRecoverOnErorrs;
+  if (Jobs.size() == 0 || (Jobs.size() > 1 && !PickFirstOfMany)) {
 SmallString<256> Msg;
 llvm::raw_svector_ostream OS(Msg);
 Jobs.Print(OS, "; ", true);
 Diags->Report(diag::err_fe_expected_compiler_job) << OS.str();
 return nullptr;
   }
-
-  const driver::Command  = cast(*Jobs.begin());
-  if (StringRef(Cmd.getCreator().getName()) != "clang") {
+  auto Cmd = llvm::find_if(Jobs, [](const driver::Command ) {
+return StringRef(Cmd.getCreator().getName()) == "clang";
+  });
+  if (Cmd == Jobs.end()) {
 Diags->Report(diag::err_fe_expected_clang_command);
 return nullptr;
   }
 
-  const ArgStringList  = Cmd.getArguments();
+  const ArgStringList  = Cmd->getArguments();
   if (CC1Args)
 *CC1Args = {CCArgs.begin(), CCArgs.end()};
   auto CI = std::make_unique();
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -624,10 +624,8 @@
   ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), );
 
   auto FooCpp = testPath("foo.cpp");
-  // clang cannot create CompilerInvocation if we pass two files in the
-  // CompileCommand. We pass the file in ExtraFlags once and CDB adds another
-  // one in getCompileCommand().
-  CDB.ExtraClangFlags.push_back(FooCpp);
+  // clang cannot create CompilerInvocation in this case.
+  CDB.ExtraClangFlags.push_back("-###");
 
   // Clang can't parse command args in that case, but we shouldn't crash.
   runAddDocument(Server, FooCpp, "int main() {}");
@@ -1080,7 +1078,7 @@
   Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   // This will make compile command broken and preamble absent.
-  CDB.ExtraClangFlags = {"yolo.cc"};
+  CDB.ExtraClangFlags = {"-###"};
   Server.addDocument(FooCpp, Code.code());
   ASSERT_TRUE(Server.blockUntilIdleForTest());
   auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -39,6 +39,7 @@
 
 void IgnoreDiagnostics::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
  const clang::Diagnostic ) {
+  DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
   IgnoreDiagnostics::log(DiagLevel, Info);
 }
 


Index: clang/unittests/Frontend/CMakeLists.txt
===
--- clang/unittests/Frontend/CMakeLists.txt
+++ clang/unittests/Frontend/CMakeLists.txt
@@ -13,6 +13,7 @@
   PCHPreambleTest.cpp
   OutputStreamTest.cpp
   TextDiagnosticTest.cpp
+  UtilsTest.cpp
   )
 clang_target_link_libraries(FrontendTests
   PRIVATE
Index: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -79,22 +79,24 @@
   }
 }
   }
-  if (Jobs.size() == 0 || !isa(*Jobs.begin()) ||
-  (Jobs.size() > 1 && !OffloadCompilation)) {
+
+  bool PickFirstOfMany = OffloadCompilation || ShouldRecoverOnErorrs;
+  if (Jobs.size() == 0 || (Jobs.size() > 1 && !PickFirstOfMany)) {
 SmallString<256> Msg;
 llvm::raw_svector_ostream OS(Msg);
 Jobs.Print(OS, "; ", true);
 Diags->Report(diag::err_fe_expected_compiler_job) << OS.str();
 return nullptr;
   }
-
-  const driver::Command  = cast(*Jobs.begin());
-  if (StringRef(Cmd.getCreator().getName()) != "clang") {
+  

[PATCH] D107632: [clangd] Avoid "expected one compiler job" by picking the first eligible job.

2021-08-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang/lib/Frontend/CreateInvocationFromCommandLine.cpp:92
-  const driver::Command  = cast(*Jobs.begin());
-  if (StringRef(Cmd.getCreator().getName()) != "clang") {
 Diags->Report(diag::err_fe_expected_clang_command);

kadircet wrote:
> hmm, this looks like a subtle behaviour change. I definitely like the 
> behaviour you proposed better, but maybe do it in a separate patch for making 
> the revert easier if need be?
Which behavior change are do you mean?

When RecoverFromErrors is false and OffloadCompilation is false, behavior is 
same as before: if there isn't exactly one job we diagnose that and exit, if 
it's not suitable we diagnose that and exit.

When RecoverFromErrors is true we search for the first suitable job, instead of 
complaining that the number is wrong or the one at the front isn't suitable, 
this is the intended change (and basically only affects clangd).

When OffloadCompilation is true, there is a behavior change: previously we'd 
use the first job and fail if it's not clang, now we'll use the first clang 
job. The old behavior seems brittle and the change only affects (previously) 
error cases, and I'd have to add more complexity to preserve it - is this 
worthwhile?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107632

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


[PATCH] D107648: [OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.

2021-08-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:248
 def warn_option_invalid_ocl_version : Warning<
-  "OpenCL version %0 does not support the option '%1'">, InGroup;
+  "%select{OpenCL C|C++ for OpenCL}0 version %1 does not support the option 
'%2'">, InGroup;
 

Since we have a number of diagnostics now that print the current lang version 
using this pattern do you think we could instead add a helper function that 
prints the full current OpenCL version spelling. We could add something similar 
to `LangOptions::getOpenCLVersionTuple()` so let's say 
`LangOptions::getOpenCLVersionString()` that could use a tuple-helper 
internally. Then we could change such diagnostics to something like:

`%0 does not support the option '%1'`

This could help us simplifying the source code and make sure the diagnostic 
wording is always consistent.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2956
 def err_attribute_requires_opencl_version : Error<
-  "%0 attribute requires OpenCL version %1%select{| or above}2">;
+  "%0 attribute requires %select{OpenCL C|C++ for OpenCL}1 version %2%select{| 
or above}3">;
 def err_invalid_branch_protection_spec : Error<

Let's simplify this to something like:


```
attribute %0 is supported in the OpenCL version %1%select{| onwards}3
```



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10151
 def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
-  "vector component name '%0' is an OpenCL C version 3.0 feature">,
+  "vector component name '%0' is %select{an OpenCL C|a C++ for OpenCL}1 
version %2 feature">,
   InGroup;

How about changing to:

`vector component name '%0' is a feature from OpenCL version 3.0 onwards`

or otherwise, we would need to enumerate all versions where it is supported 
which is not scalable.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7377
+S.Diag(AL.getLoc(), diag::warn_opencl_attr_deprecated_ignored)
+<< AL << 0 << "2.0";
 }

I feel that this condition has assumed OpenCL 2.0 which was not correct. We 
need to render the current version correctly through the 
`LangOptions::getOpenCLVersionTuple()` helper.


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

https://reviews.llvm.org/D107648

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


[PATCH] D107528: [llvm][clang][NFC] updates inline licence info

2021-08-06 Thread Chris Lattner via Phabricator via cfe-commits
lattner accepted this revision.
lattner added a comment.

Thank you for catching this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107528

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-08-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/X86InstrAVX512.td:4478
+  let Predicates = [HasFP16] in {
+def VMOVSHZrr_REV: AVX512<0x11, MRMDestReg, (outs VR128X:$dst),
+(ins VR128X:$src1, VR128X:$src2),

pengfei wrote:
> LuoYuanke wrote:
> > Sorry, I forgot what REV stand for. Do you know it?
> > Is this just encoding difference for register operand compared with 
> > VMOVSHZrr? What is it used for?
> I think REV is short for revert. Which allows a different encoding when 
> operands order are reverted.
> Yes. It's used for a different encoding.
It is short for "reverse". Meaing the operands are in the reversed order. There 
are two valid encodings moving from one register to another. This happens 
because there are separate opcodes for moving register to memory(Store) and 
moving memory to register(load). The memory operand for both of those opcodes 
can be a register as well. The assembler and isel always uses the register to 
register version of the load opcode. The reversed version is only used by the 
disassembler

There is an exception to that. For VEX encoded AVX/AVX2 instructions, 
X86MCInstLowering will use an _REV move if it allows a 2 byte VEX prefix 
instead of a 3 byte VEX prefix. This doesn't apply to any AVX512 instructions 
though. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D106959: [PowerPC] swdiv builtins for XL compatibility

2021-08-06 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-swdiv.c:17
+// CHECK-LABEL: @test_swdiv(
+// CHECK:[[TMP0:%.*]] = load double, double* @a, align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load double, double* @b, align 8

nit: alignment with CHECKs below. Same for the other test cases.



Comment at: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:452
+
+  addPass(createPPCLowerCheckedFPArithPass());
 }

+1, 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106959

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-08-06 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei marked 7 inline comments as done.
pengfei added a comment.

Thanks Yuanke.




Comment at: clang/lib/Headers/avx512fp16intrin.h:292
+
+  return (__m128h)__builtin_ia32_loadsh128_mask((__v8hf *)__A, src, __U & 1);
+}

LuoYuanke wrote:
> Just be curious, why not directly use __W?
First, this is a simple mimic of `_mm_mask_load_ss`.
I think the reason is the intrinsic requests `dst[MAX:16] := 0`, while the 
builtin returns with `src[MAX:16]`.
So we need to explicitly clear the upper bits.



Comment at: clang/lib/Headers/avx512fp16intrin.h:319
+__m512h_u __v;
+  } __attribute__((__packed__, __may_alias__));
+  return ((const struct __loadu_ph *)__p)->__v;

LuoYuanke wrote:
> What is __may_alias__ used for?
This is used for preventing type-based alias analysis.
https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#Common-Type-Attributes

"In the context of section 6.5 paragraph 7 of the C99 standard, an lvalue 
expression dereferencing such a pointer is treated like having a character 
type."
"This extension exists to support some vector APIs, in which pointers to one 
vector type are permitted to alias pointers to a different vector type."



Comment at: clang/lib/Headers/avx512fp16intrin.h:350
+   __m128h __A) {
+  __builtin_ia32_storesh128_mask((__v8hf *)__W, __A, __U & 1);
+}

LuoYuanke wrote:
> I see in _mm_mask_load_sh(), we create a __m128h with upper bits zero, not 
> sure we also need it in store intrinsic.
Both load and store intrinsics only access 16bit memory, the different is the 
load intrinsic needs to set up the high bits of the XMM register (because we do 
return a 128 bits result). We don't need to do that for a store.



Comment at: clang/lib/Headers/avx512fp16intrin.h:419
+static __inline__ short __DEFAULT_FN_ATTRS128 _mm_cvtsi128_si16(__m128i __a) {
+  __v8hi __b = (__v8hi)__a;
+  return __b[0];

LuoYuanke wrote:
> Why not return __a[0] directly?
Because `__m128i` is defined as <2 x i64>. __a[0] is correct only for i64 type.



Comment at: clang/test/CodeGen/X86/avx512fp16-abi.c:89
+  _Float16 a;
+  float b;
+};

LuoYuanke wrote:
> Any false test case that have padding between a and b?
This is the one with padding, since _Float16 aligns to 2 bytes while float 
aligns to 4.



Comment at: llvm/include/llvm/IR/Intrinsics.td:315
 def llvm_v8f16_ty  : LLVMType;//  8 x half (__fp16)
+def llvm_v16f16_ty : LLVMType;   // 16 x half (__fp16)
+def llvm_v32f16_ty : LLVMType;   // 32 x half (__fp16)

LuoYuanke wrote:
> Not sure about the legacy comments, should it be _Float16 now?
LLVM IR serves for not only one type. `__fp16` is still usable in Clang. 
Besides, OpenCL half type also use half in IR. And maybe we have other FE types 
too. So I'd like to keep it as is unless we have a better way to cover all 
other FE types.



Comment at: llvm/include/llvm/Target/TargetSelectionDAG.td:1054
+def extloadvf16 : PatFrag<(ops node:$ptr), (extload node:$ptr)> {
+  let IsLoad = 1;
+  let ScalarMemoryVT = f16;

LuoYuanke wrote:
> I notice it is true for other extload. Is it same to "true"?
Good catch. I noticed it too, but forgot to change it.



Comment at: llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp:341
 if ((insn->mode == MODE_64BIT || (byte1 & 0xc0) == 0xc0) &&
-((~byte1 & 0xc) == 0xc) && ((byte2 & 0x4) == 0x4)) {
+((~byte1 & 0x8) == 0x8) && ((byte2 & 0x4) == 0x4)) {
   insn->vectorExtensionType = TYPE_EVEX;

LuoYuanke wrote:
> This is the same to ((byte1 & 0x8) == 0x0)?
Yes, but I'm not sure if this is intentional. Maybe it keeps the shape in ` & X 
== X`?



Comment at: llvm/lib/Target/X86/X86.td:189
+// guarded under condition hasVLX. So we imply it in FeatureFP16 currently.
+// FIXME: FP16 conversion between f16 and i64 customise type v8i64, which is
+// supposed to be guarded under condition hasDQI. So we imply it in FeatureFP16

LuoYuanke wrote:
> customize?
customise seems correct too. Anyway, I can change it.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:10549
 
-  if (EltVT == MVT::i32 || EltVT == MVT::f32 || EltVT == MVT::f64 ||
-  (EltVT == MVT::i64 && Subtarget.is64Bit())) {
+  if (EltVT == MVT::i32 || EltVT == MVT::f16 || EltVT == MVT::f32 ||
+  EltVT == MVT::f64 || (EltVT == MVT::i64 && Subtarget.is64Bit()) ||

LuoYuanke wrote:
> Need check Subtarget.hasFP16()?
No, f16 is legal here, so it implies the feature.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:10551
+  EltVT == MVT::f64 || (EltVT == MVT::i64 && Subtarget.is64Bit()) ||
+  (EltVT == MVT::i16 && Subtarget.hasFP16())) {

[PATCH] D107461: [PowerPC] Do not define __PRIVILEGED__

2021-08-06 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: clang/test/Driver/ppc-mprivileged-support-check.c:25
+// HASPRIV: test() #0 {
+// HASPRIV: attributes #0 {
+// HASPRIV-SAME: +privileged

maybe check for `attributes #0 = {`  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107461

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


[PATCH] D107506: [PowerPC][AIX] Warn when using pragma align(packed) on AIX.

2021-08-06 Thread Sean Fertile via Phabricator via cfe-commits
sfertile marked an inline comment as done.
sfertile added inline comments.



Comment at: clang/test/Sema/aix-pragma-align-packed-warn.c:13
+  short a : 8;  // expected-warning {{#pragma align(packed) may not be 
compatible with objects generated with AIX XL C/C++}}
+  short b : 8;  // expected-warning {{#pragma align(packed) may not be 
compatible with objects generated with AIX XL C/C++}}
+  int c;

cebowleratibm wrote:
> It's undesirable to warn for each bitfield member.  Perhaps diagnose this in 
> Sema::ActOnTagFinishDefinition?
Thanks for the suggestion Chris, I've moved it as suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107506

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


[PATCH] D107506: [PowerPC][AIX] Warn when using pragma align(packed) on AIX.

2021-08-06 Thread Sean Fertile via Phabricator via cfe-commits
sfertile updated this revision to Diff 364814.
sfertile added a comment.

Fixed diagnostic to only emit when there is a bitfield member.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107506

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/aix-pragma-align-packed-warn.c


Index: clang/test/Sema/aix-pragma-align-packed-warn.c
===
--- /dev/null
+++ clang/test/Sema/aix-pragma-align-packed-warn.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff  -fxl-pragma-pack -verify 
-fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff  -fxl-pragma-pack -verify 
-fsyntax-only %s
+
+#pragma align(packed)
+struct A {  // expected-warning {{#pragma align(packed) may not be compatible 
with objects generated with AIX XL C/C++}}
+  short s1;
+  int   : 0;
+  short s2;
+};
+
+struct B {  // expected-warning {{#pragma align(packed) may not be compatible 
with objects generated with AIX XL C/C++}}
+  short a : 8;
+  short b : 8;
+  int c;
+};
+
+struct C {
+  int x, y, z;
+};
+#pragma align(reset)
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16573,6 +16573,23 @@
   // Notify the consumer that we've defined a tag.
   if (!Tag->isInvalidDecl())
 Consumer.HandleTagDeclDefinition(Tag);
+
+  // Clangs implementation of #pragma align(packed) differs in bitfield layout
+  // from XLs and instead matches the XL #pragma pack(1) behavior.
+  if (Context.getTargetInfo().getTriple().isOSAIX() &&
+  AlignPackStack.hasValue()) {
+AlignPackInfo APInfo = AlignPackStack.CurrentValue;
+// Only diagnose #pragma align(packed).
+if (!APInfo.IsAlignAttr() || APInfo.getAlignMode() != 
AlignPackInfo::Packed)
+  return;
+const RecordDecl *RD = dyn_cast(Tag);
+if (!RD)
+  return;
+// Only warn if there is at least 1 bitfield member.
+if (llvm::any_of(RD->fields(),
+ [](const FieldDecl *FD) { return FD->isBitField(); }))
+  Diag(BraceRange.getBegin(), diag::warn_pragma_align_not_xl_compatible);
+  }
 }
 
 void Sema::ActOnObjCContainerFinishDefinition() {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -913,6 +913,9 @@
   InGroup;
 def err_pragma_options_align_mac68k_target_unsupported : Error<
   "mac68k alignment pragma is not supported on this target">;
+def warn_pragma_align_not_xl_compatible : Warning<
+  "#pragma align(packed) may not be compatible with objects generated with AIX 
XL C/C++">,
+  InGroup;
 def warn_pragma_pack_invalid_alignment : Warning<
   "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
   InGroup;


Index: clang/test/Sema/aix-pragma-align-packed-warn.c
===
--- /dev/null
+++ clang/test/Sema/aix-pragma-align-packed-warn.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff  -fxl-pragma-pack -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff  -fxl-pragma-pack -verify -fsyntax-only %s
+
+#pragma align(packed)
+struct A {  // expected-warning {{#pragma align(packed) may not be compatible with objects generated with AIX XL C/C++}}
+  short s1;
+  int   : 0;
+  short s2;
+};
+
+struct B {  // expected-warning {{#pragma align(packed) may not be compatible with objects generated with AIX XL C/C++}}
+  short a : 8;
+  short b : 8;
+  int c;
+};
+
+struct C {
+  int x, y, z;
+};
+#pragma align(reset)
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16573,6 +16573,23 @@
   // Notify the consumer that we've defined a tag.
   if (!Tag->isInvalidDecl())
 Consumer.HandleTagDeclDefinition(Tag);
+
+  // Clangs implementation of #pragma align(packed) differs in bitfield layout
+  // from XLs and instead matches the XL #pragma pack(1) behavior.
+  if (Context.getTargetInfo().getTriple().isOSAIX() &&
+  AlignPackStack.hasValue()) {
+AlignPackInfo APInfo = AlignPackStack.CurrentValue;
+// Only diagnose #pragma align(packed).
+if (!APInfo.IsAlignAttr() || APInfo.getAlignMode() != AlignPackInfo::Packed)
+  return;
+const RecordDecl *RD = dyn_cast(Tag);
+if (!RD)
+  return;
+// Only warn if there is at least 1 bitfield member.
+if (llvm::any_of(RD->fields(),
+ [](const FieldDecl *FD) { return FD->isBitField(); }))
+  Diag(BraceRange.getBegin(), diag::warn_pragma_align_not_xl_compatible);
+  }
 }
 
 void 

[PATCH] D107553: [C++4OpenCL] Initialize temporaries in the private address space

2021-08-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Sema/Initialization.h:341
+QualType Type = TypeInfo->getType();
+if (Context.getLangOpts().OpenCL && !Type.hasAddressSpace())
+  Type = Context.getAddrSpaceQualType(Type, LangAS::opencl_private);

I wonder if we should instead change the check:

`!Type.hasAddressSpace()`

into an assert?

I also wonder if it makes sense to assert that if it has an address space it 
should be private?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107553

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


[PATCH] D107611: [ARC] Add codegen for llvm.ctlz intrinsic for the ARC backend

2021-08-06 Thread Mark Schimmel via Phabricator via cfe-commits
marksl added inline comments.



Comment at: llvm/lib/Target/ARC/ARCExpandPseudos.cpp:86
+  //   %R2 = RSUB_cc_rru6 %R2, 31, pred:2, %STATUS
+  MachineInstr  = *SII;
+  const MachineOperand  = SI.getOperand(0);

I know you're following ExpandStore above in using "SI" here, but let's switch 
to "MI" as that is the most common practice. I think he used "SI" because it 
was a store instruction. All your readers will recognize MI as a MachineInstr, 
but they will have no such association to SI.



Comment at: llvm/lib/Target/ARC/ARCExpandPseudos.cpp:93
+
+  BuildMI(*SI.getParent(), SI, SI.getDebugLoc(), TII->get(ARC::FLS_f_rr),
+  DestReg)

This is not right. The final instruction of the sequence must write to DestReg.


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

https://reviews.llvm.org/D107611

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


[PATCH] D105426: [clangd] IWYU as a library: Find all references to symbols in the file

2021-08-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this scope looks good for a first patch!




Comment at: clang-tools-extra/clangd/IWYU.cpp:18
+
+/// Main "driver" of the IWYU symbol usage discovery mechanism. Crawler
+/// traverses the AST and feeds in the locations of (sometimes implicitly) used

The first sentence doesn't mean much to me, I think we could just drop it?



Comment at: clang-tools-extra/clangd/IWYU.cpp:63
+  // This is helpful in getFoo().bar(), where Foo must be complete.
+  // FIXME(kirillbobyrev): This is a tricky case that raises a question - 
should
+  // we consider implicit types to be "used"? With auto's it's not so clear.

Is this just "FIXME: should this behavior be configurable or tweaked?"

I think it's clear enough what "this behavior" is in context.
Whereas the rest of the comment adds some confusion (e.g. what's an "implicit 
type", what usage of auto are you talking about etc. And I think it's *way* too 
soon to say that it *should* be configurable - remember the application is 
unused-include, turning this off only grants the ability for headers to be 
marked unused even if they define the type of a subexpression.

I think it's more likely we'd tweak the heuristic in the future, e.g. only do 
this if it's a type that can be incomplete.



Comment at: clang-tools-extra/clangd/IWYU.cpp:73
+if (shouldAdd(T.getTypePtrOrNull())) { // don't care about quals
+  RecursiveASTVisitor::TraverseType(T);
+}

i usually add a private `using Base = ...` and refer to `Base::TraverseType(T)` 
- intent is clearer and often we end up with several of these



Comment at: clang-tools-extra/clangd/IWYU.cpp:95
+
+  bool shouldAdd(const void *P) { return P && Visited.insert(P).second; }
+

this name is a bit vague (why wouldn't we add it?), maybe isNew?



Comment at: clang-tools-extra/clangd/IWYU.h:10
+/// \file
+/// This defines functionality modeled after Include-What-You-Use
+/// (https://include-what-you-use.org/). The variant we implement is not

Related to the naming discussion, this should first say what the functionality 
is (warnings about header hygiene: misuse of transitive headers and unused 
includes).
Then definitely credit the IWYU tool and mention the differences.



Comment at: clang-tools-extra/clangd/IWYU.h:17
+/// FIXME(kirillbobyrev): Add support for IWYU pragmas.
+/// FIXME(kirillbobyrev): Add support for mapping files.
+/// FIXME(kirillbobyrev): Add support for standard library headers.

I'm not sure we want to do this (or plan to do this) unless we have some idea 
of how discovery would work.



Comment at: clang-tools-extra/clangd/IWYU.h:34
+using ReferencedLocations = llvm::DenseSet;
+/// Goes through main file AST and computes all the locations used symbols are
+/// coming from. These locations are later used to determine which headers

Maybe just "Finds locations of all symbols used in the main file"?

If you want to talk about traversal/impl strategy, that's OK but not in the 
first paragraph.



Comment at: clang-tools-extra/clangd/IWYU.h:35
+/// Goes through main file AST and computes all the locations used symbols are
+/// coming from. These locations are later used to determine which headers
+/// should be marked as "used" and "directly used".

I'd be explicit that the returned locations may be macro expansions, and are 
not resolved to their spelling/expansion location.



Comment at: clang-tools-extra/clangd/IWYU.h:38
+///
+/// Because of the clangd limitations, this should be efficient,
+/// hence there is only one AST traversal for the whole process.

I'm not quite sure what this is saying/who the audience for the comment is.
Maybe it's interesting to say something like

We use this to compute unused headers, so:
 - we cover the whole file in a single traversal for efficiency
 - we don't attempt to describe where symbols were referenced from
 - in ambiguous cases (e.g. implicitly used symbols, multiple declarations) we 
err on the side of reporting all possible locations



Comment at: clang-tools-extra/clangd/IWYU.h:41
+///
+/// NOTE: The balance is currently shifted towards considering some of the
+/// implicitly used symbols as "used" for the sake of providing less noisy

It's a bit more general than this (e.g. multiple declaration). See previous 
comment for a wording suggestion



Comment at: clang-tools-extra/clangd/IWYU.h:43
+/// implicitly used symbols as "used" for the sake of providing less noisy
+/// "unused header" diagnostics. However, this should be re-evalated once we
+/// also want to surface "missing header" diagnostics.

I actually don't think we'd use the same entrypoint for missing include, but 

[PATCH] D106644: [clang][analyzer] Add standard streams to alpha.unix.Stream checker.

2021-08-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:504
+
+  OrigStdin = findStdStream("stdin", C);
+  OrigStdout = findStdStream("stdout", C);

balazske wrote:
> steakhal wrote:
> > balazske wrote:
> > > steakhal wrote:
> > > > martong wrote:
> > > > > We should be careful, to cache the results (either here, or deeper in 
> > > > > the call stack).
> > > > > I mean, we certainly don't want to do a lookup of "stdin" every time 
> > > > > a function is evaluated. We should do this lazily, only once.
> > > > I agree. We should do this only for the first top-level function, 
> > > > instead of doing this for every top-level function.
> > > I am not sure if the `SymbolRef` values are safe to store between 
> > > top-level function analyses. The `FILE` type and std stream declarations 
> > > are safe to cache, but the SymbolRef values of these variables probably 
> > > not.
> > I think it should be safe. But place there an assert and run the test 
> > suite. If it won't trigger, that means that we have high confidentiality 
> > that this is safe. I know it's not 100%, but pretty close.
> I tried to check if these `SymbolRef`'s are the same at `checkBeginFunction` 
> after initialized once. The assertion for equality failed sometimes, or other 
> crash happened when `dump` was called on the value. So it looks not safe to 
> cache these. And should we add assumptions about that these `StdinSym`, 
> `StdoutSym`, `StderrSym` are not equal to each other?
Good to know. I don't think it's necessary to add assertions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106644

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


[PATCH] D106644: [clang][analyzer] Add standard streams to alpha.unix.Stream checker.

2021-08-06 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:504
+
+  OrigStdin = findStdStream("stdin", C);
+  OrigStdout = findStdStream("stdout", C);

steakhal wrote:
> balazske wrote:
> > steakhal wrote:
> > > martong wrote:
> > > > We should be careful, to cache the results (either here, or deeper in 
> > > > the call stack).
> > > > I mean, we certainly don't want to do a lookup of "stdin" every time a 
> > > > function is evaluated. We should do this lazily, only once.
> > > I agree. We should do this only for the first top-level function, instead 
> > > of doing this for every top-level function.
> > I am not sure if the `SymbolRef` values are safe to store between top-level 
> > function analyses. The `FILE` type and std stream declarations are safe to 
> > cache, but the SymbolRef values of these variables probably not.
> I think it should be safe. But place there an assert and run the test suite. 
> If it won't trigger, that means that we have high confidentiality that this 
> is safe. I know it's not 100%, but pretty close.
I tried to check if these `SymbolRef`'s are the same at `checkBeginFunction` 
after initialized once. The assertion for equality failed sometimes, or other 
crash happened when `dump` was called on the value. So it looks not safe to 
cache these. And should we add assumptions about that these `StdinSym`, 
`StdoutSym`, `StderrSym` are not equal to each other?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:555
+C.getSValBuilder().makeSymbolVal(StdStream),
+C.getASTContext().getLogicalOperationType());
+Optional NotEqDef =

steakhal wrote:
> `SValBuilder::getConditionType()`, oh they are the same under the hood. We 
> should still probably prefer this one instead.
> It might worth hoisting `C.getSValBuilder()` to a local variable though.
> The symbol for `StdStream` also deserves a separate variable IMO.
This lambda is possible to improve.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106644

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


[PATCH] D107539: [OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images

2021-08-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a subscriber: svenvh.
Anastasia added a comment.

LGTM! Thanks.

CC to @azabaznov for any final feedback.

FYI this has not been officially announced but in `clang-14` we would like to 
transition away from using the huge hard to maintain `opencl-c.h` in favour of 
a more concise and fast to parse Tablegen based approach to declare builtin 
functions: https://clang.llvm.org/docs/OpenCLSupport.html#opencl-builtins. As a 
matter of fact to mature Tablegen-based solution it has been enabled by default 
in `clang-13` without any extra flags 
https://clang.llvm.org/docs/UsersManual.html#opencl-header. And it is therefore 
now a primary header exposed to the application developer in upstream clang.

Since there has not been an announcement yet we don't make it a hard 
requirement yet but it is highly encouraged to mirror any new functionality 
into `OpenCLBuiltins.td`. Conditioning functions as in this patch is usually 
quite straightforward, it just needs an extra clause around builtin 
declarations:

  let Extension =  in {
   ...
  }

And new features/extensions can be registered with:

  def  : FunctionExtension<"macro_name1 macro_name2 ...">;

Here is one example that illustrates the idea https://reviews.llvm.org/D106434

Tablegen-header has full functionality of OpenCL 2.0 so it should be possible 
to extend it to OpenCL 3.0 without significant effort.

Both me and @svenvh would be happy to provide more information and review 
should you decide to help mantaining Tablegen-header in sync with new changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107539

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


[PATCH] D107611: [ARC] Add codegen for llvm.ctlz intrinsic for the ARC backend

2021-08-06 Thread Thomas Johnson via Phabricator via cfe-commits
thomasjohns updated this revision to Diff 364806.
thomasjohns added a comment.

llvm clang-tidy rule: prefer `Register` over `unsinged int`.


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

https://reviews.llvm.org/D107611

Files:
  clang/lib/Basic/Targets/ARC.h
  llvm/lib/Target/ARC/ARCExpandPseudos.cpp
  llvm/lib/Target/ARC/ARCISelLowering.cpp
  llvm/lib/Target/ARC/ARCInstrInfo.td
  llvm/test/CodeGen/ARC/ctlz.ll

Index: llvm/test/CodeGen/ARC/ctlz.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARC/ctlz.ll
@@ -0,0 +1,14 @@
+; RUN: llc -march=arc < %s | FileCheck %s
+
+target triple = "arc"
+
+declare i32 @llvm.ctlz.i32(i32, i1)
+
+; CHECK-LABEL: clz32:
+; CHECK: fls.f   %r0, %r0
+; CHECK: mov.eq  [[R:%r[01]]], 32
+; CHECK: rsub.ne [[R]], [[R]], 31
+define i32 @clz32(i32 %x) {
+  %a = call i32 @llvm.ctlz.i32(i32 %x, i1 false)
+  ret i32 %a
+}
Index: llvm/lib/Target/ARC/ARCInstrInfo.td
===
--- llvm/lib/Target/ARC/ARCInstrInfo.td
+++ llvm/lib/Target/ARC/ARCInstrInfo.td
@@ -133,6 +133,14 @@
  "STB_FAR $dst, $addr",
  [(truncstorei8 GPR32:$dst, AddrModeFar:$addr)]>;
 
+// TODO: Add `Requires<[HasBitScan]>` predicate when available.
+def CTLZ : PseudoInstARC<(outs GPR32:$A),
+ (ins GPR32:$B),
+ "error.fls $A, $B",
+ [(set GPR32:$A, (ctlz i32:$B))]> {
+  let Defs = [STATUS32];
+}
+
 //===--===//
 // Instruction Generation multiclasses.
 // Generate many variants of a single instruction with a single defining
Index: llvm/lib/Target/ARC/ARCISelLowering.cpp
===
--- llvm/lib/Target/ARC/ARCISelLowering.cpp
+++ llvm/lib/Target/ARC/ARCISelLowering.cpp
@@ -135,6 +135,10 @@
 
   // Sign extend inreg
   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Custom);
+
+  // TODO: Predicate with `options.hasBitScan() ? Legal : Expand` when
+  //   the HasBitScan predicate is available.
+  setOperationAction(ISD::CTLZ, MVT::i32, Legal);
 }
 
 const char *ARCTargetLowering::getTargetNodeName(unsigned Opcode) const {
Index: llvm/lib/Target/ARC/ARCExpandPseudos.cpp
===
--- llvm/lib/Target/ARC/ARCExpandPseudos.cpp
+++ llvm/lib/Target/ARC/ARCExpandPseudos.cpp
@@ -13,6 +13,7 @@
 #include "ARCInstrInfo.h"
 #include "ARCRegisterInfo.h"
 #include "ARCSubtarget.h"
+#include "MCTargetDesc/ARCInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -35,6 +36,7 @@
 
 private:
   void ExpandStore(MachineFunction &, MachineBasicBlock::iterator);
+  void ExpandCTLZ(MachineFunction &, MachineBasicBlock::iterator);
 
   const ARCInstrInfo *TII;
 };
@@ -59,8 +61,8 @@
 void ARCExpandPseudos::ExpandStore(MachineFunction ,
MachineBasicBlock::iterator SII) {
   MachineInstr  = *SII;
-  unsigned AddrReg = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
-  unsigned AddOpc =
+  Register AddrReg = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+  Register AddOpc =
   isUInt<6>(SI.getOperand(2).getImm()) ? ARC::ADD_rru6 : ARC::ADD_rrlimm;
   BuildMI(*SI.getParent(), SI, SI.getDebugLoc(), TII->get(AddOpc), AddrReg)
   .addReg(SI.getOperand(1).getReg())
@@ -73,10 +75,45 @@
   SI.eraseFromParent();
 }
 
+void ARCExpandPseudos::ExpandCTLZ(MachineFunction ,
+  MachineBasicBlock::iterator SII) {
+  // Expand:
+  //	%R2 = CTLZ %R0, %STATUS
+  // To:
+  //	%R2 = FLS_f_rr %R0, %STATUS
+  //	%R2 = MOV_cc_ru6 %R2, 32, pred:1, %STATUS
+  //	%R2 = RSUB_cc_rru6 %R2, 31, pred:2, %STATUS
+  MachineInstr  = *SII;
+  const MachineOperand  = SI.getOperand(0);
+  assert(Dest.isReg());
+  const MachineOperand  = SI.getOperand(1);
+  assert(Src.isReg());
+  Register DestReg = Dest.getReg();
+
+  BuildMI(*SI.getParent(), SI, SI.getDebugLoc(), TII->get(ARC::FLS_f_rr),
+  DestReg)
+  .add(Src)
+  .addReg(ARC::STATUS32, RegState::ImplicitDefine);
+
+  Register Ra = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+  Register Rb = MF.getRegInfo().createVirtualRegister(::GPR32RegClass);
+  BuildMI(*SI.getParent(), SI, SI.getDebugLoc(), TII->get(ARC::MOV_cc_ru6), Ra)
+  .addImm(32)
+  .addImm(ARCCC::EQ)
+  .addReg(DestReg);
+  BuildMI(*SI.getParent(), SI, SI.getDebugLoc(), TII->get(ARC::RSUB_cc_rru6),
+  Rb)
+  .addImm(31)
+  .addImm(ARCCC::NE)
+  .addReg(Ra);
+
+  SI.eraseFromParent();
+}
+
 bool ARCExpandPseudos::runOnMachineFunction(MachineFunction ) {
   const ARCSubtarget *STI = ();
   TII = STI->getInstrInfo();
-  bool ExpandedStore = false;
+  bool Expanded = false;
   for (auto  : MF) {
 

[PATCH] D107636: [analyzer][solver] Compute adjustment for unsupported symbols as well

2021-08-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D107636#2931302 , @steakhal wrote:

> Seems reasonable to me. Let's wait for someone else as well.

Sure, NP.

> This is a really elegant patch, I should tell!

Thanks!  I guess my take on this, that this path to the solver just got 
forgotten and that's what produced this inconsistency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107636

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


  1   2   >