[PATCH] D82346: [WebAssebmly] Fully disable 'protected' visibility

2020-06-22 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, aheejin, jgravelle-google, dschuff.
Herald added a project: clang.
sbc100 added a reviewer: dschuff.

Emscripten doesn't use protected visibility either.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82346

Files:
  clang/lib/Basic/Targets/WebAssembly.h


Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -133,11 +133,7 @@
 
   bool hasExtIntType() const override { return true; }
 
-  bool hasProtectedVisibility() const override {
-// TODO: For now, continue to advertise "protected" support for
-// Emscripten targets.
-return getTriple().isOSEmscripten();
-  }
+  bool hasProtectedVisibility() const override { return false; }
 };
 
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo


Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -133,11 +133,7 @@
 
   bool hasExtIntType() const override { return true; }
 
-  bool hasProtectedVisibility() const override {
-// TODO: For now, continue to advertise "protected" support for
-// Emscripten targets.
-return getTriple().isOSEmscripten();
-  }
+  bool hasProtectedVisibility() const override { return false; }
 };
 
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82345: [sve][acle] Implement some of the C intrinsics for brain float.

2020-06-22 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added reviewers: sdesmalen, kmclaughlin, c-rhodes, ctetreau.
Herald added subscribers: llvm-commits, cfe-commits, psnobl, rkruppe, 
hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added projects: clang, LLVM.

The following intrinsics have been extended to support brain float types:

svbfloat16_t svclasta[_bf16](svbool_t pg, svbfloat16_t fallback, svbfloat16_t 
data)
bfloat16_t svclasta[_n_bf16](svbool_t pg, bfloat16_t fallback, svbfloat16_t 
data)
bfloat16_t svlasta[_bf16](svbool_t pg, svbfloat16_t op)

svbfloat16_t svclastb[_bf16](svbool_t pg, svbfloat16_t fallback, svbfloat16_t 
data)
bfloat16_t svclastb[_n_bf16](svbool_t pg, bfloat16_t fallback, svbfloat16_t 
data)
bfloat16_t svlastb[_bf16](svbool_t pg, svbfloat16_t op)

svbfloat16_t svdup[_n]_bf16(bfloat16_t op)
svbfloat16_t svdup[_n]_bf16_m(svbfloat16_t inactive, svbool_t pg, bfloat16_t op)
svbfloat16_t svdup[_n]_bf16_x(svbool_t pg, bfloat16_t op)
svbfloat16_t svdup[_n]_bf16_z(svbool_t pg, bfloat16_t op)

svbfloat16_t svdupq[_n]_bf16(bfloat16_t x0, bfloat16_t x1, bfloat16_t x2, 
bfloat16_t x3, bfloat16_t x4, bfloat16_t x5, bfloat16_t x6, bfloat16_t x7)
svbfloat16_t svdupq_lane[_bf16](svbfloat16_t data, uint64_t index)

svbfloat16_t svinsr[_n_bf16](svbfloat16_t op1, bfloat16_t op2)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82345

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_insr.c
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-dup-bfloat.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-dup-x.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 < %s 2>%t | FileCheck %s
 ; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
 
 ; WARN-NOT: warning
@@ -165,6 +165,14 @@
   ret  %out
 }
 
+define  @insr_bf16( %a, bfloat %b) {
+; CHECK-LABEL: insr_bf16:
+; CHECK: insr z0.h, h1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv8bf16( %a, bfloat %b)
+  ret  %out
+}
+
 define  @insr_f32( %a, float %b) {
 ; CHECK-LABEL: insr_f32:
 ; CHECK: insr z0.s, s1
@@ -348,6 +356,7 @@
 declare  @llvm.aarch64.sve.insr.nxv4i32(, i32)
 declare  @llvm.aarch64.sve.insr.nxv2i64(, i64)
 declare  @llvm.aarch64.sve.insr.nxv8f16(, half)
+declare  @llvm.aarch64.sve.insr.nxv8bf16(, bfloat)
 declare  @llvm.aarch64.sve.insr.nxv4f32(, float)
 declare  @llvm.aarch64.sve.insr.nxv2f64(, double)
 
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 < %s 2>%t | FileCheck %s
 ; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
 
 ; WARN-NOT: warning
@@ -57,6 +57,16 @@
   ret  %out
 }
 
+define  @dup_bf16( %a,  %pg, bfloat %b) {
+; CHECK-LABEL: dup_bf16:
+; CHECK: mov z0.h, p0/m, h1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dup.nxv8bf16( %a,
+ %pg,
+bfloat %b)
+  ret  %out
+}
+
 define  @dup_f32( %a,  %pg, float %b) {
 ; CHECK-LABEL: dup_f32:
 ; CHECK: mov z0.s, p0/m, s1
@@ -82,5 +92,6 @@
 declare  @llvm.aarch64.sve.dup.nxv4i32(, , i32)
 declare  @llvm.aarch64.sve.dup.nxv2i64(, , i64)
 declare  @llvm.aarch64.sve.dup.nxv8f16(, , half)
+declare  @llvm.aarch64.sve.dup.nxv8bf16(, , bfloat)
 declare  @llvm.aarch64.sve.dup.nxv4f32(, , float)
 declare  @llvm.aarch64.sve.dup.nxv2f64(, , double)
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 < %s 2>%t | FileCheck %s
 ; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
 
 ; WARN-NOT: warning
@@ -57,6 +57,16 @@
   ret  %out
 }
 

[PATCH] D81836: [PowerPC][Power10] Implement Vector Permute Builtins in LLVM/Clang

2020-06-22 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang added a comment.

This is a huge patch. I suggest you to split them into small ones for each kind 
of builtins, so that, it would be more easy to review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81836



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


[PATCH] D81869: Modify FPFeatures to use delta not absolute settings to solve PCH compatibility problems

2020-06-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:620
+//unsigned FPFeatures : 21;
+unsigned FPFeatures : 32;
   };

riccibruno wrote:
> mibintc wrote:
> > This is a temporary change, I know you don't want me to change the assert 
> > to allow a wider size than 8. So if this information is really needed (as I 
> > mentioned above it's not being used in Sema or Codegen) then alternatives 
> > are
> > 1. rewrite the == comparison using BinaryOperator
> > 2. put the FPFeatures Override into TrailingStorage (i think i will need 
> > implementation guidance if this is the path to go)
> What do you mean by `rewrite the == comparison using BinaryOperator`? If you 
> mean representing overloaded `operator==`'s by `BinaryOperator`, then that's 
> certainly not right because `BinaryOperator`s only represent binary builtin 
> operators.
> 
> You will not be able to use `TrailingObjects` with `CXXOperatorCallExpr` 
> because `CallExpr` stores its arguments after the object containing the 
> `CallExpr` sub-object. You could manually stash it after `CallExpr`'s 
> arguments, but that would be pretty ugly.
> 
> Do you really need 32-bits worth of FP options? I see from `FPOptions.def` 
> that you need 14 bits, so it should fit with room to spare.
Bruno's close to right.  The key question here is what node we use to represent 
dependent operators that might instantiate to a builtin floating-point 
operator, and the answer for binary operators (based on the code in 
`Sema::CreateOverloadedBinOp`) is that we use `CXXOperatorCallExpr` if lexical 
lookup found any matching operators (because we need some way to represent the 
operators, which `BinaryOperator` doesn't have) and otherwise we use 
`BinaryOperator`.

So, first, to create a test that depends on this, you need a dependent operator 
for which there is an overload in lexical scope, and then it needs to 
instantiate to just do a builtin operation, and this needs to be sensitive to 
the currently-active FP settings.  So maybe something like:

```
struct Distance {};
Distance operator+(Distance, Distance);

template  T add(T lhs, T rhs) {
#pragma STDC FENV_ACCESS on // or whatever pragma you like, doesn't have to be 
local, just has to override current settings and be different from the default
  return lhs + rhs;
}

float test() {
  return add(1.0f, 2.0f);
}
```

Second, how to represent this: while I think there would be some benefits from 
introducing a new `Expr` subclass that we always use to represent a dependent 
operator, I think it's fine (and certainly easier) to just stick with 
`CXXOperatorCallExpr` like we do now.  Given that, you can either follow 
Bruno's advice and use fewer bits — which is probably a fairly short-term fix, 
since tracking almost any extra state would get us into trouble — or figure out 
some other way to store these.

Honestly, it's not the end of the world if `CXXOperatorCallExpr` just stores an 
`FPOptionsOverride` as an ordinary field — it just means we're not taking 
advantage of the fact that most contexts don't have overrides.  Most instances 
of this operator are in dependent code where we can't know that we won't 
instantiate to a builtin operator, so there's no way to avoid storing the 
overrides if there are any.

If we do want to store FP features in trailing storage, then we're going to 
have to worry about the fact that `CallExpr` already has trailing storage.  I 
think the right approach in this case is to have `CallExpr` generally account 
for the overrides in its trailing storage and then, dynamically, we know that 
that only actually happens with `CXXOperatorCallExpr` — all the other factories 
pass down empty overrides.  One specific advantage of this is that it sets the 
stage for storing overrides on calls to builtins; we'd just need Sema to pass 
overrides down when it's building a builtin call.  (We can rely on this even in 
templates because you can't invoke a builtin indirectly or by instantiation.)



Comment at: clang/include/clang/Basic/LangOptions.h:455
+  llvm::errs() << "\n RoundingMode " <<
+static_cast(getRoundingMode());
+  llvm::errs() << "\n FPExceptionMode " << getFPExceptionMode();

riccibruno wrote:
> mibintc wrote:
> > Using #define OPTION trick would be preferrable except there is a 
> > compilation failure because something funny about RoundingMode--need the 
> > cast. doubtless there is fix for that
> Yes it would be preferable and it should not be in a header too.
> 
> You need the cast because `RoundingMode` is a scoped enumeration, which does 
> not have the implicit conversions of unscoped enumerations.
Putting a cast to `unsigned` in the `#define OPTION` should be fine; if any of 
these fields outgrow that, we probably need to reconsider the representation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.o

[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-22 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

> Could you give an example to demonstrate current use and how it will break?

Here is place where it would break:

https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/blob/develop/src/targets/gpu/device/include/migraphx/gpu/device/multi_index.hpp#L129

This change was already included in a fork of llvm in rocm 3.5 and 3.6 releases 
which is why this compiles. This also compiles using the hcc-based hip 
compilers which is what previous rocm versions used. It would be best if this 
can be upstreamed, so we dont have to hold on to these extra changes in a fork.

Part of the motivation for this change was that it wasn't always clear in code 
where the `__device__` attribute is needed with lambdas sometimes. It also 
makes it more consistent with `constexpr` lambdas and hcc-based hip compiler. 
Including this for capturing lambdas will make this simpler and easier to 
understand.

If there are concerns about making it default for capturing lambdas, then can 
we at least just have a flag to enable this for capturing lambdas?


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

https://reviews.llvm.org/D78655



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


Buildbot numbers for the week of 06/14/2020 - 06/20/2020

2020-06-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 06/14/2020 -
06/20/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   |  was_red
-+--
 llvm-clang-win-x-armv7l | 139:09:35
 lld-x86_64-freebsd  | 109:33:39
 mlir-nvidia | 96:23:08
 lldb-aarch64-ubuntu | 62:38:08
 libcxx-libcxxabi-libunwind-aarch64-linux| 58:02:39
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions | 48:08:45
 sanitizer-x86_64-linux  | 41:50:09
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions | 41:15:51
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions   | 40:32:36
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   | 39:20:33
 clang-x64-windows-msvc  | 28:57:51
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 26:51:32
 libcxx-libcxxabi-libunwind-armv8-linux  | 14:10:40
 llvm-clang-win-x-aarch64| 13:07:44
 clang-ppc64le-linux-multistage  | 12:50:05
 sanitizer-x86_64-linux-fast | 12:29:31
 sanitizer-x86_64-linux-bootstrap-ubsan  | 11:14:41
 ppc64le-lld-multistage-test | 09:41:16
 clang-ppc64le-linux-lnt | 09:25:03
 lldb-x64-windows-ninja  | 09:20:27
 clang-cmake-thumbv7-full-sh | 08:40:11
 clang-ppc64be-linux-multistage  | 08:37:09
 clang-s390x-linux-lnt   | 07:56:57
 clang-ppc64be-linux-lnt | 07:38:35
 clang-cmake-armv7-full  | 07:35:32
 clang-ppc64be-linux | 07:26:42
 lld-x86_64-darwin   | 07:23:31
 lld-x86_64-win  | 07:12:53
 clang-ppc64le-rhel  | 07:09:26
 fuchsia-x86_64-linux| 07:02:39
 clang-cmake-armv7-lnt   | 06:43:15
 clang-cmake-aarch64-quick   | 06:38:22
 clang-s390x-linux-multistage| 06:31:27
 clang-cmake-aarch64-global-isel | 06:22:09
 clang-ppc64le-linux | 06:08:04
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan   | 05:57:49
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan  | 05:57:28
 clang-s390x-linux   | 05:57:21
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan   | 05:57:19
 libcxx-libcxxabi-x86_64-linux-debian| 05:56:19
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian | 05:55:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 05:55:20
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11  | 05:54:50
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 05:54:28
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit  | 05:53:53
 clang-cmake-aarch64-lld | 05:53:53
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03  | 05:53:39
 libcxx-libcxxabi-libunwind-x86_64-linux-debian  | 05:53:04
 clang-cmake-armv7-global-isel   | 05:52:05
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 05:51:46
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu  | 05:51:44
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17  | 05:46:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14  | 05:42:43
 clang-cmake-armv7-quick | 05:41:26
 clang-cmake-armv8-lld   | 05:00:27
 flang-aarch64-ubuntu| 04:58:42
 clang-cmake-aarch64-full| 04:51:41
 sanitizer-ppc64le-linux | 04:48:07
 clang-with-thin-lto-ubuntu  | 03:28:45
 aosp-O3-polly-before-vectorizer-unprofitable| 03:27:28
 clang-cmake-armv7-selfhost  | 03:25:47
 sanitizer-ppc64be-linux | 03:22:10
 clang-nati

Buildbot numbers for the week of 06/7/2020 - 06/13/2020

2020-06-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 06/7/2020 - 06/13/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
 buildername | was_red
-+-
 sanitizer-x86_64-linux-android  | 97:09:18
 clang-cmake-thumbv7-full-sh | 86:10:53
 clang-cmake-armv7-full  | 63:59:05
 llvm-clang-win-x-armv7l | 63:20:01
 sanitizer-ppc64le-linux | 47:55:21
 clang-ppc64le-linux-lnt | 47:41:34
 clang-ppc64be-linux-lnt | 47:04:18
 clang-ppc64le-rhel  | 46:46:40
 clang-cmake-armv8-lld   | 41:12:19
 clang-cmake-armv7-selfhost  | 39:19:22
 clang-cmake-aarch64-global-isel | 39:14:51
 clang-cmake-armv7-global-isel   | 39:08:37
 clang-cmake-aarch64-lld | 38:59:24
 clang-cmake-aarch64-quick   | 38:16:32
 clang-cmake-aarch64-full| 37:56:25
 clang-ppc64be-linux-multistage  | 37:48:06
 clang-cmake-armv7-quick | 36:21:06
 sanitizer-x86_64-linux  | 36:19:46
 sanitizer-windows   | 34:31:26
 libcxx-libcxxabi-libunwind-aarch64-linux| 29:45:57
 flang-aarch64-ubuntu| 24:51:02
 lldb-x64-windows-ninja  | 24:23:45
 clang-x64-windows-msvc  | 24:19:53
 sanitizer-x86_64-linux-bootstrap| 23:33:08
 sanitizer-x86_64-linux-bootstrap-ubsan  | 23:03:53
 sanitizer-x86_64-linux-bootstrap-msan   | 22:15:04
 libcxx-libcxxabi-libunwind-armv7-linux  | 16:43:02
 sanitizer-x86_64-linux-fast | 16:42:18
 clang-with-lto-ubuntu   | 16:12:09
 clang-s390x-linux-multistage| 15:14:48
 clang-with-thin-lto-ubuntu  | 14:59:56
 clang-ppc64le-linux-multistage  | 14:17:26
 llvm-avr-linux  | 14:11:20
 clang-s390x-linux   | 14:10:42
 clang-s390x-linux-lnt   | 14:10:31
 clang-ppc64be-linux | 13:51:58
 sanitizer-ppc64be-linux | 13:46:01
 llvm-clang-x86_64-expensive-checks-win  | 12:17:34
 fuchsia-x86_64-linux| 12:03:48
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions | 11:48:36
 ppc64le-lld-multistage-test | 10:40:02
 flang-aarch64-ubuntu-clang  | 08:55:47
 clang-x86_64-debian-new-pass-manager-fast   | 06:59:08
 mlir-nvidia | 06:56:01
 clang-x86_64-debian-fast| 06:53:01
 lld-x86_64-ubuntu-fast  | 06:39:02
 ml-opt-dev-x86-64   | 05:59:25
 llvm-clang-x86_64-expensive-checks-ubuntu   | 05:55:18
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions | 05:30:34
 lld-x86_64-win  | 05:12:23
 lld-x86_64-darwin   | 04:53:16
 clang-ppc64le-linux | 04:42:12
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 04:11:04
 libc-x86_64-debian-dbg  | 04:10:47
 libc-x86_64-debian  | 03:29:58
 aosp-O3-polly-before-vectorizer-unprofitable| 03:25:49
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan   | 02:55:56
 clang-cmake-x86_64-avx2-linux   | 02:52:19
 mlir-windows| 02:51:03
 llvm-clang-win-x-aarch64| 02:42:32
 llvm-clang-x86_64-expensive-checks-debian   | 02:41:05
 llvm-clang-x86_64-win-fast  | 02:39:01
 ml-opt-rel-x86-64   | 02:35:30
 clang-cmake-x86_64-sde-avx512-linux | 02:34:34
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 02:29:56
 sanitizer-x86_64-linux-fuzzer   | 02:24:46
 lldb-x86_64-debian  

[clang] 2a3b86c - Fix rejects-valid when referencing an implicit operator== from within a

2020-06-22 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-22T20:19:20-07:00
New Revision: 2a3b86c157166f3b15f718443334ab0e27b40592

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

LOG: Fix rejects-valid when referencing an implicit operator== from within a
templated class.

When a defaulted operator<=> results in the injection of a defaulted
operator==, that operator== can be named by unqualified name within the
same class, even if the class is templated. To make this work, perform
the transform from defaulted operator<=> to defaulted operator== in the
template definition context instead of the template instantiation
context.

This results in our substituting into a declaration from a context where
we don't have a full list of template arguments (or indeed any), for
which we are now more careful to not spuriously instantiate declarations
that are not dependent on the arguments we're substituting.

Added: 
clang/test/SemaTemplate/defaulted.cpp

Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Template.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/PCH/cxx2a-defaulted-comparison.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index ba84f27617f5..5e00be35d8ce 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -66,6 +66,7 @@ class SourceManager;
 class Stmt;
 class StoredDeclsMap;
 class TemplateDecl;
+class TemplateParameterList;
 class TranslationUnitDecl;
 class UsingDirectiveDecl;
 
@@ -862,6 +863,10 @@ class alignas(8) Decl {
   // within the scope of a template parameter).
   bool isTemplated() const;
 
+  /// Determine the number of levels of template parameter surrounding this
+  /// declaration.
+  unsigned getTemplateDepth() const;
+
   /// isDefinedOutsideFunctionOrMethod - This predicate returns true if this
   /// scoped decl is defined outside the current function or method.  This is
   /// roughly global variables and functions, but also handles enums (which
@@ -1038,8 +1043,16 @@ class alignas(8) Decl {
 
   /// If this is a declaration that describes some template, this
   /// method returns that template declaration.
+  ///
+  /// Note that this returns nullptr for partial specializations, because they
+  /// are not modeled as TemplateDecls. Use getDescribedTemplateParams to 
handle
+  /// those cases.
   TemplateDecl *getDescribedTemplate() const;
 
+  /// If this is a declaration that describes some template or partial
+  /// specialization, this returns the corresponding template parameter list.
+  const TemplateParameterList *getDescribedTemplateParams() const;
+
   /// Returns the function itself, or the templated function if this is a
   /// function template.
   FunctionDecl *getAsFunction() LLVM_READONLY;

diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 741de48a5d24..91d175fdd050 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -121,6 +121,10 @@ enum class TemplateSubstitutionKind : char {
   return TemplateArgumentLists.size();
 }
 
+unsigned getNumRetainedOuterLevels() const {
+  return NumRetainedOuterLevels;
+}
+
 /// Determine how many of the \p OldDepth outermost template parameter
 /// lists would be removed by substituting these arguments.
 unsigned getNewDepth(unsigned OldDepth) const {
@@ -185,6 +189,9 @@ enum class TemplateSubstitutionKind : char {
 void addOuterRetainedLevel() {
   ++NumRetainedOuterLevels;
 }
+void addOuterRetainedLevels(unsigned Num) {
+  NumRetainedOuterLevels += Num;
+}
 
 /// Retrieve the innermost template argument list.
 const ArgList &getInnermost() const {

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 2aab53f4fa90..a9cd7918da9b 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -240,6 +240,16 @@ TemplateDecl *Decl::getDescribedTemplate() const {
   return nullptr;
 }
 
+const TemplateParameterList *Decl::getDescribedTemplateParams() const {
+  if (auto *TD = getDescribedTemplate())
+return TD->getTemplateParameters();
+  if (auto *CTPSD = dyn_cast(this))
+return CTPSD->getTemplateParameters();
+  if (auto *VTPSD = dyn_cast(this))
+return VTPSD->getTemplateParameters();
+  return nullptr;
+}
+
 bool Decl::isTemplated() const {
   // A declaration is dependent if it is a template or a template pattern, or
   // is within (lexcially for a friend, semantically otherwise) a dependent
@@ -248,7 +258,29 @@ bool Decl::isTemplated() const {
   if (auto *AsDC = dyn_cast(this))
 return 

Buildbot numbers for the week of 05/31/2020 - 06/6/2020

2020-06-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 05/31/2020 - 06/6/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  |  was_red
---+--
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 130:46:04
 libcxx-libcxxabi-libunwind-armv7-linux| 128:34:27
 libcxx-libcxxabi-libunwind-armv8-linux| 119:51:43
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 119:51:27
 lldb-aarch64-ubuntu   | 85:07:44
 libcxx-libcxxabi-libunwind-aarch64-linux  | 78:49:23
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 78:49:11
 clang-cmake-armv7-full| 57:30:48
 clang-cmake-thumbv7-full-sh   | 54:47:21
 clang-cmake-armv7-selfhost-neon   | 45:51:59
 clang-cmake-armv7-global-isel | 45:48:34
 clang-cmake-armv7-quick   | 44:59:01
 clang-cmake-armv8-lld | 44:42:21
 clang-cmake-armv7-selfhost| 43:43:49
 sanitizer-x86_64-linux-android| 21:04:16
 lldb-x64-windows-ninja| 20:20:08
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 20:18:17
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 19:13:15
 clang-with-thin-lto-ubuntu| 18:45:48
 clang-with-lto-ubuntu | 17:29:42
 clang-ppc64le-linux-multistage| 16:44:14
 clang-cmake-x86_64-avx2-linux | 15:43:00
 clang-cmake-x86_64-sde-avx512-linux   | 15:09:26
 sanitizer-x86_64-linux-fast   | 12:59:34
 ppc64le-lld-multistage-test   | 12:57:29
 sanitizer-x86_64-linux-bootstrap-ubsan| 12:47:19
 clang-ppc64be-linux-lnt   | 12:32:25
 clang-ppc64be-linux-multistage| 12:30:16
 lld-x86_64-ubuntu-fast| 12:27:09
 clang-ppc64be-linux   | 12:21:08
 llvm-clang-x86_64-expensive-checks-ubuntu | 12:20:23
 clang-s390x-linux | 12:05:09
 clang-s390x-linux-lnt | 12:00:35
 clang-ppc64le-linux-lnt   | 11:10:13
 clang-s390x-linux-multistage  | 10:41:43
 clang-ppc64le-linux   | 10:39:05
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 09:02:11
 llvm-avr-linux| 08:10:14
 clang-cmake-aarch64-full  | 07:20:19
 clang-cmake-aarch64-quick | 07:13:06
 clang-cmake-aarch64-lld   | 07:04:08
 clang-cmake-aarch64-global-isel   | 06:59:13
 flang-aarch64-ubuntu  | 06:57:19
 fuchsia-x86_64-linux  | 06:49:56
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 06:46:43
 llvm-clang-win-x-aarch64  | 06:44:40
 clang-x64-windows-msvc| 06:34:33
 llvm-clang-win-x-armv7l   | 06:22:37
 sanitizer-ppc64le-linux   | 06:07:35
 lld-x86_64-win| 05:48:59
 clang-x86_64-debian-new-pass-manager-fast | 05:36:21
 sanitizer-x86_64-linux| 05:33:20
 lldb-arm-ubuntu   | 04:47:51
 llvm-clang-x86_64-expensive-checks-win| 04:47:19
 lldb-x86_64-debian| 04:20:00
 aosp-O3-polly-before-vectorizer-unprofitable  | 03:52:57
 sanitizer-x86_64-linux-fuzzer | 03:21:32
 sanitizer-ppc64be-linux   | 03:08:57
 sanitizer-x86_64-linux-bootstrap-msan | 03:02:43
 clang-x86_64-debian-fast  | 02:49:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 02:25:41
 llvm-clang-x86_64-expensive-checks-debian | 02:04:31
 llvm-clang-x86_64-win-fast| 01:48:27
 sanitizer-windows | 01:45:50
 clang-armv

Buildbot numbers for the week of 05/24/2020 - 05/30/2020

2020-06-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 05/24/2020 - 05/30/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  |  was_red
---+--
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 104:15:31
 libcxx-libcxxabi-libunwind-armv8-linux| 104:13:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 54:26:53
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11   | 54:23:17
 libcxx-libcxxabi-libunwind-armv7-linux| 54:05:53
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 54:05:17
 sanitizer-x86_64-linux-bootstrap-ubsan| 53:58:07
 sanitizer-x86_64-linux-fast   | 52:55:14
 libcxx-libcxxabi-libunwind-aarch64-linux  | 51:40:22
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 51:38:41
 clang-cmake-armv7-full| 41:13:18
 llvm-clang-win-x-armv7l   | 39:58:13
 clang-cmake-thumbv7-full-sh   | 34:30:45
 llvm-clang-x86_64-expensive-checks-ubuntu | 20:44:02
 mlir-nvidia   | 20:09:29
 llvm-clang-x86_64-expensive-checks-win| 19:58:21
 llvm-clang-x86_64-expensive-checks-debian | 18:54:54
 aosp-O3-polly-before-vectorizer-unprofitable  | 15:59:54
 clang-ppc64le-linux-multistage| 12:46:42
 mlir-windows  | 09:04:43
 clang-ppc64le-linux-lnt   | 07:38:31
 clang-x64-windows-msvc| 06:25:33
 clang-cmake-armv7-selfhost| 05:58:41
 sanitizer-x86_64-linux| 05:54:05
 sanitizer-x86_64-linux-bootstrap  | 05:33:29
 clang-with-thin-lto-ubuntu| 05:20:51
 clang-with-lto-ubuntu | 05:12:03
 sanitizer-ppc64le-linux   | 05:02:45
 ppc64le-lld-multistage-test   | 05:02:34
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 05:00:44
 sanitizer-x86_64-linux-autoconf   | 04:48:19
 lld-x86_64-win| 04:47:59
 clang-cmake-aarch64-lld   | 04:47:52
 clang-cmake-armv7-global-isel | 04:30:28
 lldb-arm-ubuntu   | 04:30:04
 clang-cmake-armv7-quick   | 04:20:49
 clang-ppc64le-rhel| 04:16:59
 clang-cmake-armv8-lld | 04:16:10
 clang-s390x-linux | 04:13:31
 clang-cmake-armv7-selfhost-neon   | 04:00:38
 clang-cmake-aarch64-full  | 03:54:45
 clang-cmake-aarch64-quick | 03:51:06
 clang-cmake-aarch64-global-isel   | 03:48:13
 clang-cmake-x86_64-avx2-linux | 03:46:43
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 03:43:45
 clang-ppc64be-linux-multistage| 03:39:06
 clang-ppc64be-linux-lnt   | 03:36:42
 sanitizer-x86_64-linux-bootstrap-msan | 03:36:35
 fuchsia-x86_64-linux  | 03:33:46
 clang-x86_64-debian-fast  | 03:33:10
 clang-cmake-x86_64-sde-avx512-linux   | 03:33:06
 clang-x86_64-debian-new-pass-manager-fast | 03:30:37
 lld-x86_64-darwin | 03:30:24
 clang-ppc64be-linux   | 03:29:52
 lld-x86_64-freebsd| 03:27:43
 flang-aarch64-ubuntu  | 03:27:16
 llvm-avr-linux| 03:23:14
 llvm-clang-win-x-aarch64  | 03:15:53
 sanitizer-ppc64be-linux   | 03:09:46
 lld-x86_64-ubuntu-fast| 02:56:52
 clang-s390x-linux-lnt | 02:49:00
 clang-ppc64le-linux   | 02:39:52
 clang-s390x-linux-multistage  | 02:34:43
 sanitizer-x86_64-linux-android| 02:16:02
 lldb-x64-wi

[PATCH] D81774: [PowerPC][Power10] Implement VSX PCV Generate Operations in LLVM/Clang

2020-06-22 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19df9e2959cf: [PowerPC][Power10] Implement VSX PCV Generate 
Operations in LLVM/Clang (authored by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D81774?vs=270535&id=272589#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81774

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vsx-pcv.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -15,6 +15,18 @@
 # CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
 # CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
 pextd 1, 2, 4
+# CHECK-BE: xxgenpcvbm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x28]
+# CHECK-LE: xxgenpcvbm 0, 1, 2# encoding: [0x28,0x0f,0x02,0xf0]
+xxgenpcvbm 0, 1, 2
+# CHECK-BE: xxgenpcvhm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x2a]
+# CHECK-LE: xxgenpcvhm 0, 1, 2# encoding: [0x2a,0x0f,0x02,0xf0]
+xxgenpcvhm 0, 1, 2
+# CHECK-BE: xxgenpcvwm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x68]
+# CHECK-LE: xxgenpcvwm 0, 1, 2# encoding: [0x68,0x0f,0x02,0xf0]
+xxgenpcvwm 0, 1, 2
+# CHECK-BE: xxgenpcvdm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x6a]
+# CHECK-LE: xxgenpcvdm 0, 1, 2# encoding: [0x6a,0x0f,0x02,0xf0]
+xxgenpcvdm 0, 1, 2
 # CHECK-BE: vclrlb 1, 4, 3# encoding: [0x10,0x24,0x19,0x8d]
 # CHECK-LE: vclrlb 1, 4, 3# encoding: [0x8d,0x19,0x24,0x10]
 vclrlb 1, 4, 3
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -13,6 +13,18 @@
 # CHECK: pextd 1, 2, 4
 0x7c 0x41 0x21 0x78
 
+# CHECK xxgenpcvbm 0, 1, 2
+0xf0 0x02 0x0f 0x28
+
+# CHECK xxgenpcvhm 0, 1, 2
+0xf0 0x02 0x0f 0x2a
+
+# CHECK xxgenpcvwm 0, 1, 2
+0xf0 0x02 0x0f 0x68
+
+# CHECK xxgenpcvdm 0, 1, 2
+0xf0 0x02 0x0f 0x6a
+
 # CHECK: vclrlb 1, 4, 3
 0x10 0x24 0x19 0x8d
 
Index: llvm/test/CodeGen/PowerPC/p10-vsx-pcv.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vsx-pcv.ll
@@ -0,0 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These test cases aim to test the VSX PCV Generate Operations on Power10.
+
+declare <16 x i8> @llvm.ppc.vsx.xxgenpcvbm(<16 x i8>, i32)
+declare <8 x i16> @llvm.ppc.vsx.xxgenpcvhm(<8 x i16>, i32)
+declare <4 x i32> @llvm.ppc.vsx.xxgenpcvwm(<4 x i32>, i32)
+declare <2 x i64> @llvm.ppc.vsx.xxgenpcvdm(<2 x i64>, i32)
+
+define <16 x i8> @test_xxgenpcvbm(<16 x i8> %a) {
+; CHECK-LABEL: test_xxgenpcvbm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvbm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <16 x i8> @llvm.ppc.vsx.xxgenpcvbm(<16 x i8> %a, i32 1)
+  ret <16 x i8> %gen
+}
+
+define <8 x i16> @test_xxgenpcvhm(<8 x i16> %a) {
+; CHECK-LABEL: test_xxgenpcvhm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvhm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <8 x i16> @llvm.ppc.vsx.xxgenpcvhm(<8 x i16> %a, i32 1)
+  ret <8 x i16> %gen
+}
+
+define <4 x i32> @test_xxgenpcvwm(<4 x i32> %a) {
+; CHECK-LABEL: test_xxgenpcvwm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvwm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <4 x i32> @llvm.ppc.vsx.xxgenpcvwm(<4 x i32> %a, i32 1)
+  ret <4 x i32> %gen
+}
+
+define <2 x i64> @test_xxgenpcvdm(<2 x i64> %a) {
+; CHECK-LABEL: test_xxgenpcvdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvdm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <2 x i64> @llvm.ppc.vsx.xxgenpcvdm(<2 x i64> %a, i32 1)
+  ret <2 x i64> %gen
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -161,6 +161,22 @@
   let Inst{48-63} = D_RA{15-0}; // d1
 }
 
+// X-Form: [PO T IMM VRB XO TX]
+class XForm_XT6_IMM5_VB5 opcode, bits<10> xo, dag OOL, dag IOL,
+   

[clang] 9f9373f - Distinguish between template parameter substitutions that are forming

2020-06-22 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-22T19:34:52-07:00
New Revision: 9f9373f86d2d13b8c9f106863ce70ace69abf388

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

LOG: Distinguish between template parameter substitutions that are forming
specializations and those that are done as part of rewrites.

Do not create Subst* nodes in the latter. We previously had a hybrid of
these two behaviors where we would only create some Subst* nodes but not
others during deduction guide rewrites.

No functional change intended, but the resulting ASTs are more
principled.

Added: 


Modified: 
clang/include/clang/Sema/Template.h
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaTemplate/deduction-guide.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 8166b6cf9b6f..741de48a5d24 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -42,6 +42,17 @@ class TypedefNameDecl;
 class TypeSourceInfo;
 class VarDecl;
 
+/// The kind of template substitution being performed.
+enum class TemplateSubstitutionKind : char {
+  /// We are substituting template parameters for template arguments in order
+  /// to form a template specialization.
+  Specialization,
+  /// We are substituting template parameters for (typically) other template
+  /// parameters in order to rewrite a declaration as a 
diff erent declaration
+  /// (for example, when forming a deduction guide from a constructor).
+  Rewrite,
+};
+
   /// Data structure that captures multiple levels of template argument
   /// lists for use in template instantiation.
   ///
@@ -73,6 +84,9 @@ class VarDecl;
 /// being substituted.
 unsigned NumRetainedOuterLevels = 0;
 
+/// The kind of substitution described by this argument list.
+TemplateSubstitutionKind Kind = TemplateSubstitutionKind::Specialization;
+
   public:
 /// Construct an empty set of template argument lists.
 MultiLevelTemplateArgumentList() = default;
@@ -83,6 +97,18 @@ class VarDecl;
   addOuterTemplateArguments(&TemplateArgs);
 }
 
+void setKind(TemplateSubstitutionKind K) { Kind = K; }
+
+/// Determine the kind of template substitution being performed.
+TemplateSubstitutionKind getKind() const { return Kind; }
+
+/// Determine whether we are rewriting template parameters rather than
+/// substituting for them. If so, we should not leave references to the
+/// original template parameters behind.
+bool isRewrite() const {
+  return Kind == TemplateSubstitutionKind::Rewrite;
+}
+
 /// Determine the number of levels in this template argument
 /// list.
 unsigned getNumLevels() const {

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 073b4e818a24..3e8a7531 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2038,6 +2038,7 @@ struct ConvertConstructorToDeductionGuideTransform {
   // a list of substituted template arguments as we go.
   for (NamedDecl *Param : *InnerParams) {
 MultiLevelTemplateArgumentList Args;
+Args.setKind(TemplateSubstitutionKind::Rewrite);
 Args.addOuterTemplateArguments(SubstArgs);
 Args.addOuterRetainedLevel();
 NamedDecl *NewParam = transformTemplateParameter(Param, Args);
@@ -2057,6 +2058,7 @@ struct ConvertConstructorToDeductionGuideTransform {
 // substitute references to the old parameters into references to the
 // new ones.
 MultiLevelTemplateArgumentList Args;
+Args.setKind(TemplateSubstitutionKind::Rewrite);
 if (FTD) {
   Args.addOuterTemplateArguments(SubstArgs);
   Args.addOuterRetainedLevel();

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index bfda59d40c2a..8197e7d901e9 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1362,6 +1362,19 @@ TemplateName TemplateInstantiator::TransformTemplateName(
 
   TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
 
+  if (TemplateArgs.isRewrite()) {
+// We're rewriting the template parameter as a reference to another
+// template parameter.
+if (Arg.getKind() == TemplateArgument::Pack) {
+  assert(Arg.pack_size() == 1 && Arg.pack_begin()->isPackExpansion() &&
+ "unexpected pack arguments in template rewrite");
+  Arg = Arg.pack_begin()->getPackExpansionPattern();
+}
+assert(Arg.getKind() == TemplateArgument::Template &&
+   "unexpected nontype template argument kind in template 
rewrite");
+return Arg.

[clang] 19df9e2 - [PowerPC][Power10] Implement VSX PCV Generate Operations in LLVM/Clang

2020-06-22 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-06-22T21:09:34-05:00
New Revision: 19df9e2959cfa3f25d798bd842df798e2b75f1b2

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

LOG: [PowerPC][Power10] Implement VSX PCV Generate Operations in LLVM/Clang

This patch implements builtins for the following prototypes for the VSX Permute
Control Vector Generate with Mask Instructions:

vector unsigned char vec_genpcvm (vector unsigned char, const int);
vector unsigned short vec_genpcvm (vector unsigned short, const int);
vector unsigned int vec_genpcvm (vector unsigned int, const int);
vector unsigned long long vec_genpcvm (vector unsigned long long, const int);

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

Added: 
llvm/test/CodeGen/PowerPC/p10-vsx-pcv.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/MC/Disassembler/PowerPC/p10insts.txt
llvm/test/MC/PowerPC/p10.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 238e56b6dfce..d16c2d239064 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -399,6 +399,11 @@ BUILTIN(__builtin_vsx_xvcpsgnsp, "V4fV4fV4f", "")
 BUILTIN(__builtin_vsx_xvabssp, "V4fV4f", "")
 BUILTIN(__builtin_vsx_xvabsdp, "V2dV2d", "")
 
+BUILTIN(__builtin_vsx_xxgenpcvbm, "V16UcV16Uci", "")
+BUILTIN(__builtin_vsx_xxgenpcvhm, "V8UsV8Usi", "")
+BUILTIN(__builtin_vsx_xxgenpcvwm, "V4UiV4Uii", "")
+BUILTIN(__builtin_vsx_xxgenpcvdm, "V2ULLiV2ULLii", "")
+
 // vector Insert/Extract exponent/significand builtins
 BUILTIN(__builtin_vsx_xviexpdp, "V2dV2ULLiV2ULLi", "")
 BUILTIN(__builtin_vsx_xviexpsp, "V4fV4UiV4Ui", "")

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 385828aceced..d9ad3e331c5c 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16777,6 +16777,20 @@ vec_pext(vector unsigned long long __a, vector 
unsigned long long __b) {
   return __builtin_altivec_vpextd(__a, __b);
 }
 
+/* vec_genpcvm */
+
+#ifdef __VSX__
+#define vec_genpcvm(__a, __imm)
\
+  _Generic((__a), vector unsigned char 
\
+   : __builtin_vsx_xxgenpcvbm((__a), (int)(__imm)),
\
+ vector unsigned short 
\
+   : __builtin_vsx_xxgenpcvhm((__a), (int)(__imm)),
\
+ vector unsigned int   
\
+   : __builtin_vsx_xxgenpcvwm((__a), (int)(__imm)),
\
+ vector unsigned long long 
\
+   : __builtin_vsx_xxgenpcvdm((__a), (int)(__imm)))
+#endif /* __VSX__ */
+
 /* vec_clrl */
 
 static __inline__ vector signed char __ATTRS_o_ai

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index 829ef97435eb..be4a1b59bfe5 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -7,6 +7,8 @@
 
 vector signed char vsca;
 vector unsigned char vuca;
+vector unsigned short vusa;
+vector unsigned int vuia;
 vector unsigned long long vulla, vullb;
 unsigned int uia;
 
@@ -22,6 +24,30 @@ vector unsigned long long test_vpextd(void) {
   return vec_pext(vulla, vullb);
 }
 
+vector unsigned char test_xxgenpcvbm(void) {
+  // CHECK: @llvm.ppc.vsx.xxgenpcvbm(<16 x i8> %{{.+}}, i32
+  // CHECK-NEXT: ret <16 x i8>
+  return vec_genpcvm(vuca, 0);
+}
+
+vector unsigned short test_xxgenpcvhm(void) {
+  // CHECK: @llvm.ppc.vsx.xxgenpcvhm(<8 x i16> %{{.+}}, i32
+  // CHECK-NEXT: ret <8 x i16>
+  return vec_genpcvm(vusa, 0);
+}
+
+vector unsigned int test_xxgenpcvwm(void) {
+  // CHECK: @llvm.ppc.vsx.xxgenpcvwm(<4 x i32> %{{.+}}, i32
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_genpcvm(vuia, 0);
+}
+
+vector unsigned long long test_xxgenpcvdm(void) {
+  // CHECK: @llvm.ppc.vsx.xxgenpcvdm(<2 x i64> %{{.+}}, i32
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_genpcvm(vulla, 0);
+}
+
 vector signed char test_vec_vclrl_sc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>

diff  --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 2ca77d90e13c..43bd706cf104 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -953,6 +953,18 @@ def int_ppc_vsx_xxinsertw :
   PowerPC_VSX_Intrinsic<"xxinsertw",[llvm_v4i32_ty],

[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-22 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:825
+  // The local stack holds all alloca instructions and all byval arguments.
+  AllocaDerivedValueTracker Tracker;
+  for (Argument &Arg : F.args()) {

avl wrote:
> efriedma wrote:
> > avl wrote:
> > > efriedma wrote:
> > > > Do you have to redo the AllocaDerivedValueTracker analysis?  Is it not 
> > > > enough that the call you're trying to TRE is marked "tail"?
> > > >Do you have to redo the AllocaDerivedValueTracker analysis?
> > > 
> > > AllocaDerivedValueTracker analysis(done in markTails) could be reused 
> > > here. 
> > > But marking, done in markTails(), looks like separate tasks. i.e. it is 
> > > better 
> > > to make TRE not depending on markTails(). There is a review for this - 
> > > https://reviews.llvm.org/D60031
> > > Thus such separation looks useful(To not reuse result of markTails but 
> > > have it computed inplace).
> > > 
> > > > Is it not enough that the call you're trying to TRE is marked "tail"?
> > > 
> > > It is not enough that call which is subject to TRE is marked "Tail".
> > > It also should be checked that other calls does not capture pointer to 
> > > local stack: 
> > > 
> > > ```
> > > // do not do TRE if any pointer to local stack has escaped.
> > > if (!Tracker.EscapePoints.empty())
> > >return false;
> > > 
> > > ```
> > > 
> > > It is not enough that call which is subject to TRE is marked "Tail". It 
> > > also should be checked that other calls does not capture pointer to local 
> > > stack:
> > 
> > If there's an escaped pointer to the local stack, we wouldn't infer "tail" 
> > in the first place, would we?
> If function receives pointer to alloca then it would not be marked with 
> "Tail". Then we do not have a possibility to understand whether this function 
> receives pointer to alloca but does not capture it:
> 
> ```
> void test(int recurseCount)
> {
> if (recurseCount == 0) return;
> int temp = 10;
> globalIncrement(&temp);
> test(recurseCount - 1);
> }
> ```
> 
> test - marked with Tail.
> globalIncrement - not marked with Tail. But TRE could be done since it does 
> not capture pointer. But if it will capture the pointer then we could not do 
> TRE. So we need to check !Tracker.EscapePoints.empty().
> 
> 
> 
> test - marked with Tail.

For the given code, TRE won't mark the recursive call "tail".  That transform 
isn't legal: the recursive call could access the caller's version of "temp".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D81769: [clang-tidy] Repair various issues with modernize-avoid-bind

2020-06-22 Thread Jeff Trull via Phabricator via cfe-commits
jaafar updated this revision to Diff 272580.
jaafar added a comment.

Applied feedback from Aaron Ballman. Thanks!


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

https://reviews.llvm.org/D81769

Files:
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
@@ -7,11 +7,11 @@
 
 template 
 bind_rt bind(Fp &&, Arguments &&...);
-}
+} // namespace impl
 
 template 
 T ref(T &t);
-}
+} // namespace std
 
 namespace boost {
 template 
@@ -58,12 +58,33 @@
 
 void UseF(F);
 
+struct G {
+  G() : _member(0) {}
+  G(int m) : _member(m) {}
+
+  template 
+  void operator()(T) const {}
+
+  int _member;
+};
+
+template 
+struct H {
+  void operator()(T) const {};
+};
+
 struct placeholder {};
 placeholder _1;
 placeholder _2;
 
+namespace placeholders {
+using ::_1;
+using ::_2;
+} // namespace placeholders
+
 int add(int x, int y) { return x + y; }
 int addThree(int x, int y, int z) { return x + y + z; }
+void sub(int &x, int y) { x += y; }
 
 // Let's fake a minimal std::function-like facility.
 namespace std {
@@ -107,6 +128,7 @@
   int MemberVariable;
   static int StaticMemberVariable;
   F MemberStruct;
+  G MemberStructWithData;
 
   void testCaptureByValue(int Param, F f) {
 int x = 3;
@@ -145,6 +167,11 @@
 auto GGG = boost::bind(UseF, MemberStruct);
 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer a lambda to boost::bind [modernize-avoid-bind]
 // CHECK-FIXES: auto GGG = [this] { return UseF(MemberStruct); };
+
+auto HHH = std::bind(add, MemberStructWithData._member, 1);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer a lambda to std::bind
+// Correctly distinguish data members of other classes
+// CHECK-FIXES: auto HHH = [capture0 = MemberStructWithData._member] { return add(capture0, 1); };
   }
 };
 
@@ -217,17 +244,38 @@
   auto EEE = std::bind(*D::create(), 1, 2);
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
   // CHECK-FIXES: auto EEE = [Func = *D::create()] { return Func(1, 2); };
+
+  auto FFF = std::bind(G(), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // Templated function call operators may be used
+  // CHECK-FIXES: auto FFF = [] { return G()(1); };
+
+  int CTorArg = 42;
+  auto GGG = std::bind(G(CTorArg), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // Function objects with constructor arguments should be captured
+  // CHECK-FIXES: auto GGG = [Func = G(CTorArg)] { return Func(1); };
 }
 
+template 
+void testMemberFnOfClassTemplate(T) {
+  auto HHH = std::bind(H(), 42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // Ensure function class template arguments are preserved
+  // CHECK-FIXES: auto HHH = [] { return H()(42); };
+}
+
+template void testMemberFnOfClassTemplate(int);
+
 void testPlaceholders() {
   int x = 2;
   auto AAA = std::bind(add, x, _1);
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto AAA = [x](auto && PH1) { return add(x, PH1); };
+  // CHECK-FIXES: auto AAA = [x](auto && PH1) { return add(x, std::forward(PH1)); };
 
   auto BBB = std::bind(add, _2, _1);
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto BBB = [](auto && PH1, auto && PH2) { return add(PH2, PH1); };
+  // CHECK-FIXES: auto BBB = [](auto && PH1, auto && PH2) { return add(std::forward(PH2), std::forward(PH1)); };
 
   // No fix is applied for reused placeholders.
   auto CCC = std::bind(add, _1, _1);
@@ -238,7 +286,12 @@
   // unnamed parameters.
   auto DDD = std::bind(add, _2, 1);
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto DDD = [](auto &&, auto && PH2) { return add(PH2, 1); };
+  // CHECK-FIXES: auto DDD = [](auto &&, auto && PH2) { return add(std::forward(PH2), 1); };
+
+  // Namespace-qualified placeholders are valid too
+  auto EEE = std::bind(add, placeholders::_2, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // CHECK-FIXES: auto EEE = [](auto &&, auto && PH2) { return add(std::forward(PH2), 1); };
 }
 
 void testGlobalFunctions() {
@@ -267,6 +320,7 @@
 void testCapturedSubexpressions() {
   int x = 3;
   int y = 3;
+  int *p = &x;
 
   auto AAA = std::bind(add, 1, add(2, 5));
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
@@ -277,6 +331,11 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
   //

[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-22 Thread JunMa via Phabricator via cfe-commits
junparser added a comment.

Rather than doing it here, can we build await_resume call expression with 
MaterializedTemporaryExpr when expand the coawait expression. That's how gcc 
does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82314



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


[PATCH] D81769: [clang-tidy] Repair various issues with modernize-avoid-bind

2020-06-22 Thread Jeff Trull via Phabricator via cfe-commits
jaafar marked an inline comment as done.
jaafar added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:243
+  if ((std::distance(ME->child_begin(), ME->child_end()) == 1) &&
+  isa(*ME->children().begin())) {
+// reference to data member without explicit "this"

aaron.ballman wrote:
> jaafar wrote:
> > Is there a better way to express this? "a single child of type ThisExpr" 
> > was what I was going for...
> `if (isa(ME->getBase()))` -- `MemberExpr::children()` only 
> considers the base anyway, so there's only ever one child node to begin with.
Could there be zero? I'm just worried about dereferencing 
`ME->children().begin()` before verifying there is at least one...



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

https://reviews.llvm.org/D81769



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


[PATCH] D82249: [HWASan] Disable GlobalISel/FastISel for HWASan Globals.

2020-06-22 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D82249#2105036 , @arsenm wrote:

> Is the fallback not working correctly in this case for some reason?


I'm fairly sure that G_GLOBAL_VALUE used to fallback onto SelectionDAGISel, and 
that was changed in D78465 . Because we only 
implemented the custom `adrp+movk` lowering in SelectionDAGISel, making that 
instruction sequence no longer fallback, so we don't get our proper lowering 
for HWASan globals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82249



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


[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-22 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
aardappel added a comment.

@dschuff still working on it, it uncovered some issues (as it should :)


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

https://reviews.llvm.org/D82130



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D74166#2107831 , @plotfi wrote:

> @rjmccall
>
> FYI this diff appears to be breaking a ptrauth test on 
> apple/swift/master-next 
> (clang/test/CodeGenCXX/ptrauth-static-destructors.cpp).
>
> Investigating this further.


Looks like this was addressed in:

https://github.com/apple/llvm-project/commit/8e8176c0bee7215b397d78cfff6e617cfc50e248

and 
https://github.com/apple/llvm-project/commit/4292b7edfcf0672da076a0b4e3d4fde8b2672359#diff-75a7118d42116297f6a0b1a0fd020604


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added subscribers: rjmccall, plotfi.
plotfi added a comment.

@rjmccall

FYI this diff appears to be breaking a ptrauth test on apple/swift/master-next 
(clang/test/CodeGenCXX/ptrauth-static-destructors.cpp).

Investigating this further.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D79895#2107796 , @nick wrote:

> > This warning can be turned off by the flag 
> > `-Wno-uninitialized-const-reference`.
>
> Suggesting to turn off the warning should be the last resort. I am pointing 
> to the false positives for large existing code bases from `-Wall` diagnostic.
>
> > I don't think we can just make the diagnostic not fire for empty body 
> > consuming functions, if the function declaration and definition are in 
> > different translation units.
>
> I am talking about the particular situation that is involves only inline 
> functions with empty bodies. `boost::ignore_unused`-like functions are 
> obviously come with definition.


I feel like doing interprocedural analysis for this is overkill. What is the 
benefit of `boost::ignore_unused(foo);` rather than the more common `(void) 
foo;`? Any examples?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895



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


[clang] 009c9b8 - Fix multilevel deduction where an outer pack is used in the type of an

2020-06-22 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-22T16:47:51-07:00
New Revision: 009c9b83acfc8bb863894e349bccc2473c685dbc

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

LOG: Fix multilevel deduction where an outer pack is used in the type of an
inner non-type pack at a different index.

We previously considered the index of the outer pack (which would refer
to an unrelated template parameter) to be deduced by deducing the inner
pack, because we inspected the (largely meaningless) type of an expanded
non-type template parameter pack.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaTemplate/deduction-guide.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 877020ed4dcf..e6569d4a784f 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -738,8 +738,9 @@ class PackDeductionScope {
   // type, so we need to collect the pending deduced values for those 
packs.
   if (auto *NTTP = dyn_cast(
   TemplateParams->getParam(Index))) {
-if (auto *Expansion = dyn_cast(NTTP->getType()))
-  ExtraDeductions.push_back(Expansion->getPattern());
+if (!NTTP->isExpandedParameterPack())
+  if (auto *Expansion = dyn_cast(NTTP->getType()))
+ExtraDeductions.push_back(Expansion->getPattern());
   }
   // FIXME: Also collect the unexpanded packs in any type and template
   // parameter packs that are pack expansions.

diff  --git a/clang/test/SemaTemplate/deduction-guide.cpp 
b/clang/test/SemaTemplate/deduction-guide.cpp
index c1ce62594fa6..3ac37ac44a1f 100644
--- a/clang/test/SemaTemplate/deduction-guide.cpp
+++ b/clang/test/SemaTemplate/deduction-guide.cpp
@@ -1,14 +1,14 @@
 // RUN: %clang_cc1 -std=c++2a -verify -ast-dump -ast-dump-decl-types 
-ast-dump-filter "deduction guide" %s | FileCheck %s
+// expected-no-diagnostics
 
 template struct X {};
 
-template struct A { // expected-note 2{{candidate}}
-  template A(X, Ts (*...qs)[Ns]); // expected-note 
{{candidate}}
+template struct A {
+  template A(X, Ts (*...qs)[Ns]);
 };
 int arr1[3], arr2[3];
 short arr3[4];
-// FIXME: The CTAD deduction here succeeds, but the initialization deduction 
spuriously fails.
-A a(X<&arr1, &arr2>{}, &arr1, &arr2, &arr3); // FIXME: expected-error {{no 
matching constructor}}
+A a(X<&arr1, &arr2>{}, &arr1, &arr2, &arr3);
 using AT = decltype(a);
 using AT = A;
 



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


[clang] e135cf8 - Add -ast-dump-decl-types flag to include types of value and type

2020-06-22 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-22T16:47:51-07:00
New Revision: e135cf8a03b974d2a43eb9fb93ad2d9adefcdf34

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

LOG: Add -ast-dump-decl-types flag to include types of value and type
declarations in AST dumps.

Includes a testcase for deduction guide transformation that makes use of
this new dumping feature.

Added: 
clang/test/SemaTemplate/deduction-guide.cpp

Modified: 
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Frontend/ASTConsumers.h
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Frontend/ASTConsumers.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/tools/clang-check/ClangCheck.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index 9d2bfbf949ef..cf2235ed9274 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -603,6 +603,8 @@ def ast_dump_all : Flag<["-"], "ast-dump-all">,
 def ast_dump_all_EQ : Joined<["-"], "ast-dump-all=">,
   HelpText<"Build ASTs and then debug dump them in the specified format, "
"forcing deserialization. Supported formats include: default, 
json">;
+def ast_dump_decl_types : Flag<["-"], "ast-dump-decl-types">,
+  HelpText<"Include declaration types in AST dumps">;
 def templight_dump : Flag<["-"], "templight-dump">,
   HelpText<"Dump templight information to stdout">;
 def ast_dump_lookups : Flag<["-"], "ast-dump-lookups">,

diff  --git a/clang/include/clang/Frontend/ASTConsumers.h 
b/clang/include/clang/Frontend/ASTConsumers.h
index af8c4a517dcd..98cfc7cadc0d 100644
--- a/clang/include/clang/Frontend/ASTConsumers.h
+++ b/clang/include/clang/Frontend/ASTConsumers.h
@@ -39,7 +39,7 @@ std::unique_ptr 
CreateASTPrinter(std::unique_ptr OS,
 std::unique_ptr
 CreateASTDumper(std::unique_ptr OS, StringRef FilterString,
 bool DumpDecls, bool Deserialize, bool DumpLookups,
-ASTDumpOutputFormat Format);
+bool DumpDeclTypes, ASTDumpOutputFormat Format);
 
 // AST Decl node lister: prints qualified names of all filterable AST Decl
 // nodes.

diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 6069b5eea265..b2be33032c08 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -285,6 +285,9 @@ class FrontendOptions {
   /// Whether we include lookup table dumps in AST dumps.
   unsigned ASTDumpLookups : 1;
 
+  /// Whether we include declaration type dumps in AST dumps.
+  unsigned ASTDumpDeclTypes : 1;
+
   /// Whether we are performing an implicit module build.
   unsigned BuildingImplicitModule : 1;
 

diff  --git a/clang/lib/Frontend/ASTConsumers.cpp 
b/clang/lib/Frontend/ASTConsumers.cpp
index 043b2541b8f8..12fda45d0ef0 100644
--- a/clang/lib/Frontend/ASTConsumers.cpp
+++ b/clang/lib/Frontend/ASTConsumers.cpp
@@ -36,10 +36,10 @@ namespace {
 enum Kind { DumpFull, Dump, Print, None };
 ASTPrinter(std::unique_ptr Out, Kind K,
ASTDumpOutputFormat Format, StringRef FilterString,
-   bool DumpLookups = false)
+   bool DumpLookups = false, bool DumpDeclTypes = false)
 : Out(Out ? *Out : llvm::outs()), OwnedOut(std::move(Out)),
   OutputKind(K), OutputFormat(Format), FilterString(FilterString),
-  DumpLookups(DumpLookups) {}
+  DumpLookups(DumpLookups), DumpDeclTypes(DumpDeclTypes) {}
 
 void HandleTranslationUnit(ASTContext &Context) override {
   TranslationUnitDecl *D = Context.getTranslationUnitDecl();
@@ -91,8 +91,22 @@ namespace {
   } else if (OutputKind == Print) {
 PrintingPolicy Policy(D->getASTContext().getLangOpts());
 D->print(Out, Policy, /*Indentation=*/0, /*PrintInstantiation=*/true);
-  } else if (OutputKind != None)
+  } else if (OutputKind != None) {
 D->dump(Out, OutputKind == DumpFull, OutputFormat);
+  }
+
+  if (DumpDeclTypes) {
+Decl *InnerD = D;
+if (auto *TD = dyn_cast(D))
+  InnerD = TD->getTemplatedDecl();
+
+// FIXME: Support OutputFormat in type dumping.
+// FIXME: Support combining -ast-dump-decl-types with 
-ast-dump-lookups.
+if (auto *VD = dyn_cast(InnerD))
+  VD->getType().dump(Out);
+if (auto *TD = dyn_cast(InnerD))
+  TD->getTypeForDecl()->dump(Out);
+  }
 }
 
 raw_ostream &Out;
@@ -111,6 +125,9 @@ namespace {
 /// results will be output with a format determined by OutputKind. This is
 /// incompatible with OutputKind 

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Nikita Kniazev via Phabricator via cfe-commits
nick added a comment.

> This warning can be turned off by the flag 
> `-Wno-uninitialized-const-reference`.

Suggesting to turn off the warning should be the last resort. I am pointing to 
the false positives for large existing code bases from `-Wall` diagnostic.

> I don't think we can just make the diagnostic not fire for empty body 
> consuming functions, if the function declaration and definition are in 
> different translation units.

I am talking about the particular situation that is involves only inline 
functions with empty bodies. `boost::ignore_unused`-like functions are 
obviously come with definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-22 Thread Alexey Lapshin via Phabricator via cfe-commits
avl marked 3 inline comments as done.
avl added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:823
+
+bool TailRecursionEliminator::canTRE(Function &F) {
+  // The local stack holds all alloca instructions and all byval arguments.

laytonio wrote:
> There is no need to pass the function here since its a member variable.
Ok.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:825
+  // The local stack holds all alloca instructions and all byval arguments.
+  AllocaDerivedValueTracker Tracker;
+  for (Argument &Arg : F.args()) {

efriedma wrote:
> avl wrote:
> > efriedma wrote:
> > > Do you have to redo the AllocaDerivedValueTracker analysis?  Is it not 
> > > enough that the call you're trying to TRE is marked "tail"?
> > >Do you have to redo the AllocaDerivedValueTracker analysis?
> > 
> > AllocaDerivedValueTracker analysis(done in markTails) could be reused here. 
> > But marking, done in markTails(), looks like separate tasks. i.e. it is 
> > better 
> > to make TRE not depending on markTails(). There is a review for this - 
> > https://reviews.llvm.org/D60031
> > Thus such separation looks useful(To not reuse result of markTails but have 
> > it computed inplace).
> > 
> > > Is it not enough that the call you're trying to TRE is marked "tail"?
> > 
> > It is not enough that call which is subject to TRE is marked "Tail".
> > It also should be checked that other calls does not capture pointer to 
> > local stack: 
> > 
> > ```
> > // do not do TRE if any pointer to local stack has escaped.
> > if (!Tracker.EscapePoints.empty())
> >return false;
> > 
> > ```
> > 
> > It is not enough that call which is subject to TRE is marked "Tail". It 
> > also should be checked that other calls does not capture pointer to local 
> > stack:
> 
> If there's an escaped pointer to the local stack, we wouldn't infer "tail" in 
> the first place, would we?
If function receives pointer to alloca then it would not be marked with "Tail". 
Then we do not have a possibility to understand whether this function receives 
pointer to alloca but does not capture it:

```
void test(int recurseCount)
{
if (recurseCount == 0) return;
int temp = 10;
globalIncrement(&temp);
test(recurseCount - 1);
}
```

test - marked with Tail.
globalIncrement - not marked with Tail. But TRE could be done since it does not 
capture pointer. But if it will capture the pointer then we could not do TRE. 
So we need to check !Tracker.EscapePoints.empty().






Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:852
+
+// Do not do TRE if exists recursive calls which are not last calls.
+if (!isTailBlock(CI->getParent()) ||

efriedma wrote:
> avl wrote:
> > efriedma wrote:
> > > I thought we had some tests where we TRE in the presence of recursive 
> > > calls, like a simple recursive fibonacci.  Am I misunderstanding this?
> > right, there is a testcase for fibonacchi:
> > 
> > llvm/test/Transforms/TailCallElim/accum_recursion.ll:@test3_fib
> > 
> > areAllLastFuncCallsRecursive() checking works well for fibonacci testcase:
> > 
> > 
> > ```
> > return fib(x-1)+fib(x-2);
> > 
> > ```
> > 
> > Since, Last funcs call chain is : fib()->fib()->ret. 
> > That check should prevent from such cases:
> > 
> > 
> > ```
> > return fib(x-1)+another_call()+fib(x-2);
> > ```
> > 
> > 
> > That check should prevent from such cases: return 
> > fib(x-1)+another_call()+fib(x-2);
> 
> Why do we need to prevent this?
We do not. I misunderstood the canTransformAccumulatorRecursion(). That check 
could be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-22 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In D79972#2104854 , @RaviNarayanaswamy 
wrote:

> How do you plan to support 
>  #pragma omp target update to (arr[1:2][1:2][0:2], x, b[1:5][0:2])
>  Are you going to split this into 3 updates since your are using the arg 
> fields.


I have added a test basically base on the case in your comment (CK19 in 
target_update_codegen.cpp). Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-22 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:801
+if (Branch->isUnconditional())
+  if (ReturnInst *Ret = dyn_cast(
+  Branch->getSuccessor(0)->getFirstNonPHIOrDbg()))

can we use isa<> here?



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:816
+if (CallInst *CI = dyn_cast(&*BBI))
+  if (!canMoveAboveCall(CI, Inst, AA) && CI->getCalledFunction() != &F)
+return false;

`CI->getCalledFunction() != &F` seems cheaper than `canMoveAboveCall`



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:840
+
+  return !llvm::any_of(instructions(F), [&](Instruction &I) {
+// Because of PR962, we don't TRE dynamic allocas.

Do we need to visit all the instructions twice?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-22 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 272564.
cchen added a comment.

Updated test for clarification


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -36,5 +38,21 @@
   {
 foo();
   }
+
+  double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  int arr[4][3][2][1];
+#pragma omp target update to(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  double ***dptr;
+#pragma omp target update to(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
   return tmain(argc, argv);
 }
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,304 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 -

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D79895#2107604 , @nick wrote:

> This diagnostic bring headaches because frequently `-Wunused-variable` 
> suppression is done via no-op pseudo-consuming function like 
> `boost::ignore_unused` 
> .
>  Particularly, it fires in Boost here 
> https://github.com/boostorg/concept_check/blob/e69c81326d5a4359ac53f9c6fe53fc2baf24df50/include/boost/concept_check.hpp#L135-L141.
>  Is it possible to make the diagnostic not fire for empty body consuming 
> functions?


This warning can be turned off by the flag 
`-Wno-uninitialized-const-reference`. I don't think we can just make the 
diagnostic not fire for empty body consuming functions, if the function 
declaration and definition are in different translation units.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895



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


[PATCH] D82335: [clangd] WIP: config

2020-06-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, javed.absar, ilya-biryukov, mgorny.
Herald added a project: clang.

This is a glorious tangled mess that needs to be split, and needs tests...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82335

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Config.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigProvider.cpp
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundQueue.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -851,15 +851,15 @@
 TEST_F(TUSchedulerTests, Run) {
   TUScheduler S(CDB, optsForTest());
   std::atomic Counter(0);
-  S.run("add 1", [&] { ++Counter; });
-  S.run("add 2", [&] { Counter += 2; });
+  S.run("add 1", llvm::None, [&] { ++Counter; });
+  S.run("add 2", llvm::None, [&] { Counter += 2; });
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_EQ(Counter.load(), 3);
 
   Notification TaskRun;
   Key TestKey;
   WithContextValue CtxWithKey(TestKey, 10);
-  S.run("props context", [&] {
+  S.run("props context", llvm::None, [&] {
 EXPECT_EQ(Context::current().getExisting(TestKey), 10);
 TaskRun.notify();
   });
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -7,7 +7,9 @@
 //===--===//
 
 #include "CompileCommands.h"
+#include "Config.h"
 #include "TestFS.h"
+#include "support/Context.h"
 
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
@@ -185,6 +187,25 @@
 }
 #endif
 
+TEST(CommandMangler, ConfigEdits) {
+  auto Mangler = CommandMangler::forTests();
+  std::vector Cmd = {"clang++", "foo.cc"};
+  {
+Config Cfg;
+Cfg.CompileFlags.Edits.push_back([](std::vector &Argv) {
+  for (auto &Arg : Argv)
+for (char &C : Arg)
+  C = llvm::toUpper(C);
+});
+Cfg.CompileFlags.Edits.push_back(
+[](std::vector &Argv) { Argv.push_back("--hello"); });
+WithContextValue WithConfig(Config::Key, std::move(Cfg));
+Mangler.adjust(Cmd);
+  }
+  EXPECT_THAT(Cmd,
+  ElementsAre("CLANG++", "FOO.CC", "--hello", "-fsyntax-only"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -8,6 +8,8 @@
 
 #include "ClangdLSPServer.h"
 #include "CodeComplete.h"
+#include "Config.h"
+#include "ConfigProvider.h"
 #include "Features.inc"
 #include "PathMapping.h"
 #include "Protocol.h"
@@ -30,6 +32,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -180,6 +183,13 @@
   "combined. Type information shown where possible")),
 };
 
+opt ConfigEnabled{
+"config",
+cat(Misc),
+desc("Enable experimental YAML configuration file support"),
+init(false),
+};
+
 opt FallbackStyle{
 "fallback-style",
 cat(Features),
@@ -629,6 +639,8 @@
 }
   }
 
+  RealThreadsafeFS TFS;
+
   ClangdServer::Options Opts;
   switch (PCHStorage) {
   case PCHStorageFlag::Memory:
@@ -660,6 +672,12 @@
   Opts.BuildRecoveryAST = RecoveryAST;
   Opts.PreserveRecoveryASTType = RecoveryASTType;
 
+  std::unique_ptr ConfigProvider;
+  if (ConfigEnabled) {
+ConfigProvider = config::createFileConfigProvider(TFS);
+Opts.ConfigProvider = ConfigProvider.get();
+  }
+
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
   CCOpts.Limit = LimitResults;
@@ -676,7 +694,6 @@
   CCOpts.AllScopes = AllScopesCompletion;
   CCOpts.RunParser = CodeCompletionParse;
 
-  RealThreadsafeFS TFS;
   // 

[PATCH] D81816: [PowerPC] Add support for vector bool __int128 for Power10

2020-06-22 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir marked 2 inline comments as done.
saghir added inline comments.



Comment at: clang/test/Parser/p10-vector-bool-128.c:6
+// RUN:-target-feature +power10-vector -fsyntax-only -verify %s
+// expected-no-diagnostics
+

amyk wrote:
> I believe this comment still needs to be addressed (of the line not being 
> needed).
I think this was for a line removed earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81816



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


[PATCH] D81963: [HIP] Move HIP Linking Logic into HIP ToolChain

2020-06-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` 
`Subscribers:` `Tags:` and the text `Summary:` from the git commit with the 
following script:

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. Please keep the tag. (I 
have updated my script to use `--date=now` (setting author date to committer 
date))

`https://reviews.llvm.org/D80978` contains a git pre-push hook to automate this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81963



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


[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-22 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

So the code LGTM, were you going to add to usertest.ll in this CL?




Comment at: llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp:84
 WasmSym->setGlobalType(wasm::WasmGlobalType{
-uint8_t(Subtarget.hasAddr64() ? wasm::WASM_TYPE_I64
-  : wasm::WASM_TYPE_I32),
+uint8_t(Subtarget.hasAddr64() && strcmp(Name, "__table_base") != 0
+? wasm::WASM_TYPE_I64

aardappel wrote:
> dschuff wrote:
> > should __table_base stay as i32?
> I'd think so, right? since it refers to table indices, not memory
Oh, right; I'd misread this as setting it just for table_base but I had it 
backwards; it's exempting table_base. So yeah this is right.


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

https://reviews.llvm.org/D82130



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-22 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 272556.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833

Files:
  clang/test/CodeGen/debug-info-codeview-buildinfo.c
  lld/COFF/PDB.cpp
  lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
  lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
  lld/test/COFF/pdb-relative-source-lines.test
  lld/test/COFF/pdb-relative-source-lines2.test
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/test/DebugInfo/COFF/build-info.ll
  llvm/test/DebugInfo/COFF/global-type-hashes.ll
  llvm/test/DebugInfo/COFF/types-basic.ll
  llvm/test/DebugInfo/COFF/types-data-members.ll

Index: llvm/test/DebugInfo/COFF/types-data-members.ll
===
--- llvm/test/DebugInfo/COFF/types-data-members.ll
+++ llvm/test/DebugInfo/COFF/types-data-members.ll
@@ -727,14 +727,22 @@
 ; ASM: .asciz	"t.cpp" # StringData
 ; ASM: .byte	242
 ; ASM: .byte	241
-; ASM: # BuildInfo (0x1022)
+; ASM: # StringId (0x1022)
+; ASM: .short	0xa # Record length
+; ASM: .short	0x1605  # Record kind: LF_STRING_ID
+; ASM: .long	0x0 # Id
+; ASM: .byte0   # StringData
+; ASM: .byte	243
+; ASM: .byte	242
+; ASM: .byte	241
+; ASM: # BuildInfo (0x1023)
 ; ASM: .short	0x1a# Record length
 ; ASM: .short	0x1603  # Record kind: LF_BUILDINFO
 ; ASM: .short	0x5 # NumArgs
 ; ASM: .long	0x1020  # Argument: D:\src\llvm\build
 ; ASM: .long	0x0 # Argument
 ; ASM: .long	0x1021  # Argument: t.cpp
-; ASM: .long	0x0 # Argument
+; ASM: .long	0x1022  # Argument
 ; ASM: .long	0x0 # Argument
 ; ASM: .byte	242
 ; ASM: .byte	241
Index: llvm/test/DebugInfo/COFF/types-basic.ll
===
--- llvm/test/DebugInfo/COFF/types-basic.ll
+++ llvm/test/DebugInfo/COFF/types-basic.ll
@@ -511,14 +511,22 @@
 ; ASM: .asciz	"t.cpp" # StringData
 ; ASM: .byte	242
 ; ASM: .byte	241
-; ASM: # BuildInfo (0x1015)
+; ASM: # StringId (0x1015)
+; ASM: .short	0xa # Record length
+; ASM: .short	0x1605  # Record kind: LF_STRING_ID
+; ASM: .long	0x0 # Id
+; ASM: .byte0   # StringData
+; ASM: .byte	243
+; ASM: .byte	242
+; ASM: .byte	241
+; ASM: # BuildInfo (0x1016)
 ; ASM: .short	0x1a# Record length
 ; ASM: .short	0x1603  # Record kind: LF_BUILDINFO
 ; ASM: .short	0x5 # NumArgs
 ; ASM: .long	0x1013  # Argument: D:\src\llvm\build
 ; ASM: .long	0x0 # Argument
 ; ASM: .long	0x1014  # Argument: t.cpp
-; ASM: .long	0x0 # Argument
+; ASM: .long	0x1015  # Argument
 ; ASM: .long	0x0 # Argument
 ; ASM: .byte	242
 ; ASM: .byte	241
Index: llvm/test/DebugInfo/COFF/global-type-hashes.ll
===
--- llvm/test/DebugInfo/COFF/global-type-hashes.ll
+++ llvm/test/DebugInfo/COFF/global-type-hashes.ll
@@ -295,7 +295,8 @@
 ; YAML: - 4470750F2E319329
 ; YAML: - 0FB556FD1FAB66D7
 ; YAML: - 5970EFB4874D0F3F
-; YAML: - EDB1D74C120CF44A
+; YAML: - D8EF11198C33843F
+; YAML: - D81F744D7366282B
 ; ...
 
 
Index: llvm/test/DebugInfo/COFF/build-info.ll
===
--- llvm/test/DebugInfo/COFF/build-info.ll
+++ llvm/test/DebugInfo/COFF/build-info.ll
@@ -5,7 +5,7 @@
 ; CHECK-NEXT:  0x{{.*}}: `D:\src\scopes\clang`
 ; CHECK-NEXT:  : ``
 ; CHECK-NEXT:  0x{{.*}}: `D:\src\scopes\foo.cpp`
-; CHECK-NEXT:  : ``
+; CHECK-NEXT:  0x{{.*}}: ``
 ; CHECK-NEXT:  : ``
 
 ; CHECK: {{.*}} | S_BUILDINFO [size = 8] BuildId = `[[INFO_IDX]]`
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -77,6 +77,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
@@ -831,6 +832,31 @@
   return TypeTable.writeLeafType(SIR);
 }
 
+static std::string flattenCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+  std::string FlatCmdLine;
+  raw_string_ostream OS(FlatCmdLine);
+  StringRef LastArg;
+  for (StringRef Arg : Args) {
+if (Arg.empty())
+  continue;
+// The command-line shall not contai

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-22 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked 2 inline comments as done.
aganea added a subscriber: uweigand.
aganea added inline comments.



Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:4
+// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
+

Line 4 here fails on s390x but not on other Unix flavors, see: 
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/33346/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-info-codeview-buildinfo.c

@thakis @uweigand Any ideas would could go wrong here?



Comment at: lld/test/COFF/pdb-relative-source-lines2.test:44
+RUN: yaml2obj %S/Inputs/pdb_lines_1_relative.yaml -o 
%t/pdb_lines_1_relative.obj
+RUN: sed -e "s|String:  \.|String:  "c:\\\src"|" < 
%S/Inputs/pdb_lines_2_relative.yaml > %t/pdb_lines_2_relative.yaml
+RUN: yaml2obj pdb_lines_2_relative.yaml -o %t/pdb_lines_2_relative.obj

@thakis : I was unable to make this work otherwise than by restricting this 
test to windows (`REQUIRES: system-windows` at the top). This works now on 
Cygwin (git bash) and GnuWin32, but not on Linux. Would you mind if this test 
was Windows-specific?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-22 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In D79972#2104854 , @RaviNarayanaswamy 
wrote:

> How do you plan to support 
>  #pragma omp target update to (arr[1:2][1:2][0:2], x, b[1:5][0:2])
>  Are you going to split this into 3 updates since your are using the arg 
> fields.


There's only one runtime call for your case. and args will be { descriptor_1, 
x, descriptor_2 }, where descriptor_1 will be { { 1, 2, 80 }, { 1, 2, 20 }, { 
0, 2, 4 } }, descriptor_2 will be { { 1, 5, 16 }, { 0, 2, 4 } }. There's 
analysis in Sema that detecting if the item is non-contiguous or not and 
codegen only generate descriptor for non-contiguous item.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Sema/SemaCUDA.cpp:753
 return;
+  if (LI.Default == LCD_None && LI.Captures.size() == 0) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));

pfultz2 wrote:
> There should at least be a flag to enable capturing lambdas to be implicitly 
> HD. I dont really understand the rational for making capturing lambdas not 
> implicitly HD. It seems like its trying to prevent using an address to host 
> on the device, but I dont see how this prevents that at all. 
> 
> This will also break the compilation in rocm. Should we use a fork of llvm to 
> compile rocm?
@pfultz2:

> This will also break the compilation in rocm. Should we use a fork of llvm to 
> compile rocm?

Could you give an example to demonstrate current use and how it will break? My 
understanding that the patch *relaxes* the restrictions on lambdas so in theory 
not promoting capturing lambdas preserves the status quo. 

As for the fork, my response would be an empathic "no, please don't do it". 
Fork == different compiler == showstopper for various use cases. It would 
definitely be an issue for us at Google. 

Considering that we're still probing our way towards making lambdas more 
useful, it may be a bit premature to heavily depend on any particular 
implementation detail of an experimental feature, even if it happens to work. 
We'll need to figure out an approach that will be sustainable long-term and 
forked compiler is a rather large and hard-to-maintain hammer for this. In my 
experience, adapting source code ends up being more manageable long-term.


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

https://reviews.llvm.org/D78655



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


[PATCH] D82279: Handle invalid types in the nullPointerConstant AST matcher

2020-06-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:2618
+  )";
+  EXPECT_TRUE(matches(kTest, expr(nullPointerConstant(;
 }

aaron.ballman wrote:
> steveire wrote:
> > While this test in ASTMatchers might continue to make sense, shouldn't 
> > there be a test in `clang/unittests/AST` for this API? 
> > `isNullPointerConstant` seems to be complicated. Does it have a unit test?
> > While this test in ASTMatchers might continue to make sense, shouldn't 
> > there be a test in clang/unittests/AST for this API? isNullPointerConstant 
> > seems to be complicated. Does it have a unit test?
> 
> It does not have a unit test; we don't usually unit test AST interfaces 
> directly. AST matching tests are the typical way we'd test this because it 
> gives us an almost direct path to the AST interface we want to exercise, but 
> if you can spot an additional place to perform the test more directly, I can 
> look into adding one.
Fair enough!


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

https://reviews.llvm.org/D82279



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


[PATCH] D82115: [OPENMP50]Codegen for scan directives in parallel for simd regions.

2020-06-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert 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/D82115/new/

https://reviews.llvm.org/D82115



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-22 Thread Layton Kifer via Phabricator via cfe-commits
laytonio added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:823
+
+bool TailRecursionEliminator::canTRE(Function &F) {
+  // The local stack holds all alloca instructions and all byval arguments.

There is no need to pass the function here since its a member variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D81869: Modify FPFeatures to use delta not absolute settings to solve PCH compatibility problems

2020-06-22 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:620
+//unsigned FPFeatures : 21;
+unsigned FPFeatures : 32;
   };

mibintc wrote:
> This is a temporary change, I know you don't want me to change the assert to 
> allow a wider size than 8. So if this information is really needed (as I 
> mentioned above it's not being used in Sema or Codegen) then alternatives are
> 1. rewrite the == comparison using BinaryOperator
> 2. put the FPFeatures Override into TrailingStorage (i think i will need 
> implementation guidance if this is the path to go)
What do you mean by `rewrite the == comparison using BinaryOperator`? If you 
mean representing overloaded `operator==`'s by `BinaryOperator`, then that's 
certainly not right because `BinaryOperator`s only represent binary builtin 
operators.

You will not be able to use `TrailingObjects` with `CXXOperatorCallExpr` 
because `CallExpr` stores its arguments after the object containing the 
`CallExpr` sub-object. You could manually stash it after `CallExpr`'s 
arguments, but that would be pretty ugly.

Do you really need 32-bits worth of FP options? I see from `FPOptions.def` that 
you need 14 bits, so it should fit with room to spare.



Comment at: clang/include/clang/AST/Stmt.h:1121
   Stmt(StmtClass SC) {
-static_assert(sizeof(*this) <= 8,
+static_assert(sizeof(*this) <= 16,
   "changing bitfields changed sizeof(Stmt)");

mibintc wrote:
> this is a temporary change
It better be :)



Comment at: clang/include/clang/Basic/LangOptions.h:455
+  llvm::errs() << "\n RoundingMode " <<
+static_cast(getRoundingMode());
+  llvm::errs() << "\n FPExceptionMode " << getFPExceptionMode();

mibintc wrote:
> Using #define OPTION trick would be preferrable except there is a compilation 
> failure because something funny about RoundingMode--need the cast. doubtless 
> there is fix for that
Yes it would be preferable and it should not be in a header too.

You need the cast because `RoundingMode` is a scoped enumeration, which does 
not have the implicit conversions of unscoped enumerations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81869



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


[PATCH] D81816: [PowerPC] Add support for vector bool __int128 for Power10

2020-06-22 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision as: amyk.
amyk added a comment.

Other than Lei's concerns, personally I think this looks good to me.




Comment at: clang/test/Parser/p10-vector-bool-128.c:6
+// RUN:-target-feature +power10-vector -fsyntax-only -verify %s
+// expected-no-diagnostics
+

I believe this comment still needs to be addressed (of the line not being 
needed).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81816



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


[PATCH] D82029: [Coroutines] Ensure co_await promise.final_suspend() does not throw

2020-06-22 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG516803dc8685: [Coroutines] Ensure co_await 
promise.final_suspend() does not throw (authored by lxfind).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82029

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/AST/Inputs/std-coroutine.h
  clang/test/AST/coroutine-source-location-crash.cpp
  clang/test/Analysis/more-dtors-cfg-output.cpp
  clang/test/CodeGenCXX/ubsan-coroutines.cpp
  clang/test/CodeGenCoroutines/Inputs/coroutine.h
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-always-inline.cpp
  clang/test/CodeGenCoroutines/coro-await-domination.cpp
  clang/test/CodeGenCoroutines/coro-await-resume-eh.cpp
  clang/test/CodeGenCoroutines/coro-await.cpp
  clang/test/CodeGenCoroutines/coro-dest-slot.cpp
  clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  clang/test/CodeGenCoroutines/coro-params.cpp
  clang/test/CodeGenCoroutines/coro-promise-dtor.cpp
  clang/test/CodeGenCoroutines/coro-ret-void.cpp
  clang/test/CodeGenCoroutines/coro-return-voidtype-initlist.cpp
  clang/test/CodeGenCoroutines/coro-return.cpp
  clang/test/CodeGenCoroutines/coro-unhandled-exception.cpp
  clang/test/Index/coroutines.cpp
  clang/test/SemaCXX/Inputs/std-coroutine.h
  clang/test/SemaCXX/co_await-range-for.cpp
  clang/test/SemaCXX/coreturn-eh.cpp
  clang/test/SemaCXX/coreturn.cpp
  clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
  clang/test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
  clang/test/SemaCXX/coroutines.cpp

Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -52,21 +52,24 @@
 };
 
 struct awaitable {
-  bool await_ready();
-  template  void await_suspend(F);
-  void await_resume();
+  bool await_ready() noexcept;
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept;
 } a;
 
 struct suspend_always {
-  bool await_ready() { return false; }
-  template  void await_suspend(F);
-  void await_resume() {}
+  bool await_ready() noexcept { return false; }
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
 };
 
 struct suspend_never {
-  bool await_ready() { return true; }
-  template  void await_suspend(F);
-  void await_resume() {}
+  bool await_ready() noexcept { return true; }
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
 };
 
 struct auto_await_suspend {
@@ -127,7 +130,7 @@
 struct promise {
   void get_return_object();
   suspend_always initial_suspend();
-  suspend_always final_suspend();
+  suspend_always final_suspend() noexcept;
   awaitable yield_value(int); // expected-note 2{{candidate}}
   awaitable yield_value(yielded_thing); // expected-note 2{{candidate}}
   not_awaitable yield_value(void()); // expected-note 2{{candidate}}
@@ -138,7 +141,7 @@
 struct promise_void {
   void get_return_object();
   suspend_always initial_suspend();
-  suspend_always final_suspend();
+  suspend_always final_suspend() noexcept;
   void return_void();
   void unhandled_exception();
 };
@@ -152,13 +155,13 @@
 namespace experimental {
 template 
 struct coroutine_handle {
-  static coroutine_handle from_address(void *);
+  static coroutine_handle from_address(void *) noexcept;
 };
 template <>
 struct coroutine_handle {
   template 
-  coroutine_handle(coroutine_handle);
-  static coroutine_handle from_address(void *);
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *) noexcept;
 };
 }} // namespace std::experimental
 
@@ -402,7 +405,7 @@
 
 namespace adl_ns {
 struct coawait_arg_type {};
-awaitable operator co_await(coawait_arg_type);
+awaitable operator co_await(coawait_arg_type) noexcept;
 }
 
 namespace dependent_operator_co_await_lookup {
@@ -434,7 +437,7 @@
 typedef transform_awaitable await_arg;
 coro get_return_object();
 transformed initial_suspend();
-::adl_ns::coawait_arg_type final_suspend();
+::adl_ns::coawait_arg_type final_suspend() noexcept;
 transformed await_transform(transform_awaitable);
 void unhandled_exception();
 void return_void();
@@ -444,7 +447,7 @@
 typedef AwaitArg await_arg;
 coro get_return_object();
 awaitable initial_suspend();
-awaitable final_suspend();
+awaitable final_suspend() noexcept;
 void unhandled_exception();
 void return_void();
   };
@@ -529,7 +532,7 @@
 void return_value(int());
 
 suspend_never initial_suspend();
-suspend_never final_suspend();

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 272546.
nickdesaulniers added a comment.

- fix clang/test/OpenMP/parallel_codegen.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=limited"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: !DIEnumerator(name: "BAZ"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+class ;
+enum class ;
+
+// NODBG-NOT: ;
+// NODBG-NOT: ;
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,60 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: !DIEnumerator(name: "BAR"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "baz"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "y"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "w"
+
+// Check that debug info is not emitted for the typedef, struct, enum, and
+// union when -fno-eliminate-unused-debug-types and -g are not s

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Nikita Kniazev via Phabricator via cfe-commits
nick added a comment.

This diagnostic bring headaches because frequently `-Wunused-variable` 
suppression is done via no-op pseudo-consuming function like 
`boost::ignore_unused` 
.
 Particularly, it fires in Boost here 
https://github.com/boostorg/concept_check/blob/e69c81326d5a4359ac53f9c6fe53fc2baf24df50/include/boost/concept_check.hpp#L135-L141.
Is it possible to make the diagnostic not fire for empty body consuming 
functions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-22 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:825
+  // The local stack holds all alloca instructions and all byval arguments.
+  AllocaDerivedValueTracker Tracker;
+  for (Argument &Arg : F.args()) {

avl wrote:
> efriedma wrote:
> > Do you have to redo the AllocaDerivedValueTracker analysis?  Is it not 
> > enough that the call you're trying to TRE is marked "tail"?
> >Do you have to redo the AllocaDerivedValueTracker analysis?
> 
> AllocaDerivedValueTracker analysis(done in markTails) could be reused here. 
> But marking, done in markTails(), looks like separate tasks. i.e. it is 
> better 
> to make TRE not depending on markTails(). There is a review for this - 
> https://reviews.llvm.org/D60031
> Thus such separation looks useful(To not reuse result of markTails but have 
> it computed inplace).
> 
> > Is it not enough that the call you're trying to TRE is marked "tail"?
> 
> It is not enough that call which is subject to TRE is marked "Tail".
> It also should be checked that other calls does not capture pointer to local 
> stack: 
> 
> ```
> // do not do TRE if any pointer to local stack has escaped.
> if (!Tracker.EscapePoints.empty())
>return false;
> 
> ```
> 
> It is not enough that call which is subject to TRE is marked "Tail". It also 
> should be checked that other calls does not capture pointer to local stack:

If there's an escaped pointer to the local stack, we wouldn't infer "tail" in 
the first place, would we?



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:852
+
+// Do not do TRE if exists recursive calls which are not last calls.
+if (!isTailBlock(CI->getParent()) ||

avl wrote:
> efriedma wrote:
> > I thought we had some tests where we TRE in the presence of recursive 
> > calls, like a simple recursive fibonacci.  Am I misunderstanding this?
> right, there is a testcase for fibonacchi:
> 
> llvm/test/Transforms/TailCallElim/accum_recursion.ll:@test3_fib
> 
> areAllLastFuncCallsRecursive() checking works well for fibonacci testcase:
> 
> 
> ```
> return fib(x-1)+fib(x-2);
> 
> ```
> 
> Since, Last funcs call chain is : fib()->fib()->ret. 
> That check should prevent from such cases:
> 
> 
> ```
> return fib(x-1)+another_call()+fib(x-2);
> ```
> 
> 
> That check should prevent from such cases: return 
> fib(x-1)+another_call()+fib(x-2);

Why do we need to prevent this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[clang] 516803d - [Coroutines] Ensure co_await promise.final_suspend() does not throw

2020-06-22 Thread Xun Li via cfe-commits

Author: Xun Li
Date: 2020-06-22T15:01:42-07:00
New Revision: 516803dc8685ebcc5bce38b05391958ffee22643

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

LOG: [Coroutines] Ensure co_await promise.final_suspend() does not throw

Summary:
This patch addresses https://bugs.llvm.org/show_bug.cgi?id=46256
The spec of coroutine requires that the expression co_­await 
promise.final_­suspend() shall not be potentially-throwing.
To check this, we recursively look at every call (including Call, MemberCall, 
OperatorCall and Constructor) in all code
generated by the final suspend, and ensure that the callees are declared with 
noexcept. We also look at any returned data
type that requires explicit destruction, and check their destructors for 
noexcept.

This patch does not check declarations with dependent types yet, which will be 
done in future patches.

Updated all tests to add noexcept to the required functions, and added a 
dedicated test for this patch.

This patch might start to cause existing codebase fail to compile because most 
people may not have been strict in tagging
all the related functions noexcept.

Reviewers: lewissbaker, modocache, junparser

Reviewed By: modocache

Subscribers: arphaman, junparser, cfe-commits

Tags: #clang

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

Added: 
clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/test/AST/Inputs/std-coroutine.h
clang/test/AST/coroutine-source-location-crash.cpp
clang/test/Analysis/more-dtors-cfg-output.cpp
clang/test/CodeGenCXX/ubsan-coroutines.cpp
clang/test/CodeGenCoroutines/Inputs/coroutine.h
clang/test/CodeGenCoroutines/coro-alloc.cpp
clang/test/CodeGenCoroutines/coro-always-inline.cpp
clang/test/CodeGenCoroutines/coro-await-domination.cpp
clang/test/CodeGenCoroutines/coro-await-resume-eh.cpp
clang/test/CodeGenCoroutines/coro-await.cpp
clang/test/CodeGenCoroutines/coro-dest-slot.cpp
clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
clang/test/CodeGenCoroutines/coro-params.cpp
clang/test/CodeGenCoroutines/coro-promise-dtor.cpp
clang/test/CodeGenCoroutines/coro-ret-void.cpp
clang/test/CodeGenCoroutines/coro-return-voidtype-initlist.cpp
clang/test/CodeGenCoroutines/coro-return.cpp
clang/test/CodeGenCoroutines/coro-unhandled-exception.cpp
clang/test/Index/coroutines.cpp
clang/test/SemaCXX/Inputs/std-coroutine.h
clang/test/SemaCXX/co_await-range-for.cpp
clang/test/SemaCXX/coreturn-eh.cpp
clang/test/SemaCXX/coreturn.cpp
clang/test/SemaCXX/coroutine-rvo.cpp
clang/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
clang/test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
clang/test/SemaCXX/coroutines.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d6d0ccaa00be..66856834a98f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10523,7 +10523,13 @@ def err_await_suspend_invalid_return_type : Error<
 def note_await_ready_no_bool_conversion : Note<
   "return type of 'await_ready' is required to be contextually convertible to 
'bool'"
 >;
-}
+def err_coroutine_promise_final_suspend_requires_nothrow : Error<
+  "the expression 'co_await __promise.final_suspend()' is required to be 
non-throwing"
+>;
+def note_coroutine_function_declare_noexcept : Note<
+  "must be declared with 'noexcept'"
+>;
+} // end of coroutines issue category
 
 let CategoryName = "Documentation Issue" in {
 def warn_not_a_doxygen_trailing_member_comment : Warning<

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 8c8e981e6065..88dd0d453883 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1697,6 +1697,10 @@ class Sema final {
   static QualType GetTypeFromParser(ParsedType Ty,
 TypeSourceInfo **TInfo = nullptr);
   CanThrowResult canThrow(const Stmt *E);
+  /// Determine whether the callee of a particular function call can throw.
+  /// E, D and Loc are all optional.
+  static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
+   SourceLocation Loc = SourceLocation());
   const FunctionProtoType *ResolveExceptionSpec(SourceLocation Loc,
 const FunctionProtoType *FPT);
   void UpdateExceptionSpec(FunctionDecl *FD,

diff  --git a/clang

[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-22 Thread Alexey Lapshin via Phabricator via cfe-commits
avl marked 4 inline comments as done.
avl added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:130
+IsNocapture = true;
+  else if (Function *CalledFunction = CB.getCalledFunction()) {
+if (CalledFunction->getBasicBlockList().size() > 0 &&

efriedma wrote:
> Please don't add code to examine the callee; if we're not deducing nocapture 
> appropriately, we should fix that elsewhere.
Ok. 



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:335
+II->getIntrinsicID() == Intrinsic::assume)
+  return true;
+

efriedma wrote:
> What is the new handling for lifetime.end/assume doing?
They are just skipped. In following test case:


```
  call void @_Z5test5i(i32 %sub)
  call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %1) #5
  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0) #5
  br label %return

```

they are generated in between call and ret. It is safe to ignore them while 
checking whether transformation is possible.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:825
+  // The local stack holds all alloca instructions and all byval arguments.
+  AllocaDerivedValueTracker Tracker;
+  for (Argument &Arg : F.args()) {

efriedma wrote:
> Do you have to redo the AllocaDerivedValueTracker analysis?  Is it not enough 
> that the call you're trying to TRE is marked "tail"?
>Do you have to redo the AllocaDerivedValueTracker analysis?

AllocaDerivedValueTracker analysis(done in markTails) could be reused here. 
But marking, done in markTails(), looks like separate tasks. i.e. it is better 
to make TRE not depending on markTails(). There is a review for this - 
https://reviews.llvm.org/D60031
Thus such separation looks useful(To not reuse result of markTails but have it 
computed inplace).

> Is it not enough that the call you're trying to TRE is marked "tail"?

It is not enough that call which is subject to TRE is marked "Tail".
It also should be checked that other calls does not capture pointer to local 
stack: 

```
// do not do TRE if any pointer to local stack has escaped.
if (!Tracker.EscapePoints.empty())
   return false;

```




Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:852
+
+// Do not do TRE if exists recursive calls which are not last calls.
+if (!isTailBlock(CI->getParent()) ||

efriedma wrote:
> I thought we had some tests where we TRE in the presence of recursive calls, 
> like a simple recursive fibonacci.  Am I misunderstanding this?
right, there is a testcase for fibonacchi:

llvm/test/Transforms/TailCallElim/accum_recursion.ll:@test3_fib

areAllLastFuncCallsRecursive() checking works well for fibonacci testcase:


```
return fib(x-1)+fib(x-2);

```

Since, Last funcs call chain is : fib()->fib()->ret. 
That check should prevent from such cases:


```
return fib(x-1)+another_call()+fib(x-2);
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-22 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added inline comments.



Comment at: clang/lib/Sema/SemaCUDA.cpp:753
 return;
+  if (LI.Default == LCD_None && LI.Captures.size() == 0) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));

There should at least be a flag to enable capturing lambdas to be implicitly 
HD. I dont really understand the rational for making capturing lambdas not 
implicitly HD. It seems like its trying to prevent using an address to host on 
the device, but I dont see how this prevents that at all. 

This will also break the compilation in rocm. Should we use a fork of llvm to 
compile rocm?


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

https://reviews.llvm.org/D78655



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


[PATCH] D81869: Modify FPFeatures to use delta not absolute settings to solve PCH compatibility problems

2020-06-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 6 inline comments as done.
mibintc added a subscriber: yaxunl.
mibintc added a comment.

@rjmccall I added some inline questions and comments for you.  Thanks a lot for 
your review.




Comment at: clang/include/clang/AST/ExprCXX.h:172
+  FPOptionsOverride getFPFeatures() const {
+return FPOptionsOverride(CXXOperatorCallExprBits.FPFeatures);
   }

It seems that this field is  basically not used, if I eliminate all these 
member functions then the AST reader-writer fails but the information isn't 
being used in Sema or Codegen. I guess there's a bug somewhere if this 
information is actually needed when creating Float comparison codegen.  Also,, 
from reading the comments in this file it sems that it is needed only when 
"rewrite == operator into OperatorCall as required by CXX20", the comments also 
say that the OperatorCall rewrite could equally have occurred as a rewrite into 
a BinaryOperator.  If we choose to rewrite the == as BinaryOperator then it 
wouldn't be necessary to use TrailingStorage to hold FPOptionsOverride.  The 
previously proposed revision didn't  adding TrailingStorage on CXXOperatorCall. 
 When I was working on a different patch I did study how to add TrailingStorage 
to a Call and I didn't know how I could accomplish that. 



Comment at: clang/include/clang/AST/Stmt.h:620
+//unsigned FPFeatures : 21;
+unsigned FPFeatures : 32;
   };

This is a temporary change, I know you don't want me to change the assert to 
allow a wider size than 8. So if this information is really needed (as I 
mentioned above it's not being used in Sema or Codegen) then alternatives are
1. rewrite the == comparison using BinaryOperator
2. put the FPFeatures Override into TrailingStorage (i think i will need 
implementation guidance if this is the path to go)



Comment at: clang/include/clang/AST/Stmt.h:1121
   Stmt(StmtClass SC) {
-static_assert(sizeof(*this) <= 8,
+static_assert(sizeof(*this) <= 16,
   "changing bitfields changed sizeof(Stmt)");

this is a temporary change



Comment at: clang/include/clang/Basic/LangOptions.def:192
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
-COMPATIBLE_LANGOPT(FastMath  , 1, 0, "fast FP math optimizations, and 
__FAST_MATH__ predefined macro")
-COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined 
macro")
-COMPATIBLE_LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
-COMPATIBLE_LANGOPT(AllowFPReassoc, 1, 0, "Permit Floating Point 
reassociation")
-COMPATIBLE_LANGOPT(NoHonorNaNs   , 1, 0, "Permit Floating Point 
optimization without regard to NaN")
-COMPATIBLE_LANGOPT(NoHonorInfs   , 1, 0, "Permit Floating Point 
optimization without regard to infinities")
-COMPATIBLE_LANGOPT(NoSignedZero  , 1, 0, "Permit Floating Point 
optimization without regard to signed zeros")
-COMPATIBLE_LANGOPT(AllowRecip, 1, 0, "Permit Floating Point 
reciprocal")
-COMPATIBLE_LANGOPT(ApproxFunc, 1, 0, "Permit Floating Point 
approximation")
+BENIGN_LANGOPT(FastMath  , 1, 0, "fast FP math optimizations, and 
__FAST_MATH__ predefined macro")
+BENIGN_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined 
macro")

Here's another problem, I added the test case from bug 46166 @yaxunl but that 
test case reports incompatibility because the pch is compiled with different 
settings than where it is used. I thought maybe based on the name, 
BENIGN_LANGOPT would  allow different option values to not get the pch 
complaint but that didn't work, clang still complained about the different 
option values.  Is there some existing way to get around the option complaint 
or do I need to invent a new field in the LANGOPT e.g. a boolean that says 
"Allow opton values to differ between pch-create and pch-use".  I haven't 
deeply studied this to see if I'm missing something. I wanted to send this out 
to get comments on my other questions 



Comment at: clang/include/clang/Basic/LangOptions.h:455
+  llvm::errs() << "\n RoundingMode " <<
+static_cast(getRoundingMode());
+  llvm::errs() << "\n FPExceptionMode " << getFPExceptionMode();

Using #define OPTION trick would be preferrable except there is a compilation 
failure because something funny about RoundingMode--need the cast. doubtless 
there is fix for that



Comment at: clang/lib/Parse/ParsePragma.cpp:657
 
-  Actions.ActOnPragmaFPContract(FPC);
-  ConsumeAnnotationToken();
+  SourceLocation PragmaLoc = ConsumeAnnotationToken();
+  Actions.ActOnPragmaFPContract(PragmaLoc, FPC);

Note: This patch is putting all the pragma's that modify floating point state 
into the FpPragmaStack, using the "Set" call to set the top value of the FP 
pragma stack.  Of course the pragma's that affect the

[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D79830#2107404 , @LukeZhuang wrote:

> Thank you very much!


Turns out when I was validating my patch, someone had beaten me to it, it 
should be fixed, it just wasn't me :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D81869: Modify FPFeatures to use delta not absolute settings to solve PCH compatibility problems

2020-06-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 272536.
mibintc added a comment.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.

This revision rewrites FPOptionsOverride like @rjmccall suggests.  There are a 
couple problems, i'll add inline comments in the trouble areas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81869

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/SemaOpenCL/fp-options.cl
  llvm/include/llvm/ADT/FloatingPointMode.h

Index: llvm/include/llvm/ADT/FloatingPointMode.h
===
--- llvm/include/llvm/ADT/FloatingPointMode.h
+++ llvm/include/llvm/ADT/FloatingPointMode.h
@@ -40,6 +40,7 @@
   NearestTiesToAway = 4,///< roundTiesToAway.
 
   // Special values.
+  Unset = 6,  ///< Denotes an unset value, (for clang, must fit in 3 bits)
   Dynamic = 7,///< Denotes mode unknown at compile time.
   Invalid = -1///< Denotes invalid value.
 };
Index: clang/test/SemaOpenCL/fp-options.cl
===
--- /dev/null
+++ clang/test/SemaOpenCL/fp-options.cl
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -finclude-default-header -triple spir-unknown-unknown -emit-pch -o %t.pch
+// RUN: %clang_cc1 %s -cl-no-signed-zeros -triple spir-unknown-unknown -include-pch %t.pch -fsyntax-only -verify
+// expected-no-diagnostics
+
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -3960,7 +3960,7 @@
 }
 
 /// Write an FP_PRAGMA_OPTIONS block for the given FPOptions.
-void ASTWriter::WriteFPPragmaOptions(const FPOptions &Opts) {
+void ASTWriter::WriteFPPragmaOptions(const FPOptionsOverride &Opts) {
   RecordData::value_type Record[] = {Opts.getAsOpaqueInt()};
   Stream.EmitRecord(FP_PRAGMA_OPTIONS, Record);
 }
@@ -4790,7 +4790,7 @@
   WriteReferencedSelectorsPool(SemaRef);
   WriteLateParsedTemplates(SemaRef);
   WriteIdentifierTable(PP, SemaRef.IdResolver, isModule);
-  WriteFPPragmaOptions(SemaRef.getCurFPFeatures());
+  WriteFPPragmaOptions(SemaRef.CurFPFeatureOverrides());
   WriteOpenCLExtensions(SemaRef);
   WriteOpenCLExtensionTypes(SemaRef);
   WriteCUDAPragmas(SemaRef);
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -689,7 +689,7 @@
   E->setOperatorLoc(readSourceLocation());
   E->setCanOverflow(Record.readInt());
   if (hasFP_Features)
-E->setStoredFPFeatures(FPOptions(Record.readInt()));
+E->setStoredFPFeatures(FPOptionsOverride(Record.readInt()));
 }
 
 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
@@ -1072,7 +1072,7 @@
   E->setRHS(Record.readSubExpr());
   E->setOperatorLoc(readSourceLocation());
   if (hasFP_Features)
-E->setStoredFPFeatures(FPOptions(Record.readInt()));
+E->setStoredFPFeatures(FPOptionsOverride(Record.readInt()));
 }
 
 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -7843,7 +7843,9 @@
   // FIXME: What happens if these are changed by a module import?
   if (!FPPragmaOptions.empty()) {
 assert(FPPragmaOptions.size() == 1 && "Wrong number of FP_PRAGMA_OPTIONS");
-SemaObj->CurFPFeatures = FPOptions(FPPragmaOptions[0]);
+FPOptionsOverride NewOverrides(FPPragmaOptions[0]);
+SemaObj->CurFPFeatures =
+NewOverrides.applyOverrides(SemaObj->getLangOpt

[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 272539.
yaxunl added a comment.

Only make non-capturing lambda host and device by default.


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

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__device__ int gvar;
+
+// non-capturing lambda is implicitly host device function.
+auto global_lambda = [] () { return 123; };
+
+auto global_lambda2 = [gvar=gvar] () { return gvar; };
+// expected-note@-1{{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+template
+__global__ void kernel(F f) { f(); }
+// expected-error@-1 7{{no matching function for call to object of type}}
+
+constexpr __host__ __device__ void hd();
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+
+  int b;
+  kernel<<<1,1>>>(global_lambda);
+
+  kernel<<<1,1>>>(global_lambda2);
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+
+  kernel<<<1,1>>>([](){ hd(); });
+
+  kernel<<<1,1>>>([=](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([b](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([&]()constexpr{ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([&](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([=, &b](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([&, b](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([](){
+  auto f = [&]{ hd(); };
+  f();
+  });
+
+  return 0;
+}
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -17,6 +17,19 @@
   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
 };
 
+#ifdef __HIP__
+typedef struct hipStream *hipStream_t;
+typedef enum hipError {} hipError_t;
+int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+ size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
+  dim3 blockDim, void **args,
+  size_t sharedMem,
+  hipStream_t stream);
+#else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
 
@@ -29,6 +42,

[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-06-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:4781-4784
+/// This represents the '#pragma omp tile' loop transformation directive.
+class OMPTileDirective final
+: public OMPLoopDirective,
+  private llvm::TrailingObjects {

Meinersbur wrote:
> ABataev wrote:
> > Not sure that this is a good idea to treat this directive as the executable 
> > directive. To me, it looks like kind of `AttributedStmt`. Maybe better to 
> > introduce some kind of a new base node for this and similar constructs, 
> > which does not own the loop but is its kind of attribute-like entity?
> > Also, can we have something like:
> > ```
> > #pragma omp simd
> > #pragma omp tile ...
> > for(...) ;
> > ```
> > Thoughts?
> While not executed at runtime, syntactically it is parsed like a executable 
> (loop-associated) directive. IMHO it does 'own' the loop, but produces 
> another one for to be owned(/associated) by a different directive, as in your 
> tile/simd example, which should already work. Allowing this was the 
> motivation to do the transformation on the AST-level for now.
I'm not saying that we should separate parsing of this directive from others, 
it is just better to treat this directive as a little bit different node. 
Currently, it introduces too many changes in the base classes. Better to create 
a new base class, that does not relies on `CapturedStmt` as the base, and 
derive `OMPExecutableDirective` and this directive and other similar (+ maybe, 
`OMPSimdDirective`) from this new base class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 272530.
kpn added a comment.

Remove debugging command left in accidentally. Rebase.


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

https://reviews.llvm.org/D80952

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/CodeGen/aarch64-neon-misc-constrained.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
  clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
  clang/test/CodeGen/arm64-vrnd-constrained.c
  clang/test/CodeGen/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarch64-neon-misc-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -935,6 +935,19 @@
 setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO));
   }
 
+  if (!getTarget().hasStrictFP()) {
+if (getLangOpts().getFPRoundingMode() !=
+llvm::RoundingMode::NearestTiesToEven) {
+  getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_rounding);
+  getLangOpts().setFPRoundingMode(llvm::RoundingMode::NearestTiesToEven);
+}
+if (getLangOpts().getFPExceptionMode() 

[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-22 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:130
+IsNocapture = true;
+  else if (Function *CalledFunction = CB.getCalledFunction()) {
+if (CalledFunction->getBasicBlockList().size() > 0 &&

Please don't add code to examine the callee; if we're not deducing nocapture 
appropriately, we should fix that elsewhere.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:335
+II->getIntrinsicID() == Intrinsic::assume)
+  return true;
+

What is the new handling for lifetime.end/assume doing?



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:825
+  // The local stack holds all alloca instructions and all byval arguments.
+  AllocaDerivedValueTracker Tracker;
+  for (Argument &Arg : F.args()) {

Do you have to redo the AllocaDerivedValueTracker analysis?  Is it not enough 
that the call you're trying to TRE is marked "tail"?



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:852
+
+// Do not do TRE if exists recursive calls which are not last calls.
+if (!isTailBlock(CI->getParent()) ||

I thought we had some tests where we TRE in the presence of recursive calls, 
like a simple recursive fibonacci.  Am I misunderstanding this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-22 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang added a comment.

Thank you very much!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D78759: Add Statically Linked Libraries

2020-06-22 Thread Aaron Enye Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bafb0adcf38: Add Statically Linked Libraries (authored by 
ashi1).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D78759?vs=271220&id=272526#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78759

Files:
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/test/Driver/bindings.c
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-link-static-library.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip

Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- /dev/null
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -0,0 +1,84 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   --emit-static-lib -nogpulib \
+// RUN:   -fuse-ld=lld -fgpu-rdc -nogpuinc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// emit objects for host side path
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
+// CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
+// CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
+
+// generate image for device side path on gfx803
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
+// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
+// CHECK-SAME: "-target-cpu" "gfx803"
+// CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[A_SRC]]
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
+// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
+// CHECK-SAME: "-target-cpu" "gfx803"
+// CHECK-SAME: {{.*}} "-o" [[B_BC1:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[B_SRC]]
+
+// CHECK-NOT: "*.llvm-link"
+// CHECK-NOT: ".*opt"
+// CHECK-NOT: ".*llc"
+// CHECK: [[LLD: ".*lld"]] {{.*}} "-o" "[[IMG_DEV1:.*out]]" [[A_BC1]] [[B_BC1]]
+
+// generate image for device side path on gfx900
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
+// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
+// CHECK-SAME: "-target-cpu" "gfx900"
+// CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[A_SRC]]
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
+// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
+// CHECK-SAME: "-target-cpu" "gfx900"
+// CHECK-SAME: {{.*}} "-o" [[B_BC2:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[B_SRC]]
+
+// CHECK-NOT: "*.llvm-link"
+// CHECK-NOT: ".*opt"
+// CHECK-NOT: ".*llc"
+// CHECK: [[LLD]] {{.*}} "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+
+// combine images generated into hip fat binary object
+// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
+// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
+// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
+
+// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+
+// CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-link-static-library.hip
===
--- /dev/null
+++ clang/test/Driver/hip-link-static-library.hip
@@ -0,0 +1,27 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: 

[PATCH] D81963: [HIP] Move HIP Linking Logic into HIP ToolChain

2020-06-22 Thread Aaron Enye Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG77df5a8283ed: [HIP] Move HIP Linking Logic into HIP 
ToolChain (authored by ashi1).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D81963?vs=271210&id=272525#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81963

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/Driver/hip-binding.hip
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-link-shared-library.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -12,7 +12,23 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s
 
-// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// emit objects for host side path
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
+// CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
+// CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
+
+// generate image for device side path on gfx803
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
@@ -21,7 +37,7 @@
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
 // CHECK-SAME: "-target-cpu" "gfx803"
 // CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
-// CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
+// CHECK-SAME: {{.*}} [[A_SRC]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
@@ -32,7 +48,7 @@
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
 // CHECK-SAME: "-target-cpu" "gfx803"
 // CHECK-SAME: {{.*}} "-o" [[B_BC1:".*bc"]] "-x" "hip"
-// CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
+// CHECK-SAME: {{.*}} [[B_SRC]]
 
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
@@ -40,6 +56,7 @@
 // CHECK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
+// generate image for device side path on gfx900
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-llvm-bc"
@@ -66,23 +83,13 @@
 // CHECK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*.out]]" [[A_BC2]] [[B_BC2]]
 
-// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-emit-obj"
-// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
-// CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
-// CHECK-SAME: {{.*}} [[A_SRC]]
-
-// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-emit-obj"
-// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
-// CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
-// CHECK-SAME: {{.*}} [[B_SRC]]
-
+// combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
-// CHECK-SAME: {{.*}} "-T" "{{.*}}.lk"
+// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+
+// output the executable
+// CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -86,12 +86,22 @@
 
 // LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa

[PATCH] D81736: [openmp] Base of tablegen generated OpenMP common declaration

2020-06-22 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny accepted this revision.
jdenny added a comment.
This revision is now accepted and ready to land.

If you feel reasonably confident that each new DEPENDS is needed, then this 
LGTM.  Otherwise, give it a day to see if anyone with stronger cmake skills 
than me has a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736



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


[PATCH] D82326: [clangd] Disable printing of Value for tag-types on hover

2020-06-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This is both confusing and crashy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82326

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -696,6 +696,18 @@
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Field type initializer.
+   R"cpp(
+  struct X { int x = 2; };
+  X ^[[x]];
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "X x";
+ HI.Type = "struct X";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -978,13 +990,14 @@
 HI.LocalScope = "Foo::";
 HI.Type = "int";
 HI.Definition = "int x";
-HI.Value = "{1}";
+// FIXME: Initializer for x is a DesignatedInitListExpr, hence it 
is
+// of struct type and omitted.
   }},
   {
   R"cpp(// Field, field designator
-struct Foo { int x; };
+struct Foo { int x; int y; };
 int main() {
-  Foo bar = { .^[[x]] = 2 };
+  Foo bar = { .^[[x]] = 2, .y = 2 };
 }
   )cpp",
   [](HoverInfo &HI) {
@@ -994,7 +1007,6 @@
 HI.LocalScope = "Foo::";
 HI.Type = "int";
 HI.Definition = "int x";
-HI.Value = "{2}";
   }},
   {
   R"cpp(// Method call
@@ -1592,7 +1604,6 @@
 HI.LocalScope = "test::";
 HI.Type = "struct Test &&";
 HI.Definition = "Test &&test = {}";
-HI.Value = "{}";
   }},
   {
   R"cpp(// auto on alias
@@ -1651,7 +1662,6 @@
 HI.NamespaceScope = "";
 HI.Name = "foo";
 HI.Type = "cls>>";
-HI.Value = "{}";
   }},
   {
   R"cpp(// type of nested templates.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -341,7 +341,10 @@
   T->isFunctionReferenceType())
 return llvm::None;
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
-  if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx))
+  if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
+  // Disable printing for tag-types, as they are usually confusing and 
might
+  // make clang crash while printing the expressions.
+  Constant.Val.isStruct() || Constant.Val.isUnion())
 return llvm::None;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
@@ -353,7 +356,7 @@
   if (ECD->getInitVal() == Val)
 return llvm::formatv("{0} ({1})", ECD->getNameAsString(), Val).str();
   }
-  return Constant.Val.getAsString(Ctx, E->getType());
+  return Constant.Val.getAsString(Ctx, T);
 }
 
 llvm::Optional printExprValue(const SelectionTree::Node *N,


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -696,6 +696,18 @@
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Field type initializer.
+   R"cpp(
+  struct X { int x = 2; };
+  X ^[[x]];
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "X x";
+ HI.Type = "struct X";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -978,13 +990,14 @@
 HI.LocalScope = "Foo::";
 HI.Type = "int";
 HI.Definition = "int x";
-HI.Value = "{1}";
+// FIXME: Initializer for x is a DesignatedInitListExpr, hence it is
+// of struct type and omitted.
   }},
   {
   R"cpp(// Field, field designator
-struct Foo { int x; };
+struct Foo { int x; int y; };
 int main() {
-  Foo bar = { .^[[x]] = 2 };
+  Foo bar = { .^[[x]] = 2, .y = 2 };
 }
   )cpp",
   [](HoverInfo &HI) {
@@ -994,7 +1007,6 @@
 HI.LocalScope = "Foo::";
 HI.Type = 

[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D78655#2107190 , @yaxunl wrote:

> It seems we can only promote non-capturing lambdas, no matter whether it has 
> enclosing function or not.


I'd be OK with promoting only non-capturing lambdas until we figure out a 
consistent way to deal with the capturing ones.
Or we can promote captured ones, too and rely on postponed diags to guard 
against producing wrong-side code. We may need to improve that a bit anyways. 
E.g. what should we do if I write something like this:

  __device__ int dv;
  int hv;
  
  __host__ __device__ int hd() {
return [a = dv, b=hv](){ return a + b;}();
  }

https://godbolt.org/z/op_FE6 -- NVCC complains about not being able to access 
hv in a device function (which makes sense considering that it converts HD -> D 
after source splitting, but clang happily allows capturing both variables (but 
will likely fail during ptxas due to the fact that there will be no hv on 
device side).


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

https://reviews.llvm.org/D78655



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-22 Thread Warren Ristow via Phabricator via cfe-commits
wristow added inline comments.



Comment at: clang/test/CodeGen/fp-strictfp.cpp:1
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math 
-ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - 
%s | tee /tmp/1 | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 
-verify=exception -emit-llvm -o - %s | FileCheck %s

Need to remove the "tee" command in the pipe sequence.


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

https://reviews.llvm.org/D80952



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


[PATCH] D79755: Implement constexpr BinaryOperator for vector types

2020-06-22 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon closed this revision.
RKSimon added a comment.

Committed at rGb30c16670e428d09a0854a8f418e46a3e705e4d1 
 (with a 
typo in the Differential Revision tag so phab didn't catch it)


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

https://reviews.llvm.org/D79755



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I'll get this fixed, thanks both of you for letting me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D82324: [OPENMP]Dynamic globalization for parallel target regions.

2020-06-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl, jholewinski.
Herald added a project: clang.

Added support for dynamic memory allocation for globalized variables in
case if execution of target regions in parallel is required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82324

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
===
--- clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
+++ clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
@@ -1,9 +1,12 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix SEQ
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-cuda-parallel-target-regions | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix  PAR
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
-// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -fopenmp-cuda-teams-reduction-recs-num=2048 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix SEQ
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -fopenmp-cuda-teams-reduction-recs-num=2048 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix SEQ
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - -fopenmp-cuda-parallel-target-regions | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix PAR
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -fopenmp-cuda-teams-reduction-recs-num=2048 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - -fopenmp-cuda-parallel-target-regions | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix PAR
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
@@ -12,21 +15,21 @@
 // CHECK-DAG: [[TEAM2_REDUCE_TY:%.+]] = type { [{{1024|2048}} x i8], [{{1024|2048}} x float] }
 // CHECK-DAG: [[TEAM3_REDUCE_TY:%.+]] = type { [{{1024|2048}} x i32], [{{1024|2048}} x i16] }
 // CHECK-DAG: [[TEAMS_REDUCE_UNION_TY:%.+]] = type { [[TEAM1_REDUCE_TY]] }
-// CHECK-DAG: [[MAP_TY:%.+]] = type { [128 x i8] }
+// SEQ-DAG: [[MAP_TY:%.+]] = type { [128 x i8] }
 
-// CHECK-DAG: [[KERNEL_PTR:@.+]] = internal addrspace(3) global i8* null
-// CHECK-DAG: [[KERNEL_SHARED1:@

[clang] 77df5a8 - [HIP] Move HIP Linking Logic into HIP ToolChain

2020-06-22 Thread Aaron En Ye Shi via cfe-commits

Author: Aaron En Ye Shi
Date: 2020-06-22T19:48:48Z
New Revision: 77df5a8283edbfc33ad3b12df3bd42d54d7ba4f4

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

LOG: [HIP] Move HIP Linking Logic into HIP ToolChain

This patch is a follow up on https://reviews.llvm.org/D78759.

Extract the HIP Linker script from generic GNU linker,
and move it into HIP ToolChain. Update OffloadActionBuilder
Link actions feature to apply device linking and host linking
actions separately. Using MC Directives, embed the device images
and define symbols.

Reviewers: JonChesterfield, yaxunl

Subscribers: tra, echristo, jdoerfert, msearles, scchan

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/lib/Driver/ToolChains/HIP.h
clang/test/Driver/hip-binding.hip
clang/test/Driver/hip-link-save-temps.hip
clang/test/Driver/hip-link-shared-library.hip
clang/test/Driver/hip-phases.hip
clang/test/Driver/hip-save-temps.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc.hip

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a48761af400f..de732918fc76 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2325,8 +2325,11 @@ class OffloadingActionBuilder final {
 /// Append top level actions generated by the builder.
 virtual void appendTopLevelActions(ActionList &AL) {}
 
-/// Append linker actions generated by the builder.
-virtual void appendLinkActions(ActionList &AL) {}
+/// Append linker device actions generated by the builder.
+virtual void appendLinkDeviceActions(ActionList &AL) {}
+
+/// Append linker host action generated by the builder.
+virtual Action* appendLinkHostActions(ActionList &AL) { return nullptr; }
 
 /// Append linker actions generated by the builder.
 virtual void appendLinkDependences(OffloadAction::DeviceDependences &DA) {}
@@ -2796,17 +2799,45 @@ class OffloadingActionBuilder final {
: ABRT_Success;
 }
 
-void appendLinkDependences(OffloadAction::DeviceDependences &DA) override {
+void appendLinkDeviceActions(ActionList &AL) override {
+  if (DeviceLinkerInputs.size() == 0)
+return;
+
+  assert(DeviceLinkerInputs.size() == GpuArchList.size() &&
+ "Linker inputs and GPU arch list sizes do not match.");
+
   // Append a new link action for each device.
   unsigned I = 0;
   for (auto &LI : DeviceLinkerInputs) {
+// Each entry in DeviceLinkerInputs corresponds to a GPU arch.
 auto *DeviceLinkAction =
 C.MakeAction(LI, types::TY_Image);
-DA.add(*DeviceLinkAction, *ToolChains[0],
-   CudaArchToString(GpuArchList[I]), AssociatedOffloadKind);
+// Linking all inputs for the current GPU arch.
+// LI contains all the inputs for the linker.
+OffloadAction::DeviceDependences DeviceLinkDeps;
+DeviceLinkDeps.add(*DeviceLinkAction, *ToolChains[0],
+CudaArchToString(GpuArchList[I]), AssociatedOffloadKind);
+AL.push_back(C.MakeAction(DeviceLinkDeps,
+DeviceLinkAction->getType()));
 ++I;
   }
+  DeviceLinkerInputs.clear();
+
+  // Create a host object from all the device images by embedding them
+  // in a fat binary.
+  OffloadAction::DeviceDependences DDeps;
+  auto *TopDeviceLinkAction =
+  C.MakeAction(AL, types::TY_Object);
+  DDeps.add(*TopDeviceLinkAction, *ToolChains[0],
+  nullptr, AssociatedOffloadKind);
+
+  // Offload the host object to the host linker.
+  AL.push_back(C.MakeAction(DDeps, 
TopDeviceLinkAction->getType()));
 }
+
+Action* appendLinkHostActions(ActionList &AL) override { return AL.back(); 
}
+
+void appendLinkDependences(OffloadAction::DeviceDependences &DA) override 
{}
   };
 
   /// OpenMP action builder. The host bitcode is passed to the device frontend
@@ -2934,7 +2965,7 @@ class OffloadingActionBuilder final {
   OpenMPDeviceActions.clear();
 }
 
-void appendLinkActions(ActionList &AL) override {
+void appendLinkDeviceActions(ActionList &AL) override {
   assert(ToolChains.size() == DeviceLinkerInputs.size() &&
  "Toolchains and linker inputs sizes do not match.");
 
@@ -2953,6 +2984,14 @@ class OffloadingActionBuilder final {
   DeviceLinkerInputs.clear();
 }
 
+Action* appendLinkHostActions(ActionList &AL) override {
+  // Create wrappe

[clang] 4bafb0a - Add Statically Linked Libraries

2020-06-22 Thread Aaron En Ye Shi via cfe-commits

Author: Aaron En Ye Shi
Date: 2020-06-22T19:48:49Z
New Revision: 4bafb0adcf38cf268208ea58eb7e11402d5632e2

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

LOG: Add Statically Linked Libraries

Add GNU Static Lib Tool, which supports the --emit-static-lib
flag. For HIP, a static library archive will be created and
consist of HIP Fat Binary host object with the device images embedded.
Using llvm-ar to create the static archive. Also, delete existing
output file to ensure a new archive is created each time.

Reviewers: yaxunl, tra, rjmccall, echristo

Subscribers: echristo, JonChesterfield, scchan, msearles

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

Added: 
clang/test/Driver/hip-link-static-library.hip
clang/test/Driver/hip-toolchain-rdc-static-lib.hip

Modified: 
clang/include/clang/Driver/Action.h
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Action.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/test/Driver/bindings.c
clang/test/Driver/hip-link-save-temps.hip

Removed: 




diff  --git a/clang/include/clang/Driver/Action.h 
b/clang/include/clang/Driver/Action.h
index 8ccbb6c2bbfa..27c95c6f89d4 100644
--- a/clang/include/clang/Driver/Action.h
+++ b/clang/include/clang/Driver/Action.h
@@ -73,9 +73,10 @@ class Action {
 OffloadBundlingJobClass,
 OffloadUnbundlingJobClass,
 OffloadWrapperJobClass,
+StaticLibJobClass,
 
 JobClassFirst = PreprocessJobClass,
-JobClassLast = OffloadWrapperJobClass
+JobClassLast = StaticLibJobClass
   };
 
   // The offloading kind determines if this action is binded to a particular
@@ -637,6 +638,17 @@ class OffloadWrapperJobAction : public JobAction {
   }
 };
 
+class StaticLibJobAction : public JobAction {
+  void anchor() override;
+
+public:
+  StaticLibJobAction(ActionList &Inputs, types::ID Type);
+
+  static bool classof(const Action *A) {
+return A->getKind() == StaticLibJobClass;
+  }
+};
+
 } // namespace driver
 } // namespace clang
 

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 90a0c871140a..b024d6a0d3a3 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -548,6 +548,9 @@ class Driver {
   /// handle this action.
   bool ShouldUseFlangCompiler(const JobAction &JA) const;
 
+  /// ShouldEmitStaticLibrary - Should the linker emit a static library.
+  bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const;
+
   /// Returns true if we are performing any kind of LTO.
   bool isUsingLTO() const { return LTOMode != LTOK_None; }
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8ad582c84c60..c6474c1e5ccd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -605,6 +605,8 @@ def hip_link : Flag<["--"], "hip-link">,
 def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, 
gfx906) from the list of devices to compile for. "
"'all' resets the list to its default value.">;
+def emit_static_lib : Flag<["--"], "emit-static-lib">,
+  HelpText<"Enable linker job to emit a static library.">;
 def no_cuda_gpu_arch_EQ : Joined<["--"], "no-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   Alias;
 def cuda_noopt_device_debug : Flag<["--"], "cuda-noopt-device-debug">,

diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index f33ed991f493..7495e08fe6e6 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -139,6 +139,7 @@ class ToolChain {
   mutable std::unique_ptr Flang;
   mutable std::unique_ptr Assemble;
   mutable std::unique_ptr Link;
+  mutable std::unique_ptr StaticLibTool;
   mutable std::unique_ptr IfsMerge;
   mutable std::unique_ptr OffloadBundler;
   mutable std::unique_ptr OffloadWrapper;
@@ -147,6 +148,7 @@ class ToolChain {
   Tool *getFlang() const;
   Tool *getAssemble() const;
   Tool *getLink() const;
+  Tool *getStaticLibTool() const;
   Tool *getIfsMerge() const;
   Tool *getClangAs() const;
   Tool *getOffloadBundler() const;
@@ -174,6 +176,7 @@ class ToolChain {
 
   virtual Tool *buildAssembler() const;
   virtual Tool *buildLinker() const;
+  virtual Tool *buildStaticLibTool() const;
   virtual Tool *getTool(Action::ActionClass AC) const;
 
   /// \name Utilities for implementing subclasses.
@@ -326,6 +

[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-22 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added subscribers: yaxunl, ashi1.
ashi1 added a comment.

Hi, I am getting a compiler error due to this patch. I am using cmake command: 
cmake ../llvm -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra" 
-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" -DLLVM_ENABLE_ASSERTIONS=1 . Could you 
please take a look?

**Error:**
/root/llvm-project/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp: In 
function 'std::tuple 
getBranchWeight(llvm::Intrinsic::ID, llvm::CallInst*, int)':
/root/llvm-project/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp:62:53: 
error: converting to 'std::tuple' from initializer 
list would use explicit constructor 'constexpr std::tuple<_T1, 
_T2>::tuple(_U1&&, _U2&&) [with _U1 = llvm:🆑:opt&; _U2 = 
llvm:🆑:opt&;  = void; _T1 = unsigned int; 
_T2 = unsigned int]'

  return {LikelyBranchWeight, UnlikelyBranchWeight};
  ^

/root/llvm-project/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp:74:33: 
error: converting to 'std::tuple' from initializer 
list would use explicit constructor 'constexpr std::tuple<_T1, 
_T2>::tuple(_U1&&, _U2&&) [with _U1 = unsigned int&; _U2 = unsigned int&; 
 = void; _T1 = unsigned int; _T2 = unsigned int]'

  return {LikelyBW, UnlikelyBW};
  ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-22 Thread Lei Zhang via Phabricator via cfe-commits
antiagainst added inline comments.



Comment at: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp:62
+// __builtin_expect
+return {LikelyBranchWeight, UnlikelyBranchWeight};
+  } else {

FYI: this breaks GCC5: 
https://buildkite.com/mlir/mlir-core/builds/5841#4a7c245b-9841-44aa-a82a-97686b04b672


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.
Herald added a subscriber: wuzish.

Ping?


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

https://reviews.llvm.org/D80952



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


[PATCH] D81408: [builtins] Improve compatibility with 16 bit targets

2020-06-22 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

We don't need to block this on the pre-merge checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81408



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


[PATCH] D81736: [openmp] Base of tablegen generated OpenMP common declaration

2020-06-22 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D81736#2107202 , @jdenny wrote:

> My cmake skills are lacking.  Why are there are so many new DEPENDS 
> relationships where there were none before?  Is it because omp_gen is 
> generating a header file that's included (indirectly) in all those places, 
> where apparently that sort of dependency was unusual?
>
> Have you tried building from a new, empty build directory on your local 
> system?  Can you reproduce the CI fails without this fixup?


Yeah they are needed because of the indirect inclusion of the generated file. I 
could reproduce the failure from an empty build directory. This leads to the 
addition of the different depends in cmake files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736



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


[PATCH] D82029: [Coroutines] Ensure co_await promise.final_suspend() does not throw

2020-06-22 Thread Brian Gesiak via Phabricator via cfe-commits
modocache accepted this revision.
modocache added a comment.
This revision is now accepted and ready to land.

Sweet! Thanks for the reviews/responses, LGTM :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82029



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


[PATCH] D81736: [openmp] Base of tablegen generated OpenMP common declaration

2020-06-22 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

My cmake skills are lacking.  Why are there are so many new DEPENDS 
relationships where there were none before?  Is it because omp_gen is 
generating a header file that's included (indirectly) in all those places, 
where apparently that sort of dependency was unusual?

Have you tried building from a new, empty build directory on your local system? 
 Can you reproduce the CI fails without this fixup?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736



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


[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

In D78655#2107016 , @tra wrote:

> In D78655#2105058 , @yaxunl wrote:
>
> > - lambdas with any lambda-capture (which must therefore have an enclosing 
> > function) inherit the enclosing function's HDness.
>
>
> Nit: *any* capture does not necessarily imply existence of the enclosing 
> function. One can explicitly capture variables in the global scope. E.g.:
>
>   int x;
>   auto l = [x=x](){ return x;};
>


It seems we can only promote non-capturing lambdas, no matter whether it has 
enclosing function or not.


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

https://reviews.llvm.org/D78655



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


[clang] 0dfc8e1 - [X86] Remove encoding value from the X86_FEATURE and X86_FEATURE_COMPAT macro. NFCI

2020-06-22 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-22T11:46:21-07:00
New Revision: 0dfc8e1837e3e3ac06ab8c08fdc08b15e0ae1c2d

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

LOG: [X86] Remove encoding value from the X86_FEATURE and X86_FEATURE_COMPAT 
macro. NFCI

This was orignally done so we could separate the compatibility
values and the llvm internal only features into a separate entries
in the feature array. This was needed when we explicitly had to
convert the feature into the proper 32-bit chunk at every reference
and we didn't want things moving around.

Now everything is in an array and we have helper funtions or macros
to convert encoding to index. So we renumbering is no longer an
issue.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/Support/X86TargetParser.def
llvm/include/llvm/Support/X86TargetParser.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 0092c52b2b23..a0eaf6d1faab 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1518,14 +1518,14 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const 
{
 // X86TargetInfo::hasFeature for a somewhat comprehensive list).
 bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
   return llvm::StringSwitch(FeatureStr)
-#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, true)
+#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, true)
 #include "llvm/Support/X86TargetParser.def"
   .Default(false);
 }
 
 static llvm::X86::ProcessorFeatures getFeature(StringRef Name) {
   return llvm::StringSwitch(Name)
-#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, llvm::X86::ENUM)
+#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, llvm::X86::ENUM)
 #include "llvm/Support/X86TargetParser.def"
   ;
   // Note, this function should only be used after ensuring the value is

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8213ed8a39e1..32e43c295d23 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -11662,7 +11662,7 @@ 
CodeGenFunction::GetX86CpuSupportsMask(ArrayRef FeatureStrs) {
   for (const StringRef &FeatureStr : FeatureStrs) {
 unsigned Feature =
 StringSwitch(FeatureStr)
-#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, VAL)
+#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, llvm::X86::ENUM)
 #include "llvm/Support/X86TargetParser.def"
 ;
 FeaturesMask |= (1ULL << Feature);

diff  --git a/llvm/include/llvm/Support/X86TargetParser.def 
b/llvm/include/llvm/Support/X86TargetParser.def
index 3c2614b33bf3..e228cef760bc 100644
--- a/llvm/include/llvm/Support/X86TargetParser.def
+++ b/llvm/include/llvm/Support/X86TargetParser.def
@@ -125,56 +125,57 @@ X86_CPU_SUBTYPE   ("geode",  AMDPENTIUM_GEODE)
 
 // This macro is used for cpu types present in compiler-rt/libgcc.
 #ifndef X86_FEATURE_COMPAT
-#define X86_FEATURE_COMPAT(VAL, ENUM, STR) X86_FEATURE(VAL, ENUM)
+#define X86_FEATURE_COMPAT(ENUM, STR) X86_FEATURE(ENUM)
 #endif
 
 #ifndef X86_FEATURE
-#define X86_FEATURE(VAL, ENUM)
+#define X86_FEATURE(ENUM)
 #endif
-X86_FEATURE_COMPAT( 0, FEATURE_CMOV,"cmov")
-X86_FEATURE_COMPAT( 1, FEATURE_MMX, "mmx")
-X86_FEATURE_COMPAT( 2, FEATURE_POPCNT,  "popcnt")
-X86_FEATURE_COMPAT( 3, FEATURE_SSE, "sse")
-X86_FEATURE_COMPAT( 4, FEATURE_SSE2,"sse2")
-X86_FEATURE_COMPAT( 5, FEATURE_SSE3,"sse3")
-X86_FEATURE_COMPAT( 6, FEATURE_SSSE3,   "ssse3")
-X86_FEATURE_COMPAT( 7, FEATURE_SSE4_1,  "sse4.1")
-X86_FEATURE_COMPAT( 8, FEATURE_SSE4_2,  "sse4.2")
-X86_FEATURE_COMPAT( 9, FEATURE_AVX, "avx")
-X86_FEATURE_COMPAT(10, FEATURE_AVX2,"avx2")
-X86_FEATURE_COMPAT(11, FEATURE_SSE4_A,  "sse4a")
-X86_FEATURE_COMPAT(12, FEATURE_FMA4,"fma4")
-X86_FEATURE_COMPAT(13, FEATURE_XOP, "xop")
-X86_FEATURE_COMPAT(14, FEATURE_FMA, "fma")
-X86_FEATURE_COMPAT(15, FEATURE_AVX512F, "avx512f")
-X86_FEATURE_COMPAT(16, FEATURE_BMI, "bmi")
-X86_FEATURE_COMPAT(17, FEATURE_BMI2,"bmi2")
-X86_FEATURE_COMPAT(18, FEATURE_AES, "aes")
-X86_FEATURE_COMPAT(19, FEATURE_PCLMUL,  "pclmul")
-X86_FEATURE_COMPAT(20, FEATURE_AVX512VL,"avx512vl")
-X86_FEATURE_COMPAT(21, FEATURE_AVX512BW,"avx512bw")
-X86_FEATURE_COMPAT(22, FEATURE_AVX512DQ,"avx512dq")
-X86_FEATURE_COMPAT(23, FEATURE_AVX512CD,"avx512cd")
-X86_FEATURE_COMPAT(24, FEATURE_AVX512ER,"avx512er")
-X86_FEATURE_COMPAT(25, FEATURE_AVX512PF,"avx512pf")
-X86_FEATURE_COMPAT(26, FEATURE_AVX512VBMI,  "avx512vbmi")
-X86_F

[PATCH] D79167: [SVE][CodeGen] Legalisation of vsetcc with scalable types

2020-06-22 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.

LGTM


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

https://reviews.llvm.org/D79167



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


[PATCH] D82317: [Clang/Test]: Update tests where `frozen` attribute is necessary

2020-06-22 Thread Gui Andrade via Phabricator via cfe-commits
guiand created this revision.
Herald added subscribers: cfe-commits, sstefan1, phosek, kerbowa, luismarques, 
apazos, sameer.abuasal, pzheng, s.egerton, lenary, dmgreen, Jim, mstorsjo, 
jocewei, PkmX, jfb, arphaman, the_o, brucehoult, MartinMosbeck, rogfer01, 
atanasyan, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb, fedor.sergeev, kbarton, aheejin, sbc100, nhaehnle, 
jvesely, nemanjai, dylanmckay, jyknight, dschuff, emaste.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
guiand added a parent revision: D81678: Introduce frozen attribute at call 
sites for stricter poison analysis.
Herald added a subscriber: wuzish.

The `frozen` attribute generally applies to all scalar function
arguments and return values. In the interest of having Clang's
test suite reflect its codegen, it has been updated to include
the new attribute.

Most tests were updated programatically, although some
required more manual intervention, usually due to regexps or
other complications in parsing. Some tests were too burdensome
to update immediately, and to these were applied a cc1 flag to
mask emitting `frozen` attributes in argument position.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82317

Files:
  clang/test/ARCMT/objcmt-instancetype.m
  clang/test/ARCMT/objcmt-instancetype.m.result
  clang/test/ARCMT/objcmt-numeric-literals.m
  clang/test/ARCMT/objcmt-numeric-literals.m.result
  clang/test/AST/ast-dump-openmp-begin-declare-variant_6.c
  clang/test/ASTMerge/unnamed_fields/test.cpp
  clang/test/Analysis/casts.c
  clang/test/Analysis/inlining/DynDispatchBifurcate.m
  clang/test/Analysis/inlining/InlineObjCClassMethod.m
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/missing-bind-temporary.cpp
  clang/test/Analysis/silence-checkers-and-packages-core-all.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
  clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
  clang/test/CXX/drs/dr0xx.cpp
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CXX/special/class.copy/p3.cpp
  clang/test/CodeGen/2004-02-13-Memset.c
  clang/test/CodeGen/2004-06-17-UnorderedCompares.c
  clang/test/CodeGen/2006-05-19-SingleEltReturn.c
  clang/test/CodeGen/2007-02-25-C-DotDotDot.c
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/2008-03-05-syncPtr.c
  clang/test/CodeGen/2008-07-29-override-alias-decl.c
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
  clang/test/CodeGen/2009-02-13-zerosize-union-field.c
  clang/test/CodeGen/2009-05-04-EnumInreg.c
  clang/test/CodeGen/2009-09-24-SqrtErrno.c
  clang/test/CodeGen/3dnow-builtins.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/PR3589-freestanding-libcalls.c
  clang/test/CodeGen/_Bool-conversion.c
  clang/test/CodeGen/aapcs-align.cpp
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-args.cpp
  clang/test/CodeGen/aarch64-byval-temp.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-dot-product.c
  clang/test/CodeGen/aarch64-neon-extract.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/aarch64-varargs-ms.c
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-param.c
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/arc/arguments.c
  clang/test/CodeGen/arc/struct-align.c
  clang/test/CodeGen/arm-aapcs-vfp.c
  clang/test/CodeGen/arm-abi-vector.c
  clang/test/CodeGen/arm-arguments.c
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-byval-align.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/CodeGen/arm-float-helpers.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-homogenous

Re: [clang] 028571d - [clang][Driver] Correct tool search path priority

2020-06-22 Thread David Spickett via cfe-commits
Thanks for the heads up Nico. Yes that was a mistake, it was reviewed
as https://reviews.llvm.org/D79842 but somehow I told arc to land it
as the duplicate diff instead.

I'll look into the failure.

On Mon, 22 Jun 2020 at 13:48, Nico Weber  wrote:
>
> Hi,
>
> https://reviews.llvm.org/D79988 is apparently a "Restricted Differential 
> Revision" and I don't have permissions to do that. This being an open source 
> project, this is not something we do. I'm guessing it's not intentional?
>
> This also breaks check-clang on macOS: 
> http://45.33.8.238/mac/15950/step_7.txt Please take a look and revert if it 
> takes a while to investigate.
>
> Nico
>
> On Mon, Jun 22, 2020 at 4:41 AM David Spickett via cfe-commits 
>  wrote:
>>
>>
>> Author: David Spickett
>> Date: 2020-06-22T09:41:13+01:00
>> New Revision: 028571d60843cb87e2637ef69ee09090d4526c62
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/028571d60843cb87e2637ef69ee09090d4526c62
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/028571d60843cb87e2637ef69ee09090d4526c62.diff
>>
>> LOG: [clang][Driver] Correct tool search path priority
>>
>> Summary:
>> As seen in:
>> https://bugs.llvm.org/show_bug.cgi?id=45693
>>
>> When clang looks for a tool it has a set of
>> possible names for it, in priority order.
>> Previously it would look for these names in
>> the program path. Then look for all the names
>> in the PATH.
>>
>> This means that aarch64-none-elf-gcc on the PATH
>> would lose to gcc in the program path.
>> (which was /usr/bin in the bug's case)
>>
>> This changes that logic to search each name in both
>> possible locations, then move to the next name.
>> Which is more what you would expect to happen when
>> using a non default triple.
>>
>> (-B prefixes maybe should follow this logic too,
>> but are not changed in this patch)
>>
>> Subscribers: kristof.beyls, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D79988
>>
>> Added:
>> clang/test/Driver/program-path-priority.c
>>
>> Modified:
>> clang/lib/Driver/Driver.cpp
>> clang/test/lit.cfg.py
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
>> index a48761af400f..27477553963c 100644
>> --- a/clang/lib/Driver/Driver.cpp
>> +++ b/clang/lib/Driver/Driver.cpp
>> @@ -4717,13 +4717,11 @@ void Driver::generatePrefixedToolNames(
>>  }
>>
>>  static bool ScanDirForExecutable(SmallString<128> &Dir,
>> - ArrayRef Names) {
>> -  for (const auto &Name : Names) {
>> -llvm::sys::path::append(Dir, Name);
>> -if (llvm::sys::fs::can_execute(Twine(Dir)))
>> -  return true;
>> -llvm::sys::path::remove_filename(Dir);
>> -  }
>> + const std::string &Name) {
>> +  llvm::sys::path::append(Dir, Name);
>> +  if (llvm::sys::fs::can_execute(Twine(Dir)))
>> +return true;
>> +  llvm::sys::path::remove_filename(Dir);
>>return false;
>>  }
>>
>> @@ -4736,8 +4734,9 @@ std::string Driver::GetProgramPath(StringRef Name, 
>> const ToolChain &TC) const {
>>for (const auto &PrefixDir : PrefixDirs) {
>>  if (llvm::sys::fs::is_directory(PrefixDir)) {
>>SmallString<128> P(PrefixDir);
>> -  if (ScanDirForExecutable(P, TargetSpecificExecutables))
>> -return std::string(P.str());
>> +  for (const auto &TargetSpecificExecutable : TargetSpecificExecutables)
>> +if (ScanDirForExecutable(P, TargetSpecificExecutable))
>> +  return std::string(P.str());
>>  } else {
>>SmallString<128> P((PrefixDir + Name).str());
>>if (llvm::sys::fs::can_execute(Twine(P)))
>> @@ -4746,17 +4745,25 @@ std::string Driver::GetProgramPath(StringRef Name, 
>> const ToolChain &TC) const {
>>}
>>
>>const ToolChain::path_list &List = TC.getProgramPaths();
>> -  for (const auto &Path : List) {
>> -SmallString<128> P(Path);
>> -if (ScanDirForExecutable(P, TargetSpecificExecutables))
>> -  return std::string(P.str());
>> -  }
>> +  for (const auto &TargetSpecificExecutable : TargetSpecificExecutables) {
>> +// For each possible name of the tool look for it in
>> +// program paths first, then the path.
>> +// Higher priority names will be first, meaning that
>> +// a higher priority name in the path will be found
>> +// instead of a lower priority name in the program path.
>> +// E.g. -gcc on the path will be found instead
>> +// of gcc in the program path
>> +for (const auto &Path : List) {
>> +  SmallString<128> P(Path);
>> +  if (ScanDirForExecutable(P, TargetSpecificExecutable))
>> +return std::string(P.str());
>> +}
>>
>> -  // If all else failed, search the path.
>> -  for (const auto &TargetSpecificExecutable : TargetSpecificExecutables)
>> +// Fall back to the path
>>  if (llvm::ErrorOr P =
>>  llvm::sys::findProgramByName(TargetSpe

[PATCH] D81678: Introduce frozen attribute at call sites for stricter poison analysis

2020-06-22 Thread Gui Andrade via Phabricator via cfe-commits
guiand added a comment.

I've added the test change to yet another diff, which you can find here: 
https://reviews.llvm.org/D82317


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce frozen attribute at call sites for stricter poison analysis

2020-06-22 Thread Gui Andrade via Phabricator via cfe-commits
guiand added a comment.

@jdoerfert I've separated out changes to the language reference to 
https://reviews.llvm.org/D82316 as you suggested. I kept the name `frozen` for 
now while we reach a consensus regarding its final name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce frozen attribute at call sites for stricter poison analysis

2020-06-22 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 272489.
guiand added a comment.

I've updated this patch to only include the actual implementation of `frozen`, 
for easier review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp

Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -929,6 +929,7 @@
   case Attribute::StrictFP:
   case Attribute::UWTable:
   case Attribute::NoCfCheck:
+  case Attribute::Frozen:
 break;
   }
 
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -443,6 +443,8 @@
 return "cold";
   if (hasAttribute(Attribute::ImmArg))
 return "immarg";
+  if (hasAttribute(Attribute::Frozen))
+return "frozen";
 
   if (hasAttribute(Attribute::ByVal)) {
 std::string Result;
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -731,6 +731,8 @@
 return bitc::ATTR_KIND_SANITIZE_MEMTAG;
   case Attribute::Preallocated:
 return bitc::ATTR_KIND_PREALLOCATED;
+  case Attribute::Frozen:
+return bitc::ATTR_KIND_FROZEN;
   case Attribute::EndAttrKinds:
 llvm_unreachable("Can not encode end-attribute kinds marker.");
   case Attribute::None:
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1532,6 +1532,8 @@
 return Attribute::SanitizeMemTag;
   case bitc::ATTR_KIND_PREALLOCATED:
 return Attribute::Preallocated;
+  case bitc::ATTR_KIND_FROZEN:
+return Attribute::Frozen;
   }
 }
 
Index: llvm/lib/AsmParser/LLToken.h
===
--- llvm/lib/AsmParser/LLToken.h
+++ llvm/lib/AsmParser/LLToken.h
@@ -196,6 +196,7 @@
   kw_naked,
   kw_nest,
   kw_noalias,
+  kw_frozen,
   kw_nobuiltin,
   kw_nocapture,
   kw_noduplicate,
Index: llvm/lib/AsmParser/LLParser.cpp
===
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -1374,6 +1374,7 @@
 case lltok::kw_inalloca:
 case lltok::kw_nest:
 case lltok::kw_noalias:
+case lltok::kw_frozen:
 case lltok::kw_nocapture:
 case lltok::kw_nonnull:
 case lltok::kw_returned:
@@ -1677,6 +1678,9 @@
 case lltok::kw_inalloca:B.addAttribute(Attribute::InAlloca); break;
 case lltok::kw_inreg:   B.addAttribute(Attribute::InReg); break;
 case lltok::kw_nest:B.addAttribute(Attribute::Nest); break;
+case lltok::kw_frozen:
+  B.addAttribute(Attribute::Frozen);
+  break;
 case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
 case lltok::kw_nocapture:   B.addAttribute(Attribute::NoCapture); break;
 case lltok::kw_nofree:  B.addAttribute(Attribute::NoFree); break;
@@ -1774,6 +1778,9 @@
 }
 case lltok::kw_inreg:   B.addAttribute(Attribute::InReg); break;
 case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
+case lltok::kw_frozen:
+  B.addAttribute(Attribute::Frozen);
+  break;
 case lltok::kw_nonnull: B.addAttribute(Attribute::NonNull); break;
 case lltok::kw_signext: B.addAttribute(Attribute::SExt); break;
 case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
Index: llvm/lib/AsmParser/LLLexer.cpp
===
--- llvm/lib/AsmParser/LLLexer.cpp
+++ llvm/lib/AsmParser/LLLexer.cpp
@@ -696,6 +696,7 @@
   KEYWORD(writeonly);
   KEYWORD(zeroext);
   KEYWORD(immarg);
+  KEYWORD(frozen);
 
   KEYWORD(type);
   KEYWORD(opaque);
Index: llvm/include/llvm/IR/Attributes.td
===
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -39,6 +39,9 @@
 /// Pass structure by value.
 def ByVal : TypeAttr<"byval">;
 
+/// Parameter or return value may not contain unini

[PATCH] D82206: [ARM][BFloat] Implement bf16 get/set_lane without casts to i16 vectors

2020-06-22 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a4feb1d53df: [ARM][BFloat] Implement bf16 get/set_lane 
without casts to i16 vectors (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82206

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-bf16-getset-intrinsics.c

Index: clang/test/CodeGen/arm-bf16-getset-intrinsics.c
===
--- clang/test/CodeGen/arm-bf16-getset-intrinsics.c
+++ clang/test/CodeGen/arm-bf16-getset-intrinsics.c
@@ -1,6 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-feature +neon -target-feature +bf16 -mfloat-abi hard \
 // RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg -instcombine | FileCheck %s
+// RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-feature +neon -target-feature +bf16 -mfloat-abi soft \
+// RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg -instcombine | FileCheck %s
 
 #include 
 
@@ -98,8 +100,8 @@
 
 // CHECK-LABEL: @test_vget_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <4 x bfloat> [[V:%.*]], i32 1
-// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+// CHECK-NEXT:[[VGET_LANE:%.*]] = extractelement <4 x bfloat> [[V:%.*]], i32 1
+// CHECK-NEXT:ret bfloat [[VGET_LANE]]
 //
 bfloat16_t test_vget_lane_bf16(bfloat16x4_t v) {
   return vget_lane_bf16(v, 1);
@@ -107,8 +109,8 @@
 
 // CHECK-LABEL: @test_vgetq_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
-// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+// CHECK-NEXT:[[VGET_LANE:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
+// CHECK-NEXT:ret bfloat [[VGET_LANE]]
 //
 bfloat16_t test_vgetq_lane_bf16(bfloat16x8_t v) {
   return vgetq_lane_bf16(v, 7);
@@ -116,8 +118,8 @@
 
 // CHECK-LABEL: @test_vset_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 1
-// CHECK-NEXT:ret <4 x bfloat> [[TMP0]]
+// CHECK-NEXT:[[VSET_LANE:%.*]] = insertelement <4 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 1
+// CHECK-NEXT:ret <4 x bfloat> [[VSET_LANE]]
 //
 bfloat16x4_t test_vset_lane_bf16(bfloat16_t a, bfloat16x4_t v) {
   return vset_lane_bf16(a, v, 1);
@@ -125,8 +127,8 @@
 
 // CHECK-LABEL: @test_vsetq_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <8 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 7
-// CHECK-NEXT:ret <8 x bfloat> [[TMP0]]
+// CHECK-NEXT:[[VSET_LANE:%.*]] = insertelement <8 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 7
+// CHECK-NEXT:ret <8 x bfloat> [[VSET_LANE]]
 //
 bfloat16x8_t test_vsetq_lane_bf16(bfloat16_t a, bfloat16x8_t v) {
   return vsetq_lane_bf16(a, v, 7);
@@ -143,8 +145,8 @@
 
 // CHECK-LABEL: @test_vduph_laneq_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[VGETQ_LANE:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
-// CHECK-NEXT:ret bfloat [[VGETQ_LANE]]
+// CHECK-NEXT:[[VGET_LANE:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
+// CHECK-NEXT:ret bfloat [[VGET_LANE]]
 //
 bfloat16_t test_vduph_laneq_bf16(bfloat16x8_t v) {
   return vduph_laneq_bf16(v, 7);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -6416,21 +6416,27 @@
   default: break;
   case NEON::BI__builtin_neon_vget_lane_i8:
   case NEON::BI__builtin_neon_vget_lane_i16:
+  case NEON::BI__builtin_neon_vget_lane_bf16:
   case NEON::BI__builtin_neon_vget_lane_i32:
   case NEON::BI__builtin_neon_vget_lane_i64:
   case NEON::BI__builtin_neon_vget_lane_f32:
   case NEON::BI__builtin_neon_vgetq_lane_i8:
   case NEON::BI__builtin_neon_vgetq_lane_i16:
+  case NEON::BI__builtin_neon_vgetq_lane_bf16:
   case NEON::BI__builtin_neon_vgetq_lane_i32:
   case NEON::BI__builtin_neon_vgetq_lane_i64:
   case NEON::BI__builtin_neon_vgetq_lane_f32:
+  case NEON::BI__builtin_neon_vduph_lane_bf16:
+  case NEON::BI__builtin_neon_vduph_laneq_bf16:
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
+  case NEON::BI__builtin_neon_vset_lane_bf16:
   case NEON::BI__builtin_neon_vset_lane_i32:
   case NEON::BI__builtin_neon_vset_lane_i64:
   case NEON::BI__builtin_neon_vset_lane_f32:
   case NEON::BI__builtin_neon_vsetq_lane_i8:
   case NEON::BI__builtin_neon_vsetq_lane_i16:
+  case NEON::BI__builtin_neon_vsetq_lane_bf16:
   case NEON::BI__builtin_neon_vsetq_lane_i32:
   case NEON::BI__builtin_neon_vsetq_lane_i64:
   case NEON::BI__builtin_neon_vsetq_lane_f32:
@@ -6876,12 +6882,16 @@
   case NEON::BI__builtin_neon_vget_lane_i16:
   case NEON:

[PATCH] D82281: [clang-tidy] llvm-twine-local ignores parameters

2020-06-22 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a8b04114480: [clang-tidy] llvm-twine-local ignores 
parameters (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82281

Files:
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine &x);
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to 
use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine &x);
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-22 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37fb86030127: Add support of 
__builtin_expect_with_probability (authored by LukeZhuang, committed by 
erichkeane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-expect-with-probability.cpp
  clang/test/Sema/builtin-expect-with-probability-avr.cpp
  clang/test/Sema/builtin-expect-with-probability.cpp
  llvm/docs/BranchWeightMetadata.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll

Index: llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll
===
--- /dev/null
+++ llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll
@@ -0,0 +1,295 @@
+; RUN: opt -lower-expect -strip-dead-prototypes -S -o - < %s | FileCheck %s
+; RUN: opt -S -passes='function(lower-expect),strip-dead-prototypes' < %s | FileCheck %s
+
+; CHECK-LABEL: @test1(
+define i32 @test1(i32 %x) nounwind uwtable ssp {
+entry:
+  %retval = alloca i32, align 4
+  %x.addr = alloca i32, align 4
+  store i32 %x, i32* %x.addr, align 4
+  %tmp = load i32, i32* %x.addr, align 4
+  %cmp = icmp sgt i32 %tmp, 1
+  %conv = zext i1 %cmp to i32
+  %conv1 = sext i32 %conv to i64
+  %expval = call i64 @llvm.expect.with.probability.i64(i64 %conv1, i64 1, double 8.00e-01)
+  %tobool = icmp ne i64 %expval, 0
+; CHECK: !prof !0, !misexpect !1
+; CHECK-NOT: @llvm.expect.with.probability
+  br i1 %tobool, label %if.then, label %if.end
+
+if.then:  ; preds = %entry
+  %call = call i32 (...) @f()
+  store i32 %call, i32* %retval
+  br label %return
+
+if.end:   ; preds = %entry
+  store i32 1, i32* %retval
+  br label %return
+
+return:   ; preds = %if.end, %if.then
+  %0 = load i32, i32* %retval
+  ret i32 %0
+}
+
+declare i64 @llvm.expect.with.probability.i64(i64, i64, double) nounwind readnone
+
+declare i32 @f(...)
+
+; CHECK-LABEL: @test2(
+define i32 @test2(i32 %x) nounwind uwtable ssp {
+entry:
+  %retval = alloca i32, align 4
+  %x.addr = alloca i32, align 4
+  store i32 %x, i32* %x.addr, align 4
+  %tmp = load i32, i32* %x.addr, align 4
+  %conv = sext i32 %tmp to i64
+  %expval = call i64 @llvm.expect.with.probability.i64(i64 %conv, i64 1, double 8.00e-01)
+  %tobool = icmp ne i64 %expval, 0
+; CHECK: !prof !0, !misexpect !1
+; CHECK-NOT: @llvm.expect.with.probability
+  br i1 %tobool, label %if.then, label %if.end
+
+if.then:  ; preds = %entry
+  %call = call i32 (...) @f()
+  store i32 %call, i32* %retval
+  br label %return
+
+if.end:   ; preds = %entry
+  store i32 1, i32* %retval
+  br label %return
+
+return:   ; preds = %if.end, %if.then
+  %0 = load i32, i32* %retval
+  ret i32 %0
+}
+
+; CHECK-LABEL: @test3(
+define i32 @test3(i32 %x) nounwind uwtable ssp {
+entry:
+  %retval = alloca i32, align 4
+  %x.addr = alloca i32, align 4
+  store i32 %x, i32* %x.addr, align 4
+  %tmp = load i32, i32* %x.addr, align 4
+  %tobool = icmp ne i32 %tmp, 0
+  %lnot = xor i1 %tobool, true
+  %lnot.ext = zext i1 %lnot to i32
+  %conv = sext i32 %lnot.ext to i64
+  %expval = call i64 @llvm.expect.with.probability.i64(i64 %conv, i64 1, double 8.00e-01)
+  %tobool1 = icmp ne i64 %expval, 0
+; CHECK: !prof !0, !misexpect !1
+; CHECK-NOT: @llvm.expect.with.probability
+  br i1 %tobool1, label %if.then, label %if.end
+
+if.then:  ; preds = %entry
+  %call = call i32 (...) @f()
+  store i32 %call, i32* %retval
+  br label %return
+
+if.end:   ; preds = %entry
+  store i32 1, i32* %retval
+  br label %return
+
+return:   ; preds = %if.end, %if.then
+  %0 = load i32, i32* %retval
+  ret i32 %0
+}
+
+; CHECK-LABEL: @test4(
+define i32 @test4(i32 %x) nounwind uwtable ssp {
+entry:
+  %retval = alloca i32, align 4
+  %x.addr = alloca i32, align 4
+  store i32 %x, i32* %x.addr, align 4
+  %tmp = load i32, i32* %x.addr, align 4
+  %tobool = icmp ne i32 %tmp, 0
+  %lnot = xor i1 %tobool, true
+  %lnot1 = xor i1 %lnot, true
+  %lnot.ext = zext i1 %lnot1 to i32
+  %conv = sext i32 %lnot.ext to i64
+  %expval = call i64 @llvm.expect.with.probability.i64(i64 %conv, i64 1, double 8.00e-01)
+  %tobool2 = icmp ne i64 %expval, 0
+; CHECK: !prof !0, !misexpect !1
+; CHECK-NOT: @llvm.expect.with.probability
+  br i1 %tobool2

[PATCH] D82162: [clang-tidy] RenamerClangTidy wont emit fixes in scratch space

2020-06-22 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ae0f5f3e1d4: [clang-tidy] RenamerClangTidy wont emit fixes 
in scratch space (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82162

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -562,3 +562,19 @@
 }
 
 } // namespace redecls
+
+namespace scratchspace {
+#define DUP(Tok) Tok
+#define M1(Tok) DUP(badName##Tok())
+
+// We don't want a warning here as the call to this in Foo is in a scratch
+// buffer so its fix-it wouldn't be applied, resulting in invalid code.
+void badNameWarn();
+
+void Foo() {
+  M1(Warn);
+}
+
+#undef M1
+#undef DUP
+} // namespace scratchspace
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -156,14 +156,17 @@
   // is already in there
   RenamerClangTidyCheck::NamingCheckFailure &Failure =
   NamingCheckFailures[Decl];
-  if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second)
-return;
 
   if (!Failure.ShouldFix())
 return;
 
+  if (SourceMgr && SourceMgr->isWrittenInScratchSpace(FixLocation))
+Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
+
   if (!utils::rangeCanBeFixed(Range, SourceMgr))
 Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
+
+  Failure.RawUsageLocs.insert(FixLocation.getRawEncoding());
 }
 
 void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl, SourceRange Range,
@@ -248,13 +251,15 @@
   if (const auto *Decl =
   Result.Nodes.getNodeAs("classRef")) {
 
-addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange());
+addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange(),
+ Result.SourceManager);
 
 for (const auto *Init : Decl->inits()) {
   if (!Init->isWritten() || Init->isInClassMemberInitializer())
 continue;
   if (const FieldDecl *FD = Init->getAnyMember())
-addUsage(FD, SourceRange(Init->getMemberLocation()));
+addUsage(FD, SourceRange(Init->getMemberLocation()),
+ Result.SourceManager);
   // Note: delegating constructors and base class initializers are handled
   // via the "typeLoc" matcher.
 }
@@ -271,7 +276,7 @@
 // we want instead to replace the next token, that will be the identifier.
 Range.setBegin(CharSourceRange::getTokenRange(Range).getEnd());
 
-addUsage(Decl->getParent(), Range);
+addUsage(Decl->getParent(), Range, Result.SourceManager);
 return;
   }
 
@@ -289,7 +294,7 @@
 // further TypeLocs handled below
 
 if (Decl) {
-  addUsage(Decl, Loc->getSourceRange());
+  addUsage(Decl, Loc->getSourceRange(), Result.SourceManager);
   return;
 }
 
@@ -300,7 +305,7 @@
   SourceRange Range(Ref.getTemplateNameLoc(), Ref.getTemplateNameLoc());
   if (const auto *ClassDecl = dyn_cast(Decl)) {
 if (const NamedDecl *TemplDecl = ClassDecl->getTemplatedDecl())
-  addUsage(TemplDecl, Range);
+  addUsage(TemplDecl, Range, Result.SourceManager);
 return;
   }
 }
@@ -308,7 +313,7 @@
 if (const auto &Ref =
 Loc->getAs()) {
   if (const TagDecl *Decl = Ref.getTypePtr()->getAsTagDecl())
-addUsage(Decl, Loc->getSourceRange());
+addUsage(Decl, Loc->getSourceRange(), Result.SourceManager);
   return;
 }
   }
@@ -317,7 +322,7 @@
   Result.Nodes.getNodeAs("nestedNameLoc")) {
 if (const NestedNameSpecifier *Spec = Loc->getNestedNameSpecifier()) {
   if (const NamespaceDecl *Decl = Spec->getAsNamespace()) {
-addUsage(Decl, Loc->getLocalSourceRange());
+addUsage(Decl, Loc->getLocalSourceRange(), Result.SourceManager);
 return;
   }
 }
@@ -325,7 +330,8 @@
 
   if (const auto *Decl = Result.Nodes.getNodeAs("using")) {
 for (const auto *Shadow : Decl->shadows())
-  addUsage(Shadow->getTargetDecl(), Decl->getNameInfo().getSourceRange());
+  addUsage(Shadow->getTargetDecl(), Decl->getNameInfo().getSourceRange(),
+   Result.SourceManager);
 return;
   }
 
@@ -371,14 +377,14 @@
 // Fix using namespace declarations.
 if (const auto *UsingNS = dyn_cast(Decl))
   addUsage(UsingNS->getNominatedNamespaceAsWritten(),
-   UsingNS->getIden

[PATCH] D82318: Add `FloatingLiteral` to SyntaxTree

2020-06-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas updated this revision to Diff 272492.
eduucaldas added a comment.

removing automatically added include


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82318

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -69,6 +69,10 @@
Language == Lang_CXX20;
   }
 
+  bool isCXX17OrLater() const {
+return Language == Lang_CXX17 || Language == Lang_CXX20;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -1228,6 +1232,91 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, FloatingLiteral) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+1e-2;
+2.;
+.2;
+2.f;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-1e-2
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-2.
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-.2
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-2.f
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, FloatingLiteralHexadecimal) {
+  if (!GetParam().isCXX17OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+0xfp1;
+0xf.p1;
+0x.fp1;
+0xf.fp1f;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xfp1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xf.p1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0x.fp1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xf.fp1f
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, IntegerLiteral) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -22,6 +22,8 @@
 return OS << "CxxNullPtrExpression";
   case NodeKind::IntegerLiteralExpression:
 return OS << "IntegerLiteralExpression";
+  case NodeKind::FloatingLiteralExpression:
+return OS << "FloatingLiteralExpression";
   case NodeKind::PrefixUnaryOperatorExpression:
 return OS << "PrefixUnaryOperatorExpression";
   case NodeKind::PostfixUnaryOperatorExpression:
@@ -195,6 +197,11 @@
   findChild(syntax::NodeRole::IdExpression_id));
 }
 
+syntax::Leaf *syntax::FloatingLiteralExpression::literalToken() {
+  return llvm::cast_or_null(
+  findChild(syntax::NodeRole::LiteralToken));
+}
+
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::LiteralToken));
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -654,6 +654,13 @@
 return true;
   }
 
+  bool WalkUpFromFloatingLiteral(FloatingLiteral *S) {
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
+Builder.foldNode(Builder.getExprRange(S),
+ new (allocator()) syntax::FloatingLiteralExpression, S);
+return true;
+  }
+
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
 Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -45,6 +45,7 @@
   BinaryOperatorExpression,
   CxxNullPtrExpression,
   IntegerLiteralExpression,
+  FloatingLiteralExpression,
   IdExpression,
 
   // Statements.
@@ -254,6 +255,17 @@
   syntax::Leaf *nullPtrKeyword();
 };
 
+/// Expression for floating-point literals. C++ [lex.fcon]
+class FloatingLiteralExpression final : public Expression {
+public:
+  FloatingLiteralExpression()
+  : Expression(NodeKind::FloatingLiteralExpression) {}

[PATCH] D82318: Add `FloatingLiteral` to SyntaxTree

2020-06-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 272492.
eduucaldas added a comment.

removing automatically added include


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82318

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -69,6 +69,10 @@
Language == Lang_CXX20;
   }
 
+  bool isCXX17OrLater() const {
+return Language == Lang_CXX17 || Language == Lang_CXX20;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -1228,6 +1232,91 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, FloatingLiteral) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+1e-2;
+2.;
+.2;
+2.f;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-1e-2
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-2.
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-.2
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-2.f
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, FloatingLiteralHexadecimal) {
+  if (!GetParam().isCXX17OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+0xfp1;
+0xf.p1;
+0x.fp1;
+0xf.fp1f;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xfp1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xf.p1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0x.fp1
+| `-;
+|-ExpressionStatement
+| |-FloatingLiteralExpression
+| | `-0xf.fp1f
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, IntegerLiteral) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -22,6 +22,8 @@
 return OS << "CxxNullPtrExpression";
   case NodeKind::IntegerLiteralExpression:
 return OS << "IntegerLiteralExpression";
+  case NodeKind::FloatingLiteralExpression:
+return OS << "FloatingLiteralExpression";
   case NodeKind::PrefixUnaryOperatorExpression:
 return OS << "PrefixUnaryOperatorExpression";
   case NodeKind::PostfixUnaryOperatorExpression:
@@ -195,6 +197,11 @@
   findChild(syntax::NodeRole::IdExpression_id));
 }
 
+syntax::Leaf *syntax::FloatingLiteralExpression::literalToken() {
+  return llvm::cast_or_null(
+  findChild(syntax::NodeRole::LiteralToken));
+}
+
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::LiteralToken));
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -654,6 +654,13 @@
 return true;
   }
 
+  bool WalkUpFromFloatingLiteral(FloatingLiteral *S) {
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
+Builder.foldNode(Builder.getExprRange(S),
+ new (allocator()) syntax::FloatingLiteralExpression, S);
+return true;
+  }
+
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
 Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -45,6 +45,7 @@
   BinaryOperatorExpression,
   CxxNullPtrExpression,
   IntegerLiteralExpression,
+  FloatingLiteralExpression,
   IdExpression,
 
   // Statements.
@@ -254,6 +255,17 @@
   syntax::Leaf *nullPtrKeyword();
 };
 
+/// Expression for floating-point literals. C++ [lex.fcon]
+class FloatingLiteralExpression final : public Expression {
+public:
+  FloatingLiteralExpression()
+  : Expression(NodeKind::FloatingLiteralExpression) {}
+  static bool classof(const Node *N) 

[PATCH] D79167: [SVE][CodeGen] Legalisation of vsetcc with scalable types

2020-06-22 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 272483.
kmclaughlin added a comment.

Added tests to llvm-ir-to-intrinsic.ll which check the results of compare 
instructions


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

https://reviews.llvm.org/D79167

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll

Index: llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
===
--- llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
+++ llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
@@ -165,6 +165,95 @@
   ret  %min
 }
 
+define  @smin_split_i8( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.b
+; CHECK-NEXT:smin z0.b, p0/m, z0.b, z2.b
+; CHECK-NEXT:smin z1.b, p0/m, z1.b, z3.b
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_split_i16( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:smin z0.h, p0/m, z0.h, z4.h
+; CHECK-NEXT:smin z1.h, p0/m, z1.h, z5.h
+; CHECK-NEXT:smin z2.h, p0/m, z2.h, z6.h
+; CHECK-NEXT:smin z3.h, p0/m, z3.h, z7.h
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_split_i32( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:smin z0.s, p0/m, z0.s, z2.s
+; CHECK-NEXT:smin z1.s, p0/m, z1.s, z3.s
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_split_i64( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:smin z0.d, p0/m, z0.d, z2.d
+; CHECK-NEXT:smin z1.d, p0/m, z1.d, z3.d
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_promote_i8( %a,  %b,  %c) {
+; CHECK-LABEL: smin_promote_i8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:sxtb z1.h, p0/m, z1.h
+; CHECK-NEXT:sxtb z0.h, p0/m, z0.h
+; CHECK-NEXT:smin z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_promote_i16( %a,  %b,  %c) {
+; CHECK-LABEL: smin_promote_i16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:sxth z1.s, p0/m, z1.s
+; CHECK-NEXT:sxth z0.s, p0/m, z0.s
+; CHECK-NEXT:smin z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_promote_i32( %a,  %b,  %c) {
+; CHECK-LABEL: smin_promote_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:sxtw z1.d, p0/m, z1.d
+; CHECK-NEXT:sxtw z0.d, p0/m, z0.d
+; CHECK-NEXT:smin z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
 ;
 ; UMIN
 ;
@@ -213,6 +302,31 @@
   ret  %min
 }
 
+define  @umin_split_i64( %a,  %b,  %c) {
+; CHECK-LABEL: umin_split_i64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:umin z0.d, p0/m, z0.d, z2.d
+; CHECK-NEXT:umin z1.d, p0/m, z1.d, z3.d
+; CHECK-NEXT:ret
+  %cmp = icmp ult  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @umin_promote_i8( %a,  %b,  %c) {
+; CHECK-LABEL: umin_promote_i8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:and z1.h, z1.h, #0xff
+; CHECK-NEXT:and z0.h, z0.h, #0xff
+; CHECK-NEXT:umin z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+  %cmp = icmp ult  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
 ;
 ; SMAX
 ;
@@ -224,8 +338,8 @@
 ; CHECK-NEXT:smax z0.b, p0/m, z0.b, z1.b
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a,  %b
+  ret  %max
 }
 
 define  @smax_i16( %a,  %b,  %c) {
@@ -235,8 +349,8 @@
 ; CHECK-NEXT:smax z0.h, p0/m, z0.h, z1.h
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a,  %b
+  ret  %max
 }
 
 define  @smax_i32( %a,  %b,  %c) {
@@ -246,8 +360,8 @@
 ; CHECK-NEXT:smax z0.s, p0/m, z0.s, z1.s
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a,  %b
+  ret  %max
 }
 
 define  @smax_i64( %a,  %b,  %c) {
@@ -257,8 +371,33 @@
 ; CHECK-NEXT:smax z0.d, p0/m, z0.d, z1.d
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a,  %b
+  ret  %max
+}
+
+define  @smax_split_i32( %a,  %b,  %c) {
+; CHECK-LABEL: smax_split_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:smax z0.s, p0/m, z0.s, z2.s
+; CHECK-NEXT:  

[PATCH] D79167: [SVE][CodeGen] Legalisation of vsetcc with scalable types

2020-06-22 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin added a comment.

In D79167#2098774 , @efriedma wrote:

> Is it possible to write tests for this that don't result in a "max" or "min" 
> operation?  Or does that fail for some other reason?
>
> Otherwise LGTM.


Thanks for reviewing this, @efriedma. It was possible to add tests which don't 
result in a min/max by returning the result of the compare.


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

https://reviews.llvm.org/D79167



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


[clang] 3a4feb1 - [ARM][BFloat] Implement bf16 get/set_lane without casts to i16 vectors

2020-06-22 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-06-22T17:35:43Z
New Revision: 3a4feb1d53df68bed7748a0625b593ba4b5dae32

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

LOG: [ARM][BFloat] Implement bf16 get/set_lane without casts to i16 vectors

Currently, in order to extract an element from a bf16 vector, we cast
the vector to an i16 vector, perform the extraction, and cast the result to
bfloat. This behavior was copied from the old fp16 implementation.

The goal of this patch is to achieve optimal code generation for lane
copying intrinsics in a subsequent patch (LLVM fails to fold certain
combinations of bitcast, insertelement, extractelement and
shufflevector instructions leading to the generation of suboptimal code).

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/arm-bf16-getset-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 289f5ea47b92..42d50f726393 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -190,28 +190,20 @@ def OP_SCALAR_QRDMLAH_LN : Op<(call "vqadd", $p0, (call 
"vqrdmulh", $p1,
 def OP_SCALAR_QRDMLSH_LN : Op<(call "vqsub", $p0, (call "vqrdmulh", $p1,
   (call "vget_lane", $p2, $p3)))>;
 
-multiclass ScalarGetSetLaneOpsF16 {
-  def _GET_LN  : Op<(bitcast scalarTy,
-(call "vget_lane",
-(bitcast "int16x4_t", $p0), $p1))>;
-  def _GET_LNQ : Op<(bitcast scalarTy,
-(call "vget_lane",
-(bitcast "int16x8_t", $p0), $p1))>;
-  def _SET_LN  : Op<(bitcast vectorTy4,
-(call "vset_lane",
-(bitcast "int16_t", $p0),
-(bitcast "int16x4_t", $p1), $p2))>;
-  def _SET_LNQ : Op<(bitcast vectorTy8,
-(call "vset_lane",
-(bitcast "int16_t", $p0),
-(bitcast "int16x8_t", $p1), $p2))>;
-}
-
-defm OP_SCALAR_HALF: ScalarGetSetLaneOpsF16<"float16_t",
-"float16x4_t", "float16x8_t">;
-defm OP_SCALAR_BF16: ScalarGetSetLaneOpsF16<"bfloat16_t",
-"bfloat16x4_t", "bfloat16x8_t">;
+def OP_SCALAR_HALF_GET_LN : Op<(bitcast "float16_t",
+   (call "vget_lane",
+ (bitcast "int16x4_t", $p0), $p1))>;
+def OP_SCALAR_HALF_GET_LNQ : Op<(bitcast "float16_t",
+(call "vget_lane",
+  (bitcast "int16x8_t", $p0), $p1))>;
+def OP_SCALAR_HALF_SET_LN : Op<(bitcast "float16x4_t",
+   (call "vset_lane",
+ (bitcast "int16_t", $p0),
+ (bitcast "int16x4_t", $p1), $p2))>;
+def OP_SCALAR_HALF_SET_LNQ : Op<(bitcast "float16x8_t",
+(call "vset_lane",
+  (bitcast "int16_t", $p0),
+  (bitcast "int16x8_t", $p1), $p2))>;
 
 def OP_DOT_LN
 : Op<(call "vdot", $p0, $p1,
@@ -1918,10 +1910,12 @@ let ArchGuard = 
"defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
   def VGET_HIGH_BF : NoTestOpInst<"vget_high", ".Q", "b", OP_HI>;
   def VGET_LOW_BF  : NoTestOpInst<"vget_low", ".Q", "b", OP_LO>;
 
-  def VGET_LANE_BF : IOpInst<"vget_lane", "1.I", "b", OP_SCALAR_BF16_GET_LN>;
-  def VSET_LANE_BF : IOpInst<"vset_lane", ".1.I", "b", OP_SCALAR_BF16_SET_LN>;
-  def VGET_LANEQ_BF : IOpInst<"vget_lane", "1.I", "Qb", 
OP_SCALAR_BF16_GET_LNQ>;
-  def VSET_LANEQ_BF : IOpInst<"vset_lane", ".1.I", "Qb", 
OP_SCALAR_BF16_SET_LNQ>;
+  def VGET_LANE_BF : IInst<"vget_lane", "1.I", "bQb">;
+  def VSET_LANE_BF : IInst<"vset_lane", ".1.I", "bQb">;
+  def SCALAR_VDUP_LANE_BF : IInst<"vdup_lane", "1.I", "Sb">;
+  def SCALAR_VDUP_LANEQ_BF : IInst<"vdup_laneq", "1QI", "Sb"> {
+let isLaneQ = 1;
+  }
 
   def VLD1_BF : WInst<"vld1", ".(c*!)", "bQb">;
   def VLD2_BF : WInst<"vld2", "2(c*!)", "bQb">;
@@ -1957,18 +1951,6 @@ let ArchGuard = 
"defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
 
 }
 
-let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) && 
!defined(__aarch64__)" in {
-  def SCALAR_VDUP_LANE_BF_A32 : IOpInst<"vduph_lane", "1.I", "b", 
OP_SCALAR_BF16_GET_LN>;
-  def SCALAR_VDUP_LANEQ_BF_A32 : IOpInst<"vduph_laneq", "1.I", "Hb", 
OP_SCALAR_BF16_GET_LNQ>;
-}
-
-let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) && 
defined(__aarch64__)" in 

[clang-tools-extra] 9a8b041 - [clang-tidy] llvm-twine-local ignores parameters

2020-06-22 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-22T18:25:45+01:00
New Revision: 9a8b0411448062e7231a0ee26bd14a3d1c097e9e

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

LOG: [clang-tidy] llvm-twine-local ignores parameters

Ignore paramater declarations of type `::llvm::Twine`, These don't suffer the 
same use after free risks as local twines.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp 
b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
index 63a9314a49e5..907bdcb264bf 100644
--- a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@ namespace llvm_check {
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
index 06eb7613d439..3dcf6abe0c22 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@ class Twine {
 using namespace llvm;
 
 void foo(const Twine &x);
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to 
use-after-free bugs



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


[clang] 37fb860 - Add support of __builtin_expect_with_probability

2020-06-22 Thread Erich Keane via cfe-commits

Author: Zhi Zhuang
Date: 2020-06-22T10:21:28-07:00
New Revision: 37fb860301272d8138d289da5b606115b3fe5a13

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

LOG: Add support of __builtin_expect_with_probability

Add a new builtin-function __builtin_expect_with_probability and
intrinsic llvm.expect.with.probability.
The interface is __builtin_expect_with_probability(long expr, long
expected, double probability).
It is mainly the same as __builtin_expect besides one more argument
indicating the probability of expression equal to expected value. The
probability should be a constant floating-point expression and be in
range [0.0, 1.0] inclusive.
It is similar to builtin-expect-with-probability function in GCC
built-in functions.

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

Added: 
clang/test/CodeGen/builtin-expect-with-probability.cpp
clang/test/Sema/builtin-expect-with-probability-avr.cpp
clang/test/Sema/builtin-expect-with-probability.cpp
llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll

Modified: 
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/docs/BranchWeightMetadata.rst
llvm/docs/LangRef.rst
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index ac9af6028867..c060d49ba338 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -566,6 +566,7 @@ BUILTIN(__builtin___vprintf_chk, "iicC*a", "FP:1:")
 
 BUILTIN(__builtin_unpredictable, "LiLi"   , "nc")
 BUILTIN(__builtin_expect, "LiLiLi"   , "nc")
+BUILTIN(__builtin_expect_with_probability, "LiLiLid", "nc")
 BUILTIN(__builtin_prefetch, "vvC*.", "nc")
 BUILTIN(__builtin_readcyclecounter, "ULLi", "n")
 BUILTIN(__builtin_trap, "v", "nr")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7c72eba8c2c1..d6d0ccaa00be 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10839,4 +10839,12 @@ def err_ext_int_bad_size : 
Error<"%select{signed|unsigned}0 _ExtInt must "
  "have a bit size of at least %select{2|1}0">;
 def err_ext_int_max_size : Error<"%select{signed|unsigned}0 _ExtInt of bit "
  "sizes greater than %1 not supported">;
+
+// errors of expect.with.probability
+def err_probability_not_constant_float : Error<
+   "probability argument to __builtin_expect_with_probability must be constant 
"
+   "floating-point expression">;
+def err_probability_out_of_range : Error<
+   "probability argument to __builtin_expect_with_probability is outside the "
+   "range [0.0, 1.0]">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7943c3f34504..c18f01b75353 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2194,6 +2194,33 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Builder.CreateCall(FnExpect, {ArgValue, ExpectedValue}, "expval");
 return RValue::get(Result);
   }
+  case Builtin::BI__builtin_expect_with_probability: {
+Value *ArgValue = EmitScalarExpr(E->getArg(0));
+llvm::Type *ArgType = ArgValue->getType();
+
+Value *ExpectedValue = EmitScalarExpr(E->getArg(1));
+llvm::APFloat Probability(0.0);
+const Expr *ProbArg = E->getArg(2);
+bool EvalSucceed = ProbArg->EvaluateAsFloat(Probability, CGM.getContext());
+assert(EvalSucceed && "probability should be able to evaluate as float");
+(void)EvalSucceed;
+bool LoseInfo = false;
+Probability.convert(llvm::APFloat::IEEEdouble(),
+llvm::RoundingMode::Dynamic, &LoseInfo);
+llvm::Type *Ty = ConvertType(ProbArg->getType());
+Constant *Confidence = ConstantFP::get(Ty, Probability);
+// Don't generate llvm.expect.with.probability on -O0 as the backend
+// won't use it for anything.
+// Note, we still IRGen ExpectedValue because it could have side-effects.
+if (CGM.getCodeGenOpts().OptimizationLevel == 0)
+  return RValue::get(ArgValue);
+
+Function *FnExpect =
+CGM.getIntrinsic(Intrinsic::expect_with_probability, ArgType);
+Value *Result = Builder.CreateCall(
+FnExpect, {ArgValue, ExpectedValue, Confidence}, "expval");
+return RValue::get(Result);
+  }
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScala

[clang-tools-extra] 6ae0f5f - [clang-tidy] RenamerClangTidy wont emit fixes in scratch space

2020-06-22 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-22T18:26:18+01:00
New Revision: 6ae0f5f3e1d465e6a663a50f2cc077671bc6d097

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

LOG: [clang-tidy] RenamerClangTidy wont emit fixes in scratch space

Prevent fixes being displayed if usages are found in the scratch buffer.
See [[ https://bugs.llvm.org/show_bug.cgi?id=46219 | Fix-It hints are being 
generated in the ScratchBuffer ]].
It may be wise down the line to put in a general fix in clang-tidy to prevent 
ScratchBuffer replacements being applied, but for now this will help.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index e90ab1782b4b..040378d980f1 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -156,14 +156,17 @@ void RenamerClangTidyCheck::addUsage(
   // is already in there
   RenamerClangTidyCheck::NamingCheckFailure &Failure =
   NamingCheckFailures[Decl];
-  if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second)
-return;
 
   if (!Failure.ShouldFix())
 return;
 
+  if (SourceMgr && SourceMgr->isWrittenInScratchSpace(FixLocation))
+Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
+
   if (!utils::rangeCanBeFixed(Range, SourceMgr))
 Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
+
+  Failure.RawUsageLocs.insert(FixLocation.getRawEncoding());
 }
 
 void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl, SourceRange Range,
@@ -248,13 +251,15 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
   if (const auto *Decl =
   Result.Nodes.getNodeAs("classRef")) {
 
-addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange());
+addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange(),
+ Result.SourceManager);
 
 for (const auto *Init : Decl->inits()) {
   if (!Init->isWritten() || Init->isInClassMemberInitializer())
 continue;
   if (const FieldDecl *FD = Init->getAnyMember())
-addUsage(FD, SourceRange(Init->getMemberLocation()));
+addUsage(FD, SourceRange(Init->getMemberLocation()),
+ Result.SourceManager);
   // Note: delegating constructors and base class initializers are handled
   // via the "typeLoc" matcher.
 }
@@ -271,7 +276,7 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
 // we want instead to replace the next token, that will be the identifier.
 Range.setBegin(CharSourceRange::getTokenRange(Range).getEnd());
 
-addUsage(Decl->getParent(), Range);
+addUsage(Decl->getParent(), Range, Result.SourceManager);
 return;
   }
 
@@ -289,7 +294,7 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
 // further TypeLocs handled below
 
 if (Decl) {
-  addUsage(Decl, Loc->getSourceRange());
+  addUsage(Decl, Loc->getSourceRange(), Result.SourceManager);
   return;
 }
 
@@ -300,7 +305,7 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
   SourceRange Range(Ref.getTemplateNameLoc(), Ref.getTemplateNameLoc());
   if (const auto *ClassDecl = dyn_cast(Decl)) {
 if (const NamedDecl *TemplDecl = ClassDecl->getTemplatedDecl())
-  addUsage(TemplDecl, Range);
+  addUsage(TemplDecl, Range, Result.SourceManager);
 return;
   }
 }
@@ -308,7 +313,7 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
 if (const auto &Ref =
 Loc->getAs()) {
   if (const TagDecl *Decl = Ref.getTypePtr()->getAsTagDecl())
-addUsage(Decl, Loc->getSourceRange());
+addUsage(Decl, Loc->getSourceRange(), Result.SourceManager);
   return;
 }
   }
@@ -317,7 +322,7 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
   Result.Nodes.getNodeAs("nestedNameLoc")) {
 if (const NestedNameSpecifier *Spec = Loc->getNestedNameSpecifier()) {
   if (const NamespaceDecl *Decl = Spec->getAsNamespace()) {
-addUsage(Decl, Loc->getLocalSourceRange());
+addUsage(Decl, Loc->getLocalSourceRange(), Result.SourceManager);
 return;
   }
 }
@@ -325,7 +330,8 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
 
   if (const auto *Decl = Result.Nodes.ge

[PATCH] D81736: [openmp] Base of tablegen generated OpenMP common declaration

2020-06-22 Thread Valentin Clement via Phabricator via cfe-commits
clementval requested review of this revision.
clementval added a comment.

@jdoerfert @jdenny I had to add a bunch of dependencies so that the file is 
generated correctly when needed. Do you have any feedback on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736



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


[PATCH] D82141: [sve][acle] Add SVE BFloat16 extensions.

2020-06-22 Thread Francesco Petrogalli via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGef597eda8efc: [sve][acle] Add SVE BFloat16 extensions. 
(authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82141

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfdot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
  clang/utils/TableGen/SveEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll
@@ -0,0 +1,243 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; BFDOT
+;
+
+define  @bfdot_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfdot_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_0_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 0)
+  ret  %out
+}
+
+define  @bfdot_lane_1_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_1_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[1]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 1)
+  ret  %out
+}
+
+define  @bfdot_lane_2_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_2_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[2]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 2)
+  ret  %out
+}
+
+define  @bfdot_lane_3_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_3_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[3]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 3)
+  ret  %out
+}
+
+;
+; BFMLALB
+;
+
+define  @bfmlalb_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfmlalb_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_0_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 0)
+  ret  %out
+}
+
+define  @bfmlalb_lane_1_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_1_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[1]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 1)
+  ret  %out
+}
+
+define  @bfmlalb_lane_2_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_2_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[2]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 2)
+  ret  %out
+}
+
+define  @bfmlalb_lane_3_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_3_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[3]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 3)
+  ret  %out
+}
+
+define  @bfmlalb_lane_4_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_4_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[4]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 4)
+  ret  %out
+}
+
+define  @bfmlalb_lane_5_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_5_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[5]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 5)
+  ret  %out
+}
+
+define  @bfmlalb_lane_6_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_6_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[6]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 6)
+  ret  %out
+}
+
+define  @bfmlalb_lane_7_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_7_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[7]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 7)
+  ret  %out
+}
+
+;
+; BFMLALT
+;
+
+define  @bfmlalt_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalt_f32:
+; CHECK-NEXT:  bfmlalt z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalt( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfmlalt_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalt_lane_0_f32:
+; CHECK-NEXT:  bfmlalt z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = ca

[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-22 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.
This revision is now accepted and ready to land.

Great!




Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:68
+  else
+CmdArgs.push_back("-m wasm32");
+

All the other drivers seem to do `CmdArgs.push_back("-m");` .. 
CmdArgs.push_back("xxx");

I would expect these to be two distinct argument..  in fact I'm not sure how it 
works with once arg that contains a space like this.



Comment at: lld/wasm/Driver.cpp:385
+StringRef s = arg->getValue();
+if (s == "wasm32")
+  config->is64 = false;

aardappel wrote:
> dschuff wrote:
> > any particular reason this shouldn't use the more conventional `-m32`/`m64`?
> > edit: nevermind, this is lld not clang. I'll defer to Sam's opinion on lld 
> > flags.
> Yup, @sbc100 suggested this.
Yeah it looks like gnu ld and lld elf always accept `-m ` from clang.



Comment at: lld/wasm/Driver.cpp:390
+else
+  error("'" + s + "' not a valid target");
+  }

It looks like lld ELF inherits the GNU ld terminology and calls this argument 
"emulation".   

```
  -m emulation
   Emulate the emulation linker.  You can list the available emulations 
with the
   --verbose or -V options.

   If the -m option is not used, the emulation is taken from the 
"LDEMULATION"
   environment variable, if that is defined.

   Otherwise, the default emulation depends upon how the linker was 
configured.


Pretty odd choice of name I think and we probably are ok no to copy that here.

But how about I think I prefer the term "architecture" to target.  Seems a 
little more specific.  

How about: `error("invalid target architecture: " + s);`



Comment at: lld/wasm/InputChunks.cpp:338
 
+  auto WASM_OPCODE_PTR_CONST =
+  config->is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST;

Just use normal variable names here?  `opcode_const` and `opcode_add`?


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

https://reviews.llvm.org/D82130



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


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Support/PrettyStackTrace.cpp:36
 
+static const char *BugReportMsg =
+"PLEASE submit a bug report to " BUG_REPORT_URL

This variable is mutable. Please use `const char BugReportMsg[]`


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

https://reviews.llvm.org/D81672



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


  1   2   >