[PATCH] D74806: [analyzer] NFCi: Refactor CStringChecker: use strongly typed internal API

2020-02-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, baloghadamsoftware, Szelethus.
steakhal added a project: clang.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a reviewer: rengolin.
steakhal edited the summary of this revision.
steakhal updated this revision to Diff 245300.
steakhal added a comment.

Upload the right diff.


CStringChecker is a huge beast.

My effort in improving the analyzer regarding taint analysis is humbled by 
multiple factors.
I wanted to extend the diagnostics of the CStringChecker with taintedness.

In the long run, the diagnostic emitting parts of the `GenericTaintChecker` 
would be migrated to multiple checkers, leaving it's responsibility only to 
*model* taint propagation.
Eg. the `GenericTaintChecker::checkTaintedBufferSize` functionality will be 
mostly part of the CStringChecker.

This plan requires the `CStringChecker` to be refactored to support a more 
flexible reporting mechanism.

This patch does only refactorings, such:

- eliminates always `false` parameters (like `WarnAboutSize`)
- reduces the number of parameters
- makes strong types differentiating *source* and *destination* buffers (same 
with size expressions)
- binds the argument expression and the index, making diagnostics accurate and 
easy to emit
- removes a bunch of default parameters to make it more readable
- remove random `const char *` warning message parameters, making clear where 
and what is going to be emitted

Note that:

- `CheckBufferAccess` now checks *only* one buffer, this removed about 100 LOC 
code duplication
- not every function was refactored to use the /new/ strongly typed API, since 
the CString related functions are really closely coupled monolithic beasts, I 
will refactor them separately
- all tests are preserved and passing; only *the message changed at some 
places*. In my opinion, these messages are holding the same information.

I would also highlight that this refactoring caught a bug in 
`clang/test/Analysis/string.c:454` where the diagnostic did not reflect 
reality. This catch backs my effort on simplifying this monolithic 
CStringChecker.


Repository:
  rC Clang

https://reviews.llvm.org/D74806

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bsd-string.c
  clang/test/Analysis/bstring.c
  clang/test/Analysis/null-deref-ps-region.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -353,7 +353,7 @@
 void strcpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-strcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcpy(x, y); // expected-warning{{String copy function overflows the destination buffer}}
 }
 #endif
 
@@ -394,7 +394,7 @@
 void stpcpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-stpcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+stpcpy(x, y); // expected-warning{{String copy function overflows the destination buffer}}
 }
 #endif
 
@@ -451,19 +451,19 @@
 void strcat_overflow_0(char *y) {
   char x[4] = "12";
   if (strlen(y) == 4)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 
 void strcat_overflow_1(char *y) {
   char x[4] = "12";
   if (strlen(y) == 3)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 
 void strcat_overflow_2(char *y) {
   char x[4] = "12";
   if (strlen(y) == 2)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 #endif
 
@@ -547,25 +547,28 @@
 // of the C-string checker.
 void cstringchecker_bounds_nocrash() {
   char *p = malloc(2);
-  strncpy(p, "AAA", sizeof("AAA")); // expected-warning {{Size argument is greater than the length of the destination buffer}}
+  strncpy(p, "AAA", sizeof("AAA"));
+  // expected-warning@-1 {{String copy function overflows the destination buffer}}
   free(p);
 }
 
 void strncpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+strncpy(x, y, 5);
+// expected-warning@-1 {{String copy function overflows the destination buffer}}
 #ifndef VARIANT
-  // expected-warning@-2{{size argument is too large; destination buffer has size 4, but size argument is 5}}
+// expected-warning@-3 {{size argument is too large; destination bu

[clang] ea789f8 - Remove unused option that gcc ignored

2020-02-18 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2020-02-19T08:36:07+08:00
New Revision: ea789f819f26a1b003a1bf07466fc9fa2fe558ec

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

LOG: Remove unused option that gcc ignored

Reviewers: efriedma, MaskRay

Reviewed By: efriedma, MaskRay

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1a42925ca530..4104a4ae6ed0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3325,9 +3325,6 @@ defm strength_reduce :
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, 
Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, 
Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  
Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  
Group;
-defm tree_loop_linear : BooleanFFlag<"tree_loop_linear">,  
Group;
 defm tree_salias : BooleanFFlag<"tree-salias">, Group;
 defm tree_ter : BooleanFFlag<"tree-ter">, 
Group;
 defm tree_vectorizer_verbose : BooleanFFlag<"tree-vectorizer-verbose">, 
Group;

diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 970b4e934e78..3d0d74ba5ab9 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -291,9 +291,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -431,9 +428,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not 
supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not 
supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported



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


[PATCH] D72825: Remove unused option that gcc ignored

2020-02-18 Thread Jim Lin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea789f819f26: Remove unused option that gcc ignored 
(authored by Jim).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72825

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -291,9 +291,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -431,9 +428,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not 
supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not 
supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3325,9 +3325,6 @@
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, 
Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, 
Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  
Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  
Group;
-defm tree_loop_linear : BooleanFFlag<"tree_loop_linear">,  
Group;
 defm tree_salias : BooleanFFlag<"tree-salias">, Group;
 defm tree_ter : BooleanFFlag<"tree-ter">, 
Group;
 defm tree_vectorizer_verbose : BooleanFFlag<"tree-vectorizer-verbose">, 
Group;


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -291,9 +291,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -431,9 +428,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3325,9 +3325,6 @@
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  Group;
-defm

[PATCH] D74790: [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! I can't see this being a performance problem (famous last words...)




Comment at: clang/lib/Sema/SemaCodeComplete.cpp:8780
+
+  // We need to manually resolve symlinks since the directory_iterator
+  // doesn't do it for us. Alternatively we could use a heuristic such as

I think we can state the problem more directly here:

To know whether a symlink should be treated as file or a directory, we have to 
stat it.
This is cheap enough as there shouldn't be many symlinks.

(I think we can drop the heuristic idea from the comment, it was a silly 
premature optimization)



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:8784
+  // symlinks.
+  auto Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {

nit: expand auto here, "type" is vague and `It` is already auto



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:8786
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+auto FileStatus = FS.status(It->path());
+if (FileStatus) {

nit: inline (`if (auto FileStatus = ...)`)
drop braces around inner if


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74790



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


[PATCH] D74807: Add cl_khr_mipmap_image_writes as supported to AMDGPU

2020-02-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: b-sumner.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

https://reviews.llvm.org/D74807

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


Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -263,6 +263,7 @@
   Opts.support("cl_khr_int64_base_atomics");
   Opts.support("cl_khr_int64_extended_atomics");
   Opts.support("cl_khr_mipmap_image");
+  Opts.support("cl_khr_mipmap_image_writes");
   Opts.support("cl_khr_subgroups");
   Opts.support("cl_khr_3d_image_writes");
   Opts.support("cl_amd_media_ops");


Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -263,6 +263,7 @@
   Opts.support("cl_khr_int64_base_atomics");
   Opts.support("cl_khr_int64_extended_atomics");
   Opts.support("cl_khr_mipmap_image");
+  Opts.support("cl_khr_mipmap_image_writes");
   Opts.support("cl_khr_subgroups");
   Opts.support("cl_khr_3d_image_writes");
   Opts.support("cl_amd_media_ops");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D72231#1881797 , @nickdesaulniers 
wrote:

> In D72231#1881784 , @rjmccall wrote:
>
> > In D72231#1881760 , 
> > @nickdesaulniers wrote:
> >
> > > In D72231#1879347 , @rjmccall 
> > > wrote:
> > >
> > > > In D72231#1878528 , 
> > > > @nathanchance wrote:
> > > >
> > > > > There appear to a be semantic difference between GCC and clang with 
> > > > > the current version of this patch which results in a lot of 
> > > > > additional warnings in the Linux kernel: https://godbolt.org/z/eHFJd8
> > > >
> > > >
> > > > Warning about casting to an enum seems clearly correct and in scope for 
> > > > this warning.  Warning about casting to `_Bool` seems clearly incorrect 
> > > > and should not be warned about at all.
> > >
> > >
> > > Maybe we should only warn if the size of the `void*` is smaller than the 
> > > size of the `enum`? (32b `void*`, 64b `enum`)? 
> > > https://godbolt.org/z/oAts-u
> > >
> > > Otherwise this warning creates a massive mess for us to clean up, and I 
> > > suspect Linux kernel developers will just end up disabling the warning.
> >
> >
> > If deployment is easier if we split out a subgroup that we can turn off, 
> > that seems fine.  But I don't see any good abstract justification for 
> > warning about a cast to `int` and not a cast to an `int`-sized `enum`.  
> > What would the reasoning be, just that the latter "couldn't possibly" be 
> > intended to preserve the original pointer value, so it must be an opaque 
> > value being represented as a `void*`?  That seems pretty weak to me.
>
>
> Less about enums, more about casts to/from void*, since you might use that in 
> place of a union that would be too large to describe.  Specifically, this 
> `struct` is used throughout the kernel for most drivers: 
> https://elixir.bootlin.com/linux/v5.5.4/source/include/linux/mod_devicetable.h#L260
>   It is exceedingly common to stuff whatever data in there: 
> https://elixir.bootlin.com/linux/v5.5.4/source/drivers/ata/ahci_brcm.c#L428 
> so long as the driver is careful not to reinterpret the data as the incorrect 
> type.  Describing such a union for ever possible enum packed in there would 
> not be fun.


No, I understand the pattern, but they must have already done some sort of pass 
over the code to make it warning-clean when they're working with a smaller 
integer type.  Or do they just in practice never store smaller integers in 
there, whereas it's hard to control size with an enum?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D73649: [CodeComplete] Member completion for concept-constrained types.

2020-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added inline comments.



Comment at: clang/lib/Sema/CodeCompleteConsumer.cpp:592
 }
+for (const FixItHint &FixIt : Results[I].FixIts) {
+  const SourceLocation BLoc = FixIt.RemoveRange.getBegin();

(This is just a fix to the -code-complete-at testing facility: it wasn't 
printing fixits for RK_Pattern completions)



Comment at: clang/test/CodeCompletion/concepts.cpp:34
+  // RUN: | FileCheck %s -check-prefix=DOT -implicit-check-not=xxx_t
+  // DOT: Pattern : [#convertible_to#]aaa()
+  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")

nridge wrote:
> Doesn't the presence of the `x` mean we should only get results that start 
> with `x`?
> 
> (Or, if "column 5" actually means we're completing right after the dot, why 
> is the `x` present in the testcase at all -- just so that the line is 
> syntactically well formed?)
Yeah we're completing before the x.
And in fact it doesn't matter, since clang's internal completion engine doesn't 
filter the results using the incomplete identifier (which is what lets clangd 
apply its own fuzzy-matching rules).

I think this is well-enough understood around the CodeCompletion tests and I 
tend to worry about incomplete lines confusing the parser (I don't want to 
repeat this function decl 3 times!), but I can try to drop these if you think 
it makes a big difference.



Comment at: clang/test/CodeCompletion/concepts.cpp:35
+  // DOT: Pattern : [#convertible_to#]aaa()
+  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")
+  // DOT: Pattern : bbb()

nridge wrote:
> Should we be taking completions from just one branch of a logical-or in a 
> requirement?
> 
> To simplify the scenario a bit:
> 
> ```
> template 
>   requires (requires(T t) { t.foo(); } || requires(T t) { t.bar(); })
> void f(T t) {
>   t.^
> }
> ```
> 
> Do we want to be offering both `foo()` and `bar()` as completions here? 
> Logically, it seems we only ought to offer completions from expressions that 
> appear in _both_ branches of the logical-or (so, if `t.foo()` appeared as a 
> requirement in both branches, we could offer `foo()`).
Strictly speaking yes, a function is only guaranteed available if it's in both 
branches.

In practice I think this behavior would be no more useful (probably less 
useful), and obviously more complicated to implement (as we have to track 
result sets for subexpressions to intersect them).

AIUI the language has no way to force you to only use properties guaranteed by 
the constraints. So it's perfectly plausible to write something like (forgive 
suspicious syntax)
```template  requires Dumpable || Printable
void output(const T &val) {
  if constexpr (Dumpable)
val.dump();
  else
val.print();
}```

Or even cases where the same expression is valid in all cases but we lose track 
of that somehow (e.g. T is either a dumb pointer or a smart pointer to a 
constrained type, and our analysis fails on the smart pointer case).

Basically I think we're desperate enough for information in these scenarios 
that we'll accept a little inaccuracy :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73649



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


[clang] 492d4a9 - [NFC] Update the testcase clang_f_opts.c for the removed options

2020-02-18 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2020-02-19T09:28:41+08:00
New Revision: 492d4a992d88516da471b60ecd9a37ea80dbf9a4

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

LOG: [NFC] Update the testcase clang_f_opts.c for the removed options

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 3d0d74ba5ab9..6fb820a9938d 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -364,9 +364,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D72231#1881855 , @rjmccall wrote:

> No, I understand the pattern, but they must have already done some sort of 
> pass over the code to make it warning-clean when they're working with a 
> smaller integer type.  Or do they just in practice never store smaller 
> integers in there, whereas it's hard to control size with an enum?


Unsure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[clang-tools-extra] 28728bf - Fix a signed/unsigned warning promoted to error.

2020-02-18 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2020-02-18T17:49:22-08:00
New Revision: 28728bf06f556dc8be5bc1fa77129906ba68

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

LOG: Fix a signed/unsigned warning promoted to error.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
index d365bbbe3c43..2938e2b9c7cd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -86,7 +86,7 @@ static bool checkParamDeclOfAncestorCallExprHasRValueRefType(
   if (const clang::CallExpr *TheCallExpr =
   tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr,
 Context)) {
-for (int i = 0; i < TheCallExpr->getNumArgs(); ++i) {
+for (unsigned i = 0; i < TheCallExpr->getNumArgs(); ++i) {
   const Expr *Arg = TheCallExpr->getArg(i);
   if (Arg->getSourceRange() == TheCxxConstructExpr->getSourceRange()) {
 if (const auto *TheCallExprFuncProto =



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


[PATCH] D74811: [Driver] Escape the program path for -frecord-command-line

2020-02-18 Thread Ravi Ramaseshan via Phabricator via cfe-commits
ravi-ramaseshan created this revision.
ravi-ramaseshan added reviewers: scott.linder, rjmccall.
Herald added a project: clang.

Similar to the rest of the command line that is recorded, the program
path must also have spaces and backslashes escaped. Without this
parsing the recorded command line becomes hard on platforms like
Windows where spaces and backslashes are common.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74811

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


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5880,7 +5880,7 @@
   Arg->render(Args, OriginalArgs);
 
 SmallString<256> Flags;
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
@@ -6788,7 +6788,7 @@
 
 SmallString<256> Flags;
 const char *Exec = getToolChain().getDriver().getClangProgramPath();
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5880,7 +5880,7 @@
   Arg->render(Args, OriginalArgs);
 
 SmallString<256> Flags;
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
@@ -6788,7 +6788,7 @@
 
 SmallString<256> Flags;
 const char *Exec = getToolChain().getDriver().getClangProgramPath();
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 061f3a5 - P0593R6: Pseudo-destructor expressions end object lifetimes.

2020-02-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-18T18:41:03-08:00
New Revision: 061f3a50dd824f1eb2394d0f699f3f2ee374b21a

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

LOG: P0593R6: Pseudo-destructor expressions end object lifetimes.

This only has an observable effect on constant evaluation.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 641368ebfdd9..9a31b64eedda 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1417,6 +1417,31 @@ static bool isFormalAccess(AccessKinds AK) {
   return isAnyAccess(AK) && AK != AK_Construct && AK != AK_Destroy;
 }
 
+/// Is this kind of axcess valid on an indeterminate object value?
+static bool isValidIndeterminateAccess(AccessKinds AK) {
+  switch (AK) {
+  case AK_Read:
+  case AK_Increment:
+  case AK_Decrement:
+// These need the object's value.
+return false;
+
+  case AK_ReadObjectRepresentation:
+  case AK_Assign:
+  case AK_Construct:
+  case AK_Destroy:
+// Construction and destruction don't need the value.
+return true;
+
+  case AK_MemberCall:
+  case AK_DynamicCast:
+  case AK_TypeId:
+// These aren't really meaningful on scalars.
+return true;
+  }
+  llvm_unreachable("unknown access kind");
+}
+
 namespace {
   struct ComplexValue {
   private:
@@ -3201,9 +3226,8 @@ findSubobject(EvalInfo &Info, const Expr *E, const 
CompleteObject &Obj,
   for (unsigned I = 0, N = Sub.Entries.size(); /**/; ++I) {
 // Reading an indeterminate value is undefined, but assigning over one is 
OK.
 if ((O->isAbsent() && !(handler.AccessKind == AK_Construct && I == N)) ||
-(O->isIndeterminate() && handler.AccessKind != AK_Construct &&
- handler.AccessKind != AK_Assign &&
- handler.AccessKind != AK_ReadObjectRepresentation)) {
+(O->isIndeterminate() &&
+ !isValidIndeterminateAccess(handler.AccessKind))) {
   if (!Info.checkingPotentialConstantExpression())
 Info.FFDiag(E, diag::note_constexpr_access_uninit)
 << handler.AccessKind << O->isIndeterminate();
@@ -5476,6 +5500,8 @@ static bool EvaluateArgs(ArrayRef Args, 
ArgVector &ArgValues,
 }
 }
   }
+  // FIXME: This is the wrong evaluation order for an assignment operator
+  // called via operator syntax.
   for (unsigned Idx = 0; Idx < Args.size(); Idx++) {
 if (!Evaluate(ArgValues[Idx], Info, Args[Idx])) {
   // If we're checking for a potential constant expression, evaluate all
@@ -6936,10 +6962,8 @@ class ExprEvaluatorBase
   } else if (const auto *PDE = dyn_cast(Callee)) {
 if (!Info.getLangOpts().CPlusPlus2a)
   Info.CCEDiag(PDE, diag::note_constexpr_pseudo_destructor);
-// FIXME: If pseudo-destructor calls ever start ending the lifetime of
-// their callee, we should start calling HandleDestruction here.
-// For now, we just evaluate the object argument and discard it.
-return EvaluateObjectArgument(Info, PDE->getBase(), ThisVal);
+return EvaluateObjectArgument(Info, PDE->getBase(), ThisVal) &&
+   HandleDestruction(Info, PDE, ThisVal, PDE->getDestroyedType());
   } else
 return Error(Callee);
   FD = Member;

diff  --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp 
b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index cc6380e044fb..c418767f8d12 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -424,8 +424,26 @@ namespace PseudoDtor {
   int k;
   typedef int I;
   struct T {
-int n : (k.~I(), 1); // cxx11-warning {{constant expression}} cxx11-note 
{{pseudo-destructor}}
+int n : (k.~I(), 1); // expected-error {{constant expression}} 
expected-note {{visible outside that expression}}
   };
+
+  // FIXME: It's unclear whether this should be accepted in C++20 mode. The 
parameter is destroyed twice here.
+  constexpr int f(int a = 1) { // cxx11-error {{constant expression}}
+return (
+a.~I(), // cxx11-note 2{{pseudo-destructor}}
+0);
+  }
+  static_assert(f() == 0, ""); // cxx11-error {{constant expression}} 
cxx11-note {{in call}}
+
+  // This is OK in C++20: the union has no active member after the
+  // pseudo-destructor call, so the union destructor has no effect.
+  union U { int x; };
+  constexpr int g(U u = {1}) { // cxx11-error {{constant expression}}
+return (
+u.x.~I(), // cxx11-note 2{{pseudo-destructor}}
+0);
+  }
+  static_assert(g() == 0, ""); // cxx11-error {{constant expression}} 
cxx11-note {{in call}}
 }
 
 // - increment or decrem

[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

There seems to be still an issue with this patch, when linking the LLVM unit 
tests on a two-stage build, it ends with:

  FAILED: tools/clang/unittests/StaticAnalyzer/StaticAnalysisTests.exe
  cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe 
--intdir=tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir
 --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe 
--mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests  -- 
D:\llvm-project\buildninjaRel\bin\lld-link.exe /nologo 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\AnalyzerOptionsTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\CallDescriptionTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\StoreTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\RegisterCustomCheckersTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\SymbolReaperTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\D_\llvm-project\llvm\resources\windows_version_resource.rc.res
  /out:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.exe 
/implib:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.lib 
/pdb:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.pdb /version:0.0  
/machine:x64 -fuse-ld=lld /STACK:1000 /DEBUG /OPT:REF /OPT:ICF 
/lldltocache:D:/llvm-project/buildninjaRelMiMalloc/lto.cache /INCREMENTAL:NO 
/subsystem:console  lib\LLVMSupport.lib  lib\LLVMSupport.lib  
lib\gtest_main.lib  lib\gtest.lib  lib\clangBasic.lib  lib\clangAnalysis.lib  
lib\clangAST.lib  lib\clangASTMatchers.lib  lib\clangCrossTU.lib  
lib\clangFrontend.lib  lib\clangSerialization.lib  
lib\clangStaticAnalyzerCore.lib  lib\clangStaticAnalyzerFrontend.lib  
lib\clangTooling.lib  lib\clangStaticAnalyzerCheckers.lib  
lib\clangStaticAnalyzerCore.lib  lib\clangCrossTU.lib  lib\clangIndex.lib  
lib\clangFrontend.lib  lib\clangParse.lib  lib\clangSerialization.lib  
lib\clangSema.lib  lib\clangAnalysis.lib  lib\clangASTMatchers.lib  
lib\clangEdit.lib  lib\clangDriver.lib  version.lib  lib\LLVMOption.lib  
lib\clangFormat.lib  lib\clangToolingInclusions.lib  lib\clangToolingCore.lib  
lib\clangAST.lib  lib\LLVMFrontendOpenMP.lib  lib\LLVMTransformUtils.lib  
lib\LLVMAnalysis.lib  lib\LLVMProfileData.lib  lib\LLVMObject.lib  
lib\LLVMBitReader.lib  lib\LLVMMCParser.lib  lib\LLVMTextAPI.lib  
lib\clangRewrite.lib  lib\clangLex.lib  lib\clangBasic.lib  lib\LLVMCore.lib  
lib\LLVMRemarks.lib  lib\LLVMBitstreamReader.lib  lib\LLVMMC.lib  
lib\LLVMBinaryFormat.lib  lib\LLVMDebugInfoCodeView.lib  
lib\LLVMDebugInfoMSF.lib  lib\LLVMSupport.lib  psapi.lib  shell32.lib  
ole32.lib  uuid.lib  advapi32.lib  delayimp.lib  -delayload:shell32.dll  
-delayload:ole32.dll  lib\LLVMDemangle.lib  kernel32.lib user32.lib gdi32.lib 
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib 
advapi32.lib && cd ."
  LINK: command "D:\llvm-project\buildninjaRel\bin\lld-link.exe /nologo 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\AnalyzerOptionsTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\CallDescriptionTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\StoreTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\RegisterCustomCheckersTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\SymbolReaperTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\D_\llvm-project\llvm\resources\windows_version_resource.rc.res
 /out:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.exe 
/implib:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.lib 
/pdb:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.pdb /version:0.0 
/machine:x64 -fuse-ld=lld /STACK:1000 /DEBUG /OPT:REF /OPT:ICF 
/lldltocache:D:/llvm-project/buildninjaRelMiMalloc/lto.cache /INCREMENTAL:NO 
/subsystem:console lib\LLVMSupport.lib lib\LLVMSupport.lib lib\gtest_main.lib 
lib\gtest.lib lib\clangBasic.lib lib\clangAnalysis.lib lib\clangAST.lib 
lib\clangASTMatchers.lib lib\clangCrossTU.lib lib\clangFrontend.lib 
lib\clangSerialization.lib lib\clangStaticAnalyzerCore.lib 
lib\clangStaticAnalyzerFrontend.lib lib\clangTooling.lib 
lib\clangStaticAnalyzerCheckers.lib lib\clangStaticAnalyzerCore.lib 
lib\clangCrossTU.lib lib\clangIndex.lib lib\clangFrontend.lib 
lib\clangParse.lib lib\clangSerialization.lib lib\clangSema.lib 
lib\clangAnalysis.lib lib\clangASTMatchers.lib lib\clangEdit.lib 
lib\clangDriver.lib version.lib lib\LLVMOption.lib lib\clangFormat.lib 
lib\clangToolingInclusions.lib lib\clangToolingCore.lib lib\clangAST.lib 
lib\LLVMFrontendOpenMP.lib lib\LLVMTransformUtils.lib lib\LLVMAnalysis.lib 
lib\LLVMProfileData.lib lib\LLVMObject.

[PATCH] D74812: [Sema] Teach -Warm-interrupt-safety about func ptrs

2020-02-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs created this revision.
jroelofs added reviewers: efriedma, weimingz, EricWF.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

Fixes:

  https://bugs.llvm.org/show_bug.cgi?id=35527
  https://bugs.llvm.org/show_bug.cgi?id=35528


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74812

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/arm-interrupt-attr.c

Index: clang/test/Sema/arm-interrupt-attr.c
===
--- clang/test/Sema/arm-interrupt-attr.c
+++ clang/test/Sema/arm-interrupt-attr.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 %s -triple arm-apple-darwin  -target-feature +vfp2 -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumb-apple-darwin  -target-feature +vfp3 -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple armeb-none-eabi  -target-feature +vfp4 -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi  -target-feature +neon -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon -target-feature +soft-float -DSOFT -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple arm-apple-darwin  -target-feature +vfp2 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple thumb-apple-darwin  -target-feature +vfp3 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple armeb-none-eabi  -target-feature +vfp4 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple thumbeb-none-eabi  -target-feature +neon -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple thumbeb-none-eabi -target-feature +neon -target-feature +soft-float -DSOFT -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
@@ -26,24 +26,36 @@
   callee2();
 }
 
-#ifndef SOFT
 __attribute__((interrupt("IRQ"))) void caller2() {
+#ifndef SOFT
   callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
-  callee2();
-}
-
-void (*callee3)();
-__attribute__((interrupt("IRQ"))) void caller3() {
-  callee3(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
-}
 #else
-__attribute__((interrupt("IRQ"))) void caller2() {
   callee1();
+#endif
   callee2();
 }
 
 void (*callee3)();
 __attribute__((interrupt("IRQ"))) void caller3() {
+#ifndef SOFT
+  callee3(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
+#else
   callee3();
+#endif
 }
+
+void __attribute__((interrupt("IRQ"))) bugzilla35527() {
+  typedef void __attribute__((interrupt("IRQ"))) (*interrupt_callback_t)(int i, void *ctx);
+  interrupt_callback_t interrupt_callee;
+  interrupt_callee(42, 0);
+  (interrupt_callee)(42, 0);
+  (*interrupt_callee)(42, 0);
+
+  typedef void (*callback_t)(int i, void *ctx);
+  callback_t callee;
+#ifndef SOFT
+  callee(37, 0); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
+#else
+  callee(37, 0);
 #endif
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5925,12 +5925,20 @@
   // so there's some risk when calling out to non-interrupt handler functions
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
-  if (auto *Caller = getCurFunctionDecl())
-if (Caller->hasAttr()) {
-  bool VFP = Context.getTargetInfo().hasFeature("vfp");
-  if (VFP && (!FDecl || !FDecl->hasAttr()))
-Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
-}
+  if (Context.getTargetInfo().hasFeature("vfp"))
+if (auto *Caller = getCurFunctionDecl())
+  if (Caller->hasAttr()) {
+const Decl *CalleeDecl = FDecl;
+if (const auto *UO = dyn_cast(Fn->IgnoreParens())) {
+  if (const auto *TT =
+  dyn_cast(UO->getSubExpr()->getType()))
+CalleeDecl = TT->getDecl();
+} else if (const auto *TT = Fn->getType()->getAs()) {
+  CalleeDecl = TT->getDecl();
+}
+if (!CalleeDecl || !CalleeDecl->hasAttr())
+  Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+  }
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+

[PATCH] D74812: [Sema] Teach -Warm-interrupt-safety about func ptrs

2020-02-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done.
jroelofs added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:5931
+  if (Caller->hasAttr()) {
+const Decl *CalleeDecl = FDecl;
+if (const auto *UO = dyn_cast(Fn->IgnoreParens())) {

This feels very fragile, and I know is missing at least one case. Is there a 
better way to reliably get at the typedef's attributes from here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74812



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

In D72231#1881855 , @rjmccall wrote:

> In D72231#1881797 , @nickdesaulniers 
> wrote:
>
> > In D72231#1881784 , @rjmccall 
> > wrote:
> >
> > > In D72231#1881760 , 
> > > @nickdesaulniers wrote:
> > >
> > > > In D72231#1879347 , @rjmccall 
> > > > wrote:
> > > >
> > > > > In D72231#1878528 , 
> > > > > @nathanchance wrote:
> > > > >
> > > > > > There appear to a be semantic difference between GCC and clang with 
> > > > > > the current version of this patch which results in a lot of 
> > > > > > additional warnings in the Linux kernel: 
> > > > > > https://godbolt.org/z/eHFJd8
> > > > >
> > > > >
> > > > > Warning about casting to an enum seems clearly correct and in scope 
> > > > > for this warning.  Warning about casting to `_Bool` seems clearly 
> > > > > incorrect and should not be warned about at all.
> > > >
> > > >
> > > > Maybe we should only warn if the size of the `void*` is smaller than 
> > > > the size of the `enum`? (32b `void*`, 64b `enum`)? 
> > > > https://godbolt.org/z/oAts-u
> > > >
> > > > Otherwise this warning creates a massive mess for us to clean up, and I 
> > > > suspect Linux kernel developers will just end up disabling the warning.
> > >
> > >
> > > If deployment is easier if we split out a subgroup that we can turn off, 
> > > that seems fine.  But I don't see any good abstract justification for 
> > > warning about a cast to `int` and not a cast to an `int`-sized `enum`.  
> > > What would the reasoning be, just that the latter "couldn't possibly" be 
> > > intended to preserve the original pointer value, so it must be an opaque 
> > > value being represented as a `void*`?  That seems pretty weak to me.
> >
> >
> > Less about enums, more about casts to/from void*, since you might use that 
> > in place of a union that would be too large to describe.  Specifically, 
> > this `struct` is used throughout the kernel for most drivers: 
> > https://elixir.bootlin.com/linux/v5.5.4/source/include/linux/mod_devicetable.h#L260
> >   It is exceedingly common to stuff whatever data in there: 
> > https://elixir.bootlin.com/linux/v5.5.4/source/drivers/ata/ahci_brcm.c#L428 
> > so long as the driver is careful not to reinterpret the data as the 
> > incorrect type.  Describing such a union for ever possible enum packed in 
> > there would not be fun.
>
>
> No, I understand the pattern, but they must have already done some sort of 
> pass over the code to make it warning-clean when they're working with a 
> smaller integer type.  Or do they just in practice never store smaller 
> integers in there, whereas it's hard to control size with an enum?


Yes, if the data is a regular `int`, rather than an `enum`, all of the 
callsites either cast to `long` or `uintptr_t` (which is typedef'd in the 
kernel to `unsigned long`). There are a lot fewer of those spots in the kernel 
(at least from my super quick `rg` search), most of the spots use an `enum`, 
maybe to purposefully avoid this warning? Most, if not all the sites, only 
store a number that is less than 5 because they use that number to determine 
exactly which device is present from the match data so the driver can handle 
different quirks with things like case statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-02-18 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

It's been almost a month since the last comments on this review. If you need 
more time, please comment here. Otherwise, I will submit this with the current 
approvals by the end of the week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69868



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-02-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D69868#1881985 , @void wrote:

> It's been almost a month since the last comments on this review. If you need 
> more time, please comment here. Otherwise, I will submit this with the 
> current approvals by the end of the week.


Explicit ping @nickdesaulniers, who blocked this, and @jyknight and @rnk, both 
explicitly requested by @MaskRay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69868



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


[clang] 048239e - [Coroutines][6/6] Clang schedules new passes

2020-02-18 Thread Brian Gesiak via cfe-commits

Author: Brian Gesiak
Date: 2020-02-19T01:03:28-05:00
New Revision: 048239e46e490d441f21f3e26073ec38f19e8a10

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

LOG: [Coroutines][6/6] Clang schedules new passes

Summary:
Depends on https://reviews.llvm.org/D71902.

The last in a series of six patches that ports the LLVM coroutines
passes to the new pass manager infrastructure.

This patch has Clang schedule the new coroutines passes when the
`-fexperimental-new-pass-manager` option is used. With this and the
previous 5 patches, Clang is capable of building and successfully
running the test suite of large coroutines projects such as
https://github.com/lewissbaker/cppcoro with
`ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=On`.

Reviewers: GorNishanov, lewissbaker, chandlerc, junparser

Subscribers: EricWF, cfe-commits, llvm-commits

Tags: #clang

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

Added: 
clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp

Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 6c71cf793c0f..b244fd499fb0 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,10 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Coroutines.h"
+#include "llvm/Transforms/Coroutines/CoroCleanup.h"
+#include "llvm/Transforms/Coroutines/CoroEarly.h"
+#include "llvm/Transforms/Coroutines/CoroElide.h"
+#include "llvm/Transforms/Coroutines/CoroSplit.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
@@ -957,6 +961,22 @@ static PassBuilder::OptimizationLevel mapToLevel(const 
CodeGenOptions &Opts) {
   }
 }
 
+static void addCoroutinePassesAtO0(ModulePassManager &MPM,
+   const LangOptions &LangOpts,
+   const CodeGenOptions &CodeGenOpts) {
+  if (!LangOpts.Coroutines)
+return;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass()));
+
+  CGSCCPassManager CGPM(CodeGenOpts.DebugPassManager);
+  CGPM.addPass(CoroSplitPass());
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
+}
+
 static void addSanitizersAtO0(ModulePassManager &MPM,
   const Triple &TargetTriple,
   const LangOptions &LangOpts,
@@ -1076,6 +1096,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+  PTO.Coroutines = LangOpts.Coroutines;
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI;
@@ -1279,6 +1300,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts);
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
 }
   }

diff  --git a/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp 
b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
new file mode 100644
index ..aed2cf13f892
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -0,0 +1,57 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
+// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
+// RUN:   -O1 %s 2>&1 | FileCheck %s
+//
+// CHECK: Starting llvm::Module pass manager run.
+// CHECK: Running pass:{{.*}}CoroEarlyPass
+//
+// The first coro-split pass enqueues a second run of the entire CGSCC 
pipeline.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// The second coro-split pass splits coroutine 'foo' into funclets
+// 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// CHECK: Running pass:{

[PATCH] D71903: [Coroutines][6/6] Clang schedules new passes

2020-02-18 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG048239e46e49: [Coroutines][6/6] Clang schedules new passes 
(authored by modocache).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71903

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp

Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -0,0 +1,57 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O1 %s 2>&1 | FileCheck %s
+//
+// CHECK: Starting llvm::Module pass manager run.
+// CHECK: Running pass:{{.*}}CoroEarlyPass
+//
+// The first coro-split pass enqueues a second run of the entire CGSCC pipeline.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// The second coro-split pass splits coroutine 'foo' into funclets
+// 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK: Finished llvm::Module pass manager run.
+
+namespace std {
+namespace experimental {
+
+struct handle {};
+
+struct awaitable {
+  bool await_ready() { return true; }
+  void await_suspend(handle) {}
+  bool await_resume() { return true; }
+};
+
+template  struct coroutine_handle {
+  static handle from_address(void *address) { return {}; }
+};
+
+template  struct coroutine_traits {
+  struct promise_type {
+awaitable initial_suspend() { return {}; }
+awaitable final_suspend() { return {}; }
+void return_void() {}
+T get_return_object() { return T(); }
+void unhandled_exception() {}
+  };
+};
+} // namespace experimental
+} // namespace std
+
+void foo() { co_return; }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,10 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Coroutines.h"
+#include "llvm/Transforms/Coroutines/CoroCleanup.h"
+#include "llvm/Transforms/Coroutines/CoroEarly.h"
+#include "llvm/Transforms/Coroutines/CoroElide.h"
+#include "llvm/Transforms/Coroutines/CoroSplit.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
@@ -957,6 +961,22 @@
   }
 }
 
+static void addCoroutinePassesAtO0(ModulePassManager &MPM,
+   const LangOptions &LangOpts,
+   const CodeGenOptions &CodeGenOpts) {
+  if (!LangOpts.Coroutines)
+return;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass()));
+
+  CGSCCPassManager CGPM(CodeGenOpts.DebugPassManager);
+  CGPM.addPass(CoroSplitPass());
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
+}
+
 static void addSanitizersAtO0(ModulePassManager &MPM,
   const Triple &TargetTriple,
   const LangOptions &LangOpts,
@@ -1076,6 +1096,7 @@
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+  PTO.Coroutines = LangOpts.Coroutines;
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI;
@@ -1279,6 +1300,7 @@
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts);
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74757: Fix compiler extension in standalone mode

2020-02-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 245327.
serge-sans-paille added a comment.

Take @Meinersbur review into account.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74757

Files:
  clang/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt

Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -136,6 +136,7 @@
 FILES_MATCHING PATTERN *.cmake
 PATTERN .svn EXCLUDE
 PATTERN LLVMConfig.cmake EXCLUDE
+PATTERN LLVMConfigExtensions.cmake EXCLUDE
 PATTERN LLVMConfigVersion.cmake EXCLUDE
 PATTERN LLVM-Config.cmake EXCLUDE
 PATTERN GetHostTriple.cmake EXCLUDE)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -873,63 +873,62 @@
 if (TARGET intrinsics_gen)
   add_dependencies(obj.${name} intrinsics_gen)
 endif()
-message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
-set_property(GLOBAL APPEND PROPERTY LLVM_COMPILE_EXTENSIONS ${name})
+set_property(GLOBAL APPEND PROPERTY LLVM_STATIC_EXTENSIONS ${name})
   elseif(NOT ARG_NO_MODULE)
 add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
   else()
 add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
   endif()
+  message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
 
 endfunction(add_llvm_pass_plugin)
 
-# process_llvm_pass_plugins([NO_GEN])
+# process_llvm_pass_plugins([GEN_CONFIG])
 #
 # Correctly set lib dependencies between plugins and tools, based on tools
 # registered with the ENABLE_PLUGINS option.
 #
-# Unless NO_GEN option is set, also generate X Macro file for extension
+# if GEN_CONFIG option is set, also generate X Macro file for extension
 # handling. It provides a HANDLE_EXTENSION(extension_namespace, ExtensionProject)
 # call for each extension allowing client code to define
 # HANDLE_EXTENSION to have a specific code be run for each extension.
 #
 function(process_llvm_pass_plugins)
   cmake_parse_arguments(ARG
-  "NO_GEN" "" ""
+  "GEN_CONFIG" "" ""
 ${ARGN})
 
+  if(ARG_GEN_CONFIG)
+  get_property(LLVM_STATIC_EXTENSIONS GLOBAL PROPERTY LLVM_STATIC_EXTENSIONS)
+  else()
+  include(LLVMConfigExtensions)
+  endif()
+
   # Add static plugins to each plugin target.
-  get_property(LLVM_EXTENSIONS GLOBAL PROPERTY LLVM_COMPILE_EXTENSIONS)
-  foreach(llvm_extension ${LLVM_EXTENSIONS})
-string(TOUPPER ${llvm_extension} llvm_extension_upper)
-string(TOLOWER ${llvm_extension} llvm_extension_lower)
-
-if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
-  get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
-  foreach(llvm_plugin_target ${llvm_plugin_targets})
-set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
-set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
-  endforeach()
-else()
-  add_llvm_library(${llvm_extension_lower} MODULE obj.${llvm_extension_lower})
-endif()
+  foreach(llvm_extension ${LLVM_STATIC_EXTENSIONS})
+get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
+foreach(llvm_plugin_target ${llvm_plugin_targets})
+  set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
+  set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
+endforeach()
   endforeach()
 
-  # Eventually generate the extension header.
-  if(NOT ARG_NO_GEN)
-  file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "//extension handlers\n")
-  foreach(llvm_extension ${LLVM_EXTENSIONS})
-string(TOLOWER ${llvm_extension} llvm_extension_lower)
-
-string(TOUPPER ${llvm_extension} llvm_extension_upper)
-string(SUBSTRING ${llvm_extension_upper} 0 1 llvm_extension_upper_first)
-string(SUBSTRING ${llvm_extension_lower} 1 -1 llvm_extension_lower_tail)
-string(CONCAT llvm_extension_project ${llvm_extension_upper_first} ${llvm_extension_lower_tail})
-
-if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
-  file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "HANDLE_EXTENSION(${llvm_extension_project})\n")
-endif()
+  # Eventually generate the extension header, and store config to a cmake file
+  # for usage in third-party configuration.
+  if(ARG_GEN_CONFIG)
+  set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+  set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKA

[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-02-18 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv created this revision.
alexbdv added reviewers: MaskRay, vsk, JonasToth, ruiu.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Function blocks don't have a name specified in source code. Currently their 
symbol name is based on the parent function's name and an index. 
Ex: _ZN1Parent_Funciton_block_invoke_1
One issue that happens with the current naming scheme is that in subsequent 
builds, the name of the function block can change even if the function block or 
the parent function has changed. This presents issues for tools that use symbol 
names to identify changes in source code / tracking of binary metrics.

The proposed solution here is to add a flag (default=off) that enables adding a 
hash of the block contents to the block name. 
Ex: _ZN1Parent_Funciton_block_invoke_38172  (38172 is the hash)
Therefore, the function block name will only change if its content or the 
parent function name changes. And will now remain stable regardless if new 
function blocks are added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74813

Files:
  clang/include/clang/AST/Mangle.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Mangle.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2817,6 +2817,9 @@
   Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
   Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
 
+  Opts.ObjCEnableHashFuncBlockNames =
+  Args.hasArg(OPT_enable_hash_in_objc_func_block_names);
+
   Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
   Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -24,11 +24,61 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Mangler.h"
-#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ErrorHandling.h"	
+#include "llvm/Support/MD5.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 
+static std::string getBlockIDByHash(const BlockDecl *BD,
+unsigned discriminator) {
+  Stmt *stmt = BD ? BD->getBody() : nullptr;
+
+  std::string strOutBuff;
+  llvm::raw_string_ostream strOutStream(strOutBuff);
+
+  strOutStream << "_block_invoke";
+
+  if (!stmt) {
+if (discriminator)
+  strOutStream << "_" << discriminator + 1;
+
+return strOutBuff;
+  }
+
+  std::string strStmtBuff;
+  llvm::raw_string_ostream strStmtStream(strStmtBuff);
+
+  // Dump the statement IR to a text stream for hasing
+  stmt->dump(strStmtStream);
+  strStmtBuff = strStmtStream.str();
+
+  // Strip out addresses
+  char *ptr = &strStmtBuff[1];
+  while (*ptr) {
+if (*ptr == 'x' && *(ptr - 1) == '0') {
+  ptr++;
+  while ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'a' && *ptr <= 'f')) {
+*ptr = '_';
+ptr++;
+  }
+  continue;
+}
+ptr++;
+  }
+
+  // Hash the statement string
+  llvm::MD5 Hash;
+  llvm::MD5::MD5Result Result;
+
+  Hash.update(strStmtBuff);
+  Hash.final(Result);
+
+  strOutStream << "_" << *(unsigned short *)&Result;
+  return strOutBuff;
+}
+
+
 // FIXME: For blocks we currently mimic GCC's mangling scheme, which leaves
 // much to be desired. Come up with a better mangling scheme.
 
@@ -37,6 +87,12 @@
 const BlockDecl *BD,
 raw_ostream &Out) {
   unsigned discriminator = Context.getBlockId(BD, true);
+  	
+  if (Context.shouldAddHashOfBlockToName()) {
+Out << "__" << Outer << getBlockIDByHash(BD, discriminator);
+return;
+  }
+
   if (discriminator == 0)
 Out << "__" << Outer << "_block_invoke";
   else
@@ -89,6 +145,10 @@
 return CCM_Vector;
   }
 }
+	
+bool MangleContext::shouldAddHashOfBlockToName() {
+  return getASTContext().getLangOpts().ObjCEnableHashFuncBlockNames;
+}
 
 bool MangleContext::shouldMangleDeclName(const NamedDecl *D) {
   const ASTContext &ASTContext = getASTContext();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1349,6 +1349,8 @@
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
   Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Write minimized bitcode to  for the ThinLTO thin link only">;
+def enable_hash_in_objc_func_block_names : Flag<["-"], "enable-hash-in-objc-func-block-names">, Flags<[CC1Option]>, Group,
+  HelpText<"For objc function blocks - enable adding a hash of the block in the blocks's

[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-18 Thread Hongtao Yu via Phabricator via cfe-commits
hoyFB created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
hoyFB added a reviewer: wenlei.
hoyFB added a subscriber: wenlei.

The IR printing always prints out all functions in a module with the new pass 
manager, even with -filter-print-funcs specified. This is being fixed in this 
change. However, there are two exceptions, i.e, with user-specified wildcast 
switch -filter-print-funcs=* or -print-module-scope, under which IR of all 
functions should be printed.

Test Plan:
make check-clang
make check-llvm


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74814

Files:
  clang/test/Misc/print-single-function.c
  llvm/lib/Passes/StandardInstrumentations.cpp


Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -70,16 +70,24 @@
   llvm_unreachable("Unknown IR unit");
 }
 
-void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
-  dbgs() << Banner << Extra << "\n";
-  M->print(dbgs(), nullptr, false);
-}
 void printIR(const Function *F, StringRef Banner,
  StringRef Extra = StringRef()) {
   if (!llvm::isFunctionInPrintList(F->getName()))
 return;
   dbgs() << Banner << Extra << "\n" << static_cast(*F);
 }
+
+void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
+  if (llvm::isFunctionInPrintList("*") || llvm::forcePrintModuleIR()) {
+dbgs() << Banner << Extra << "\n";
+M->print(dbgs(), nullptr, false);
+  } else {
+for (const auto &F : M->functions()) {
+  printIR(&F, Banner, Extra);
+}
+  }
+}
+
 void printIR(const LazyCallGraph::SCC *C, StringRef Banner,
  StringRef Extra = StringRef()) {
   bool BannerPrinted = false;
Index: clang/test/Misc/print-single-function.c
===
--- /dev/null
+++ clang/test/Misc/print-single-function.c
@@ -0,0 +1,21 @@
+// Testing single function IR printing with the new pass manager.  there are 
two exceptions, i.e, with user-specified wildcast switch -filter-print-funcs=* 
or -print-module-scope, under which IR of all functions should be printed.
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-after-all -mllvm -filter-print-funcs=foo %s -o %t 2>&1 | FileCheck %s 
--check-prefix=FOO
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-after-all -mllvm -filter-print-funcs=foo %s -mllvm -print-module-scope 
-o %t 2>&1 | FileCheck %s --check-prefix=ALL
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-after-all -mllvm -filter-print-funcs=* %s -o %t 2>&1 | FileCheck %s 
--check-prefix=ALL
+
+// FOO: *** IR Dump After AlwaysInlinerPass ***
+// FOO: define void @foo()
+// FOO-NOT: define void @bar()
+
+// ALL: *** IR Dump After AlwaysInlinerPass ***
+// ALL-NEXT: ; ModuleID =
+// ALL: define void @foo()
+// ALL: define void @bar()
+
+void bar() {
+  return;
+}
+
+void foo() {
+  bar();
+}


Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -70,16 +70,24 @@
   llvm_unreachable("Unknown IR unit");
 }
 
-void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) {
-  dbgs() << Banner << Extra << "\n";
-  M->print(dbgs(), nullptr, false);
-}
 void printIR(const Function *F, StringRef Banner,
  StringRef Extra = StringRef()) {
   if (!llvm::isFunctionInPrintList(F->getName()))
 return;
   dbgs() << Banner << Extra << "\n" << static_cast(*F);
 }
+
+void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) {
+  if (llvm::isFunctionInPrintList("*") || llvm::forcePrintModuleIR()) {
+dbgs() << Banner << Extra << "\n";
+M->print(dbgs(), nullptr, false);
+  } else {
+for (const auto &F : M->functions()) {
+  printIR(&F, Banner, Extra);
+}
+  }
+}
+
 void printIR(const LazyCallGraph::SCC *C, StringRef Banner,
  StringRef Extra = StringRef()) {
   bool BannerPrinted = false;
Index: clang/test/Misc/print-single-function.c
===
--- /dev/null
+++ clang/test/Misc/print-single-function.c
@@ -0,0 +1,21 @@
+// Testing single function IR printing with the new pass manager.  there are two exceptions, i.e, with user-specified wildcast switch -filter-print-funcs=* or -print-module-scope, under which IR of all functions should be printed.
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-after-all -mllvm -filter-print-funcs=foo %s -o %t 2>&1 | FileCheck %s --check-prefix=FOO
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-after-all -mllvm -filte

[PATCH] D74606: [clangd] Add add commit characters to the server capabilities

2020-02-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 245331.
kbobyrev added a comment.

Add pipe and single quote to commit characters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74606

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@
   /// the client side.
   float score = 0.f;
 
+  // TODO: Add custom commitCharacters for some of the completion items. For
+  // example, it makes sense to use () only for the functions.
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\"'|"},
  {"resolveProvider", false},
  // We do extra checks for '>' and ':' in completion to only
  // trigger on '->' and '::'.


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@
   /// the client side.
   float score = 0.f;
 
+  // TODO: Add custom commitCharacters for some of the completion items. For
+  // example, it makes sense to use () only for the functions.
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\"'|"},
  {"resolveProvider", false},
  // We do extra checks for '>' and ':' in completion to only
  // trigger on '->' and '::'.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 2a095ff - [clangd] Add add commit characters to the server capabilities

2020-02-18 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-02-19T08:32:00+01:00
New Revision: 2a095ff6f5028b7612dae50358a2f6939b6cdc9f

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

LOG: [clangd] Add add commit characters to the server capabilities

Summary:
Make it more convinient for the clients to select completion items by
providing a set of default characters (punctuation).

Related issue: https://github.com/clangd/clangd/issues/284

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/initialize-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 93609a8852db..c31a0a417ebe 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\"'|"},
  {"resolveProvider", false},
  // We do extra checks for '>' and ':' in completion to only
  // trigger on '->' and '::'.

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 80a11ee00307..a376e5f39e79 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@ struct CompletionItem {
   /// the client side.
   float score = 0.f;
 
+  // TODO: Add custom commitCharacters for some of the completion items. For
+  // example, it makes sense to use () only for the functions.
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index e5ec9fb3d7ac..8984f36db7d0 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",



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


[PATCH] D74606: [clangd] Add add commit characters to the server capabilities

2020-02-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a095ff6f502: [clangd] Add add commit characters to the 
server capabilities (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74606

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@
   /// the client side.
   float score = 0.f;
 
+  // TODO: Add custom commitCharacters for some of the completion items. For
+  // example, it makes sense to use () only for the functions.
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\"'|"},
  {"resolveProvider", false},
  // We do extra checks for '>' and ':' in completion to only
  // trigger on '->' and '::'.


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
 # CHECK-NEXT:"resolveProvider": false,
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  ".",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@
   /// the client side.
   float score = 0.f;
 
+  // TODO: Add custom commitCharacters for some of the completion items. For
+  // example, it makes sense to use () only for the functions.
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\"'|"},
  {"resolveProvider", false},
  // We do extra checks for '>' and ':' in completion to only
  // trigger on '->' and '::'.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74564: libclang: Add static build support for Windows

2020-02-18 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan accepted this revision.
yvvan added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/include/clang-c/Platform.h:31
+#elif defined(CINDEX_EXPORTS)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif

cristian.adam wrote:
> yvvan wrote:
> > Is it different from just leaving CINDEX_LINKAGE empty?
> On Windows the default symbol visibility is hidden and with CINDEX_LINKAGE we 
> make the symbols visible.
> 
> On Linux it's the other way around, everything is visible, but 
> with CMAKE_CXX_VISIBILITY_PRESET=hidden we will have the Windows behavior and 
> then we need to make CINDEX_LINKAGE point to something that will make the 
> symbols visible.
but this one happens only in non-Windows case (#elif) so it should not change 
anything I guess


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74564



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


[PATCH] D74732: [ARM,CDE] Cosmetic changes, additonal driver tests

2020-02-18 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Cheers, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74732



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


[PATCH] D73846: make sure to not warn about unused macros from -D

2020-02-18 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping..


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

https://reviews.llvm.org/D73846



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-02-18 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping.


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

https://reviews.llvm.org/D69585



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


[clang] 90dc78b - [ARM, MVE] Add intrinsics for abs, neg and not operations.

2020-02-18 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-18T09:34:50Z
New Revision: 90dc78bc62784faaa55afb0320cf3c2187d80ac6

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

LOG: [ARM,MVE] Add intrinsics for abs, neg and not operations.

Summary:
This commit adds the unpredicated intrinsics for the unary operations
vabsq (absolute value), vnegq (arithmetic negation), vmvnq (bitwise
complement), vqabsq and vqnegq (saturating versions of abs and neg for
signed integers, in the sense that they give INT_MAX if an input lane
is INT_MIN).

This is done entirely in clang: all of these operations have existing
isel patterns and existing tests for them on the LLVM side, so I've
just made clang emit the same IR that those patterns already match.

Reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard

Reviewed By: MarkMurrayARM

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/absneg.c

Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 5cd88b07ebaa..dfc0ee87bb2f 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -234,6 +234,33 @@ let params = T.Unsigned in {
   defm vdwdup: vxdup_mc<(? u32:$limit, imm_1248:$step), (? $limit, $step)>;
 }
 
+let params = T.Int in {
+  def vmvnq: Intrinsic;
+}
+let params = T.Signed in {
+  def vnegq: Intrinsic;
+  def vabsq: Intrinsic;
+  def vqnegq: Intrinsic;
+  def vqabsq: Intrinsic;
+}
+let params = T.Float in {
+  def vnegq_f: Intrinsic,
+   NameOverride<"vnegq">;
+  def vabsq_f: Intrinsic $a)>, NameOverride<"vabsq">;
+}
+
 // The bitcasting below is not overcomplicating the IR because while
 // Vector and UVector may be 
diff erent vector types at the C level i.e.
 // vectors of same size signed/unsigned ints. Once they're lowered

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index d4e821589cfd..2d080f2653aa 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -98,6 +98,9 @@ def extend: CGHelperFn<"SignOrZeroExtend"> {
   let special_params = [IRBuilderIntParam<2, "bool">];
 }
 def zeroinit: IRFunction<"llvm::Constant::getNullValue">;
+def int_min: CGHelperFn<"ARMMVEConstantSplat<1,0>">;
+def int_max: CGHelperFn<"ARMMVEConstantSplat<0,1>">;
+def uint_max: CGHelperFn<"ARMMVEConstantSplat<1,1>">;
 def undef: IRFunction<"UndefValue::get">;
 def icmp_eq: IRBuilder<"CreateICmpEQ">;
 def icmp_ne: IRBuilder<"CreateICmpNE">;
@@ -117,6 +120,7 @@ def fcmp_lt: IRBuilder<"CreateFCmpOLT">;
 def fcmp_le: IRBuilder<"CreateFCmpOLE">;
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
+def fneg: IRBuilder<"CreateFNeg">;
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5e411bc7aa93..0081740f7280 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7056,6 +7056,19 @@ static llvm::Value *ARMMVEVectorReinterpret(CGBuilderTy 
&Builder,
   }
 }
 
+template
+static llvm::Value *ARMMVEConstantSplat(CGBuilderTy &Builder, llvm::Type *VT) {
+  // MVE-specific helper function to make a vector splat of a constant such as
+  // UINT_MAX or INT_MIN, in which all bits below the highest one are equal.
+  llvm::Type *T = VT->getVectorElementType();
+  unsigned LaneBits = T->getPrimitiveSizeInBits();
+  uint32_t Value = HighBit << (LaneBits - 1);
+  if (OtherBits)
+Value |= (1UL << (LaneBits - 1)) - 1;
+  llvm::Value *Lane = llvm::ConstantInt::get(T, Value);
+  return ARMMVEVectorSplat(Builder, Lane);
+}
+
 Value *CodeGenFunction::EmitARMMVEBuiltinExpr(unsigned BuiltinID,
   const CallExpr *E,
   ReturnValueSlot ReturnValue,

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/absneg.c 
b/clang/test/CodeGen/arm-mve-intrinsics/absneg.c
new file mode 100644
index ..db4253f3590b
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/absneg.c
@@ -0,0 +1,338 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp

[clang] b6236e9 - [ARM, MVE] Add the vrev16q, vrev32q, vrev64q family.

2020-02-18 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-18T09:34:50Z
New Revision: b6236e94799e43fad1f024e84ed56a85d9a3623f

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

LOG: [ARM,MVE] Add the vrev16q, vrev32q, vrev64q family.

Summary:
These intrinsics just reorder the lanes of a vector, so the natural IR
representation is as a shufflevector operation. Existing LLVM codegen
already recognizes those particular shufflevectors and generates the
MVE VREV instruction.

This commit adds the unpredicated forms only.

Reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard

Reviewed By: dmgreen

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vrev.c

Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index a2bf7afad41e..126c2e2214ae 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -1180,6 +1180,13 @@ defm vrmlsldavh : MVEBinaryVectorHoriz64R;
 defm vrmlsldavh : MVEBinaryVectorHoriz64R;
 }
 
+let params = T.All8 in
+def vrev16q : Intrinsic;
+let params = !listconcat(T.All8, T.All16) in
+def vrev32q : Intrinsic;
+let params = T.Usual in
+def vrev64q : Intrinsic;
+
 foreach desttype = T.All in {
   // We want a vreinterpretq between every pair of supported vector types
   // _except_ that there shouldn't be one from a type to itself.

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index c2e4a4232c23..9f245d0436c4 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -125,6 +125,9 @@ def sitofp: IRBuilder<"CreateSIToFP">;
 def uitofp: IRBuilder<"CreateUIToFP">;
 def fptosi: IRBuilder<"CreateFPToSI">;
 def fptoui: IRBuilder<"CreateFPToUI">;
+def vrev: CGHelperFn<"ARMMVEVectorElementReverse"> {
+  let special_params = [IRBuilderIntParam<1, "unsigned">];
+}
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 0081740f7280..788f14b37123 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7069,6 +7069,21 @@ static llvm::Value *ARMMVEConstantSplat(CGBuilderTy 
&Builder, llvm::Type *VT) {
   return ARMMVEVectorSplat(Builder, Lane);
 }
 
+static llvm::Value *ARMMVEVectorElementReverse(CGBuilderTy &Builder,
+   llvm::Value *V,
+   unsigned ReverseWidth) {
+  // MVE-specific helper function which reverses the elements of a
+  // vector within every (ReverseWidth)-bit collection of lanes.
+  SmallVector Indices;
+  unsigned LaneSize = V->getType()->getScalarSizeInBits();
+  unsigned Elements = 128 / LaneSize;
+  unsigned Mask = ReverseWidth / LaneSize - 1;
+  for (unsigned i = 0; i < Elements; i++)
+Indices.push_back(i ^ Mask);
+  return Builder.CreateShuffleVector(V, llvm::UndefValue::get(V->getType()),
+ Indices);
+}
+
 Value *CodeGenFunction::EmitARMMVEBuiltinExpr(unsigned BuiltinID,
   const CallExpr *E,
   ReturnValueSlot ReturnValue,

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vrev.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vrev.c
new file mode 100644
index ..384d736d2a6d
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vrev.c
@@ -0,0 +1,215 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa 
-early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrev16q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> 
undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev16q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev16q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = s

[clang] c8b3196 - [ARM, MVE] Add intrinsics for FP rounding operations.

2020-02-18 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-18T09:34:50Z
New Revision: c8b3196e54308b0113d2a0888d13ccc92e3b7ccc

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

LOG: [ARM,MVE] Add intrinsics for FP rounding operations.

Summary:
This adds the unpredicated forms of six different MVE intrinsics which
all round a vector of floating-point numbers to integer values,
leaving them still in FP format, differing only in rounding mode and
exception settings.

Five of them map to existing target-independent intrinsics in LLVM IR,
such as @llvm.trunc and @llvm.rint. The sixth, mapping to the `vrintn`
instruction, is done by inventing a target-specific intrinsic.

(`vrintn` behaves the same as `vrintx` in terms of the output value:
the side effects on the FPSCR flags are the only difference between
the two. But ACLE specifies separate user-callable intrinsics for the
two, so the side effects matter enough to make sure we generate the
right one of the two instructions in each case.)

Reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard

Reviewed By: miyuki

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 5b20f23c75c7..a2bf7afad41e 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -417,6 +417,21 @@ defm : float_int_conversions;
 defm : float_int_conversions;
 defm : float_int_conversions;
 
+let params = T.Float in {
+  def vrndq: Intrinsic $a)>;
+  def vrndmq: Intrinsic $a)>;
+  def vrndpq: Intrinsic $a)>;
+  def vrndaq: Intrinsic $a)>;
+  def vrndxq: Intrinsic $a)>;
+  def vrndnq: Intrinsic $a)>;
+}
+
 multiclass compare_with_pred {
   // Make the predicated and unpredicated versions of a single comparison.

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vrnd.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
new file mode 100644
index ..a324c36ed838
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
@@ -0,0 +1,173 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa 
-early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrndaq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.round.v8f16(<8 x half> 
[[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndaq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndaq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.round.v4f32(<4 x 
float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndaq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.floor.v8f16(<8 x half> 
[[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndmq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return vrndmq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.floor.v4f32(<4 x 
float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndmq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return vrndmq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndpq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.ceil.v8f16(<8 x half> 
[[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndpq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndpq(a);
+#else /* POLYMORPHIC */
+return vrndpq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CH

[clang] df3ed6c - [ARM, MVE] Add intrinsics for int <-> float conversion.

2020-02-18 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-18T09:34:50Z
New Revision: df3ed6c0fe31094941e4cd814cdf924b63993c4e

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

LOG: [ARM,MVE] Add intrinsics for int <-> float conversion.

Summary:
This adds the unpredicated versions of the family of vcvtq intrinsics
that convert between a vector of floats and a vector of the same size
of integer. These are represented in IR using the standard fptosi,
fptoui, sitofp and uitofp operations, which existing LLVM codegen
already handles.

Reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard

Reviewed By: MarkMurrayARM

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
clang/test/CodeGen/arm-mve-intrinsics/vcvt.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index dfc0ee87bb2f..5b20f23c75c7 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -400,6 +400,23 @@ foreach half = [ "b", "t" ] in {
   } // params = [f32], pnt = PNT_None
 } // loop over half = "b", "t"
 
+multiclass float_int_conversions {
+  defvar FVector = VecOf;
+  defvar IVector = VecOf;
+
+  let params = [IScalar], pnt = PNT_2Type in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # FScalar>;
+  let params = [FScalar], pnt = PNT_None in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # IScalar>;
+}
+
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+
 multiclass compare_with_pred {
   // Make the predicated and unpredicated versions of a single comparison.

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index 2d080f2653aa..c2e4a4232c23 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -121,6 +121,10 @@ def fcmp_le: IRBuilder<"CreateFCmpOLE">;
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
 def fneg: IRBuilder<"CreateFNeg">;
+def sitofp: IRBuilder<"CreateSIToFP">;
+def uitofp: IRBuilder<"CreateUIToFP">;
+def fptosi: IRBuilder<"CreateFPToSI">;
+def fptoui: IRBuilder<"CreateFPToUI">;
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vcvt.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
index a1c99de62ebb..3220100d7b89 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
@@ -4,6 +4,102 @@
 
 #include 
 
+// CHECK-LABEL: @test_vcvtq_f16_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f16_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_u32(uint32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_u32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_s16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vcvtq_s16_f16(float16x8_t a)
+{
+return vcvtq_s16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_s32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vcvtq_s32_f32(float32x4_t a)
+{
+return vcvtq_s32_f32(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_

[clang] 68b49f7 - [ARM,MVE] Add intrinsics vclzq and vclsq.

2020-02-18 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-18T09:34:50Z
New Revision: 68b49f7ef49eec068b7ddcf86c868e2a193e64e1

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

LOG: [ARM,MVE] Add intrinsics vclzq and vclsq.

Summary:
vclzq maps nicely to the existing target-independent @llvm.ctlz IR
intrinsic. But vclsq ('count leading sign bits') has no corresponding
target-independent intrinsic, so I've made up @llvm.arm.mve.vcls.

This commit adds the unpredicated forms only.

Reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard

Reviewed By: miyuki

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vclz.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 126c2e2214ae..21801b4d448e 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -237,8 +237,11 @@ let params = T.Unsigned in {
 let params = T.Int in {
   def vmvnq: Intrinsic;
+  def vclzq: Intrinsic $a, (i1 0))>;
 }
 let params = T.Signed in {
+  def vclsq: Intrinsic $a)>;
   def vnegq: Intrinsic;
   def vabsq: Intrinsic {
   let special_params = [IRBuilderIntParam<1, "unsigned">];
 }
 
+// Helper for making boolean flags in IR
+def i1: IRBuilderBase {
+  let prefix = "llvm::ConstantInt::get(Builder.getInt1Ty(), ";
+  let special_params = [IRBuilderIntParam<0, "bool">];
+}
+
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.
 def address;

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vclz.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vclz.c
new file mode 100644
index ..7a2ebe0a627a
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vclz.c
@@ -0,0 +1,132 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve 
-mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve 
-mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone 
-DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vclzq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> 
[[A:%.*]], i1 false)
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vclzq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> 
[[A:%.*]], i1 false)
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vclzq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> 
[[A:%.*]], i1 false)
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vclzq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> 
[[A:%.*]], i1 false)
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vclzq_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> 
[[A:%.*]], i1 false)
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vclzq_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> 
[[A:%.*]], i1 false)
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+uint32x4_t test_vclzq_u32(uint32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+ret

[PATCH] D74331: [ARM,MVE] Add intrinsics for abs, neg and not operations.

2020-02-18 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90dc78bc6278: [ARM,MVE] Add intrinsics for abs, neg and not 
operations. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74331

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/absneg.c

Index: clang/test/CodeGen/arm-mve-intrinsics/absneg.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/absneg.c
@@ -0,0 +1,338 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vabsq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vabsq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.fabs.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vabsq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <16 x i8> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <16 x i8> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <16 x i1> [[TMP0]], <16 x i8> [[TMP1]], <16 x i8> [[A]]
+// CHECK-NEXT:ret <16 x i8> [[TMP2]]
+//
+int8x16_t test_vabsq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <8 x i16> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <8 x i16> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP0]], <8 x i16> [[TMP1]], <8 x i16> [[A]]
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+//
+int16x8_t test_vabsq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabsq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <4 x i32> [[A:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <4 x i32> zeroinitializer, [[A]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP0]], <4 x i32> [[TMP1]], <4 x i32> [[A]]
+// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+//
+int32x4_t test_vabsq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vabsq(a);
+#else /* POLYMORPHIC */
+return vabsq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vmvnq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i16> [[A:%.*]], 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vmvnq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <4 x i32> [[A:%.*]], 
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vmvnq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vmvnq_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vmvnq(a);
+#else /* POLYMORPHIC */
+return vmvnq_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmvnq_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i16> [[A:%.*]], 
+// CHECK-NEXT:ret <8 x i16> [[TMP0

[clang] 5e97940 - [ARM, MVE] Add the vmovlbq, vmovltq intrinsic family.

2020-02-18 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-18T09:34:50Z
New Revision: 5e97940cd27961a0b872ff551fc98135507288b3

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

LOG: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic family.

Summary:
These intrinsics take a vector of 2n elements, and return a vector of
n wider elements obtained by sign- or zero-extending every other
element of the input vector. They're represented in IR as a
shufflevector that extracts the odd or even elements of the input,
followed by a sext or zext.

Existing LLVM codegen already matches this pattern and generates the
VMOVLB instruction (which widens the even-index input lanes). But no
existing isel rule was generating VMOVLT, so I've added some. However,
the new rules currently only work in little-endian MVE, because the
pattern they expect from isel lowering includes a bitconvert which
doesn't have the right semantics in big-endian.

The output of one existing codegen test is improved by those new
rules.

This commit adds the unpredicated forms only.

Reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard

Reviewed By: dmgreen

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
clang/lib/CodeGen/CGBuiltin.cpp
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/test/CodeGen/Thumb2/mve-shuffleext.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 21801b4d448e..55ddfc22aa3d 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -420,6 +420,13 @@ defm : float_int_conversions;
 defm : float_int_conversions;
 defm : float_int_conversions;
 
+let params = [s8, u8, s16, u16] in {
+  def vmovlbq: Intrinsic;
+  def vmovltq: Intrinsic;
+}
+
 let params = T.Float in {
   def vrndq: Intrinsic $a)>;

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index 9e5b7b32c511..f6816cdf45c9 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -128,6 +128,9 @@ def fptoui: IRBuilder<"CreateFPToUI">;
 def vrev: CGHelperFn<"ARMMVEVectorElementReverse"> {
   let special_params = [IRBuilderIntParam<1, "unsigned">];
 }
+def unzip: CGHelperFn<"VectorUnzip"> {
+  let special_params = [IRBuilderIntParam<1, "bool">];
+}
 
 // Helper for making boolean flags in IR
 def i1: IRBuilderBase {

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 788f14b37123..b30a79a0bf10 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7056,6 +7056,17 @@ static llvm::Value *ARMMVEVectorReinterpret(CGBuilderTy 
&Builder,
   }
 }
 
+static llvm::Value *VectorUnzip(CGBuilderTy &Builder, llvm::Value *V, bool 
Odd) {
+  // Make a shufflevector that extracts every other element of a vector (evens
+  // or odds, as desired).
+  SmallVector Indices;
+  unsigned InputElements = V->getType()->getVectorNumElements();
+  for (unsigned i = 0; i < InputElements; i += 2)
+Indices.push_back(i + Odd);
+  return Builder.CreateShuffleVector(V, llvm::UndefValue::get(V->getType()),
+ Indices);
+}
+
 template
 static llvm::Value *ARMMVEConstantSplat(CGBuilderTy &Builder, llvm::Type *VT) {
   // MVE-specific helper function to make a vector splat of a constant such as

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vmovl.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
new file mode 100644
index ..0b8ef596faed
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
@@ -0,0 +1,126 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve 
-mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve 
-mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone 
-DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vmovlbq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> 
undef, <8 x i32> 
+// CHECK-NEXT:[[TMP1:%.*]] = sext <8 x i8> [[TMP0]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP1]]
+//
+int16x8_t test_vmovlbq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vmovlbq(a);
+#else /* P

[clang] c32af44 - [ARM, MVE] Add the vmovnbq, vmovntq intrinsic family.

2020-02-18 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-18T09:34:50Z
New Revision: c32af4447f79f5e7f246917fe1c3f58b2f6fc2a6

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

LOG: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

Summary:
These are in some sense the inverse of vmovl[bt]q: they take a vector
of n wide elements and truncate each to half its width. So they only
write half a vector's worth of output data, and therefore they also
take an 'inactive' parameter to provide the other half of the data in
the output vector. So vmovnb overwrites the even lanes of 'inactive'
with the narrowed values from the main input, and vmovnt overwrites
the odd lanes.

LLVM had existing codegen which generates these MVE instructions in
response to IR that takes two vectors of wide elements, or two vectors
of narrow ones. But in this case, we have one vector of each. So my
clang codegen strategy is to narrow the input vector of wide elements
by simply reinterpreting it as the output type, and then we have two
narrow vectors and can represent the operation as a vector shuffle
that interleaves lanes from both of them.

Even so, not all the cases I needed ended up being selected as a
single MVE instruction, so I've added a couple more patterns that spot
combinations of the 'MVEvmovn' and 'ARMvrev32' SDNodes which can be
generated as a VMOVN instruction with operands swapped.

This commit adds the unpredicated forms only.

Reviewers: dmgreen, miyuki, MarkMurrayARM, ostannard

Reviewed By: dmgreen

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/utils/TableGen/MveEmitter.cpp
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 55ddfc22aa3d..3a6b63199e39 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -427,6 +427,14 @@ let params = [s8, u8, s16, u16] in {
 (extend (unzip $a, 1), DblVector, (unsignedflag Scalar))>;
 }
 
+let params = [s16, u16, s32, u32] in {
+  def vmovnbq: Intrinsic;
+  def vmovntq: Intrinsic;
+}
+
 let params = T.Float in {
   def vrndq: Intrinsic $a)>;

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index f6816cdf45c9..7f8f717e8163 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -131,6 +131,7 @@ def vrev: CGHelperFn<"ARMMVEVectorElementReverse"> {
 def unzip: CGHelperFn<"VectorUnzip"> {
   let special_params = [IRBuilderIntParam<1, "bool">];
 }
+def zip: CGHelperFn<"VectorZip">;
 
 // Helper for making boolean flags in IR
 def i1: IRBuilderBase {
@@ -187,6 +188,10 @@ def seq;
 // and 0 for a signed (or floating) one.
 def unsignedflag;
 
+// 'bitsize' also takes a scalar type, and expands into an integer
+// constant giving its size in bits.
+def bitsize;
+
 // If you put CustomCodegen<"foo"> in an intrinsic's codegen field, it
 // indicates that the IR generation for that intrinsic is done by handwritten
 // C++ and not autogenerated at all. The effect in the MVE builtin codegen

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b30a79a0bf10..401c4d8e0539 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7067,6 +7067,19 @@ static llvm::Value *VectorUnzip(CGBuilderTy &Builder, 
llvm::Value *V, bool Odd)
  Indices);
 }
 
+static llvm::Value *VectorZip(CGBuilderTy &Builder, llvm::Value *V0,
+  llvm::Value *V1) {
+  // Make a shufflevector that interleaves two vectors element by element.
+  assert(V0->getType() == V1->getType() && "Can't zip 
diff erent vector types");
+  SmallVector Indices;
+  unsigned InputElements = V0->getType()->getVectorNumElements();
+  for (unsigned i = 0; i < InputElements; i++) {
+Indices.push_back(i);
+Indices.push_back(i + InputElements);
+  }
+  return Builder.CreateShuffleVector(V0, V1, Indices);
+}
+
 template
 static llvm::Value *ARMMVEConstantSplat(CGBuilderTy &Builder, llvm::Type *VT) {
   // MVE-specific helper function to make a vector splat of a constant such as

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vmovn.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
new file mode 100644
index ..5d157de0feb8
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
@@ -0,0 +1,199 @@
+// NOTE: Assert

[PATCH] D74334: [ARM,MVE] Add the vrev16q, vrev32q, vrev64q family.

2020-02-18 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6236e94799e: [ARM,MVE] Add the vrev16q, vrev32q, vrev64q 
family. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74334

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vrev.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vrev.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrev.c
@@ -0,0 +1,215 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrev16q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev16q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev16q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev16q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev16q(a);
+#else /* POLYMORPHIC */
+return vrev16q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev32q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev32q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vrev32q_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vrev32q_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev32q_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x half> [[A:%.*]], <8 x half> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrev32q_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev32q(a);
+#else /* POLYMORPHIC */
+return vrev32q_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vrev64q_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> undef, <16 x i32> 
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+uint8x16_t test_vrev64q_u8(uint8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_u8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrev64q_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> undef, <8 x i32> 
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vrev64q_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrev64q(a);
+#else /* POLYMORPHIC */
+return vrev64q_s16(a);
+#endif /* POLYMORPHIC */

[PATCH] D74332: [ARM,MVE] Add intrinsics for int <-> float conversion.

2020-02-18 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf3ed6c0fe31: [ARM,MVE] Add intrinsics for int <-> 
float conversion. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74332

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vcvt.c

Index: clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
@@ -4,6 +4,102 @@
 
 #include 
 
+// CHECK-LABEL: @test_vcvtq_f16_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f16_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <8 x i16> [[A:%.*]] to <8 x half>
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vcvtq_f16_u16(uint16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f16_u16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = sitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_s32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_f32_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = uitofp <4 x i32> [[A:%.*]] to <4 x float>
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vcvtq_f32_u32(uint32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vcvtq(a);
+#else /* POLYMORPHIC */
+return vcvtq_f32_u32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vcvtq_s16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vcvtq_s16_f16(float16x8_t a)
+{
+return vcvtq_s16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_s32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptosi <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vcvtq_s32_f32(float32x4_t a)
+{
+return vcvtq_s32_f32(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u16_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <8 x half> [[A:%.*]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+uint16x8_t test_vcvtq_u16_f16(float16x8_t a)
+{
+return vcvtq_u16_f16(a);
+}
+
+// CHECK-LABEL: @test_vcvtq_u32_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fptoui <4 x float> [[A:%.*]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+uint32x4_t test_vcvtq_u32_f32(float32x4_t a)
+{
+return vcvtq_u32_f32(a);
+}
+
 // CHECK-LABEL: @test_vcvttq_f16_f32(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.arm.mve.vcvt.narrow(<8 x half> [[A:%.*]], <4 x float> [[B:%.*]], i32 1)
Index: clang/include/clang/Basic/arm_mve_defs.td
===
--- clang/include/clang/Basic/arm_mve_defs.td
+++ clang/include/clang/Basic/arm_mve_defs.td
@@ -121,6 +121,10 @@
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
 def fneg: IRBuilder<"CreateFNeg">;
+def sitofp: IRBuilder<"CreateSIToFP">;
+def uitofp: IRBuilder<"CreateUIToFP">;
+def fptosi: IRBuilder<"CreateFPToSI">;
+def fptoui: IRBuilder<"CreateFPToUI">;
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.
Index: clang/include/clang/Basic/arm_mve.td
===
--- clang/include/clang/Basic/arm_mve.td
+++ clang/include/clang/Basic/arm_mve.td
@@ -400,6 +400,23 @@
   } // params = [f32], pnt = PNT_None
 } // loop over half = "b", "t"
 
+multiclass float_int_conversions {
+  defvar FVector = VecOf;
+  defvar IVector = VecOf;
+
+  let params = [IScalar], pnt = PNT_2Type in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # FScalar>;
+  let params = [FScalar], pnt = PNT_None in
+def : Intrinsic,
+  NameOverride<"vcvtq_" # IScalar>;
+}
+
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+defm : float_int_conversions;
+
 multiclass compare_with_pred {
   // Make the predicated and unpredicated versions of a single comparison.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
h

[PATCH] D74335: [ARM,MVE] Add intrinsics vclzq and vclsq.

2020-02-18 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68b49f7ef49e: [ARM,MVE] Add intrinsics vclzq and vclsq. 
(authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74335

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vclz.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vcls.ll
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vclsq_s8(<16 x i8> %a) {
+; CHECK-LABEL: test_vclsq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s8 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8> %a)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vclsq_s16(<8 x i16> %a) {
+; CHECK-LABEL: test_vclsq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vclsq_s32(<4 x i32> %a) {
+; CHECK-LABEL: test_vclsq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcls.s32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32> %a)
+  ret <4 x i32> %0
+}
+
+declare <16 x i8> @llvm.arm.mve.vcls.v16i8(<16 x i8>)
+declare <8 x i16> @llvm.arm.mve.vcls.v8i16(<8 x i16>)
+declare <4 x i32> @llvm.arm.mve.vcls.v4i32(<4 x i32>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -2076,6 +2076,13 @@
 (v4i32 ( MVE_VCLZs32 (v4i32 MQPR:$val1)))>;
   def : Pat<(v8i16 ( ctlz (v8i16 MQPR:$val1))),
 (v8i16 ( MVE_VCLZs16 (v8i16 MQPR:$val1)))>;
+
+  def : Pat<(v16i8 ( int_arm_mve_vcls (v16i8 MQPR:$val1))),
+(v16i8 ( MVE_VCLSs8 (v16i8 MQPR:$val1)))>;
+  def : Pat<(v4i32 ( int_arm_mve_vcls (v4i32 MQPR:$val1))),
+(v4i32 ( MVE_VCLSs32 (v4i32 MQPR:$val1)))>;
+  def : Pat<(v8i16 ( int_arm_mve_vcls (v8i16 MQPR:$val1))),
+(v8i16 ( MVE_VCLSs16 (v8i16 MQPR:$val1)))>;
 }
 
 class MVE_VABSNEG_int size, bit negate,
Index: llvm/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/include/llvm/IR/IntrinsicsARM.td
+++ llvm/include/llvm/IR/IntrinsicsARM.td
@@ -1161,5 +1161,7 @@
 
 def int_arm_mve_vrintn: Intrinsic<
   [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+def int_arm_mve_vcls: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
 
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vclz.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vclz.c
@@ -0,0 +1,132 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vclzq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vclzq_s8(int8x16_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s8(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <8 x i16> [[TMP0]]
+//
+int16x8_t test_vclzq_s16(int16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vclzq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> [[A:%.*]], i1 false)
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vclzq_s32(int32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vclzq(a);
+#else /* POLYMORPHIC */
+return vclzq_s32(a)

[PATCH] D74333: [ARM,MVE] Add intrinsics for FP rounding operations.

2020-02-18 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8b3196e5430: [ARM,MVE] Add intrinsics for FP rounding 
operations. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74333

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vrintn.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vrndnq_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vrndnq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half> %a)
+  ret <8 x half> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vrndnq_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vrndnq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vrintn.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float> %a)
+  ret <4 x float> %0
+}
+
+declare <8 x half> @llvm.arm.mve.vrintn.v8f16(<8 x half>)
+declare <4 x float> @llvm.arm.mve.vrintn.v4f32(<4 x float>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3179,6 +3179,10 @@
 (v4f32 (MVE_VRINTf32P (v4f32 MQPR:$val1)))>;
   def : Pat<(v8f16 (fceil (v8f16 MQPR:$val1))),
 (v8f16 (MVE_VRINTf16P (v8f16 MQPR:$val1)))>;
+  def : Pat<(v4f32 (int_arm_mve_vrintn (v4f32 MQPR:$val1))),
+(v4f32 (MVE_VRINTf32N (v4f32 MQPR:$val1)))>;
+  def : Pat<(v8f16 (int_arm_mve_vrintn (v8f16 MQPR:$val1))),
+(v8f16 (MVE_VRINTf16N (v8f16 MQPR:$val1)))>;
 }
 
 class MVEFloatArithNeon, llvm_anyvector_ty>;
+
+def int_arm_mve_vrintn: Intrinsic<
+  [llvm_anyvector_ty], [LLVMMatchType<0>], [IntrNoMem]>;
+
 } // end TargetPrefix
Index: clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-mve-intrinsics/vrnd.c
@@ -0,0 +1,173 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vrndaq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.round.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndaq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndaq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.round.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndaq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndaq(a);
+#else /* POLYMORPHIC */
+return vrndaq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.floor.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndmq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return vrndmq_f16(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndmq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x float> @llvm.floor.v4f32(<4 x float> [[A:%.*]])
+// CHECK-NEXT:ret <4 x float> [[TMP0]]
+//
+float32x4_t test_vrndmq_f32(float32x4_t a)
+{
+#ifdef POLYMORPHIC
+return vrndmq(a);
+#else /* POLYMORPHIC */
+return vrndmq_f32(a);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vrndpq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.ceil.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vrndpq_f16(float16x8_t a)
+{
+#ifdef POLYMORPHIC
+return vrndpq(a);
+#else /* POLYMORPHIC */
+

[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-18 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc32af4447f79: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic 
family. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
  clang/utils/TableGen/MveEmitter.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=LE %s
+; RUN: llc -mtriple=thumbebv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=BE %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovnbq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnb.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %0)
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovnbq_s32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_s32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnb.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = tail call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %0)
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_u16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovnbq_u16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_u16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnb.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %0)
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_u32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovnbq_u32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_u32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnb.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = tail call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %0)
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_s16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovntq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnt.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovntq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnt.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %a)
+  %1 = shufflevector <8 x i16> %0, <8 x i16> %b, <16 x i32> 
+  %2 = trunc <16 x i16> %1 to <16 x i8>
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovntq_s32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovntq_s32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnt.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovntq_s32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnt.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm

[PATCH] D74336: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic family.

2020-02-18 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e97940cd279: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic 
family. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74336

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
  llvm/test/CodeGen/Thumb2/mve-shuffleext.ll

Index: llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
===
--- llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
+++ llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
@@ -15,8 +15,7 @@
 define arm_aapcs_vfpcc <4 x i32> @sext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: sext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -38,8 +37,7 @@
 define arm_aapcs_vfpcc <4 x i32> @zext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: zext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:vmovlt.u16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -61,8 +59,7 @@
 define arm_aapcs_vfpcc <8 x i16> @sext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: sext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:vmovlt.s8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
@@ -84,8 +81,7 @@
 define arm_aapcs_vfpcc <8 x i16> @zext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: zext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:vmovlt.u8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
@@ -0,0 +1,147 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=LE %s
+; RUN: llc -mtriple=thumbebv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=BE %s
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_s8(<16 x i8> %a) {
+; LE-LABEL: test_vmovlbq_s8:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.s8 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_s8:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovlb.s8 q1, q1
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = sext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_s16(<8 x i16> %a) {
+; LE-LABEL: test_vmovlbq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.s16 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovlb.s16 q1, q1
+; BE-NEXT:vrev64.32 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = sext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_u8(<16 x i8> %a) {
+; LE-LABEL: test_vmovlbq_u8:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.u8 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_u8:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovlb.u8 q1, q1
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = zext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_u16(<8 x i16> %a) {
+; LE-LABEL: test_vmovlbq_u16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.u16 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_u16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovlb.u16 q1, q1
+; BE-NEXT:vrev64.32 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = zext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovltq_s8(<16 x i8> %a) {
+; LE-LABEL: test_vmovltq_s8:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlt.s8 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-18 Thread Victor Lomuller via Phabricator via cfe-commits
Naghasan added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.def:206
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
+ENUM_LANGOPT(SYCLVersion, SYCLVersionList, 4, SYCLVersionList::undefined, 
"Version of the SYCL standard used")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")

Ruyk wrote:
> bader wrote:
> > All other language options controlling standard versions are added as 
> > "LANGOPT" i.e. `int`. Why SYCLVersion is different?
> > @Ruyk, do you think we should convert other options (e.g. `OpenCL`) to 
> > enums as well?
> Thats a good point. I don't see strong reasons for the enum, basically I read 
> the comment in 
> https://code.woboq.org/llvm/clang/include/clang/Basic/LangOptions.def.html#22
> 
> 
> ```
> // ENUM_LANGOPT: for options that have enumeration, rather than unsigned, 
> type.
> ```
> 
> And since there is a known set of SYCL specifications, made more sense to 
> enumerate it.
> It also simplifies writing variants to 1.2.1 (e.g. 1.2.1-oneapi) in the code 
> since then you can add another entry to the enum.
> 
> But no strong feelings, so feel free to change it.
> 
`int` allows the use of relational operators which should ease version 
managements.

As `SYCLVersionList` is a strongly typed enum so this may not be the best, and 
as the SYCL version are now meant to be a year `int` should do just fine.



Comment at: clang/include/clang/Driver/Options.td:3401
+def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"SYCL language standard to compile for.">, Values<"1.2.1">;
 

Ruyk wrote:
> bader wrote:
> > What do you think we integrate sycl versions to existing clang options 
> > controlling language version: `-std`.
> > As far as I can see it's used for all the C/C+ extensions like 
> > OpenMP/OpenCL/CUDA/HIP/ObjC.
> > 
> > If I understand correctly clang supports `-cl-std` only because it's 
> > required by OpenCL standard. Similar option (i.e. `-sycl-std`) is not 
> > required by the SYCL specification, so using `-std` is more aligned with 
> > existing clang design.
> > 
> > See clang/include/clang/Basic/LangStandard.h and 
> > clang/include/clang/Basic/LangStandards.def.
> In the case of SYCL, you may want to compile your code with C++17 and SYCL 
> 2015, in which case you need both -std=c++17 and -sycl=sycl-2015 . 
> SYCL specification mandates a minimum C++ version but users can write code on 
> newer versions as long as the code in the kernel scope is still valid.
+1 on this, ComputeCpp used to mix-up both and this proved to be complex to 
manage. It also integrates better with build systems.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

bader wrote:
> ABataev wrote:
> > bader wrote:
> > > ABataev wrote:
> > > > bader wrote:
> > > > > ABataev wrote:
> > > > > > bader wrote:
> > > > > > > ABataev wrote:
> > > > > > > > bader wrote:
> > > > > > > > > ABataev wrote:
> > > > > > > > > > This option also must be controlled by `-fsycl`:
> > > > > > > > > > ```
> > > > > > > > > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > > > > > > > > Args.hasArg(options::OPT_fsycl_is_device);
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > Does it really has to? This logic is already present in the 
> > > > > > > > > driver and it makes front-end tests verbose `%clang_cc1 
> > > > > > > > > -fsycl -fsycl-is-device`.
> > > > > > > > > Can `-fsycl-is-device` imply `-fsycl`?
> > > > > > > > > Looking how CUDA/OpenMP options are handled, not all of them 
> > > > > > > > > are processed using this pattern.
> > > > > > > > In general, this is how we handle it in OpenMP. Cuda works 
> > > > > > > > differently, because it has its own kind of files (.cu) and 
> > > > > > > > Cuda is triggered by the language switch (-x cu). Seems to me, 
> > > > > > > > you're using something close to OpenMP model, no? Or do you 
> > > > > > > > want to define your own language kind just like Cuda?
> > > > > > > I applied you suggest, although I don't fully understand the need 
> > > > > > > of using two options instead of two. I would prefer having 
> > > > > > > following code:
> > > > > > > ```
> > > > > > > Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
> > > > > > > Opts.SYCL = Args.hasArg(options::OPT_fsycl) || Opts.SYCLIsDevice; 
> > > > > > > // -fsycl-is-device enable SYCL mode as well
> > > > > > > ```
> > > > > > I'm not quite familiar with SYCL model, maybe this the right 
> > > > > > approach. You'd better try to provide more details. Are there any 
> > > > > > differences between just SYCL and SYCL-device compilation modes? 
> > > > > > How do you see the compilation sequence in general? At first yo

[PATCH] D69782: Summary: Instead of dropping all the ranges associated with a Diagnostic when converting them to a ClangTidy error, instead attach them to the ClangTidyError, so they can be consumed b

2020-02-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thanks for the update!

Please upload patches with full context. That makes navigating the code much 
easier during reviews. See https://llvm.org/docs/Phabricator.html

A few more comments inline.




Comment at: include/clang/Tooling/Core/Diagnostic.h:62-70
+/// Represents extra source ranges to be associated with a diagnostic.
+struct DiagnosticAssociatedRanges {
+  DiagnosticAssociatedRanges() = default;
+
+  DiagnosticAssociatedRanges(const SourceManager &Sources,
+ ArrayRef SourceRanges);
+

Why is this needed? Shouldn't `LLVM_YAML_IS_SEQUENCE_VECTOR` be enough to allow 
for SmallVector to be yaml serializable? Seems 
to work with `DiagnosticMessage` and `Diagnostic::Notes`.



Comment at: lib/Tooling/Core/Diagnostic.cpp:51
+  for (const CharSourceRange &Range : SourceRanges) {
+Ranges.emplace_back(DiagnosticAssociatedRange(Sources, Range));
+  }

With emplace_back constructor parameters can be used directly:

  Ranges.emplace_back(Sources, Range);

That's the whole point of `emplace_back`.


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

https://reviews.llvm.org/D69782



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


[clang] 8b65f79 - [OpenCL] Add Arm dot product builtin functions

2020-02-18 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-02-18T10:02:06Z
New Revision: 8b65f792a0a96a091c24fdacf4ce04686e0eefb2

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

LOG: [OpenCL] Add Arm dot product builtin functions

Add the Arm dot product builtin functions from the OpenCL extension
available at
https://www.khronos.org/registry/OpenCL/extensions/arm/cl_arm_integer_dot_product.txt

Patch by Pierre Gondois and Sven van Haastregt.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 888978dfdbd3..f0790dd32527 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -66,6 +66,12 @@ def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sha
 // Multiple extensions
 def FuncExtKhrMipmapWritesAndWrite3d : 
FunctionExtension<"cl_khr_mipmap_image_writes cl_khr_3d_image_writes">;
 
+// Arm extensions.
+def ArmIntegerDotProductInt8   : 
FunctionExtension<"cl_arm_integer_dot_product_int8">;
+def ArmIntegerDotProductAccumulateInt8 : 
FunctionExtension<"cl_arm_integer_dot_product_accumulate_int8">;
+def ArmIntegerDotProductAccumulateInt16: 
FunctionExtension<"cl_arm_integer_dot_product_accumulate_int16">;
+def ArmIntegerDotProductAccumulateSaturateInt8 : 
FunctionExtension<"cl_arm_integer_dot_product_accumulate_saturate_int8">;
+
 // Qualified Type.  These map to ASTContext::QualType.
 class QualType {
   // Name of the field or function in a clang::ASTContext
@@ -1350,3 +1356,30 @@ let Extension = FuncExtKhrGlMsaaSharing in {
 def : Builtin<"get_image_array_size", [Size, 
ImageType], Attr.Const>;
   }
 }
+
+//
+// Arm extensions.
+let Extension = ArmIntegerDotProductInt8 in {
+  foreach name = ["arm_dot"] in {
+def : Builtin, VectorType]>;
+def : Builtin, VectorType]>;
+  }
+}
+let Extension = ArmIntegerDotProductAccumulateInt8 in {
+  foreach name = ["arm_dot_acc"] in {
+def : Builtin, VectorType, 
UInt]>;
+def : Builtin, VectorType, Int]>;
+  }
+}
+let Extension = ArmIntegerDotProductAccumulateInt16 in {
+  foreach name = ["arm_dot_acc"] in {
+def : Builtin, VectorType, 
UInt]>;
+def : Builtin, VectorType, 
Int]>;
+  }
+}
+let Extension = ArmIntegerDotProductAccumulateSaturateInt8 in {
+  foreach name = ["arm_dot_acc_sat"] in {
+def : Builtin, VectorType, 
UInt]>;
+def : Builtin, VectorType, Int]>;
+  }
+}



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


[PATCH] D73903: [AArch64][SVE] Add remaining SVE2 intrinsics for widening DSP operations

2020-02-18 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:1100
 [IntrNoMem]>;
+
   class SVE2_2VectorArg_Narrowing_Intrinsic

nit: unnecessary change


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

https://reviews.llvm.org/D73903



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


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-18 Thread Alexey Bader via Phabricator via cfe-commits
bader marked 3 inline comments as done.
bader added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.def:206
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
+ENUM_LANGOPT(SYCLVersion, SYCLVersionList, 4, SYCLVersionList::undefined, 
"Version of the SYCL standard used")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")

Naghasan wrote:
> Ruyk wrote:
> > bader wrote:
> > > All other language options controlling standard versions are added as 
> > > "LANGOPT" i.e. `int`. Why SYCLVersion is different?
> > > @Ruyk, do you think we should convert other options (e.g. `OpenCL`) to 
> > > enums as well?
> > Thats a good point. I don't see strong reasons for the enum, basically I 
> > read the comment in 
> > https://code.woboq.org/llvm/clang/include/clang/Basic/LangOptions.def.html#22
> > 
> > 
> > ```
> > // ENUM_LANGOPT: for options that have enumeration, rather than unsigned, 
> > type.
> > ```
> > 
> > And since there is a known set of SYCL specifications, made more sense to 
> > enumerate it.
> > It also simplifies writing variants to 1.2.1 (e.g. 1.2.1-oneapi) in the 
> > code since then you can add another entry to the enum.
> > 
> > But no strong feelings, so feel free to change it.
> > 
> `int` allows the use of relational operators which should ease version 
> managements.
> 
> As `SYCLVersionList` is a strongly typed enum so this may not be the best, 
> and as the SYCL version are now meant to be a year `int` should do just fine.
Okay. I'll change the type from enum to int.



Comment at: clang/include/clang/Driver/Options.td:3401
+def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"SYCL language standard to compile for.">, Values<"1.2.1">;
 

Naghasan wrote:
> Ruyk wrote:
> > bader wrote:
> > > What do you think we integrate sycl versions to existing clang options 
> > > controlling language version: `-std`.
> > > As far as I can see it's used for all the C/C+ extensions like 
> > > OpenMP/OpenCL/CUDA/HIP/ObjC.
> > > 
> > > If I understand correctly clang supports `-cl-std` only because it's 
> > > required by OpenCL standard. Similar option (i.e. `-sycl-std`) is not 
> > > required by the SYCL specification, so using `-std` is more aligned with 
> > > existing clang design.
> > > 
> > > See clang/include/clang/Basic/LangStandard.h and 
> > > clang/include/clang/Basic/LangStandards.def.
> > In the case of SYCL, you may want to compile your code with C++17 and SYCL 
> > 2015, in which case you need both -std=c++17 and -sycl=sycl-2015 . 
> > SYCL specification mandates a minimum C++ version but users can write code 
> > on newer versions as long as the code in the kernel scope is still valid.
> +1 on this, ComputeCpp used to mix-up both and this proved to be complex to 
> manage. It also integrates better with build systems.
Okay. I'll leave it as a separate option.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2548
+  Opts.SYCL = Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false);
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {

Naghasan wrote:
> bader wrote:
> > ABataev wrote:
> > > bader wrote:
> > > > ABataev wrote:
> > > > > bader wrote:
> > > > > > ABataev wrote:
> > > > > > > bader wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > bader wrote:
> > > > > > > > > > ABataev wrote:
> > > > > > > > > > > This option also must be controlled by `-fsycl`:
> > > > > > > > > > > ```
> > > > > > > > > > > Opts.SYCLIsDevice =  Opts.SYCL && 
> > > > > > > > > > > Args.hasArg(options::OPT_fsycl_is_device);
> > > > > > > > > > > 
> > > > > > > > > > > ```
> > > > > > > > > > Does it really has to? This logic is already present in the 
> > > > > > > > > > driver and it makes front-end tests verbose `%clang_cc1 
> > > > > > > > > > -fsycl -fsycl-is-device`.
> > > > > > > > > > Can `-fsycl-is-device` imply `-fsycl`?
> > > > > > > > > > Looking how CUDA/OpenMP options are handled, not all of 
> > > > > > > > > > them are processed using this pattern.
> > > > > > > > > In general, this is how we handle it in OpenMP. Cuda works 
> > > > > > > > > differently, because it has its own kind of files (.cu) and 
> > > > > > > > > Cuda is triggered by the language switch (-x cu). Seems to 
> > > > > > > > > me, you're using something close to OpenMP model, no? Or do 
> > > > > > > > > you want to define your own language kind just like Cuda?
> > > > > > > > I applied you suggest, although I don't fully understand the 
> > > > > > > > need of using two options instead of two. I would prefer having 
> > > > > > > > following code:
> > > > > > > > ```
> > > > > > > > Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
> > > > > > > > Opts.SYCL = Args.hasArg(options::OPT_fsycl) || 
> > > > > > > > Opts.SYCLIsDevice; // -fsycl-is-device enable SYCL m

[PATCH] D72523: [remark][diagnostics] Using clang diagnostic handler for IR input files

2020-02-18 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

This change triggers a crash in a release build of llvm:
See https://bugs.llvm.org/show_bug.cgi?id=44896


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72523



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


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-02-18 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey added a comment.

Hi @aprantl, I have included all of your suggestions. Can I merge this?


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

https://reviews.llvm.org/D73462



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


[clang] 58f66f8 - [ARM,CDE] Cosmetic changes, additonal driver tests

2020-02-18 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-02-18T10:23:09Z
New Revision: 58f66f8af01db7f7f349654793a2b88376644122

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

LOG: [ARM,CDE] Cosmetic changes, additonal driver tests

Summary:
This is a follow-up patch addressing post-commit comments in
https://reviews.llvm.org/D74044:
* Add more Clang driver tests (-march=armv8.1m.main and 
-march=armv8.1m.main+mve.fp)
* Clang-format a chunk in ARMAsmParser.cpp
* Add a missing copyright header to ARMInstrCDE.td

Reviewers: SjoerdMeijer, simon_tatham, dmgreen

Reviewed By: SjoerdMeijer

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/test/Driver/arm-cde.c
llvm/lib/Target/ARM/ARMInstrCDE.td
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Removed: 




diff  --git a/clang/test/Driver/arm-cde.c b/clang/test/Driver/arm-cde.c
index 696bee46cc34..8dfa130da3fb 100644
--- a/clang/test/Driver/arm-cde.c
+++ b/clang/test/Driver/arm-cde.c
@@ -1,5 +1,7 @@
-// RUN: %clang -target arm-none-none-eabi -march=armv8m.main %s -### -c 2>&1 | 
FileCheck %s --check-prefix=CHECK-NOCDE
-// CHECK-NOCDE: "-triple" "thumbv8m.main-none-none-eabi"
+// RUN: %clang -target arm-none-none-eabi -march=armv8m.main %s -### -c 2>&1 | 
FileCheck %s --check-prefixes=CHECK-NOCDE,CHECK-NOCDE-V8
+// RUN: %clang -target arm-none-none-eabi -march=armv8.1m.main %s -### -c 2>&1 
| FileCheck %s --check-prefixes=CHECK-NOCDE,CHECK-NOCDE-V81
+// CHECK-NOCDE-V8: "-triple" "thumbv8m.main-none-none-eabi"
+// CHECK-NOCDE-V81: "-triple" "thumbv8.1m.main-none-none-eabi"
 // CHECK-NOCDE-NOT: "-target-feature" "+cdecp0"
 // CHECK-NOCDE-NOT: "-target-feature" "+cdecp1"
 // CHECK-NOCDE-NOT: "-target-feature" "+cdecp2"
@@ -9,13 +11,20 @@
 // CHECK-NOCDE-NOT: "-target-feature" "+cdecp6"
 // CHECK-NOCDE-NOT: "-target-feature" "+cdecp7"
 
-// RUN: %clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3 %s 
-### -c 2>&1 | FileCheck %s --check-prefix=CHECK-CDE1
-// CHECK-CDE1: "-triple" "thumbv8m.main-none-none-eabi"
+// RUN: %clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3 %s 
-### -c 2>&1 | FileCheck %s --check-prefixes=CHECK-CDE1,CHECK-CDE1-V8
+// RUN: %clang -target arm-none-none-eabi -march=armv8.1m.main+cdecp0+cdecp3 
%s -### -c 2>&1 | FileCheck %s --check-prefixes=CHECK-CDE1,CHECK-CDE1-V81
+// RUN: %clang -target arm-none-none-eabi 
-march=armv8.1m.main+mve.fp+cdecp0+cdecp3 %s -### -c 2>&1 | FileCheck %s 
--check-prefixes=CHECK-CDE1,CHECK-CDE1-V81MVE
+// CHECK-CDE1-V8: "-triple" "thumbv8m.main-none-none-eabi"
+// CHECK-CDE1-V81: "-triple" "thumbv8.1m.main-none-none-eabi"
+// CHECK-CDE1-V81MVE: "-triple" "thumbv8.1m.main-none-none-eabi"
+// CHECK-CDE1-V81MVE-DAG: "-target-feature" "+mve.fp"
 // CHECK-CDE1-DAG: "-target-feature" "+cdecp0"
 // CHECK-CDE1-DAG: "-target-feature" "+cdecp3"
 
-// RUN: %clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3 %s 
-### -c 2>&1 | FileCheck %s --check-prefix=CHECK-CDE2
-// CHECK-CDE2: "-triple" "thumbv8m.main-none-none-eabi"
+// RUN: %clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3 %s 
-### -c 2>&1 | FileCheck %s --check-prefixes=CHECK-CDE2,CHECK-CDE2-V8
+// RUN: %clang -target arm-none-none-eabi -march=armv8.1m.main+cdecp0+cdecp3 
%s -### -c 2>&1 | FileCheck %s --check-prefixes=CHECK-CDE2,CHECK-CDE2-V81
+// CHECK-CDE2-V8: "-triple" "thumbv8m.main-none-none-eabi"
+// CHECK-CDE2-V81: "-triple" "thumbv8.1m.main-none-none-eabi"
 // CHECK-CDE2-NOT: "-target-feature" "+cdecp1"
 // CHECK-CDE2-NOT: "-target-feature" "+cdecp2"
 // CHECK-CDE2-NOT: "-target-feature" "+cdecp4"

diff  --git a/llvm/lib/Target/ARM/ARMInstrCDE.td 
b/llvm/lib/Target/ARM/ARMInstrCDE.td
index 4e73ea819473..fb02e9fefd8c 100644
--- a/llvm/lib/Target/ARM/ARMInstrCDE.td
+++ b/llvm/lib/Target/ARM/ARMInstrCDE.td
@@ -1,3 +1,15 @@
+//===-- ARMInstrCDE.td - CDE support for ARM ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the Arm CDE (Custom Datapath Extension) instruction set.
+//
+//===--===//
+
 // Immediate operand of arbitrary bit width
 class BitWidthImmOperand
   : ImmAsmOperand<0, !add(!shl(1, width), -1)> {

diff  --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp 
b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 65c2d4790633..3ffee6804b3c 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMA

[PATCH] D74757: Fix compiler extension in standalone mode

2020-02-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

I still need to test many configurations, I'll report here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74757



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


[PATCH] D74757: Fix compiler extension in standalone mode

2020-02-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: Meinersbur, Keruspe.
Herald added subscribers: llvm-commits, cfe-commits, mgorny.
Herald added projects: clang, LLVM.
serge-sans-paille added a comment.

I still need to test many configurations, I'll report here.


Use a dedicated cmake file to store the extension configured within LLVM.

This patch is related to https://reviews.llvm.org/D74602


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74757

Files:
  clang/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in

Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -112,3 +112,5 @@
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
+
+
Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -136,6 +136,7 @@
 FILES_MATCHING PATTERN *.cmake
 PATTERN .svn EXCLUDE
 PATTERN LLVMConfig.cmake EXCLUDE
+PATTERN LLVMConfigExtensions.cmake EXCLUDE
 PATTERN LLVMConfigVersion.cmake EXCLUDE
 PATTERN LLVM-Config.cmake EXCLUDE
 PATTERN GetHostTriple.cmake EXCLUDE)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -873,13 +873,13 @@
 if (TARGET intrinsics_gen)
   add_dependencies(obj.${name} intrinsics_gen)
 endif()
-message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
-set_property(GLOBAL APPEND PROPERTY LLVM_COMPILE_EXTENSIONS ${name})
+set_property(GLOBAL APPEND PROPERTY LLVM_STATIC_EXTENSIONS ${name})
   elseif(NOT ARG_NO_MODULE)
 add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
   else()
 add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
   endif()
+  message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
 
 endfunction(add_llvm_pass_plugin)
 
@@ -888,48 +888,47 @@
 # Correctly set lib dependencies between plugins and tools, based on tools
 # registered with the ENABLE_PLUGINS option.
 #
-# Unless NO_GEN option is set, also generate X Macro file for extension
+# if GEN_CONFIG option is set, also generate X Macro file for extension
 # handling. It provides a HANDLE_EXTENSION(extension_namespace, ExtensionProject)
 # call for each extension allowing client code to define
 # HANDLE_EXTENSION to have a specific code be run for each extension.
 #
 function(process_llvm_pass_plugins)
   cmake_parse_arguments(ARG
-  "NO_GEN" "" ""
+  "GEN_CONFIG" "" ""
 ${ARGN})
 
+  if(ARG_GEN_CONFIG)
+  get_property(LLVM_STATIC_EXTENSIONS GLOBAL PROPERTY LLVM_STATIC_EXTENSIONS)
+  else()
+  include(LLVMConfigExtensions)
+  endif()
+
   # Add static plugins to each plugin target.
-  get_property(LLVM_EXTENSIONS GLOBAL PROPERTY LLVM_COMPILE_EXTENSIONS)
-  foreach(llvm_extension ${LLVM_EXTENSIONS})
-string(TOUPPER ${llvm_extension} llvm_extension_upper)
-string(TOLOWER ${llvm_extension} llvm_extension_lower)
-
-if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
-  get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
-  foreach(llvm_plugin_target ${llvm_plugin_targets})
-set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
-set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
-  endforeach()
-else()
-  add_llvm_library(${llvm_extension_lower} MODULE obj.${llvm_extension_lower})
-endif()
+  foreach(llvm_extension ${LLVM_STATIC_EXTENSIONS})
+get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
+foreach(llvm_plugin_target ${llvm_plugin_targets})
+  set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
+  set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
+endforeach()
   endforeach()
 
-  # Eventually generate the extension header.
-  if(NOT ARG_NO_GEN)
-  file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "//extension handlers\n")
-  foreach(llvm_extension ${LLVM_EXTENSIONS})
-string(TOLOWER ${llvm_extension} llvm_extension_lower)
-
-string(TOUPPER ${llvm_extension} llvm_extension_upper)
-string(SUBSTRING ${llvm_extension_upper} 0 1 llvm_extension_upper_first)
-string(SUBSTRING ${llvm_extension_lower} 1 -1 llvm_extension_lower_tail)
-string(CONCAT llvm_extension_project ${llvm_extension_upper_f

[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-18 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd230142d8a0: Support -fuse-ld=lld for riscv (authored by 
serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/riscv32-toolchain.c


Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -3,6 +3,10 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
+// Test interaction with -fuse-ld=lld
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 
2>&1 | FileCheck -check-prefix=LLD %s
+// LLD: ld.lld
+
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -142,7 +142,7 @@
 CmdArgs.push_back("elf32lriscv");
   }
 
-  std::string Linker = getToolChain().GetProgramPath(getShortName());
+  std::string Linker = getToolChain().GetLinkerPath();
 
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);


Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -3,6 +3,10 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
+// Test interaction with -fuse-ld=lld
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// LLD: ld.lld
+
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -142,7 +142,7 @@
 CmdArgs.push_back("elf32lriscv");
   }
 
-  std::string Linker = getToolChain().GetProgramPath(getShortName());
+  std::string Linker = getToolChain().GetLinkerPath();
 
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74732: [ARM,CDE] Cosmetic changes, additonal driver tests

2020-02-18 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58f66f8af01d: [ARM,CDE] Cosmetic changes, additonal driver 
tests (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74732

Files:
  clang/test/Driver/arm-cde.c
  llvm/lib/Target/ARM/ARMInstrCDE.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -8136,15 +8136,36 @@
 break;
   }
 
-  case ARM::CDE_CX1: case ARM::CDE_CX1A: case ARM::CDE_CX1D: case ARM::CDE_CX1DA:
-  case ARM::CDE_CX2: case ARM::CDE_CX2A: case ARM::CDE_CX2D: case ARM::CDE_CX2DA:
-  case ARM::CDE_CX3: case ARM::CDE_CX3A: case ARM::CDE_CX3D: case ARM::CDE_CX3DA:
-  case ARM::CDE_VCX1_vec:  case ARM::CDE_VCX1_fpsp:  case ARM::CDE_VCX1_fpdp:
-  case ARM::CDE_VCX1A_vec: case ARM::CDE_VCX1A_fpsp: case ARM::CDE_VCX1A_fpdp:
-  case ARM::CDE_VCX2_vec:  case ARM::CDE_VCX2_fpsp:  case ARM::CDE_VCX2_fpdp:
-  case ARM::CDE_VCX2A_vec: case ARM::CDE_VCX2A_fpsp: case ARM::CDE_VCX2A_fpdp:
-  case ARM::CDE_VCX3_vec:  case ARM::CDE_VCX3_fpsp:  case ARM::CDE_VCX3_fpdp:
-  case ARM::CDE_VCX3A_vec: case ARM::CDE_VCX3A_fpsp: case ARM::CDE_VCX3A_fpdp: {
+  case ARM::CDE_CX1:
+  case ARM::CDE_CX1A:
+  case ARM::CDE_CX1D:
+  case ARM::CDE_CX1DA:
+  case ARM::CDE_CX2:
+  case ARM::CDE_CX2A:
+  case ARM::CDE_CX2D:
+  case ARM::CDE_CX2DA:
+  case ARM::CDE_CX3:
+  case ARM::CDE_CX3A:
+  case ARM::CDE_CX3D:
+  case ARM::CDE_CX3DA:
+  case ARM::CDE_VCX1_vec:
+  case ARM::CDE_VCX1_fpsp:
+  case ARM::CDE_VCX1_fpdp:
+  case ARM::CDE_VCX1A_vec:
+  case ARM::CDE_VCX1A_fpsp:
+  case ARM::CDE_VCX1A_fpdp:
+  case ARM::CDE_VCX2_vec:
+  case ARM::CDE_VCX2_fpsp:
+  case ARM::CDE_VCX2_fpdp:
+  case ARM::CDE_VCX2A_vec:
+  case ARM::CDE_VCX2A_fpsp:
+  case ARM::CDE_VCX2A_fpdp:
+  case ARM::CDE_VCX3_vec:
+  case ARM::CDE_VCX3_fpsp:
+  case ARM::CDE_VCX3_fpdp:
+  case ARM::CDE_VCX3A_vec:
+  case ARM::CDE_VCX3A_fpsp:
+  case ARM::CDE_VCX3A_fpdp: {
 assert(Inst.getOperand(1).isImm() &&
"CDE operand 1 must be a coprocessor ID");
 int64_t Coproc = Inst.getOperand(1).getImm();
@@ -8157,17 +8178,48 @@
 break;
   }
 
-  case ARM::t2CDP: case ARM::t2CDP2:
-  case ARM::t2LDC2L_OFFSET: case ARM::t2LDC2L_OPTION: case ARM::t2LDC2L_POST: case ARM::t2LDC2L_PRE:
-  case ARM::t2LDC2_OFFSET: case ARM::t2LDC2_OPTION: case ARM::t2LDC2_POST: case ARM::t2LDC2_PRE:
-  case ARM::t2LDCL_OFFSET: case ARM::t2LDCL_OPTION: case ARM::t2LDCL_POST: case ARM::t2LDCL_PRE:
-  case ARM::t2LDC_OFFSET: case ARM::t2LDC_OPTION: case ARM::t2LDC_POST: case ARM::t2LDC_PRE:
-  case ARM::t2MCR: case ARM::t2MCR2: case ARM::t2MCRR: case ARM::t2MCRR2:
-  case ARM::t2MRC: case ARM::t2MRC2: case ARM::t2MRRC: case ARM::t2MRRC2:
-  case ARM::t2STC2L_OFFSET: case ARM::t2STC2L_OPTION: case ARM::t2STC2L_POST: case ARM::t2STC2L_PRE:
-  case ARM::t2STC2_OFFSET: case ARM::t2STC2_OPTION: case ARM::t2STC2_POST: case ARM::t2STC2_PRE:
-  case ARM::t2STCL_OFFSET: case ARM::t2STCL_OPTION: case ARM::t2STCL_POST: case ARM::t2STCL_PRE:
-  case ARM::t2STC_OFFSET: case ARM::t2STC_OPTION: case ARM::t2STC_POST: case ARM::t2STC_PRE: {
+  case ARM::t2CDP:
+  case ARM::t2CDP2:
+  case ARM::t2LDC2L_OFFSET:
+  case ARM::t2LDC2L_OPTION:
+  case ARM::t2LDC2L_POST:
+  case ARM::t2LDC2L_PRE:
+  case ARM::t2LDC2_OFFSET:
+  case ARM::t2LDC2_OPTION:
+  case ARM::t2LDC2_POST:
+  case ARM::t2LDC2_PRE:
+  case ARM::t2LDCL_OFFSET:
+  case ARM::t2LDCL_OPTION:
+  case ARM::t2LDCL_POST:
+  case ARM::t2LDCL_PRE:
+  case ARM::t2LDC_OFFSET:
+  case ARM::t2LDC_OPTION:
+  case ARM::t2LDC_POST:
+  case ARM::t2LDC_PRE:
+  case ARM::t2MCR:
+  case ARM::t2MCR2:
+  case ARM::t2MCRR:
+  case ARM::t2MCRR2:
+  case ARM::t2MRC:
+  case ARM::t2MRC2:
+  case ARM::t2MRRC:
+  case ARM::t2MRRC2:
+  case ARM::t2STC2L_OFFSET:
+  case ARM::t2STC2L_OPTION:
+  case ARM::t2STC2L_POST:
+  case ARM::t2STC2L_PRE:
+  case ARM::t2STC2_OFFSET:
+  case ARM::t2STC2_OPTION:
+  case ARM::t2STC2_POST:
+  case ARM::t2STC2_PRE:
+  case ARM::t2STCL_OFFSET:
+  case ARM::t2STCL_OPTION:
+  case ARM::t2STCL_POST:
+  case ARM::t2STCL_PRE:
+  case ARM::t2STC_OFFSET:
+  case ARM::t2STC_OPTION:
+  case ARM::t2STC_POST:
+  case ARM::t2STC_PRE: {
 unsigned Opcode = Inst.getOpcode();
 // Inst.getOperand indexes operands in the (oops ...) and (iops ...) dags,
 // CopInd is the index of the coprocessor operand.
@@ -8176,11 +8228,13 @@
   CopInd = 2;
 else if (Opcode == ARM::t2MRC || Opcode == ARM::t2MRC2)
   CopInd = 1;
-assert(Inst.getOperand(CopInd).isImm() && "Operand must be a coprocessor ID");
+assert(Inst.getOperand(CopInd).isImm() &&
+   "Operand must be a coprocessor ID");
 int64_t Coproc = Inst.getOperand(CopInd).getImm();
 //

[clang] dd23014 - Support -fuse-ld=lld for riscv

2020-02-18 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-02-18T11:24:09+01:00
New Revision: dd230142d8a00f5f30c3930a2407000e845dcfbf

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

LOG: Support -fuse-ld=lld for riscv

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/RISCVToolchain.cpp
clang/test/Driver/riscv32-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp 
b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
index 24c2b37c4b77..21106d003859 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -142,7 +142,7 @@ void RISCV::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("elf32lriscv");
   }
 
-  std::string Linker = getToolChain().GetProgramPath(getShortName());
+  std::string Linker = getToolChain().GetLinkerPath();
 
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);

diff  --git a/clang/test/Driver/riscv32-toolchain.c 
b/clang/test/Driver/riscv32-toolchain.c
index 2ff3a585bda3..1b765dba6b9a 100644
--- a/clang/test/Driver/riscv32-toolchain.c
+++ b/clang/test/Driver/riscv32-toolchain.c
@@ -3,6 +3,10 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
+// Test interaction with -fuse-ld=lld
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 
2>&1 | FileCheck -check-prefix=LLD %s
+// LLD: ld.lld
+
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 



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


[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2020-02-18 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis updated this revision to Diff 245113.
abelkocsis added a comment.

Test cases adding, checker modifying to pass new cases.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70876

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-spuriously-wake-up-functions.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.c
  clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s bugprone-spuriously-wake-up-functions %t -- --
+#define NULL 0
+
+namespace std {
+using intmax_t = int;
+
+template 
+class ratio {
+public:
+  static constexpr intmax_t num = 0;
+  static constexpr intmax_t den = 0;
+  typedef ratio type;
+};
+typedef ratio<1, 1000> milli;
+namespace chrono {
+
+template >
+class duration {
+public:
+  using rep = Rep;
+  using period = Period;
+
+public:
+  constexpr duration() = default;
+  template 
+  constexpr explicit duration(const Rep2 &r);
+  template 
+  constexpr duration(const duration &d);
+  ~duration() = default;
+  duration(const duration &) = default;
+};
+
+template 
+class time_point {
+public:
+  using clock = Clock;
+  using duration = Duration;
+
+public:
+  constexpr time_point();
+  constexpr explicit time_point(const duration &d);
+  template 
+  constexpr time_point(const time_point &t);
+};
+
+using milliseconds = duration;
+
+class system_clock {
+public:
+  typedef milliseconds duration;
+  typedef duration::rep rep;
+  typedef duration::period period;
+  typedef chrono::time_point time_point;
+
+  static time_point now() noexcept;
+};
+} // namespace chrono
+
+class mutex;
+template 
+class unique_lock {
+public:
+  typedef Mutex mutex_type;
+
+  unique_lock() noexcept;
+  explicit unique_lock(mutex_type &m);
+};
+
+class mutex {
+public:
+  constexpr mutex() noexcept;
+  ~mutex();
+  mutex(const mutex &) = delete;
+  mutex &operator=(const mutex &) = delete;
+};
+
+enum class cv_status {
+  no_timeout,
+  timeout
+};
+
+class condition_variable {
+public:
+  condition_variable();
+  ~condition_variable();
+  condition_variable(const condition_variable &) = delete;
+
+  void wait(unique_lock &lock);
+  template 
+  void wait(unique_lock &lock, Predicate pred);
+  template 
+  cv_status wait_until(unique_lock &lock,
+   const chrono::time_point &abs_time){};
+  template 
+  bool wait_until(unique_lock &lock,
+  const chrono::time_point &abs_time,
+  Predicate pred){};
+  template 
+  cv_status wait_for(unique_lock &lock,
+ const chrono::duration &rel_time){};
+  template 
+  bool wait_for(unique_lock &lock,
+const chrono::duration &rel_time,
+Predicate pred){};
+};
+
+} // namespace std
+
+struct Node1 {
+  void *Node1;
+  struct Node1 *next;
+};
+
+static Node1 list;
+static std::mutex m;
+static std::condition_variable condition;
+
+void consume_list_element(std::condition_variable &condition) {
+  std::unique_lock lk(m);
+
+  if (list.next == nullptr) {
+condition.wait(lk);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait' should be placed inside a while statement or used with a conditional parameter [bugprone-spuriously-wake-up-functions]
+  }
+
+  while (list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  do {
+condition.wait(lk);
+  } while (list.next == nullptr);
+
+  for (;; list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  if (list.next == nullptr) {
+while (list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+
+  if (list.next == nullptr) {
+do {
+  condition.wait(lk);
+} while (list.next == nullptr);
+  }
+
+  if (list.next == nullptr) {
+for (;; list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+  using durtype = std::chrono::duration;
+  durtype dur = std::chrono::duration();
+  if (list.next == nullptr) {
+condition.wait_for(lk, dur);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait_for' should be placed inside a while statement or used with a conditional parameter [bugprone-spuriously-wake-up-functions]
+  }
+  if (l

[PATCH] D74564: libclang: Add static build support for Windows

2020-02-18 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

I do not have commit rights, I need help to submit this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74564



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


[PATCH] D73903: [AArch64][SVE] Add remaining SVE2 intrinsics for widening DSP operations

2020-02-18 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4576080da72: [AArch64][SVE] Add remaining SVE2 intrinsics 
for widening DSP operations (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D73903?vs=244367&id=245114#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73903

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
===
--- llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
@@ -193,6 +193,69 @@
 }
 
 ;
+; SADDWB
+;
+
+define  @saddwb_b( %a,  %b) {
+; CHECK-LABEL: saddwb_b:
+; CHECK: saddwb z0.h, z0.h, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwb_h( %a,  %b) {
+; CHECK-LABEL: saddwb_h:
+; CHECK: saddwb z0.s, z0.s, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwb.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwb_s( %a,  %b) {
+; CHECK-LABEL: saddwb_s:
+; CHECK: saddwb z0.d, z0.d, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwb.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SADDWT
+;
+
+define  @saddwt_b( %a,  %b) {
+; CHECK-LABEL: saddwt_b:
+; CHECK: saddwt z0.h, z0.h, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwt_h( %a,  %b) {
+; CHECK-LABEL: saddwt_h:
+; CHECK: saddwt z0.s, z0.s, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @saddwt_s( %a,  %b) {
+; CHECK-LABEL: saddwt_s:
+; CHECK: saddwt z0.d, z0.d, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddwt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+
+;
 ; SMULLB (Vectors)
 ;
 
@@ -224,6 +287,30 @@
 }
 
 ;
+; SMULLB (Indexed)
+;
+
+define  @smullb_lane_h( %a,  %b) {
+; CHECK-LABEL: smullb_lane_h:
+; CHECK: smullb z0.s, z0.h, z1.h[4]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullb.lane.nxv4i32( %a,
+%b,
+   i32 4)
+  ret  %out
+}
+
+define  @smullb_lane_s( %a,  %b) {
+; CHECK-LABEL: smullb_lane_s:
+; CHECK: smullb z0.d, z0.s, z1.s[3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullb.lane.nxv2i64( %a,
+%b,
+   i32 3)
+  ret  %out
+}
+
+;
 ; SMULLT (Vectors)
 ;
 
@@ -255,6 +342,30 @@
 }
 
 ;
+; SMULLT (Indexed)
+;
+
+define  @smullt_lane_h( %a,  %b) {
+; CHECK-LABEL: smullt_lane_h:
+; CHECK: smullt z0.s, z0.h, z1.h[5]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullt.lane.nxv4i32( %a,
+%b,
+   i32 5)
+  ret  %out
+}
+
+define  @smullt_lane_s( %a,  %b) {
+; CHECK-LABEL: smullt_lane_s:
+; CHECK: smullt z0.d, z0.s, z1.s[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.smullt.lane.nxv2i64( %a,
+%b,
+   i32 2)
+  ret  %out
+}
+
+;
 ; SQDMULLB (Vectors)
 ;
 
@@ -286,6 +397,30 @@
 }
 
 ;
+; SQDMULLB (Indexed)
+;
+
+define  @sqdmullb_lane_h( %a,  %b) {
+; CHECK-LABEL: sqdmullb_lane_h:
+; CHECK: sqdmullb z0.s, z0.h, z1.h[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmullb.lane.nxv4i32( %a,
+  %b,
+ i32 2)
+  ret  %out
+}
+
+define  @sqdmullb_lane_s( %a,  %b) {
+; CHECK-LABEL: sqdmullb_lane_s:
+; CHECK: sqdmullb z0.d, z0.s, z1.s[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqdmullb.lane.nxv2i64( %a,
+  %b,
+ i32 1)
+  ret  %out
+}
+
+;
 ; SQDMULLT (Vectors)
 ;
 
@@ -317,6 +452,30 @@
 }
 
 ;
+; SQDMULLT (Indexed)
+;
+
+define  @sqdmullt_la

[PATCH] D74689: [clang-tidy] Better custom class support for performance-inefficient-vector-operation

2020-02-18 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 245115.
njames93 added a comment.

- Added support for converting loops over c style arrays


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74689

Files:
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
@@ -1,7 +1,11 @@
 // RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- \
-// RUN: -format-style=llvm \
 // RUN: -config='{CheckOptions: \
-// RUN:  [{key: performance-inefficient-vector-operation.EnableProto, value: 1}]}'
+// RUN:  [{key: performance-inefficient-vector-operation.EnableProto, value: 1}, \
+// RUN:   {key: performance-inefficient-vector-operation.VectorLikeClasses, value : MyContainer}, \
+// RUN:   {key: performance-inefficient-vector-operation.SupportedRanges, value : MyContainer}, \
+// RUN:   {key: performance-inefficient-vector-operation.ReserveNames, value : Reserve}, \
+// RUN:   {key: performance-inefficient-vector-operation.AppendNames, value : PushBack}, \
+// RUN:   {key: performance-inefficient-vector-operation.SizeNames, value : Size}, ]}'
 
 namespace std {
 
@@ -359,3 +363,254 @@
 }
   }
 }
+
+namespace OptionsValidMatchDefault {
+template 
+class MyContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  MyContainer CC1;
+  // CHECK-FIXES: {{^}}  CC1.reserve(C.size());
+  for (auto I : C) {
+CC1.push_back(I);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace OptionsValidMatchDefault
+
+namespace OptionsValidMatchDifferentMethods {
+template 
+class MyContainer {
+public:
+  unsigned Size() const;
+  T *begin() const;
+  T *end() const;
+  void PushBack(const T &);
+  void Reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  MyContainer CC2;
+  // CHECK-FIXES: {{^}}  CC2.Reserve(C.Size());
+  for (auto I : C) {
+CC2.PushBack(I);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'PushBack' is called
+  }
+}
+} // namespace OptionsValidMatchDifferentMethods
+
+namespace UnknownContainer {
+template 
+class MyUContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyUContainer &C) {
+  // MyUContainer isn't specified as a VectorLikeClass in the Config Options
+  MyUContainer CC3;
+  // CHECK-FIXES-NOT: {{^}}  CC3.reserve(C.size());
+  for (auto I : C) {
+CC3.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace UnknownContainer
+
+namespace PrivateMethods {
+namespace Size {
+template 
+class MyContainer {
+  unsigned size() const;
+
+public:
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  // MyContainer::size is private, so calling it will be invalid
+  MyContainer CC4;
+  // CHECK-FIXES-NOT: {{^}}  CC4.reserve(C.size());
+  for (auto I : C) {
+CC4.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace Size
+namespace Reserve {
+template 
+class MyContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+
+private:
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  // MyContainer::reserve is private, so calling it will be invalid
+  MyContainer CC5;
+  // CHECK-FIXES-NOT: {{^}}  CC5.reserve(C.size());
+  for (auto I : C) {
+CC5.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace Reserve
+} // namespace PrivateMethods
+
+namespace BadSignatures {
+namespace Size {
+template 
+class MyContainer {
+public:
+  char *size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  // MyContainer::size doesn't return an integral type(char *), so ignore this class
+  MyContainer CC6;
+  // CHECK-FIXES-NOT: {{^}}  CC6.reserve(C.size());
+  for (auto I : C) {
+CC6.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push

[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-02-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:872
+///
+/// Example: \c class T : public S { using S::S; }; T(1);
+class CXXInheritedConstructorCall : public AnyFunctionCall {

Perhaps the example could provide the definition of  the class `S` too.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:436
   case CXXConstructExpr::CK_Complete: {
+assert(CE && "Complete constructors cannot be inherited!");
 std::tie(State, Target) =

Should there be rather `CIE` in the assert? Or the text after `&&` is 
confusing. 



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:494
   if (State != Pred->getState()) {
+assert(CE && "Inherited constructors do not have construction contexts!");
 static SimpleProgramPointTag T("ExprEngine",

`CIE` ?



Comment at: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp:545
 
+// Anonymous parameters of an inheriting constructor are live for the 
entire
+// duration of the constructor.

`live` -> `alive` ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D74735



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


[PATCH] D74689: [clang-tidy] Better custom class support for performance-inefficient-vector-operation

2020-02-18 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 245116.
njames93 added a comment.

- Small nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74689

Files:
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
@@ -1,7 +1,11 @@
 // RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- \
-// RUN: -format-style=llvm \
 // RUN: -config='{CheckOptions: \
-// RUN:  [{key: performance-inefficient-vector-operation.EnableProto, value: 1}]}'
+// RUN:  [{key: performance-inefficient-vector-operation.EnableProto, value: 1}, \
+// RUN:   {key: performance-inefficient-vector-operation.VectorLikeClasses, value : MyContainer}, \
+// RUN:   {key: performance-inefficient-vector-operation.SupportedRanges, value : MyContainer}, \
+// RUN:   {key: performance-inefficient-vector-operation.ReserveNames, value : Reserve}, \
+// RUN:   {key: performance-inefficient-vector-operation.AppendNames, value : PushBack}, \
+// RUN:   {key: performance-inefficient-vector-operation.SizeNames, value : Size}, ]}'
 
 namespace std {
 
@@ -359,3 +363,254 @@
 }
   }
 }
+
+namespace OptionsValidMatchDefault {
+template 
+class MyContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  MyContainer CC1;
+  // CHECK-FIXES: {{^}}  CC1.reserve(C.size());
+  for (auto I : C) {
+CC1.push_back(I);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace OptionsValidMatchDefault
+
+namespace OptionsValidMatchDifferentMethods {
+template 
+class MyContainer {
+public:
+  unsigned Size() const;
+  T *begin() const;
+  T *end() const;
+  void PushBack(const T &);
+  void Reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  MyContainer CC2;
+  // CHECK-FIXES: {{^}}  CC2.Reserve(C.Size());
+  for (auto I : C) {
+CC2.PushBack(I);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'PushBack' is called
+  }
+}
+} // namespace OptionsValidMatchDifferentMethods
+
+namespace UnknownContainer {
+template 
+class MyUContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyUContainer &C) {
+  // MyUContainer isn't specified as a VectorLikeClass in the Config Options
+  MyUContainer CC3;
+  // CHECK-FIXES-NOT: {{^}}  CC3.reserve(C.size());
+  for (auto I : C) {
+CC3.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace UnknownContainer
+
+namespace PrivateMethods {
+namespace Size {
+template 
+class MyContainer {
+  unsigned size() const;
+
+public:
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  // MyContainer::size is private, so calling it will be invalid
+  MyContainer CC4;
+  // CHECK-FIXES-NOT: {{^}}  CC4.reserve(C.size());
+  for (auto I : C) {
+CC4.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace Size
+namespace Reserve {
+template 
+class MyContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+
+private:
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  // MyContainer::reserve is private, so calling it will be invalid
+  MyContainer CC5;
+  // CHECK-FIXES-NOT: {{^}}  CC5.reserve(C.size());
+  for (auto I : C) {
+CC5.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace Reserve
+} // namespace PrivateMethods
+
+namespace BadSignatures {
+namespace Size {
+template 
+class MyContainer {
+public:
+  char *size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer &C) {
+  // MyContainer::size doesn't return an integral type(char *), so ignore this class
+  MyContainer CC6;
+  // CHECK-FIXES-NOT: {{^}}  CC6.reserve(C.size());
+  for (auto I : C) {
+CC6.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace Size

[clang] cc7a197 - Fix riscv/lld test interaction

2020-02-18 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-02-18T12:34:07+01:00
New Revision: cc7a197f9f1039e36625249199aa652f84506802

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

LOG: Fix riscv/lld test interaction

Fix for dd230142d8a00f5f30c3930a2407000e845dcfbf, in case ld.lld is not
available.

Added: 


Modified: 
clang/test/Driver/riscv32-toolchain.c

Removed: 




diff  --git a/clang/test/Driver/riscv32-toolchain.c 
b/clang/test/Driver/riscv32-toolchain.c
index 1b765dba6b9a..c5f82d309af5 100644
--- a/clang/test/Driver/riscv32-toolchain.c
+++ b/clang/test/Driver/riscv32-toolchain.c
@@ -3,9 +3,9 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
-// Test interaction with -fuse-ld=lld
+// Test interaction with -fuse-ld=lld, if ld.lld is available.
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 
2>&1 | FileCheck -check-prefix=LLD %s
-// LLD: ld.lld
+// LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib



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


[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-02-18 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

If the AST is hard to work with would it make sense to try to change the AST a 
bit?




Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:944
+  if (Data) {
+loc::MemRegionVal MV(static_cast(Data));
+if (SymbolRef Sym = MV.getAsSymbol(true))

Maybe reusing `getCXXThisVal` here to reduce the number of casts?


Repository:
  rC Clang

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

https://reviews.llvm.org/D74735



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 245123.
djtodoro added a comment.

-Addressing the latest comments


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

https://reviews.llvm.org/D73534

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  lldb/packages/Python/lldbsuite/test/decorators.py
  
lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/TargetOptionsImpl.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/ARM/smml.ll
  llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
  llvm/test/CodeGen/X86/call-site-info-output.ll
  llvm/test/CodeGen/X86/tail-dup-repeat.ll
  llvm/test/DebugInfo/AArch64/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
  llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
  llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
  llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
  llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
  llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
  llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
  llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
  llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
  llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
  llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
  llvm/test/DebugInfo/X86/dbg-value-range.ll
  llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
  llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
  llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
  llvm/test/DebugInfo/X86/loclists-dwp.ll
  llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll
  llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
  llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
  llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
  llvm/test/tools/llvm-locstats/locstats.ll

Index: llvm/test/tools/llvm-locstats/locstats.ll
===
--- llvm/test/tools/llvm-locstats/locstats.ll
+++ llvm/test/tools/llvm-locstats/locstats.ll
@@ -9,9 +9,9 @@
 ; LOCSTATS: [10%,20%) 0 0%
 ; LOCSTATS: [20%,30%) 1 11%
 ; LOCSTATS: [30%,40%) 0 0%
-; LOCSTATS: [40%,50%) 1 11%
-; LOCSTATS: [50%,60%) 1 11%
-; LOCSTATS: [60%,70%) 1 11%
+; LOCSTATS: [40%,50%) 0 0%
+; LOCSTATS: [50%,60%) 0 0%
+; LOCSTATS: [60%,70%) 3 33%
 ; LOCSTATS: [70%,80%) 0 0%
 ; LOCSTATS: [80%,90%) 2 22%
 ; LOCSTATS: [90%,100%) 1 11%
Index: llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
===
--- llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extension

[PATCH] D74760: [Analyzer] Fix for iterator modeling and checkers: handle negative numbers correctly

2020-02-18 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: steakhal, Charusso, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, whisperity.

Currently, using negative numbers in iterator operations (additions and 
subractions) results in advancements with huge positive numbers due to an 
error. This patch fixes it.


Repository:
  rC Clang

https://reviews.llvm.org/D74760

Files:
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/test/Analysis/iterator-modelling.cpp

Index: clang/test/Analysis/iterator-modelling.cpp
===
--- clang/test/Analysis/iterator-modelling.cpp
+++ clang/test/Analysis/iterator-modelling.cpp
@@ -100,6 +100,16 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 2}}
 }
 
+void plus_equal_negative(const std::vector &v) {
+  auto i = v.end();
+
+  clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
+
+  i += -2;
+
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 2}}
+}
+
 void minus_equal(const std::vector &v) {
   auto i = v.end();
 
@@ -110,6 +120,16 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 2}}
 }
 
+void minus_equal_negative(const std::vector &v) {
+  auto i = v.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
+
+  i -= -2;
+
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 2}}
+}
+
 void copy(const std::vector &v) {
   auto i1 = v.end();
 
@@ -132,6 +152,17 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin() + 2}}
 }
 
+void plus_negative(const std::vector &v) {
+  auto i1 = v.end();
+
+  clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
+
+  auto i2 = i1 + (-2);
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.end() - 2}}
+}
+
 void minus(const std::vector &v) {
   auto i1 = v.end();
 
@@ -143,6 +174,17 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.end() - 2}}
 }
 
+void minus_negative(const std::vector &v) {
+  auto i1 = v.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
+
+  auto i2 = i1 - (-2);
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); //expected-warning{{$v.begin() + 2}}
+}
+
 void copy_and_increment1(const std::vector &v) {
   auto i1 = v.begin();
 
Index: clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
+++ clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
@@ -200,22 +200,29 @@
 
   auto &SymMgr = State->getStateManager().getSymbolManager();
   auto &SVB = State->getStateManager().getSValBuilder();
+  auto &BVF = State->getStateManager().getBasicVals();
 
   assert ((Op == OO_Plus || Op == OO_PlusEqual ||
Op == OO_Minus || Op == OO_MinusEqual) &&
   "Advance operator must be one of +, -, += and -=.");
   auto BinOp = (Op == OO_Plus || Op == OO_PlusEqual) ? BO_Add : BO_Sub;
-  if (const auto IntDist = Distance.getAs()) {
-// For concrete integers we can calculate the new position
-const auto NewPos =
-  Pos->setTo(SVB.evalBinOp(State, BinOp,
-   nonloc::SymbolVal(Pos->getOffset()),
-   *IntDist, SymMgr.getType(Pos->getOffset()))
- .getAsSymbol());
-return setIteratorPosition(State, Iter, NewPos);
-  }
+  const auto IntDistOp = Distance.getAs();
+  if (!IntDistOp)
+return nullptr;
 
-  return nullptr;
+  // For concrete integers we can calculate the new position
+  nonloc::ConcreteInt IntDist = *IntDistOp;
+
+  if (IntDist.getValue().isNegative()) {
+IntDist = nonloc::ConcreteInt(BVF.getValue(-IntDist.getValue()));
+BinOp = (BinOp == BO_Add) ? BO_Sub : BO_Add;
+  }
+  const auto NewPos =
+Pos->setTo(SVB.evalBinOp(State, BinOp,
+ nonloc::SymbolVal(Pos->getOffset()),
+ IntDist, SymMgr.getType(Pos->getOffset()))
+   .getAsSymbol());
+  return setIteratorPosition(State, Iter, NewPos);
 }
 
 // This function tells the analyzer's engine that symbols produced by our
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74724: [AArch64][SVE] CodeGen of ACLE Builtin Types

2020-02-18 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 245127.
sdesmalen added a comment.

- Inlined function into switch statement
- Removed changes to IRTranslator.cpp from this patch.


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

https://reviews.llvm.org/D74724

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGen/aarch64-sve.c

Index: clang/test/CodeGen/aarch64-sve.c
===
--- clang/test/CodeGen/aarch64-sve.c
+++ clang/test/CodeGen/aarch64-sve.c
@@ -1,9 +1,51 @@
 // RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
-// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s
+// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s -check-prefix=CHECK-DEBUG
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN:  -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
-// Placeholder test for SVE types
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt8_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint8_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVBool_t'
 
-// CHECK: cannot yet generate code for SVE type '__SVInt8_t'
-// CHECK: cannot yet generate debug info for SVE type '__SVInt8_t'
+// CHECK: @ptr = common global * null, align 8
+// CHECK: %s8 = alloca , align 16
+// CHECK: %s16 = alloca , align 16
+// CHECK: %s32 = alloca , align 16
+// CHECK: %s64 = alloca , align 16
+// CHECK: %u8 = alloca , align 16
+// CHECK: %u16 = alloca , align 16
+// CHECK: %u32 = alloca , align 16
+// CHECK: %u64 = alloca , align 16
+// CHECK: %f16 = alloca , align 16
+// CHECK: %f32 = alloca , align 16
+// CHECK: %f64 = alloca , align 16
+// CHECK: %b8 = alloca , align 2
 
 __SVInt8_t *ptr;
+
+void test_locals(void) {
+  __SVInt8_t s8;
+  __SVInt16_t s16;
+  __SVInt32_t s32;
+  __SVInt64_t s64;
+
+  __SVUint8_t u8;
+  __SVUint16_t u16;
+  __SVUint32_t u32;
+  __SVUint64_t u64;
+
+  __SVFloat16_t f16;
+  __SVFloat32_t f32;
+  __SVFloat64_t f64;
+
+  __SVBool_t b8;
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -511,23 +511,44 @@
 case BuiltinType::OCLReserveID:
   ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
   break;
-
-// TODO: real CodeGen support for SVE types requires more infrastructure
-// to be added first.  Report an error until then.
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
-{
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "cannot yet generate code for SVE type '%0'");
-  auto *BT = cast(Ty);
-  auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
-  CGM.getDiags().Report(DiagID) << Name;
-  // Return something safe.
-  ResultType = llvm::IntegerType::get(getLLVMContext(), 32);
+case BuiltinType::SveInt8:
+case BuiltinType::SveUint8:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 8),
+   {16, true});
+case BuiltinType::SveInt16:
+case BuiltinType::SveUint16:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 16),
+   {8, true});
+case BuiltinType::SveInt32:
+case BuiltinType::SveUint32:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 32),
+   {4, true});
+case BuiltinType::SveInt64:
+case BuiltinType::SveUint64:
+  return llvm::VectorType::get(llvm::IntegerType::get(getLLVMContext(), 64),
+   {2, true});
+case BuiltinType::SveFloat16:
+  return llvm::VectorType::get(
+  getTypeForFormat(getLLVMContext(),
+   Context.getFloatTypeSemantics(Context.HalfTy),
+   /* UseNativeHalf = */ true),
+  {8, true});
+case BuiltinType::SveFloat32:
+  return llvm::VectorType::get(
+  getTypeForFormat(getLLVMContext(),
+  

[PATCH] D71433: [analyzer] CERT: POS34-C

2020-02-18 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.
Herald added a subscriber: martong.

I think for an alpha checker this is ready to land if you're ready -- do you 
have commit access or need assistance?


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

https://reviews.llvm.org/D71433



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


[clang] a82d3e8 - Reland "[DebugInfo] Enable the debug entry values feature by default"

2020-02-18 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-02-18T14:41:08+01:00
New Revision: a82d3e8a6e67473c94a5ce6345372748e9b61718

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

LOG: Reland "[DebugInfo] Enable the debug entry values feature by default"

This patch enables the debug entry values feature.

  - Remove the (CC1) experimental -femit-debug-entry-values option
  - Enable it for x86, arm and aarch64 targets
  - Resolve the test failures
  - Leave the llc experimental option for targets that do not
support the CallSiteInfo yet

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

Added: 
llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
llvm/test/CodeGen/ARM/smml.ll
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/CodeGen/X86/hoist-invariant-load.ll
llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
llvm/test/CodeGen/X86/statepoint-allocas.ll
llvm/test/CodeGen/X86/tail-dup-repeat.ll
llvm/test/CodeGen/X86/xray-custom-log.ll
llvm/test/CodeGen/X86/xray-typed-event-log.ll
llvm/test/DebugInfo/AArch64/call-site-info-output.ll
llvm/test/DebugInfo/ARM/call-site-info-output.ll
llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test

[PATCH] D74763: [libTooling] Add option for `buildAST` to report diagnostics.

2020-02-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added a project: clang.

Currently, `buildAST[WithArgs]` either succeeds or fails.  This patch adds
support for the caller to pass a `DiagnosticConsumer` to receive all relevant
diagnostics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74763

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -101,6 +101,15 @@
   }
   return false;
 }
+
+struct TestDiagnosticConsumer : public DiagnosticConsumer {
+  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+++NumDiagnosticsSeen;
+  }
+  unsigned NumDiagnosticsSeen;
+};
 } // end namespace
 
 TEST(runToolOnCode, FindsClassDecl) {
@@ -129,6 +138,16 @@
   EXPECT_FALSE(FindClassDeclX(AST.get()));
 }
 
+TEST(buildASTFromCode, ReportsErrors) {
+  TestDiagnosticConsumer Consumer;
+  std::unique_ptr AST = buildASTFromCodeWithArgs(
+  "int x = \"A\";", {}, "input.cc", "clang-tool",
+  std::make_shared(),
+  getClangStripDependencyFileAdjuster(), FileContentMappings(), &Consumer);
+  EXPECT_TRUE(AST.get());
+  EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen);
+}
+
 TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {
   std::unique_ptr Factory(
   newFrontendActionFactory());
@@ -639,15 +658,6 @@
   EXPECT_EQ(2u, ASTs.size());
 }
 
-struct TestDiagnosticConsumer : public DiagnosticConsumer {
-  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
-  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
-const Diagnostic &Info) override {
-++NumDiagnosticsSeen;
-  }
-  unsigned NumDiagnosticsSeen;
-};
-
 TEST(ClangToolTest, InjectDiagnosticConsumer) {
   FixedCompilationDatabase Compilations("/", std::vector());
   ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -619,7 +619,8 @@
 std::unique_ptr buildASTFromCodeWithArgs(
 StringRef Code, const std::vector &Args, StringRef FileName,
 StringRef ToolName, std::shared_ptr 
PCHContainerOps,
-ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles) 
{
+ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles,
+DiagnosticConsumer *DiagConsumer) {
   std::vector> ASTs;
   ASTBuilderAction Action(ASTs);
   llvm::IntrusiveRefCntPtr OverlayFileSystem(
@@ -633,6 +634,7 @@
   ToolInvocation Invocation(
   getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileName), FileName),
   &Action, Files.get(), std::move(PCHContainerOps));
+  Invocation.setDiagnosticConsumer(DiagConsumer);
 
   InMemoryFileSystem->addFile(FileName, 0,
   llvm::MemoryBuffer::getMemBufferCopy(Code));
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -225,7 +225,8 @@
 std::shared_ptr PCHContainerOps =
 std::make_shared(),
 ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster(),
-const FileContentMappings &VirtualMappedFiles = FileContentMappings());
+const FileContentMappings &VirtualMappedFiles = FileContentMappings(),
+DiagnosticConsumer *DiagConsumer = nullptr);
 
 /// Utility to run a FrontendAction in a single clang invocation.
 class ToolInvocation {


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -101,6 +101,15 @@
   }
   return false;
 }
+
+struct TestDiagnosticConsumer : public DiagnosticConsumer {
+  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+++NumDiagnosticsSeen;
+  }
+  unsigned NumDiagnosticsSeen;
+};
 } // end namespace
 
 TEST(runToolOnCode, FindsClassDecl) {
@@ -129,6 +138,16 @@
   EXPECT_FALSE(FindClassDeclX(AST.get()));
 }
 
+TEST(buildASTFromCode, ReportsErrors) {
+  TestDiagnosticConsumer Consumer;
+  std::unique_ptr AST = buildASTFromCodeWithArgs(
+  "int x = \"A\";", {}, "input.cc", "clang-tool",
+  std::make_shared(),
+  getClangStripDependencyFileAdjuster(), FileContentMappings(), &Consumer);
+  EXPECT_TRUE(AST.get());
+  EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen);
+}
+
 TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {

[clang] 523cae3 - [libTooling] Add option for `buildAST` to report diagnostics.

2020-02-18 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-02-18T09:11:51-05:00
New Revision: 523cae324d79d2e532d2be797058a94e8214ec45

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

LOG: [libTooling] Add option for `buildAST` to report diagnostics.

Summary:
Currently, `buildAST[WithArgs]` either succeeds or fails.  This patch adds
support for the caller to pass a `DiagnosticConsumer` to receive all relevant
diagnostics.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Tooling.h
clang/lib/Tooling/Tooling.cpp
clang/unittests/Tooling/ToolingTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Tooling.h 
b/clang/include/clang/Tooling/Tooling.h
index f759789170d9..ced2405f6e83 100644
--- a/clang/include/clang/Tooling/Tooling.h
+++ b/clang/include/clang/Tooling/Tooling.h
@@ -225,7 +225,8 @@ std::unique_ptr buildASTFromCodeWithArgs(
 std::shared_ptr PCHContainerOps =
 std::make_shared(),
 ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster(),
-const FileContentMappings &VirtualMappedFiles = FileContentMappings());
+const FileContentMappings &VirtualMappedFiles = FileContentMappings(),
+DiagnosticConsumer *DiagConsumer = nullptr);
 
 /// Utility to run a FrontendAction in a single clang invocation.
 class ToolInvocation {

diff  --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index be200f2e3560..bee20ebb878d 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -619,7 +619,8 @@ buildASTFromCode(StringRef Code, StringRef FileName,
 std::unique_ptr buildASTFromCodeWithArgs(
 StringRef Code, const std::vector &Args, StringRef FileName,
 StringRef ToolName, std::shared_ptr 
PCHContainerOps,
-ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles) 
{
+ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles,
+DiagnosticConsumer *DiagConsumer) {
   std::vector> ASTs;
   ASTBuilderAction Action(ASTs);
   llvm::IntrusiveRefCntPtr OverlayFileSystem(
@@ -633,6 +634,7 @@ std::unique_ptr buildASTFromCodeWithArgs(
   ToolInvocation Invocation(
   getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileName), FileName),
   &Action, Files.get(), std::move(PCHContainerOps));
+  Invocation.setDiagnosticConsumer(DiagConsumer);
 
   InMemoryFileSystem->addFile(FileName, 0,
   llvm::MemoryBuffer::getMemBufferCopy(Code));

diff  --git a/clang/unittests/Tooling/ToolingTest.cpp 
b/clang/unittests/Tooling/ToolingTest.cpp
index 59c9b4fb3863..0ff66206e06e 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -101,6 +101,15 @@ bool FindClassDeclX(ASTUnit *AST) {
   }
   return false;
 }
+
+struct TestDiagnosticConsumer : public DiagnosticConsumer {
+  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+++NumDiagnosticsSeen;
+  }
+  unsigned NumDiagnosticsSeen;
+};
 } // end namespace
 
 TEST(runToolOnCode, FindsClassDecl) {
@@ -129,6 +138,16 @@ TEST(buildASTFromCode, FindsClassDecl) {
   EXPECT_FALSE(FindClassDeclX(AST.get()));
 }
 
+TEST(buildASTFromCode, ReportsErrors) {
+  TestDiagnosticConsumer Consumer;
+  std::unique_ptr AST = buildASTFromCodeWithArgs(
+  "int x = \"A\";", {}, "input.cc", "clang-tool",
+  std::make_shared(),
+  getClangStripDependencyFileAdjuster(), FileContentMappings(), &Consumer);
+  EXPECT_TRUE(AST.get());
+  EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen);
+}
+
 TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {
   std::unique_ptr Factory(
   newFrontendActionFactory());
@@ -639,15 +658,6 @@ TEST(ClangToolTest, BuildASTs) {
   EXPECT_EQ(2u, ASTs.size());
 }
 
-struct TestDiagnosticConsumer : public DiagnosticConsumer {
-  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
-  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
-const Diagnostic &Info) override {
-++NumDiagnosticsSeen;
-  }
-  unsigned NumDiagnosticsSeen;
-};
-
 TEST(ClangToolTest, InjectDiagnosticConsumer) {
   FixedCompilationDatabase Compilations("/", std::vector());
   ClangTool Tool(Compilations, std::vector(1, "/a.cc"));



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


[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-18 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked an inline comment as done.
Xiangling_L added a comment.

ping.


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

https://reviews.llvm.org/D74015



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


[PATCH] D74763: [libTooling] Add option for `buildAST` to report diagnostics.

2020-02-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG523cae324d79: [libTooling] Add option for `buildAST` to 
report diagnostics. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74763

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -101,6 +101,15 @@
   }
   return false;
 }
+
+struct TestDiagnosticConsumer : public DiagnosticConsumer {
+  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+++NumDiagnosticsSeen;
+  }
+  unsigned NumDiagnosticsSeen;
+};
 } // end namespace
 
 TEST(runToolOnCode, FindsClassDecl) {
@@ -129,6 +138,16 @@
   EXPECT_FALSE(FindClassDeclX(AST.get()));
 }
 
+TEST(buildASTFromCode, ReportsErrors) {
+  TestDiagnosticConsumer Consumer;
+  std::unique_ptr AST = buildASTFromCodeWithArgs(
+  "int x = \"A\";", {}, "input.cc", "clang-tool",
+  std::make_shared(),
+  getClangStripDependencyFileAdjuster(), FileContentMappings(), &Consumer);
+  EXPECT_TRUE(AST.get());
+  EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen);
+}
+
 TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {
   std::unique_ptr Factory(
   newFrontendActionFactory());
@@ -639,15 +658,6 @@
   EXPECT_EQ(2u, ASTs.size());
 }
 
-struct TestDiagnosticConsumer : public DiagnosticConsumer {
-  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
-  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
-const Diagnostic &Info) override {
-++NumDiagnosticsSeen;
-  }
-  unsigned NumDiagnosticsSeen;
-};
-
 TEST(ClangToolTest, InjectDiagnosticConsumer) {
   FixedCompilationDatabase Compilations("/", std::vector());
   ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -619,7 +619,8 @@
 std::unique_ptr buildASTFromCodeWithArgs(
 StringRef Code, const std::vector &Args, StringRef FileName,
 StringRef ToolName, std::shared_ptr 
PCHContainerOps,
-ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles) 
{
+ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles,
+DiagnosticConsumer *DiagConsumer) {
   std::vector> ASTs;
   ASTBuilderAction Action(ASTs);
   llvm::IntrusiveRefCntPtr OverlayFileSystem(
@@ -633,6 +634,7 @@
   ToolInvocation Invocation(
   getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileName), FileName),
   &Action, Files.get(), std::move(PCHContainerOps));
+  Invocation.setDiagnosticConsumer(DiagConsumer);
 
   InMemoryFileSystem->addFile(FileName, 0,
   llvm::MemoryBuffer::getMemBufferCopy(Code));
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -225,7 +225,8 @@
 std::shared_ptr PCHContainerOps =
 std::make_shared(),
 ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster(),
-const FileContentMappings &VirtualMappedFiles = FileContentMappings());
+const FileContentMappings &VirtualMappedFiles = FileContentMappings(),
+DiagnosticConsumer *DiagConsumer = nullptr);
 
 /// Utility to run a FrontendAction in a single clang invocation.
 class ToolInvocation {


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -101,6 +101,15 @@
   }
   return false;
 }
+
+struct TestDiagnosticConsumer : public DiagnosticConsumer {
+  TestDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+++NumDiagnosticsSeen;
+  }
+  unsigned NumDiagnosticsSeen;
+};
 } // end namespace
 
 TEST(runToolOnCode, FindsClassDecl) {
@@ -129,6 +138,16 @@
   EXPECT_FALSE(FindClassDeclX(AST.get()));
 }
 
+TEST(buildASTFromCode, ReportsErrors) {
+  TestDiagnosticConsumer Consumer;
+  std::unique_ptr AST = buildASTFromCodeWithArgs(
+  "int x = \"A\";", {}, "input.cc", "clang-tool",
+  std::make_shared(),
+  getClangStripDependencyFileAdjuster(), FileContentMappings(), &Consumer);
+  EXPECT_TRUE(AST.get());
+  EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen);
+}
+
 TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {
   std::

[PATCH] D74765: [compiler-rt] Addd FreeBSD arm64 sanitizer support

2020-02-18 Thread Andrew Turner via Phabricator via cfe-commits
andrew created this revision.
andrew added a reviewer: Sanitizers.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls, 
krytarowski, arichardson, dberris, emaste.
Herald added projects: clang, Sanitizers, LLVM.

Add support for asan, msan, and tsan on FreeBSD on aarch64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74765

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  compiler-rt/lib/asan/asan_mapping.h
  compiler-rt/lib/msan/msan.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
  compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
  compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
  compiler-rt/test/fuzzer/lit.cfg.py
  compiler-rt/test/sanitizer_common/TestCases/FreeBSD/capsicum.cpp
  compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -416,6 +416,14 @@
   0x3800,  // OriginBase
 };
 
+// aarch64 FreeBSD
+static const MemoryMapParams FreeBSD_AArch64_MemoryMapParams = {
+  0x18000,  // AndMask
+  0x04000,  // XorMask
+  0x02000,  // ShadowBase
+  0x07000,  // OriginBase
+};
+
 // x86_64 NetBSD
 static const MemoryMapParams NetBSD_X86_64_MemoryMapParams = {
   0,   // AndMask
@@ -449,6 +457,12 @@
   &FreeBSD_X86_64_MemoryMapParams,
 };
 
+static const PlatformMemoryMapParams FreeBSD_ARM_MemoryMapParams = {
+  nullptr,
+  &FreeBSD_AArch64_MemoryMapParams,
+};
+
+
 static const PlatformMemoryMapParams NetBSD_X86_MemoryMapParams = {
   nullptr,
   &NetBSD_X86_64_MemoryMapParams,
@@ -895,6 +909,9 @@
   case Triple::x86:
 MapParams = FreeBSD_X86_MemoryMapParams.bits32;
 break;
+  case Triple::aarch64:
+MapParams = FreeBSD_ARM_MemoryMapParams.bits64;
+break;
   default:
 report_fatal_error("unsupported architecture");
 }
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -105,6 +105,7 @@
 static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36;
 static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
 static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
+static const uint64_t kFreeBSD_AArch64_ShadowOffset64 = 1ULL << 47;
 static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30;
 static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46;
 static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff9000;
@@ -482,6 +483,8 @@
   Mapping.Offset = kPPC64_ShadowOffset64;
 else if (IsSystemZ)
   Mapping.Offset = kSystemZ_ShadowOffset64;
+else if (IsFreeBSD && IsAArch64)
+  Mapping.Offset = kFreeBSD_AArch64_ShadowOffset64;
 else if (IsFreeBSD && !IsMIPS64)
   Mapping.Offset = kFreeBSD_ShadowOffset64;
 else if (IsNetBSD) {
Index: compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Posix/crypt.cpp
@@ -6,7 +6,11 @@
 #include 
 #include 
 #include 
+#ifdef __FreeBSD__
+#include 
+#else
 #include 
+#endif
 
 int
 main (int argc, char** argv)
Index: compiler-rt/test/sanitizer_common/TestCases/FreeBSD/capsicum.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/FreeBSD/capsicum.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/FreeBSD/capsicum.cpp
@@ -11,7 +11,7 @@
 #include 
 
 void test_cap_ioctls() {
-  cap_rights_t rights;
+  cap_rights_t rights = {0};
   unsigned long ncmds[] = {TIOCGETA, TIOCGWINSZ, FIODTYPE};
   unsigned long rcmds = 0;
   cap_rights_t *rptr = cap_rights_init(&rights, CAP_IOCTL, CAP_READ);
Index: compiler-rt/test/fuzzer/lit.cfg.py
===
--- compiler-rt/test/fuzzer/lit.cfg.py
+++ compiler-rt/test/fuzzer/lit.cfg.py
@@ -27,7 +27,6 @@
 
 # LeakSanitizer is not supported on OSX or Windows right now.
 if (sys.platform.startswith('darwin') or
-sys.platform.startswith('freebsd') or
 sys.platform.startswith('win')):
   lit_config.note('lsan feature unavailable')
 else:
Index: compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
===
--- compiler-rt/lib/tsan/rtl/tsan_platform_linu

[PATCH] D74766: [ARM] Fixing range checks for Neon's vqdmulhq_lane and vqrdmulhq_lane intrinsics

2020-02-18 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

The range checks performed for the vqrdmulh_lane and vqrdmulh_lane Neon
intrinsics were incorrectly using their return type as the base type for
the range check performed on their 'lane' argument.

This patch updates those intrisics to use the type of the proper reference
argument to perform the range checks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74766

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-neon-range-checks.c


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside 
the valid range}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is 
outside the valid range}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range}}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5802,8 +5802,12 @@
   case NEON::BI__builtin_neon_vqdmulh_lane_v:
   case NEON::BI__builtin_neon_vqrdmulhq_lane_v:
   case NEON::BI__builtin_neon_vqrdmulh_lane_v: {
+llvm::Type* RTy = Ty;
+if (BuiltinID == NEON::BI__builtin_neon_vqdmulhq_lane_v ||
+BuiltinID == NEON::BI__builtin_neon_vqrdmulhq_lane_v)
+  RTy = llvm::VectorType::get(Ty->getVectorElementType(), 
Ty->getVectorNumElements() * 2);
 llvm::Type *Tys[2] = {
-Ty, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
+RTy, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
 /*isQuad*/ false))};
 return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, NameHint);
   }
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -547,8 +547,8 @@
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
 }
 let ArchGuard = "defined(__aarch64__)" in {
-def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..qI", "siQsQi">;
-def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..qI", "siQsQi">;
+def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..(!q)I", "siQsQi">;
+def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..(!q)I", "siQsQi">;
 }
 
 let ArchGuard = "defined(__ARM_FEATURE_QRDMX)" in {


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside the valid range}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is outside the valid range}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range}}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/C

[PATCH] D74562: [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

2020-02-18 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 245151.
fghanim added a comment.

addressing review comments - Adding a comment to explain minor change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74562

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/cancel_codegen.cpp

Index: clang/test/OpenMP/cancel_codegen.cpp
===
--- clang/test/OpenMP/cancel_codegen.cpp
+++ clang/test/OpenMP/cancel_codegen.cpp
@@ -192,9 +192,7 @@
 // IRBUILDER: [[CMP:%.+]] = icmp eq i32 [[RES]], 0
 // IRBUILDER: br i1 [[CMP]], label %[[CONTINUE:[^,].+]], label %[[EXIT:.+]]
 // IRBUILDER: [[EXIT]]
-// IRBUILDER: br label %[[EXIT2:.+]]
-// IRBUILDER: [[EXIT2]]
-// IRBUILDER: br label %[[RETURN]]
+// IRBUILDER: br label %[[RETURN:.+]]
 // IRBUILDER: [[CONTINUE]]
 // IRBUILDER: br label %[[ELSE:.+]]
 
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -36,6 +36,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
@@ -255,6 +256,114 @@
 unsigned Index;
   };
 
+  // Helper class for the OpenMP IR Builder. Allows reusability of code used for
+  // region body, and finalization codegen callbacks. This will class will also
+  // contain privatization functions used by the privatization call backs
+  struct OMPBuilderCBHelpers {
+
+using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+
+/// Emit the Finalization for an OMP region
+/// \param CGF	The Codegen function this belongs to
+/// \param IP	Insertion point for generating the finalization code.
+static void FinalizeOMPRegion(CodeGenFunction &CGF, InsertPointTy IP) {
+  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
+  assert(IP.getBlock()->end() != IP.getPoint() &&
+ "OpenMP IR Builder should cause terminated block!");
+
+  llvm::BasicBlock *IPBB = IP.getBlock();
+  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
+  assert(DestBB && "Finalization block should have one successor!");
+
+  // erase and replace with cleanup branch.
+  IPBB->getTerminator()->eraseFromParent();
+  CGF.Builder.SetInsertPoint(IPBB);
+  CodeGenFunction::JumpDest Dest = CGF.getJumpDestInCurrentScope(DestBB);
+  CGF.EmitBranchThroughCleanup(Dest);
+}
+
+/// Emit the body of an OMP region
+/// \param CGF	The Codegen function this belongs to
+/// \param RegionBodyStmt	The body statement for the OpenMP region being
+/// 			 generated
+/// \param CodeGenIP	Insertion point for generating the body code.
+/// \param FiniBB	The finalization basic block
+static void EmitOMPRegionBody(CodeGenFunction &CGF,
+  const Stmt *RegionBodyStmt,
+  InsertPointTy CodeGenIP,
+  llvm::BasicBlock &FiniBB) {
+  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+  if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
+CodeGenIPBBTI->eraseFromParent();
+
+  CGF.Builder.SetInsertPoint(CodeGenIPBB);
+
+  CGF.EmitStmt(RegionBodyStmt);
+
+  if (CGF.Builder.saveIP().isSet())
+CGF.Builder.CreateBr(&FiniBB);
+}
+
+/// RAII for preserving necessary info during Outlined region body codegen.
+class OutlinedRegionBodyRAII {
+
+  llvm::AssertingVH OldAllocaIP;
+  CodeGenFunction::JumpDest OldReturnBlock;
+  CodeGenFunction &CGF;
+
+public:
+  OutlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP,
+ llvm::BasicBlock &RetBB)
+  : CGF(cgf) {
+assert(AllocaIP.isSet() &&
+   "Must specify Insertion point for allocas of outlined function");
+OldAllocaIP = CGF.AllocaInsertPt;
+CGF.AllocaInsertPt = &*AllocaIP.getPoint();
+
+OldReturnBlock = CGF.ReturnBlock;
+CGF.ReturnBlock = CGF.getJumpDestInCurrentScope(&RetBB);
+  }
+
+  ~OutlinedRegionBodyRAII() {
+CGF.AllocaInsertPt = OldAllocaIP;
+CGF.ReturnBlock = OldReturnBlock;
+  }
+};
+
+/// RAII for preserving necessary info during inlined region body codegen.
+class InlinedRegionBodyRAII {
+
+  llvm::AssertingVH OldAllocaIP;
+  CodeGenFunction &CGF;
+
+public:
+  InlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP,
+llvm::BasicBlock &FiniBB)
+  : CGF(cgf) {
+// Alloca insertion block should be in the entry block of the containing
+// function so

[PATCH] D74765: [compiler-rt] Addd FreeBSD arm64 sanitizer support

2020-02-18 Thread Andrew Turner via Phabricator via cfe-commits
andrew marked an inline comment as done.
andrew added inline comments.



Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:451-463
+# if defined(__aarch64__) || defined(__mips__)
+// Variant I
+//
+// dtv = segbase[0];
+// dtv[2] = base of TLS block of the main program
+void **dtv = (void**) segbase[0];
+if ((uptr) dtv[1] >= 2) {

This is from D49942


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74765



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


[PATCH] D74765: [compiler-rt] Addd FreeBSD arm64 sanitizer support

2020-02-18 Thread Andrew Turner via Phabricator via cfe-commits
andrew updated this revision to Diff 245152.
andrew marked an inline comment as done.
andrew added a comment.

Remove unintended changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74765

Files:
  compiler-rt/lib/asan/asan_mapping.h
  compiler-rt/lib/msan/msan.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
  compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Index: compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
===
--- compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
+++ compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -386,7 +386,11 @@
 #ifdef __powerpc__
 # define LONG_JMP_SP_ENV_SLOT 0
 #elif SANITIZER_FREEBSD
-# define LONG_JMP_SP_ENV_SLOT 2
+# ifdef __aarch64__
+#  define LONG_JMP_SP_ENV_SLOT 1
+# else
+#  define LONG_JMP_SP_ENV_SLOT 2
+#endif
 #elif SANITIZER_NETBSD
 # define LONG_JMP_SP_ENV_SLOT 6
 #elif SANITIZER_LINUX
Index: compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
===
--- compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
+++ compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
@@ -19,7 +19,7 @@
 # define SYSCALL(name) __NR_ ## name
 #endif
 
-#if defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
+#if (defined(__x86_64__) || defined(__aarch64__)) && (SANITIZER_FREEBSD || SANITIZER_MAC)
 # define internal_syscall __syscall
 # else
 # define internal_syscall syscall
Index: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
===
--- compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -381,7 +381,9 @@
 #if SANITIZER_FREEBSD
 static void **ThreadSelfSegbase() {
   void **segbase = 0;
-# if defined(__i386__)
+# if defined(__aarch64__)
+  __asm __volatile("mrs %0, tpidr_el0" : "=r" (segbase));
+# elif defined(__i386__)
   // sysarch(I386_GET_GSBASE, segbase);
   __asm __volatile("mov %%gs:0, %0" : "=r" (segbase));
 # elif defined(__x86_64__)
@@ -406,7 +408,10 @@
 uptr ThreadSelf() {
   return (uptr)ThreadSelfTlsTcb()->tcb_pthread;
 }
+#endif  // SANITIZER_NETBSD
 
+#if SANITIZER_NETBSD || (SANITIZER_FREEBSD && \
+(defined(__aarch64__) || defined(__mips__)))
 int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
   const Elf_Phdr *hdr = info->dlpi_phdr;
   const Elf_Phdr *last_hdr = hdr + info->dlpi_phnum;
@@ -419,7 +424,8 @@
   }
   return 0;
 }
-#endif  // SANITIZER_NETBSD
+#endif  // SANITIZER_NETBSD || (SANITIZER_FREEBSD && (defined(__aarch64__) ||
+// defined(__mips__)))
 
 #if !SANITIZER_GO
 static void GetTls(uptr *addr, uptr *size) {
@@ -442,6 +448,22 @@
   *addr = 0;
   *size = 0;
   if (segbase != 0) {
+# if defined(__aarch64__) || defined(__mips__)
+// Variant I
+//
+// dtv = segbase[0];
+// dtv[2] = base of TLS block of the main program
+void **dtv = (void**) segbase[0];
+if ((uptr) dtv[1] >= 2) {
+  // Find size (p_memsz) of TLS block of the main program.
+  dl_iterate_phdr(GetSizeFromHdr, size);
+
+  if (*size != 0)
+*addr = (uptr) dtv[2];
+}
+# elif defined(__x86_64__) || defined(__i386__)
+// Variant II
+//
 // tcbalign = 16
 // tls_size = round(tls_static_space, tcbalign);
 // dtv = segbase[1];
@@ -449,6 +471,9 @@
 void **dtv = (void**) segbase[1];
 *addr = (uptr) dtv[2];
 *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]);
+#else
+#error "unsupported CPU arch"
+#endif
   }
 #elif SANITIZER_NETBSD
   struct tls_tcb * const tcb = ThreadSelfTlsTcb();
Index: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
===
--- compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1334,7 +1334,7 @@
: "memory", "$29" );
   return res;
 }
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) && SANITIZER_LINUX
 uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
 int *parent_tidptr, void *newtls, int *child_tidptr) {
   long long res;
@@ -1734,7 +1734,7 @@
 void internal_join_thread(void *th) {}
 #endif
 
-#if defined(__aarch64__)
+#if defined(__aarch64__) && SANITIZER_LINUX
 // Android headers in the older NDK releases miss this definition.
 struct __sanitizer_esr_context {
   struct _aarch64_ctx head;
@@ -1833,7 +1833,7 @@
   static const uptr FSR_WRITE = 1U << 11;
   uptr fsr = ucontext->uc_mcontext.error_code;
   return fsr & FSR_WRITE ? WRITE : READ;
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) && SANITIZER_LINUX
   sta

[clang] cd2c5af - Reland D74436 "Change clang option -ffp-model=precise to select ffp-contract=on""

2020-02-18 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-02-18T06:55:36-08:00
New Revision: cd2c5af6dfd6e32ee7043894bcb42981ce99e8ac

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

LOG: Reland D74436 "Change clang option -ffp-model=precise to select 
ffp-contract=on""
Change clang option -ffp-model=precise, the default, to select 
ffp-contract=on
The patch caused some problems for PowerPC but ibm has made
adjustments so I am resubmitting this patch.  Additionally, Andy looked
at the performance regressions on LNT and it looks like a loop
unrolling decision that could be adjusted.

Reviewers: rjmccall, Andy Kaylor

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

Added: 


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

Removed: 




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

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 2585a5fa05da..d1197556aeef 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2525,10 +2525,9 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "";
+  StringRef FPContract = "on";
   bool StrictFPModel = false;
 
-
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
 

[clang] 4518aab - [AArch64] Add Cortex-A34 Support for clang and llvm

2020-02-18 Thread Luke Geeson via cfe-commits

Author: Luke Geeson
Date: 2020-02-18T14:56:16Z
New Revision: 4518aab289a090a668af0ca4ecde976e18fb2b1e

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

LOG: [AArch64] Add Cortex-A34 Support for clang and llvm

This patch upstreams support for the AArch64 Armv8-A cpu Cortex-A34.

In detail adding support for:
 - mcpu option in clang
 - AArch64 Target Features in clang
 - llvm AArch64 TargetParser definitions

details of the cpu can be found here:
https://developer.arm.com/ip-products/processors/cortex-a/cortex-a34

Reviewers: SjoerdMeijer

Reviewed By: SjoerdMeijer

Subscribers: SjoerdMeijer, kristof.beyls, hiraditya, cfe-commits,
llvm-commits

Tags: #clang, #llvm

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

Change-Id: Ida101fc544ca183a0a0e61a1277c8957855fde0b

Added: 


Modified: 
clang/test/Driver/aarch64-cpus.c
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/lib/Support/Host.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/remat.ll
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index c7dc5f63d678..f1b53d98e150 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -45,6 +45,22 @@
 // ARM64-CA35: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a35"
 // ARM64-CA35-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"
 
+// RUN: %clang -target aarch64 -mcpu=cortex-a34 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA34 %s
+// RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a34 -### -c %s 
2>&1 | FileCheck -check-prefix=CA34 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a34 -### -c %s 
2>&1 | FileCheck -check-prefix=CA34 %s
+// RUN: %clang -target aarch64 -mtune=cortex-a34 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA34-TUNE %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a34 -### -c %s 
2>&1 | FileCheck -check-prefix=CA34-TUNE %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a34 -### -c %s 
2>&1 | FileCheck -check-prefix=CA34-TUNE %s
+// CA34: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a34"
+// CA34-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target arm64 -mcpu=cortex-a34 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-CA34 %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a34 -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-CA34 %s
+// RUN: %clang -target arm64 -mtune=cortex-a34 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-CA34-TUNE %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a34 -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-CA34-TUNE %s
+// ARM64-CA34: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a34"
+// ARM64-CA34-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"
+
 // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA53 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 
2>&1 | FileCheck -check-prefix=CA53 %s
 // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 
2>&1 | FileCheck -check-prefix=CA53 %s
@@ -267,6 +283,15 @@
 // CA35-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"cortex-a35"
 // CA35-BE-TUNE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic"
 
+// RUN: %clang -target aarch64_be -mcpu=cortex-a34 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA34-BE %s
+// RUN: %clang -target aarch64 -mbig-endian -mcpu=cortex-a34 -### -c %s 2>&1 | 
FileCheck -check-prefix=CA34-BE %s
+// RUN: %clang -target aarch64_be -mbig-endian -mcpu=cortex-a34 -### -c %s 
2>&1 | FileCheck -check-prefix=CA34-BE %s
+// RUN: %clang -target aarch64_be -mtune=cortex-a34 -### -c %s 2>&1 | 
FileCheck -check-prefix=CA34-BE-TUNE %s
+// RUN: %clang -target aarch64 -mbig-endian -mtune=cortex-a34 -### -c %s 2>&1 
| FileCheck -check-prefix=CA34-BE-TUNE %s
+// RUN: %clang -target aarch64_be -mbig-endian -mtune=cortex-a34 -### -c %s 
2>&1 | FileCheck -check-prefix=CA34-BE-TUNE %s
+// CA34-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"cortex-a34"
+// CA34-BE-TUNE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic"
+
 // RUN: %clang -target aarch64_be -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA53-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -mcpu=cortex-a53 -### -c %s 2>&1 | 
FileCheck -check-prefix=CA53-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -mcpu=cortex-a53 -### -c %s 
2>&1 | FileCheck -check-prefix=CA53-BE %s

diff  --git a/clang/

[PATCH] D74483: [AArch64] Add Cortex-A34 Support for clang and llvm

2020-02-18 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson closed this revision.
LukeGeeson marked an inline comment as not done.
LukeGeeson added inline comments.



Comment at: llvm/unittests/Support/TargetParserTest.cpp:784
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a34", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_SIMD |

SjoerdMeijer wrote:
> nit: this looks the same as the a35. Would be better to keep the same order 
> of arch extension and also the formatting (to make it easier to eyeball 
> differences).
Good spot thanks, fixed.


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

https://reviews.llvm.org/D74483



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


[PATCH] D74606: [clangd] Add add commit characters to the server capabilities

2020-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:562
  llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\""},
  {"resolveProvider", false},

I think you're missing pipe and single-quote


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74606



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


[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-02-18 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D74735#1880390 , @xazax.hun wrote:

> If the AST is hard to work with would it make sense to try to change the AST 
> a bit?


Hmm, you mean making `CXXConstructExpr` an abstract base with subclasses 
`CXXSimpleConstructExpr` and `CXXInheritedConstructExpr`? For me it seems 
reasonable but I am afraid it would be a huge impact to clang, and not only to 
the analyzer.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:896
+public:
+  virtual const CXXInheritedCtorInitExpr *getOriginExpr() const {
+return cast(AnyFunctionCall::getOriginExpr());

I wonder whether we could reduce code-duplication using some kind of mixin-like 
inheritance here.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:436
   case CXXConstructExpr::CK_Complete: {
+assert(CE && "Complete constructors cannot be inherited!");
 std::tie(State, Target) =

martong wrote:
> Should there be rather `CIE` in the assert? Or the text after `&&` is 
> confusing. 
Surely not `CIE`, since the code below uses `CE`. I see nothing confusing here: 
`CE` must exist because complete constructors cannot be inherited, thus `CIE` 
cannot exist.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:494
   if (State != Pred->getState()) {
+assert(CE && "Inherited constructors do not have construction contexts!");
 static SimpleProgramPointTag T("ExprEngine",

martong wrote:
> `CIE` ?
No. `CE`. Since inherited constructors do not have construction contexts, 
`State` is the same for `CIE` as the previous `State`. Thus if they are 
different, we are facing a `CE`.



Comment at: clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp:30
+
+namespace arguments_with_constructors {
+struct S {

Not `constructors_with_arguments`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D74735



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


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2549
+  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL || Opts.SYCLIsDevice) {
+// -sycl-std applies to any SYCL source, not only those containing kernels,

Just `Opt.SYCL` should be enough



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:455
+  // SYCL Version is set to a value when building SYCL applications
+  switch (LangOpts.getSYCLVersion()) {
+  case LangOptions::SYCLVersionList::SYCL_2015:

Must be guarded with `LangOpts.SYCL`:
```
if (LangOpts.SYCL) ...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D74769: [AArch64][SVE] Add SVE2 intrinsics for polynomial arithmetic

2020-02-18 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, c-rhodes, dancgr, cameron.mcinally, 
efriedma.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Implements the following intrinsics:

- @llvm.aarch64.sve.eorbt
- @llvm.aarch64.sve.eortb
- @llvm.aarch64.sve.pmullb.pair
- @llvm.aarch64.sve.pmullt.pair


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74769

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic-128.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-polynomial-arithmetic.ll
@@ -0,0 +1,149 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; EORBT
+;
+
+define  @eorbt_i8( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i8:
+; CHECK: eorbt z0.b, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv16i8( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eorbt_i16( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i16:
+; CHECK: eorbt z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv8i16( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eorbt_i32( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i32:
+; CHECK: eorbt z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv4i32( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eorbt_i64( %a,  %b,  %c) {
+; CHECK-LABEL: eorbt_i64:
+; CHECK: eorbt z0.d, z1.d, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eorbt.nxv2i64( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+;
+; EORTB
+;
+
+define  @eortb_i8( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i8:
+; CHECK: eortb z0.b, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv16i8( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eortb_i16( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i16:
+; CHECK: eortb z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv8i16( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eortb_i32( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i32:
+; CHECK: eortb z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv4i32( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+define  @eortb_i64( %a,  %b,  %c) {
+; CHECK-LABEL: eortb_i64:
+; CHECK: eortb z0.d, z1.d, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.eortb.nxv2i64( %a,
+  %b,
+  %c)
+  ret  %out
+}
+
+;
+; PMULLB
+;
+
+define  @pmullb_i8( %a,  %b) {
+; CHECK-LABEL: pmullb_i8:
+; CHECK: pmullb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullb.pair.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @pmullb_i32( %a,  %b) {
+; CHECK-LABEL: pmullb_i32:
+; CHECK: pmullb z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullb.pair.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+;
+; PMULLT
+;
+
+define  @pmullt_i8( %a,  %b) {
+; CHECK-LABEL: pmullt_i8:
+; CHECK: pmullt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullt.pair.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @pmullt_i32( %a,  %b) {
+; CHECK-LABEL: pmullt_i32:
+; CHECK: pmullt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.pmullt.pair.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.eorbt.nxv16i8(, , )
+declare  @llvm.aarch64.sve.eorbt.nxv8i16(, , )
+declare  @llvm.aarc

[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-02-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/lib/Basic/FixedPoint.cpp:242
+  } else
+Overflowed = Result < Min || Result > Max;
+

rjmccall wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > rjmccall wrote:
> > > > ebevhan wrote:
> > > > > ebevhan wrote:
> > > > > > rjmccall wrote:
> > > > > > > If the maximum expressible value is *k*, and the fully-precise 
> > > > > > > multiplication yields *k+e* for some epsilon *e* that isn't 
> > > > > > > representable in the result semantics, is that considered an 
> > > > > > > overflow?  If so, I think you need to do the shift after these 
> > > > > > > bound checks, since the shift destroys the difference between *k* 
> > > > > > > and *k+e*.  That is, unless there's a compelling mathematical 
> > > > > > > argument that it's not possible to overflow only in the 
> > > > > > > fully-precision multiplication — but while I think that's 
> > > > > > > possibly true of `_Fract` (since *k^2 < k*), it seems unlikely to 
> > > > > > > be true of `_Accum`, although I haven't looked for a 
> > > > > > > counter-example.  And if there is a compelling argument, it 
> > > > > > > should probably be at least alluded to in a comment.
> > > > > > > 
> > > > > > > Would this algorithm be simpler if you took advantage of the fact 
> > > > > > > that `APFixedPointSemantics` doesn't have to correspond to a real 
> > > > > > > type?  You could probably just convert to a double-width common 
> > > > > > > semantics, right?
> > > > > > > If the maximum expressible value is *k*, and the fully-precise 
> > > > > > > multiplication yields *k+e* for some epsilon *e* that isn't 
> > > > > > > representable in the result semantics, is that considered an 
> > > > > > > overflow? If so, I think you need to do the shift after these 
> > > > > > > bound checks, since the shift destroys the difference between *k* 
> > > > > > > and *k+e*.
> > > > > > 
> > > > > > I don't think I would consider that to be overflow; that's 
> > > > > > precision loss. E-C considers these to be different:
> > > > > > 
> > > > > > > If the source value cannot be represented exactly by the 
> > > > > > > fixed-point type, the source value is rounded to either the 
> > > > > > > closest fixed-point value greater than the source value (rounded 
> > > > > > > up) or to the closest fixed-point value less than the source 
> > > > > > > value (rounded down).
> > > > > > >
> > > > > > > When the source value does not fit within the range of the 
> > > > > > > fixed-point type, the conversion overflows. [...]
> > > > > > >
> > > > > > > [...]
> > > > > > >
> > > > > > > If the result type of an arithmetic operation is a fixed-point 
> > > > > > > type, [...] the calculated result is the mathematically exact 
> > > > > > > result with overflow handling and rounding performed to the full 
> > > > > > > precision of the result type as explained in 4.1.3. 
> > > > > > 
> > > > > > There is also no value of `e` that would affect saturation. Any 
> > > > > > full precision calculation that gives `k+e` must be `k` after 
> > > > > > downscaling, since the bits that represent `e` must come from the 
> > > > > > extra precision range. Even though `k+e` is technically larger than 
> > > > > > `k`, saturation would still just give us `k` after truncating out 
> > > > > > `e`, so the end result is the same.
> > > > > > 
> > > > > > > Would this algorithm be simpler if you took advantage of the fact 
> > > > > > > that APFixedPointSemantics doesn't have to correspond to a real 
> > > > > > > type? You could probably just convert to a double-width common 
> > > > > > > semantics, right?
> > > > > > 
> > > > > > It's likely possible to use APFixedPoint in the calculations here, 
> > > > > > but I used APInt to make the behavior explicit and not accidentally 
> > > > > > be dependent on the behavior of APFixedPoint's conversions or 
> > > > > > operations.
> > > > > Although.,. I guess I see your point in that an intermediate result 
> > > > > of k+e technically "does not fit within the range of the fixed-point 
> > > > > type"... but I wonder if treating such cases as overflow is 
> > > > > particularly meaningful. I don't find there to be much of a 
> > > > > distinction between such a case and the case where the exact result 
> > > > > lands inbetween two representable values. We just end up with a less 
> > > > > precise result.
> > > > Right, I was wondering if there was an accepted answer here.  For 
> > > > saturating arithmetic, it's equivalent to truncate this extra precision 
> > > > down to *k* or to saturate to the maximum representable value, since by 
> > > > assumption that was just *k*; but for non-saturating arithmetic, it 
> > > > affects whether the operation has UB.  All else being the same, it's 
> > > > better to have fewer corner-case sources of UB.
> > > > 
> > > > My read is that Embedded C is saying there's a sequence here: compute 
> > > > the exact mathematical result

[clang] 2bf44d1 - Revert "Reland "[DebugInfo] Enable the debug entry values feature by default""

2020-02-18 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-02-18T16:38:11+01:00
New Revision: 2bf44d11cb42a952bdeb778210d8b3e737f0b96e

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

LOG: Revert "Reland "[DebugInfo] Enable the debug entry values feature by 
default""

This reverts commit rGa82d3e8a6e67.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
llvm/test/CodeGen/ARM/smml.ll
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/CodeGen/X86/hoist-invariant-load.ll
llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
llvm/test/CodeGen/X86/statepoint-allocas.ll
llvm/test/CodeGen/X86/tail-dup-repeat.ll
llvm/test/CodeGen/X86/xray-custom-log.ll
llvm/test/CodeGen/X86/xray-typed-event-log.ll
llvm/test/DebugInfo/AArch64/call-site-info-output.ll
llvm/test/DebugInfo/ARM/call-site-info-output.ll
llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/DebugInfo/X86/loclists-dwp.ll
llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
llvm/test

[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Stella Stamenova via Phabricator via cfe-commits
stella.stamenova added a comment.

It looks like this broke the windows lldb bot:

lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13902


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Thanks for reporting that, are you sure this was the cause of the failure? I'll 
revert this while investigate, but it does not seem to me this is related to 
this patch.


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

https://reviews.llvm.org/D73534



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


[PATCH] D74116: [Sema][C++] Propagate conversion type in order to specialize the diagnostics

2020-02-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 245164.
Anastasia retitled this revision from "[Sema][C++] Strawman patch to propagate 
conversion type in order to specialize the diagnostics" to "[Sema][C++] 
Propagate conversion type in order to specialize the diagnostics".
Anastasia added a comment.

- Updated expected diagnostics for function pointer tests
- Make DiagnoseAsignmentResult return true for all incompatible cases in C++


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

https://reviews.llvm.org/D74116

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/conv/conv.fctptr/p1.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/except/except.handle/p16.cpp
  clang/test/CXX/expr/p13.cpp
  clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp
  clang/test/OpenMP/allocate_allocator_messages.cpp
  clang/test/Sema/block-return.c
  clang/test/Sema/callingconv-ms_abi.c
  clang/test/Sema/callingconv-sysv_abi.c
  clang/test/Sema/callingconv.c
  clang/test/Sema/overloadable.c
  clang/test/Sema/pass-object-size.c
  clang/test/Sema/preserve-call-conv.c
  clang/test/SemaCXX/addr-of-overloaded-function.cpp
  clang/test/SemaCXX/decl-microsoft-call-conv.cpp
  clang/test/SemaCXX/goto.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/ms-property-error.cpp
  clang/test/SemaObjC/comptypes-legal.m
  clang/test/SemaObjCXX/arc-type-conversion.mm
  clang/test/SemaObjCXX/comptypes-1.mm
  clang/test/SemaObjCXX/comptypes-7.mm
  clang/test/SemaObjCXX/instantiate-expr.mm
  clang/test/SemaObjCXX/instantiate-stmt.mm
  clang/test/SemaObjCXX/noescape.mm
  clang/test/SemaObjCXX/nullability-pragmas.mm
  clang/test/SemaObjCXX/objc-container-subscripting.mm
  clang/test/SemaObjCXX/parameterized_classes_subst.mm
  clang/test/SemaObjCXX/property-invalid-type.mm
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl
  clang/test/SemaTemplate/extern-templates.cpp
  clang/test/SemaTemplate/instantiate-member-class.cpp
  clang/test/SemaTemplate/member-access-expr.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -194,7 +194,7 @@
   template
   struct Y {
 static void f(T x) { 
-  x = 1; // expected-error{{assigning to 'int *' from incompatible type 'int'}}
+  x = 1; // expected-error{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
 }
   };
 
Index: clang/test/SemaTemplate/member-access-expr.cpp
===
--- clang/test/SemaTemplate/member-access-expr.cpp
+++ clang/test/SemaTemplate/member-access-expr.cpp
@@ -156,7 +156,7 @@
 void get(B **ptr) {
   // It's okay if at some point we figure out how to diagnose this
   // at instantiation time.
-  *ptr = field; // expected-error {{assigning to 'test6::B *' from incompatible type 'test6::A *}}
+  *ptr = field; // expected-error {{incompatible pointer types assigning to 'test6::B *' from 'test6::A *'}}
 }
   };
 }
Index: clang/test/SemaTemplate/instantiate-member-class.cpp
===
--- clang/test/SemaTemplate/instantiate-member-class.cpp
+++ clang/test/SemaTemplate/instantiate-member-class.cpp
@@ -43,8 +43,8 @@
 X::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type}}
 
 void test_naming() {
-  c1 = c2; // expected-error{{assigning to 'X::C *' from incompatible type 'X::C *'}}
-  xi = xf;  // expected-error{{assigning to 'X::X *' from incompatible type 'X::X *'}}
+  c1 = c2; // expected-error{{incompatible pointer types assigning to 'X::C *' from 'X::C *'}}
+  xi = xf;  // expected-error{{incompatible pointer types assigning to 'X::X *' from 'X::X *'}}
 // FIXME: error above doesn't print the type X::X cleanly!
 }
 
Index: clang/test/SemaTemplate/extern-templates.cpp
===
--- clang/test/SemaTemplate/extern-templates.cpp
+++ clang/test/SemaTemplate/extern-templates.cpp
@@ -23,9 +23,9 @@
 template
 void X0::Inner::g(T t) {
 #ifdef MS
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}} expected-error{{assigning to 'int *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}} expected-error{{incompatible integer to pointer conversion assigning to 'int *'}}
 #else
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assign

[PATCH] D74631: [clang][XCOFF] Indicate that XCOFF does not support COMDATs

2020-02-18 Thread David Tenty via Phabricator via cfe-commits
daltenty added a comment.

In D74631#1876995 , @sfertile wrote:

> 1. We should probably update the COMDAT section of the lang ref to mention 
> XCOFF doesn't support COMDATS.


I will update the langref as suggested.

> 2. Will we report an error somewhere in the backend if we encounter a COMDAT?

As mentioned by @Xiangling_L, we will run into `report_fatal_error("COMDAT not 
yet supported by AIX.")`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74631



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


[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-02-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:436
   case CXXConstructExpr::CK_Complete: {
+assert(CE && "Complete constructors cannot be inherited!");
 std::tie(State, Target) =

baloghadamsoftware wrote:
> martong wrote:
> > Should there be rather `CIE` in the assert? Or the text after `&&` is 
> > confusing. 
> Surely not `CIE`, since the code below uses `CE`. I see nothing confusing 
> here: `CE` must exist because complete constructors cannot be inherited, thus 
> `CIE` cannot exist.
Maybe it's just me and seems like nit picking, but this is still confusing for 
me b/c above `CK` gets its value either from `CE` or from `CIE`. And the case 
depends on the kind of `CK`.

Perhaps it would be more expressive (?) : `assert(!CIE && CE && "Inherited 
constructors cannot be complete!");`
Alternatively maybe the assert above in line 400 could be `assert(!CE != 
!CIE);` to express that it is either inherited or not but cannot be both 
(logical xor).


Repository:
  rC Clang

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

https://reviews.llvm.org/D74735



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


[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-02-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Basic/FixedPoint.cpp:242
+  } else
+Overflowed = Result < Min || Result > Max;
+

ebevhan wrote:
> rjmccall wrote:
> > leonardchan wrote:
> > > ebevhan wrote:
> > > > rjmccall wrote:
> > > > > ebevhan wrote:
> > > > > > ebevhan wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > If the maximum expressible value is *k*, and the fully-precise 
> > > > > > > > multiplication yields *k+e* for some epsilon *e* that isn't 
> > > > > > > > representable in the result semantics, is that considered an 
> > > > > > > > overflow?  If so, I think you need to do the shift after these 
> > > > > > > > bound checks, since the shift destroys the difference between 
> > > > > > > > *k* and *k+e*.  That is, unless there's a compelling 
> > > > > > > > mathematical argument that it's not possible to overflow only 
> > > > > > > > in the fully-precision multiplication — but while I think 
> > > > > > > > that's possibly true of `_Fract` (since *k^2 < k*), it seems 
> > > > > > > > unlikely to be true of `_Accum`, although I haven't looked for 
> > > > > > > > a counter-example.  And if there is a compelling argument, it 
> > > > > > > > should probably be at least alluded to in a comment.
> > > > > > > > 
> > > > > > > > Would this algorithm be simpler if you took advantage of the 
> > > > > > > > fact that `APFixedPointSemantics` doesn't have to correspond to 
> > > > > > > > a real type?  You could probably just convert to a double-width 
> > > > > > > > common semantics, right?
> > > > > > > > If the maximum expressible value is *k*, and the fully-precise 
> > > > > > > > multiplication yields *k+e* for some epsilon *e* that isn't 
> > > > > > > > representable in the result semantics, is that considered an 
> > > > > > > > overflow? If so, I think you need to do the shift after these 
> > > > > > > > bound checks, since the shift destroys the difference between 
> > > > > > > > *k* and *k+e*.
> > > > > > > 
> > > > > > > I don't think I would consider that to be overflow; that's 
> > > > > > > precision loss. E-C considers these to be different:
> > > > > > > 
> > > > > > > > If the source value cannot be represented exactly by the 
> > > > > > > > fixed-point type, the source value is rounded to either the 
> > > > > > > > closest fixed-point value greater than the source value 
> > > > > > > > (rounded up) or to the closest fixed-point value less than the 
> > > > > > > > source value (rounded down).
> > > > > > > >
> > > > > > > > When the source value does not fit within the range of the 
> > > > > > > > fixed-point type, the conversion overflows. [...]
> > > > > > > >
> > > > > > > > [...]
> > > > > > > >
> > > > > > > > If the result type of an arithmetic operation is a fixed-point 
> > > > > > > > type, [...] the calculated result is the mathematically exact 
> > > > > > > > result with overflow handling and rounding performed to the 
> > > > > > > > full precision of the result type as explained in 4.1.3. 
> > > > > > > 
> > > > > > > There is also no value of `e` that would affect saturation. Any 
> > > > > > > full precision calculation that gives `k+e` must be `k` after 
> > > > > > > downscaling, since the bits that represent `e` must come from the 
> > > > > > > extra precision range. Even though `k+e` is technically larger 
> > > > > > > than `k`, saturation would still just give us `k` after 
> > > > > > > truncating out `e`, so the end result is the same.
> > > > > > > 
> > > > > > > > Would this algorithm be simpler if you took advantage of the 
> > > > > > > > fact that APFixedPointSemantics doesn't have to correspond to a 
> > > > > > > > real type? You could probably just convert to a double-width 
> > > > > > > > common semantics, right?
> > > > > > > 
> > > > > > > It's likely possible to use APFixedPoint in the calculations 
> > > > > > > here, but I used APInt to make the behavior explicit and not 
> > > > > > > accidentally be dependent on the behavior of APFixedPoint's 
> > > > > > > conversions or operations.
> > > > > > Although.,. I guess I see your point in that an intermediate result 
> > > > > > of k+e technically "does not fit within the range of the 
> > > > > > fixed-point type"... but I wonder if treating such cases as 
> > > > > > overflow is particularly meaningful. I don't find there to be much 
> > > > > > of a distinction between such a case and the case where the exact 
> > > > > > result lands inbetween two representable values. We just end up 
> > > > > > with a less precise result.
> > > > > Right, I was wondering if there was an accepted answer here.  For 
> > > > > saturating arithmetic, it's equivalent to truncate this extra 
> > > > > precision down to *k* or to saturate to the maximum representable 
> > > > > value, since by assumption that was just *k*; but for non-saturating 
> > > > > arithmetic, it affects whether the operation has UB.  All else being 
> > > > > the same, it's

[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Stella Stamenova via Phabricator via cfe-commits
stella.stamenova added a comment.

I am not sure this was the cause of the failure, but other than your patches, 
there was only one other change in the first failing build. I have not had time 
to fully investigate yet.


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

https://reviews.llvm.org/D73534



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


[clang] 260b91f - Use getLocation() in "too few/too many arguments" diagnostic

2020-02-18 Thread Aaron Ballman via cfe-commits

Author: John Marshall
Date: 2020-02-18T11:23:17-05:00
New Revision: 260b91f379c8f86d3d6008648b3f2a945a007888

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

LOG: Use getLocation() in "too few/too many arguments" diagnostic

Use the more accurate location when emitting the location of the
function being called's prototype in diagnostics emitted when calling
a function with an incorrect number of arguments.

In particular, avoids showing a trace of irrelevant macro expansions
for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/Misc/serialized-diags.c
clang/test/Sema/exprs.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3a1865124199..591d079784fe 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5195,7 +5195,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   return true;
 }
@@ -5240,7 +5240,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);

diff  --git a/clang/test/Misc/serialized-diags.c 
b/clang/test/Misc/serialized-diags.c
index e401477a2ebd..2f4b86fb42f9 100644
--- a/clang/test/Misc/serialized-diags.c
+++ b/clang/test/Misc/serialized-diags.c
@@ -56,7 +56,7 @@ void rdar11040133() {
 // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 
{{.*[/\\]}}serialized-diags.c:22:18
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 
'false' []
 // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 
{{.*[/\\]}}serialized-diags.c:20:16
-// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:6: note: 'taz' declared here []
 // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to 
pointer conversion initializing 'char *' with an expression of type 'int' 
[-Wint-conversion]
 // CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 
{{.*[/\\]}}serialized-diags.h:5:17
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from 
{{.*[/\\]}}serialized-diags.c:26: []

diff  --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
index 760c45e02f37..4e144041acae 100644
--- a/clang/test/Sema/exprs.c
+++ b/clang/test/Sema/exprs.c
@@ -163,12 +163,15 @@ void test17(int x) {
   x = sizeof(x/0);  // no warning.
 }
 
-// PR6501 & PR11857
+// PR6501, PR11857, and PR23564
 void test18_a(int a); // expected-note 2 {{'test18_a' declared here}}
 void test18_b(int); // expected-note {{'test18_b' declared here}}
 void test18_c(int a, int b); // expected-note 2 {{'test18_c' declared here}}
 void test18_d(int a, ...); // expected-note {{'test18_d' declared here}}
 void test18_e(int a, int b, ...); // expected-note {{'test18_e' declared here}}
+#define MY_EXPORT __attribute__((visibility("default")))
+MY_EXPORT void // (no "declared here" notes on this line, no "expanded from 
MY_EXPORT" notes either)
+test18_f(int a, int b); // expected-note 2 {{'test18_f' declared here}}
 void test18(int b) {
   test18_a(b, b); // expected-error {{too many arguments to function call, 
expected single argument 'a', have 2}}
   test18_a(); // expected-error {{too few arguments to function call, single 
argument 'a' was not specified}}
@@ -177,6 +180,8 @@ void test18(int b) {
   test18_c(b, b, b); // expected-error {{too many arguments to function call, 
expected 2, have 3}}
   test18_d(); // expected-error {{too few arguments to function call, at least 
argument 'a' must be specified}}
   test18_e(); // expected-error {{too few arguments to function call, expected 
at least 2, have 0}}
+  test18_f(b); // expected-error {{too few arguments to function call, 
expected 2, have 1}}
+  test18_f(b, b, b); // expected-error {{too many arguments to function call, 
expected 2, have 3}}
 }
 
 typedef int __attribute__((address_space(256))) int_AS256;



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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-18 Thread Aaron Ballman via cfe-commits
I've commit on your behalf in
260b91f379c8f86d3d6008648b3f2a945a007888, thank you for the patch!

~Aaron

On Mon, Feb 10, 2020 at 12:42 PM Aaron Ballman  wrote:
>
> On Mon, Feb 10, 2020 at 10:06 AM John Marshall
>  wrote:
> >
> > Thanks Aaron (and Hubert).
> >
> > I've attached an updated patch that now includes new test cases alongside 
> > some existing "too few / too many" test cases in test/Sema/exprs.c. This 
> > splits the function declaration over two lines so it can use -verify to 
> > validate the source location's line (but not column). If you'd prefer a 
> > FileCheck approach to get the column too, I'm happy to do that but please 
> > advise whether it would be best to create a new test/Sema/foo.c file for 
> > these tests or to add to one of the existing test files.
> >
> > Verified that without the patch, the notes are on the "MY_EXPORT void" line 
> > and the test cases fail. All tests still pass after this, after adjusting 
> > one existing FileCheck-based test case that also happens to exercise the 
> > patch's change.
>
> Thank you for the patch -- I think it is fine to not check the column
> for the cases you've added, so this iteration LGTM. I'm happy to
> commit this on your behalf, but it will have to wait until next week
> because I'm out at wg21 meetings this week. If no one else commits
> this before I get home, I'll handle it then.
>
> ~Aaron
>
> >
> > John
> >
> >
> > On 7 Feb 2020, at 15:40, Aaron Ballman wrote:
> > > Thank you for the patch -- I think the changes look reasonable, but it
> > > should come with some test cases as well. Source location stuff is a
> > > bit onerous to try to test, but I think the best approach would be to
> > > add a new test that uses FileCheck instead of -verify so that you can
> > > validate the source location's line and column are as expected in the
> > > note. Once you have such a test (and have verified that no other tests
> > > fail with your changes), I'm happy to commit on your behalf.
> > >
> > > ~Aaron
> > >
> > > On Fri, Feb 7, 2020 at 10:23 AM Hubert Tong
> > >  wrote:
> > >>
> > >> I think this looks okay. I think Richard or Aaron might be able to 
> > >> provide a more informed opinion.
> > >>
> > >> -- HT
> >
> >
> > commit cbd4a4a155b40dc77c2ed82f397fe303dfc10837
> > Author: John Marshall 
> > AuthorDate: Mon Jan 20 14:58:14 2020 +
> > Commit: John Marshall 
> > CommitDate: Mon Feb 10 14:30:58 2020 +
> >
> > Use getLocation() in "too few/too many arguments" diagnostic
> >
> > Use the more accurate location when emitting the location of the
> > function being called's prototype in diagnostics emitted when calling
> > a function with an incorrect number of arguments.
> >
> > In particular, avoids showing a trace of irrelevant macro expansions
> > for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.
> >
> > Add test cases alongside other "too few/too many arguments" tests.
> > Adjust column position in incidentally related FileCheck-based test.
> >
> > diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
> > index ffe72c98356..b9d7024f083 100644
> > --- a/clang/lib/Sema/SemaExpr.cpp
> > +++ b/clang/lib/Sema/SemaExpr.cpp
> > @@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr 
> > *Fn,
> >
> >// Emit the location of the prototype.
> >if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
> > -Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
> > +Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
> >
> >return true;
> >  }
> > @@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr 
> > *Fn,
> >
> >// Emit the location of the prototype.
> >if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
> > -Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
> > +Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
> >
> >// This deletes the extra arguments.
> >Call->shrinkNumArgs(NumParams);
> > diff --git a/clang/test/Misc/serialized-diags.c 
> > b/clang/test/Misc/serialized-diags.c
> > index e401477a2eb..2f4b86fb42f 100644
> > --- a/clang/test/Misc/serialized-diags.c
> > +++ b/clang/test/Misc/serialized-diags.c
> > @@ -56,7 +56,7 @@ void rdar11040133() {
> >  // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 
> > {{.*[/\\]}}serialized-diags.c:22:18
> >  // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 
> > 'false' []
> >  // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 
> > {{.*[/\\]}}serialized-diags.c:20:16
> > -// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here 
> > []
> > +// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:6: note: 'taz' declared here 
> > []
> >  // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer 
> > to pointer conversion initializing 'char *' with an expression of type 
> > 'int

[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-02-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 2 inline comments as done.
NoQ added a comment.

In D74735#1880617 , 
@baloghadamsoftware wrote:

> In D74735#1880390 , @xazax.hun wrote:
>
> > If the AST is hard to work with would it make sense to try to change the 
> > AST a bit?
>
>
> Hmm, you mean making `CXXConstructExpr` an abstract base with subclasses 
> `CXXSimpleConstructExpr` and `CXXInheritedConstructExpr`? For me it seems 
> reasonable but I am afraid it would be a huge impact to clang, and not only 
> to the analyzer.


I'm not extremely confident of my ability to write down the argument 
expressions correctly (which is the bigger problem here), especially when 
arguments need to be constructed. Like, not sure if it's harder to get right 
than this patch, but it's definitely easier to get wrong.




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:436
   case CXXConstructExpr::CK_Complete: {
+assert(CE && "Complete constructors cannot be inherited!");
 std::tie(State, Target) =

martong wrote:
> baloghadamsoftware wrote:
> > martong wrote:
> > > Should there be rather `CIE` in the assert? Or the text after `&&` is 
> > > confusing. 
> > Surely not `CIE`, since the code below uses `CE`. I see nothing confusing 
> > here: `CE` must exist because complete constructors cannot be inherited, 
> > thus `CIE` cannot exist.
> Maybe it's just me and seems like nit picking, but this is still confusing 
> for me b/c above `CK` gets its value either from `CE` or from `CIE`. And the 
> case depends on the kind of `CK`.
> 
> Perhaps it would be more expressive (?) : `assert(!CIE && CE && "Inherited 
> constructors cannot be complete!");`
> Alternatively maybe the assert above in line 400 could be `assert(!CE != 
> !CIE);` to express that it is either inherited or not but cannot be both 
> (logical xor).
The big question here is, should assert messages explain what happens when they 
fail, or why shouldn't they fail? I.e., `assert(CE && !CIE && "A complete 
constructor is inherited!");` or `assert(CE && !CIE && "A complete constructor 
cannot be inherited!");`? I think it's the former because that produces a more 
understandable crash dump. In this sense, i agree that the assert is confusing.

> Alternatively maybe the assert above in line 400 could be `assert(!CE != 
> !CIE);`

Dunno, that's kinda obvious because they're `dyn_cast`s to unrelated classes 
(and thankfully we don't have much multiple inheritance in the AST).



Comment at: clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp:30
+
+namespace arguments_with_constructors {
+struct S {

baloghadamsoftware wrote:
> Not `constructors_with_arguments`?
The focus is on how `B::B(S, int)` has an argument of type `S` that needs to be 
constructed. So it's kinda `constructors_with_arguments_with_constructors`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74735



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


Re: patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-02-18 Thread John Marshall via cfe-commits
On 18 Feb 2020, at 16:24, Aaron Ballman  wrote:
> 
> I've commit on your behalf in
> 260b91f379c8f86d3d6008648b3f2a945a007888, thank you for the patch!

Thanks very much, Aaron.

I regret to report that this appears to have broken an additional test [1] that 
I didn't see when running the test suite locally with "make check-clang". Patch 
(untested) attached.

John

[1] 
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/23835/steps/test-check-all/logs/stdio

--- a/clang/bindings/python/tests/cindex/test_diagnostics.py
+++ b/clang/bindings/python/tests/cindex/test_diagnostics.py
@@ -100,7 +100,7 @@ class TestDiagnostics(unittest.TestCase):
 self.assertRegexpMatches(children[0].spelling,
 '.*declared here')
 self.assertEqual(children[0].location.line, 1)
-self.assertEqual(children[0].location.column, 1)
+self.assertEqual(children[0].location.column, 6)
 
 def test_diagnostic_string_repr(self):
 tu = get_tu('struct MissingSemicolon{}')

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


[clang] 66c0162 - Hopefully fixing a failing build bot.

2020-02-18 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-02-18T11:39:23-05:00
New Revision: 66c01627719f088bff9a0d09655a8ca0842b2c82

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

LOG: Hopefully fixing a failing build bot.

Should fix the changes from 260b91f379c8f86d3d6008648b3f2a945a007888.

Added: 


Modified: 
clang/bindings/python/tests/cindex/test_diagnostics.py

Removed: 




diff  --git a/clang/bindings/python/tests/cindex/test_diagnostics.py 
b/clang/bindings/python/tests/cindex/test_diagnostics.py
index 52928db73035..64d0ca2ef9bc 100644
--- a/clang/bindings/python/tests/cindex/test_diagnostics.py
+++ b/clang/bindings/python/tests/cindex/test_diagnostics.py
@@ -100,7 +100,7 @@ def test_diagnostic_children(self):
 self.assertRegexpMatches(children[0].spelling,
 '.*declared here')
 self.assertEqual(children[0].location.line, 1)
-self.assertEqual(children[0].location.column, 1)
+self.assertEqual(children[0].location.column, 6)
 
 def test_diagnostic_string_repr(self):
 tu = get_tu('struct MissingSemicolon{}')



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


  1   2   3   >