[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-06 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp created this revision.
carlosgalvezp added reviewers: aaron.ballman, alexfh.
Herald added subscribers: arphaman, xazax.hun.
carlosgalvezp requested review of this revision.
Herald added a project: clang-tools-extra.

To simplify suppressing multiple warnings, e.g. coming from check aliases.

The code for globbing is the same as for enabling checks, so the semantics are 
identical. Naturally, the meaning is reversed since we are _disabling_ warnings 
in NOLINT expressions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111208

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -46,6 +46,17 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
+// NOLINTNEXTLINE(google*)
+class I1 { I1(int i); };
+
+// NOLINTNEXTLINE(google*,-google*)
+class I2 { I2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*,-google*)
+class I3 { I3(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 10 warnings (10 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -119,4 +119,18 @@
 
 MACRO_NO_LINT_INSIDE_MACRO
 
-// CHECK-MESSAGES: Suppressed 18 warnings (18 NOLINT).
+// NOLINTBEGIN(google*)
+class C13 { C13(int i); };
+// NOLINTEND(google*)
+
+// NOLINTBEGIN(google*,-google*)
+class C14 { C14(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(google*,-google*)
+
+// NOLINTBEGIN(*,-google*)
+class C15 { C15(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(*,-google*)
+
+// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT).
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -51,4 +51,16 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
+class D1 { D1(int x); }; // NOLINT(google*)
+class D2 { D2(int x); }; // NOLINT(*explicit-constructor)
+class D3 { D3(int x); }; // NOLINT(*explicit*)
+
+class D4 { D4(int x); }; // NOLINT(google*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+class D5 { D5(int x); }; // NOLINT(google*,-google*,google*)
+
+class D6 { D6(int x); }; // NOLINT(*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 17 warnings (17 NOLINT)
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -173,11 +173,11 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
---fix-notes- 
- If a warning has no fix, but a single fix can 
- be found through an associated diagnostic note, 
- apply the fix. 
- Specifying this flag will implicitly enable the 
+--fix-notes-
+ If a warning has no fix, but a single fix can
+ be found through an associated diagnostic note,
+ apply the fix.
+ Specifying this flag will implicitly enable the
  '--fix' flag.
 --format-style=-
  Style for formatting code around a

[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-06 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 377442.
carlosgalvezp added a comment.

Fixed formatting.


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

https://reviews.llvm.org/D111208

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -46,6 +46,17 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
+// NOLINTNEXTLINE(google*)
+class I1 { I1(int i); };
+
+// NOLINTNEXTLINE(google*,-google*)
+class I2 { I2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*,-google*)
+class I3 { I3(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 10 warnings (10 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -119,4 +119,18 @@
 
 MACRO_NO_LINT_INSIDE_MACRO
 
-// CHECK-MESSAGES: Suppressed 18 warnings (18 NOLINT).
+// NOLINTBEGIN(google*)
+class C13 { C13(int i); };
+// NOLINTEND(google*)
+
+// NOLINTBEGIN(google*,-google*)
+class C14 { C14(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(google*,-google*)
+
+// NOLINTBEGIN(*,-google*)
+class C15 { C15(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(*,-google*)
+
+// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT).
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -51,4 +51,16 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
+class D1 { D1(int x); }; // NOLINT(google*)
+class D2 { D2(int x); }; // NOLINT(*explicit-constructor)
+class D3 { D3(int x); }; // NOLINT(*explicit*)
+
+class D4 { D4(int x); }; // NOLINT(google*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+class D5 { D5(int x); }; // NOLINT(google*,-google*,google*)
+
+class D6 { D6(int x); }; // NOLINT(*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 17 warnings (17 NOLINT)
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -173,11 +173,11 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
---fix-notes- 
- If a warning has no fix, but a single fix can 
- be found through an associated diagnostic note, 
- apply the fix. 
- Specifying this flag will implicitly enable the 
+--fix-notes-
+ If a warning has no fix, but a single fix can
+ be found through an associated diagnostic note,
+ apply the fix.
+ Specifying this flag will implicitly enable the
  '--fix' flag.
 --format-style=-
  Style for formatting code around applied fixes:
@@ -308,7 +308,10 @@
 comments).
 
 All comments can be followed by an optional list of check names in parentheses
-(see below for the formal syntax).
+(see below for the formal syntax). The list of check names supports globbing,
+with the same format and semantics as for enabling checks. Note that adding
+a dash, e.g. `NOLINT(-check-name)`, is 

[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-06 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 377445.
carlosgalvezp added a comment.

Update comment in code.


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

https://reviews.llvm.org/D111208

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -46,6 +46,17 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
+// NOLINTNEXTLINE(google*)
+class I1 { I1(int i); };
+
+// NOLINTNEXTLINE(google*,-google*)
+class I2 { I2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*,-google*)
+class I3 { I3(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 10 warnings (10 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -119,4 +119,18 @@
 
 MACRO_NO_LINT_INSIDE_MACRO
 
-// CHECK-MESSAGES: Suppressed 18 warnings (18 NOLINT).
+// NOLINTBEGIN(google*)
+class C13 { C13(int i); };
+// NOLINTEND(google*)
+
+// NOLINTBEGIN(google*,-google*)
+class C14 { C14(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(google*,-google*)
+
+// NOLINTBEGIN(*,-google*)
+class C15 { C15(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(*,-google*)
+
+// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT).
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -51,4 +51,16 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
+class D1 { D1(int x); }; // NOLINT(google*)
+class D2 { D2(int x); }; // NOLINT(*explicit-constructor)
+class D3 { D3(int x); }; // NOLINT(*explicit*)
+
+class D4 { D4(int x); }; // NOLINT(google*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+class D5 { D5(int x); }; // NOLINT(google*,-google*,google*)
+
+class D6 { D6(int x); }; // NOLINT(*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 17 warnings (17 NOLINT)
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -173,11 +173,11 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
---fix-notes- 
- If a warning has no fix, but a single fix can 
- be found through an associated diagnostic note, 
- apply the fix. 
- Specifying this flag will implicitly enable the 
+--fix-notes-
+ If a warning has no fix, but a single fix can
+ be found through an associated diagnostic note,
+ apply the fix.
+ Specifying this flag will implicitly enable the
  '--fix' flag.
 --format-style=-
  Style for formatting code around applied fixes:
@@ -308,7 +308,10 @@
 comments).
 
 All comments can be followed by an optional list of check names in parentheses
-(see below for the formal syntax).
+(see below for the formal syntax). The list of check names supports globbing,
+with the same format and semantics as for enabling checks. Note that adding
+a dash, e.g. `NOLINT(-check-name)

[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-06 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 377446.
carlosgalvezp added a comment.

Remove empty lines


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

https://reviews.llvm.org/D111208

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -46,6 +46,17 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
+// NOLINTNEXTLINE(google*)
+class I1 { I1(int i); };
+
+// NOLINTNEXTLINE(google*,-google*)
+class I2 { I2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*,-google*)
+class I3 { I3(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 10 warnings (10 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -119,4 +119,18 @@
 
 MACRO_NO_LINT_INSIDE_MACRO
 
-// CHECK-MESSAGES: Suppressed 18 warnings (18 NOLINT).
+// NOLINTBEGIN(google*)
+class C13 { C13(int i); };
+// NOLINTEND(google*)
+
+// NOLINTBEGIN(google*,-google*)
+class C14 { C14(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(google*,-google*)
+
+// NOLINTBEGIN(*,-google*)
+class C15 { C15(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(*,-google*)
+
+// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT).
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -51,4 +51,16 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
+class D1 { D1(int x); }; // NOLINT(google*)
+class D2 { D2(int x); }; // NOLINT(*explicit-constructor)
+class D3 { D3(int x); }; // NOLINT(*explicit*)
+
+class D4 { D4(int x); }; // NOLINT(google*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+class D5 { D5(int x); }; // NOLINT(google*,-google*,google*)
+
+class D6 { D6(int x); }; // NOLINT(*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 17 warnings (17 NOLINT)
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -173,11 +173,11 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
---fix-notes- 
- If a warning has no fix, but a single fix can 
- be found through an associated diagnostic note, 
- apply the fix. 
- Specifying this flag will implicitly enable the 
+--fix-notes-
+ If a warning has no fix, but a single fix can
+ be found through an associated diagnostic note,
+ apply the fix.
+ Specifying this flag will implicitly enable the
  '--fix' flag.
 --format-style=-
  Style for formatting code around applied fixes:
@@ -308,7 +308,10 @@
 comments).
 
 All comments can be followed by an optional list of check names in parentheses
-(see below for the formal syntax).
+(see below for the formal syntax). The list of check names supports globbing,
+with the same format and semantics as for enabling checks. Note that adding
+a dash, e.g. `NOLINT(-check-name)`, is

[clang] 13d3cd3 - [PowerPC] Implement vector float and vector double version for vec_orc builtin

2021-10-06 Thread Albion Fung via cfe-commits

Author: Albion Fung
Date: 2021-10-06T02:47:42-05:00
New Revision: 13d3cd37e27889cb343d92313944d5dabfe2762b

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

LOG: [PowerPC] Implement vector float and vector double version for vec_orc 
builtin

The builtin for vec_orc has support for the following two signatures,
but currently the compiler marks it ambiguous:
vector float vec_orc(vector float, vector float)
vector double vec_orc(vector double, vector double)

This patch implements these two builtins.

Differential revision: https://reviews.llvm.org/D110858

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p8vector.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 4e229a4bf510c..a6dfe2d14423a 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -7109,6 +7109,11 @@ vec_orc(vector float __a, vector bool int __b) {
   return (vector float)((vector unsigned int)__a | ~__b);
 }
 
+static __inline__ vector float __ATTRS_o_ai vec_orc(vector float __a,
+vector float __b) {
+  return (vector float)((vector unsigned int)__a | ~(vector unsigned int)__b);
+}
+
 static __inline__ vector signed long long __ATTRS_o_ai
 vec_orc(vector signed long long __a, vector signed long long __b) {
   return __a | ~__b;
@@ -7153,6 +7158,12 @@ static __inline__ vector double __ATTRS_o_ai
 vec_orc(vector bool long long __a, vector double __b) {
   return (vector double)(__a | ~(vector unsigned long long)__b);
 }
+
+static __inline__ vector double __ATTRS_o_ai vec_orc(vector double __a,
+ vector double __b) {
+  return (vector double)((vector bool long long)__a |
+ ~(vector unsigned long long)__b);
+}
 #endif
 
 /* vec_vor */

diff  --git a/clang/test/CodeGen/builtins-ppc-p8vector.c 
b/clang/test/CodeGen/builtins-ppc-p8vector.c
index 16a306cc82ed2..90e6de283cb15 100644
--- a/clang/test/CodeGen/builtins-ppc-p8vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -35,7 +35,9 @@ vector signed __int128 vsx = { 1 };
 vector unsigned __int128 vux = { 1 };
 
 vector float vfa = { 1.e-4f, -132.23f, -22.1, 32.00f };
+vector float vfb = { 1.e-4f, -132.23f, -22.1, 32.00f };
 vector double vda = { 1.e-11, -132.23e10 };
+vector double vdb = { 1.e-11, -132.23e10 };
 
 int res_i;
 double res_d;
@@ -1067,6 +1069,12 @@ void test1() {
 // CHECK: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
 // CHECK: or <4 x i32> {{%.+}}, [[T1]]
 // CHECK-LE: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
+// CHECK-LE: or <4 x i32> {{%.+}}, [[T1]]
+
+  res_vf = vec_orc(vfa, vfb);
+// CHECK: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
+// CHECK: or <4 x i32> {{%.+}}, [[T1]]
+// CHECK-LE: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
 // CHECK-LE: or <4 x i32> {{%.+}}, [[T1]]
 
   res_vsll = vec_orc(vsll, vsll);
@@ -1121,6 +1129,12 @@ void test1() {
 // CHECK: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
 // CHECK: or <2 x i64> {{%.+}}, [[T1]]
 // CHECK-LE: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
+// CHECK-LE: or <2 x i64> {{%.+}}, [[T1]]
+
+  res_vd = vec_orc(vda, vdb);
+// CHECK: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
+// CHECK: or <2 x i64> {{%.+}}, [[T1]]
+// CHECK-LE: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
 // CHECK-LE: or <2 x i64> {{%.+}}, [[T1]]
 
   /* vec_sub */



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


[PATCH] D110858: [PowerPC] Implement vector float and vector double version for vec_orc builtin

2021-10-06 Thread Albion Fung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13d3cd37e278: [PowerPC] Implement vector float and vector 
double version for vec_orc builtin (authored by Conanap).

Changed prior to commit:
  https://reviews.llvm.org/D110858?vs=376273&id=377453#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110858

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p8vector.c


Index: clang/test/CodeGen/builtins-ppc-p8vector.c
===
--- clang/test/CodeGen/builtins-ppc-p8vector.c
+++ clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -35,7 +35,9 @@
 vector unsigned __int128 vux = { 1 };
 
 vector float vfa = { 1.e-4f, -132.23f, -22.1, 32.00f };
+vector float vfb = { 1.e-4f, -132.23f, -22.1, 32.00f };
 vector double vda = { 1.e-11, -132.23e10 };
+vector double vdb = { 1.e-11, -132.23e10 };
 
 int res_i;
 double res_d;
@@ -1067,6 +1069,12 @@
 // CHECK: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
 // CHECK: or <4 x i32> {{%.+}}, [[T1]]
 // CHECK-LE: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
+// CHECK-LE: or <4 x i32> {{%.+}}, [[T1]]
+
+  res_vf = vec_orc(vfa, vfb);
+// CHECK: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
+// CHECK: or <4 x i32> {{%.+}}, [[T1]]
+// CHECK-LE: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
 // CHECK-LE: or <4 x i32> {{%.+}}, [[T1]]
 
   res_vsll = vec_orc(vsll, vsll);
@@ -1121,6 +1129,12 @@
 // CHECK: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
 // CHECK: or <2 x i64> {{%.+}}, [[T1]]
 // CHECK-LE: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
+// CHECK-LE: or <2 x i64> {{%.+}}, [[T1]]
+
+  res_vd = vec_orc(vda, vdb);
+// CHECK: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
+// CHECK: or <2 x i64> {{%.+}}, [[T1]]
+// CHECK-LE: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
 // CHECK-LE: or <2 x i64> {{%.+}}, [[T1]]
 
   /* vec_sub */
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -7109,6 +7109,11 @@
   return (vector float)((vector unsigned int)__a | ~__b);
 }
 
+static __inline__ vector float __ATTRS_o_ai vec_orc(vector float __a,
+vector float __b) {
+  return (vector float)((vector unsigned int)__a | ~(vector unsigned int)__b);
+}
+
 static __inline__ vector signed long long __ATTRS_o_ai
 vec_orc(vector signed long long __a, vector signed long long __b) {
   return __a | ~__b;
@@ -7153,6 +7158,12 @@
 vec_orc(vector bool long long __a, vector double __b) {
   return (vector double)(__a | ~(vector unsigned long long)__b);
 }
+
+static __inline__ vector double __ATTRS_o_ai vec_orc(vector double __a,
+ vector double __b) {
+  return (vector double)((vector bool long long)__a |
+ ~(vector unsigned long long)__b);
+}
 #endif
 
 /* vec_vor */


Index: clang/test/CodeGen/builtins-ppc-p8vector.c
===
--- clang/test/CodeGen/builtins-ppc-p8vector.c
+++ clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -35,7 +35,9 @@
 vector unsigned __int128 vux = { 1 };
 
 vector float vfa = { 1.e-4f, -132.23f, -22.1, 32.00f };
+vector float vfb = { 1.e-4f, -132.23f, -22.1, 32.00f };
 vector double vda = { 1.e-11, -132.23e10 };
+vector double vdb = { 1.e-11, -132.23e10 };
 
 int res_i;
 double res_d;
@@ -1067,6 +1069,12 @@
 // CHECK: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
 // CHECK: or <4 x i32> {{%.+}}, [[T1]]
 // CHECK-LE: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
+// CHECK-LE: or <4 x i32> {{%.+}}, [[T1]]
+
+  res_vf = vec_orc(vfa, vfb);
+// CHECK: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
+// CHECK: or <4 x i32> {{%.+}}, [[T1]]
+// CHECK-LE: [[T1:%.+]] = xor <4 x i32> {{%.+}}, 
 // CHECK-LE: or <4 x i32> {{%.+}}, [[T1]]
 
   res_vsll = vec_orc(vsll, vsll);
@@ -1121,6 +1129,12 @@
 // CHECK: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
 // CHECK: or <2 x i64> {{%.+}}, [[T1]]
 // CHECK-LE: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
+// CHECK-LE: or <2 x i64> {{%.+}}, [[T1]]
+
+  res_vd = vec_orc(vda, vdb);
+// CHECK: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
+// CHECK: or <2 x i64> {{%.+}}, [[T1]]
+// CHECK-LE: [[T1:%.+]] = xor <2 x i64> {{%.+}}, 
 // CHECK-LE: or <2 x i64> {{%.+}}, [[T1]]
 
   /* vec_sub */
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -7109,6 +7109,11 @@
   return (vector float)((vector unsigned int)__a | ~__b);
 }
 
+static __inline__ vector float __ATTRS_o_ai vec_orc(vector float __a,
+vector float __b) {
+  return (vector float)((vector unsigned int)__a | ~(vector unsigned int)__b);
+}
+
 static __inline__ vector signed long long __ATTRS_o_ai
 vec_orc(vector signed long long __a, vector signed long long __b)

[PATCH] D111210: [Analysis][CFG] Fix CFG building for standalone `CaseStmt`s.

2021-10-06 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added reviewers: Szelethus, NoQ.
courbet requested review of this revision.
Herald added a project: clang.

One is supposed ot be able to create a CFG for any statement, as per the
comment on `CFGBuilder::buildCFG`:

"The AST can represent an arbitrary statement.  Examples include a single
expression or a function body (compound statement)"

When building a CFG from a `CaseStmt`, we currently have a crash:

  clang/lib/Analysis/CFG.cpp:4242: clang::CFGBlock *(anonymous
  namespace)::CFGBuilder::VisitCaseStmt(clang::CaseStmt *): Assertion
  `SwitchTerminatedBlock' failed.

Add a unit test to show this, and avoid updating the parent `SwitchStmt`
block when none exists.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111210

Files:
  clang/lib/Analysis/CFG.cpp
  clang/unittests/Analysis/CFGTest.cpp


Index: clang/unittests/Analysis/CFGTest.cpp
===
--- clang/unittests/Analysis/CFGTest.cpp
+++ clang/unittests/Analysis/CFGTest.cpp
@@ -268,6 +268,50 @@
   }
 }
 
+class CFGCallback : public ast_matchers::MatchFinder::MatchCallback {
+public:
+  CFGCallback(std::unique_ptr AST) : AST(std::move(AST)) {}
+
+  std::unique_ptr AST;
+  BuildResult TheBuildResult = BuildResult::ToolRan;
+  CFG::BuildOptions Options;
+
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+const auto *Func = Result.Nodes.getNodeAs("func");
+Stmt *Body = Func->getBody();
+if (!Body)
+  return;
+TheBuildResult = BuildResult::SawFunctionBody;
+Options.AddImplicitDtors = true;
+if (std::unique_ptr Cfg =
+CFG::buildCFG(nullptr, Body, Result.Context, Options))
+  TheBuildResult = {BuildResult::BuiltCFG, Func, std::move(Cfg),
+std::move(AST)};
+  }
+};
+
+// It is valid to create a CFG for a single statement. Creating a CFG for an
+// isolated `CaseStmt` should not crash.`
+TEST(CFG, SwitchCase) {
+  const char *Code = "void f(int i) {\n"
+ "  switch (i) {\n"
+ "case 0:\n"
+ "  return;\n"
+ "  }\n"
+ "}\n";
+  std::vector Args = {"-std=c++11",
+   "-fno-delayed-template-parsing"};
+  std::unique_ptr AST = tooling::buildASTFromCodeWithArgs(Code, Args);
+  ASSERT_NE(AST, nullptr);
+
+  auto Matches = ast_matchers::match(ast_matchers::caseStmt().bind("case"),
+ AST->getASTContext());
+  auto *Case = ast_matchers::selectFirst("case", Matches);
+  std::unique_ptr Cfg =
+  CFG::buildCFG(nullptr, const_cast(Case),
+&AST->getASTContext(), CFG::BuildOptions{});
+}
+
 } // namespace
 } // namespace analysis
 } // namespace clang
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -4215,10 +4215,12 @@
   else
 TopBlock = currentBlock;
 
-  addSuccessor(SwitchTerminatedBlock,
-   shouldAddCase(switchExclusivelyCovered, switchCond,
- CS, *Context)
-   ? currentBlock : nullptr);
+  if (SwitchTerminatedBlock)
+addSuccessor(
+SwitchTerminatedBlock,
+shouldAddCase(switchExclusivelyCovered, switchCond, CS, *Context)
+? currentBlock
+: nullptr);
 
   LastBlock = currentBlock;
   CS = cast(Sub);
@@ -4241,10 +4243,10 @@
 
   // Add this block to the list of successors for the block with the switch
   // statement.
-  assert(SwitchTerminatedBlock);
-  addSuccessor(SwitchTerminatedBlock, CaseBlock,
-   shouldAddCase(switchExclusivelyCovered, switchCond,
- CS, *Context));
+  if (SwitchTerminatedBlock)
+addSuccessor(
+SwitchTerminatedBlock, CaseBlock,
+shouldAddCase(switchExclusivelyCovered, switchCond, CS, *Context));
 
   // We set Block to NULL to allow lazy creation of a new block (if necessary)
   Block = nullptr;


Index: clang/unittests/Analysis/CFGTest.cpp
===
--- clang/unittests/Analysis/CFGTest.cpp
+++ clang/unittests/Analysis/CFGTest.cpp
@@ -268,6 +268,50 @@
   }
 }
 
+class CFGCallback : public ast_matchers::MatchFinder::MatchCallback {
+public:
+  CFGCallback(std::unique_ptr AST) : AST(std::move(AST)) {}
+
+  std::unique_ptr AST;
+  BuildResult TheBuildResult = BuildResult::ToolRan;
+  CFG::BuildOptions Options;
+
+  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
+const auto *Func = Result.Nodes.getNodeAs("func");
+Stmt *Body = Func->getBody();
+if (!Body)
+  return;
+TheBuildResult = BuildResult::SawFunctionBody;
+Options.AddImplicitDtors = true;
+if (std::unique_ptr Cfg =
+CFG::buildCFG(nullptr, B

[PATCH] D111210: [Analysis][CFG] Fix CFG building for standalone `CaseStmt`s.

2021-10-06 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 377457.
courbet added a comment.

remove accidental paste


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111210

Files:
  clang/lib/Analysis/CFG.cpp
  clang/unittests/Analysis/CFGTest.cpp


Index: clang/unittests/Analysis/CFGTest.cpp
===
--- clang/unittests/Analysis/CFGTest.cpp
+++ clang/unittests/Analysis/CFGTest.cpp
@@ -268,6 +268,28 @@
   }
 }
 
+// It is valid to create a CFG for a single statement. Creating a CFG for an
+// isolated `CaseStmt` should not crash.`
+TEST(CFG, SwitchCase) {
+  const char *Code = "void f(int i) {\n"
+ "  switch (i) {\n"
+ "case 0:\n"
+ "  return;\n"
+ "  }\n"
+ "}\n";
+  std::vector Args = {"-std=c++11",
+   "-fno-delayed-template-parsing"};
+  std::unique_ptr AST = tooling::buildASTFromCodeWithArgs(Code, Args);
+  ASSERT_NE(AST, nullptr);
+
+  auto Matches = ast_matchers::match(ast_matchers::caseStmt().bind("case"),
+ AST->getASTContext());
+  auto *Case = ast_matchers::selectFirst("case", Matches);
+  std::unique_ptr Cfg =
+  CFG::buildCFG(nullptr, const_cast(Case),
+&AST->getASTContext(), CFG::BuildOptions{});
+}
+
 } // namespace
 } // namespace analysis
 } // namespace clang
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -4215,10 +4215,12 @@
   else
 TopBlock = currentBlock;
 
-  addSuccessor(SwitchTerminatedBlock,
-   shouldAddCase(switchExclusivelyCovered, switchCond,
- CS, *Context)
-   ? currentBlock : nullptr);
+  if (SwitchTerminatedBlock)
+addSuccessor(
+SwitchTerminatedBlock,
+shouldAddCase(switchExclusivelyCovered, switchCond, CS, *Context)
+? currentBlock
+: nullptr);
 
   LastBlock = currentBlock;
   CS = cast(Sub);
@@ -4241,10 +4243,10 @@
 
   // Add this block to the list of successors for the block with the switch
   // statement.
-  assert(SwitchTerminatedBlock);
-  addSuccessor(SwitchTerminatedBlock, CaseBlock,
-   shouldAddCase(switchExclusivelyCovered, switchCond,
- CS, *Context));
+  if (SwitchTerminatedBlock)
+addSuccessor(
+SwitchTerminatedBlock, CaseBlock,
+shouldAddCase(switchExclusivelyCovered, switchCond, CS, *Context));
 
   // We set Block to NULL to allow lazy creation of a new block (if necessary)
   Block = nullptr;


Index: clang/unittests/Analysis/CFGTest.cpp
===
--- clang/unittests/Analysis/CFGTest.cpp
+++ clang/unittests/Analysis/CFGTest.cpp
@@ -268,6 +268,28 @@
   }
 }
 
+// It is valid to create a CFG for a single statement. Creating a CFG for an
+// isolated `CaseStmt` should not crash.`
+TEST(CFG, SwitchCase) {
+  const char *Code = "void f(int i) {\n"
+ "  switch (i) {\n"
+ "case 0:\n"
+ "  return;\n"
+ "  }\n"
+ "}\n";
+  std::vector Args = {"-std=c++11",
+   "-fno-delayed-template-parsing"};
+  std::unique_ptr AST = tooling::buildASTFromCodeWithArgs(Code, Args);
+  ASSERT_NE(AST, nullptr);
+
+  auto Matches = ast_matchers::match(ast_matchers::caseStmt().bind("case"),
+ AST->getASTContext());
+  auto *Case = ast_matchers::selectFirst("case", Matches);
+  std::unique_ptr Cfg =
+  CFG::buildCFG(nullptr, const_cast(Case),
+&AST->getASTContext(), CFG::BuildOptions{});
+}
+
 } // namespace
 } // namespace analysis
 } // namespace clang
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -4215,10 +4215,12 @@
   else
 TopBlock = currentBlock;
 
-  addSuccessor(SwitchTerminatedBlock,
-   shouldAddCase(switchExclusivelyCovered, switchCond,
- CS, *Context)
-   ? currentBlock : nullptr);
+  if (SwitchTerminatedBlock)
+addSuccessor(
+SwitchTerminatedBlock,
+shouldAddCase(switchExclusivelyCovered, switchCond, CS, *Context)
+? currentBlock
+: nullptr);
 
   LastBlock = currentBlock;
   CS = cast(Sub);
@@ -4241,10 +4243,10 @@
 
   // Add this block to the list of successors for the block with the switch
   // statement.
-  assert(SwitchTerminatedBlock);
-  addSuccessor(SwitchTerminatedBlock, CaseBlock,
-

[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-10-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I stuggle to see that

  if (
  quitelongarg != (alsolongarg - 1)
  )

is correct, I mean 3 lines for a 1 line if seems like this is something 
different,  its like

  auto string = std::string(
  );

This just doesn't seem correct for empty functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Good catch Artem, thanks for the report!

Maybe a single line change could solve this?

  const VarDecl *VD = VR->getDecl()->getCanonicalDecl();




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1663
 // We can trust a const value or a value of a global initializer in main().
 const VarDecl *VD = VR->getDecl();
 if (VD->getType().isConstQualified() ||

const VarDecl *VD = VR->getDecl()->getCanonicalDecl();


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104285

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


[PATCH] D110625: [analyzer] canonicalize special case of structure/pointer deref

2021-10-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.

It looks great.
Thanks Vince!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110625

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


[PATCH] D105690: [RISCV] Rename assembler mnemonic of unordered floating-point reductions for v1.0-rc change

2021-10-06 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

In D105690#3044417 , @HsiangKai wrote:

> I think we could restart to review this patch.

Thanks for bringing it up - I've lost track of the various 1.0 patches.

This one LGTM from what I can tell.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105690

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


[PATCH] D111215: clang release notes: document the -Wbool-operation improvement

2021-10-06 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added reviewers: xbolva00, nathanchance.
sylvestre.ledru requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111215

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -51,7 +51,7 @@
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- -Wbool-operation warns about use of bitwise with boolean operands
 
 Non-comprehensive list of changes in this release
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -51,7 +51,7 @@
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- -Wbool-operation warns about use of bitwise with boolean operands
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-10-06 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

It found a few issues on Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=1734285

I think it should be added it in the release notes:
 https://reviews.llvm.org/D111215


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108003

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


[PATCH] D111215: clang release notes: document the -Wbool-operation improvement

2021-10-06 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:54
 
-- ...
+- -Wbool-operation warns about use of bitwise with boolean operands
 

-Wbitwise-instead-of-logical (part of -Wbool-operation) warns … 


?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111215

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


[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-10-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Basic/Targets/SPIR.h:59
+// translation). This mapping is enabled when the language mode is HIP.
+1, // cuda_device
+// cuda_constant pointer can be casted to default/"flat" pointer, but in

bader wrote:
> Anastasia wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > bader wrote:
> > > > > Anastasia wrote:
> > > > > > linjamaki wrote:
> > > > > > > bader wrote:
> > > > > > > > keryell wrote:
> > > > > > > > > Anastasia wrote:
> > > > > > > > > > bader wrote:
> > > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > > I am slightly confused as in the LLVM project those 
> > > > > > > > > > > > address spaces are for SPIR not SPIR-V though. It is 
> > > > > > > > > > > > however used outside of LLVM project by some tools like 
> > > > > > > > > > > > SPIRV-LLVM Translator as a path to SPIR-V, but it has 
> > > > > > > > > > > > only been done as a workaround since we had no SPIR-V 
> > > > > > > > > > > > support in the LLVM project yet. And if we are adding 
> > > > > > > > > > > > it let's do it clean to avoid/resolve any confusion.
> > > > > > > > > > > > 
> > > > > > > > > > > > I think we need to keep both because some vendors do 
> > > > > > > > > > > > target/use SPIR but not SPIR-V.
> > > > > > > > > > > > 
> > > > > > > > > > > > So if you are interested in SPIR-V and not SPIR you 
> > > > > > > > > > > > should probably add a new target that will make things 
> > > > > > > > > > > > cleaner.
> > > > > > > > > > > > I think we need to keep both because some vendors do 
> > > > > > > > > > > > target/use SPIR but not SPIR-V.
> > > > > > > > > > > 
> > > > > > > > > > > @Anastasia, could you elaborate more on the difference 
> > > > > > > > > > > between SPIR and SPIR-V?
> > > > > > > > > > > I would like to understand what these terms mean in the 
> > > > > > > > > > > context of LLVM project.
> > > > > > > > > > Their conceptual differences are just that they are two 
> > > > > > > > > > different intermediate formats.
> > > > > > > > > > 
> > > > > > > > > > The important thing to highlight is that it is not 
> > > > > > > > > > impossible that some vendors use SPIR (without using 
> > > > > > > > > > SPIR-V) even despite the fact it has been discontinued by 
> > > > > > > > > > Khronos. 
> > > > > > > > > > 
> > > > > > > > > > Nobody has deprecated or discontinued SPIR in the LLVM 
> > > > > > > > > > project yet.
> > > > > > > > > > Their conceptual differences are just that they are two 
> > > > > > > > > > different intermediate formats.
> > > > > > > > > > 
> > > > > > > > > > The important thing to highlight is that it is not 
> > > > > > > > > > impossible that some vendors use SPIR (without using 
> > > > > > > > > > SPIR-V) even despite the fact it has been discontinued by 
> > > > > > > > > > Khronos. 
> > > > > > > > > > 
> > > > > > > > > > Nobody has deprecated or discontinued SPIR in the LLVM 
> > > > > > > > > > project yet.
> > > > > > > > > 
> > > > > > > > > All the official Xilinx OpenCL stack is based on legacy SPIR 
> > > > > > > > > (encoded in LLVM 6.x IR but this is another story) and I 
> > > > > > > > > suspect this is the case for other companies.
> > > > > > > > > So, do not deprecate or discontinue, please. :-)
> > > > > > > > > The important thing to highlight is that it is not impossible 
> > > > > > > > > that some vendors use SPIR (without using SPIR-V) even 
> > > > > > > > > despite the fact it has been discontinued by Khronos.
> > > > > > > > > Nobody has deprecated or discontinued SPIR in the LLVM 
> > > > > > > > > project yet.
> > > > > > > > 
> > > > > > > > Strictly speaking `SPIR` is not defined as an intermediate 
> > > > > > > > language. Khronos defines `SPIR-1.2` and `SPIR-2.0` formats 
> > > > > > > > which are based on LLVM 3.2 and LLVM 3.4 version 
> > > > > > > > (https://www.khronos.org/spir/). There is no definition of SPIR 
> > > > > > > > format based on current version of LLVM IR. Another note is 
> > > > > > > > that metadata and intrinsics emitted for OpenCL with clang-14 
> > > > > > > > doesn't follow neither `SPIR-1.2` nor `SPIR-2.0`.
> > > > > > > > 
> > > > > > > > I always think of LLVM IR as leaving thing that is subject to 
> > > > > > > > change by LLVM community, so tools working with LLVM IR must 
> > > > > > > > adjust to the particular version (e.g. release version like 
> > > > > > > > LLVM 13 or ToT). We apply this logic to SPIRV-LLVM-Translator 
> > > > > > > > tool and update it according to LLVM format changes (e.g. 
> > > > > > > > kernel argument information defined in Khronos spec must be 
> > > > > > > > named metadata whereas clang emits function metadata).
> > > > > > > > 
> > > > > > > > > I am slightly confused as in the LLVM project those address 
> > > > > > > > > spaces are for SPIR not SPIR-V though.
> > > > > > > > [skip]
> > > > > > > > > Their conceptual differences are just that they are two 
> > > > >

[PATCH] D110911: [analyzer][NFC] Add RangeSet::dump

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 377482.
martong added a comment.

- Rebase
- Mark the dump methods with LLVM_DUMP_METHOD
- Add Range::dump


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110911

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -494,15 +494,17 @@
   return intersect(From, Upper, Lower);
 }
 
-void Range::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void Range::dump(raw_ostream &OS) const {
   OS << '[' << toString(From(), 10) << ", " << toString(To(), 10) << ']';
 }
+LLVM_DUMP_METHOD void Range::dump() const { dump(llvm::errs()); }
 
-void RangeSet::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void RangeSet::dump(raw_ostream &OS) const {
   OS << "{ ";
   llvm::interleaveComma(*this, OS, [&OS](const Range &R) { R.dump(OS); });
   OS << " }";
 }
+LLVM_DUMP_METHOD void RangeSet::dump() const { dump(llvm::errs()); }
 
 REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(SymbolSet, SymbolRef)
 
Index: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -48,6 +48,7 @@
 ID.AddPointer(&To());
   }
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   // In order to keep non-overlapping ranges sorted, we can compare only From
   // points.
@@ -282,6 +283,7 @@
   bool contains(llvm::APSInt Point) const { return containsImpl(Point); }
 
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   bool operator==(const RangeSet &Other) const { return *Impl == *Other.Impl; }
   bool operator!=(const RangeSet &Other) const { return !(*this == Other); }


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -494,15 +494,17 @@
   return intersect(From, Upper, Lower);
 }
 
-void Range::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void Range::dump(raw_ostream &OS) const {
   OS << '[' << toString(From(), 10) << ", " << toString(To(), 10) << ']';
 }
+LLVM_DUMP_METHOD void Range::dump() const { dump(llvm::errs()); }
 
-void RangeSet::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void RangeSet::dump(raw_ostream &OS) const {
   OS << "{ ";
   llvm::interleaveComma(*this, OS, [&OS](const Range &R) { R.dump(OS); });
   OS << " }";
 }
+LLVM_DUMP_METHOD void RangeSet::dump() const { dump(llvm::errs()); }
 
 REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(SymbolSet, SymbolRef)
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -48,6 +48,7 @@
 ID.AddPointer(&To());
   }
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   // In order to keep non-overlapping ranges sorted, we can compare only From
   // points.
@@ -282,6 +283,7 @@
   bool contains(llvm::APSInt Point) const { return containsImpl(Point); }
 
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   bool operator==(const RangeSet &Other) const { return *Impl == *Other.Impl; }
   bool operator!=(const RangeSet &Other) const { return !(*this == Other); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-10-06 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D108003#3044853 , @sylvestre.ledru 
wrote:

> It found a few issues on Firefox:
> https://bugzilla.mozilla.org/show_bug.cgi?id=1734285
>
> I think it should be added it in the release notes:
>  https://reviews.llvm.org/D111215

Thanks, all found cases are not “security/memory” issues but they should use 
logical op to improve code readability (no reason for bitwise op).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108003

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


[PATCH] D110618: [HIPSPV][2/4] Add HIPSPV tool chain

2021-10-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D110618#3039275 , @linjamaki wrote:

> In D110618#3032899 , @Anastasia 
> wrote:
>
>> Considering that SPIR-V translation step is also required for other 
>> languages would it make sense to add `llvm-spirv` as a common tool like for 
>> example C/C++ linkers and create a bit of common infrastructure? It might be 
>> something we can do as a separate step too but it would be good to make sure 
>> nothing prevents us from doing this in the future... We should probably also 
>> think about the command line interface unification as it probably doesn't 
>> make sense for every language to add their own flags for locating SPIR-V 
>> translator.
>
> I don’t think it would work out well. llvm-spirv (or other tool relying on 
> LLVM bitcode input) and LLVM may have version differences that cause obscure 
> error cases - like newer LLVM producing bitcode with new features the tools 
> are not expecting and ready for them. The usage of llvm-spirv tool in the 
> HIPSPV tool chain is not intended to be a longer term solution due to this 
> shortcoming.

I don't feel it is different for OpenCL though... I am not in favour of 
repeating the same functionality for every language since the requirement will 
be likely identical. There is no timeline for when this functionality will be 
dropped so we have to assume that even though temporary it might be a solution 
for long enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110618

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


[PATCH] D111215: clang release notes: document the -Wbool-operation improvement

2021-10-06 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 377483.
sylvestre.ledru added a comment.

Take in account the comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111215

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -51,7 +51,7 @@
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- -Wbitwise-instead-of-logical (part of -Wbool-operation) warns about use of 
bitwise with boolean operands
 
 Non-comprehensive list of changes in this release
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -51,7 +51,7 @@
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- -Wbitwise-instead-of-logical (part of -Wbool-operation) warns about use of bitwise with boolean operands
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94472: [clang][cli] Command line round-trip for HeaderSearch options

2021-10-06 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:677
+  SwapOpts(Res);
+  bool Success2 = Parse(Res, GeneratedArgs1, Diags);
+

saudi wrote:
> Hello,
> 
> I encountered crashes on Windows targets, related to this line, when rebasing 
> https://reviews.llvm.org/D80833, where `CodeGenOpts::CommandLineArgs` is read 
> later in the compilation process.
> 
> When the function exits, `GeneratedArgs1` is destroyed but 
> `Res.getCodeGenOpts().CommandLineArgs` still references its contents. The 
> code has changed since this patch was submitted, but the logic remains the 
> same in more recent code.
> 
> Note that the bug doesn't happen when round-trip is skipped, as 
> `CommandLineArgs` then refers to `ArgV` which content is valid for the entire 
> compiler run.
> 
> As a solution I considered allowing `CodeGenOptions` to optionally own the 
> memory by introducing `BumpPtrAllocator CodeGenOptions::CommandLineArgsAlloc`.
>  However it has drawbacks:
>  - need to customize `CodeGenOptions` copy constructor/operator,
>  - lifetime for copies of `CodeGenOptions::CommandLineArgs` (e.g. to other 
> structures) would be bound to the lifetime of the original `CodeGenOptions` 
> object.
>  
> Another solution (slower) would be to use 2 dummy `CompilerInvocation` to 
> perform the round-trip test, and use the regular arguments on the main 
> instance. It would change the behavior since the main instance currently uses 
> `GeneratedArgs1`.
> 
> WDYT?
> Hello,
> 
> I encountered crashes on Windows targets, related to this line, when rebasing 
> https://reviews.llvm.org/D80833, where `CodeGenOpts::CommandLineArgs` is read 
> later in the compilation process.
> 
> When the function exits, `GeneratedArgs1` is destroyed but 
> `Res.getCodeGenOpts().CommandLineArgs` still references its contents. The 
> code has changed since this patch was submitted, but the logic remains the 
> same in more recent code.
> 
> Note that the bug doesn't happen when round-trip is skipped, as 
> `CommandLineArgs` then refers to `ArgV` which content is valid for the entire 
> compiler run.

Hi, you're right, I can see the lifetime issues here.

> As a solution I considered allowing `CodeGenOptions` to optionally own the 
> memory by introducing `BumpPtrAllocator CodeGenOptions::CommandLineArgsAlloc`.
>  However it has drawbacks:
>  - need to customize `CodeGenOptions` copy constructor/operator,
>  - lifetime for copies of `CodeGenOptions::CommandLineArgs` (e.g. to other 
> structures) would be bound to the lifetime of the original `CodeGenOptions` 
> object.

Instead of introducing `BumpPtrAllocator` in `CodeGenOptions` and dealing with 
custom copy constructor/assignment, I think it should be possible to use an 
owning type (e.g. `std::vector>`), WDYT? That's the approach we 
generally take in `CompilerInvocation` members.

> Another solution (slower) would be to use 2 dummy `CompilerInvocation` to 
> perform the round-trip test, and use the regular arguments on the main 
> instance. It would change the behavior since the main instance currently uses 
> `GeneratedArgs1`.

Referring to `ArgV` instead of `GeneratedArgs1` should be fine too, since they 
are guaranteed to be semantically equivalent anyways.

> WDYT?

I think both approaches are valid, but I think the cleanest solution would be 
to drop `CodeGenOptions::CommandLineArgs` entirely. It's one of the few cases 
where `CompilerInvocation` points to memory owned by someone else. (I thought 
this only happens in `PreprocessorOptions::RemappedFileBuffers`, but I stand 
corrected.) Whenever clients need the original command-line, they can call 
`CompilerInvocation::generateCC1CommandLine` and get semantically equivalent 
list of cc1 arguments. Would that work for you use-case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D111215: clang release notes: document the -Wbool-operation improvement

2021-10-06 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 accepted this revision.
xbolva00 added a comment.
This revision is now accepted and ready to land.

One small comment about side effects, otherwise LG.

Please wait a +-day for potentional review comments.




Comment at: clang/docs/ReleaseNotes.rst:54
 
-- ...
+- -Wbitwise-instead-of-logical (part of -Wbool-operation) warns about use of 
bitwise with boolean operands
 

I think we should mention that with boolean operands which have side effects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111215

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


[PATCH] D111215: clang release notes: document the -Wbool-operation improvement

2021-10-06 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@xbolva00 sorry but you would like

-Wbitwise-instead-of-logical (part of -Wbool-operation) warns about use of 
bitwise with boolean operands which have side effects

or 
-Wbitwise-instead-of-logical (part of -Wbool-operation) warns about use of 
bitwise with boolean operands
Be aware that boolean operands might have side effects.

?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111215

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


[PATCH] D111215: clang release notes: document the -Wbool-operation improvement

2021-10-06 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

First form is better I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111215

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


[PATCH] D111215: clang release notes: document the -Wbool-operation improvement

2021-10-06 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 377486.
sylvestre.ledru added a comment.

add "which have side effects"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111215

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -51,7 +51,7 @@
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- -Wbitwise-instead-of-logical (part of -Wbool-operation) warns about use of 
bitwise with boolean operands which have side effects.
 
 Non-comprehensive list of changes in this release
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -51,7 +51,7 @@
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- -Wbitwise-instead-of-logical (part of -Wbool-operation) warns about use of bitwise with boolean operands which have side effects.
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b29186c - [analyzer] canonicalize special case of structure/pointer deref

2021-10-06 Thread via cfe-commits

Author: Vince Bridgers
Date: 2021-10-06T05:18:27-05:00
New Revision: b29186c08ae230d0decbca67565be68919c6b24d

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

LOG: [analyzer] canonicalize special case of structure/pointer deref

This simple change addresses a special case of structure/pointer
aliasing that produced different symbolvals, leading to false positives
during analysis.

The reproducer is as simple as this.

```lang=C++
struct s {
  int v;
};

void foo(struct s *ps) {
  struct s ss = *ps;
  clang_analyzer_dump(ss.v); // reg_$1},0 S64b,struct s}.v>
  clang_analyzer_dump(ps->v); //reg_$3}.v>
  clang_analyzer_eval(ss.v == ps->v); // UNKNOWN
}
```

Acks: Many thanks to @steakhal and @martong for the group debug session.

Reviewed By: steakhal, martong

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/Store.cpp
clang/test/Analysis/ptr-arith.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/Store.cpp 
b/clang/lib/StaticAnalyzer/Core/Store.cpp
index b867b0746f90f..f7f0b6c71abf5 100644
--- a/clang/lib/StaticAnalyzer/Core/Store.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -442,6 +442,19 @@ SVal StoreManager::getLValueIvar(const ObjCIvarDecl *decl, 
SVal base) {
 
 SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset,
 SVal Base) {
+
+  // Special case, if index is 0, return the same type as if
+  // this was not an array dereference.
+  if (Offset.isZeroConstant()) {
+QualType BT = Base.getType(this->Ctx);
+if (!BT.isNull() && !elementType.isNull()) {
+  QualType PointeeTy = BT->getPointeeType();
+  if (!PointeeTy.isNull() &&
+  PointeeTy.getCanonicalType() == elementType.getCanonicalType())
+return Base;
+}
+  }
+
   // If the base is an unknown or undefined value, just return it back.
   // FIXME: For absolute pointer addresses, we just return that value back as
   //  well, although in reality we should return the offset added to that

diff  --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c
index c0798f94504ed..54347d3bd3748 100644
--- a/clang/test/Analysis/ptr-arith.c
+++ b/clang/test/Analysis/ptr-arith.c
@@ -2,6 +2,7 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,debug.ExprInspection
 -analyzer-store=region -Wno-pointer-to-int-cast -verify -triple 
i686-apple-darwin9 -Wno-tautological-pointer-compare -analyzer-config 
eagerly-assume=false %s
 
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
 
 void f1() {
   int a[10];
@@ -330,3 +331,59 @@ float test_nowarning_on_vector_deref() {
   simd_float2 x = {0, 1};
   return x[1]; // no-warning
 }
+
+struct s {
+  int v;
+};
+
+// These three expressions should produce the same sym vals.
+void struct_pointer_canon(struct s *ps) {
+  struct s ss = *ps;
+  clang_analyzer_dump((*ps).v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps[0].v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps->v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang_analyzer_eval((*ps).v == ps->v);   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ps[0].v == ps->v);   // expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_bidim(struct s **ps) {
+  struct s ss = **ps;
+  clang_analyzer_eval(&(ps[0][0].v) == &((*ps)->v)); // 
expected-warning{{TRUE}}
+}
+
+typedef struct s T1;
+typedef struct s T2;
+void struct_pointer_canon_typedef(T1 *ps) {
+  T2 ss = *ps;
+  clang_analyzer_dump((*ps).v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps[0].v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps->v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang_analyzer_eval((*ps).v == ps->v);   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ps[0].v == ps->v);   // expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_bidim_typedef(T1 **ps) {
+  T2 ss = **ps;
+  clang_analyzer_eval(&(ps[0][0].v) == &((*ps)->v)); // 
expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_const(const struct s *ps) {
+  struct s ss = *ps;
+  clang_analyzer_dump((*ps).v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps[0].v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps->v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang

[PATCH] D110625: [analyzer] canonicalize special case of structure/pointer deref

2021-10-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb29186c08ae2: [analyzer] canonicalize special case of 
structure/pointer deref (authored by vabridgers, committed by einvbri 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110625

Files:
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/ptr-arith.c


Index: clang/test/Analysis/ptr-arith.c
===
--- clang/test/Analysis/ptr-arith.c
+++ clang/test/Analysis/ptr-arith.c
@@ -2,6 +2,7 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,debug.ExprInspection
 -analyzer-store=region -Wno-pointer-to-int-cast -verify -triple 
i686-apple-darwin9 -Wno-tautological-pointer-compare -analyzer-config 
eagerly-assume=false %s
 
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
 
 void f1() {
   int a[10];
@@ -330,3 +331,59 @@
   simd_float2 x = {0, 1};
   return x[1]; // no-warning
 }
+
+struct s {
+  int v;
+};
+
+// These three expressions should produce the same sym vals.
+void struct_pointer_canon(struct s *ps) {
+  struct s ss = *ps;
+  clang_analyzer_dump((*ps).v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps[0].v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps->v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang_analyzer_eval((*ps).v == ps->v);   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ps[0].v == ps->v);   // expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_bidim(struct s **ps) {
+  struct s ss = **ps;
+  clang_analyzer_eval(&(ps[0][0].v) == &((*ps)->v)); // 
expected-warning{{TRUE}}
+}
+
+typedef struct s T1;
+typedef struct s T2;
+void struct_pointer_canon_typedef(T1 *ps) {
+  T2 ss = *ps;
+  clang_analyzer_dump((*ps).v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps[0].v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps->v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang_analyzer_eval((*ps).v == ps->v);   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ps[0].v == ps->v);   // expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_bidim_typedef(T1 **ps) {
+  T2 ss = **ps;
+  clang_analyzer_eval(&(ps[0][0].v) == &((*ps)->v)); // 
expected-warning{{TRUE}}
+}
+
+void struct_pointer_canon_const(const struct s *ps) {
+  struct s ss = *ps;
+  clang_analyzer_dump((*ps).v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps[0].v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_dump(ps->v);
+  // expected-warning-re@-1{{reg_${{[[:digit:]]+}}}.v>}}
+  clang_analyzer_eval((*ps).v == ps[0].v); // expected-warning{{TRUE}}
+  clang_analyzer_eval((*ps).v == ps->v);   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ps[0].v == ps->v);   // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -442,6 +442,19 @@
 
 SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset,
 SVal Base) {
+
+  // Special case, if index is 0, return the same type as if
+  // this was not an array dereference.
+  if (Offset.isZeroConstant()) {
+QualType BT = Base.getType(this->Ctx);
+if (!BT.isNull() && !elementType.isNull()) {
+  QualType PointeeTy = BT->getPointeeType();
+  if (!PointeeTy.isNull() &&
+  PointeeTy.getCanonicalType() == elementType.getCanonicalType())
+return Base;
+}
+  }
+
   // If the base is an unknown or undefined value, just return it back.
   // FIXME: For absolute pointer addresses, we just return that value back as
   //  well, although in reality we should return the offset added to that


Index: clang/test/Analysis/ptr-arith.c
===
--- clang/test/Analysis/ptr-arith.c
+++ clang/test/Analysis/ptr-arith.c
@@ -2,6 +2,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,debug.ExprInspection -analyzer-store=region -Wno-pointer-to-int-cast -verify -triple i686-apple-darwin9 -Wno-tautological-pointer-compare -analyzer-config eagerly-assume=false %s
 
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
 
 void f1() {
   int a[10];
@@ -330,3 +331,59 @@
   simd_float2 x = {0, 1};
   return x[1]; // no-warning
 }
+
+struct s {
+  int v;
+};
+
+// These three expr

[PATCH] D111218: [AMDGPU][OpenMP] Mark oulined functions always_inline

2021-10-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal created this revision.
pdhaliwal added reviewers: JonChesterfield, jdoerfert, jhuber6, ggeorgakoudis.
Herald added subscribers: guansong, t-tye, tpr, dstuttard, yaxunl, kzhuravl.
pdhaliwal requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

This depends on D102107  and unblocks the 
failing amdgcn runtime
tests in the latter.

>From what I understand is that amd-stg-open is working because
everything is marked inline in an internal pass which main branch
currently does not have. Marking the outlined functions as
always_inline does fix the issue, however, proper fixes to the
backend are still required. Until then, this will work. I have also
added TODO on top of the added code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111218

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -503,6 +503,13 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // TODO: should not need this once amdgcn handles function calls properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+F->removeFnAttr(llvm::Attribute::NoInline);
+F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, Loc, Loc);
   Address ContextAddr = CGF.GetAddrOfLocalVar(CD->getContextParam());
@@ -664,9 +671,14 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
-  // Always inline the outlined function if optimizations are enabled.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+  // Always inline the outlined function if optimizations are enabled or 
current
+  // target is amdgcn.
+  // TODO: amdgcn check should be removed once it handles function calls 
properly.
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0 || 
CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::NoInline);
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
 F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
 
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -503,6 +503,13 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // TODO: should not need this once amdgcn handles function calls properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+F->removeFnAttr(llvm::Attribute::NoInline);
+F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, Loc, Loc);
   Address ContextAddr = CGF.GetAddrOfLocalVar(CD->getContextParam());
@@ -664,9 +671,14 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
-  // Always inline the outlined function if optimizations are enabled.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+  // Always inline the outlined function if optimizations are enabled or current
+  // target is amdgcn.
+  // TODO: amdgcn check should be removed once it handles function calls properly.
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0 || CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::NoInline);
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
 F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
 
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111190: Comment parsing: Complete list of Doxygen commands

2021-10-06 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 377492.
aaronpuchert added a comment.

Also support `\ifnot` but give up on treating `\if`/`\endif` as 
`VerbatimBlockCommand`. That's not meaningful anyway if we don't understand 
`\else` or `\endif`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90

Files:
  clang/include/clang/AST/CommentCommands.td
  clang/lib/AST/CommentLexer.cpp
  clang/test/AST/ast-dump-comment.cpp
  clang/test/Index/comment-lots-of-unknown-commands.c
  clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp

Index: clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
===
--- clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
+++ clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
@@ -83,6 +83,12 @@
 default:
   Mangled += Str[i];
   break;
+case '(':
+  Mangled += "lparen";
+  break;
+case ')':
+  Mangled += "rparen";
+  break;
 case '[':
   Mangled += "lsquare";
   break;
Index: clang/test/Index/comment-lots-of-unknown-commands.c
===
--- clang/test/Index/comment-lots-of-unknown-commands.c
+++ clang/test/Index/comment-lots-of-unknown-commands.c
@@ -39,7 +39,7 @@
 @ien
 @fr
 @en
-@tet
+@teq
 @le
 @L
 @os
@@ -77,7 +77,7 @@
 @rU
 @ar
 @eD
-@iE
+@iEx
 @se
 @st1
 @rr
@@ -106,7 +106,7 @@
 @hd
 @be
 @It
-@id
+@idz
 @cm
 @ua
 @fs
@@ -114,7 +114,7 @@
 @axn
 @rt
 @to
-@is
+@isj
 @fo
 @i
 @an
@@ -185,7 +185,7 @@
 // CHECK: (CXComment_InlineCommand CommandName=[ien] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[fr] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[en] RenderNormal HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[tet] RenderNormal HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[teq] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[le] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[L] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[os] RenderNormal HasTrailingNewline)
@@ -223,7 +223,7 @@
 // CHECK: (CXComment_InlineCommand CommandName=[rU] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ar] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[eD] RenderNormal HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[iE] RenderNormal HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[iEx] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[se] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[st1] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[rr] RenderNormal HasTrailingNewline)
@@ -252,7 +252,7 @@
 // CHECK: (CXComment_InlineCommand CommandName=[hd] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[be] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[It] RenderNormal HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[id] RenderNormal HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[idz] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[cm] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[ua] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[fs] RenderNormal HasTrailingNewline)
@@ -260,7 +260,7 @@
 // CHECK: (CXComment_InlineCommand CommandName=[axn] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[rt] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[to] RenderNormal HasTrailingNewline)
-// CHECK: (CXComment_InlineCommand CommandName=[is] RenderNormal HasTrailingNewline)
+// CHECK: (CXComment_InlineCommand CommandName=[isj] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[fo] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[i] RenderNormal HasTrailingNewline)
 // CHECK: (CXComment_InlineCommand CommandName=[an] RenderNormal HasTrailingNewline)
Index: clang/test/AST/ast-dump-comment.cpp
===
--- clang/test/AST/ast-dump-comment.cpp
+++ clang/test/AST/ast-dump-comment.cpp
@@ -76,10 +76,22 @@
 /// \verbatim
 /// Aaa
 /// \endverbatim
+/// \f$ a \f$
+/// \f( b \f)
+/// \f[ c \f]
+/// \f

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-10-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

I have created a patch (D111218 ) with fix 
for amdgcn. This is a temporary fix. I will still keep on looking into it until 
I find a real root cause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D111218: [AMDGPU][OpenMP] Mark oulined functions always_inline

2021-10-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield edited reviewers, added: tianshilei1992, ye-luo, grokos; 
removed: ggeorgakoudis.
JonChesterfield added a comment.

Not pretty but unblocking D102107  is 
important. Could you write up your current understanding of what we're 
miscompiling for function calls as a comment to this patch? I'm guessing it's 
still attribute related but am a few days out of date.

I won't tag it as accepted because it's taking on debt in clang openmp to work 
around a bug in amdgpu middle/back end and I have a conflict of interest there. 
Hopefully an external person will accept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111218

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


[clang] b9b90bb - [clang] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine)

2021-10-06 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-10-06T11:43:19+01:00
New Revision: b9b90bb5426ffc23cf90f133a90d1469d263522c

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

LOG: [clang] Replace report_fatal_error(std::string) uses with 
report_fatal_error(Twine)

As described on D111049, we're trying to remove the  dependency from 
error handling and replace uses of report_fatal_error(const std::string&) with 
the Twine() variant which can be forward declared.

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
clang/include/clang/Serialization/ASTRecordReader.h
clang/lib/Basic/ProfileList.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Tooling/CommonOptionsParser.cpp

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
index b8ee9972f6f86..c0459cc80ca4c 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -141,7 +141,7 @@ runCheckOnCode(StringRef Code, std::vector 
*Errors = nullptr,
 for (const auto &Error : DiagConsumer.take()) {
   ErrorText += Error.Message.Message + "\n";
 }
-llvm::report_fatal_error(ErrorText);
+llvm::report_fatal_error(llvm::Twine(ErrorText));
   }
 
   tooling::Replacements Fixes;

diff  --git a/clang/include/clang/Serialization/ASTRecordReader.h 
b/clang/include/clang/Serialization/ASTRecordReader.h
index b85609bf4e05b..36179ec23408f 100644
--- a/clang/include/clang/Serialization/ASTRecordReader.h
+++ b/clang/include/clang/Serialization/ASTRecordReader.h
@@ -350,7 +350,7 @@ struct SavedStreamPosition {
   ~SavedStreamPosition() {
 if (llvm::Error Err = Cursor.JumpToBit(Offset))
   llvm::report_fatal_error(
-  "Cursor should always be able to go back, failed: " +
+  llvm::Twine("Cursor should always be able to go back, failed: ") +
   toString(std::move(Err)));
   }
 

diff  --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 2cb05c1c3c073..9c88559d1c333 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -58,7 +58,7 @@ ProfileSpecialCaseList::createOrDie(const 
std::vector &Paths,
   std::string Error;
   if (auto PSCL = create(Paths, VFS, Error))
 return PSCL;
-  llvm::report_fatal_error(Error);
+  llvm::report_fatal_error(llvm::Twine(Error));
 }
 
 }

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 1adf0ad9c0e5b..acfda02826672 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -264,7 +264,7 @@ class PCHContainerGenerator : public ASTConsumer {
 std::string Error;
 auto Triple = Ctx.getTargetInfo().getTriple();
 if (!llvm::TargetRegistry::lookupTarget(Triple.getTriple(), Error))
-  llvm::report_fatal_error(Error);
+  llvm::report_fatal_error(llvm::Twine(Error));
 
 // Emit the serialized Clang AST into its own section.
 assert(Buffer->IsComplete && "serialization did not complete");

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 97db833d41ca6..d011d14612d13 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3851,7 +3851,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
   Expected MaybeDeclCode = Record.readRecord(DeclsCursor, Code);
   if (!MaybeDeclCode)
 llvm::report_fatal_error(
-"ASTReader::readDeclRecord failed reading decl code: " +
+Twine("ASTReader::readDeclRecord failed reading decl code: ") +
 toString(MaybeDeclCode.takeError()));
   switch ((DeclCode)MaybeDeclCode.get()) {
   case DECL_CONTEXT_LEXICAL:
@@ -4236,12 +4236,12 @@ void 
ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
   if (llvm::Error JumpFailed = Cursor.JumpToBit(Offset))
 // FIXME don't do a fatal error.
 llvm::report_fatal_error(
-"ASTReader::loadDeclUpdateRecords failed jumping: " +
+Twine("ASTReader::loadDeclUpdateRecords failed jumping: ") +
 toString(std::move(JumpFailed)));
   Expected MaybeCode = Cursor.ReadCode();
   if (!MaybeCode)
 llvm::report_fatal_error(
-"ASTReader::loadDeclUpdateRecords failed reading code: " +
+Twine("ASTReader::loadDeclUpdateRecords failed reading code: ") +
 toString(MaybeCode.takeError()));
   unsigned Code = MaybeCode.get();
   ASTRecordReader Record(*this, *F);
@@ -4250,7 +4250,7 @@ void ASTReader::loa

[PATCH] D110685: [HIPSPV][4/4] Add option to use llc to emit SPIR-V

2021-10-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.
Herald added a subscriber: ormris.

Ok, is the idea to deprecate this flag once we switch to `llc` by default then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110685

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


[PATCH] D110913: [analyzer][solver] Handle simplification to ConcreteInt

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 377495.
martong marked 2 inline comments as done.
martong added a comment.

- Add better comments to `simplify` functions
- Add a new check and explanation to the test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110913

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/solver-sym-simplification-concreteint.c

Index: clang/test/Analysis/solver-sym-simplification-concreteint.c
===
--- /dev/null
+++ clang/test/Analysis/solver-sym-simplification-concreteint.c
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_warnIfReached();
+void clang_analyzer_eval();
+
+void test_simplification_to_concrete_int(int b, int c) {
+  if (b < 0 || b > 1) // b: [0,1]
+return;
+  if (c < 0 || c > 1) // c: [0,1]
+return;
+  if (c + b != 0) // c + b == 0
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (b != 1) // b == 1  --> c + 1 == 0
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+
+  // After the simplification with b==1 we have a constraint
+  // c+1==0 but we do not reorder this equality to c==-1. Besides we have another
+  // constraint that we inherited from a previous State, this is c: [0, 1]
+  // Now, when we query c==-1 then the latter constraint is found, thus
+  // resulting in an infeasible state
+  clang_analyzer_eval(c == -1);   // expected-warning{{FALSE}}
+
+  // c == 0 --> 0 + 1 == 0 contradiction
+  clang_analyzer_eval(c == 0);// expected-warning{{FALSE}}
+
+  // c == 1 --> 1 + 1 == 0 contradiction
+  clang_analyzer_eval(c != 0);// expected-warning{{FALSE}}
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
Index: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -226,9 +226,13 @@
   }
 }
 
-SymbolRef simplify(ProgramStateRef State, SymbolRef Sym) {
+SVal simplifyToSVal(ProgramStateRef State, SymbolRef Sym) {
   SValBuilder &SVB = State->getStateManager().getSValBuilder();
-  SVal SimplifiedVal = SVB.simplifySVal(State, SVB.makeSymbolVal(Sym));
+  return SVB.simplifySVal(State, SVB.makeSymbolVal(Sym));
+}
+
+SymbolRef simplify(ProgramStateRef State, SymbolRef Sym) {
+  SVal SimplifiedVal = simplifyToSVal(State, Sym);
   if (SymbolRef SimplifiedSym = SimplifiedVal.getAsSymbol())
 return SimplifiedSym;
   return Sym;
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2096,7 +2096,19 @@
ProgramStateRef State, EquivalenceClass Class) {
   SymbolSet ClassMembers = Class.getClassMembers(State);
   for (const SymbolRef &MemberSym : ClassMembers) {
-SymbolRef SimplifiedMemberSym = ento::simplify(State, MemberSym);
+
+SymbolRef SimplifiedMemberSym = nullptr;
+SVal SimplifiedMemberVal = simplifyToSVal(State, MemberSym);
+if (const auto CI = SimplifiedMemberVal.getAs()) {
+  const llvm::APSInt &SV = CI->getValue();
+  const RangeSet *ClassConstraint = getConstraint(State, Class);
+  // We have found a contradiction.
+  if (ClassConstraint && !ClassConstraint->contains(SV))
+return nullptr;
+} else {
+  SimplifiedMemberSym = SimplifiedMemberVal.getAsSymbol();
+}
+
 if (SimplifiedMemberSym && MemberSym != SimplifiedMemberSym) {
   // The simplified symbol should be the member of the original Class,
   // however, it might be in another existing class at the moment. We
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -387,11 +387,19 @@
   static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment);
 };
 
-/// Try to simplify a given symbolic expression's associated value based on the
-/// constraints in State. This is needed because the Environment bindings are
-/// not getting updated when a new constraint is added to the State.
+/// Try to simplify a given symbolic 

[PATCH] D110913: [analyzer][solver] Handle simplification to ConcreteInt

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:390-396
 /// Try to simplify a given symbolic expression's associated value based on the
 /// constraints in State. This is needed because the Environment bindings are
 /// not getting updated when a new constraint is added to the State.
+SVal simplifyToSVal(ProgramStateRef State, SymbolRef Sym);
+/// If the symbol is simplified to a constant then it returns the original
+/// symbol.
 SymbolRef simplify(ProgramStateRef State, SymbolRef Sym);

steakhal wrote:
> I'm confused about which comment corresponds to which function.
> You should also signify the difference between the two APIs.
> 
> Shouldn't be one of them an implementation detail? If so, why do we have the 
> same visibility?
> Shouldn't be one of them an implementation detail? If so, why do we have the 
> same visibility?

No, we use both of them. `simplify` that always returns a symbol is used e.g. 
in `RangedConstraintManager::assumeSym`.

And we use `simplifyToSVal` directly in `EquivalenceClass::simplify`.



Comment at: clang/test/Analysis/solver-sym-simplification-concreteint.c:22
+  // c == 0 --> 0 + 1 == 0 contradiction
+  clang_analyzer_eval(c == 0);// expected-warning{{FALSE}}
+

steakhal wrote:
> Could we have an `eval(c == -1) // TRUE`?
> Also, please disable eager bifurcation to prevent state-splits in the eval 
> arguments.
Actually,  it is `eval(c == -1) // FALSE` that holds. 

This is because after the simplification with `b==1` we have a constraint 
`c+1==0` but we do not reorder this equality to `c==-1`. Besides we have 
another constraint that we inherited from a previous State, this is `c: [0, 
1]`. Now, when you query `c==-1` then the latter constraint is found, thus 
resulting in an infeasible state, so you'll receive `FALSE` in the warning. 
Actually, these are the constraints after line 19:
```
  "constraints": [
{ "symbol": "(reg_$1) + (reg_$0)", "range": "{ [0, 0] }" },
{ "symbol": "(reg_$1) + 1", "range": "{ [0, 0] }" },
{ "symbol": "reg_$0", "range": "{ [1, 1] }" },
{ "symbol": "reg_$1", "range": "{ [0, 1] }" }
  ],
```

I am considering to create a follow-up patch, where the reordering of `c+1==0` 
to `c==-1` is done (perhaps by reusing `RangedConstraintManager::assumeSymRel`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110913

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


[PATCH] D111218: [AMDGPU][OpenMP] Mark oulined functions always_inline

2021-10-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal planned changes to this revision.
pdhaliwal added a comment.

I don't have any concrete evidence but I have some doubt on presence of 
function pointers causing backend to behave improperly. Also, here removing 
optnone alone suffices to fix the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111218

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


[PATCH] D105191: [Clang][OpenMP] Add partial support for Static Device Libraries

2021-10-06 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 377500.
saiislam marked 3 inline comments as done.
saiislam added a comment.

Function name refactoring for AddStaticDeviceLibs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/openmp_static_device_link/libFatArchive.a
  clang/test/Driver/fat_archive_amdgpu.cpp
  clang/test/Driver/fat_archive_nvptx.cpp
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -180,6 +180,28 @@
   }
 };
 
+static StringRef getDeviceFileExtension(StringRef Device) {
+  if (Device.contains("gfx"))
+return ".bc";
+  if (Device.contains("sm_"))
+return ".cubin";
+
+  WithColor::warning() << "Could not determine extension for archive"
+  "members, using \".o\"\n";
+  return ".o";
+}
+
+static std::string getDeviceLibraryFileName(StringRef BundleFileName,
+StringRef Device) {
+  StringRef LibName = sys::path::stem(BundleFileName);
+  StringRef Extension = getDeviceFileExtension(Device);
+
+  std::string Result;
+  Result += LibName;
+  Result += Extension;
+  return Result;
+}
+
 /// Generic file handler interface.
 class FileHandler {
 public:
@@ -1229,7 +1251,9 @@
   BundledObjectFileName.assign(BundledObjectFile);
   auto OutputBundleName =
   Twine(llvm::sys::path::stem(BundledObjectFileName) + "-" +
-CodeObject)
+CodeObject +
+getDeviceLibraryFileName(BundledObjectFileName,
+ CodeObjectInfo.GPUArch))
   .str();
   // Replace ':' in optional target feature list with '_' to ensure
   // cross-platform validity.
Index: clang/test/Driver/fat_archive_nvptx.cpp
===
--- /dev/null
+++ clang/test/Driver/fat_archive_nvptx.cpp
@@ -0,0 +1,81 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// See the steps to create a fat archive are given at the end of the file.
+
+// Given a FatArchive, clang-offload-bundler should be called to create a
+// device specific archive, which should be passed to clang-nvlink-wrapper.
+// RUN: %clang -O2 -### -fopenmp -fopenmp-targets=nvptx64 %s -L%S/Inputs/openmp_static_device_link -lFatArchive 2>&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "nvptx64"{{.*}}"-target-cpu" "[[GPU:sm_[0-9]+]]"{{.*}}"-o" "[[HOSTBC:.*.s]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-unbundle" "-type=a" "-inputs={{.*}}/Inputs/openmp_static_device_link/libFatArchive.a" "-targets=openmp-nvptx64-[[GPU]]" "-outputs=[[DEVICESPECIFICARCHIVE:.*.a]]" "-allow-missing-bundles"
+// CHECK: clang-nvlink-wrapper{{.*}}"-o" "{{.*}}.out" "-arch" "[[GPU]]" "{{.*}}[[DEVICESPECIFICARCHIVE]]"
+// CHECK: ld"{{.*}}" "-L{{.*}}/Inputs/openmp_static_device_link" "{{.*}} "-lFatArchive" "{{.*}}" "-lomp{{.*}}-lomptarget"
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 10
+
+#pragma omp declare target
+// Functions defined in Fat Archive.
+extern "C" void func_present(float *, float *, unsigned);
+
+#ifdef MISSING
+// Function not defined in the fat archive.
+extern "C" void func_missing(float *, float *, unsigned);
+#endif
+
+#pragma omp end declare target
+
+int main() {
+  float in[N], out[N], sum = 0;
+  unsigned i;
+
+#pragma omp parallel for
+  for (i = 0; i < N; ++i) {
+in[i] = i;
+  }
+
+  func_present(in, out, N); // Returns out[i] = a[i] * 0
+
+#ifdef MISSING
+  func_missing(in, out, N); // Should throw an error here
+#endif
+
+#pragma omp parallel for reduction(+ \
+   : sum)
+  for (i = 0; i < N; ++i)
+sum += out[i];
+
+  if (!sum)
+return 0;
+  return sum;
+}
+
+#endif
+
+/***
+   Steps to create Fat Archive (libFatArchive.a)
+
+* File: func_1.c ***
+void func_present(float* in, float* out, unsigned n){
+  unsigned i;
+  #pragma omp target teams distribute parallel for map(to: in[0:n]) map(from: out[0:n])
+  for(i=0; i&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "[[GPU:gfx[0-9]+]]"{{.*}}"-o" "[[HOSTBC:.*.bc]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-un

[PATCH] D111115: [OPENMP] Fix assert of "Unable to find base lambda address" from adjustMemberOfForLambdaCaptures.

2021-10-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D15

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


[PATCH] D108592: [clang][Fuchsia] Support __attribute__((availability)) on Fuchsia

2021-10-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3557
+def warn_availability_fuchsia_unavailable_minor : Warning<
+  "Fuchsia API Level only support 'major', not '.minor[.subminor]'">,
+  InGroup;





Comment at: clang/lib/Basic/Targets/OSTargets.h:893
   Builder.defineMacro("_GNU_SOURCE");
+Builder.defineMacro("FUCHSIA_API_LEVEL", Twine(Opts.FuchsiaAPILevel));
+this->PlatformName = "fuchsia";

I think this macro should be using a reserved name, as suggested by @phosek.



Comment at: clang/test/Frontend/attr-availability-fuchsia.c:2
+// Test that `-mfuchsia-version` is propagated to cc1.
+// RUN: %clang -target x86_64-unknown-fuchsia -ffuchsia-api-level=16 -c %s 
-### 2>&1| FileCheck %s
+//

Can you also add a test that shows how we handle `-ffuchsia-api-level=16.0.0`?



Comment at: clang/test/Frontend/attr-availability-fuchsia.c:2
+// Test that `-mfuchsia-version` is propagated to cc1.
+// RUN: %clang -target x86_64-unknown-fuchsia -mfuchsia-version=16 -c %s -### 
|& FileCheck %s
+//

aaron.ballman wrote:
> Is `|&` intentional? I think that's causing shell parse errors on Windows 
> (same for the other test).
> 
> Also should this test be in `Driver` instead as it's testing the driver 
> functionality?
This test should be in `Driver`, right?



Comment at: clang/test/Sema/attr-availability-fuchsia.c:14
+void f5(int) __attribute__((availability(ios, introduced = 3.2), 
availability(fuchsia, unavailable)));   
// expected-note{{'f5' has been explicitly marked unavailable here}}
+void f6(int) __attribute__((availability(fuchsia, introduced = 16.0)));
  
// expected-warning {{Fuchsia API Level only support 'major', not 
'.minor[.subminor]}}
+void f7(int) __attribute__((availability(fuchsia, introduced = 16.1))); // 
expected-warning {{Fuchsia API Level only support 'major', not 
'.minor[.subminor]}}

FWIW, this surprises me. I would have expected that `16`, `16.0`, and `16.0.0` 
were all equivalent and the issue was with specifying a nonzero value for 
those. I've suggested new wording for the diagnostic that might make it more 
clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108592

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


[PATCH] D111218: [AMDGPU][OpenMP] Mark oulined functions always_inline

2021-10-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 377502.
pdhaliwal added a comment.

Only removing optnone.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111218

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -503,6 +503,11 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // TODO: should not need this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, Loc, Loc);
   Address ContextAddr = CGF.GetAddrOfLocalVar(CD->getContextParam());
@@ -665,8 +670,14 @@
   F->setDoesNotRecurse();
 
   // Always inline the outlined function if optimizations are enabled.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0) {
 F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+
+  // TODO: remove this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
 
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -503,6 +503,11 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // TODO: should not need this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, Args, Loc, Loc);
   Address ContextAddr = CGF.GetAddrOfLocalVar(CD->getContextParam());
@@ -665,8 +670,14 @@
   F->setDoesNotRecurse();
 
   // Always inline the outlined function if optimizations are enabled.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0) {
 F->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
+
+  // TODO: remove this once amdgcn handles function pointers properly.
+  if (CGM.getTriple().isAMDGCN()) {
+F->removeFnAttr(llvm::Attribute::OptimizeNone);
+  }
 
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111109: AddGlobalAnnotations for function with or without function body.

2021-10-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I think this is reasonable, but can you update the summary to also explain why 
these changes are useful?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D09

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


[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-10-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from a nit, but please give some time for @rjmccall to review as 
well in case he spots something I've missed.




Comment at: clang/lib/Sema/TreeTransform.h:3844
+  if (auto *AIL = dyn_cast(Init)) {
+auto *OVE = cast(AIL->getCommonExpr());
+Init = OVE->getSourceExpr();

No need for the cast, this function already returns that type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

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


[PATCH] D110685: [HIPSPV][4/4] Add option to use llc to emit SPIR-V

2021-10-06 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

In D110685#3044993 , @Anastasia wrote:

> Ok, is the idea to deprecate this flag once we switch to `llc` by default 
> then?

The idea is to remove the flags if no one else needs them when the HIPSPV tool 
chain switches over to `llc`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110685

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


[PATCH] D111224: [clang] Traverse enum integer-base specifiers in RAV

2021-10-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: nridge, hokein.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Visit enum integer-base specifiers explicitly written in the code.

This is achieved by:

- traversing the typeloc for integer-base on enum decls when they are spelled 
in the code (similar to base-specifiers for CXXRecordDecls).
- Visiting the typesourceinfo for integer-base in libindex, similar to 
base-specifiers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111224

Files:
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/Index/IndexTypeSourceInfo.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -377,6 +377,18 @@
  Not(HasRole(SymbolRole::RelationBaseOf);
 }
 
+TEST(IndexTest, EnumBase) {
+  std::string Code = R"cpp(
+typedef int MyTypedef;
+enum Foo : MyTypedef {};
+  )cpp";
+  auto Index = std::make_shared();
+  tooling::runToolOnCode(std::make_unique(Index), Code);
+  // A should not be the base of anything.
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("MyTypedef"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 16);
+}
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -7,8 +7,10 @@
 //===--===//
 
 #include "IndexingContext.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Casting.h"
 
 using namespace clang;
 using namespace index;
@@ -305,6 +307,9 @@
 for (const auto &I : CXXRD->bases()) {
   indexTypeSourceInfo(I.getTypeSourceInfo(), CXXRD, CXXRD, /*isBase=*/true);
 }
+  } else if (auto *ED = dyn_cast(D)) {
+if (auto *TSI = ED->getIntegerTypeSourceInfo())
+  indexTypeSourceInfo(TSI, ED, ED, /*isBase=*/true);
   }
   indexDeclContext(D);
 }
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1863,6 +1863,9 @@
 DEF_TRAVERSE_DECL(EnumDecl, {
   TRY_TO(TraverseDeclTemplateParameterLists(D));
 
+  if (auto *TSI = D->getIntegerTypeSourceInfo())
+TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
+
   if (D->getTypeForDecl())
 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
 
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -880,6 +880,15 @@
 };
   )cpp",
 
+  R"cpp(// Enum base
+typedef int $def[[MyTypeDef]];
+enum Foo : My^TypeDef;
+  )cpp",
+  R"cpp(// Enum base
+using $def[[MyTypeDef]] = int;
+enum Foo : My^TypeDef {};
+  )cpp",
+
   R"objc(
 @protocol Dog;
 @protocol $decl[[Dog]]
@@ -1951,6 +1960,16 @@
   [[f^oo]](s);
 }
   )cpp",
+
+  // Enum base
+  R"cpp(
+typedef int $def[[MyTypeDef]];
+enum MyEnum : [[MyTy^peDef]] { };
+  )cpp",
+  R"cpp(
+using $def[[MyTypeDef]] = int;
+enum MyEnum : [[MyTy^peDef]] { };
+  )cpp",
   };
   for (const char *Test : Tests)
 checkFindRefs(Test);
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -780,6 +780,16 @@
 $LocalVariable_decl[[d]]($LocalVariable[[b]]) ]() {}();
 }
   )cpp",
+  // Enum base specifier
+  R"cpp(
+using $Primitive_decl[[MyTypedef]] = int;
+enum $Enum_decl[[MyEnum]] : $Primitive[[MyTypedef]] {};
+  )cpp",
+  // Enum base specifier
+  R"cpp(
+typedef int $Primitive_decl[[MyTypedef]];
+enum $Enum_decl[[MyEnum]] : $Primitive[[MyTypedef]] {};
+  )cpp",
   };
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
___
cfe-commits mailing

[PATCH] D111218: [AMDGPU][OpenMP] Remove optnone from outlined functions

2021-10-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

What if we track down the problem instead? This will simply pop up again in O0 
user code, no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111218

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


[PATCH] D111218: [AMDGPU][OpenMP] Remove optnone from outlined functions

2021-10-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Root cause would definitely be better but we don't have one at present and 
would like to unblock the linked diff. O0 is likely to have more problems than 
just this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111218

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


[PATCH] D111228: [clang-tidy] Add options to bugprone-unused-return-value.

2021-10-06 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, martong, gamesh411, Szelethus, dkrupp, 
xazax.hun, whisperity.
balazske requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Extend the check with option to include or exclude specific functions.
This makes it more easy to add extra functions or remove from the checked 
function set
without specifying all functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111228

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-return-value-custom.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-return-value-custom.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-return-value-custom.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-return-value-custom.cpp
@@ -1,7 +1,11 @@
 // RUN: %check_clang_tidy %s bugprone-unused-return-value %t \
 // RUN: -config='{CheckOptions: \
 // RUN:  [{key: bugprone-unused-return-value.CheckedFunctions, \
-// RUN:value: "::fun;::ns::Outer::Inner::memFun;::ns::Type::staticFun;::ns::ClassTemplate::memFun;::ns::ClassTemplate::staticFun"}]}' \
+// RUN:value: "::fun;::ns::Outer::Inner::memFun;::ns::Type::staticFun;::ns::ClassTemplate::memFun;::ns::ClassTemplate::staticFun;::excludedFun"}, \
+// RUN:  {key: bugprone-unused-return-value.IncludedFunctions, \
+// RUN:value: "::includedFun;::excludedFun"}, \
+// RUN:  {key: bugprone-unused-return-value.ExcludedFunctions, \
+// RUN:value: "::excludedFun"}]}' \
 // RUN: --
 
 namespace std {
@@ -44,6 +48,8 @@
 
 int fun();
 void fun(int);
+int includedFun();
+int excludedFun();
 
 void warning() {
   fun();
@@ -81,6 +87,10 @@
   ns::ClassTemplate::staticFun();
   // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
   // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
+
+  includedFun();
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
 }
 
 void noWarning() {
@@ -105,4 +115,7 @@
 
   ns::Type ObjB3;
   ObjB3.memFun();
+
+  // no warning on function that is specified as excluded and as to be checked
+  excludedFun();
 }
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
@@ -29,6 +29,8 @@
 
 private:
   std::string CheckedFunctions;
+  std::string IncludedFunctions;
+  std::string ExcludedFunctions;
 };
 
 } // namespace bugprone
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -30,116 +30,129 @@
   Finder, Builder);
 }
 
+const std::string DefaultCheckedFunctions = "::std::async;"
+"::std::launder;"
+"::std::remove;"
+"::std::remove_if;"
+"::std::unique;"
+"::std::unique_ptr::release;"
+"::std::basic_string::empty;"
+"::std::vector::empty;"
+"::std::back_inserter;"
+"::std::distance;"
+"::std::find;"
+"::std::find_if;"
+"::std::inserter;"
+"::std::lower_bound;"
+"::std::make_pair;"
+"::std::map::count;"
+"::std::map::find;"
+"::std::map::lower_bound;"
+"::std::multimap::equal_range;"
+"::std::multimap::upper_bound;"
+"::std::set::count;"
+"::std::set::find;"
+"::std::setfill;"
+"::std::setprecision;"
+"::std::setw;"
+"::std::upper_bound;"
+  

[PATCH] D110781: [CUDA] Make sure is included with original __THROW defined.

2021-10-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I first had to read up on pop_macro -.-. Still unsure if it is OK to push it 
once and pop it twice, that works fine?
Can't we move the string include earlier, grouped with stdlib and cmath? then 
we don't need to play with __THROW twice.
Other than that it seems sensible to let string have a __THROW, even though 
none of this mismatch is really sensible at the end of the day...

While we are here, we should be able to have a test, no? Something in string.h 
that depends on __THROW being present should suffice I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110781

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


[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-06 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 377504.
carlosgalvezp added a comment.

Remove redundant "*" if branch.


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

https://reviews.llvm.org/D111208

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -46,6 +46,17 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
+// NOLINTNEXTLINE(google*)
+class I1 { I1(int i); };
+
+// NOLINTNEXTLINE(google*,-google*)
+class I2 { I2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*,-google*)
+class I3 { I3(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 10 warnings (10 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -119,4 +119,18 @@
 
 MACRO_NO_LINT_INSIDE_MACRO
 
-// CHECK-MESSAGES: Suppressed 18 warnings (18 NOLINT).
+// NOLINTBEGIN(google*)
+class C13 { C13(int i); };
+// NOLINTEND(google*)
+
+// NOLINTBEGIN(google*,-google*)
+class C14 { C14(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(google*,-google*)
+
+// NOLINTBEGIN(*,-google*)
+class C15 { C15(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(*,-google*)
+
+// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT).
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -51,4 +51,16 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
+class D1 { D1(int x); }; // NOLINT(google*)
+class D2 { D2(int x); }; // NOLINT(*explicit-constructor)
+class D3 { D3(int x); }; // NOLINT(*explicit*)
+
+class D4 { D4(int x); }; // NOLINT(google*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+class D5 { D5(int x); }; // NOLINT(google*,-google*,google*)
+
+class D6 { D6(int x); }; // NOLINT(*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 17 warnings (17 NOLINT)
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -173,11 +173,11 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
---fix-notes- 
- If a warning has no fix, but a single fix can 
- be found through an associated diagnostic note, 
- apply the fix. 
- Specifying this flag will implicitly enable the 
+--fix-notes-
+ If a warning has no fix, but a single fix can
+ be found through an associated diagnostic note,
+ apply the fix.
+ Specifying this flag will implicitly enable the
  '--fix' flag.
 --format-style=-
  Style for formatting code around applied fixes:
@@ -308,7 +308,10 @@
 comments).
 
 All comments can be followed by an optional list of check names in parentheses
-(see below for the formal syntax).
+(see below for the formal syntax). The list of check names supports globbing,
+with the same format and semantics as for enabling checks. Note that adding
+a dash, e.g. `NOLINT(-che

[PATCH] D111224: [clang] Traverse enum integer-base specifiers in RAV

2021-10-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 377527.
kadircet added a comment.

- Fix tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111224

Files:
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/Index/IndexTypeSourceInfo.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -377,6 +377,18 @@
  Not(HasRole(SymbolRole::RelationBaseOf);
 }
 
+TEST(IndexTest, EnumBase) {
+  std::string Code = R"cpp(
+typedef int MyTypedef;
+enum Foo : MyTypedef {};
+  )cpp";
+  auto Index = std::make_shared();
+  tooling::runToolOnCode(std::make_unique(Index), Code);
+  // A should not be the base of anything.
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("MyTypedef"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 16);
+}
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -7,8 +7,10 @@
 //===--===//
 
 #include "IndexingContext.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Casting.h"
 
 using namespace clang;
 using namespace index;
@@ -305,6 +307,9 @@
 for (const auto &I : CXXRD->bases()) {
   indexTypeSourceInfo(I.getTypeSourceInfo(), CXXRD, CXXRD, /*isBase=*/true);
 }
+  } else if (auto *ED = dyn_cast(D)) {
+if (auto *TSI = ED->getIntegerTypeSourceInfo())
+  indexTypeSourceInfo(TSI, ED, ED, /*isBase=*/true);
   }
   indexDeclContext(D);
 }
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1863,6 +1863,9 @@
 DEF_TRAVERSE_DECL(EnumDecl, {
   TRY_TO(TraverseDeclTemplateParameterLists(D));
 
+  if (auto *TSI = D->getIntegerTypeSourceInfo())
+TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
+
   if (D->getTypeForDecl())
 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
 
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -880,6 +880,15 @@
 };
   )cpp",
 
+  R"cpp(// Enum base
+typedef int $decl[[MyTypeDef]];
+enum Foo : My^TypeDef {};
+  )cpp",
+  R"cpp(// Enum base
+using $decl[[MyTypeDef]] = int;
+enum Foo : My^TypeDef {};
+  )cpp",
+
   R"objc(
 @protocol Dog;
 @protocol $decl[[Dog]]
@@ -1953,6 +1962,16 @@
   [[f^oo]](s);
 }
   )cpp",
+
+  // Enum base
+  R"cpp(
+typedef int $def[[MyTypeDef]];
+enum MyEnum : [[MyTy^peDef]] { };
+  )cpp",
+  R"cpp(
+using $def[[MyTypeDef]] = int;
+enum MyEnum : [[MyTy^peDef]] { };
+  )cpp",
   };
   for (const char *Test : Tests)
 checkFindRefs(Test);
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -780,6 +780,16 @@
 $LocalVariable_decl[[d]]($LocalVariable[[b]]) ]() {}();
 }
   )cpp",
+  // Enum base specifier
+  R"cpp(
+using $Primitive_decl[[MyTypedef]] = int;
+enum $Enum_decl[[MyEnum]] : $Primitive[[MyTypedef]] {};
+  )cpp",
+  // Enum base specifier
+  R"cpp(
+typedef int $Primitive_decl[[MyTypedef]];
+enum $Enum_decl[[MyEnum]] : $Primitive[[MyTypedef]] {};
+  )cpp",
   };
   for (const auto &TestCase : TestCases)
 // Mask off scope modifiers to keep the tests manageable.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111228: [clang-tidy] Add options to bugprone-unused-return-value.

2021-10-06 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added reviewers: aaron.ballman, martong, jranieri-grammatech, 
sammccall.
balazske added a comment.
Herald added a subscriber: rnkovacs.

These options are added to make the configuration more comfortable if only 
functions are to be added or removed from the list. I plan another commit that 
extends the list of checked functions significantly (to include all or some of 
the functions listed in CERT ERR33-C 
)
 (but after looking at D76083  I am not sure).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111228

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


[PATCH] D111229: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-06 Thread Kamau Bridgeman via Phabricator via cfe-commits
kamaub created this revision.
kamaub added reviewers: PowerPC, nemanjai, lei, stefanp.
Herald added subscribers: shchenz, kbarton.
kamaub requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The builtin __rlwnm is currently constrained to accept only constants
for the shift parameter but the instructions emitted for it have no such
constraint, this patch allows the builtins to accept variable shift.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111229

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c
@@ -43,7 +43,7 @@
 void test_builtin_ppc_rlwnm() {
   unsigned int shift;
   unsigned int mask;
-  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7);
   res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
   res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00);// expected-error 
{{argument 2 value should represent a contiguous bit field}}
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3432,8 +3432,7 @@
   // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must
   // be a constant that represents a contiguous bit field.
   case PPC::BI__builtin_ppc_rlwnm:
-return SemaBuiltinConstantArg(TheCall, 1, Result) ||
-   SemaValueIsRunOfOnes(TheCall, 2);
+return SemaValueIsRunOfOnes(TheCall, 2);
   case PPC::BI__builtin_ppc_rlwimi:
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -117,7 +117,7 @@
 BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
 BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
 // Rotate
-BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
+BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "")
 BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
 BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
 // load


Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c
@@ -43,7 +43,7 @@
 void test_builtin_ppc_rlwnm() {
   unsigned int shift;
   unsigned int mask;
-  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7);
   res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
   res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00);// expected-error {{argument 2 value should represent a contiguous bit field}}
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3432,8 +3432,7 @@
   // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must
   // be a constant that represents a contiguous bit field.
   case PPC::BI__builtin_ppc_rlwnm:
-return SemaBuiltinConstantArg(TheCall, 1, Result) ||
-   SemaValueIsRunOfOnes(TheCall, 2);
+return SemaValueIsRunOfOnes(TheCall, 2);
   case PPC::BI__builtin_ppc_rlwimi:
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -117,7 +117,7 @@
 BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
 BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
 // Rotate
-BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
+BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "")
 BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
 BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
 // load
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110910: [analyzer][solver] Fix CmpOpTable handling bug

2021-10-06 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

I see the problem. It appears when you meet, say, '>' in a //true// branch and 
'<=' in a //false// branch which then turns into `>` again and trigger the 
flag, but shouldn't. Your solution is correct and looks clear.
Here I propose you one more to not use additional abstruction in a favor of 
performance. See inlines.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1129
 
-int UnknownStates = 0;
+llvm::SmallSet QueriedToUnknown;
 





Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1166-1167
   if (BranchState == OperatorRelationsTable::Unknown) {
-if (++UnknownStates == 2)
+QueriedToUnknown.insert(QueriedOP);
+if (QueriedToUnknown.size() == 2)
   // If we met both Unknown states.





Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1174-1175
   BranchState = CmpOpTable.getCmpOpStateForUnknownX2(CurrentOP);
 else
   continue;
   }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110910

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


[PATCH] D111224: [clang] Traverse enum integer-base specifiers in RAV

2021-10-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

the RAV change looks good.

I think it might be worth to split this patch (one for RAV, one for libindex).




Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:1866
 
+  if (auto *TSI = D->getIntegerTypeSourceInfo())
+TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));

we have unittests for RAV, they are in 
`clang/unittests/Tooling/RecursiveASTVisitorTests/`, but unfortunately, we 
don't have one for enum decl, we can create one.



Comment at: clang/lib/Index/IndexTypeSourceInfo.cpp:310
 }
+  } else if (auto *ED = dyn_cast(D)) {
+if (auto *TSI = ED->getIntegerTypeSourceInfo())

this seem to work if the D is a definition, I think it won't report the 
reference if the enum decl is a declaration.

```
 typedef int MyTypedef;
 enum Foo : MyTypedef;
```



Comment at: clang/unittests/Index/IndexTests.cpp:387
+  tooling::runToolOnCode(std::make_unique(Index), Code);
+  // A should not be the base of anything.
+  EXPECT_THAT(Index->Symbols,

This seems to be a copy-paste error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111224

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


[PATCH] D110676: [CFE][Codegen] Update auto-generated check lines for few GPU lit tests

2021-10-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

I compared the auto generated check lines with original ones. Overall I think 
this will make life easier since it seems easier to inspect autogenerated lines 
than manually updating them.

Therefore LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110676

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


[PATCH] D110428: [AIX] Define WCHAR_T_TYPE as unsigned short on AIX for wchar.c test case.

2021-10-06 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49dbde9c9e51: [AIX] Define WCHAR_T_TYPE as unsigned short on 
AIX for wchar.c test case. (authored by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110428

Files:
  clang/test/Sema/wchar.c


Index: clang/test/Sema/wchar.c
===
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -4,7 +4,8 @@
 typedef __WCHAR_TYPE__ wchar_t;
 
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
- || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
+ || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR) \
+ || (defined(_AIX) && !defined(__64BIT__))
   #define WCHAR_T_TYPE unsigned short
 #elif defined(__aarch64__)
   // See AArch64TargetInfo constructor -- unsigned on non-darwin non-OpenBSD 
non-NetBSD.


Index: clang/test/Sema/wchar.c
===
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -4,7 +4,8 @@
 typedef __WCHAR_TYPE__ wchar_t;
 
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
- || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
+ || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR) \
+ || (defined(_AIX) && !defined(__64BIT__))
   #define WCHAR_T_TYPE unsigned short
 #elif defined(__aarch64__)
   // See AArch64TargetInfo constructor -- unsigned on non-darwin non-OpenBSD non-NetBSD.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 49dbde9 - [AIX] Define WCHAR_T_TYPE as unsigned short on AIX for wchar.c test case.

2021-10-06 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2021-10-06T08:49:37-05:00
New Revision: 49dbde9c9e5149bcc8b906f7dbd040be76a2a267

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

LOG: [AIX] Define WCHAR_T_TYPE as unsigned short on AIX for wchar.c test case.

The default wchar type is different on AIX vs. Linux. When this test is run on
AIX, WCHAR_T_TYPE ends up being set to int. This is incorrect as the default
wchar type on AIX is actually unsigned short, and setting the type incorrectly
causes the expected errors to not be found.

This patch sets the type correctly (to unsigned short) for AIX.

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

Added: 


Modified: 
clang/test/Sema/wchar.c

Removed: 




diff  --git a/clang/test/Sema/wchar.c b/clang/test/Sema/wchar.c
index 83ea6372168d6..fff12442ed543 100644
--- a/clang/test/Sema/wchar.c
+++ b/clang/test/Sema/wchar.c
@@ -4,7 +4,8 @@
 typedef __WCHAR_TYPE__ wchar_t;
 
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
- || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
+ || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR) \
+ || (defined(_AIX) && !defined(__64BIT__))
   #define WCHAR_T_TYPE unsigned short
 #elif defined(__aarch64__)
   // See AArch64TargetInfo constructor -- unsigned on non-darwin non-OpenBSD 
non-NetBSD.



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


[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-06 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:72
+  multiple warnings in the same line.
 - Added support for `NOLINTBEGIN` ... `NOLINTEND` comments to suppress
   Clang-Tidy warnings over multiple lines.

Please separate with newline.


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

https://reviews.llvm.org/D111208

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


[PATCH] D111232: [clang] Don't mark _ReadBarrier(), _ReadWriteBarrier(), _WriteBarrier() deprecated

2021-10-06 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added reviewers: hans, rnk.
thakis requested review of this revision.

It's true that docs.microsoft.com says:

"""The _ReadBarrier, _WriteBarrier, and _ReadWriteBarrier compiler
intrinsics and the MemoryBarrier macro are all deprecated and should not
be used. For inter-thread communication, use mechanisms such as
atomic_thread_fence and std::atomic, which are defined in the C++
Standard Library. For hardware access, use the /volatile:iso compiler
option together with the volatile keyword."""

And these attributes have been here since these builtins were added in
r192860.

However:

- cl.exe does not warn on them even with /Wall
- none of the replacements are useful for C code
- we don't add __attribute__((__deprecated__())) to any other declarations in 
intrin.h
- intrin0.h in the MSVC headers declares _ReadWriteBarrier() (but without the 
deprecation attribute), so you get inconsistent deprecation warnings depending 
on if you include intrin.h or intrin0.h

The motivation is that compiling sqlite.h with clang-cl produces a
deprecation warning with clang-cl for _ReadWriteBarrier(), but not with
cl.exe.


https://reviews.llvm.org/D111232

Files:
  clang/lib/Headers/intrin.h


Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -150,10 +150,8 @@
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadBarrier(void);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadWriteBarrier(void);
+void _ReadBarrier(void);
+void _ReadWriteBarrier(void);
 unsigned int _rorx_u32(unsigned int, const unsigned int);
 int _sarx_i32(int, unsigned int);
 #if __STDC_HOSTED__
@@ -164,8 +162,7 @@
 void _Store_HLERelease(long volatile *, long);
 void _Store64_HLERelease(__int64 volatile *, __int64);
 void _StorePointer_HLERelease(void *volatile *, void *);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _WriteBarrier(void);
+void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
 


Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -150,10 +150,8 @@
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadBarrier(void);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadWriteBarrier(void);
+void _ReadBarrier(void);
+void _ReadWriteBarrier(void);
 unsigned int _rorx_u32(unsigned int, const unsigned int);
 int _sarx_i32(int, unsigned int);
 #if __STDC_HOSTED__
@@ -164,8 +162,7 @@
 void _Store_HLERelease(long volatile *, long);
 void _Store64_HLERelease(__int64 volatile *, __int64);
 void _StorePointer_HLERelease(void *volatile *, void *);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _WriteBarrier(void);
+void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111232: [clang] Don't mark _ReadBarrier(), _ReadWriteBarrier(), _WriteBarrier() deprecated

2021-10-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Sounds very reasonable to me. lgtm


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

https://reviews.llvm.org/D111232

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


[clang] f9457f1 - [clang] Don't mark _ReadBarrier, _ReadWriteBarrier, _WriteBarrier deprecated

2021-10-06 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-06T10:50:02-04:00
New Revision: f9457f1f88b3e835fca8942b5272f3ecf26d4e98

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

LOG: [clang] Don't mark _ReadBarrier, _ReadWriteBarrier, _WriteBarrier 
deprecated

It's true that docs.microsoft.com says:

"""The _ReadBarrier, _WriteBarrier, and _ReadWriteBarrier compiler
intrinsics and the MemoryBarrier macro are all deprecated and should not
be used. For inter-thread communication, use mechanisms such as
atomic_thread_fence and std::atomic, which are defined in the C++
Standard Library. For hardware access, use the /volatile:iso compiler
option together with the volatile keyword."""

And these attributes have been here since these builtins were added in
r192860.

However:

- cl.exe does not warn on them even with /Wall
- none of the replacements are useful for C code
- we don't add __attribute__((__deprecated__())) to any other
  declarations in intrin.h
- intrin0.h in the MSVC headers declares _ReadWriteBarrier() (but
  without the deprecation attribute), so you get inconsistent
  deprecation warnings depending on if you include intrin.h or intrin0.h

The motivation is that compiling sqlite.h with clang-cl produces a
deprecation warning with clang-cl for _ReadWriteBarrier(), but not with
cl.exe.

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

Added: 


Modified: 
clang/lib/Headers/intrin.h

Removed: 




diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 4803277472ee..3fd6d4dc6d15 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -150,10 +150,8 @@ long _InterlockedExchangeAdd_HLEAcquire(long volatile *, 
long);
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadBarrier(void);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadWriteBarrier(void);
+void _ReadBarrier(void);
+void _ReadWriteBarrier(void);
 unsigned int _rorx_u32(unsigned int, const unsigned int);
 int _sarx_i32(int, unsigned int);
 #if __STDC_HOSTED__
@@ -164,8 +162,7 @@ unsigned int _shrx_u32(unsigned int, unsigned int);
 void _Store_HLERelease(long volatile *, long);
 void _Store64_HLERelease(__int64 volatile *, __int64);
 void _StorePointer_HLERelease(void *volatile *, void *);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _WriteBarrier(void);
+void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
 



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


[PATCH] D111232: [clang] Don't mark _ReadBarrier(), _ReadWriteBarrier(), _WriteBarrier() deprecated

2021-10-06 Thread Nico Weber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9457f1f88b3: [clang] Don't mark _ReadBarrier, 
_ReadWriteBarrier, _WriteBarrier deprecated (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111232

Files:
  clang/lib/Headers/intrin.h


Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -150,10 +150,8 @@
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadBarrier(void);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadWriteBarrier(void);
+void _ReadBarrier(void);
+void _ReadWriteBarrier(void);
 unsigned int _rorx_u32(unsigned int, const unsigned int);
 int _sarx_i32(int, unsigned int);
 #if __STDC_HOSTED__
@@ -164,8 +162,7 @@
 void _Store_HLERelease(long volatile *, long);
 void _Store64_HLERelease(__int64 volatile *, __int64);
 void _StorePointer_HLERelease(void *volatile *, void *);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _WriteBarrier(void);
+void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
 


Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -150,10 +150,8 @@
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadBarrier(void);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _ReadWriteBarrier(void);
+void _ReadBarrier(void);
+void _ReadWriteBarrier(void);
 unsigned int _rorx_u32(unsigned int, const unsigned int);
 int _sarx_i32(int, unsigned int);
 #if __STDC_HOSTED__
@@ -164,8 +162,7 @@
 void _Store_HLERelease(long volatile *, long);
 void _Store64_HLERelease(__int64 volatile *, __int64);
 void _StorePointer_HLERelease(void *volatile *, void *);
-void __attribute__((__deprecated__(
-"use other intrinsics or C++11 atomics instead"))) _WriteBarrier(void);
+void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-06 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 377551.
carlosgalvezp added a comment.

Fixed comments.


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

https://reviews.llvm.org/D111208

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -46,6 +46,17 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
+// NOLINTNEXTLINE(google*)
+class I1 { I1(int i); };
+
+// NOLINTNEXTLINE(google*,-google*)
+class I2 { I2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*,-google*)
+class I3 { I3(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 10 warnings (10 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -119,4 +119,18 @@
 
 MACRO_NO_LINT_INSIDE_MACRO
 
-// CHECK-MESSAGES: Suppressed 18 warnings (18 NOLINT).
+// NOLINTBEGIN(google*)
+class C13 { C13(int i); };
+// NOLINTEND(google*)
+
+// NOLINTBEGIN(google*,-google*)
+class C14 { C14(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(google*,-google*)
+
+// NOLINTBEGIN(*,-google*)
+class C15 { C15(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit
+// NOLINTEND(*,-google*)
+
+// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT).
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -51,4 +51,16 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
+class D1 { D1(int x); }; // NOLINT(google*)
+class D2 { D2(int x); }; // NOLINT(*explicit-constructor)
+class D3 { D3(int x); }; // NOLINT(*explicit*)
+
+class D4 { D4(int x); }; // NOLINT(google*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+class D5 { D5(int x); }; // NOLINT(google*,-google*,google*)
+
+class D6 { D6(int x); }; // NOLINT(*,-google*)
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// CHECK-MESSAGES: Suppressed 17 warnings (17 NOLINT)
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -173,11 +173,11 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
---fix-notes- 
- If a warning has no fix, but a single fix can 
- be found through an associated diagnostic note, 
- apply the fix. 
- Specifying this flag will implicitly enable the 
+--fix-notes-
+ If a warning has no fix, but a single fix can
+ be found through an associated diagnostic note,
+ apply the fix.
+ Specifying this flag will implicitly enable the
  '--fix' flag.
 --format-style=-
  Style for formatting code around applied fixes:
@@ -308,7 +308,10 @@
 comments).
 
 All comments can be followed by an optional list of check names in parentheses
-(see below for the formal syntax).
+(see below for the formal syntax). The list of check names supports globbing,
+with the same format and semantics as for enabling checks. Note that adding
+a dash, e.g. `NOLINT(-check-name)`, is a 

[libunwind] 60fe1f5 - [runtimes][ci] Run the tests for libunwind in the CI

2021-10-06 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2021-10-06T11:25:26-04:00
New Revision: 60fe1f59d08b815a280761e625d12a74a501f444

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

LOG: [runtimes][ci] Run the tests for libunwind in the CI

We should arguably have always been doing that. The state of libunwind
is quite sad, so this commit adds several XFAILs to make the CI pass.
We need to investigate why so many tests are not passing in some
configurations, but I'll defer that to folks who actually work on
libunwind for lack of bandwidth.

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

Added: 


Modified: 
libcxx/utils/ci/run-buildbot
libcxx/utils/libcxx/test/params.py
libunwind/test/forceunwind.pass.cpp
libunwind/test/frameheadercache_test.pass.cpp
libunwind/test/libunwind_01.pass.cpp
libunwind/test/libunwind_02.pass.cpp
libunwind/test/remember_state_leak.pass.sh.s
libunwind/test/signal_frame.pass.cpp
libunwind/test/signal_unwind.pass.cpp
libunwind/test/unw_getcontext.pass.cpp
libunwind/test/unwind_leaffunction.pass.cpp

Removed: 




diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 5ac0a39a53a7..5c97aef605c5 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -113,15 +113,18 @@ function generate-cmake-libcxx-win() {
   "${@}"
 }
 
-function check-cxx-cxxabi() {
-echo "--- Installing libc++ and libc++abi to a fake location"
-${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi
+function check-runtimes() {
+echo "--- Installing libc++, libc++abi and libunwind to a fake location"
+${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi install-unwind
 
 echo "+++ Running the libc++ tests"
 ${NINJA} -vC "${BUILD_DIR}" check-cxx
 
 echo "+++ Running the libc++abi tests"
 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi
+
+echo "+++ Running the libunwind tests"
+${NINJA} -vC "${BUILD_DIR}" check-unwind
 }
 
 # TODO: The goal is to test this against all configurations. We should also 
move
@@ -190,181 +193,181 @@ generic-cxx03)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-cxx11)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-cxx14)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-cxx17)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-cxx20)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-cxx2b)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx2b.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-assertions)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-assertions.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-debug-iterators)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-debug-iterators.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 check-abi-list
 ;;
 generic-noexceptions)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-noexceptions.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 ;;
 generic-modules)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in"
-check-cxx-cxxabi
+check-runtimes
 ;;
 generic-static)
 clean
 generate-cmake -C 
"${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake" \
-DLIBCXX_TEST_CONFIG="llvm-libc++-static.cfg.in"
-check-cxx-cxxabi
+check-runt

[PATCH] D110641: Implement P0857R0 -Part B: requires clause for template-template params

2021-10-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ping!


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

https://reviews.llvm.org/D110641

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


[clang] f37e8b0 - [Clang][OpenMP] Infix OMPLoopTransformationDirective abstract class. NFC.

2021-10-06 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-10-06T10:49:07-05:00
New Revision: f37e8b0b831e61d3b6033829fff05d6d193ab735

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

LOG: [Clang][OpenMP] Infix OMPLoopTransformationDirective abstract class. NFC.

Insert OMPLoopTransformationDirective between OMPLoopBasedDirective and the 
loop transformations OMPTileDirective and OMPUnrollDirective. This simplifies 
handling of loop transformations not requiring distinguishing between 
OMPTileDirective and OMPUnrollDirective anymore.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/StmtOpenMP.h
clang/include/clang/Basic/StmtNodes.td
clang/lib/AST/StmtOpenMP.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index f028c3b32398..285426d26e21 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -889,22 +889,23 @@ class OMPLoopBasedDirective : public 
OMPExecutableDirective {
 
   /// Calls the specified callback function for all the loops in \p CurStmt,
   /// from the outermost to the innermost.
-  static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
-unsigned NumLoops,
-llvm::function_ref 
Callback,
-llvm::function_ref
-OnTransformationCallback);
+  static bool
+  doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
+unsigned NumLoops,
+llvm::function_ref Callback,
+llvm::function_ref
+OnTransformationCallback);
   static bool
   doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
 unsigned NumLoops,
 llvm::function_ref Callback,
-llvm::function_ref
+llvm::function_ref
 OnTransformationCallback) {
 auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) {
   return Callback(Cnt, CurStmt);
 };
 auto &&NewTransformCb =
-[OnTransformationCallback](OMPLoopBasedDirective *A) {
+[OnTransformationCallback](OMPLoopTransformationDirective *A) {
   OnTransformationCallback(A);
 };
 return doForAllLoops(const_cast(CurStmt), 
TryImperfectlyNestedLoops,
@@ -917,7 +918,7 @@ class OMPLoopBasedDirective : public OMPExecutableDirective 
{
   doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
 unsigned NumLoops,
 llvm::function_ref Callback) {
-auto &&TransformCb = [](OMPLoopBasedDirective *) {};
+auto &&TransformCb = [](OMPLoopTransformationDirective *) {};
 return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, 
Callback,
  TransformCb);
   }
@@ -954,6 +955,38 @@ class OMPLoopBasedDirective : public 
OMPExecutableDirective {
   }
 };
 
+/// The base class for all loop transformation directives.
+class OMPLoopTransformationDirective : public OMPLoopBasedDirective {
+  friend class ASTStmtReader;
+
+protected:
+  explicit OMPLoopTransformationDirective(StmtClass SC,
+  OpenMPDirectiveKind Kind,
+  SourceLocation StartLoc,
+  SourceLocation EndLoc,
+  unsigned NumAssociatedLoops)
+  : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops) 
{}
+
+public:
+  /// Return the number of associated (consumed) loops.
+  unsigned getNumAssociatedLoops() const { return getLoopsNumber(); }
+
+  /// Get the de-sugared statements after after the loop transformation.
+  ///
+  /// Might be nullptr if either the directive generates no loops and is 
handled
+  /// directly in CodeGen, or resolving a template-dependence context is
+  /// required.
+  Stmt *getTransformedStmt() const;
+
+  /// Return preinits statement.
+  Stmt *getPreInits() const;
+
+  static bool classof(const Stmt *T) {
+return T->getStmtClass() == OMPTileDirectiveClass ||
+   T->getStmtClass() == OMPUnrollDirectiveClass;
+  }
+};
+
 /// This is a common base class for loop directives ('omp simd', 'omp
 /// for', 'omp for simd' etc.). It is responsible for the loop code generation.
 ///
@@ -5011,7 +5044,7 @@ class OMPTargetTeamsDistributeSimdDirective final : 
public OMPLoopDirective {
 };
 
 /// This represents the '#p

[PATCH] D111119: [Clang][OpenMP] Infix OMPLoopTransformationDirective abstract class. NFC.

2021-10-06 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf37e8b0b831e: [Clang][OpenMP] Infix 
OMPLoopTransformationDirective abstract class. NFC. (authored by Meinersbur).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D19

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/StmtNodes.td
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2046,6 +2046,8 @@
   void VisitOMPLoopDirective(const OMPLoopDirective *D);
   void VisitOMPParallelDirective(const OMPParallelDirective *D);
   void VisitOMPSimdDirective(const OMPSimdDirective *D);
+  void
+  VisitOMPLoopTransformationDirective(const OMPLoopTransformationDirective *D);
   void VisitOMPTileDirective(const OMPTileDirective *D);
   void VisitOMPUnrollDirective(const OMPUnrollDirective *D);
   void VisitOMPForDirective(const OMPForDirective *D);
@@ -2901,12 +2903,17 @@
   VisitOMPLoopDirective(D);
 }
 
-void EnqueueVisitor::VisitOMPTileDirective(const OMPTileDirective *D) {
+void EnqueueVisitor::VisitOMPLoopTransformationDirective(
+const OMPLoopTransformationDirective *D) {
   VisitOMPLoopBasedDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTileDirective(const OMPTileDirective *D) {
+  VisitOMPLoopTransformationDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPUnrollDirective(const OMPUnrollDirective *D) {
-  VisitOMPLoopBasedDirective(D);
+  VisitOMPLoopTransformationDirective(D);
 }
 
 void EnqueueVisitor::VisitOMPForDirective(const OMPForDirective *D) {
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2223,13 +2223,18 @@
   Code = serialization::STMT_OMP_SIMD_DIRECTIVE;
 }
 
-void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective *D) {
+void ASTStmtWriter::VisitOMPLoopTransformationDirective(
+OMPLoopTransformationDirective *D) {
   VisitOMPLoopBasedDirective(D);
+}
+
+void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective *D) {
+  VisitOMPLoopTransformationDirective(D);
   Code = serialization::STMT_OMP_TILE_DIRECTIVE;
 }
 
 void ASTStmtWriter::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
-  VisitOMPLoopBasedDirective(D);
+  VisitOMPLoopTransformationDirective(D);
   Code = serialization::STMT_OMP_UNROLL_DIRECTIVE;
 }
 
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2324,12 +2324,17 @@
   VisitOMPLoopDirective(D);
 }
 
-void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
+void ASTStmtReader::VisitOMPLoopTransformationDirective(
+OMPLoopTransformationDirective *D) {
   VisitOMPLoopBasedDirective(D);
 }
 
+void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
+  VisitOMPLoopTransformationDirective(D);
+}
+
 void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
-  VisitOMPLoopBasedDirective(D);
+  VisitOMPLoopTransformationDirective(D);
 }
 
 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -3823,13 +3823,8 @@
 VisitSubCaptures(S);
   }
 
-  void VisitOMPTileDirective(OMPTileDirective *S) {
-// #pragma omp tile does not introduce data sharing.
-VisitStmt(S);
-  }
-
-  void VisitOMPUnrollDirective(OMPUnrollDirective *S) {
-// #pragma omp unroll does not introduce data sharing.
+  void VisitOMPLoopTransformationDirective(OMPLoopTransformationDirective *S) {
+// Loop transformation directives do not introduce data sharing
 VisitStmt(S);
   }
 
@@ -9050,15 +9045,8 @@
 }
 return false;
   },
-  [&SemaRef, &Captures](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform)) {
-  DependentPreInits = Dir->getPreInits();
-} else if (auto *Dir = dyn_cast(Transform)) {
-  DependentPreInits = Dir->getPreInits();
-} else {
-  llvm_unreachable("Unexpected loop transformation");
-}
+  [&SemaRef, &Captures](OMPLoopTransformationDirective *Transform) {
+Stmt *DependentPreInits = Transform->getPreInits();
 if (!DependentPreInits)
   retu

[PATCH] D110910: [analyzer][solver] Fix CmpOpTable handling bug

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 377564.
martong added a comment.

- Update to use a single variable to track the state
- Make CurrentOP `const`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110910

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


Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- clang/test/Analysis/constraint_manager_conditions.cpp
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -211,3 +211,17 @@
   clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
 }
 }
+
+// Test the logic of reaching the `Unknonw` tristate in CmpOpTable.
+void cmp_op_table_unknownX2(int x, int y, int z) {
+  if (x >= y) {
+// x >= y[1, 1]
+if (x + z < y)
+  return;
+// x + z < y [0, 0]
+if (z != 0)
+  return;
+// x < y [0, 0]
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} 
expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1112,7 +1112,7 @@
 if (!SSE)
   return llvm::None;
 
-BinaryOperatorKind CurrentOP = SSE->getOpcode();
+const BinaryOperatorKind CurrentOP = SSE->getOpcode();
 
 // We currently do not support <=> (C++20).
 if (!BinaryOperator::isComparisonOp(CurrentOP) || (CurrentOP == BO_Cmp))
@@ -1126,7 +1126,12 @@
 
 SymbolManager &SymMgr = State->getSymbolManager();
 
-int UnknownStates = 0;
+// We use this variable to store the last queried operator (`QueriedOP`)
+// for which the `getCmpOpState` returned with `Unknown`. If there are two
+// different OPs that returned `Unknown` then we have to query the special
+// `UnknownX2` column. We assume that `getCmpOpState(CurrentOP, CurrentOP)`
+// never returns `Unknown`, so `CurrentOP` is a good initial value.
+BinaryOperatorKind LastQueriedOpToUnknown = CurrentOP;
 
 // Loop goes through all of the columns exept the last one ('UnknownX2').
 // We treat `UnknownX2` column separately at the end of the loop body.
@@ -1163,15 +1168,18 @@
   CmpOpTable.getCmpOpState(CurrentOP, QueriedOP);
 
   if (BranchState == OperatorRelationsTable::Unknown) {
-if (++UnknownStates == 2)
-  // If we met both Unknown states.
+if (LastQueriedOpToUnknown != CurrentOP &&
+LastQueriedOpToUnknown != QueriedOP) {
+  // If we got the Unknown state for both different operators.
   // if (x <= y)// assume true
   //   if (x != y)  // assume true
   // if (x < y) // would be also true
   // Get a state from `UnknownX2` column.
   BranchState = CmpOpTable.getCmpOpStateForUnknownX2(CurrentOP);
-else
+} else {
+  LastQueriedOpToUnknown = QueriedOP;
   continue;
+}
   }
 
   return (BranchState == OperatorRelationsTable::True) ? getTrueRange(T)


Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- clang/test/Analysis/constraint_manager_conditions.cpp
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -211,3 +211,17 @@
   clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
 }
 }
+
+// Test the logic of reaching the `Unknonw` tristate in CmpOpTable.
+void cmp_op_table_unknownX2(int x, int y, int z) {
+  if (x >= y) {
+// x >= y[1, 1]
+if (x + z < y)
+  return;
+// x + z < y [0, 0]
+if (z != 0)
+  return;
+// x < y [0, 0]
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1112,7 +1112,7 @@
 if (!SSE)
   return llvm::None;
 
-BinaryOperatorKind CurrentOP = SSE->getOpcode();
+const BinaryOperatorKind CurrentOP = SSE->getOpcode();
 
 // We currently do not support <=> (C++20).
 if (!BinaryOperator::isComparisonOp(CurrentOP) || (CurrentOP == BO_Cmp))
@@ -1126,7 +1126,12 @@
 
 SymbolManager &SymMgr = State->getSymbolManager();
 
-int UnknownStates = 0;
+// We use this variable to store the last queried operator (`QueriedOP`)
+// for which the `getCmpOpState` returned with `Unknown`. If there are two
+// different OPs that returned `Unknown` then we have to query

[PATCH] D110910: [analyzer][solver] Fix CmpOpTable handling bug

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks for the review Denys!

I've updated accordingly to your suggestion, it is certainly more efficient. 
However, I've found your solution more difficult to follow, thus I've added 
some more explanatory comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110910

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


[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-10-06 Thread Jason Rice via Phabricator via cfe-commits
ricejasonf updated this revision to Diff 377566.
ricejasonf marked an inline comment as done.
ricejasonf added a comment.

Remove unnecessary cast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/CodeGenCXX/pr45964-decomp-transform.cpp


Index: clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+
+int a[1];
+// CHECK: @a = global [1 x i32] zeroinitializer
+template 
+void test_transform() {
+  auto [b] = a;
+}
+void (*d)(){test_transform<0>};
+// CHECK-LABEL: define {{.*}} @_Z14test_transformILi0EEvv
+// CHECK:   [[ENTRY:.*]]:
+// CHECK-NEXT:  [[ARR:%.*]] = alloca [1 x i32]
+// CHECK-NEXT:  [[BEGIN:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* 
[[ARR]], i64 0, i64 0
+// CHECK-NEXT:  br label %[[BODY:.*]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[BODY]]:
+// CHECK-NEXT:  [[CUR:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], 
%[[BODY]] ]
+// CHECK-NEXT:  [[DEST:%.*]] = getelementptr inbounds i32, i32* [[BEGIN]], i64 
[[CUR]]
+// CHECK-NEXT:  [[SRC:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* @a, 
i64 0, i64 [[CUR]]
+// CHECK-NEXT:  [[X:%.*]] = load i32, i32* [[SRC]]
+// CHECK-NEXT:  store i32 [[X]], i32* [[DEST]]
+// CHECK-NEXT:  [[NEXT]] = add nuw i64 [[CUR]], 1
+// CHECK-NEXT:  [[EQ:%.*]] = icmp eq i64 [[NEXT]], 1
+// CHECK-NEXT:  br i1 [[EQ]], label %[[FIN:.*]], label %[[BODY]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[FIN]]:
+// CHECK-NEXT:  ret void
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3840,8 +3840,10 @@
   if (auto *FE = dyn_cast(Init))
 Init = FE->getSubExpr();
 
-  if (auto *AIL = dyn_cast(Init))
-Init = AIL->getCommonExpr();
+  if (auto *AIL = dyn_cast(Init)) {
+OpaqueValueExpr *OVE = AIL->getCommonExpr();
+Init = OVE->getSourceExpr();
+  }
 
   if (MaterializeTemporaryExpr *MTE = dyn_cast(Init))
 Init = MTE->getSubExpr();


Index: clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+int a[1];
+// CHECK: @a = global [1 x i32] zeroinitializer
+template 
+void test_transform() {
+  auto [b] = a;
+}
+void (*d)(){test_transform<0>};
+// CHECK-LABEL: define {{.*}} @_Z14test_transformILi0EEvv
+// CHECK:   [[ENTRY:.*]]:
+// CHECK-NEXT:  [[ARR:%.*]] = alloca [1 x i32]
+// CHECK-NEXT:  [[BEGIN:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* [[ARR]], i64 0, i64 0
+// CHECK-NEXT:  br label %[[BODY:.*]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[BODY]]:
+// CHECK-NEXT:  [[CUR:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], %[[BODY]] ]
+// CHECK-NEXT:  [[DEST:%.*]] = getelementptr inbounds i32, i32* [[BEGIN]], i64 [[CUR]]
+// CHECK-NEXT:  [[SRC:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* @a, i64 0, i64 [[CUR]]
+// CHECK-NEXT:  [[X:%.*]] = load i32, i32* [[SRC]]
+// CHECK-NEXT:  store i32 [[X]], i32* [[DEST]]
+// CHECK-NEXT:  [[NEXT]] = add nuw i64 [[CUR]], 1
+// CHECK-NEXT:  [[EQ:%.*]] = icmp eq i64 [[NEXT]], 1
+// CHECK-NEXT:  br i1 [[EQ]], label %[[FIN:.*]], label %[[BODY]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[FIN]]:
+// CHECK-NEXT:  ret void
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3840,8 +3840,10 @@
   if (auto *FE = dyn_cast(Init))
 Init = FE->getSubExpr();
 
-  if (auto *AIL = dyn_cast(Init))
-Init = AIL->getCommonExpr();
+  if (auto *AIL = dyn_cast(Init)) {
+OpaqueValueExpr *OVE = AIL->getCommonExpr();
+Init = OVE->getSourceExpr();
+  }
 
   if (MaterializeTemporaryExpr *MTE = dyn_cast(Init))
 Init = MTE->getSubExpr();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.

2021-10-06 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D104285#3044103 , @NoQ wrote:

> Hey, I brought you some regressions!
>
>> ! In D104285#3044804 , @martong 
>> wrote:
>
>   const VarDecl *VD = VR->getDecl()->getCanonicalDecl();

Wow, nice! I've been recently working on some improvements in this scope. I'll 
take this into account and present a fix soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104285

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


[PATCH] D110911: [analyzer][NFC] Add RangeSet::dump

2021-10-06 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov 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/D110911/new/

https://reviews.llvm.org/D110911

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


[PATCH] D105690: [RISCV] Rename assembler mnemonic of unordered floating-point reductions for v1.0-rc change

2021-10-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D105690/new/

https://reviews.llvm.org/D105690

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


[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2021-10-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D110663#3041672 , @phosek wrote:

> In D110663#3041379 , @MaskRay wrote:
>
>> In D110663#3029577 , @phosek wrote:
>>
>>> This is going to break Fuchsia as implemented. We assume that 
>>> `{x86_64,aarch64}-unknown-fuchsia` and `{x86_64,aarch64}-fuchsia` behave 
>>> identically and developers are allowed to use whichever spelling they 
>>> prefer. With this change that's no longer true. This may break other 
>>> platforms that make similar assumptions.
>>
>> Are Fuchsia developers specifying `--target=` explicitly? I think that's the 
>> direction we don't want to support.
>
> Within Fuchsia source tree, we're trying use normalized triple (that is 
> `${arch}-unknown-fuchsia`) but I'm aware of other projects that target 
> Fuchsia and use different spellings. For example, Rust uses 
> `${arch}-fuchsia`, but they also use `${arch}-unknown-linux-gnu` (rather than 
> `${arch}-linux-gnu`).
>
>> I can special case Fuchsia to use the normalized triple, but that's code 
>> that I want to avoid.
>
> I don't think this issue is specific to just Fuchsia. Rather it seems to me 
> like the problem is the inconsistent handling of triples on Linux and I'd 
> like to avoid introducing workarounds for other platforms.
>
>> From my understanding of D110900 , if a 
>> Linux distro prefers `*-linux` to `*-linux-gnu`, we should drop `--target=` 
>> normalization to make this available.
>>
>> ---
>>
>> I think clang driver does normalization so that OS and environment checks 
>> can work , otherwise the constructor `Triple::Triple` can be fooled to use 
>> `unknown`.
>> This does not mean that we should use normalized paths for include and 
>> library paths that users don't explicitly specify.
>>
>> Some ideas that normalization may not be great. Different platforms may 
>> prefer different normalization styles. For example, llvm-project's old 
>> `config.guess` may prefer the `unknown` vendor while newer `config.guess` 
>> prefers the `pc` vendor. redhat may prefer `*-linux` instead of 
>> `*-linux-gnu`. If we need to do normalization for include and library paths, 
>> we need to encode many rules. If we avoid normalization we can save much 
>> code and be less surprising.
>
> That's why I'd prefer the idea I implemented in D101194 
>  where we let each driver handle the 
> normalization rather than trying to come with a single universal way that 
> apparently doesn't exist.
>
> We would also provide a default that would be `llvm::Triple::normalize` so 
> only the platforms that want to deviate from that would need to implement a 
> custom logic.

Now I re-read D101194 , it did make 
simplification to code like `ToolChain::getRuntimePath`, but I may not call it 
moving into the desired state.

I think the best approach is to avoid normalization for include/library path 
purpose, then we don't even need `getMultiarchTriple` overloads at all and 
avoid all the platform customization.
This is necessary to prevent that platforms add more conversion like (D111207 
, which I think is moving toward the wrong 
direction).
The correct `LLVM_DEFAULT_TARGET_TRIPLE` compensates for dropping the 
customization.

> For example, Rust uses `${arch}-fuchsia`, but they also use 
> `${arch}-unknown-linux-gnu` (rather than `${arch}-linux-gnu`).

Such loosen usage is partly due to the traditional fuzzy behavior of clang 
driver `Generic_GCC::GCCInstallationDetector::init` but I am not sure we want 
to encourage it / support it in the future.
People keep adding more customization to override the previous (IMHO wrong) 
behavior.
Asking them to be strict and sticking with one triple is the right direction, 
can greatly simplify the code in clang driver, and make porting to new 
platforms (since they don't even need to add customization to clang driver at 
all!) easier.
For Rust's case, `${arch}-unknown-linux-gnu` does not look good since newer 
config.guess prefers `${arch}-pc-linux-gnu` now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[clang] 792be5d - [analyzer][solver] Fix CmpOpTable handling bug

2021-10-06 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-10-06T18:28:03+02:00
New Revision: 792be5df92e8d068ca32444383bc4e9e7f024bd8

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

LOG: [analyzer][solver] Fix CmpOpTable handling bug

There is an error in the implementation of the logic of reaching the `Unknonw` 
tristate in CmpOpTable.

```
void cmp_op_table_unknownX2(int x, int y, int z) {
  if (x >= y) {
// x >= y[1, 1]
if (x + z < y)
  return;
// x + z < y [0, 0]
if (z != 0)
  return;
// x < y [0, 0]
clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} 
expected-warning{{FALSE}}
  }
}
```
We miss the `FALSE` warning because the false branch is infeasible.

We have to exploit simplification to discover the bug. If we had `x < y`
as the second condition then the analyzer would return the parent state
on the false path and the new constraint would not be part of the State.
But adding `z` to the condition makes both paths feasible.

The root cause of the bug is that we reach the `Unknown` tristate
twice, but in both occasions we reach the same `Op` that is `>=` in the
test case. So, we reached `>=` twice, but we never reached `!=`, thus
querying the `Unknonw2x` column with `getCmpOpStateForUnknownX2` is
wrong.

The solution is to ensure that we reached both **different** `Op`s once.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index c972494f4262..b9492370c404 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1112,7 +1112,7 @@ class SymbolicRangeInferrer
 if (!SSE)
   return llvm::None;
 
-BinaryOperatorKind CurrentOP = SSE->getOpcode();
+const BinaryOperatorKind CurrentOP = SSE->getOpcode();
 
 // We currently do not support <=> (C++20).
 if (!BinaryOperator::isComparisonOp(CurrentOP) || (CurrentOP == BO_Cmp))
@@ -1126,7 +1126,12 @@ class SymbolicRangeInferrer
 
 SymbolManager &SymMgr = State->getSymbolManager();
 
-int UnknownStates = 0;
+// We use this variable to store the last queried operator (`QueriedOP`)
+// for which the `getCmpOpState` returned with `Unknown`. If there are two
+// 
diff erent OPs that returned `Unknown` then we have to query the special
+// `UnknownX2` column. We assume that `getCmpOpState(CurrentOP, CurrentOP)`
+// never returns `Unknown`, so `CurrentOP` is a good initial value.
+BinaryOperatorKind LastQueriedOpToUnknown = CurrentOP;
 
 // Loop goes through all of the columns exept the last one ('UnknownX2').
 // We treat `UnknownX2` column separately at the end of the loop body.
@@ -1163,15 +1168,18 @@ class SymbolicRangeInferrer
   CmpOpTable.getCmpOpState(CurrentOP, QueriedOP);
 
   if (BranchState == OperatorRelationsTable::Unknown) {
-if (++UnknownStates == 2)
-  // If we met both Unknown states.
+if (LastQueriedOpToUnknown != CurrentOP &&
+LastQueriedOpToUnknown != QueriedOP) {
+  // If we got the Unknown state for both 
diff erent operators.
   // if (x <= y)// assume true
   //   if (x != y)  // assume true
   // if (x < y) // would be also true
   // Get a state from `UnknownX2` column.
   BranchState = CmpOpTable.getCmpOpStateForUnknownX2(CurrentOP);
-else
+} else {
+  LastQueriedOpToUnknown = QueriedOP;
   continue;
+}
   }
 
   return (BranchState == OperatorRelationsTable::True) ? getTrueRange(T)

diff  --git a/clang/test/Analysis/constraint_manager_conditions.cpp 
b/clang/test/Analysis/constraint_manager_conditions.cpp
index f148151ab357..c0eb73ef2470 100644
--- a/clang/test/Analysis/constraint_manager_conditions.cpp
+++ b/clang/test/Analysis/constraint_manager_conditions.cpp
@@ -211,3 +211,17 @@ void comparison_le_ge(int x, int y) {
   clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
 }
 }
+
+// Test the logic of reaching the `Unknonw` tristate in CmpOpTable.
+void cmp_op_table_unknownX2(int x, int y, int z) {
+  if (x >= y) {
+// x >= y[1, 1]
+if (x + z < y)
+  return;
+// x + z < y [0, 0]
+if (z != 0)
+  return;
+// x < y [0, 0]
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} 
expected-warning{{FALSE}}
+  }
+}



___

[PATCH] D110910: [analyzer][solver] Fix CmpOpTable handling bug

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG792be5df92e8: [analyzer][solver] Fix CmpOpTable handling bug 
(authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110910

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


Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- clang/test/Analysis/constraint_manager_conditions.cpp
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -211,3 +211,17 @@
   clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
 }
 }
+
+// Test the logic of reaching the `Unknonw` tristate in CmpOpTable.
+void cmp_op_table_unknownX2(int x, int y, int z) {
+  if (x >= y) {
+// x >= y[1, 1]
+if (x + z < y)
+  return;
+// x + z < y [0, 0]
+if (z != 0)
+  return;
+// x < y [0, 0]
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} 
expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1112,7 +1112,7 @@
 if (!SSE)
   return llvm::None;
 
-BinaryOperatorKind CurrentOP = SSE->getOpcode();
+const BinaryOperatorKind CurrentOP = SSE->getOpcode();
 
 // We currently do not support <=> (C++20).
 if (!BinaryOperator::isComparisonOp(CurrentOP) || (CurrentOP == BO_Cmp))
@@ -1126,7 +1126,12 @@
 
 SymbolManager &SymMgr = State->getSymbolManager();
 
-int UnknownStates = 0;
+// We use this variable to store the last queried operator (`QueriedOP`)
+// for which the `getCmpOpState` returned with `Unknown`. If there are two
+// different OPs that returned `Unknown` then we have to query the special
+// `UnknownX2` column. We assume that `getCmpOpState(CurrentOP, CurrentOP)`
+// never returns `Unknown`, so `CurrentOP` is a good initial value.
+BinaryOperatorKind LastQueriedOpToUnknown = CurrentOP;
 
 // Loop goes through all of the columns exept the last one ('UnknownX2').
 // We treat `UnknownX2` column separately at the end of the loop body.
@@ -1163,15 +1168,18 @@
   CmpOpTable.getCmpOpState(CurrentOP, QueriedOP);
 
   if (BranchState == OperatorRelationsTable::Unknown) {
-if (++UnknownStates == 2)
-  // If we met both Unknown states.
+if (LastQueriedOpToUnknown != CurrentOP &&
+LastQueriedOpToUnknown != QueriedOP) {
+  // If we got the Unknown state for both different operators.
   // if (x <= y)// assume true
   //   if (x != y)  // assume true
   // if (x < y) // would be also true
   // Get a state from `UnknownX2` column.
   BranchState = CmpOpTable.getCmpOpStateForUnknownX2(CurrentOP);
-else
+} else {
+  LastQueriedOpToUnknown = QueriedOP;
   continue;
+}
   }
 
   return (BranchState == OperatorRelationsTable::True) ? getTrueRange(T)


Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- clang/test/Analysis/constraint_manager_conditions.cpp
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -211,3 +211,17 @@
   clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
 }
 }
+
+// Test the logic of reaching the `Unknonw` tristate in CmpOpTable.
+void cmp_op_table_unknownX2(int x, int y, int z) {
+  if (x >= y) {
+// x >= y[1, 1]
+if (x + z < y)
+  return;
+// x + z < y [0, 0]
+if (z != 0)
+  return;
+// x < y [0, 0]
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1112,7 +1112,7 @@
 if (!SSE)
   return llvm::None;
 
-BinaryOperatorKind CurrentOP = SSE->getOpcode();
+const BinaryOperatorKind CurrentOP = SSE->getOpcode();
 
 // We currently do not support <=> (C++20).
 if (!BinaryOperator::isComparisonOp(CurrentOP) || (CurrentOP == BO_Cmp))
@@ -1126,7 +1126,12 @@
 
 SymbolManager &SymMgr = State->getSymbolManager();
 
-int UnknownStates = 0;
+// We use this variable to store the last queried operator (`QueriedOP`)
+// for which the `getCmpOpState` returned with `Unknown`. I

[PATCH] D111207: Driver: Add a gcc equivalent triple to the list of triples to search

2021-10-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think we should reduce normalization for include/library path detection in 
the clang driver (D110663 ), instead of 
adding more customization for each platform.
Some clang driver code uses os and environment to check feature compatibility 
with a target triple. Due to the limitation of `llvm::Triple::Triple` 
(os/environ is wrong if un-normalized), such code can keep using the normalized 
triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111207

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


[PATCH] D110910: [analyzer][solver] Fix CmpOpTable handling bug

2021-10-06 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

LGTM




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1129-1134
+// We use this variable to store the last queried operator (`QueriedOP`)
+// for which the `getCmpOpState` returned with `Unknown`. If there are two
+// different OPs that returned `Unknown` then we have to query the special
+// `UnknownX2` column. We assume that `getCmpOpState(CurrentOP, CurrentOP)`
+// never returns `Unknown`, so `CurrentOP` is a good initial value.
+BinaryOperatorKind LastQueriedOpToUnknown = CurrentOP;

Perfect explanation. This is really worth to be here.

P.S. My nit. Disregard if you think it is unnecessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110910

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


[PATCH] D111062: [RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.

2021-10-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoV.td:1372
+(VMANDN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
+
+def : InstAlias<"vmornot.mm $vd, $vs2, $vs1",

Probably not worth having a blank line between vmandnot and vmornot



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td:4018
 
//===--===//
-// 16.2. Vector mask population count vpopc
+// 16.2. Vector mask population count vcpop
 
//===--===//

To be consistent with line 4683

```
// 16.2. Vector count population in mask vcpop.m
```



Comment at: llvm/test/MC/RISCV/rvv/aliases.s:82
+# ALIAS:vcpop.m a2, v4, v0.t # encoding: [0x57,0x26,0x48,0x40]
+# NO-ALIAS: vcpop.m  a2, v4, v0.t # encoding: [0x57,0x26,0x48,0x40]
+vpopc.m a2, v4, v0.t

line "a2, v4, v0.t" up with the previous line.



Comment at: llvm/test/MC/RISCV/rvv/aliases.s:85
+# ALIAS:vmandn.mm   v8, v4, v20  # encoding: [0x57,0x24,0x4a,0x62]
+# NO-ALIAS: vmandn.mm v8, v4, v20  # encoding: [0x57,0x24,0x4a,0x62]
+vmandnot.mm v8, v4, v20

Same here



Comment at: llvm/test/MC/RISCV/rvv/aliases.s:88
+# ALIAS:vmorn.mmv8, v4, v20  # encoding: [0x57,0x24,0x4a,0x72]
+# NO-ALIAS: vmorn.mm  v8, v4, v20  # encoding: [0x57,0x24,0x4a,0x72]
+vmornot.mm v8, v4, v20

And here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111062

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


[PATCH] D110781: [CUDA] Make sure is included with original __THROW defined.

2021-10-06 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 377573.
tra edited the summary of this revision.
tra added a comment.

Added a missing push_macro


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110781

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -208,7 +208,12 @@
 // CUDA-9.2 needs host-side memcpy for some host functions in
 // device_functions.hpp
 #if CUDA_VERSION >= 9020
+// string.h needs __THROW to match the rest of the system includes.
+#pragma pop_macro("__THROW")
 #include 
+// .. but we still need to undef it in order to include other CUDA headers.
+#pragma push_macro("__THROW")
+#undef __THROW
 #endif
 #include "crt/math_functions.hpp"
 #else


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -208,7 +208,12 @@
 // CUDA-9.2 needs host-side memcpy for some host functions in
 // device_functions.hpp
 #if CUDA_VERSION >= 9020
+// string.h needs __THROW to match the rest of the system includes.
+#pragma pop_macro("__THROW")
 #include 
+// .. but we still need to undef it in order to include other CUDA headers.
+#pragma push_macro("__THROW")
+#undef __THROW
 #endif
 #include "crt/math_functions.hpp"
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110911: [analyzer][NFC] Add RangeSet::dump

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks for the reivew!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110911

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


[clang] b8f6c85 - [analyzer][NFC] Add RangeSet::dump

2021-10-06 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-10-06T18:45:07+02:00
New Revision: b8f6c85a831ffb62563a519d1db0b8695c628def

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

LOG: [analyzer][NFC] Add RangeSet::dump

This tiny change improves the debugging experience of the solver a lot!

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

Added: 


Modified: 

clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
index c67df1e51b4f..c1d2b4665f1d 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -48,6 +48,7 @@ class Range {
 ID.AddPointer(&To());
   }
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   // In order to keep non-overlapping ranges sorted, we can compare only From
   // points.
@@ -282,6 +283,7 @@ class RangeSet {
   bool contains(llvm::APSInt Point) const { return containsImpl(Point); }
 
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   bool operator==(const RangeSet &Other) const { return *Impl == *Other.Impl; }
   bool operator!=(const RangeSet &Other) const { return !(*this == Other); }

diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index b9492370c404..829948693885 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -494,15 +494,17 @@ RangeSet RangeSet::Factory::deletePoint(RangeSet From,
   return intersect(From, Upper, Lower);
 }
 
-void Range::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void Range::dump(raw_ostream &OS) const {
   OS << '[' << toString(From(), 10) << ", " << toString(To(), 10) << ']';
 }
+LLVM_DUMP_METHOD void Range::dump() const { dump(llvm::errs()); }
 
-void RangeSet::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void RangeSet::dump(raw_ostream &OS) const {
   OS << "{ ";
   llvm::interleaveComma(*this, OS, [&OS](const Range &R) { R.dump(OS); });
   OS << " }";
 }
+LLVM_DUMP_METHOD void RangeSet::dump() const { dump(llvm::errs()); }
 
 REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(SymbolSet, SymbolRef)
 



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


[PATCH] D110911: [analyzer][NFC] Add RangeSet::dump

2021-10-06 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb8f6c85a831f: [analyzer][NFC] Add RangeSet::dump (authored 
by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110911

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -494,15 +494,17 @@
   return intersect(From, Upper, Lower);
 }
 
-void Range::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void Range::dump(raw_ostream &OS) const {
   OS << '[' << toString(From(), 10) << ", " << toString(To(), 10) << ']';
 }
+LLVM_DUMP_METHOD void Range::dump() const { dump(llvm::errs()); }
 
-void RangeSet::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void RangeSet::dump(raw_ostream &OS) const {
   OS << "{ ";
   llvm::interleaveComma(*this, OS, [&OS](const Range &R) { R.dump(OS); });
   OS << " }";
 }
+LLVM_DUMP_METHOD void RangeSet::dump() const { dump(llvm::errs()); }
 
 REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(SymbolSet, SymbolRef)
 
Index: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -48,6 +48,7 @@
 ID.AddPointer(&To());
   }
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   // In order to keep non-overlapping ranges sorted, we can compare only From
   // points.
@@ -282,6 +283,7 @@
   bool contains(llvm::APSInt Point) const { return containsImpl(Point); }
 
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   bool operator==(const RangeSet &Other) const { return *Impl == *Other.Impl; }
   bool operator!=(const RangeSet &Other) const { return !(*this == Other); }


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -494,15 +494,17 @@
   return intersect(From, Upper, Lower);
 }
 
-void Range::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void Range::dump(raw_ostream &OS) const {
   OS << '[' << toString(From(), 10) << ", " << toString(To(), 10) << ']';
 }
+LLVM_DUMP_METHOD void Range::dump() const { dump(llvm::errs()); }
 
-void RangeSet::dump(raw_ostream &OS) const {
+LLVM_DUMP_METHOD void RangeSet::dump(raw_ostream &OS) const {
   OS << "{ ";
   llvm::interleaveComma(*this, OS, [&OS](const Range &R) { R.dump(OS); });
   OS << " }";
 }
+LLVM_DUMP_METHOD void RangeSet::dump() const { dump(llvm::errs()); }
 
 REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(SymbolSet, SymbolRef)
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -48,6 +48,7 @@
 ID.AddPointer(&To());
   }
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   // In order to keep non-overlapping ranges sorted, we can compare only From
   // points.
@@ -282,6 +283,7 @@
   bool contains(llvm::APSInt Point) const { return containsImpl(Point); }
 
   void dump(raw_ostream &OS) const;
+  void dump() const;
 
   bool operator==(const RangeSet &Other) const { return *Impl == *Other.Impl; }
   bool operator!=(const RangeSet &Other) const { return !(*this == Other); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111195: [clang][Tooling] Use Windows command lines on all Windows, except Cygwin

2021-10-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D95#3044594 , @mstorsjo wrote:

> This looks ok to me I guess. Technically in this case, this is pretty much 
> equivalent to `#ifdef _WIN32`, i.e. any form when running on windows, where 
> the process considers itself windows (cygwin doesn't define `_WIN32`), but I 
> guess keeping it based on `getProcessTriple()` is fine too.
>
> I'll leave it open for discussion for a while, but if there's no further 
> opinions I can accept it later.
>
> @rnk Do you happen to have any experience here?

I think the largest producer of JSON compilation databases with untokenized 
command line strings is CMake. If CMake uses Windows quoting rules to build up 
command lines, then clang should make the same assumption.




Comment at: clang/lib/Tooling/JSONCompilationDatabase.cpp:138-144
 Syntax = JSONCommandLineSyntax::Gnu;
 llvm::Triple Triple(llvm::sys::getProcessTriple());
-if (Triple.getOS() == llvm::Triple::OSType::Win32) {
+if (Triple.isOSWindows()) {
   // Assume Windows command line parsing on Win32 unless the triple
   // explicitly tells us otherwise.
-  if (!Triple.hasEnvironment() ||
-  Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
+  if (!Triple.isWindowsCygwinEnvironment())
 Syntax = JSONCommandLineSyntax::Windows;

This seems like it can be simplified to:
  Syntax = (Triple.isOSWindows() && !Triple.isWindowsCygwinEnvironment()) ?
JSONCommandLineSyntax::Windows : JSONCommandLineSyntax::Gnu;
Alternatively, the ifdef _WIN32 would work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95

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


[clang] afdac5f - [clang] Allow printing 64 bit ints in diagnostics

2021-10-06 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-06T09:53:47-07:00
New Revision: afdac5fbcb6a375245d435e4427086a376de59ff

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

LOG: [clang] Allow printing 64 bit ints in diagnostics

Currently we're limited to 32 bit ints in diagnostics.
With support for 4GB alignments coming soon, we need to report 4GB as the max 
alignment allowed.
I've tested that this does indeed properly print 2^32.

Reviewed By: rsmith

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

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/NestedNameSpecifier.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Sema/ParsedAttr.h
clang/lib/Basic/Diagnostic.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 651f98adc733..6366d6e8837e 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -374,8 +374,7 @@ struct ParsedTargetAttr {
 
 inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
  const Attr *At) {
-  DB.AddTaggedVal(reinterpret_cast(At),
-  DiagnosticsEngine::ak_attr);
+  DB.AddTaggedVal(reinterpret_cast(At), DiagnosticsEngine::ak_attr);
   return DB;
 }
 }  // end namespace clang

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index d124ed282bb1..b46499203b0b 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4589,7 +4589,7 @@ class EmptyDecl : public Decl {
 /// into a diagnostic with <<.
 inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
  const NamedDecl *ND) {
-  PD.AddTaggedVal(reinterpret_cast(ND),
+  PD.AddTaggedVal(reinterpret_cast(ND),
   DiagnosticsEngine::ak_nameddecl);
   return PD;
 }

diff  --git a/clang/include/clang/AST/NestedNameSpecifier.h 
b/clang/include/clang/AST/NestedNameSpecifier.h
index 8bc3e25c0f4b..eb01780598a7 100644
--- a/clang/include/clang/AST/NestedNameSpecifier.h
+++ b/clang/include/clang/AST/NestedNameSpecifier.h
@@ -521,7 +521,7 @@ class NestedNameSpecifierLocBuilder {
 /// NestedNameSpecifiers into a diagnostic with <<.
 inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
  NestedNameSpecifier *NNS) {
-  DB.AddTaggedVal(reinterpret_cast(NNS),
+  DB.AddTaggedVal(reinterpret_cast(NNS),
   DiagnosticsEngine::ak_nestednamespec);
   return DB;
 }

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index b8d72f904d0b..f8c1fe91085f 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -7146,7 +7146,7 @@ inline const StreamingDiagnostic &operator<<(const 
StreamingDiagnostic &PD,
 /// into a diagnostic with <<.
 inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
  QualType T) {
-  PD.AddTaggedVal(reinterpret_cast(T.getAsOpaquePtr()),
+  PD.AddTaggedVal(reinterpret_cast(T.getAsOpaquePtr()),
   DiagnosticsEngine::ak_qualtype);
   return PD;
 }

diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index efb725845d3e..e5577e74fa63 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -164,9 +164,9 @@ struct DiagnosticStorage {
   /// The values for the various substitution positions.
   ///
   /// This is used when the argument is not an std::string. The specific value
-  /// is mangled into an intptr_t and the interpretation depends on exactly
+  /// is mangled into an uint64_t and the interpretation depends on exactly
   /// what sort of argument kind it is.
-  intptr_t DiagArgumentsVal[MaxArguments];
+  uint64_t DiagArgumentsVal[MaxArguments];
 
   /// The values for the various substitution positions that have
   /// string arguments.
@@ -1179,7 +1179,7 @@ class StreamingDiagnostic {
 DiagStorage = nullptr;
   }
 
-  void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const {
+  void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const {
 if (!DiagStorage)
   DiagStorage = getStorage();
 
@@ -1402,6 +1402,12 @@ inline const StreamingDiagnostic &operator<<(const 
StreamingDiagnostic &DB,
   return DB;
 }
 
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ int64_t I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
+  return DB;
+}
+
 // We use enable_if here to prevent that this overlo

[PATCH] D111242: Add `TypeLoc`-related matchers.

2021-10-06 Thread James King via Phabricator via cfe-commits
jcking1034 created this revision.
jcking1034 added reviewers: ymandel, tdl-g.
jcking1034 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Contributes several matchers that involve `TypeLoc`s.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111242

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -5764,5 +5764,425 @@
  IsPlacementNew));
 }
 
+TEST(HasUnqualifiedLoc, BindsToConstIntVarDecl) {
+  EXPECT_TRUE(matches("const int x = 0;", qualifiedTypeLoc(hasUnqualifiedLoc(
+  loc(asString("int"));
+}
+
+TEST(HasUnqualifiedLoc, BindsToVolatileIntVarDecl) {
+  EXPECT_TRUE(matches("volatile int x = 0;", qualifiedTypeLoc(hasUnqualifiedLoc(
+ loc(asString("int"));
+}
+
+TEST(HasUnqualifiedLoc, BindsToConstVolatileIntPointerVarDecl) {
+  EXPECT_TRUE(
+  matches("const volatile int* x = 0;",
+  qualifiedTypeLoc(hasUnqualifiedLoc(loc(asString("int"));
+}
+
+TEST(HasUnqualifiedLoc, BindsToConstIntFunctionDecl) {
+  EXPECT_TRUE(
+  matches("const int f() { return 5; }",
+  qualifiedTypeLoc(hasUnqualifiedLoc(loc(asString("int"));
+}
+
+TEST(HasUnqualifiedLoc, FloatBindsToConstFloatVarDecl) {
+  EXPECT_TRUE(matches("const float x = 0;", qualifiedTypeLoc(hasUnqualifiedLoc(
+loc(asString("float"));
+}
+
+TEST(HasUnqualifiedLoc, FloatDoesNotBindToIntVarDecl) {
+  EXPECT_TRUE(notMatches("int x = 0;", qualifiedTypeLoc(hasUnqualifiedLoc(
+   loc(asString("float"));
+}
+
+TEST(HasUnqualifiedLoc, FloatDoesNotBindToConstIntVarDecl) {
+  EXPECT_TRUE(notMatches("const int x = 0;", qualifiedTypeLoc(hasUnqualifiedLoc(
+ loc(asString("float"));
+}
+
+TEST(HasReturnTypeLoc, BindsToIntReturnTypeLoc) {
+  EXPECT_TRUE(matches(
+  "int f() { return 5; }",
+  functionDecl(hasName("f"), hasReturnTypeLoc(loc(asString("int"));
+}
+
+TEST(HasReturnTypeLoc, BindsToFloatReturnTypeLoc) {
+  EXPECT_TRUE(matches(
+  "float f() { return 5.0; }",
+  functionDecl(hasName("f"), hasReturnTypeLoc(loc(asString("float"));
+}
+
+TEST(HasReturnTypeLoc, BindsToVoidReturnTypeLoc) {
+  EXPECT_TRUE(matches(
+  "void f() {}",
+  functionDecl(hasName("f"), hasReturnTypeLoc(loc(asString("void"));
+}
+
+TEST(HasReturnTypeLoc, FloatDoesNotBindToIntReturnTypeLoc) {
+  EXPECT_TRUE(notMatches(
+  "int f() { return 5; }",
+  functionDecl(hasName("f"), hasReturnTypeLoc(loc(asString("float"));
+}
+
+TEST(HasReturnTypeLoc, IntDoesNotBindToFloatReturnTypeLoc) {
+  EXPECT_TRUE(notMatches(
+  "float f() { return 5.0; }",
+  functionDecl(hasName("f"), hasReturnTypeLoc(loc(asString("int"));
+}
+
+TEST(HasPointeeLoc, BindsToAnyPointeeTypeLoc) {
+  auto matcher = varDecl(hasName("x"),
+ hasTypeLoc(pointerTypeLoc(hasPointeeLoc(typeLoc();
+  EXPECT_TRUE(matches("int* x;", matcher));
+  EXPECT_TRUE(matches("float* x;", matcher));
+  EXPECT_TRUE(matches("char* x;", matcher));
+  EXPECT_TRUE(matches("void* x;", matcher));
+}
+
+TEST(HasPointeeLoc, DoesNotBindToTypeLocWithoutPointee) {
+  auto matcher = varDecl(hasName("x"),
+ hasTypeLoc(pointerTypeLoc(hasPointeeLoc(typeLoc();
+  EXPECT_TRUE(notMatches("int x;", matcher));
+  EXPECT_TRUE(notMatches("float x;", matcher));
+  EXPECT_TRUE(notMatches("char x;", matcher));
+}
+
+TEST(HasPointeeLoc, BindsToTypeLocPointingToInt) {
+  EXPECT_TRUE(
+  matches("int* x;", pointerTypeLoc(hasPointeeLoc(loc(asString("int"));
+}
+
+TEST(HasPointeeLoc, BindsToTypeLocPointingToIntPointer) {
+  EXPECT_TRUE(matches("int** x;",
+  pointerTypeLoc(hasPointeeLoc(loc(asString("int *"));
+}
+
+TEST(HasPointeeLoc, BindsToTypeLocPointingToTypeLocPointingToInt) {
+  EXPECT_TRUE(matches("int** x;", pointerTypeLoc(hasPointeeLoc(pointerTypeLoc(
+  hasPointeeLoc(loc(asString("int";
+}
+
+TEST(HasPointeeLoc, BindsToTypeLocPointingToFloat) {
+  EXPECT_TRUE(matches("float* x;",
+  pointerTypeLoc(hasPointeeLoc(loc(asString("float"));
+}
+
+TEST(HasPointeeLoc, IntPointeeDoesNotBindToTypeLocPointingToFloat) {
+  EXPECT_TRUE(notMatches("float* x;",
+ pointerTypeLoc(hasPointeeLoc(loc(asString("int"));
+}
+
+TEST(HasPointeeLoc, FloatPointeeDo

[clang] df84c1f - [IR] Increase max alignment to 4GB

2021-10-06 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-06T09:54:14-07:00
New Revision: df84c1fe78130a86445d57563dea742e1b85156a

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

LOG: [IR] Increase max alignment to 4GB

Currently the max alignment representable is 1GB, see D108661.
Setting the align of an object to 4GB is desirable in some cases to make sure 
the lower 32 bits are clear which can be used for some optimizations, e.g. 
https://crbug.com/1016945.

This uses an extra bit in instructions that carry an alignment. We can store 15 
bits of "free" information, and with this change some instructions (e.g. 
AtomicCmpXchgInst) use 14 bits.
We can increase the max alignment representable above 4GB (up to 2^62) since 
we're only using 33 of the 64 values, but I've just limited it to 4GB for now.

The one place we have to update the bitcode format is for the alloca 
instruction. It stores its alignment into 5 bits of a 32 bit bitfield. I've 
added another field which is 8 bits and should be future proof for a while. For 
backward compatibility, we check if the old field has a value and use that, 
otherwise use the new field.

Updating clang's max allowed alignment will come in a future patch.

Reviewed By: hans

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

Added: 
llvm/test/CodeGen/MIR/X86/load-with-max-alignment.mir

Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenModule.cpp
llvm/include/llvm/Bitcode/BitcodeCommon.h
llvm/include/llvm/IR/DataLayout.h
llvm/include/llvm/IR/GlobalObject.h
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/IR/Instructions.h
llvm/include/llvm/IR/Value.h
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/MIRParser/MIParser.cpp
llvm/lib/CodeGen/SafeStack.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/test/Assembler/align-inst-alloca.ll
llvm/test/Assembler/align-inst-load.ll
llvm/test/Assembler/align-inst-store.ll
llvm/test/Assembler/align-inst.ll
llvm/test/Bitcode/Inputs/invalid-align.bc
llvm/test/Bitcode/inalloca.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
llvm/test/Transforms/Attributor/callbacks.ll
llvm/test/Transforms/Attributor/liveness.ll
llvm/test/Transforms/Attributor/memory_locations.ll
llvm/test/Transforms/Attributor/noalias.ll
llvm/test/Transforms/Attributor/nocapture-1.ll
llvm/test/Transforms/Attributor/noundef.ll
llvm/test/Transforms/Attributor/undefined_behavior.ll
llvm/test/Transforms/Attributor/value-simplify.ll
llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
llvm/test/Transforms/InstCombine/atomic.ll
llvm/test/Transforms/InstCombine/getelementptr.ll
llvm/test/Transforms/InstCombine/load.ll
llvm/test/Transforms/InstCombine/mempcpy.ll
llvm/test/Transforms/InstCombine/pr44245.ll
llvm/test/Transforms/InstCombine/store.ll
llvm/test/Transforms/OpenMP/parallel_level_fold.ll
llvm/test/Verifier/align-md.ll
llvm/unittests/IR/ValueTest.cpp

Removed: 
llvm/test/CodeGen/MIR/X86/load-with-1gb-alignment.mir



diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index c8bf47fdc837..2da2014345d8 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -2695,8 +2695,8 @@ const BlockByrefInfo 
&CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
 size = varOffset;
 
   // Conversely, we might have to prevent LLVM from inserting padding.
-  } else if (CGM.getDataLayout().getABITypeAlignment(varTy)
-   > varAlign.getQuantity()) {
+  } else if (CGM.getDataLayout().getABITypeAlignment(varTy) >
+ uint64_t(varAlign.getQuantity())) {
 packed = true;
   }
   types.push_back(varTy);

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index ee0a66919c31..70966c9e7b35 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5021,12 +5021,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 auto scalarAlign = 
CGM.getDataLayout().getPrefTypeAlignment(scalarType);
 
 // Materialize to a temporary.
-addr = CreateTempAlloca(
-RV.getScalarVal()->getType(),
-

[PATCH] D110451: [IR] Increase max alignment to 4GB

2021-10-06 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf84c1fe7813: [IR] Increase max alignment to 4GB (authored 
by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110451

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/Bitcode/BitcodeCommon.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/GlobalObject.h
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/Value.h
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/MIRParser/MIParser.cpp
  llvm/lib/CodeGen/SafeStack.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Assembler/align-inst-alloca.ll
  llvm/test/Assembler/align-inst-load.ll
  llvm/test/Assembler/align-inst-store.ll
  llvm/test/Assembler/align-inst.ll
  llvm/test/Bitcode/Inputs/invalid-align.bc
  llvm/test/Bitcode/inalloca.ll
  llvm/test/CodeGen/MIR/X86/load-with-1gb-alignment.mir
  llvm/test/CodeGen/MIR/X86/load-with-max-alignment.mir
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/liveness.ll
  llvm/test/Transforms/Attributor/memory_locations.ll
  llvm/test/Transforms/Attributor/noalias.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/Attributor/value-simplify.ll
  llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/getelementptr.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mempcpy.ll
  llvm/test/Transforms/InstCombine/pr44245.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/OpenMP/parallel_level_fold.ll
  llvm/test/Verifier/align-md.ll
  llvm/unittests/IR/ValueTest.cpp

Index: llvm/unittests/IR/ValueTest.cpp
===
--- llvm/unittests/IR/ValueTest.cpp
+++ llvm/unittests/IR/ValueTest.cpp
@@ -61,9 +61,9 @@
  GlobalVariable::NotThreadLocal,
  1);
 
-  EXPECT_TRUE(Value::MaximumAlignment == 1073741824U);
-  Dummy0->setAlignment(Align(1073741824));
-  EXPECT_EQ(Dummy0->getAlignment(), 1073741824U);
+  EXPECT_TRUE(Value::MaximumAlignment == 4294967296ULL);
+  Dummy0->setAlignment(Align(4294967296ULL));
+  EXPECT_EQ(Dummy0->getAlignment(), 4294967296ULL);
 
   // Make sure the address space isn't dropped when returning this.
   Constant *Dummy1 = M->getOrInsertGlobal("dummy", Int32Ty);
@@ -101,7 +101,7 @@
  Constant::getAllOnesValue(Int32Ty), "var", nullptr,
  GlobalVariable::NotThreadLocal, 1);
 
-  EXPECT_DEATH(Var->setAlignment(Align(2147483648U)),
+  EXPECT_DEATH(Var->setAlignment(Align(8589934592ULL)),
"Alignment is greater than MaximumAlignment");
 }
 #endif
Index: llvm/test/Verifier/align-md.ll
===
--- llvm/test/Verifier/align-md.ll
+++ llvm/test/Verifier/align-md.ll
@@ -52,7 +52,7 @@
 
 define i8* @f7(i8** %x) {
 entry:
-  %y = load i8*, i8** %x, !align !{i64 2147483648}
+  %y = load i8*, i8** %x, !align !{i64 8589934592}
   ret i8* %y
 }
 ; CHECK: alignment is larger that implementation defined limit
Index: llvm/test/Transforms/OpenMP/parallel_level_fold.ll
===
--- llvm/test/Transforms/OpenMP/parallel_level_fold.ll
+++ llvm/test/Transforms/OpenMP/parallel_level_fold.ll
@@ -49,9 +49,9 @@
 
 define weak void @parallel() {
 ; CHECK-LABEL: define {{[^@]+}}@parallel() {
-; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 1073741824 null, i8 2, i1 false, i1 false)
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 4294967296 null, i8 2, i1 false, i1 false)
 ; CHECK-NEXT:call void @spmd_helper()
-; CHECK-NEXT:call void @__kmpc_parallel_51(%struct.ident_t* noalias noundef align 1073741824 null, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i8* noalias noundef align 1073741824 null, i8* noalias noundef align 1073741824 null, i8** noalias noundef align 1

[PATCH] D110781: [CUDA] Make sure is included with original __THROW defined.

2021-10-06 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 377587.
tra added a comment.

re-set __THROW to an empty value. It's still needed for CUDA-7.5


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110781

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -208,7 +208,13 @@
 // CUDA-9.2 needs host-side memcpy for some host functions in
 // device_functions.hpp
 #if CUDA_VERSION >= 9020
+// string.h needs __THROW to match the rest of the system includes.
+#pragma pop_macro("__THROW")
 #include 
+// .. but we still need to undef it in order to include other CUDA headers.
+#pragma push_macro("__THROW")
+#undef __THROW
+#define __THROW
 #endif
 #include "crt/math_functions.hpp"
 #else


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -208,7 +208,13 @@
 // CUDA-9.2 needs host-side memcpy for some host functions in
 // device_functions.hpp
 #if CUDA_VERSION >= 9020
+// string.h needs __THROW to match the rest of the system includes.
+#pragma pop_macro("__THROW")
 #include 
+// .. but we still need to undef it in order to include other CUDA headers.
+#pragma push_macro("__THROW")
+#undef __THROW
+#define __THROW
 #endif
 #include "crt/math_functions.hpp"
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f0ffff4 - [CMake] Fix typo in error message for LLD in bootstrap builds.

2021-10-06 Thread Shivam Gupta via cfe-commits

Author: Frederic Cambus
Date: 2021-10-06T22:38:12+05:30
New Revision: f043b765ee0484e5303edc82f9e528a3547e

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

LOG: [CMake] Fix typo in error message for LLD in bootstrap builds.

Reviewed By: xgupta

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f562c73af3fe..5a58d7faa9fa 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -639,7 +639,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
 # adding lld to clang-bootstrap-deps without having it enabled in
 # LLVM_ENABLE_PROJECTS just generates a cryptic error message.
 if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
-  message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is 
not in LLVM_ENABLE_PROJECTS")
+  message(FATAL_ERROR "LLD is enabled in the bootstrap build, but lld is 
not in LLVM_ENABLE_PROJECTS")
 endif()
 add_dependencies(clang-bootstrap-deps lld)
   endif()



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


[PATCH] D110836: [CMake] Fix typo in error message for LLD in bootstrap builds.

2021-10-06 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf043b765: [CMake] Fix typo in error message for LLD in 
bootstrap builds. (authored by fcambus, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110836

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -639,7 +639,7 @@
 # adding lld to clang-bootstrap-deps without having it enabled in
 # LLVM_ENABLE_PROJECTS just generates a cryptic error message.
 if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
-  message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is 
not in LLVM_ENABLE_PROJECTS")
+  message(FATAL_ERROR "LLD is enabled in the bootstrap build, but lld is 
not in LLVM_ENABLE_PROJECTS")
 endif()
 add_dependencies(clang-bootstrap-deps lld)
   endif()


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -639,7 +639,7 @@
 # adding lld to clang-bootstrap-deps without having it enabled in
 # LLVM_ENABLE_PROJECTS just generates a cryptic error message.
 if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
-  message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is not in LLVM_ENABLE_PROJECTS")
+  message(FATAL_ERROR "LLD is enabled in the bootstrap build, but lld is not in LLVM_ENABLE_PROJECTS")
 endif()
 add_dependencies(clang-bootstrap-deps lld)
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111195: [clang][Tooling] Use Windows command lines on all Windows, except Cygwin

2021-10-06 Thread Jeremy Drake via Phabricator via cfe-commits
jeremyd2019 updated this revision to Diff 377590.
jeremyd2019 added a comment.

Switched to #ifdef _WIN32 instead of checking triple


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

https://reviews.llvm.org/D95

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp


Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -135,15 +135,12 @@
 std::vector unescapeCommandLine(JSONCommandLineSyntax Syntax,
  StringRef EscapedCommandLine) {
   if (Syntax == JSONCommandLineSyntax::AutoDetect) {
+#ifdef _WIN32
+// Assume Windows command line parsing on Win32
+Syntax = JSONCommandLineSyntax::Windows;
+#else
 Syntax = JSONCommandLineSyntax::Gnu;
-llvm::Triple Triple(llvm::sys::getProcessTriple());
-if (Triple.getOS() == llvm::Triple::OSType::Win32) {
-  // Assume Windows command line parsing on Win32 unless the triple
-  // explicitly tells us otherwise.
-  if (!Triple.hasEnvironment() ||
-  Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
-Syntax = JSONCommandLineSyntax::Windows;
-}
+#endif
   }
 
   if (Syntax == JSONCommandLineSyntax::Windows) {


Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -135,15 +135,12 @@
 std::vector unescapeCommandLine(JSONCommandLineSyntax Syntax,
  StringRef EscapedCommandLine) {
   if (Syntax == JSONCommandLineSyntax::AutoDetect) {
+#ifdef _WIN32
+// Assume Windows command line parsing on Win32
+Syntax = JSONCommandLineSyntax::Windows;
+#else
 Syntax = JSONCommandLineSyntax::Gnu;
-llvm::Triple Triple(llvm::sys::getProcessTriple());
-if (Triple.getOS() == llvm::Triple::OSType::Win32) {
-  // Assume Windows command line parsing on Win32 unless the triple
-  // explicitly tells us otherwise.
-  if (!Triple.hasEnvironment() ||
-  Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
-Syntax = JSONCommandLineSyntax::Windows;
-}
+#endif
   }
 
   if (Syntax == JSONCommandLineSyntax::Windows) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110781: [CUDA] Make sure is included with original __THROW defined.

2021-10-06 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 377593.
tra added a comment.

Moved string.h inclusion to the top of the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110781

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #undef __CUDACC__
 
 // Preserve common macros that will be changed below by us or by CUDA
@@ -205,11 +206,6 @@
 #endif
 
 #if CUDA_VERSION >= 9000
-// CUDA-9.2 needs host-side memcpy for some host functions in
-// device_functions.hpp
-#if CUDA_VERSION >= 9020
-#include 
-#endif
 #include "crt/math_functions.hpp"
 #else
 #include "math_functions.hpp"


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #undef __CUDACC__
 
 // Preserve common macros that will be changed below by us or by CUDA
@@ -205,11 +206,6 @@
 #endif
 
 #if CUDA_VERSION >= 9000
-// CUDA-9.2 needs host-side memcpy for some host functions in
-// device_functions.hpp
-#if CUDA_VERSION >= 9020
-#include 
-#endif
 #include "crt/math_functions.hpp"
 #else
 #include "math_functions.hpp"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-10-06 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In D109144#3042247 , @Anastasia wrote:

> 1. Implementing SPIR-V target as SPIR target.  @bader do you suggest that we 
> add `spirv` triple to clang and map it into SPIR taget or do you suggest 
> something different?

What I have in mind is to continue using SPIR target for now (until SPIR-V 
back-end is added).
For instance, SYCL compiler emits code for SPIR target and code format is 
configured via flag.

`-emit-llvm` changes output file format for regular C++ compilation flow:

  clang++ a.cpp -c -o a.o  # object format by default 
  clang++ a.cpp -c -emit-llvm -o a.bc  # LLVM IR format with 
`-emit-llvm`

Similar approach for HIP device compilation flow:

  clang++ -target spir -x hip a.cpp -cuda-device-only -o a.spv 
# SPIR-V format by default
  clang++ -target spir -x hip a.cpp -cuda-device-only -emit-llvm -o a.bc   
# LLVM IR (aka SPIR) format with `-emit-llvm` if needed

I think this was proposed in RFC. @linjamaki, am I right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

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


[clang] 2130117 - [Clang][OpenMP] Allow loop-transformations with template parameters.

2021-10-06 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-10-06T12:21:04-05:00
New Revision: 2130117f92e51df73ac8c4b7e37f7f89178a89f2

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

LOG: [Clang][OpenMP] Allow loop-transformations with template parameters.

Clang would reject

#pragma omp for
#pragma omp tile sizes(P)
for (int i = 0; i < 128; ++i) {}

where P is a template parameter, but the loop itself is not
template-dependent. Because P context-dependent, the TransformedStmt
cannot be generated and therefore is nullptr (until the template is
instantiated by TreeTransform). The OMPForDirective would still expect
the a loop is the dependent context and trigger an error.

Fix by introducing a NumGeneratedLoops field to OMPLoopTransformation.
This is used to distinguish the case where no TransformedStmt will be
generated at all (e.g. #pragma omp unroll full) and template
instantiation is needed. In the latter case, delay resolving the
iteration space like when the for-loop itself is template-dependent
until the template instatiation.

A more radical solution would always delay the iteration space analysis
until template instantiation, but would also break many test cases.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/StmtOpenMP.h
clang/lib/AST/StmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/OpenMP/tile_ast_print.cpp
clang/test/OpenMP/unroll_ast_print.cpp

Removed: 




diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 285426d26e21..60d47b93ba79 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -959,6 +959,9 @@ class OMPLoopBasedDirective : public OMPExecutableDirective 
{
 class OMPLoopTransformationDirective : public OMPLoopBasedDirective {
   friend class ASTStmtReader;
 
+  /// Number of loops generated by this loop transformation.
+  unsigned NumGeneratedLoops = 0;
+
 protected:
   explicit OMPLoopTransformationDirective(StmtClass SC,
   OpenMPDirectiveKind Kind,
@@ -967,10 +970,16 @@ class OMPLoopTransformationDirective : public 
OMPLoopBasedDirective {
   unsigned NumAssociatedLoops)
   : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops) 
{}
 
+  /// Set the number of loops generated by this loop transformation.
+  void setNumGeneratedLoops(unsigned Num) { NumGeneratedLoops = Num; }
+
 public:
   /// Return the number of associated (consumed) loops.
   unsigned getNumAssociatedLoops() const { return getLoopsNumber(); }
 
+  /// Return the number of loops generated by this loop transformation.
+  unsigned getNumGeneratedLoops() { return NumGeneratedLoops; }
+
   /// Get the de-sugared statements after after the loop transformation.
   ///
   /// Might be nullptr if either the directive generates no loops and is 
handled
@@ -5058,7 +5067,9 @@ class OMPTileDirective final : public 
OMPLoopTransformationDirective {
 unsigned NumLoops)
   : OMPLoopTransformationDirective(OMPTileDirectiveClass,
llvm::omp::OMPD_tile, StartLoc, EndLoc,
-   NumLoops) {}
+   NumLoops) {
+setNumGeneratedLoops(3 * NumLoops);
+  }
 
   void setPreInits(Stmt *PreInits) {
 Data->getChildren()[PreInitsOffset] = PreInits;
@@ -5163,7 +5174,7 @@ class OMPUnrollDirective final : public 
OMPLoopTransformationDirective {
   static OMPUnrollDirective *
   Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
  ArrayRef Clauses, Stmt *AssociatedStmt,
- Stmt *TransformedStmt, Stmt *PreInits);
+ unsigned NumGeneratedLoops, Stmt *TransformedStmt, Stmt *PreInits);
 
   /// Build an empty '#pragma omp unroll' AST node for deserialization.
   ///

diff  --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index c615463f42da..014274f46cae 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -138,9 +138,18 @@ bool OMPLoopBasedDirective::doForAllLoops(
 
   Stmt *TransformedStmt = Dir->getTransformedStmt();
   if (!TransformedStmt) {
-// May happen if the loop transformation does not result in a
-// generated loop (such as full unrolling).
-break;
+unsigned NumGeneratedLoops = Dir->getNumGeneratedLoops();
+if (NumGeneratedLoops == 0) {
+  // May happen if the loop transformation does not result in a
+  // generated loop (such as full unrolling).
+

[PATCH] D111124: [Clang][OpenMP] Allow loop-transformations with template parameters.

2021-10-06 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2130117f92e5: [Clang][OpenMP] Allow loop-transformations 
with template parameters. (authored by Meinersbur).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D24

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/tile_ast_print.cpp
  clang/test/OpenMP/unroll_ast_print.cpp

Index: clang/test/OpenMP/unroll_ast_print.cpp
===
--- clang/test/OpenMP/unroll_ast_print.cpp
+++ clang/test/OpenMP/unroll_ast_print.cpp
@@ -124,4 +124,26 @@
   unroll_templated();
 }
 
+
+// PRINT-LABEL: template  void unroll_templated_factor(int start, int stop, int step) {
+// DUMP-LABEL:  FunctionTemplateDecl {{.*}} unroll_templated_factor
+template 
+void unroll_templated_factor(int start, int stop, int step) {
+  // PRINT: #pragma omp unroll partial(Factor)
+  // DUMP:  OMPUnrollDirective
+  // DUMP-NEXT: OMPPartialClause
+  // DUMP-NEXT:   DeclRefExpr {{.*}} 'Factor' 'int'
+  #pragma omp unroll partial(Factor)
+// PRINT-NEXT: for (int i = start; i < stop; i += step)
+// DUMP-NEXT:  ForStmt
+for (int i = start; i < stop; i += step)
+  // PRINT-NEXT: body(i);
+  // DUMP:  CallExpr
+  body(i);
+}
+void unroll_template_factor() {
+  unroll_templated_factor<4>(0, 42, 2);
+}
+
+
 #endif
Index: clang/test/OpenMP/tile_ast_print.cpp
===
--- clang/test/OpenMP/tile_ast_print.cpp
+++ clang/test/OpenMP/tile_ast_print.cpp
@@ -162,4 +162,25 @@
 }
 
 
+// PRINT-LABEL: template  void foo7(int start, int stop, int step) {
+// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo7
+template 
+void foo7(int start, int stop, int step) {
+  // PRINT: #pragma omp tile sizes(Tile)
+  // DUMP:  OMPTileDirective
+  // DUMP-NEXT:   OMPSizesClause
+  // DUMP-NEXT: DeclRefExpr {{.*}} 'Tile' 'int'
+  #pragma omp tile sizes(Tile)
+// PRINT-NEXT:  for (int i = start; i < stop; i += step)
+// DUMP-NEXT: ForStmt
+for (int i = start; i < stop; i += step)
+  // PRINT-NEXT: body(i);
+  // DUMP:  CallExpr
+  body(i);
+}
+void tfoo7() {
+  foo7<5>(0, 42, 2);
+}
+
+
 #endif
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2226,6 +2226,7 @@
 void ASTStmtWriter::VisitOMPLoopTransformationDirective(
 OMPLoopTransformationDirective *D) {
   VisitOMPLoopBasedDirective(D);
+  Record.writeUInt32(D->getNumGeneratedLoops());
 }
 
 void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective *D) {
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2327,6 +2327,7 @@
 void ASTStmtReader::VisitOMPLoopTransformationDirective(
 OMPLoopTransformationDirective *D) {
   VisitOMPLoopBasedDirective(D);
+  D->setNumGeneratedLoops(Record.readUInt32());
 }
 
 void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -12919,10 +12919,12 @@
   Body, OriginalInits))
 return StmtError();
 
+  unsigned NumGeneratedLoops = PartialClause ? 1 : 0;
+
   // Delay unrolling to when template is completely instantiated.
   if (CurContext->isDependentContext())
 return OMPUnrollDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
-  nullptr, nullptr);
+  NumGeneratedLoops, nullptr, nullptr);
 
   OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers.front();
 
@@ -12941,9 +12943,9 @@
   // The generated loop may only be passed to other loop-associated directive
   // when a partial clause is specified. Without the requirement it is
   // sufficient to generate loop unroll metadata at code-generation.
-  if (!PartialClause)
+  if (NumGeneratedLoops == 0)
 return OMPUnrollDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
-  nullptr, nullptr);
+  NumGeneratedLoops, nullptr, nullptr);
 
   // Otherwise, we need to provide a de-sugared/transformed AST that can be
   // associated with another loop directive.
@@ -13164,7 +13166,8 @@
   LoopHelper.Init->getBeginLoc(), LoopHelper.Inc->getEndLoc());
 
   return OMPUnrollDirective::Create(Context, StartLoc, EndLoc, Clauses, 

[clang] 72cf8b6 - Revert "[IR] Increase max alignment to 4GB"

2021-10-06 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-06T10:21:35-07:00
New Revision: 72cf8b60445441635745ee65ff0c1f9c1a4418fe

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

LOG: Revert "[IR] Increase max alignment to 4GB"

This reverts commit df84c1fe78130a86445d57563dea742e1b85156a.

Breaks some bots

Added: 
llvm/test/CodeGen/MIR/X86/load-with-1gb-alignment.mir

Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenModule.cpp
llvm/include/llvm/Bitcode/BitcodeCommon.h
llvm/include/llvm/IR/DataLayout.h
llvm/include/llvm/IR/GlobalObject.h
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/IR/Instructions.h
llvm/include/llvm/IR/Value.h
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/MIRParser/MIParser.cpp
llvm/lib/CodeGen/SafeStack.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/test/Assembler/align-inst-alloca.ll
llvm/test/Assembler/align-inst-load.ll
llvm/test/Assembler/align-inst-store.ll
llvm/test/Assembler/align-inst.ll
llvm/test/Bitcode/Inputs/invalid-align.bc
llvm/test/Bitcode/inalloca.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
llvm/test/Transforms/Attributor/callbacks.ll
llvm/test/Transforms/Attributor/liveness.ll
llvm/test/Transforms/Attributor/memory_locations.ll
llvm/test/Transforms/Attributor/noalias.ll
llvm/test/Transforms/Attributor/nocapture-1.ll
llvm/test/Transforms/Attributor/noundef.ll
llvm/test/Transforms/Attributor/undefined_behavior.ll
llvm/test/Transforms/Attributor/value-simplify.ll
llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
llvm/test/Transforms/InstCombine/atomic.ll
llvm/test/Transforms/InstCombine/getelementptr.ll
llvm/test/Transforms/InstCombine/load.ll
llvm/test/Transforms/InstCombine/mempcpy.ll
llvm/test/Transforms/InstCombine/pr44245.ll
llvm/test/Transforms/InstCombine/store.ll
llvm/test/Transforms/OpenMP/parallel_level_fold.ll
llvm/test/Verifier/align-md.ll
llvm/unittests/IR/ValueTest.cpp

Removed: 
llvm/test/CodeGen/MIR/X86/load-with-max-alignment.mir



diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 2da2014345d8..c8bf47fdc837 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -2695,8 +2695,8 @@ const BlockByrefInfo 
&CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
 size = varOffset;
 
   // Conversely, we might have to prevent LLVM from inserting padding.
-  } else if (CGM.getDataLayout().getABITypeAlignment(varTy) >
- uint64_t(varAlign.getQuantity())) {
+  } else if (CGM.getDataLayout().getABITypeAlignment(varTy)
+   > varAlign.getQuantity()) {
 packed = true;
   }
   types.push_back(varTy);

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 70966c9e7b35..ee0a66919c31 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5021,12 +5021,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 auto scalarAlign = 
CGM.getDataLayout().getPrefTypeAlignment(scalarType);
 
 // Materialize to a temporary.
-addr =
-CreateTempAlloca(RV.getScalarVal()->getType(),
- CharUnits::fromQuantity(std::max(
- layout->getAlignment().value(), scalarAlign)),
- "tmp",
- /*ArraySize=*/nullptr, &AllocaAddr);
+addr = CreateTempAlloca(
+RV.getScalarVal()->getType(),
+CharUnits::fromQuantity(std::max(
+(unsigned)layout->getAlignment().value(), scalarAlign)),
+"tmp",
+/*ArraySize=*/nullptr, &AllocaAddr);
 tempSize = EmitLifetimeStart(scalarSize, AllocaAddr.getPointer());
 
 Builder.CreateStore(RV.getScalarVal(), addr);

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index dfb74a3fc654..5b3d39f20b41 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1142,7 +1142,7 @@ Address CodeGenModule::createUnnamedGlobalFrom(const 
VarDecl &D,
 GV->setAlignment(Align.getAsAlign());
 GV->setUnnamedAddr(l

[PATCH] D111134: Add basic aarch64-none-elf bare metal driver.

2021-10-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:133
+
+  if (Triple.getVendor() != llvm::Triple::UnknownVendor)
+return false;

Is vendor check necessary?



Comment at: clang/test/Driver/baremetal.cpp:105
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:  -target aarch64-none-elf \

You may follow the style in `linux-cross.cpp` and enumerate include paths.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D34

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


[PATCH] D110781: [CUDA] Make sure is included with original __THROW defined.

2021-10-06 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D110781#3045280 , @jdoerfert wrote:

> I first had to read up on pop_macro -.-. Still unsure if it is OK to push it 
> once and pop it twice, that works fine?

Good catch.

> Can't we move the string include earlier, grouped with stdlib and cmath? then 
> we don't need to play with __THROW twice.

Indeed, that's a better fix. I've updated the patch.

> Other than that it seems sensible to let string have a __THROW, even though 
> none of this mismatch is really sensible at the end of the day...
>
> While we are here, we should be able to have a test, no? Something in 
> string.h that depends on __THROW being present should suffice I guess.

Tests for this header are hard to do in-tree as the header is intended to 
interact with the specific CUDA SDK headers.
All this is tested on CUDA buildbots running test-suite  and compiles the tests 
with multiple CUDA versions.
If we get `__THROW` wrong where it matters, we'll end up with compiler 
complaining about the mismatch, like it did in the bug report that prompted 
this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110781

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


[clang] a2796f1 - [Driver][test] Add Debian multiarch lib/clang/14.0.0/x86_64-linux-gnu and include/x86_64-linux-gnu/c++/v1 tests

2021-10-06 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-10-06T10:49:25-07:00
New Revision: a2796f1e86555fc0848b060a3bc0fe03e4ecf93b

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

LOG: [Driver][test] Add Debian multiarch lib/clang/14.0.0/x86_64-linux-gnu and 
include/x86_64-linux-gnu/c++/v1 tests

Added: 
clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin/.keep

clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/c++/v1/.keep

clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/i386-linux-gnu/c++/v1/.keep

clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/x86_64-linux-gnu/c++/v1/.keep

clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/i386-linux-gnu/libclang_rt.builtins.a

clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/x86_64-linux-gnu/libclang_rt.builtins.a

clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/i386-linux-gnu/.keep

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/i386-linux-gnu/libclang_rt.builtins.a

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/x86_64-linux-gnu/libclang_rt.builtins.a

Modified: 
clang/test/Driver/linux-cross.cpp

Removed: 




diff  --git 
a/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin/.keep 
b/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/c++/v1/.keep
 
b/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/c++/v1/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/i386-linux-gnu/c++/v1/.keep
 
b/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/i386-linux-gnu/c++/v1/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/x86_64-linux-gnu/c++/v1/.keep
 
b/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/include/x86_64-linux-gnu/c++/v1/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/i386-linux-gnu/libclang_rt.builtins.a
 
b/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/i386-linux-gnu/libclang_rt.builtins.a
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/x86_64-linux-gnu/libclang_rt.builtins.a
 
b/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/x86_64-linux-gnu/libclang_rt.builtins.a
new file mode 100644
index ..e69de29bb2d1

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

diff  --git 
a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/i386-linux-gnu/libclang_rt.builtins.a
 
b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/i386-linux-gnu/libclang_rt.builtins.a
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/x86_64-linux-gnu/libclang_rt.builtins.a
 
b/clang/test/Driver/Inputs/resource_dir_with_per_target_subdir_debian/lib/x86_64-linux-gnu/libclang_rt.builtins.a
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/linux-cross.cpp 
b/clang/test/Driver/linux-cross.cpp
index 2d4025f32461..98e4b7cb1baa 100644
--- a/clang/test/Driver/linux-cross.cpp
+++ b/clang/test/Driver/linux-cross.cpp
@@ -151,6 +151,55 @@
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/lib"
 // DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
 
+/// Test native x86-64 with -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on.
+/// FIXME -internal-isystem .*bin/../include/x86_64-linux-gnu/c++/v1 and 
-L[[PREFIX]]/bin/../lib/x86_64-linux-gnu are missing.
+// RUN: %clang -### %s --target=x86_64-linux-gnu 
--sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   -ccc-install-dir 
%S/Inputs/debian_per_target_tree/usr/lib/llvm-14/bin 
-resource-dir=%S/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0 
\
+// RUN:   --stdlib=libc++ --rtlib=compiler-rt 2>&1 | FileCheck %s 
--check-prefix=DEBIAN_X86_64_PER_TARGET
+// DEBIAN_X86_64_PER_TARGET:  "-resource-dir" "[

  1   2   >