Re: [PATCH] D78598: [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd

2020-05-11 Thread Kadir Çetinkaya via cfe-commits
yes that's the case. See
https://github.com/clangd/vscode-clangd/pulls?q=is%3Apr

On Mon, May 11, 2020 at 9:57 AM Nathan Ridge via Phabricator <
revi...@reviews.llvm.org> wrote:

> nridge added a comment.
>
> Also, does this mean that patches to vscode-clangd should now be submitted
> as a Github PR rather than via Phabricator?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D78598/new/
>
> https://reviews.llvm.org/D78598
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8222107 - [AST] Preserve the type in RecoveryExprs for broken function calls.

2020-05-11 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-05-11T08:46:18+02:00
New Revision: 8222107aa9249aada81334c922a2d284042242ed

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

LOG: [AST] Preserve the type in RecoveryExprs for broken function calls.

RecoveryExprs are modeled as dependent type to prevent bogus diagnostics
and crashes in clang.

This patch allows to preseve the type for broken calls when the
RecoveryEprs have a known type, e.g. a broken non-overloaded call, a
overloaded call when the all candidates have the same return type, so
that more features (code completion still work on "take2args(x).^") still
work.

However, adding the type is risky, which may result in more clang code being
affected leading to new crashes and hurt diagnostic, and it requires large
effort to minimize the affect (update all sites in clang to handle errorDepend
case), so we add a new flag (off by default) to allow us to develop/test
them incrementally.

This patch also has some trivial fixes to suppress diagnostics (to prevent 
regressions).

Tested:

all existing tests are passed (when both "-frecovery-ast", 
"-frecovery-ast-type" flags are flipped on);

Reviewed By: sammccall

Subscribers: rsmith, arphaman, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/AST/ast-dump-recovery.cpp
clang/test/CodeCompletion/member-access.cpp
clang/test/Index/getcursor-recovery.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 6c83bc6c649d..0ca4941789e7 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6097,21 +6097,25 @@ class TypoExpr : public Expr {
 /// subexpressions of some expression that we could not construct and source
 /// range covered by the expression.
 ///
-/// For now, RecoveryExpr is type-, value- and instantiation-dependent to take
-/// advantage of existing machinery to deal with dependent code in C++, e.g.
-/// RecoveryExpr is preserved in `decltype()` as part of the
+/// By default, RecoveryExpr is type-, value- and instantiation-dependent to
+/// take advantage of existing machinery to deal with dependent code in C++,
+/// e.g. RecoveryExpr is preserved in `decltype()` as part of the
 /// `DependentDecltypeType`. In addition to that, clang does not report most
 /// errors on dependent expressions, so we get rid of bogus errors for free.
 /// However, note that unlike other dependent expressions, RecoveryExpr can be
 /// produced in non-template contexts.
+/// In addition, we will preserve the type in RecoveryExpr when the type is
+/// known, e.g. preserving the return type for a broken non-overloaded function
+/// call, a overloaded call where all candidates have the same return type.
 ///
 /// One can also reliably suppress all bogus errors on expressions containing
 /// recovery expressions by examining results of Expr::containsErrors().
 class RecoveryExpr final : public Expr,
private llvm::TrailingObjects 
{
 public:
-  static RecoveryExpr *Create(ASTContext &Ctx, SourceLocation BeginLoc,
-  SourceLocation EndLoc, ArrayRef 
SubExprs);
+  static RecoveryExpr *Create(ASTContext &Ctx, QualType T,
+  SourceLocation BeginLoc, SourceLocation EndLoc,
+  ArrayRef SubExprs);
   static RecoveryExpr *CreateEmpty(ASTContext &Ctx, unsigned NumSubExprs);
 
   ArrayRef subExpressions() {
@@ -6136,8 +6140,8 @@ class RecoveryExpr final : public Expr,
   }
 
 private:
-  RecoveryExpr(ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc,
-   ArrayRef SubExprs);
+  RecoveryExpr(ASTContext &Ctx, QualType T, SourceLocation BeginLoc,
+   SourceLocation EndLoc, ArrayRef SubExprs);
   RecoveryExpr(EmptyShell Empty, unsigned NumSubExprs)
   : Expr(RecoveryExprClass, Empty), NumExprs(NumSubExprs) {}
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 02f67636d03d..8073031e5975 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -149,6 +149,7 @@ LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed 
matching of template t
 LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for 
all language standard modes")
 
 COMPATI

[clang] d82538b - Fix -Wunused compiler warning.

2020-05-11 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-05-11T09:20:48+02:00
New Revision: d82538b3f691f3ba1cb7a945a5f8594f71816fdf

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

LOG: Fix -Wunused compiler warning.

Added: 


Modified: 
clang/lib/AST/Expr.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 2a0e0425ef1f..8b327300fb2d 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -4686,8 +4686,10 @@ RecoveryExpr::RecoveryExpr(ASTContext &Ctx, QualType T, 
SourceLocation BeginLoc,
 : Expr(RecoveryExprClass, T, VK_LValue, OK_Ordinary), BeginLoc(BeginLoc),
   EndLoc(EndLoc), NumExprs(SubExprs.size()) {
   assert(!T.isNull());
+#ifndef NDEBUG // avoid -Wunused warnings.
   for (auto *E : SubExprs)
 assert(E != nullptr);
+#endif
 
   llvm::copy(SubExprs, getTrailingObjects());
   setDependence(computeDependence(this));



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


[PATCH] D79587: [CodeGen][SVE] Legalisation of extends with scalable types

2020-05-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

For sunpckhi... no, not really.  You'd need to either add a new opcode, or add 
a new shuffle operation of some sort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79587



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


[PATCH] D79276: [FileCheck] Support comment directives

2020-05-11 Thread James Henderson via Phabricator via cfe-commits
jhenderson added inline comments.



Comment at: llvm/test/FileCheck/comment/suffixes.txt:1-2
+# Comment prefixes plus check directive suffixes are not comment directives
+# and are treated as plain text.
+

jdenny wrote:
> jhenderson wrote:
> > jdenny wrote:
> > > jhenderson wrote:
> > > > I don't think you should change anything here, but if I'm following 
> > > > this right, this leads to the amusing limitation that you can "comment 
> > > > out" (via --comment-prefixes) any CHECK lines that use a suffix 
> > > > (CHECK-NEXT, CHECK-NOT etc) but not those that don't without changing 
> > > > --check-prefixes value!
> > > > 
> > > > By the way, do we need to have a test-case for that? I.e. that 
> > > > --comment-prefixes=CHECK-NEXT disables the CHECK-NEXT lines (assuming 
> > > > it does of course)?
> > > > I don't think you should change anything here, but if I'm following 
> > > > this right, this leads to the amusing limitation that you can "comment 
> > > > out" (via --comment-prefixes) any CHECK lines that use a suffix 
> > > > (CHECK-NEXT, CHECK-NOT etc) but not those that don't without changing 
> > > > --check-prefixes value!
> > > 
> > > That's right, but check prefixes have this problem too.  That is, you can 
> > > do things like `-check-prefixes=FOO,FOO-NOT` so that `FOO-NOT` is not 
> > > negative.
> > > 
> > > `ValidatePrefixes` should be extended to catch such cases, I think.  But 
> > > in a separate patch.
> > > 
> > > > By the way, do we need to have a test-case for that? I.e. that 
> > > > --comment-prefixes=CHECK-NEXT disables the CHECK-NEXT lines (assuming 
> > > > it does of course)?
> > > 
> > > Hmm.  I think it's behavior we don't want to support.  Maybe the test 
> > > case should be added when extending `ValidatePrefixes` as I described 
> > > above?
> > > 
> > I agree it's separate work. FWIW, I just came up with a genuinely useful 
> > use-case for it with CHECK directives, but it might just be unnecessary. 
> > Imagine the case where you want a test where some specific output is 
> > printed under one condition and not another condition. You'd want something 
> > like:
> > 
> > ```
> > # RUN: ... | FileCheck %s --check-prefix=WITH
> > # RUN: ... | FileCheck %s --check-prefix=WITHOUT
> > 
> > # WITH: some text that should be matched
> > # WITHOUT-NOT: some text that should be matched
> > ```
> > 
> > A careleses developer could change the text of "WITH" to match some new 
> > behaviour without changing "WITHOUT-NOT", thus breaking the second case. 
> > You could instead do:
> > 
> > ```
> > # RUN: ... | FileCheck %s --check-prefix=CHECK-NOT
> > # RUN: ... | FileCheck %s
> > 
> > # CHECK-NOT: some text that should be matched
> > ```
> > Then, if the output changed, you'd update both the regular and NOT match. I 
> > might have used this pattern in a few tests in the past had it occurred to 
> > me.
> > 
> > Anyway, I think there are other ways of solving that problem, although not 
> > without work on FileCheck (I've been prototyping a method with only limited 
> > success so far), and I agree it's otherwise mostly horrible, so I'm not 
> > seriously opposing the suggestion.
> I agree the use case is important, and I also agree there must be a better 
> solution.
> 
> The underlying issue is that we want to reuse a pattern.  Perhaps there 
> should be some way to define a FileCheck variable once and reuse it among 
> multiple FileCheck commands. For example:
> 
> ```
> # RUN: ... | FileCheck %s --check-prefix=WITH,ALL
> # RUN: ... | FileCheck %s --check-prefix=WITHOUT,ALL
> 
> # ALL-DEF: [[VAR:some text that should be matched]]
> # WITH: [[VAR]]
> # WITHOUT-NOT: [[VAR]]
> ```
> 
> It should probably be possible to use regexes in such a variable.  I'm not 
> sure if that's possible now.  It might require a special variable type.  We 
> currently have `#` to indicate numeric variables.  Perhaps `~` would indicate 
> pattern variables.
That's almost exactly what I've been prototyping on-and-off over the past few 
months, but I've been running into various ordering issues, which I haven't yet 
solved to my satisfaction. My original thread that inspired the idea is 
http://lists.llvm.org/pipermail/llvm-dev/2020-January/138822.html.


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

https://reviews.llvm.org/D79276



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


[PATCH] D79160: [AST] Preserve the type in RecoveryExprs for broken function calls.

2020-05-11 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8222107aa924: [AST] Preserve the type in RecoveryExprs for 
broken function calls. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79160

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/CodeCompletion/member-access.cpp
  clang/test/Index/getcursor-recovery.cpp

Index: clang/test/Index/getcursor-recovery.cpp
===
--- clang/test/Index/getcursor-recovery.cpp
+++ clang/test/Index/getcursor-recovery.cpp
@@ -2,15 +2,24 @@
 int foo(int, double);
 int x;
 
-void testTypedRecoveryExpr() {
-  // Inner foo() is a RecoveryExpr, outer foo() is an overloaded call.
-  foo(x, foo(x));
+void testTypedRecoveryExpr1() {
+  // Inner bar() is an unresolved overloaded call, outer foo() is an overloaded call.
+  foo(x, bar(x));
 }
-// RUN: c-index-test -cursor-at=%s:7:3 %s -Xclang -frecovery-ast | FileCheck -check-prefix=OUTER-FOO %s
+// RUN: c-index-test -cursor-at=%s:7:3 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=OUTER-FOO %s
 // OUTER-FOO: OverloadedDeclRef=foo[2:5, 1:5]
-// RUN: c-index-test -cursor-at=%s:7:7 %s -Xclang -frecovery-ast | FileCheck -check-prefix=OUTER-X %s
+// RUN: c-index-test -cursor-at=%s:7:7 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=OUTER-X %s
 // OUTER-X: DeclRefExpr=x:3:5
-// RUN: c-index-test -cursor-at=%s:7:10 %s -Xclang -frecovery-ast | FileCheck -check-prefix=INNER-FOO %s
-// INNER-FOO: OverloadedDeclRef=foo[2:5, 1:5]
-// RUN: c-index-test -cursor-at=%s:7:14 %s -Xclang -frecovery-ast | FileCheck -check-prefix=INNER-X %s
+// RUN: c-index-test -cursor-at=%s:7:10 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=INNER-FOO %s
+// INNER-FOO: OverloadedDeclRef=bar
+// RUN: c-index-test -cursor-at=%s:7:14 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=INNER-X %s
 // INNER-X: DeclRefExpr=x:3:5
+
+void testTypedRecoveryExpr2() {
+  // Inner foo() is a RecoveryExpr (with int type), outer foo() is a valid "foo(int, int)" call.
+  foo(x, foo(x));
+}
+// RUN: c-index-test -cursor-at=%s:20:3 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=TEST2-OUTER %s
+// TEST2-OUTER: DeclRefExpr=foo:1:5
+// RUN: c-index-test -cursor-at=%s:20:10 %s -Xclang -frecovery-ast -Xclang -frecovery-ast-type | FileCheck -check-prefix=TEST2-INNER %s
+// TEST2-INNER: OverloadedDeclRef=foo[2:5, 1:5]
Index: clang/test/CodeCompletion/member-access.cpp
===
--- clang/test/CodeCompletion/member-access.cpp
+++ clang/test/CodeCompletion/member-access.cpp
@@ -273,3 +273,12 @@
 // RUN: --implicit-check-not="[#char#]operator=("
 // CHECK-OPER: [#int#]operator=(
 
+struct S { int member; };
+S overloaded(int);
+S overloaded(double);
+void foo() {
+  // No overload matches, but we have recovery-expr with the correct type.
+  overloaded().
+}
+// RUN: not %clang_cc1 -fsyntax-only -frecovery-ast -frecovery-ast-type -code-completion-at=%s:281:16 %s -o - | FileCheck -check-prefix=CHECK-RECOVERY %s
+// CHECK-RECOVERY: [#int#]member
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -1,12 +1,13 @@
-// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -frecovery-ast -ast-dump %s | FileCheck -strict-whitespace %s
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -frecovery-ast -frecovery-ast-type -ast-dump %s | FileCheck -strict-whitespace %s
 // RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -fno-recovery-ast -ast-dump %s | FileCheck --check-prefix=DISABLED -strict-whitespace %s
 
 int some_func(int *);
 
 // CHECK: VarDecl {{.*}} invalid_call
-// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
-// CHECK-NEXT:  |-UnresolvedLookupExpr {{.*}} 'some_func'
-// CHECK-NEXT:  `-IntegerLiteral {{.*}} 123
+// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' contains-errors
+// CHECK-NEXT:  `-RecoveryExpr {{.*}} 'int' contains-errors
+// CHECK-NEXT:|-UnresolvedLookupExpr {{.*}} 'some_func'
+// CHECK-NEXT:`-IntegerLiteral {{.*}} 123
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int invalid_call = some_func(123);
 

[clang] 507d1eb - Add a missing test file for recovery expressions.

2020-05-11 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-05-11T09:23:32+02:00
New Revision: 507d1eb1cec33ccc2fce0ee7f688e19a42e43990

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

LOG: Add a missing test file for recovery expressions.

The test was missed in 8222107aa9249aada81334c922a2d284042242.

Added: 
clang/test/SemaCXX/recovery-expr-type.cpp

Modified: 


Removed: 




diff  --git a/clang/test/SemaCXX/recovery-expr-type.cpp 
b/clang/test/SemaCXX/recovery-expr-type.cpp
new file mode 100644
index ..df40e5cd6021
--- /dev/null
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -fsyntax-only -verify
+
+namespace test0 {
+struct Indestructible {
+  // Indestructible();
+  ~Indestructible() = delete; // expected-note 2{{deleted}}
+};
+Indestructible make_indestructible();
+
+void test() {
+  // no crash.
+  int s = sizeof(make_indestructible()); // expected-error {{deleted}}
+  constexpr int ss = sizeof(make_indestructible()); // expected-error 
{{deleted}}
+  static_assert(ss, "");
+  int array[ss];
+}
+}
+
+namespace test1 {
+constexpr int foo() { return 1; } // expected-note {{candidate function not 
viable}}
+// verify the "not an integral constant expression" diagnostic is suppressed.
+static_assert(1 == foo(1), ""); // expected-error {{no matching function}}
+}
+
+namespace test2 {
+void foo(); // expected-note 3{{requires 0 arguments}}
+void func() {
+  // verify that "field has incomplete type" diagnostic is suppressed.
+  typeof(foo(42)) var; // expected-error {{no matching function}}
+
+  // FIXME: suppress the "cannot initialize a variable" diagnostic.
+  int a = foo(1); // expected-error {{no matching function}} \
+  // expected-error {{cannot initialize a variable of type}}
+
+  // FIXME: suppress the "invalid application" diagnostic.
+  int s = sizeof(foo(42)); // expected-error {{no matching function}} \
+   // expected-error {{invalid application of 
'sizeof'}}
+};
+}
+
+namespace test3 {
+template 
+constexpr int templated() __attribute__((enable_if(N, ""))) { // expected-note 
{{candidate disabled}}
+  return 1;
+}
+// verify that "constexpr variable must be initialized" diagnostic is 
suppressed.
+constexpr int A = templated<0>(); // expected-error{{no matching function}}
+
+template 
+struct AA {
+  template 
+  static constexpr int getB() { // expected-note{{candidate template ignored}}
+return 2;
+  }
+  static constexpr int foo2() {
+return AA::getB(); // expected-error{{no matching function for call to 
'getB'}} \
+  // expected-note {{subexpression not valid in a 
constant expression}}
+  }
+};
+// FIXME: should we suppress the "be initialized by a constant expression" 
diagnostic?
+constexpr auto x2 = AA::foo2(); // expected-error {{be initialized by a 
constant expression}} \
+ // expected-note {{in instantiation of 
member function}} \
+ // expected-note {{in call to}}
+}



___
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-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

This looks good now, but sorry, one more request: I've just noticed a Clang 
driver test is missing. Can you add a test for this to 
`clang/test/Driver/aarch64-cpus.c`? And related to this, the relevant tests to 
`llvm/unittests/Support/TargetParserTest.cpp`?


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] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-11 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 accepted this revision.
gamesh411 added a comment.
This revision is now accepted and ready to land.

With the minor adjustment in the one test case this LGTM.




Comment at: clang/test/Analysis/vla.c:107
+  if (x == BIGINDEX) {
+size_t s = sizeof(int[x][x][x][x]); // expected-warning{{Declared 
variable-length array (VLA) has too large size}}
+return s;

martong wrote:
> I think we could make the arithmetic more clear here:
> x = BIGINDEX 65536 (2^16) and `char[x][x][x][x]` would be the first to 
> overflow.
> And `char[x][x][x][x-1]` should not overflow.
> 
> And if we are at it, then `size_t`'s range is target dependent, so I think we 
> must extend the `RUN` line with `-target`.
I would also find the extra comment and the extra passing test case helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[clang-tools-extra] cc9fefe - [clangd] Make version in PublishDiagnosticsParams optional

2020-05-11 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-05-11T10:31:10+02:00
New Revision: cc9fefec4368efb64e78dee1109e342b37d21bca

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

LOG: [clangd] Make version in PublishDiagnosticsParams optional

Summary: We were serializing it no matter what, which was against the spec

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/test/diagnostics-no-tidy.test
clang-tools-extra/clangd/test/diagnostics.test

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 675ba18e80ce..ecae65336e5b 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -560,11 +560,13 @@ bool fromJSON(const llvm::json::Value &Params, Diagnostic 
&R) {
 }
 
 llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
-  return llvm::json::Object{
+  llvm::json::Object Result{
   {"uri", PDP.uri},
   {"diagnostics", PDP.diagnostics},
-  {"version", PDP.version},
   };
+  if (PDP.version)
+Result["version"] = PDP.version;
+  return std::move(Result);
 }
 
 bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R) {

diff  --git a/clang-tools-extra/clangd/test/diagnostics-no-tidy.test 
b/clang-tools-extra/clangd/test/diagnostics-no-tidy.test
index 1a1068dafd5b..9341275b6c21 100644
--- a/clang-tools-extra/clangd/test/diagnostics-no-tidy.test
+++ b/clang-tools-extra/clangd/test/diagnostics-no-tidy.test
@@ -32,8 +32,7 @@
 #  CHECK:  "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [],
-# CHECK-NEXT:"uri": "file://{{.*}}/foo.c",
-# CHECK-NEXT:"version": null
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}

diff  --git a/clang-tools-extra/clangd/test/diagnostics.test 
b/clang-tools-extra/clangd/test/diagnostics.test
index 6f54e2cf115a..588fefdbf2e0 100644
--- a/clang-tools-extra/clangd/test/diagnostics.test
+++ b/clang-tools-extra/clangd/test/diagnostics.test
@@ -48,8 +48,7 @@
 #  CHECK:  "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [],
-# CHECK-NEXT:"uri": "file://{{.*}}/foo.c",
-# CHECK-NEXT:"version": null
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}



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


[PATCH] D79500: [clangd] Refactor code completion signal's utility properties.

2020-05-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:112
 SymbolRelevanceSignals Relevance;
-Relevance.Name = Sym.Name;
 Relevance.Query = SymbolRelevanceSignals::Generic;

why this change?



Comment at: clang-tools-extra/clangd/Quality.h:129
 
+  // Properties and utilites used to compute derived signals. These are ignored
+  // by a scoring function. Must be explicitly assigned.

Why is it better to group the fields acconding to how they're used in the 
scoring function, rather than by what they mean?
(I find the new grouping harder to follow)



Comment at: clang-tools-extra/clangd/Quality.h:153
+unsigned ScopeProximityDistance = FileDistance::Unreachable;
+  } Derived;
+

Can we make this Optional, so we can verify it gets computed? In fact, does it 
need to be a member at all, or can it just be transiently created while calling 
evaluate?



Comment at: clang-tools-extra/clangd/Quality.h:155
+
+  void calculateDerivedSignals();
+

why must this be called explicitly rather than being computed by Evaluate?



Comment at: clang-tools-extra/clangd/Quality.h.rej:1
+--- third_party/llvm/llvm-project/clang-tools-extra/clangd/Quality.h
 third_party/llvm/llvm-project/clang-tools-extra/clangd/Quality.h

Bad merge?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79500



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


[PATCH] D79692: [clangd] Make version in PublishDiagnosticsParams optional

2020-05-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc9fefec4368: [clangd] Make version in 
PublishDiagnosticsParams optional (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D79692?vs=263084&id=263117#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79692

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/test/diagnostics-no-tidy.test
  clang-tools-extra/clangd/test/diagnostics.test


Index: clang-tools-extra/clangd/test/diagnostics.test
===
--- clang-tools-extra/clangd/test/diagnostics.test
+++ clang-tools-extra/clangd/test/diagnostics.test
@@ -48,8 +48,7 @@
 #  CHECK:  "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [],
-# CHECK-NEXT:"uri": "file://{{.*}}/foo.c",
-# CHECK-NEXT:"version": null
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
Index: clang-tools-extra/clangd/test/diagnostics-no-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-no-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-no-tidy.test
@@ -32,8 +32,7 @@
 #  CHECK:  "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [],
-# CHECK-NEXT:"uri": "file://{{.*}}/foo.c",
-# CHECK-NEXT:"version": null
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -560,11 +560,13 @@
 }
 
 llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
-  return llvm::json::Object{
+  llvm::json::Object Result{
   {"uri", PDP.uri},
   {"diagnostics", PDP.diagnostics},
-  {"version", PDP.version},
   };
+  if (PDP.version)
+Result["version"] = PDP.version;
+  return std::move(Result);
 }
 
 bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R) {


Index: clang-tools-extra/clangd/test/diagnostics.test
===
--- clang-tools-extra/clangd/test/diagnostics.test
+++ clang-tools-extra/clangd/test/diagnostics.test
@@ -48,8 +48,7 @@
 #  CHECK:  "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [],
-# CHECK-NEXT:"uri": "file://{{.*}}/foo.c",
-# CHECK-NEXT:"version": null
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
Index: clang-tools-extra/clangd/test/diagnostics-no-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-no-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-no-tidy.test
@@ -32,8 +32,7 @@
 #  CHECK:  "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [],
-# CHECK-NEXT:"uri": "file://{{.*}}/foo.c",
-# CHECK-NEXT:"version": null
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -560,11 +560,13 @@
 }
 
 llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
-  return llvm::json::Object{
+  llvm::json::Object Result{
   {"uri", PDP.uri},
   {"diagnostics", PDP.diagnostics},
-  {"version", PDP.version},
   };
+  if (PDP.version)
+Result["version"] = PDP.version;
+  return std::move(Result);
 }
 
 bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4cad975 - [SveEmitter] Add builtins for svmovlb and svmovlt

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

Author: Sander de Smalen
Date: 2020-05-11T09:41:58+01:00
New Revision: 4cad97595f40f7a5bda25f4aa107cbbce05bd394

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

LOG: [SveEmitter] Add builtins for svmovlb and svmovlt

These builtins are expanded in CGBuiltin to use intrinsics
for (signed/unsigned) shift left long top/bottom.

Reviewers: efriedma, SjoerdMeijer

Reviewed By: efriedma

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

Added: 
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlb.c
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlt.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 97668dfa162d..b827601d56c1 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1481,6 +1481,11 @@ def SVSHLLB_U_N : SInst<"svshllb[_n_{d}]", "dhi", 
"UsUiUl", MergeNone, "aarch64_
 def SVSHLLT_S_N : SInst<"svshllt[_n_{d}]", "dhi", "sil",MergeNone, 
"aarch64_sve_sshllt", [], [ImmCheck<1, ImmCheckShiftLeft,  0>]>;
 def SVSHLLT_U_N : SInst<"svshllt[_n_{d}]", "dhi", "UsUiUl", MergeNone, 
"aarch64_sve_ushllt", [], [ImmCheck<1, ImmCheckShiftLeft,  0>]>;
 
+def SVMOVLB_S_N : SInst<"svmovlb[_{d}]", "dh",  "sil",MergeNone>;
+def SVMOVLB_U_N : SInst<"svmovlb[_{d}]", "dh",  "UsUiUl", MergeNone>;
+def SVMOVLT_S_N : SInst<"svmovlt[_{d}]", "dh",  "sil",MergeNone>;
+def SVMOVLT_U_N : SInst<"svmovlt[_{d}]", "dh",  "UsUiUl", MergeNone>;
+
 def SVMLALB_S_LANE : SInst<"svmlalb_lane[_{d}]",   "ddhhi", "il",   MergeNone, 
"aarch64_sve_smlalb_lane",   [], [ImmCheck<3, ImmCheckLaneIndex, 2>]>;
 def SVMLALB_U_LANE : SInst<"svmlalb_lane[_{d}]",   "ddhhi", "UiUl", MergeNone, 
"aarch64_sve_umlalb_lane",   [], [ImmCheck<3, ImmCheckLaneIndex, 2>]>;
 def SVMLALT_S_LANE : SInst<"svmlalt_lane[_{d}]",   "ddhhi", "il",   MergeNone, 
"aarch64_sve_smlalt_lane",   [], [ImmCheck<3, ImmCheckLaneIndex, 2>]>;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index dbe8826454dc..c64fde719445 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7824,6 +7824,13 @@ Value *CodeGenFunction::EmitSVEPMull(SVETypeFlags 
TypeFlags,
   return EmitSVEReinterpret(Call, Ty);
 }
 
+Value *CodeGenFunction::EmitSVEMovl(SVETypeFlags TypeFlags,
+ArrayRef Ops, unsigned BuiltinID) 
{
+  llvm::Type *OverloadedTy = getSVEType(TypeFlags);
+  Function *F = CGM.getIntrinsic(BuiltinID, OverloadedTy);
+  return Builder.CreateCall(F, {Ops[0], Builder.getInt32(0)});
+}
+
 Value *CodeGenFunction::EmitSVEPrefetchLoad(SVETypeFlags TypeFlags,
 SmallVectorImpl &Ops,
 unsigned BuiltinID) {
@@ -8070,6 +8077,26 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, {Ops[0], Ops[1], Ops[0]});
   }
 
+  case SVE::BI__builtin_sve_svmovlb_u16:
+  case SVE::BI__builtin_sve_svmovlb_u32:
+  case SVE::BI__builtin_sve_svmovlb_u64:
+return EmitSVEMovl(TypeFlags, Ops, Intrinsic::aarch64_sve_ushllb);
+
+  case SVE::BI__builtin_sve_svmovlb_s16:
+  case SVE::BI__builtin_sve_svmovlb_s32:
+  case SVE::BI__builtin_sve_svmovlb_s64:
+return EmitSVEMovl(TypeFlags, Ops, Intrinsic::aarch64_sve_sshllb);
+
+  case SVE::BI__builtin_sve_svmovlt_u16:
+  case SVE::BI__builtin_sve_svmovlt_u32:
+  case SVE::BI__builtin_sve_svmovlt_u64:
+return EmitSVEMovl(TypeFlags, Ops, Intrinsic::aarch64_sve_ushllt);
+
+  case SVE::BI__builtin_sve_svmovlt_s16:
+  case SVE::BI__builtin_sve_svmovlt_s32:
+  case SVE::BI__builtin_sve_svmovlt_s64:
+return EmitSVEMovl(TypeFlags, Ops, Intrinsic::aarch64_sve_sshllt);
+
   case SVE::BI__builtin_sve_svpmullt_u16:
   case SVE::BI__builtin_sve_svpmullt_u64:
   case SVE::BI__builtin_sve_svpmullt_n_u16:

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 06898f3232f4..61b51118212c 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3924,6 +3924,9 @@ class CodeGenFunction : public CodeGenTypeCache {
   llvm::Value *EmitSVEPMull(SVETypeFlags TypeFlags,
 llvm::SmallVectorImpl &Ops,
 unsigned BuiltinID);
+  llvm::Value *EmitSVEMovl(SVETypeFlags TypeFlags,
+   llvm::ArrayRef Ops,
+   unsigned BuiltinID);
   llvm::Value *EmitSVEPredicateCast(llvm::Value *Pred,
 llvm::ScalableVectorType *VTy);
   llvm::Value *EmitSVEGatherLoad(SVETypeFlags T

[PATCH] D60193: [OpenCL] Added addrspace_cast operator

2020-05-11 Thread Marco Antognini via Phabricator via cfe-commits
mantognini accepted this revision.
mantognini added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/SemaOpenCLCXX/addrspace_cast.cl:19-24
+template 
+void test_temp(__global int *par) {
+  T *var1 = addrspace_cast(par);
+  __private T *var2 = addrspace_cast<__private T *>(par);
+  T var3 = addrspace_cast(par);
+}

Anastasia wrote:
> mantognini wrote:
> > Does this test anything since it's not instantiated?
> It tests AST creation and Sema  but not after the TreeTransforms. I have now 
> enhanced it.
It is now much clearer.


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

https://reviews.llvm.org/D60193



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


[PATCH] D79579: [SveEmitter] Add builtins for svmovlb and svmovlt

2020-05-11 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cad97595f40: [SveEmitter] Add builtins for svmovlb and 
svmovlt (authored by sdesmalen).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D79579?vs=262624&id=263125#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79579

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlt.c

Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlt.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlt.c
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify=overload -verify-ignore-unexpected=error %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
+
+svint16_t test_svmovlt_s16(svint8_t op1)
+{
+  // CHECK-LABEL: test_svmovlt_s16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.sshllt.nxv8i16( %op1, i32 0)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svmovlt'}}
+  // expected-warning@+1 {{implicit declaration of function 'svmovlt_s16'}}
+  return SVE_ACLE_FUNC(svmovlt,_s16,,)(op1);
+}
+
+svint32_t test_svmovlt_s32(svint16_t op1)
+{
+  // CHECK-LABEL: test_svmovlt_s32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.sshllt.nxv4i32( %op1, i32 0)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svmovlt'}}
+  // expected-warning@+1 {{implicit declaration of function 'svmovlt_s32'}}
+  return SVE_ACLE_FUNC(svmovlt,_s32,,)(op1);
+}
+
+svint64_t test_svmovlt_s64(svint32_t op1)
+{
+  // CHECK-LABEL: test_svmovlt_s64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.sshllt.nxv2i64( %op1, i32 0)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svmovlt'}}
+  // expected-warning@+1 {{implicit declaration of function 'svmovlt_s64'}}
+  return SVE_ACLE_FUNC(svmovlt,_s64,,)(op1);
+}
+
+svuint16_t test_svmovlt_u16(svuint8_t op1)
+{
+  // CHECK-LABEL: test_svmovlt_u16
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ushllt.nxv8i16( %op1, i32 0)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svmovlt'}}
+  // expected-warning@+1 {{implicit declaration of function 'svmovlt_u16'}}
+  return SVE_ACLE_FUNC(svmovlt,_u16,,)(op1);
+}
+
+svuint32_t test_svmovlt_u32(svuint16_t op1)
+{
+  // CHECK-LABEL: test_svmovlt_u32
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ushllt.nxv4i32( %op1, i32 0)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svmovlt'}}
+  // expected-warning@+1 {{implicit declaration of function 'svmovlt_u32'}}
+  return SVE_ACLE_FUNC(svmovlt,_u32,,)(op1);
+}
+
+svuint64_t test_svmovlt_u64(svuint32_t op1)
+{
+  // CHECK-LABEL: test_svmovlt_u64
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.ushllt.nxv2i64( %op1, i32 0)
+  // CHECK: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svmovlt'}}
+  // expected-warning@+1 {{implicit declaration of function 'svmovlt_u64'}}
+  return SVE_ACLE_FUNC(svmovlt,_u64,,)(op1);
+}
Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlb.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_movlb.c
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-argument

[PATCH] D78658: [clang][Frontend] Add missing error handling

2020-05-11 Thread LemonBoy via Phabricator via cfe-commits
LemonBoy added a comment.

Ping?


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

https://reviews.llvm.org/D78658



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


[PATCH] D79701: [clangd] Add metrics for selection tree and recovery expressions.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79701

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -9,6 +9,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "support/TestTracer.h"
 #include "clang/AST/Decl.h"
 #include "llvm/Support/Casting.h"
 #include "gmock/gmock.h"
@@ -390,6 +391,7 @@
   )cpp", "DeclRefExpr"} // DeclRefExpr to the "operator->" method.
   };
   for (const Case &C : Cases) {
+trace::TestTracer Tracer;
 Annotations Test(C.Code);
 
 TestTU TU;
@@ -407,6 +409,7 @@
 if (Test.ranges().empty()) {
   // If no [[range]] is marked in the example, there should be no selection.
   EXPECT_FALSE(T.commonAncestor()) << C.Code << "\n" << T;
+  EXPECT_THAT(Tracer.takeMetric("selection"), testing::IsEmpty());
 } else {
   // If there is an expected selection, common ancestor should exist
   // with the appropriate node type.
@@ -422,6 +425,9 @@
   // and no nodes outside it are selected.
   EXPECT_TRUE(verifyCommonAncestor(T.root(), T.commonAncestor(), C.Code))
   << C.Code;
+  EXPECT_THAT(Tracer.takeMetric("selection"), testing::SizeIs(1));
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery_ast"),
+  testing::IsEmpty());
 }
   }
 }
@@ -436,6 +442,20 @@
   EXPECT_FALSE(D->isInjectedClassName());
 }
 
+TEST(SelectionTree, Metrics) {
+  const char *Code = R"cpp(
+// error-ok: testing behavior on recovery expression
+int foo();
+int foo(int, int);
+int x = fo^o(42);
+  )cpp";
+  auto AST = TestTU::withCode(Annotations(Code).code()).build();
+  trace::TestTracer Tracer;
+  auto T = makeSelectionTree(Code, AST);
+  EXPECT_THAT(Tracer.takeMetric("selection"), testing::SizeIs(1));
+  EXPECT_THAT(Tracer.takeMetric("selection_recovery_ast"), testing::SizeIs(1));
+}
+
 // FIXME: Doesn't select the binary operator node in
 //  #define FOO(X) X + 1
 //  int a, b = [[FOO(a)]];
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -9,6 +9,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
@@ -35,6 +36,23 @@
 using Node = SelectionTree::Node;
 using ast_type_traits::DynTypedNode;
 
+void recordMetrics(const SelectionTree &S) {
+  static constexpr trace::Metric Selection("selection", trace::Metric::Counter);
+  static constexpr trace::Metric SelectionRecoveryAST("selection_recovery_ast",
+  trace::Metric::Counter);
+  const auto *Common = S.commonAncestor();
+  if (Common)
+Selection.record(1); // account if something is actually selected.
+  for (const auto *N = Common; N; N = N->Parent) {
+if (N->ASTNode.get()) {
+  // FIXME: tracing the type through the label?
+  SelectionRecoveryAST.record(1);
+  break;
+}
+  }
+  return;
+}
+
 // An IntervalSet maintains a set of disjoint subranges of an array.
 //
 // Initially, it contains the entire array.
@@ -774,6 +792,7 @@
.printToString(SM));
   Nodes = SelectionVisitor::collect(AST, Tokens, PrintPolicy, Begin, End, FID);
   Root = Nodes.empty() ? nullptr : &Nodes.front();
+  recordMetrics(*this);
   dlog("Built selection tree\n{0}", *this);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2020-05-11 Thread Joxean Koret via Phabricator via cfe-commits
joxeankoret added a comment.

Any news? It's amazing that such a basic feature (getting an operator kind) 
with working patches (since 2015) is not yet available in 2020. If there is any 
work that needs to be done, I propose myself to do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D10833



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


[PATCH] D78190: Add Bfloat IR type

2020-05-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij added a comment.

Hi there, a gentle ping: does this look good to you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190



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


[PATCH] D79701: [clangd] Add metrics for selection tree and recovery expressions.

2020-05-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:39
 
+void recordMetrics(const SelectionTree &S) {
+  static constexpr trace::Metric Selection("selection", 
trace::Metric::Counter);

this deserves a comment about what we're tracking and why.
Like "measure the fraction of selections that were enabled by recovery AST"



Comment at: clang-tools-extra/clangd/Selection.cpp:40
+void recordMetrics(const SelectionTree &S) {
+  static constexpr trace::Metric Selection("selection", 
trace::Metric::Counter);
+  static constexpr trace::Metric SelectionRecoveryAST("selection_recovery_ast",

just realized a slightly more elegant(?) way to measure this:

```
Metric SelectionUsedRecovery("selection_recovery", Distribution);
...
for (...) {
  if (...) {
SelectionUsedRecovery.record(1); // used
return;
  }
}
SelectionUsedRecovery.record(0); // not used
```

Now the count is the total number of selections, and the average is the 
fraction that used recovery.



Comment at: clang-tools-extra/clangd/Selection.cpp:48
+if (N->ASTNode.get()) {
+  // FIXME: tracing the type through the label?
+  SelectionRecoveryAST.record(1);

FWIW, my original RecoveryExpr proposal included a StmtClass for the type of 
expr that was "supposed" to be here. (e.g. CallExpr for a failed overload 
resolution). It was dropped to keep the scope minimal.

I'm not sure if that exact idea generalizes to all the places that RecoveryExpr 
is used, but it would be great to somehow keep track of the semantic context 
where recovery was used. And I think it would make a great label here. Maybe 
this would be better as a dedicated enum, or just a string literal (e.g. 
"variable initializer").

Anyway, an idea for another time...



Comment at: clang-tools-extra/clangd/Selection.cpp:48
+if (N->ASTNode.get()) {
+  // FIXME: tracing the type through the label?
+  SelectionRecoveryAST.record(1);

sammccall wrote:
> FWIW, my original RecoveryExpr proposal included a StmtClass for the type of 
> expr that was "supposed" to be here. (e.g. CallExpr for a failed overload 
> resolution). It was dropped to keep the scope minimal.
> 
> I'm not sure if that exact idea generalizes to all the places that 
> RecoveryExpr is used, but it would be great to somehow keep track of the 
> semantic context where recovery was used. And I think it would make a great 
> label here. Maybe this would be better as a dedicated enum, or just a string 
> literal (e.g. "variable initializer").
> 
> Anyway, an idea for another time...
not clear quite what you mean by this - the *actual* type isn't a suitable 
label, as it's a large unbounded set.
The presence/absense might be interesting I guess, but I'm not sure about it: 
it's unclear what significance it has if the containing expression's type is 
know, if we're selecting something inside it. (More significant if the selected 
expression's type is known/unknown because a contained RecoveryExpr's type is 
known/unknown, but we can't track that)

I'm not sure this is a FIXME, it seems most likely we decide not to fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79701



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


[PATCH] D79678: [clangd] Add CSV export for trace metrics

2020-05-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 6 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/support/Trace.cpp:210
+assert(!needsQuote(Metric.Name));
+std::string QuotedLabel;
+if (needsQuote(Label))

kadircet wrote:
> do we ever expect to have any of `\r \n , "` in a label? I think it would be 
> OK to just assert notNeedsQuote on Label.
> 
> Up to you though.
I don't think it's terribly likely but I can certainly imagine:
 - using a filename as a label, and some people have weird filenames
 - wanting a compound label, and choosing comma as a separator

I was torn between:
 - doing the escaping (seems a little silly)
 - asserting (a bit of a time bomb in cases above)
 - just ignoring this and outputting garbage

Chose A because it's pretty short, and I wrote a test :-)



Comment at: clang-tools-extra/clangd/support/Trace.cpp:251
+using namespace std::chrono;
+return MicrosT0SinceEpoch +
+   duration(steady_clock::now() - 
SteadyT0).count();

kadircet wrote:
> what are the benefits for making these absolute apart from being able to 
> merge streams coming from different runs?
> I am not sure if we'll ever merge data from multiple users, or even multiple 
> runs from the same user.
> 
> This would help decrease output size only by a couple percents though, so not 
> that important. Just wondering if there are any other reasons.
Yeah no good reason I think. Removed.
Was thinking about converting into walltimes in analysis but it seems unlikely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79678



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


[PATCH] D79678: [clangd] Add CSV export for trace metrics

2020-05-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 263137.
sammccall added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79678

Files:
  clang-tools-extra/clangd/support/Trace.cpp
  clang-tools-extra/clangd/support/Trace.h
  clang-tools-extra/clangd/test/metrics.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  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
@@ -11,6 +11,7 @@
 #include "support/Trace.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/Threading.h"
@@ -22,7 +23,11 @@
 namespace clangd {
 namespace {
 
+using testing::_;
+using testing::ElementsAre;
+using testing::MatchesRegex;
 using testing::SizeIs;
+using testing::StartsWith;
 
 MATCHER_P(StringNode, Val, "") {
   if (arg->getType() != llvm::yaml::Node::NK_Scalar) {
@@ -138,6 +143,51 @@
   EXPECT_THAT(Tracer.takeMetric(MetricName, OpName), SizeIs(1));
 }
 
+class CSVMetricsTracerTest : public ::testing::Test {
+protected:
+  CSVMetricsTracerTest()
+  : OS(Output), Tracer(trace::createCSVMetricTracer(OS)), Session(*Tracer) {
+  }
+  trace::Metric Dist = {"dist", trace::Metric::Distribution, "lbl"};
+  trace::Metric Counter = {"cnt", trace::Metric::Counter};
+
+  std::vector outputLines() {
+// Deliberately don't flush output stream, the tracer should do that.
+// This is important when clangd crashes.
+llvm::SmallVector Lines;
+llvm::StringRef(Output).split(Lines, "\r\n");
+return {Lines.begin(), Lines.end()};
+  }
+
+  std::string Output;
+  llvm::raw_string_ostream OS;
+  std::unique_ptr Tracer;
+  trace::Session Session;
+};
+
+TEST_F(CSVMetricsTracerTest, RecordsValues) {
+  Dist.record(1, "x");
+  Counter.record(1, "");
+  Dist.record(2, "y");
+
+  EXPECT_THAT(
+  outputLines(),
+  ElementsAre("Kind,Metric,Label,Value,Timestamp",
+  MatchesRegex(R"(d,dist,x,1\.00e\+00,[0-9]+\.[0-9]{6})"),
+  StartsWith("c,cnt,,1.00e+00,"),
+  StartsWith("d,dist,y,2.00e+00,"), ""));
+}
+
+TEST_F(CSVMetricsTracerTest, Escaping) {
+  Dist.record(1, ",");
+  Dist.record(1, "a\"b");
+  Dist.record(1, "a\nb");
+
+  EXPECT_THAT(outputLines(), ElementsAre(_, StartsWith(R"(d,dist,",",1)"),
+ StartsWith(R"(d,dist,"a""b",1)"),
+ StartsWith("d,dist,\"a\nb\",1"), ""));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -539,18 +539,23 @@
   // Setup tracing facilities if CLANGD_TRACE is set. In practice enabling a
   // trace flag in your editor's config is annoying, launching with
   // `CLANGD_TRACE=trace.json vim` is easier.
-  llvm::Optional TraceStream;
+  llvm::Optional TracerStream;
   std::unique_ptr Tracer;
-  if (auto *TraceFile = getenv("CLANGD_TRACE")) {
+  const char *JSONTraceFile = getenv("CLANGD_TRACE");
+  const char *MetricsCSVFile = getenv("CLANGD_METRICS");
+  const char *TracerFile = JSONTraceFile ? JSONTraceFile : MetricsCSVFile;
+  if (TracerFile) {
 std::error_code EC;
-TraceStream.emplace(TraceFile, /*ref*/ EC,
-llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
+TracerStream.emplace(TracerFile, /*ref*/ EC,
+ llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
 if (EC) {
-  TraceStream.reset();
-  llvm::errs() << "Error while opening trace file " << TraceFile << ": "
+  TracerStream.reset();
+  llvm::errs() << "Error while opening trace file " << TracerFile << ": "
<< EC.message();
 } else {
-  Tracer = trace::createJSONTracer(*TraceStream, PrettyPrint);
+  Tracer = (TracerFile == JSONTraceFile)
+   ? trace::createJSONTracer(*TracerStream, PrettyPrint)
+   : trace::createCSVMetricTracer(*TracerStream);
 }
   }
 
Index: clang-tools-extra/clangd/test/metrics.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/metrics.test
@@ -0,0 +1,11 @@
+# RUN: env CLANGD_METRICS=%t clangd -lit-test < %s && FileCheck %s < %t
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":

[PATCH] D79201: [clang-format] : Fix additional pointer alignment for overloaded operators

2020-05-11 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

gentle ping!


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

https://reviews.llvm.org/D79201



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: ASDenysPetrov, martong, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
xazax.hun, whisperity.

Currently, parameters of functions without their definition present cannot be 
represented as regions because it would be difficult to ensure that the same 
declaration is used in every case. To overcome this, we introduce a new kind of 
region called `ParamRegion` which does not store the `Decl` of the parameter 
variable. Instead it stores the index of the parameter which enables retrieving 
the actual `Decl` every time using the function declaration of the stack frame.


Repository:
  rC Clang

https://reviews.llvm.org/D79704

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -440,6 +440,9 @@
   if (const auto *VR = dyn_cast(MR))
 return isLive(VR, true);
 
+  if (const auto *PR = dyn_cast(MR))
+return isLive(PR, true);
+
   // FIXME: This is a gross over-approximation. What we really need is a way to
   // tell if anything still refers to this region. Unlike SymbolicRegions,
   // AllocaRegions don't have associated symbols, though, so we don't actually
@@ -573,3 +576,53 @@
 
   return VarContext->isParentOf(CurrentContext);
 }
+
+bool SymbolReaper::isLive(const ParamRegion *PR,
+  bool includeStoreBindings) const{
+  const StackFrameContext *ParamContext = PR->getStackFrame();
+
+  if (!ParamContext)
+return true;
+
+  if (!LCtx)
+return false;
+  const StackFrameContext *CurrentContext = LCtx->getStackFrame();
+
+  if (ParamContext == CurrentContext) {
+// If no statement is provided, everything is live.
+if (!Loc)
+  return true;
+
+// Anonymous parameters of an inheriting constructor are live for the entire
+// duration of the constructor.
+if (isa(Loc))
+  return true;
+
+if (const ParmVarDecl *PVD = PR->getDecl()) {
+  if (LCtx->getAnalysis()->isLive(Loc, PVD))
+return true;
+}
+
+if (!includeStoreBindings)
+  return false;
+
+unsigned &cachedQuery =
+  const_cast(this)->includedRegionCache[PR];
+
+if (cachedQuery) {
+  return cachedQuery == 1;
+}
+
+// Query the store to see if the region occurs in any live bindings.
+if (Store store = reapedStore.getStore()) {
+  bool hasRegion =
+reapedStore.getStoreManager().includedInBindings(store, PR);
+  cachedQuery = hasRegion ? 1 : 2;
+  return hasRegion;
+}
+
+return false;
+  }
+
+  return ParamContext->isParentOf(CurrentContext);
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -138,6 +138,7 @@
 case MemRegion::CXXTempObjectRegionKind:
 case MemRegion::CXXBaseObjectRegionKind:
 case MemRegion::CXXDerivedObjectRegionKind:
+case MemRegion::ParamRegionKind:
   return MakeElementRegion(cast(R), PointeeTy);
 
 case MemRegion::ElementRegionKind: {
@@ -435,6 +436,19 @@
   return svalBuilder.dispatchCast(V, castTy);
 }
 
+Loc StoreManager::getLValueVar(const VarDecl *VD, const LocationContext *LC) {
+  if (const auto *PVD = dyn_cast(VD)) {
+const Expr* Call;
+unsigned Index;
+std::tie(Call, Index) = ParamRegion::getExprAndIndexForParam(PVD, LC);
+
+if (Call)
+  return svalBuilder.makeLoc(MRMgr.getParamRegion(Call, Index, LC));
+  }
+
+  return svalBuilder

[PATCH] D79201: [clang-format] : Fix additional pointer alignment for overloaded operators

2020-05-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Sorry, I thought I approved already :-(


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

https://reviews.llvm.org/D79201



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


[PATCH] D79708: [clangd][BFloat] add NEON emitter for bfloat

2020-05-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, kristof.beyls, mgorny.
Herald added a project: clang.
stuij added a parent revision: D76077: [ARM] Add __bf16 as new Bfloat16 C Type.
stuij edited parent revisions, added: D79711: [ARM][BFloat] Add poly64_t on 
AArch32.; removed: D76077: [ARM] Add __bf16 as new Bfloat16 C Type.

This patch adds the bfloat16_t struct typedefs (e.g. bfloat16x8x2_t) to
arm_neon.h

This patch is part of a series implementing the Bfloat16 extension of the
Armv8.6-a architecture, as detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties is specified in the Arm C language
extension specification:

https://developer.arm.com/docs/ihi0055/d/procedure-call-standard-for-the-arm-64-bit-architecture


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79708

Files:
  clang/include/clang/Basic/arm_bf16.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  clang/utils/TableGen/NeonEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -85,6 +85,7 @@
 
 void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitBF16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitNeonSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitNeonTest(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitNeon2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangOpenCLBuiltins,
   GenArmNeon,
   GenArmFP16,
+  GenArmBF16,
   GenArmNeonSema,
   GenArmNeonTest,
   GenArmMveHeader,
@@ -186,6 +187,7 @@
"Generate OpenCL builtin declaration handlers"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
+clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
 clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
"Generate ARM NEON sema support for clang"),
 clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
@@ -360,6 +362,9 @@
   case GenArmFP16:
 EmitFP16(Records, OS);
 break;
+  case GenArmBF16:
+EmitBF16(Records, OS);
+break;
   case GenArmNeonSema:
 EmitNeonSema(Records, OS);
 break;
Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -99,7 +99,8 @@
   Poly128,
   Float16,
   Float32,
-  Float64
+  Float64,
+  BFloat16
 };
 
 } // end namespace NeonTypeFlags
@@ -147,6 +148,7 @@
 SInt,
 UInt,
 Poly,
+BFloat16,
   };
   TypeKind Kind;
   bool Immediate, Constant, Pointer;
@@ -199,6 +201,7 @@
   bool isInt() const { return isInteger() && ElementBitwidth == 32; }
   bool isLong() const { return isInteger() && ElementBitwidth == 64; }
   bool isVoid() const { return Kind == Void; }
+  bool isBFloat16() const { return Kind == BFloat16; }
   unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
   unsigned getSizeInBits() const { return Bitwidth; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -585,8 +588,11 @@
   // runFP16 - Emit arm_fp16.h.inc
   void runFP16(raw_ostream &o);
 
-  // runHeader - Emit all the __builtin prototypes used in arm_neon.h
-	// and arm_fp16.h
+  // runBF16 - Emit arm_bf16.h.inc
+  void runBF16(raw_ostream &o);
+
+  // runHeader - Emit all the __builtin prototypes used in arm_neon.h,
+  // arm_fp16.h and arm_bf16.h
   void runHeader(raw_ostream &o);
 
   // runTests - Emit tests for all the Neon intrinsics.
@@ -611,12 +617,15 @@
 S += "poly";
   else if (isFloating())
 S += "float";
+  else if (isBFloat16())
+S += "bfloat";
   else
 S += "int";
 
   S += utostr(ElementBitwidth);
   if (isVector())
 S += "x" + utostr(getNumElements());
+
   if (NumVectors > 1)
 S += "x" + utostr(NumVectors);
   S += "_t";
@@ -650,7 +659,10 @@
 case 128: S += "LLLi"; break;
 default: llvm_unreachable("Unhandled case!");
 }
-  else
+  else if (isBFloat16()) {
+assert(ElementBitwidth == 

[PATCH] D79710: [clangd][BFloat] add create/set/get/dup intrinsics

2020-05-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, kristof.beyls.
Herald added a project: clang.

This patch is part of a series that adds support for the Bfloat16 extension of
the Armv8.6-a architecture, as detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties is specified in the Arm C language extension
specification:

https://developer.arm.com/docs/ihi0055/d/procedure-call-standard-for-the-arm-64-bit-architecture


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79710

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

Index: clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-feature +neon -target-feature +bf16 \
+// RUN:  -O2 -fallow-half-arguments-and-returns -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK64
+// RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-feature +neon -target-feature +bf16 -mfloat-abi hard \
+// RUN:  -O2 -fallow-half-arguments-and-returns -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK32
+
+#include 
+
+bfloat16x4_t test_vcreate_bf16(uint64_t a) {
+  return vcreate_bf16(a);
+}
+// CHECK-LABEL: test_vcreate_bf16
+// CHECK64: %0 = bitcast i64 %a to <4 x bfloat>
+// CHECK32: %0 = bitcast i64 %a to <4 x bfloat>
+
+bfloat16x4_t test_vdup_n_bf16(bfloat16_t v) {
+  return vdup_n_bf16(v);
+}
+// CHECK-LABEL: test_vdup_n_bf16
+// CHECK64: %vecinit.i = insertelement <4 x bfloat> undef, bfloat %v, i32 0
+// CHECK32: %vecinit.i = insertelement <4 x bfloat> undef, bfloat %v, i32 0
+// CHECK: %vecinit{{.*}} = shufflevector <4 x bfloat> %vecinit.i, <4 x bfloat> undef, <4 x i32> zeroinitializer
+
+bfloat16x8_t test_vdupq_n_bf16(bfloat16_t v) {
+  return vdupq_n_bf16(v);
+}
+// CHECK-LABEL: test_vdupq_n_bf16
+// CHECK64: %vecinit.i = insertelement <8 x bfloat> undef, bfloat %v, i32 0
+// CHECK32: %vecinit.i = insertelement <8 x bfloat> undef, bfloat %v, i32 0
+// CHECK:   %vecinit{{.*}} = shufflevector <8 x bfloat> %vecinit.i, <8 x bfloat> undef, <8 x i32> zeroinitializer
+
+bfloat16x4_t test_vdup_lane_bf16(bfloat16x4_t v) {
+  return vdup_lane_bf16(v, 1);
+}
+// CHECK-LABEL: test_vdup_lane_bf16
+// CHECK64: %lane = shufflevector <4 x bfloat> %v, <4 x bfloat> undef, <4 x i32> 
+// CHECK32: %lane = shufflevector <4 x bfloat> %v, <4 x bfloat> undef, <4 x i32> 
+
+bfloat16x8_t test_vdupq_lane_bf16(bfloat16x4_t v) {
+  return vdupq_lane_bf16(v, 1);
+}
+// CHECK-LABEL: test_vdupq_lane_bf16
+// CHECK64: %lane = shufflevector <4 x bfloat> %v, <4 x bfloat> undef, <8 x i32> 
+// CHECK32: %lane = shufflevector <4 x bfloat> %v, <4 x bfloat> undef, <8 x i32> 
+
+bfloat16x4_t test_vdup_laneq_bf16(bfloat16x8_t v) {
+  return vdup_laneq_bf16(v, 7);
+}
+// CHECK-LABEL: test_vdup_laneq_bf16
+// CHECK64: %lane = shufflevector <8 x bfloat> %v, <8 x bfloat> undef, <4 x i32> 
+// CHECK32: %lane = shufflevector <8 x bfloat> %v, <8 x bfloat> undef, <4 x i32> 
+
+bfloat16x8_t test_vdupq_laneq_bf16(bfloat16x8_t v) {
+  return vdupq_laneq_bf16(v, 7);
+}
+// CHECK-LABEL: test_vdupq_laneq_bf16
+// CHECK64: %lane = shufflevector <8 x bfloat> %v, <8 x bfloat> undef, <8 x i32> 
+// CHECK32: %lane = shufflevector <8 x bfloat> %v, <8 x bfloat> undef, <8 x i32> 
+
+bfloat16x8_t test_vcombine_bf16(bfloat16x4_t low, bfloat16x4_t high) {
+  return vcombine_bf16(low, high);
+}
+// CHECK-LABEL: test_vcombine_bf16
+// CHECK64: %shuffle.i = shufflevector <4 x bfloat> %low, <4 x bfloat> %high, <8 x i32> 
+// CHECK32: %shuffle.i = shufflevector <4 x bfloat> %low, <4 x bfloat> %high, <8 x i32> 
+
+bfloat16x4_t test_vget_high_bf16(bfloat16x8_t a) {
+  return vget_high_bf16(a);
+}
+// CHECK-LABEL: test_vget_high_bf16
+// CHECK64: %shuffle.i = shufflevector <8 x bfloat> %a, <8 x bfloat> undef, <4 x i32> 
+// CHECK32: %shuffle.i = shufflevector <8 x bfloat> %a, <8 x bfloat> undef, <4 x i32> 
+
+bfloat16x4_t test_vget_low_bf16(bfloat16x8_t a) {
+  return vget_low_bf16(a);
+}
+// CHECK-LABEL: test_vget_low_bf16
+// CHECK64: %shuffle.i = shufflevector <8 x bfloat> %a, <8 x bfloat> undef, <4 x i32> 
+// CHECK32: %shuffle.i = shufflevector <8 x bfloat> %a, <8 x bfloat> undef, <4 x i32> 
+
+bfloat16_t test_vget_lane_bf16(bfloat16x4_t v) {
+  return vget_lane_bf16(v, 1);
+}
+// CHECK-LABEL: test_vget_lane_bf16
+// CHECK64: %vget_lane = extractelement <4 x bfloat> %v, i32 1
+// CHECK32: %vget_lane = extractelement <4 x bfloat> %v, i32 1
+
+bfloat16_t test_vgetq_lane_bf16(bfloat16x8_t v) {
+  return vgetq_lane_bf16(v, 7);
+}
+// CHECK-LABEL: test_vgetq_lane_bf16
+// CHECK64: %vgetq_lane = extracteleme

[PATCH] D79711: [ARM][BFloat] Add poly64_t on AArch32.

2020-05-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added subscribers: cfe-commits, danielkiss, kristof.beyls.
Herald added a project: clang.
stuij added a parent revision: D76077: [ARM] Add __bf16 as new Bfloat16 C Type.
stuij added a child revision: D79708: [clangd][BFloat] add NEON emitter for 
bfloat.

The poly64 types are guarded with ifdefs for AArch64 only. This is wrong. This
was also incorrectly documented in the ACLE spec, but this has been rectified in
the latest release. See paragraph 13.1.2 "Vector data types":

https://developer.arm.com/docs/101028/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79711

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Sema/SemaType.cpp
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2235,6 +2235,7 @@
   OS << "#else\n";
   OS << "typedef int8_t poly8_t;\n";
   OS << "typedef int16_t poly16_t;\n";
+  OS << "typedef int64_t poly64_t;\n";
   OS << "#endif\n";
 
   // Emit Neon vector typedefs.
@@ -2247,7 +2248,7 @@
   for (auto &TS : TDTypeVec) {
 bool IsA64 = false;
 Type T(TS, ".");
-if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+if (T.isDouble())
   IsA64 = true;
 
 if (InIfdef && !IsA64) {
@@ -2280,7 +2281,7 @@
 for (auto &TS : TDTypeVec) {
   bool IsA64 = false;
   Type T(TS, ".");
-  if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+  if (T.isDouble())
 IsA64 = true;
 
   if (InIfdef && !IsA64) {
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7552,15 +7552,16 @@
 Triple.getArch() == llvm::Triple::aarch64_be;
   if (VecKind == VectorType::NeonPolyVector) {
 if (IsPolyUnsigned) {
-  // AArch64 polynomial vectors are unsigned and support poly64.
+  // AArch64 polynomial vectors are unsigned.
   return BTy->getKind() == BuiltinType::UChar ||
  BTy->getKind() == BuiltinType::UShort ||
  BTy->getKind() == BuiltinType::ULong ||
  BTy->getKind() == BuiltinType::ULongLong;
 } else {
-  // AArch32 polynomial vector are signed.
+  // AArch32 polynomial vectors are signed.
   return BTy->getKind() == BuiltinType::SChar ||
- BTy->getKind() == BuiltinType::Short;
+ BTy->getKind() == BuiltinType::Short ||
+ BTy->getKind() == BuiltinType::LongLong;
 }
   }
 
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3165,6 +3165,7 @@
 case BuiltinType::UShort:
   EltName = "poly16_t";
   break;
+case BuiltinType::LongLong:
 case BuiltinType::ULongLong:
   EltName = "poly64_t";
   break;
Index: clang/include/clang/Basic/TargetBuiltins.h
===
--- clang/include/clang/Basic/TargetBuiltins.h
+++ clang/include/clang/Basic/TargetBuiltins.h
@@ -157,7 +157,7 @@
 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
 bool isPoly() const {
   EltType ET = getEltType();
-  return ET == Poly8 || ET == Poly16;
+  return ET == Poly8 || ET == Poly16 || ET == Poly64;
 }
 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
 bool isQuad() const { return (Flags & QuadFlag) != 0; }


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2235,6 +2235,7 @@
   OS << "#else\n";
   OS << "typedef int8_t poly8_t;\n";
   OS << "typedef int16_t poly16_t;\n";
+  OS << "typedef int64_t poly64_t;\n";
   OS << "#endif\n";
 
   // Emit Neon vector typedefs.
@@ -2247,7 +2248,7 @@
   for (auto &TS : TDTypeVec) {
 bool IsA64 = false;
 Type T(TS, ".");
-if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+if (T.isDouble())
   IsA64 = true;
 
 if (InIfdef && !IsA64) {
@@ -2280,7 +2281,7 @@
 for (auto &TS : TDTypeVec) {
   bool IsA64 = false;
   Type T(TS, ".");
-  if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+  if (T.isDouble())
 IsA64 = true;
 
   if (InIfdef && !IsA64) {
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7552,15 +7552,16 @@
 Triple.getArch() == llvm::Triple::aarch64_be;
   if (VecKind == VectorType::NeonPolyVector) {
 if (IsPolyUnsigned) {
-  // AA

[PATCH] D79378: PR34581: Don't remove an 'if (p)' guarding a call to 'operator delete(p)' under -Oz.

2020-05-11 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added a comment.

From my point it does LGTM.




Comment at: clang/lib/CodeGen/CGExprCXX.cpp:2042-2049
   // Null check the pointer.
   llvm::BasicBlock *DeleteNotNull = createBasicBlock("delete.notnull");
   llvm::BasicBlock *DeleteEnd = createBasicBlock("delete.end");
 
   llvm::Value *IsNull = Builder.CreateIsNull(Ptr.getPointer(), "isnull");
 
   Builder.CreateCondBr(IsNull, DeleteEnd, DeleteNotNull);

rsmith wrote:
> dnsampaio wrote:
> > Unless I missed something, isn't it better to just avoid emitting this 
> > check and basic blocks all together if we are optimizing for size and when 
> > we know that Ptr is never null?
> > I would consider in doing something alike:
> >  ```
> >   const bool emitNullCheck = CGM.getCodeGenOpts().OptimizeSize <= 1;
> >   llvm::BasicBlock *DeleteNotNull;
> >   llvm::BasicBlock *DeleteEnd;
> >   if (emitNullCheck){
> > // Null check the pointer.
> > DeleteNotNull = createBasicBlock("delete.notnull");
> > DeleteEnd = createBasicBlock("delete.end");
> > 
> > llvm::Value *IsNull = Builder.CreateIsNull(Ptr.getPointer(), "isnull");
> > 
> > Builder.CreateCondBr(IsNull, DeleteEnd, DeleteNotNull);
> > EmitBlock(DeleteNotNull);
> >   }
> > ```
> > 
> > and we use the same emitNullCheck to avoid EmitBlocks below.
> I don't think we can reasonably do this. There are a lot of different ways 
> that `delete` emission can be performed, and many of them (for example, 
> calling a virtual deleting destructor, destroying operator delete, or array 
> delete with cookie) require the null check to be performed in advance for 
> correctness. It would be brittle to duplicate all of those checks here.
> 
> We *could* sink the null checks into the various paths through 
> `EmitArrayDelete` and `EmitObjectDelete`, but I think that makes the code 
> significantly more poorly factored.
Fair enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79378



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

> Currently, parameters of functions without their definition present cannot be 
> represented as regions because it would be difficult to ensure that the same 
> declaration is used in every case. To overcome this, we introduce a new kind 
> of region called ParamRegion which does not store the Decl of the parameter 
> variable. Instead it stores the index of the parameter which enables 
> retrieving the actual Decl every time using the function declaration of the 
> stack frame.

I know vaguely of what you're talking about because I've been trying to follow 
your works so far, but I'd prefer to include a bit more context for those not 
so familiar with MemRegions. Such as, "Usually, we identify a MemRegion with 
..., but for parameters, this is difficult because ..., as seen on this example 
... . So, this patch introduces a new region, etcetc."

Some immediate questions:

- What identifies a `MemRegion`, `TypedValueRegion`s in particular? Why are 
parameters so special that they deserve their own region? Do you have a 
concrete, problematic example?
- Why is it an issue that we don't always use the same declaration? Does this 
result in a crash, incorrect modeling?
- Why are we making `ParamRegion` **not** a subclass of `VarRegion`?
- The patch includes some code duplication, which may be okay, but do we need 
it?

I haven't read every line thoroughly just yet, so I'll catch up with this patch 
later! In any case, thank you so much for your investment in the health of the 
codebase!




Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:435-442
+  const VarDecl *VD;
+  if (const auto *VR =
+  dyn_cast(cast(Sym)->getRegion())) {
+VD = cast(VR->getDecl());
+  } else if (const auto *PR =
+ dyn_cast(cast(Sym)->getRegion())) 
{
+VD = cast(PR->getDecl());

Hmm. So, the surrounding code definitely suggests that we're definitely 
finishing for a parameter here, but it isn't always a parameter region? I know 
you struggled with this, have you gained any insight as to why?



Comment at: clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp:176-180
   if (const auto *DeclReg = Reg->getAs()) {
 if (isa(DeclReg->getDecl()))
   Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();
+  } else if (const auto *ParamReg = Reg->getAs()) {
+Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();

This is interesting. I looked up `DeclRegion`, and it seems to be the region 
that is tied to a `ValueDecl`. `VarDecl` is a subtype of `ValueDecl`, and 
`ParmVarDecl` is a subtype of `VarDecl`, so wouldn't it make sense for 
`ParamRegion` to be a subtype of `VarRegion`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D79704



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


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I will work @rjmccall comment about codegen vs langopt - can you leave it in 
place for now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 263151.
balazske added a comment.

Added target dependent tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330

Files:
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/test/Analysis/vla-overflow.c

Index: clang/test/Analysis/vla-overflow.c
===
--- /dev/null
+++ clang/test/Analysis/vla-overflow.c
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core -verify %s
+
+typedef unsigned long size_t;
+#define BIGINDEX 65536U
+
+size_t check_VLA_overflow_sizeof(unsigned int x) {
+  if (x == BIGINDEX) {
+// We expect here that size_t is a 64 bit value.
+// Size of this array should be the first to overflow.
+size_t s = sizeof(char[x][x][x][x]); // expected-warning{{Declared variable-length array (VLA) has too large size}}
+return s;
+  }
+  return 0;
+}
+
+void check_VLA_overflow_typedef() {
+  unsigned int x = BIGINDEX;
+  typedef char VLA[x][x][x][x]; // expected-warning{{Declared variable-length array (VLA) has too large size}}
+}
+
+void check_VLA_no_overflow() {
+  unsigned int x = BIGINDEX;
+  typedef char VLA[x][x][x][x - 1];
+  typedef char VLA1[0xu];
+}
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -34,14 +34,18 @@
 : public Checker,
  check::PreStmt> {
   mutable std::unique_ptr BT;
-  enum VLASize_Kind { VLA_Garbage, VLA_Zero, VLA_Tainted, VLA_Negative };
+  enum VLASize_Kind {
+VLA_Garbage,
+VLA_Zero,
+VLA_Tainted,
+VLA_Negative,
+VLA_Overflow
+  };
 
   ProgramStateRef checkVLA(CheckerContext &C, ProgramStateRef State,
-   const VariableArrayType *VLA,
-   const VariableArrayType *&VLALast,
-   llvm::SmallVector &VLASizes) const;
-  ProgramStateRef checkVLASize(CheckerContext &C, ProgramStateRef State,
-   const Expr *SizeE) const;
+   const VariableArrayType *VLA, SVal &ArraySize) const;
+  ProgramStateRef checkVLAIndexSize(CheckerContext &C, ProgramStateRef State,
+const Expr *SizeE) const;
 
   void reportBug(VLASize_Kind Kind, const Expr *SizeE, ProgramStateRef State,
  CheckerContext &C,
@@ -54,14 +58,15 @@
 };
 } // end anonymous namespace
 
-ProgramStateRef
-VLASizeChecker::checkVLA(CheckerContext &C, ProgramStateRef State,
- const VariableArrayType *VLA,
- const VariableArrayType *&VLALast,
- llvm::SmallVector &VLASizes) const {
+ProgramStateRef VLASizeChecker::checkVLA(CheckerContext &C,
+ ProgramStateRef State,
+ const VariableArrayType *VLA,
+ SVal &ArraySize) const {
   assert(VLA && "Function should be called with non-null VLA argument.");
 
-  VLALast = nullptr;
+  const VariableArrayType *VLALast = nullptr;
+  llvm::SmallVector VLASizes;
+
   // Walk over the VLAs for every dimension until a non-VLA is found.
   // Collect the sizes in VLASizes, put the most inner VLA to `VLALast`.
   // In "vla[x][2][y][3]" this will be the array for index "y".
@@ -69,7 +74,7 @@
   // until a non-vla is found.
   while (VLA) {
 const Expr *SizeE = VLA->getSizeExpr();
-State = checkVLASize(C, State, SizeE);
+State = checkVLAIndexSize(C, State, SizeE);
 if (!State)
   return nullptr;
 VLASizes.push_back(SizeE);
@@ -79,12 +84,61 @@
   assert(VLALast &&
  "Array should have at least one variably-modified dimension.");
 
+  ASTContext &Ctx = C.getASTContext();
+  SValBuilder &SVB = C.getSValBuilder();
+  CanQualType SizeTy = Ctx.getSizeType();
+  uint64_t SizeMax =
+  SVB.getBasicValueFactory().getMaxValue(SizeTy).getZExtValue();
+
+  // Get the element size.
+  CharUnits EleSize = Ctx.getTypeSizeInChars(VLALast->getElementType());
+  NonLoc ArrSize =
+  SVB.makeIntVal(EleSize.getQuantity(), SizeTy).castAs();
+
+  // Try to calculate the known real size of the array in KnownSize.
+  uint64_t KnownSize = 0;
+  if (const llvm::APSInt *KV = SVB.getKnownValue(State, ArrSize))
+KnownSize = KV->getZExtValue();
+
+  for (const Expr *SizeE : VLASizes) {
+auto SizeD = C.getSVal(SizeE).castAs();
+// Convert the array length to size_t.
+NonLoc IndexLength =
+SVB.evalCast(SizeD, SizeTy, SizeE->getType()).castAs();
+// Multiply the array length by the element size.
+SVal Mul = SVB.evalBinOpNN(State, BO_Mul, ArrSize, IndexLength, SizeTy);
+if (auto MulNonLoc = Mul.getAs())
+ 

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 2 inline comments as done.
mibintc added a comment.

Some inline replies/comments to @rjmccall and @plotfi




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3185
   Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only) ||
   Args.hasArg(OPT_cl_finite_math_only) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);

@rjmccall @plotfi These earlier patches are also deriving the value of LangOpts 
from the settings of CG opts



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3187
   Args.hasArg(OPT_cl_fast_relaxed_math);
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||

@rjmccall @plotfi here the codegen args are evaluated first.  Perhaps we could 
have a "reconcile codegen and lang args" function which would resolve the 
floating point settings into a final setting? so that codegen or lang could be 
parsed in either order? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-11 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

What name and email do you want this committed with?


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

https://reviews.llvm.org/D79504



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


[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-11 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D79504#2029267 , @ldionne wrote:

> What name and email do you want this committed with?


Kamlesh Kumar
kamleshbha...@gmail.com


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

https://reviews.llvm.org/D79504



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added a comment.

Thank you for quickly looking into this.

In D79704#2029230 , @Szelethus wrote:

> - What identifies a `MemRegion`, `TypedValueRegion`s in particular? Why are 
> parameters so special that they deserve their own region? Do you have a 
> concrete, problematic example?


`ParamRegion` contains different data: mainly the index of the parameter. This 
makes it independent of the actual `Decl` of the parameter.

> - Why is it an issue that we don't always use the same declaration? Does this 
> result in a crash, incorrect modeling?

See D49443#1193290 .

> - Why are we making `ParamRegion` **not** a subclass of `VarRegion`?

Because `VarRegion` is a `DeclRegion` which stores the `Decl` of the variable. 
Here the main purpose is to not to store it.

> - The patch includes some code duplication, which may be okay, but do we need 
> it?

Yes, and this comes from my previous answers.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:435-442
+  const VarDecl *VD;
+  if (const auto *VR =
+  dyn_cast(cast(Sym)->getRegion())) {
+VD = cast(VR->getDecl());
+  } else if (const auto *PR =
+ dyn_cast(cast(Sym)->getRegion())) 
{
+VD = cast(PR->getDecl());

Szelethus wrote:
> Hmm. So, the surrounding code definitely suggests that we're definitely 
> finishing for a parameter here, but it isn't always a parameter region? I 
> know you struggled with this, have you gained any insight as to why?
Not all regions for `ParmVarDecl` are `ParamRegions`. Exceptions are parameters 
captured by a lambda or a block as well as parameters of functions analyzed 
top-level.



Comment at: clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp:176-180
   if (const auto *DeclReg = Reg->getAs()) {
 if (isa(DeclReg->getDecl()))
   Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();
+  } else if (const auto *ParamReg = Reg->getAs()) {
+Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();

Szelethus wrote:
> This is interesting. I looked up `DeclRegion`, and it seems to be the region 
> that is tied to a `ValueDecl`. `VarDecl` is a subtype of `ValueDecl`, and 
> `ParmVarDecl` is a subtype of `VarDecl`, so wouldn't it make sense for 
> `ParamRegion` to be a subtype of `VarRegion`?
`DeclRegion` stores the `Decl`, `ParamRegion` retrieves it based on the `Index` 
it stores. There is no is-a relation between them.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1051
+
+  const Expr *OriginExpr;
+  unsigned Index;

We do not use this at all. However, if I remove it then tests begin to fail 
with strange reasons, some of them even crashes at strange points. It seems 
that we need this for profiling the subclass.


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

https://reviews.llvm.org/D79704



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


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@rjmccall Uncertain how to proceed, can you recommend?  If I recall correctly, 
I added the lines in CompilerOptions because there were many failing lit tests, 
i could have fixed the lit fails by adding the lang options to the lit tests. 
(of course that change could have other repercussions)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 263154.
baloghadamsoftware added a comment.

Minor fix to get rid of a warning, some comments added.


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

https://reviews.llvm.org/D79704

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -440,6 +440,9 @@
   if (const auto *VR = dyn_cast(MR))
 return isLive(VR, true);
 
+  if (const auto *PR = dyn_cast(MR))
+return isLive(PR, true);
+
   // FIXME: This is a gross over-approximation. What we really need is a way to
   // tell if anything still refers to this region. Unlike SymbolicRegions,
   // AllocaRegions don't have associated symbols, though, so we don't actually
@@ -573,3 +576,53 @@
 
   return VarContext->isParentOf(CurrentContext);
 }
+
+bool SymbolReaper::isLive(const ParamRegion *PR,
+  bool includeStoreBindings) const{
+  const StackFrameContext *ParamContext = PR->getStackFrame();
+
+  if (!ParamContext)
+return true;
+
+  if (!LCtx)
+return false;
+  const StackFrameContext *CurrentContext = LCtx->getStackFrame();
+
+  if (ParamContext == CurrentContext) {
+// If no statement is provided, everything is live.
+if (!Loc)
+  return true;
+
+// Anonymous parameters of an inheriting constructor are live for the entire
+// duration of the constructor.
+if (isa(Loc))
+  return true;
+
+if (const ParmVarDecl *PVD = PR->getDecl()) {
+  if (LCtx->getAnalysis()->isLive(Loc, PVD))
+return true;
+}
+
+if (!includeStoreBindings)
+  return false;
+
+unsigned &cachedQuery =
+  const_cast(this)->includedRegionCache[PR];
+
+if (cachedQuery) {
+  return cachedQuery == 1;
+}
+
+// Query the store to see if the region occurs in any live bindings.
+if (Store store = reapedStore.getStore()) {
+  bool hasRegion =
+reapedStore.getStoreManager().includedInBindings(store, PR);
+  cachedQuery = hasRegion ? 1 : 2;
+  return hasRegion;
+}
+
+return false;
+  }
+
+  return ParamContext->isParentOf(CurrentContext);
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -138,6 +138,7 @@
 case MemRegion::CXXTempObjectRegionKind:
 case MemRegion::CXXBaseObjectRegionKind:
 case MemRegion::CXXDerivedObjectRegionKind:
+case MemRegion::ParamRegionKind:
   return MakeElementRegion(cast(R), PointeeTy);
 
 case MemRegion::ElementRegionKind: {
@@ -435,6 +436,19 @@
   return svalBuilder.dispatchCast(V, castTy);
 }
 
+Loc StoreManager::getLValueVar(const VarDecl *VD, const LocationContext *LC) {
+  if (const auto *PVD = dyn_cast(VD)) {
+const Expr* Call;
+unsigned Index;
+std::tie(Call, Index) = ParamRegion::getExprAndIndexForParam(PVD, LC);
+
+if (Call)
+  return svalBuilder.makeLoc(MRMgr.getParamRegion(Call, Index, LC));
+  }
+
+  return svalBuilder.makeLoc(MRMgr.getVarRegion(VD, LC));
+}
+
 SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
   if (Base.isUnknownOrUndef())
 return Base;
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -569,6 +569,8 @@
 
   SVal getBindingForVar(RegionBindingsConstRef B, const VarRegion *R);
 
+  SVal getBindingForParam(RegionBindingsConstRef B, const ParamRegion *R);
+
   SVal getBindingForLazySymbol(const 

Re: [clang] c90e198 - Fix parsing of enum-base to follow C++11 rules.

2020-05-11 Thread Hans Wennborg via cfe-commits
On Sat, May 9, 2020 at 4:32 AM Richard Smith via cfe-commits
 wrote:
>
>
> Author: Richard Smith
> Date: 2020-05-08T19:32:00-07:00
> New Revision: c90e198107431f64b73686bdce31c293e3380ac7
>
> URL: 
> https://github.com/llvm/llvm-project/commit/c90e198107431f64b73686bdce31c293e3380ac7
> DIFF: 
> https://github.com/llvm/llvm-project/commit/c90e198107431f64b73686bdce31c293e3380ac7.diff
>
> LOG: Fix parsing of enum-base to follow C++11 rules.
>
> Previously we implemented non-standard disambiguation rules to
> distinguish an enum-base from a bit-field but otherwise treated a :
> after an elaborated-enum-specifier as introducing an enum-base. That
> misparses various examples (anywhere an elaborated-type-specifier can
> appear followed by a colon, such as within a ternary operator or
> _Generic).
>
> We now implement the C++11 rules, with the old cases accepted as
> extensions where that seemed reasonable. These amount to:
>  * an enum-base must always be accompanied by an enum definition (except
>in a standalone declaration of the form 'enum E : T;')
>  * in a member-declaration, 'enum E :' always introduces an enum-base,
>never a bit-field
>  * in a type-specifier (or similar context), 'enum E :' is not
>permitted; the colon means whatever else it would mean in that
>context.
>
> Fixed underlying types for enums are also permitted in Objective-C and
> under MS extensions, plus as a language extension in all other modes.
> The behavior in ObjC and MS extensions modes is unchanged (but the
> bit-field disambiguation is a bit better); remaining language modes
> follow the C++11 rules.
>
> Fixes PR45726, PR39979, PR19810, PR44941, and most of PR24297, plus C++
> core issues 1514 and 1966.

Hello from Chromium :-)

We saw new errors from some code in a header that looked like this:

  // Adapted from NSPathUtilities.h and NSObjCRuntime.h.
  typedef enum NSSearchPathDirectory : unsigned long NSSearchPathDirectory;

For us we think the enum itself is enough, so we'll fix it by dropping
the typedef, but this raised the question of how your change affects
the Mac system headers. IIUC your change makes an exception for Obj-C,
but the headers can be used from regular C/C++ too. Do you think there
might be issues there?

(See https://chromium-review.googlesource.com/c/chromium/src/+/2193673
for the Chromium discussion.)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-11 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a reviewer: krasimir.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79715

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -581,8 +581,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift 
Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -639,8 +638,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be 
between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -727,7 +725,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -772,16 +772,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, 
IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
+#include "BreakableToken.h"
 #include "ContinuationIndenter.h"
 #include "FormatInternal.h"
 #include "FormatTokenLexer.h"
@@ -997,6 +998,12 @@
 // #imports, etc.)
 GoogleStyle.IncludeStyle.IncludeBlocks =
 tooling::IncludeStyle::IBS_Preserve;
+  } else if (Language == FormatStyle::LK_CSharp) {
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
+GoogleStyle.BreakStringLiterals = false;
+GoogleStyle.ColumnLimit = 100;
+GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
   }
 
   return GoogleStyle;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -581,8 +581,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -639,8 +638,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -727,7 +725,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -772,16 +772,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "Af

[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2020-05-11 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Solves https://bugs.llvm.org/show_bug.cgi?id=45634
Be more agressive than GCC with -Wdeprecated-copy. Also provide 
-W(no-)deprecated-copy-user-provided options to on/off this behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79714

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy.cpp
  clang/test/SemaCXX/deprecated.cpp

Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -103,10 +103,10 @@
   void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Dtor' first required here}}
 
   struct DefaultedDtor {
-~DefaultedDtor() = default;
-  };
-  DefaultedDtor d1, d2(d1);
-  void h() { d1 = d2; }
+~DefaultedDtor() = default; // expected-warning {{definition of implicit copy constructor for 'DefaultedDtor' is deprecated because it has a user-declared destructor}}
+  };// expected-warning@-1 {{definition of implicit copy assignment operator for 'DefaultedDtor' is deprecated because it has a user-declared destructor}}
+  DefaultedDtor d1, d2(d1); // expected-note {{in implicit copy constructor for 'DeprecatedCopy::DefaultedDtor' first required here}}
+  void h() { d1 = d2; } // expected-note {{in implicit copy assignment operator for 'DeprecatedCopy::DefaultedDtor' first required here}}
 }
 #endif
 
Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -1,7 +1,12 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wno-deprecated-copy-user-provided -DNO_USER_PROVIDED -verify
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -DDEPRECATED_COPY_DTOR -verify
 // RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
 
+#ifdef NO_USER_PROVIDED
+// expected-no-diagnostics
+#endif
+
 #ifdef DEPRECATED_COPY_DTOR
 struct A {
   int *ptr;
@@ -14,10 +19,30 @@
 }
 #else
 struct B {
-  B &operator=(const B &); // expected-warning {{definition of implicit copy constructor for 'B' is deprecated because it has a user-declared copy assignment operator}}
+  B &operator=(const B &);
+#ifndef NO_USER_PROVIDED
+// expected-warning@-2 {{definition of implicit copy constructor for 'B' is deprecated because it has a user-declared copy assignment operator}}
+#endif
 };
 
 void bar() {
-  B b1, b2(b1); // expected-note {{implicit copy constructor for 'B' first required here}}
+  B b1, b2(b1);
+#ifndef NO_USER_PROVIDED
+// expected-note@-2 {{implicit copy constructor for 'B' first required here}}
+#endif
 }
+
+struct S {
+  int i;
+  S &operator=(const S &) = delete;
+#ifndef NO_USER_PROVIDED
+// expected-warning@-2 {{definition of implicit copy constructor for 'S' is deprecated because it has a user-declared copy assignment operator}}
+#endif
+};
+
+S test(const S &s) { return S(s); }
+#ifndef NO_USER_PROVIDED
+// expected-note@-2  {{in implicit copy constructor for 'S' first required here}}
+#endif
+
 #endif
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -13850,11 +13850,17 @@
 assert(UserDeclaredOperation);
   }
 
-  if (UserDeclaredOperation && UserDeclaredOperation->isUserProvided()) {
-S.Diag(UserDeclaredOperation->getLocation(),
-   isa(UserDeclaredOperation)
-   ? diag::warn_deprecated_copy_dtor_operation
-   : diag::warn_deprecated_copy_operation)
+  if (UserDeclaredOperation) {
+unsigned DiagID;
+if (UserDeclaredOperation->isUserProvided())
+  DiagID = isa(UserDeclaredOperation)
+   ? diag::warn_deprecated_copy_dtor_operation_user_provided
+   : diag::warn_deprecated_copy_operation_user_provided;
+else
+  DiagID = isa(UserDeclaredOperation)
+   ? diag::warn_deprecated_copy_dtor_operation
+   : diag::warn_deprecated_copy_operation;
+S.Diag(UserDeclaredOperation->getLocation(), DiagID)
 << RD << /*copy assignment*/ !isa(CopyOp);
   }
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -561,6 +561,12 @@
   "definition of implicit copy %select{constructor|assignment operator}1 "
   "for %0 is deprecated because it has a user-declared destructor">,
   InGroup, DefaultIgnore;
+def warn_deprecated_c

[clang] ec2d93c - [analyzer] SATestBuild.py: Allow comments in run_static_analyzer.cmd.

2020-05-11 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-05-11T17:26:37+03:00
New Revision: ec2d93c7d7b00374535cb3d6658abec4b150f6f6

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

LOG: [analyzer] SATestBuild.py: Allow comments in run_static_analyzer.cmd.

Because those can get really weird sometimes.

Added: 


Modified: 
clang/utils/analyzer/SATestBuild.py

Removed: 




diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index 691ded80a1ef..38273af27f21 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -298,7 +298,7 @@ def runScanBuild(Args, Dir, SBOutputDir, PBuildLogFile):
 SBPrefix = "scan-build " + SBOptions + " "
 for Command in SBCommandFile:
 Command = Command.strip()
-if len(Command) == 0:
+if len(Command) == 0 or Command.startswith("#"):
 continue
 
 # Custom analyzer invocation specified by project.



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


[PATCH] D79388: [clang-format] Fix AlignConsecutive on PP blocks

2020-05-11 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD added a comment.

Hey, @MyDeveloperDay, can I get your assistance in committing this? It's 
probably been long enough for anyone to chime in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79388



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


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-11 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

I expect that accepting this patch will need require an update to be made to 
https://github.com/google/styleguide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79715



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

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



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:403
   /// frame. May fail; returns null on failure.
-  const VarRegion *getParameterLocation(unsigned Index,
-unsigned BlockCount) const;
+  const TypedValueRegion *getParameterLocation(unsigned Index,
+   unsigned BlockCount) const;

I would expect that this returns a `ParamRegion` (from the name of the 
function). (The implementation shows that the type can just be changed.)



Comment at: clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp:176-180
   if (const auto *DeclReg = Reg->getAs()) {
 if (isa(DeclReg->getDecl()))
   Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();
+  } else if (const auto *ParamReg = Reg->getAs()) {
+Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();

baloghadamsoftware wrote:
> Szelethus wrote:
> > This is interesting. I looked up `DeclRegion`, and it seems to be the 
> > region that is tied to a `ValueDecl`. `VarDecl` is a subtype of 
> > `ValueDecl`, and `ParmVarDecl` is a subtype of `VarDecl`, so wouldn't it 
> > make sense for `ParamRegion` to be a subtype of `VarRegion`?
> `DeclRegion` stores the `Decl`, `ParamRegion` retrieves it based on the 
> `Index` it stores. There is no is-a relation between them.
During the lifetime of a `ParamRegion` is it possible that it will return 
different `Decl` objects?



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:745
 
 // Can only reasonably pretty-print DeclRegions.
+if (const auto *DR = dyn_cast(R)) {

This comment is not fully true any more.



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:255
   // correspond to the stack frame's function declaration.
   assert(VR->getStackFrame() == SFC);
 

Is it correct to create `VR` only to have this assert?



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:357
   V = *OptV;
-else
-  break;
+else break;
 State = addObjectUnderConstruction(State, {CE, Idx}, LCtx, V);

This `break` is at wrong place.


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

https://reviews.llvm.org/D79704



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


[clang] 9aee35b - [Clang] Fix the incorrect return type of atomic_is_lock_free

2020-05-11 Thread Louis Dionne via cfe-commits

Author: Kamlesh Kumar
Date: 2020-05-11T10:48:35-04:00
New Revision: 9aee35bcc90faa9db3ea0111c0a80ebee7446cac

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

LOG: [Clang] Fix the incorrect return type of atomic_is_lock_free

Fixing the return type of atomic_is_lock_free as per
https://en.cppreference.com/w/c/atomic/atomic_is_lock_free

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

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/test/CodeGen/atomic-ops.c
clang/test/CodeGen/big-atomic-ops.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 9613f312d52d..4f1a7f24c432 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -724,7 +724,7 @@ ATOMIC_BUILTIN(__c11_atomic_fetch_max, "v.", "t")
 ATOMIC_BUILTIN(__c11_atomic_fetch_min, "v.", "t")
 BUILTIN(__c11_atomic_thread_fence, "vi", "n")
 BUILTIN(__c11_atomic_signal_fence, "vi", "n")
-BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
+BUILTIN(__c11_atomic_is_lock_free, "bz", "n")
 
 // GNU atomic builtins.
 ATOMIC_BUILTIN(__atomic_load, "v.", "t")
@@ -753,8 +753,8 @@ BUILTIN(__atomic_test_and_set, "bvD*i", "n")
 BUILTIN(__atomic_clear, "vvD*i", "n")
 BUILTIN(__atomic_thread_fence, "vi", "n")
 BUILTIN(__atomic_signal_fence, "vi", "n")
-BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
-BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
+BUILTIN(__atomic_always_lock_free, "bzvCD*", "n")
+BUILTIN(__atomic_is_lock_free, "bzvCD*", "n")
 
 // OpenCL 2.0 atomic builtins.
 ATOMIC_BUILTIN(__opencl_atomic_init, "v.", "t")

diff  --git a/clang/test/CodeGen/atomic-ops.c b/clang/test/CodeGen/atomic-ops.c
index 25ecb4328876..2cf5d2beb3a8 100644
--- a/clang/test/CodeGen/atomic-ops.c
+++ b/clang/test/CodeGen/atomic-ops.c
@@ -343,20 +343,20 @@ struct Incomplete;
 int lock_free(struct Incomplete *incomplete) {
   // CHECK-LABEL: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call

diff  --git a/clang/test/CodeGen/big-atomic-ops.c 
b/clang/test/CodeGen/big-atomic-ops.c
index 6a7a7001f96d..b06302f73f96 100644
--- a/clang/test/CodeGen/big-atomic-ops.c
+++ b/clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@ struct Seventeen {
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call



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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2020-05-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:158
+def DeprecatedCopy : DiagGroup<"deprecated-copy", 
[DeprecatedCopyUserProvided]>;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", 
[DeprecatedCopyDtorUserProvided]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;

If we're going to provide these options at all, I think it would be more 
grammatical to call them `-Wdeprecated-copy-with-deleted-copy` and 
`-Wdeprecated-copy-with-deleted-dtor`.

The existing code is already confusing by talking about a "copy dtor" as if 
that's a thing; I think it makes it even worse to talk about "deprecated copy 
user provided," since the actually deprecated thing is the //implicitly 
generated// copy.

I get that we're trying to be terse, and also somewhat hierarchical in putting 
all the `-Wdeprecated-copy`-related warnings under `-Wdeprecated-copy-foo-bar`; 
but the current names are too far into the ungrammatical realm for me 
personally.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:568
+def warn_deprecated_copy_dtor_operation_user_provided : Warning<
+  warn_deprecated_copy_dtor_operation.Text>,
+  InGroup, DefaultIgnore;

This is the first time I've ever seen this idiom. As a person who often greps 
the wording of an error message to find out where it comes from, I would very 
strongly prefer to see the actual string literal here. But if this is 
established practice, then okay.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13864
+S.Diag(UserDeclaredOperation->getLocation(), DiagID)
 << RD << /*copy assignment*/ !isa(CopyOp);
   }

I wonder if this would be easier to read as

```
if (UserDeclaredOperation) {
bool UDOIsUserProvided = UserDeclaredOperation->isUserProvided();
bool UDOIsDestructor = isa(UserDeclaredOperation);
bool IsCopyAssignment = !isa(CopyOp);
unsigned DiagID =
( UDOIsUserProvided &&  UDOIsDestructor) ? 
diag::warn_deprecated_copy_dtor_operation_user_provided :
( UDOIsUserProvided && !UDOIsDestructor) ? 
diag::warn_deprecated_copy_operation_user_provided :
(!UDOIsUserProvided &&  UDOIsDestructor) ? 
diag::warn_deprecated_copy_dtor_operation :
diag::warn_deprecated_copy_operation;
S.Diag(UserDeclaredOperation->getLocation(), DiagID)
<< RD << /*copy assignment*/ IsCopyAssignment;
```



Comment at: clang/test/SemaCXX/deprecated-copy.cpp:7
+#ifdef NO_USER_PROVIDED
+// expected-no-diagnostics
+#endif

I'm fairly confident this should just be two different test files. Also, if a 
test file has an un-ifdeffed `// expected-no-diagnostics` plus an un-ifdeffed 
`// expected-note ...`, which one wins?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79714



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


[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-11 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I'll commit this since I think everyone was fine with it.


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

https://reviews.llvm.org/D79504



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


[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-11 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9aee35bcc90f: [Clang] Fix the incorrect return type of 
atomic_is_lock_free (authored by kamleshbhalui, committed by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79504

Files:
  clang/include/clang/Basic/Builtins.def
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGen/big-atomic-ops.c


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -343,20 +343,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK-LABEL: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -724,7 +724,7 @@
 ATOMIC_BUILTIN(__c11_atomic_fetch_min, "v.", "t")
 BUILTIN(__c11_atomic_thread_fence, "vi", "n")
 BUILTIN(__c11_atomic_signal_fence, "vi", "n")
-BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
+BUILTIN(__c11_atomic_is_lock_free, "bz", "n")
 
 // GNU atomic builtins.
 ATOMIC_BUILTIN(__atomic_load, "v.", "t")
@@ -753,8 +753,8 @@
 BUILTIN(__atomic_clear, "vvD*i", "n")
 BUILTIN(__atomic_thread_fence, "vi", "n")
 BUILTIN(__atomic_signal_fence, "vi", "n")
-BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
-BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
+BUILTIN(__atomic_always_lock_free, "bzvCD*", "n")
+BUILTIN(__atomic_is_lock_free, "bzvCD*", "n")
 
 // OpenCL 2.0 atomic builtins.
 ATOMIC_BUILTIN(__opencl_atomic_init, "v.", "t")


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call

[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Thanks for these! We should probably split this in three patches.  I commented 
below, mostly minor stuff.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:101
+extern Type *IntPtrTy;
+extern Type *SizeTy;
+

I can totally see why we need `int` and `size_t` but I'm not sure about the 
others.
`void` is universally translated to `i8*` Adding a pointer to a type should be 
done in OMPKinds.def, something like:
```
#define __OMP_PTR_TYPE(NAME, BASE) OMP_TYPE(NAME, Base->getPointerTo());
__OMP_PTR_TYPE(VoidPtr, Int8)
__OMP_PTR_TYPE(VoidPtrPtr, VoidPtr)
```



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:68
+  InsertPointTy SaveIP() { return Builder.saveIP(); }
+
   /// Callback type for variable finalization (think destructors).

The above can be committed separately as "wrap IRBuilder methods" or something, 
LGTM for that part.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:371
+  /// threads copy the 'copyin' variables from Master copy to threadprivate
+  /// copies.
+  ///

Copy & paste, also below.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:234
 __OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, Int32)
+__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, IntPtrTy)
 __OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)

I think this was correct before:
```
  KMP_EXPORT void __kmpc_critical_with_hint(ident_t *, kmp_int32 global_tid, 
kmp_critical_name *, uint32_t hint);
```



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:240
+__OMP_RTL(__kmpc_threadprivate_cached, false, VoidPtr, IdentPtr, Int32, 
VoidPtr, SizeTy, Void3Ptr)
+__OMP_RTL(__kmpc_threadprivate_register, false, Void, IdentPtr, VoidPtr, 
KmpcCtorTy, KmpcCopyCtorTy, KmpcDtorTy)
+

Can you add attributes (below) for these and call them in 
`llvm/test/Transforms/OpenMP/add_attributes.ll` [if not already present]. These 
changes and the additional types should go in a separate patch.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:122
+  }
+}
+

(I doubt we need the `initVoidPtr` function but if we do, the condition looks 
wrong)



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:594
+  // PRegPreFiniTI->getSuccessor(0) == PRegExitBB &&
+  // "Unexpected CFG structure!");
 

Preferably we would have a modified assertion. If that is too cumbersome, we 
can probably remove it. 



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:930
+InsertPointTy IP, Value *MasterAddr, Value *PrivateAddr,
+llvm::IntegerType *IntPtrTy, bool BranchtoEnd) {
+  if (!IP.isSet())

Can you add a comment here, maybe some ascii art, describing what we generate.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:1013
+  return Builder.CreateCall(Fn, Args);
+}
+

I think we should have a unit test for each of these.

Style: drop the `llvm::`, not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-05-11 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

I'm in favor of this change. I'm not too happy with how this works in CMake, 
I've expressed similar concerns when the FORCE_ON approach was suggested in 
D71306 .

I really like what we ended up with in LLDB. The TL;DR is that we have 3 
values: ON, OFF and Auto. The later will resolve to either ON or OFF depending 
on whether the dependency was found. The "clever" part is that we use shadowing 
to avoid having another CMake variable without overwriting the cache.

Here's what it looks like in LLDB: 
https://github.com/llvm/llvm-project/blob/3df40007e6317955176dff0fa9e0b029dc4a11d1/lldb/cmake/modules/LLDBConfig.cmake#L26

Maybe we can consider something similar here? I'd be more than happy to hoist 
the corresponding CMake into llvm.

(edit: added myself as a reviewer so this shows up in my review queue)




Comment at: llvm/cmake/config-ix.cmake:514
+  if(ZLIB_FOUND)
+set(LLVM_ENABLE_ZLIB "YES" CACHE STRING
+  "Use zlib for compression/decompression if available. Can be ON, OFF, or 
FORCE_ON"

If I understand correctly, after running the configuration phase with 
LLVM_ENABLE_ZLIB to FORCE_ON, the cached value will be overwritten by ON? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79219



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


[PATCH] D79639: [SveEmitter] Builtins for SVE matrix multiply `mmla`.

2020-05-11 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:74
 // q: 1/4 width elements, 4x element count
+// b: 1/4 width elements, 4x element count, integer, unsigned
 // o: 4x width elements, 1/4 element count

Can you phrase this like `e` and move it below `e` as well:

  1/4 width unsigned elements, 4 x element count



Comment at: clang/include/clang/Basic/arm_sve.td:1228
+let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_INT8)" in {
+def SVMLLA_S32 : SInst<"svmmla[_s32]", "ddqq","i", MergeNone, 
"aarch64_sve_smmla">;
+def SVMLLA_U32 : SInst<"svmmla[_u32]", "ddqq","Ui", MergeNone, 
"aarch64_sve_ummla">;

nit: please fix the alignment like how this is done for the other definitions.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7988
 
-  auto *Builtin = findARMVectorIntrinsicInMap(AArch64SVEIntrinsicMap, 
BuiltinID,
-  
AArch64SVEIntrinsicsProvenSorted);
+  const ARMVectorIntrinsicInfo *Builtin = findARMVectorIntrinsicInMap(
+  AArch64SVEIntrinsicMap, BuiltinID, AArch64SVEIntrinsicsProvenSorted);

unnecessary change, please remove.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c:1
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_FP32 \
+// RUN:-triple aarch64-none-linux-gnu -target-feature +sve \

nit: These RUN lines no longer match all the other ACLE tests (with the added 
newlines)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79639



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


[PATCH] D79595: Fix bugs when an included file name is typo corrected.

2020-05-11 Thread Abhinav Gaba via Phabricator via cfe-commits
abhinavgaba added inline comments.



Comment at: clang/test/Lexer/case-insensitive-include-win.c:8
 // RUN: touch %t.dir/foo.h
-// RUN: not %clang_cl /FI\\?\%t.dir\FOO.h /WX -Xclang -verify -fsyntax-only %s 
2>&1 | FileCheck %s
+// RUN: not %clang_cl /FI\\?\%t.dir\FOO.h /WX -fsyntax-only %s 2>&1 | 
FileCheck %s
 

The test is currently failing if path of an existing directory in a network 
mounted drive, using forward slashes, is in CPATH. (e.g. `export 
CPATH=//abc.def.com/dir1`).

The error in that case is:
```
fatal error: cannot open file
  
'//abc.def.com/dir1\?\\test\Lexer\Output\case-insensitive-include-win.c.tmp.dir\FOO.h':
  The specified path is invalid.
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79595



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-05-11 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: hubert.reinterpretcast, jasonliu, sfertile, 
cebowleratibm.
Xiangling_L added a project: LLVM.
Herald added subscribers: cfe-commits, kbarton, nemanjai.
Herald added a project: clang.

Implement AIX special alignment rule by recursively checking if the
'real' first member is a double/long double. If yes, then this member
should be naturally aligned to 8 rather than 4.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecordLayout.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

Index: clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | FileCheck \
+// RUN: --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc64-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | FileCheck \
+// RUN: --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+struct A {
+  double d1;
+  virtual void boo() {}
+};
+
+struct B {
+  double d2;
+  A a;
+};
+
+struct C : public A {
+  double d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::A
+// CHECK-NEXT:0 |   (A vtable pointer)
+// CHECK32-NEXT:  4 |   double d1
+// CHECK32-NEXT:| [sizeof=12, dsize=12, align=4,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4]
+// CHECK64-NEXT:  8 |   double d1
+// CHECK64-NEXT:| [sizeof=16, dsize=16, align=8,
+// CHECK64-NEXT:|  nvsize=16, nvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::B
+// CHECK-NEXT:0 |   double d2
+// CHECK-NEXT:8 |   struct test1::A a
+// CHECK-NEXT:8 | (A vtable pointer)
+// CHECK32-NEXT: 12 | double d1
+// CHECK32-NEXT:| [sizeof=24, dsize=20, align=8,
+// CHECK32-NEXT:|  nvsize=20, nvalign=8]
+// CHECK64-NEXT: 16 | double d1
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::C
+// CHECK-NEXT:0 |   struct test1::A (primary base)
+// CHECK-NEXT:0 | (A vtable pointer)
+// CHECK32-NEXT:  4 | double d1
+// CHECK32-NEXT: 12 |   double d3
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=4,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4]
+// CHECK64-NEXT:  8 | double d1
+// CHECK64-NEXT: 16 |   double d3
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8]
+
+}; // namespace test1
+
+namespace test2 {
+struct A {
+  long long l1;
+};
+
+struct B : public virtual A {
+  double d2;
+};
+
+#pragma pack(2)
+struct C : public virtual A {
+  double __attribute__((aligned(4))) d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::A
+// CHECK-NEXT:0 |   long long l1
+// CHECK-NEXT:  | [sizeof=8, dsize=8, align=8,
+// CHECK-NEXT:  |  nvsize=8, nvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::B
+// CHECK-NEXT:0 |   (B vtable pointer)
+// CHECK32-NEXT:  4 |   double d2
+// CHECK64-NEXT:  8 |   double d2
+// CHECK-NEXT:   16 |   struct test2::A (virtual base)
+// CHECK-NEXT:   16 | long long l1
+// CHECK-NEXT:  | [sizeof=24, dsize=24, align=8,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4]
+// CHECK64-NEXT:|  nvsize=16, nvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::C
+// CHECK-NEXT:0 |   (C vtable pointer)
+// CHECK32-NEXT:  4 |   double d3
+// CHECK32-NEXT: 12 |   struct test2::A (virtual base)
+// CHECK32-NEXT: 12 | long long l1
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=2,
+// CHECK32-NEXT:|  nvsize=12, nvalign=2]
+// CHECK64-NEXT:  8 |   double d3
+// CHECK64-NEXT: 16 |   struct test2::A (virtual base)
+// CHECK64-NEXT: 16 | long long l1
+// CHECK64-NEXT: 

[PATCH] D79721: [Clang][AArch64] Capturing proper pointer alignment for Neon vld1 intrinsicts

2020-05-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: cfe-commits, danielkiss, kristof.beyls.
Herald added a project: clang.
pratlucas added reviewers: t.p.northover, ostannard, pcc.

During CodeGen for AArch64 Neon intrinsics, Clang was incorrectly
assuming all the pointers from which loads were being generated for vld1
intrinsics were aligned according to the intrinsics result type, causing
alignment faults on the code generated by the backend.

This patch updates vld1 intrinsics' CodeGen to properly capture the
correct load alignment based on the type of the pointer provided as
input for the intrinsic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79721

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-intrinsics.c

Index: clang/test/CodeGen/aarch64-neon-intrinsics.c
===
--- clang/test/CodeGen/aarch64-neon-intrinsics.c
+++ clang/test/CodeGen/aarch64-neon-intrinsics.c
@@ -8956,7 +8956,7 @@
 
 // CHECK-LABEL: @test_vld1q_u8(
 // CHECK:   [[TMP0:%.*]] = bitcast i8* %a to <16 x i8>*
-// CHECK:   [[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[TMP0]]
+// CHECK:   [[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[TMP0]], align 1
 // CHECK:   ret <16 x i8> [[TMP1]]
 uint8x16_t test_vld1q_u8(uint8_t const *a) {
   return vld1q_u8(a);
@@ -8965,7 +8965,7 @@
 // CHECK-LABEL: @test_vld1q_u16(
 // CHECK:   [[TMP0:%.*]] = bitcast i16* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <8 x i16>*
-// CHECK:   [[TMP2:%.*]] = load <8 x i16>, <8 x i16>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <8 x i16>, <8 x i16>* [[TMP1]], align 2
 // CHECK:   ret <8 x i16> [[TMP2]]
 uint16x8_t test_vld1q_u16(uint16_t const *a) {
   return vld1q_u16(a);
@@ -8974,7 +8974,7 @@
 // CHECK-LABEL: @test_vld1q_u32(
 // CHECK:   [[TMP0:%.*]] = bitcast i32* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <4 x i32>*
-// CHECK:   [[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]], align 4
 // CHECK:   ret <4 x i32> [[TMP2]]
 uint32x4_t test_vld1q_u32(uint32_t const *a) {
   return vld1q_u32(a);
@@ -8983,7 +8983,7 @@
 // CHECK-LABEL: @test_vld1q_u64(
 // CHECK:   [[TMP0:%.*]] = bitcast i64* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <2 x i64>*
-// CHECK:   [[TMP2:%.*]] = load <2 x i64>, <2 x i64>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <2 x i64>, <2 x i64>* [[TMP1]], align 8
 // CHECK:   ret <2 x i64> [[TMP2]]
 uint64x2_t test_vld1q_u64(uint64_t const *a) {
   return vld1q_u64(a);
@@ -8991,7 +8991,7 @@
 
 // CHECK-LABEL: @test_vld1q_s8(
 // CHECK:   [[TMP0:%.*]] = bitcast i8* %a to <16 x i8>*
-// CHECK:   [[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[TMP0]]
+// CHECK:   [[TMP1:%.*]] = load <16 x i8>, <16 x i8>* [[TMP0]], align 1
 // CHECK:   ret <16 x i8> [[TMP1]]
 int8x16_t test_vld1q_s8(int8_t const *a) {
   return vld1q_s8(a);
@@ -9000,7 +9000,7 @@
 // CHECK-LABEL: @test_vld1q_s16(
 // CHECK:   [[TMP0:%.*]] = bitcast i16* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <8 x i16>*
-// CHECK:   [[TMP2:%.*]] = load <8 x i16>, <8 x i16>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <8 x i16>, <8 x i16>* [[TMP1]], align 2
 // CHECK:   ret <8 x i16> [[TMP2]]
 int16x8_t test_vld1q_s16(int16_t const *a) {
   return vld1q_s16(a);
@@ -9009,7 +9009,7 @@
 // CHECK-LABEL: @test_vld1q_s32(
 // CHECK:   [[TMP0:%.*]] = bitcast i32* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <4 x i32>*
-// CHECK:   [[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]], align 4
 // CHECK:   ret <4 x i32> [[TMP2]]
 int32x4_t test_vld1q_s32(int32_t const *a) {
   return vld1q_s32(a);
@@ -9018,7 +9018,7 @@
 // CHECK-LABEL: @test_vld1q_s64(
 // CHECK:   [[TMP0:%.*]] = bitcast i64* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <2 x i64>*
-// CHECK:   [[TMP2:%.*]] = load <2 x i64>, <2 x i64>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <2 x i64>, <2 x i64>* [[TMP1]], align 8
 // CHECK:   ret <2 x i64> [[TMP2]]
 int64x2_t test_vld1q_s64(int64_t const *a) {
   return vld1q_s64(a);
@@ -9027,7 +9027,7 @@
 // CHECK-LABEL: @test_vld1q_f16(
 // CHECK:   [[TMP0:%.*]] = bitcast half* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <8 x half>*
-// CHECK:   [[TMP2:%.*]] = load <8 x half>, <8 x half>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <8 x half>, <8 x half>* [[TMP1]], align 2
 // CHECK:   ret <8 x half> [[TMP2]]
 float16x8_t test_vld1q_f16(float16_t const *a) {
   return vld1q_f16(a);
@@ -9036,7 +9036,7 @@
 // CHECK-LABEL: @test_vld1q_f32(
 // CHECK:   [[TMP0:%.*]] = bitcast float* %a to i8*
 // CHECK:   [[TMP1:%.*]] = bitcast i8* [[TMP0]] to <4 x float>*
-// CHECK:   [[TMP2:%.*]] = load <4 x float>, <4 x float>* [[TMP1]]
+// CHECK:   [[TMP2:%.*]] = load <4 x float>, <4 x float>* [[TMP1]], align 4
 // CHECK:   ret <4 x float> [[TMP2]]
 float32x4_t test_vld1q_f

[PATCH] D62368: Add vendor identity check for Hygon Dhyana processor in Scudo

2020-05-11 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

In D62368#2027895 , @fanjinke wrote:

> Hi Cryptoad,
>
> Could you help me to commit the patch? Because I don't have access.
>
> Thanks.


Done, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D62368: Add vendor identity check for Hygon Dhyana processor in Scudo

2020-05-11 Thread Kostya Kortchinsky via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9959eb918acf: Add vendor identity check for Hygon Dhyana 
processor in Scudo (authored by cryptoad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368

Files:
  compiler-rt/lib/scudo/scudo_utils.cpp
  compiler-rt/lib/scudo/standalone/checksum.cpp


Index: compiler-rt/lib/scudo/standalone/checksum.cpp
===
--- compiler-rt/lib/scudo/standalone/checksum.cpp
+++ compiler-rt/lib/scudo/standalone/checksum.cpp
@@ -31,6 +31,13 @@
 #define bit_SSE4_2 bit_SSE42 // clang and gcc have different defines.
 #endif
 
+#ifndef signature_HYGON_ebx // They are not defined in gcc.
+// HYGON: "HygonGenuine".
+#define signature_HYGON_ebx 0x6f677948
+#define signature_HYGON_edx 0x6e65476e
+#define signature_HYGON_ecx 0x656e6975
+#endif
+
 bool hasHardwareCRC32() {
   u32 Eax, Ebx = 0, Ecx = 0, Edx = 0;
   __get_cpuid(0, &Eax, &Ebx, &Ecx, &Edx);
@@ -39,7 +46,10 @@
(Ecx == signature_INTEL_ecx);
   const bool IsAMD = (Ebx == signature_AMD_ebx) && (Edx == signature_AMD_edx) 
&&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) &&
+   (Edx == signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
   return !!(Ecx & bit_SSE4_2);
Index: compiler-rt/lib/scudo/scudo_utils.cpp
===
--- compiler-rt/lib/scudo/scudo_utils.cpp
+++ compiler-rt/lib/scudo/scudo_utils.cpp
@@ -62,6 +62,14 @@
 # ifndef bit_SSE4_2
 #  define bit_SSE4_2 bit_SSE42  // clang and gcc have different defines.
 # endif
+
+#ifndef signature_HYGON_ebx // They are not defined in gcc.
+// HYGON: "HygonGenuine".
+#define signature_HYGON_ebx 0x6f677948
+#define signature_HYGON_edx 0x6e65476e
+#define signature_HYGON_ecx 0x656e6975
+#endif
+
 bool hasHardwareCRC32() {
   u32 Eax, Ebx, Ecx, Edx;
   __get_cpuid(0, &Eax, &Ebx, &Ecx, &Edx);
@@ -71,7 +79,10 @@
   const bool IsAMD = (Ebx == signature_AMD_ebx) &&
  (Edx == signature_AMD_edx) &&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) &&
+   (Edx == signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
   return !!(Ecx & bit_SSE4_2);


Index: compiler-rt/lib/scudo/standalone/checksum.cpp
===
--- compiler-rt/lib/scudo/standalone/checksum.cpp
+++ compiler-rt/lib/scudo/standalone/checksum.cpp
@@ -31,6 +31,13 @@
 #define bit_SSE4_2 bit_SSE42 // clang and gcc have different defines.
 #endif
 
+#ifndef signature_HYGON_ebx // They are not defined in gcc.
+// HYGON: "HygonGenuine".
+#define signature_HYGON_ebx 0x6f677948
+#define signature_HYGON_edx 0x6e65476e
+#define signature_HYGON_ecx 0x656e6975
+#endif
+
 bool hasHardwareCRC32() {
   u32 Eax, Ebx = 0, Ecx = 0, Edx = 0;
   __get_cpuid(0, &Eax, &Ebx, &Ecx, &Edx);
@@ -39,7 +46,10 @@
(Ecx == signature_INTEL_ecx);
   const bool IsAMD = (Ebx == signature_AMD_ebx) && (Edx == signature_AMD_edx) &&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) &&
+   (Edx == signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
   return !!(Ecx & bit_SSE4_2);
Index: compiler-rt/lib/scudo/scudo_utils.cpp
===
--- compiler-rt/lib/scudo/scudo_utils.cpp
+++ compiler-rt/lib/scudo/scudo_utils.cpp
@@ -62,6 +62,14 @@
 # ifndef bit_SSE4_2
 #  define bit_SSE4_2 bit_SSE42  // clang and gcc have different defines.
 # endif
+
+#ifndef signature_HYGON_ebx // They are not defined in gcc.
+// HYGON: "HygonGenuine".
+#define signature_HYGON_ebx 0x6f677948
+#define signature_HYGON_edx 0x6e65476e
+#define signature_HYGON_ecx 0x656e6975
+#endif
+
 bool hasHardwareCRC32() {
   u32 Eax, Ebx, Ecx, Edx;
   __get_cpuid(0, &Eax, &Ebx, &Ecx, &Edx);
@@ -71,7 +79,10 @@
   const bool IsAMD = (Ebx == signature_AMD_ebx) &&
  (Edx == signature_AMD_edx) &&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) &&
+   (Edx == signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cp

[clang] 8e3e56f - [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

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

Author: Thomas Lively
Date: 2020-05-11T10:01:55-07:00
New Revision: 8e3e56f2a36701480eeb65e426701d5a9025cc59

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

LOG: [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

Summary:

Although using `__builtin_shufflevector` and the `shufflevector`
instruction works fine, they are not opaque to the optimizer. As a
result, DAGCombine can potentially reduce the number of shuffles and
change the shuffle masks. This is unexpected behavior for users of the
WebAssembly SIMD intrinsics who have crafted their shuffles to
optimize the code generated by engines. This patch solves the problem
by adding a new shuffle intrinsic that is opaque to the optimizers in
line with the decision of the WebAssembly SIMD contributors at
https://github.com/WebAssembly/simd/issues/196#issuecomment-622494748. In
the future we may implement custom DAG combines to properly optimize
shuffles and replace this solution.

Reviewers: aheejin, dschuff

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

Tags: #clang, #llvm

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

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/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index cbdb33c0c352..3c7e27544856 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -119,6 +119,7 @@ TARGET_BUILTIN(__builtin_wasm_avgr_u_i8x16, "V16cV16cV16c", 
"nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8sV8sV8s", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_shuffle_v8x16, 
"V16cV16cV16cIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_any_true_i8x16, "iV16c", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_any_true_i16x8, "iV8s", "nc", "simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c64fde719445..541dac7b7580 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16044,6 +16044,20 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 CGM.getIntrinsic(IntNo, {ConvertType(E->getType()), Vec->getType()});
 return Builder.CreateCall(Callee, Vec);
   }
+  case WebAssembly::BI__builtin_wasm_shuffle_v8x16: {
+Value *Ops[18];
+size_t OpIdx = 0;
+Ops[OpIdx++] = EmitScalarExpr(E->getArg(0));
+Ops[OpIdx++] = EmitScalarExpr(E->getArg(1));
+while (OpIdx < 18) {
+  llvm::APSInt LaneConst;
+  if (!E->getArg(OpIdx)->isIntegerConstantExpr(LaneConst, getContext()))
+llvm_unreachable("Constant arg isn't actually constant?");
+  Ops[OpIdx++] = llvm::ConstantInt::get(getLLVMContext(), LaneConst);
+}
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_shuffle);
+return Builder.CreateCall(Callee, Ops);
+  }
   default:
 return nullptr;
   }

diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index 612aec139723..b81594efcc82 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -1020,23 +1020,31 @@ wasm_f32x4_convert_u32x4(v128_t __a) {
 #define wasm_v8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, 
\
__c7, __c8, __c9, __c10, __c11, __c12, __c13,   
\
__c14, __c15)   
\
-  ((v128_t)(__builtin_shufflevector(   
\
-  (__u8x16)(__a), (__u8x16)(__b), __c0, __c1, __c2, __c3, __c4, __c5,  
\
-  __c6, __c7, __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15)))
+  ((v128_t)__builtin_wasm_shuffle_v8x16(   
\
+  (__i8x16)(__a), (__i8x16)(__b), __c0, __c1, __c2, __c3, __c4, __c5,  
\
+  __c6, __c7, __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15))
 
 #define wasm_v16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, 
\
__c7)   
\
-  ((v128_t)(__builtin_shufflevector((__u16x8)(__a), (__u16x8)(__b), __c0,  
\
-__c1, __c2, __c3, __c4, __c5, __c6,
\
-__c7)))
+  ((v128_t)__builtin_wasm_shuffle_v

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 263204.
baloghadamsoftware added a comment.

Thank you for your comments, @balazske. You are completely right, I updated the 
patch now.


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

https://reviews.llvm.org/D79704

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -440,6 +440,9 @@
   if (const auto *VR = dyn_cast(MR))
 return isLive(VR, true);
 
+  if (const auto *PR = dyn_cast(MR))
+return isLive(PR, true);
+
   // FIXME: This is a gross over-approximation. What we really need is a way to
   // tell if anything still refers to this region. Unlike SymbolicRegions,
   // AllocaRegions don't have associated symbols, though, so we don't actually
@@ -573,3 +576,53 @@
 
   return VarContext->isParentOf(CurrentContext);
 }
+
+bool SymbolReaper::isLive(const ParamRegion *PR,
+  bool includeStoreBindings) const{
+  const StackFrameContext *ParamContext = PR->getStackFrame();
+
+  if (!ParamContext)
+return true;
+
+  if (!LCtx)
+return false;
+  const StackFrameContext *CurrentContext = LCtx->getStackFrame();
+
+  if (ParamContext == CurrentContext) {
+// If no statement is provided, everything is live.
+if (!Loc)
+  return true;
+
+// Anonymous parameters of an inheriting constructor are live for the entire
+// duration of the constructor.
+if (isa(Loc))
+  return true;
+
+if (const ParmVarDecl *PVD = PR->getDecl()) {
+  if (LCtx->getAnalysis()->isLive(Loc, PVD))
+return true;
+}
+
+if (!includeStoreBindings)
+  return false;
+
+unsigned &cachedQuery =
+  const_cast(this)->includedRegionCache[PR];
+
+if (cachedQuery) {
+  return cachedQuery == 1;
+}
+
+// Query the store to see if the region occurs in any live bindings.
+if (Store store = reapedStore.getStore()) {
+  bool hasRegion =
+reapedStore.getStoreManager().includedInBindings(store, PR);
+  cachedQuery = hasRegion ? 1 : 2;
+  return hasRegion;
+}
+
+return false;
+  }
+
+  return ParamContext->isParentOf(CurrentContext);
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -138,6 +138,7 @@
 case MemRegion::CXXTempObjectRegionKind:
 case MemRegion::CXXBaseObjectRegionKind:
 case MemRegion::CXXDerivedObjectRegionKind:
+case MemRegion::ParamRegionKind:
   return MakeElementRegion(cast(R), PointeeTy);
 
 case MemRegion::ElementRegionKind: {
@@ -435,6 +436,19 @@
   return svalBuilder.dispatchCast(V, castTy);
 }
 
+Loc StoreManager::getLValueVar(const VarDecl *VD, const LocationContext *LC) {
+  if (const auto *PVD = dyn_cast(VD)) {
+const Expr* Call;
+unsigned Index;
+std::tie(Call, Index) = ParamRegion::getExprAndIndexForParam(PVD, LC);
+
+if (Call)
+  return svalBuilder.makeLoc(MRMgr.getParamRegion(Call, Index, LC));
+  }
+
+  return svalBuilder.makeLoc(MRMgr.getVarRegion(VD, LC));
+}
+
 SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
   if (Base.isUnknownOrUndef())
 return Base;
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -569,6 +569,8 @@
 
   SVal getBindingForVar(RegionBindingsConstRef B, const VarRegion *R);
 
+  SVal getBindingForParam(RegionBindingsConstRef B, const ParamRegion *R);
+
  

[PATCH] D78442: Create a warning flag for 'warn_conv_*_not_used'

2020-05-11 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler updated this revision to Diff 263202.
rdwampler added a comment.

Rebase.


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

https://reviews.llvm.org/D78442

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Misc/warning-flags.c


Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,7 +18,8 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (72):
+CHECK: Warnings without flags (69):
+
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
 CHECK-NEXT:   ext_missing_declspec
@@ -41,9 +42,6 @@
 CHECK-NEXT:   warn_char_constant_too_large
 CHECK-NEXT:   warn_collection_expr_type
 CHECK-NEXT:   warn_conflicting_variadic
-CHECK-NEXT:   warn_conv_to_base_not_used
-CHECK-NEXT:   warn_conv_to_self_not_used
-CHECK-NEXT:   warn_conv_to_void_not_used
 CHECK-NEXT:   warn_delete_array_type
 CHECK-NEXT:   warn_double_const_requires_fp64
 CHECK-NEXT:   warn_drv_assuming_mfloat_abi_is
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8572,11 +8572,14 @@
 def err_conv_function_redeclared : Error<
   "conversion function cannot be redeclared">;
 def warn_conv_to_self_not_used : Warning<
-  "conversion function converting %0 to itself will never be used">;
+  "conversion function converting %0 to itself will never be used">,
+  InGroup;
 def warn_conv_to_base_not_used : Warning<
-  "conversion function converting %0 to its base class %1 will never be used">;
+  "conversion function converting %0 to its base class %1 will never be used">,
+  InGroup;
 def warn_conv_to_void_not_used : Warning<
-  "conversion function converting %0 to %1 will never be used">;
+  "conversion function converting %0 to %1 will never be used">,
+  InGroup;
 
 def warn_not_compound_assign : Warning<
   "use of unary operator that may be intended as compound assignment (%0=)">;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -60,6 +60,7 @@
 def BoolConversion : DiagGroup<"bool-conversion", [PointerBoolConversion,
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
+def ClassConversion: DiagGroup<"class-conversion">;
 def DeprecatedEnumCompareConditional :
   DiagGroup<"deprecated-enum-compare-conditional">;
 def EnumCompareConditional : DiagGroup<"enum-compare-conditional",


Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,7 +18,8 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (72):
+CHECK: Warnings without flags (69):
+
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
 CHECK-NEXT:   ext_missing_declspec
@@ -41,9 +42,6 @@
 CHECK-NEXT:   warn_char_constant_too_large
 CHECK-NEXT:   warn_collection_expr_type
 CHECK-NEXT:   warn_conflicting_variadic
-CHECK-NEXT:   warn_conv_to_base_not_used
-CHECK-NEXT:   warn_conv_to_self_not_used
-CHECK-NEXT:   warn_conv_to_void_not_used
 CHECK-NEXT:   warn_delete_array_type
 CHECK-NEXT:   warn_double_const_requires_fp64
 CHECK-NEXT:   warn_drv_assuming_mfloat_abi_is
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8572,11 +8572,14 @@
 def err_conv_function_redeclared : Error<
   "conversion function cannot be redeclared">;
 def warn_conv_to_self_not_used : Warning<
-  "conversion function converting %0 to itself will never be used">;
+  "conversion function converting %0 to itself will never be used">,
+  InGroup;
 def warn_conv_to_base_not_used : Warning<
-  "conversion function converting %0 to its base class %1 will never be used">;
+  "conversion function converting %0 to its base class %1 will never be used">,
+  InGroup;
 def warn_conv_to_void_not_used : Warning<
-  "conversion function converting %0 to %1 will never be used">;
+  "conversion function converting %0 to %1 will never be used">,
+  InGroup;
 
 def warn_not_compound_assign : Warning<
   "use of unary operator that may be intended as compound assignment (%0=)">;
Index: clang/include/clang/Basic/DiagnosticGroups.td

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 5 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp:176-180
   if (const auto *DeclReg = Reg->getAs()) {
 if (isa(DeclReg->getDecl()))
   Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();
+  } else if (const auto *ParamReg = Reg->getAs()) {
+Reg = C.getState()->getSVal(SV.castAs()).getAsRegion();

balazske wrote:
> baloghadamsoftware wrote:
> > Szelethus wrote:
> > > This is interesting. I looked up `DeclRegion`, and it seems to be the 
> > > region that is tied to a `ValueDecl`. `VarDecl` is a subtype of 
> > > `ValueDecl`, and `ParmVarDecl` is a subtype of `VarDecl`, so wouldn't it 
> > > make sense for `ParamRegion` to be a subtype of `VarRegion`?
> > `DeclRegion` stores the `Decl`, `ParamRegion` retrieves it based on the 
> > `Index` it stores. There is no is-a relation between them.
> During the lifetime of a `ParamRegion` is it possible that it will return 
> different `Decl` objects?
@NoQ?


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

https://reviews.llvm.org/D79704



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


[PATCH] D66983: [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

2020-05-11 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8e3e56f2a367: [WebAssembly] Add wasm-specific vector shuffle 
builtin and intrinsic (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66983

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/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -141,6 +141,36 @@
   ret <16 x i8> %a
 }
 
+; CHECK-LABEL: shuffle_v16i8:
+; NO-SIMD128-NOT: v8x16
+; SIMD128-NEXT: .functype shuffle_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
+; SIMD128-SAME: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.shuffle(
+  <16 x i8>, <16 x i8>, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
+  i32, i32, i32, i32, i32)
+define <16 x i8> @shuffle_v16i8(<16 x i8> %x, <16 x i8> %y) {
+  %res = call <16 x i8> @llvm.wasm.shuffle(<16 x i8> %x, <16 x i8> %y,
+  i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7,
+  i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 35)
+  ret <16 x i8> %res
+}
+
+; CHECK-LABEL: shuffle_undef_v16i8:
+; NO-SIMD128-NOT: v8x16
+; SIMD128-NEXT: .functype shuffle_undef_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: v8x16.shuffle $push[[R:[0-9]+]]=, $0, $1,
+; SIMD128-SAME: 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+define <16 x i8> @shuffle_undef_v16i8(<16 x i8> %x, <16 x i8> %y) {
+  %res = call <16 x i8> @llvm.wasm.shuffle(<16 x i8> %x, <16 x i8> %y,
+  i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef,
+  i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef,
+  i32 undef, i32 undef, i32 undef, i32 2)
+  ret <16 x i8> %res
+}
+
 ; ==
 ; 8 x i16
 ; ==
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1353,6 +1353,24 @@
Op.getOperand(3)  // thrown value
});
   }
+
+  case Intrinsic::wasm_shuffle: {
+// Drop in-chain and replace undefs, but otherwise pass through unchanged
+SDValue Ops[18];
+size_t OpIdx = 0;
+Ops[OpIdx++] = Op.getOperand(1);
+Ops[OpIdx++] = Op.getOperand(2);
+while (OpIdx < 18) {
+  const SDValue &MaskIdx = Op.getOperand(OpIdx + 1);
+  if (MaskIdx.isUndef() ||
+  cast(MaskIdx.getNode())->getZExtValue() >= 32) {
+Ops[OpIdx++] = DAG.getConstant(0, DL, MVT::i32);
+  } else {
+Ops[OpIdx++] = MaskIdx;
+  }
+}
+return DAG.getNode(WebAssemblyISD::SHUFFLE, DL, Op.getValueType(), Ops);
+  }
   }
 }
 
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -104,6 +104,13 @@
   Intrinsic<[llvm_v16i8_ty],
 [llvm_v16i8_ty, llvm_v16i8_ty],
 [IntrNoMem, IntrSpeculatable]>;
+def int_wasm_shuffle :
+  Intrinsic<[llvm_v16i8_ty],
+[llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty, llvm_i32_ty,
+ llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
+ llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
+ llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable]>;
 def int_wasm_sub_saturate_signed :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>],
@@ -116,7 +123,6 @@
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
-
 def int_wasm_bitselect :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
@@ -170,7 +176,6 @@
 [llvm_anyvector_ty],
 [IntrNoMem, IntrSpeculatable]>;
 
-
 //===--===//
 // Bulk memory intrinsics
 //===--===//
Index: clang/test/CodeGen/builtins-wa

[PATCH] D62368: Add vendor identity check for Hygon Dhyana processor in Scudo

2020-05-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I noticed when I pulled this morning that this seems to have been pushed as a 
branch to the repo

From https://github.com/llvm/llvm-project

  eb7d32e..63a4fdd  master -> origin/master

- [new branch]  arcpatch-D62368 -> origin/arcpatch-D62368


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3192
+  Opts.NoHonorNaNs =
+  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
+  Opts.NoHonorInfs =

@rjmccall I could set these by using Args.hasArg instead of CGOpts, would that 
be acceptabel? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

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



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3185
   Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only) ||
   Args.hasArg(OPT_cl_finite_math_only) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);

mibintc wrote:
> @rjmccall @plotfi These earlier patches are also deriving the value of 
> LangOpts from the settings of CG opts
I don't know what you mean here; the code you're quoting just seems to be 
looking at `Args`.  It's fine to re-parse arguments in both places if that 
makes something easier.  The problem is that you're looking at the 
CodeGenOptions structure itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79730: [NFCi] Switch ordering of ParseLangArgs and ParseCodeGenArgs.

2020-05-11 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
plotfi added reviewers: rjmccall, ab.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After speaking with @ab and @rjmccall on 
https://reviews.llvm.org/D72841#2027740 and 
https://github.com/apple/llvm-project/pull/1202.

it sounds like code-gen option parsing should depend on language-option 
parsing, not the other way around. Apple Clang llvm-project master does this in 
the right order but upstream llvm.org does it in the opposite order.

This patch changes the order to the way apple-master does it, which we think is 
the correct order. At the moment D72841  
causes some bot failures on apple-master (only on tests added in D72841 
). I think D72841 
 should be reverted, and then reapplied after 
_this_  patch is landed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79730

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3626,8 +3626,6 @@
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
-  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
-  Res.getTargetOpts(), Res.getFrontendOpts());
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
 Res.getFileSystemOpts().WorkingDir);
   llvm::Triple T(Res.getTargetOpts().Triple);
@@ -3665,6 +3663,9 @@
   LangOpts.FunctionAlignment =
   getLastArgIntValue(Args, OPT_function_alignment, 0, Diags);
 
+  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
+  Res.getTargetOpts(), Res.getFrontendOpts());
+
   if (LangOpts.CUDA) {
 // During CUDA device-side compilation, the aux triple is the
 // triple used for host compilation.


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3626,8 +3626,6 @@
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
-  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
-  Res.getTargetOpts(), Res.getFrontendOpts());
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
 Res.getFileSystemOpts().WorkingDir);
   llvm::Triple T(Res.getTargetOpts().Triple);
@@ -3665,6 +3663,9 @@
   LangOpts.FunctionAlignment =
   getLastArgIntValue(Args, OPT_function_alignment, 0, Diags);
 
+  Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
+  Res.getTargetOpts(), Res.getFrontendOpts());
+
   if (LangOpts.CUDA) {
 // During CUDA device-side compilation, the aux triple is the
 // triple used for host compilation.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

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



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3192
+  Opts.NoHonorNaNs =
+  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
+  Opts.NoHonorInfs =

mibintc wrote:
> @rjmccall I could set these by using Args.hasArg instead of CGOpts, would 
> that be acceptabel? 
I think so, yes.  Ideally the CG options would then be set based on the earlier 
values, or replaced with uses of the language options structure, but not having 
a direct dependency at all may be simpler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79655: [WebAssembly] Ignore exception specifications

2020-05-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin marked an inline comment as done.
aheejin added inline comments.



Comment at: clang/test/CodeGenCXX/wasm-eh.cpp:399
 
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature 
+exception-handling -S -o - -std=c++11 | FileCheck %s --check-prefix=ASSEMBLY
+

This was preexisting just moved


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79655



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


[PATCH] D79655: [WebAssembly] Ignore exception specifications

2020-05-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 263218.
aheejin added a comment.

- Delete a debugging(?) line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGenCXX/wasm-eh.cpp


Index: clang/test/CodeGenCXX/wasm-eh.cpp
===
--- clang/test/CodeGenCXX/wasm-eh.cpp
+++ clang/test/CodeGenCXX/wasm-eh.cpp
@@ -1,7 +1,6 @@
 // REQUIRES: webassembly-registered-target
 // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature 
+exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
 // RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature 
+exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature 
+exception-handling -S -o - -std=c++11 | FileCheck %s --check-prefix=ASSEMBLY
 
 void may_throw();
 void dont_throw() noexcept;
@@ -385,9 +384,20 @@
 
 // CHECK:   unreachable
 
+// Wasm ignores exception specifications at the moment. Checks if a warning
+// message is printed.
+void test9() throw() {
+}
+
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature 
+exception-handling -emit-llvm -std=c++11 2>&1 | FileCheck %s 
--check-prefix=WARNING
+
+// WARNING: warning: exception specifications are currently ignored in wasm
+
 // Here we only check if the command enables wasm exception handling in the
 // backend so that exception handling instructions can be generated in .s file.
 
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature 
+exception-handling -S -o - -std=c++11 | FileCheck %s --check-prefix=ASSEMBLY
+
 // ASSEMBLY: try
 // ASSEMBLY: catch
 // ASSEMBLY: rethrow
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
@@ -468,6 +469,12 @@
 // encode these in an object file but MSVC doesn't do anything with it.
 if (getTarget().getCXXABI().isMicrosoft())
   return;
+// TODO Correctly handle exception specification in wasm
+if (getTarget().getCXXABI() == TargetCXXABI::WebAssembly) {
+  CGM.getDiags().Report(D->getLocation(),
+diag::warn_wasm_exception_spec_ignored);
+  return;
+}
 unsigned NumExceptions = Proto->getNumExceptions();
 EHFilterScope *Filter = EHStack.pushFilter(NumExceptions);
 
@@ -544,6 +551,9 @@
 // encode these in an object file but MSVC doesn't do anything with it.
 if (getTarget().getCXXABI().isMicrosoft())
   return;
+// TODO Correctly handle exception specification in wasm
+if (getTarget().getCXXABI() == TargetCXXABI::WebAssembly)
+  return;
 EHFilterScope &filterScope = cast(*EHStack.begin());
 emitFilterDispatchBlock(*this, filterScope);
 EHStack.popFilter();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1590,6 +1590,8 @@
   "exception specification of %0 uses itself">;
 def err_exception_spec_incomplete_type : Error<
   "exception specification needed for member of incomplete class %0">;
+def warn_wasm_exception_spec_ignored : Warning<
+  "exception specifications are currently ignored in wasm">;
 
 // C++ access checking
 def err_class_redeclared_with_different_access : Error<


Index: clang/test/CodeGenCXX/wasm-eh.cpp
===
--- clang/test/CodeGenCXX/wasm-eh.cpp
+++ clang/test/CodeGenCXX/wasm-eh.cpp
@@ -1,7 +1,6 @@
 // REQUIRES: webassembly-registered-target
 // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
 // RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -fwasm-e

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-05-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

This approach seems to reflect the consensus from the mailing list.




Comment at: clang/include/clang/AST/RecordLayout.h:74
+  /// The maximum allowed field alignment. This is set by #pragma pack.
+  CharUnits MaxFieldAlignment;
+

If we have to keep around extra data anyway, probably better to add a field for 
the preferred alignment, so we can keep the preferred alignment handling 
together.



Comment at: clang/lib/AST/ASTContext.cpp:2518
+  (T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
+   getTargetInfo().getTriple().isOSAIX()))
 // Don't increase the alignment if an alignment attribute was specified on 
a

We try to avoid OS-specific checks here.  But I'm not sure what this should 
look like on other targets.



Comment at: clang/lib/AST/ASTContext.cpp:2527
+// as its first member.
+if (getTargetInfo().getTriple().isOSAIX()) {
+  const RecordDecl *RD = RT->getDecl();

I'd prefer to centralize the check for "AIX struct layout" in one place, as 
opposed to putting checks for AIX targets in multiple places.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:3438
+C.getPreferredTypeAlign(RD->getTypeForDecl()))
+   .getQuantity());
 

Please don't make the dumping code lie about the "align".  If you want to dump 
the preferred alignment in addition, that would be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D79732: AMDGPU/HIP: Don't replace pointer types in kernel argument structs

2020-05-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: hliao, yaxunl.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

Currently this is counterproductive and doesn't have the desired
effect. The way the promotion is handled is by reinterpreting the
pointers in memory, which ultimately results in GVN using
ptrtoint/inttoptr. This defeats InferAddressSpaces and other
optimizations, which was the point of trying to do this replacement.


https://reviews.llvm.org/D79732

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu


Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -3,10 +3,12 @@
 
 #include "Inputs/cuda.h"
 
-// Coerced struct from `struct S` without all generic pointers lowered into
-// global ones.
-// CHECK: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }
-// CHECK: %struct.T.coerce = type { [2 x float addrspace(1)*] }
+// TODO: These should coerced structs from `struct S` without all generic
+// pointers lowered into global ones when the optimizer doesn't introduce
+// ptrtoint/inttoptr
+
+// CHECK: %struct.S = type { i32*, float* }
+// CHECK: %struct.T = type { [2 x float*] }
 
 // On the host-side compilation, generic pointer won't be coerced.
 // HOST-NOT: %struct.S.coerce
@@ -42,7 +44,7 @@
 };
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
-// CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
+// CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S %s.coerce)
 // HOST: define void @_Z22__device_stub__kernel41S(i32* %s.coerce0, float* 
%s.coerce1)
 __global__ void kernel4(struct S s) {
   s.x[0]++;
@@ -61,7 +63,7 @@
   float *x[2];
 };
 // `by-val` array is also coerced.
-// CHECK: define amdgpu_kernel void @_Z7kernel61T(%struct.T.coerce %t.coerce)
+// CHECK: define amdgpu_kernel void @_Z7kernel61T(%struct.T %t.coerce)
 // HOST: define void @_Z22__device_stub__kernel61T(float* %t.coerce0, float* 
%t.coerce1)
 __global__ void kernel6(struct T t) {
   t.x[0][0] += 1.f;
@@ -74,3 +76,12 @@
 __global__ void kernel7(int *__restrict x) {
   x[0]++;
 }
+
+struct SinglePtrEltStruct {
+  int *x;
+};
+
+// CHECK: define amdgpu_kernel void 
@_Z14single_ptr_elt18SinglePtrEltStruct(i32 addrspace(1)* %s.coerce)
+__global__ void single_ptr_elt(struct SinglePtrEltStruct s) {
+  s.x[0]++;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8336,33 +8336,11 @@
   // Coerce HIP pointer arguments from generic pointers to global ones.
   llvm::Type *coerceKernelArgumentType(llvm::Type *Ty, unsigned FromAS,
unsigned ToAS) const {
-// Structure types.
-if (auto STy = dyn_cast(Ty)) {
-  SmallVector EltTys;
-  bool Changed = false;
-  for (auto T : STy->elements()) {
-auto NT = coerceKernelArgumentType(T, FromAS, ToAS);
-EltTys.push_back(NT);
-Changed |= (NT != T);
-  }
-  // Skip if there is no change in element types.
-  if (!Changed)
-return STy;
-  if (STy->hasName())
-return llvm::StructType::create(
-EltTys, (STy->getName() + ".coerce").str(), STy->isPacked());
-  return llvm::StructType::get(getVMContext(), EltTys, STy->isPacked());
-}
-// Array types.
-if (auto ATy = dyn_cast(Ty)) {
-  auto T = ATy->getElementType();
-  auto NT = coerceKernelArgumentType(T, FromAS, ToAS);
-  // Skip if there is no change in that element type.
-  if (NT == T)
-return ATy;
-  return llvm::ArrayType::get(NT, ATy->getNumElements());
-}
-// Single value types.
+// TODO: This should promote generic pointers in aggregates. This used to 
be
+// done, but was removed due to the way memory reinterpret resulted in the
+// optimizer introducing ptrotoint/inttoptr. This blocks the address space
+// inference, thereby defeating the point of doing the replacement. Single
+// value types.
 if (Ty->isPointerTy() && Ty->getPointerAddressSpace() == FromAS)
   return llvm::PointerType::get(
   cast(Ty)->getElementType(), ToAS);


Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -3,10 +3,12 @@
 
 #include "Inputs/cuda.h"
 
-// Coerced struct from `struct S` without all generic pointers lowered into
-// global ones.
-// CHECK: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-11 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a subscriber: ab.
plotfi added a comment.

@ab @rjmccall @mibintc Posted D79730  for 
consideration.
@mibintc can you produce a version of _this_ diff that works with D79730 
 applied. Currently the following fail, as 
they do on Apple Master:

  Failing Tests (4):
Clang :: CodeGen/finite-math.c
Clang :: CodeGen/fp-floatcontrol-stack.cpp
Clang :: CodeGenOpenCL/relaxed-fpmath.cl
Clang :: Frontend/diagnostics-order.c



In D72841#2029309 , @mibintc wrote:

> @rjmccall Uncertain how to proceed, can you recommend?  If I recall 
> correctly, I added the lines in CompilerOptions because there were many 
> failing lit tests, i could have fixed the lit fails by adding the lang 
> options to the lit tests. (of course that change could have other 
> repercussions)





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D62368: Add vendor identity check for Hygon Dhyana processor in Scudo

2020-05-11 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

In D62368#2029752 , @craig.topper 
wrote:

> I noticed when I pulled this morning that this seems to have been pushed as a 
> branch to the repo
>
> From https://github.com/llvm/llvm-project
>
> eb7d32e..63a4fdd  master -> origin/master
>   * [new branch]  arcpatch-D62368 -> origin/arcpatch-D62368


Hey Craig, I gave a try to arc land this morning as opposed to my regular git 
llvm push workflow.
The initial attempt failed at some point so I went back to git llvm push which 
succeeded 
(https://github.com/llvm/llvm-project/commit/9959eb918acfd37ce89d4a7082ac9957d3628f16#diff-483266ff26e7d1b17130f1b371c4e62d).
Is there something I have to clean up somewhere for that other branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D79733: [clang][SLH] Add __has_feature(speculative_load_hardening)

2020-05-11 Thread Zola Bridges via Phabricator via cfe-commits
zbrid marked an inline comment as done.
zbrid added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5357
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, 
options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))

This is a style fix only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79733



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


[PATCH] D79733: [clang][SLH] Add __has_feature(speculative_load_hardening)

2020-05-11 Thread Zola Bridges via Phabricator via cfe-commits
zbrid marked an inline comment as done.
zbrid added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5357
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, 
options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))

zbrid wrote:
> This is a style fix only.
Err, I mean the change in this line is only a style fix. The rest of the patch 
is the functional change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79733



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


[PATCH] D79733: [clang][SLH] Add __has_feature(speculative_load_hardening)

2020-05-11 Thread Zola Bridges via Phabricator via cfe-commits
zbrid created this revision.
zbrid added reviewers: craig.topper, echristo.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zbrid marked an inline comment as done.
zbrid added inline comments.
zbrid marked an inline comment as done.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5357
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, 
options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))

This is a style fix only.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5357
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, 
options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))

zbrid wrote:
> This is a style fix only.
Err, I mean the change in this line is only a style fix. The rest of the patch 
is the functional change.


SLH doesn't support asm goto and is unlikely to ever support it. Users of asm
goto need a way to choose whether to use asm goto or fallback to an SLH
compatible code path when SLH is enabled. This feature flag will give users
this ability.

Tested via unit test


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79733

Files:
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3372,6 +3372,8 @@
   }
 
   Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
+  Opts.SpeculativeLoadHardeningEnabled =
+  Args.hasArg(OPT_mspeculative_load_hardening);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5354,8 +5354,8 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_pthread);
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, 
options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(TC, Args, CmdArgs, KernelOrKext);
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -366,6 +366,9 @@
  "Key used for return address signing")
 LANGOPT(BranchTargetEnforcement, 1, 0, "Branch-target enforcement enabled")
 
+BENIGN_LANGOPT(SpeculativeLoadHardeningEnabled, 1, 0,
+   "Speculative load hardening enabled")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -36,6 +36,7 @@
 #define EXTENSION(Name, Predicate)
 #endif
 
+FEATURE(speculative_load_hardening, LangOpts.SpeculativeLoadHardeningEnabled)
 FEATURE(address_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3372,6 +3372,8 @@
   }
 
   Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
+  Opts.SpeculativeLoadHardeningEnabled =
+  Args.hasArg(OPT_mspeculative_load_hardening);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5354,8 +5354,8 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_pthread);
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOpti

[PATCH] D79698: Run Coverage pass before other *San passes under new pass manager

2020-05-11 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan 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/D79698/new/

https://reviews.llvm.org/D79698



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


[clang] 9a9a5f9 - [FileCheck] Support comment directives

2020-05-11 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-11T14:53:48-04:00
New Revision: 9a9a5f9893c8db05cebc8818eb8485bff61f7c74

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

LOG: [FileCheck] Support comment directives

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.

Reviewed By: jhenderson, thopre

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

Added: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt

Modified: 
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/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 




diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 21ba2b3269c2..6b3d7bc2e32a 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// COM-LABEL: define i32 @test1()
+// CHECK-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// COM-LABEL: define i32 @test2(i32 %i)
-// COM: %[[addr:.*]] = getelementptr
+// CHECK-LABEL: define i32 @test2(i32 %i)
+// CHECK: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// COM-LABEL: define void @test3()
+// CHECK-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index 35cc54c50d6f..e1f3f6fe1419 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o 

[PATCH] D79735: FP LangOpts should not be dependent on CGOpts

2020-05-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: plotfi, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This bug was observed by Apple since their compiler processes LangOpts and 
CGOpts in a different order


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79735

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2454,7 +2454,7 @@
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const TargetOptions &TargetOpts,
-  PreprocessorOptions &PPOpts, CodeGenOptions &CGOpts,
+  PreprocessorOptions &PPOpts,
   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -3188,13 +3188,21 @@
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
-  Opts.AllowFPReassoc = Opts.FastMath || CGOpts.Reassociate;
-  Opts.NoHonorNaNs =
-  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
-  Opts.NoHonorInfs =
-  Opts.FastMath || CGOpts.NoInfsFPMath || Opts.FiniteMathOnly;
-  Opts.NoSignedZero = Opts.FastMath || CGOpts.NoSignedZeros;
-  Opts.AllowRecip = Opts.FastMath || CGOpts.ReciprocalMath;
+  Opts.AllowFPReassoc = Opts.FastMath || Args.hasArg(OPT_mreassociate);
+  Opts.NoHonorNaNs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_nans) ||
+ Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoHonorInfs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_infinities) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoSignedZero = Opts.FastMath || (Args.hasArg(OPT_fno_signed_zeros) ||
+  Args.hasArg(OPT_cl_no_signed_zeros) ||
+  Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+  Args.hasArg(OPT_cl_fast_relaxed_math));
+  Opts.AllowRecip = Opts.FastMath || Args.hasArg(OPT_freciprocal_math);
   // Currently there's no clang option to enable this individually
   Opts.ApproxFunc = Opts.FastMath;
 
@@ -3650,7 +3658,7 @@
 // Other LangOpts are only initialized when the input is not AST or LLVM 
IR.
 // FIXME: Should we really be calling this for an Language::Asm input?
 ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
-  Res.getPreprocessorOpts(), Res.getCodeGenOpts(), Diags);
+  Res.getPreprocessorOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
 if (T.isOSDarwin() && DashX.isPreprocessed()) {


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2454,7 +2454,7 @@
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const TargetOptions &TargetOpts,
-  PreprocessorOptions &PPOpts, CodeGenOptions &CGOpts,
+  PreprocessorOptions &PPOpts,
   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -3188,13 +3188,21 @@
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
-  Opts.AllowFPReassoc = Opts.FastMath || CGOpts.Reassociate;
-  Opts.NoHonorNaNs =
-  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
-  Opts.NoHonorInfs =
-  Opts.FastMath || CGOpts.NoInfsFPMath || Opts.FiniteMathOnly;
-  Opts.NoSignedZero = Opts.FastMath || CGOpts.NoSignedZeros;
-  Opts.AllowRecip = Opts.FastMath || CGOpts.ReciprocalMath;
+  Opts.AllowFPReassoc = Opts.FastMath || Args.hasArg(OPT_mreassociate);
+  Opts.NoHonorNaNs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_nans) ||
+ Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoHonorInfs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT

[PATCH] D79639: [SveEmitter] Builtins for SVE matrix multiply `mmla`.

2020-05-11 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

Adding some text here as phabricator refuses to submit with an empty comment...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79639



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


[PATCH] D79639: [SveEmitter] Builtins for SVE matrix multiply `mmla`.

2020-05-11 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 263239.
fpetrogalli marked 4 inline comments as done.
fpetrogalli added a comment.

Thank you for the review @sdesmalen, I have addressed all your comments.

Francesco


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79639

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -513,6 +513,11 @@
   case 'q':
 ElementBitwidth /= 4;
 break;
+  case 'b':
+Signed = false;
+Float = false;
+ElementBitwidth /= 4;
+break;
   case 'o':
 ElementBitwidth *= 4;
 break;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_INT8 -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 -D__ARM_FEATURE_SVE_MATMUL_INT8 -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
+
+svint32_t test_svmmla_s32(svint32_t x, svint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svmmla_s32
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.smmla.nxv4i32( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svmmla, _s32, , )(x, y, z);
+}
+
+svuint32_t test_svmmla_u32(svuint32_t x, svuint8_t y, svuint8_t z) {
+  // CHECK-LABEL: test_svmmla_u32
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.ummla.nxv4i32( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svmmla, _u32, , )(x, y, z);
+}
+
+svint32_t test_svusmmla_s32(svint32_t x, svuint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svusmmla_s32
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usmmla.nxv4i32( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusmmla, _s32, , )(x, y, z);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp64.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp64.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_FP64 -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 -D__ARM_FEATURE_SVE_MATMUL_FP64 -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
+
+svfloat64_t test_svmmla_f64(svfloat64_t x, svfloat64_t y, svfloat64_t z) {
+  // CHECK-LABEL: test_svmmla_f64
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.mmla.nxv2f64( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svmmla, _f64, , )(x, y, z);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_FP32 -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 -D__ARM_FEATURE_SVE_MATMUL_FP32 -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
+
+svfloat32_t test_svmmla_f32(svfloat32_t x, svfloat32_t y, svfloat32_

[PATCH] D79526: [CUDA][HIP] Workaround for resolving host device function against wrong-sided function

2020-05-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11670
 
+  bool IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D);
+

I think this can be `static` as it does not need Sema's state.



Comment at: clang/lib/Sema/SemaCUDA.cpp:217-220
+  if (auto *A = D->getAttr())
+if (A->isImplicit())
+  return true;
+  return D->isImplicit();

Is it possible for us to ever end up here with an explicitly set attribute but 
with an implicit function? If that were to happen, we'd return true and that 
would be incorrect.
Perhaps add an assert to make sure it does not happen or always return 
`A->isImplicit()` if an attribute is already set.



Comment at: clang/test/SemaCUDA/function-overload.cu:471-477
+inline double callee(double x);
+#pragma clang force_cuda_host_device begin
+inline void callee(int x);
+inline double implicit_hd_caller() {
+  return callee(1.0);
+}
+#pragma clang force_cuda_host_device end

yaxunl wrote:
> tra wrote:
> > These tests only veryfy that the code compiled, but it does not guarantee 
> > that we've picked the correct overload.
> > You should give callees different return types and assign the result to a 
> > variable of intended type.  See `test_host_device_calls_hd_template() ` on 
> > line 341 for an example.
> they have different return types. The right one returns double and the wrong 
> one returns void. If the wrong one is chosen, there is syntax error since the 
> caller returns double.
Ah. I've missed it. Could you change the types to `struct 
CorrectOverloadRetTy`/`struct IncorrectOverloadRetTy` to make it more obvious?


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

https://reviews.llvm.org/D79526



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


[PATCH] D62368: Add vendor identity check for Hygon Dhyana processor in Scudo

2020-05-11 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

In D62368#2030005 , @craig.topper 
wrote:

> I've deleted the branch in the github web interface. I didn't know I could do 
> that.


Ok thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2020-05-11 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked 4 inline comments as done.
xbolva00 added a comment.

Thanks for initial comments.




Comment at: clang/include/clang/Basic/DiagnosticGroups.td:158
+def DeprecatedCopy : DiagGroup<"deprecated-copy", 
[DeprecatedCopyUserProvided]>;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", 
[DeprecatedCopyDtorUserProvided]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;

Quuxplusone wrote:
> If we're going to provide these options at all, I think it would be more 
> grammatical to call them `-Wdeprecated-copy-with-deleted-copy` and 
> `-Wdeprecated-copy-with-deleted-dtor`.
> 
> The existing code is already confusing by talking about a "copy dtor" as if 
> that's a thing; I think it makes it even worse to talk about "deprecated copy 
> user provided," since the actually deprecated thing is the //implicitly 
> generated// copy.
> 
> I get that we're trying to be terse, and also somewhat hierarchical in 
> putting all the `-Wdeprecated-copy`-related warnings under 
> `-Wdeprecated-copy-foo-bar`; but the current names are too far into the 
> ungrammatical realm for me personally.
Yeah, better names are welcome :)



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:568
+def warn_deprecated_copy_dtor_operation_user_provided : Warning<
+  warn_deprecated_copy_dtor_operation.Text>,
+  InGroup, DefaultIgnore;

Quuxplusone wrote:
> This is the first time I've ever seen this idiom. As a person who often greps 
> the wording of an error message to find out where it comes from, I would very 
> strongly prefer to see the actual string literal here. But if this is 
> established practice, then okay.
> 
I think this is established way how to duplicated warning text strings.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13864
+S.Diag(UserDeclaredOperation->getLocation(), DiagID)
 << RD << /*copy assignment*/ !isa(CopyOp);
   }

Quuxplusone wrote:
> I wonder if this would be easier to read as
> 
> ```
> if (UserDeclaredOperation) {
> bool UDOIsUserProvided = UserDeclaredOperation->isUserProvided();
> bool UDOIsDestructor = isa(UserDeclaredOperation);
> bool IsCopyAssignment = !isa(CopyOp);
> unsigned DiagID =
> ( UDOIsUserProvided &&  UDOIsDestructor) ? 
> diag::warn_deprecated_copy_dtor_operation_user_provided :
> ( UDOIsUserProvided && !UDOIsDestructor) ? 
> diag::warn_deprecated_copy_operation_user_provided :
> (!UDOIsUserProvided &&  UDOIsDestructor) ? 
> diag::warn_deprecated_copy_dtor_operation :
> diag::warn_deprecated_copy_operation;
> S.Diag(UserDeclaredOperation->getLocation(), DiagID)
> << RD << /*copy assignment*/ IsCopyAssignment;
> ```
I have been thinking about similar form, so +1.



Comment at: clang/test/SemaCXX/deprecated-copy.cpp:7
+#ifdef NO_USER_PROVIDED
+// expected-no-diagnostics
+#endif

Quuxplusone wrote:
> I'm fairly confident this should just be two different test files. Also, if a 
> test file has an un-ifdeffed `// expected-no-diagnostics` plus an un-ifdeffed 
> `// expected-note ...`, which one wins?
ifdef is here

and ifNdef is below :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79714



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


[PATCH] D76996: [analyzer] Improve PlacementNewChecker

2020-05-11 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat added a comment.

In D76996#2017572 , @martong wrote:

> > ... This draws a pattern that we should recursively descend down to the top 
> > most base region. I.e. the different check*RegionAlign methods should call 
> > into each other until we reach the top level base region.
>
>
>
> > The observation here is that the alignment of a region can be correct only 
> > if we can prove that its base region is aligned properly (and other 
> > requirements, e.g. the offset is divisible). But the base region may have 
> > another base region and we have to prove the alignment correctness to that 
> > as well.
>
> This could be an issue not just with alignment but maybe with the size as 
> well, I am not sure if we handle the offset properly in compound cases like 
> this: `Xi.b[0].a[1][6]`.
>
> Even though the above issue is still not investigated/handled, I think this 
> patch is now acceptable because seems like most of the practical cases are 
> handled. We could further investigate the concern and improve in a follow-up 
> patch.
>  I'd like to see this landed and thanks for your work!


Thanks for feedback!

I still have no rights to push in the repo so if you think that it is 
acceptable could you commit it please?




Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:189
+  if (const MemRegion *MRegion = PlaceVal.getAsRegion()) {
+if (const ElementRegion *TheElementRegion =
+MRegion->getAs()) {

NoQ wrote:
> martong wrote:
> > f00kat wrote:
> > > f00kat wrote:
> > > > NoQ wrote:
> > > > > NoQ wrote:
> > > > > > The sequence of `FieldRegion`s and `ElementRegion`s on top of a 
> > > > > > base region may be arbitrary: `var.a[0].b[1][2].c.d[3]` etc.
> > > > > > 
> > > > > > I'd rather unwrap those regions one-by-one in a loop and look at 
> > > > > > the alignment of each layer.
> > > > > Alternatively, just decompose the whole region into base region and 
> > > > > offset and see if base region has the necessary alignment and the 
> > > > > offset is divisible by the necessary alignment.
> > > > > The sequence of FieldRegions and ElementRegions on top of a base 
> > > > > region may be arbitrary: var.a[0].b[1][2].c.d[3] etc.
> > > > 
> > > > But i think(hope) I already do this and even have tests for this cases. 
> > > > For example
> > > > ```void test22() {
> > > >   struct alignas(alignof(short)) Z {
> > > > char p;
> > > > char c[10];
> > > >   };
> > > > 
> > > >   struct Y {
> > > > char p;
> > > > Z b[10];
> > > >   };
> > > > 
> > > >   struct X {
> > > > Y a[10];
> > > >   } Xi; // expected-note {{'Xi' initialized here}}
> > > > 
> > > >   // ok. 2(X align) + 1 (offset Y.p) + 1(align Z.p to 'short') + 
> > > > 1(offset Z.p) + 3(index)
> > > >   ::new (&Xi.a[0].b[0].c[3]) long;
> > > > }```
> > > > 
> > > > Cases with multidimensional arrays will also be handled correctly 
> > > > because method 'TheElementRegion->getAsArrayOffset()' calculates the 
> > > > offset for multidimensional arrays
> > > > ```void testXX() {
> > > > struct Y {
> > > > char p;
> > > > char b[10][10];
> > > > };
> > > > 
> > > > struct X {
> > > > Y a[10];
> > > > } Xi;
> > > > 
> > > > ::new (&Xi.a[0].b[0][0]) long;
> > > > }```
> > > > 
> > > > I can explain the code below for ElementRegion if needed.
> > > ?
> > Yeah, the tests are convincing and I think that you are handling the 
> > regions well.
> > 
> > On the other hand, this code is getting really complex, we should make it 
> > easier to read and understand.
> > E.g. `FieldOffsetValue` should be explained more, is it the offset started 
> > from the the start address of the multidimensional array, or it is just the 
> > offset from one element's start address?
> > Also, you have two variables named as `Offset`. They are offsets from which 
> > starting address? Perhaps we should have in the comments a running example, 
> > maybe for `&Xi.a[0].b[0][0]`? I mean is `FieldOffseValue` is standing for 
> > `b` or for `a`?
> > Alternatively, just decompose the whole region into base region and offset 
> > and see if base region has the necessary alignment and the offset is 
> > divisible by the necessary alignment.
> 
> I expect this to be, like, 5 lines of code. I don't understand why the 
> current code is so complicated, it looks like you're considering multiple 
> cases but ultimately doing the same thing.
Thank you for feedback!
Rewroted the code for ElementRegion cases. Now it is much easier to understand, 
and there was also a bug in logic.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:261
+
+  if (const VarRegion *TheVarRegion = BaseRegion->getAs()) {
+const VarDecl *TheVarDecl = TheVarRegion->getDecl();

martong wrote:
> martong wrote:
> > Perhaps you could call instead `checkVarRegionAl

[PATCH] D62368: Add vendor identity check for Hygon Dhyana processor in Scudo

2020-05-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D62368#2029870 , @cryptoad wrote:

> In D62368#2029752 , @craig.topper 
> wrote:
>
> > I noticed when I pulled this morning that this seems to have been pushed as 
> > a branch to the repo
> >
> > From https://github.com/llvm/llvm-project
> >
> > eb7d32e..63a4fdd  master -> origin/master
> >   * [new branch]  arcpatch-D62368 -> origin/arcpatch-D62368
>
>
> Hey Craig, I gave a try to arc land this morning as opposed to my regular git 
> llvm push workflow.
>  The initial attempt failed at some point so I went back to git llvm push 
> which succeeded 
> (https://github.com/llvm/llvm-project/commit/9959eb918acfd37ce89d4a7082ac9957d3628f16#diff-483266ff26e7d1b17130f1b371c4e62d).
>  Is there something I have to clean up somewhere for that other branch?


I've deleted the branch in the github web interface. I didn't know I could do 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2020-05-11 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: clang/test/SemaCXX/deprecated-copy.cpp:7
+#ifdef NO_USER_PROVIDED
+// expected-no-diagnostics
+#endif

xbolva00 wrote:
> Quuxplusone wrote:
> > I'm fairly confident this should just be two different test files. Also, if 
> > a test file has an un-ifdeffed `// expected-no-diagnostics` plus an 
> > un-ifdeffed `// expected-note ...`, which one wins?
> ifdef is here
> 
> and ifNdef is below :)
and DEPRECATED_COPY_DTOR is in own "code block"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79714



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


[PATCH] D79276: [FileCheck] Support comment directives

2020-05-11 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a9a5f9893c8: [FileCheck] Support comment directives 
(authored by jdenny).

Repository:
  rG LLVM Github Monorepo

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

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/after-words.txt
  llvm/test/FileCheck/comment/bad-comment-prefix.txt
  llvm/test/FileCheck/comment/blank-comments.txt
  llvm/test/FileCheck/comment/suffixes.txt
  llvm/test/FileCheck/comment/suppresses-checks.txt
  llvm/test/FileCheck/comment/unused-check-prefixes.txt
  llvm/test/FileCheck/comment/unused-comment-prefixes.txt
  llvm/test/FileCheck/comment/within-checks.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);
 
Index: llvm/test/FileCheck/validate-check-prefix.txt
===
--- llvm/test/FileCheck/validate-check-prefix.txt
+++ llvm/test/FileCheck/validate-check-prefix.txt
@@ -8,6 +8,6 @@
 
 ; BAD_PREFIX: supplied check prefix must start with a letter and contain only alphanumeric characters, hyphens, and underscores: 'A!'
 
-; DUPLICATE_PREFIX: error: supplied check prefix must be unique among check prefixes: 'REPEAT'
+; DUPLICATE_PREFIX: error: supplied check prefix must be unique among check and comment prefixes: 'REPEAT'
 
 ; EMPTY_PREFIX: error: supplied check prefix must not be the empty string
Index: llvm/test/FileCheck/first-character-match.txt
===
--- llvm/test/FileCheck/first-character-match.txt
+++ llvm/test/FileCheck/first-character-match.txt
@@ -1,2 +1,2 @@
-RUN: FileCheck -check-prefix=RUN -input-file %s %s
+RUN: FileCheck -check-prefix=RUN --comment-prefixes=COM -input-file %s %s
 // Prefix is at the first character in the file. The run line then matches itself.
Index: llvm/test/FileCheck/comment/within-checks.txt
===
--- /dev/null
+++ llvm/test/FileCheck/comment/within-checks.txt
@@ -0,0 +1,8 @@
+# A comment directive is not recognized within a check directive's pattern and
+# thus does not comment out the remainder of the pattern.
+
+RUN: echo 'foo' > %t.in
+RUN: echo 'CHECK: foo COM: bar' > %t.chk
+RUN: %ProtectFileCheckOutput not FileCheck %t.chk < %t.in 2>&1 | FileCheck %s
+
+CHECK: .chk:1:8: error: CHECK: expected string not found in input
Index: llvm/test/FileCheck/comment/unused-comment-prefixes.txt
===
--- /dev/null
+++ llvm/test/FileCheck/comment/unused-comment-prefixes.txt
@@ -0,0 +1,16 @@
+# Not using comment directives is always fine.
+
+RUN: echo 'foo'> %t.in
+RUN: echo 'CHECK: foo' > %t.chk
+
+# Check the case of default comment prefixes.
+RUN: %ProtectFileCheckOutput \
+RUN: FileCheck -vv %t.chk < %t.in 2>&1 | FileCheck %s
+
+# Specifying non-default comment prefixes doesn't mean you have to use them.
+# For example, they might be applied to an entire test suite via
+# FILECHECK_OPTS or via a wrapper command or substitution.
+RUN: %ProtectFileCheckOutput \
+RUN: FileCheck -vv -c

[PATCH] D79735: FP LangOpts should not be dependent on CGOpts

2020-05-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, Melanie.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79735



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


[clang] 01dc694 - FP LangOpts should not be dependent on CGOpt

2020-05-11 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-05-11T12:32:35-07:00
New Revision: 01dc694ccb8689a4b4a180da67ed042f85bbcfd5

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

LOG: FP LangOpts should not be dependent on CGOpt
This bug was observed by Apple since their compiler processes LangOpts and 
CGOpts in a different order.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index ec415472ea3c..2d6f4be6885e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2454,7 +2454,7 @@ static const StringRef GetInputKindName(InputKind IK) {
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const TargetOptions &TargetOpts,
-  PreprocessorOptions &PPOpts, CodeGenOptions &CGOpts,
+  PreprocessorOptions &PPOpts,
   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -3188,13 +3188,21 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
-  Opts.AllowFPReassoc = Opts.FastMath || CGOpts.Reassociate;
-  Opts.NoHonorNaNs =
-  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
-  Opts.NoHonorInfs =
-  Opts.FastMath || CGOpts.NoInfsFPMath || Opts.FiniteMathOnly;
-  Opts.NoSignedZero = Opts.FastMath || CGOpts.NoSignedZeros;
-  Opts.AllowRecip = Opts.FastMath || CGOpts.ReciprocalMath;
+  Opts.AllowFPReassoc = Opts.FastMath || Args.hasArg(OPT_mreassociate);
+  Opts.NoHonorNaNs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_nans) ||
+ Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoHonorInfs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_infinities) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoSignedZero = Opts.FastMath || (Args.hasArg(OPT_fno_signed_zeros) ||
+  Args.hasArg(OPT_cl_no_signed_zeros) ||
+  Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+  Args.hasArg(OPT_cl_fast_relaxed_math));
+  Opts.AllowRecip = Opts.FastMath || Args.hasArg(OPT_freciprocal_math);
   // Currently there's no clang option to enable this individually
   Opts.ApproxFunc = Opts.FastMath;
 
@@ -3652,7 +3660,7 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 // Other LangOpts are only initialized when the input is not AST or LLVM 
IR.
 // FIXME: Should we really be calling this for an Language::Asm input?
 ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
-  Res.getPreprocessorOpts(), Res.getCodeGenOpts(), Diags);
+  Res.getPreprocessorOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
 if (T.isOSDarwin() && DashX.isPreprocessed()) {



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


[PATCH] D79730: [NFCi] Switch ordering of ParseLangArgs and ParseCodeGenArgs.

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

I don't think the reversion is necessary; it's being fixed to remove the 
dependency.  This is a good change, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79730



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


[PATCH] D79733: [clang][SLH] Add __has_feature(speculative_load_hardening)

2020-05-11 Thread Matthew Riley via Phabricator via cfe-commits
mattdr added subscribers: rsmith, mattdr.
mattdr added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.def:369
 
+BENIGN_LANGOPT(SpeculativeLoadHardeningEnabled, 1, 0,
+   "Speculative load hardening enabled")

I've read the description of `LANGOPT`, `COMPATIBLE_LANGOPT`, and 
`BENIGN_LANGOPT` a few times and, though I'm still not //confident//, I 
//think// this should be `LANGOPT`.

A few reasons:
1. We actually expect the SLH setting to be the same throughout a compiled 
binary, so it **shouldn't** differ between modules and the consequences if it 
does are already not well defined
2. Looking through the other `BENIGN_LANGOPT`s, many seem to describe changing 
the boundaries for programs that will be accepted/rejected at parsing, which 
doesn't read on SLH.
3. We're adding this so we can use `__has_feature` to change the code that's 
compiled (e.g. avoiding `asm goto`), so we definitely anticipate cases where 
the setting for this option changes the AST in semantic ways

@rsmith -- can you please check my math?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79733



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


[PATCH] D79276: [FileCheck] Support comment directives

2020-05-11 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: llvm/test/FileCheck/comment/suffixes.txt:1-2
+# Comment prefixes plus check directive suffixes are not comment directives
+# and are treated as plain text.
+

jhenderson wrote:
> jdenny wrote:
> > jhenderson wrote:
> > > jdenny wrote:
> > > > jhenderson wrote:
> > > > > I don't think you should change anything here, but if I'm following 
> > > > > this right, this leads to the amusing limitation that you can 
> > > > > "comment out" (via --comment-prefixes) any CHECK lines that use a 
> > > > > suffix (CHECK-NEXT, CHECK-NOT etc) but not those that don't without 
> > > > > changing --check-prefixes value!
> > > > > 
> > > > > By the way, do we need to have a test-case for that? I.e. that 
> > > > > --comment-prefixes=CHECK-NEXT disables the CHECK-NEXT lines (assuming 
> > > > > it does of course)?
> > > > > I don't think you should change anything here, but if I'm following 
> > > > > this right, this leads to the amusing limitation that you can 
> > > > > "comment out" (via --comment-prefixes) any CHECK lines that use a 
> > > > > suffix (CHECK-NEXT, CHECK-NOT etc) but not those that don't without 
> > > > > changing --check-prefixes value!
> > > > 
> > > > That's right, but check prefixes have this problem too.  That is, you 
> > > > can do things like `-check-prefixes=FOO,FOO-NOT` so that `FOO-NOT` is 
> > > > not negative.
> > > > 
> > > > `ValidatePrefixes` should be extended to catch such cases, I think.  
> > > > But in a separate patch.
> > > > 
> > > > > By the way, do we need to have a test-case for that? I.e. that 
> > > > > --comment-prefixes=CHECK-NEXT disables the CHECK-NEXT lines (assuming 
> > > > > it does of course)?
> > > > 
> > > > Hmm.  I think it's behavior we don't want to support.  Maybe the test 
> > > > case should be added when extending `ValidatePrefixes` as I described 
> > > > above?
> > > > 
> > > I agree it's separate work. FWIW, I just came up with a genuinely useful 
> > > use-case for it with CHECK directives, but it might just be unnecessary. 
> > > Imagine the case where you want a test where some specific output is 
> > > printed under one condition and not another condition. You'd want 
> > > something like:
> > > 
> > > ```
> > > # RUN: ... | FileCheck %s --check-prefix=WITH
> > > # RUN: ... | FileCheck %s --check-prefix=WITHOUT
> > > 
> > > # WITH: some text that should be matched
> > > # WITHOUT-NOT: some text that should be matched
> > > ```
> > > 
> > > A careleses developer could change the text of "WITH" to match some new 
> > > behaviour without changing "WITHOUT-NOT", thus breaking the second case. 
> > > You could instead do:
> > > 
> > > ```
> > > # RUN: ... | FileCheck %s --check-prefix=CHECK-NOT
> > > # RUN: ... | FileCheck %s
> > > 
> > > # CHECK-NOT: some text that should be matched
> > > ```
> > > Then, if the output changed, you'd update both the regular and NOT match. 
> > > I might have used this pattern in a few tests in the past had it occurred 
> > > to me.
> > > 
> > > Anyway, I think there are other ways of solving that problem, although 
> > > not without work on FileCheck (I've been prototyping a method with only 
> > > limited success so far), and I agree it's otherwise mostly horrible, so 
> > > I'm not seriously opposing the suggestion.
> > I agree the use case is important, and I also agree there must be a better 
> > solution.
> > 
> > The underlying issue is that we want to reuse a pattern.  Perhaps there 
> > should be some way to define a FileCheck variable once and reuse it among 
> > multiple FileCheck commands. For example:
> > 
> > ```
> > # RUN: ... | FileCheck %s --check-prefix=WITH,ALL
> > # RUN: ... | FileCheck %s --check-prefix=WITHOUT,ALL
> > 
> > # ALL-DEF: [[VAR:some text that should be matched]]
> > # WITH: [[VAR]]
> > # WITHOUT-NOT: [[VAR]]
> > ```
> > 
> > It should probably be possible to use regexes in such a variable.  I'm not 
> > sure if that's possible now.  It might require a special variable type.  We 
> > currently have `#` to indicate numeric variables.  Perhaps `~` would 
> > indicate pattern variables.
> That's almost exactly what I've been prototyping on-and-off over the past few 
> months, but I've been running into various ordering issues, which I haven't 
> yet solved to my satisfaction. My original thread that inspired the idea is 
> http://lists.llvm.org/pipermail/llvm-dev/2020-January/138822.html.
Cool.  I think I could benefit from this feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79276



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


[PATCH] D79735: FP LangOpts should not be dependent on CGOpts

2020-05-11 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

@mibintc Nice solution. I think this would work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79735



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


[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 263238.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Define two helper functions in Sema that compute the alignment of a VarDecl and 
a constant offset from it and use them instead of the classes for evaluating 
lvalue and pointer expressions in ExprConstant.cpp.

Using the classes in ExprConstant.cpp to compute an expression alignment as I 
did in the previous patch is probably not a good idea since they are for 
evaluating constant expressions. They don't return the lvalue base variables 
and offsets in some cases ( for example, `(A *)&m_ref` in the test case) and 
using them for this purpose can make it harder to make changes to the way 
constant expressions are evaluated. The current patch is far from perfect as it 
misses many cases that could be detected by the classes in ExprConstant.cpp, 
but is at least an improvement over what we have now.

I was also thinking about fixing the alignment computation of captured 
variables, but I think I should do that separately in a follow-up as it might 
not be trivial. It will probably require looking up the captured variables in 
all the enclosing `CapturingScopeInfo`s.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp

Index: clang/test/SemaCXX/warn-cast-align.cpp
===
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -43,3 +43,53 @@
   typedef int *IntPtr;
   c = IntPtr(P);
 }
+
+struct __attribute__((aligned(16))) A {
+  char m0[16];
+  char m1[16];
+};
+
+struct B {
+  char m0[16];
+};
+
+struct C {
+  A &m0;
+  B &m1;
+  A m2;
+};
+
+struct D {
+  char m0[8];
+};
+
+void test2(int n, A *a2) {
+  __attribute__((aligned(16))) char m[sizeof(A) * 2];
+  char(&m_ref)[sizeof(A) * 2] = m;
+  __attribute__((aligned(16))) char vararray[10][n];
+  A t0;
+  B t1;
+  C t2 = {.m0 = t0, .m1 = t1};
+  __attribute__((aligned(16))) char t3[5][5][5];
+
+  A *a;
+  a = (A *)&m;
+  a = (A *)(m + sizeof(A));
+  a = (A *)(sizeof(A) + m);
+  a = (A *)((sizeof(A) * 2 + m) - sizeof(A));
+  a = (A *)((sizeof(A) * 2 + m) - 1); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + 1);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(1 + m);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + n);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&m[sizeof(A)];
+  a = (A *)&m[n]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&m_ref;
+  a = (A *)(&vararray[4][0]);// expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(a2->m0 + sizeof(A)); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(&t2.m0);
+  a = (A *)(&t2.m1); // expected-warning {{cast from 'B *' to 'A *'}}
+  a = (A *)(&t2.m2);
+  a = (A *)(t2.m2.m1);
+  a = (A *)(&t3[3][3][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(&t3[2][2][4]);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -30,6 +30,7 @@
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -13055,17 +13056,126 @@
   return HasInvalidParm;
 }
 
-/// A helper function to get the alignment of a Decl referred to by DeclRefExpr
-/// or MemberExpr.
-static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign,
-  ASTContext &Context) {
-  if (const auto *DRE = dyn_cast(E))
-return Context.getDeclAlign(DRE->getDecl());
+std::tuple static getBaseAlignmentAndOffsetFromPtr(
+const Expr *E, ASTContext &Ctx);
 
-  if (const auto *ME = dyn_cast(E))
-return Context.getDeclAlign(ME->getMemberDecl());
+/// This helper function takes an lvalue expression and returns the alignment of
+/// a VarDecl and a constant offset from the VarDecl. The first element of the
+/// tuple it returns is true if a VarDecl is found and the offset is constant.
+std::tuple
+static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext &Ctx) {
+  E = E->IgnoreParens();
+  switch (E->getStmtClass()) {
+  default:
+break;
+  case Stmt::ArraySubscriptExprClass: {
+if (!E->getType()->isConstantSizeType())
+  break;
+auto *ASE = cast(E);
+auto P = getBaseAlignmentAndOffsetFromPtr(ASE->getBase(), Ctx);
+if (std::get<0>(P)) {
+  llvm::APSInt IdxRes;
+  if (ASE->getIdx()->isIntegerConstantExpr(IdxRes, Ctx)) {
+CharUnits EltSize = Ctx.getTypeSizeInChars(E->getType());
+return std::ma

[PATCH] D79733: [clang][SLH] Add __has_feature(speculative_load_hardening)

2020-05-11 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 263247.
zbrid added a comment.

Change langopt type + SpeculativeLoadHardeningEnabled -> 
SpeculativeLoadHardening

This is to match the CodeGenOpt for SLH that already exists and to address
mattdr's feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79733

Files:
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3372,6 +3372,7 @@
   }
 
   Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
+  Opts.SpeculativeLoadHardening = Args.hasArg(OPT_mspeculative_load_hardening);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5354,8 +5354,8 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_pthread);
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, 
options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(TC, Args, CmdArgs, KernelOrKext);
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -366,6 +366,8 @@
  "Key used for return address signing")
 LANGOPT(BranchTargetEnforcement, 1, 0, "Branch-target enforcement enabled")
 
+LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load hardening enabled")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -36,6 +36,7 @@
 #define EXTENSION(Name, Predicate)
 #endif
 
+FEATURE(speculative_load_hardening, LangOpts.SpeculativeLoadHardening)
 FEATURE(address_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3372,6 +3372,7 @@
   }
 
   Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
+  Opts.SpeculativeLoadHardening = Args.hasArg(OPT_mspeculative_load_hardening);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5354,8 +5354,8 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_pthread);
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening, options::OPT_mno_speculative_load_hardening,
-   false))
+  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
+   options::OPT_mno_speculative_load_hardening, false))
 CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
 
   RenderSSPOptions(TC, Args, CmdArgs, KernelOrKext);
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -366,6 +366,8 @@
  "Key used for return address signing")
 LANGOPT(BranchTargetEnforcement, 1, 0, "Branch-target enforcement enabled")
 
+LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load hardening enabled")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -36,6 +36,7 @@
 #define EXTENSION(Name, Predicate)
 #endif
 
+FEATURE(speculative_load_hardening, LangOpts.SpeculativeLoadHardening)
 FEATURE(address_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
SanitizerKind::KernelAddress))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailm

[PATCH] D79735: FP LangOpts should not be dependent on CGOpts

2020-05-11 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01dc694ccb86: FP LangOpts should not be dependent on CGOpt 
This bug was observed by Apple… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79735

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2454,7 +2454,7 @@
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const TargetOptions &TargetOpts,
-  PreprocessorOptions &PPOpts, CodeGenOptions &CGOpts,
+  PreprocessorOptions &PPOpts,
   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -3188,13 +3188,21 @@
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
-  Opts.AllowFPReassoc = Opts.FastMath || CGOpts.Reassociate;
-  Opts.NoHonorNaNs =
-  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
-  Opts.NoHonorInfs =
-  Opts.FastMath || CGOpts.NoInfsFPMath || Opts.FiniteMathOnly;
-  Opts.NoSignedZero = Opts.FastMath || CGOpts.NoSignedZeros;
-  Opts.AllowRecip = Opts.FastMath || CGOpts.ReciprocalMath;
+  Opts.AllowFPReassoc = Opts.FastMath || Args.hasArg(OPT_mreassociate);
+  Opts.NoHonorNaNs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_nans) ||
+ Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoHonorInfs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_infinities) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoSignedZero = Opts.FastMath || (Args.hasArg(OPT_fno_signed_zeros) ||
+  Args.hasArg(OPT_cl_no_signed_zeros) ||
+  Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+  Args.hasArg(OPT_cl_fast_relaxed_math));
+  Opts.AllowRecip = Opts.FastMath || Args.hasArg(OPT_freciprocal_math);
   // Currently there's no clang option to enable this individually
   Opts.ApproxFunc = Opts.FastMath;
 
@@ -3652,7 +3660,7 @@
 // Other LangOpts are only initialized when the input is not AST or LLVM 
IR.
 // FIXME: Should we really be calling this for an Language::Asm input?
 ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
-  Res.getPreprocessorOpts(), Res.getCodeGenOpts(), Diags);
+  Res.getPreprocessorOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
 if (T.isOSDarwin() && DashX.isPreprocessed()) {


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2454,7 +2454,7 @@
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   const TargetOptions &TargetOpts,
-  PreprocessorOptions &PPOpts, CodeGenOptions &CGOpts,
+  PreprocessorOptions &PPOpts,
   DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -3188,13 +3188,21 @@
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
   Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
   Args.hasArg(OPT_cl_fast_relaxed_math);
-  Opts.AllowFPReassoc = Opts.FastMath || CGOpts.Reassociate;
-  Opts.NoHonorNaNs =
-  Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
-  Opts.NoHonorInfs =
-  Opts.FastMath || CGOpts.NoInfsFPMath || Opts.FiniteMathOnly;
-  Opts.NoSignedZero = Opts.FastMath || CGOpts.NoSignedZeros;
-  Opts.AllowRecip = Opts.FastMath || CGOpts.ReciprocalMath;
+  Opts.AllowFPReassoc = Opts.FastMath || Args.hasArg(OPT_mreassociate);
+  Opts.NoHonorNaNs = Opts.FastMath || Opts.FiniteMathOnly ||
+ Args.hasArg(OPT_menable_no_nans) ||
+ Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+ Args.hasArg(OPT_cl_finite_math_only) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoHonorInfs = Opts.FastMath || Opts.FiniteMathOnly ||
+ 

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D72841#2029821 , @plotfi wrote:

> @ab @rjmccall @mibintc Posted D79730  for 
> consideration.
>  @mibintc can you produce a version of _this_ diff that works with D79730 
>  applied. Currently the following fail, as 
> they do on Apple Master:


@rjmccall accepted the proposed patch https://reviews.llvm.org/D79735, so I 
pushed that.  I also tried your patch and the 3 CodeGen tests pass but the 
diagnostics-order.c test fails

> 
> 
>   Failing Tests (4):
> Clang :: CodeGen/finite-math.c
> Clang :: CodeGen/fp-floatcontrol-stack.cpp
> Clang :: CodeGenOpenCL/relaxed-fpmath.cl
> Clang :: Frontend/diagnostics-order.c




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[clang] 7d5bb94 - Run Coverage pass before other *San passes under new pass manager

2020-05-11 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-05-11T12:59:09-07:00
New Revision: 7d5bb94d78386e4653535c35d3e8258bf4502340

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

LOG: Run Coverage pass before other *San passes under new pass manager

Summary:
This fixes compiler-rt/test/msan/coverage-levels.cpp under the new pass manager 
(final check-msan test!).
Under the old pass manager, the coverage pass would run before the MSan pass. 
The opposite happened under the new pass manager. The MSan pass adds extra 
basic blocks, changing the number of coverage callbacks.

Reviewers: vitalybuka, leonardchan

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index ba4b48d8bd5f..0dc6c08eafe3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1002,6 +1002,15 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
   const Triple &TargetTriple,
   const LangOptions &LangOpts,
   const CodeGenOptions &CodeGenOpts) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(
+SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+CodeGenOpts.SanitizeCoverageBlacklistFiles));
+  }
+
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1242,6 +1251,17 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+  CodeGenOpts.SanitizeCoverageBlacklistFiles));
+});
+  }
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1326,15 +1346,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   }
 }
 
-if (CodeGenOpts.SanitizeCoverageType ||
-CodeGenOpts.SanitizeCoverageIndirectCalls ||
-CodeGenOpts.SanitizeCoverageTraceCmp) {
-  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-  MPM.addPass(ModuleSanitizerCoveragePass(
-  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-  CodeGenOpts.SanitizeCoverageBlacklistFiles));
-}
-
 if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
   bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
   MPM.addPass(HWAddressSanitizerPass(



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


  1   2   >