[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

2021-05-04 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

I think this patch is ready to go: running the test-suite on an ARM machine 
didn't complain anything.

Well, but one thing that I'm concerned about is that from tomorrow I'll not be 
online for about three weeks. :(

I'd like to find someone who reverts this patch if there is any serious problem.




Comment at: llvm/test/Transforms/InstCombine/or.ll:1135
 ; CHECK-NEXT:ret i1 [[OR]]
 ;
   %x = icmp sge i16 %a, %b

aqjune wrote:
> This can be salvaged as well: 
> https://alive2.llvm.org/ce/z/yXF96T
> 
> But I think there are more patterns that are missing. I'll leave them as 
> missing optimization opportunities at bugzilla after this patch is reviewed.
Addressed via D101801


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D101813: [Driver] Move -print-runtime-dir and -print-resource-dir tests

2021-05-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/print-resource-dir.c:3
+// RUN:-resource-dir=%S/Inputs/resource-dir \
+// RUN:  | FileCheck %s -check-prefix=PRINT-RESOURCE-DIR
+// PRINT-RESOURCE-DIR: Inputs{{/|\\}}resource-dir

You can use `-DFILE=%S/Inputs/resource-dir` and check that the printed string 
is exactly `[[FILE]]`.

Just use `/` and let Harbomaster confirm that Windows doesn't need backslash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101813

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


[PATCH] D101884: [WebAssembly] Fix constness of pointer params to load intrinsics

2021-05-04 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, sbc100, 
dschuff.
tlively requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update the SIMD builtin load functions to take pointers to const data and update
the intrinsics themselves to not cast away constness.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101884

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --force-update
 // REQUIRES: webassembly-registered-target
 
-// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 | FileCheck %s
+// RUN: %clang %s -O2 -emit-llvm -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -Werror | FileCheck %s
 
 #include 
 
@@ -165,7 +165,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP2]]
 //
-v128_t test_v128_load8_lane(uint8_t *ptr, v128_t vec) {
+v128_t test_v128_load8_lane(const uint8_t *ptr, v128_t vec) {
   return wasm_v128_load8_lane(ptr, vec, 15);
 }
 
@@ -176,7 +176,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x i16> [[TMP1]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP2]]
 //
-v128_t test_v128_load16_lane(uint16_t *ptr, v128_t vec) {
+v128_t test_v128_load16_lane(const uint16_t *ptr, v128_t vec) {
   return wasm_v128_load16_lane(ptr, vec, 7);
 }
 
@@ -185,7 +185,7 @@
 // CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x i32> @llvm.wasm.load32.lane(i32* [[PTR:%.*]], <4 x i32> [[VEC:%.*]], i32 3)
 // CHECK-NEXT:ret <4 x i32> [[TMP0]]
 //
-v128_t test_v128_load32_lane(uint32_t *ptr, v128_t vec) {
+v128_t test_v128_load32_lane(const uint32_t *ptr, v128_t vec) {
   return wasm_v128_load32_lane(ptr, vec, 3);
 }
 
@@ -196,7 +196,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP2]]
 //
-v128_t test_v128_load64_lane(uint64_t *ptr, v128_t vec) {
+v128_t test_v128_load64_lane(const uint64_t *ptr, v128_t vec) {
   return wasm_v128_load64_lane(ptr, vec, 1);
 }
 
Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -284,28 +284,28 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
-i8x16 load8_lane(signed char *p, i8x16 v) {
+i8x16 load8_lane(const signed char *p, i8x16 v) {
   return __builtin_wasm_load8_lane(p, v, 0);
   // WEBASSEMBLY: tail call <16 x i8> @llvm.wasm.load8.lane(
   // WEBASSEMBLY-SAME: i8* %p, <16 x i8> %v, i32 0)
   // WEBASSEMBLY-NEXT: ret
 }
 
-i16x8 load16_lane(short *p, i16x8 v) {
+i16x8 load16_lane(const short *p, i16x8 v) {
   return __builtin_wasm_load16_lane(p, v, 0);
   // WEBASSEMBLY: tail call <8 x i16> @llvm.wasm.load16.lane(
   // WEBASSEMBLY-SAME: i16* %p, <8 x i16> %v, i32 0)
   // WEBASSEMBLY-NEXT: ret
 }
 
-i32x4 load32_lane(int *p, i32x4 v) {
+i32x4 load32_lane(const int *p, i32x4 v) {
   return __builtin_wasm_load32_lane(p, v, 0);
   // WEBASSEMBLY: tail call <4 x i32> @llvm.wasm.load32.lane(
   // WEBASSEMBLY-SAME: i32* %p, <4 x i32> %v, i32 0)
   // WEBASSEMBLY-NEXT: ret
 }
 
-i64x2 load64_lane(long long *p, i64x2 v) {
+i64x2 load64_lane(const long long *p, i64x2 v) {
   return __builtin_wasm_load64_lane(p, v, 0);
   // WEBASSEMBLY: tail call <2 x i64> @llvm.wasm.load64.lane(
   // WEBASSEMBLY-SAME: i64* %p, <2 x i64> %v, i32 0)
@@ -904,13 +904,13 @@
   // WEBASSEMBLY: ret
 }
 
-i32x4 load32_zero(int *p) {
+i32x4 load32_zero(const int *p) {
   return __builtin_wasm_load32_zero(p);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.load32.zero(i32* %p)
   // WEBASSEMBLY: ret
 }
 
-i64x2 load64_zero(long long *p) {
+i64x2 load64_zero(const long long *p) {
   return __builtin_wasm_load64_zero(p);
   // WEBASSEMBLY: call <2 x i64> @llvm.wasm.load64.zero(i64* %p)
   // WEBASSEMBLY: ret
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -169,18 +169,19 @@
 }
 
 #define wasm_v128_load8_lane(__ptr, __vec, __i)\
-  ((v128_t)__builtin_wasm_load8_lane((signed char *)(__ptr), (__i8x16)(__vec), \
- (__i)))
+  ((v128_t)__builtin_wasm_load8_lane((const signed char *)(__ptr), \
+ (__i8x16)(__vec), (__i)))
 
 #define wasm_v128_load16_lane(__ptr, __vec, __i)   \
-  

[PATCH] D101813: [Driver] Move -print-runtime-dir and -print-resource-dir tests

2021-05-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 342950.
phosek marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101813

Files:
  clang/test/Driver/immediate-options.c
  clang/test/Driver/print-resource-dir.c
  clang/test/Driver/print-runtime-dir.c


Index: clang/test/Driver/print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/print-runtime-dir.c
@@ -0,0 +1,11 @@
+// Default directory layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+// PRINT-RUNTIME-DIR: lib{{/|\\}}windows
+
+// Per-target directory layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-PER-TARGET %s
+// PRINT-RUNTIME-DIR-PER-TARGET: lib{{/|\\}}x86_64-pc-windows-msvc
Index: clang/test/Driver/print-resource-dir.c
===
--- /dev/null
+++ clang/test/Driver/print-resource-dir.c
@@ -0,0 +1,4 @@
+// RUN: %clang -print-resource-dir --target=x86_64-unknown-linux-gnu \
+// RUN:-resource-dir=%S/Inputs/resource-dir \
+// RUN:  | FileCheck %s -check-prefix=PRINT-RESOURCE-DIR
+// PRINT-RESOURCE-DIR: Inputs{{/|\\}}resource-dir
Index: clang/test/Driver/immediate-options.c
===
--- clang/test/Driver/immediate-options.c
+++ clang/test/Driver/immediate-options.c
@@ -12,20 +12,3 @@
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
 // DUMPVERSION: {{[0-9]+\.[0-9.]+}}
-
-// Test if the -print-resource-dir option is accepted without error.
-// Allow unspecified output because the value of CLANG_RESOURCE_DIR is unknown.
-// RUN: %clang -print-resource-dir | FileCheck %s 
-check-prefix=PRINT-RESOURCE-DIR
-// PRINT-RESOURCE-DIR: {{.+}}
-
-// Default resource-dir layout
-// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
-// RUN:-resource-dir=%S/Inputs/resource_dir \
-// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
-// PRINT-RUNTIME-DIR: lib{{/|\\}}windows
-
-// Per target dir layout
-// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
-// RUN:-resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-PER-TARGET %s
-// PRINT-RUNTIME-DIR-PER-TARGET: lib{{/|\\}}x86_64-pc-windows-msvc


Index: clang/test/Driver/print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/print-runtime-dir.c
@@ -0,0 +1,11 @@
+// Default directory layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+// PRINT-RUNTIME-DIR: lib{{/|\\}}windows
+
+// Per-target directory layout
+// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
+// RUN:-resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-PER-TARGET %s
+// PRINT-RUNTIME-DIR-PER-TARGET: lib{{/|\\}}x86_64-pc-windows-msvc
Index: clang/test/Driver/print-resource-dir.c
===
--- /dev/null
+++ clang/test/Driver/print-resource-dir.c
@@ -0,0 +1,4 @@
+// RUN: %clang -print-resource-dir --target=x86_64-unknown-linux-gnu \
+// RUN:-resource-dir=%S/Inputs/resource-dir \
+// RUN:  | FileCheck %s -check-prefix=PRINT-RESOURCE-DIR
+// PRINT-RESOURCE-DIR: Inputs{{/|\\}}resource-dir
Index: clang/test/Driver/immediate-options.c
===
--- clang/test/Driver/immediate-options.c
+++ clang/test/Driver/immediate-options.c
@@ -12,20 +12,3 @@
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
 // DUMPVERSION: {{[0-9]+\.[0-9.]+}}
-
-// Test if the -print-resource-dir option is accepted without error.
-// Allow unspecified output because the value of CLANG_RESOURCE_DIR is unknown.
-// RUN: %clang -print-resource-dir | FileCheck %s -check-prefix=PRINT-RESOURCE-DIR
-// PRINT-RESOURCE-DIR: {{.+}}
-
-// Default resource-dir layout
-// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
-// RUN:-resource-dir=%S/Inputs/resource_dir \
-// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
-// PRINT-RUNTIME-DIR: lib{{/|\\}}windows
-
-// Per target dir layout
-// RUN: %clang -print-runtime-dir --target=x86_64-pc-windows-msvc \
-// RUN:-resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN:  | FileCheck 

[PATCH] D101883: [WebAssembly] Update SIMD builtin function operand types

2021-05-04 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 342946.
tlively added a comment.

- Remove (incorrect) const pointer changes. Will fix them and put them in a 
separate revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101883

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/test/CodeGen/builtins-wasm.c


Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -857,7 +857,7 @@
   // WEBASSEMBLY: ret
 }
 
-u8x16 narrow_u_i8x16_i16x8(u16x8 low, u16x8 high) {
+u8x16 narrow_u_i8x16_i16x8(i16x8 low, i16x8 high) {
   return __builtin_wasm_narrow_u_i8x16_i16x8(low, high);
   // WEBASSEMBLY: call <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16(
   // WEBASSEMBLY-SAME: <8 x i16> %low, <8 x i16> %high)
@@ -871,7 +871,7 @@
   // WEBASSEMBLY: ret
 }
 
-u16x8 narrow_u_i16x8_i32x4(u32x4 low, u32x4 high) {
+u16x8 narrow_u_i16x8_i32x4(i32x4 low, i32x4 high) {
   return __builtin_wasm_narrow_u_i16x8_i32x4(low, high);
   // WEBASSEMBLY: call <8 x i16> @llvm.wasm.narrow.unsigned.v8i16.v4i32(
   // WEBASSEMBLY-SAME: <4 x i32> %low, <4 x i32> %high)
Index: clang/include/clang/Basic/BuiltinsWebAssembly.def
===
--- clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -185,9 +185,9 @@
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", 
"simd128")
 
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16ScV8sV8s", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8UsV8Us", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8sV8s", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", 
"simd128")
 
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", 
"simd128")


Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -857,7 +857,7 @@
   // WEBASSEMBLY: ret
 }
 
-u8x16 narrow_u_i8x16_i16x8(u16x8 low, u16x8 high) {
+u8x16 narrow_u_i8x16_i16x8(i16x8 low, i16x8 high) {
   return __builtin_wasm_narrow_u_i8x16_i16x8(low, high);
   // WEBASSEMBLY: call <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16(
   // WEBASSEMBLY-SAME: <8 x i16> %low, <8 x i16> %high)
@@ -871,7 +871,7 @@
   // WEBASSEMBLY: ret
 }
 
-u16x8 narrow_u_i16x8_i32x4(u32x4 low, u32x4 high) {
+u16x8 narrow_u_i16x8_i32x4(i32x4 low, i32x4 high) {
   return __builtin_wasm_narrow_u_i16x8_i32x4(low, high);
   // WEBASSEMBLY: call <8 x i16> @llvm.wasm.narrow.unsigned.v8i16.v4i32(
   // WEBASSEMBLY-SAME: <4 x i32> %low, <4 x i32> %high)
Index: clang/include/clang/Basic/BuiltinsWebAssembly.def
===
--- clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -185,9 +185,9 @@
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16ScV8sV8s", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8UsV8Us", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8sV8s", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101883: [WebAssembly] Update SIMD builtin function operand types

2021-05-04 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, sbc100, 
dschuff.
tlively requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Add `const` to the pointer operands of load builtins.
- Make the inputs to all narrowing builtins signed, which is how they are 
interpreted by the underlying instructions (only the result changes sign 
between instructions).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101883

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/test/CodeGen/builtins-wasm.c

Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -284,28 +284,28 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
-i8x16 load8_lane(signed char *p, i8x16 v) {
+i8x16 load8_lane(const signed char *p, i8x16 v) {
   return __builtin_wasm_load8_lane(p, v, 0);
   // WEBASSEMBLY: tail call <16 x i8> @llvm.wasm.load8.lane(
   // WEBASSEMBLY-SAME: i8* %p, <16 x i8> %v, i32 0)
   // WEBASSEMBLY-NEXT: ret
 }
 
-i16x8 load16_lane(short *p, i16x8 v) {
+i16x8 load16_lane(const short *p, i16x8 v) {
   return __builtin_wasm_load16_lane(p, v, 0);
   // WEBASSEMBLY: tail call <8 x i16> @llvm.wasm.load16.lane(
   // WEBASSEMBLY-SAME: i16* %p, <8 x i16> %v, i32 0)
   // WEBASSEMBLY-NEXT: ret
 }
 
-i32x4 load32_lane(int *p, i32x4 v) {
+i32x4 load32_lane(const int *p, i32x4 v) {
   return __builtin_wasm_load32_lane(p, v, 0);
   // WEBASSEMBLY: tail call <4 x i32> @llvm.wasm.load32.lane(
   // WEBASSEMBLY-SAME: i32* %p, <4 x i32> %v, i32 0)
   // WEBASSEMBLY-NEXT: ret
 }
 
-i64x2 load64_lane(long long *p, i64x2 v) {
+i64x2 load64_lane(const long long *p, i64x2 v) {
   return __builtin_wasm_load64_lane(p, v, 0);
   // WEBASSEMBLY: tail call <2 x i64> @llvm.wasm.load64.lane(
   // WEBASSEMBLY-SAME: i64* %p, <2 x i64> %v, i32 0)
@@ -857,7 +857,7 @@
   // WEBASSEMBLY: ret
 }
 
-u8x16 narrow_u_i8x16_i16x8(u16x8 low, u16x8 high) {
+u8x16 narrow_u_i8x16_i16x8(i16x8 low, i16x8 high) {
   return __builtin_wasm_narrow_u_i8x16_i16x8(low, high);
   // WEBASSEMBLY: call <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16(
   // WEBASSEMBLY-SAME: <8 x i16> %low, <8 x i16> %high)
@@ -871,7 +871,7 @@
   // WEBASSEMBLY: ret
 }
 
-u16x8 narrow_u_i16x8_i32x4(u32x4 low, u32x4 high) {
+u16x8 narrow_u_i16x8_i32x4(i32x4 low, i32x4 high) {
   return __builtin_wasm_narrow_u_i16x8_i32x4(low, high);
   // WEBASSEMBLY: call <8 x i16> @llvm.wasm.narrow.unsigned.v8i16.v4i32(
   // WEBASSEMBLY-SAME: <4 x i32> %low, <4 x i32> %high)
@@ -904,13 +904,13 @@
   // WEBASSEMBLY: ret
 }
 
-i32x4 load32_zero(int *p) {
+i32x4 load32_zero(const int *p) {
   return __builtin_wasm_load32_zero(p);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.load32.zero(i32* %p)
   // WEBASSEMBLY: ret
 }
 
-i64x2 load64_zero(long long *p) {
+i64x2 load64_zero(const long long *p) {
   return __builtin_wasm_load64_zero(p);
   // WEBASSEMBLY: call <2 x i64> @llvm.wasm.load64.zero(i64* %p)
   // WEBASSEMBLY: ret
Index: clang/include/clang/Basic/BuiltinsWebAssembly.def
===
--- clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -185,22 +185,22 @@
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16ScV8sV8s", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8UsV8Us", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16UcV8sV8s", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4UiV4Ui", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_promote_low_f32x4_f64x2, "V2dV4f", "nc", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4ii*C", "n", "simd128")
+TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLi*C", "n", "simd128")
 
-TARGET_BUILTIN(__builtin_wasm_load8_lane, "V16ScSc*V16ScIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load16_lane, "V8ss*V8sIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load32_lane, "V4ii*V4iIi", "n", "simd128")
-TARGET_BUILTIN(__builtin_wasm_load64_lane, "V2LLiLLi*V2LLiIi", "n", "simd128")

[PATCH] D101684: [WebAssembly] Add end-to-end codegen tests for wasm_simd128.h

2021-05-04 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

In D101684#2737842 , @penzn wrote:

> I think there is another dimension to this aside from project composition - 
> intrinsics have a tendency to "interact" with their surroundings, and it 
> better to capture the IR rather than the end result. Even if we can verify 
> that simple calls produce instructions we expect, this might not hold true is 
> the arguments change, or the call is in a different context. IR definitely 
> gives more opportunities to test things through.

Yeah, the contract that specific instructions are generated really only holds 
in trivial cases by design. I'm not sure how to best formalize that, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101684

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


[PATCH] D99755: Remove `clang/runtime`

2021-05-04 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

D101497  is more safe/conservative and gets 
the job done to prepare for`GnuInstallDirs`. Closing in favor of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

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


[PATCH] D99860: Remove `COMPILER_RT_INSTALL_PATH`

2021-05-04 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 abandoned this revision.
Ericson2314 added a comment.

D101497  is more safe/conservative and gets 
the job done to prepare for`GnuInstallDirs`. Closing in favor of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99860

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


[PATCH] D100810: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-05-04 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a subscriber: compnerd.
Ericson2314 added a comment.

@compnerd Would you like to review this one too (which the other you approved 
needs)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

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


[PATCH] D101684: [WebAssembly] Add end-to-end codegen tests for wasm_simd128.h

2021-05-04 Thread Petr Penzin via Phabricator via cfe-commits
penzn added a comment.

I think there is another dimension to this aside from project composition - 
intrinsics have a tendency to "interact" with their surroundings, and it better 
to capture the IR rather than the end result. Even if we can verify that simple 
calls produce instructions we expect, this might not hold true is the arguments 
change, or the call is in a different context. IR definitely gives more 
opportunities to test things through.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101684

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


LLVM buildmaster will be restarted tonight

2021-05-04 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be restarted at 8 PM PST today.

Thanks

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


[PATCH] D101878: [git-clang-format] Do not apply clang-format to symlinks

2021-05-04 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 342927.
pirama added a comment.

Leave two empty lines after filter_symlinks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101878

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -137,10 +137,15 @@
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
+  # The computed diff outputs absolute paths, so we must cd before accessing
+  # those files.
+  cd_to_toplevel()
+  filter_symlinks(changed_lines)
   if opts.verbose >= 1:
 ignored_files.difference_update(changed_lines)
 if ignored_files:
-  print('Ignoring changes in the following files (wrong extension):')
+  print(
+'Ignoring changes in the following files (wrong extension or 
symlink):')
   for filename in ignored_files:
 print('%s' % filename)
 if changed_lines:
@@ -151,9 +156,6 @@
 if opts.verbose >= 0:
   print('no modified files to format')
 return
-  # The computed diff outputs absolute paths, so we must cd before accessing
-  # those files.
-  cd_to_toplevel()
   if len(commits) > 1:
 old_tree = commits[1]
 new_tree = run_clang_format_and_save_to_tree(changed_lines,
@@ -337,6 +339,14 @@
   del dictionary[filename]
 
 
+def filter_symlinks(dictionary):
+  """Delete every key in `dictionary` that is a symlink."""
+  for filename in list(dictionary.keys()):
+print(os.getcwd())
+if os.path.islink(filename):
+  del dictionary[filename]
+
+
 def cd_to_toplevel():
   """Change to the top level of the git repository."""
   toplevel = run('git', 'rev-parse', '--show-toplevel')


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -137,10 +137,15 @@
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
+  # The computed diff outputs absolute paths, so we must cd before accessing
+  # those files.
+  cd_to_toplevel()
+  filter_symlinks(changed_lines)
   if opts.verbose >= 1:
 ignored_files.difference_update(changed_lines)
 if ignored_files:
-  print('Ignoring changes in the following files (wrong extension):')
+  print(
+'Ignoring changes in the following files (wrong extension or symlink):')
   for filename in ignored_files:
 print('%s' % filename)
 if changed_lines:
@@ -151,9 +156,6 @@
 if opts.verbose >= 0:
   print('no modified files to format')
 return
-  # The computed diff outputs absolute paths, so we must cd before accessing
-  # those files.
-  cd_to_toplevel()
   if len(commits) > 1:
 old_tree = commits[1]
 new_tree = run_clang_format_and_save_to_tree(changed_lines,
@@ -337,6 +339,14 @@
   del dictionary[filename]
 
 
+def filter_symlinks(dictionary):
+  """Delete every key in `dictionary` that is a symlink."""
+  for filename in list(dictionary.keys()):
+print(os.getcwd())
+if os.path.islink(filename):
+  del dictionary[filename]
+
+
 def cd_to_toplevel():
   """Change to the top level of the git repository."""
   toplevel = run('git', 'rev-parse', '--show-toplevel')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101878: [git-clang-format] Do not apply clang-format to symlinks

2021-05-04 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: MyDeveloperDay, srhines.
pirama requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes PR46992.

Git stores symlinks as text files and we should not format them even if
they have one of the requested extensions.

(Move the call to `cd_to_toplevel()` up a few lines so we can also print
the skipped symlinks during verbose output.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101878

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -137,10 +137,15 @@
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
+  # The computed diff outputs absolute paths, so we must cd before accessing
+  # those files.
+  cd_to_toplevel()
+  filter_symlinks(changed_lines)
   if opts.verbose >= 1:
 ignored_files.difference_update(changed_lines)
 if ignored_files:
-  print('Ignoring changes in the following files (wrong extension):')
+  print(
+'Ignoring changes in the following files (wrong extension or 
symlink):')
   for filename in ignored_files:
 print('%s' % filename)
 if changed_lines:
@@ -151,9 +156,6 @@
 if opts.verbose >= 0:
   print('no modified files to format')
 return
-  # The computed diff outputs absolute paths, so we must cd before accessing
-  # those files.
-  cd_to_toplevel()
   if len(commits) > 1:
 old_tree = commits[1]
 new_tree = run_clang_format_and_save_to_tree(changed_lines,
@@ -337,6 +339,13 @@
   del dictionary[filename]
 
 
+def filter_symlinks(dictionary):
+  """Delete every key in `dictionary` that is a symlink."""
+  for filename in list(dictionary.keys()):
+print(os.getcwd())
+if os.path.islink(filename):
+  del dictionary[filename]
+
 def cd_to_toplevel():
   """Change to the top level of the git repository."""
   toplevel = run('git', 'rev-parse', '--show-toplevel')


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -137,10 +137,15 @@
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
+  # The computed diff outputs absolute paths, so we must cd before accessing
+  # those files.
+  cd_to_toplevel()
+  filter_symlinks(changed_lines)
   if opts.verbose >= 1:
 ignored_files.difference_update(changed_lines)
 if ignored_files:
-  print('Ignoring changes in the following files (wrong extension):')
+  print(
+'Ignoring changes in the following files (wrong extension or symlink):')
   for filename in ignored_files:
 print('%s' % filename)
 if changed_lines:
@@ -151,9 +156,6 @@
 if opts.verbose >= 0:
   print('no modified files to format')
 return
-  # The computed diff outputs absolute paths, so we must cd before accessing
-  # those files.
-  cd_to_toplevel()
   if len(commits) > 1:
 old_tree = commits[1]
 new_tree = run_clang_format_and_save_to_tree(changed_lines,
@@ -337,6 +339,13 @@
   del dictionary[filename]
 
 
+def filter_symlinks(dictionary):
+  """Delete every key in `dictionary` that is a symlink."""
+  for filename in list(dictionary.keys()):
+print(os.getcwd())
+if os.path.islink(filename):
+  del dictionary[filename]
+
 def cd_to_toplevel():
   """Change to the top level of the git repository."""
   toplevel = run('git', 'rev-parse', '--show-toplevel')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-05-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:1914-1915
+  BuildMI(MBB, MI, DL, get(AArch64::LDRXui))
+  .addReg(Reg, getKillRegState(false))
+  .addReg(Reg, RegState::Define)
+  .addImm(Options.StackProtectorGuardOffset >> 3);

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > nickdesaulniers wrote:
> > > @efriedma can you please check that I have these flags correct? I'm not 
> > > sure that I do.  Also, I suspect that I can't allocated a virtual 
> > > register for the result of the LDR, since this is post-RA?
> > @efriedma bumping for review; otherwise can you suggest another reviewer?
> In particular, I'm most curious about the use of `RegState::Renamable`; the 
> result of reading via `mrs` is a temporary; but this is post-RA, so isn't it 
> too late for further register renaming?
Additionally, if it's a temporary, should it be `RegState::Implicit`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

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


[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-05-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:1914-1915
+  BuildMI(MBB, MI, DL, get(AArch64::LDRXui))
+  .addReg(Reg, getKillRegState(false))
+  .addReg(Reg, RegState::Define)
+  .addImm(Options.StackProtectorGuardOffset >> 3);

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > @efriedma can you please check that I have these flags correct? I'm not 
> > sure that I do.  Also, I suspect that I can't allocated a virtual register 
> > for the result of the LDR, since this is post-RA?
> @efriedma bumping for review; otherwise can you suggest another reviewer?
In particular, I'm most curious about the use of `RegState::Renamable`; the 
result of reading via `mrs` is a temporary; but this is post-RA, so isn't it 
too late for further register renaming?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

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


[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-05-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 342921.
nickdesaulniers added a comment.

- prefer addDef, explicit register kills


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/stack-protector-guard.c
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll

Index: llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
@@ -0,0 +1,73 @@
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=0 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NO-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=8 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-POSITIVE-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=-8 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NEGATIVE-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=1 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NPOT-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=-1 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NPOT-NEG-OFFSET %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+; Verify that we `mrs` from `SP_EL0` twice, rather than load from
+; __stack_chk_guard.
+define dso_local void @foo(i64 %t) local_unnamed_addr #0 {
+; CHECK-LABEL:   foo:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT:stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
+; CHECK-NEXT:mov x29, sp
+; CHECK-NEXT:sub sp, sp, #16 // =16
+; CHECK-NEXT:.cfi_def_cfa w29, 16
+; CHECK-NEXT:.cfi_offset w30, -8
+; CHECK-NEXT:.cfi_offset w29, -16
+; CHECK-NEXT:mrs x8, SP_EL0
+; CHECK-NO-OFFSET:   ldr x8, [x8]
+; CHECK-POSITIVE-OFFSET: ldr x8, [x8, #8]
+; CHECK-NEGATIVE-OFFSET: ldr x8, [x8, #-8]
+; CHECK-NPOT-OFFSET: ldur x8, [x8, #1]
+; CHECK-NPOT-NEG-OFFSET: ldur x8, [x8, #-1]
+; CHECK-NEXT:lsl x9, x0, #2
+; CHECK-NEXT:add x9, x9, #15 // =15
+; CHECK-NEXT:and x9, x9, #0xfff0
+; CHECK-NEXT:stur x8, [x29, #-8]
+; CHECK-NEXT:mov x8, sp
+; CHECK-NEXT:sub x0, x8, x9
+; CHECK-NEXT:mov sp, x0
+; CHECK-NEXT:bl baz
+; CHECK-NEXT:ldur x8, [x29, #-8]
+; CHECK-NEXT:mrs x9, SP_EL0
+; CHECK-NO-OFFSET:   ldr x9, [x9]
+; CHECK-POSITIVE-OFFSET: ldr x9, [x9, #8]
+; CHECK-NEGATIVE-OFFSET: ldr x9, [x9, #-8]
+; CHECK-NPOT-OFFSET: ldur x9, [x9, #1]
+; CHECK-NPOT-NEG-OFFSET: ldur x9, [x9, #-1]
+; CHECK-NEXT:cmp x9, x8
+; CHECK-NEXT:b.ne .LBB0_2
+; CHECK-NEXT:  // %bb.1: // %entry
+; CHECK-NEXT:mov sp, x29
+; CHECK-NEXT:ldp x29, x30, [sp], #16 // 16-byte Folded Reload
+; CHECK-NEXT:ret
+; CHECK-NEXT:  .LBB0_2: // %entry
+; CHECK-NEXT:bl __stack_chk_fail
+; CHECK-NOT: __stack_chk_guard
+entry:
+  %vla = alloca i32, i64 %t, align 4
+  call void @baz(i32* nonnull %vla)
+  ret void
+}
+
+declare dso_local void @baz(i32*) local_unnamed_addr
+
+attributes #0 = { sspstrong }
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -1901,6 +1901,30 @@
   }
 
   Register Reg = MI.getOperand(0).getReg();
+  if (MI.getOpcode() == AArch64::LOAD_STACK_GUARD) {
+TargetOptions Options = MI.getParent()->getParent()->getTarget().Options;
+if (Options.StackProtectorGuard == StackProtectorGuards::SysReg) {
+  const AArch64SysReg::SysReg *SrcReg =
+  AArch64SysReg::lookupSysRegByName(Options.StackProtectorGuardReg);
+  assert(SrcReg && "Unable to encode SysReg");
+  BuildMI(MBB, MI, DL, get(AArch64::MRS))
+  .addDef(Reg, RegState::Renamable)
+  .addImm(SrcReg->Encoding);
+  if (Options.StackProtectorGuardOffset % 8 == 0)
+BuildMI(MBB, MI, DL, get(AArch64::LDRXui))
+.addUse(Reg, RegState::Kill)
+.addDef(Reg)
+.addImm(Options.StackProtectorGuardOffset >> 3);
+  else
+BuildMI(MBB, MI, DL, get(AArch64::LDURXi))
+.addUse(Reg, RegState::Kill)
+.addDef(Reg)
+

[PATCH] D101876: [clang] Support -fpic -fno-semantic-interposition for RISCV

2021-05-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: craig.topper, jrtc27, luismarques, serge-sans-paille.
Herald added subscribers: StephenFan, vkmr, evandro, sameer.abuasal, s.egerton, 
Jim, benna, psnobl, rogfer01, shiva0217, kito-cheng, simoncook.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

-fno-semantic-interposition can optimize default visibility external
linkage (non-ifunc-non-COMDAT) access to not use GOT, e.g.

  int var;
  int load() { return var; }

-fpic (var is dso_preemptable) vs -fpic -fno-semantic-interposition (var is 
dso_local)

  -   auipc   a0, %got_pcrel_hi(var)
  -   ld  a0, %pcrel_lo(.LBB2_1)(a0)
  +   auipc   a0, %pcrel_hi(.Lvar$local)
  +   addia0, a0, %pcrel_lo(.LBB2_1)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101876

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsemantic-interposition.c


Index: clang/test/Driver/fsemantic-interposition.c
===
--- clang/test/Driver/fsemantic-interposition.c
+++ clang/test/Driver/fsemantic-interposition.c
@@ -10,6 +10,8 @@
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
+// RUN: %clang -target riscv32 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
+// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4718,7 +4718,7 @@
  options::OPT_fno_semantic_interposition);
 if (RelocationModel != llvm::Reloc::Static && !IsPIE) {
   // The supported targets need to call AsmPrinter::getSymbolPreferLocal.
-  bool SupportsLocalAlias = Triple.isX86();
+  bool SupportsLocalAlias = Triple.isRISCV() || Triple.isX86();
   if (!A)
 CmdArgs.push_back("-fhalf-no-semantic-interposition");
   else if (A->getOption().matches(options::OPT_fsemantic_interposition))


Index: clang/test/Driver/fsemantic-interposition.c
===
--- clang/test/Driver/fsemantic-interposition.c
+++ clang/test/Driver/fsemantic-interposition.c
@@ -10,6 +10,8 @@
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
+// RUN: %clang -target riscv32 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
+// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4718,7 +4718,7 @@
  options::OPT_fno_semantic_interposition);
 if (RelocationModel != llvm::Reloc::Static && !IsPIE) {
   // The supported targets need to call AsmPrinter::getSymbolPreferLocal.
-  bool SupportsLocalAlias = Triple.isX86();
+  bool SupportsLocalAlias = Triple.isRISCV() || Triple.isX86();
   if (!A)
 CmdArgs.push_back("-fhalf-no-semantic-interposition");
   else if (A->getOption().matches(options::OPT_fsemantic_interposition))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-05-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:1914-1915
+  BuildMI(MBB, MI, DL, get(AArch64::LDRXui))
+  .addReg(Reg, getKillRegState(false))
+  .addReg(Reg, RegState::Define)
+  .addImm(Options.StackProtectorGuardOffset >> 3);

nickdesaulniers wrote:
> @efriedma can you please check that I have these flags correct? I'm not sure 
> that I do.  Also, I suspect that I can't allocated a virtual register for the 
> result of the LDR, since this is post-RA?
@efriedma bumping for review; otherwise can you suggest another reviewer?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

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


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-04 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/include/llvm/CodeGen/MIRYamlMapping.h:351
 IO.enumCase(ID, "scalable-vector", TargetStackID::ScalableVector);
+IO.enumCase(ID, "object", TargetStackID::Object);
 IO.enumCase(ID, "noalloc", TargetStackID::NoAlloc);

Is there a good test to demonstrate this change in?



Comment at: llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp:34-36
+// runs between then and DAG building time, though, so instead we hoist stack
+// objects lazily when they are first used, and comprehensively after the DAG 
is
+// built via the PreprocessISelDAG hook, called by the

Why do this in two places instead of just once comprehensively in the hook? It 
would be good to explain that in the comment, too.



Comment at: llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp:63-64
+  MFI.setObjectOffset(FrameIndex, Local);
+  // Allocate WebAssembly locals for each non-aggregate component of the
+  // allocation.
+  for (EVT ValueVT : ValueVTs)

Can there be aggregate components? What do we do with them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-04 Thread Giorgis Georgakoudis 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 rG956cae2f09b2: [OpenMP][NFC] Refactor Clang OpenMP tests 
using update_cc_test_checks (authored by ggeorgakoudis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101849

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/ordered_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  

[PATCH] D101873: [clang] Support clang -fpic -fno-semantic-interposition for AArch64 Depends on D101872

2021-05-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: dmgreen, efriedma, peter.smith.
Herald added subscribers: danielkiss, s.egerton, simoncook, kristof.beyls.
MaskRay 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/D101873

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsemantic-interposition.c


Index: clang/test/Driver/fsemantic-interposition.c
===
--- clang/test/Driver/fsemantic-interposition.c
+++ clang/test/Driver/fsemantic-interposition.c
@@ -10,6 +10,7 @@
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
+// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
@@ -20,8 +21,8 @@
 /// local aliases, use the traditional half-baked behavor: interprocedural
 /// optimizations are allowed but local aliases are not used. If references are
 /// not optimized out, semantic interposition at runtime is possible.
-// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
 // RUN: %clang -target ppc64le %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
+// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
 
 // RUN: %clang -target x86_64 %s -Werror -fPIC -c -### 2>&1 | FileCheck 
--check-prefix=HALF %s
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4718,7 +4718,7 @@
  options::OPT_fno_semantic_interposition);
 if (RelocationModel != llvm::Reloc::Static && !IsPIE) {
   // The supported targets need to call AsmPrinter::getSymbolPreferLocal.
-  bool SupportsLocalAlias = Triple.isX86();
+  bool SupportsLocalAlias = Triple.isAArch64() || Triple.isX86();
   if (!A)
 CmdArgs.push_back("-fhalf-no-semantic-interposition");
   else if (A->getOption().matches(options::OPT_fsemantic_interposition))


Index: clang/test/Driver/fsemantic-interposition.c
===
--- clang/test/Driver/fsemantic-interposition.c
+++ clang/test/Driver/fsemantic-interposition.c
@@ -10,6 +10,7 @@
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
+// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
@@ -20,8 +21,8 @@
 /// local aliases, use the traditional half-baked behavor: interprocedural
 /// optimizations are allowed but local aliases are not used. If references are
 /// not optimized out, semantic interposition at runtime is possible.
-// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=HALF %s
 // RUN: %clang -target ppc64le %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=HALF %s
+// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=HALF %s
 
 // RUN: %clang -target x86_64 %s -Werror -fPIC -c -### 2>&1 | FileCheck --check-prefix=HALF %s
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4718,7 +4718,7 @@
  options::OPT_fno_semantic_interposition);
 if (RelocationModel != llvm::Reloc::Static && !IsPIE) {
   // The supported targets need to call AsmPrinter::getSymbolPreferLocal.
-  bool SupportsLocalAlias = Triple.isX86();
+  bool SupportsLocalAlias = Triple.isAArch64() || Triple.isX86();
   if (!A)
 CmdArgs.push_back("-fhalf-no-semantic-interposition");
   else if (A->getOption().matches(options::OPT_fsemantic_interposition))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101805: [WebAssembly] Add codegen test for wasm_simd128.h

2021-05-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D101805#2737531 , @tlively wrote:

> At just under 4 seconds on my machine, it's certainly not one of the quickest 
> clang lit tests, but neither is it one of the slowest. It looks like there 
> are many that take tens of seconds.

Yep, sounds alright - thanks for the data!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101805

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


[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-05-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll:20
+; RUN:   --stack-protector-guard-offset=-1 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NPOT-NEG-OFFSET %s
+

DavidSpickett wrote:
> What does NPOT stand for here, something to do with the offset not being a 
> multiple of 8 bytes?
Non Power Of Two


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

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


[PATCH] D100919: [AArch64] Support customizing stack protector guard

2021-05-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 342905.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

- rebase, update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100919

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/stack-protector-guard.c
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll

Index: llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
@@ -0,0 +1,73 @@
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=0 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NO-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=8 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-POSITIVE-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=-8 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NEGATIVE-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=1 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NPOT-OFFSET %s
+; RUN: llc %s --stack-protector-guard=sysreg \
+; RUN:   --stack-protector-guard-reg=sp_el0 \
+; RUN:   --stack-protector-guard-offset=-1 -o - | \
+; RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NPOT-NEG-OFFSET %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+; Verify that we `mrs` from `SP_EL0` twice, rather than load from
+; __stack_chk_guard.
+define dso_local void @foo(i64 %t) local_unnamed_addr #0 {
+; CHECK-LABEL:   foo:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT:stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
+; CHECK-NEXT:mov x29, sp
+; CHECK-NEXT:sub sp, sp, #16 // =16
+; CHECK-NEXT:.cfi_def_cfa w29, 16
+; CHECK-NEXT:.cfi_offset w30, -8
+; CHECK-NEXT:.cfi_offset w29, -16
+; CHECK-NEXT:mrs x8, SP_EL0
+; CHECK-NO-OFFSET:   ldr x8, [x8]
+; CHECK-POSITIVE-OFFSET: ldr x8, [x8, #8]
+; CHECK-NEGATIVE-OFFSET: ldr x8, [x8, #-8]
+; CHECK-NPOT-OFFSET: ldur x8, [x8, #1]
+; CHECK-NPOT-NEG-OFFSET: ldur x8, [x8, #-1]
+; CHECK-NEXT:lsl x9, x0, #2
+; CHECK-NEXT:add x9, x9, #15 // =15
+; CHECK-NEXT:and x9, x9, #0xfff0
+; CHECK-NEXT:stur x8, [x29, #-8]
+; CHECK-NEXT:mov x8, sp
+; CHECK-NEXT:sub x0, x8, x9
+; CHECK-NEXT:mov sp, x0
+; CHECK-NEXT:bl baz
+; CHECK-NEXT:ldur x8, [x29, #-8]
+; CHECK-NEXT:mrs x9, SP_EL0
+; CHECK-NO-OFFSET:   ldr x9, [x9]
+; CHECK-POSITIVE-OFFSET: ldr x9, [x9, #8]
+; CHECK-NEGATIVE-OFFSET: ldr x9, [x9, #-8]
+; CHECK-NPOT-OFFSET: ldur x9, [x9, #1]
+; CHECK-NPOT-NEG-OFFSET: ldur x9, [x9, #-1]
+; CHECK-NEXT:cmp x9, x8
+; CHECK-NEXT:b.ne .LBB0_2
+; CHECK-NEXT:  // %bb.1: // %entry
+; CHECK-NEXT:mov sp, x29
+; CHECK-NEXT:ldp x29, x30, [sp], #16 // 16-byte Folded Reload
+; CHECK-NEXT:ret
+; CHECK-NEXT:  .LBB0_2: // %entry
+; CHECK-NEXT:bl __stack_chk_fail
+; CHECK-NOT: __stack_chk_guard
+entry:
+  %vla = alloca i32, i64 %t, align 4
+  call void @baz(i32* nonnull %vla)
+  ret void
+}
+
+declare dso_local void @baz(i32*) local_unnamed_addr
+
+attributes #0 = { sspstrong }
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -1901,6 +1901,30 @@
   }
 
   Register Reg = MI.getOperand(0).getReg();
+  if (MI.getOpcode() == AArch64::LOAD_STACK_GUARD) {
+TargetOptions Options = MI.getParent()->getParent()->getTarget().Options;
+if (Options.StackProtectorGuard == StackProtectorGuards::SysReg) {
+  const AArch64SysReg::SysReg *SrcReg =
+  AArch64SysReg::lookupSysRegByName(Options.StackProtectorGuardReg);
+  assert(SrcReg && "Unable to encode SysReg");
+  BuildMI(MBB, MI, DL, get(AArch64::MRS))
+  .addReg(Reg, RegState::Define)
+  .addImm(SrcReg->Encoding);
+  if (Options.StackProtectorGuardOffset % 8 == 0)
+BuildMI(MBB, MI, DL, get(AArch64::LDRXui))
+.addReg(Reg, getKillRegState(false))
+.addReg(Reg, RegState::Define)
+.addImm(Options.StackProtectorGuardOffset >> 3);
+  else
+BuildMI(MBB, MI, DL, get(AArch64::LDURXi))
+.addReg(Reg, getKillRegState(false))
+  

[PATCH] D101870: [clangd] Check if macro is already in the IdentifierTable before loading it

2021-05-04 Thread Queen Dela Cruz via Phabricator via cfe-commits
qdelacru created this revision.
qdelacru added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
qdelacru requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Having nested macros in the C code could cause clangd to fail an assert in 
clang::Preprocessor::setLoadedMacroDirective() and crash.

#0 0x007acd79 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/qdelacru/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x007ace30 PrintStackTraceSignalHandler(void*) 
/qdelacru/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x007aaded llvm::sys::RunSignalHandlers() 
/qdelacru/llvm-project/llvm/lib/Support/Signals.cpp:76:20
 #3 0x007ac7c1 SignalHandler(int) 
/qdelacru/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x7f096604db20 __restore_rt (/lib64/libpthread.so.0+0x12b20)
 #5 0x7f0964b307ff raise (/lib64/libc.so.6+0x377ff)
 #6 0x7f0964b1ac35 abort (/lib64/libc.so.6+0x21c35)
 #7 0x7f0964b1ab09 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21b09)
 #8 0x7f0964b28de6 (/lib64/libc.so.6+0x2fde6)
 #9 0x01004d1a 
clang::Preprocessor::setLoadedMacroDirective(clang::IdentifierInfo*, 
clang::MacroDirective*, clang::MacroDirective*) 
/qdelacru/llvm-project/clang/lib/Lex/PPMacroExpansion.cpp:116:5
#10 0x032287b5 
clang::ASTReader::resolvePendingMacro(clang::IdentifierInfo*, 
clang::ASTReader::PendingMacroInfo const&) 
/qdelacru/llvm-project/clang/lib/Serialization/ASTReader.cpp:2219:31
#11 0x0324f130 clang::ASTReader::finishPendingActions() 
/qdelacru/llvm-project/clang/lib/Serialization/ASTReader.cpp:9249:7
#12 0x0325d15e clang::ASTReader::FinishedDeserializing() 
/qdelacru/llvm-project/clang/lib/Serialization/ASTReader.cpp:11575:5
#13 0x0093c64b 
clang::ExternalASTSource::Deserializing::~Deserializing() 
/qdelacru/llvm-project/clang/include/clang/AST/ExternalASTSource.h:89:5
#14 0x0324a74f clang::ASTReader::get(llvm::StringRef) 
/qdelacru/llvm-project/clang/lib/Serialization/ASTReader.cpp:8038:10
#15 0x011c5708 clang::clangd::(anonymous 
namespace)::loadMainFilePreambleMacros(clang::Preprocessor const&, 
clang::clangd::PreambleData const&) 
/qdelacru/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1113:44
#16 0x011c5de0 clang::clangd::(anonymous 
namespace)::semaCodeComplete(std::unique_ptr >, clang::CodeCompleteOptions 
const&, clang::clangd::(anonymous namespace)::SemaCompleteInput const&, 
clang::clangd::IncludeStructure*) 
/qdelacru/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1190:3
#17 0x011c703b clang::clangd::(anonymous 
namespace)::CodeCompleteFlow::run(clang::clangd::(anonymous 
namespace)::SemaCompleteInput const&) && 
/qdelacru/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1395:21
#18 0x011ca87a clang::clangd::codeComplete(llvm::StringRef, 
clang::clangd::Position, clang::clangd::PreambleData const*, 
clang::clangd::ParseInputs const&, clang::clangd::CodeCompleteOptions, 
clang::clangd::SpeculativeFuzzyFind*) 
/qdelacru/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1865:78
#19 0x0119c351 
clang::clangd::ClangdServer::codeComplete(llvm::StringRef, 
clang::clangd::Position, clang::clangd::CodeCompleteOptions const&, 
llvm::unique_function)>)::'lambda'(llvm::Expected)::operator()(llvm::Expected)
 /qdelacru/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp:377:61
#20 0x011a821a void llvm::detail::UniqueFunctionBase 
>::CallImpl)>)::'lambda'(llvm::Expected)>(void*,
 llvm::Expected&) 
/qdelacru/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:204:16
#21 0x01554403 llvm::unique_function)>::operator()(llvm::Expectedget(). Since these macro names are store in a StringSet 
(has StringMap underlying container), the order of the iterator is not 
guaranteed to be same as the order seen in the source code.

When clangd is trying to resolve nested macros it sometimes attempts to load 
them out of order which causes a macro to be stored twice. In the example 
above, ECHO2 macro gets resolved first, but since it uses another macro that 
has not been resolved it will try to resolve/store that as well. Now there are 
two MacroDirectives stored in the Preprocessor, ECHO and ECHO2. When clangd 
tries to load the next macro, ECHO, the preprocessor fails an assert in 
clang::Preprocessor::setLoadedMacroDirective() because there is already a 
MacroDirective stored for that macro name.

In this diff, I check if the macro is already inside the IdentifierTable and if 
it is skip it so that it is not resolved twice.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101870

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


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- 

[PATCH] D101868: Adds a formatter for aligning arrays of structs

2021-05-04 Thread Fred Grim via Phabricator via cfe-commits
feg208 created this revision.
feg208 added reviewers: tinloaf, djasper, klimek, curdeius.
feg208 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This adds a new formatter to arrange array of struct initializers into neat 
columns


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101868

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16347,6 +16347,29 @@
getLLVMStyle());
 }
 
+TEST_F(FormatTest, CatchAlignArrayOfStructuresInit) {
+  auto Style = getLLVMStyle();
+  Style.AlignArrayOfStructuresInit = true;
+  verifyFormat("struct test demo[] = {\n"
+   "{56, 23,\"hello\" },\n"
+   "{-1, 93463, \"world\" },\n"
+   "{7,  5, \"!!\"}\n"
+   "};\n",
+   Style);
+  verifyFormat("struct test demo[3] = {\n"
+   "{56, 23,\"hello\" },\n"
+   "{-1, 93463, \"world\" },\n"
+   "{7,  5, \"!!\"}\n"
+   "};\n",
+   Style);
+  verifyFormat("struct test demo[3] = {\n"
+   "{int{56}, 23,\"hello\" },\n"
+   "{int{-1}, 93463, \"world\" },\n"
+   "{int{7},  5, \"!!\"}\n"
+   "};\n",
+   Style);
+}
+
 TEST_F(FormatTest, UnderstandsPragmas) {
   verifyFormat("#pragma omp reduction(| : var)");
   verifyFormat("#pragma omp reduction(+ : var)");
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -10,7 +10,9 @@
 #include "NamespaceEndCommentsFixer.h"
 #include "WhitespaceManager.h"
 #include "llvm/Support/Debug.h"
+#include 
 #include 
+#include 
 
 #define DEBUG_TYPE "format-formatter"
 
@@ -26,6 +28,62 @@
  NextNext && NextNext->is(tok::l_brace);
 }
 
+// The notion here is that we walk through the annotated line looking for
+// things like static initialization of arrays and flag them
+bool isArrayOfStructuresInit(const AnnotatedLine ) {
+  if (!Line.MustBeDeclaration)
+return false;
+  const auto *CurrentToken = Line.First;
+  enum class DetectAsiFsm {
+null,
+in_struct_decl,
+in_type_decl,
+in_var_name_decl,
+in_bracket_decl,
+finished_bracket_decl,
+outer_l_brace
+  };
+  DetectAsiFsm AsiFsm{DetectAsiFsm::null};
+  while (CurrentToken != Line.Last && CurrentToken != nullptr) {
+if (CurrentToken->is(tok::kw_struct)) {
+  if (AsiFsm != DetectAsiFsm::null)
+return false;
+  AsiFsm = DetectAsiFsm::in_struct_decl;
+} else if (CurrentToken->is(tok::identifier)) {
+  switch (AsiFsm) {
+  case DetectAsiFsm::null:
+[[clang::fallthrough]];
+  case DetectAsiFsm::in_struct_decl:
+AsiFsm = DetectAsiFsm::in_type_decl;
+break;
+  case DetectAsiFsm::in_type_decl:
+AsiFsm = DetectAsiFsm::in_var_name_decl;
+break;
+  default:
+return false;
+  }
+} else if (CurrentToken->is(tok::l_square)) {
+  if (AsiFsm != DetectAsiFsm::in_var_name_decl)
+return false;
+  AsiFsm = DetectAsiFsm::in_bracket_decl;
+} else if (CurrentToken->is(tok::numeric_constant)) {
+  if (AsiFsm != DetectAsiFsm::in_bracket_decl)
+return false;
+} else if (CurrentToken->is(tok::r_square)) {
+  if (AsiFsm != DetectAsiFsm::in_bracket_decl)
+return false;
+  AsiFsm = DetectAsiFsm::finished_bracket_decl;
+} else if (CurrentToken->is(tok::l_brace)) {
+  if (AsiFsm == DetectAsiFsm::finished_bracket_decl)
+AsiFsm = DetectAsiFsm::outer_l_brace;
+  else
+return AsiFsm == DetectAsiFsm::outer_l_brace;
+}
+CurrentToken = CurrentToken->getNextNonComment();
+  }
+  return false;
+}
+
 /// Tracks the indent level of \c AnnotatedLines across levels.
 ///
 /// \c nextLine must be called for each \c AnnotatedLine, after which \c
@@ -1101,6 +1159,176 @@
   llvm::SpecificBumpPtrAllocator Allocator;
 };
 
+/// Breaks a static array of struct initializers into regular
+/// columns
+class AlignedArrayOfStructuresInitLineFormatter : public LineFormatter {
+  struct FormatArgs {
+LineState 
+unsigned 
+unsigned FirstIndent;
+unsigned FirstStartColumn;
+bool DryRun;
+  };
+
+public:
+  AlignedArrayOfStructuresInitLineFormatter(
+  ContinuationIndenter *Indenter, WhitespaceManager *Whitespaces,
+  const FormatStyle , UnwrappedLineFormatter *BlockFormatter)
+  : LineFormatter(Indenter, Whitespaces, 

[PATCH] D101805: [WebAssembly] Add codegen test for wasm_simd128.h

2021-05-04 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

At just under 4 seconds on my machine, it's certainly not one of the quickest 
clang lit tests, but neither is it one of the slowest. It looks like there are 
many that take tens of seconds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101805

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


[PATCH] D101867: [clang][test] Update -fc++-abi tests

2021-05-04 Thread Leonard Chan 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 rG0277a24f4bba: [clang][test] Update -fc++-abi tests (authored 
by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101867

Files:
  clang/test/Driver/cxx-abi-flag.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp
  clang/test/Frontend/valid-cxx-abi.cpp


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S 
-emit-llvm -o /dev/null
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
-// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
+// These shouldn't be valid -fc++-abi values.
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=InvalidABI %s 2>&1 
| FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=Fuchsia %s 2>&1 | 
FileCheck %s -check-prefix=CASE-SENSITIVE
 // INVALID: error: Invalid C++ ABI name 'InvalidABI'
 // CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
 
-// The flag is propgated from the driver to cc1.
-// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s 
-check-prefix=CC1-FLAG
-// CC1-FLAG: -fc++-abi=InvalidABI
-
 // Some C++ ABIs are not supported on some platforms.
-// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck 
%s -check-prefix=UNSUPPORTED-FUCHSIA
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=fuchsia -triple 
i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
 // UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target 
triple 'i386'
Index: clang/test/Driver/cxx-abi-flag.cpp
===
--- /dev/null
+++ clang/test/Driver/cxx-abi-flag.cpp
@@ -0,0 +1,11 @@
+// Ensure that the driver flag is propagated to cc1.
+// RUN: %clang -### -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=ITANIUM
+// RUN: %clang -### -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=FUCHSIA
+// RUN: %clang -### -fc++-abi=microsoft -target x86_64-unknown-windows-msvc %s 
\
+// RUN:   2>&1 | FileCheck %s -check-prefix=MICROSOFT
+//
+// ITANIUM: -fc++-abi=itanium
+// FUCHSIA: -fc++-abi=fuchsia
+// MICROSOFT: -fc++-abi=microsoft


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S -emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S -emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S -emit-llvm -o /dev/null
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia 

[clang] 0277a24 - [clang][test] Update -fc++-abi tests

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T15:53:00-07:00
New Revision: 0277a24f4bbac284ba7a2ace7eeefdf6305e7f69

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

LOG: [clang][test] Update -fc++-abi tests

This attempts to move driver tests out of Frontend and to Driver, separates
RUNs that should fail from RUNs that should succeed, and prevent creating
output files or dumping output.

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

Added: 
clang/test/Driver/cxx-abi-flag.cpp
clang/test/Frontend/valid-cxx-abi.cpp

Modified: 
clang/test/Frontend/invalid-cxx-abi.cpp

Removed: 




diff  --git a/clang/test/Driver/cxx-abi-flag.cpp 
b/clang/test/Driver/cxx-abi-flag.cpp
new file mode 100644
index ..e6b13dbaf4e4
--- /dev/null
+++ b/clang/test/Driver/cxx-abi-flag.cpp
@@ -0,0 +1,11 @@
+// Ensure that the driver flag is propagated to cc1.
+// RUN: %clang -### -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=ITANIUM
+// RUN: %clang -### -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=FUCHSIA
+// RUN: %clang -### -fc++-abi=microsoft -target x86_64-unknown-windows-msvc %s 
\
+// RUN:   2>&1 | FileCheck %s -check-prefix=MICROSOFT
+//
+// ITANIUM: -fc++-abi=itanium
+// FUCHSIA: -fc++-abi=fuchsia
+// MICROSOFT: -fc++-abi=microsoft

diff  --git a/clang/test/Frontend/invalid-cxx-abi.cpp 
b/clang/test/Frontend/invalid-cxx-abi.cpp
index 2bc0aac52cc7..df1ea9463670 100644
--- a/clang/test/Frontend/invalid-cxx-abi.cpp
+++ b/clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
-// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
+// These shouldn't be valid -fc++-abi values.
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=InvalidABI %s 2>&1 
| FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=Fuchsia %s 2>&1 | 
FileCheck %s -check-prefix=CASE-SENSITIVE
 // INVALID: error: Invalid C++ ABI name 'InvalidABI'
 // CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
 
-// The flag is propgated from the driver to cc1.
-// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s 
-check-prefix=CC1-FLAG
-// CC1-FLAG: -fc++-abi=InvalidABI
-
 // Some C++ ABIs are not supported on some platforms.
-// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck 
%s -check-prefix=UNSUPPORTED-FUCHSIA
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=fuchsia -triple 
i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
 // UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target 
triple 'i386'

diff  --git a/clang/test/Frontend/valid-cxx-abi.cpp 
b/clang/test/Frontend/valid-cxx-abi.cpp
new file mode 100644
index ..99f8dc869e0d
--- /dev/null
+++ b/clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S 
-emit-llvm -o /dev/null



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


[PATCH] D101867: [clang][test] Update -fc++-abi tests

2021-05-04 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 342891.
leonardchan added a comment.

Forgot the pipe in cxx-abi-flag.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101867

Files:
  clang/test/Driver/cxx-abi-flag.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp
  clang/test/Frontend/valid-cxx-abi.cpp


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S 
-emit-llvm -o /dev/null
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
-// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
+// These shouldn't be valid -fc++-abi values.
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=InvalidABI %s 2>&1 
| FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=Fuchsia %s 2>&1 | 
FileCheck %s -check-prefix=CASE-SENSITIVE
 // INVALID: error: Invalid C++ ABI name 'InvalidABI'
 // CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
 
-// The flag is propgated from the driver to cc1.
-// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s 
-check-prefix=CC1-FLAG
-// CC1-FLAG: -fc++-abi=InvalidABI
-
 // Some C++ ABIs are not supported on some platforms.
-// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck 
%s -check-prefix=UNSUPPORTED-FUCHSIA
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=fuchsia -triple 
i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
 // UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target 
triple 'i386'
Index: clang/test/Driver/cxx-abi-flag.cpp
===
--- /dev/null
+++ clang/test/Driver/cxx-abi-flag.cpp
@@ -0,0 +1,11 @@
+// Ensure that the driver flag is propagated to cc1.
+// RUN: %clang -### -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=ITANIUM
+// RUN: %clang -### -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s \
+// RUN:   2>&1 | FileCheck %s -check-prefix=FUCHSIA
+// RUN: %clang -### -fc++-abi=microsoft -target x86_64-unknown-windows-msvc %s 
\
+// RUN:   2>&1 | FileCheck %s -check-prefix=MICROSOFT
+//
+// ITANIUM: -fc++-abi=itanium
+// FUCHSIA: -fc++-abi=fuchsia
+// MICROSOFT: -fc++-abi=microsoft


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S -emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S -emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S -emit-llvm -o /dev/null
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: 

[PATCH] D101867: [clang][test] Update -fc++-abi tests

2021-05-04 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 342889.
leonardchan marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101867

Files:
  clang/test/Driver/cxx-abi-flag.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp
  clang/test/Frontend/valid-cxx-abi.cpp


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S 
-emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S 
-emit-llvm -o /dev/null
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
-// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
+// These shouldn't be valid -fc++-abi values.
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=InvalidABI %s 2>&1 
| FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=Fuchsia %s 2>&1 | 
FileCheck %s -check-prefix=CASE-SENSITIVE
 // INVALID: error: Invalid C++ ABI name 'InvalidABI'
 // CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
 
-// The flag is propgated from the driver to cc1.
-// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s 
-check-prefix=CC1-FLAG
-// CC1-FLAG: -fc++-abi=InvalidABI
-
 // Some C++ ABIs are not supported on some platforms.
-// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck 
%s -check-prefix=UNSUPPORTED-FUCHSIA
+// RUN: not %clang_cc1 -S -emit-llvm -o /dev/null -fc++-abi=fuchsia -triple 
i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
 // UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target 
triple 'i386'
Index: clang/test/Driver/cxx-abi-flag.cpp
===
--- /dev/null
+++ clang/test/Driver/cxx-abi-flag.cpp
@@ -0,0 +1,11 @@
+// Ensure that the driver flag is propagated to cc1.
+// RUN: %clang -### -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s \
+// RUN:   2>&1 FileCheck %s -check-prefix=ITANIUM
+// RUN: %clang -### -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s \
+// RUN:   2>&1 FileCheck %s -check-prefix=FUCHSIA
+// RUN: %clang -### -fc++-abi=microsoft -target x86_64-unknown-windows-msvc %s 
\
+// RUN:   2>&1 FileCheck %s -check-prefix=MICROSOFT
+//
+// ITANIUM: -fc++-abi=itanium
+// FUCHSIA: -fc++-abi=fuchsia
+// MICROSOFT: -fc++-abi=microsoft


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -S -emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -S -emit-llvm -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -S -emit-llvm -o /dev/null
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c 

[PATCH] D101867: [clang][test] Update -fc++-abi tests

2021-05-04 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Couple cleanups, but should be better now. Thanks!

-eric




Comment at: clang/test/Driver/cxx-abi-flag.cpp:3
+// RUN: %clang -### -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s \
+// RUN:   |& FileCheck %s -check-prefix=ITANIUM
+// RUN: %clang -### -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s \

This is typically done via 2>&1 rather than |&.



Comment at: clang/test/Frontend/valid-cxx-abi.cpp:2
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s 
-fsyntax-only
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s 
-fsyntax-only

I'd add a -S -o - to each of these command lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101867

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


[PATCH] D101867: [clang][test] Update -fc++-abi tests

2021-05-04 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added a reviewer: echristo.
leonardchan added a project: clang.
Herald added a subscriber: phosek.
leonardchan requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101867

Files:
  clang/test/Driver/cxx-abi-flag.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp
  clang/test/Frontend/valid-cxx-abi.cpp


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s 
-fsyntax-only
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s 
-fsyntax-only
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s 
-fsyntax-only
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
-// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID
-// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
+// These shouldn't be valid -fc++-abi values.
+// RUN: not %clang_cc1 -fsyntax-only -fc++-abi=InvalidABI %s 2>&1 | FileCheck 
%s -check-prefix=INVALID
+// RUN: not %clang_cc1 -fsyntax-only -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s 
-check-prefix=CASE-SENSITIVE
 // INVALID: error: Invalid C++ ABI name 'InvalidABI'
 // CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
 
-// The flag is propgated from the driver to cc1.
-// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s 
-check-prefix=CC1-FLAG
-// CC1-FLAG: -fc++-abi=InvalidABI
-
 // Some C++ ABIs are not supported on some platforms.
-// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck 
%s -check-prefix=UNSUPPORTED-FUCHSIA
+// RUN: not %clang_cc1 -fsyntax-only -fc++-abi=fuchsia -triple i386 %s 2>&1 | 
FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
 // UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target 
triple 'i386'
Index: clang/test/Driver/cxx-abi-flag.cpp
===
--- /dev/null
+++ clang/test/Driver/cxx-abi-flag.cpp
@@ -0,0 +1,11 @@
+// Ensure that the driver flag is propagated to cc1.
+// RUN: %clang -### -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s \
+// RUN:   |& FileCheck %s -check-prefix=ITANIUM
+// RUN: %clang -### -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s \
+// RUN:   |& FileCheck %s -check-prefix=FUCHSIA
+// RUN: %clang -### -fc++-abi=microsoft -target x86_64-unknown-windows-msvc %s 
\
+// RUN:   |& FileCheck %s -check-prefix=MICROSOFT
+//
+// ITANIUM: -fc++-abi=itanium
+// FUCHSIA: -fc++-abi=fuchsia
+// MICROSOFT: -fc++-abi=microsoft


Index: clang/test/Frontend/valid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/valid-cxx-abi.cpp
@@ -0,0 +1,4 @@
+// These should be valid cxx abi flags for these targets.
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s -fsyntax-only
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s -fsyntax-only
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s -fsyntax-only
Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- clang/test/Frontend/invalid-cxx-abi.cpp
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,24 +1,9 @@
-// REQUIRES: x86-registered-target
-
-// These should succeed.
-// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
-// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
-// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
-
-// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
-// RUN: not %clang -c 

[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, thanks for making this happen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101849

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


[PATCH] D101851: Make clangd CompletionModel not depend on directory layout.

2021-05-04 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 accepted this revision.
usaxena95 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/quality/CompletionModel.cmake:9
 function(gen_decision_forest model filename cpp_class)
-  set(model_compiler 
${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py)
+  set(model_compiler ${CLANGD_COMPLETION_MODEL_COMPILER})
 

We can remove this variable as well and use the above var at all places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101851

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


[PATCH] D101851: Make clangd CompletionModel not depend on directory layout.

2021-05-04 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk marked an inline comment as done.
hvdijk added inline comments.



Comment at: clang-tools-extra/clangd/quality/CompletionModel.cmake:7
 # namespace-qualified class name.
+set(CLANGD_QUALITY_DIR ${CMAKE_CURRENT_LIST_DIR})
 function(gen_decision_forest model filename cpp_class)

usaxena95 wrote:
> nit: Directly refer to code generator instead of storing quality dir.
> `set(CLANGD_COMPLETION_MODEL_COMPILER 
> ${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py)`
Alright, done. Testing in progress just to be on the safe side. We could also 
get rid of `model_compiler` and use `${CLANGD_COMPLETION_MODEL_COMPILER}` 
directly, but I felt that looked bad due to the conflicting variable naming 
styles and the long lines, so I left that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101851

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


[PATCH] D101851: Make clangd CompletionModel not depend on directory layout.

2021-05-04 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk updated this revision to Diff 342881.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101851

Files:
  clang-tools-extra/clangd/quality/CompletionModel.cmake


Index: clang-tools-extra/clangd/quality/CompletionModel.cmake
===
--- clang-tools-extra/clangd/quality/CompletionModel.cmake
+++ clang-tools-extra/clangd/quality/CompletionModel.cmake
@@ -4,8 +4,9 @@
 # ${CMAKE_CURRENT_BINARY_DIR}. The generated header
 # will define a C++ class called ${cpp_class} - which may be a
 # namespace-qualified class name.
+set(CLANGD_COMPLETION_MODEL_COMPILER 
${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py)
 function(gen_decision_forest model filename cpp_class)
-  set(model_compiler 
${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py)
+  set(model_compiler ${CLANGD_COMPLETION_MODEL_COMPILER})
 
   set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
   set(header_file ${output_dir}/${filename}.h)


Index: clang-tools-extra/clangd/quality/CompletionModel.cmake
===
--- clang-tools-extra/clangd/quality/CompletionModel.cmake
+++ clang-tools-extra/clangd/quality/CompletionModel.cmake
@@ -4,8 +4,9 @@
 # ${CMAKE_CURRENT_BINARY_DIR}. The generated header
 # will define a C++ class called ${cpp_class} - which may be a
 # namespace-qualified class name.
+set(CLANGD_COMPLETION_MODEL_COMPILER ${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py)
 function(gen_decision_forest model filename cpp_class)
-  set(model_compiler ${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py)
+  set(model_compiler ${CLANGD_COMPLETION_MODEL_COMPILER})
 
   set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
   set(header_file ${output_dir}/${filename}.h)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-05-04 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: clang/test/Frontend/invalid-cxx-abi.cpp:1
+// These should succeed.
+// RUN: %clang -c -fc++-abi=itanium %s

Following up on an offline conversation :)

This should be a driver test rather than (what it ended up being) as a full end 
to end test including code generation. You'll just want to check that the clang 
command line is handled and translated, etc. It'll also let you keep some of 
the more elaborate target triples that ended up being removed. Note that the 
cc1 tests are also doing this so need to be changed as well.

I'd probably also suggest removing the not clang ones and putting those into a 
different file, but that's largely stylistic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

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


[PATCH] D96215: [clang-tidy] Aliasing: Add support for lambda captures.

2021-05-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Aliasing.cpp:45
+// Treat lambda capture by reference as a form of taking a reference.
+return llvm::any_of(LE->captures(), [Var](const LambdaCapture ) {
+  return C.capturesVariable() && C.getCaptureKind() == LCK_ByRef &&

xazax.hun wrote:
> Will this cover generalized captures? E.g.:
> ```
> int i;
> auto lambda = [foo=] { return *foo; };
> ```
This one's good; we still react on the operator & inside the init-expression. 
This one's worse however: `[ = i]` (i had such test for the next patch but 
not for this patch). Let me patch this up.


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

https://reviews.llvm.org/D96215

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


[PATCH] D101851: Make clangd CompletionModel not depend on directory layout.

2021-05-04 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/quality/CompletionModel.cmake:7
 # namespace-qualified class name.
+set(CLANGD_QUALITY_DIR ${CMAKE_CURRENT_LIST_DIR})
 function(gen_decision_forest model filename cpp_class)

nit: Directly refer to code generator instead of storing quality dir.
`set(CLANGD_COMPLETION_MODEL_COMPILER 
${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101851

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


[PATCH] D101805: [WebAssembly] Add codegen test for wasm_simd128.h

2021-05-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

how's the runtime of this test compared to others in clang? Is it worth 
splitting it up to improve test execution parallelism? (I'm guessing /probably 
not/ (guess while the file is long, it's relatively simple for the compiler 
compared to some other non-trivial template recursion tests, etc), but wanted 
to check)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101805

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


[PATCH] D101862: [clang-format] Rename common types between C#/JS

2021-05-04 Thread Eliza Velasquez via Phabricator via cfe-commits
exv created this revision.
exv added a reviewer: curdeius.
exv requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change is based on https://reviews.llvm.org/D101860


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101862

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1480,9 +1480,9 @@
 }
 case tok::equal:
   // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType
-  // TT_JsFatArrow. The always start an expression or a child block if
+  // TT_FatArrow. The always start an expression or a child block if
   // followed by a curly.
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 nextToken();
 if (FormatTok->is(tok::l_brace)) {
   // C# may break after => if the next character is a newline.
@@ -1588,7 +1588,7 @@
   --Line->Level;
   break;
 case tok::equal:
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 ++Line->Level;
 do {
   nextToken();
@@ -1791,7 +1791,7 @@
   // replace this by using parseAssigmentExpression() inside.
   do {
 if (Style.isCSharp()) {
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 nextToken();
 // Fat arrows can be followed by simple expressions or by child blocks
 // in curly braces.
@@ -1807,7 +1807,7 @@
 tryToParseJSFunction();
 continue;
   }
-  if (FormatTok->is(TT_JsFatArrow)) {
+  if (FormatTok->is(TT_FatArrow)) {
 nextToken();
 // Fat arrows can be followed by simple expressions or by child blocks
 // in curly braces.
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1358,7 +1358,7 @@
 if (!CurrentToken->isOneOf(
 TT_LambdaLSquare, TT_LambdaLBrace, TT_AttributeMacro,
 TT_ForEachMacro, TT_TypenameMacro, TT_FunctionLBrace,
-TT_ImplicitStringLiteral, TT_InlineASMBrace, TT_JsFatArrow,
+TT_ImplicitStringLiteral, TT_InlineASMBrace, TT_FatArrow,
 TT_LambdaArrow, TT_NamespaceMacro, TT_OverloadedOperator,
 TT_RegexLiteral, TT_TemplateString, TT_ObjCStringLiteral,
 TT_UntouchableMacroFunc, TT_ConstraintJunctions,
@@ -1571,13 +1571,13 @@
 tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
 Keywords.kw_set) ||
 Current.Previous->Tok.isLiteral()) {
-  Current.setType(TT_JsNonNullAssertion);
+  Current.setType(TT_NonNullAssertion);
   return;
 }
   }
   if (Current.Next &&
   Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
-Current.setType(TT_JsNonNullAssertion);
+Current.setType(TT_NonNullAssertion);
 return;
   }
 }
@@ -2167,7 +2167,7 @@
 return prec::Assignment;
   if (Current->is(TT_LambdaArrow))
 return prec::Comma;
-  if (Current->is(TT_JsFatArrow))
+  if (Current->is(TT_FatArrow))
 return prec::Assignment;
   if (Current->isOneOf(tok::semi, TT_InlineASMColon, TT_SelectorName) ||
   (Current->is(tok::comment) && NextNonComment &&
@@ -3138,7 +3138,7 @@
   return true;
 
 // Spaces around '=>'.
-if (Left.is(TT_JsFatArrow) || Right.is(TT_JsFatArrow))
+if (Left.is(TT_FatArrow) || Right.is(TT_FatArrow))
   return true;
 
 // No spaces around attribute target colons
@@ -3158,7 +3158,7 @@
   return false;
 
 // No space before null forgiving '!'.
-if (Right.is(TT_JsNonNullAssertion))
+if (Right.is(TT_NonNullAssertion))
   return false;
 
 // No space between consecutive commas '[,,]'.
@@ -3186,7 +3186,7 @@
 Right.is(tok::l_paren))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(TT_JsFatArrow))
+if (Left.is(TT_FatArrow))
   return true;
 // for await ( ...
 if (Right.is(tok::l_paren) && Left.is(Keywords.kw_await) && Left.Previous &&
@@ -3197,7 +3197,7 @@
   const FormatToken *Next = Right.MatchingParen->getNextNonComment();
   // An async arrow function, for example: `x = async () => foo();`,
   // as opposed to calling a function called async: `x = async();`
-  if (Next && Next->is(TT_JsFatArrow))
+  if (Next && Next->is(TT_FatArrow))
 return true;
 }
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
@@ -3271,9 +3271,9 

[PATCH] D101860: [clang-format] Fix C# nullable-related errors

2021-05-04 Thread Eliza Velasquez via Phabricator via cfe-commits
exv created this revision.
exv requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This diff is based on https://reviews.llvm.org/D101702.

This fixes two errors:

Previously, clang-format was splitting up type identifiers from the
nullable ?. This changes this behavior so that the type name sticks with
the operator.

Additionally, nullable operators attached to return types in interface
functions were not parsed correctly. Digging deeper, it looks like
interface bodies were being parsed differently than classes and structs,
causing MustBeDeclaration to be incorrect for interface members. They
now share the same logic.

One other change is reintroducing the CSharpNullable type independent of
JsTypeOptionalQuestion. Despite having a similar semantic purpose, their
actual syntax differs quite a bit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101860

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -848,6 +848,21 @@
   verifyFormat(R"(var x = (int?)y;)", Style); // Cast to a nullable type.
 
   verifyFormat(R"(var x = new MyContainer();)", Style); // Generics.
+
+  verifyFormat(R"(//
+public interface I {
+  int? Function();
+})",
+   Style); // Interface methods.
+
+  Style.ColumnLimit = 10;
+  verifyFormat(R"(//
+public VeryLongType? Function(
+int arg1,
+int arg2) {
+  //
+})",
+   Style); // ? sticks with identifier.
 }
 
 TEST_F(FormatTestCSharp, CSharpArraySubscripts) {
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -114,6 +114,7 @@
   void parseNew();
   void parseAccessSpecifier();
   bool parseEnum();
+  bool parseStructLike();
   void parseConcept();
   void parseRequires();
   void parseRequiresExpression(unsigned int OriginalLevel);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1316,15 +1316,7 @@
 case tok::kw_struct:
 case tok::kw_union:
 case tok::kw_class:
-  // parseRecord falls through and does not yet add an unwrapped line as a
-  // record declaration or definition can start a structural element.
-  parseRecord();
-  // This does not apply for Java, JavaScript and C#.
-  if (Style.Language == FormatStyle::LK_Java ||
-  Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) {
-if (FormatTok->is(tok::semi))
-  nextToken();
-addUnwrappedLine();
+  if (parseStructLike()) {
 return;
   }
   break;
@@ -1438,6 +1430,13 @@
 return;
   }
 
+  if (FormatTok->is(Keywords.kw_interface)) {
+if (parseStructLike()) {
+  return;
+}
+break;
+  }
+
   if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
 parseStatementMacro();
 return;
@@ -2525,6 +2524,21 @@
   // "} n, m;" will end up in one unwrapped line.
 }
 
+bool UnwrappedLineParser::parseStructLike() {
+  // parseRecord falls through and does not yet add an unwrapped line as a
+  // record declaration or definition can start a structural element.
+  parseRecord();
+  // This does not apply for Java, JavaScript and C#.
+  if (Style.Language == FormatStyle::LK_Java ||
+  Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) {
+if (FormatTok->is(tok::semi))
+  nextToken();
+addUnwrappedLine();
+return true;
+  }
+  return false;
+}
+
 namespace {
 // A class used to set and restore the Token position when peeking
 // ahead in the token source.
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1071,7 +1071,7 @@
 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
  Tok->Next->Next->is(tok::equal))) {
-  Tok->setType(TT_JsTypeOptionalQuestion);
+  Tok->setType(TT_CSharpNullable);
   break;
 }
   }
@@ -3154,7 +3154,7 @@
   return Style.SpacesInSquareBrackets;
 
 // No space before ? in nullable types.
-if (Right.is(TT_JsTypeOptionalQuestion))
+if (Right.is(TT_CSharpNullable))
   return false;
 
 // No space before null forgiving '!'.
@@ -3811,6 

[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Preferably a new one unless it's something really minor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Eliza Velasquez via Phabricator via cfe-commits
exv added a comment.

I have completed two other formatting fixes related to C# 8 nullables since my 
last commit. Should I create a new review request for those or update this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[PATCH] D96215: [clang-tidy] Aliasing: Add support for lambda captures.

2021-05-04 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Aliasing.cpp:45
+// Treat lambda capture by reference as a form of taking a reference.
+return llvm::any_of(LE->captures(), [Var](const LambdaCapture ) {
+  return C.capturesVariable() && C.getCaptureKind() == LCK_ByRef &&

Will this cover generalized captures? E.g.:
```
int i;
auto lambda = [foo=] { return *foo; };
```


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

https://reviews.llvm.org/D96215

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


[PATCH] D100934: [clang][modules] Build inferred modules

2021-05-04 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D100934#2735955 , @jansvoboda11 
wrote:

> In D100934#2733857 , @dexonsmith 
> wrote:
>
>> Given that there are four different things being done in this commit, it 
>> sounds naively like it should be four separate commits. If the logic is too 
>> intertwined to land each of the four pieces separately (certainly possible), 
>> can you quickly explain why, to motivate landing them together? (Or maybe 
>> there's an NFC refactoring that could be separated as a prep, to make the 
>> functional changes more isolated / easy to reason about?)
>
> I think that landing everything together provides more context for people 
> going through git log in the future.
>
> If you really think splitting this up would be better, how about this?
>
> 1. Fix `AsWritten` for umbrella headers/directories.
> 2. Add tests to `clang/test/Modules`.

It sounds like these two pieces could be done together (since the refactor for 
`AsWritten` seems like it deserves a test), as a commit that adds support for 
building inferred modules explicitly.

> 3. Add tests to `clang/test/ClangScanDeps`, make the necessary changes to 
> `Tooling/DependencyScanning`, add response file Python script.

Followed by this, for changing clang-scan-deps to support scanning for inferred 
modules.

WDYT?




Comment at: clang/test/ClangScanDeps/modules-inferred-explicit-build.m:10-12
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=Inferred > %t.inferred.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=System > %t.system.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp

jansvoboda11 wrote:
> dexonsmith wrote:
> > I took me a while to figure out that `.rsp` and `-to-rsp` means "response 
> > file". Can we just use `response` (or even `response-file`?) in both cases, 
> > or is `.rsp` a well-known extension I'm just not aware of?
> > 
> > I'm also not sure we want to use this in a test (see my next comment). If 
> > it's a useful utility regardless perhaps it could have a home in 
> > clang/utils.
> The Clang driver already has an option `--rsp-quoting={posix,windows}`, so I 
> think the shortcut is somewhat known. I can rename the script to 
> `module-deps-to-response-file`, if you think that's clearer. It could be 
> useful in general, co moving this  to `clang/utils` sounds fine.
It's probably fine as `rsp` then, just a name I personally didn't know.



Comment at: clang/test/ClangScanDeps/modules-inferred-explicit-build.m:13-17
+// RUN: %clang @%t.inferred.rsp -pedantic -Werror
+// RUN: %clang @%t.system.rsp -pedantic -Werror
+// RUN: %clang -x objective-c -fsyntax-only %t.dir/modules_cdb_input.cpp \
+// RUN:   -F%S/Inputs/frameworks -fmodules -fimplicit-module-maps \
+// RUN:   -pedantic -Werror @%t.tu.rsp

jansvoboda11 wrote:
> dexonsmith wrote:
> > I feel like the clang invocations that build/use modules should be in 
> > `clang/test/Modules`. Two independent things:
> > - Can clang build inferred modules explicitly? (tested in 
> > clang/test/Modules)
> > - Can clang-scan-deps generate deps for inferred modules? (tested in 
> > clang/test/ClangScanDeps)
> I agree that we should test explicit build of inferred modules in 
> `clang/test/Modules` (without `clang-scan-deps`). I'll look into it.
> 
> I'm not sure I'd be happy with only checking the dependencies produced by 
> `clang-scan-deps` here. Testing that the generated command-line actually 
> works is as important IMO, and it will be even more so when we start 
> optimizing the command line (stripping out unused header search paths, 
> definitions etc.).
I'm not sure precisely what you mean by "works". I'm not sure just checking if 
it still compiles tells us much. What's important is that the modified options 
have the same semantics, and I think a subtle change that still compiles is 
more likely than preventing compilation entirely.

I don't think it would scale to check for semantic problems here -- that needs 
a body of testcases that covers all the things modules support.

One option would be to use the testcases (or a selection of them) in 
clang/test/Modules, by adding an extra RUN line that builds 
clang-scan-deps-discovered modules both with and without command-line 
stripping. For most changes, we can arrange the AST block such that skipped 
options won't affect it, and we could compare the hash of just that block. If 
and when we start stripping ignored `-D` options we'll need something smarter, 
but we can solve that problem later. (Ideally, this would just be a mode in 
clang, `clang -Xclang -fmodules-depscan`, which does an initial depscan and 
builds the modules in order. This might actually be an improvement on the 
existing implicit modules.)

@Bigcheese, maybe you can weigh in? If you both think `clang -cc1` should be 
tested here, I'm open to it. (In that case, though, 

[PATCH] D96215: [clang-tidy] Aliasing: Add support for lambda captures.

2021-05-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D96215#2735546 , @njames93 wrote:

> Just my $0.02, We shouldn't worry too much about pathological cases like 
> that. I imagine that code would almost never appear in the wild. And for 
> cases where you don't have access to definition for `hidden_reference `, 
> there's not much that can be done anyway.

That's not what I typically tell myself; it really amazes me that for almost 
all such pathological cases there appear to be users who write such code on a 
regular basis.

That said, this specific false positive with references (unlike the two 
lambda/block false positives in this patch and the next patch) wasn't derived 
from a bug report *yet*. So i'm not super worried about it.


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

https://reviews.llvm.org/D96215

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


[PATCH] D96215: [clang-tidy] Aliasing: Add support for lambda captures.

2021-05-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 342844.
NoQ added a comment.

Unforget to add `-fblocks` to the bugprone-redundant-branch-condition checks. 
Thanks pre-commit testing! - it wasn't failing on my machine, I guess it's 
enabled by default on darwin.


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

https://reviews.llvm.org/D96215

Files:
  clang-tools-extra/clang-tidy/utils/Aliasing.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s bugprone-redundant-branch-condition %t
+// RUN: %check_clang_tidy %s bugprone-redundant-branch-condition %t \
+// RUN:   -- -- -fblocks
 
 extern unsigned peopleInTheBuilding;
 extern unsigned fireFighters;
@@ -1179,6 +1180,86 @@
   }
 }
 
+// Lambda / block captures.
+
+template  void accept_callback(T t) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void accept_block(void (^)(void)) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void wait(void) {
+  // Wait for the previously passed callback to be called.
+}
+
+void capture_and_mutate_by_lambda() {
+  bool x = true;
+  accept_callback([&]() { x = false; });
+  if (x) {
+wait();
+if (x) {
+}
+  }
+}
+
+void lambda_capture_by_value() {
+  bool x = true;
+  accept_callback([x]() { if (x) {} });
+  if (x) {
+wait();
+if (x) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'x' [bugprone-redundant-branch-condition]
+}
+  }
+}
+
+void capture_by_lambda_but_not_mutate() {
+  bool x = true;
+  accept_callback([&]() { if (x) {} });
+  if (x) {
+wait();
+// FIXME: Should warn.
+if (x) {
+}
+  }
+}
+
+void capture_and_mutate_by_block() {
+  __block bool x = true;
+  accept_block(^{ x = false; });
+  if (x) {
+wait();
+if (x) {
+}
+  }
+}
+
+void block_capture_by_value() {
+  bool x = true;
+  accept_block(^{ if (x) {} });
+  if (x) {
+wait();
+if (x) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'x' [bugprone-redundant-branch-condition]
+}
+  }
+}
+
+void capture_by_block_but_not_mutate() {
+  __block bool x = true;
+  accept_callback(^{ if (x) {} });
+  if (x) {
+wait();
+// FIXME: Should warn.
+if (x) {
+}
+  }
+}
+
 // GNU Expression Statements
 
 void negative_gnu_expression_statement() {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s bugprone-infinite-loop %t -- -- -fexceptions
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t \
+// RUN:   -- -- -fexceptions -fblocks
 
 void simple_infinite_loop1() {
   int i = 0;
@@ -378,6 +379,84 @@
   } while (i < Limit);
 }
 
+template  void accept_callback(T t) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void accept_block(void (^)(void)) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void wait(void) {
+  // Wait for the previously passed callback to be called.
+}
+
+void lambda_capture_from_outside() {
+  bool finished = false;
+  accept_callback([&]() {
+finished = true;
+  });
+  while (!finished) {
+wait();
+  }
+}
+
+void lambda_capture_from_outside_by_value() {
+  bool finished = false;
+  accept_callback([finished]() {
+if (finished) {}
+  });
+  while (!finished) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (finished) are updated in the loop body [bugprone-infinite-loop]
+wait();
+  }
+}
+
+void lambda_capture_from_outside_but_unchanged() {
+  bool finished = false;
+  accept_callback([]() {
+if (finished) {}
+  });
+  while (!finished) {
+// FIXME: Should warn.
+wait();
+  }
+}
+
+void block_capture_from_outside() {
+  __block bool finished = false;
+  accept_block(^{
+finished = true;
+  });
+  while (!finished) {
+wait();
+  }
+}
+
+void block_capture_from_outside_by_value() {
+  bool finished = false;
+  accept_block(^{
+if (finished) {}
+  });
+  while (!finished) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (finished) are updated in the loop body [bugprone-infinite-loop]
+ 

[PATCH] D101851: Make clangd CompletionModel not depend on directory layout.

2021-05-04 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk created this revision.
hvdijk added reviewers: sammccall, usaxena95.
hvdijk added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman, mgorny.
hvdijk requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.

The current code accounts for two possible layouts, but there is at least a 
third supported layout: clang-tools-extra may also be checked out as 
clang/tools/extra with the releases, which was not yet handled. Rather than 
treating that as a special case, use the location of CompletionModel.cmake to 
handle all three cases. This should address the problems that prompted D96787 
 and the problems that prompted the proposed 
revert D100625 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101851

Files:
  clang-tools-extra/clangd/quality/CompletionModel.cmake


Index: clang-tools-extra/clangd/quality/CompletionModel.cmake
===
--- clang-tools-extra/clangd/quality/CompletionModel.cmake
+++ clang-tools-extra/clangd/quality/CompletionModel.cmake
@@ -4,8 +4,9 @@
 # ${CMAKE_CURRENT_BINARY_DIR}. The generated header
 # will define a C++ class called ${cpp_class} - which may be a
 # namespace-qualified class name.
+set(CLANGD_QUALITY_DIR ${CMAKE_CURRENT_LIST_DIR})
 function(gen_decision_forest model filename cpp_class)
-  set(model_compiler 
${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py)
+  set(model_compiler ${CLANGD_QUALITY_DIR}/CompletionModelCodegen.py)
 
   set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
   set(header_file ${output_dir}/${filename}.h)


Index: clang-tools-extra/clangd/quality/CompletionModel.cmake
===
--- clang-tools-extra/clangd/quality/CompletionModel.cmake
+++ clang-tools-extra/clangd/quality/CompletionModel.cmake
@@ -4,8 +4,9 @@
 # ${CMAKE_CURRENT_BINARY_DIR}. The generated header
 # will define a C++ class called ${cpp_class} - which may be a
 # namespace-qualified class name.
+set(CLANGD_QUALITY_DIR ${CMAKE_CURRENT_LIST_DIR})
 function(gen_decision_forest model filename cpp_class)
-  set(model_compiler ${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py)
+  set(model_compiler ${CLANGD_QUALITY_DIR}/CompletionModelCodegen.py)
 
   set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
   set(header_file ${output_dir}/${filename}.h)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6c3a107 - Mark Basic/TargetCXXABI.def as textual in the module map.

2021-05-04 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2021-05-04T12:52:52-07:00
New Revision: 6c3a10760da3707186d5204bd9283e99344fa90f

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

LOG: Mark Basic/TargetCXXABI.def as textual in the module map.

Added: 


Modified: 
clang/include/clang/module.modulemap

Removed: 




diff  --git a/clang/include/clang/module.modulemap 
b/clang/include/clang/module.modulemap
index 82aba40b9f84..33fcf9dc7576 100644
--- a/clang/include/clang/module.modulemap
+++ b/clang/include/clang/module.modulemap
@@ -65,6 +65,7 @@ module Clang_Basic {
   textual header "Basic/PPCTypes.def"
   textual header "Basic/RISCVVTypes.def"
   textual header "Basic/Sanitizers.def"
+  textual header "Basic/TargetCXXABI.def"
   textual header "Basic/TokenKinds.def"
   textual header "Basic/X86Target.def"
 



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


[PATCH] D86310: [X86] Align i128 to 16 bytes in x86-64 datalayout

2021-05-04 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.
Herald added a subscriber: pengfei.

There is a risk of bitcode incompatibilities with this change, but we already 
have that the code we generate now is incompatible with GCC and results in 
crashes that way too, I don't think there's a perfect fix, I'd like it if we 
could merge this. I came up with roughly the same patch today, based on current 
sources, to fix bug #50198 before finding this one.




Comment at: llvm/lib/IR/AutoUpgrade.cpp:4323
+  // alignment. We'll handle them separately.
+  if (TT.isArch64Bit() && !DL.contains("-i128:128")) {
+auto I = DL.find("-i64:64-");

This needs to not be limited to `TT.isArch64Bit()`. i128 needs 16-byte 
alignment on all targets, and although clang disables `__int128` for X86, we 
still use it for lowering f128.


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

https://reviews.llvm.org/D86310

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


[PATCH] D99432: [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

2021-05-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D99432#2736970 , @estewart08 wrote:

> In D99432#2728788 , @ABataev wrote:
>
>> In D99432#2726997 , @estewart08 
>> wrote:
>>
>>> In D99432#2726845 , @ABataev wrote:
>>>
 In D99432#2726588 , @estewart08 
 wrote:

> In D99432#2726391 , @ABataev 
> wrote:
>
>> In D99432#2726337 , @estewart08 
>> wrote:
>>
>>> In D99432#2726060 , @ABataev 
>>> wrote:
>>>
 In D99432#2726050 , 
 @estewart08 wrote:

> In D99432#2726025 , @ABataev 
> wrote:
>
>> In D99432#2726019 , 
>> @estewart08 wrote:
>>
>>> In reference to https://bugs.llvm.org/show_bug.cgi?id=48851, I do 
>>> not see how this helps SPMD mode with team privatization of 
>>> declarations in-between target teams and parallel regions.
>>
>> Diв you try the reproducer with the applied patch?
>
> Yes, I still saw the test fail, although it was not with latest 
> llvm-project. Are you saying the reproducer passes for you?

 I don't have CUDA installed but from what I see in the LLVM IR it 
 shall pass. Do you have a debug log, does it crashes or produces 
 incorrect results?
>>>
>>> This is on an AMDGPU but I assume the behavior would be similar for 
>>> NVPTX.
>>>
>>> It produces incorrect/incomplete results in the dist[0] index after a 
>>> manual reduction and in turn the final global gpu_results array is 
>>> incorrect.
>>> When thread 0 does a reduction into dist[0] it has no knowledge of 
>>> dist[1] having been updated by thread 1. Which tells me the array is 
>>> still thread private.
>>> Adding some printfs, looking at one teams' output:
>>>
>>> SPMD
>>>
>>>   Thread 0: dist[0]: 1
>>>   Thread 0: dist[1]: 0  // This should be 1
>>>   After reduction into dist[0]: 1  // This should be 2
>>>   gpu_results = [1,1]  // [2,2] expected
>>>
>>> Generic Mode:
>>>
>>>   Thread 0: dist[0]: 1
>>>   Thread 0: dist[1]: 1   
>>>   After reduction into dist[0]: 2
>>>   gpu_results = [2,2]
>>
>> Hmm, I would expect a crash if the array was allocated in the local 
>> memory. Could you try to add some more printfs (with data and addresses 
>> of the array) to check the results? Maybe there is a data race somewhere 
>> in the code?
>
> As a reminder, each thread updates a unique index in the dist array and 
> each team updates a unique index in gpu_results.
>
> SPMD - shows each thread has a unique address for dist array
>
>   Team 0 Thread 1: dist[0]: 0, 0x7f92e24a8bf8
>   Team 0 Thread 1: dist[1]: 1, 0x7f92e24a8bfc
>   
>   Team 0 Thread 0: dist[0]: 1, 0x7f92e24a8bf0
>   Team 0 Thread 0: dist[1]: 0, 0x7f92e24a8bf4
>   
>   Team 0 Thread 0: After reduction into dist[0]: 1
>   Team 0 Thread 0: gpu_results address: 0x7f92a500
>   --
>   Team 1 Thread 1: dist[0]: 0, 0x7f92f9ec5188
>   Team 1 Thread 1: dist[1]: 1, 0x7f92f9ec518c
>   
>   Team 1 Thread 0: dist[0]: 1, 0x7f92f9ec5180
>   Team 1 Thread 0: dist[1]: 0, 0x7f92f9ec5184
>   
>   Team 1 Thread 0: After reduction into dist[0]: 1
>   Team 1 Thread 0: gpu_results address: 0x7f92a500
>   
>   gpu_results[0]: 1
>   gpu_results[1]: 1
>
> Generic - shows each team shares dist array address amongst threads
>
>   Team 0 Thread 1: dist[0]: 1, 0x7fac01938880
>   Team 0 Thread 1: dist[1]: 1, 0x7fac01938884
>   
>   Team 0 Thread 0: dist[0]: 1, 0x7fac01938880
>   Team 0 Thread 0: dist[1]: 1, 0x7fac01938884
>   
>   Team 0 Thread 0: After reduction into dist[0]: 2
>   Team 0 Thread 0: gpu_results address: 0x7fabc500
>   --
>   Team 1 Thread 1: dist[0]: 1, 0x7fac19354e10
>   Team 1 Thread 1: dist[1]: 1, 0x7fac19354e14
>   
>   Team 1 Thread 0: dist[0]: 1, 0x7fac19354e10
>   Team 1 Thread 0: dist[1]: 1, 0x7fac19354e14
>   
>   Team 1 Thread 0: After reduction into dist[0]: 2
>   Team 1 Thread 0: gpu_results address: 0x7fabc500

 Could you check if it works with 
 `-fno-openmp-cuda-parallel-target-regions` option?
>>>
>>> Unfortunately that crashes:
>>> llvm-project/llvm/lib/IR/Instructions.cpp:495: void 
>>> 

[PATCH] D101849: [OpenMP][NFC] Refactor Clang OpenMP tests using update_cc_test_checks

2021-05-04 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis created this revision.
Herald added subscribers: jfb, guansong, yaxunl.
ggeorgakoudis requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101849

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/ordered_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/sections_reduction_codegen.cpp
  

[PATCH] D99432: [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

2021-05-04 Thread Ethan Stewart via Phabricator via cfe-commits
estewart08 added a comment.

In D99432#2728788 , @ABataev wrote:

> In D99432#2726997 , @estewart08 
> wrote:
>
>> In D99432#2726845 , @ABataev wrote:
>>
>>> In D99432#2726588 , @estewart08 
>>> wrote:
>>>
 In D99432#2726391 , @ABataev 
 wrote:

> In D99432#2726337 , @estewart08 
> wrote:
>
>> In D99432#2726060 , @ABataev 
>> wrote:
>>
>>> In D99432#2726050 , 
>>> @estewart08 wrote:
>>>
 In D99432#2726025 , @ABataev 
 wrote:

> In D99432#2726019 , 
> @estewart08 wrote:
>
>> In reference to https://bugs.llvm.org/show_bug.cgi?id=48851, I do 
>> not see how this helps SPMD mode with team privatization of 
>> declarations in-between target teams and parallel regions.
>
> Diв you try the reproducer with the applied patch?

 Yes, I still saw the test fail, although it was not with latest 
 llvm-project. Are you saying the reproducer passes for you?
>>>
>>> I don't have CUDA installed but from what I see in the LLVM IR it shall 
>>> pass. Do you have a debug log, does it crashes or produces incorrect 
>>> results?
>>
>> This is on an AMDGPU but I assume the behavior would be similar for 
>> NVPTX.
>>
>> It produces incorrect/incomplete results in the dist[0] index after a 
>> manual reduction and in turn the final global gpu_results array is 
>> incorrect.
>> When thread 0 does a reduction into dist[0] it has no knowledge of 
>> dist[1] having been updated by thread 1. Which tells me the array is 
>> still thread private.
>> Adding some printfs, looking at one teams' output:
>>
>> SPMD
>>
>>   Thread 0: dist[0]: 1
>>   Thread 0: dist[1]: 0  // This should be 1
>>   After reduction into dist[0]: 1  // This should be 2
>>   gpu_results = [1,1]  // [2,2] expected
>>
>> Generic Mode:
>>
>>   Thread 0: dist[0]: 1
>>   Thread 0: dist[1]: 1   
>>   After reduction into dist[0]: 2
>>   gpu_results = [2,2]
>
> Hmm, I would expect a crash if the array was allocated in the local 
> memory. Could you try to add some more printfs (with data and addresses 
> of the array) to check the results? Maybe there is a data race somewhere 
> in the code?

 As a reminder, each thread updates a unique index in the dist array and 
 each team updates a unique index in gpu_results.

 SPMD - shows each thread has a unique address for dist array

   Team 0 Thread 1: dist[0]: 0, 0x7f92e24a8bf8
   Team 0 Thread 1: dist[1]: 1, 0x7f92e24a8bfc
   
   Team 0 Thread 0: dist[0]: 1, 0x7f92e24a8bf0
   Team 0 Thread 0: dist[1]: 0, 0x7f92e24a8bf4
   
   Team 0 Thread 0: After reduction into dist[0]: 1
   Team 0 Thread 0: gpu_results address: 0x7f92a500
   --
   Team 1 Thread 1: dist[0]: 0, 0x7f92f9ec5188
   Team 1 Thread 1: dist[1]: 1, 0x7f92f9ec518c
   
   Team 1 Thread 0: dist[0]: 1, 0x7f92f9ec5180
   Team 1 Thread 0: dist[1]: 0, 0x7f92f9ec5184
   
   Team 1 Thread 0: After reduction into dist[0]: 1
   Team 1 Thread 0: gpu_results address: 0x7f92a500
   
   gpu_results[0]: 1
   gpu_results[1]: 1

 Generic - shows each team shares dist array address amongst threads

   Team 0 Thread 1: dist[0]: 1, 0x7fac01938880
   Team 0 Thread 1: dist[1]: 1, 0x7fac01938884
   
   Team 0 Thread 0: dist[0]: 1, 0x7fac01938880
   Team 0 Thread 0: dist[1]: 1, 0x7fac01938884
   
   Team 0 Thread 0: After reduction into dist[0]: 2
   Team 0 Thread 0: gpu_results address: 0x7fabc500
   --
   Team 1 Thread 1: dist[0]: 1, 0x7fac19354e10
   Team 1 Thread 1: dist[1]: 1, 0x7fac19354e14
   
   Team 1 Thread 0: dist[0]: 1, 0x7fac19354e10
   Team 1 Thread 0: dist[1]: 1, 0x7fac19354e14
   
   Team 1 Thread 0: After reduction into dist[0]: 2
   Team 1 Thread 0: gpu_results address: 0x7fabc500
>>>
>>> Could you check if it works with `-fno-openmp-cuda-parallel-target-regions` 
>>> option?
>>
>> Unfortunately that crashes:
>> llvm-project/llvm/lib/IR/Instructions.cpp:495: void 
>> llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
>> llvm::ArrayRef, 
>> llvm::ArrayRef >, const llvm::Twine&): 
>> Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
>> Args[i]->getType()) && "Calling a 

[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Eliza via Phabricator via cfe-commits
exv marked an inline comment as done.
exv added a comment.

Eliza Velasquez 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[PATCH] D101763: [analyzer][ctu] Avoid parsing invocation list again and again during on-demand parsing of CTU

2021-05-04 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thank you for this patch!

Could you please provide a lit test that ignites the over and over parsing 
behaviour? I think you need to create two files and the second one should 
contain parser error(s).




Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:257
 llvm::Optional InvocationList;
+index_error_code InvocationListParsingError = index_error_code::no_error;
   };

I think it would be more consistent to make this an `llvm::Error`. I.e. we 
would store the result of the whole `lazyInitInvocationList` in this member 
variable. And as such, a better name could be `PreviousResult`. And this could 
be an `Optional` to indicate that we have never called `lazyInitInvocationList` 
before.
This means we would check in `lazyInitInvocationList` whether the 
`PreviousResult` is set and if yes is it an error. And if both conditions are 
true then return with the stashed error.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:670
 return llvm::Error::success();
+  else if (index_error_code::no_error != InvocationListParsingError)
+return llvm::make_error(InvocationListParsingError);

The `if` here is superfluous because the condition must be `true` always, 
otherwise we would have an `InvocationList`, wouldn't we?

Or we can have this condition, but then the `if (InvocatioList)` is not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101763

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


[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D101702#2736886 , @exv wrote:

> According to the wiki, it seems like someone who has commit access must now 
> submit this change.

Yes, I'll land it. Please provide "Name " for commit attribution 
if it differs from the info in your Phabricator account.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[PATCH] D101683: [Utils] Run non-filecheck runlines in-order in update_cc_test_checks

2021-05-04 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92f2c39f915a: [Utils] Run non-filecheck runlines in-order in 
update_cc_test_checks (authored by ggeorgakoudis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101683

Files:
  clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
  clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
  llvm/utils/update_cc_test_checks.py

Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -218,7 +218,7 @@
 
   for ti in common.itertests(initial_args.tests, parser, 'utils/' + script_name,
  comment_prefix='//', argparse_callback=infer_dependent_args):
-# Build a list of clang command lines and check prefixes from RUN lines.
+# Build a list of filechecked and non-filechecked RUN lines.
 run_list = []
 line2spell_and_mangled_list = collections.defaultdict(list)
 
@@ -240,11 +240,10 @@
   exec_args = shlex.split(commands[0])
   # Execute non-clang runline.
   if exec_args[0] not in SUBST:
-print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr)
 # Do lit-like substitutions.
 for s in subs:
   exec_args = [i.replace(s, subs[s]) if s in i else i for i in exec_args]
-exec_run_line(exec_args)
+run_list.append((None, exec_args, None, None))
 continue
   # This is a clang runline, apply %clang substitution rule, do lit-like substitutions,
   # and append args.clang_args
@@ -258,10 +257,9 @@
   filecheck_cmd = commands[-1]
   common.verify_filecheck_prefixes(filecheck_cmd)
   if not filecheck_cmd.startswith('FileCheck '):
-print('NOTE: Executing non-FileChecked clang RUN line: ' + l, file=sys.stderr)
 # Execute non-filechecked clang runline.
 exe = [ti.args.clang] + clang_args
-exec_run_line(exe)
+run_list.append((None, exe, None, None))
 continue
 
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
@@ -272,12 +270,21 @@
 
 # Execute clang, generate LLVM IR, and extract functions.
 
+# Store only filechecked runlines.
+filecheck_run_list = [i for i in run_list if i[0]]
 builder = common.FunctionTestBuilder(
-  run_list=run_list,
+  run_list=filecheck_run_list,
   flags=ti.args,
   scrubber_args=[])
 
-for prefixes, clang_args, extra_commands, triple_in_cmd in run_list:
+for prefixes, args, extra_commands, triple_in_cmd in run_list:
+  # Execute non-filechecked runline.
+  if not prefixes:
+print('NOTE: Executing non-FileChecked RUN line: ' + ' '.join(args), file=sys.stderr)
+exec_run_line(args)
+continue
+
+  clang_args = args
   common.debug('Extracted clang cmd: clang {}'.format(clang_args))
   common.debug('Extracted FileCheck prefixes: {}'.format(prefixes))
 
@@ -291,7 +298,7 @@
 
 func_dict = builder.finish_and_get_func_dict()
 global_vars_seen_dict = {}
-prefix_set = set([prefix for p in run_list for prefix in p[0]])
+prefix_set = set([prefix for p in filecheck_run_list for prefix in p[0]])
 output_lines = []
 
 include_generated_funcs = common.find_arg_in_test(ti,
@@ -325,7 +332,7 @@
  prefixes,
  func_dict, func)
 
-  common.add_checks_at_end(output_lines, run_list, builder.func_order(),
+  common.add_checks_at_end(output_lines, filecheck_run_list, builder.func_order(),
'//', lambda my_output_lines, prefixes, func:
check_generator(my_output_lines,
prefixes, func))
@@ -359,7 +366,7 @@
   if added:
 output_lines.append('//')
   added.add(mangled)
-  common.add_ir_checks(output_lines, '//', run_list, func_dict, mangled,
+  common.add_ir_checks(output_lines, '//', filecheck_run_list, func_dict, mangled,
False, args.function_signature, global_vars_seen_dict)
   if line.rstrip('\n') == '//':
 include_line = False
Index: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
@@ -3,16 +3,38 @@
 // RUN: cp %s %S/Output/execute-all-runlines.copy.c
 // RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
-// RUN: 

[clang] 92f2c39 - [Utils] Run non-filecheck runlines in-order in update_cc_test_checks

2021-05-04 Thread Giorgis Georgakoudis via cfe-commits

Author: Giorgis Georgakoudis
Date: 2021-05-04T12:06:03-07:00
New Revision: 92f2c39f915adc8f71be02d2604df4916069c9d4

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

LOG: [Utils] Run non-filecheck runlines in-order in update_cc_test_checks

The script update_cc_test_checks runs all non-filechecked runlines before the 
filechecked ones. This creates problems since outputs of those non-filechecked 
runlines may conflict and that will fail the execution of 
update_cc_test_checks. This patch executes non-filechecked in the order 
specified in the test file to avoid this issue.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
llvm/utils/update_cc_test_checks.py

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
index e0dfc42c4bd6..60d608b8cadd 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
+++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
@@ -2,10 +2,20 @@
 // RUN: cp %s %S/Output/execute-all-runlines.copy.c
 // RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c 
-emit-llvm-bc -o %t-host.bc
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -include-pch %t %s.copy.c 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -include-pch %t 
%s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK3
+
+
+#ifndef HEADER
+#define HEADER
 
 void use(int);
 
 void test(int a)
 {
 }
+
+#endif

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
index ae9745fa9b1e..cebd3846b2d9 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
+++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
@@ -3,16 +3,38 @@
 // RUN: cp %s %S/Output/execute-all-runlines.copy.c
 // RUN: cp %S/Output/execute-all-runlines.copy.c %s.copy.c
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp %s.copy.c 
-emit-llvm-bc -o %t-host.bc
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -include-pch %t %s.copy.c 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -include-pch %t 
%s.copy.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK3
+
+
+#ifndef HEADER
+#define HEADER
 
 void use(int);
 
-// CHECK-LABEL: @test(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
-// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
-// CHECK-NEXT:ret void
+// CHECK1-LABEL: @test(
+// CHECK1-NEXT:  entry:
+// CHECK1-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK1-NEXT:ret void
+//
+// CHECK2-LABEL: @test(
+// CHECK2-NEXT:  entry:
+// CHECK2-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK2-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK2-NEXT:ret void
+//
+// CHECK3-LABEL: @test(
+// CHECK3-NEXT:  entry:
+// CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK3-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK3-NEXT:ret void
 //
 void test(int a)
 {
 }
+
+#endif

diff  --git a/llvm/utils/update_cc_test_checks.py 
b/llvm/utils/update_cc_test_checks.py
index d3af5308ac6a..cbe58765f9fc 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -218,7 +218,7 @@ def main():
 
   for ti in 

[PATCH] D101800: [OpenMP] Fix non-determinism in clang task codegen (lastprivates)

2021-05-04 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG313ee609e16b: [OpenMP] Fix non-determinism in clang task 
codegen (lastprivates) (authored by ggeorgakoudis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101800

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4293,7 +4293,7 @@
 }
   }
   // Get list of lastprivate variables (for taskloops).
-  llvm::DenseMap LastprivateDstsOrigs;
+  llvm::MapVector LastprivateDstsOrigs;
   for (const auto *C : S.getClausesOfKind()) {
 auto IRef = C->varlist_begin();
 auto ID = C->destination_exprs().begin();
@@ -4304,8 +4304,8 @@
 Data.LastprivateCopies.push_back(IInit);
   }
   LastprivateDstsOrigs.insert(
-  {cast(cast(*ID)->getDecl()),
-   cast(*IRef)});
+  std::make_pair(cast(cast(*ID)->getDecl()),
+ cast(*IRef)));
   ++IRef;
   ++ID;
 }


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4293,7 +4293,7 @@
 }
   }
   // Get list of lastprivate variables (for taskloops).
-  llvm::DenseMap LastprivateDstsOrigs;
+  llvm::MapVector LastprivateDstsOrigs;
   for (const auto *C : S.getClausesOfKind()) {
 auto IRef = C->varlist_begin();
 auto ID = C->destination_exprs().begin();
@@ -4304,8 +4304,8 @@
 Data.LastprivateCopies.push_back(IInit);
   }
   LastprivateDstsOrigs.insert(
-  {cast(cast(*ID)->getDecl()),
-   cast(*IRef)});
+  std::make_pair(cast(cast(*ID)->getDecl()),
+ cast(*IRef)));
   ++IRef;
   ++ID;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 313ee60 - [OpenMP] Fix non-determinism in clang task codegen (lastprivates)

2021-05-04 Thread Giorgis Georgakoudis via cfe-commits

Author: Giorgis Georgakoudis
Date: 2021-05-04T11:56:31-07:00
New Revision: 313ee609e16b93a7d81cd595f8cffdb408390495

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

LOG: [OpenMP] Fix non-determinism in clang task codegen (lastprivates)

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e7ddc0aa4c8d..1f714b01b3f1 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4293,7 +4293,7 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
 }
   }
   // Get list of lastprivate variables (for taskloops).
-  llvm::DenseMap LastprivateDstsOrigs;
+  llvm::MapVector LastprivateDstsOrigs;
   for (const auto *C : S.getClausesOfKind()) {
 auto IRef = C->varlist_begin();
 auto ID = C->destination_exprs().begin();
@@ -4304,8 +4304,8 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
 Data.LastprivateCopies.push_back(IInit);
   }
   LastprivateDstsOrigs.insert(
-  {cast(cast(*ID)->getDecl()),
-   cast(*IRef)});
+  std::make_pair(cast(cast(*ID)->getDecl()),
+ cast(*IRef)));
   ++IRef;
   ++ID;
 }



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


[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Eliza via Phabricator via cfe-commits
exv marked an inline comment as done.
exv added a comment.

According to the wiki, it seems like someone who has commit access must now 
submit this change.




Comment at: clang/lib/Format/FormatTokenLexer.cpp:102
+
+// FIXME: Investigate what token type gives the correct operator priority.
+if (tryMergeTokens(FatArrow, TT_JsFatArrow))

curdeius wrote:
> Could you explain in what case the operator precedence may be wrong here?
It's unlikely this comment is still relevant for this section. I will delete it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-04 Thread Eliza via Phabricator via cfe-commits
exv updated this revision to Diff 342813.
exv marked an inline comment as done.
exv added a comment.

- Remove obsolete comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -358,6 +358,39 @@
   verifyFormat("return _name ?? \"DEF\";");
 }
 
+TEST_F(FormatTestCSharp, CSharpNullCoalescingAssignment) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+  Style.SpaceBeforeAssignmentOperators = true;
+
+  verifyFormat("test \?\?= ABC;", Style);
+  verifyFormat("test \?\?= true;", Style);
+
+  Style.SpaceBeforeAssignmentOperators = false;
+
+  verifyFormat("test\?\?= ABC;", Style);
+  verifyFormat("test\?\?= true;", Style);
+}
+
+TEST_F(FormatTestCSharp, CSharpNullForgiving) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat("var test = null!;", Style);
+  verifyFormat("string test = someFunctionCall()! + \"ABC\"!", Style);
+  verifyFormat("int test = (1! + 2 + bar! + foo())!", Style);
+  verifyFormat("test \?\?= !foo!;", Style);
+  verifyFormat("test = !bar! \?\? !foo!;", Style);
+  verifyFormat("bool test = !(!true && !true! || !null && !null! || !false && "
+   "!false! && !bar()! + (!foo()))!",
+   Style);
+
+  // Check that line break keeps identifier with the bang.
+  Style.ColumnLimit = 14;
+
+  verifyFormat("var test =\n"
+   "foo!;",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, AttributesIndentation) {
   FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
   Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1048,13 +1048,6 @@
 CurrentToken->Previous->setType(TT_OverloadedOperator);
   break;
 case tok::question:
-  if (Tok->is(TT_CSharpNullConditionalLSquare)) {
-if (!parseSquare())
-  return false;
-break;
-  }
-  if (Tok->isOneOf(TT_CSharpNullConditional, TT_CSharpNullCoalescing))
-break;
   if (Style.Language == FormatStyle::LK_JavaScript && Tok->Next &&
   Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
  tok::r_brace)) {
@@ -1078,7 +1071,7 @@
 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
  Tok->Next->Next->is(tok::equal))) {
-  Tok->setType(TT_CSharpNullable);
+  Tok->setType(TT_JsTypeOptionalQuestion);
   break;
 }
   }
@@ -1564,39 +1557,29 @@
   // The token type is already known.
   return;
 
-if (Style.isCSharp() && CurrentToken->is(tok::question)) {
-  if (CurrentToken->TokenText == "??") {
-Current.setType(TT_CSharpNullCoalescing);
-return;
-  }
-  if (CurrentToken->TokenText == "?.") {
-Current.setType(TT_CSharpNullConditional);
-return;
-  }
-  if (CurrentToken->TokenText == "?[") {
-Current.setType(TT_CSharpNullConditionalLSquare);
-return;
-  }
-}
-
-if (Style.Language == FormatStyle::LK_JavaScript) {
-  if (Current.is(tok::exclaim)) {
-if (Current.Previous &&
-(Keywords.IsJavaScriptIdentifier(
- *Current.Previous, /* AcceptIdentifierName= */ true) ||
- Current.Previous->isOneOf(
- tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
- Keywords.kw_type, Keywords.kw_get, Keywords.kw_set) ||
- Current.Previous->Tok.isLiteral())) {
-  Current.setType(TT_JsNonNullAssertion);
-  return;
-}
-if (Current.Next &&
-Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
+if ((Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) &&
+Current.is(tok::exclaim)) {
+  if (Current.Previous) {
+bool isIdentifier =
+Style.Language == FormatStyle::LK_JavaScript
+? Keywords.IsJavaScriptIdentifier(
+  *Current.Previous, /* AcceptIdentifierName= */ true)
+: Current.Previous->is(tok::identifier);
+if (isIdentifier ||
+Current.Previous->isOneOf(
+tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
+tok::kw_false, 

[clang] 9c72a21 - Fix for test failure caused by 84c475437267e7fffedc40029ce274b099d8f8f3.

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T11:45:32-07:00
New Revision: 9c72a210b58f19632af0e91679da7aa63f51ad7a

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

LOG: Fix for test failure caused by 84c475437267e7fffedc40029ce274b099d8f8f3.

Reduces the number of targets/triples for this test since not all cmake
invocations will build for those targets.

Added: 


Modified: 
clang/test/Frontend/invalid-cxx-abi.cpp

Removed: 




diff  --git a/clang/test/Frontend/invalid-cxx-abi.cpp 
b/clang/test/Frontend/invalid-cxx-abi.cpp
index 95ee442f286d..2bc0aac52cc7 100644
--- a/clang/test/Frontend/invalid-cxx-abi.cpp
+++ b/clang/test/Frontend/invalid-cxx-abi.cpp
@@ -1,21 +1,11 @@
+// REQUIRES: x86-registered-target
+
 // These should succeed.
-// RUN: %clang -c -fc++-abi=itanium %s
-// RUN: %clang -c -fc++-abi=arm -target arm64 %s
-// RUN: %clang -c -fc++-abi=ios -target arm64-apple-ios %s
-// RUN: %clang -c -fc++-abi=aarch64 -target arm64 %s
-// RUN: %clang -c -fc++-abi=mips -target mips %s
-// RUN: %clang -c -fc++-abi=webassembly -target wasm64 %s
+// RUN: %clang -c -fc++-abi=itanium -target x86_64-unknown-linux-gnu %s
 // RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
-// RUN: %clang -S -fc++-abi=xl -target powerpc-unknown-aix %s -o /dev/null
 // RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
-// RUN: %clang_cc1 -fc++-abi=itanium %s
-// RUN: %clang_cc1 -fc++-abi=arm -triple arm64 %s
-// RUN: %clang_cc1 -fc++-abi=ios -triple arm64-apple-ios %s
-// RUN: %clang_cc1 -fc++-abi=aarch64 -triple arm64 %s
-// RUN: %clang_cc1 -fc++-abi=mips -triple mips %s
-// RUN: %clang_cc1 -fc++-abi=webassembly -triple wasm64 %s
+// RUN: %clang_cc1 -fc++-abi=itanium -triple x86_64-unknown-linux-gnu %s
 // RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
-// RUN: %clang_cc1 -S -fc++-abi=xl -triple powerpc-unknown-aix %s -o /dev/null
 // RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
 
 // RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s 
-check-prefix=INVALID



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


[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew 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 rG1971823ecb9e: [Driver] Fix `ToolChain::getCompilerRTPath()` 
to return the correct path on… (authored by delcypher).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/darwin-print-file-name.c
  clang/test/Driver/darwin-print-runtime-dir.c


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{$}}
Index: clang/test/Driver/darwin-print-file-name.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-file-name.c
@@ -0,0 +1,27 @@
+// Regression test. Previously Clang just returned the library name instead
+// of the full path.
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{/|\\}}libclang_rt.osx.a
+
+// RUN: %clang -print-file-name=libclang_rt.ios.a 
--target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-IOS %s
+// PRINT-RUNTIME-DIR-IOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.ios.a
+
+// RUN: %clang -print-file-name=libclang_rt.tvos.a 
--target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-TVOS %s
+// PRINT-RUNTIME-DIR-TVOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.tvos.a
+
+// RUN: %clang -print-file-name=libclang_rt.watchos.a 
--target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-WATCHOS %s
+// PRINT-RUNTIME-DIR-WATCHOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.watchos.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -387,6 +387,9 @@
 }
 
 StringRef ToolChain::getOSLibName() const {
+  if (Triple.isOSDarwin())
+return "darwin";
+
   switch (Triple.getOS()) {
   case llvm::Triple::FreeBSD:
 return "freebsd";


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir 

[clang] 1971823 - [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew via cfe-commits

Author: Dan Liew
Date: 2021-05-04T11:28:26-07:00
New Revision: 1971823ecb9eaa077554a5d268a44c7cb75eccce

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

LOG: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path 
on Apple platforms.

When the target triple was an Apple platform `ToolChain::getOSLibName()`
(called by `getCompilerRTPath()`) would return the full OS name
including the version number (e.g. `darwin20.3.0`). This is not correct
because the library directory for all Apple platforms is `darwin`.

This in turn caused

* `-print-runtime-dir` to return a non-existant path.
* `-print-file-name=` to return the filename
  instead of the full path to the library.

Two regression tests are included.

rdar://77417317

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

Added: 
clang/test/Driver/darwin-print-file-name.c
clang/test/Driver/darwin-print-runtime-dir.c

Modified: 
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 88bc640a0b2d..3342de85fc30 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -387,6 +387,9 @@ static StringRef getArchNameForCompilerRTLib(const 
ToolChain ,
 }
 
 StringRef ToolChain::getOSLibName() const {
+  if (Triple.isOSDarwin())
+return "darwin";
+
   switch (Triple.getOS()) {
   case llvm::Triple::FreeBSD:
 return "freebsd";

diff  --git a/clang/test/Driver/darwin-print-file-name.c 
b/clang/test/Driver/darwin-print-file-name.c
new file mode 100644
index ..91623a4c589f
--- /dev/null
+++ b/clang/test/Driver/darwin-print-file-name.c
@@ -0,0 +1,27 @@
+// Regression test. Previously Clang just returned the library name instead
+// of the full path.
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{/|\\}}libclang_rt.osx.a
+
+// RUN: %clang -print-file-name=libclang_rt.ios.a 
--target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-IOS %s
+// PRINT-RUNTIME-DIR-IOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.ios.a
+
+// RUN: %clang -print-file-name=libclang_rt.tvos.a 
--target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-TVOS %s
+// PRINT-RUNTIME-DIR-TVOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.tvos.a
+
+// RUN: %clang -print-file-name=libclang_rt.watchos.a 
--target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-WATCHOS %s
+// PRINT-RUNTIME-DIR-WATCHOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.watchos.a

diff  --git a/clang/test/Driver/darwin-print-runtime-dir.c 
b/clang/test/Driver/darwin-print-runtime-dir.c
new file mode 100644
index ..967cdbfa94b7
--- /dev/null
+++ b/clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{$}}



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


[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew via Phabricator via cfe-commits
delcypher marked an inline comment as done.
delcypher added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:408
   default:
 return getOS();
   }

arphaman wrote:
> It might be cleaner to do a check for `isOSDarwin` here, as that will help 
> with any other Darwin platforms that we need to support.
@arphaman That seems like a good idea. I didn't know this API existed. I'll try 
to switch to that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

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


[PATCH] D101682: [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.

2021-05-04 Thread Dan Liew via Phabricator via cfe-commits
delcypher updated this revision to Diff 342809.
delcypher edited the summary of this revision.
delcypher added a comment.

Use `isOSDarwin()` instead of explicitly checking Darwin OS enum values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/darwin-print-file-name.c
  clang/test/Driver/darwin-print-runtime-dir.c


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{$}}
Index: clang/test/Driver/darwin-print-file-name.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-file-name.c
@@ -0,0 +1,27 @@
+// Regression test. Previously Clang just returned the library name instead
+// of the full path.
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-file-name=libclang_rt.osx.a 
--target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}darwin{{/|\\}}libclang_rt.osx.a
+
+// RUN: %clang -print-file-name=libclang_rt.ios.a 
--target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-IOS %s
+// PRINT-RUNTIME-DIR-IOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.ios.a
+
+// RUN: %clang -print-file-name=libclang_rt.tvos.a 
--target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-TVOS %s
+// PRINT-RUNTIME-DIR-TVOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.tvos.a
+
+// RUN: %clang -print-file-name=libclang_rt.watchos.a 
--target=arm64-apple-watchos5.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR-WATCHOS %s
+// PRINT-RUNTIME-DIR-WATCHOS: lib{{/|\\}}darwin{{/|\\}}libclang_rt.watchos.a
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -387,6 +387,9 @@
 }
 
 StringRef ToolChain::getOSLibName() const {
+  if (Triple.isOSDarwin())
+return "darwin";
+
   switch (Triple.getOS()) {
   case llvm::Triple::FreeBSD:
 return "freebsd";


Index: clang/test/Driver/darwin-print-runtime-dir.c
===
--- /dev/null
+++ clang/test/Driver/darwin-print-runtime-dir.c
@@ -0,0 +1,24 @@
+// Regression test. Previously the output returned the full OS name
+// (e.g. `darwin20.3.0`) instead of just `darwin`.
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-darwin20.3.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=x86_64-apple-macosx11.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-ios14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-tvos14.0.0 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=arm64-apple-watchos5.0.0 \
+// RUN:

[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61dc0f2b593d: [Format] Dont sort includes if 
DisableFormat is true (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101628

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


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2605,7 +2605,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2605,7 +2605,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 61dc0f2 - [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-05-04T19:04:12+01:00
New Revision: 61dc0f2b593da149a4c0cea67819cd7bdbdd50b8

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

LOG: [Format] Don't sort includes if DisableFormat is true

Fixes https://llvm.org/PR35099.

I'm not sure if this decision was intentional but its definitely confusing for 
users.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, curdeius

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ba7b03de8b3d3..f1508b98653d7 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2605,7 +2605,7 @@ tooling::Replacements sortIncludes(const FormatStyle 
, StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;

diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index 47ec319294bae..4efeb96124bf4 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@ TEST_F(SortIncludesTest, MergeLines) {
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang



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


[PATCH] D85802: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-05-04 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG84c475437267: [clang] Add -fc++-abi= flag for specifying 
which C++ ABI to use (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85802

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetCXXABI.def
  clang/include/clang/Basic/TargetCXXABI.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/cxx-abi-switch.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp

Index: clang/test/Frontend/invalid-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/Frontend/invalid-cxx-abi.cpp
@@ -0,0 +1,34 @@
+// These should succeed.
+// RUN: %clang -c -fc++-abi=itanium %s
+// RUN: %clang -c -fc++-abi=arm -target arm64 %s
+// RUN: %clang -c -fc++-abi=ios -target arm64-apple-ios %s
+// RUN: %clang -c -fc++-abi=aarch64 -target arm64 %s
+// RUN: %clang -c -fc++-abi=mips -target mips %s
+// RUN: %clang -c -fc++-abi=webassembly -target wasm64 %s
+// RUN: %clang -c -fc++-abi=fuchsia -target x86_64-unknown-fuchsia %s
+// RUN: %clang -S -fc++-abi=xl -target powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang -c -fc++-abi=microsoft -target x86_64-windows-msvc %s
+// RUN: %clang_cc1 -fc++-abi=itanium %s
+// RUN: %clang_cc1 -fc++-abi=arm -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=ios -triple arm64-apple-ios %s
+// RUN: %clang_cc1 -fc++-abi=aarch64 -triple arm64 %s
+// RUN: %clang_cc1 -fc++-abi=mips -triple mips %s
+// RUN: %clang_cc1 -fc++-abi=webassembly -triple wasm64 %s
+// RUN: %clang_cc1 -fc++-abi=fuchsia -triple x86_64-unknown-fuchsia %s
+// RUN: %clang_cc1 -S -fc++-abi=xl -triple powerpc-unknown-aix %s -o /dev/null
+// RUN: %clang_cc1 -fc++-abi=microsoft -triple x86_64-windows-msvc %s
+
+// RUN: not %clang -c -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang -c -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID
+// RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE
+// INVALID: error: Invalid C++ ABI name 'InvalidABI'
+// CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia'
+
+// The flag is propgated from the driver to cc1.
+// RUN: %clang -fc++-abi=InvalidABI %s -### 2>&1 | FileCheck %s -check-prefix=CC1-FLAG
+// CC1-FLAG: -fc++-abi=InvalidABI
+
+// Some C++ ABIs are not supported on some platforms.
+// RUN: not %clang_cc1 -c -fc++-abi=fuchsia -triple i386 %s 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-FUCHSIA
+// UNSUPPORTED-FUCHSIA: error: C++ ABI 'fuchsia' is not supported on target triple 'i386'
Index: clang/test/CodeGenCXX/cxx-abi-switch.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx-abi-switch.cpp
@@ -0,0 +1,28 @@
+// Assert that the ABI switch uses the proper codegen. Fuchsia uses the
+// "return this" ABI on constructors and destructors by default, but if we
+// explicitly choose the generic itanium C++ ABI, we should not return "this" on
+// ctors/dtors.
+//
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-fuchsia -fc++-abi=itanium | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=aarch64-unknown-fuchsia -fc++-abi=itanium | FileCheck %s
+
+class A {
+public:
+  virtual ~A();
+  int x_;
+};
+
+class B : public A {
+public:
+  B(int *i);
+  virtual ~B();
+  int *i_;
+};
+
+B::B(int *i) : i_(i) {}
+B::~B() {}
+
+// CHECK: define{{.*}} void @_ZN1BC2EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BC1EPi(%class.B* {{[^,]*}} %this, i32* %i)
+// CHECK: define{{.*}} void @_ZN1BD2Ev(%class.B* {{[^,]*}} %this)
+// CHECK: define{{.*}} void @_ZN1BD1Ev(%class.B* {{[^,]*}} %this)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3512,6 +3512,10 @@
   if (Opts.getSignReturnAddressKey() ==
   LangOptions::SignReturnAddressKeyKind::BKey)
 GenerateArg(Args, OPT_msign_return_address_key_EQ, "b_key", SA);
+
+  if (Opts.CXXABI)
+GenerateArg(Args, OPT_fcxx_abi_EQ, TargetCXXABI::getSpelling(*Opts.CXXABI),
+SA);
 }
 
 bool CompilerInvocation::ParseLangArgs(LangOptions , ArgList ,
@@ -3996,6 +4000,20 @@
 }
   }
 
+  // The value can be empty, which indicates the system default should be used.
+  StringRef CXXABI = Args.getLastArgValue(OPT_fcxx_abi_EQ);
+  if (!CXXABI.empty()) {

[clang] 84c4754 - [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

2021-05-04 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2021-05-04T10:52:13-07:00
New Revision: 84c475437267e7fffedc40029ce274b099d8f8f3

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

LOG: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use

This implements the flag proposed in RFC
http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html.

The goal is to add a way to override the default target C++ ABI through a
compiler flag. This makes it easier to test and transition between different
C++ ABIs through compile flags rather than build flags.

In this patch:

- Store -fc++-abi= in a LangOpt. This isn't stored in a CodeGenOpt because
  there are instances outside of codegen where Clang needs to know what the
  ABI is (particularly through ASTContext::createCXXABI), and we should be
  able to override the target default if the flag is provided at that point.
- Expose the existing ABIs in TargetCXXABI as values that can be passed
  through this flag.
  - Create a .def file for these ABIs to make it easier to check flag values.
  - Add an error for diagnosing bad ABI flag values.

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

Added: 
clang/include/clang/Basic/TargetCXXABI.def
clang/test/CodeGenCXX/cxx-abi-switch.cpp
clang/test/Frontend/invalid-cxx-abi.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetCXXABI.h
clang/include/clang/Driver/Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 1b73e4a2b8ee9..bef793831c6b2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -40,6 +40,7 @@
 #include "clang/Basic/ProfileList.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -730,6 +731,11 @@ class ASTContext : public RefCountedBase {
 return FullSourceLoc(Loc,SourceMgr);
   }
 
+  /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
+  /// at compile time with `-fc++-abi=`. If this is not provided, we instead 
use
+  /// the default ABI set by the target.
+  TargetCXXABI::Kind getCXXABIKind() const;
+
   /// All comments in this translation unit.
   RawCommentList Comments;
 

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 92ce91c11b71e..0e3ac3065ebc5 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -540,6 +540,9 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE 
setting %0 is not recognize
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 
+def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">;
+def err_unsupported_cxx_abi : Error<"C++ ABI '%0' is not supported on target 
triple '%1'">;
+
 def note_cc1_round_trip_original : Note<"Original arguments in round-trip: 
%0">;
 def note_cc1_round_trip_generated : Note<"Generated arguments #%0 in 
round-trip: %1">;
 def remark_cc1_round_trip_generated : Remark<"Generated arguments #%0 in 
round-trip: %1">, InGroup;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 85fe4af720235..5ccac6367a5f3 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/LangStandard.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/TargetCXXABI.h"
 #include "clang/Basic/Visibility.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/StringRef.h"
@@ -337,6 +338,10 @@ class LangOptions : public LangOptionsBase {
   /// like CUDA/HIP.
   std::string CUID;
 
+  /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
+  /// This overrides the default ABI used by the target.
+  llvm::Optional CXXABI;
+
   /// Indicates whether the front-end is explicitly told that the
   /// input is a header file (i.e. -x c-header).
   bool IsHeaderFile = false;

diff  --git a/clang/include/clang/Basic/TargetCXXABI.def 
b/clang/include/clang/Basic/TargetCXXABI.def
new file mode 100644
index 0..9501cca760945
--- /dev/null
+++ 

[PATCH] D100591: [Clang][AArch64] Disable rounding of return values for AArch64

2021-05-04 Thread Andrew Savonichev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb451ecd86e13: [Clang][AArch64] Disable rounding of return 
values for AArch64 (authored by asavonic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100591

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/arm64-arguments.c
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/attr-noundef.cpp
  clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp

Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -198,12 +198,11 @@
   testReturnLarge();
 }
 
-// CHECK: define{{.*}} i64 @_Z20testReturnHasTrivialv()
+// CHECK: define{{.*}} i32 @_Z20testReturnHasTrivialv()
 // CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_TRIVIAL:.*]], align 4
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_TRIVIAL]], %[[STRUCT_TRIVIAL]]* %[[RETVAL]], i32 0, i32 0
 // CHECK: %[[V0:.*]] = load i32, i32* %[[COERCE_DIVE]], align 4
-// CHECK: %[[COERCE_VAL_II:.*]] = zext i32 %[[V0]] to i64
-// CHECK: ret i64 %[[COERCE_VAL_II]]
+// CHECK: ret i32 %[[V0]]
 // CHECK: }
 
 Trivial testReturnHasTrivial() {
Index: clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -87,7 +87,7 @@
 // LINUX-LABEL: define{{.*}} void @_Z12small_returnv(%struct.Small* noalias sret(%struct.Small) align 4 %agg.result)
 // WIN32: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
 // WIN64: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
-// WOA64: define dso_local i64 @"?small_return@@YA?AUSmall@@XZ"()
+// WOA64: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
 
 Medium medium_return() { return Medium(); }
 // LINUX-LABEL: define{{.*}} void @_Z13medium_returnv(%struct.Medium* noalias sret(%struct.Medium) align 4 %agg.result)
Index: clang/test/CodeGen/attr-noundef.cpp
===
--- clang/test/CodeGen/attr-noundef.cpp
+++ clang/test/CodeGen/attr-noundef.cpp
@@ -11,7 +11,7 @@
 Trivial ret_trivial() { return {}; }
 void pass_trivial(Trivial e) {}
 // CHECK-INTEL: [[DEFINE:define( dso_local)?]] i32 @{{.*}}ret_trivial
-// CHECK-AARCH: [[DEFINE:define( dso_local)?]] i64 @{{.*}}ret_trivial
+// CHECK-AARCH: [[DEFINE:define( dso_local)?]] i32 @{{.*}}ret_trivial
 // CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i32 %
 // CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i64 %
 
@@ -43,7 +43,7 @@
 Trivial ret_trivial() { return {}; }
 void pass_trivial(Trivial e) {}
 // CHECK-INTEL: [[DEFINE]] i32 @{{.*}}ret_trivial
-// CHECK-AARCH: [[DEFINE]] i64 @{{.*}}ret_trivial
+// CHECK-AARCH: [[DEFINE]] i32 @{{.*}}ret_trivial
 // CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i32 %
 // CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i64 %
 
Index: clang/test/CodeGen/arm64-microsoft-arguments.cpp
===
--- clang/test/CodeGen/arm64-microsoft-arguments.cpp
+++ clang/test/CodeGen/arm64-microsoft-arguments.cpp
@@ -104,8 +104,8 @@
 
 // Pass and return an object with a non-trivial explicitly defaulted constructor
 // (passed directly, returned directly)
-// CHECK: define {{.*}} i64 @"?f6@@YA?AUS6@@XZ"()
-// CHECK: call i64 {{.*}}func6{{.*}}(i64 {{.*}})
+// CHECK: define {{.*}} i8 @"?f6@@YA?AUS6@@XZ"()
+// CHECK: call i8 {{.*}}func6{{.*}}(i64 {{.*}})
 struct S6a {
   S6a();
 };
@@ -123,8 +123,8 @@
 
 // Pass and return an object with a non-trivial implicitly defaulted constructor
 // (passed directly, returned directly)
-// CHECK: define {{.*}} i64 @"?f7@@YA?AUS7@@XZ"()
-// CHECK: call i64 {{.*}}func7{{.*}}(i64 {{.*}})
+// CHECK: define {{.*}} i8 @"?f7@@YA?AUS7@@XZ"()
+// CHECK: call i8 {{.*}}func7{{.*}}(i64 {{.*}})
 struct S7 {
   S6a x;
 };
Index: clang/test/CodeGen/arm64-arguments.c
===
--- clang/test/CodeGen/arm64-arguments.c
+++ clang/test/CodeGen/arm64-arguments.c
@@ -1,33 +1,41 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 
 // CHECK: define{{.*}} signext i8 @f0()
 char f0(void) {
   

[clang] b451ecd - [Clang][AArch64] Disable rounding of return values for AArch64

2021-05-04 Thread Andrew Savonichev via cfe-commits

Author: Andrew Savonichev
Date: 2021-05-04T20:29:01+03:00
New Revision: b451ecd86e13ec6ef47caf37f62977645c4f748e

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

LOG: [Clang][AArch64] Disable rounding of return values for AArch64

If a return value is explicitly rounded to 64 bits, an additional zext
instruction is emitted, and in some cases it prevents tail call
optimization.

As discussed in D100225, this rounding is not necessary and can be
disabled.

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/aarch64-varargs.c
clang/test/CodeGen/arm64-arguments.c
clang/test/CodeGen/arm64-microsoft-arguments.cpp
clang/test/CodeGen/attr-noundef.cpp
clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
clang/test/CodeGenCXX/trivial_abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 9577b61ca6d0..633b963965ed 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -5781,6 +5781,18 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType 
RetTy,
 if (getTarget().isRenderScriptTarget()) {
   return coerceToIntArray(RetTy, getContext(), getVMContext());
 }
+
+if (Size <= 64 && getDataLayout().isLittleEndian()) {
+  // Composite types are returned in lower bits of a 64-bit register for 
LE,
+  // and in higher bits for BE. However, integer types are always returned
+  // in lower bits for both LE and BE, and they are not rounded up to
+  // 64-bits. We can skip rounding up of composite types for LE, but not 
for
+  // BE, otherwise composite types will be indistinguishable from integer
+  // types.
+  return ABIArgInfo::getDirect(
+  llvm::IntegerType::get(getVMContext(), Size));
+}
+
 unsigned Alignment = getContext().getTypeAlign(RetTy);
 Size = llvm::alignTo(Size, 64); // round up to multiple of 8 bytes
 

diff  --git a/clang/test/CodeGen/aarch64-varargs.c 
b/clang/test/CodeGen/aarch64-varargs.c
index b71ec4af7aca..908fb4ae5d10 100644
--- a/clang/test/CodeGen/aarch64-varargs.c
+++ b/clang/test/CodeGen/aarch64-varargs.c
@@ -473,7 +473,8 @@ typedef struct __attribute__((packed,aligned(2))) {
   int val;
 } underaligned_int_struct;
 underaligned_int_struct underaligned_int_struct_test() {
-// CHECK-LABEL: define{{.*}} i64 @underaligned_int_struct_test()
+// CHECK-LE-LABEL: define{{.*}} i32 @underaligned_int_struct_test()
+// CHECK-BE-LABEL: define{{.*}} i64 @underaligned_int_struct_test()
   return va_arg(the_list, underaligned_int_struct);
 // CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds 
(%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[EARLY_ONSTACK:%[a-z_0-9]+]] = icmp sge i32 [[GR_OFFS]], 0
@@ -675,7 +676,8 @@ typedef struct {
   int val __attribute__((packed,aligned(2)));
 } underaligned_int_struct_member;
 underaligned_int_struct_member underaligned_int_struct_member_test() {
-// CHECK-LABEL: define{{.*}} i64 @underaligned_int_struct_member_test()
+// CHECK-LE-LABEL: define{{.*}} i32 @underaligned_int_struct_member_test()
+// CHECK-BE-LABEL: define{{.*}} i64 @underaligned_int_struct_member_test()
   return va_arg(the_list, underaligned_int_struct_member);
 // CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds 
(%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[EARLY_ONSTACK:%[a-z_0-9]+]] = icmp sge i32 [[GR_OFFS]], 0

diff  --git a/clang/test/CodeGen/arm64-arguments.c 
b/clang/test/CodeGen/arm64-arguments.c
index a40e5365cc51..b362346aa8a8 100644
--- a/clang/test/CodeGen/arm64-arguments.c
+++ b/clang/test/CodeGen/arm64-arguments.c
@@ -1,33 +1,41 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi 
darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi 
darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -target-feature +neon 
-target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
 
 // CHECK: define{{.*}} signext i8 @f0()
 char f0(void) {
   return 0;
 }
 
-// Struct as return type. Aggregates <= 16 bytes are passed directly and round
-// up to multiple of 8 bytes.
-// CHECK: define{{.*}} i64 @f1()
+// Struct as return type. Aggregates <= 16 bytes are passed directly. For BE,
+// return values are round up to 64 bits.
+//
+// CHECK-LE: define{{.*}} i8 @f1()
+// CHECK-BE: define{{.*}} i64 @f1()
 struct s1 { char f0; };
 struct s1 f1(void) {}
 
-// CHECK: define{{.*}} 

[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101628

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 5 inline comments as done.
mibintc added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:234
+FEM_Extended,
+/// Use the default float eval method specified by Target
+FEM_TargetDefault

mibintc wrote:
> aaron.ballman wrote:
> > FYI: it may be somewhat confusing that we have an enumerator with `default` 
> > in the name but that enumerator isn't the default.
> That's true. I had a heck of a time getting the initialization of the lang 
> option setting correct: the setting should come from the TargetInfo if 
> command line options don't override. That seems simple enough but there's 
> somethng really odd about initialization. Adding the "default target" 
> enumeral allowed me to get it initialized the way I wanted.
I redid the comments to eliminate the confusion



Comment at: clang/lib/Sema/SemaAttr.cpp:429
+  case PFC_Source:
+//Builder.defineMacro("__FLT_EVAL_METHOD__", Twine("0"));
+NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Source);

mibintc wrote:
> @rjmccall I would like to push a new value for __FLT_EVAL_METHOD__ at the 
> start of the scope of this pragma, then pop that value of the macro to 
> restore the previous setting when the scope is exited, should I do that in 
> ParsePragma? Can I do that by injecting "pragma push_macro(...)" into the 
> token stream, do you have other suggestion or is there something similar in 
> clang that I can study how to do this? 
Nevermind, I found a way to set the macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

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


[PATCH] D100917: [NewPM] Only invalidate modified functions' analyses in CGSCC passes

2021-05-04 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

In D100917#2736702 , @aeubanks wrote:

> In D100917#2735651 , @nikic wrote:
>
>> An unfortunate side-effect of this change is that NewPM uses even more 
>> memory. tramp3d-v4 is up 20% in max-rss 
>> (https://llvm-compile-time-tracker.com/compare.php?from=4ef1f90e4d564b872e3598ccef45adb740eb0f0d=d14d84af2f5ebb8ae2188ce6884a29a586dc0a40=max-rss)
>
> Hmm that is a concern. I'm not sure how we want to balance memory vs compile 
> times. Any thoughts?

(Drive-by thought) - maybe this is because a bunch of analyses that are needed 
during function simplification aren't needed anymore after. We could quickly 
check by adding a pass at the end of all function simplification, module-wide, 
that clears all fct analyses, and see if the memory overhead is still there?

If that's the case, we could identify what's not needed after function 
simplification and scope it somehow in a less hacky way than my above 
suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100917

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


[PATCH] D101572: Make `hasTypeLoc` matcher support more node types.

2021-05-04 Thread Weston Carvalho via Phabricator via cfe-commits
SilensAngelusNex added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:138-150
+template  struct disjunction;
+template  struct disjunction : public T {};
+template  struct disjunction {
+  using type =
+  typename std::conditional>::type;
+  static constexpr bool value = type::value;
+};

Is there a better way to express this? I was originally using

```
template  struct is_one_of {
  template 
  static constexpr bool value = (std::is_base_of_v || ...);
};
```
but that didn't compile because `is_base_of_v` and fold expressions are C++17 
features.

Maybe it would be better to just explicitly write out an overload of 
`GetTypeSourceInfo` for each type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101572

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


[PATCH] D101721: [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-04 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1c729c56829: [clang-tidy][NFC] Update tests and Default 
options to use boolean value (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101721

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-ignore-single-argument.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-strict.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-array-subscript-expression.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-int.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-pointer-offset.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-explicit-only.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-implicit-enabled.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-before-safe.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage-strict.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment-warn-only-if-this-has-suspicious-field.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-caps-only.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-command-line-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-pedanticmode-option.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-allow-missing-move-when-copy-is-deleted.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-relaxed.cpp
  
clang-tools-extra/test/clang-tidy/checkers/hicpp-multiway-paths-covered-else.cpp
  
clang-tools-extra/test/clang-tidy/checkers/hicpp-signed-bitwise-integer-literals.cpp
  
clang-tools-extra/test/clang-tidy/checkers/misc-non-private-member-variables-in-classes.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters-strict.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal-delimiter.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-cast-remove-stars.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-min-type-name-length.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-new-remove-stars.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals-ignore-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace-ignore-implicit-constructors.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-copy.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-macros.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-delete-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-override-allow-override-and-final.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-override-no-destructors.cpp
  

[PATCH] D100917: [NewPM] Only invalidate modified functions' analyses in CGSCC passes

2021-05-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D100917#2735651 , @nikic wrote:

> An unfortunate side-effect of this change is that NewPM uses even more 
> memory. tramp3d-v4 is up 20% in max-rss 
> (https://llvm-compile-time-tracker.com/compare.php?from=4ef1f90e4d564b872e3598ccef45adb740eb0f0d=d14d84af2f5ebb8ae2188ce6884a29a586dc0a40=max-rss)

Hmm that is a concern. I'm not sure how we want to balance memory vs compile 
times. Any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100917

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


[clang-tools-extra] e1c729c - [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-04 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-05-04T18:17:56+01:00
New Revision: e1c729c56829d3b9502b9ac2439003f87231db50

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

LOG: [clang-tidy][NFC] Update tests and Default options to use boolean value

Change instances where options which are boolean are assigned the value 1|0 to 
use true|false instead.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-ignore-single-argument.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-strict.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-array-subscript-expression.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-int.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-pointer-offset.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-explicit-only.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-widening-cast-implicit-enabled.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-not-null-terminated-result-memcpy-before-safe.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier-invert.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage-strict.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-enum-usage.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-string-compare.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment-warn-only-if-this-has-suspicious-field.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-caps-only.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-command-line-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-pedanticmode-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init-use-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-allow-missing-move-when-copy-is-deleted.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-special-member-functions-relaxed.cpp

clang-tools-extra/test/clang-tidy/checkers/hicpp-multiway-paths-covered-else.cpp

clang-tools-extra/test/clang-tidy/checkers/hicpp-signed-bitwise-integer-literals.cpp

clang-tools-extra/test/clang-tidy/checkers/misc-non-private-member-variables-in-classes.cpp
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters-strict.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal-delimiter.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-cast-remove-stars.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-min-type-name-length.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-auto-new-remove-stars.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals-ignore-macros.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-use-bool-literals.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init-macros.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace-ignore-implicit-constructors.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-copy.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-equals-default-macros.cpp


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-05-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 342792.
mibintc added a comment.

I rebased the patch and responded to review comments from @aaron.ballman and 
@jansvoboda11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/PragmaKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init-arm.c
  clang/test/Preprocessor/init-mips.c
  clang/test/Preprocessor/init-ppc.c
  clang/test/Preprocessor/init-ppc64.c
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-v7k-compat.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c
  clang/test/Preprocessor/predefined-flteval-macro.c

Index: clang/test/Preprocessor/predefined-flteval-macro.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-flteval-macro.c
@@ -0,0 +1,346 @@
+// RUN: %clang_cc1 -std=c11  -E -triple=aarch64 -xc  %s | FileCheck %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=arm64 -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64_be -xc  -fsyntax-only %s
+// RUN: %clang_cc1  -triple=arm64 -xc++  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-apple-ios7.0 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=small -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=tiny -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -triple=aarch64 -mcmodel=large -xc  -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv7-windows-msvc -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1  -x c++ -ffreestanding -triple=arm-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple arm-none-none -target-abi apcs-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armeb-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-linux-gnueabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv6-unknown-cloudabi-eabihf -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabi -fsyntax-only %s
+// RUN: %clang -c -ffreestanding -target arm-netbsd-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=arm-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabi -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-eabihf -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=aarch64-none-elf -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7s -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7 -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mhwdiv=thumb -x c -fsyntax-only %s
+// RUN: %clang -c -target arm -mthumb -mhwdiv=arm -x c -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=armebv8-none-none -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbebv8 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c11  -ffreestanding -triple=thumbv5 -fsyntax-only %s

[PATCH] D101572: Make `hasTypeLoc` matcher support more node types.

2021-05-04 Thread Weston Carvalho via Phabricator via cfe-commits
SilensAngelusNex updated this revision to Diff 342790.
SilensAngelusNex retitled this revision from "Make `hasTypeLoc` matcher support 
nodes of type `CXXFunctionalCastExpr` and `CXXTemporaryObjectExpr`." to "Make 
`hasTypeLoc` matcher support more node types.".
SilensAngelusNex added a comment.

Added support for node types in groups #1 and #3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101572

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

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Host.h"
 #include "gtest/gtest.h"
@@ -375,15 +376,104 @@
   typedefNameDecl(hasType(asString("foo")), hasName("bar";
 }
 
-TEST(HasTypeLoc, MatchesDeclaratorDecls) {
+TEST(HasTypeLoc, MatchesBlockDecl) {
+  EXPECT_TRUE(matchesConditionally(
+  "auto x = ^int (int a, int b) { return a + b; };",
+  blockDecl(hasTypeLoc(loc(asString("int (int, int)", true,
+  {"-fblocks"}));
+}
+
+TEST(HasTypeLoc, MatchesCXXBaseSpecifierAndCtorInitializer) {
+  llvm::StringRef code = R"cpp(
+  class Foo {};
+  class Bar : public Foo {
+Bar() : Foo() {}
+  };
+  )cpp";
+
+  EXPECT_TRUE(matches(
+  code, cxxRecordDecl(hasAnyBase(hasTypeLoc(loc(asString("class Foo")));
+  EXPECT_TRUE(matches(
+  code, cxxCtorInitializer(hasTypeLoc(loc(asString("class Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXFunctionalCastExpr) {
+  EXPECT_TRUE(matches("auto x = int(3);",
+  cxxFunctionalCastExpr(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesCXXNewExpr) {
+  EXPECT_TRUE(matches("auto* x = new int(3);",
+  cxxNewExpr(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("class Foo{}; auto* x = new Foo();",
+  cxxNewExpr(hasTypeLoc(loc(asString("class Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXTemporaryObjectExpr) {
+  EXPECT_TRUE(
+  matches("struct Foo { Foo(int, int); }; auto x = Foo(1, 2);",
+  cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("struct Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCXXUnresolvedConstructExpr) {
+  EXPECT_TRUE(
+  matches("template  T make() { return T(); }",
+  cxxUnresolvedConstructExpr(hasTypeLoc(loc(asString("T"));
+}
+
+TEST(HasTypeLoc, MatchesClassTemplateSpecializationDecl) {
+  EXPECT_TRUE(matches(
+  "template  class Foo; template <> class Foo {};",
+  classTemplateSpecializationDecl(hasTypeLoc(loc(asString("Foo"));
+}
+
+TEST(HasTypeLoc, MatchesCompoundLiteralExpr) {
+  EXPECT_TRUE(
+  matches("int* x = (int [2]) { 0, 1 };",
+  compoundLiteralExpr(hasTypeLoc(loc(asString("int [2]"));
+}
+
+TEST(HasTypeLoc, MatchesDeclaratorDecl) {
   EXPECT_TRUE(matches("int x;",
   varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("int x(3);",
+  varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(
+  matches("struct Foo { Foo(int, int); }; Foo x(1, 2);",
+  varDecl(hasName("x"), hasTypeLoc(loc(asString("struct Foo"));
 
   // Make sure we don't crash on implicit constructors.
   EXPECT_TRUE(notMatches("class X {}; X x;",
  declaratorDecl(hasTypeLoc(loc(asString("int"));
 }
 
+TEST(HasTypeLoc, MatchesExplicitCastExpr) {
+  EXPECT_TRUE(matches("auto x = (int) 3;",
+  explicitCastExpr(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("auto x = static_cast(3);",
+  explicitCastExpr(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesObjCPropertyDecl) {
+  EXPECT_TRUE(matchesObjC(R"objc(
+  @interface Foo
+  @property int enabled;
+  @end
+)objc",
+  objcPropertyDecl(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesTemplateArgumentLoc) {
+  EXPECT_TRUE(matches("template  class Foo {}; Foo x;",
+  templateArgumentLoc(hasTypeLoc(loc(asString("int"));
+}
+
+TEST(HasTypeLoc, MatchesTypedefNameDecl) {
+  EXPECT_TRUE(matches("typedef int X;",
+  typedefNameDecl(hasTypeLoc(loc(asString("int"));
+  EXPECT_TRUE(matches("using X = int;",
+  typedefNameDecl(hasTypeLoc(loc(asString("int"));
+}
 
 TEST(Callee, MatchesDeclarations) {
   StatementMatcher CallMethodX = 

[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-05-04 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.
This revision is now accepted and ready to land.

Thanks! Looks good to me in general. See a comment.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10006
   "use of %select{type|declaration}0 %1 requires %2 support">;
+def ext_opencl_double_without_pragma : Extension<
+  "Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is 
supported">;

nit: this can be extended to use arbitrary type and extension for other patches 
which will eliminate pragmas for types


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

https://reviews.llvm.org/D100980

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


[PATCH] D100983: [OpenCL] Fix optional image types

2021-05-04 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.

LGTM. Thanks!


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

https://reviews.llvm.org/D100983

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


[PATCH] D101832: [clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist=

2021-05-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added subscribers: vitalybuka, MaskRay.
MaskRay added a comment.

I think @vitalybuka has concrete suggestion on the naming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101832

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


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

2021-05-04 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D79714#2735455 , @Abpostelnicu 
wrote:

> I'm seeing here something very strange, if the user provided copy assignment 
> operator is provided but is = delete and the copy constructor is default this 
> warning will still trigger. Is this something expected?
> I'm referring at this issue from the mozilla 
>  
> code-base.

Yes, that implicit default is deprecated.
If you want your copy constructor to be defaulted, even in the presence of 
deleted SMFs, you should explicitly `=default` it. Here's an example: 
https://godbolt.org/z/GaGn1638E


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79714

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


[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

2021-05-04 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 342778.
njames93 added a comment.

Add test case demonstrating new behvaiour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101628

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


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2603,7 +2603,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -9,6 +9,7 @@
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -1034,6 +1035,16 @@
   EXPECT_EQ(Expected, sort(Code, "a.cpp", 1));
 }
 
+TEST_F(SortIncludesTest, DisableFormatDisablesIncludeSorting) {
+  StringRef Sorted = "#include \n"
+ "#include \n";
+  StringRef Unsorted = "#include \n"
+   "#include \n";
+  EXPECT_EQ(Sorted, sort(Unsorted));
+  FmtStyle.DisableFormat = true;
+  EXPECT_EQ(Unsorted, sort(Unsorted, "input.cpp", 0));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2603,7 +2603,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99599: [NewPM] Add an option to dump pass structure

2021-05-04 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

> Could you explain why -debug-pass-manager doesn't fit your use case?

I wanted to have something similar to -debug-pass=Structure, because the above 
is too verbose and lacks identation. What's the problem with this one, anyway?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99599

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


[PATCH] D99599: [NewPM] Add an option to dump pass structure

2021-05-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D99599#2735582 , @evgeny777 wrote:

>> I've already run into having to update these two golden file tests twice
>
> I think you can just reduce the tests. No need to revert the entire change, 
> unless there is a replacement for it (D101797 
>  is not)

Could you explain why -debug-pass-manager doesn't fit your use case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99599

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


[PATCH] D101630: [HIP] Fix device-only compilation

2021-05-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:977
   NegFlag>;
+defm hip_bundle_device_output : BoolFOption<"hip-bundle-device-output", 
EmptyKPM, DefaultTrue,
+  PosFlag,

jansvoboda11 wrote:
> The TableGen marshalling infrastructure (`BoolFOption` et. al.) is only 
> intended for flags that map to the `-cc1` frontend and its 
> `CompilerInvocation` class. (`EmptyKPM` that disables this mapping shouldn't 
> even exist anymore.)
> 
> Since these flags only work on the driver level, use something like this 
> instead:
> 
> ```
> def fhip_bundle_device_output : Flag<["-"], "fhip-bundle-device-output">, 
> Group;
> def fno_hip_bundle_device_output : Flag<["-"], 
> "fno-hip-bundle-device-output">, Group, HelpText<"Do not bundle 
> output files of HIP device compilation">;
> ```

It would be great if `BoolFOption` would at least document that assumption.
It would be even better if it would be allowed to be used to implement a 
driver-only option, maybe with a flag.
The class is very useful to handle -fsomething/-fno-something and restricting 
it to cc1 only will continue to be a constant source of this kind of confusion. 
I think we've already seen handful of them in reviews since the flag tablegen 
got overhauled.


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

https://reviews.llvm.org/D101630

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


[PATCH] D101843: [OpenCL] Add clang extension for bitfields

2021-05-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, olestrohm.
Herald added subscribers: ebevhan, kerbowa, yaxunl, nhaehnle, jvesely, 
jholewinski.
Anastasia requested review of this revision.

Bitfields result in struct/union layout that is implementation dependent and 
therefore it was excluded from OpenCL originally for portability reasons. In 
kernel prameters use of bitfields can result in functionality issues.

However, use of bitfields has been desirable feature for some applications, 
there was a discussion about allowing this in the next standards 
(https://github.com/KhronosGroup/OpenCL-Docs/issues/301) but regardless to that 
clang can expose this functionality as a compiler extension for the application 
that can take advanatge of it at the price of reduced portability.

This addresses PR45339!


https://reviews.llvm.org/D101843

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Misc/amdgcn.languageOptsOpenCL.cl
  clang/test/Misc/nvptx.languageOptsOpenCL.cl
  clang/test/Misc/r600.languageOptsOpenCL.cl
  clang/test/SemaOpenCL/unsupported.cl

Index: clang/test/SemaOpenCL/unsupported.cl
===
--- clang/test/SemaOpenCL/unsupported.cl
+++ clang/test/SemaOpenCL/unsupported.cl
@@ -1,7 +1,15 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -DBITFIELDS_EXT
 
-struct {
-  int a : 1; // expected-error {{bit-fields are not supported in OpenCL}}
+#ifdef BITFIELDS_EXT
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+#endif
+
+struct test {
+  int a : 1;
+#ifndef BITFIELDS_EXT
+// expected-error@-2 {{bit-fields are not supported in OpenCL}}
+#endif
 };
 
 void no_vla(int n) {
Index: clang/test/Misc/r600.languageOptsOpenCL.cl
===
--- clang/test/Misc/r600.languageOptsOpenCL.cl
+++ clang/test/Misc/r600.languageOptsOpenCL.cl
@@ -34,6 +34,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_bitfields
+#error "Missing __cl_clang_bitfields define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+
 #ifdef cl_khr_fp16
 #error "Incorrect cl_khr_fp16 define"
 #endif
Index: clang/test/Misc/nvptx.languageOptsOpenCL.cl
===
--- clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -28,6 +28,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_bitfields
+#error "Missing __cl_clang_bitfields define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+
 #ifdef cl_khr_fp16
 #error "Incorrect cl_khr_fp16 define"
 #endif
Index: clang/test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- clang/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ clang/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -24,6 +24,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_bitfields
+#error "Missing __cl_clang_bitfields define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
+
 #ifndef cl_khr_fp16
 #error "Missing cl_khr_fp16 define"
 #endif
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16796,7 +16796,8 @@
   InvalidDecl = true;
 }
 // OpenCL v1.2 s6.9.c: bitfields are not supported.
-if (BitWidth) {
+if (BitWidth && !getOpenCLOptions().isAvailableOption(
+"__cl_clang_bitfields", LangOpts)) {
   Diag(Loc, diag::err_opencl_bitfields);
   InvalidDecl = true;
 }
Index: clang/lib/Basic/Targets/NVPTX.h
===
--- clang/lib/Basic/Targets/NVPTX.h
+++ clang/lib/Basic/Targets/NVPTX.h
@@ -133,6 +133,7 @@
 Opts["cl_clang_storage_class_specifiers"] = true;
 Opts["__cl_clang_function_pointers"] = true;
 Opts["__cl_clang_variadic_functions"] = true;
+Opts["__cl_clang_bitfields"] = true;
 
 Opts["cl_khr_fp64"] = true;
 Opts["cl_khr_byte_addressable_store"] = true;
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -287,6 +287,7 @@
 Opts["cl_clang_storage_class_specifiers"] = true;
 Opts["__cl_clang_variadic_functions"] = true;
 Opts["__cl_clang_function_pointers"] = true;
+Opts["__cl_clang_bitfields"] = true;
 
 bool IsAMDGCN = isAMDGCN(getTriple());
 
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- 

[PATCH] D101781: Fix assert on the variable which is used in omp clause is not marked as used

2021-05-04 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5285748c2c76: Fix assert on the variable which is used in 
omp clause is not marked (authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101781

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/constexpr_capture.cpp


Index: clang/test/OpenMP/constexpr_capture.cpp
===
--- clang/test/OpenMP/constexpr_capture.cpp
+++ clang/test/OpenMP/constexpr_capture.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-linux 
-S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++  
-fopenmp-targets=x86_64-pc-linux-gnu -triple powerpc64le-unknown-linux -S 
-emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
 // expected-no-diagnostics
 
 template  struct integral_constant {
@@ -12,10 +13,24 @@
 struct V {
   template ::type> V();
 };
+
+constexpr double h_chebyshev_coefs[] = {
+1.020784639703, 0.0021491446496202074};
+
+void test(double *d_value)
+{
+#pragma omp target map(tofrom  \
+   : d_value [0:1]) map(always, to \
+: h_chebyshev_coefs [0:2])
+  *d_value = h_chebyshev_coefs[1];  return;
+}
+
+// CHECK: void @__omp_offloading_{{.+}}test{{.+}}(double* %0)
+
 int main() {
 #pragma omp target
   V v;
   return 0;
 }
 
-// CHECK: call void @__omp_offloading_{{.+}}_main_l16()
+// CHECK: call void @__omp_offloading_{{.+}}_main_{{.+}}()
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2527,6 +2527,7 @@
 
 void Sema::EndOpenMPClause() {
   DSAStack->setClauseParsingMode(/*K=*/OMPC_unknown);
+  CleanupVarDeclMarking();
 }
 
 static std::pair


Index: clang/test/OpenMP/constexpr_capture.cpp
===
--- clang/test/OpenMP/constexpr_capture.cpp
+++ clang/test/OpenMP/constexpr_capture.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-linux -S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++  -fopenmp-targets=x86_64-pc-linux-gnu -triple powerpc64le-unknown-linux -S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
 // expected-no-diagnostics
 
 template  struct integral_constant {
@@ -12,10 +13,24 @@
 struct V {
   template ::type> V();
 };
+
+constexpr double h_chebyshev_coefs[] = {
+1.020784639703, 0.0021491446496202074};
+
+void test(double *d_value)
+{
+#pragma omp target map(tofrom  \
+   : d_value [0:1]) map(always, to \
+: h_chebyshev_coefs [0:2])
+  *d_value = h_chebyshev_coefs[1];  return;
+}
+
+// CHECK: void @__omp_offloading_{{.+}}test{{.+}}(double* %0)
+
 int main() {
 #pragma omp target
   V v;
   return 0;
 }
 
-// CHECK: call void @__omp_offloading_{{.+}}_main_l16()
+// CHECK: call void @__omp_offloading_{{.+}}_main_{{.+}}()
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2527,6 +2527,7 @@
 
 void Sema::EndOpenMPClause() {
   DSAStack->setClauseParsingMode(/*K=*/OMPC_unknown);
+  CleanupVarDeclMarking();
 }
 
 static std::pair
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D101030#2736508 , @jdoerfert wrote:

> I'll wait for @ggeorgakoudis to update the tests with the script, then I'll 
> adjust all clang tests again. FWIW, this also fixes an issue in OpenMC where 
> declare target triggered this:
>
>   llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:719: void 
> clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, 
> clang::QualType, llvm::Function *, const clang::CodeGen::CGFunctionInfo &, 
> const clang::CodeGen::FunctionArgList &, clang::SourceLocation, 
> clang::SourceLocation): Assertion `CurFn->isDeclaration() && "Function 
> already has body?"' failed.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[clang] 5285748 - Fix assert on the variable which is used in omp clause is not marked

2021-05-04 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2021-05-04T09:07:35-07:00
New Revision: 5285748c2c764c1d7fb3f882ba9f11ed79f676a1

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

LOG: Fix assert on the variable which is used in omp clause is not marked
as used.

The problem only happens with constexpr variable, for constexpr variable,
variable is not marked during parser variable.   This is because compiler
might find some var's associate expressions may not actully an odr-used
later,  the variables get kept in MaybeODRUseExprs, in normal case, at
end of process fullExpr, the variable will be marked during the call to
CleanupVarDeclMarking(). Since we are processing expression of OpenMP
clauses, and the ActOnFinishFullExpr is not getting called that casue
variable is not get marked.

One way to fix this is to call CleanupVarDeclMarking() in EndOpenMPClause
for each omp directive.

This to fix https://bugs.llvm.org/show_bug.cgi?id=50206

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/constexpr_capture.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 25ee46d95aa55..9ac3e48781849 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2527,6 +2527,7 @@ void Sema::StartOpenMPClause(OpenMPClauseKind K) {
 
 void Sema::EndOpenMPClause() {
   DSAStack->setClauseParsingMode(/*K=*/OMPC_unknown);
+  CleanupVarDeclMarking();
 }
 
 static std::pair

diff  --git a/clang/test/OpenMP/constexpr_capture.cpp 
b/clang/test/OpenMP/constexpr_capture.cpp
index 9577f6e0c0fe2..ba404d7fdafd0 100644
--- a/clang/test/OpenMP/constexpr_capture.cpp
+++ b/clang/test/OpenMP/constexpr_capture.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-linux 
-S -emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++  
-fopenmp-targets=x86_64-pc-linux-gnu -triple powerpc64le-unknown-linux -S 
-emit-llvm %s -o - -std=c++11 2>&1 | FileCheck %s
 // expected-no-diagnostics
 
 template  struct integral_constant {
@@ -12,10 +13,24 @@ struct decay {
 struct V {
   template ::type> V();
 };
+
+constexpr double h_chebyshev_coefs[] = {
+1.020784639703, 0.0021491446496202074};
+
+void test(double *d_value)
+{
+#pragma omp target map(tofrom  \
+   : d_value [0:1]) map(always, to \
+: h_chebyshev_coefs [0:2])
+  *d_value = h_chebyshev_coefs[1];  return;
+}
+
+// CHECK: void @__omp_offloading_{{.+}}test{{.+}}(double* %0)
+
 int main() {
 #pragma omp target
   V v;
   return 0;
 }
 
-// CHECK: call void @__omp_offloading_{{.+}}_main_l16()
+// CHECK: call void @__omp_offloading_{{.+}}_main_{{.+}}()



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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: ggeorgakoudis.
jdoerfert added a comment.

I'll wait for @ggeorgakoudis to update the tests with the script, then I'll 
adjust all clang tests again. FWIW, this also fixes an issue in OpenMC where 
declare target triggered this:

  llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:719: void 
clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, 
clang::QualType, llvm::Function *, const clang::CodeGen::CGFunctionInfo &, 
const clang::CodeGen::FunctionArgList &, clang::SourceLocation, 
clang::SourceLocation): Assertion `CurFn->isDeclaration() && "Function already 
has body?"' failed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 7 inline comments as done.
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2618
+void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) {
+  for (Expr *E : const_cast(D)->varlists()) {
+auto *DE = cast(E);

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > ABataev wrote:
> > > > > > jdoerfert wrote:
> > > > > > > ABataev wrote:
> > > > > > > > Why need to remove constantness here?
> > > > > > > The problem is that the declaration, which might have been 
> > > > > > > already generated in IR or not, had no address space attached 
> > > > > > > before. Now we want to do that after the fact, potentially *way 
> > > > > > > later*. To reuse the general codegen mechanism I modify the 
> > > > > > > VarDecl (temporarily) by attaching the new address space and 
> > > > > > > calling codegen again. If you have a better idea, I'm happy to 
> > > > > > > change this.
> > > > > > Why not just create it manually rather than rely on 
> > > > > > `GetOrCreateLLVMGlobal`?
> > > > > I'm not sure I follow. Creating a global is complicated, need to make 
> > > > > sure all the linkage, visibility, address space stuff is set up, 
> > > > > mangling, etc. Why would we duplicate all that code and risk messing 
> > > > > things up now or in the future?
> > > > And what about just setting the address-space on the LLVM type directly?
> > > It's part of the type, we can't change it after the fact (at least that 
> > > is not an existing API). 
> > What about `Value::mutateType`?
> I'll give it a shot, though the comment makes me nervous:
> 
> ```
> /// Mutate the type of this Value to be of the specified type.
>   
>   
>  
> ///
> /// Note that this is an extremely dangerous operation which can create
> /// completely invalid IR very easily.  It is strongly recommended that 
> you
> /// recreate IR objects with the right types instead of mutating them in
> /// place.
> ```
> 
> 
Seems to work with the mutate API. Let's try it out ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


  1   2   >