[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

@balazske Do you see any problems with this patch?


Repository:
  rC Clang

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

https://reviews.llvm.org/D74542



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


[PATCH] D74620: [ARM,MVE] Add vector-scalar intrinsics

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

I like how this uses a splat for all the register arguments. That sounds like a 
good idea.

The one's that worry me are the floating point instructions. Last time we tried 
those it was actually causing performance regressions because of extra sp->gpr 
mov's left in the loop.

If this is just the backend patterns though, not the sinking of splats into 
loops too, then I think it should be OK. On it's own I don't think it will 
usually cause problems. And some quick tests seem to verify that.




Comment at: clang/test/CodeGen/arm-mve-intrinsics/vaddq.c:2
 // 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
+// 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 -O1 | 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 -O1 | 
FileCheck %s

Why is this running the entire -O1 pass pipeline? These tests deliberately uses 
a limit subset to not need adjusting with every midend llvm change. (But not be 
littered with clang's verbose ir output).

I'm guessing the half args are being a pain again. Is it something to do with 
halfs?



Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:4496
+UnpredSign)),
+  (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 GPR:$val)))>;
+// Predicated version

These GPR's can use the same regclass as the instruction. rGPR in this case I 
think?



Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:4566
+  0b0, VTI.Unsigned>;
+  defvar unpred_op = !if(VTI.Unsigned, unpred_op_u, unpred_op_s);
+  defm : MVE_vec_scalar_int_pat_m(NAME), VTI,

I find all these if's at different levels a little hard to follow. It looks OK, 
but is it possible to rearrange things to not need it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74620



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-17 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added inline comments.



Comment at: clang/test/Driver/flang/clang-driver-2-frontend01.f90:10
+! RUN: cp %clang %t1
+! RUN: %clang --driver-mode=flang -fortran-fe %basename_t.tmp1 -### %s 2>&1 | 
FileCheck --check-prefixes=ALL %s
+

CarolineConcatto wrote:
> richard.barton.arm wrote:
> > Does %t1 not work again on this line?
> If I don't create the fake link getProgramPath will only return the name, not 
> the entire path.
> t1 here is the path for the frontend.  
> For instance:
> clang --driver-mode=flang -fortran-fe %test
> the frontend name is test, but when running it should print:
>  /test -fc1
>  without the link it will only print:
> test -fc1
> Like I said before it is more a preference that actually a requisite.
Understood - thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[clang] 7ae1347 - clang analyzer: Fix the webpage rendering

2020-02-17 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2020-02-17T10:03:20+01:00
New Revision: 7ae1347fb259c6f5feb92567192c0b1032553c02

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

LOG: clang analyzer: Fix the webpage rendering

Added: 


Modified: 
clang/www/analyzer/alpha_checks.html

Removed: 




diff  --git a/clang/www/analyzer/alpha_checks.html 
b/clang/www/analyzer/alpha_checks.html
index 3d4075e5aaf9..181ce1b9de59 100644
--- a/clang/www/analyzer/alpha_checks.html
+++ b/clang/www/analyzer/alpha_checks.html
@@ -1083,9 +1083,6 @@ Non-determinism 
Alpha Checkers
f(i);
 }
 
-
-
-
 
 alpha.nondeterminism.PointerSorting
 (C++)



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


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-02-17 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

Is there any chance to get this commit cherry-picked to 10.x branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71460



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


[PATCH] D73996: [Sema] Demote call-site-based 'alignment is a power of two' check for AllocAlignAttr into a warning

2020-02-17 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Bump @rsmith / @erichkeane 
thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73996



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


[PATCH] D73020: [Sema] Perform call checking when building CXXNewExpr

2020-02-17 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Bump @rsmith
thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73020



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Oh god, this code is a mess, so many knobs, and apparently I made it worst in 
the past sorry for that :D

I totally understand if you want to make minimal changes to the code like this, 
but it would be great to simplify it a little bit without regressing too much, 
currently there is a knob for function locals and then another for parameters 
in declarations, then there is an implicit conditioning for function 
definitions.
I would say it would be sensible to only have `IndexFunctionLocals` as an 
option and do full indexing of parameters, both in declarations and definitions 
if it is present (assuming this doesn't result in real regressions in the 
client code), but it is also OK to leave it as it is, since the mess is beyond 
the scope of this patch.

But if you leave it as it is, I believe we'll still be missing some references 
to decls inside default arguments in clangd, for example:

a.h:

  int var = 2;
  void foo(int x = var);

a.cc

  void foo(int x) {
va^r = x;
  }

clangd won't have the reference occuring in default arg inside the index, as 
preambles are not indexed with `IndexParametersInDeclarations` option turned on.




Comment at: clang/lib/Index/IndexDecl.cpp:102
 auto *DC = Parm->getDeclContext();
+IndexDefaultParmeterArgument(Parm, Parent);
 if (auto *FD = dyn_cast(DC)) {

this should move into the `else` clause down below, otherwise it would end up 
being indexed twice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2020-02-17 Thread Jobst Ziebell via Phabricator via cfe-commits
iolojz added a comment.

In D33029#1538200 , @gracicot wrote:

> Will this option also work with dangling braces from initializers?
>
> I have some code that looks like this:
>
>   return some_type_with_a_long_name{
>   get_param_number_one(),
>   get_param_number_two()
>   };
>   
>
> Clang format will put the brace at the end of the line:
>
>   return some_type_with_a_long_name{
>   get_param_number_one(),
>   get_param_number_two()};
>   
>
> I would like to keep the style of the first snippet.


I would also love that (y)


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

https://reviews.llvm.org/D33029



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


[PATCH] D74550: [AArch64][SVE] Add SVE index intrinsic

2020-02-17 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Nice, thanks for adding those tests @kmclaughlin. LGTM!


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

https://reviews.llvm.org/D74550



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


[PATCH] D74669: [clang-tidy] New check: misc-no-include-cpp

2020-02-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:43
+
+void SuspiciousIncludePPCallbacks::InclusionDirective(
+SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,

This function is used for `#import` on modules. Do we still want the same 
behaviour when importing modules? More thinking about the extension suggestions 
with that one. 



Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:59
+Optional File = PP->LookupFile(
+HashLoc /* FIXME: lies */, (FileName + RE).str(), IsAngled, 
nullptr,
+nullptr, CurDir, nullptr, nullptr, nullptr, nullptr, nullptr);

jroelofs wrote:
> FIXME: is this a reasonable `SourceLocation` to give to `LookupFile`?
Main thing is to make sure that the same location is used for the warnings and 
the notes.
I personally found this the most pleasing diagnostics

```
SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);
```

```
/home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
 warning: suspicious #include of file with .cpp extension 
[bugprone-suspicious-include]
#include "a.cpp"
  ^
/home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
 note: did you mean to include 'a'?
/home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
 note: did you mean to include 'a.h'?
/home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
 note: did you mean to include 'a.hpp'?
```


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

https://reviews.llvm.org/D74669



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


[PATCH] D74639: Add linkage check to ASTNodeImporter::hasSameVisibilityContext and rename to hasSameVisibilityContextAndLinkage

2020-02-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:989
!Found->hasExternalFormalLinkage();
 }
 

This would be equivalent but more clear code (formatting is probably not 
correct here):
```
  if (Found->getLinkageInternal() != From->getLinkageInternal())
return false;

  if (From->hasExternalFormalLinkage())
return true;

  return Importer.GetFromTU(Found) == From->getTranslationUnitDecl() &&
 From->isInAnonymousNamespace() == Found->isInAnonymousNamespace();
```


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

https://reviews.llvm.org/D74639



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


[PATCH] D74634: Remove "ELF Only" restriction from section flags

2020-02-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

In the commit message,  which is currently "Remove "ELF Only" restriction from 
section flags" maybe add "help text" or something to make it obvious this only 
changes the help text -- i.e. it's not removing any actual "elf only" 
restriction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74634



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


[PATCH] D74550: [AArch64][SVE] Add SVE index intrinsic

2020-02-17 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG633db60f3ed0: [AArch64][SVE] Add SVE index intrinsic 
(authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74550

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-index.ll
@@ -0,0 +1,178 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; INDEX (IMMEDIATES)
+;
+
+define  @index_ii_i8() {
+; CHECK-LABEL: index_ii_i8:
+; CHECK: index z0.b, #-16, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 -16, i8 15)
+  ret  %out
+}
+
+define  @index_ii_i16() {
+; CHECK-LABEL: index_ii_i16:
+; CHECK: index z0.h, #15, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 15, i16 -16)
+  ret  %out
+}
+
+define  @index_ii_i32() {
+; CHECK-LABEL: index_ii_i32:
+; CHECK: index z0.s, #-16, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 -16, i32 15)
+  ret  %out
+}
+
+define  @index_ii_i64() {
+; CHECK-LABEL: index_ii_i64:
+; CHECK: index z0.d, #15, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 15, i64 -16)
+  ret  %out
+}
+
+define  @index_ii_range() {
+; CHECK-LABEL: index_ii_range:
+; CHECK: mov w8, #16
+; CHECK-NEXT: mov x9, #-17
+; CHECK-NEXT: index z0.d, x9, x8
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 -17, i64 16)
+  ret  %out
+}
+
+;
+; INDEX (IMMEDIATE, SCALAR)
+;
+
+define  @index_ir_i8(i8 %a) {
+; CHECK-LABEL: index_ir_i8:
+; CHECK: index z0.b, #15, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 15, i8 %a)
+  ret  %out
+}
+
+define  @index_ir_i16(i16 %a) {
+; CHECK-LABEL: index_ir_i16:
+; CHECK: index z0.h, #-16, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 -16, i16 %a)
+  ret  %out
+}
+
+define  @index_ir_i32(i32 %a) {
+; CHECK-LABEL: index_ir_i32:
+; CHECK: index z0.s, #15, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 15, i32 %a)
+  ret  %out
+}
+
+define  @index_ir_i64(i64 %a) {
+; CHECK-LABEL: index_ir_i64:
+; CHECK: index z0.d, #-16, x0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 -16, i64 %a)
+  ret  %out
+}
+
+define  @index_ir_range(i32 %a) {
+; CHECK-LABEL: index_ir_range:
+; CHECK: mov w8, #-17
+; CHECK: index z0.s, w8, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 -17, i32 %a)
+  ret  %out
+}
+
+;
+; INDEX (SCALAR, IMMEDIATE)
+;
+
+define  @index_ri_i8(i8 %a) {
+; CHECK-LABEL: index_ri_i8:
+; CHECK: index z0.b, w0, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 -16)
+  ret  %out
+}
+
+define  @index_ri_i16(i16 %a) {
+; CHECK-LABEL: index_ri_i16:
+; CHECK: index z0.h, w0, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 15)
+  ret  %out
+}
+
+define  @index_ri_i32(i32 %a) {
+; CHECK-LABEL: index_ri_i32:
+; CHECK: index z0.s, w0, #-16
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 -16)
+  ret  %out
+}
+
+define  @index_ri_i64(i64 %a) {
+; CHECK-LABEL: index_ri_i64:
+; CHECK: index z0.d, x0, #15
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 15)
+  ret  %out
+}
+
+define  @index_ri_range(i16 %a) {
+; CHECK-LABEL: index_ri_range:
+; CHECK: mov w8, #16
+; CHECK: index z0.h, w0, w8
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 16)
+  ret  %out
+}
+
+;
+; INDEX (SCALARS)
+;
+
+define  @index_rr_i8(i8 %a, i8 %b) {
+; CHECK-LABEL: index_rr_i8:
+; CHECK: index z0.b, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv16i8(i8 %a, i8 %b)
+  ret  %out
+}
+
+define  @index_rr_i16(i16 %a, i16 %b) {
+; CHECK-LABEL: index_rr_i16:
+; CHECK: index z0.h, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv8i16(i16 %a, i16 %b)
+  ret  %out
+}
+
+define  @index_rr_i32(i32 %a, i32 %b) {
+; CHECK-LABEL: index_rr_i32:
+; CHECK: index z0.s, w0, w1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv4i32(i32 %a, i32 %b)
+  ret  %out
+}
+
+define  @index_rr_i64(i64 %a, i64 %b) {
+; CHECK-LABEL: index_rr_i64:
+; CHECK: index z0.d, x0, x1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.index.nxv2i64(i64 %a, i64 %b)
+  ret  %out
+}
+
+declare 

[PATCH] D74620: [ARM,MVE] Add vector-scalar intrinsics

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki marked an inline comment as done.
miyuki added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/vaddq.c:2
 // 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
+// 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 -O1 | 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 -O1 | 
FileCheck %s

dmgreen wrote:
> Why is this running the entire -O1 pass pipeline? These tests deliberately 
> uses a limit subset to not need adjusting with every midend llvm change. (But 
> not be littered with clang's verbose ir output).
> 
> I'm guessing the half args are being a pain again. Is it something to do with 
> halfs?
Yes, with just -mem2reg I get:

```
define arm_aapcs_vfpcc <8 x half> @test_vaddq_n_f16(<8 x half> %a, float 
%b.coerce) #0 {
entry:
  %b = alloca half, align 2
  %tmp = alloca float, align 4
  store float %b.coerce, float* %tmp, align 4
  %0 = bitcast float* %tmp to i8*
  %1 = bitcast half* %b to i8*
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 2 %1, i8* align 4 %0, i32 2, 
i1 false)
  %b1 = load half, half* %b, align 2
[...]
```
SROA seems to do the trick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74620



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


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

2020-02-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3880
+ToType, From->getType(), From, Action);
+// assert(Diagnosed && "failed to diagnose bad conversion");
+(void)Diagnosed;

rjmccall wrote:
> This assertion seems important; can we make it work?
Currently DiagnoseAssignmentResult returns true only for `Incompatible` , 
However we can change it to return true for all `Incompatibel*` in C++ mode. So 
yes it should be doable.


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

https://reviews.llvm.org/D74116



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


[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

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

In D74542#1878576 , @teemperor wrote:

> @balazske Do you see any problems with this patch?


I have no opinion against the change. Probably sorting order of imported source 
locations makes not much sense (specially if recursive imports happen) and I 
can not tell what is the consequence of this, maybe no problem (there was 
something that triggered this crash, does this way of sorting order give some 
usable results?).


Repository:
  rC Clang

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

https://reviews.llvm.org/D74542



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> I totally understand if you want to make minimal changes to the code like 
> this, but it would be great to simplify it a little bit without regressing 
> too much, currently there is a knob for function locals and then another for 
> parameters in declarations, then there is an implicit conditioning for 
> function definitions.
>  I would say it would be sensible to only have IndexFunctionLocals as an 
> option and do full indexing of parameters, both in declarations and 
> definitions if it is present (assuming this doesn't result in real 
> regressions in the client code), but it is also OK to leave it as it is, 
> since the mess is beyond the scope of this patch.

removing the `shouldIndexParametersInDeclarations` seems good to me, looks like 
clangd is the only user of this flag. Regression is the concern -- as we are 
changing the behavior of libindex, and the libindex doesn't seem to have enough 
test coverage. I'd land this fix as it-is, and cleanup afterwards.

> But if you leave it as it is, I believe we'll still be missing some 
> references to decls inside default arguments in clangd, for example:
> 
> a.h:
> 
> int var = 2;
>  void foo(int x = var);
>  a.cc
> 
> void foo(int x) {
> 
>   va^r = x;
> 
> }
>  clangd won't have the reference occuring in default arg inside the index, as 
> preambles are not indexed with IndexParametersInDeclarations option turned on.

Are you talking about dynamic index? clangd doesn't record any refs in preamble 
by design -- as we skip function bodies in preamble




Comment at: clang/lib/Index/IndexDecl.cpp:102
 auto *DC = Parm->getDeclContext();
+IndexDefaultParmeterArgument(Parm, Parent);
 if (auto *FD = dyn_cast(DC)) {

kadircet wrote:
> this should move into the `else` clause down below, otherwise it would end up 
> being indexed twice
My reading to the source is that

- `IndexCtx.handleDecl(Parm)` just reports the `Parm` decl occurrence, it 
doesn't traversal the default arguments unfortunately :(
- the `if (const ParmVarDecl *Parm = dyn_cast(D))` here is only 
triggered for ObjC cases, C++ never run into this code path :(

a conservative fix is that we only need the change on Line 117. I removed the 
change in the current `if` clause.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 244935.
hokein marked 2 inline comments as done.
hokein added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -80,7 +80,6 @@
!MD->isSynthesizedAccessorStub();
   }
 
-  
   void handleDeclarator(const DeclaratorDecl *D,
 const NamedDecl *Parent = nullptr,
 bool isIBType = false) {
@@ -90,6 +89,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
@@ -106,7 +111,8 @@
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +122,7 @@
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -80,7 +80,6 @@
!MD->isSynthesizedAccessorStub();
   }
 
-  
   void handleDeclarator(const DeclaratorDecl *D,
 const NamedDecl *Parent = nullptr,
 bool isIBType = false) {
@@ -90,6 +89,12 @@
  

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

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

- Added check if size() method is const for range loops
- Optimised FixItHint creation


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,194 @@
 }
   }
 }
+
+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: 

[clang] 801627e - [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-02-17 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-02-17T15:24:04+03:00
New Revision: 801627ee490e1106380184256503dbd520c5f802

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

LOG: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

Summary:
D69169, which was necessary for running libc++ tests on remote host, got 
reverted. I couldn't think of a less invasive way to achieve this behavior but 
specify libc++abi paths in our cache file.

Reviewers: vvereschaka, aorlov, andreil99, EricWF

Reviewed By: vvereschaka

Subscribers: mgorny, kristof.beyls, ldionne, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 50957b153328..7a6af734f0de 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@ set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-02-17 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG801627ee490e: [CMake] Explicitly specify paths to libc++abi 
in CrossWinToARMLinux.cmake (authored by broadwaylamb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74347

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-02-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added a reviewer: asb.
Herald added subscribers: cfe-commits, evandro, luismarques, apazos, 
sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, 
the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, 
jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74704

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


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/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


[clang] 35367e0 - Revert "[CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake"

2020-02-17 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-02-17T16:06:30+03:00
New Revision: 35367e06b84618e21945674aa22e7cfda1957ea4

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

LOG: Revert "[CMake] Explicitly specify paths to libc++abi in 
CrossWinToARMLinux.cmake"

This reverts commit 801627ee490e1106380184256503dbd520c5f802.

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 7a6af734f0de..50957b153328 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,9 +83,6 @@ set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
-set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
-set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
-set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")



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


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

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

Add test case. This test fails with current master, see 
https://bugzilla.redhat.com/show_bug.cgi?id=1803698


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] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-02-17 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb added a comment.

Reverted this because it broke our buildbot: 
http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/4704/steps/build-llvm-project/logs/stdio.

Going to investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74347



___
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-17 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added inline comments.



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

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.


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] D74564: libclang: Add static build support for Windows

2020-02-17 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam updated this revision to Diff 244944.
cristian.adam marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74564

Files:
  clang/include/clang-c/Platform.h
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,11 +77,11 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC OR WIN32)
+if(LLVM_ENABLE_PIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
+if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
@@ -114,6 +114,7 @@
   )
 
 if(ENABLE_SHARED)
+  target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
   if(WIN32)
 set_target_properties(libclang
   PROPERTIES
Index: clang/include/clang-c/Platform.h
===
--- clang/include/clang-c/Platform.h
+++ clang/include/clang-c/Platform.h
@@ -18,14 +18,20 @@
 
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-#define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-#define CINDEX_LINKAGE __declspec(dllimport)
+/* Windows DLL import/export. */
+#ifdef _WIN32
+  #ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+  #define CINDEX_LINKAGE __declspec(dllexport)
+#else
+  #define CINDEX_LINKAGE __declspec(dllimport)
+#endif
   #endif
-#else
+#elif defined(CINDEX_EXPORTS)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif
+
+#ifndef CINDEX_LINKAGE
   #define CINDEX_LINKAGE
 #endif
 


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,11 +77,11 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC OR WIN32)
+if(LLVM_ENABLE_PIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
+if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
@@ -114,6 +114,7 @@
   )
 
 if(ENABLE_SHARED)
+  target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS)
   if(WIN32)
 set_target_properties(libclang
   PROPERTIES
Index: clang/include/clang-c/Platform.h
===
--- clang/include/clang-c/Platform.h
+++ clang/include/clang-c/Platform.h
@@ -18,14 +18,20 @@
 
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-#define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-#define CINDEX_LINKAGE __declspec(dllimport)
+/* Windows DLL import/export. */
+#ifdef _WIN32
+  #ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+  #define CINDEX_LINKAGE __declspec(dllexport)
+#else
+  #define CINDEX_LINKAGE __declspec(dllimport)
+#endif
   #endif
-#else
+#elif defined(CINDEX_EXPORTS)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif
+
+#ifndef CINDEX_LINKAGE
   #define CINDEX_LINKAGE
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d4741c4 - [ASTImporter] Added visibility check for scoped enums.

2020-02-17 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-02-17T14:34:13+01:00
New Revision: d4741c44ab45a6ab9f32d773612f1bb79854f52f

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

LOG: [ASTImporter] Added visibility check for scoped enums.

Summary:
ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.

Reviewers: martong, a.sidorin, shafik, a_sidorin, teemperor

Reviewed By: shafik, a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
clang/unittests/AST/ASTImporterVisibilityTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 49058ceaab25..8710ef06aa51 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -2578,6 +2578,7 @@ ExpectedDecl ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
 IDNS |= Decl::IDNS_Ordinary;
 
   // We may already have an enum of the same name; try to find and match it.
+  EnumDecl *PrevDecl = nullptr;
   if (!DC->isFunctionOrMethod() && SearchName) {
 SmallVector ConflictingDecls;
 auto FoundDecls =
@@ -2594,8 +2595,13 @@ ExpectedDecl ASTNodeImporter::VisitEnumDecl(EnumDecl *D) 
{
   if (auto *FoundEnum = dyn_cast(FoundDecl)) {
 if (!hasSameVisibilityContext(FoundEnum, D))
   continue;
-if (IsStructuralMatch(D, FoundEnum))
-  return Importer.MapImported(D, FoundEnum);
+if (IsStructuralMatch(D, FoundEnum)) {
+  EnumDecl *FoundDef = FoundEnum->getDefinition();
+  if (D->isThisDeclarationADefinition() && FoundDef)
+return Importer.MapImported(D, FoundDef);
+  PrevDecl = FoundEnum->getMostRecentDecl();
+  break;
+}
 ConflictingDecls.push_back(FoundDecl);
   }
 }
@@ -2623,7 +2629,7 @@ ExpectedDecl ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
   EnumDecl *D2;
   if (GetImportedOrCreateDecl(
   D2, D, Importer.getToContext(), DC, ToBeginLoc,
-  Loc, Name.getAsIdentifierInfo(), nullptr, D->isScoped(),
+  Loc, Name.getAsIdentifierInfo(), PrevDecl, D->isScoped(),
   D->isScopedUsingClassTag(), D->isFixed()))
 return D2;
 

diff  --git a/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp 
b/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
index 0f994c107340..e0c5e9407788 100644
--- a/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
+++ b/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
@@ -35,6 +35,15 @@ struct Class {
   }
 };
 
+struct EnumClass {
+  using DeclTy = EnumDecl;
+  static constexpr auto *Prototype = "enum class X;";
+  static constexpr auto *Definition = "enum class X {};";
+  BindableMatcher getPattern() {
+return enumDecl(hasName("X"), unless(isImplicit()));
+  }
+};
+
 struct Variable {
   using DeclTy = VarDecl;
   static constexpr auto *Prototype = "extern int X;";
@@ -406,6 +415,9 @@ ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Class, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
+RedeclChain, EnumClass, ,
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
@@ -426,6 +438,8 @@ ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, 
Function, ,
 
DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, ,
 
DefinitionShouldBeImportedAsADefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, EnumClass, ,
+
DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 
DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
@@ -441,6 +455,8 @@ ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, 
Function, ,
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, ,
 ImportPrototypeAfterImportedPrototype)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, EnumClass, ,
+  

[PATCH] D74554: [ASTImporter] Added visibility check for scoped enums.

2020-02-17 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4741c44ab45: [ASTImporter] Added visibility check for 
scoped enums. (authored by balazske).

Changed prior to commit:
  https://reviews.llvm.org/D74554?vs=244582&id=244951#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74554

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
  clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -69,6 +69,8 @@
 // EnumDecl:
 const auto *ExternE = "enum E {};";
 const auto *AnonE = "namespace { enum E {}; }";
+const auto *ExternEC = "enum class E;";
+const auto *AnonEC = "namespace { enum class E; }";
 // TypedefNameDecl:
 const auto *ExternTypedef = "typedef int T;";
 const auto *AnonTypedef = "namespace { typedef int T; }";
@@ -125,6 +127,7 @@
 using ImportFunctionsVisibilityChain = ImportVisibilityChain;
 using ImportVariablesVisibilityChain = ImportVisibilityChain;
 using ImportClassesVisibilityChain = ImportVisibilityChain;
+using ImportScopedEnumsVisibilityChain = ImportVisibilityChain;
 using ImportFunctionTemplatesVisibilityChain =
 ImportVisibilityChain;
 using ImportClassTemplatesVisibilityChain =
@@ -142,6 +145,10 @@
 TEST_P(ImportClassesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for scoped enums.
+TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 // Value-parameterized test for function templates.
 TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
@@ -173,6 +180,11 @@
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
 ::testing::Values(ExternC, AnonC)), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportScopedEnumsVisibilityChain,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(ExternEC, AnonEC)), );
 INSTANTIATE_TEST_CASE_P(ParameterizedTests,
 ImportFunctionTemplatesVisibilityChain,
 ::testing::Combine(DefaultTestValuesForRunOptions,
@@ -291,6 +303,7 @@
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
 using ImportEnumsVisibility = ImportVisibility;
+using ImportScopedEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
 using ImportFunctionTemplatesVisibility = ImportVisibility;
 using ImportClassTemplatesVisibility = ImportVisibility;
@@ -323,6 +336,12 @@
 TEST_P(ImportEnumsVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImportWithMerge();
 }
+TEST_P(ImportScopedEnumsVisibility, ImportAfter) {
+  TypedTest_ImportAfter();
+}
+TEST_P(ImportScopedEnumsVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 // TypedefNameDecl.
 TEST_P(ImportTypedefNameVisibility, ImportAfter) {
   TypedTest_ImportAfterWithMerge();
@@ -393,6 +412,15 @@
 std::make_tuple(AnonE, ExternE, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonE, AnonE, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportScopedEnumsVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternEC, ExternEC, ExpectLinkedDeclChain),
+std::make_tuple(ExternEC, AnonEC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonEC, ExternEC, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonEC, AnonEC, ExpectUnlinkedDeclChain))), );
+INSTANTIATE_TEST_CASE_P(
 ParameterizedTests, ImportTypedefNameVisibility,
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
Index: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
===
--- clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
+++ clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
@@ -64,6 +64,14 @@
   Language getLang() { return Lang_CXX; }
 };
 
+struct EnumClass {
+  using DeclTy = EnumDecl;
+  static constexpr auto *Definition = "enum class X { a, b };";
+  static constexpr auto *ConflictingDefinition = "enum class X { a, b, c };";
+  BindableMatcher getPattern() { return enumDecl(hasName("X")); }
+  Language getLang() { return Lang_CXX11; }
+};
+
 struct EnumConstant {
   using DeclTy = EnumConstantDecl;
   static constexpr auto *Definition = "enum E { X = 0 };";
@@ -397,6 +405,9 @@
 Enum, Liberal, ,
 ImportConflictingDefAfterDef)
 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_CASE(
+EnumClass, Liberal, ,
+ImportConflictingDefAfterDef)
+A

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

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

- Moved const size method check to matcher


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,194 @@
 }
   }
 }
+
+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 call

[PATCH] D74709: [clangd] Allow renaming class templates in cross-file rename.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kbobyrev.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

It was disabled because we don't handle explicit template
specialization well (due to the index limitation).

renaming templates is normal in practic, rather than disabling it, this patch
allows to rename them though it is not perfect (just a known limitation).

Context: https://github.com/clangd/clangd/issues/280


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74709

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -887,6 +887,23 @@
 }
   )cpp",
   },
+  {
+  // class templates.
+  R"cpp(
+template 
+class [[Foo]] {};
+// FIXME: explicit template specilizations are not supported due the
+// clangd index limitations.
+template <>
+class Foo {};
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void func() {
+  [[F^oo]] foo;
+}
+  )cpp",
+  },
   {
   // class methods.
   R"cpp(
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -184,13 +184,6 @@
   if (!Index)
 return ReasonToReject::NoIndexProvided;
 
-  // Blacklist symbols that are not supported yet in cross-file mode due to the
-  // limitations of our index.
-  // FIXME: Renaming templates requires to rename all related specializations,
-  // our index doesn't have this information.
-  if (RenameDecl.getDescribedTemplate())
-return ReasonToReject::UnsupportedSymbol;
-
   // FIXME: Renaming virtual methods requires to rename all overridens in
   // subclasses, our index doesn't have this information.
   // Note: Within-file rename does support this through the AST.


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -887,6 +887,23 @@
 }
   )cpp",
   },
+  {
+  // class templates.
+  R"cpp(
+template 
+class [[Foo]] {};
+// FIXME: explicit template specilizations are not supported due the
+// clangd index limitations.
+template <>
+class Foo {};
+  )cpp",
+  R"cpp(
+#include "foo.h"
+void func() {
+  [[F^oo]] foo;
+}
+  )cpp",
+  },
   {
   // class methods.
   R"cpp(
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -184,13 +184,6 @@
   if (!Index)
 return ReasonToReject::NoIndexProvided;
 
-  // Blacklist symbols that are not supported yet in cross-file mode due to the
-  // limitations of our index.
-  // FIXME: Renaming templates requires to rename all related specializations,
-  // our index doesn't have this information.
-  if (RenameDecl.getDescribedTemplate())
-return ReasonToReject::UnsupportedSymbol;
-
   // FIXME: Renaming virtual methods requires to rename all overridens in
   // subclasses, our index doesn't have this information.
   // Note: Within-file rename does support this through the AST.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71714: [Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

2020-02-17 Thread Ilya Mirsky via Phabricator via cfe-commits
ilya added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71714



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


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

2020-02-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

I am worried about the interaction between `-fuse-ld=lld` and linker relaxation 
(which is not supported by LLD, as I understand it)

1. clang could ignore `-fuse-ld=lld` when linker relaxation is enabled
2. clang could ignore (disable) linker relaxation if `-fuse-ld=lld` is used

At the very least, a warning of some kind should be emitted if linker 
relaxation is combined with `-fuse-ld=lld`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[PATCH] D74639: Add linkage check to ASTNodeImporter::hasSameVisibilityContext and rename to hasSameVisibilityContextAndLinkage

2020-02-17 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/lib/AST/ASTImporter.cpp:989
!Found->hasExternalFormalLinkage();
 }
 

balazske wrote:
> This would be equivalent but more clear code (formatting is probably not 
> correct here):
> ```
>   if (Found->getLinkageInternal() != From->getLinkageInternal())
> return false;
> 
>   if (From->hasExternalFormalLinkage())
> return true;
> 
>   return Importer.GetFromTU(Found) == From->getTranslationUnitDecl() &&
>  From->isInAnonymousNamespace() == Found->isInAnonymousNamespace();
> ```
Yeah, this function is not easy to follow, so this could benefit from a 
refactoring, I agree. But that is somewhat orthogonal to this change in my 
opinion.


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

https://reviews.llvm.org/D74639



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


[clang-tools-extra] 5fc5c7d - Strength reduce vectors into arrays. NFCI.

2020-02-17 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-02-17T15:37:35+01:00
New Revision: 5fc5c7db38672c8962879b6fdce68393181c5e08

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

LOG: Strength reduce vectors into arrays. NFCI.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Tooling/ArgumentsAdjusters.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
llvm/lib/Target/Mips/MicroMipsSizeReduction.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
mlir/lib/Dialect/StandardOps/Ops.cpp
mlir/lib/Dialect/VectorOps/VectorOps.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
index cd094219c50b..e00043841b99 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
@@ -16,12 +16,10 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
-static const llvm::SmallVector DeprecatedTypes = {
-{"::std::ios_base::io_state"},
-{"::std::ios_base::open_mode"},
-{"::std::ios_base::seek_dir"},
-{"::std::ios_base::streamoff"},
-{"::std::ios_base::streampos"}};
+static constexpr std::array DeprecatedTypes = {
+"::std::ios_base::io_state", "::std::ios_base::open_mode",
+"::std::ios_base::seek_dir", "::std::ios_base::streamoff",
+"::std::ios_base::streampos"};
 
 static const llvm::StringMap ReplacementTypes = {
 {"io_state", "iostate"},

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 77f48b92eb01..af9be3a1c128 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3962,19 +3962,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const 
GlobalDecl GD, unsigned BuiltinID,
 
   // Create a vector of the arguments, as well as a constant value to
   // express to the runtime the number of variadic arguments.
-  std::vector Args = {
-  Queue,  Flags, Range,
-  Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
-  ElemPtr};
-  std::vector ArgTys = {
+  llvm::Value *const Args[] = {Queue,  Flags,
+   Range,  Kernel,
+   Block,  ConstantInt::get(IntTy, NumArgs - 
4),
+   ElemPtr};
+  llvm::Type *const ArgTys[] = {
   QueueTy,  IntTy, RangeTy,   GenericVoidPtrTy,
   GenericVoidPtrTy, IntTy, ElemPtr->getType()};
 
-  llvm::FunctionType *FTy = llvm::FunctionType::get(
-  Int32Ty, llvm::ArrayRef(ArgTys), false);
-  auto Call =
-  RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Args)));
+  llvm::FunctionType *FTy = llvm::FunctionType::get(Int32Ty, ArgTys, 
false);
+  auto Call = RValue::get(
+  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), Args));
   if (TmpSize)
 EmitLifetimeEnd(TmpSize, TmpPtr);
   return Call;

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2652c05d844f..c356657541fa 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1527,7 +1527,7 @@ static void findRISCVBareMetalMultilibs(const Driver &D,
   };
   // currently only support the set of multilibs like riscv-gnu-toolchain does.
   // TODO: support MULTILIB_REUSE
-  SmallVector RISCVMultilibSet = {
+  constexpr RiscvMultilib RISCVMultilibSet[] = {
   {"rv32i", "ilp32"}, {"rv32im", "ilp32"}, {"rv32iac", "ilp32"},
   {"rv32imac", "ilp32"},  {"rv32imafc", "ilp32f"}, {"rv64imac", "lp64"},
   {"rv64imafdc", "lp64d"}};

diff  --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp 
b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index a609e4ed2469..5869377a03c9 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -26,7 +26,7 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
   return [](const CommandLineArguments &Args, StringRef /*unused*/) {
 CommandLineArguments AdjustedArgs;
 bool HasSyntaxOnly = false;
-const std::vector OutputCommands = {
+constexpr llvm::StringRef

[clang] 5fc5c7d - Strength reduce vectors into arrays. NFCI.

2020-02-17 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-02-17T15:37:35+01:00
New Revision: 5fc5c7db38672c8962879b6fdce68393181c5e08

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

LOG: Strength reduce vectors into arrays. NFCI.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Tooling/ArgumentsAdjusters.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
llvm/lib/Target/Mips/MicroMipsSizeReduction.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
mlir/lib/Dialect/StandardOps/Ops.cpp
mlir/lib/Dialect/VectorOps/VectorOps.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
index cd094219c50b..e00043841b99 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
@@ -16,12 +16,10 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
-static const llvm::SmallVector DeprecatedTypes = {
-{"::std::ios_base::io_state"},
-{"::std::ios_base::open_mode"},
-{"::std::ios_base::seek_dir"},
-{"::std::ios_base::streamoff"},
-{"::std::ios_base::streampos"}};
+static constexpr std::array DeprecatedTypes = {
+"::std::ios_base::io_state", "::std::ios_base::open_mode",
+"::std::ios_base::seek_dir", "::std::ios_base::streamoff",
+"::std::ios_base::streampos"};
 
 static const llvm::StringMap ReplacementTypes = {
 {"io_state", "iostate"},

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 77f48b92eb01..af9be3a1c128 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3962,19 +3962,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const 
GlobalDecl GD, unsigned BuiltinID,
 
   // Create a vector of the arguments, as well as a constant value to
   // express to the runtime the number of variadic arguments.
-  std::vector Args = {
-  Queue,  Flags, Range,
-  Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
-  ElemPtr};
-  std::vector ArgTys = {
+  llvm::Value *const Args[] = {Queue,  Flags,
+   Range,  Kernel,
+   Block,  ConstantInt::get(IntTy, NumArgs - 
4),
+   ElemPtr};
+  llvm::Type *const ArgTys[] = {
   QueueTy,  IntTy, RangeTy,   GenericVoidPtrTy,
   GenericVoidPtrTy, IntTy, ElemPtr->getType()};
 
-  llvm::FunctionType *FTy = llvm::FunctionType::get(
-  Int32Ty, llvm::ArrayRef(ArgTys), false);
-  auto Call =
-  RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Args)));
+  llvm::FunctionType *FTy = llvm::FunctionType::get(Int32Ty, ArgTys, 
false);
+  auto Call = RValue::get(
+  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), Args));
   if (TmpSize)
 EmitLifetimeEnd(TmpSize, TmpPtr);
   return Call;

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2652c05d844f..c356657541fa 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1527,7 +1527,7 @@ static void findRISCVBareMetalMultilibs(const Driver &D,
   };
   // currently only support the set of multilibs like riscv-gnu-toolchain does.
   // TODO: support MULTILIB_REUSE
-  SmallVector RISCVMultilibSet = {
+  constexpr RiscvMultilib RISCVMultilibSet[] = {
   {"rv32i", "ilp32"}, {"rv32im", "ilp32"}, {"rv32iac", "ilp32"},
   {"rv32imac", "ilp32"},  {"rv32imafc", "ilp32f"}, {"rv64imac", "lp64"},
   {"rv64imafdc", "lp64d"}};

diff  --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp 
b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index a609e4ed2469..5869377a03c9 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -26,7 +26,7 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
   return [](const CommandLineArguments &Args, StringRef /*unused*/) {
 CommandLineArguments AdjustedArgs;
 bool HasSyntaxOnly = false;
-const std::vector OutputCommands = {
+constexpr llvm::StringRef

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

2020-02-17 Thread James Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D74704#1878921 , @lenary wrote:

> I am worried about the interaction between `-fuse-ld=lld` and linker 
> relaxation (which is not supported by LLD, as I understand it)
>
> 1. clang could ignore `-fuse-ld=lld` when linker relaxation is enabled
> 2. clang could ignore (disable) linker relaxation if `-fuse-ld=lld` is used
>
>   At the very least, a warning of some kind should be emitted if linker 
> relaxation is combined with `-fuse-ld=lld`.


This isn't a new problem. The Linux and FreeBSD toolchains already support 
-fuse-ld=lld properly, it's just the bare metal one that didn't. People also 
generally don't include -fuse-ld=lld in CFLAGS, only LDFLAGS, and there's no 
need to include -mno-relax in LDFLAGS, so I suspect you wouldn't catch many 
issues. These days (https://reviews.llvm.org/D71820), LLD will give you an 
informative error (rather than silently mis-linking) if you forget -mno-relax.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


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

2020-02-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

In D74704#1878944 , @jrtc27 wrote:

> This isn't a new problem. The Linux and FreeBSD toolchains already support 
> -fuse-ld=lld properly, it's just the bare metal one that didn't. People also 
> generally don't include -fuse-ld=lld in CFLAGS, only LDFLAGS, and there's no 
> need to include -mno-relax in LDFLAGS, so I suspect you wouldn't catch many 
> issues. These days (https://reviews.llvm.org/D71820), LLD will give you an 
> informative error (rather than silently mis-linking) if you forget -mno-relax.


Ah, ok, I see how these parts fit together now.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


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

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 244969.
simon_tatham added a comment.

Made the new isel patterns work in big-endian as well as little. Depends on the 
extra preparatory patch D74716 .


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:vmovl

[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Looking the source code closely,  we also have another code path of indexing 
the `ParmVarDecl` in `clang/lib/Index/IndexTypeSourceInfo.cpp`,  it was called 
via `IndexCtx.indexTypeSourceInfo` in `handleDeclarator`.

In summary:

1. default arguments will be visited if this is a non-definition decl, 
regardless the shouldIndexFunctionLocatl -- this is done in IndexTypeSourceInfo
2. default arguments will be visited if this is a definition decl and 
shouldIndexFunctionLocal is fasle -- this is done in IndexDecl.
3. default arguments will not be visited if this is a definition decl and 
shouldIndexFunctionLocal is true

This patch fixes 3).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 244968.
hokein added a comment.

remove an accident change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
@@ -106,7 +112,8 @@
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +123,7 @@
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+}

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

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 244970.
simon_tatham added a comment.

Added tests to make sure the isel rules work in both big- and little-endian.


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.arm.mve.vreinterpretq.v4i32

[PATCH] D74692: [clang-tidy] Make bugprone-use-after-move ignore std::move for const values

2020-02-17 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

I've added some individual comments above, but I'd question whether it's really 
necessary to make this change? Even if no move actually happens, the code is 
still wrong (it shouldn't be using std::move in the first place), and it's 
likely the author actually intended for a move to happen, so we should warn 
that that would cause a use-after-move.




Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:408
+   unless(anyOf(inDecltypeOrTemplateArg(),
+hasType(qualType(isConstQualified())
   .bind("call-move");

Is this in the right place? It looks as if it's applying to the std::move, not 
its argument?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:137
+  // CHECK-NOTES-NOT: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES-NOT: [[@LINE-3]]:15: note: move occurred here
+}

Generally, I would avoid CHECK-NOTES-NOT if possible. Just leave off the 
comments entirely; the test will fail if there were any unexpected diagnostics, 
and the test is more resilient this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74692



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM,

just wondering though if you've tried the solution we discussed offline 
regarding updating `indexTypeSourceInfo` instead of this call site, could you 
mention the results in here?
So that the next soul that touches these lines has an idea about what's 
expecting them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



___
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-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the patch. May I know the motivation of this patch? Personally, I'd 
be conservative of exposing too many options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74689



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


[clang] dd4d093 - [ARM] Add initial support for Custom Datapath Extension (CDE)

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

Author: Mikhail Maltsev
Date: 2020-02-17T15:39:16Z
New Revision: dd4d09376209cdc5615097a5be92105f55d06f5d

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

LOG: [ARM] Add initial support for Custom Datapath Extension (CDE)

Summary:
This patch adds assembly-level support for a new Arm M-profile
architecture extension, Custom Datapath Extension (CDE).

A brief description of the extension is available at
https://developer.arm.com/architectures/instruction-sets/custom-instructions

The latest specification for CDE is currently a beta release and is
available at
https://static.docs.arm.com/ddi0607/aa/DDI0607A_a_armv8m_arm_supplement_cde.pdf

CDE allows chip vendors to add custom CPU instructions.  The CDE
instructions re-use the same encoding space as existing coprocessor
instructions (such as MRC, MCR, CDP etc.). Each coprocessor in range
cp0-cp7 can be configured as either general purpose (GCP) or custom
datapath (CDEv1).  This configuration is defined by the CPU vendor and
is provided to LLVM using 8 subtarget features: cdecp0 ... cdecp7.

The semantics of CDE instructions are implementation-defined, but the
instructions are guaranteed to be pure (that is, they are stateless,
they do not access memory or any registers except their explicit
inputs/outputs).

CDE requires the CPU to support at least Armv8.0-M mainline
architecture. CDE includes 3 sets of instructions:
* Instructions that operate on general purpose registers and NZCV
  flags
* Instructions that operate on the S or D register file (require
  either FP or MVE extension)
* Instructions that operate on the Q register file, require MVE

The user-facing names that can be specified on the command line are
the same as the 8 subtarget feature names. For example:

$ clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3

tells the compiler that the coprocessors 0 and 3 are configured as
CDEv1 and the remaining coprocessors are configured as GCP (which is
the default).

Reviewers: simon_tatham, ostannard, dmgreen, eli.friedman

Reviewed By: simon_tatham

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

Tags: #clang, #llvm

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

Added: 
clang/test/Driver/arm-cde.c
llvm/lib/Target/ARM/ARMInstrCDE.td
llvm/test/MC/ARM/cde-fp-vec.s
llvm/test/MC/ARM/cde-integer.s
llvm/test/MC/ARM/cde-vec-pred.s
llvm/test/MC/Disassembler/ARM/cde-fp-vec.txt
llvm/test/MC/Disassembler/ARM/cde-integer.txt
llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt

Modified: 
llvm/include/llvm/Support/ARMTargetParser.def
llvm/include/llvm/Support/ARMTargetParser.h
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMInstrInfo.td
llvm/lib/Target/ARM/ARMPredicates.td
llvm/lib/Target/ARM/ARMRegisterInfo.td
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h

Removed: 




diff  --git a/clang/test/Driver/arm-cde.c b/clang/test/Driver/arm-cde.c
new file mode 100644
index ..696bee46cc34
--- /dev/null
+++ b/clang/test/Driver/arm-cde.c
@@ -0,0 +1,24 @@
+// 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"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp0"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp1"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp2"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp3"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp4"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp5"
+// 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"
+// 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"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp1"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp2"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp4"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp5"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp6"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp7"

diff  --git a/llvm/include/llvm/Support/ARMTargetParser.def 
b/llvm/include/llvm/Support/ARMTargetParser.def
index 7f03d9a1320a..c3d8c894db85 100644
--- a/llvm/include

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

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.

Nice one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74336



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


[PATCH] D74044: [ARM] Add initial support for Custom Datapath Extension (CDE)

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd4d09376209: [ARM] Add initial support for Custom Datapath 
Extension (CDE) (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74044

Files:
  clang/test/Driver/arm-cde.c
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMInstrCDE.td
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/lib/Target/ARM/ARMRegisterInfo.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h
  llvm/test/MC/ARM/cde-fp-vec.s
  llvm/test/MC/ARM/cde-integer.s
  llvm/test/MC/ARM/cde-vec-pred.s
  llvm/test/MC/Disassembler/ARM/cde-fp-vec.txt
  llvm/test/MC/Disassembler/ARM/cde-integer.txt
  llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt

Index: llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt
@@ -0,0 +1,19 @@
+# RUN: llvm-mc -disassemble -triple=thumbv8m.main -mattr=+mve -mattr=+cdecp0 -mattr=+cdecp1 < %s | FileCheck %s
+
+# CHECK: vptete.i8 eq, q0, q0
+[0x41,0xfe,0x00,0xef]
+# CHECK-NEXT: vcx1t p0, q1, #1234
+[0x29,0xec,0xd2,0x20]
+# CHECK-NEXT: vcx1ae p1, q5, #4095
+[0x2f,0xfd,0xff,0xa1]
+# CHECK-NEXT: vcx2t p1, q0, q6, #123
+[0x3e,0xed,0xdc,0x01]
+# CHECK-NEXT: vcx2ae p1, q3, q7, #127
+[0x3f,0xfd,0xde,0x61]
+
+# CHECK-NEXT: vpte.i8 eq, q0, q0
+[0x41,0xfe,0x00,0x8f]
+# CHECK-NEXT: vcx3at p1, q3, q7, q6, #15
+[0xbe,0xfd,0x5c,0x61]
+# CHECK-NEXT: vcx3e p0, q0, q2, q0, #12
+[0xa4,0xed,0x40,0x00]
Index: llvm/test/MC/Disassembler/ARM/cde-integer.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/ARM/cde-integer.txt
@@ -0,0 +1,137 @@
+# RUN: not llvm-mc -disassemble -triple=thumbv8m.main -mattr=+cdecp0 -mattr=+cdecp1 < %s 2>%t | FileCheck %s
+# RUN: FileCheck <%t --check-prefix=ERROR %s
+
+# GCP instructions
+
+# CHECK: mrc p3, #1, r3, c15, c15, #5
+[0x3f,0xee,0xbf,0x33]
+# CHECK-NEXT: mcr2 p3, #2, r2, c7, c11, #7
+[0x47,0xfe,0xfb,0x23]
+
+# Predication
+
+# CHECK: itte eq
+[0x06,0xbf]
+itte eq
+# CHECK-NEXT: cx1aeq p0, r3, #8191
+[0x3f,0xfe,0xbf,0x30]
+# CHECK-NEXT: cx2aeq p0, r2, r3, #123
+[0x43,0xfe,0xbb,0x20]
+# CHECK-NEXT: cx3ane p0, r1, r5, r7, #63
+[0xf5,0xfe,0xb1,0x70]
+# CHECK-NEXT: itte eq
+[0x06,0xbf]
+# CHECK-NEXT: cx1daeq p0, r0, r1, #8191
+[0x3f,0xfe,0xff,0x00]
+# CHECK-NEXT: cx2daeq p0, r0, r1, r3, #123
+[0x43,0xfe,0xfb,0x00]
+# CHECK-NEXT: cx3dane p0, r0, r1, r5, r7, #63
+[0xf5,0xfe,0xf0,0x70]
+
+# CX1
+
+# CHECK-NEXT: cx1	p0, r3, #8191
+[0x3f,0xee,0xbf,0x30]
+# CHECK-NEXT: cx1a	p1, r2, #0
+[0x00,0xfe,0x00,0x21]
+# CHECK-NEXT: cx1d p0, r4, r5, #1234
+[0x09,0xee,0xd2,0x40]
+# CHECK-NEXT: cx1da	p1, r2, r3, #1234
+[0x09,0xfe,0xd2,0x21]
+# CHECK-NEXT: cx1	p0, apsr_nzcv, #8191
+[0x3f,0xee,0xbf,0xf0]
+
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx1 p0, sp, #8191
+[0x3f,0xee,0xbf,0xd0]
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx1d p0, r12, sp, #1234
+[0x09,0xee,0xd2,0xc0]
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx1d p0, r2, r3, #1234
+[0x09,0xee,0xd2,0x30]
+
+# CX2
+
+# CHECK-NEXT: cx2	p0, r3, r7, #0
+[0x47,0xee,0x00,0x30]
+# CHECK-NEXT: cx2a	p0, r1, r4, #511
+[0x74,0xfe,0xbf,0x10]
+# CHECK-NEXT: cx2d	p0, r2, r3, r1, #123
+[0x41,0xee,0xfb,0x20]
+# CHECK-NEXT: cx2da p0, r2, r3, r7, #123
+[0x47,0xfe,0xfb,0x20]
+# CHECK-NEXT: cx2da p1, r10, r11, apsr_nzcv, #123
+[0x4f,0xfe,0xfb,0xa1]
+
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx2a	p0, r1, sp, #511
+[0x7d,0xfe,0xbf,0x10]
+# ERROR: [[@LINE+1]]:{{[0-9]+}}: warning: invalid instruction encoding
+[0x4f,0xfe,0xfb,0xe1]
+
+# CX3
+
+# CHECK-NEXT: cx3 p0, r1, r2, r3, #0
+[0x82,0xee,0x01,0x30]
+# CHECK-NEXT: cx3a p0, r1, r5, r7, #63
+[0xf5,0xfe,0xb1,0x70]
+# CHECK-NEXT: cx3d p1, r0, r1, r7, r1, #12
+[0x97,0xee,0xc0,0x11]
+# CHECK-NEXT: cx3da p0, r8, r9, r2, r3, #12
+[0x92,0xfe,0xc8,0x30]
+# CHECK-NEXT: cx3	p1, apsr_nzcv, r7, apsr_nzcv, #12
+[0x97,0xee,0x8f,0xf1]
+# CHECK-NEXT: cx3d	p0, r8, r9, apsr_nzcv, apsr_nzcv, #12
+[0x9f,0xee,0xc8,0xf0]
+
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx3 p0, r1, r2, sp, #0
+[0x82,0xee,0x01,0xd0]
+# ERROR: [[@LINE+1]]:{{[0-9]+}}: warning: invalid instruction encoding
+[0x9f,0xee,0xce,0xf0]
+
+# VCX1
+
+# ERROR: [[@LINE+1]]:{{[0-9]+}}: warning: invalid instruc

[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D74610#1879054 , @kadircet wrote:

> LGTM,
>
> just wondering though if you've tried the solution we discussed offline 
> regarding updating `indexTypeSourceInfo` instead of this call site, could you 
> mention the results in here?
>  So that the next soul that touches these lines has an idea about what's 
> expecting them?


It seemed breaking a few existing tests...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



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


[clang-tools-extra] af8b0cd - [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-17T16:45:04+01:00
New Revision: af8b0cd58dbda773a0cbbb2a9c67559fc6a59d1d

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

LOG: [clang][Index] Visit the default parameter arguements in libindex.

Summary:
We are missing the default parmeter arguments when IndexFunctionLocals
is true.

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

Reviewers: kadircet

Subscribers: kristof.beyls, ilya-biryukov, jkorous, arphaman, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang/lib/Index/IndexDecl.cpp
clang/unittests/Index/IndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 226213979b8b..b75c218d143f 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@ TEST(FindReferences, WithinAST) {
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);

diff  --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp
index c59b1372e399..2002c695a9b1 100644
--- a/clang/lib/Index/IndexDecl.cpp
+++ b/clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@ class IndexingDeclVisitor : public 
ConstDeclVisitor {
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
@@ -106,7 +112,8 @@ class IndexingDeclVisitor : public 
ConstDeclVisitor {
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +123,7 @@ class IndexingDeclVisitor : public 
ConstDeclVisitor {
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }

diff  --git a/clang/unittests/Index/IndexTests.cpp 
b/clang/unittests/Index/IndexTests.cpp
index 068b30ebfa8a..52744e101f92 100644
--- a/clang/unittests/Index/IndexTests.cpp
+++ b/clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@ TEST(IndexTest, InjecatedNameClass) {
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang



___
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-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D74689#1879065 , @hokein wrote:

> Thanks for the patch. May I know the motivation of this patch? Personally, 
> I'd be conservative of exposing too many options.


I was using custom classes with a different naming convention which was not 
being picked up by this check. Right now this check is only good for classes 
that mimick the stl conventions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74689



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


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

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/vmovn.c:10
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> 
undef, <16 x i32> 
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x i16>
+// CHECK-NEXT:[[TMP2:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> 
[[TMP1]], <16 x i32> 

These would be vreinterpret's in bigendian?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf8b0cd58dbd: [clang][Index] Visit the default parameter 
arguements in libindex. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
@@ -106,7 +112,8 @@
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +123,7 @@
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+ 

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

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham marked an inline comment as done.
simon_tatham added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/vmovn.c:10
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> 
undef, <16 x i32> 
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x i16>
+// CHECK-NEXT:[[TMP2:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> 
[[TMP1]], <16 x i32> 

dmgreen wrote:
> These would be vreinterpret's in bigendian?
Yes – they're constructed by the `vreinterpret` record in the clang-side 
tablegen. Good point; perhaps I should expand the clang test to include a check 
of the BE output too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337



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


[PATCH] D74571: [OpenMP][CUDA] Add CUDA 10.2 support

2020-02-17 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 added a comment.

Summary

- In order to avoid the bug in PR44587 
, one needs to build with >9.0.
- With CUDA toolkit 10.2, building the trunk will fail because 10.0.0 does not 
support it yet.


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

https://reviews.llvm.org/D74571



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


[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-17 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+  const auto MacroIt = llvm::find_if(
+  PP.macros(), [&](const auto &K) { return K.first->getName() == Macro; });
+  if (MacroIt == PP.macro_end())
+return llvm::None;

Szelethus wrote:
> NoQ wrote:
> > martong wrote:
> > > Szelethus wrote:
> > > > This seems a bit clunky even for the `Preprocessor` -- how about
> > > > 
> > > > ```lang=c++
> > > > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > > > if (!MacroII)
> > > >   return;
> > > > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > > > assert(MI);
> > > > ```
> > > Ok, but we cannot assert on `MI`, because there may be cases when the 
> > > macro is not defined in a TU. In that case we should just return with 
> > > None.
> > What exactly happens when the macro is `#undef`-ined and redefined? We get 
> > the last redefinition that's valid at the end of the translation unit, 
> > right? Can we check whether there are multiple definitions and guard 
> > against that?
> Ugh, now that you say it that is a valid concern. I had to deal with that 
> back in the day: https://reviews.llvm.org/D52794?id=171962#inline-476352
Solving this does not seem easy in my opinion. To handle `#undef`s we should 
build an infrastructure where summaries can reference callable objects. This is 
necessary, because in `evalCall` the value of `EOF` would depend on the souce 
location of the call expression of the function with the summary. Not 
impossible to solve, but certainly introduces complexity. Do you think that the 
redefinition of EOF is so common? I mean maybe it is too much hassle for a very 
rare edge case (?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74720: [ASTImporter] Improved variable template redecl chain handling.

2020-02-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, teemperor, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74720

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterGenericRedeclTest.cpp

Index: clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
===
--- clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
+++ clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
@@ -74,6 +74,21 @@
   }
 };
 
+struct VariableTemplate {
+  using DeclTy = VarTemplateDecl;
+  static constexpr auto *Prototype = "template  extern T X;";
+  static constexpr auto *Definition =
+  R"(
+  template  T X;
+  template <> int X;
+  )";
+  // There is no matcher for varTemplateDecl so use a work-around.
+  BindableMatcher getPattern() {
+return namedDecl(hasName("X"), unless(isImplicit()),
+ has(templateTypeParmDecl()));
+  }
+};
+
 struct FunctionTemplateSpec {
   using DeclTy = FunctionDecl;
   static constexpr auto *Prototype =
@@ -427,6 +442,9 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
+RedeclChain, VariableTemplate, ,
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
@@ -446,6 +464,8 @@
 DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 DefinitionShouldBeImportedAsADefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -463,6 +483,8 @@
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedPrototype)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -480,6 +502,8 @@
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportDefinitionAfterImportedPrototype)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -497,6 +521,8 @@
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedDefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -513,6 +539,8 @@
 ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypes)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
 ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
@@ -529,6 +557,8 @@
 ImportDefinitions)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1468
   }
-  S.DeviceDeferredDiags.erase(It);
 

This particular change causes duplication of deferred diagnostics.
Consider the following example (please correct me if I'm doing something wrong, 
I'm not an expert in OpenMP):

```
int foobar1() { throw 1; } // error is expected here

// let's try to use foobar1 in the code where exceptions aren't allowed
#pragma omp declare target
int (*B)() = &foobar1;
#pragma omp end declare target

// and in some other place let's use foobar1 in device code again
#pragma omp declare target
int a = foobar1();
#pragma omp end declare target

```
Then diagnostic for `foobar1`  will be duplicated for each use of `foobar1` 
under `target` directive.
I first experienced this behavior not with OpenMP, so I suppose reproducer can 
be done for each programming model which uses deferred diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74721: [ARM,MVE] Add vbrsrq intrinsics family

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.
miyuki added a parent revision: D74620: [ARM,MVE] Add vector-scalar intrinsics.

This patch adds a new MVE intrinsics family, `vbrsrq`: vector bit
reverse and shift right. The intrinsics are compiled into the VBRSR
instruction. Two new LLVM IR intrinsics were also added: arm.mve.vbrsr
and arm.mve.vbrsr.predicated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74721

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

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vbrsrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vbrsrq.ll
@@ -0,0 +1,89 @@
+; 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
+
+declare <8 x half> @llvm.arm.mve.vbrsr.v8f16(<8 x half>, i32)
+declare <4 x i32> @llvm.arm.mve.vbrsr.v4i32(<4 x i32>, i32)
+declare <16 x i8> @llvm.arm.mve.vbrsr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, <16 x i1>)
+declare <8 x i16> @llvm.arm.mve.vbrsr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, i32, <8 x i1>)
+declare <4 x float> @llvm.arm.mve.vbrsr.predicated.v4f32.v4i1(<4 x float>, <4 x float>, i32, <4 x i1>)
+declare <8 x half> @llvm.arm.mve.vbrsr.predicated.v8f16.v8i1(<8 x half>, <8 x half>, i32, <8 x i1>)
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32)
+
+define arm_aapcs_vfpcc <4 x i32> @test_vbrsrq_n_u32(<4 x i32> %a, i32 %b) {
+; CHECK-LABEL: test_vbrsrq_n_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vbrsr.32 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <4 x i32> @llvm.arm.mve.vbrsr.v4i32(<4 x i32> %a, i32 %b)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x half> @test_vbrsrq_n_f16(<8 x half> %a, i32 %b) {
+; CHECK-LABEL: test_vbrsrq_n_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vbrsr.16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <8 x half> @llvm.arm.mve.vbrsr.v8f16(<8 x half> %a, i32 %b)
+  ret <8 x half> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vbrsrq_m_n_s8(<16 x i8> %inactive, <16 x i8> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_m_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = call <16 x i8> @llvm.arm.mve.vbrsr.predicated.v16i8.v16i1(<16 x i8> %inactive, <16 x i8> %a, i32 %b, <16 x i1> %1)
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vbrsrq_m_n_f32(<4 x float> %inactive, <4 x float> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_m_n_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <4 x float> @llvm.arm.mve.vbrsr.predicated.v4f32.v4i1(<4 x float> %inactive, <4 x float> %a, i32 %b, <4 x i1> %1)
+  ret <4 x float> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vbrsrq_x_n_u16(<8 x i16> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_x_n_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = call <8 x i16> @llvm.arm.mve.vbrsr.predicated.v8i16.v8i1(<8 x i16> undef, <8 x i16> %a, i32 %b, <8 x i1> %1)
+  ret <8 x i16> %2
+}
+
+define arm_aapcs_vfpcc <8 x half> @test_vbrsrq_x_n_f16(<8 x half> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_x_n_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = call <8 x half> @llvm.arm.mve.vbrsr.predicated.v8f16.v8i1(<8 x half> undef, <8 x half> %a, i32 %b, <8 x i1> %1)
+  ret <8 x half> %2
+}
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -4760,6 +4760,20 @@
 def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
 def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
 
+multiclass

[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

2020-02-17 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+  const auto MacroIt = llvm::find_if(
+  PP.macros(), [&](const auto &K) { return K.first->getName() == Macro; });
+  if (MacroIt == PP.macro_end())
+return llvm::None;

martong wrote:
> Szelethus wrote:
> > NoQ wrote:
> > > martong wrote:
> > > > Szelethus wrote:
> > > > > This seems a bit clunky even for the `Preprocessor` -- how about
> > > > > 
> > > > > ```lang=c++
> > > > > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > > > > if (!MacroII)
> > > > >   return;
> > > > > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > > > > assert(MI);
> > > > > ```
> > > > Ok, but we cannot assert on `MI`, because there may be cases when the 
> > > > macro is not defined in a TU. In that case we should just return with 
> > > > None.
> > > What exactly happens when the macro is `#undef`-ined and redefined? We 
> > > get the last redefinition that's valid at the end of the translation 
> > > unit, right? Can we check whether there are multiple definitions and 
> > > guard against that?
> > Ugh, now that you say it that is a valid concern. I had to deal with that 
> > back in the day: https://reviews.llvm.org/D52794?id=171962#inline-476352
> Solving this does not seem easy in my opinion. To handle `#undef`s we should 
> build an infrastructure where summaries can reference callable objects. This 
> is necessary, because in `evalCall` the value of `EOF` would depend on the 
> souce location of the call expression of the function with the summary. Not 
> impossible to solve, but certainly introduces complexity. Do you think that 
> the redefinition of EOF is so common? I mean maybe it is too much hassle for 
> a very rare edge case (?).
The standard library (libc or libc++) should define EOF consitently in stdio.h.
Now, if the application redefines the value of EOF then the code could be 
broken, or at least it would not be compatible with libc. Consider the 
following code that is perfectly legit if we don't redefine EOF, but if we do:
```
#include 
#include 
#define EOF -2 // Here be dragons !!!
int main(void)
{
FILE* fp = fopen("test.txt", "r");
int c;
while ((c = fgetc(fp)) != EOF) { // BOOM: Infinite loop !!!
   putchar(c);
}
fclose(fp);
}
```
So, redefinition of EOF (or any standard macro) results in broken code.
And this is also a warning:
```
) clang eof-inf.c
eof-inf.c:3:9: warning: 'EOF' macro redefined [-Wmacro-redefined]
#define EOF -2 // Here be dragons !!!
^
/usr/include/x86_64-linux-gnu/bits/libio.h:66:10: note: previous definition is 
here
# define EOF (-1)
 ^
1 warning generated.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D60225: [clang-format] [PR19056] Add support for indenting class members and methods one level under the modifiers

2020-02-17 Thread Denis Rouzaud via Phabricator via cfe-commits
3nids added a comment.

Hi there, is there anything we can do to help this to go through?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60225



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


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

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 244984.
simon_tatham added a comment.

Test on the clang side in both endiannesses.


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.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %a)
+  %1 = shu

[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-17 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

+ @rjmccall


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227



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


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

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337



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


[clang-tools-extra] 351ed50 - Reland "[clang-tools-extra] fix the check for if '-latomic' is necessary""

2020-02-17 Thread Luís Marques via cfe-commits

Author: Gokturk Yuksek
Date: 2020-02-17T16:53:29Z
New Revision: 351ed50dcb2a67a88213ef67469f70bd5e2b4a60

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

LOG: Reland "[clang-tools-extra] fix the check for if '-latomic' is necessary""

The buildbot failures on MSVC should have been fixed by f128f442a3d.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index e3eccb50a496..fc5a07e69e9d 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -30,7 +30,7 @@ if(CLANG_BUILT_STANDALONE)
 endif()
 
 set(CLANGD_ATOMIC_LIB "")
-if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
   list(APPEND CLANGD_ATOMIC_LIB "atomic")
 endif()
 



___
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-17 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: rsandifo-arm, rovka, rjmccall, efriedma.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, 
kristof.beyls, tschuett.
Herald added projects: clang, LLVM.

This patch adds codegen support for the ACLE builtin types added in:

  https://reviews.llvm.org/D62960

so that the ACLE builtin types are emitted as corresponding scalable
vector types in LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74724

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

Index: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
===
--- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -226,7 +226,8 @@
   if (FrameIndices.find(&AI) != FrameIndices.end())
 return FrameIndices[&AI];
 
-  uint64_t ElementSize = DL->getTypeAllocSize(AI.getAllocatedType());
+  uint64_t ElementSize =
+  DL->getTypeAllocSize(AI.getAllocatedType()).getKnownMinSize();
   uint64_t Size =
   ElementSize * cast(AI.getArraySize())->getZExtValue();
 
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
@@ -377,6 +377,48 @@
   return ResultType;
 }
 
+static llvm::Type *getSVEType(ASTContext &Ctx, llvm::LLVMContext &LLVMCtx,
+  BuiltinType::Kind K) {
+  switch (K) {
+  case BuiltinType::SveInt8:
+  case BuiltinType::SveUint8:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 8),
+ {16, true});
+  case BuiltinType::SveInt16:
+  case BuiltinType::SveUint16:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 16),
+ {8, true});
+  case BuiltinType::SveInt32:
+  case BuiltinType::SveUint32:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 32),
+ {4, true});
+  case BuiltinType::SveInt64:
+  case BuiltinType::SveUint64:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 64),
+ {2, true});
+  case BuiltinType::SveFloat16:
+return llvm::VectorType::get(
+getTypeForFormat(LLVMCtx, Ctx.getFloatTypeSemantics(Ctx.HalfTy),
+ /* UseNativeHalf = */ true),
+{8, true});

[PATCH] D74044: [ARM] Add initial support for Custom Datapath Extension (CDE)

2020-02-17 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/test/Driver/arm-cde.c:12
+
+// 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"

Probably good to add a test for v8.1-M too, and also with MVE



Comment at: llvm/lib/Target/ARM/ARMInstrCDE.td:1
+// Immediate operand of arbitrary bit width
+class BitWidthImmOperand

This file needs the copyright header



Comment at: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp:8161
+  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:

clang-format this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74044



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


[PATCH] D68578: [HIP] Fix device stub name

2020-02-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 244988.
yaxunl added a comment.
Herald added a subscriber: kerbowa.

Revised by John's comments. Introduced HIPKernelType for GlobalDecl so that we 
can use GlobalDecl to
represent stub and kernel during host compilation. Revised mangler so that 
GlobalDecl carrying
pertinent information can be passed through.


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

https://reviews.llvm.org/D68578

Files:
  clang/include/clang/AST/GlobalDecl.h
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  clang/test/CodeGenCUDA/kernel-stub-name.cu
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- clang/test/CodeGenCUDA/unnamed-types.cu
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -36,4 +36,4 @@
   }(p);
 }
 // HOST: @__hip_register_globals
-// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
+// HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -6,15 +6,50 @@
 
 #include "Inputs/cuda.h"
 
+extern "C" __global__ void ckernel() {}
+
+namespace ns {
+__global__ void nskernel() {}
+} // namespace ns
+
 template
 __global__ void kernelfunc() {}
 
+__global__ void kernel_decl();
+
+// Device side kernel names
+
+// CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
+// CHECK: @[[NSKERN:[0-9]*]] = {{.*}} c"_ZN2ns8nskernelEv\00"
+// CHECK: @[[TKERN:[0-9]*]] = {{.*}} c"_Z10kernelfuncIiEvv\00"
+
+// Non-template kernel stub functions
+
+// CHECK: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK: define{{.*}}@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[NSSTUB]]
+
 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
-// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
-void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+// CHECK: call void @[[CSTUB]]()
+// CHECK: call void @[[NSSTUB]]()
+// CHECK: call void @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]]()
+// CHECK: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
+void hostfunc(void) {
+  ckernel<<<1, 1>>>();
+  ns::nskernel<<<1, 1>>>();
+  kernelfunc<<<1, 1>>>();
+  kernel_decl<<<1, 1>>>();
+}
+
+// Template kernel stub functions
+
+// CHECK: define{{.*}}@[[TSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[TSTUB]]
 
-// CHECK: define{{.*}}@[[STUB]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+// CHECK: declare{{.*}}@[[DSTUB]]
 
 // CHECK-LABEL: define{{.*}}@__hip_register_globals
-// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[CSTUB]]{{.*}}@[[CKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[NSSTUB]]{{.*}}@[[NSKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[TSTUB]]{{.*}}@[[TKERN]]
Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -13,19 +13,19 @@
 // HOST-NOT: %struct.T.coerce
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce)
-// HOST: define void @_Z7kernel1Pi.stub(i32* %x)
+// HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
 __global__ void kernel1(int *x) {
   x[0]++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel2Ri(i32 addrspace(1)* dereferenceable(4) %x.coerce)
-// HOST: define void @_Z7kernel2Ri.stub(i32* dereferenceable(4) %x)
+// HOST: define void @_Z22__device_stub__kernel2Ri(i32* dereferenceable(4) %x)
 __global__ void kernel2(int &x) {
   x++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
-// HOST: define void @_Z7kernel3PU3AS2iPU3AS1i.stub(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
+// HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
 __global__ void kernel3(__attribute__((address_space(2))) int *x,
 __attribute__((address_space(1))) int *y) {
   y[0] = x[0];
@@ -43,7 +43,7 @@
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
 // CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
-// HOST: define void @_Z7kernel41S.stub(i32* %s.coerce0, float* %s.coerce1)
+// HOST: define void @_Z22__device_s

[PATCH] D74620: [ARM,MVE] Add vector-scalar intrinsics

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:4566
+  0b0, VTI.Unsigned>;
+  defvar unpred_op = !if(VTI.Unsigned, unpred_op_u, unpred_op_s);
+  defm : MVE_vec_scalar_int_pat_m(NAME), VTI,

dmgreen wrote:
> I find all these if's at different levels a little hard to follow. It looks 
> OK, but is it possible to rearrange things to not need it here?
I meant trying to remove this `defvar unpred_op = !if(` line. I think it's 
always going to be a bit difficult to follow whatever we do here though (or we 
end up repeating ourselves a lot), so you can ignore this one :)


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

https://reviews.llvm.org/D74620



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


[PATCH] D74669: [clang-tidy] New check: misc-no-include-cpp

2020-02-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 244994.
jroelofs added a comment.

Implement review feedback re: DiagLoc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with .cpp extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:10: warning: suspicious #include of file with .c extension
+#import "c.c"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include of file with .c extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with .cc extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with .cxx extension
+#  include  
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
@@ -0,0 +1,39 @@
+//===--- SuspiciousIncludeCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Warns on inclusion of files whose names suggest that they're implementation
+/// files, instead of headers. E.g:
+///
+/// #include "foo.cpp"  // warning
+/// #include "bar.c"// warning
+/// #include "baz.h"// no diagnostic
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-include.html
+class SuspiciousIncludeCheck : public ClangTidyCheck {
+public:
+  SuspiciousIncludeCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -0,0 +1,75 @@
+//===--- SuspiciousIncludeCheck.cpp - clang-tidy --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "SuspiciousIncludeCheck.h"
+#include "clang/AST/ASTContext.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+namespace {
+class SuspiciousIncludePPCallbacks : public PPCallbacks {
+public:
+  explicit SuspiciousIncludePPCallbacks(ClangTidyCheck &Check,
+const SourceManager &SM,
+Preprocessor *PP)
+  : Check(Check), PP(PP) {}
+
+  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+  

[PATCH] D74669: [clang-tidy] New check: misc-no-include-cpp

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



Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:59
+Optional File = PP->LookupFile(
+HashLoc /* FIXME: lies */, (FileName + RE).str(), IsAngled, 
nullptr,
+nullptr, CurDir, nullptr, nullptr, nullptr, nullptr, nullptr);

njames93 wrote:
> jroelofs wrote:
> > FIXME: is this a reasonable `SourceLocation` to give to `LookupFile`?
> Main thing is to make sure that the same location is used for the warnings 
> and the notes.
> I personally found this the most pleasing diagnostics
> 
> ```
> SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);
> ```
> 
> ```
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  warning: suspicious #include of file with .cpp extension 
> [bugprone-suspicious-include]
> #include "a.cpp"
>   ^
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  note: did you mean to include 'a'?
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  note: did you mean to include 'a.h'?
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  note: did you mean to include 'a.hpp'?
> ```
I don't have much experience with modules to lean on for intuition on what this 
check should do with them. I've added a test to codify what the pass currently 
does in that case, but if there's something better it should be trying when 
searching for suggestions, let's make it do that instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D74044: [ARM] Add initial support for Custom Datapath Extension (CDE)

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

@SjoerdMeijer, thanks for the heads up. Will fix in a followup patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74044



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


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

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



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3880
+ToType, From->getType(), From, Action);
+// assert(Diagnosed && "failed to diagnose bad conversion");
+(void)Diagnosed;

Anastasia wrote:
> rjmccall wrote:
> > This assertion seems important; can we make it work?
> Currently DiagnoseAssignmentResult returns true only for `Incompatible` , 
> However we can change it to return true for all `Incompatibel*` in C++ mode. 
> So yes it should be doable.
Okay.  My guess is it should return true whenever we emit an error rather than 
a warning (ignoring the effects of things like `-Werror`, of course).


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

https://reviews.llvm.org/D74116



___
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-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

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.


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] D73835: [IRBuilder] Virtualize IRBuilder

2020-02-17 Thread Nikita Popov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3eaa53e80543: Reapply "[IRBuilder] Virtualize 
IRBuilder" (authored by nikic).

Changed prior to commit:
  https://reviews.llvm.org/D73835?vs=244871&id=245004#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73835

Files:
  clang/lib/CodeGen/CGBuilder.h
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/IRBuilderFolder.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  polly/include/polly/CodeGen/IRBuilder.h

Index: polly/include/polly/CodeGen/IRBuilder.h
===
--- polly/include/polly/CodeGen/IRBuilder.h
+++ polly/include/polly/CodeGen/IRBuilder.h
@@ -131,15 +131,14 @@
 ///
 /// This is used to add additional items such as e.g. the llvm.loop.parallel
 /// metadata.
-class IRInserter : protected llvm::IRBuilderDefaultInserter {
+class IRInserter final : public llvm::IRBuilderDefaultInserter {
 public:
   IRInserter() = default;
   IRInserter(class ScopAnnotator &A) : Annotator(&A) {}
 
-protected:
   void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
 llvm::BasicBlock *BB,
-llvm::BasicBlock::iterator InsertPt) const {
+llvm::BasicBlock::iterator InsertPt) const override {
 llvm::IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt);
 if (Annotator)
   Annotator->annotate(I);
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -129,7 +129,7 @@
 
 /// A custom IRBuilder inserter which prefixes all names, but only in
 /// Assert builds.
-class IRBuilderPrefixedInserter : public IRBuilderDefaultInserter {
+class IRBuilderPrefixedInserter final : public IRBuilderDefaultInserter {
   std::string Prefix;
 
   const Twine getNameWithPrefix(const Twine &Name) const {
@@ -139,9 +139,8 @@
 public:
   void SetNamePrefix(const Twine &P) { Prefix = P.str(); }
 
-protected:
   void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB,
-BasicBlock::iterator InsertPt) const {
+BasicBlock::iterator InsertPt) const override {
 IRBuilderDefaultInserter::InsertHelper(I, getNameWithPrefix(Name), BB,
InsertPt);
   }
@@ -2368,7 +2367,8 @@
 Instruction *OldUserI = cast(OldUse->getUser());
 IRB.SetInsertPoint(OldUserI);
 IRB.SetCurrentDebugLocation(OldUserI->getDebugLoc());
-IRB.SetNamePrefix(Twine(NewAI.getName()) + "." + Twine(BeginOffset) + ".");
+IRB.getInserter().SetNamePrefix(
+Twine(NewAI.getName()) + "." + Twine(BeginOffset) + ".");
 
 CanSROA &= visit(cast(OldUse->getUser()));
 if (VecTy || IntTy)
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -24,6 +24,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Operator.h"
+#include "llvm/IR/NoFolder.h"
 #include "llvm/IR/Statepoint.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
@@ -784,3 +785,9 @@
   Function *Fn = Intrinsic::getDeclaration(M, ID, Types);
   return createCallHelper(Fn, Args, this, Name, FMFSource);
 }
+
+IRBuilderDefaultInserter::~IRBuilderDefaultInserter() {}
+IRBuilderCallbackInserter::~IRBuilderCallbackInserter() {}
+IRBuilderFolder::~IRBuilderFolder() {}
+void ConstantFolder::anchor() {}
+void NoFolder::anchor() {}
Index: llvm/lib/Analysis/ConstantFolding.cpp
===
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -23,6 +23,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/TargetFolder.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Analysis/VectorUtils.h"
@@ -2660,3 +2661,5 @@
 
   return false;
 }
+
+void TargetFolder::anchor() {}
Index: llvm/include/llvm/IR/NoFolder.h
===
--- llvm/include/llvm/IR/NoFolder.h
+++ llvm/include/llvm/IR/NoFolder.h
@@ -26,11 +26,14 @@
 #include "llvm/IR/InstrTypes.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
+#include "llvm/IR/IRBuilderFolder.h"
 
 namespace llvm {
 
 /// NoFolder - Create "constants" (actually, instructions) with no folding.
-class NoFolder {
+class NoFolder final : public IRBuilderFolder {
+  virtual void anchor();
+
 public:
   explicit NoFo

[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng created this revision.
AnakinZheng added reviewers: kadircet, sammccall.
AnakinZheng added a project: clang.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.

Previously this piece of code asserts when processing extended ASCII. Proposing 
a fix to extend the ascii handling code to take extended ascii as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74731

Files:
  clang-tools-extra/clangd/SourceCode.cpp


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -59,7 +59,7 @@
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -59,7 +59,7 @@
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;
___
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-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: SjoerdMeijer, simon_tatham, dmgreen.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

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


Repository:
  rG LLVM Github Monorepo

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;
-as

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1468
   }
-  S.DeviceDeferredDiags.erase(It);
 

Fznamznon wrote:
> This particular change causes duplication of deferred diagnostics.
> Consider the following example (please correct me if I'm doing something 
> wrong, I'm not an expert in OpenMP):
> 
> ```
> int foobar1() { throw 1; } // error is expected here
> 
> // let's try to use foobar1 in the code where exceptions aren't allowed
> #pragma omp declare target
> int (*B)() = &foobar1;
> #pragma omp end declare target
> 
> // and in some other place let's use foobar1 in device code again
> #pragma omp declare target
> int a = foobar1();
> #pragma omp end declare target
> 
> ```
> Then diagnostic for `foobar1`  will be duplicated for each use of `foobar1` 
> under `target` directive.
> I first experienced this behavior not with OpenMP, so I suppose reproducer 
> can be done for each programming model which uses deferred diagnostics.
The change is intentional so that each call chain causing the diagnostic can be 
identified. The drawback is that it is more verbose.

I can change this behavior so that the diagnostic will be emitted only for the 
first call chain that causes the diagnostic, if less verbose diagnostics is 
preferred.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


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

2020-02-17 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 245014.
fghanim marked 2 inline comments as done.
fghanim added a comment.

Fixed bug where variables where still being allocated in original function 
entry block


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,110 @@
 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::JumpDest FinilizationBlock;
+  CodeGenFunction &CGF;
+
+public:
+  InlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP,
+llvm::BasicBlock &FiniBB)
+  : CGF(c

[PATCH] D73835: [IRBuilder] Virtualize IRBuilder

2020-02-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

This broke the LLVM_ENABLE_MODULES build because it introduces a cyclic 
dependency between LLVM_IR and LLVM_intrinsic_gen:

  FAILED: 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o
 
  
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/lld/lib/ReaderWriter/MachO 
-I/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO 
-I/Users/teemperor/1llvm/llvm-project/lld/include -Itools/lld/include 
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/libxml2
 -Iinclude -I/Users/teemperor/1llvm/llvm-project/llvm/include 
-I/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/. -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -fmodules 
-fmodules-cache-path=/Users/teemperor/1llvm/rel/module.cache -fcxx-modules 
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -O3  
-isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
-fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o
 -MF 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o.d
 -o 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o
 -c 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
  While building module 'LLVM_Object' imported from 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:
  While building module 'LLVM_IR' imported from 
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/Object/IRSymtab.h:29:
  While building module 'LLVM_intrinsic_gen' imported from 
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/IR/IRBuilderFolder.h:18:
  In file included from :1:
  /Users/teemperor/1llvm/llvm-project/llvm/include/llvm/IR/Argument.h:19:10: 
fatal error: cyclic dependency in module 'LLVM_IR': LLVM_IR -> 
LLVM_intrinsic_gen -> LLVM_IR
  #include "llvm/IR/Value.h"
   ^
  While building module 'LLVM_Object' imported from 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:
  While building module 'LLVM_IR' imported from 
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/Object/IRSymtab.h:29:
  In file included from :13:
  
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/IR/IRBuilderFolder.h:18:10:
 fatal error: could not build module 'LLVM_intrinsic_gen'
  #include "llvm/IR/InstrTypes.h"
   ^~
  While building module 'LLVM_Object' imported from 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:
  In file included from :4:
  
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/Object/IRSymtab.h:29:10: 
fatal error: could not build module 'LLVM_IR'
  #include "llvm/IR/GlobalValue.h"
   ^~~
  
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:10:
 fatal error: could not build module 'LLVM_Object'
  #include "llvm/Object/MachO.h"
   ^
  4 errors generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73835



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


[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D74542#1878732 , @balazske wrote:

> In D74542#1878576 , @teemperor wrote:
>
> > @balazske Do you see any problems with this patch?
>
>
> I have no opinion against the change. Probably sorting order of imported 
> source locations makes not much sense (specially if recursive imports happen) 
> and I can not tell what is the consequence of this, maybe no problem (there 
> was something that triggered this crash, does this way of sorting order give 
> some usable results?).


Before this patch we would get a Clang crash in 
`SourceManager::isBeforeInTranslationUnit` when emitting diagnostics that cover 
multiple (main) files. With this patch we get a normal diagnostic. The order of 
the `note:` messages is in the order in which they were encountered by LLDB but 
that is fine as long as the order is deterministic (I also don't see a very 
logical order in which they should be ordered and we're fine as long as the 
order is deterministic).


Repository:
  rC Clang

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

https://reviews.llvm.org/D74542



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


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

2020-02-17 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Regarding the third comment (which was removed for some reason), This new 
update should fix that




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3134
 
 // TODO: Replace with a generic helper function for emitting body
 auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,

jdoerfert wrote:
> These TODOs are now obsolete ;)
We need to split our patches to keep them small :p



Comment at: clang/lib/CodeGen/CodeGenFunction.h:354
+
+FinilizationBlock = CGF.getJumpDestInCurrentScope(&FiniBB);
+  }

jdoerfert wrote:
> Don't we have to set/reset the `CGF.ReturnBlock` ? If not, why do we need 
> `FinilizationBlock` here?
Yes, and we still do for outlined regions (check `OutlinedRegionBodyRAII` ctor 
above). 

This is for inlined regions, and those shouldn't change the `CGF.ReturnBlock`. 
It should re-use the `CGF.ReturnBlock` for the enclosing outlined region.
The only reason I kept it, is because `CGF.getJumpDestInCurrentScope()` was 
updating a counter that seemed to me to relate to `EHStack`, and I didn't want 
to remove it without investigating first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74562



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Jacques Pienaar via Phabricator via cfe-commits
jpienaar added a comment.

This seems to result in triggering clang/lib/CodeGen/CGExpr.cpp:2626 when 
compiling mlir/lib/Transforms/AffineDataCopyGeneration.cpp with clang build 
with assertions on (clean build at e8e078c 
 just 
before this change, broken at this, assert triggering at build fix commit).

https://buildkite.com/mlir/mlir-core/builds/2792#a54fb239-718b-4f0b-a309-f83e46ceb252


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74734: [AArch64][SVE] Add the SVE dupq_lane intrinsic

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

Implements the @llvm.aarch64.sve.dupq.lane intrinsic.

As specified in the ACLE, the behaviour of:

  svdupq_lane_u64(data, index)

...is identical to:

  svtbl(data, svadd_x(svptrue_b64(),
   svand_x(svptrue_b64(), svindex_u64(0, 1), 1),
   index * 2))

If the index is in the range [0,3], the operation is equivalent
to a single DUP (.q) instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74734

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -297,6 +297,179 @@
 }
 
 ;
+; DUPQ
+;
+
+define  @dupq_i8( %a) {
+; CHECK-LABEL: dupq_i8:
+; CHECK: mov z0.q, q0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %a, i64 0)
+  ret  %out
+}
+
+define  @dupq_i16( %a) {
+; CHECK-LABEL: dupq_i16:
+; CHECK: mov z0.q, z0.q[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %a, i64 1)
+  ret  %out
+}
+
+define  @dupq_i32( %a) {
+; CHECK-LABEL: dupq_i32:
+; CHECK: mov z0.q, z0.q[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %a, i64 2)
+  ret  %out
+}
+
+define  @dupq_i64( %a) {
+; CHECK-LABEL: dupq_i64:
+; CHECK: mov z0.q, z0.q[3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %a, i64 3)
+  ret  %out
+}
+
+define  @dupq_f16( %a) {
+; CHECK-LABEL: dupq_f16:
+; CHECK: mov z0.q, q0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8f16( %a, i64 0)
+  ret  %out
+}
+
+define  @dupq_f32( %a) {
+; CHECK-LABEL: dupq_f32:
+; CHECK: mov z0.q, z0.q[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4f32( %a, i64 1)
+  ret  %out
+}
+
+define  @dupq_f64( %a) {
+; CHECK-LABEL: dupq_f64:
+; CHECK: mov z0.q, z0.q[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2f64( %a, i64 2)
+  ret  %out
+}
+
+;
+; DUPQ_LANE
+;
+
+define  @dupq_lane_i8( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i8:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK-NEXT: tbl   z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i16( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i16:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i32( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i32:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i64( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i64:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_f16( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_f16:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z

[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

`C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74731



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


[PATCH] D74387: [SYCL] Do not diagnose use of __float128

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

In D74387#1874612 , @Fznamznon wrote:

> > In D74387#1869845 , @rjmccall 
> > wrote:
> > 
> >> The right approach here is probably what we do in ObjC ARC when we see 
> >> types that are illegal in ARC: in system headers, we allow the code but 
> >> add a special `UnavailableAttr` to the declaration so that it can't be 
> >> directly used.
> >>
> >> That is straightforward enough that I think you should just do it instead 
> >> of leaving this as technical debt.
> > 
> > 
> > I haven't considered something like this, because I'm not familiar with 
> > ObjC at all... I will give it a try, thanks.
>
> Hi @rjmccall , I assume, I took a look at this. 
>  Let's imagine, I will try to diagnose `__float128` type using already 
> implemented functionality. It seems like I need to call something like
>
>   S.DelayedDiagnostics.add(
>   sema::DelayedDiagnostic::makeForbiddenType(loc,  
>   diag::err_type_unsupported, type, "__float128"));
>   `
>
> right?
>  I suppose, then this diagnostic will be saved and emitted inside function 
> named `handleDelayedForbiddenType`.
>  Here it checks that this forbidden type is actually allowed and emits a 
> diagnostic if it's not.


This isn't quite right.  The goal here is to delay the diagnostic *twice*.  The 
first delay is between the point where we parse/process the type (i.e. 
SemaType) and the point where we've fully processed the declaration that the 
type is part of (i.e. SemaDecl).  That's the point where we call 
`handleDelayedForbiddenType`, and you're right that it's too early to know 
whether the declaration is really device code.  However, you're missing 
something important about how `handleDelayedForbiddenType` works: it's never 
really trying to suppress the diagnostic completely, but just to delay it for 
certain declarations until the point that the declaration is actually used, 
under the hope that in fact it will never be used and everything will work out. 
 For ARC, we chose to delay for all declarations in system headers, under the 
assumption that (1) system headers will never introduce functions that have to 
be emitted eagerly, and (2) we always want to warn people about problematic 
code in their own headers.  Those choices don't really fit SYCL's use case, and 
you should change the logic in `isForbiddenTypeAllowed` to delay your 
diagnostic for essentially all declarations (except kernels?), since 
effectively all non-kernel code in device mode is lazily emitted.  But if you 
do that, it should combine well with CUDA/OMP deferred diagnostics:

- If `foo` uses `__float128` (whether in its signature or internally), that is 
invalid in device mode, but the diagnostic will be delayed by the 
forbidden-type mechanism, meaning that it will become an `unavailable` 
attribute on `foo`.
- If `bar` uses `foo`, that use is invalid in device mode (because of the 
`unavailable` attribute), but the diagnostic will be delayed via the standard 
CUDA/OMP mechanism because we don't know yet whether `bar` should be emitted as 
a device function.
- If `kernel` uses `bar`, that will trigger the emission of the delayed 
diagnostics of `bar`, including the use-of-`unavailable`-function diagnostic 
where it uses `foo`.  It should be straightforward to specialize this 
diagnostic so that it reports the error by actually diagnosing the use of 
`__float128` at the original location (which is recorded in the `unavailable` 
attribute) and then just adding a note about how `foo` is used by `bar`.

> It seems that the second problem is the same problem which prevented me from 
> implementing diagnosing of `__float128` type through CUDA/OMP deferred 
> diagnostics (I mentioned my attempt in the last comment 
> https://reviews.llvm.org/D74387#1870014). I still need to find best place for 
> diagnostic issuing. It seems that there are so many places where type can 
> actually be introduced to resulting LLVM IR module, and in some of them I 
> need to check some additional conditions to do not prevent `__float128` usage 
> when it actually doesn't introduce forbidden type to resulting LLVM IR module.

The key thing here is that all uses should be associated with some top-level 
declaration that's either eagerly-emitted in device mode or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387



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


[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

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



Comment at: clang/lib/Parse/ParseTentative.cpp:798
+if (Tok.is(tok::l_square)) {
+  ConsumeBracket();
+  if (!SkipUntil(tok::r_square))

Do you want to check for double-brackets here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



___
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-17 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

Ping.


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] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, rnkovacs, Szelethus, 
baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, martong, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, kristof.beyls.
Herald added a project: clang.

`CXXInheritedCtorInitExpr` shows up when code looks roughly like this:

  struct A {
A(int x) { ... }
  };
  
  struct B {
using A::A;  // !!
  };

The AST for the autogenerated constructor for `B` looks like this:

  `-CXXConstructorDecl implicit used A 'void (int)' inline
|-ParmVarDecl implicit 'int'
|-CXXCtorInitializer 'A'
| `-CXXInheritedCtorInitExpr 'A'  // !!
`-CompoundStmt

So far we've been dropping coverage every time we've encountered 
`CXXInheritedCtorInitExpr`. This patch attempts to add some support for it.

The AST is rather annoying to work with. `CXXInheritedCtorInitExpr` is not 
related to `CXXConstructExpr`, so it requires a new `CallEvent` sub-class in 
order to capture its semantics properly.

There are also no argument expressions, even though the inherited constructor 
for `A` takes one argument `x`. The current patch takes argument expressions 
from the topmost `CXXConstructExpr`, which also requires a different location 
context to access. As far as i can see, the result of such substitution is 
always correct, i.e., the resulting argument `SVal` obtained from the 
Environment this way will always be `evalBinOp`-equal to the correct argument 
value. I'm still not sure it's a great long-term solution; it might be better 
to outright forbid calling `getArgExpr()` and `getNumArgs()` on a 
`CXXInheritedConstructorCall`.

Another piece of work that needs to be done (probably in follow-up patches) is 
supporting argument constructors in the `CXXInheritedCtorInitExpr`; the last 
test shows that it's not quite working. It's also going to be very annoying 
because the construct-expressions for such arguments are also not present in 
the AST. So this is going to be yet another kind of `CallEvent`s that don't 
correspond to any `Expr` (the previous such case being destructors that aren't 
invoked manually).


Repository:
  rC Clang

https://reviews.llvm.org/D74735

Files:
  clang/include/clang/Analysis/ConstructionContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp

Index: clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
===
--- /dev/null
+++ clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(bool);
+
+namespace basic_tests {
+struct A {
+  int x;
+  A(int x): x(x) {}
+};
+
+struct B : A {
+  using A::A;
+};
+
+struct C : B {
+  using B::B;
+};
+
+void test_B() {
+  B b(1);
+  clang_analyzer_eval(b.x == 1); // expected-warning{{TRUE}}
+}
+
+void test_C() {
+  C c(2);
+  clang_analyzer_eval(c.x == 2); // expected-warning{{TRUE}}
+}
+} // namespace basic_tests
+
+namespace arguments_with_constructors {
+struct S {
+  int x, y;
+  S(int x, int y): x(x), y(y) {}
+  ~S() {}
+};
+
+struct A {
+  S s;
+  int z;
+  A(S s, int z) : s(s), z(z) {}
+};
+
+struct B : A {
+  using A::A;
+};
+
+void test_B() {
+  B b(S(1, 2), 3);
+  // FIXME: There should be no execution path on which this is false.
+  clang_analyzer_eval(b.s.x == 1); // expected-warning{{TRUE}}
+   // expected-warning@-1{{FALSE}}
+
+  // FIXME: There should be no execution path on which this is false.
+  clang_analyzer_eval(b.s.y == 2); // expected-warning{{TRUE}}
+   // expected-warning@-1{{FALSE}}
+
+  clang_analyzer_eval(b.z == 3); // expected-warning{{TRUE}}
+}
+} // namespace arguments_with_constructors
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -542,6 +542,11 @@
 if (!Loc)
   return true;
 
+// Anonymous parameters of an inheriting constructor are live for the entire
+// duration of the constructor.
+if (isa(Loc))
+  return true;
+
 if (LCtx->getAnalysis()->isLive(Loc, VR->getDecl()))
   return true;
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -668,8 +668,8 @@

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

2020-02-17 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CodeGenTypes.cpp:559
 #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);
-  break;
+  ResultType = getSVEType(getContext(), getLLVMContext(),
+  cast(Ty)->getKind());

Is there a reason to make getSVEType a separate function, as opposed to just 
writing out the cases inline?

Also, we can probably get rid of the "cannot yet generate code for SVE type" 
error?



Comment at: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:230
+  uint64_t ElementSize =
+  DL->getTypeAllocSize(AI.getAllocatedType()).getKnownMinSize();
   uint64_t Size =

Please submit this separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74724



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


RE: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Liu, Yaxun (Sam) via cfe-commits
[AMD Official Use Only - Internal Distribution Only]

I am taking a look. Thanks.

Sam

-Original Message-
From: Jacques Pienaar via Phabricator  
Sent: Monday, February 17, 2020 10:58 AM
To: Liu, Yaxun (Sam) ; t...@google.com; rjmcc...@gmail.com; 
rich...@metafoo.co.uk; jdoerf...@anl.gov; a.bat...@hotmail.com
Cc: jpien...@google.com; mask...@google.com; michael.hl...@gmail.com; 
mariya.podchishcha...@intel.com; alexey.ba...@intel.com; 
zhang.guans...@gmail.com; her...@google.com; r...@google.com; 
cfe-commits@lists.llvm.org; mlek...@skidmore.edu; blitzrak...@gmail.com; 
shen...@google.com
Subject: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a 
post-parsing AST travese

[CAUTION: External Email]

jpienaar added a comment.

This seems to result in triggering clang/lib/CodeGen/CGExpr.cpp:2626 when 
compiling mlir/lib/Transforms/AffineDataCopyGeneration.cpp with clang build 
with assertions on (clean build at e8e078c 

 just before this change, broken at this, assert triggering at build fix 
commit).

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbuildkite.com%2Fmlir%2Fmlir-core%2Fbuilds%2F2792%23a54fb239-718b-4f0b-a309-f83e46ceb252&data=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872&sdata=nma5u9l5h6tkzQEX0hVfYe6VJQBXubt%2FCOF%2BWyWSujM%3D&reserved=0


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172%2Fnew%2F&data=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872&sdata=yGGqSBdf6zVYW7IDFW57UEagQAyvaOfn2a8xu%2BaIr9o%3D&reserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172&data=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872&sdata=sbHpgiR9tKyv0%2F4ZnuhUX%2BFaIHdtwoHTyOJxX1%2F46mg%3D&reserved=0


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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Yeah I think there must be some confusion about what this code is doing. It's 
specifically iterating over the unicode codepoints of what are supposed to be 
UTF-8-encoded input bytes.

The input turns out sometimes not to be UTF-8 (e.g. the file on disk is 
ISO-8859-1 and clang thinks it's UTF-8 and just loads the bytes). We can't give 
any sort of right answer in these cases - we don't know the actual encoding and 
we can't even always detect these cases!

What we can do is strengthen the contract: instead of UB, assert in practice, 
we can say returns some garbage value but doesn't crash.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74361: [Clang] Uninitialize attribute on global variables

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

I'm not sure if it's a good idea to be re-using the existing attribute like 
this.  It's not that unreasonable, I guess, but I'd like to hear JF's thoughts.

I think you do need to update the documentation to mention the impact on 
globals.  For normal targets (i.e. ones with loaders), I assume this guarantees 
a zero pattern.  Except maybe not for thread-locals?  Do we have any targets 
where we can actually optimize thread-locals by suppressing initialization?

This will need to impact static analysis and the AST, I think.  Local variables 
can't be redeclared, but global variables can, so disallowing initializers 
syntactically when the attribute is present doesn't necessarily stop other 
declarations from defining the variable.  Also, you need to make the attribute 
mark something as a definition, the same way that e.g. the alias attribute 
does.  Also, this probably ought to disable the default-initialization of 
non-trivial types in C++, in case that's not already done.




Comment at: clang/test/Sema/attr-uninitialized.c:9
   int im_bad __attribute((uninitialized("zero")));  // expected-error 
{{'uninitialized' attribute takes no arguments}}
-  static int im_baaad __attribute((uninitialized)); // expected-warning 
{{'uninitialized' attribute only applies to local variables}}
 }
 

In general, you shouldn't remove the existing test lines; just modify them to 
not report a diagnostic.



Comment at: clang/test/Sema/attr-uninitialized.c:12
+void answer_right_now() __attribute((uninitialized)) {}
// expected-warning {{'uninitialized' attribute only applies to variables}}
+void just_to_tell_you_once_again(__attribute((uninitialized)) int whos_bad) {}
 

This should still be diagnosed; it doesn't make any sense to apply this to 
parameters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng updated this revision to Diff 245021.
AnakinZheng added a comment.

Fix the previous stupid mistake.


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

https://reviews.llvm.org/D74731

Files:
  clang-tools-extra/clangd/SourceCode.cpp


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -58,8 +58,8 @@
   // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
-unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
+unsigned short C = static_cast(U8[I]);
+if (LLVM_LIKELY(C <= 255)) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -58,8 +58,8 @@
   // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
-unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
+unsigned short C = static_cast(U8[I]);
+if (LLVM_LIKELY(C <= 255)) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng marked an inline comment as done.
AnakinZheng added a comment.

Update patch.




Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

kadircet wrote:
> `C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.
Updated the patch, now it should be correct.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74692: [clang-tidy] Make bugprone-use-after-move ignore std::move for const values

2020-02-17 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In D74692#1879039 , @mboehme wrote:

> Even if no move actually happens, the code is still wrong


IMHO, it's not wrong, but it's inefficient. And will be reported by 
performance-move-const-arg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74692



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Specifically, we can't change the return value for any valid utf-8 string (see 
tests).

Instead, where we currently assert length is between 2 and 4, you could change 
that to an if and treat it (arbitrarily) as a one-utf-8-byte, 
one-utf-16-code-unit character.

This new behavior should have a test.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

AnakinZheng wrote:
> kadircet wrote:
> > `C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.
> Updated the patch, now it should be correct.
sorry but this is still the same since `C` is an `unsigned char` it is always 
guaranteed to be less than or equal to 255.

As @sammccall explained above, we should rather re-arrange the logic to get rid 
of the assertion below, e.g. when `UTF8Length` is less than 2 or more than 4 we 
can choose to interpret it as ascii, instead of asserting, while commenting the 
reason for this choice.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng marked an inline comment as done.
AnakinZheng added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

kadircet wrote:
> AnakinZheng wrote:
> > kadircet wrote:
> > > `C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.
> > Updated the patch, now it should be correct.
> sorry but this is still the same since `C` is an `unsigned char` it is always 
> guaranteed to be less than or equal to 255.
> 
> As @sammccall explained above, we should rather re-arrange the logic to get 
> rid of the assertion below, e.g. when `UTF8Length` is less than 2 or more 
> than 4 we can choose to interpret it as ascii, instead of asserting, while 
> commenting the reason for this choice.
It's unsigned short in the new patch. Ok, I'll try @sammccall 's suggestion.


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

https://reviews.llvm.org/D74731



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


  1   2   >