[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-05-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D74051#2016078 , @mgorny wrote:

> This broke running clang tests stand-alone:
>
>   Traceback (most recent call last):
> File 
> "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang-abi_x86_64.amd64/bin/../../llvm/utils/lit/lit/TestingConfig.py",
>  line 89, in load_from_path
>   exec(compile(data, path, 'exec'), cfg_globals, None)
> File 
> "/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang/test/utils/update_cc_test_checks/lit.local.cfg",
>  line 21, in 
>   assert os.path.isfile(script_path)
>   AssertionError
> 
>   FAILED: test/CMakeFiles/check-clang
>  
>
>
> Obviously this fails when LLVM source tree is not available.


Is that a supported build mode for clang?

> If this is used only in clang, the script should be moved to clang as well.

I was under impression that it is exactly what this change did.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


LLVM lab network works on May 2nd at 11:00 am PDT

2020-05-01 Thread Galina Kistanova via cfe-commits
Hello everyone,


LLVM buildmaster will be unavailable tomorrow on Saturday, May 2nd at
11:00AM PDT due to network maintenance works.

Hopefully this will take about half hour.


Thank you for understanding.


Thanks


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


[PATCH] D79232: [analyzer] Refactor range inference for symbolic expressions

2020-05-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a subscriber: steakhal.
NoQ added a comment.

Very nice, i like this architecture.

@baloghadamsoftware @steakhal @ASDenysPetrov will you be able to plug D49074 
/D50256 
/D77792 
/D77802 
/D78933  into 
this so that to separate algebra from pattern-matching and ensure no 
performance regressions? Or is something still missing?




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:271-281
+  RangeSet VisitSymIntExpr(const SymIntExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }
+
+  RangeSet VisitIntSymExpr(const IntSymExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }

Can we replace these three with a single `VisitBinarySymExpr()`? Or is there 
too much template duck typing involved?



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:340-345
+// TODO #2: We didn't go into the nested expressions before, so it
+// might cause us spending much more time doing the inference.
+// This can be a problem for deeply nested expressions that are
+// involved in conditions and get tested continuously.  We definitely
+// need to address this issue and introduce some sort of caching
+// in here.

I think this is a must-have, at least in some form. We've been exploding like 
this before on real-world code, well, probably not with bitwise ops but i'm 
still worried.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79232



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


[PATCH] D74051: Move update_cc_test_checks.py tests to clang

2020-05-01 Thread Michał Górny via Phabricator via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

This broke running clang tests stand-alone:

  Traceback (most recent call last):
File 
"/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang-abi_x86_64.amd64/bin/../../llvm/utils/lit/lit/TestingConfig.py",
 line 89, in load_from_path
  exec(compile(data, path, 'exec'), cfg_globals, None)
File 
"/var/tmp/portage/sys-devel/clang-11.0.0./work/x/y/clang/test/utils/update_cc_test_checks/lit.local.cfg",
 line 21, in 
  assert os.path.isfile(script_path)
  AssertionError
 
  FAILED: test/CMakeFiles/check-clang

Obviously this fails when LLVM source tree is not available. If this is used 
only in clang, the script should be moved to clang as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74051



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


[PATCH] D79118: Implement _ExtInt ABI for all ABIs in Clang, enable type for ABIs

2020-05-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

A little cavalier with `byval`; I gave it a thorough audit, but you might want 
your own pass.




Comment at: clang/lib/CodeGen/ABIInfo.h:107
+// only difference is that this considers _ExtInt as well.
+bool isPromotableIntegerType(QualType Ty) const;
+

Maybe add a "ForABI" suffix here so that it's clearer that this is a 
specialized use-case.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:719
+ !getContext().getTargetInfo().hasInt128Type()))
+  return getNaturalAlignIndirect(Ty);
+

It's very weird for 64 and 128 to be showing up as constants in the default ABI 
rule.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1537
+  return (isPromotableIntegerType(RetTy) ? ABIArgInfo::getExtend(RetTy)
+ : ABIArgInfo::getDirect());
 }

Won't this treat literally all ExtInt types as either extend or direct?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4938
+if (EIT->getNumBits() > 128)
+  return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
+

Does this need to consider the aggregate-as-array logic below?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:5014
+if (EIT->getNumBits() > 128)
+  return getNaturalAlignIndirect(RetTy, /*ByVal=*/true);
+

`byval` is not legal on return values.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:6339
+  if (EIT->getNumBits() > 64)
+return getNaturalAlignIndirect(RetTy, /*ByVal=*/true);
+

`byval` is not legal on return types.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:6658
 /// Checks if the type is unsupported directly by the current target.
 static bool isUnsupportedType(ASTContext &Context, QualType T) {
   if (!Context.getTargetInfo().hasFloat16Type() && T->isFloat16Type())

Ugh.  Please go ahead and rename this to make it clear that it's an NVPTX 
helper function.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7921
+if (Size > 64 && RetTy->isExtIntType())
+  return getNaturalAlignIndirect(RetTy, /*ByVal=*/true);
+

`byval` is not legal on a return.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8988
 
-  uint64_t Size = getContext().getTypeSize(Ty);
+  uint64_t Size = getContext().getIntWidth(Ty);
 

Why this change?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:10297
+   EIT->getNumBits() > 64))
+return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
+}

Looks like this shouldn't be `byval`.


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

https://reviews.llvm.org/D79118



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


[PATCH] D72281: [Matrix] Add matrix type to Clang.

2020-05-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/TypeNodes.td:73
 def ExtVectorType : TypeNode;
+def MatrixType : TypeNode;
 def FunctionType : TypeNode;

I think some parts of your life might be easier if there were a common base 
class here.  You can either call the abstract superclass something like 
`AbstractMatrixType`, or you can call it `MatrixType` and then make this the 
concrete subclass `ConstantMatrixType`.

This is something we've occasionally regretted with vector types.



Comment at: clang/lib/AST/ASTContext.cpp:3840
+ RowExpr, ColumnExpr, AttrLoc);
+  } else {
+QualType CanonicalMatrixElementType = getCanonicalType(MatrixElementType);

Is this logic copied from the dependent vector code?  It's actually wrong in a 
sense — it'll end up creating a non-canonical matrix type wrapping Canon even 
if all the components are exactly the same.  Probably the only impact is that 
we waste a little memory, although it's also possible that type-printing in 
diagnostics will be a little weird.  It'd be better to recognize that the 
components match Canon exactly and avoid creating a redundant node.

Please cache the result of calling `getCanonicalType(MatrixElementType)` above.



Comment at: clang/lib/AST/ASTContext.cpp:3848
+  assert(!CanonCheck && "Dependent-sized matrix canonical type broken");
+  (void)CanonCheck;
+  DependentSizedMatrixTypes.InsertNode(New, InsertPos);

Please do this in an `#ifndef NDEBUG`.



Comment at: clang/lib/AST/ItaniumMangle.cpp:3349
+void CXXNameMangler::mangleType(const MatrixType *T) {
+  Out << "Dm" << T->getNumRows() << "_" << T->getNumColumns() << '_';
+  mangleType(T->getElementType());

fhahn wrote:
> rjmccall wrote:
> > fhahn wrote:
> > > rjmccall wrote:
> > > > You need to ask the Itanium C++ ABI for this mangling, since it's not 
> > > > using a vendor-extension prefix.  I know that wasn't done for vector 
> > > > types, but we're trying to do the right thing.
> > > That basically means reaching out to 
> > > https://github.com/itanium-cxx-abi/cxx-abi/, right?
> > > 
> > > Do you think it would be feasible to initially go with a 
> > > vendor-extensions mangling (like 
> > > `uMatrixxx`)? I've updated the 
> > > mangling to this.
> > Yeah, you can open an issue there.
> > 
> > That approach doesn't quite work because mangling the element type can use 
> > or introduce substitutions, but the demangler will naturally skip the whole 
> > thing.  I think there are two possible approaches here: we could either 
> > treat the entire matrix type as a vendor-extended qualifier on the element 
> > type (i.e. `U11matrix_typeILi3ELi4EEi`), or we could extend the 
> > vendor-extended type mangling to allow template-args (i.e. 
> > `u11matrix_typeIiLi3ELi4EE`).  The latter is probably better and should fit 
> > cleanly into the mangling grammar.
> Thanks for those suggestions. For now I went with the vendor-extended 
> qualifier, because IIUC that would fit in the existing mangling scheme 
> without any changes, while the second option would require changes to the 
> grammar, right?
> 
Yes, but it's a very modest change; please raise this with the Itanium 
committee (which is largely just me again, but wearing a different hat).

In the meantime, the qualifier approach is fine as a hack, but it's not 
technically correct unless you do annoying things with the mangling of 
actually-qualified matrix types.  But the proper qualifier approach is to 
provide the arguments as template-arguments, not one big unstructured string.

Also you should do the same thing with DependentSizedMatrixType.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:2071
+MatrixArg->getElementType(), Info, Deduced, TDF);
+  }
+  // Matrix-Matrix deduction.

This should just fail with `TDK_NonDeducedMismatch`, like a ConstantArrayType 
would if the argument was a DependentSizedArrayType.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:2109
+if (!RowExprTemplateParam || !ColumnExprTemplateParam)
+  return Sema::TDK_Success;
+

You should just do this right.  If you can find a template parameter in the 
parameter's row/column expression, you have to try to deduce it, and 
short-circuit if that fails.  Deduction is order-agnostic, so don't worry about 
that.

Also, you need to handle DependentSizedMatrixTypes here in order to get 
function template partial ordering right.  Pattern the code on how 
DependentSizedArrayTypes would handle it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72281



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cg

[clang] f3a3db8 - Add the missing '='. NFC.

2020-05-01 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-05-02T01:07:44-04:00
New Revision: f3a3db8627e9fa673fa413a2e41fe5443db7c6c3

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

LOG: Add the missing '='. NFC.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 7456e6d5fb48..96e0bd2276fa 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1471,7 +1471,7 @@ void UnwrappedLineParser::parseStructuralElement() {
   } else if (Style.Language == FormatStyle::LK_Proto &&
  FormatTok->Tok.is(tok::less)) {
 nextToken();
-parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum*/false,
+parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false,
 /*ClosingBraceKind=*/tok::greater);
   }
   break;
@@ -1824,7 +1824,7 @@ bool UnwrappedLineParser::parseBracedList(bool 
ContinueOnSemicolons,
 case tok::less:
   if (Style.Language == FormatStyle::LK_Proto) {
 nextToken();
-parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum*/false,
+parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false,
 /*ClosingBraceKind=*/tok::greater);
   } else {
 nextToken();



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


[PATCH] D79279: Allow volatile parameters to __builtin_mem{cpy,move,set}

2020-05-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Most of the complexity of this patch is introduced by the decision to 
type-check these calls with a volatile-typed parameter, which seems like it 
does nothing but cause problems.  If your goal is to make these functions do 
the right thing when given arbitrary pointer types, I think you need to give 
these calls special type-checking semantics.  Done right, that will also let 
you e.g. accept pointers into arbitrary address spaces.  But I'm not sure how 
good of an idea this actually is at base, since these builtins are typically 
used for direct calls to their associated library functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D79236: [docs] Regenerate DiagnosticsReference.rst

2020-05-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

There's no good reason for this file to exist; documenting the warning options 
is useful, but the file should be generated as an intermediate output of the 
documentation build and then ultimately fed into Sphinx.

There's even a TODO in the docs about it:

> TODO: Generate this from tblgen. Define one anchor per warning group.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79236



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


[PATCH] D78969: [clang][OpenMP] Fix getNDSWDS for aarch64.

2020-05-01 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 261610.
fpetrogalli added a comment.

I have added (indirect) testing of the values of NDS and WDS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78969

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

Index: clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c
===
--- /dev/null
+++ clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve  -fopenmp  -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve  -fopenmp-simd -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+// Note: -fopemp and -fopenmp-simd behavior are expected to be the same.
+
+// This test checks the values of Widest Data Size (WDS), as defined
+// in https://github.com/ARM-software/abi-aa/tree/master/vfabia64
+//
+// WDS is used to check the accepted values  of `simdlen()` when
+// targeting fixed-length SVE vector function names. The values of
+// `` that are accepted are such that for X = WDS *  * 8,
+// 128-bit <= X <= 2048-bit and X is a multiple of 128-bit.
+
+#pragma omp declare simd simdlen(8)
+#pragma omp declare simd simdlen(16)
+#pragma omp declare simd simdlen(256)
+#pragma omp declare simd simdlen(272)
+char WDS_is_sizeof_char(char in);
+// WDS = 1, simdlen(8) and simdlen(272) are not generated.
+// CHECK-DAG: _ZGVsM16v_WDS_is_sizeof_char
+// CHECK-DAG: _ZGVsM256v_WDS_is_sizeof_char
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_char
+
+#pragma omp declare simd simdlen(4)
+#pragma omp declare simd simdlen(8)
+#pragma omp declare simd simdlen(128)
+#pragma omp declare simd simdlen(136)
+char WDS_is_sizeof_short(short in);
+// WDS = 2, simdlen(4) and simdlen(136) are not generated.
+// CHECK-DAG: _ZGVsM8v_WDS_is_sizeof_short
+// CHECK-DAG: _ZGVsM128v_WDS_is_sizeof_short
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_short
+
+#pragma omp declare simd linear(sin) notinbranch simdlen(2)
+#pragma omp declare simd linear(sin) notinbranch simdlen(4)
+#pragma omp declare simd linear(sin) notinbranch simdlen(64)
+#pragma omp declare simd linear(sin) notinbranch simdlen(68)
+void WDS_is_sizeof_float_pointee(float in, float *sin);
+// WDS = 4, simdlen(2) and simdlen(68) are not generated.
+// CHECK-DAG: _ZGVsM4vl4_WDS_is_sizeof_float_pointee
+// CHECK-DAG: _ZGVsM64vl4_WDS_is_sizeof_float_pointee
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_float_pointee
+
+#pragma omp declare simd linear(sin) notinbranch simdlen(2)
+#pragma omp declare simd linear(sin) notinbranch simdlen(4)
+#pragma omp declare simd linear(sin) notinbranch simdlen(32)
+#pragma omp declare simd linear(sin) notinbranch simdlen(34)
+void WDS_is_sizeof_double_pointee(float in, double *sin);
+// WDS = 8 because of the linear clause, simdlen(34) is not generated.
+// CHECK-DAG: _ZGVsM2vl8_WDS_is_sizeof_double_pointee
+// CHECK-DAG: _ZGVsM4vl8_WDS_is_sizeof_double_pointee
+// CHECK-DAG: _ZGVsM32vl8_WDS_is_sizeof_double_pointee
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_double_pointee
+
+#pragma omp declare simd simdlen(2)
+#pragma omp declare simd simdlen(4)
+#pragma omp declare simd simdlen(32)
+#pragma omp declare simd simdlen(34)
+double WDS_is_sizeof_double(double in);
+// WDS = 8, simdlen(34) is not generated.
+// CHECK-DAG: _ZGVsM2v_WDS_is_sizeof_double
+// CHECK-DAG: _ZGVsM4v_WDS_is_sizeof_double
+// CHECK-DAG: _ZGVsM32v_WDS_is_sizeof_double
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_double
+
+static char C;
+static short S;
+static float F;
+static double D;
+
+void do_something() {
+  C = WDS_is_sizeof_char(C);
+  C = WDS_is_sizeof_short(S);
+  WDS_is_sizeof_float_pointee(F, &F);
+  WDS_is_sizeof_double_pointee(F, &D);
+  D = WDS_is_sizeof_double(D);
+}
Index: clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c
===
--- /dev/null
+++ clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp  -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp-simd -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+// Note: -fopemp and -fopenmp-simd behavior are expected to be the same.
+
+// This test checks the values of Narrowest Data Size (NDS), as defined in
+// https://github.com/ARM-software/abi-aa/tree/master/vfabia64
+//
+// NDS is used to compute the  token in the name of AdvSIMD
+// vector functions when no `simdlen` is specified, with the rule:
+//
+// if NDS(f) = 1, then VLEN = 16, 8;
+// if NDS(f) = 2, then VLEN = 8, 4;
+// if NDS(f) = 4, t

[PATCH] D78969: [clang][OpenMP] Fix getNDSWDS for aarch64.

2020-05-01 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 261611.
fpetrogalli added a comment.

Removed single use variable definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78969

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

Index: clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c
===
--- /dev/null
+++ clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve  -fopenmp  -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve  -fopenmp-simd -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+// Note: -fopemp and -fopenmp-simd behavior are expected to be the same.
+
+// This test checks the values of Widest Data Size (WDS), as defined
+// in https://github.com/ARM-software/abi-aa/tree/master/vfabia64
+//
+// WDS is used to check the accepted values  of `simdlen()` when
+// targeting fixed-length SVE vector function names. The values of
+// `` that are accepted are such that for X = WDS *  * 8,
+// 128-bit <= X <= 2048-bit and X is a multiple of 128-bit.
+
+#pragma omp declare simd simdlen(8)
+#pragma omp declare simd simdlen(16)
+#pragma omp declare simd simdlen(256)
+#pragma omp declare simd simdlen(272)
+char WDS_is_sizeof_char(char in);
+// WDS = 1, simdlen(8) and simdlen(272) are not generated.
+// CHECK-DAG: _ZGVsM16v_WDS_is_sizeof_char
+// CHECK-DAG: _ZGVsM256v_WDS_is_sizeof_char
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_char
+
+#pragma omp declare simd simdlen(4)
+#pragma omp declare simd simdlen(8)
+#pragma omp declare simd simdlen(128)
+#pragma omp declare simd simdlen(136)
+char WDS_is_sizeof_short(short in);
+// WDS = 2, simdlen(4) and simdlen(136) are not generated.
+// CHECK-DAG: _ZGVsM8v_WDS_is_sizeof_short
+// CHECK-DAG: _ZGVsM128v_WDS_is_sizeof_short
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_short
+
+#pragma omp declare simd linear(sin) notinbranch simdlen(2)
+#pragma omp declare simd linear(sin) notinbranch simdlen(4)
+#pragma omp declare simd linear(sin) notinbranch simdlen(64)
+#pragma omp declare simd linear(sin) notinbranch simdlen(68)
+void WDS_is_sizeof_float_pointee(float in, float *sin);
+// WDS = 4, simdlen(2) and simdlen(68) are not generated.
+// CHECK-DAG: _ZGVsM4vl4_WDS_is_sizeof_float_pointee
+// CHECK-DAG: _ZGVsM64vl4_WDS_is_sizeof_float_pointee
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_float_pointee
+
+#pragma omp declare simd linear(sin) notinbranch simdlen(2)
+#pragma omp declare simd linear(sin) notinbranch simdlen(4)
+#pragma omp declare simd linear(sin) notinbranch simdlen(32)
+#pragma omp declare simd linear(sin) notinbranch simdlen(34)
+void WDS_is_sizeof_double_pointee(float in, double *sin);
+// WDS = 8 because of the linear clause, simdlen(34) is not generated.
+// CHECK-DAG: _ZGVsM2vl8_WDS_is_sizeof_double_pointee
+// CHECK-DAG: _ZGVsM4vl8_WDS_is_sizeof_double_pointee
+// CHECK-DAG: _ZGVsM32vl8_WDS_is_sizeof_double_pointee
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_double_pointee
+
+#pragma omp declare simd simdlen(2)
+#pragma omp declare simd simdlen(4)
+#pragma omp declare simd simdlen(32)
+#pragma omp declare simd simdlen(34)
+double WDS_is_sizeof_double(double in);
+// WDS = 8, simdlen(34) is not generated.
+// CHECK-DAG: _ZGVsM2v_WDS_is_sizeof_double
+// CHECK-DAG: _ZGVsM4v_WDS_is_sizeof_double
+// CHECK-DAG: _ZGVsM32v_WDS_is_sizeof_double
+// CHECK-NOT: _ZGV{{.*}}_WDS_is_sizeof_double
+
+static char C;
+static short S;
+static float F;
+static double D;
+
+void do_something() {
+  C = WDS_is_sizeof_char(C);
+  C = WDS_is_sizeof_short(S);
+  WDS_is_sizeof_float_pointee(F, &F);
+  WDS_is_sizeof_double_pointee(F, &D);
+  D = WDS_is_sizeof_double(D);
+}
Index: clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c
===
--- /dev/null
+++ clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp  -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp-simd -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+// Note: -fopemp and -fopenmp-simd behavior are expected to be the same.
+
+// This test checks the values of Narrowest Data Size (NDS), as defined in
+// https://github.com/ARM-software/abi-aa/tree/master/vfabia64
+//
+// NDS is used to compute the  token in the name of AdvSIMD
+// vector functions when no `simdlen` is specified, with the rule:
+//
+// if NDS(f) = 1, then VLEN = 16, 8;
+// if NDS(f) = 2, then VLEN = 8, 4;
+// if NDS(f) = 4, then VLEN = 4, 2;
+// i

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

2020-05-01 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 261602.
Xiangling_L added a comment.
Herald added a reviewer: aaron.ballman.

Fix a minor issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,55 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
 struct test {
   test();
   ~test();
 } t;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd, i8* null }]
+// CHECK: define dso_local void @__cxx_global_var_init() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__dtor_t() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*) #3
+
+// CHECK: define dso_local void @__cxx_global_var_destruct_t() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t)
+// CHECK:   %guard.hasSrterm = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasSrterm, label %destruct.check, label %destruct.end
+
+// CHECK: destruct.check:
+// CHECK:   call void @__dtor_t()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*) #3
+
+// CHECK: define dso_local void @__sinit8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_b2e4830f1c9d2d063e5ea946868f3bfd() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-priority-attribute.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s 2>&1 | \
+// RUN: FileCheck %s
+
+int foo() __attribute__((constructor(180)));
+int bar() __attribute__((destructor(180)));
+
+class test {
+   int a;
+public:
+test(int c) {a = c;}
+~test() {a = 0;}
+};
+
+__attribute__ ((init_priority (2000)))
+test t(1);
+
+// CHECK: warning: 'constructor' attribute argument not supported:
+// CHECK: int foo() __attribute__((constructor(180)));
+
+// CHECK: warning: 'destructor' attribute argument not supported:
+// check: int bar() __attribute__((destructor(180)));
+
+// CHECK: warning: 'init_priority' attribute argument not supported:
+// CHECK: __attribute__ ((init_priority (2000)))
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6895,13 +6895,19 @@
 handlePassObjectSizeAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Constructor:
-handleConstructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << "";
+else
+  handleConstructorAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Deprecated:
 handleDeprecatedAttr(S, D, AL);
 break;
   case ParsedAttr::AT_Destructor:
-handleDestructorAttr(S, D, AL);
+if (S.Context.getTargetInfo().getTriple().isOSAIX())
+  S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << 

[PATCH] D79087: [SVE][Codegen] Lower legal min & max operations

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

LGTM


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

https://reviews.llvm.org/D79087



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


[PATCH] D76689: [Sema][SVE] Fix handling of initialisers for built-in SVE types

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76689



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


[PATCH] D77982: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally

2020-05-01 Thread Ten Tzen via Phabricator via cfe-commits
tentzen added a reviewer: asl.
tentzen added a comment.

Hi, Anton,
I found you are the Code Owner of "Exception handling, Windows CodeGen, ARM 
EABI".
could you please provide a quick review here? thanks,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77982



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


[PATCH] D78750: [SveEmitter] Add builtins for svdupq and svdupq_lane

2020-05-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8054
+
+Value *Alloca = Builder.CreateAlloca(EltTy, Builder.getInt32(NumOpnds));
+for (unsigned I = 0; I < NumOpnds; ++I)

Please use something like `CreateTempAlloca(llvm::ArrayType::get(EltTy, 
NumOpnds), CharUnits::fromQuantity(16))`.

(In particular, the way you've written it, the code allocates stack memory 
dynamically.  Might want to add a test with some control flow to demonstrate 
that you're putting the alloca into the entry block.)



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8058
+  IsBoolTy ? Builder.CreateZExt(Ops[I], EltTy) : Ops[I],
+  Builder.CreateGEP(Alloca, Builder.getInt32(I)));
+

Builder.getInt64().



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c:257
+  // CHECK: %[[BASE:.*]] = getelementptr inbounds [4 x float], [4 x float]* 
%[[ALLOCA]], i64 0, i64 0
+  // CHECK: store float %x0, float* %[[BASE]]
+  // 

Please CHECK the alignment of all these operations.


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

https://reviews.llvm.org/D78750



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


[PATCH] D79279: Allow volatile parameters to __builtin_mem{cpy,move,set}

2020-05-01 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
Herald added subscribers: cfe-commits, ributzka, dexonsmith, jkorous, 
JDevlieghere.
Herald added a project: clang.

These builtins are often used (or should be used) in places where time-of-check
time-of-use security issues are important (e.g. copying from untrusted buffers).
They don't accept volatile pointee parameters in C++, and merely warn about such
parameters in C, which leads to confusion. In these settings, it's useful to
overload the builtin and permit volatile pointee parameters. The code generation
then directly emits the existing volatile variant of the mem* builtin function
call, which ensures that the affected memory location is only accessed once
(thereby preventing double-reads under an adversatial memory mapping).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79279

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtin-memfns.c
  clang/test/CodeGen/builtin-volatile-memfns.c

Index: clang/test/CodeGen/builtin-volatile-memfns.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-volatile-memfns.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple arm64-unknown-unknown -emit-llvm < %s| FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+// Regular char* parameters
+
+// CHECK-LABEL: dst_cpy(
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}, i1 true)
+void dst_cpy(volatile char *dst, const char *src, size_t size) { __builtin_memcpy(dst, src, size); }
+
+// CHECK-LABEL: src_cpy(
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}, i1 true)
+void src_cpy(char *dst, volatile const char *src, size_t size) { __builtin_memcpy(dst, src, size); }
+
+// CHECK-LABEL: dstsrc_cpy(
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}, i1 true)
+void dstsrc_cpy(volatile char *dst, volatile const char *src, size_t size) { __builtin_memcpy(dst, src, size); }
+
+// CHECK-LABEL: dst_move(
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i64({{.*}}, i1 true)
+void dst_move(volatile char *dst, const char *src, size_t size) { __builtin_memmove(dst, src, size); }
+
+// CHECK-LABEL: src_move(
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i64({{.*}}, i1 true)
+void src_move(char *dst, volatile const char *src, size_t size) { __builtin_memmove(dst, src, size); }
+
+// CHECK-LABEL: dstsrc_move(
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i64({{.*}}, i1 true)
+void dstsrc_move(volatile char *dst, volatile const char *src, size_t size) { __builtin_memmove(dst, src, size); }
+
+// CHECK-LABEL: set(
+// CHECK: call void @llvm.memset.p0i8.i64({{.*}}, i1 true)
+void set(volatile char *dst, char value, size_t size) { __builtin_memset(dst, value, size); }
+
+// Arrays
+
+extern const char asrc[512];
+extern const volatile char avsrc[512];
+extern char adst[512];
+extern volatile char avdst[512];
+
+// CHECK-LABEL: array_dst_cpy(
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}, i1 true)
+void array_dst_cpy(size_t size) { __builtin_memcpy(avdst, asrc, size); }
+
+// CHECK-LABEL: array_src_cpy(
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}, i1 true)
+void array_src_cpy(size_t size) { __builtin_memcpy(adst, avsrc, size); }
+
+// CHECK-LABEL: array_dstsrc_cpy(
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}, i1 true)
+void array_dstsrc_cpy(size_t size) { __builtin_memcpy(avdst, avsrc, size); }
+
+// CHECK-LABEL: array_dst_move(
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i64({{.*}}, i1 true)
+void array_dst_move(size_t size) { __builtin_memmove(avdst, asrc, size); }
+
+// CHECK-LABEL: array_src_move(
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i64({{.*}}, i1 true)
+void array_src_move(size_t size) { __builtin_memmove(adst, avsrc, size); }
+
+// CHECK-LABEL: array_dstsrc_move(
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i64({{.*}}, i1 true)
+void array_dstsrc_move(size_t size) { __builtin_memmove(avdst, avsrc, size); }
+
+// CHECK-LABEL: array_set(
+// CHECK: call void @llvm.memset.p0i8.i64({{.*}}, i1 true)
+void array_set(char value, size_t size) { __builtin_memset(avdst, value, size); }
Index: clang/test/CodeGen/builtin-memfns.c
===
--- clang/test/CodeGen/builtin-memfns.c
+++ clang/test/CodeGen/builtin-memfns.c
@@ -7,10 +7,10 @@
 void *memccpy(void *, void const *, int, size_t);
 
 // CHECK: @test1
-// CHECK: call void @llvm.memset.p0i8.i32
-// CHECK: call void @llvm.memset.p0i8.i32
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
-// CHECK: call void @llvm.memmove.p0i8.p0i8.i32
+// CHECK: call void @llvm.memset.p0i8.i32({{.*}}, i1 false)
+// CHECK: call void @llvm.memset.p0i8.i32({{.*}}, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32({{.*}}, i1 false)
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i32({{.*}}, i1 false)
 // CHECK-NOT: __builtin
 // CHECK: ret
 int test1(int argc, char **argv) {
@@ -26,31 +26,31 @@
 // rdar://9289468
 
 // CHECK: @test2
-// CHECK: call voi

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-05-01 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 261597.
jcai19 added a comment.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -571,8 +571,8 @@
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=zero %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-BAD %s
 // CHECK-TRIVIAL-UNINIT-NOT: hasn't been enabled
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
Index: clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=4 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-4
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=4 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-4
+
+#define ARRLEN 10
+
+typedef struct {
+  int i;
+  char c;
+} S;
+
+int foo(unsigned n) {
+  long a = 888;
+  S arr1[ARRLEN];
+  void *p;
+  p = __builtin_alloca(sizeof(unsigned long long) * n);
+  // PATTERN-STOP-AFTER-2-NOT: store i8* inttoptr (i64 -6148914691236517206 to i8*), i8** %p, align 8
+  // PATTERN-STOP-AFTER-3: store i8* inttoptr (i64 -6148914691236517206 to i8*), i8** %p, align 8
+  // PATTERN-STOP-AFTER-3-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 -86, i64 %mul, i1 false)
+  // PATTERN-STOP-AFTER-4: call void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 -86, i64 %mul, i1 false)
+  // ZERO-STOP-AFTER-2-NOT: store i8* null, i8** %p, align 8
+  // ZERO-STOP-AFTER-3: store i8* null, i8** %p, align 8
+  // ZERO-STOP-AFTER-3-NOT: void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 0, i64 %mul, i1 false)
+  // ZERO-STOP-AFTER-4: void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 0, i64 %mul, i1 false)
+  return 0;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3256,6 +3256,11 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init_stop_after)) {
+unsigned Val = (unsigned)std::stoi(A->getValue());
+Opts.TrivialAutoVarInitStopAfter = Val;
+  }
+
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
   Diags, Opts.Sanitize);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/

[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-05-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5806
+if (Opc == ARM::BL || Opc == ARM::tBL || Opc == ARM::BLX ||
+Opc == ARM::tBLXr || Opc == ARM::tBLXi)
+  UnknownCallOutlineType = outliner::InstrType::LegalTerminator;

efriedma wrote:
> Maybe also look for TAILJMP opcodes?
Oh, nevermind, TAILJMP is a terminator so it gets handled earlier.



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5817
+  // Be conservative with program counter.
+  if (MI.readsRegister(ARM::PC, TRI) || MI.modifiesRegister(ARM::PC, TRI))
+return outliner::InstrType::Illegal;

efriedma wrote:
> samparker wrote:
> > Cheers. AArch64 is nice and doesn't allow arbitrary writes to the PC, but 
> > we won't have that luxury here.
> You might also want to support POP_RET.
Oh, nevermind, POP_RET is a terminator so it gets handled earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76066



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-05-01 Thread Jian Cai via Phabricator via cfe-commits
jcai19 marked an inline comment as done.
jcai19 added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:1817
+  CGM.countAutoVarInit();
+}
+

jfb wrote:
> This isn't the right place to stop auto-init: we can get past this point even 
> without auto-init. As-is you're introducing a change in the regular language.
> 
> I hope that some tests for whatever happens below would break if you hack 
> your flag to always stop auto-init for any value. i.e. just on your machine, 
> run the entire test suite with this forcibly on. Only auto-init tests should 
> fail, the others should all still pass.
I tried to always return and it seemed only auto-init tests failed while 
running check-clang. But I agree this is not the right place. I have moved this 
piece of code. Thanks!



Comment at: clang/lib/CodeGen/CodeGenModule.h:305
   const CodeGenOptions &CodeGenOpts;
+  mutable unsigned NumAutoVarInit = 0;
   llvm::Module &TheModule;

jfb wrote:
> This is reachable from a context where `CodeGenModule` is `const` ? :( 
I copied it from my previous iteration and forgot to remove the keyword. Thanks 
for catching that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-05-01 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 261595.
jcai19 marked 3 inline comments as done.
jcai19 added a comment.

Update based on comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -571,8 +571,8 @@
 // CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
 
 // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
-// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
+// RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -ftrivial-auto-var-init-stop-after=1 %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s
 // RUN: %clang -### -S -ftrivial-auto-var-init=zero %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-BAD %s
 // CHECK-TRIVIAL-UNINIT-NOT: hasn't been enabled
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
Index: clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/auto-var-init-stop-after.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=pattern -ftrivial-auto-var-init-stop-after=4 %s -emit-llvm -o - | FileCheck %s -check-prefix=PATTERN-STOP-AFTER-4
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=2 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=3 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ftrivial-auto-var-init=zero -ftrivial-auto-var-init-stop-after=4 %s -emit-llvm -o - | FileCheck %s -check-prefix=ZERO-STOP-AFTER-4
+
+#define ARRLEN 10
+
+typedef struct {
+  int i;
+  char c;
+} S;
+
+int foo(unsigned n) {
+  long a = 888;
+  S arr1[ARRLEN];
+  void *p;
+  p = __builtin_alloca(sizeof(unsigned long long) * n);
+  // PATTERN-STOP-AFTER-2-NOT: store i8* inttoptr (i64 -6148914691236517206 to i8*), i8** %p, align 8
+  // PATTERN-STOP-AFTER-3: store i8* inttoptr (i64 -6148914691236517206 to i8*), i8** %p, align 8
+  // PATTERN-STOP-AFTER-3-NOT: call void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 -86, i64 %mul, i1 false)
+  // PATTERN-STOP-AFTER-4: call void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 -86, i64 %mul, i1 false)
+  // ZERO-STOP-AFTER-2-NOT: store i8* null, i8** %p, align 8
+  // ZERO-STOP-AFTER-3: store i8* null, i8** %p, align 8
+  // ZERO-STOP-AFTER-3-NOT: void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 0, i64 %mul, i1 false)
+  // ZERO-STOP-AFTER-4: void @llvm.memset.p0i8.i64(i8* align 16 %2, i8 0, i64 %mul, i1 false)
+  return 0;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3256,6 +3256,11 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init_stop_after)) {
+unsigned Val = (unsigned)std::stoi(A->getValue());
+Opts.TrivialAutoVarInitStopAfter = Val;
+  }
+
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
   Diags, Opts.Sanitize);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- c

[PATCH] D79224: [WebAssembly] Renumber SIMD opcodes

2020-05-01 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0f52842c8bc: [WebAssembly] Renumber SIMD opcodes (authored 
by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79224

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-conversions.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/Disassembler/WebAssembly/wasm.txt
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -6,17 +6,47 @@
 # CHECK: v128.load 48 # encoding: [0xfd,0x00,0x04,0x30]
 v128.load 48
 
-# CHECK: v128.store 48 # encoding: [0xfd,0x01,0x04,0x30]
+# CHECK: i16x8.load8x8_s 32 # encoding: [0xfd,0x01,0x03,0x20]
+i16x8.load8x8_s 32
+
+# CHECK: i16x8.load8x8_u 32 # encoding: [0xfd,0x02,0x03,0x20]
+i16x8.load8x8_u 32
+
+# CHECK: i32x4.load16x4_s 32 # encoding: [0xfd,0x03,0x03,0x20]
+i32x4.load16x4_s 32
+
+# CHECK: i32x4.load16x4_u 32 # encoding: [0xfd,0x04,0x03,0x20]
+i32x4.load16x4_u 32
+
+# CHECK: i64x2.load32x2_s 32 # encoding: [0xfd,0x05,0x03,0x20]
+i64x2.load32x2_s 32
+
+# CHECK: i64x2.load32x2_u 32 # encoding: [0xfd,0x06,0x03,0x20]
+i64x2.load32x2_u 32
+
+# CHECK: v8x16.load_splat 48 # encoding: [0xfd,0x07,0x00,0x30]
+v8x16.load_splat 48
+
+# CHECK: v16x8.load_splat 48 # encoding: [0xfd,0x08,0x01,0x30]
+v16x8.load_splat 48
+
+# CHECK: v32x4.load_splat 48 # encoding: [0xfd,0x09,0x02,0x30]
+v32x4.load_splat 48
+
+# CHECK: v64x2.load_splat 48 # encoding: [0xfd,0x0a,0x03,0x30]
+v64x2.load_splat 48
+
+# CHECK: v128.store 48 # encoding: [0xfd,0x0b,0x04,0x30]
 v128.store 48
 
 # CHECK: v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
 
 # CHECK: v128.const 256, 770, 1284, 1798, 2312, 2826, 3340, 3854
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 256, 770, 1284, 1798, 2312, 2826, 3340, 3854
@@ -25,577 +55,535 @@
 
 # CHECK: v128.const 0x1.0402p-121, 0x1.0c0a08p-113,
 # CHECK-SAME:   0x1.14121p-105, 0x1.1c1a18p-97
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 0x1.0402p-121, 0x1.0c0a08p-113, 0x1.14121p-105, 0x1.1c1a18p-97
 
 # CHECK: v128.const 0x1.60504030201p-911, 0x1.e0d0c0b0a0908p-783
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 0x1.60504030201p-911, 0x1.e0d0c0b0a0908p-783
 
 # CHECK: v8x16.shuffle 0, 17, 2, 19, 4, 21, 6, 23,
 # CHECK-SAME:  8, 25, 10, 27, 12, 29, 14, 31
-# CHECK-SAME: # encoding: [0xfd,0x03,
+# CHECK-SAME: # encoding: [0xfd,0x0d,
 # CHECK-SAME: 0x00,0x11,0x02,0x13,0x04,0x15,0x06,0x17,
 # CHECK-SAME: 0x08,0x19,0x0a,0x1b,0x0c,0x1d,0x0e,0x1f]
 v8x16.shuffle 0, 17, 2, 19, 4, 21, 6, 23, 8, 25, 10, 27, 12, 29, 14, 31
 
-# CHECK: i8x16.splat # encoding: [0xfd,0x04]
+# CHECK: v8x16.swizzle # encoding: [0xfd,0x0e]
+v8x16.swizzle
+
+# CHECK: i8x16.splat # encoding: [0xfd,0x0f]
 i8x16.splat
 
-# CHECK: i8x16.extract_lane_s 15 # encoding: [0xfd,0x05,0x0f]
+# CHECK: i16x8.splat # encoding: [0xfd,0x10]
+i16x8.splat
+
+# CHECK: i32x4.splat # encoding: [0xfd,0x11]
+i32x4.splat
+
+# CHECK: i64x2.splat # encoding: [0xfd,0x12]
+i64x2.splat
+
+# CHECK: f32x4.splat # encoding: [0xfd,0x13]
+f32x4.splat
+
+# CHECK: f64x2.splat # encoding: [0xfd,0x14]
+f64x2.splat
+
+# CHECK: i8x16.extract_lane_s 15 # encoding: [0xfd,0x15,0x0f]
 i8x16.extract_lane_s 15
 
-# CHECK: i8x16.extract_lane_u 15 # encoding: [0xfd,0x06,0x0f]
+# CHECK: i8x16.extract_lane_u 15 # encoding: [0xfd,0x16,0x0f]
 i8x16.extract_lane_u 15
 
-# CHECK: i8x16.replace_lane 15 # encoding: [0xfd,0x07,0x0f]
+# CHECK: i8x16.replace_lane 1

[PATCH] D78965: [clang][OpenMP] Fix mangling of linear parameters.

2020-05-01 Thread Francesco Petrogalli via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7585ba208e67: [clang][OpenMP] Fix mangling of linear 
parameters. (authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78965

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

Index: clang/test/OpenMP/declare_simd_codegen.cpp
===
--- clang/test/OpenMP/declare_simd_codegen.cpp
+++ clang/test/OpenMP/declare_simd_codegen.cpp
@@ -136,14 +136,14 @@
 // CHECK-DAG: declare {{.+}}@_Z5add_2Pf(
 // CHECK-DAG: define {{.+}}@_Z11constlineari(
 
-// CHECK-DAG: "_ZGVbM4l8__Z5add_1Pf"
-// CHECK-DAG: "_ZGVbN4l8__Z5add_1Pf"
-// CHECK-DAG: "_ZGVcM8l8__Z5add_1Pf"
-// CHECK-DAG: "_ZGVcN8l8__Z5add_1Pf"
-// CHECK-DAG: "_ZGVdM8l8__Z5add_1Pf"
-// CHECK-DAG: "_ZGVdN8l8__Z5add_1Pf"
-// CHECK-DAG: "_ZGVeM16l8__Z5add_1Pf"
-// CHECK-DAG: "_ZGVeN16l8__Z5add_1Pf"
+// CHECK-DAG: "_ZGVbM4l32__Z5add_1Pf"
+// CHECK-DAG: "_ZGVbN4l32__Z5add_1Pf"
+// CHECK-DAG: "_ZGVcM8l32__Z5add_1Pf"
+// CHECK-DAG: "_ZGVcN8l32__Z5add_1Pf"
+// CHECK-DAG: "_ZGVdM8l32__Z5add_1Pf"
+// CHECK-DAG: "_ZGVdN8l32__Z5add_1Pf"
+// CHECK-DAG: "_ZGVeM16l32__Z5add_1Pf"
+// CHECK-DAG: "_ZGVeN16l32__Z5add_1Pf"
 // CHECK-DAG: "_ZGVbM32v__Z5add_1Pf"
 // CHECK-DAG: "_ZGVcM32v__Z5add_1Pf"
 // CHECK-DAG: "_ZGVdM32v__Z5add_1Pf"
@@ -180,14 +180,14 @@
 // CHECK-DAG: "_ZGVeM16uus1__ZN2VV3addEii"
 // CHECK-DAG: "_ZGVeN16uus1__ZN2VV3addEii"
 
-// CHECK-DAG: "_ZGVbM4lla16l4a4__ZN2VV6taddpfEPfRS0_"
-// CHECK-DAG: "_ZGVbN4lla16l4a4__ZN2VV6taddpfEPfRS0_"
-// CHECK-DAG: "_ZGVcM8lla16l4a4__ZN2VV6taddpfEPfRS0_"
-// CHECK-DAG: "_ZGVcN8lla16l4a4__ZN2VV6taddpfEPfRS0_"
-// CHECK-DAG: "_ZGVdM8lla16l4a4__ZN2VV6taddpfEPfRS0_"
-// CHECK-DAG: "_ZGVdN8lla16l4a4__ZN2VV6taddpfEPfRS0_"
-// CHECK-DAG: "_ZGVeM16lla16l4a4__ZN2VV6taddpfEPfRS0_"
-// CHECK-DAG: "_ZGVeN16lla16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVbM4ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVbN4ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVcM8ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVcN8ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVdM8ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVdN8ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVeM16ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
+// CHECK-DAG: "_ZGVeN16ll4a16l4a4__ZN2VV6taddpfEPfRS0_"
 
 // CHECK-DAG: "_ZGVbM4vvl8__ZN2VV4taddERA_iRi"
 // CHECK-DAG: "_ZGVbN4vvl8__ZN2VV4taddERA_iRi"
@@ -293,23 +293,23 @@
 // CHECK-DAG: "_ZGVeM16vvv__Z3bax2VVPdi"
 // CHECK-DAG: "_ZGVeN16vvv__Z3bax2VVPdi"
 
-// CHECK-DAG: "_ZGVbM4ua16vl1__Z3fooPffi"
-// CHECK-DAG: "_ZGVbN4ua16vl1__Z3fooPffi"
-// CHECK-DAG: "_ZGVcM8ua16vl1__Z3fooPffi"
-// CHECK-DAG: "_ZGVcN8ua16vl1__Z3fooPffi"
-// CHECK-DAG: "_ZGVdM8ua16vl1__Z3fooPffi"
-// CHECK-DAG: "_ZGVdN8ua16vl1__Z3fooPffi"
-// CHECK-DAG: "_ZGVeM16ua16vl1__Z3fooPffi"
-// CHECK-DAG: "_ZGVeN16ua16vl1__Z3fooPffi"
-
-// CHECK-DAG: "_ZGVbM4l8__Z5add_2Pf"
-// CHECK-DAG: "_ZGVbN4l8__Z5add_2Pf"
-// CHECK-DAG: "_ZGVcM8l8__Z5add_2Pf"
-// CHECK-DAG: "_ZGVcN8l8__Z5add_2Pf"
-// CHECK-DAG: "_ZGVdM8l8__Z5add_2Pf"
-// CHECK-DAG: "_ZGVdN8l8__Z5add_2Pf"
-// CHECK-DAG: "_ZGVeM16l8__Z5add_2Pf"
-// CHECK-DAG: "_ZGVeN16l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVbM4ua16vl__Z3fooPffi"
+// CHECK-DAG: "_ZGVbN4ua16vl__Z3fooPffi"
+// CHECK-DAG: "_ZGVcM8ua16vl__Z3fooPffi"
+// CHECK-DAG: "_ZGVcN8ua16vl__Z3fooPffi"
+// CHECK-DAG: "_ZGVdM8ua16vl__Z3fooPffi"
+// CHECK-DAG: "_ZGVdN8ua16vl__Z3fooPffi"
+// CHECK-DAG: "_ZGVeM16ua16vl__Z3fooPffi"
+// CHECK-DAG: "_ZGVeN16ua16vl__Z3fooPffi"
+
+// CHECK-DAG: "_ZGVbM4l32__Z5add_2Pf"
+// CHECK-DAG: "_ZGVbN4l32__Z5add_2Pf"
+// CHECK-DAG: "_ZGVcM8l32__Z5add_2Pf"
+// CHECK-DAG: "_ZGVcN8l32__Z5add_2Pf"
+// CHECK-DAG: "_ZGVdM8l32__Z5add_2Pf"
+// CHECK-DAG: "_ZGVdN8l32__Z5add_2Pf"
+// CHECK-DAG: "_ZGVeM16l32__Z5add_2Pf"
+// CHECK-DAG: "_ZGVeN16l32__Z5add_2Pf"
 // CHECK-DAG: "_ZGVbM32v__Z5add_2Pf"
 // CHECK-DAG: "_ZGVcM32v__Z5add_2Pf"
 // CHECK-DAG: "_ZGVdM32v__Z5add_2Pf"
Index: clang/test/OpenMP/declare_simd_aarch64.c
===
--- clang/test/OpenMP/declare_simd_aarch64.c
+++ clang/test/OpenMP/declare_simd_aarch64.c
@@ -130,12 +130,12 @@
 /*/
 #pragma omp declare simd linear(sin) linear(cos)
 void sincos(double in, double *sin, double *cos);
-// AARCH64: "_ZGVnN2vll_sincos"
+// AARCH64: "_ZGVnN2vl8l8_sincos"
 // AARCH64-NOT: sincos
 
 #pragma omp declare simd linear(sin : 1) linear(cos : 2)
 void SinCos(double in, double *sin, double *cos);
-// AARCH64: "_ZGVnN2vll2_SinCos"
+// AARCH64: "_ZGVnN2vl8l16_SinCos"
 // AARCH64-NOT: SinCos
 
 // Selection of tests based on the examples provided in chapter 5 of
@@ -158,7 +158,7 @@
 // Listing 6, p. 19
 #pragma omp declare simd linear(x) aligned(x : 16) simdlen(4)
 int foo4(int *x

[PATCH] D74668: [Clang][BPF] implement __builtin_btf_type_id() builtin function

2020-05-01 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

In D74668#2015294 , @anakryiko wrote:

> Let's extend __builtin_btf_type_id() to accept second argument specifying 
> whether it's local BTF ID (from program's BTF) or target BTF ID (from 
> kernel/module BTF)? We can probably make it an enum just like with 
> preserve_access_index() built-in, for easy future extension. WDYT?


This is on my to-do list. Haven't do it since the builtin is not used yet. Will 
do this once my bpf_iter v2 is sent out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74668



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


[clang] e0f5284 - [WebAssembly] Renumber SIMD opcodes

2020-05-01 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-05-01T17:20:49-07:00
New Revision: e0f52842c8bcf1e0a59d2535072795597571adb6

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

LOG: [WebAssembly] Renumber SIMD opcodes

Summary:
As described in https://github.com/WebAssembly/simd/pull/209. This is
the final reorganization of the SIMD opcode space before
standardization. It has been landed in concert with corresponding
changes in other projects in the WebAssembly SIMD ecosystem.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/wasm_simd128.h
clang/test/CodeGen/builtins-wasm.c
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-conversions.ll
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/Disassembler/WebAssembly/wasm.txt
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 5fb7a603fe17..0d66535fa8ec 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -153,8 +153,6 @@ TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", 
"nc", "unimplemented-s
 
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32x4_f32x4, "V4iV4f", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64x2_f64x2, "V2LLiV2d", "nc", 
"unimplemented-simd128")
-TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64x2_f64x2, "V2LLiV2d", "nc", 
"unimplemented-simd128")
 
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16cV8sV8s", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16cV8sV8s", "nc", 
"simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2fa9ed9b2443..94c0adfdf4af 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15546,8 +15546,7 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
   case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32_f64:
   case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f32:
   case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f64:
-  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32x4_f32x4:
-  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64x2_f64x2: {
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32x4_f32x4: {
 Value *Src = EmitScalarExpr(E->getArg(0));
 llvm::Type *ResT = ConvertType(E->getType());
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_signed,
@@ -15558,8 +15557,7 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
   case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32_f64:
   case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f32:
   case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f64:
-  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32x4_f32x4:
-  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64x2_f64x2: {
+  case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32x4_f32x4: {
 Value *Src = EmitScalarExpr(E->getArg(0));
 llvm::Type *ResT = ConvertType(E->getType());
 Function *Callee = 
CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_unsigned,

diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index c2c57cadfdf2..612aec139723 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -1007,20 +1007,6 @@ wasm_u32x4_trunc_saturate_f32x4(v128_t __a) {
   return (v128_t)__builtin_wasm_trunc_saturate_u_i32x4_f32x4((__f32x4)__a);
 }
 
-#ifdef __wasm_unimplemented_simd128__
-
-static __inline__ v128_t __DEFAULT_FN_ATTRS
-wasm_i64x2_trunc_saturate_f64x2(v128_t __a) {
-  return (v128_t)__builtin_wasm_trunc_saturate_s_i64x2_f64x2((__f64x2)__a);
-}
-
-static __inline__ v128_t __DEFAULT_FN_ATTRS
-wasm_u64x2_trunc_saturate_f64x2(v128_t __a) {
-  return (v128_t)__builtin_wasm_trunc_saturate_s_i64x2_f64x2((__f64x2)__a);
-}
-
-#endif // __wasm_unimplemented_simd128__
-
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_f32x4_convert_i32x4(v128_t __a) {
   return (v128_t) __builtin_convertvector((__i32x4)__a, __f32x4);
@@ -1031,20 +1017,6 @@ wasm_f32x4_convert_u32x4(v128_t __a) {
   return (v128_t) __builtin_convertvector((__u32x4)__a, __f32x4);
 }
 
-#ifdef __wasm_unimplemented_simd128__
-
-static __inline

[PATCH] D79276: [FileCheck] Support comment directives

2020-05-01 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: probinson, thopre, hfinkel, jhenderson, jroelofs, 
jdoerfert.
Herald added subscribers: cfe-commits, hiraditya, arichardson, Anastasia.
Herald added projects: clang, LLVM.

Sometimes you want to disable a FileCheck directive without removing
it entirely, or you want to write comments that mention a directive by
name.  The `COM:` directive makes it easy to do this.  For example,
you might have:

  ; X32: pinsrd_1:
  ; X32:pinsrd $1, 4(%esp), %xmm0
  
  ; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but 
  ; COM: X64 will have something similar to X32:
  ; COM:
  ; COM:   X64: pinsrd_1:
  ; COM:   X64:pinsrd $1, %edi, %xmm0

Without this patch, you need to use some combination of rewording and 
directive syntax mangling to prevent FileCheck from recognizing the 
commented occurrences of `X32:` and `X64:` above as directives.
Moreover, FileCheck diagnostics have been proposed that might complain
about the occurrences of `X64` that don't have the trailing `:` 
because they look like directive typos:

  

I think dodging all these problems can prove tedious for test authors,
and directive syntax mangling already makes the purpose of existing
test code unclear.  `COM:` can avoid all these problems.

This patch also updates the small set of existing tests that define
`COM` as a check prefix:

- clang/test/CodeGen/default-address-space.c
- clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
- clang/test/Driver/hip-device-libs.hip
- llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll

I think lit should support `COM:` as well.  Perhaps `clang -verify`
should too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79276

Files:
  clang/test/CodeGen/default-address-space.c
  clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
  clang/test/Driver/hip-device-libs.hip
  llvm/docs/CommandGuide/FileCheck.rst
  llvm/include/llvm/Support/FileCheck.h
  llvm/lib/Support/FileCheck.cpp
  llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
  llvm/test/FileCheck/comment.txt
  llvm/test/FileCheck/first-character-match.txt
  llvm/test/FileCheck/validate-check-prefix.txt
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -44,6 +44,14 @@
 cl::desc(
 "Alias for -check-prefix permitting multiple comma separated values"));
 
+static cl::list CommentPrefixes(
+"comment-prefixes", cl::CommaSeparated, cl::Hidden,
+cl::desc("Comma-separated list of comment prefixes to use from check file\n"
+ "(defaults to 'COM,RUN').  Please avoid using this feature in\n"
+ "LLVM's LIT-based test suites, which should be easier to\n"
+ "maintain if they all follow a consistent comment style.  This\n"
+ "feature is meant for non-LIT test suites using FileCheck."));
+
 static cl::opt NoCanonicalizeWhiteSpace(
 "strict-whitespace",
 cl::desc("Do not treat all horizontal whitespace as equivalent"));
@@ -279,6 +287,8 @@
 return "label";
   case Check::CheckEmpty:
 return "empty";
+  case Check::CheckComment:
+return "com";
   case Check::CheckEOF:
 return "eof";
   case Check::CheckBadNot:
@@ -565,6 +575,9 @@
   for (StringRef Prefix : CheckPrefixes)
 Req.CheckPrefixes.push_back(Prefix);
 
+  for (StringRef Prefix : CommentPrefixes)
+Req.CommentPrefixes.push_back(Prefix);
+
   for (StringRef CheckNot : ImplicitCheckNot)
 Req.ImplicitCheckNot.push_back(CheckNot);
 
@@ -601,12 +614,8 @@
 Req.Verbose = true;
 
   FileCheck FC(Req);
-  if (!FC.ValidateCheckPrefixes()) {
-errs() << "Supplied check-prefix is invalid! Prefixes must be unique and "
-  "start with a letter and contain only alphanumeric characters, "
-  "hyphens and underscores\n";
+  if (!FC.ValidateCheckPrefixes())
 return 2;
-  }
 
   Regex PrefixRE = FC.buildCheckPrefixRegex();
   std::string REError;
Index: llvm/test/FileCheck/validate-check-prefix.txt
===
--- llvm/test/FileCheck/validate-check-prefix.txt
+++ llvm/test/FileCheck/validate-check-prefix.txt
@@ -1,10 +1,13 @@
 // RUN: %ProtectFileCheckOutput not FileCheck -check-prefix=A! -input-file %s %s 2>&1 | FileCheck -check-prefix=BAD_PREFIX %s
 // RUN: FileCheck -check-prefix=A1a-B_c -input-file %s %s
-// RUN: %ProtectFileCheckOutput not FileCheck -check-prefix=REPEAT -check-prefix=REPEAT -input-file %s %s 2>&1 | FileCheck -check-prefix=BAD_PREFIX %s
+// RUN: %ProtectFileCheckOutput not FileCheck -check-prefix=REPEAT -check-prefix=REPEAT -input-file %s %s 2>&1 | FileCheck -check-prefix=DUPLICATE_PREFIX %s
 // RUN: %ProtectFileCheckOutput not FileCheck -check-prefix=VALID -check-prefix=A! -input-file %s %s 2>

[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-05-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5607
+  // * Register R12(IP),
+  // * Condition codes (and thus the CPSR register)
+  //

If you control all the instructions that execute, you don't need to worry about 
what the procedure call standard says.  You do need to worry about linker 
veneers if the outlined function is in a different section, though.

So you need to worry about `R12`/`CPSR` on entry to the outlined function, but 
not on exit from the outlined function.



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5806
+if (Opc == ARM::BL || Opc == ARM::tBL || Opc == ARM::BLX ||
+Opc == ARM::tBLXr || Opc == ARM::tBLXi)
+  UnknownCallOutlineType = outliner::InstrType::LegalTerminator;

Maybe also look for TAILJMP opcodes?



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5813
+  // Don't touch the link register
+  if (MI.readsRegister(ARM::LR, TRI) || MI.modifiesRegister(ARM::LR, TRI))
+return outliner::InstrType::Illegal;

Why do you need to forbid outlining code that touches LR or SP? None of the new 
instructions you're generating read or clobber them.   (It might start 
mattering if you add support for additional forms of outlining, or Thumb1 
support, but this patch has neither.)



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5817
+  // Be conservative with program counter.
+  if (MI.readsRegister(ARM::PC, TRI) || MI.modifiesRegister(ARM::PC, TRI))
+return outliner::InstrType::Illegal;

samparker wrote:
> Cheers. AArch64 is nice and doesn't allow arbitrary writes to the PC, but we 
> won't have that luxury here.
You might also want to support POP_RET.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76066



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


[PATCH] D79274: Fix template class debug info for Visual Studio visualizers

2020-05-01 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth created this revision.
amccarth added reviewers: rnk, hans.
Herald added a subscriber: aprantl.

An earlier change eliminated spaces between the close brackets of nested
template lists.  Unfortunately that prevents the Windows debuggers from
matching some types to their corresponding visualizers (e.g., std::map).

This selects the SeparateTemplateClosers flag when generating COFF debug
info.  Note that we were already making formatting adjustments under
similar circumstances for similar reasons.

This solves the immediate problem, but there aren't many tests for COFF
debug info (that I can see).  I will be looking into integrated tests with
Dexter next.


https://reviews.llvm.org/D79274

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -231,9 +231,12 @@
   // If we're emitting codeview, it's important to try to match MSVC's naming 
so
   // that visualizers written for MSVC will trigger for our class names. In
   // particular, we can't have spaces between arguments of standard templates
-  // like basic_string and vector.
-  if (CGM.getCodeGenOpts().EmitCodeView)
+  // like basic_string and vector, but we must have spaces between consecutive
+  // angle brackets that close nested template argument lists.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
 PP.MSVCFormatting = true;
+PP.SplitTemplateClosers = true;
+  }
 
   // Apply -fdebug-prefix-map.
   PP.Callbacks = &PrintCB;


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -231,9 +231,12 @@
   // If we're emitting codeview, it's important to try to match MSVC's naming so
   // that visualizers written for MSVC will trigger for our class names. In
   // particular, we can't have spaces between arguments of standard templates
-  // like basic_string and vector.
-  if (CGM.getCodeGenOpts().EmitCodeView)
+  // like basic_string and vector, but we must have spaces between consecutive
+  // angle brackets that close nested template argument lists.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
 PP.MSVCFormatting = true;
+PP.SplitTemplateClosers = true;
+  }
 
   // Apply -fdebug-prefix-map.
   PP.Callbacks = &PrintCB;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79210: Let clang print registered targets for --version

2020-05-01 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Yeah, it's fine. We might want to put it behind a "long information" option, 
but for now it's ok. Keep an eye open if someone complains please.


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

https://reviews.llvm.org/D79210



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-05-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 261563.
ASDenysPetrov edited the summary of this revision.

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

https://reviews.llvm.org/D78933

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_conditions.cpp

Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -0,0 +1,183 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void comparison_lt(int x, int y) {
+  if (x < y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_gt(int x, int y) {
+  if (x > y) {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_le(int x, int y) {
+  if (x <= y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expe

[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-05-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 261556.

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

https://reviews.llvm.org/D78933

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_conditions.cpp

Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -0,0 +1,183 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void comparison_lt(int x, int y) {
+  if (x < y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_gt(int x, int y) {
+  if (x > y) {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_le(int x, int y) {
+  if (x <= y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+   

[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-05-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 261552.

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

https://reviews.llvm.org/D78933

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_conditions.cpp

Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -0,0 +1,183 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void comparison_lt(int x, int y) {
+  if (x < y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_gt(int x, int y) {
+  if (x > y) {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_le(int x, int y) {
+  if (x <= y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+   

[PATCH] D79224: [WebAssembly] Renumber SIMD opcodes

2020-05-01 Thread Thomas Lively via Phabricator via cfe-commits
tlively marked 3 inline comments as done.
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:186
 // 64x2 conversions are not in the spec
-if (!Subtarget->hasUnimplementedSIMD128())
-  for (auto Op :

aheejin wrote:
> So these have been decided not be included in the spec?
That's correct



Comment at: llvm/test/CodeGen/WebAssembly/simd-conversions.ll:88
-; SIMD128-NEXT: i64x2.trunc_sat_f64x2_u $push[[R:[0-9]+]]=, $0
-; SIMD128-NEXT: return $pop[[R]]
 define <2 x i64> @trunc_sat_u_v2i64(<2 x double> %x) {

aheejin wrote:
> We don't need this anymore?
No, these instructions have been removed because they are no longer in the 
proposal and there is not a great set of opcodes to assign them to. These test 
functions are still here to test that the compiler doesn't crash, but their 
contents aren't important to test here. The instructions get scalarized and our 
normal complicated lowering of fp-to-int gets applied, so we end up with a very 
large amount of code in this case.



Comment at: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll:479
-  ret <2 x i64> %a
-}
-

aheejin wrote:
> Ditto
These LLVM intrinsics are no longer supported, so the entire function is 
removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79224



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


[PATCH] D78750: [SveEmitter] Add builtins for svdupq and svdupq_lane

2020-05-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:98
+  bool isScalarPredicate() const {
+return !Float && Predicate && NumVectors == 0;
+  }

note: the changes to isScalarPredicate and to SVEType::str() are fixes to allow 
expressing `bool`, which weren't previously exhibited because there wasn't yet 
a builtin that used a scalar `bool` as argument.


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

https://reviews.llvm.org/D78750



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


[PATCH] D79210: Let clang print registered targets for --version

2020-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Is it OK to commit this? Thanks.


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

https://reviews.llvm.org/D79210



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


[PATCH] D78750: [SveEmitter] Add builtins for svdupq and svdupq_lane

2020-05-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 261545.
sdesmalen added a comment.

- Re-added patch with diff context.


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

https://reviews.llvm.org/D78750

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -94,7 +94,9 @@
   bool isDefault() const { return DefaultType; }
   bool isFloat() const { return Float; }
   bool isInteger() const { return !Float && !Predicate; }
-  bool isScalarPredicate() const { return !Float && ElementBitwidth == 1; }
+  bool isScalarPredicate() const {
+return !Float && Predicate && NumVectors == 0;
+  }
   bool isPredicateVector() const { return Predicate; }
   bool isPredicatePattern() const { return PredicatePattern; }
   bool isPrefetchOp() const { return PrefetchOp; }
@@ -407,12 +409,12 @@
 
 if (Float)
   S += "float";
-else if (isScalarPredicate())
+else if (isScalarPredicate() || isPredicateVector())
   S += "bool";
 else
   S += "int";
 
-if (!isScalarPredicate())
+if (!isScalarPredicate() && !isPredicateVector())
   S += utostr(ElementBitwidth);
 if (!isScalableVector() && isVector())
   S += "x" + utostr(getNumElements());
@@ -433,7 +435,6 @@
 switch (I) {
 case 'P':
   Predicate = true;
-  ElementBitwidth = 1;
   break;
 case 'U':
   Signed = false;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
@@ -0,0 +1,367 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8_t test_svdupq_lane_s8(svint8_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s8,,)(data, index);
+}
+
+svint16_t test_svdupq_lane_s16(svint16_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s16,,)(data, index);
+}
+
+svint32_t test_svdupq_lane_s32(svint32_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s32,,)(data, index);
+}
+
+svint64_t test_svdupq_lane_s64(svint64_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s64,,)(data, index);
+}
+
+svuint8_t test_svdupq_lane_u8(svuint8_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u8,,)(data, index);
+}
+
+svuint16_t test_svdupq_lane_u16(svuint16_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u16,,)(data, index);
+}
+
+svuint32_t test_svdupq_lane_u32(svuint32_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u32,,)(data, index);
+}
+
+svuint64_t test_svdupq_lane_u64(svuint64_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u64,,)(data, index);
+}
+
+svfloat16_t test_svdupq_lane_f16(svfloat16_t data,

[PATCH] D79265: Let normalize() for posix style convert backslash to slash unconditionally.

2020-05-01 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: compnerd.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Currently, normalize() for posix replaces backslashes to slashes, except
that two backslashes in sequence are kept as-is.

clang calls normalize() to convert \ to / is microsoft compat mode. This
generally works well, but a path like "c:\\foo\\bar.h" with two
backslashes doesn't work due to the exception in normalize().

These paths happen naturally on Windows hosts with e.g.
`#include __FILE__`, and them not working on other hosts makes it
more difficult to write tests for this case.

The special case has been around without justification since this code
was added in r203611 (since then moved around in r215241 r215243).  No
integration tests fail if I remove it.

Try removing the special case.


https://reviews.llvm.org/D79265

Files:
  clang/test/Lexer/case-insensitive-include-ms.c
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp


Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1182,7 +1182,7 @@
   Tests.emplace_back("a", "a", "a");
   Tests.emplace_back("a/b", "a\\b", "a/b");
   Tests.emplace_back("a\\b", "a\\b", "a/b");
-  Tests.emplace_back("ab", "ab", "ab");
+  Tests.emplace_back("ab", "ab", "a//b");
   Tests.emplace_back("\\a", "\\a", "/a");
   Tests.emplace_back("a\\", "a\\", "a/");
 
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -539,17 +539,11 @@
   PathHome.append(Path.begin() + 1, Path.end());
   Path = PathHome;
 }
-  } else {
-for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI) {
-  if (*PI == '\\') {
-auto PN = PI + 1;
-if (PN < PE && *PN == '\\')
-  ++PI; // increment once, the for loop will move over the escaped 
slash
-else
-  *PI = '/';
-  }
-}
+return;
   }
+  for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI)
+if (*PI == '\\')
+  *PI = '/';
 }
 
 std::string convert_to_slash(StringRef path, Style style) {
Index: clang/test/Lexer/case-insensitive-include-ms.c
===
--- clang/test/Lexer/case-insensitive-include-ms.c
+++ clang/test/Lexer/case-insensitive-include-ms.c
@@ -6,15 +6,17 @@
 // RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s -include %s -I 
%t/Output -verify
 // RUN: %clang_cc1 -fsyntax-only -fms-compatibility 
-fdiagnostics-parseable-fixits %s -include %s -I %t/Output 2>&1 | FileCheck %s
 
-// FIXME: Add a test with repeated backslashes once clang can handle that
-// in ms-compat mode on non-Windows hosts.
 #include "..\Output\.\case-insensitive-include.h"
 #include "..\Output\.\Case-Insensitive-Include.h" // expected-warning 
{{non-portable path}}
 // CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\""
+#include "..\\Output\.\\Case-Insensitive-Include.h" // expected-warning 
{{non-portable path}}
+// CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:52}:"\"..Output\\.case-insensitive-include.h\""
 #include "..\output\.\case-insensitive-include.h" // expected-warning 
{{non-portable path}}
 // CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\""
 
 #include "apath\..\.\case-insensitive-include.h"
 #include "apath\..\.\Case-Insensitive-Include.h" // expected-warning 
{{non-portable path}}
 // CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:49}:"\"apath\\..\\.\\case-insensitive-include.h\""
+#include "apath\\..\\.\\Case-Insensitive-Include.h" // expected-warning 
{{non-portable path}}
+// CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:52}:"\"apath...case-insensitive-include.h\""
 #include "APath\..\.\case-insensitive-include.h" // For the sake of 
efficiency, this case is not diagnosed. :-(


Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1182,7 +1182,7 @@
   Tests.emplace_back("a", "a", "a");
   Tests.emplace_back("a/b", "a\\b", "a/b");
   Tests.emplace_back("a\\b", "a\\b", "a/b");
-  Tests.emplace_back("ab", "ab", "ab");
+  Tests.emplace_back("ab", "ab", "a//b");
   Tests.emplace_back("\\a", "\\a", "/a");
   Tests.emplace_back("a\\", "a\\", "a/");
 
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -539,17 +539,11 @@
   PathHome.append(Path.begin() + 1, Path.end());
   Path = PathHome;
 }
-  } else {
-for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI) {
-  if (*PI == '\\') {
-

[PATCH] D78750: [SveEmitter] Add builtins for svdupq and svdupq_lane

2020-05-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D78750#2009037 , @efriedma wrote:

> Is there some reason you decided to implement these particular functions as 
> inline functions directly in the header?


Earlier implementations of the ACLE had a lot more things done in the header 
file (such as the predication with zero/undef, immediate checks, etc). We've 
moved most of that to CGBuiltins. These macros were a bit specific and hadn't 
been moved to CGBuiltin yet, but are now kind of remnants of the old 
implementation. These are better expressed like the other builtins, so that we 
can further simplify the header file and maybe get rid of it entirely at some 
point. I've updated the patch accordingly.


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

https://reviews.llvm.org/D78750



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


[PATCH] D78740: [clangd] Handle PresumedLocations in IncludeCollector

2020-05-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Headers.cpp:40
+  auto PreLoc = SM.getPresumedLoc(HashLoc);
+  if (auto FE = SM.getFileManager().getFile(PreLoc.getFilename())) {
+if (SM.getFileEntryForID(SM.getMainFileID()) == *FE) {

sammccall wrote:
> wouldn't be SM.getFileEntryForID(PreLoc.FID) be more efficient?
well, that would've been even easier to just check for `PreLoc.FID == 
SM.getMainFileID()`, but unfortunately `PresumedLoc.FID` is invalid in presence 
of line directives :/

but we can do something like storing the MainFilePath and then just compare the 
PreLoc.getFileName with it.



Comment at: clang-tools-extra/clangd/Headers.cpp:44
+PreLoc.getColumn());
+  PreLoc = SM.getPresumedLoc(FilenameRange.getBegin());
+  auto FileNameBegin = SM.translateLineCol(

sammccall wrote:
> This part looks a little iffy to me, with all the coordinate transforms.
> 
> If we're synthesizing the include, chars don't have to match 1:1 right?
> e.g. if the original code was `#   include /* foo */ "bar.h" // baz` and 
> we synthesize `#include "bar.h"`, how is this going to get the coordinates of 
> "bar.h" right?
> 
> This seems awkward to resolve. `R` isn't actually used much though, 
> go-to-definition looks at its line number only, and DocumentLink uses it (but 
> it seems OK to just to do approximate re-lexing there). Maybe we can just 
> drop it?
> 
> ---
> (Original comment disregarding above problem)
> 
> Isn't it the case that the filename expansion location has to be in the same 
> file as the hashloc?
> So can we do something like:
> 
> ```
> FilenameRange = SM.getExpansionRange(FilenameRange);
> if (SM.getFileID(FilenameRange.start()) == SM.getFileID(FilenameRange.end()) 
> == SM.getFileID(OrigHashLoc)) {
>   // all in the same file
>   // compute NewStart = OrigStart - OrigHashLoc + NewHashLoc, etc
> } else {
>   FilenameRange = CharSourceRange();
> }
> ```
> This part looks a little iffy to me, with all the coordinate transforms.
> 
> If we're synthesizing the include, chars don't have to match 1:1 right?
> e.g. if the original code was #   include /* foo */ "bar.h" // baz and we 
> synthesize #include "bar.h", how is this going to get the coordinates of 
> "bar.h" right?

well, the patching actually ensures both `#` and `"filename"` starts at the 
correct offset, by padding them with whitespaces ignoring any comments and such.

> 
> This seems awkward to resolve. R isn't actually used much though, 
> go-to-definition looks at its line number only, and DocumentLink uses it (but 
> it seems OK to just to do approximate re-lexing there). Maybe we can just 
> drop it?

I am fine with dropping it too, the padding looks really ugly in the patching 
code :D.

Regarding go-to-def, I suppose we can keep storing the include line, since we 
calculate it anyway while getting the presumed location for HashLoc.

For DocumentLink, I suppose we can either lex while handling the request or 
store those separately in parsedast. I would go with the former.

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78740



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


[PATCH] D78750: [SveEmitter] Add builtins for svdupq and svdupq_lane

2020-05-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 261537.
sdesmalen added a comment.

- Moved dupq implementation to CGBuiltins


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

https://reviews.llvm.org/D78750

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -94,7 +94,9 @@
   bool isDefault() const { return DefaultType; }
   bool isFloat() const { return Float; }
   bool isInteger() const { return !Float && !Predicate; }
-  bool isScalarPredicate() const { return !Float && ElementBitwidth == 1; }
+  bool isScalarPredicate() const {
+return !Float && Predicate && NumVectors == 0;
+  }
   bool isPredicateVector() const { return Predicate; }
   bool isPredicatePattern() const { return PredicatePattern; }
   bool isPrefetchOp() const { return PrefetchOp; }
@@ -407,12 +409,12 @@
 
 if (Float)
   S += "float";
-else if (isScalarPredicate())
+else if (isScalarPredicate() || isPredicateVector())
   S += "bool";
 else
   S += "int";
 
-if (!isScalarPredicate())
+if (!isScalarPredicate() && !isPredicateVector())
   S += utostr(ElementBitwidth);
 if (!isScalableVector() && isVector())
   S += "x" + utostr(getNumElements());
@@ -433,7 +435,6 @@
 switch (I) {
 case 'P':
   Predicate = true;
-  ElementBitwidth = 1;
   break;
 case 'U':
   Signed = false;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
@@ -0,0 +1,367 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8_t test_svdupq_lane_s8(svint8_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s8,,)(data, index);
+}
+
+svint16_t test_svdupq_lane_s16(svint16_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s16,,)(data, index);
+}
+
+svint32_t test_svdupq_lane_s32(svint32_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s32,,)(data, index);
+}
+
+svint64_t test_svdupq_lane_s64(svint64_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_s64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_s64,,)(data, index);
+}
+
+svuint8_t test_svdupq_lane_u8(svuint8_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u8
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u8,,)(data, index);
+}
+
+svuint16_t test_svdupq_lane_u16(svuint16_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u16,,)(data, index);
+}
+
+svuint32_t test_svdupq_lane_u32(svuint32_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u32,,)(data, index);
+}
+
+svuint64_t test_svdupq_lane_u64(svuint64_t data, uint64_t index)
+{
+  // CHECK-LABEL: test_svdupq_lane_u64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %data, i64 %index)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svdupq_lane,_u64,,)(data, index);
+}
+
+svfloat16_t test_svdupq_lane_f16(svfloat16_t

[PATCH] D79224: [WebAssembly] Renumber SIMD opcodes

2020-05-01 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 261532.
tlively added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Remove i64x2 conversion ops in clang as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79224

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-conversions.ll
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/Disassembler/WebAssembly/wasm.txt
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -6,17 +6,47 @@
 # CHECK: v128.load 48 # encoding: [0xfd,0x00,0x04,0x30]
 v128.load 48
 
-# CHECK: v128.store 48 # encoding: [0xfd,0x01,0x04,0x30]
+# CHECK: i16x8.load8x8_s 32 # encoding: [0xfd,0x01,0x03,0x20]
+i16x8.load8x8_s 32
+
+# CHECK: i16x8.load8x8_u 32 # encoding: [0xfd,0x02,0x03,0x20]
+i16x8.load8x8_u 32
+
+# CHECK: i32x4.load16x4_s 32 # encoding: [0xfd,0x03,0x03,0x20]
+i32x4.load16x4_s 32
+
+# CHECK: i32x4.load16x4_u 32 # encoding: [0xfd,0x04,0x03,0x20]
+i32x4.load16x4_u 32
+
+# CHECK: i64x2.load32x2_s 32 # encoding: [0xfd,0x05,0x03,0x20]
+i64x2.load32x2_s 32
+
+# CHECK: i64x2.load32x2_u 32 # encoding: [0xfd,0x06,0x03,0x20]
+i64x2.load32x2_u 32
+
+# CHECK: v8x16.load_splat 48 # encoding: [0xfd,0x07,0x00,0x30]
+v8x16.load_splat 48
+
+# CHECK: v16x8.load_splat 48 # encoding: [0xfd,0x08,0x01,0x30]
+v16x8.load_splat 48
+
+# CHECK: v32x4.load_splat 48 # encoding: [0xfd,0x09,0x02,0x30]
+v32x4.load_splat 48
+
+# CHECK: v64x2.load_splat 48 # encoding: [0xfd,0x0a,0x03,0x30]
+v64x2.load_splat 48
+
+# CHECK: v128.store 48 # encoding: [0xfd,0x0b,0x04,0x30]
 v128.store 48
 
 # CHECK: v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
 
 # CHECK: v128.const 256, 770, 1284, 1798, 2312, 2826, 3340, 3854
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 256, 770, 1284, 1798, 2312, 2826, 3340, 3854
@@ -25,577 +55,535 @@
 
 # CHECK: v128.const 0x1.0402p-121, 0x1.0c0a08p-113,
 # CHECK-SAME:   0x1.14121p-105, 0x1.1c1a18p-97
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 0x1.0402p-121, 0x1.0c0a08p-113, 0x1.14121p-105, 0x1.1c1a18p-97
 
 # CHECK: v128.const 0x1.60504030201p-911, 0x1.e0d0c0b0a0908p-783
-# CHECK-SAME: # encoding: [0xfd,0x02,
+# CHECK-SAME: # encoding: [0xfd,0x0c,
 # CHECK-SAME: 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
 # CHECK-SAME: 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f]
 v128.const 0x1.60504030201p-911, 0x1.e0d0c0b0a0908p-783
 
 # CHECK: v8x16.shuffle 0, 17, 2, 19, 4, 21, 6, 23,
 # CHECK-SAME:  8, 25, 10, 27, 12, 29, 14, 31
-# CHECK-SAME: # encoding: [0xfd,0x03,
+# CHECK-SAME: # encoding: [0xfd,0x0d,
 # CHECK-SAME: 0x00,0x11,0x02,0x13,0x04,0x15,0x06,0x17,
 # CHECK-SAME: 0x08,0x19,0x0a,0x1b,0x0c,0x1d,0x0e,0x1f]
 v8x16.shuffle 0, 17, 2, 19, 4, 21, 6, 23, 8, 25, 10, 27, 12, 29, 14, 31
 
-# CHECK: i8x16.splat # encoding: [0xfd,0x04]
+# CHECK: v8x16.swizzle # encoding: [0xfd,0x0e]
+v8x16.swizzle
+
+# CHECK: i8x16.splat # encoding: [0xfd,0x0f]
 i8x16.splat
 
-# CHECK: i8x16.extract_lane_s 15 # encoding: [0xfd,0x05,0x0f]
+# CHECK: i16x8.splat # encoding: [0xfd,0x10]
+i16x8.splat
+
+# CHECK: i32x4.splat # encoding: [0xfd,0x11]
+i32x4.splat
+
+# CHECK: i64x2.splat # encoding: [0xfd,0x12]
+i64x2.splat
+
+# CHECK: f32x4.splat # encoding: [0xfd,0x13]
+f32x4.splat
+
+# CHECK: f64x2.splat # encoding: [0xfd,0x14]
+f64x2.splat
+
+# CHECK: i8x16.extract_lane_s 15 # encoding: [0xfd,0x15,0x0f]
 i8x16.extract_lane_s 15
 
-# CHECK: i8x16.extract_lane_u 15 # encoding: [0xfd,0x06,0x0f]
+# CHECK: i8x16.extract_lane_u 15 # encoding: [0xfd,0x16,0x0f]
 i8x16.extract_lane_u 15
 
-# CHECK: i8x16.replace_lane 15 # encoding: [0xfd,0x07,0x0f]
+# CHE

[PATCH] D74668: [Clang][BPF] implement __builtin_btf_type_id() builtin function

2020-05-01 Thread Andrii Nakryiko via Phabricator via cfe-commits
anakryiko added a comment.

Let's extend __builtin_btf_type_id() to accept second argument specifying 
whether it's local BTF ID (from program's BTF) or target BTF ID (from 
kernel/module BTF)? We can probably make it an enum just like with 
preserve_access_index() built-in, for easy future extension. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74668



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


[PATCH] D79118: Implement _ExtInt ABI for all ABIs in Clang, enable type for ABIs

2020-05-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 261523.
erichkeane retitled this revision from "[WIP] _ExtInt calling convention Audit" 
to "Implement _ExtInt ABI for all ABIs in Clang, enable type for ABIs".
erichkeane edited the summary of this revision.
erichkeane added a subscriber: cfe-commits.
erichkeane added a comment.
Herald added subscribers: kerbowa, luismarques, apazos, sameer.abuasal, pzheng, 
lenary, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
atanasyan, edward-jones, zzheng, MaskRay, niosHD, sabuasal, johnrusso, rbar, 
asb, kbarton, jgravelle-google, sbc100, nhaehnle, jvesely, nemanjai, sdardis, 
jyknight, jholewinski.

@rjmccall

Alright, i finished the audit and finished all of the ABIs, as well as wrote 
tests for each.  I added a test for situations that I'd not previously covered 
as well.

Can you please review when you can/suggest others to do so?

Thanks!


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

https://reviews.llvm.org/D79118

Files:
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARC.h
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/Hexagon.h
  clang/lib/Basic/Targets/Lanai.h
  clang/lib/Basic/Targets/Mips.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/PNaCl.h
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/Sparc.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/XCore.h
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ext-int-cc.c
  clang/test/CodeGen/ext-int-sanitizer.cpp
  clang/test/CodeGenCXX/ext-int.cpp

Index: clang/test/CodeGenCXX/ext-int.cpp
===
--- clang/test/CodeGenCXX/ext-int.cpp
+++ clang/test/CodeGenCXX/ext-int.cpp
@@ -98,7 +98,7 @@
 };
 
 void UnderlyingTypeUsage(AsEnumUnderlyingType Param) {
-  // LIN: define void @_Z19UnderlyingTypeUsage20AsEnumUnderlyingType(i16 %
+  // LIN: define void @_Z19UnderlyingTypeUsage20AsEnumUnderlyingType(i9 signext %
   // WIN: define dso_local void @"?UnderlyingTypeUsage@@YAXW4AsEnumUnderlyingType@@@Z"(i9 %
   AsEnumUnderlyingType Var;
   // CHECK: alloca i9, align 2
Index: clang/test/CodeGen/ext-int-sanitizer.cpp
===
--- clang/test/CodeGen/ext-int-sanitizer.cpp
+++ clang/test/CodeGen/ext-int-sanitizer.cpp
@@ -145,8 +145,7 @@
 
   // Also triggers signed integer overflow.
   E / E;
-  // CHECK: %[[E1LOAD:.+]] = load i11
-  // CHECK: store i11 %[[E1LOAD]], i11* %[[EADDR:.+]]
+  // CHECK: %[[EADDR:.+]] = alloca i11
   // CHECK: %[[E:.+]] = load i11, i11* %[[EADDR]]
   // CHECK: %[[E2:.+]] = load i11, i11* %[[EADDR]]
   // CHECK: %[[NEZERO:.+]] = icmp ne i11 %[[E2]], 0
@@ -163,8 +162,7 @@
 // CHECK: define void @_Z6ShiftsU7_ExtIntILi9EEi
 void Shifts(_ExtInt(9) E) {
   E >> E;
-  // CHECK: %[[E1LOAD:.+]] = load i9, i9*
-  // CHECK: store i9 %[[E1LOAD]], i9* %[[EADDR:.+]]
+  // CHECK: %[[EADDR:.+]] = alloca i9
   // CHECK: %[[LHSE:.+]] = load i9, i9* %[[EADDR]]
   // CHECK: %[[RHSE:.+]] = load i9, i9* %[[EADDR]]
   // CHECK: %[[CMP:.+]] = icmp ule i9 %[[RHSE]], 8
@@ -227,8 +225,7 @@
  unsigned _ExtInt(23) SmallE,
  unsigned _ExtInt(35) BigE) {
   u = SmallE + SmallE;
-  // CHECK: %[[LOADBIGGESTE2:.+]] = load i23
-  // CHECK: store i23 %[[LOADBIGGESTE2]], i23* %[[BIGGESTEADDR:.+]]
+  // CHECK: %[[BIGGESTEADDR:.+]] = alloca i23
   // CHECK: %[[LOADE1:.+]] = load i23, i23* %[[BIGGESTEADDR]]
   // CHECK: %[[LOADE2:.+]] = load i23, i23* %[[BIGGESTEADDR]]
   // CHECK: %[[OFCALL:.+]] = call { i23, i1 } @llvm.uadd.with.overflow.i23(i23 %[[LOADE1]], i23 %[[LOADE2]])
Index: clang/test/CodeGen/ext-int-cc.c
===
--- clang/test/CodeGen/ext-int-cc.c
+++ clang/test/CodeGen/ext-int-cc.c
@@ -2,6 +2,32 @@
 // RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=WIN64
 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=LIN32
 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=WIN32
+// RUN: %clang_cc1 -triple le32-nacl -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=NACL
+// RUN: %clang_cc1 -triple nvptx64 -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=NVPTX64
+// RUN: %clang_cc1 -triple nvptx -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=NVPTX
+// RUN: %clang_cc1 -triple sparcv9 -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=SPARCV9
+// RUN: %clang_cc1 -triple sparc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --c

[PATCH] D79118: Implement _ExtInt ABI for all ABIs in Clang, enable type for ABIs

2020-05-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 261524.
erichkeane edited the summary of this revision.
erichkeane added a comment.
Herald added a subscriber: wuzish.

Remove test for which there is no longer a target where extint isn't supported 
(thus I cannot spell the condition).  Also, clang-formatted the previous 
revision.


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

https://reviews.llvm.org/D79118

Files:
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARC.h
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/Hexagon.h
  clang/lib/Basic/Targets/Lanai.h
  clang/lib/Basic/Targets/Mips.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/PNaCl.h
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/Sparc.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/XCore.h
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ext-int-cc.c
  clang/test/CodeGen/ext-int-sanitizer.cpp
  clang/test/CodeGenCXX/ext-int.cpp
  clang/test/Sema/ext-int-not-supported.c

Index: clang/test/Sema/ext-int-not-supported.c
===
--- clang/test/Sema/ext-int-not-supported.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s
-
-void foo() {
-  _ExtInt(33) a; // expected-error{{_ExtInt is not supported on this target}}
-}
Index: clang/test/CodeGenCXX/ext-int.cpp
===
--- clang/test/CodeGenCXX/ext-int.cpp
+++ clang/test/CodeGenCXX/ext-int.cpp
@@ -98,7 +98,7 @@
 };
 
 void UnderlyingTypeUsage(AsEnumUnderlyingType Param) {
-  // LIN: define void @_Z19UnderlyingTypeUsage20AsEnumUnderlyingType(i16 %
+  // LIN: define void @_Z19UnderlyingTypeUsage20AsEnumUnderlyingType(i9 signext %
   // WIN: define dso_local void @"?UnderlyingTypeUsage@@YAXW4AsEnumUnderlyingType@@@Z"(i9 %
   AsEnumUnderlyingType Var;
   // CHECK: alloca i9, align 2
Index: clang/test/CodeGen/ext-int-sanitizer.cpp
===
--- clang/test/CodeGen/ext-int-sanitizer.cpp
+++ clang/test/CodeGen/ext-int-sanitizer.cpp
@@ -145,8 +145,7 @@
 
   // Also triggers signed integer overflow.
   E / E;
-  // CHECK: %[[E1LOAD:.+]] = load i11
-  // CHECK: store i11 %[[E1LOAD]], i11* %[[EADDR:.+]]
+  // CHECK: %[[EADDR:.+]] = alloca i11
   // CHECK: %[[E:.+]] = load i11, i11* %[[EADDR]]
   // CHECK: %[[E2:.+]] = load i11, i11* %[[EADDR]]
   // CHECK: %[[NEZERO:.+]] = icmp ne i11 %[[E2]], 0
@@ -163,8 +162,7 @@
 // CHECK: define void @_Z6ShiftsU7_ExtIntILi9EEi
 void Shifts(_ExtInt(9) E) {
   E >> E;
-  // CHECK: %[[E1LOAD:.+]] = load i9, i9*
-  // CHECK: store i9 %[[E1LOAD]], i9* %[[EADDR:.+]]
+  // CHECK: %[[EADDR:.+]] = alloca i9
   // CHECK: %[[LHSE:.+]] = load i9, i9* %[[EADDR]]
   // CHECK: %[[RHSE:.+]] = load i9, i9* %[[EADDR]]
   // CHECK: %[[CMP:.+]] = icmp ule i9 %[[RHSE]], 8
@@ -227,8 +225,7 @@
  unsigned _ExtInt(23) SmallE,
  unsigned _ExtInt(35) BigE) {
   u = SmallE + SmallE;
-  // CHECK: %[[LOADBIGGESTE2:.+]] = load i23
-  // CHECK: store i23 %[[LOADBIGGESTE2]], i23* %[[BIGGESTEADDR:.+]]
+  // CHECK: %[[BIGGESTEADDR:.+]] = alloca i23
   // CHECK: %[[LOADE1:.+]] = load i23, i23* %[[BIGGESTEADDR]]
   // CHECK: %[[LOADE2:.+]] = load i23, i23* %[[BIGGESTEADDR]]
   // CHECK: %[[OFCALL:.+]] = call { i23, i1 } @llvm.uadd.with.overflow.i23(i23 %[[LOADE1]], i23 %[[LOADE2]])
Index: clang/test/CodeGen/ext-int-cc.c
===
--- clang/test/CodeGen/ext-int-cc.c
+++ clang/test/CodeGen/ext-int-cc.c
@@ -2,6 +2,32 @@
 // RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=WIN64
 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=LIN32
 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=WIN32
+// RUN: %clang_cc1 -triple le32-nacl -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=NACL
+// RUN: %clang_cc1 -triple nvptx64 -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=NVPTX64
+// RUN: %clang_cc1 -triple nvptx -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=NVPTX
+// RUN: %clang_cc1 -triple sparcv9 -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=SPARCV9
+// RUN: %clang_cc1 -triple sparc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=SPARC
+// RUN: %clang_cc1 -triple mips64 -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=MIPS64
+// RUN: %clang_cc1 -triple mips -O3 -disable-llvm-pas

[PATCH] D77836: [Attribute] Fix noderef attribute false-negatives

2020-05-01 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 261519.
leonardchan marked 6 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77836

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Frontend/noderef.cpp

Index: clang/test/Frontend/noderef.cpp
===
--- clang/test/Frontend/noderef.cpp
+++ clang/test/Frontend/noderef.cpp
@@ -80,12 +80,28 @@
   int member;
   int NODEREF *member2;
   int NODEREF member3; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *member4;
+
+  int func() { return member; }
+  virtual int func_virt() { return member; }
+
+  A(NODEREF int *x) : member4(x) {} // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
 };
 
+class Child : public A {};
+
 void MemberPointer() {
   int NODEREF A::*var = &A::member; // expected-warning{{'noderef' can only be used on an array or pointer type}}
 }
 
+int MethodCall(NODEREF A *a) { // expected-note{{a declared here}}
+  return a->func();// expected-warning{{dereferencing a; was declared with a 'noderef' type}}
+}
+
+int ChildCall(NODEREF Child *child) { // expected-note{{child declared here}}
+  return child->func();   // expected-warning{{dereferencing child; was declared with a 'noderef' type}}
+}
+
 template 
 class B {
   Ty NODEREF *member;
@@ -100,3 +116,53 @@
 
 int NODEREF *glob_ptr;  // expected-note{{glob_ptr declared here}}
 int glob_int = *glob_ptr;  // expected-warning{{dereferencing glob_ptr; was declared with a 'noderef' type}}
+
+void cast_from_void_ptr(NODEREF void *x) {
+  int *a = static_cast(x);  // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+
+  // Allow regular C-style casts and C-style through reinterpret_casts to be holes
+  int *b = reinterpret_cast(x);
+  int *c = (int *)x;
+}
+
+void conversion_sequences() {
+  NODEREF int *x;
+  int *x2 = x; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+  int *x3 = static_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+  int *x4 = reinterpret_cast(x);
+
+  // Functional cast - This is exactly equivalent to a C-style cast.
+  typedef int *INT_PTR;
+  int *x5 = INT_PTR(x);
+
+  NODEREF Child *child;
+  Child *child2 = dynamic_cast(child); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+int *static_cast_from_same_ptr_type(NODEREF int *x) {
+  return static_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+A *dynamic_cast_up(NODEREF Child *child) {
+  return dynamic_cast(child); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+Child *dynamic_cast_down(NODEREF A *a) {
+  return dynamic_cast(a); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+A *dynamic_cast_side(NODEREF A *a) {
+  return dynamic_cast(a); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+void *dynamic_cast_to_void_ptr(NODEREF A *a) {
+  return dynamic_cast(a); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+int *const_cast_check(NODEREF const int *x) {
+  return const_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+const int *const_cast_check(NODEREF int *x) {
+  return const_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -8179,9 +8179,13 @@
 if (const auto *ToPtrType = Step->Type->getAs()) {
   if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
   !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
-S.Diag(CurInit.get()->getExprLoc(),
-   diag::warn_noderef_to_dereferenceable_pointer)
-<< CurInit.get()->getSourceRange();
+// Do not check static casts here because they are checked earlier
+// in Sema::ActOnCXXNamedCast()
+if (!Kind.isStaticCast()) {
+  S.Diag(CurInit.get()->getExprLoc(),
+ diag::warn_noderef_to_dereferenceable_pointer)
+  << CurInit.get()->getSourceRange();
+}
   }
 }
   }
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -159,6 +159,30 @@
   PlaceholderKind = (BuiltinType::Kind) 0;
   

[PATCH] D77836: [Attribute] Fix noderef attribute false-negatives

2020-05-01 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2557-2558
   return;
+CheckNoDeref(Self, SrcExpr.get()->getType(), ResultType,
+ OpRange.getBegin());
   }

rsmith wrote:
> Should we be checking this for a C-style cast?  You previously said  you were 
> going to turn off the checks for C-style casts. Did you change your mind on 
> that?
No, you're right. I accidentally left this in.



Comment at: clang/lib/Sema/SemaCast.cpp:2982
 
+  CheckNoDeref(*this, Op.SrcExpr.get()->getType(), Op.ResultType, LPLoc);
+

rsmith wrote:
> As above, should we be checking this for a C-style cast? (It also looks like 
> we're doing this check twice in C++.)
Also accidentally left this in.



Comment at: clang/lib/Sema/SemaInit.cpp:8182-8184
+// Do not check static casts here because they are checked earlier
+// in Sema::ActOnCXXNamedCast()
+if (!Kind.isStaticCast()) {

rsmith wrote:
> leonardchan wrote:
> > leonardchan wrote:
> > > rsmith wrote:
> > > > Are there any `static_cast` cases that don't get here? I'm also a 
> > > > little surprised that `static_cast` would get here but the 
> > > > `static_cast` interpretation of a C-style or functional cast would not.
> > > I'll double check on this. The reason I added this here was because the 
> > > cast in `static_cast_from_same_ptr_type()` triggered 2 of the 
> > > `warn_noderef_to_dereferenceable_pointer` warnings and one of them was 
> > > triggered here.
> > Yeah it seems the `int *a = static_cast(x);` case in 
> > `cast_from_void_ptr()` is an example of a static_cast that doesn't go 
> > through here.
> I see, this is only reached for the part of `static_cast` that considers 
> implicit conversion sequences. OK.
> 
> I expect there's similar overlap for all the other kinds of cast too. Should 
> we be suppressing this check for *all* casts, given that we perform the check 
> in `SemaCast` instead?
Hmm. I think for this particular location, `static_cast` contexts are all we 
need to suppress it for to prevent duplicate warnings from showing.

We don't need to suppress for these since the attribute is allowed to pass 
through these:
```
IC_CStyleCast
IC_FunctionalCast
```

We perform the check for implicit casts here since (AFAICT) only explicit casts 
(C-style, functional, and C++ style) seem to be covered in `SemaCast`:
```
IC_Implicit
```
This would cover cases like `int *ptr = noderef_ptr;`.

I'm not sure about these ones, but none of the cases I have seem to fail if I 
suppress only them:
```
IC_Normal
IC_ExplicitConvs
```

It could be though that there's a particular case I'm not covering in my tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77836



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


[PATCH] D79186: [OPENMP]Consider 'omp_null_allocator' as a predefined allocator.

2020-05-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 261513.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79186

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/allocate_allocator_ast_print.cpp
  clang/test/OpenMP/allocate_allocator_messages.cpp
  clang/test/OpenMP/master_taskloop_firstprivate_messages.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_messages.cpp
  clang/test/OpenMP/master_taskloop_lastprivate_messages.cpp
  clang/test/OpenMP/master_taskloop_private_messages.cpp
  clang/test/OpenMP/master_taskloop_reduction_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_firstprivate_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_lastprivate_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_linear_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_private_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_reduction_messages.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_firstprivate_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_reduction_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_linear_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_reduction_messages.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_ast_print.cpp
  clang/test/OpenMP/target_parallel_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_ast_print.cpp
  clang/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_lastprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_linear_messages.cpp
  clang/test/OpenMP/target_parallel_for_private_messages.cpp
  clang/test/OpenMP/target_parallel_for_reduction_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_ast_print.cpp
  clang/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_lastprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp
  clang/test/OpenMP/target_parallel_private_messages.cpp
  clang/test/OpenMP/target_parallel_reduction_messages.cpp
  clang/test/OpenMP/target_private_messages.cpp
  clang/test/OpenMP/target_reduction_messages.cpp
  clang/test/OpenMP/target_simd_ast_print.cpp
  clang/test/OpenMP/target_simd_firstprivate_messages.cpp
  clang/test/OpenMP/target_simd_lastprivate_messages.cpp
  clang/test/OpenMP/target_simd_linear_messages.cpp
  clang/test/OpenMP/target_simd_private_messages.cpp
  clang/test/OpenMP/target_simd_reduction_messages.cpp
  clang/test/OpenMP/target_teams_ast_print.cpp
  clang/test/OpenMP/target_teams_distribute_ast_print.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_ast_print.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_messages.cpp
  clang/test/OpenMP/target_teams_distribute_private_messages.cpp
  clang/test/OpenMP/target_teams_distribute_reduction_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_ast_print.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_lastprivate_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_private_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_reduction

[PATCH] D77910: AMDGPU: Define cl_khr_gl_sharing as a supported extension

2020-05-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D77910#1989163 , @b-sumner wrote:

> In D77910#1988807 , @arsenm wrote:
>
> > In D77910#1981828 , @b-sumner 
> > wrote:
> >
> > > In D77910#1981429 , @arsenm 
> > > wrote:
> > >
> > > > In D77910#1976171 , @b-sumner 
> > > > wrote:
> > > >
> > > > > I don't think we can guarantee this is or will be supported on all 
> > > > > devices.  The language runtime makes this decision.
> > > >
> > > >
> > > > We don't need to worry about theoretical devices. We should know the 
> > > > properties of the driver from -amdhsa, -amdpal, -mesa3d
> > >
> > >
> > > It takes more than support in the ISA for some features.  The OpenCL 
> > > driver may not want to support a given optional feature, e.g. images.  
> > > I'm not opposed to defaults, but if the driver chooses to not support 
> > > images, it needs to be able to prevent `__IMAGE_SUPPORT__` from being 
> > > defined.  Conformance will fail if the runtime and compiler are not 
> > > consistent.
> >
> >
> > The driver details should be captured by the the triple. If some weird 
> > driver decided to do something different, we would need to add a new triple 
> > for it. We don't have such a driver, so I don't see why worry about it. 
> > It's possible to work around with undef and redef in an implicitly included 
> > header. We need to fix properties of the driver based on the target to have 
> > perfectly matching offline compilation
>
>
> I don't see anywhere in the triple talking about driver specific details, 
> unless you would use the environment?  That seems like overkill to me.  But 
> again, I'm not opposed to defaults, and as long as the driver can override 
> them, this should be OK.


The OS is the driver. It doesn't need to specifically encode these details; the 
OS should encode properties of the driver environment. Anything using -amdhsa 
should be reporting image support


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

https://reviews.llvm.org/D77910



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


[PATCH] D78979: OpenCL: Include builtin header by default

2020-05-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D78979#2010739 , @Anastasia wrote:

> In D78979#2010527 , @svenvh wrote:
>
> > In D78979#2007643 , @Anastasia 
> > wrote:
> >
> > > > Would it not become confusing since the builtins are going to be 
> > > > included by default? Should we rename the flag at least? Also ideally 
> > > > it should be documented in 
> > > > https://clang.llvm.org/docs/UsersManual.html#opencl-header
> > >
> > > ah I guess if we leave it under `-cc1 ` we will have the command line 
> > > interface as follows:
> > >
> > > - Driver (without `-cc1`) adds OpenCL header by default that can be 
> > > overridden by the flag added in this patch.
> > > - Frontend (with `-cc1`) doesn't add the header by default but there are 
> > > two flags `-fdeclare-opencl-builtins` or `-finclude-default-header` that 
> > > allow to include the header.
> >
> >
> > The name of `-fdeclare-opencl-builtins` becomes a bit non-intuitive, a more 
> > intuitive name would be something like `-fopencl-tablegen-builtins` perhaps 
> > or `-fopencl-fast-builtins` if we don't want to mention TableGen.  But 
> > since it is still an experimental option, I have no objections against 
> > postponing the renaming until the option has reached maturity.
>
>
> I vote for `-fopencl-fast-builtins`.


The main problem I'm trying to solve is that users shouldn't need to concern 
themselves with including any header, much less a choice between two internal 
implementation details. Switching the two internal header implementations seems 
OK to leave as a cc1 flag. The main question I think is what the spelling of 
how to disable whatever default header was chosen, and what the internal flags 
to switch the implementation look like.

So what's the agreement on spelling? Use -nostdinc/-nostdlib? Have 2 different 
cc1 flags for the header implementation switch? Surface/invert 
-fno-include-default-header?


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

https://reviews.llvm.org/D78979



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


[PATCH] D78429: [clangd] Metric tracking through Tracer

2020-05-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 261514.
kadircet added a comment.

- Track renamed files instead of occurences


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78429

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/support/Trace.cpp
  clang-tools-extra/clangd/support/Trace.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/LSPClient.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTracer.h
  clang-tools-extra/clangd/unittests/support/TestTracer.cpp
  clang-tools-extra/clangd/unittests/support/TestTracer.h
  clang-tools-extra/clangd/unittests/support/TraceTests.cpp

Index: clang-tools-extra/clangd/unittests/support/TraceTests.cpp
===
--- clang-tools-extra/clangd/unittests/support/TraceTests.cpp
+++ clang-tools-extra/clangd/unittests/support/TraceTests.cpp
@@ -6,10 +6,12 @@
 //
 //===--===//
 
+#include "support/Context.h"
+#include "support/TestTracer.h"
 #include "support/Trace.h"
-
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/YAMLParser.h"
@@ -20,6 +22,8 @@
 namespace clangd {
 namespace {
 
+using testing::SizeIs;
+
 MATCHER_P(StringNode, Val, "") {
   if (arg->getType() != llvm::yaml::Node::NK_Scalar) {
 *result_listener << "is a " << arg->getVerbatimTag();
@@ -122,6 +126,18 @@
   ASSERT_EQ(++Prop, Root->end());
 }
 
+TEST(MetricsTracer, LatencyTest) {
+  trace::TestTracer Tracer;
+  constexpr llvm::StringLiteral MetricName = "span_latency";
+  constexpr llvm::StringLiteral OpName = "op_name";
+  {
+// A span should record latencies to span_latency by default.
+trace::Span SpanWithLat(OpName);
+EXPECT_THAT(Tracer.takeMetric(MetricName, OpName), SizeIs(0));
+  }
+  EXPECT_THAT(Tracer.takeMetric(MetricName, OpName), SizeIs(1));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/support/TestTracer.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/support/TestTracer.h
@@ -0,0 +1,49 @@
+//===-- TestTracer.h *- 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
+//
+//===--===//
+//
+// Allows setting up a fake tracer for tests.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SUPPORT_TESTTRACER_H
+#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SUPPORT_TESTTRACER_H
+
+#include "support/Trace.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace trace {
+
+/// A RAII Tracer that can be used by tests.
+class TestTracer : public EventTracer {
+public:
+  TestTracer() : Session(*this) {}
+  /// Stores all the measurements to be returned with take later on.
+  void record(const Metric &Metric, double Value,
+  llvm::StringRef Label) override;
+
+  /// Returns recorded measurements for \p Metric and clears them.
+  std::vector takeMetric(llvm::StringRef Metric,
+ llvm::StringRef Label = "");
+
+private:
+  std::mutex Mu;
+  /// Measurements recorded per metric per label.
+  llvm::StringMap>> Measurements;
+  Session Session;
+};
+
+} // namespace trace
+} // namespace clangd
+} // namespace clang
+#endif
Index: clang-tools-extra/clangd/unittests/support/TestTracer.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/support/TestTracer.cpp
@@ -0,0 +1,37 @@
+//===-- TestTracer.cpp - Tracing unit tests -*- 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
+//
+//===--===//
+#include "TestTracer.h"
+#include "support/Trace.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace trace {
+
+void TestTracer::record(

[PATCH] D78655: [HIP] Let lambda be host device by default

2020-05-01 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

> It captures addresses as seen at the point in time on the processor which 
> executed the constructor.

Yea and the same happens when assigning the address to a pointer, which is 
later used on a different device.

> Another point that capturing lambdas are not something ready for the prime 
> time.

The same issues exist with functions. We dont prevent passing a pointer to host 
memory to a device function. I guess because the analysis to do so is 
incomplete and expensive. A lambda capturing by reference does seem simpler to 
analyze at least for implicit HD.

> Could you elaborate? I'm not sure what you mean by we seem to delay this and 
> what does it have to do with the assertion that lambdas are not always 
> constexpr by default?

Lambdas are not always `constexpr`, and this patch doesnt make lambdas to 
always be generated for host and device, even though, it does always have a HD 
attribute. Instead it pushes the decision to emit the lambda for host or device 
to later when we are emitting the code for codegen(at least thats how I 
understand this happening, @yaxunl can correct me if I am wrong here).

> I think it's done here:

I actually meant how constexpr lambdas was implemented, which I can see here:

https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaExpr.cpp#L16087

It doesn't annotate a lambda as `constexpr`. Instead it tries to evaluate all 
lambdas as `constexpr` when its used in `constexpr` context. This is similar to 
what we do for HD. We treat all lambdas as HD, but then only emit it for the 
device when its called in a device function. The big difference is that 
`constexpr` doesn't participate in overload resolution so constexpr lambdas are 
not observable by the user whereas host and device attributes are.

> We basically slap implicit HD on constexpr functions when we process function 
> declarations. It's likely that lambdas may go through a different code path 
> and miss this.

Yea, which wont work for lambdas since `NewD->isConstexpr()` will return 
false(unless the user explicitly adds `constexpr`). We could traverse the AST 
to see if the lambda only calls constexpr functions and then annotate it with 
HD(we could also extend this to HD functions as well). However, this seems 
costly.

It would be better to take the same approach for `constexpr` lambdas and treat 
all lambdas as potentially HD(which is what this patch seems to do).


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

https://reviews.llvm.org/D78655



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-05-01 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D78979: OpenCL: Include builtin header by default

2020-05-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D78979#2011582 , @jvesely wrote:

> In D78979#2006901 , @yaxunl wrote:
>
> > In D78979#2006847 , @arsenm wrote:
> >
> > > I'm also wondering if using -nogpulib for the corresponding linker 
> > > purpose was correct, since in the OpenCL case it's not really an offload 
> > > target. Maybe this should switch to -nostdlib?
> >
> >
> > -nogpulib is fine since opencl compiler is in parallel with the device 
> > compiler of CUDA/HIP. The library it uses is the device library.
>
>
> OpenCL can target other devices than GPUs, including CPUs and FPGAs, 
> referring to gpulibs wrt opencl is a misnomer.


It makes sense to have a separate flag from -nostdiinc for CUDA/HIP/OpenMP 
since you have to consider both the host and offload target code.

> It would be nice to have some clarity as to how OpenCL is handled wrt clang 
> frontend vs. clang driver.
>  OpenCL options are currently split between the two (e.g. cl-denorms-are-zero 
> is only available in the driver and not the frontend)

Users shouldn't ever need to concern themselves with cc1 flags. That's part of 
the issue with not including the header by default today. Only the user facing 
driver should be guaranteed to have all the spec flags

> There are 3 implementations of CL headers, two in clang which might or might 
> not be included by default, and the 3rd one in libclc.

I think the libclc header should just be removed


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

https://reviews.llvm.org/D78979



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


[PATCH] D76496: [clang-tidy] add support to 3-arg find() in StringFindStartswith

2020-05-01 Thread Niko Weh via Phabricator via cfe-commits
niko added a comment.

In D76496#1976713 , @njames93 wrote:

> In D76496#1949851 , @niko wrote:
>
> > Correct me if I'm wrong, but that seems to be in violation of IWYU? Maybe 
> > I'm misreading this, or is the idea that higher-lever tooling (e.g. IWYU 
> > fixer) is supposed to address that?
>
>
> It is but it sort of gets a pass as the absl/strings/match.h has to include 
> it. 
>  Similar to how if you `#include `, you wouldn't then `#include 
> ` so you could construct a `std::vector` using a 
> `std::initializer_list`.


Makes sense. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76496



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


[PATCH] D78980: Elaborate more on --rocm-path flag.

2020-05-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked an inline comment as done.
arsenm added inline comments.



Comment at: clang/include/clang/Driver/Options.td:612
 def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group,
-  HelpText<"ROCm installation path">;
+  HelpText<"ROCm installation path, used for finding and automatically linking 
required bitcode libraries.">;
 def hip_device_lib_path_EQ : Joined<["--"], "hip-device-lib-path=">, 
Group,

yaxunl wrote:
> we also want to use this for adding include and library path for HIP.
It doesn't actually do that yet though


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

https://reviews.llvm.org/D78980



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


[PATCH] D76496: [clang-tidy] add support to 3-arg find() in StringFindStartswith

2020-05-01 Thread Niko Weh via Phabricator via cfe-commits
niko updated this revision to Diff 261512.
niko added a comment.

[clang-tidy] add 3-arg support to StringFindStartswith via string_view


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76496

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-startswith.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-startswith.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-startswith.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-startswith.cpp
@@ -13,6 +13,7 @@
   ~basic_string();
   int find(basic_string s, int pos = 0);
   int find(const char *s, int pos = 0);
+  int find(const char *s, int pos, int n);
 };
 typedef basic_string string;
 typedef basic_string wstring;
@@ -41,6 +42,10 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
   // CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, s);{{$}}
 
+  s.find(s, 0) == 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
+  // CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, s);{{$}}
+
   s.find("aaa") != 0;
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StartsWith
   // CHECK-FIXES: {{^[[:space:]]*}}!absl::StartsWith(s, "aaa");{{$}}
@@ -61,9 +66,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
   // CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s2, "a");{{$}}
 
+  s.find("a", 0, 1) == 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StartsWith
+  // CHECK-FIXES: {{^[[:space:]]*}}absl::StartsWith(s, absl::string_view("a", 
1));{{$}}
+
   // expressions that don't trigger the check are here.
   A_MACRO(s.find("a"), 0);
   s.find("a", 1) == 0;
   s.find("a", 1) == 1;
   s.find("a") == 1;
+  s.find("a", 1, 1) == 0;
 }
Index: clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -40,12 +40,13 @@
 
   auto StringFind = cxxMemberCallExpr(
   // .find()-call on a string...
-  callee(cxxMethodDecl(hasName("find"))),
-  on(hasType(StringType)),
+  callee(cxxMethodDecl(hasName("find"))), on(hasType(StringType)),
   // ... with some search expression ...
   hasArgument(0, expr().bind("needle")),
   // ... and either "0" as second argument or the default argument (also 
0).
-  anyOf(hasArgument(1, ZeroLiteral), hasArgument(1, cxxDefaultArgExpr(;
+  anyOf(hasArgument(1, ZeroLiteral), hasArgument(1, cxxDefaultArgExpr())),
+  // ... and optionally a third argument for 'search string length'.
+  optionally(hasArgument(2, expr().bind("needle_length";
 
   Finder->addMatcher(
   // Match [=!]= with a zero on one side and a string.find on the other.
@@ -69,6 +70,7 @@
   const Expr *Haystack = Result.Nodes.getNodeAs("findexpr")
  ->getImplicitObjectArgument();
   assert(Haystack != nullptr);
+  const auto *NeedleLength = Result.Nodes.getNodeAs("needle_length");
 
   if (ComparisonExpr->getBeginLoc().isMacroID())
 return;
@@ -82,6 +84,21 @@
   CharSourceRange::getTokenRange(Haystack->getSourceRange()), Source,
   Context.getLangOpts());
 
+  // If there is a third argument (search string length), create an
+  // absl::string_view(search string, search string length) and use that
+  // as the search string in StartsWith.
+  std::string NewNeedleStr;
+  if (NeedleLength != nullptr) {
+const StringRef NeedleLengthCode = Lexer::getSourceText(
+CharSourceRange::getTokenRange(NeedleLength->getSourceRange()), Source,
+Context.getLangOpts());
+NewNeedleStr = std::string("absl::string_view(") +
+NeedleExprCode.str() + ", " + NeedleLengthCode.str() +
+")";
+  } else {
+NewNeedleStr = NeedleExprCode.str();
+  }
+
   // Create the StartsWith string, negating if comparison was "!=".
   bool Neg = ComparisonExpr->getOpcodeStr() == "!=";
   StringRef StartswithStr;
@@ -100,7 +117,7 @@
 
   Diagnostic << FixItHint::CreateReplacement(
   ComparisonExpr->getSourceRange(),
-  (StartswithStr + "(" + HaystackExprCode + ", " + NeedleExprCode + ")")
+  (StartswithStr + "(" + HaystackExprCode + ", " + NewNeedleStr + ")")
   .str());
 
   // Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks


Index: clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-startswith.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-startswith.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-starts

[PATCH] D79249: [NOT FOR REVIEW] Experimental support for zero-or-trap behavior foruninitialized variables.

2020-05-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 261511.
rsmith added a comment.

- The second operand of 'store' is the pointer, not the first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79249

Files:
  clang/lib/CodeGen/CGDecl.cpp
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp

Index: llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
===
--- llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
+++ llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
@@ -6,8 +6,9 @@
 //
 //===--===//
 //
-// This pass lowers all remaining 'objectsize' 'is.constant' intrinsic calls
-// and provides constant propagation and basic CFG cleanup on the result.
+// This pass lowers all remaining 'objectsize', 'is.constant', and 'trapping'
+// intrinsic calls and provides constant propagation and basic CFG cleanup on
+// the result.
 //
 //===--===//
 
@@ -39,6 +40,8 @@
   "Number of 'is.constant' intrinsic calls handled");
 STATISTIC(ObjectSizeIntrinsicsHandled,
   "Number of 'objectsize' intrinsic calls handled");
+STATISTIC(TrappingIntrinsicsHandled,
+  "Number of 'trapping' intrinsic calls handled");
 
 static Value *lowerIsConstantIntrinsic(IntrinsicInst *II) {
   Value *Op = II->getOperand(0);
@@ -99,6 +102,7 @@
 break;
   case Intrinsic::is_constant:
   case Intrinsic::objectsize:
+  case Intrinsic::trapping:
 Worklist.push_back(WeakTrackingVH(&I));
 break;
   }
@@ -125,6 +129,10 @@
   NewValue = lowerObjectSizeCall(II, DL, TLI, true);
   ObjectSizeIntrinsicsHandled++;
   break;
+case Intrinsic::trapping:
+  NewValue = II->getOperand(0);
+  TrappingIntrinsicsHandled++;
+  break;
 }
 HasDeadBlocks |= replaceConditionalBranchesOnConstant(II, NewValue);
   }
Index: llvm/lib/Transforms/InstCombine/InstCombineInternal.h
===
--- llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -635,6 +635,8 @@
 
   Instruction *foldIntrinsicWithOverflowCommon(IntrinsicInst *II);
 
+  bool simplifyTrappingUse(Use &U);
+
 public:
   /// Inserts an instruction \p New before instruction \p Old
   ///
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1846,6 +1846,80 @@
   return nullptr;
 }
 
+static bool canObservePoison(Use &U, Instruction *I) {
+  if (U.getOperandNo() == 0 &&
+  (isa(I) || isa(I) || isa(I)))
+return true;
+  if (auto *CB = dyn_cast(I))
+if (CB->getCalledOperandUse().getOperandNo() == U.getOperandNo())
+  return true;
+  if (auto *LI = dyn_cast(I))
+if (LI->getPointerOperandIndex() == U.getOperandNo())
+  return true;
+  if (auto *SI = dyn_cast(I))
+if (SI->getPointerOperandIndex() == U.getOperandNo())
+  return true;
+  if (U.getOperandNo() == 1 && I->isIntDivRem())
+return true;
+  // FIXME: More cases?
+  return false;
+}
+
+/// Simplify a use of @llvm.trapping.( %x)
+///
+/// Return true if we've performed a simplification and the use should be
+/// replaced by %x.
+bool InstCombiner::simplifyTrappingUse(Use &U) {
+  auto *I = dyn_cast(U.getUser());
+
+  // We only care about trapping indicators on instructions.
+  if (!I)
+return true;
+
+  // FIXME: If all operands are trapping, we can convert to trapping(phi(...)).
+  if (isa(I))
+return false;
+
+  // The result of select is trapping if its condition is trapping.
+  if (isa(I) && U.getOperandNo() != 0)
+return false;
+
+  // trapping(trapping(x)) -> trapping(x).
+  if (auto *II = dyn_cast(I))
+if (II->getIntrinsicID() == Intrinsic::trapping)
+  return true;
+
+  // op(trapping(x)) -> @llvm.trap() where possible.
+  if (canObservePoison(U, I)) {
+CallInst *Trap = CallInst::Create(
+Intrinsic::getDeclaration(I->getModule(), Intrinsic::trap));
+InsertNewInstBefore(Trap, *I);
+return true;
+  }
+
+  // We can't propagate trapping to the result of a void-typed instruction and
+  // a few other cases.
+  if (I->getType()->isVoidTy() || I->getType()->isTokenTy() ||
+  I->isTerminator())
+return false;
+
+  /

[PATCH] D78660: [SemaObjC] Add a warning for dictionary literals with duplicate keys

2020-05-01 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


Repository:
  rC Clang

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

https://reviews.llvm.org/D78660



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


[PATCH] D79223: Fix pr31836 on Windows too, and correctly handle repeated separators.

2020-05-01 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis marked an inline comment as done.
thakis added a comment.

Thanks!


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

https://reviews.llvm.org/D79223



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


[PATCH] D78129: Add Marvell ThunderX3T110 support

2020-05-01 Thread Wei Zhao via Phabricator via cfe-commits
wxz2020 updated this revision to Diff 261497.
wxz2020 marked an inline comment as done.
wxz2020 added a comment.

fixed all the feedback suggestions. Thanks,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78129

Files:
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SchedA53.td
  llvm/lib/Target/AArch64/AArch64SchedA57.td
  llvm/lib/Target/AArch64/AArch64SchedCyclone.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM3.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM4.td
  llvm/lib/Target/AArch64/AArch64SchedExynosM5.td
  llvm/lib/Target/AArch64/AArch64SchedFalkor.td
  llvm/lib/Target/AArch64/AArch64SchedKryo.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX2T99.td
  llvm/lib/Target/AArch64/AArch64SchedThunderX3T110.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/aarch64-combine-fmul-fsub.mir
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
  llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -943,6 +943,11 @@
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
   AArch64::AEK_RDM | AArch64::AEK_FP | AArch64::AEK_SIMD, "8.1-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "thunderx3t110", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
+  AArch64::AEK_RDM | AArch64::AEK_FP | AArch64::AEK_SIMD |
+  AArch64::AEK_RAS | AArch64::AEK_PROFILE, "8.3-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "thunderx", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_SIMD |
   AArch64::AEK_FP | AArch64::AEK_PROFILE,
@@ -977,7 +982,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 37;
+static constexpr unsigned NumAArch64CPUArchs = 38;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/remat.ll
===
--- llvm/test/CodeGen/AArch64/remat.ll
+++ llvm/test/CodeGen/AArch64/remat.ll
@@ -19,6 +19,7 @@
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=thunderx2t99 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=tsv110 -o - %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnuabi -mattr=+custom-cheap-as-move -o - %s | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=thunderx3t110 -o - %s | FileCheck %s
 
 %X = type { i64, i64, i64 }
 declare void @f(%X*)
Index: llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
===
--- llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
+++ llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
@@ -19,6 +19,7 @@
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderxt83 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderxt88 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderx2t99 < %s | FileCheck --check-prefixes=ALIGN3,CHECK %s
+; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=thunderx3t110 < %s | FileCheck --check-prefixes=ALIGN4,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=exynos-m3 < %s | FileCheck --check-prefixes=ALIGN5,CHECK %s
 
 define void @test() {
Index: llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
===
--- llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
+++ llvm/test/CodeGen/AArch64/machine-combiner-madd.ll
@@ -6,6 +6,7 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=exynos-m3  < %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=kryo   < %s | FileCheck %s
 ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=thunderx2t99 < %s | FileCheck %s
+; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=thunderx3t110 < %s | FileCheck %s
 
 ; Make sure that inst-combine fuses the multiply add in the addressing mode of
 ; the load.
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -23,6 +23,7 @@
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=saphira 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=kryo 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=thunderx2t99 2>&1 | FileC

[PATCH] D78129: Add Marvell ThunderX3T110 support

2020-05-01 Thread Wei Zhao via Phabricator via cfe-commits
wxz2020 marked 7 inline comments as done.
wxz2020 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:89
 CPU = llvm::sys::getHostCPUName();
-
   if (CPU == "generic") {

DavidSpickett wrote:
> Remove stray change.
Removed



Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:167
 AARCH64_CPU_NAME("thunderx2t99", ARMV8_1A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_NONE))
+ (AArch64::AEK_CRC | AEK_CRYPTO | AEK_FP | AEK_SIMD | AEK_LSE 
| AEK_RAND))
+AARCH64_CPU_NAME("thunderx3t110", ARMV8_3A, FK_CRYPTO_NEON_FP_ARMV8, false,

DavidSpickett wrote:
> Is this change also correcting the options for the x2t99? I think that should 
> be a separate patch if so.
I will have it removed. irrelevant to this change.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:168
+ (AArch64::AEK_CRC | AEK_CRYPTO | AEK_FP | AEK_SIMD | AEK_LSE 
| AEK_RAND))
+AARCH64_CPU_NAME("thunderx3t110", ARMV8_3A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_CRC | AEK_CRYPTO | AEK_FP | AEK_SIMD | AEK_LSE 
| AEK_RAND | AArch64::AEK_PROFILE | AArch64::AEK_RAS))

DavidSpickett wrote:
> Add a tests for this in llvm/unittests/Support/TargetParserTest.cpp (there 
> are existing ones for "thunderx2t99").
> Might need to update "NumAArch64CPUArchs" too.
OK, we will have it fixed



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:849-857
+// These pointer authentication instructions require armv8.3a
+let Predicates = [HasV8_3a, HasPA] in {
 let Uses = [LR], Defs = [LR] in {
   def PACIAZ   : SystemNoOperands<0b000, "hint\t#24">;
   def PACIBZ   : SystemNoOperands<0b010, "hint\t#26">;
   let isAuthenticated = 1 in {
 def AUTIAZ   : SystemNoOperands<0b100, "hint\t#28">;

chill wrote:
> wxz2020 wrote:
> > wxz2020 wrote:
> > > ktkachov wrote:
> > > > IIRC these instructions are deliberately allowed in pre-armv8.3 targets 
> > > > because they are encoded in the NOP-space and can be deployed on 
> > > > pre-armv8.3 targets 
> > > I will do some research on this.
> > According to the documents, pointer authenticatoin got officially 
> > supporoted starting from armv8.3.  
> These instructions are executed as NOP on pre v8.3-A architectures. It allows 
> you to have a single compatible binary that works correctly on pre v8.3-a 
> (ofc, without pointer authentication), as well as on
> 8.3-a and later cores, with pointer authentication.
> 
> Please, remove the predicates.
Agree. Will remove it.



Comment at: llvm/lib/Target/AArch64/AArch64SchedThunderX3T110.td:13
+//===--===//
+
+//===--===//

SjoerdMeijer wrote:
> I don't intend to check the numbers here, but just curious if there's an 
> optimisation guide if people are curious?
We will release a document about the details soon.



Comment at: llvm/test/CodeGen/AArch64/loop-micro-op-buffer-size-t110.ll:25
+; CHECK: %val5 = add nuw nsw i32 %counter, 10
+; CHECK-NOT: %val = add i32 %counter, 5
+; CHECK-NOT: %val = add i32 %counter, 6

SjoerdMeijer wrote:
> I guess there won't be another define %val, it will be %val6, so this 
> CHECK-NOT will never match even if there's another add?
This test is for our internal use. Sorry, Will have it removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78129



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


[PATCH] D79213: [hip] Add noalias on restrict qualified coerced hip pointers

2020-05-01 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2556-2563
+  // Restrict qualified HIP pointers that were coerced to global pointers
+  // can be marked with the noalias attribute.
+  if (isCoercedHIPGlobalPointer(*this, getLangOpts(), ArgI, Ty) &&
+  Arg->getType().isRestrictQualified()) {
+auto AI = cast(FnArgs[FirstIRArg]);
+AI->addAttr(llvm::Attribute::NoAlias);
+  }

yaxunl wrote:
> hliao wrote:
> > I don't think we need to check pointer address and/or HIP specific. As the 
> > generic argument processing, if the original type has any qualifiers, the 
> > coerced type (if it has a single value as the original parameter) should 
> > have those qualifiers as well. Here, we not only miss `restrict` but also 
> > alignment, `nonnull`, and etc. It should be fixed as a generic case instead 
> > of a target- or language-specific one.
> I agree we should migrate other argument properties for promoted pointer-type 
> kernel arg for HIP, and that should be possible since other than the address 
> space change, the type is the same.
> 
> However, I am not sure if we can do that for coerced function arguments in 
> general. It may not even be pointer any more.
If the coerced type is still a pointer but diffs on the element type, address 
space, or others. They should share the same qualifiers for pointers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79213



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


[PATCH] D79223: Fix pr31836 on Windows too, and correctly handle repeated separators.

2020-05-01 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

OK as is, but please consider re-using `llvm::sys::path` to distinguish 
separators.

Please also check that there are no regressions in the clang VFS tests.




Comment at: clang/lib/Lex/PPDirectives.cpp:2118
+return c == '/' || (BackslashIsSeparator && c == '\\');
+  };
+

Can you re-use `llvm::sys::path::is_separator` instead of inventing a new 
thing?  You can explicitly pass `llvm::path::Style::windows` if the Microsoft 
extensions are enabled.  Otherwise let it default to llvm::path::Style::native.


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

https://reviews.llvm.org/D79223



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


[PATCH] D77056: [Sema][SVE] Allow non-member operators for SVE types

2020-05-01 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

I'd like to promote this from an RFC to an RFA.  The associated cfe-dev 
discussion was:

http://lists.llvm.org/pipermail/cfe-dev/2020-March/065060.html

continuing into April here:

http://lists.llvm.org/pipermail/cfe-dev/2020-April/065069.html

I don't think there were any objections to the proposal.  In particular, in:

http://lists.llvm.org/pipermail/cfe-dev/2020-March/065062.html

Erich referred specifically to 'other' vector types, so it didn't sound like 
that was an objection to allowing overloading for these SVE types.  (The SVE 
types aren't vectors at the language level, but are instead just opaque blobs.  
The patch is specific to them, and leaves the handing of normal vectors 
unchanged.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77056



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


[PATCH] D79249: [NOT FOR REVIEW] Experimental support for zero-or-trap behavior foruninitialized variables.

2020-05-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, hiraditya.
Herald added projects: clang, LLVM.
rsmith updated this revision to Diff 261511.
rsmith added a comment.

- The second operand of 'store' is the pointer, not the first.


Add  @llvm.trapping.() intrinsic.

This is intended to produce either the given value or, if we can trace a
use of the value to an instruction with side-effects, a trap.
Notionally, it behaves as a nondeterministic choice between the given
value and poison, where the choice is made angelically such that the
given value is always chosen when the program does not reach a trap.

Simplify trapping(x) and convert it into traps where possible.

Update Clang CodeGen to produce trapping(x) in trivial auto var init
mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79249

Files:
  clang/lib/CodeGen/CGDecl.cpp
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp

Index: llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
===
--- llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
+++ llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
@@ -6,8 +6,9 @@
 //
 //===--===//
 //
-// This pass lowers all remaining 'objectsize' 'is.constant' intrinsic calls
-// and provides constant propagation and basic CFG cleanup on the result.
+// This pass lowers all remaining 'objectsize', 'is.constant', and 'trapping'
+// intrinsic calls and provides constant propagation and basic CFG cleanup on
+// the result.
 //
 //===--===//
 
@@ -39,6 +40,8 @@
   "Number of 'is.constant' intrinsic calls handled");
 STATISTIC(ObjectSizeIntrinsicsHandled,
   "Number of 'objectsize' intrinsic calls handled");
+STATISTIC(TrappingIntrinsicsHandled,
+  "Number of 'trapping' intrinsic calls handled");
 
 static Value *lowerIsConstantIntrinsic(IntrinsicInst *II) {
   Value *Op = II->getOperand(0);
@@ -99,6 +102,7 @@
 break;
   case Intrinsic::is_constant:
   case Intrinsic::objectsize:
+  case Intrinsic::trapping:
 Worklist.push_back(WeakTrackingVH(&I));
 break;
   }
@@ -125,6 +129,10 @@
   NewValue = lowerObjectSizeCall(II, DL, TLI, true);
   ObjectSizeIntrinsicsHandled++;
   break;
+case Intrinsic::trapping:
+  NewValue = II->getOperand(0);
+  TrappingIntrinsicsHandled++;
+  break;
 }
 HasDeadBlocks |= replaceConditionalBranchesOnConstant(II, NewValue);
   }
Index: llvm/lib/Transforms/InstCombine/InstCombineInternal.h
===
--- llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -635,6 +635,8 @@
 
   Instruction *foldIntrinsicWithOverflowCommon(IntrinsicInst *II);
 
+  bool simplifyTrappingUse(Use &U);
+
 public:
   /// Inserts an instruction \p New before instruction \p Old
   ///
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1846,6 +1846,80 @@
   return nullptr;
 }
 
+static bool canObservePoison(Use &U, Instruction *I) {
+  if (U.getOperandNo() == 0 &&
+  (isa(I) || isa(I) || isa(I)))
+return true;
+  if (auto *CB = dyn_cast(I))
+if (CB->getCalledOperandUse().getOperandNo() == U.getOperandNo())
+  return true;
+  if (auto *LI = dyn_cast(I))
+if (LI->getPointerOperandIndex() == U.getOperandNo())
+  return true;
+  if (auto *SI = dyn_cast(I))
+if (SI->getPointerOperandIndex() == U.getOperandNo())
+  return true;
+  if (U.getOperandNo() == 1 && I->isIntDivRem())
+return true;
+  // FIXME: More cases?
+  return false;
+}
+
+/// Simplify a use of @llvm.trapping.( %x)
+///
+/// Return true if we've performed a simplification and the use should be
+/// replaced by %x.
+bool InstCombiner::simplifyTrappingUse(Use &U) {
+  auto *I = dyn_cast(U.getUser());
+
+  // We only care about trapping indicators on instructions.
+  if (!I)
+return true;
+
+  // FIXME: If all operands are trapping, we can convert to trapping(phi(...)).
+  if (isa(I))
+return false;
+
+  // The result of select is trapping if its condition is trapping.
+  if (isa(I) && U.getOperandNo() != 0)
+return false;
+
+  // trapping(trapping(x)) -> tra

[PATCH] D79139: [clangd] Fix whitespace between chunks in markdown paragraphs.

2020-05-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet marked an inline comment as done.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks lgtm!




Comment at: clang-tools-extra/clangd/FormattedString.cpp:439
+  bool AdjacentCode =
+  !Chunks.empty() && Chunks.back().Kind == Chunk::InlineCode;
   std::string Norm = canonicalizeSpaces(std::move(Code));

sammccall wrote:
> kadircet wrote:
> > I would say we should also put a space even when the previous chunk is 
> > text, as:
> > 
> > foo`bar`
> > 
> > is also malformed.
> Do you have a reference or example for that? I can't find it in the spec, and 
> the couple of parsers I tried accept it.
i remembered this rule from emphasis(IIRC asdf_foo_bar doesn't count as 
emphasis because it is not separated from surrounding letters.), and thought it 
also applies to code spans, tried it over phab and it didn't render as inline 
:D so i didn't check more.

but you are right, looks like preceding/trailing whitespaces are not required. 
sorry for the hussle.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79139



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


[PATCH] D76689: [Sema][SVE] Fix handling of initialisers for built-in SVE types

2020-05-01 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

In D76689#1939834 , @efriedma wrote:

> Semantically, this makes sense.
>
> I'm not really happy with the use of the term "scalar initializer" to refer 
> to initializing a vector.  Seems likely to confuse users.


Yeah, fair point :-)  I've tried to use more appropriate wording in the update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76689



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


[PATCH] D72281: [Matrix] Add matrix type to Clang.

2020-05-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked 2 inline comments as done.
fhahn added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:3349
+void CXXNameMangler::mangleType(const MatrixType *T) {
+  Out << "Dm" << T->getNumRows() << "_" << T->getNumColumns() << '_';
+  mangleType(T->getElementType());

rjmccall wrote:
> fhahn wrote:
> > rjmccall wrote:
> > > You need to ask the Itanium C++ ABI for this mangling, since it's not 
> > > using a vendor-extension prefix.  I know that wasn't done for vector 
> > > types, but we're trying to do the right thing.
> > That basically means reaching out to 
> > https://github.com/itanium-cxx-abi/cxx-abi/, right?
> > 
> > Do you think it would be feasible to initially go with a vendor-extensions 
> > mangling (like `uMatrixxx`)? I've 
> > updated the mangling to this.
> Yeah, you can open an issue there.
> 
> That approach doesn't quite work because mangling the element type can use or 
> introduce substitutions, but the demangler will naturally skip the whole 
> thing.  I think there are two possible approaches here: we could either treat 
> the entire matrix type as a vendor-extended qualifier on the element type 
> (i.e. `U11matrix_typeILi3ELi4EEi`), or we could extend the vendor-extended 
> type mangling to allow template-args (i.e. `u11matrix_typeIiLi3ELi4EE`).  The 
> latter is probably better and should fit cleanly into the mangling grammar.
Thanks for those suggestions. For now I went with the vendor-extended 
qualifier, because IIUC that would fit in the existing mangling scheme without 
any changes, while the second option would require changes to the grammar, 
right?




Comment at: clang/lib/CodeGen/CGExpr.cpp:1781
+  Addr.getAlignment());
+}
+  }

rjmccall wrote:
> fhahn wrote:
> > rjmccall wrote:
> > > Please use `CreateElementBitCast`.  It's cleaner and will handle address 
> > > spaces correctly.
> > > 
> > > What are you trying to do here?  You're expecting the pointer to be a 
> > > pointer to an array, and you're casting that to a pointer to a vector of 
> > > the same number of elements?  Why not just use the vector type as the 
> > > expected memory type for the matrix type?
> > > What are you trying to do here? You're expecting the pointer to be a 
> > > pointer to an array, and you're casting that to a pointer to a vector of 
> > > the same number of elements? Why not just use the vector type as the 
> > > expected memory type for the matrix type?
> > 
> > The main reason for using an array type as expected memory type is to avoid 
> > having to use LLVM's large vector alignment for matrix values as 
> > class/struct members. Consistently using pointers to arrays as expected 
> > memory type seemed the least ugly way to handle it, but I am probably 
> > missing a much better alternative.
> > 
> >  An alternative could be to use packed LLVM structs with matrix members, 
> > but that seems more invasive.
> > 
> Clang should already handle the possibility that the LLVM type is more or 
> less aligned than the C type.  However, it does require the allocation size 
> to match the C size, and since LLVM's vector alignment rules can affect 
> vector sizes, I guess we do need to use an array instead.  This might be a 
> little awkward for IRGen, though.
> 
> You should be able to assume that the type is right for the C type.
> 
> If you're thinking of ever adding interior padding, it might be reasonable to 
> go ahead and extract functions to load/store these rather than growing those 
> operations internally in EmitLoad/StoreOfScalar.
> Clang should already handle the possibility that the LLVM type is more or 
> less aligned than the C type. However, it does require the allocation size to 
> match the C size, and since LLVM's vector alignment rules can affect vector 
> sizes, I guess we do need to use an array instead. This might be a little 
> awkward for IRGen, though.

Yes I think the main problem is when a VectorType is used in an LLVM struct, 
then LLVM's vector alignment rules may impact the overall size.

> If you're thinking of ever adding interior padding, it might be reasonable to 
> go ahead and extract functions to load/store these rather than growing those 
> operations internally in EmitLoad/StoreOfScalar.

I've moved the code to separate static functions. They don't have to be exposed 
in CodeGenFunction for now I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72281



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


[PATCH] D79223: Fix pr31836 on Windows too, and correctly handle repeated separators.

2020-05-01 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 261481.
thakis edited the summary of this revision.

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

https://reviews.llvm.org/D79223

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Lexer/case-insensitive-include-ms.c
  clang/test/Lexer/case-insensitive-include-pr31836.sh
  clang/test/Lexer/case-insensitive-include.c
  llvm/include/llvm/Support/Path.h

Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ -47,7 +47,7 @@
 ///   foo/   => foo,.
 ///   /foo/bar   => /,foo,bar
 ///   ../=> ..,.
-///   C:\foo\bar => C:,/,foo,bar
+///   C:\foo\bar => C:,\,foo,bar
 /// @endcode
 class const_iterator
 : public iterator_facade_base&1 | FileCheck %s
 
+// FIXME: Add a test with repeated backslashes once clang can handle that
+// in ms-compat mode on non-Windows hosts.
 #include "..\Output\.\case-insensitive-include.h"
 #include "..\Output\.\Case-Insensitive-Include.h" // expected-warning {{non-portable path}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\""
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1918,14 +1918,18 @@
   SourceLocation FilenameLoc = FilenameTok.getLocation();
   StringRef LookupFilename = Filename;
 
-#ifndef _WIN32
+#ifdef _WIN32
+  bool BackslashIsSeparator = true;
+#else
   // Normalize slashes when compiling with -fms-extensions on non-Windows. This
   // is unnecessary on Windows since the filesystem there handles backslashes.
   SmallString<128> NormalizedPath;
+  bool BackslashIsSeparator = false;
   if (LangOpts.MicrosoftExt) {
 NormalizedPath = Filename.str();
 llvm::sys::path::native(NormalizedPath);
 LookupFilename = NormalizedPath;
+BackslashIsSeparator = true;
   }
 #endif
 
@@ -2108,21 +2112,44 @@
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
-  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
+
+  const auto IsSep = [BackslashIsSeparator](char c) {
+return c == '/' || (BackslashIsSeparator && c == '\\');
+  };
+
   for (auto Component : Components) {
-if (isLeadingSeparator)
-  isLeadingSeparator = false;
-else
+// On POSIX, Components will contain a single '/' as first element
+// exactly if Name is an absolute path.
+// On Windows, it will contain "C:" followed by '\' for absolute paths.
+// The drive letter is optional for absolute paths on Windows, but
+// clang currently cannot process absolute paths in #include lines that
+// don't have a drive.
+// If the first entry in Components is a directory separator,
+// then the code at the bottom of this loop that keeps the original
+// directory separator style copies it. If the second entry is
+// a directory separator (the C:\ case), then that separator already
+// got copied when the C: was processed and we want to skip that entry.
+if (!(Component.size() == 1 && IsSep(Component[0])))
   Path.append(Component);
-// Append the separator the user used, or the close quote
-Path.push_back(
-  Path.size() <= Filename.size() ? Filename[Path.size()-1] :
-(isAngled ? '>' : '"'));
+else if (!Path.empty())
+  continue;
+
+// Append the separator(s) the user used, or the close quote
+if (Path.size() > Filename.size()) {
+  Path.push_back(isAngled ? '>' : '"');
+  continue;
+}
+assert(IsSep(Filename[Path.size()-1]));
+do
+  Path.push_back(Filename[Path.size()-1]);
+while (Path.size() <= Filename.size() && IsSep(Filename[Path.size()-1]));
   }
-  // For user files and known standard headers, by default we issue a diagnostic.
-  // For other system headers, we don't. They can be controlled separately.
-  auto DiagId = (FileCharacter == SrcMgr::C_User || warnByDefaultOnWrongCase(Name)) ?
-  diag::pp_nonportable_path : diag::pp_nonportable_system_path;
+  // For user files and known standard headers, issue a diagnostic.
+  // For other system headers, don't. They can be controlled separately.
+  auto DiagId =
+  (FileCharacter == SrcMgr::C_User || warnByDefaultOnWrongCase(Name))
+  ? diag::pp_nonportable_path
+  : diag::pp_nonportable_system_path;
   Diag(FilenameTok, DiagId) << Path <<
 FixItHint::CreateReplacement(FilenameRange, Path);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76689: [Sema][SVE] Fix handling of initialisers for built-in SVE types

2020-05-01 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 261483.
rsandifo-arm added a comment.

Don't refer to the sizeless types as "scalars"

Also add more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76689

Files:
  clang/docs/DiagnosticsReference.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -94,9 +94,18 @@
 
 #if __cplusplus >= 201103L
   int empty_brace_init_int = {};
+  svint8_t empty_brace_init_int8 = {};
 #else
   int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}}
+  svint8_t empty_brace_init_int8 = {}; // expected-error {{initializer for sizeless type 'svint8_t' (aka '__SVInt8_t') cannot be empty}}
 #endif
+  svint8_t brace_init_int8 = {local_int8};
+  svint8_t bad_brace_init_int8_1 = {local_int8, 0};// expected-error {{excess elements in initializer for indivisible sizeless type 'svint8_t'}}
+  svint8_t bad_brace_init_int8_2 = {0};// expected-error {{rvalue of type 'int'}}
+  svint8_t bad_brace_init_int8_3 = {local_int16};  // expected-error {{lvalue of type 'svint16_t'}}
+  svint8_t bad_brace_init_int8_4 = {[0] = local_int8}; // expected-error {{designator in initializer for indivisible sizeless type 'svint8_t'}} expected-warning {{array designators are a C99 extension}}
+  svint8_t bad_brace_init_int8_5 = {{local_int8}}; // expected-warning {{too many braces around initializer}}
+  svint8_t bad_brace_init_int8_6 = {{local_int8, 0}};  // expected-warning {{too many braces around initializer}}
 
   const svint8_t const_int8 = local_int8; // expected-note {{declared const here}}
   const svint8_t uninit_const_int8;   // expected-error {{default initialization of an object of const type 'const svint8_t'}}
@@ -455,6 +464,14 @@
   local_int8 = ref_int8;
 
 #if __cplusplus >= 201103L
+  svint8_t zero_init_int8{};
+  svint8_t init_int8{local_int8};
+  svint8_t bad_brace_init_int8_1{local_int8, 0}; // expected-error {{excess elements in initializer for indivisible sizeless type 'svint8_t'}}
+  svint8_t bad_brace_init_int8_2{0}; // expected-error {{rvalue of type 'int'}}
+  svint8_t bad_brace_init_int8_3{local_int16};   // expected-error {{lvalue of type 'svint16_t'}}
+  svint8_t bad_brace_init_int8_4{[0] = local_int8}; // expected-error {{designator in initializer for indivisible sizeless type 'svint8_t'}} expected-warning {{array designators are a C99 extension}}
+  svint8_t bad_brace_init_int8_5{{local_int8}}; // expected-warning {{too many braces around initializer}}
+  svint8_t bad_brace_init_int8_6{{local_int8, 0}};  // expected-warning {{too many braces around initializer}}
   svint8_t wrapper_init_int8{wrapper()};
   svint8_t &ref_init_int8{local_int8};
 
@@ -601,4 +618,9 @@
 
 #if __cplusplus >= 201103L
 svint8_t ret_bad_conv() { return explicit_conv(); } // expected-error {{no viable conversion from returned value of type 'explicit_conv' to function return type 'svint8_t'}}
+
+#pragma clang diagnostic warning "-Wc++98-compat"
+
+void incompat_init() { __attribute__((unused)) svint8_t foo = {}; } // expected-warning {{initializing 'svint8_t' (aka '__SVInt8_t') from an empty initializer list is incompatible with C++98}}
+
 #endif
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -83,6 +83,14 @@
   svint8_t bad_init_int8 = for; // expected-error {{expected expression}}
 
   int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}}
+  svint8_t empty_brace_init_int8 = {}; // expected-error {{initializer for sizeless type 'svint8_t' (aka '__SVInt8_t') cannot be empty}}
+  svint8_t brace_init_int8 = {local_int8};
+  svint8_t bad_brace_init_int8_1 = {local_int8, 0};// expected-warning {{excess elements in initializer for indivisible sizeless type 'svint8_t'}}
+  svint8_t bad_brace_init_int8_2 = {0};// expected-error {{incompatible type 'int'}}
+  svint8_t bad_brace_init_int8_3 = {local_int16};  // expected-error {{incompatible type 'svint16_t'}}
+  svint8_t bad_brace_init_int8_4 = {[0] = local_int8}; // expected-error {{designator in initializer for indivisible sizeless type 'svint8_t'}}
+  svint8_t bad_brace_init_int8_5 = {{local_int8}}; // expected-warning {{too many braces around initializer}}
+  svint8_t bad_brace_init_int8_6 = {{local_int8, 0}};  // expected-warning {{too many braces around initializer}}
 
   const svint8_t const_int8 = local_int8; // expected-note {{declared const here}}
   const svint8_t uninit_const_

[PATCH] D78827: Add support for #pragma clang fp reassoc(on|off) -- floating point control of associative math transformations

2020-05-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3159
+controlled with this pragma.
+``#pragma clang fp allow_reassociation`` allows control over the reassociation
+of floating point expressions. When enabled, this pragma allows the expression

sepavloff wrote:
> I would say the previous name, `reassoc`, was more consistent. We do not use 
> `allow_contraction`.
"contract" isn't a shortening, though, it's a verb.  The idea is that a pragma 
is a directive to the compiler.  So arguably the more consistent spelling would 
be something like `#pragma clang fp reassociate`.



Comment at: clang/docs/LanguageExtensions.rst:3177
+Both floating point reassociation and floating point contraction can be
+controlled with this pragma.
+``#pragma clang fp reassoc`` allows control over the reassociation

Let's go ahead and word this as if arbitrary things will be controllable in the 
future.  So:

> Currently, the following things can be controlled by this pragma:



Comment at: clang/docs/LanguageExtensions.rst:3191
 option is identical to using ``#pragma STDC FP_CONTRACT(ON)`` and it allows
 fusion as specified the language standard.  The ``fast`` option allows fusiong
 in cases when the language standard does not make this possible (e.g. across

Please fix this typo while you're here.



Comment at: clang/include/clang/Basic/LangOptions.h:186
+FPM_Fast
   };
 

I'm not sure I think this fusion was an improvement; the net effect was to 
remove a few lines from this header and make a bunch of switches unnecessarily 
non-exhaustive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78827



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


[PATCH] D79244: [Sema] Put existing warning under -Wexcess-initializers

2020-05-01 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
rsandifo-arm added a parent revision: D79236: [docs] Regenerate 
DiagnosticsReference.rst.
rsandifo-arm added a child revision: D76689: [Sema][SVE] Fix handling of 
initialisers for built-in SVE types.

I have a follow-on patch that uses an alternative wording for
this warning in some cases.  This patch puts it under its own
-W option in order to avoid a regression in Misc/warning-flags.c.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79244

Files:
  clang/docs/DiagnosticsReference.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Misc/warning-flags.c
  clang/test/Sema/init.c


Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -121,6 +121,10 @@
 };
 
 struct foo2 bar3 = { 1, 2 }; // expected-warning{{excess elements in struct 
initializer}}
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wexcess-initializers"
+struct foo2 bar3_silent = { 1, 2 };
+#pragma clang diagnostic pop
 
 int* ptest1 = __builtin_choose_expr(1, (int*)0, (int*)0);
 
Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,8 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (75):
-CHECK-NEXT:   ext_excess_initializers
+CHECK: Warnings without flags (74):
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5381,7 +5381,8 @@
 def err_excess_initializers : Error<
   "excess elements in %select{array|vector|scalar|union|struct}0 initializer">;
 def ext_excess_initializers : ExtWarn<
-  "excess elements in %select{array|vector|scalar|union|struct}0 initializer">;
+  "excess elements in %select{array|vector|scalar|union|struct}0 initializer">,
+  InGroup>;
 def err_excess_initializers_in_char_array_initializer : Error<
   "excess elements in char array initializer">;
 def ext_excess_initializers_in_char_array_initializer : ExtWarn<
Index: clang/docs/DiagnosticsReference.rst
===
--- clang/docs/DiagnosticsReference.rst
+++ clang/docs/DiagnosticsReference.rst
@@ -4481,6 +4481,27 @@
 
+-+
 
 
+-Wexcess-initializers
+-
+This diagnostic is enabled by default.
+
+**Diagnostic text:**
+
++-++---+
+|:warning:`warning:` |nbsp| :diagtext:`excess elements in` |nbsp| 
|+--+| |nbsp| :diagtext:`initializer`|
+| 
||:diagtext:`array` ||   |
+| 
|+--+|   |
+| 
||:diagtext:`vector`||   |
+| 
|+--+|   |
+| 
||:diagtext:`scalar`||   |
+| 
|+--+|   |
+| 
||:diagtext:`union` ||   |
+| 
|+--+|   |
+| 
||:diagtext:`struct`||   |
+| 
|+--+|   |
++-++---+
+
+
 -Wexit-time-destructors
 ---
 **Diagnostic text:**


Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -121,6 +121,10 @@
 };
 
 struct foo2 bar3 = { 1, 2 }; // expected-warning{{excess elements in s

[PATCH] D72281: [Matrix] Add matrix type to Clang.

2020-05-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 261476.
fhahn added a comment.

Switch mangling to use a  vendor extended type qualifier, hoist code for 
loading/storing of matrix values to separate functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72281

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/debug-info-matrix-types.c
  clang/test/CodeGen/matrix-type.c
  clang/test/CodeGenCXX/matrix-type.cpp
  clang/test/Parser/matrix-type-disabled.c
  clang/test/SemaCXX/matrix-type.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1787,6 +1787,8 @@
 DEFAULT_TYPELOC_IMPL(DependentSizedExtVector, Type)
 DEFAULT_TYPELOC_IMPL(Vector, Type)
 DEFAULT_TYPELOC_IMPL(ExtVector, VectorType)
+DEFAULT_TYPELOC_IMPL(Matrix, Type)
+DEFAULT_TYPELOC_IMPL(DependentSizedMatrix, Type)
 DEFAULT_TYPELOC_IMPL(FunctionProto, FunctionType)
 DEFAULT_TYPELOC_IMPL(FunctionNoProto, FunctionType)
 DEFAULT_TYPELOC_IMPL(Record, TagType)
Index: clang/test/SemaCXX/matrix-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/matrix-type.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -fenable-matrix -std=c++11 -verify -triple x86_64-apple-darwin %s
+
+using matrix_double_t = double __attribute__((matrix_type(6, 6)));
+using matrix_float_t = float __attribute__((matrix_type(6, 6)));
+using matrix_int_t = int __attribute__((matrix_type(6, 6)));
+
+void matrix_var_dimensions(int Rows, unsigned Columns, char C) {
+  using matrix1_t = int __attribute__((matrix_type(Rows, 1)));// expected-error{{matrix_type attribute requires an integer constant}}
+  using matrix2_t = int __attribute__((matrix_type(1, Columns))); // expected-error{{matrix_type attribute requires an integer constant}}
+  using matrix3_t = int __attribute__((matrix_type(C, C)));   // expected-error{{matrix_type attribute requires an integer constant}}
+  using matrix4_t = int __attribute__((matrix_type(-1, 1)));  // expected-error{{matrix row size too large}}
+  using matrix5_t = int __attribute__((matrix_type(1, -1)));  // expected-error{{matrix column size too large}}
+  using matrix6_t = int __attribute__((matrix_type(0, 1)));   // expected-error{{zero matrix size}}
+  using matrix7_t = int __attribute__((matrix_type(1, 0)));   // expected-error{{zero matrix size}}
+  using matrix7_t = int __attribute__((matrix_type(char, 0)));// expected-error{{expected '(' for function-style cast or type construction}}
+  using matrix8_t = int __attribute__((matrix_type(1048576, 1))); // expected-error{{matrix row size too large}}
+}
+
+struct S1 {};
+
+enum TestEnum {
+  A,
+  B
+};
+
+void matrix_unsupported_element_type() {
+  using matrix1_t = char *__attribute__((matrix_type(1, 1)));// expected-error{{invalid matrix element type 'char *'}}
+  using matrix2_t = S1 __attribute__((matrix_type(1, 1)));   // expected-error{{invalid matrix element type 'S1'}}
+  using matrix3_t = bool __attribute__((matrix_type(1, 1))); // expected-error{{invalid matrix element type 'bool'}}
+  using matrix4_t = TestEnum __attribute__((matrix_type(1, 1))); // expected-error{{invalid matrix element type 'TestEnum'}}
+}
+
+template  // expected-note{{declared here}}
+void matrix_template_1() {
+  using matrix1_t = float __attribute__((matrix_type(T, T))); // expected-error{{'T' does not refer to a value}}
+}
+
+template  // expected-note{{decla

[PATCH] D79237: [CUDA][HIP] Fix constexpr variables for C++17

2020-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.

constexpr variables are compile time constants and implicitly const, therefore
they are safe to emit on both device and host side. Besides, in many cases
they are intended for both device and host, therefore it makes sense
to emit them on both device and host sides if necessary.

In most cases constexpr variables are used as rvalue and the variables
themselves do not need to be emitted. However if their address is taken,
then they need to be emitted.

The following example shows constexpr is available on device side without
`__device__` or `__constant__` attribute

https://godbolt.org/z/Uf7CgK

Which indicates that we need to emit constexpr variables on device side
even without `__device__` or `__constant__` attribute when necessary.
This should be OK since the initializer is compile time constant and the
variable itself is constant. They can just be emitted in the same way
as the host side.

For C++14, clang is able to handle that since clang emits them with
available_externally linkage together with the initializer.

However for C++17, the constexpr static data member of a class or template class
become inline variables implicitly. Therefore they become definitions with
linkonce_odr or weak_odr linkages. As such, they can not have 
available_externally
linkage.

This patch fixes that by allowing clang to emit definitions of constexpr 
variables
in the standard way on device side.


https://reviews.llvm.org/D79237

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/constexpr-variables.cu


Index: clang/test/CodeGenCUDA/constexpr-variables.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/constexpr-variables.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -o - -triple nvptx \
+// RUN:   -fcuda-is-device | FileCheck --check-prefixes=COM,CXX14 %s
+// RUN: %clang_cc1 -std=c++17 %s -emit-llvm -o - -triple nvptx \
+// RUN:   -fcuda-is-device | FileCheck --check-prefixes=COM,CXX17 %s
+
+#include "Inputs/cuda.h"
+
+// COM: @_ZL1a = internal {{.*}}constant i32 7
+constexpr int a = 7;
+__constant__ const int &use_a = a;
+
+namespace B {
+ // COM: @_ZN1BL1bE = internal {{.*}}constant i32 9
+  constexpr int b = 9;
+}
+__constant__ const int &use_B_b = B::b;
+
+struct Q {
+  // CXX14: @_ZN1Q1kE = available_externally {{.*}}constant i32 5
+  // CXX17: @_ZN1Q1kE = linkonce_odr {{.*}}constant i32 5
+  static constexpr int k = 5;
+};
+__constant__ const int &use_Q_k = Q::k;
+
+template struct X {
+  // CXX14: @_ZN1XIiE1aE = available_externally {{.*}}constant i32 123
+  // CXX17: @_ZN1XIiE1aE = linkonce_odr {{.*}}constant i32 123
+  static constexpr int a = 123;
+};
+__constant__ const int &use_X_a = X::a;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2549,12 +2549,16 @@
   // If this is CUDA, be selective about which declarations we emit.
   if (LangOpts.CUDA) {
 if (LangOpts.CUDAIsDevice) {
+  bool IsConstexprVar = false;
+  if (auto *VD = dyn_cast(Global))
+IsConstexprVar = VD->isConstexpr();
   if (!Global->hasAttr() &&
   !Global->hasAttr() &&
   !Global->hasAttr() &&
   !Global->hasAttr() &&
   !Global->getType()->isCUDADeviceBuiltinSurfaceType() &&
-  !Global->getType()->isCUDADeviceBuiltinTextureType())
+  !Global->getType()->isCUDADeviceBuiltinTextureType() &&
+  !IsConstexprVar)
 return;
 } else {
   // We need to emit host-side 'shadows' for all global


Index: clang/test/CodeGenCUDA/constexpr-variables.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/constexpr-variables.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -o - -triple nvptx \
+// RUN:   -fcuda-is-device | FileCheck --check-prefixes=COM,CXX14 %s
+// RUN: %clang_cc1 -std=c++17 %s -emit-llvm -o - -triple nvptx \
+// RUN:   -fcuda-is-device | FileCheck --check-prefixes=COM,CXX17 %s
+
+#include "Inputs/cuda.h"
+
+// COM: @_ZL1a = internal {{.*}}constant i32 7
+constexpr int a = 7;
+__constant__ const int &use_a = a;
+
+namespace B {
+ // COM: @_ZN1BL1bE = internal {{.*}}constant i32 9
+  constexpr int b = 9;
+}
+__constant__ const int &use_B_b = B::b;
+
+struct Q {
+  // CXX14: @_ZN1Q1kE = available_externally {{.*}}constant i32 5
+  // CXX17: @_ZN1Q1kE = linkonce_odr {{.*}}constant i32 5
+  static constexpr int k = 5;
+};
+__constant__ const int &use_Q_k = Q::k;
+
+template struct X {
+  // CXX14: @_ZN1XIiE1aE = available_externally {{.*}}constant i32 123
+  // CXX17: @_ZN1XIiE1aE = linkonce_odr {{.*}}constant i32 123
+  static constexpr int a = 123;
+};
+__constant__ const int &use_X_a = X::a;
Index: clang/lib/CodeGen/CodeGenModule.cpp

[PATCH] D79236: [docs] Regenerate DiagnosticsReference.rst

2020-05-01 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: aaron.ballman, efriedma, rjmccall.
Herald added subscribers: cfe-commits, s.egerton, jfb, simoncook, aheejin.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
rsandifo-arm added a child revision: D79244: [Sema] Put existing warning under 
-Wexcess-initializers.

It looks like it has been a while since the checked-in version of
DiagnosticsReference.rst was regenerated.  I realise there probably
isn't any expectation that the checked-in version is kept up-to-date,
but now that the project is on github and the rst can be viewed directly
from the repo's web interface, it seemed worth having something a bit
more recent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79236

Files:
  clang/docs/DiagnosticsReference.rst



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


[PATCH] D79087: [SVE][Codegen] Lower legal min & max operations

2020-05-01 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked an inline comment as done.
kmclaughlin added inline comments.



Comment at: llvm/lib/Target/AArch64/SVEInstrFormats.td:3851
+  def : SVE_1_Op_Imm_Arith_Pred_Pat(NAME # _S)>;
+  def : SVE_1_Op_Imm_Arith_Pred_Pat(NAME # _D)>;
 }

efriedma wrote:
> kmclaughlin wrote:
> > efriedma wrote:
> > > I don't see any test for this part of the patch?
> > The tests for these patterns are in `sve-int-arith-imm.ll`, which was added 
> > as part of D71779
> I'd also like to see tests for the intrinsic where the second operand is an 
> immediate, since we can pattern-match that to the immdiate smax now.
I see what you mean now, I've added the intrinsic tests to 
sve-intrinsics-int-arith-imm.ll


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

https://reviews.llvm.org/D79087



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


[PATCH] D79087: [SVE][Codegen] Lower legal min & max operations

2020-05-01 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 261462.
kmclaughlin added a comment.

- Added tests for the intrinsics where the second operand is an immediate
- Changed the range SelectSVESignedArithImm checks for, as the range for the 
immediates of smin & smax is -128 to +127 (inclusive)


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

https://reviews.llvm.org/D79087

Files:
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll
@@ -1,5 +1,221 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
 
+; SMAX
+
+define  @smax_i8( %a) {
+; CHECK-LABEL: smax_i8:
+; CHECK: smax z0.b, z0.b, #-128
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  %elt = insertelement  undef, i8 -128, i32 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smax.nxv16i8( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+define  @smax_i16( %a) {
+; CHECK-LABEL: smax_i16:
+; CHECK: smax z0.h, z0.h, #127
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
+  %elt = insertelement  undef, i16 127, i32 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smax.nxv8i16( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+define  @smax_i32( %a) {
+; CHECK-LABEL: smax_i32:
+; CHECK: smax z0.s, z0.s, #-128
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
+  %elt = insertelement  undef, i32 -128, i32 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smax.nxv4i32( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+define  @smax_i64( %a) {
+; CHECK-LABEL: smax_i64:
+; CHECK: smax z0.d, z0.d, #127
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
+  %elt = insertelement  undef, i64 127, i64 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smax.nxv2i64( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+; SMIN
+
+define  @smin_i8( %a) {
+; CHECK-LABEL: smin_i8:
+; CHECK: smin z0.b, z0.b, #127
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  %elt = insertelement  undef, i8 127, i32 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smin.nxv16i8( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+define  @smin_i16( %a) {
+; CHECK-LABEL: smin_i16:
+; CHECK: smin z0.h, z0.h, #-128
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
+  %elt = insertelement  undef, i16 -128, i32 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smin.nxv8i16( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+define  @smin_i32( %a) {
+; CHECK-LABEL: smin_i32:
+; CHECK: smin z0.s, z0.s, #127
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
+  %elt = insertelement  undef, i32 127, i32 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smin.nxv4i32( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+define  @smin_i64( %a) {
+; CHECK-LABEL: smin_i64:
+; CHECK: smin z0.d, z0.d, #-128
+; CHECK-NEXT: ret
+  %pg = call  @llvm.aarch64.sve.ptrue.nxv2i1(i32 31)
+  %elt = insertelement  undef, i64 -128, i64 0
+  %splat = shufflevector  %elt,  undef,  zeroinitializer
+  %out = call  @llvm.aarch64.sve.smin.nxv2i64( %pg,
+ %a,
+ %splat)
+  ret  %out
+}
+
+; UMAX
+
+define  @umax_i8( %a) {
+; CHECK-LABEL: umax_i8:
+;

[clang] 334931f - [SveEmitter] Add builtins for shifts.

2020-05-01 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-05-01T22:27:24+01:00
New Revision: 334931f54b959c3ef03386770877789d4167d24f

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

LOG: [SveEmitter] Add builtins for shifts.

This patch adds builtins for:
- svasrd
- svlsl
- svlsr

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asr.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_lsl.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_lsr.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/utils/TableGen/SveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index c794441dbc34..013357c3de9b 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -73,8 +73,11 @@
 //
 // w: vector of element type promoted to 64bits, vector maintains
 //signedness of its element type.
+// f: element type promoted to uint64_t (splat to vector type)
 // j: element type promoted to 64bits (splat to vector type)
 // K: element type bitcast to a signed integer (splat to vector type)
+// L: element type bitcast to an unsigned integer (splat to vector type)
+//
 // i: constant uint64_t
 // k: int32_t
 // l: int64_t
@@ -677,6 +680,29 @@ defm SVNOT  : SInstZPZ<"svnot",  "csilUcUsUiUl", 
"aarch64_sve_not">;
 
 

 // Shifts
+
+multiclass SInst_SHIFT {
+  def _M : SInst;
+  def _X : SInst;
+  def _Z : SInst;
+
+  def _N_M : SInst;
+  def _N_X : SInst;
+  def _N_Z : SInst;
+
+  def _WIDE_M : SInst;
+  def _WIDE_X : SInst;
+  def _WIDE_Z : SInst;
+
+  def _WIDE_N_M : SInst;
+  def _WIDE_N_X : SInst;
+  def _WIDE_N_Z : SInst;
+}
+
+defm SVASR : SInst_SHIFT<"svasr", "aarch64_sve_asr", "csil", "csi">;
+defm SVLSL : SInst_SHIFT<"svlsl", "aarch64_sve_lsl", "csilUcUsUiUl", 
"csiUcUsUi">;
+defm SVLSR : SInst_SHIFT<"svlsr", "aarch64_sve_lsr", "UcUsUiUl", "UcUsUi">;
+
 def SVASRD_M : SInst<"svasrd[_n_{d}]", "dPdi", "csil",MergeOp1,  
"aarch64_sve_asrd", [], [ImmCheck<2, ImmCheckShiftRight, 1>]>;
 
 


diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asr.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asr.c
new file mode 100644
index ..2fb80acc2822
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asr.c
@@ -0,0 +1,412 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8_t test_svasr_s8_z(svbool_t pg, svint8_t op1, svuint8_t op2)
+{
+  // CHECK-LABEL: test_svasr_s8_z
+  // CHECK: %[[SEL:.*]] = call  
@llvm.aarch64.sve.sel.nxv16i8( %pg,  %op1, 
 zeroinitializer)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.asr.nxv16i8( %pg,  
%[[SEL]],  %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svasr,_s8,_z,)(pg, op1, op2);
+}
+
+svint16_t test_svasr_s16_z(svbool_t pg, svint16_t op1, svuint16_t op2)
+{
+  // CHECK-LABEL: test_svasr_s16_z
+  // CHECK-DAG: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK-DAG: %[[SEL:.*]] = call  
@llvm.aarch64.sve.sel.nxv8i16( %[[PG]],  
%op1,  zeroinitializer)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.asr.nxv8i16( %[[PG]],  
%[[SEL]],  %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svasr,_s16,_z,)(pg, op1, op2);
+}
+
+svint32_t test_svasr_s32_z(svbool_t pg, svint32_t op1, svuint32_t op2)
+{
+  // CHECK-LABEL: test_svasr_s32_z
+  // CHECK-DAG: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK-DAG: %[[SEL:.*]] = call  
@llvm.aarch64.sve.sel.nxv4i32( %[[PG]],  
%op1,  zeroinitializer)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.asr.nxv4i32( %[[PG]],  
%[[SEL]],  %op2)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svasr,_s32,_z,)(pg, op1, op2);
+}
+
+svint64_t test_svasr_s64_z(svbool_t pg, svint64_t op1, svuint64_t op2)
+{
+  // CHECK-LABEL: test_svasr_s64_z
+  // CHECK-DAG: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK-DAG: %[[SEL:.*]] = call  
@llvm.aarch64.sve.sel.nxv2i64( %[[PG]],  
%op1

[clang] 7585ba2 - [clang][OpenMP] Fix mangling of linear parameters.

2020-05-01 Thread Francesco Petrogalli via cfe-commits

Author: Francesco Petrogalli
Date: 2020-05-01T21:19:00Z
New Revision: 7585ba208e67443d0fbc883db320934c65312b02

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

LOG: [clang][OpenMP] Fix mangling of linear parameters.

Summary:
The linear parameter token in the mangling function must be multiplied
by the pointee size in bytes when the parameter is a pointer.

Reviewers: ABataev, andwar, jdoerfert

Subscribers: yaxunl, guansong, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/declare_simd_aarch64.c
clang/test/OpenMP/declare_simd_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 307750ccfec9..6a69d02fa817 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -11073,7 +11073,7 @@ emitX86DeclareSimdFunction(const FunctionDecl *FD, 
llvm::Function *Fn,
   break;
 case Linear:
   Out << 'l';
-  if (!!ParamAttr.StrideOrArg)
+  if (ParamAttr.StrideOrArg != 1)
 Out << ParamAttr.StrideOrArg;
   break;
 case Uniform:
@@ -11213,7 +11213,7 @@ static std::string 
mangleVectorParameters(ArrayRef ParamAttrs) {
   Out << 'l';
   // Don't print the step value if it is not present or if it is
   // equal to 1.
-  if (!!ParamAttr.StrideOrArg && ParamAttr.StrideOrArg != 1)
+  if (ParamAttr.StrideOrArg != 1)
 Out << ParamAttr.StrideOrArg;
   break;
 case Uniform:
@@ -11451,15 +11451,24 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const 
FunctionDecl *FD,
   for (const Expr *E : Attr->linears()) {
 E = E->IgnoreParenImpCasts();
 unsigned Pos;
+// Rescaling factor needed to compute the linear parameter
+// value in the mangled name.
+unsigned PtrRescalingFactor = 1;
 if (isa(E)) {
   Pos = ParamPositions[FD];
 } else {
   const auto *PVD = cast(cast(E)->getDecl())
 ->getCanonicalDecl();
   Pos = ParamPositions[PVD];
+  if (auto *P = dyn_cast(PVD->getType()))
+PtrRescalingFactor = CGM.getContext()
+ .getTypeSizeInChars(P->getPointeeType())
+ .getQuantity();
 }
 ParamAttrTy &ParamAttr = ParamAttrs[Pos];
 ParamAttr.Kind = Linear;
+// Assuming a stride of 1, for `linear` without modifiers.
+ParamAttr.StrideOrArg = llvm::APSInt::getUnsigned(1);
 if (*SI) {
   Expr::EvalResult Result;
   if (!(*SI)->EvaluateAsInt(Result, C, Expr::SE_AllowSideEffects)) {
@@ -11475,6 +11484,11 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const 
FunctionDecl *FD,
 ParamAttr.StrideOrArg = Result.Val.getInt();
   }
 }
+// If we are using a linear clause on a pointer, we need to
+// rescale the value of linear_step with the byte size of the
+// pointee type.
+if (Linear == ParamAttr.Kind)
+  ParamAttr.StrideOrArg = ParamAttr.StrideOrArg * PtrRescalingFactor;
 ++SI;
 ++MI;
   }

diff  --git a/clang/test/OpenMP/declare_simd_aarch64.c 
b/clang/test/OpenMP/declare_simd_aarch64.c
index 4af2ad9bb603..21c83c225963 100644
--- a/clang/test/OpenMP/declare_simd_aarch64.c
+++ b/clang/test/OpenMP/declare_simd_aarch64.c
@@ -130,12 +130,12 @@ double constlinear(const int i);
 /*/
 #pragma omp declare simd linear(sin) linear(cos)
 void sincos(double in, double *sin, double *cos);
-// AARCH64: "_ZGVnN2vll_sincos"
+// AARCH64: "_ZGVnN2vl8l8_sincos"
 // AARCH64-NOT: sincos
 
 #pragma omp declare simd linear(sin : 1) linear(cos : 2)
 void SinCos(double in, double *sin, double *cos);
-// AARCH64: "_ZGVnN2vll2_SinCos"
+// AARCH64: "_ZGVnN2vl8l16_SinCos"
 // AARCH64-NOT: SinCos
 
 // Selection of tests based on the examples provided in chapter 5 of
@@ -158,7 +158,7 @@ int foo3(int *x, int i, unsigned char c);
 // Listing 6, p. 19
 #pragma omp declare simd linear(x) aligned(x : 16) simdlen(4)
 int foo4(int *x, float y);
-// AARCH64: "_ZGVnM4la16v_foo4" "_ZGVnN4la16v_foo4"
+// AARCH64: "_ZGVnM4l4a16v_foo4" "_ZGVnN4l4a16v_foo4"
 // AARCH64-NOT: foo4
 
 static int *I;

diff  --git a/clang/test/OpenMP/declare_simd_codegen.cpp 
b/clang/test/OpenMP/declare_simd_codegen.cpp
index ef7ad8772e51..1967f3b248dc 100644
--- a/clang/test/OpenMP/declare_simd_codegen.cpp
+++ b/clang/test/OpenMP/declare_simd_codegen.cpp
@@ -136,14 +136,14 @@ double constlinear(const int i) { return 0.0; }
 // CHECK-DAG: declare {{.+}}@_Z5add_2Pf(
 // CHECK-DAG: defin

[clang] cac8cd0 - [clang] [unittest/AST] Fix linking to LLVMTestingSupport

2020-05-01 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2020-05-01T21:22:51+02:00
New Revision: cac8cd0a16e9c0410e33aaca93c760c503eeb68e

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

LOG: [clang] [unittest/AST] Fix linking to LLVMTestingSupport

Link to LLVMTestingSupport via target_link_libraries() instead of
clang_target_link_libraries().  The latter is ineffective if tests
are linked to libclang.so.  This solution is consistent with what other
tests do.

Added: 


Modified: 
clang/unittests/AST/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index 868635b6eea5..5d9ff5b97dbd 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -43,5 +43,9 @@ clang_target_link_libraries(ASTTests
   clangFrontend
   clangSerialization
   clangTooling
-  LLVMTestingSupport
   )
+
+target_link_libraries(ASTTests
+  PRIVATE
+  LLVMTestingSupport
+)



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


[clang] b9d50bd - Fix pr31836 on Windows too, and correctly handle repeated separators.

2020-05-01 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-05-01T14:17:01-04:00
New Revision: b9d50bdff211eb806dce5bc42167a6b9c0cac6e6

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

LOG: Fix pr31836 on Windows too, and correctly handle repeated separators.

The approach in D3 assumes that the '/' returned by path::begin()
is the first element for absolute paths, but that's not true on
Windows.

Also, on Windows backslashes in include lines often end up escaped
so that there are two of them. Having backslashes in include lines
is undefined behavior in most cases and implementation-defined
behavior in C++20, but since clang treats it as normal repeated
path separators, the diagnostic should too.

Unbreaks -Wnonportable-include-path for absolute paths on Windows,
and unbreaks it on non-Windows in the case of absolute paths with
repeated directory separators.

This affects e.g. the `#include __FILE__` technique if the file
passed to clang has the wrong case for the drive letter. Before:

C:\src\llvm-project>bin\clang-cl.exe c:\src\llvm-project\test.cc
c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file
'"c\\srccllvm-projectctest.cc.'; specified path differs in case from
file name on disk [-Wnonportable-include-path]
 ^

Now:

C:\src\llvm-project> out\gn\bin\clang-cl c:\src\llvm-project\test.cc
c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file
'"C:\\src\\llvm-project\\test.cc"'; specified path differs in case from
file name on disk [-Wnonportable-include-path]
 ^

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

Added: 


Modified: 
clang/lib/Lex/PPDirectives.cpp
clang/test/Lexer/case-insensitive-include-ms.c
clang/test/Lexer/case-insensitive-include-pr31836.sh
clang/test/Lexer/case-insensitive-include.c
llvm/include/llvm/Support/Path.h
llvm/unittests/Support/Path.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 03bd36bfe267..8b1d1fb320e7 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1915,14 +1915,18 @@ Preprocessor::ImportAction 
Preprocessor::HandleHeaderIncludeOrImport(
   SourceLocation FilenameLoc = FilenameTok.getLocation();
   StringRef LookupFilename = Filename;
 
-#ifndef _WIN32
+#ifdef _WIN32
+  llvm::sys::path::Style BackslashStyle = llvm::sys::path::Style::windows;
+#else
   // Normalize slashes when compiling with -fms-extensions on non-Windows. This
   // is unnecessary on Windows since the filesystem there handles backslashes.
   SmallString<128> NormalizedPath;
+  llvm::sys::path::Style BackslashStyle = llvm::sys::path::Style::posix;
   if (LangOpts.MicrosoftExt) {
 NormalizedPath = Filename.str();
 llvm::sys::path::native(NormalizedPath);
 LookupFilename = NormalizedPath;
+BackslashStyle = llvm::sys::path::Style::windows;
   }
 #endif
 
@@ -2105,21 +2109,44 @@ Preprocessor::ImportAction 
Preprocessor::HandleHeaderIncludeOrImport(
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
-  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
+
+  const auto IsSep = [BackslashStyle](char c) {
+return llvm::sys::path::is_separator(c, BackslashStyle);
+  };
+
   for (auto Component : Components) {
-if (isLeadingSeparator)
-  isLeadingSeparator = false;
-else
+// On POSIX, Components will contain a single '/' as first element
+// exactly if Name is an absolute path.
+// On Windows, it will contain "C:" followed by '\' for absolute paths.
+// The drive letter is optional for absolute paths on Windows, but
+// clang currently cannot process absolute paths in #include lines that
+// don't have a drive.
+// If the first entry in Components is a directory separator,
+// then the code at the bottom of this loop that keeps the original
+// directory separator style copies it. If the second entry is
+// a directory separator (the C:\ case), then that separator already
+// got copied when the C: was processed and we want to skip that entry.
+if (!(Component.size() == 1 && IsSep(Component[0])))
   Path.append(Component);
-// Append the separator the user used, or the close quote
-Path.push_back(
-  Path.size() <= Filename.size() ? Filename[Path.size()-1] :
-(isAngled ? '>' : '"'));
+else if (!Path.empty())
+  continue;
+
+// Append the separator(s) the user used, or the close quote
+if (Path.size() > Filename.size()) {
+  Path.push_back(isAngled ? '>' : '"');
+  continue;
+}
+assert(Is

[PATCH] D79213: [hip] Add noalias on restrict qualified coerced hip pointers

2020-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2556-2563
+  // Restrict qualified HIP pointers that were coerced to global pointers
+  // can be marked with the noalias attribute.
+  if (isCoercedHIPGlobalPointer(*this, getLangOpts(), ArgI, Ty) &&
+  Arg->getType().isRestrictQualified()) {
+auto AI = cast(FnArgs[FirstIRArg]);
+AI->addAttr(llvm::Attribute::NoAlias);
+  }

hliao wrote:
> I don't think we need to check pointer address and/or HIP specific. As the 
> generic argument processing, if the original type has any qualifiers, the 
> coerced type (if it has a single value as the original parameter) should have 
> those qualifiers as well. Here, we not only miss `restrict` but also 
> alignment, `nonnull`, and etc. It should be fixed as a generic case instead 
> of a target- or language-specific one.
I agree we should migrate other argument properties for promoted pointer-type 
kernel arg for HIP, and that should be possible since other than the address 
space change, the type is the same.

However, I am not sure if we can do that for coerced function arguments in 
general. It may not even be pointer any more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79213



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


[PATCH] D79044: [AIX] Avoid structor alias; die before bad alias codegen

2020-05-01 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu 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/D79044/new/

https://reviews.llvm.org/D79044



___
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-05-01 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto 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
+

awarzynski wrote:
> richard.barton.arm wrote:
> > 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.
> There's only one run line here, so `--check-prefixes` is not required here. 
> 
> Could you please use the default label instead, i.e. `CHECK`?
Ok!



Comment at: clang/test/Driver/flang/flang-driver-2-frontend01.f90:7-8
+! Copy clang to a temporary file to be the driver name
+! RUN: cp %clang %t1
+! RUN: %t1 --driver-mode=flang -###  %s 2>&1 | FileCheck --check-prefixes=ALL 
%s
+

awarzynski wrote:
> IIUC, copying is not required here. This could be simplified as:
> 
> ```
> ! RUN: %clang --driver-mode=flang -###  %s 2>&1 | FileCheck 
> --check-prefixes=ALL %s
> ```
> Also, this scenario is already tested in `flang.90`. I'd rather we didn't add 
> this file.
Ok, I agree with you. The other  test is more complete.



Comment at: clang/test/Driver/flang/flang-driver-2-frontend02.f90:2
+! Check wich name of flang frontend is invoked by the driver
+
+! The flag -fortran-fe is passed by the driver.

awarzynski wrote:
> This test is very similar to `clang-driver-2-frontend01.f90` - the scenario 
> tested here is already covered elsewhere and IMO this file can be removed 
> from this patch.
Ok, it is I certain way, as we are only testing the flag being used and not the 
driver.



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


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

2020-05-01 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto updated this revision to Diff 261451.
CarolineConcatto marked 3 inline comments as done.
CarolineConcatto added a comment.

This patch updates the flag name from ffc-fortran-name to cfc-fortran-name,
where cfc stands for custom frontend compiler.

Moreover, the tests need pruning to test cfc-frotran-name flag output.
The tests check if the flang frontend being called is "flang" or the
one passed by the flag -cfc-fortran-name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/clang-driver-2-frontend01.f90
  clang/test/Driver/flang/custom_frontend_flang.f90
  clang/test/Driver/flang/driver-2-frontend01.f90
  clang/test/Driver/flang/driver-2-frontend02.f90
  clang/test/Driver/flang/flang-driver-2-frontend01.f90
  clang/test/Driver/flang/flang-driver-2-frontend02.f90

Index: clang/test/Driver/flang/flang-driver-2-frontend02.f90
===
--- clang/test/Driver/flang/flang-driver-2-frontend02.f90
+++ /dev/null
@@ -1,19 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name has flang, but the flag -ffc-fortran-name is passed by the driver.
-! The flag has preference over any other name that the Driver may have.
-! Therefore the driver invokes the FE given by the flag.
-
-! The invocations should begin with .tmp2 -fc1.
-! ALL-LABEL: "{{[^"]*}}flang-driver-2-frontend02.f90.tmp2" "-fc1"
-
-! Copy clang to two temporary file.
-! t1 is the driver name. %t2 is the frontend name
-! RUN: cp %clang %t1
-! RUN: cp %clang %t2
-! RUN: %t1 --driver-mode=flang -ffc-fortran-name %basename_t.tmp2 -### %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}flang-driver-2-frontend02.f90"{{$}}
Index: clang/test/Driver/flang/flang-driver-2-frontend01.f90
===
--- clang/test/Driver/flang/flang-driver-2-frontend01.f90
+++ /dev/null
@@ -1,16 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name has flang, therefore the Driver invokes FE
-! with the same name as the driver.
-
-! The invocations should begin with .tmp1 -fc1.
-! ALL-LABEL: "{{[^"]*}}flang" "-fc1"
-
-! Copy clang to a temporary file to be the driver name
-! RUN: cp %clang %t1
-! RUN: %t1 --driver-mode=flang -###  %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}flang-driver-2-frontend01.f90"{{$}}
Index: clang/test/Driver/flang/driver-2-frontend02.f90
===
--- clang/test/Driver/flang/driver-2-frontend02.f90
+++ /dev/null
@@ -1,19 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name is a randon name. It does not contain flang or clang,
-! but the driver gives a flag with the desired FE to be used.
-! Therefore it should use the FE given by the flag.
-
-! The invocations should begin with .tmp2 -fc1.
-! ALL-LABEL: "{{[^"]*}}driver-2-frontend02.f90.tmp2" "-fc1"
-
-! Copy clang to two temporary file.
-! t1 is the driver name. t2 is the frontend name
-! RUN: cp %clang %t1
-! RUN: cp %clang %t2
-! RUN: %t1 --driver-mode=flang -### -ffc-fortran-name %basename_t.tmp2 %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}driver-2-frontend02.f90"{{$}}
Index: clang/test/Driver/flang/driver-2-frontend01.f90
===
--- clang/test/Driver/flang/driver-2-frontend01.f90
+++ /dev/null
@@ -1,18 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name is a randon name. It does not contain flag, flang or clang,
-! therefore the driver invokes flang FE.
-
-! The invocations should begin with flang -fc1.
-! ALL-LABEL: "{{[^"]*}}flang" "-fc1"
-
-! Copy clang to two temporary file
-! t1 is the new driver name.
-! RUN: cp %clang %t1
-! RUN: %t1 --driver-mode=flang -###  %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}driver-2-frontend01.f90"{{$}}
-
Index: clang/test/Driver/flang/custom_frontend_flang.f90
===
--- /dev/null
+++ clang/test/Driver/flang/custom_frontend_flang.f90
@@ -0,0 +1,10 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! The fl

[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-05-01 Thread Sam Parker via Phabricator via cfe-commits
samparker added a comment.

Thanks for adding the MVE changes, but I also still don't see any DSP tests, 
i.e QADD, SADD16.




Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5753
+  // ahead and skip over them.
+  if (MI.isKill())
+return outliner::InstrType::Invisible;

Should IMPLICIT_DEF instructions be considered invisible too?



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5817
+  // Be conservative with program counter.
+  if (MI.readsRegister(ARM::PC, TRI) || MI.modifiesRegister(ARM::PC, TRI))
+return outliner::InstrType::Illegal;

Cheers. AArch64 is nice and doesn't allow arbitrary writes to the PC, but we 
won't have that luxury here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76066



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


[clang] 68e89c5 - [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu

2020-05-01 Thread Sylvestre Ledru via cfe-commits

Author: Samuel Thibault
Date: 2020-05-01T12:37:12+02:00
New Revision: 68e89c5b96038e00aeeffa642c415cfc0bcaa3dc

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

LOG: [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu
Add missing files

Summary: The current code for GNU/Linux is actually completely generic, and can 
be moved to Gnu, so it can benefit GNU/Hurd and GNU/kFreeBSD

Reviewers: kristina, sammccall, lebedev.ri, MaskRay, arsenm, phosek

Reviewed By: MaskRay, phosek

Subscribers: wdng, ormris, emaste, arichardson, krytarowski, cfe-commits

Tags: #clang

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

Added: 
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/lib/.keep

clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o

clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o

clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginS.o

clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginT.o

Modified: 


Removed: 




diff  --git 
a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as 
b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
new file mode 100755
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld 
b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
new file mode 100755
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/lib/.keep 
b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/lib/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
 
b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
 
b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginS.o
 
b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginS.o
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginT.o
 
b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginT.o
new file mode 100644
index ..e69de29bb2d1



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


[clang] c298e5a - [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu

2020-05-01 Thread Sylvestre Ledru via cfe-commits

Author: Samuel Thibault
Date: 2020-05-01T12:12:27+02:00
New Revision: c298e5a022928b59941d74680a41fc9c76038b2a

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

LOG: [Gnu toolchain] Move GCC multilib/multiarch paths support from Linux to Gnu

Summary: The current code for GNU/Linux is actually completely generic, and can 
be moved to Gnu, so it can benefit GNU/Hurd and GNU/kFreeBSD

Reviewers: kristina, sammccall, lebedev.ri, MaskRay, arsenm, phosek

Reviewed By: MaskRay, phosek

Subscribers: wdng, ormris, emaste, arichardson, krytarowski, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Hurd.cpp
clang/test/Driver/hurd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hurd.cpp 
b/clang/lib/Driver/ToolChains/Hurd.cpp
index ce1806c4043b..3448e4f4a294 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -63,7 +63,19 @@ static StringRef getOSLibDir(const llvm::Triple &Triple, 
const ArgList &Args) {
 
 Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : Generic_ELF(D, Triple, Args) {
+  GCCInstallation.init(Triple, Args);
+  Multilibs = GCCInstallation.getMultilibs();
+  SelectedMultilib = GCCInstallation.getMultilib();
   std::string SysRoot = computeSysRoot();
+  ToolChain::path_list &PPaths = getProgramPaths();
+
+  Generic_GCC::PushPPaths(PPaths);
+
+  // The selection of paths to try here is designed to match the patterns which
+  // the GCC driver itself uses, as this is part of the GCC-compatible driver.
+  // This was determined by running GCC in a fake filesystem, creating all
+  // possible permutations of these directories, and seeing which ones it added
+  // to the link paths.
   path_list &Paths = getFilePaths();
 
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
@@ -73,8 +85,11 @@ Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
   ExtraOpts.push_back("--build-id");
 #endif
 
-  // If we are currently running Clang inside of the requested system root, add
-  // its parent library paths to those searched.
+  Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
+
+  // Similar to the logic for GCC above, if we currently running Clang inside
+  // of the requested system root, add its parent library paths to
+  // those searched.
   // FIXME: It's not clear whether we should use the driver's installed
   // directory ('Dir' below) or the ResourceDir.
   if (StringRef(D.Dir).startswith(SysRoot)) {
@@ -88,8 +103,11 @@ Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
   addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
   addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
 
-  // If we are currently running Clang inside of the requested system root, add
-  // its parent library path to those searched.
+  Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
+
+  // Similar to the logic for GCC above, if we are currently running Clang
+  // inside of the requested system root, add its parent library path to those
+  // searched.
   // FIXME: It's not clear whether we should use the driver's installed
   // directory ('Dir' below) or the ResourceDir.
   if (StringRef(D.Dir).startswith(SysRoot))
@@ -156,6 +174,9 @@ void Hurd::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 
   // Lacking those, try to detect the correct set of system includes for the
   // target triple.
+
+  AddMultilibIncludeArgs(DriverArgs, CC1Args);
+
   if (getTriple().getArch() == llvm::Triple::x86) {
 std::string Path = SysRoot + "/usr/include/i386-gnu";
 if (D.getVFS().exists(Path))

diff  --git a/clang/test/Driver/hurd.c b/clang/test/Driver/hurd.c
index a6ca8ea3379f..7dbbe923557b 100644
--- a/clang/test/Driver/hurd.c
+++ b/clang/test/Driver/hurd.c
@@ -11,7 +11,7 @@
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
 // CHECK: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -33,7 +33,7 @@
 // CHECK-STATIC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "crtbeginT.o"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginT.o"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-STATIC: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ 

[PATCH] D79232: [analyzer] Refactor range inference for symbolic expressions

2020-05-01 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a project: clang.

This change introduces a new component to unite all of the reasoning
we have about operations on ranges in the analyzer's solver.
In many cases, we might conclude that the range for a symbolic operation
is much more narrow than the type implies.  While reasoning about
runtime conditions (especially in loops), we need to support more and
more of those little pieces of logic.  The new component mostly plays
a role of an organizer for those, and allows us to focus on the actual
reasoning about ranges and not dispatching manually on the types of the
nested symbolic expressions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79232

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c

Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -115,7 +115,10 @@
 #endif
 
   // Check that dynamically computed constants also work.
-  int constant = 1 << 3;
+  unsigned int constant = 1 << 3;
   unsigned int d = a | constant;
-  clang_analyzer_eval(constant > 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(d >= constant); // expected-warning{{TRUE}}
+
+  // Check that nested expressions also work.
+  clang_analyzer_eval(((a | 10) | 5) >= 10); // expected-warning{{TRUE}}
 }
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -16,6 +16,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
 #include "llvm/Support/raw_ostream.h"
@@ -23,10 +24,16 @@
 using namespace clang;
 using namespace ento;
 
+//===--===//
+//   RangeSet implementation
+//===--===//
+
 void RangeSet::IntersectInRange(BasicValueFactory &BV, Factory &F,
-  const llvm::APSInt &Lower, const llvm::APSInt &Upper,
-  PrimRangeSet &newRanges, PrimRangeSet::iterator &i,
-  PrimRangeSet::iterator &e) const {
+const llvm::APSInt &Lower,
+const llvm::APSInt &Upper,
+PrimRangeSet &newRanges,
+PrimRangeSet::iterator &i,
+PrimRangeSet::iterator &e) const {
   // There are six cases for each range R in the set:
   //   1. R is entirely before the intersection range.
   //   2. R is entirely after the intersection range.
@@ -238,6 +245,190 @@
 }
 
 namespace {
+
+/// A little component aggregating all of the reasoning we have about
+/// the ranges of symbolic expressions.
+///
+/// Even when we don't know the exact values of the operands, we still
+/// can get a pretty good estimate of the result's range.
+class SymbolicRangeInferrer
+: public SymExprVisitor {
+public:
+  static RangeSet inferRange(BasicValueFactory &BV, RangeSet::Factory &F,
+ ProgramStateRef State, SymbolRef Sym) {
+SymbolicRangeInferrer Inferrer(BV, F, State);
+return Inferrer.infer(Sym);
+  }
+
+  RangeSet VisitSymExpr(SymbolRef Sym) {
+// If we got to this function, the actual type of the symbolic
+// expression is not supported for advanced inference.
+// In this case, we simply backoff to the default "let's simply
+// infer the range from the expression's type".
+return infer(Sym->getType());
+  }
+
+  RangeSet VisitSymIntExpr(const SymIntExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }
+
+  RangeSet VisitIntSymExpr(const IntSymExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }
+
+  RangeSet VisitSymSymExpr(const SymSymExpr *Sym) {
+return VisitBinaryOperator(Sym);
+  }
+
+private:
+  SymbolicRangeInferrer(BasicValueFactory &BV, RangeSet::Factory &F,
+ProgramStateRef S)
+  : ValueFactory(BV), RangeFactory(F), State(S) {}
+
+  /// Infer range information from the given integer constant.
+  ///
+  /// It's not a real "inference", but is here

[PATCH] D78429: [clangd] Metric tracking through Tracer

2020-05-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 261441.
kadircet marked 4 inline comments as done.
kadircet added a comment.

- Change IsEmpty with SizeIs
- Make TestTracer thread-safe


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78429

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/support/Trace.cpp
  clang-tools-extra/clangd/support/Trace.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/LSPClient.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTracer.h
  clang-tools-extra/clangd/unittests/support/TestTracer.cpp
  clang-tools-extra/clangd/unittests/support/TestTracer.h
  clang-tools-extra/clangd/unittests/support/TraceTests.cpp

Index: clang-tools-extra/clangd/unittests/support/TraceTests.cpp
===
--- clang-tools-extra/clangd/unittests/support/TraceTests.cpp
+++ clang-tools-extra/clangd/unittests/support/TraceTests.cpp
@@ -6,10 +6,12 @@
 //
 //===--===//
 
+#include "support/Context.h"
+#include "support/TestTracer.h"
 #include "support/Trace.h"
-
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/YAMLParser.h"
@@ -20,6 +22,8 @@
 namespace clangd {
 namespace {
 
+using testing::SizeIs;
+
 MATCHER_P(StringNode, Val, "") {
   if (arg->getType() != llvm::yaml::Node::NK_Scalar) {
 *result_listener << "is a " << arg->getVerbatimTag();
@@ -122,6 +126,18 @@
   ASSERT_EQ(++Prop, Root->end());
 }
 
+TEST(MetricsTracer, LatencyTest) {
+  trace::TestTracer Tracer;
+  constexpr llvm::StringLiteral MetricName = "span_latency";
+  constexpr llvm::StringLiteral OpName = "op_name";
+  {
+// A span should record latencies to span_latency by default.
+trace::Span SpanWithLat(OpName);
+EXPECT_THAT(Tracer.takeMetric(MetricName, OpName), SizeIs(0));
+  }
+  EXPECT_THAT(Tracer.takeMetric(MetricName, OpName), SizeIs(1));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/support/TestTracer.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/support/TestTracer.h
@@ -0,0 +1,49 @@
+//===-- TestTracer.h *- 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
+//
+//===--===//
+//
+// Allows setting up a fake tracer for tests.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SUPPORT_TESTTRACER_H
+#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SUPPORT_TESTTRACER_H
+
+#include "support/Trace.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace trace {
+
+/// A RAII Tracer that can be used by tests.
+class TestTracer : public EventTracer {
+public:
+  TestTracer() : Session(*this) {}
+  /// Stores all the measurements to be returned with take later on.
+  void record(const Metric &Metric, double Value,
+  llvm::StringRef Label) override;
+
+  /// Returns recorded measurements for \p Metric and clears them.
+  std::vector takeMetric(llvm::StringRef Metric,
+ llvm::StringRef Label = "");
+
+private:
+  std::mutex Mu;
+  /// Measurements recorded per metric per label.
+  llvm::StringMap>> Measurements;
+  Session Session;
+};
+
+} // namespace trace
+} // namespace clangd
+} // namespace clang
+#endif
Index: clang-tools-extra/clangd/unittests/support/TestTracer.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/support/TestTracer.cpp
@@ -0,0 +1,37 @@
+//===-- TestTracer.cpp - Tracing unit tests -*- 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
+//
+//===--===//
+#include "TestTracer.h"
+#include "support/Trace.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+
+namespace clang {
+namespa