[PATCH] D83497: [PowerPC][Power10] Fix VINS* (vector insert byte/half/word) instructions to have i32 arguments.

2020-07-15 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc5530862870: [PowerPC][Power10] Fix VINS* (vector insert 
byte/half/word) instructions to… (authored by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83497

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
@@ -82,71 +82,71 @@
 }
 declare <2 x i64> @llvm.ppc.vsx.xxblendvd(<2 x i64>, <2 x i64>, <2 x i64>)
 
-define <16 x i8> @testVINSBLX(<16 x i8> %a, i64 %b, i64 %c) {
+define <16 x i8> @testVINSBLX(<16 x i8> %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: testVINSBLX:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vinsblx v2, r5, r6
 ; CHECK-NEXT:blr
 entry:
-  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsblx(<16 x i8> %a, i64 %b, i64 %c)
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsblx(<16 x i8> %a, i32 %b, i32 %c)
   ret <16 x i8> %0
 }
-declare <16 x i8> @llvm.ppc.altivec.vinsblx(<16 x i8>, i64, i64)
+declare <16 x i8> @llvm.ppc.altivec.vinsblx(<16 x i8>, i32, i32)
 
-define <16 x i8> @testVINSBRX(<16 x i8> %a, i64 %b, i64 %c) {
+define <16 x i8> @testVINSBRX(<16 x i8> %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: testVINSBRX:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vinsbrx v2, r5, r6
 ; CHECK-NEXT:blr
 entry:
-  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsbrx(<16 x i8> %a, i64 %b, i64 %c)
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsbrx(<16 x i8> %a, i32 %b, i32 %c)
   ret <16 x i8> %0
 }
-declare <16 x i8> @llvm.ppc.altivec.vinsbrx(<16 x i8>, i64, i64)
+declare <16 x i8> @llvm.ppc.altivec.vinsbrx(<16 x i8>, i32, i32)
 
-define <8 x i16> @testVINSHLX(<8 x i16> %a, i64 %b, i64 %c) {
+define <8 x i16> @testVINSHLX(<8 x i16> %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: testVINSHLX:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vinshlx v2, r5, r6
 ; CHECK-NEXT:blr
 entry:
-  %0 = tail call <8 x i16> @llvm.ppc.altivec.vinshlx(<8 x i16> %a, i64 %b, i64 %c)
+  %0 = tail call <8 x i16> @llvm.ppc.altivec.vinshlx(<8 x i16> %a, i32 %b, i32 %c)
   ret <8 x i16> %0
 }
-declare <8 x i16> @llvm.ppc.altivec.vinshlx(<8 x i16>, i64, i64)
+declare <8 x i16> @llvm.ppc.altivec.vinshlx(<8 x i16>, i32, i32)
 
-define <8 x i16> @testVINSHRX(<8 x i16> %a, i64 %b, i64 %c) {
+define <8 x i16> @testVINSHRX(<8 x i16> %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: testVINSHRX:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vinshrx v2, r5, r6
 ; CHECK-NEXT:blr
 entry:
-  %0 = tail call <8 x i16> @llvm.ppc.altivec.vinshrx(<8 x i16> %a, i64 %b, i64 %c)
+  %0 = tail call <8 x i16> @llvm.ppc.altivec.vinshrx(<8 x i16> %a, i32 %b, i32 %c)
   ret <8 x i16> %0
 }
-declare <8 x i16> @llvm.ppc.altivec.vinshrx(<8 x i16>, i64, i64)
+declare <8 x i16> @llvm.ppc.altivec.vinshrx(<8 x i16>, i32, i32)
 
-define <4 x i32> @testVINSWLX(<4 x i32> %a, i64 %b, i64 %c) {
+define <4 x i32> @testVINSWLX(<4 x i32> %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: testVINSWLX:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vinswlx v2, r5, r6
 ; CHECK-NEXT:blr
 entry:
-  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinswlx(<4 x i32> %a, i64 %b, i64 %c)
+  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinswlx(<4 x i32> %a, i32 %b, i32 %c)
   ret <4 x i32> %0
 }
-declare <4 x i32> @llvm.ppc.altivec.vinswlx(<4 x i32>, i64, i64)
+declare <4 x i32> @llvm.ppc.altivec.vinswlx(<4 x i32>, i32, i32)
 
-define <4 x i32> @testVINSWRX(<4 x i32> %a, i64 %b, i64 %c) {
+define <4 x i32> @testVINSWRX(<4 x i32> %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: testVINSWRX:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vinswrx v2, r5, r6
 ; CHECK-NEXT:blr
 entry:
-  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinswrx(<4 x i32> %a, i64 %b, i64 %c)
+  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinswrx(<4 x i32> %a, i32 %b, i32 %c)
   ret <4 x i32> %0
 }
-declare <4 x i32> @llvm.ppc.altivec.vinswrx(<4 x i32>, i64, i64)
+declare <4 x i32> @llvm.ppc.altivec.vinswrx(<4 x i32>, i32, i32)
 
 define <2 x i64> @testVINSDLX(<2 x i64> %a, i64 %b, i64 %c) {
 ; CHECK-LABEL: testVINSDLX:
@@ -232,16 +232,16 @@
 }
 declare <4 x i32> @llvm.ppc.altivec.vinswvrx(<4 x i32>, i64, <4 x i32>)
 
-define <4 x i32> @testVINSW(<4 x i32> %a, i64 %b) {
+define <4 x i32> @testVINSW(<4 x i32> %a, i32 %b) {
 ; CHECK-LABEL: testVINSW:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:vinsw v2, r5, 1
 ; CHECK-NEXT:blr
 entry:
-  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> %a, i64 %b, i32 1)
+  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> %a, i32 %b, i32 1)

[clang] fc55308 - [PowerPC][Power10] Fix VINS* (vector insert byte/half/word) instructions to have i32 arguments.

2020-07-15 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-07-16T00:30:24-05:00
New Revision: fc55308628709bfc64b100dadf9a030fbb2afaee

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

LOG: [PowerPC][Power10] Fix VINS* (vector insert byte/half/word) instructions 
to have i32 arguments.

Previously, the vins* intrinsic was incorrectly defined to have its second and
third argument arguments as an i64. This patch fixes the second and third
argument of the vins* instruction and intrinsic to have i32s instead.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 6b291e6b0806..5d445c253a85 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -321,12 +321,12 @@ BUILTIN(__builtin_altivec_vsldbi, "V16UcV16UcV16UcIi", "")
 BUILTIN(__builtin_altivec_vsrdbi, "V16UcV16UcV16UcIi", "")
 
 // P10 Vector Insert built-ins.
-BUILTIN(__builtin_altivec_vinsblx, "V16UcV16UcULLiULLi", "")
-BUILTIN(__builtin_altivec_vinsbrx, "V16UcV16UcULLiULLi", "")
-BUILTIN(__builtin_altivec_vinshlx, "V8UsV8UsULLiULLi", "")
-BUILTIN(__builtin_altivec_vinshrx, "V8UsV8UsULLiULLi", "")
-BUILTIN(__builtin_altivec_vinswlx, "V4UiV4UiULLiULLi", "")
-BUILTIN(__builtin_altivec_vinswrx, "V4UiV4UiULLiULLi", "")
+BUILTIN(__builtin_altivec_vinsblx, "V16UcV16UcUiUi", "")
+BUILTIN(__builtin_altivec_vinsbrx, "V16UcV16UcUiUi", "")
+BUILTIN(__builtin_altivec_vinshlx, "V8UsV8UsUiUi", "")
+BUILTIN(__builtin_altivec_vinshrx, "V8UsV8UsUiUi", "")
+BUILTIN(__builtin_altivec_vinswlx, "V4UiV4UiUiUi", "")
+BUILTIN(__builtin_altivec_vinswrx, "V4UiV4UiUiUi", "")
 BUILTIN(__builtin_altivec_vinsdlx, "V2ULLiV2ULLiULLiULLi", "")
 BUILTIN(__builtin_altivec_vinsdrx, "V2ULLiV2ULLiULLiULLi", "")
 BUILTIN(__builtin_altivec_vinsbvlx, "V16UcV16UcULLiV16Uc", "")

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index c51c24f25986..4e804fbafb30 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -402,25 +402,25 @@ vector double test_vec_blend_d(void) {
 }
 
 vector unsigned char test_vec_insertl_uc(void) {
-  // CHECK-BE: @llvm.ppc.altivec.vinsblx(<16 x i8> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-BE: @llvm.ppc.altivec.vinsblx(<16 x i8> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-BE-NEXT: ret <16 x i8>
-  // CHECK-LE: @llvm.ppc.altivec.vinsbrx(<16 x i8> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-LE: @llvm.ppc.altivec.vinsbrx(<16 x i8> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-LE-NEXT: ret <16 x i8>
   return vec_insertl(uca, vuca, uia);
 }
 
 vector unsigned short test_vec_insertl_us(void) {
-  // CHECK-BE: @llvm.ppc.altivec.vinshlx(<8 x i16> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-BE: @llvm.ppc.altivec.vinshlx(<8 x i16> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-BE-NEXT: ret <8 x i16>
-  // CHECK-LE: @llvm.ppc.altivec.vinshrx(<8 x i16> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-LE: @llvm.ppc.altivec.vinshrx(<8 x i16> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-LE-NEXT: ret <8 x i16>
   return vec_insertl(usa, vusa, uia);
 }
 
 vector unsigned int test_vec_insertl_ui(void) {
-  // CHECK-BE: @llvm.ppc.altivec.vinswlx(<4 x i32> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-BE: @llvm.ppc.altivec.vinswlx(<4 x i32> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-BE-NEXT: ret <4 x i32>
-  // CHECK-LE: @llvm.ppc.altivec.vinswrx(<4 x i32> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-LE: @llvm.ppc.altivec.vinswrx(<4 x i32> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-LE-NEXT: ret <4 x i32>
   return vec_insertl(uib, vuia, uia);
 }
@@ -458,25 +458,25 @@ vector unsigned int test_vec_insertl_uiv(void) {
 }
 
 vector unsigned char test_vec_inserth_uc(void) {
-  // CHECK-BE: @llvm.ppc.altivec.vinsbrx(<16 x i8> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-BE: @llvm.ppc.altivec.vinsbrx(<16 x i8> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-BE-NEXT: ret <16 x i8>
-  // CHECK-LE: @llvm.ppc.altivec.vinsblx(<16 x i8> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-LE: @llvm.ppc.altivec.vinsblx(<16 x i8> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-LE-NEXT: ret <16 x i8>
   return vec_inserth(uca, vuca, uia);
 }
 
 vector unsigned short test_vec_inserth_us(void) {
-  // CHECK-BE: @llvm.ppc.altivec.vinshrx(<8 x i16> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-BE: @llvm.ppc.altivec.vinshrx(<8 x i16> %{{.+}}, i32 %{{.+}}, i32
   // CHECK-BE-NEXT: ret <8 x i16>
-  // CHECK-LE: @llvm.ppc.altivec.vinshlx(<8 x i16> %{{.+}}, i64 %{{.+}}, i64
+  // CHECK-LE: 

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Merge request for 11.0 https://bugs.llvm.org/show_bug.cgi?id=46740


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper reopened this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

Reverted in 00f3579aea6e3d4a4b7464c3db47294f71cef9e4 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[clang] 00f3579 - Revert "[InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X transforms" and subsequent patches

2020-07-15 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-07-15T22:02:33-07:00
New Revision: 00f3579aea6e3d4a4b7464c3db47294f71cef9e4

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

LOG: Revert "[InstSimplify] Remove select ?, undef, X -> X and select ?, X, 
undef -> X transforms" and subsequent patches

This reverts most of the following patches due to reports of miscompiles.
I've left the added test cases with comments updated to be FIXMEs.

1cf6f210a2e [IR] Disable select ? C : undef -> C fold in 
ConstantFoldSelectInstruction unless we know C isn't poison.
469da663f2d [InstSimplify] Re-enable select ?, undef, X -> X transform when X 
is provably not poison
122b0640fc9 [InstSimplify] Don't fold vectors of partial undef in 
SimplifySelectInst if the non-undef element value might produce poison
ac0af12ed2f [InstSimplify] Add test cases for opportunities to fold select ?, 
X, undef -> X when we can prove X isn't poison
9b1e95329af [InstSimplify] Remove select ?, undef, X -> X and select ?, X, 
undef -> X transforms

Added: 


Modified: 
clang/test/CodeGen/arm-mve-intrinsics/dup.c
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/test/Transforms/InferAddressSpaces/AMDGPU/select.ll
llvm/test/Transforms/InstCombine/select.ll
llvm/test/Transforms/InstSimplify/select.ll

Removed: 




diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/dup.c 
b/clang/test/CodeGen/arm-mve-intrinsics/dup.c
index b443917cb258..283c08257005 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/dup.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/dup.c
@@ -242,8 +242,7 @@ uint32x4_t test_vdupq_m_n_u32(uint32x4_t inactive, uint32_t 
a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <8 x half> undef, 
half [[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <8 x half> 
[[DOTSPLATINSERT]], <8 x half> undef, <8 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x half> 
[[DOTSPLAT]], <8 x half> undef
-// CHECK-NEXT:ret <8 x half> [[TMP2]]
+// CHECK-NEXT:ret <8 x half> [[DOTSPLAT]]
 //
 float16x8_t test_vdupq_x_n_f16(float16_t a, mve_pred16_t p)
 {
@@ -256,8 +255,7 @@ float16x8_t test_vdupq_x_n_f16(float16_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <4 x float> undef, 
float [[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <4 x float> 
[[DOTSPLATINSERT]], <4 x float> undef, <4 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x float> 
[[DOTSPLAT]], <4 x float> undef
-// CHECK-NEXT:ret <4 x float> [[TMP2]]
+// CHECK-NEXT:ret <4 x float> [[DOTSPLAT]]
 //
 float32x4_t test_vdupq_x_n_f32(float32_t a, mve_pred16_t p)
 {
@@ -270,8 +268,7 @@ float32x4_t test_vdupq_x_n_f32(float32_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> undef, i8 
[[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <16 x i8> 
[[DOTSPLATINSERT]], <16 x i8> undef, <16 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP2:%.*]] = select <16 x i1> [[TMP1]], <16 x i8> 
[[DOTSPLAT]], <16 x i8> undef
-// CHECK-NEXT:ret <16 x i8> [[TMP2]]
+// CHECK-NEXT:ret <16 x i8> [[DOTSPLAT]]
 //
 int8x16_t test_vdupq_x_n_s8(int8_t a, mve_pred16_t p)
 {
@@ -284,8 +281,7 @@ int8x16_t test_vdupq_x_n_s8(int8_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> undef, i16 
[[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <8 x i16> 
[[DOTSPLATINSERT]], <8 x i16> undef, <8 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i16> 
[[DOTSPLAT]], <8 x i16> undef
-// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+// CHECK-NEXT:ret <8 x i16> [[DOTSPLAT]]
 //
 int16x8_t test_vdupq_x_n_s16(int16_t a, mve_pred16_t p)
 {
@@ -298,8 +294,7 @@ int16x8_t test_vdupq_x_n_s16(int16_t a, mve_pred16_t p)
 // CHECK-NEXT:[[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 
[[TMP0]])
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 
[[A:%.*]], i32 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <4 x i32> 
[[DOTSPLATINSERT]], <4 x i32> undef, <4 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> 
[[DOTSPLAT]], <4 x i32> undef
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:ret <4 x 

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm going to revert this as Eric requested. And I'll ask to merge the revert to 
the 11 branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D70411: [analyzer] CERT STR rule checkers: STR31-C

2020-07-15 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks for the reviews!

In D70411#2153562 , @Szelethus wrote:

> Please do not bypass the previous comments that hadn't reached a conclusion 
> -- littering inlines about miscellaneous stuff at this stage does more harm 
> then good, and derails the discussion.


Ugh, it is a long story. I really wanted to create the best and trendiest 
checker of all time with Artem so all the comments are made for him at first. 
We have had the exact opposite sense what we are trying to achieve here, that 
is why we left the project dead.

Hopefully I get your suggestion right and you want to make sure I have 
addressed all the comments. Let me begin with a suggestion as well:

> If you are interested in the solution, please do not care about the problem, 
> but the solution.

- non-literal advice from //It's Not About the Shark: How to Solve Unsolvable 
Problems//

-

Let me rewind / summarize what problems happened in chunks if you would Ctrl+F5 
for certain quotes and what we did in chronological order:

> You're bringing in a completely brand-new machinery here, could you explain 
> how it works and why do you need it?

I have attached multiple bug reports to the program state (by registering a 
map) and invalidated all the non-fatal reports in chain on the bug-path to a 
given fatal-report to support two functionality of the checker.

That two functionality was a complete stupidity it turned out, I have left only 
the necessary one.

> I think it would really help if you draw a state machine for the checker

Because I have removed the complexity of the checker now it is easy to 
understand and it does not require an appendix.

> But it doesn't necessarily mean that static analysis tools can be built by 
> generalizing over the examples from the CERT wiki.

Artem refuse the usefulness of the CERT rules from the static analysis 
perspective, which I agree with.

> "if string length metadata is tainted (in particular, if the string itself is 
> tainted) and is potentially larger than the destination buffer size (eg., 
> unconstrained), warn"

Artem suggests to develop taint analysis, which I do not want to develop, but 
his concerns are real.

> Traditionally checkers either warn immediately when they can detect an error, 
> or assume that the error has not happened.

That was the near the point when I have realized we need to warn on the 
function calls immediately. The buffer overflow is immediately a security 
issue, but I was dumb to realize.

> I took a look at first 5 and in all of them the code does in fact ensure that 
> the buffer space is sufficient, but in 5 different ways.

Artem believes the arrays are cool because they cannot overflow. For example we 
obtain an IP address, which has enough space as `char[64]` our mental model 
suggests. I believe any overflow is not cool in a security point of view: 
https://twitter.com/TwitterSupport/status/1283526400146837511

Now I have accepted Artem's suggestion and I do not care about arrays because 
the Analyzer cannot model the constraints of the array size yet / taintness. If 
someone working with a plain char array that could be easy to detect and 
measure. For the security problems we want to catch allocations.

> The known size does not mean that the string is going to be null-terminated.
>  The problem is not the size, but the missing '\0' (which you can have 
> multiple of at any point).

I still wanted to care about null-termination, however the entire checker 
should be about overflow.

> - "The checker warns every time it finds an execution path on which 
> unintended behavior occurs"
> - "The checker enforces a certain coding guideline on the user": (say, "don't 
> pass the string by pointer anywhere before you null-terminate it")
> - If you rely on the existing taint analysis infrastructure and make a good 
> check, that'll be wonderful and would further encourage us to move taint 
> analysis out of alpha.

Artem tried to create a direction for the checker, it was pretty complex. I 
have refused again, because all the people null terminate by hand.

> This text may be hard to understand.

Balazs get confused by the second behavior, like Artem did for a while. I have 
tried to rephrase the documentation. With Balazs' help we made the 
documentation cool (Thanks again!).

> Get rid of the secondary behavior for now.

That was the time when I have learnt complexity is a huge issue and people will 
get confused. I have removed the entire secondary behavior of null termination 
checking and moved some logic to STR32-C.

-

The conclusion: Now this checker is very strict and hopefully enough simple. I 
hope we could design the future of checker-writing.




Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:859
+
+def Str31cChecker : Checker<"31c">,
+  HelpText<"SEI CERT checker of rules defined in STR31-C">,


[PATCH] D70411: [analyzer] CERT STR rule checkers: STR31-C

2020-07-15 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 278368.
Charusso marked 18 inline comments as done.
Charusso edited the summary of this revision.
Charusso added a comment.

- Resolve most of the review comments.
- We really need to specify the design of future checkers.


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

https://reviews.llvm.org/D70411

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/AST/FormatStringParsing.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/FormatStringParsing.h
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-extras.cpp
  clang/test/Analysis/cert/str31-c-notes.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,184 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.31c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31-C:
+// https://wiki.sei.cmu.edu/confluence/x/sNUxBQ
+
+#include "../Inputs/system-header-simulator.h"
+
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+// expected-warning@-1 {{'gets' could write outside of 'buf'}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+  // expected-warning@-1 {{'sprintf' could write outside of 'buf'}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  fscanf(stdin, "%s", buf);
+  // expected-warning@-1 {{'fscanf' could write outside of 'buf'}}
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  fscanf(stdin, "%1023s", buff);
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+  // expected-warning@-1 {{'strcpy' could write outside of 'prog_name'}}
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+// expected-warning@-1 {{'strcpy' could write outside of 'buff'}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following are from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_bad
+
+namespace test_loop_index_good {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n - 1); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_good
+
+namespace test_getchar_bad {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  char *p;
+  int ch;
+  p = buf;
+  while ((ch = getchar()) != '\n' && ch != EOF) {
+*p++ = (char)ch;
+  }
+  *p++ = 0;
+  if (ch == EOF) {
+/* Handle EOF or error */
+  }
+}
+} // namespace test_getchar_bad
+
+namespace test_getchar_good {
+enum { BUFFERSIZE = 

[PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption

2020-07-15 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 278361.
pzheng added a comment.

Add target triple used in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83648

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/integrated-as.c


Index: clang/test/Driver/integrated-as.c
===
--- clang/test/Driver/integrated-as.c
+++ clang/test/Driver/integrated-as.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s
 
 // CHECK: cc1as
@@ -7,6 +8,10 @@
 
 // FIAS: cc1as
 
+// RUN: %clang -target x86_64 -### -fintegrated-as %s 2>&1 | FileCheck %s 
-check-prefix FIAS-LINK
+
+// FIAS-LINK-NOT: -fintegrated-as
+
 // RUN: %clang -target none -### -fno-integrated-as -S %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix NOFIAS
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2887,7 +2887,7 @@
   MetaVarName<"">;
 def y : Joined<["-"], "y">;
 
-defm integrated_as : OptOutFFlag<"integrated-as", "Enable the integrated 
assembler", "Disable the integrated assembler">;
+defm integrated_as : OptOutFFlag<"integrated-as", "Enable", "Disable", " the 
integrated assembler", [DriverOption]>;
 
 def fintegrated_cc1 : Flag<["-"], "fintegrated-cc1">,
   Flags<[CoreOption, DriverOption]>, Group,


Index: clang/test/Driver/integrated-as.c
===
--- clang/test/Driver/integrated-as.c
+++ clang/test/Driver/integrated-as.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s
 
 // CHECK: cc1as
@@ -7,6 +8,10 @@
 
 // FIAS: cc1as
 
+// RUN: %clang -target x86_64 -### -fintegrated-as %s 2>&1 | FileCheck %s -check-prefix FIAS-LINK
+
+// FIAS-LINK-NOT: -fintegrated-as
+
 // RUN: %clang -target none -### -fno-integrated-as -S %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix NOFIAS
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2887,7 +2887,7 @@
   MetaVarName<"">;
 def y : Joined<["-"], "y">;
 
-defm integrated_as : OptOutFFlag<"integrated-as", "Enable the integrated assembler", "Disable the integrated assembler">;
+defm integrated_as : OptOutFFlag<"integrated-as", "Enable", "Disable", " the integrated assembler", [DriverOption]>;
 
 def fintegrated_cc1 : Flag<["-"], "fintegrated-cc1">,
   Flags<[CoreOption, DriverOption]>, Group,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption

2020-07-15 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng marked 2 inline comments as done.
pzheng added a comment.

In D83648#2146606 , @MaskRay wrote:

> Created http://lists.llvm.org/pipermail/cfe-dev/2020-July/066245.html 
> [cfe-dev] Usage of clang::driver::options::DriverOption (-Xarch_ & gcc 
> toolchain)
>  to ask about the use case.
>
> When I get time, I'll work on a patch fixing the whole class of options 
> instead of just -fintegrated-as. I will use `OPT_Link_Group` and add some 
> extra options in the new group:  `GCCLinkOption`.


Sounds like I should remove the test from this patch since you will fix a class 
of options later?




Comment at: clang/test/Driver/integrated-as.c:10
 
+// RUN: %clang -### -fintegrated-as %s 2>&1 | FileCheck %s -check-prefix 
FIAS-LINK
+

MaskRay wrote:
> MaskRay wrote:
> > This test is incorrect. You need a specific target triple to select 
> > bare-metal like GCC driver.
> There are so many clang specific options. I think we just need a centralized 
> test file to test options in patch, instead of adding random `-NOT` check 
> lines to random files.
Thanks for pointing this out. Will update the triple.



Comment at: clang/test/Driver/integrated-as.c:10
 
+// RUN: %clang -### -fintegrated-as %s 2>&1 | FileCheck %s -check-prefix 
FIAS-LINK
+

pzheng wrote:
> MaskRay wrote:
> > MaskRay wrote:
> > > This test is incorrect. You need a specific target triple to select 
> > > bare-metal like GCC driver.
> > There are so many clang specific options. I think we just need a 
> > centralized test file to test options in patch, instead of adding random 
> > `-NOT` check lines to random files.
> Thanks for pointing this out. Will update the triple.
Can you suggest a file to add the test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83648



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


[libunwind] fd802cc - [libunwind] Fix getSLEB128 on large values

2020-07-15 Thread Ryan Prichard via cfe-commits

Author: Ryan Prichard
Date: 2020-07-15T19:12:56-07:00
New Revision: fd802cc4dea4ed1a233ff725f98c686dc2836bf3

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

LOG: [libunwind] Fix getSLEB128 on large values

Previously, for large-enough values, getSLEB128 would attempt to shift
a signed int in the range [0..0x7f] by 28, 35, 42... bits, which is
undefined behavior and likely to fail.

Avoid shifting (-1ULL) by 70 for large values. e.g. For INT64_MAX, the
last two bytes will be:
 - 0x7f [bit==56]
 - 0x00 [bit==63]

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

Added: 


Modified: 
libunwind/src/AddressSpace.hpp

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index a4564cb67328..764aaa3489f2 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -290,11 +290,11 @@ inline int64_t LocalAddressSpace::getSLEB128(pint_t 
, pint_t end) {
 if (p == pend)
   _LIBUNWIND_ABORT("truncated sleb128 expression");
 byte = *p++;
-result |= ((byte & 0x7f) << bit);
+result |= (uint64_t)(byte & 0x7f) << bit;
 bit += 7;
   } while (byte & 0x80);
   // sign extend negative numbers
-  if ((byte & 0x40) != 0)
+  if ((byte & 0x40) != 0 && bit < 64)
 result |= (-1ULL) << bit;
   addr = (pint_t) p;
   return result;



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


[libunwind] 52d0a78 - [libunwind] Fix CIE v1 return address parsing

2020-07-15 Thread Ryan Prichard via cfe-commits

Author: Ryan Prichard
Date: 2020-07-15T19:12:55-07:00
New Revision: 52d0a78b831584c46eda78b7cf349ab93ce13df0

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

LOG: [libunwind] Fix CIE v1 return address parsing

 - For CIE version 1 (e.g. in DWARF 2.0.0), the return_address_register
   field is a ubyte [0..255].

 - For CIE version 3 (e.g. in DWARF 3), the field is instead a ULEB128
   constant.

Previously, libunwind accepted a CIE version of 1 or 3, but always
parsed the field as ULEB128.

Clang always outputs CIE version 1 into .eh_frame. (It can output CIE
version 3 or 4, but only into .debug_frame.)

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

Added: 


Modified: 
libunwind/src/DwarfParser.hpp

Removed: 




diff  --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index d05ac468367f..c98c4f92a6ad 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -336,7 +336,8 @@ const char *CFI_Parser::parseCIE(A , pint_t 
cie,
   // parse data alignment factor
   cieInfo->dataAlignFactor = (int)addressSpace.getSLEB128(p, cieContentEnd);
   // parse return address register
-  uint64_t raReg = addressSpace.getULEB128(p, cieContentEnd);
+  uint64_t raReg = (version == 1) ? addressSpace.get8(p++)
+  : addressSpace.getULEB128(p, cieContentEnd);
   assert(raReg < 255 && "return address register too large");
   cieInfo->returnAddressRegister = (uint8_t)raReg;
   // parse augmentation data based on augmentation string



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread George Rokos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG537b16e9b8da: [OpenMP 5.0] Codegen support to pass 
user-defined mapper functions to runtime (authored by grokos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67833

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.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_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/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_parallel_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

OK, now it works. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67833



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In D83360#2154637 , @aqjune wrote:

> In D83360#2154584 , @echristo wrote:
>
> > It's that even before the msan instrumentation the IR doesn't look correct 
> > - thus a miscompile.
>
>
> I'll share a prototype of the InstSimplify patch on Phabricator, in a day or 
> two; it would be great if the miscompilation is fixed with the patch.


Would it be reasonable to revert this in the meantime?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 278343.
jdenny edited the summary of this revision.
jdenny set the repository for this revision to rG LLVM Github Monorepo.
jdenny added a comment.

Rebased, and extracted D83922  as discussed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83061

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_data_ast_print.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp

Index: clang/test/OpenMP/target_teams_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_map_messages.cpp
+++ clang/test/OpenMP/target_teams_map_messages.cpp
@@ -468,7 +468,7 @@
 
 #pragma omp target data map(always, tofrom: x)
 #pragma omp target data map(always: x) // expected-error {{missing map type}}
-#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
 #pragma omp target data map(always, tofrom: always, tofrom, x)
 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   foo();
@@ -543,7 +543,7 @@
 
 #pragma omp target data map(always, tofrom: x)
 #pragma omp target data map(always: x) // expected-error {{missing map type}}
-#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
 #pragma omp target data map(always, tofrom: always, tofrom, x)
 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   foo();
Index: clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
===
--- clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
+++ clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
@@ -175,7 +175,7 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always: x) // expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always, tofrom: always, tofrom, x)
   for (i = 0; i < argc; ++i) foo();
@@ -287,7 +287,7 @@
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always: x) // expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}}
+#pragma omp target teams distribute simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', 'mapper', or 'present'}} expected-error {{missing map type}}
   for (i = 0; i < argc; ++i) foo();
 #pragma omp target teams distribute simd map(always, tofrom: always, tofrom, x)
   for (i = 0; i < argc; ++i) foo();
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp

[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: ABataev, jdoerfert, hfinkel, Meinersbur, kkwli0, 
grokos, sfantao, gtbercea, Hahnfeld.
Herald added subscribers: cfe-commits, sstefan1, guansong, yaxunl.
Herald added a project: clang.

For example, without this patch:

  $ cat test.c
  int main() {
int x[3];
#pragma omp target map(tofrom:x[0:3])
  #ifdef USE 
x[0] = 1 
  #endif
;   
return 0;
  }
  $ clang -fopenmp -fopenmp-targets=nvptx64-nvida-cuda -S -emit-llvm test.c
  $ grep '^@.offload_maptypes' test.ll
  $ echo $?
  1
  $ clang -fopenmp -fopenmp-targets=nvptx64-nvida-cuda -S -emit-llvm test.c \
  -DUSE
  $ grep '^@.offload_maptypes' test.ll
  @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 35] 

With this patch, both greps produce the same result.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83922

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_teams_map_codegen.cpp

Index: clang/test/OpenMP/target_teams_map_codegen.cpp
===
--- clang/test/OpenMP/target_teams_map_codegen.cpp
+++ clang/test/OpenMP/target_teams_map_codegen.cpp
@@ -20,15 +20,16 @@
 #ifndef HEADER
 #define HEADER
 
+// HOST: @[[MAPTYPES_PRIVATE:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
 // HOST: @[[MAPTYPES_FIRSTPRIVATE:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
 // HOST: @[[MAPTYPES_REDUCTION:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
 // HOST: @[[MAPTYPES_FROM:.offload_maptypes[0-9.]*]] = private {{.*}}constant [1 x i64] [i64 34]
 // HOST: @[[MAPTYPES_TO:.offload_maptypes[0-9.]*]] = private {{.*}}constant [1 x i64] [i64 33]
 // HOST: @[[MAPTYPES_ALLOC:.offload_maptypes[0-9.]*]] = private {{.*}}constant [1 x i64] [i64 32]
-// HOST: @[[MAPTYPES_ARRAY_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
-// HOST: @[[MAPTYPES_ARRAY_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 33, i64 33]
-// HOST-INT128: @[[MAPTYPES_INT128_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 35, i64 35]
-// HOST-INT128: @[[MAPTYPES_INT128_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [2 x i64] [i64 34, i64 34]
+// HOST: @[[MAPTYPES_ARRAY_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 35, i64 35, i64 35]
+// HOST: @[[MAPTYPES_ARRAY_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 33, i64 33, i64 33]
+// HOST-INT128: @[[MAPTYPES_INT128_R0:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 35, i64 35, i64 35]
+// HOST-INT128: @[[MAPTYPES_INT128_R1:.offload_maptypes[0-9.]*]] = private {{.*}}constant [3 x i64] [i64 34, i64 34, i64 34]
 //
 // CHECK: @.omp_offloading.entry_name{{[0-9.]*}} = {{.*}} c"[[OFFLOAD_PRIVATE:__omp_offloading_[^"\\]*mapWithPrivate[^"\\]*]]\00"
 // CHECK: @.omp_offloading.entry_name{{[0-9.]*}} = {{.*}} c"[[OFFLOAD_FIRSTPRIVATE:__omp_offloading_[^"\\]*mapWithFirstprivate[^"\\]*]]\00"
@@ -42,9 +43,7 @@
 // INT128: @.omp_offloading.entry_name{{[0-9.]*}} = {{.*}} c"[[OFFLOAD_INT128_R1:__omp_offloading_[^"\\]*mapInt128[^"\\]*]]\00"
 
 // HOST: define {{.*}}mapWithPrivate
-// HOST: call {{.*}} @.[[OFFLOAD_PRIVATE]].region_id
-// HOST-NOT: offload_maptypes
-// HOST-SAME: {{$}}
+// HOST: call {{.*}} @.[[OFFLOAD_PRIVATE]].region_id{{.*}} @[[MAPTYPES_PRIVATE]]
 //
 // CHECK: define {{.*}} void @[[OFFLOAD_PRIVATE]]()
 // CHECK: call void ({{.*}}@[[OUTLINE_PRIVATE:.omp_outlined.[.0-9]*]]
Index: clang/test/OpenMP/target_map_codegen.cpp
===
--- clang/test/OpenMP/target_map_codegen.cpp
+++ clang/test/OpenMP/target_map_codegen.cpp
@@ -1307,12 +1307,26 @@
 
 #endif
 ///==///
-// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s --check-prefix CK19 --check-prefix CK19-64
+// RUN: %clang_cc1 -DUSE -DCK19 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s --check-prefixes=CK19,CK19-64,CK19-USE
+// RUN: %clang_cc1 -DUSE -DCK19 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -DUSE -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefixes=CK19,CK19-64,CK19-USE
+// RUN: %clang_cc1 -DUSE -DCK19 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread Lingda Li via Phabricator via cfe-commits
lildmh added a comment.

In D67833#2154312 , @grokos wrote:

> I tried to build clang with this patch and I get errors like:
>
>   CGOpenMPRuntime.cpp:9463:38: error: 
> ‘OMPRTL___tgt_target_teams_nowait_mapper’ was not declared in this scope
>   ? 
> OMPRTL___tgt_target_teams_nowait_mapper
>
>
> Where are these `OMPRTL___tgt_` symbols defined?


Sorry I forgot to include the llvm part. Please try again


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

https://reviews.llvm.org/D67833



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 278344.
lildmh added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Include the llvm part


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

https://reviews.llvm.org/D67833

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.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_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/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_parallel_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

In D83360#2154584 , @echristo wrote:

> It's that even before the msan instrumentation the IR doesn't look correct - 
> thus a miscompile.


I'll share a prototype of the InstSimplify patch on Phabricator, in a day or 
two; it would be great if the miscompilation is fixed with the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-15 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278341.
dokyungs added a comment.

Ensure the fuzzer RT module is initialized at the beginning of the interceptors.

Interceptors can be called before __fuzzer_init is called. So I added a check 
at the beginning of the interceptors, which ensures that __fuzzer_init has been 
called before proceeding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/fuzzer/CMakeLists.txt
  compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test

Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
===
--- /dev/null
+++ compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
@@ -0,0 +1,171 @@
+//===-- FuzzerInterceptors.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// Intercept certain libc functions to aid fuzzing.
+// Linked only when other RTs that define their own interceptors are not linked.
+//===--===//
+
+#include "FuzzerPlatform.h"
+#include 
+#include 
+#include 
+
+#define GET_CALLER_PC() __builtin_return_address(0)
+
+#if LIBFUZZER_LINUX
+
+#define PTR_TO_REAL(x) real_##x
+#define REAL(x) __interception::PTR_TO_REAL(x)
+#define FUNC_TYPE(x) x##_type
+#define DEFINE_REAL(ret_type, func, ...) 

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

It's that even before the msan instrumentation the IR doesn't look correct - 
thus a miscompile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83893: [CUDA][HIP] Always defer diagnostics for wrong-sided reference

2020-07-15 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

tra and I talked offline and I...think this makes sense.


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

https://reviews.llvm.org/D83893



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D83360#2154545 , @echristo wrote:

> We're starting to see miscompiles as we do more testing as well, just nothing 
> smaller at the moment.


Could you clarify, do you mean that this fix is causing (new) miscompiles?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

We're starting to see miscompiles as we do more testing as well, just nothing 
smaller at the moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D83360#2154540 , @echristo wrote:

> This seems like something that we should then revert until we know that 
> instsimplify can be updated with a fix?


Possibility for a miscompile sounds much worse to me than a false-positive 
diag..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-15 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

This seems like something that we should then revert until we know that 
instsimplify can be updated with a fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83914: [clangd] Plan features for FoldingRanges

2020-07-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 278329.
kbobyrev added a comment.

Add some missing ranges.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83914

Files:
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -234,6 +234,510 @@
   }
 }
 
+TEST(FoldingRanges, ControlFlow) {
+  const char *Tests[] = {
+  // If.
+  R"cpp(
+int main() {[[
+  bool B = true;
+  int I = 0;
+  char C = 'z';
+
+  if ([[B && I > 42 || ~([[++I]])]]) {[[
+++I;
+  ]]} else {[[
+B = false;
+  ]]}
+
+  if ([[B && ([[!B]]) || !([[([[C == 'a']])]])]]) {[[
+++I;
+  ]]} else if ([[!B]]) {[[
+--I;
+  ]]} else {[[
+C = 'a';
+  ]]}
+]]}
+  )cpp",
+  // While.
+  R"cpp(
+int main() {[[
+  bool B;
+  while ([[B]]) {[[
+B = !B;
+  ]]}
+
+  do {[[
+B = !B;
+  ]]} while ([[B]]);
+]]}
+  )cpp",
+  // For.
+  R"cpp(
+int main() {[[
+  for (int I = 0]];[[I < 42]];[[++I) {[[
+--I;
+  ]]}
+]]}
+  )cpp",
+  // Switch.
+  R"cpp(
+void noop();
+
+int main() {[[
+  int i = 2;
+  switch ([[i]]) {[[
+  case 1:[[ noop();]]
+  case 2:[[ noop(); //[[execution starts at this case label
+  case 3:[[ noop();]]
+  case 4:
+  case 5:[[ noop();
+  break;  //[[execution of subsequent statements is terminated
+  case 6:[[ noop();]]
+  ]]}
+]]}
+  )cpp",
+  };
+  for (const char *Test : Tests) {
+auto T = Annotations(Test);
+auto AST = TestTU::withCode(T.code()).build();
+EXPECT_THAT(gatherFoldingRanges(llvm::cantFail(getFoldingRanges(AST))),
+UnorderedElementsAreArray(T.ranges()))
+<< Test;
+  }
+}
+
+TEST(FoldingRanges, Misc) {
+  const char *Tests[] = {
+  // Statement groups.
+  R"cpp(
+int main() {[[
+  [[int X = 5;
+  int Y = 42;
+  bool B = 15;]]
+  if ([[B]]) {[[ ++X; ]]}
+  unsigned U = 9000;
+]]}
+  )cpp",
+  // Enum.
+  R"cpp(
+enum Color {[[
+  Green = 0,
+  YInMn,
+  Orange,
+]]};
+  )cpp",
+  // Argument lists.
+  R"cpp(
+int foo([[char C, bool B]]) {[[ return static_cast(C); ]]}
+
+foo([['z', true]]);
+
+struct Foo {
+  Foo([[int I, unsigned U, bool B=true]]) {}
+};
+
+Foo F = Foo([[/*[[I=]]*/1, /*[[U=]]*/2, /*[[B=]]false]]);
+F = Foo([[1, 2]]);
+  )cpp",
+  // Namespace.
+  R"cpp(
+namespace ns {[[
+int Variable = 42;
+namespace nested {[[
+int NestedVariable = 50;
+]]}
+]]}
+
+namespace a {[[
+namespace b {[[
+namespace c {[[
+
+]]} //[[ namespacee c]]
+]]} //[[ namespacee b]]
+]]} //[[ namespacee a]]
+
+namespace modern::ns::syntax {[[
+]]} //[[ namespace modern::ns::syntax]]
+
+namespace {[[
+]]} //[[ namespace]]
+  )cpp",
+  // Strings.
+  R"cpp(
+std::string String = "[[ShortString]]";
+String = "[[Super Long String]]";
+String = u8"[[Super Long String]]";
+
+String = R"raw([[Super Looong String]])raw";
+
+const char *text =
+  "[[This"
+  "is a multiline"
+  "string]]";
+
+const char *text2 =
+  "[[Here is another \
+string \
+also \
+multilinee]]";
+  )cpp",
+  // Arrays.
+  R"cpp(
+char Array[] = {[[ 'F', 'o', 'o', 'b', 'a', 'r', '\0' ]};
+
+Array = {[[ 'F', 'o', 'o', 'b', 'a', 'r', 'F', 'o', 'o', 'b',
+ 'a', 'r', '\0' ]]};
+
+int Nested[3][4] = {[[{[[0,1,2,3]]}, {[[4,5,6,7]]}, {[[8,9,10,11]]}};
+  )cpp",
+  // Templates.
+  R"cpp(
+template <[[typename T, typename U, typename V, int X, char C, bool B]]>
+class Foo {};
+
+template <[[bool B]]>
+class Foo<[[unsigned, unsigned, unsigned, -42, 'z', B]]> {
+  int Specialization;
+};
+
+template <>
+class Foo<[[unsigned, unsigned, unsigned, -42, 'z', false]]> {
+  int Specialization;
+};
+
+Foo<[[char, int, bool, 42, 'x', false]]> F;
+
+   

[PATCH] D83914: [clangd] Plan features for FoldingRanges

2020-07-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 278327.
kbobyrev added a comment.

Fix some typos.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83914

Files:
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -234,6 +234,510 @@
   }
 }
 
+TEST(FoldingRanges, ControlFlow) {
+  const char *Tests[] = {
+  // If.
+  R"cpp(
+int main() {[[
+  bool B = true;
+  int I = 0;
+  char C = 'z';
+
+  if ([[B && I > 42 || ~([[++I]])]]) {[[
+++I;
+  ]]} else {[[
+B = false;
+  ]]}
+
+  if ([[B && ([[!B]]) || !([[([[C == 'a']])]])]]) {[[
+++I;
+  ]]} else if ([[!B]]) {[[
+--I;
+  ]]} else {[[
+C = 'a';
+  ]]}
+]]}
+  )cpp",
+  // While.
+  R"cpp(
+int main() {[[
+  bool B;
+  while ([[B]]) {[[
+B = !B;
+  ]]}
+
+  do {[[
+B = !B;
+  ]]} while ([[B]]);
+]]}
+  )cpp",
+  // For.
+  R"cpp(
+int main() {[[
+  for (int I = 0]];[[I < 42]];[[++I) {[[
+--I;
+  ]]}
+]]}
+  )cpp",
+  // Switch.
+  R"cpp(
+void noop();
+
+int main() {[[
+  int i = 2;
+  switch ([[i]]) {[[
+  case 1:[[ noop();]]
+  case 2:[[ noop(); //[[execution starts at this case label
+  case 3:[[ noop();]]
+  case 4:
+  case 5:[[ noop();
+  break;  //[[execution of subsequent statements is terminated
+  case 6:[[ noop();]]
+  ]]}
+]]}
+  )cpp",
+  };
+  for (const char *Test : Tests) {
+auto T = Annotations(Test);
+auto AST = TestTU::withCode(T.code()).build();
+EXPECT_THAT(gatherFoldingRanges(llvm::cantFail(getFoldingRanges(AST))),
+UnorderedElementsAreArray(T.ranges()))
+<< Test;
+  }
+}
+
+TEST(FoldingRanges, Misc) {
+  const char *Tests[] = {
+  // Statement groups.
+  R"cpp(
+int main() {[[
+  [[int X = 5;
+  int Y = 42;
+  bool B = 15;]]
+  if ([[B]]) {[[ ++X; ]]}
+  unsigned U = 9000;
+]]}
+  )cpp",
+  // Enum.
+  R"cpp(
+enum Color {[[
+  Green = 0,
+  YInMn,
+  Orange,
+]]};
+  )cpp",
+  // Argument lists.
+  R"cpp(
+int foo([[char C, bool B]]) { return static_cast(C); }
+
+foo([['z', true]]);
+
+struct Foo {
+  Foo([[int I, unsigned U, bool B=true]]) {}
+};
+
+Foo F = Foo([[/*[[I=]]*/1, /*[[U=]]*/2, /*[[B=]]false]]);
+F = Foo([[1, 2]]);
+  )cpp",
+  // Namespace.
+  R"cpp(
+namespace ns {[[
+int Variable = 42;
+namespace nested {[[
+int NestedVariable = 50;
+]]}
+]]}
+
+namespace a {[[
+namespace b {[[
+namespace c {[[
+
+]]} //[[ namespacee c]]
+]]} //[[ namespacee b]]
+]]} //[[ namespacee a]]
+
+namespace modern::ns::syntax {[[
+]]} //[[ namespace modern::ns::syntax]]
+
+namespace {[[
+]]} //[[ namespace]]
+  )cpp",
+  // Strings.
+  R"cpp(
+std::string String = "[[ShortString]]";
+String = "[[Super Long String]]";
+String = u8"[[Super Long String]]";
+
+String = R"raw([[Super Looong String]])raw";
+
+const char *text =
+  "[[This"
+  "is a multiline"
+  "string]]";
+
+const char *text2 =
+  "[[Here is another \
+string \
+also \
+multilinee]]";
+  )cpp",
+  // Arrays.
+  R"cpp(
+char Array[] = {[[ 'F', 'o', 'o', 'b', 'a', 'r', '\0' ]};
+
+Array = {[[ 'F', 'o', 'o', 'b', 'a', 'r', 'F', 'o', 'o', 'b',
+ 'a', 'r', '\0' ]]};
+
+int Nested[3][4] = {[[{[[0,1,2,3]]}, {[[4,5,6,7]]}, {[[8,9,10,11]]}};
+  )cpp",
+  // Templates.
+  R"cpp(
+template <[[typename T, typename U, typename V, int X, char C, bool B]]>
+class Foo {};
+
+template <[[bool B]]>
+class Foo<[[unsigned, unsigned, unsigned, -42, 'z', B]]> {
+  int Specialization;
+};
+
+template <>
+class Foo<[[unsigned, unsigned, unsigned, -42, 'z', false]]> {
+  int Specialization;
+};
+
+Foo<[[char, int, bool, 42, 'x', false]]> F;
+
+

[PATCH] D83914: [clangd] Plan features for FoldingRanges

2020-07-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

This is not an actual patch, this is an RFC + TDD plan for future RAV
implementation. Hopefully, the implementation would gradually make all of the
tests from this snippet pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83914

Files:
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -234,6 +234,510 @@
   }
 }
 
+TEST(FoldingRanges, ControlFlow) {
+  const char *Tests[] = {
+  // If.
+  R"cpp(
+int main() {[[
+  bool B = true;
+  int I = 0;
+  char C = 'z';
+
+  if ([[B && I > 42 || ~([[++I]])]]) {[[
+++I;
+  ]]} else {[[
+B = false;
+  ]]}
+
+  if ([[B && ([[!B]]) || !([[([[C == 'a']])]])]]) {[[
+++I;
+  ]]} else if ([[!B]]) {[[
+--I;
+  ]]} else {[[
+C = 'a';
+  ]]}
+]]}
+  )cpp",
+  // While.
+  R"cpp(
+int main() {[[
+  bool B;
+  while ([[B]]) {[[
+B = !B;
+  ]]}
+
+  do {[[
+B = !B;
+  ]]} while ([[B]]);
+]]}
+  )cpp",
+  // For.
+  R"cpp(
+int main() {[[
+  for (int I = 0]];[[I < 42]];[[++I) {[[
+--I;
+  ]]}
+]]}
+  )cpp",
+  // Switch.
+  R"cpp(
+void noop();
+
+int main() {[[
+  int i = 2;
+  switch ([[i]]) {[[
+  case 1:[[ noop();]]
+  case 2:[[ noop(); //[[execution starts at this case label
+  case 3:[[ noop();]]
+  case 4:
+  case 5:[[ noop();
+  break;  //[[execution of subsequent statements is terminated
+  case 6:[[ noop();]]
+  ]]}
+]]}
+  )cpp",
+  };
+  for (const char *Test : Tests) {
+auto T = Annotations(Test);
+auto AST = TestTU::withCode(T.code()).build();
+EXPECT_THAT(gatherFoldingRanges(llvm::cantFail(getFoldingRanges(AST))),
+UnorderedElementsAreArray(T.ranges()))
+<< Test;
+  }
+}
+
+TEST(FoldingRanges, Misc) {
+  const char *Tests[] = {
+  // Statement groups.
+  R"cpp(
+int main() {[[
+  [[int X = 5;
+  int Y = 42;
+  bool B = 15;]]
+  if ([[B]]) {[[ ++X; ]]}
+  unsigned U = 9000;
+]]}
+  )cpp",
+  // Enum.
+  R"cpp(
+enum Color {[[
+  Green = 0,
+  YInMn,
+  Orange,
+]]};
+  )cpp",
+  // Argument lists.
+  R"cpp(
+int foo([[char C, bool B]]) { return static_cast(C); }
+
+foo([['z', true]]);
+
+struct Foo {
+  Foo([[int I, unsigned U, bool B=true]]) {}
+};
+
+Foo F = Foo([[/*[[I=]]*/1, /*[[U=]]*/2, /*[[B=]]false]]);
+F = Foo([[1, 2]]);
+  )cpp",
+  // Namespace.
+  R"cpp(
+namespace ns {[[
+int Variable = 42;
+namespace nested {[[
+int NestedVariable = 50;
+]]}
+]]}
+
+namespace a {[[
+namespace b {[[
+namespace c {[[
+
+]]} //[[ namespacee c]]
+]]} //[[ namespacee b]]
+]]} //[[ namespacee a]]
+
+namespace modern::ns::syntax {[[
+]]} //[[ namespace modern::ns::syntax]]
+
+namespace {[[
+]]} //[[ namespace]]
+  )cpp",
+  // Strings.
+  R"cpp(
+std::string String = "[[ShortString]]";
+String = "[[Super Long String]]";
+String = u8"[[Super Long String]]";
+
+String = R"raw([[Super Looong String]])raw";
+
+const char *text =
+  "[[This"
+  "is a multiline"
+  "string]]";
+
+const char *text2 =
+  "[[Here is another \
+string \
+also \
+multilinee]]";
+  )cpp",
+  // Arrays.
+  R"cpp(
+char Array[] = {[[ 'F', 'o', 'o', 'b', 'a', 'r', '\0' ]};
+
+Array = {[[ 'F', 'o', 'o', 'b', 'a', 'r', 'F', 'o', 'o', 'b',
+ 'a', 'r', '\0' ]]};
+
+int Nested[3][4] = {[[{[[0,1,2,3]]}, {[[4,5,6,7]]}, {[[8,9,10,11]]}};
+  )cpp",
+  // Templates.
+  R"cpp(
+template <[[typename T, typename U, typename V, int X, char C, bool B]]>
+class Foo {};
+
+template <[[bool B]]>
+class Foo<[[unsigned, unsigned, unsigned, -42, 'z', B]]> {
+  int 

[PATCH] D83906: [CodeGen] Emit a call instruction instead of an invoke if the called llvm function is marked nounwind

2020-07-15 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed6b578040a8: [CodeGen] Emit a call instruction instead of 
an invoke if the called llvm… (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83906

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/debug-info-class.cpp
  clang/test/CodeGenObjCXX/arc-list-init-destruct.mm
  clang/test/CodeGenObjCXX/os_log.mm
  clang/test/OpenMP/atomic_codegen.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_num_threads_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/sections_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp

Index: clang/test/OpenMP/taskgroup_codegen.cpp
===
--- clang/test/OpenMP/taskgroup_codegen.cpp
+++ clang/test/OpenMP/taskgroup_codegen.cpp
@@ -16,7 +16,7 @@
 
 // CHECK:   define {{.*}}void [[FOO:@.+]]()
 
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 // CHECK-LABEL: @main
 // TERM_DEBUG-LABEL: @main
Index: clang/test/OpenMP/single_codegen.cpp
===
--- clang/test/OpenMP/single_codegen.cpp
+++ clang/test/OpenMP/single_codegen.cpp
@@ -42,7 +42,7 @@
 TestClass tc2[2];
 #pragma omp threadprivate(tc, tc2)
 
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 struct SS {
   int a;
Index: clang/test/OpenMP/simd_codegen.cpp
===
--- clang/test/OpenMP/simd_codegen.cpp
+++ clang/test/OpenMP/simd_codegen.cpp
@@ -26,7 +26,7 @@
 // OMP50-DAG: [[LAST_IV:@.+]] = {{.*}}common global i64 0
 // OMP50-DAG: [[LAST_A:@.+]] = {{.*}}common global i32 0
 
-long long get_val() { return 0; }
+long long get_val() { extern void mayThrow(); mayThrow(); return 0; }
 double *g_ptr;
 
 struct S {
@@ -798,7 +798,7 @@
 
 #endif // OMP5
 // TERM_DEBUG-LABEL: bar
-int bar() {return 0;};
+int bar() { extern void mayThrow(); mayThrow(); return 0; };
 
 // TERM_DEBUG-LABEL: parallel_simd
 void parallel_simd(float *a) {
Index: clang/test/OpenMP/sections_codegen.cpp
===
--- clang/test/OpenMP/sections_codegen.cpp
+++ clang/test/OpenMP/sections_codegen.cpp
@@ -12,9 +12,9 @@
 // CHECK-DAG: [[IMPLICIT_BARRIER_SECTIONS_LOC:@.+]] = private unnamed_addr global %{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
 // CHECK-DAG: [[SECTIONS_LOC:@.+]] = private unnamed_addr global %{{.+}} { i32 0, i32 1026, i32 0, i32 0, i8*
 // CHECK-LABEL: foo
-void foo() {};
+void foo() { extern void mayThrow(); mayThrow(); };
 // CHECK-LABEL: bar
-void bar() {};
+void bar() { extern void mayThrow(); mayThrow(); };
 
 template 
 T tmain() {
Index: clang/test/OpenMP/parallel_sections_codegen.cpp
===
--- clang/test/OpenMP/parallel_sections_codegen.cpp
+++ clang/test/OpenMP/parallel_sections_codegen.cpp
@@ -10,9 +10,9 @@
 #ifndef HEADER
 #define HEADER
 // CHECK-LABEL: foo
-void foo() {};
+void foo() { extern void mayThrow(); mayThrow(); };
 // CHECK-LABEL: bar
-void bar() {};
+void bar() { extern void mayThrow(); mayThrow(); };
 
 template 
 T tmain() {
Index: clang/test/OpenMP/parallel_num_threads_codegen.cpp
===
--- clang/test/OpenMP/parallel_num_threads_codegen.cpp
+++ clang/test/OpenMP/parallel_num_threads_codegen.cpp
@@ -22,7 +22,7 @@
 struct S {
   intptr_t a, b, c;
   S(intptr_t a) : a(a) {}
-  operator char() { return a; }
+  operator char() { extern void mayThrow(); mayThrow(); return a; }
   ~S() {}
 };
 
Index: clang/test/OpenMP/parallel_master_codegen.cpp
===
--- clang/test/OpenMP/parallel_master_codegen.cpp
+++ clang/test/OpenMP/parallel_master_codegen.cpp
@@ -18,7 +18,7 @@
 // CK1-DAG: [[DEF_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
 
 // CK1-LABEL: foo
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 void parallel_master() {
 #pragma omp parallel master
Index: clang/test/OpenMP/parallel_for_simd_codegen.cpp
===
--- 

[clang] ed6b578 - [CodeGen] Emit a call instruction instead of an invoke if the called

2020-07-15 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-07-15T14:47:45-07:00
New Revision: ed6b578040a85977026c93bf4188f996148f3218

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

LOG: [CodeGen] Emit a call instruction instead of an invoke if the called
llvm function is marked nounwind

This fixes cases where an invoke is emitted, despite the called llvm
function being marked nounwind, because ConstructAttributeList failed to
add the attribute to the attribute list. llvm optimization passes turn
invokes into calls and optimize away the exception handling code, but
it's better to avoid emitting the code in the front-end if the called
function is known not to raise an exception.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGenCXX/debug-info-class.cpp
clang/test/CodeGenObjCXX/arc-list-init-destruct.mm
clang/test/CodeGenObjCXX/os_log.mm
clang/test/OpenMP/atomic_codegen.cpp
clang/test/OpenMP/critical_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/for_codegen.cpp
clang/test/OpenMP/for_simd_codegen.cpp
clang/test/OpenMP/master_codegen.cpp
clang/test/OpenMP/parallel_for_codegen.cpp
clang/test/OpenMP/parallel_for_simd_codegen.cpp
clang/test/OpenMP/parallel_master_codegen.cpp
clang/test/OpenMP/parallel_num_threads_codegen.cpp
clang/test/OpenMP/parallel_sections_codegen.cpp
clang/test/OpenMP/sections_codegen.cpp
clang/test/OpenMP/simd_codegen.cpp
clang/test/OpenMP/single_codegen.cpp
clang/test/OpenMP/taskgroup_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index e8235c775d8f..3f27e1bb8955 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4841,6 +4841,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   } else {
 // Otherwise, nounwind call sites will never throw.
 CannotThrow = Attrs.hasFnAttribute(llvm::Attribute::NoUnwind);
+
+if (auto *FPtr = dyn_cast(CalleePtr))
+  if (FPtr->hasFnAttribute(llvm::Attribute::NoUnwind))
+CannotThrow = true;
   }
 
   // If we made a temporary, be sure to clean up after ourselves. Note that we

diff  --git a/clang/test/CodeGenCXX/debug-info-class.cpp 
b/clang/test/CodeGenCXX/debug-info-class.cpp
index b3e79c37923d..94d5a0f1f082 100644
--- a/clang/test/CodeGenCXX/debug-info-class.cpp
+++ b/clang/test/CodeGenCXX/debug-info-class.cpp
@@ -13,7 +13,7 @@ class B {
   virtual ~B();
 };
 
-B::~B() {
+B::~B() { extern void mayThrow(); mayThrow();
 }
 
 struct C {

diff  --git a/clang/test/CodeGenObjCXX/arc-list-init-destruct.mm 
b/clang/test/CodeGenObjCXX/arc-list-init-destruct.mm
index 09a66458c260..513af64d5203 100644
--- a/clang/test/CodeGenObjCXX/arc-list-init-destruct.mm
+++ b/clang/test/CodeGenObjCXX/arc-list-init-destruct.mm
@@ -16,6 +16,8 @@ @interface Class0;
 };
 
 bool getBool() {
+  extern void mayThrow();
+  mayThrow();
   return false;
 }
 

diff  --git a/clang/test/CodeGenObjCXX/os_log.mm 
b/clang/test/CodeGenObjCXX/os_log.mm
index b6e0bc25ca80..c9efe329b587 100644
--- a/clang/test/CodeGenObjCXX/os_log.mm
+++ b/clang/test/CodeGenObjCXX/os_log.mm
@@ -6,13 +6,14 @@
   void release(int *lock);
 
   // CHECK-LABEL: define {{.*}} @_ZN13no_eh_cleanup3logERiPcS1_(
+  // CHECK: call void @__os_log_helper_1_2_2_4_0_8_34(
+
   void log(int , char *data, char *buf) {
   int lock __attribute__((cleanup(release)));
   __builtin_os_log_format(buf, "%d %{public}s", i, data);
   }
 
-  // An `invoke` of a `nounwind` callee is simplified to a direct
-  // call by an optimization in llvm. Just check that we emit `nounwind`.
+  // Check that the os_log_helper is marked `nounwind`.
   // CHECK: define {{.*}} @__os_log_helper_1_2_2_4_0_8_34({{.*}} 
[[NUW:#[0-9]+]]
 }
 

diff  --git a/clang/test/OpenMP/atomic_codegen.cpp 
b/clang/test/OpenMP/atomic_codegen.cpp
index 4377213e6d82..47371fe912aa 100644
--- a/clang/test/OpenMP/atomic_codegen.cpp
+++ b/clang/test/OpenMP/atomic_codegen.cpp
@@ -82,7 +82,7 @@ void parallel_atomic_ewc() {
 }
 }
 
-int () { return a; }
+int () { extern void mayThrow(); mayThrow(); return a; }
 
 // TERM_DEBUG-LABEL: parallel_atomic
 void parallel_atomic() {

diff  --git a/clang/test/OpenMP/critical_codegen.cpp 
b/clang/test/OpenMP/critical_codegen.cpp
index f49c9cc9c21a..4b2566bbf364 100644
--- a/clang/test/OpenMP/critical_codegen.cpp
+++ b/clang/test/OpenMP/critical_codegen.cpp
@@ -22,7 +22,7 @@
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 // ALL-LABEL: @main
 // TERM_DEBUG-LABEL: @main


[PATCH] D83906: [CodeGen] Emit a call instruction instead of an invoke if the called llvm function is marked nounwind

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

Update comment in test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83906

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/debug-info-class.cpp
  clang/test/CodeGenObjCXX/arc-list-init-destruct.mm
  clang/test/CodeGenObjCXX/os_log.mm
  clang/test/OpenMP/atomic_codegen.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_num_threads_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/sections_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp

Index: clang/test/OpenMP/taskgroup_codegen.cpp
===
--- clang/test/OpenMP/taskgroup_codegen.cpp
+++ clang/test/OpenMP/taskgroup_codegen.cpp
@@ -16,7 +16,7 @@
 
 // CHECK:   define {{.*}}void [[FOO:@.+]]()
 
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 // CHECK-LABEL: @main
 // TERM_DEBUG-LABEL: @main
Index: clang/test/OpenMP/single_codegen.cpp
===
--- clang/test/OpenMP/single_codegen.cpp
+++ clang/test/OpenMP/single_codegen.cpp
@@ -42,7 +42,7 @@
 TestClass tc2[2];
 #pragma omp threadprivate(tc, tc2)
 
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 struct SS {
   int a;
Index: clang/test/OpenMP/simd_codegen.cpp
===
--- clang/test/OpenMP/simd_codegen.cpp
+++ clang/test/OpenMP/simd_codegen.cpp
@@ -26,7 +26,7 @@
 // OMP50-DAG: [[LAST_IV:@.+]] = {{.*}}common global i64 0
 // OMP50-DAG: [[LAST_A:@.+]] = {{.*}}common global i32 0
 
-long long get_val() { return 0; }
+long long get_val() { extern void mayThrow(); mayThrow(); return 0; }
 double *g_ptr;
 
 struct S {
@@ -798,7 +798,7 @@
 
 #endif // OMP5
 // TERM_DEBUG-LABEL: bar
-int bar() {return 0;};
+int bar() { extern void mayThrow(); mayThrow(); return 0; };
 
 // TERM_DEBUG-LABEL: parallel_simd
 void parallel_simd(float *a) {
Index: clang/test/OpenMP/sections_codegen.cpp
===
--- clang/test/OpenMP/sections_codegen.cpp
+++ clang/test/OpenMP/sections_codegen.cpp
@@ -12,9 +12,9 @@
 // CHECK-DAG: [[IMPLICIT_BARRIER_SECTIONS_LOC:@.+]] = private unnamed_addr global %{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
 // CHECK-DAG: [[SECTIONS_LOC:@.+]] = private unnamed_addr global %{{.+}} { i32 0, i32 1026, i32 0, i32 0, i8*
 // CHECK-LABEL: foo
-void foo() {};
+void foo() { extern void mayThrow(); mayThrow(); };
 // CHECK-LABEL: bar
-void bar() {};
+void bar() { extern void mayThrow(); mayThrow(); };
 
 template 
 T tmain() {
Index: clang/test/OpenMP/parallel_sections_codegen.cpp
===
--- clang/test/OpenMP/parallel_sections_codegen.cpp
+++ clang/test/OpenMP/parallel_sections_codegen.cpp
@@ -10,9 +10,9 @@
 #ifndef HEADER
 #define HEADER
 // CHECK-LABEL: foo
-void foo() {};
+void foo() { extern void mayThrow(); mayThrow(); };
 // CHECK-LABEL: bar
-void bar() {};
+void bar() { extern void mayThrow(); mayThrow(); };
 
 template 
 T tmain() {
Index: clang/test/OpenMP/parallel_num_threads_codegen.cpp
===
--- clang/test/OpenMP/parallel_num_threads_codegen.cpp
+++ clang/test/OpenMP/parallel_num_threads_codegen.cpp
@@ -22,7 +22,7 @@
 struct S {
   intptr_t a, b, c;
   S(intptr_t a) : a(a) {}
-  operator char() { return a; }
+  operator char() { extern void mayThrow(); mayThrow(); return a; }
   ~S() {}
 };
 
Index: clang/test/OpenMP/parallel_master_codegen.cpp
===
--- clang/test/OpenMP/parallel_master_codegen.cpp
+++ clang/test/OpenMP/parallel_master_codegen.cpp
@@ -18,7 +18,7 @@
 // CK1-DAG: [[DEF_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
 
 // CK1-LABEL: foo
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 void parallel_master() {
 #pragma omp parallel master
Index: clang/test/OpenMP/parallel_for_simd_codegen.cpp
===
--- clang/test/OpenMP/parallel_for_simd_codegen.cpp
+++ 

[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-15 Thread Andy Soffer via Phabricator via cfe-commits
asoffer added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:93
+  // Not all transformations will want or need to attach metadata and therefore
+  // sholud not be requierd to do so.
   AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {

ymandel wrote:
> nit: typos
> 
> The same applies to `Note`. Since this is a nullable type, can we ask that 
> the user check `Metadata != nullptr`?
I don't think I'm understanding the question. Where/when would users check for 
Metadata != nullptr?

Currently in this diff, any library construction of the Metadata field will be 
non-null. Users would have to explicitly pass null in if they wanted it to be 
null which would pretty quickly break when the generator is called, so this 
seems like a not-too-big foot-gun? Does that answer the question?



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:270
 
-// TODO(asoffer): If this returns an llvm::Expected, should we unwrap?
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the

ymandel wrote:
> I think I understand now. Is the idea that we'll only get one implicit 
> construction from the compiler, so we want to use that "free" conversion on 
> the `llvm::Any`, rather than on the `llvm::Expected`, which would force the 
> user to explicitly construct the `llvm::Any`?
> 
> I think we should address this with separate functions (or overloads at 
> least), one for the case of never-fail metadata constructors and one for 
> failable constructors. That said, any computation that takes the matchresult 
> is prone to failure because of unbound nodes.  so, I would expect it to be 
> common for the Callable to be failable.  however, if you feel that's the 
> uncommon case, let's optimize towards the common case, like you've done.
> 
> With all that said, I agree that if the Callable returns an `Expected` we 
> should rewrap correctly, not bury in `Any`.
I think you're asking about why the generic callable instead of a std::function 
or LLVM equivalent type. It's not about implicit conversions but rather about 
deduction. Type deduction allows only for conversions on qualifiers (T to const 
T&, for example). So if we specified a std::function, it would either require:
1. The cannot pass lambdas without explicitly wrapping them in a std::function 
construction so that the return type can be deduced.
2. We have an explicit std::function, but then the 
user-provided callable would have to return an llvm::Any explicitly.
Neither of these seem ideal.

The Expected-unwrapping requires some ugly SFINAE, so I'd prefer to punt on 
this until we feel the need to have Expected's in metadata.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820



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


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-15 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 278315.
asoffer marked 2 inline comments as done.
asoffer added a comment.

Typo fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820

Files:
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -440,6 +440,12 @@
 }
 
 TEST_F(TransformerTest, WithMetadata) {
+  auto makeMetadata = [](const MatchFinder::MatchResult ) -> llvm::Any {
+int N =
+R.Nodes.getNodeAs("int")->getValue().getLimitedValue();
+return N;
+  };
+
   std::string Input = R"cc(
 int f() {
   int x = 5;
@@ -448,8 +454,11 @@
   )cc";
 
   Transformer T(
-  makeRule(declStmt().bind("decl"),
-   withMetadata(remove(statement(std::string("decl"))), 17)),
+  makeRule(
+  declStmt(containsDeclaration(0, varDecl(hasInitializer(
+  integerLiteral().bind("int")
+  .bind("decl"),
+  withMetadata(remove(statement(std::string("decl"))), makeMetadata)),
   consumer());
   T.registerMatchers();
   auto Factory = newFrontendActionFactory();
@@ -459,7 +468,7 @@
   ASSERT_EQ(Changes.size(), 1u);
   const llvm::Any  = Changes[0].getMetadata();
   ASSERT_TRUE(llvm::any_isa(Metadata));
-  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+  EXPECT_THAT(llvm::any_cast(Metadata), 5);
 }
 
 TEST_F(TransformerTest, MultiChange) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -44,10 +44,13 @@
 auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
+auto Metadata = E.Metadata(Result);
+if (!Metadata)
+  return Metadata.takeError();
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-T.Metadata = E.Metadata;
+T.Metadata = std::move(*Metadata);
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -47,6 +47,8 @@
 
 using TextGenerator = std::shared_ptr>;
 
+using AnyGenerator = MatchConsumer;
+
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
 // node, a replacement and, optionally, an explanation for the edit.
@@ -87,7 +89,11 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
-  llvm::Any Metadata;
+  // Not all transformations will want or need to attach metadata and therefore
+  // should not be requierd to do so.
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
+return llvm::Any();
+  };
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -261,9 +267,27 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
-  edit.Metadata = std::move(Metadata);
-  return edit;
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. If
+// it accepted a `std::function`, lambdas or other callable types
+// would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
+template 
+inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
+  Edit.Metadata =
+  [Gen = std::move(Metadata)](
+  const ast_matchers::MatchFinder::MatchResult ) -> llvm::Any {
+return Gen(R);
+  };
+
+  return Edit;
 }
 
 /// The following three functions are a low-level part of the RewriteRule
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83909: [OPENMP] Fix PR46730: Fix compiler crash on taskloop over constructible loop counters.

2020-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

If the variable is constrcutible, its copy is created by calling a
constructor. Such variables are duplicated and thus, must be captured.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83909

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


Index: clang/test/OpenMP/taskloop_codegen.cpp
===
--- clang/test/OpenMP/taskloop_codegen.cpp
+++ clang/test/OpenMP/taskloop_codegen.cpp
@@ -229,4 +229,20 @@
 // CHECK: br label %
 // CHECK: ret i32 0
 
+class St {
+public:
+  operator int();
+  St +=(int);
+};
+
+// CHECK-LABEL: taskloop_with_class
+void taskloop_with_class() {
+  St s1;
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* 
@{{.+}}, i32 [[GTID:%.+]], i32 1, i64 88, i64 8, i32 (i32, i8*)* bitcast (i32 
(i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], 
i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 
0, i8* bitcast (void ([[TD_TYPE]]*, [[TD_TYPE]]*, i32)* @{{.+}} to i8*))
+#pragma omp taskloop
+  for (St s = St(); s < s1; s += 1) {
+  }
+}
+
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2244,7 +2244,11 @@
   [](OpenMPDirectiveKind K) { return isOpenMPTaskingDirective(K); },
   Level)) {
 bool IsTriviallyCopyable =
-D->getType().getNonReferenceType().isTriviallyCopyableType(Context);
+D->getType().getNonReferenceType().isTriviallyCopyableType(Context) &&
+!D->getType()
+ .getNonReferenceType()
+ .getCanonicalType()
+ ->getAsCXXRecordDecl();
 OpenMPDirectiveKind DKind = DSAStack->getDirective(Level);
 SmallVector CaptureRegions;
 getOpenMPCaptureRegions(CaptureRegions, DKind);


Index: clang/test/OpenMP/taskloop_codegen.cpp
===
--- clang/test/OpenMP/taskloop_codegen.cpp
+++ clang/test/OpenMP/taskloop_codegen.cpp
@@ -229,4 +229,20 @@
 // CHECK: br label %
 // CHECK: ret i32 0
 
+class St {
+public:
+  operator int();
+  St +=(int);
+};
+
+// CHECK-LABEL: taskloop_with_class
+void taskloop_with_class() {
+  St s1;
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID:%.+]], i32 1, i64 88, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* bitcast (void ([[TD_TYPE]]*, [[TD_TYPE]]*, i32)* @{{.+}} to i8*))
+#pragma omp taskloop
+  for (St s = St(); s < s1; s += 1) {
+  }
+}
+
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2244,7 +2244,11 @@
   [](OpenMPDirectiveKind K) { return isOpenMPTaskingDirective(K); },
   Level)) {
 bool IsTriviallyCopyable =
-D->getType().getNonReferenceType().isTriviallyCopyableType(Context);
+D->getType().getNonReferenceType().isTriviallyCopyableType(Context) &&
+!D->getType()
+ .getNonReferenceType()
+ .getCanonicalType()
+ ->getAsCXXRecordDecl();
 OpenMPDirectiveKind DKind = DSAStack->getDirective(Level);
 SmallVector CaptureRegions;
 getOpenMPCaptureRegions(CaptureRegions, DKind);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-15 Thread David Van Cleve via Phabricator via cfe-commits
davidvancleve added a comment.

Thanks for the quick response! Nope, no compile_commands.json files, and they 
didn't previously contain .clangd files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-15 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked an inline comment as done.
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:614
+
+TEST_F(SymbolCollectorTest, ObjCClassExtensions) {
+  Annotations Header(R"(

Here's the ClassExtension that I was talking about.

Ideally we can map each

`Cat ()` --> `@implementation Cat` like I did in XRefs

But as you said the `Cat ()` could be in a different file and I think it has a 
different USR.

See also 
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html#//apple_ref/doc/uid/TP40011210-CH6-SW3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[PATCH] D83906: [CodeGen] Emit a call instruction instead of an invoke if the called llvm function is marked nounwind

2020-07-15 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Looks good to me.




Comment at: clang/test/CodeGenObjCXX/os_log.mm:16
 
   // An `invoke` of a `nounwind` callee is simplified to a direct
   // call by an optimization in llvm. Just check that we emit `nounwind`.

This comment can simply read "Check that the os_log_helper is marked 
`nounwind`."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83906



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-15 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 278310.
dgoldman marked an inline comment as done.
dgoldman added a comment.

SymbolCollector fixes + more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -674,7 +674,57 @@
   enum class E { [[A]], B };
   E e = E::A^;
 };
-  )cpp"};
+  )cpp",
+
+  R"objc(
+@protocol Dog;
+@protocol $decl[[Dog]]
+- (void)bark;
+@end
+id getDoggo() {
+  return 0;
+}
+  )objc",
+
+  R"objc(
+@interface Cat
+@end
+@implementation Cat
+@end
+@interface $decl[[Cat]] (Exte^nsion)
+- (void)meow;
+@end
+@implementation $def[[Cat]] (Extension)
+- (void)meow {}
+@end
+  )objc",
+
+  R"objc(
+@class $decl[[Foo]];
+Fo^o * getFoo() {
+  return 0;
+}
+  )objc",
+
+  R"objc(
+@class Foo;
+@interface $decl[[Foo]]
+@end
+Fo^o * getFoo() {
+  return 0;
+}
+  )objc",
+
+  R"objc(
+@class Foo;
+@interface $decl[[Foo]]
+@end
+@implementation $def[[Foo]]
+@end
+Fo^o * getFoo() {
+  return 0;
+}
+  )objc"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 llvm::Optional WantDecl;
@@ -692,6 +742,7 @@
 // FIXME: Auto-completion in a template requires disabling delayed template
 // parsing.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+TU.ExtraArgs.push_back("-xobjective-c++");
 
 auto AST = TU.build();
 auto Results = locateSymbolAt(AST, T.point());
@@ -709,6 +760,131 @@
   }
 }
 
+TEST(LocateSymbol, AllMulti) {
+  // Ranges in tests:
+  //   $declN is the declaration location
+  //   $defN is the definition location (if absent, symbol has no definition)
+  //
+  // NOTE:
+  //   N starts at 0.
+  //   Due to limitations in clang's Annotations, you can't annotate the same
+  //   text with multiple ranges, e.g. `$def0$def1[[Foo]]` is invalid.
+  struct ExpectedRanges {
+Range WantDecl;
+llvm::Optional WantDef;
+  };
+  const char *Tests[] = {
+  R"objc(
+  @interface $decl0[[Cat]]
+  @end
+  @implementation $def0[[Cat]]
+  @end
+  @interface $decl1[[Ca^t]] (Extension)
+  - (void)meow;
+  @end
+  @implementation $def1[[Cat]] (Extension)
+  - (void)meow {}
+  @end
+)objc",
+
+  R"objc(
+  @interface $decl0[[Cat]]
+  @end
+  @implementation $def0[[Cat]]
+  @end
+  @interface $decl1[[Cat]] (Extension)
+  - (void)meow;
+  @end
+  @implementation $def1[[Ca^t]] (Extension)
+  - (void)meow {}
+  @end
+)objc",
+  };
+  for (const char *Test : Tests) {
+Annotations T(Test);
+std::vector Ranges;
+for (int Idx = 0; true; Idx++) {
+  bool HasDecl = !T.ranges("decl" + std::to_string(Idx)).empty();
+  bool HasDef = !T.ranges("def" + std::to_string(Idx)).empty();
+  if (!HasDecl && !HasDef)
+break;
+  ExpectedRanges Range;
+  if (HasDecl)
+Range.WantDecl = T.range("decl" + std::to_string(Idx));
+  if (HasDef)
+Range.WantDef = T.range("def" + std::to_string(Idx));
+  Ranges.push_back(Range);
+}
+
+TestTU TU;
+TU.Code = std::string(T.code());
+TU.ExtraArgs.push_back("-xobjective-c++");
+
+auto AST = TU.build();
+auto Results = locateSymbolAt(AST, T.point());
+
+ASSERT_THAT(Results, ::testing::SizeIs(Ranges.size())) << Test;
+for (size_t Idx = 0; Idx < Ranges.size(); Idx++) {
+  EXPECT_EQ(Results[Idx].PreferredDeclaration.range, Ranges[Idx].WantDecl)
+  << "($decl" << Idx << ")" << Test;
+  llvm::Optional GotDef;
+  if (Results[Idx].Definition)
+GotDef = Results[Idx].Definition->range;
+  EXPECT_EQ(GotDef, Ranges[Idx].WantDef) << "($def" << Idx << ")" << Test;
+}
+  }
+}
+
+TEST(LocateSymbol, MultipleDeclsWithSameDefinition) {
+  // Ranges in tests:
+  //   $def is the shared definition location
+  //   $declN is one of the declaration locations
+  //
+  // NOTE:
+  //   N starts at 0.
+  const char *Tests[] = {
+  R"objc(
+  @interface $decl0[[Cat]]
+  @end
+  @interface $decl1[[Ca^t]] ()
+  - (void)meow;
+  @end
+  @implementation 

[PATCH] D83906: [CodeGen] Emit a call instruction instead of an invoke if the called llvm function is marked nounwind

2020-07-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In case it wasn't clear, the calls to `mayThrow()` in the test cases are needed 
to prevent `TryMarkNoThrow` from annotating the functions with nounwind, which 
would cause a lot of churn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83906



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


[PATCH] D83242: [clang][BPF] support expr with typedef/record type for FIELD_EXISTENCE reloc

2020-07-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 278305.
yonghong-song added a comment.

fix clang-format warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/BPF.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
  clang/test/Sema/builtins-bpf.c

Index: clang/test/Sema/builtins-bpf.c
===
--- clang/test/Sema/builtins-bpf.c
+++ clang/test/Sema/builtins-bpf.c
@@ -1,14 +1,27 @@
 // RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
 
-struct s { int a; int b[4]; int c:1; };
-union u { int a; int b[4]; int c:1; };
+struct s {
+  int a;
+  int b[4];
+  int c:1;
+};
+union u {
+  int a;
+  int b[4];
+  int c:1;
+};
+typedef struct {
+  int a;
+  int b;
+} __t;
+typedef int (*__f)(void);
 
 unsigned invalid1(const int *arg) {
-  return __builtin_preserve_field_info(arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 not a field access}}
+  return __builtin_preserve_field_info(arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
 }
 
 unsigned invalid2(const int *arg) {
-  return __builtin_preserve_field_info(*arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 not a field access}}
+  return __builtin_preserve_field_info(*arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
 }
 
 void *invalid3(struct s *arg) {
@@ -46,3 +59,25 @@
 unsigned invalid11(struct s *arg, int info_kind) {
   return __builtin_preserve_field_info(arg->a, info_kind); // expected-error {{__builtin_preserve_field_info argument 2 not a constant}}
 }
+
+unsigned valid12() {
+  const struct s t = {};
+  return __builtin_preserve_field_info(t, 2);
+}
+
+unsigned valid13() {
+  return __builtin_preserve_field_info(*(struct s *)0, 2);
+}
+
+unsigned valid14() {
+  __t t = {};
+  return __builtin_preserve_field_info(t, 2);
+}
+
+unsigned valid15() {
+  return __builtin_preserve_field_info((const __f)0, 2);
+}
+
+unsigned invalid16(struct s *arg) {
+  return __builtin_preserve_field_info(arg->a + 2, 2); // expected-error {{__builtin_preserve_field_info argument 1 invalid}}
+}
Index: clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
@@ -0,0 +1,33 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x, y) (__builtin_preserve_field_info((x), (y)))
+
+struct s {
+  char a;
+};
+typedef struct {
+  char a;
+} __s1;
+
+typedef int (*__func)(void);
+
+unsigned unit1() {
+  const __s1 v = {};
+  return _(v, 2) + _(*(struct s *)0, 2);
+}
+
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0s_struct.__s1s(%struct.__s1* %{{[0-9a-z]+}}, i64 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[CONST_S1:[0-9]+]]
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0s_struct.ss(%struct.s* null, i64 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S:[0-9]+]]
+
+unsigned unit2() {
+  __func f;
+  return _((__func)0, 2) + _(f, 2);
+}
+
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0f_i32f(i32 ()* null, i64 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[TYPEDEF:[0-9]+]]
+// CHECK: call i32 @llvm.bpf.preserve.field.info.p0p0f_i32f(i32 ()** %{{[0-9a-z]+}}, i64 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[TYPEDEF:[0-9]+]]
+
+// CHECK: ![[STRUCT_S]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s"
+// CHECK: ![[TYPEDEF]] = !DIDerivedType(tag: DW_TAG_typedef, name: "__func"
+// CHECK: ![[CONST_S1]] = !DIDerivedType(tag: DW_TAG_const_type
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2563,7 +2563,7 @@
CallExpr *TheCall) {
   assert((BuiltinID == BPF::BI__builtin_preserve_field_info ||
   BuiltinID == BPF::BI__builtin_btf_type_id) &&
- "unexpected ARM builtin");
+ "unexpected BPF builtin");
 
   if (checkArgCount(*this, TheCall, 2))
 return true;
@@ -2583,20 +2583,6 @@
 return false;
   }
 
-  // The first argument needs to be a record field access.
-  // If it is an array element access, we delay decision
-  // to BPF backend to check whether the access is a
-  // field access or not.
-  Arg = TheCall->getArg(0);
-  if (Arg->getType()->getAsPlaceholderType() ||
-  (Arg->IgnoreParens()->getObjectKind() != OK_BitField &&
-   !dyn_cast(Arg->IgnoreParens()) &&
-   !dyn_cast(Arg->IgnoreParens( {

[PATCH] D83906: [CodeGen] Emit a call instruction instead of an invoke if the called llvm function is marked nounwind

2020-07-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: vsk, rjmccall, ABataev.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous.

This fixes cases where an invoke is emitted, despite the called llvm function 
being marked nounwind, because `CodeGenModule::ConstructAttributeList` failed 
to add the attribute to the attribute list. llvm optimization passes turn 
invokes into calls and optimize away the exception handling code, but it's 
better to avoid emitting the code in the front-end if the called function is 
known not to raise an exception.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83906

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/debug-info-class.cpp
  clang/test/CodeGenObjCXX/arc-list-init-destruct.mm
  clang/test/CodeGenObjCXX/os_log.mm
  clang/test/OpenMP/atomic_codegen.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_num_threads_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/sections_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp

Index: clang/test/OpenMP/taskgroup_codegen.cpp
===
--- clang/test/OpenMP/taskgroup_codegen.cpp
+++ clang/test/OpenMP/taskgroup_codegen.cpp
@@ -16,7 +16,7 @@
 
 // CHECK:   define {{.*}}void [[FOO:@.+]]()
 
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 // CHECK-LABEL: @main
 // TERM_DEBUG-LABEL: @main
Index: clang/test/OpenMP/single_codegen.cpp
===
--- clang/test/OpenMP/single_codegen.cpp
+++ clang/test/OpenMP/single_codegen.cpp
@@ -42,7 +42,7 @@
 TestClass tc2[2];
 #pragma omp threadprivate(tc, tc2)
 
-void foo() {}
+void foo() { extern void mayThrow(); mayThrow(); }
 
 struct SS {
   int a;
Index: clang/test/OpenMP/simd_codegen.cpp
===
--- clang/test/OpenMP/simd_codegen.cpp
+++ clang/test/OpenMP/simd_codegen.cpp
@@ -26,7 +26,7 @@
 // OMP50-DAG: [[LAST_IV:@.+]] = {{.*}}common global i64 0
 // OMP50-DAG: [[LAST_A:@.+]] = {{.*}}common global i32 0
 
-long long get_val() { return 0; }
+long long get_val() { extern void mayThrow(); mayThrow(); return 0; }
 double *g_ptr;
 
 struct S {
@@ -798,7 +798,7 @@
 
 #endif // OMP5
 // TERM_DEBUG-LABEL: bar
-int bar() {return 0;};
+int bar() { extern void mayThrow(); mayThrow(); return 0; };
 
 // TERM_DEBUG-LABEL: parallel_simd
 void parallel_simd(float *a) {
Index: clang/test/OpenMP/sections_codegen.cpp
===
--- clang/test/OpenMP/sections_codegen.cpp
+++ clang/test/OpenMP/sections_codegen.cpp
@@ -12,9 +12,9 @@
 // CHECK-DAG: [[IMPLICIT_BARRIER_SECTIONS_LOC:@.+]] = private unnamed_addr global %{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
 // CHECK-DAG: [[SECTIONS_LOC:@.+]] = private unnamed_addr global %{{.+}} { i32 0, i32 1026, i32 0, i32 0, i8*
 // CHECK-LABEL: foo
-void foo() {};
+void foo() { extern void mayThrow(); mayThrow(); };
 // CHECK-LABEL: bar
-void bar() {};
+void bar() { extern void mayThrow(); mayThrow(); };
 
 template 
 T tmain() {
Index: clang/test/OpenMP/parallel_sections_codegen.cpp
===
--- clang/test/OpenMP/parallel_sections_codegen.cpp
+++ clang/test/OpenMP/parallel_sections_codegen.cpp
@@ -10,9 +10,9 @@
 #ifndef HEADER
 #define HEADER
 // CHECK-LABEL: foo
-void foo() {};
+void foo() { extern void mayThrow(); mayThrow(); };
 // CHECK-LABEL: bar
-void bar() {};
+void bar() { extern void mayThrow(); mayThrow(); };
 
 template 
 T tmain() {
Index: clang/test/OpenMP/parallel_num_threads_codegen.cpp
===
--- clang/test/OpenMP/parallel_num_threads_codegen.cpp
+++ clang/test/OpenMP/parallel_num_threads_codegen.cpp
@@ -22,7 +22,7 @@
 struct S {
   intptr_t a, b, c;
   S(intptr_t a) : a(a) {}
-  operator char() { return a; }
+  operator char() { extern void mayThrow(); mayThrow(); return a; }
   ~S() {}
 };
 
Index: clang/test/OpenMP/parallel_master_codegen.cpp
===
--- clang/test/OpenMP/parallel_master_codegen.cpp
+++ clang/test/OpenMP/parallel_master_codegen.cpp
@@ -18,7 +18,7 @@
 // CK1-DAG: [[DEF_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* 

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

I tried to build clang with this patch and I get errors like:

  CGOpenMPRuntime.cpp:9463:38: error: ‘OMPRTL___tgt_target_teams_nowait_mapper’ 
was not declared in this scope
  ? OMPRTL___tgt_target_teams_nowait_mapper

Where are these `OMPRTL___tgt_` symbols defined?


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

https://reviews.llvm.org/D67833



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


[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-07-15 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

In D82118#2154280 , @vsapsai wrote:

> Didn't get into details but overall GenModuleActionWrapper approach looks 
> pretty complicated. Haven't tried to accomplish the same myself, so cannot 
> say if such complexity is warranted or not.


Yes the approach is complicated. But one thing to note is that the 
`GenModuleActionWrapper`-related facilities are upstreamed from 
apple/llvm-project. I adopted this approach just because it was available. 
Haven't explored other ways, but yes there might be a simpler approach.

> What happens with fixits in modules when you don't have 
> GenModuleActionWrapper?

If the fixit action is not forwarded to the new compiler instance, it will be 
handled by the 'outer' compiler instance, which has a different source manager 
that does not see the module files, so the source location cannot be correctly 
interpreted. From my experiments, the fixit hint is trying to write into the 
`` file buffer in this test case, when I don't have the action 
forwarded using `GenModuleActionWrapper`. In this case the fixit rewriter 
quietly fails because `` cannot be rewritten, but since this is not 
caught I think there might be cases where the wrong file ends up getting 
updated.

> How does it work with modules disabled? Also looks like there are no tests 
> for incomplete umbrella warning when modules are disabled.

Haven't tested this, will give a try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-15 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked 7 inline comments as done.
dgoldman added a comment.

In D83501#2153605 , @sammccall wrote:

> In D83501#2148671 , @dgoldman wrote:
>
> > I implemented goto-definition from Foo() --> Foo impl in Xrefs, on the 
> > symbolcollector side I don't think there's anything to do?
>
>
> This can't be done purely in xrefs as the AST may not be available.
>
> A.m: `@class Foo; ^Foo x;` <-- go-to-definition at ^
>  B.m: `@interface Foo...@end @implementation Foo...@end`
>
> The index needs to know that for the USR associated with the @class (found by 
> targetDecl), the canonical decl is the @interface in B and the definition is 
> the @implementation in B.
>  So SymbolCollector needs to see it as a definition. **The tests seem to show 
> it does already**, but it's not obvious why from the code. Do you know? Maybe 
> it's the fact that they share a USR and thus a symbol ID. This is worth 
> making explicit somewhere.


Think we're talking about different things. See `ObjCClassExtensions` in 
SymbolCollectorTests which I added, the idea is that the `Cat ()` can link to 
the implementation like I added to XRefs, but I'm not sure how this should be 
represented. As for @class -> @interface/@implementation those should have the 
same USR, yes.




Comment at: clang-tools-extra/clangd/XRefs.cpp:276
getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {

sammccall wrote:
> dgoldman wrote:
> > sammccall wrote:
> > > dgoldman wrote:
> > > > sammccall wrote:
> > > > > dgoldman wrote:
> > > > > > sammccall wrote:
> > > > > > > dgoldman wrote:
> > > > > > > > Think it would make sense to special case ObjCInterfaceDecl 
> > > > > > > > here to get at both the interface definition + implementation 
> > > > > > > > if available?
> > > > > > > Rather than returning both results, I think it's more consistent 
> > > > > > > to return them as a declaration/definition pair.
> > > > > > > 
> > > > > > > (This means special-casing ObjCImplDecl in namedDecl or at least 
> > > > > > > getDeclAsPosition, so you always end up with the 
> > > > > > > ObjCInterfaceDecl instead)
> > > > > > Whoops, meant to comment here but it was lost. I'm not sure what 
> > > > > > you meant here. Should this be done here inside the for loop or in 
> > > > > > getDeclAtPosition?
> > > > > > 
> > > > > > Are you saying that given:
> > > > > > 
> > > > > > ```
> > > > > > @interface Foo // A
> > > > > > @end
> > > > > > @implementation Foo // B
> > > > > > @end
> > > > > > ```
> > > > > > B --> A here
> > > > > > 
> > > > > > and similarly
> > > > > > 
> > > > > > ```
> > > > > > @interface Foo // A
> > > > > > @end
> > > > > > @interface Foo (Ext) // B
> > > > > > @end
> > > > > > @implementation Foo (Ext) // C
> > > > > > @end
> > > > > > ```
> > > > > > B --> A
> > > > > > C --> B (and A? it's unclear how this should map over, e.g. maybe 
> > > > > > Foo loc --> A, Ext --> B)
> > > > > In the first example, selecting either A or B should yield one 
> > > > > LocatedSymbol with {Decl=A, Def=B}. This shouldn't require any 
> > > > > special-casing.
> > > > > 
> > > > > The second example is very similar to template specialization, with 
> > > > > exceptions:
> > > > >  - there's always a Decl/Def pair you may want to navigate between, 
> > > > > whereas in templates there rarely is, so we have ambiguity
> > > > >  - there's no AST like there is for template names and args, just a 
> > > > > bag of tokens
> > > > > 
> > > > > I'd suggest, given `@interface Foo (Ext)`:
> > > > >  - we produce a LocatedSymbol with {Decl=@interface Foo(Ext), 
> > > > > Def=@implementation  Foo(Ext)} - this is the default behavior
> > > > >  - if the cursor is exactly on the token `Foo`, we also produce a 
> > > > > LocatedSymbol with {Decl=@interface Foo, Def=@implementation Foo} - 
> > > > > this is similar to the template special case
> > > > >  - if the cursor is exactly on the token Ext... are categories 
> > > > > explicitly/separately declared anywhere? I guess not. If they are, we 
> > > > > could special case this too.
> > > > > And `@implementation Foo(Ext)` should behave in exactly the same way.
> > > > Trying this out now, two problems:
> > > > 
> > > > - getDeclAtPosition will call findTarget. Due to the changes above we 
> > > > map `ObjCCategoryImplDecl` to its interface. This is OK but then when 
> > > > we check for the loc it's obviously != to the impl's loc. Should I 
> > > > modify this to check the contents of the loc for equality?
> > > > 
> > > > - We call `getDeclAtPosition` only looking for 
> > > > DeclRelation::TemplatePattern | DeclRelation::Alias, but this is 
> > > > actually a DeclRelation::Underlying. If I don't add that we filter out 
> > > > the ObjCCategoryImplDecl. If I add it we get a 

[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D83099#2154185 , @davidvancleve 
wrote:

> Hey, quick question about this change:
>
> I'm seeing .cache directories appear off of subdirectories too, not just my 
> project root:
>
> 1. Untracked files: 31 #»  .cache/ 32 #»  
> content/browser/frame_host/.cache/ 33 #»  content/public/browser/.cache/ 
> 34 #»  content/test/.cache/ 35 #»  net/http/.cache/ 36 #»  
> services/network/.cache/ 37 #»  services/network/trust_tokens/.cache/
>
>   Is this working as intended?


Hmm, maybe not. Do these directories have `compile_commands.json` files? 
(That's what we treat as a "project root", it may be a subproject)
Did they previously have `.clangd` directories created for indexes? (This patch 
shouldn't have changed which directories have indexes placed in them, just the 
names of the index directories).

Sorry about the churn, in any case :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099



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


[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-07-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Didn't get into details but overall GenModuleActionWrapper approach looks 
pretty complicated. Haven't tried to accomplish the same myself, so cannot say 
if such complexity is warranted or not. What happens with fixits in modules 
when you don't have GenModuleActionWrapper? How does it work with modules 
disabled? Also looks like there are no tests for incomplete umbrella warning 
when modules are disabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118



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


[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9566
+MEHandler.generateAllInfo(BasePointers, Pointers, Sizes, MapTypes,
+  CapturedVarSet, /*PresentModifierOnly=*/true);
 

jdenny wrote:
> ABataev wrote:
> > jdenny wrote:
> > > ABataev wrote:
> > > > jdenny wrote:
> > > > > In today's OpenMP/LLVM call, it was pointed out that this issue 
> > > > > represents a general Clang bug for map clauses: map clauses generally 
> > > > > shouldn't be ignored just because their variables aren't referenced 
> > > > > in the construct.
> > > > > 
> > > > > Here, I tried to handle this issue only in the case of a `present` 
> > > > > modifier because I previously didn't consider whether the existing 
> > > > > behavior for other map types was a bug.  My solution here was similar 
> > > > > to what's done for `omp target data`, which doesn't have captures at 
> > > > > all.  Perhaps, this should generalized to other map types.
> > > > > 
> > > > > Another possibility might be to expand what's captured in Sema.
> > > > It must be fixed in a separate patch. We definitely should not modify 
> > > > sema here, just the codegen. Currently, it iterates through all 
> > > > captures in region, also need to iterate through the explicit maps.
> > > Thanks for the response.  I'd be happy to generalize and extract into a 
> > > new patch.
> > > 
> > > It looks like all I need to extract is the changes to `generateAllInfo` 
> > > and `emitTargetCall` except I wouldn't have the `PresentModifierOnly` 
> > > restriction.  Of course, I would need to add tests.  Does all that sound 
> > > about right?  If so, I'll work on it.
> > Yes, something like this. Most probably, you won't need to add new tests, 
> > just modify the existing ones.
> OK, I'm working on this.  One point from the call I'm not confident about:  
> Is this change just for globals or locals too?  That is, which variables in 
> the following examples should have map entries?
> 
> ```
> int x;
> void fn() {
>   int y;
>   #pragma omp target map(x,y)
>   {
> // no references to x and y are lexically contained
>   }
> }
> ```
I think, both. We need to have references in the data environment for all 
explicitly mapped variables.


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

https://reviews.llvm.org/D83061



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread Lingda Li via Phabricator via cfe-commits
lildmh added a comment.

@grokos Could you upstream this patch and the runtime patch neck to neck? 
Upstreaming one of them will break the OpenMP offloading. It will be nice if 
you can test this patch locally with the runtime patch. Thanks


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

https://reviews.llvm.org/D67833



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


[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9566
+MEHandler.generateAllInfo(BasePointers, Pointers, Sizes, MapTypes,
+  CapturedVarSet, /*PresentModifierOnly=*/true);
 

ABataev wrote:
> jdenny wrote:
> > ABataev wrote:
> > > jdenny wrote:
> > > > In today's OpenMP/LLVM call, it was pointed out that this issue 
> > > > represents a general Clang bug for map clauses: map clauses generally 
> > > > shouldn't be ignored just because their variables aren't referenced in 
> > > > the construct.
> > > > 
> > > > Here, I tried to handle this issue only in the case of a `present` 
> > > > modifier because I previously didn't consider whether the existing 
> > > > behavior for other map types was a bug.  My solution here was similar 
> > > > to what's done for `omp target data`, which doesn't have captures at 
> > > > all.  Perhaps, this should generalized to other map types.
> > > > 
> > > > Another possibility might be to expand what's captured in Sema.
> > > It must be fixed in a separate patch. We definitely should not modify 
> > > sema here, just the codegen. Currently, it iterates through all captures 
> > > in region, also need to iterate through the explicit maps.
> > Thanks for the response.  I'd be happy to generalize and extract into a new 
> > patch.
> > 
> > It looks like all I need to extract is the changes to `generateAllInfo` and 
> > `emitTargetCall` except I wouldn't have the `PresentModifierOnly` 
> > restriction.  Of course, I would need to add tests.  Does all that sound 
> > about right?  If so, I'll work on it.
> Yes, something like this. Most probably, you won't need to add new tests, 
> just modify the existing ones.
OK, I'm working on this.  One point from the call I'm not confident about:  Is 
this change just for globals or locals too?  That is, which variables in the 
following examples should have map entries?

```
int x;
void fn() {
  int y;
  #pragma omp target map(x,y)
  {
// no references to x and y are lexically contained
  }
}
```


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

https://reviews.llvm.org/D83061



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


[PATCH] D83242: [clang][BPF] support expr with typedef/record type for FIELD_EXISTENCE reloc

2020-07-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

In D83242#2154145 , @ast wrote:

> lgtm.
>  curious what happens when type is defined within args, like:
>  __builtin_preserve_field_info(*(struct { int a; } *)0, 2);


-bash-4.4$ clang -target bpf -O2 -g -S t1.c
t1.c:3:40: error: __builtin_preserve_field_info argument 1 invalid

  return __builtin_preserve_field_info(*(struct { int a; } *)0, 2);

it will flag out an error since an non-empty name is required
as we will need it to generate relocation.

  if (!RT || RT->getDecl()->getDeclName().isEmpty())

With an name, it works properly.

  -bash-4.4$ cat t1.c
  
  unsigned unit1() {
return __builtin_preserve_field_info(*(struct t { int a; } *)0, 2);
  }
  -bash-4.4$ clang -target bpf -O2 -g -S t1.c   
 
  -bash-4.4$




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D67833



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


[PATCH] D83242: [clang][BPF] support expr with typedef/record type for FIELD_EXISTENCE reloc

2020-07-15 Thread Andrii Nakryiko via Phabricator via cfe-commits
anakryiko added a comment.

This is awesome. I'll apply patches locally and will play with them tonight to 
see if everything works in libbpf as well. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-15 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 278291.
lildmh added a comment.

Update diff and pass test. Please accept


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

https://reviews.llvm.org/D67833

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.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_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/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_parallel_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  

[PATCH] D83901: [clang] Disable a few formatting options for test/

2020-07-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: aaron.ballman, jdoerfert, lebedev.ri, 
MyDeveloperDay.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

Hopefully this will make the bot a little less noisy. Rationale for each:

`AlignTrailingComments`: We don't want to force-align the various 
`expected-error` and friends.
`CommentPragmas`: Tell clang-format to leave the `// CHECK:` and the `// 
expected-` alone.
`AlwaysBreakTemplateDeclarations`: Templates in tests often have no break 
between the template-head and the declaration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83901

Files:
  clang/test/.clang-format


Index: clang/test/.clang-format
===
--- clang/test/.clang-format
+++ clang/test/.clang-format
@@ -1,2 +1,5 @@
 BasedOnStyle: LLVM
 ColumnLimit: 0
+AlignTrailingComments: false
+CommentPragmas: "(^ ?CHECK|^ ?expected-)"
+AlwaysBreakTemplateDeclarations: No


Index: clang/test/.clang-format
===
--- clang/test/.clang-format
+++ clang/test/.clang-format
@@ -1,2 +1,5 @@
 BasedOnStyle: LLVM
 ColumnLimit: 0
+AlignTrailingComments: false
+CommentPragmas: "(^ ?CHECK|^ ?expected-)"
+AlwaysBreakTemplateDeclarations: No
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-15 Thread David Van Cleve via Phabricator via cfe-commits
davidvancleve added a comment.

Hey, quick question about this change:

I'm seeing .cache directories appear off of subdirectories too, not just my 
project root:

Untracked files:


31 #»  .cache/  

 
 32 #»  content/browser/frame_host/.cache/  

  
 33 #»  content/public/browser/.cache/  

  
 34 #»  content/test/.cache/

  
 35 #»  net/http/.cache/

  
 36 #»  services/network/.cache/

  
 37 #»  services/network/trust_tokens/.cache/

Is this working as intended?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099



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


[PATCH] D83897: [X86] Add a generic 32-bit CPU with sse2 with modern tuning flags to be used as the default for the 32-bit targets instead of pentium4

2020-07-15 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Did you want to just change the pentium4 tuning? Otherwise naming things is 
hard and this feels awkward, but I don't have any better ideas :)


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

https://reviews.llvm.org/D83897



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


[PATCH] D83398: [OPENMP50]Perform data mapping analysis only for explicitly mapped data.

2020-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 278284.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83398

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


Index: clang/test/OpenMP/target_map_messages.cpp
===
--- clang/test/OpenMP/target_map_messages.cpp
+++ clang/test/OpenMP/target_map_messages.cpp
@@ -604,6 +604,7 @@
   const int ()[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} 
le45-error {{expected at least one 'map' or 'use_device_ptr' clause for 
'#pragma omp target data'}} le50-error {{expected at least one 'map', 
'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note 
{{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -750,6 +751,12 @@
 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} 
expected-note {{to match this '['}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+Arr[0] = 2; // le45-error {{original storage of expression in data 
environment is shared but data environment do not fully contain mapped 
expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -17484,6 +17484,7 @@
   /*CurrentRegionOnly=*/true, CurComponents, CKind))
   break;
 if (CKind == OMPC_map &&
+(SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
   /*CurrentRegionOnly=*/false, CurComponents, CKind))
   break;


Index: clang/test/OpenMP/target_map_messages.cpp
===
--- clang/test/OpenMP/target_map_messages.cpp
+++ clang/test/OpenMP/target_map_messages.cpp
@@ -604,6 +604,7 @@
   const int ()[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} le45-error {{expected at least one 'map' or 'use_device_ptr' clause for '#pragma omp target data'}} le50-error {{expected at least one 'map', 'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -750,6 +751,12 @@
 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+Arr[0] = 2; // le45-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -17484,6 +17484,7 @@
   /*CurrentRegionOnly=*/true, CurComponents, CKind))
   break;
 if (CKind == OMPC_map &&
+(SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
   /*CurrentRegionOnly=*/false, CurComponents, CKind))
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Looks like your changes to the .cpp and test files were reverted...




Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:93
+  // Not all transformations will want or need to attach metadata and therefore
+  // sholud not be requierd to do so.
   AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {

nit: typos

The same applies to `Note`. Since this is a nullable type, can we ask that the 
user check `Metadata != nullptr`?



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:270
 
-// TODO(asoffer): If this returns an llvm::Expected, should we unwrap?
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the

I think I understand now. Is the idea that we'll only get one implicit 
construction from the compiler, so we want to use that "free" conversion on the 
`llvm::Any`, rather than on the `llvm::Expected`, which would force the user to 
explicitly construct the `llvm::Any`?

I think we should address this with separate functions (or overloads at least), 
one for the case of never-fail metadata constructors and one for failable 
constructors. That said, any computation that takes the matchresult is prone to 
failure because of unbound nodes.  so, I would expect it to be common for the 
Callable to be failable.  however, if you feel that's the uncommon case, let's 
optimize towards the common case, like you've done.

With all that said, I agree that if the Callable returns an `Expected` we 
should rewrap correctly, not bury in `Any`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820



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


[PATCH] D83242: [clang][BPF] support expr with typedef/record type for FIELD_EXISTENCE reloc

2020-07-15 Thread Alexei Starovoitov via Phabricator via cfe-commits
ast added a comment.

lgtm.
curious what happens when type is defined within args, like:
__builtin_preserve_field_info(*(struct { int a; } *)0, 2);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242



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


[PATCH] D82576: [PowerPC][Power10] Implement low-order Vector Modulus Builtins, and add Vector Multiply/Divide/Modulus Builtins Tests

2020-07-15 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:28
+  return vec_mul(vulla, vullb);
+}
+

Are the tests for `vec_mul` with `v4i32` missing ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82576



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


[PATCH] D83893: [CUDA][HIP] Always defer diagnostics for wrong-sided reference

2020-07-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added subscribers: jlebar, rsmith.
tra added a comment.

> This is different from nvcc behavior, where it is diagnosed only if the 
> function is really emitted:

That by itself is not a sufficient reason for relaxing the checks. Clang is 
stricter/more principled in diagnosing other questionalbe things nvcc lets 
through, even when it should not have. 
NVCC only sees part of the source, so it's limited in what it can diagnose 
during particular compilation side. Clang can do better.

> Current clang behavior causes diagnostics for wrong-sided reference emitted 
> twice, once in host compilation, once in device compilation, which is 
> unnecessary and cluttering the screen.

I don't think it's a problem. Clang will abort compilation if one of 
sub-compilation fails. We'll only see the error once.

> More importantly, current clang behavior causes false alarms for valid use 
> cases:

I'm not convinced that your example is valid. To me it looks like `test` should 
not have been a HD, given that it always uses a host function.

That said, I can see where it may be useful in case of `test` being a constexpr 
template function (for example somewhere in a standard library) parametrized by 
something else which may be host or device-only.
E.g. this may be a somewhat better example: https://godbolt.org/z/44vPv8

OK. I think it is useful, but I could also use a second opinion. 
@rsmith , @jlebar do you have any thoughts on this?


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

https://reviews.llvm.org/D83893



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


[PATCH] D83334: [OPENMP]Fix PR46593: Reduction initializer missing construnctor call.

2020-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG41d0af00740a: [OPENMP]Fix PR46593: Reduction initializer 
missing construnctor call. (authored by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D83334?vs=277448=278276#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83334

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp

Index: clang/test/OpenMP/for_reduction_codegen_UDR.cpp
===
--- clang/test/OpenMP/for_reduction_codegen_UDR.cpp
+++ clang/test/OpenMP/for_reduction_codegen_UDR.cpp
@@ -203,9 +203,11 @@
 // For + reduction operation initial value of private variable is -1.
 // CHECK: call void [[RED_INIT1:@.+]](float* %{{.+}}, float* %{{.+}})
 
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[VAR_PRIV]]
 // For & reduction operation initial value of private variable is defined by call of 'init()' function.
 // CHECK: call void [[RED_INIT2:@.+]](
 
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[VAR1_PRIV]]
 // For && reduction operation initial value of private variable is 1.0.
 // CHECK: call void [[RED_INIT3:@.+]](
 
@@ -598,6 +600,17 @@
 // CHECK: br i1 [[DONE]],
 
 // Check initialization of private copy.
+// CHECK: [[BEGIN:%.+]] = getelementptr inbounds [10 x [4 x [[S_FLOAT_TY, [10 x [4 x [[S_FLOAT_TY* [[ARRS_PRIV]], i32 0, i32 0, i32 0
+// CHECK: [[END:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[BEGIN]], i64 40
+// CHECK: br label %[[CTOR:[^,]+]]
+// CHECK: [[CTOR]]:
+// CHECK: [[CUR:%.+]] = phi [[S_FLOAT_TY]]* [ [[BEGIN]], %{{.+}} ], [ [[NEXT:%.+]], %[[CTOR]] ]
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[CUR]])
+// CHECK: [[NEXT:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[CUR]], i64 1
+// CHECK: [[IS_DONE:%.+]] = icmp eq [[S_FLOAT_TY]]* [[NEXT]], [[END]]
+// CHECK: br i1 [[IS_DONE]], label %[[DONE:[^,]+]], label %[[CTOR]]
+// CHECK: [[DONE]]:
+
 // CHECK: [[BEGIN:%.+]] = getelementptr inbounds [10 x [4 x [[S_FLOAT_TY, [10 x [4 x [[S_FLOAT_TY* [[ARRS_PRIV]], i32 0, i32 0, i32 0
 // CHECK: [[LHS_BEGIN:%.+]] = bitcast [10 x [4 x [[S_FLOAT_TY* %{{.+}} to [[S_FLOAT_TY]]*
 // CHECK: [[END:%.+]] = getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[BEGIN]], i64 40
@@ -901,9 +914,11 @@
 // For + reduction operation initial value of private variable is 0.
 // CHECK: call void [[RED_INIT6:@.+]](
 
+// CHECK: call void @_ZN1SIiEC1Ev([[S_INT_TY]]* [[VAR_PRIV]]
 // For & reduction operation initial value of private variable is ones in all bits.
 // CHECK: call void [[RED_INIT2:@.+]](
 
+// CHECK: call void @_ZN1SIiEC1Ev([[S_INT_TY]]* [[VAR1_PRIV]]
 // For && reduction operation initial value of private variable is 1.0.
 // CHECK: call void [[RED_INIT7:@.+]](
 
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15153,6 +15153,7 @@
   auto *DRDRef = DeclareReductionRef.getAs();
   auto *DRD = cast(DRDRef->getDecl());
   if (DRD->getInitializer()) {
+S.ActOnUninitializedDecl(PrivateVD);
 Init = DRDRef;
 RHSVD->setInit(DRDRef);
 RHSVD->setInitStyle(VarDecl::CallInit);
@@ -15259,10 +15260,19 @@
 llvm_unreachable("Unexpected reduction operation");
   }
 }
-if (Init && DeclareReductionRef.isUnset())
+if (Init && DeclareReductionRef.isUnset()) {
   S.AddInitializerToDecl(RHSVD, Init, /*DirectInit=*/false);
-else if (!Init)
+  // Store initializer for single element in private copy. Will be used
+  // during codegen.
+  PrivateVD->setInit(RHSVD->getInit());
+  PrivateVD->setInitStyle(RHSVD->getInitStyle());
+} else if (!Init) {
   S.ActOnUninitializedDecl(RHSVD);
+  // Store initializer for single element in private copy. Will be used
+  // during codegen.
+  PrivateVD->setInit(RHSVD->getInit());
+  PrivateVD->setInitStyle(RHSVD->getInitStyle());
+}
 if (RHSVD->isInvalidDecl())
   continue;
 if (!RHSVD->hasInit() &&
@@ -15276,10 +15286,6 @@
   << D;
   continue;
 }
-// Store initializer for single element in private copy. Will be used during
-// codegen.
-PrivateVD->setInit(RHSVD->getInit());
-PrivateVD->setInitStyle(RHSVD->getInitStyle());
 DeclRefExpr *PrivateDRE = buildDeclRefExpr(S, PrivateVD, PrivateTy, ELoc);
 ExprResult ReductionOp;
 if (DeclareReductionRef.isUsable()) {
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -886,8 +886,11 @@
   SharedType, SharedAddresses[N].first.getBaseInfo(),
   

[clang] 41d0af0 - [OPENMP]Fix PR46593: Reduction initializer missing construnctor call.

2020-07-15 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-07-15T15:14:22-04:00
New Revision: 41d0af00740ac5140f11c7f37157fc6e6dd1b016

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

LOG: [OPENMP]Fix PR46593: Reduction initializer missing construnctor call.

Summary:
If user-defined reductions with the initializer are used with classes,
the compiler misses the constructor call when trying to create a private
copy of the reduction variable.

Reviewers: jdoerfert

Subscribers: cfe-commits, yaxunl, guansong, caomhin

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/for_reduction_codegen_UDR.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 43cbe9c720ea..a7e1fe8560b6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -886,8 +886,11 @@ void ReductionCodeGen::emitInitialization(
   SharedType, SharedAddresses[N].first.getBaseInfo(),
   CGF.CGM.getTBAAInfoForSubobject(SharedAddresses[N].first, SharedType));
   if (CGF.getContext().getAsArrayType(PrivateVD->getType())) {
+if (DRD && DRD->getInitializer())
+  (void)DefaultInit(CGF);
 emitAggregateInitialization(CGF, N, PrivateAddr, SharedLVal, DRD);
   } else if (DRD && (DRD->getInitializer() || !PrivateVD->hasInit())) {
+(void)DefaultInit(CGF);
 emitInitWithReductionInitializer(CGF, DRD, ClausesData[N].ReductionOp,
  PrivateAddr, SharedLVal.getAddress(CGF),
  SharedLVal.getType());

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 920463da4027..8bf605e5e76b 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15153,6 +15153,7 @@ static bool actOnOMPReductionKindClause(
   auto *DRDRef = DeclareReductionRef.getAs();
   auto *DRD = cast(DRDRef->getDecl());
   if (DRD->getInitializer()) {
+S.ActOnUninitializedDecl(PrivateVD);
 Init = DRDRef;
 RHSVD->setInit(DRDRef);
 RHSVD->setInitStyle(VarDecl::CallInit);
@@ -15259,10 +15260,19 @@ static bool actOnOMPReductionKindClause(
 llvm_unreachable("Unexpected reduction operation");
   }
 }
-if (Init && DeclareReductionRef.isUnset())
+if (Init && DeclareReductionRef.isUnset()) {
   S.AddInitializerToDecl(RHSVD, Init, /*DirectInit=*/false);
-else if (!Init)
+  // Store initializer for single element in private copy. Will be used
+  // during codegen.
+  PrivateVD->setInit(RHSVD->getInit());
+  PrivateVD->setInitStyle(RHSVD->getInitStyle());
+} else if (!Init) {
   S.ActOnUninitializedDecl(RHSVD);
+  // Store initializer for single element in private copy. Will be used
+  // during codegen.
+  PrivateVD->setInit(RHSVD->getInit());
+  PrivateVD->setInitStyle(RHSVD->getInitStyle());
+}
 if (RHSVD->isInvalidDecl())
   continue;
 if (!RHSVD->hasInit() &&
@@ -15276,10 +15286,6 @@ static bool actOnOMPReductionKindClause(
   << D;
   continue;
 }
-// Store initializer for single element in private copy. Will be used 
during
-// codegen.
-PrivateVD->setInit(RHSVD->getInit());
-PrivateVD->setInitStyle(RHSVD->getInitStyle());
 DeclRefExpr *PrivateDRE = buildDeclRefExpr(S, PrivateVD, PrivateTy, ELoc);
 ExprResult ReductionOp;
 if (DeclareReductionRef.isUsable()) {

diff  --git a/clang/test/OpenMP/for_reduction_codegen_UDR.cpp 
b/clang/test/OpenMP/for_reduction_codegen_UDR.cpp
index 45962b3ed2b1..31168bc325e3 100644
--- a/clang/test/OpenMP/for_reduction_codegen_UDR.cpp
+++ b/clang/test/OpenMP/for_reduction_codegen_UDR.cpp
@@ -203,9 +203,11 @@ int main() {
 // For + reduction operation initial value of private variable is -1.
 // CHECK: call void [[RED_INIT1:@.+]](float* %{{.+}}, float* %{{.+}})
 
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[VAR_PRIV]]
 // For & reduction operation initial value of private variable is defined by 
call of 'init()' function.
 // CHECK: call void [[RED_INIT2:@.+]](
 
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[VAR1_PRIV]]
 // For && reduction operation initial value of private variable is 1.0.
 // CHECK: call void [[RED_INIT3:@.+]](
 
@@ -598,6 +600,17 @@ int main() {
 // CHECK: br i1 [[DONE]],
 
 // Check initialization of private copy.
+// CHECK: [[BEGIN:%.+]] = getelementptr inbounds [10 x [4 x [[S_FLOAT_TY, 
[10 x [4 x [[S_FLOAT_TY* [[ARRS_PRIV]], i32 0, i32 0, i32 0
+// CHECK: [[END:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* 
[[BEGIN]], i64 40
+// CHECK: br label 

[PATCH] D83696: [OPENMP]Fix PR46688: cast the type of the allocated variable to the initial one.

2020-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9dc327d1b746: [OPENMP]Fix PR46688: cast the type of the 
allocated variable to the initial one. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83696

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp


Index: clang/test/OpenMP/nvptx_allocate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_allocate_codegen.cpp
+++ clang/test/OpenMP/nvptx_allocate_codegen.cpp
@@ -101,7 +101,7 @@
 // CHECK: alloca float,
 // CHECK-NOT: alloca double,
 // CHECK: load float, float* %
-// CHECK: store double {{.+}}, double addrspace(3)* @bar_b,
+// CHECK: store double {{.+}}, double* addrspacecast (double addrspace(3)* 
@bar_b to double*),
 }
 
 #pragma omp end declare target
Index: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4770,6 +4770,7 @@
 const VarDecl *VD) {
   if (VD && VD->hasAttr()) {
 const auto *A = VD->getAttr();
+auto AS = LangAS::Default;
 switch (A->getAllocatorType()) {
   // Use the default allocator here as by default local vars are
   // threadlocal.
@@ -4783,42 +4784,30 @@
 case OMPAllocateDeclAttr::OMPUserDefinedMemAlloc:
   // TODO: implement aupport for user-defined allocators.
   return Address::invalid();
-case OMPAllocateDeclAttr::OMPConstMemAlloc: {
-  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
-  auto *GV = new llvm::GlobalVariable(
-  CGM.getModule(), VarTy, /*isConstant=*/false,
-  llvm::GlobalValue::InternalLinkage,
-  llvm::Constant::getNullValue(VarTy), VD->getName(),
-  /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
-  CGM.getContext().getTargetAddressSpace(LangAS::cuda_constant));
-  CharUnits Align = CGM.getContext().getDeclAlign(VD);
-  GV->setAlignment(Align.getAsAlign());
-  return Address(GV, Align);
-}
-case OMPAllocateDeclAttr::OMPPTeamMemAlloc: {
-  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
-  auto *GV = new llvm::GlobalVariable(
-  CGM.getModule(), VarTy, /*isConstant=*/false,
-  llvm::GlobalValue::InternalLinkage,
-  llvm::Constant::getNullValue(VarTy), VD->getName(),
-  /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
-  CGM.getContext().getTargetAddressSpace(LangAS::cuda_shared));
-  CharUnits Align = CGM.getContext().getDeclAlign(VD);
-  GV->setAlignment(Align.getAsAlign());
-  return Address(GV, Align);
-}
+case OMPAllocateDeclAttr::OMPConstMemAlloc:
+  AS = LangAS::cuda_constant;
+  break;
+case OMPAllocateDeclAttr::OMPPTeamMemAlloc:
+  AS = LangAS::cuda_shared;
+  break;
 case OMPAllocateDeclAttr::OMPLargeCapMemAlloc:
-case OMPAllocateDeclAttr::OMPCGroupMemAlloc: {
-  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
-  auto *GV = new llvm::GlobalVariable(
-  CGM.getModule(), VarTy, /*isConstant=*/false,
-  llvm::GlobalValue::InternalLinkage,
-  llvm::Constant::getNullValue(VarTy), VD->getName());
-  CharUnits Align = CGM.getContext().getDeclAlign(VD);
-  GV->setAlignment(Align.getAsAlign());
-  return Address(GV, Align);
-}
+case OMPAllocateDeclAttr::OMPCGroupMemAlloc:
+  break;
 }
+llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
+auto *GV = new llvm::GlobalVariable(
+CGM.getModule(), VarTy, /*isConstant=*/false,
+llvm::GlobalValue::InternalLinkage, 
llvm::Constant::getNullValue(VarTy),
+VD->getName(),
+/*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
+CGM.getContext().getTargetAddressSpace(AS));
+CharUnits Align = CGM.getContext().getDeclAlign(VD);
+GV->setAlignment(Align.getAsAlign());
+return Address(
+CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+GV, VarTy->getPointerTo(CGM.getContext().getTargetAddressSpace(
+VD->getType().getAddressSpace(,
+Align);
   }
 
   if (getDataSharingMode(CGM) != CGOpenMPRuntimeNVPTX::Generic)


Index: clang/test/OpenMP/nvptx_allocate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_allocate_codegen.cpp
+++ clang/test/OpenMP/nvptx_allocate_codegen.cpp
@@ -101,7 +101,7 @@
 // CHECK: alloca float,
 // CHECK-NOT: alloca double,
 // CHECK: load float, float* %
-// CHECK: store double {{.+}}, double addrspace(3)* @bar_b,
+// CHECK: store double {{.+}}, double* addrspacecast (double addrspace(3)* @bar_b to double*),
 

[clang] 9dc327d - [OPENMP]Fix PR46688: cast the type of the allocated variable to the initial one.

2020-07-15 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-07-15T14:54:19-04:00
New Revision: 9dc327d1b74637dac6dc432fb66f88711af16a55

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

LOG: [OPENMP]Fix PR46688: cast the type of the allocated variable to the 
initial one.

Summary:
If the original variable is marked for allocation in the different
address space using #pragma omp allocate, need to cast the allocated
variable to its original type with the original address space.
Otherwise, the compiler may crash trying to bitcast the type of the new
allocated variable to the original type in some cases, like passing this
variable as an argument in function calls.

Reviewers: jdoerfert

Subscribers: jholewinski, cfe-commits, yaxunl, guansong, caomhin

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
clang/test/OpenMP/nvptx_allocate_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
index cbd443134e7a..ac6ec742335c 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4770,6 +4770,7 @@ Address 
CGOpenMPRuntimeNVPTX::getAddressOfLocalVariable(CodeGenFunction ,
 const VarDecl *VD) {
   if (VD && VD->hasAttr()) {
 const auto *A = VD->getAttr();
+auto AS = LangAS::Default;
 switch (A->getAllocatorType()) {
   // Use the default allocator here as by default local vars are
   // threadlocal.
@@ -4783,42 +4784,30 @@ Address 
CGOpenMPRuntimeNVPTX::getAddressOfLocalVariable(CodeGenFunction ,
 case OMPAllocateDeclAttr::OMPUserDefinedMemAlloc:
   // TODO: implement aupport for user-defined allocators.
   return Address::invalid();
-case OMPAllocateDeclAttr::OMPConstMemAlloc: {
-  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
-  auto *GV = new llvm::GlobalVariable(
-  CGM.getModule(), VarTy, /*isConstant=*/false,
-  llvm::GlobalValue::InternalLinkage,
-  llvm::Constant::getNullValue(VarTy), VD->getName(),
-  /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
-  CGM.getContext().getTargetAddressSpace(LangAS::cuda_constant));
-  CharUnits Align = CGM.getContext().getDeclAlign(VD);
-  GV->setAlignment(Align.getAsAlign());
-  return Address(GV, Align);
-}
-case OMPAllocateDeclAttr::OMPPTeamMemAlloc: {
-  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
-  auto *GV = new llvm::GlobalVariable(
-  CGM.getModule(), VarTy, /*isConstant=*/false,
-  llvm::GlobalValue::InternalLinkage,
-  llvm::Constant::getNullValue(VarTy), VD->getName(),
-  /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
-  CGM.getContext().getTargetAddressSpace(LangAS::cuda_shared));
-  CharUnits Align = CGM.getContext().getDeclAlign(VD);
-  GV->setAlignment(Align.getAsAlign());
-  return Address(GV, Align);
-}
+case OMPAllocateDeclAttr::OMPConstMemAlloc:
+  AS = LangAS::cuda_constant;
+  break;
+case OMPAllocateDeclAttr::OMPPTeamMemAlloc:
+  AS = LangAS::cuda_shared;
+  break;
 case OMPAllocateDeclAttr::OMPLargeCapMemAlloc:
-case OMPAllocateDeclAttr::OMPCGroupMemAlloc: {
-  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
-  auto *GV = new llvm::GlobalVariable(
-  CGM.getModule(), VarTy, /*isConstant=*/false,
-  llvm::GlobalValue::InternalLinkage,
-  llvm::Constant::getNullValue(VarTy), VD->getName());
-  CharUnits Align = CGM.getContext().getDeclAlign(VD);
-  GV->setAlignment(Align.getAsAlign());
-  return Address(GV, Align);
-}
+case OMPAllocateDeclAttr::OMPCGroupMemAlloc:
+  break;
 }
+llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
+auto *GV = new llvm::GlobalVariable(
+CGM.getModule(), VarTy, /*isConstant=*/false,
+llvm::GlobalValue::InternalLinkage, 
llvm::Constant::getNullValue(VarTy),
+VD->getName(),
+/*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
+CGM.getContext().getTargetAddressSpace(AS));
+CharUnits Align = CGM.getContext().getDeclAlign(VD);
+GV->setAlignment(Align.getAsAlign());
+return Address(
+CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+GV, VarTy->getPointerTo(CGM.getContext().getTargetAddressSpace(
+VD->getType().getAddressSpace(,
+Align);
   }
 
   if (getDataSharingMode(CGM) != CGOpenMPRuntimeNVPTX::Generic)

diff  --git a/clang/test/OpenMP/nvptx_allocate_codegen.cpp 
b/clang/test/OpenMP/nvptx_allocate_codegen.cpp
index 

[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-15 Thread Andy Soffer via Phabricator via cfe-commits
asoffer marked 4 inline comments as done.
asoffer added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:92
   TextGenerator Note;
-  llvm::Any Metadata;
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
+return llvm::Any();

ymandel wrote:
> Why default, especially when we don't default the others? Is it worth a 
> comment?
Added comments.



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:268
 
-inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
-  edit.Metadata = std::move(Metadata);
-  return edit;
+// TODO(asoffer): If this returns an llvm::Expected, should we unwrap?
+template 

gribozavr2 wrote:
> What is "this" who is "we"? Should this be an implementation comment instead 
> (in the function body next to the relevant line)?
Added comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820



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


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-15 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 278262.
asoffer added a comment.

Add comments describing why we provide defaults for Metadata generation and 
design of withMetadata function template.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820

Files:
  clang/include/clang/Tooling/Transformer/RewriteRule.h


Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -89,6 +89,8 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
+  // Not all transformations will want or need to attach metadata and therefore
+  // sholud not be requierd to do so.
   AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
 return llvm::Any();
   };
@@ -265,7 +267,18 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-// TODO(asoffer): If this returns an llvm::Expected, should we unwrap?
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be 
a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. 
If
+// it accepted a `std::function`, lambdas or other callable 
types
+// would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
 template 
 inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
   Edit.Metadata =


Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -89,6 +89,8 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
+  // Not all transformations will want or need to attach metadata and therefore
+  // sholud not be requierd to do so.
   AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
 return llvm::Any();
   };
@@ -265,7 +267,18 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-// TODO(asoffer): If this returns an llvm::Expected, should we unwrap?
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. If
+// it accepted a `std::function`, lambdas or other callable types
+// would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
 template 
 inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
   Edit.Metadata =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83897: [X86] Add a generic 32-bit CPU with sse2 with modern tuning flags to be used as the default for the 32-bit targets instead of pentium4

2020-07-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, echristo, andreadb.
Herald added subscribers: jfb, hiraditya.
Herald added a project: LLVM.

Currently our default 32-bit CPU on Linux and Windows is "pentium4" which comes 
with pentium4 tuning settings and almost non-existent scheduler.

This patch proposes to add a 32-bit CPU with sse2, but with more modern tuning 
settings to replace the default pentium4. I've chosen this way so that 
-march=pentium4 behavior doesn't change. Alternatively we can just change the 
pentium4 settings and assume no one cares about truly tuning for pentium4 these 
days.

This would be unnecessary if -mtune were supported, but this is a lot less 
effort than plumbing mtune.


https://reviews.llvm.org/D83897

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/nacl-direct.c
  clang/test/Driver/x86_features.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/X86TargetParser.h
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td

Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1294,6 +1294,25 @@
   FeatureInsertVZEROUPPER
 ]>;
 
+// Provide a generic 32-bit sse2 CPU with modern tuning settings. This is the
+// default for 32-bit mode.
+// FIXME: If we supported mtune we could have generic tuning for modern with
+// arch as pentium4.
+def : ProcessorModel<"x86-32-sse2", SandyBridgeModel, [
+  FeatureX87,
+  FeatureCMPXCHG8B,
+  FeatureCMOV,
+  FeatureMMX,
+  FeatureSSE2,
+  FeatureFXSR,
+  FeatureNOPL,
+  FeatureSlow3OpsLEA,
+  FeatureSlowDivide64,
+  FeatureSlowIncDec,
+  FeatureMacroFusion,
+  FeatureInsertVZEROUPPER
+]>;
+
 //===--===//
 // Calling Conventions
 //===--===//
Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -370,6 +370,8 @@
   { {"znver2"}, CK_ZNVER2, FEATURE_AVX2, FeaturesZNVER2 },
   // Generic 64-bit processor.
   { {"x86-64"}, CK_x86_64, ~0U, FeaturesX86_64 },
+  // Generic 32-bit processor.
+  { {"x86-32-sse2"}, CK_x86_32_sse2, ~0U, FeaturesPentium4 },
   // Geode processors.
   { {"geode"}, CK_Geode, ~0U, FeaturesGeode },
 };
Index: llvm/include/llvm/Support/X86TargetParser.h
===
--- llvm/include/llvm/Support/X86TargetParser.h
+++ llvm/include/llvm/Support/X86TargetParser.h
@@ -119,6 +119,7 @@
   CK_ZNVER1,
   CK_ZNVER2,
   CK_x86_64,
+  CK_x86_32_sse2,
   CK_Geode,
 };
 
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -20,7 +20,7 @@
 // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
 // X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
 // X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
-// X86-SAME: x86-64, geode
+// X86-SAME: x86-64, x86-32-sse2, geode
 
 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
 // X86_64: error: unknown target CPU 'not-a-cpu'
Index: clang/test/Driver/x86_features.c
===
--- clang/test/Driver/x86_features.c
+++ clang/test/Driver/x86_features.c
@@ -1,5 +1,5 @@
 // RUN: %clang -target i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse  2>&1 | FileCheck %s
-// CHECK: "pentium4" "-target-feature" "+sse4.2" "-target-feature" "-mmx" "-target-feature" "+sse"
+// CHECK: "x86-32-sse2" "-target-feature" "+sse4.2" "-target-feature" "-mmx" "-target-feature" "+sse"
 // Note that we filter out all but the last -m(no)sse.
 
 // Test that we don't produce an error with -mieee-fp.
Index: clang/test/Driver/nacl-direct.c
===
--- clang/test/Driver/nacl-direct.c
+++ clang/test/Driver/nacl-direct.c
@@ -6,7 +6,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-I686 %s
 // CHECK-I686: {{.*}}clang{{.*}}" "-cc1"
 // CHECK-I686-NOT: "-fno-use-init-array"
-// CHECK-I686: "-target-cpu" "pentium4"
+// CHECK-I686: "-target-cpu" "x86-32-sse2"
 // CHECK-I686: "-resource-dir" "foo"
 // CHECK-I686: "-internal-isystem" "foo{{/|}}include"
 // CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include"
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ 

[clang] 268025e - Fix "unused variable" warning from recent GCC.

2020-07-15 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-15T11:33:25-07:00
New Revision: 268025e2636c023fc39eed80cc4589f7ce9db786

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

LOG: Fix "unused variable" warning from recent GCC.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d20c2382b6ac..41a4ae4b91c8 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9930,8 +9930,7 @@ namespace {
   const ConstantArrayType *CAT =
   Info.Ctx.getAsConstantArrayType(E->getType());
   if (!CAT) {
-if (const IncompleteArrayType *IAT =
-Info.Ctx.getAsIncompleteArrayType(E->getType())) {
+if (E->getType()->isIncompleteArrayType()) {
   // We can be asked to zero-initialize a flexible array member; this
   // is represented as an ImplicitValueInitExpr of incomplete array
   // type. In this case, the array has zero elements.



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


[PATCH] D83893: [CUDA][HIP] Always defer diagnostics for wrong-sided reference

2020-07-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a subscriber: kristof.beyls.

When a device function calls a host function or vice versa, this is wrong-sided
reference. Currently clang immediately diagnose it. This is different from nvcc
behavior, where it is diagnosed only if the function is really emitted:

  void foo();
  inline __device__ void bar() { foo(); }

https://godbolt.org/z/4G8P31

To me nvcc behavior makes more sense, since we do not need a diagnostic
unless we really need it. Current clang behavior causes diagnostics for 
wrong-sided
reference emitted twice, once in host compilation, once in device compilation,
which is unnecessary and cluttering the screen.

More importantly, current clang behavior causes false alarms for valid use 
cases:

  __device__ void bar(int x);
  
  template
  __device__ void foo(T x) {
bar(x);
  }
  
  struct A {
int a;
operator int() { return a; }
  };
  
  void foo(A a) {}
  
  template
  __device__ __host__ void test(T t) {
foo(t);
  }
  
  int main() {
A a;
test(a);
return 0;
  } 

In this example, we only emit `test` on host, it should compile.
However since `test` is a host device function, it triggers
instantiation of `foo` in device compilation. `foo` calls
a host `operator int()` which causes immediate diagnostics.

In this case, user may never intend to use `foo` on device side.
The instantiation of `foo` is a side effect of instantiation of
host device function `test`, therefore any diagnostics incurred
by `foo` should be deferred.

This patch let clang always defer diagnostics for wrong-sided
reference.


https://reviews.llvm.org/D83893

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/SemaCUDA/builtins.cu
  clang/test/SemaCUDA/call-kernel-from-kernel.cu
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/function-target.cu
  clang/test/SemaCUDA/implicit-device-lambda.cu
  clang/test/SemaCUDA/method-target.cu
  clang/test/SemaCUDA/reference-to-kernel-fn.cu

Index: clang/test/SemaCUDA/reference-to-kernel-fn.cu
===
--- clang/test/SemaCUDA/reference-to-kernel-fn.cu
+++ clang/test/SemaCUDA/reference-to-kernel-fn.cu
@@ -1,12 +1,14 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify \
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=host \
+// RUN:   -verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify=dev \
 // RUN:   -verify-ignore-unexpected=note %s
-// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify \
-// RUN:   -verify-ignore-unexpected=note -DDEVICE %s
 
 // Check that we can reference (get a function pointer to) a __global__
 // function from the host side, but not the device side.  (We don't yet support
 // device-side kernel launches.)
 
+// host-no-diagnostics
+
 #include "Inputs/cuda.h"
 
 struct Dummy {};
@@ -17,13 +19,11 @@
 
 __host__ __device__ fn_ptr_t get_ptr_hd() {
   return kernel;
-#ifdef DEVICE
-  // expected-error@-2 {{reference to __global__ function}}
-#endif
+  // dev-error@-1 {{reference to __global__ function}}
 }
 __host__ fn_ptr_t get_ptr_h() {
   return kernel;
 }
 __device__ fn_ptr_t get_ptr_d() {
-  return kernel;  // expected-error {{reference to __global__ function}}
+  return kernel;  // dev-error {{reference to __global__ function}}
 }
Index: clang/test/SemaCUDA/method-target.cu
===
--- clang/test/SemaCUDA/method-target.cu
+++ clang/test/SemaCUDA/method-target.cu
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify=host,expected %s
+// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify=dev,expected %s
 
 #include "Inputs/cuda.h"
 
@@ -6,11 +7,11 @@
 // Test 1: host method called from device function
 
 struct S1 {
-  void method() {} // expected-note {{'method' declared here}}
+  void method() {} // dev-note {{'method' declared here}}
 };
 
 __device__ void foo1(S1& s) {
-  s.method(); // expected-error {{reference to __host__ function 'method' in __device__ function}}
+  s.method(); // dev-error {{reference to __host__ function 'method' in __device__ function}}
 }
 
 //--
@@ -29,22 +30,22 @@
 // Test 3: device method called from host function
 
 struct S3 {
-  __device__ void method() {} // expected-note {{'method' declared here}}
+  __device__ void method() {} // host-note {{'method' declared here}}
 };
 
 void foo3(S3& s) {
-  s.method(); // expected-error {{reference to __device__ function 'method' in __host__ function}}
+  s.method(); // host-error {{reference to __device__ function 'method' in __host__ function}}
 }
 
 //--
 // Test 4: device method called from host function
 
 struct S4 {
-  __device__ void method() {}  // expected-note 

[PATCH] D83550: [PATCH 1/4][Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute

2020-07-15 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes marked 6 inline comments as done.
c-rhodes added inline comments.



Comment at: clang/test/Sema/arm-feature-sve-bits-macro.c:3
+
+#include 
+

aaron.ballman wrote:
> c-rhodes wrote:
> > aaron.ballman wrote:
> > > This should not be using a system include (unless you control the include 
> > > path from the RUN line so this doesn't depend on the system running the 
> > > test).
> > Good spot, I missed `// REQUIRES: aarch64-registered-target` which we use 
> > in the other ACLE tests.
> That makes me uncomfortable as this means you won't get any testing on 
> platforms that may have odd behaviors, like Windows when in MS compatibility 
> mode. I'm not keen on adding attributes that can only be tested under certain 
> circumstances as we want to ensure behavior on all platforms.
> 
> We typically handle this by requiring the test to replicate the system header 
> in an Inputs folder that then gets set on the RUN line so that the test can 
> be reproduced on any platform. Was that approach considered and rejected for 
> some reason?
> That makes me uncomfortable as this means you won't get any testing on 
> platforms that may have odd behaviors, like Windows when in MS compatibility 
> mode. I'm not keen on adding attributes that can only be tested under certain 
> circumstances as we want to ensure behavior on all platforms.

I've removed `// REQUIRES: aarch64-registered-target` and the include, it's 
sufficient to typedef the types we need from the header.

> We typically handle this by requiring the test to replicate the system header 
> in an Inputs folder that then gets set on the RUN line so that the test can 
> be reproduced on any platform. Was that approach considered and rejected for 
> some reason?

I wasn't aware of this, good to know! That might come in handy in the next 
patch actually as I use a function from the ACLE to test calls with 
fixed-length types.


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

https://reviews.llvm.org/D83550



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


[PATCH] D83550: [PATCH 1/4][Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute

2020-07-15 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 278249.
c-rhodes added a comment.

- Add a note to docs explaining this feature is a WIP.
- `s/__ARM_FEATURE_SVE_BITS__EXPERIMENTAL/__ARM_FEATURE_SVE_BITS_EXPERIMENTAL`.
- `s/validIntegerConstantExpr/verifyValidIntegerConstantExpr`.
- Removed unrelated change.
- Removed `// REQUIRES: aarch64-registered-target` and `#include ` 
from test. Sizeless ACLE types are typedef'd in the test, copied from header.


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

https://reviews.llvm.org/D83550

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Driver/aarch64-sve-vector-bits.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Sema/attr-arm-sve-vector-bits.c

Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- /dev/null
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=128 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=256 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=1024 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=2048 -fallow-half-arguments-and-returns %s
+
+#define N __ARM_FEATURE_SVE_BITS_EXPERIMENTAL
+
+typedef __SVInt8_t svint8_t;
+typedef __SVInt16_t svint16_t;
+typedef __SVInt32_t svint32_t;
+typedef __SVInt64_t svint64_t;
+typedef __SVUint8_t svuint8_t;
+typedef __SVUint16_t svuint16_t;
+typedef __SVUint32_t svuint32_t;
+typedef __SVUint64_t svuint64_t;
+typedef __SVFloat16_t svfloat16_t;
+typedef __SVFloat32_t svfloat32_t;
+typedef __SVFloat64_t svfloat64_t;
+
+#if defined(__ARM_FEATURE_SVE_BF16)
+typedef __SVBFloat16_t svbfloat16_t;
+#endif
+
+typedef __SVBool_t svbool_t;
+
+// Define valid fixed-width SVE types
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint16_t fixed_int16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svuint8_t fixed_uint8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint16_t fixed_uint16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint32_t fixed_uint32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint64_t fixed_uint64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svfloat16_t fixed_float16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat32_t fixed_float32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbfloat16_t fixed_bfloat16_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
+
+// Attribute must have a single argument
+typedef svint8_t no_argument __attribute__((arm_sve_vector_bits)); // expected-error {{'arm_sve_vector_bits' attribute takes one argument}}
+typedef svint8_t two_arguments __attribute__((arm_sve_vector_bits(2, 4))); // expected-error {{'arm_sve_vector_bits' attribute takes one argument}}
+
+// The number of SVE vector bits must be an integer constant expression
+typedef svint8_t non_int_size1 __attribute__((arm_sve_vector_bits(2.0)));   // expected-error {{'arm_sve_vector_bits' attribute requires an integer constant}}
+typedef svint8_t non_int_size2 __attribute__((arm_sve_vector_bits("256"))); // expected-error {{'arm_sve_vector_bits' attribute requires an integer constant}}
+
+typedef __clang_svint8x2_t svint8x2_t;
+typedef __clang_svfloat32x3_t svfloat32x3_t;
+
+// Attribute must be attached to a single SVE vector or predicate type.
+typedef void *badtype1 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'void *'}}
+typedef int badtype2 

[PATCH] D83892: Port CodeGen option flags to new option parsing system

2020-07-15 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Depends on D83698 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83892

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -293,6 +293,7 @@
   CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument;
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
+  CodeGenOpts.DisableFree = FrontendOpts.DisableFree;
   FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
@@ -830,10 +831,6 @@
 }
   }
 
-  Opts.DebugPassManager =
-  Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
-   /* Default */ false);
-
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
 if (Name == "Accelerate")
@@ -876,23 +873,9 @@
   Opts.setDebuggerTuning(static_cast(Val));
   }
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
-  Opts.DebugColumnInfo = !Args.hasArg(OPT_gno_column_info);
-  Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
-  Opts.CodeViewGHash = Args.hasArg(OPT_gcodeview_ghash);
-  Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
-  Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
-  Opts.VirtualFunctionElimination =
-  Args.hasArg(OPT_fvirtual_function_elimination);
-  Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
   Opts.SplitDwarfFile = std::string(Args.getLastArgValue(OPT_split_dwarf_file));
   Opts.SplitDwarfOutput =
   std::string(Args.getLastArgValue(OPT_split_dwarf_output));
-  Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
-  Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
-  Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
-  Opts.EmbedSource = Args.hasArg(OPT_gembed_source);
-  Opts.ForceDwarfFrameSection = Args.hasArg(OPT_fforce_dwarf_frame);
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
@@ -900,16 +883,9 @@
 {std::string(Split.first), std::string(Split.second)});
   }
 
-  if (const Arg *A =
-  Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
-Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
-
-  Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
-  Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
-
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
-  llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::aarch64,
-  llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
+  llvm::Triple::x86,llvm::Triple::x86_64, llvm::Triple::aarch64,
+  llvm::Triple::arm,llvm::Triple::armeb,  llvm::Triple::mips,
   llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
   llvm::Triple T(TargetOpts.Triple);
@@ -917,27 +893,12 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
-  Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
-  Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
-  Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
-  Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
-  Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
-OPT_fuse_register_sized_bitfield_access);
-  Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
-  Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
-  Opts.FineGrainedBitfieldAccesses =
-  Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
-   OPT_fno_fine_grained_bitfield_accesses, false);
   Opts.DwarfDebugFlags =
   std::string(Args.getLastArgValue(OPT_dwarf_debug_flags));
   Opts.RecordCommandLine =
   std::string(Args.getLastArgValue(OPT_record_command_line));
-  Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
-  Opts.NoCommon = !Args.hasArg(OPT_fcommon);
-  Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
-  Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
   Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
   

[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D82663#2153176 , @ebevhan wrote:

> In D82663#2144551 , @rjmccall wrote:
>
> > In D82663#2144219 , @ebevhan wrote:
> >
> > > In D82663#2142426 , @rjmccall 
> > > wrote:
> > >
> > > > Would it be sensible to use a technical design more like what the 
> > > > matrix folks are doing, where LLVM provides a small interface for 
> > > > emitting operations with various semantics?  FixedPointSemantics would 
> > > > move to that header, and Clang would just call into it.  That way you 
> > > > get a lot more flexibility in how you generate code, and the Clang 
> > > > IRGen logic is still transparently correct.  If you want to add 
> > > > intrinsics or otherwise change the IR patterns used for various 
> > > > operations, you don't have to rewrite a bunch of Clang IRGen logic 
> > > > every time, you just have to update the tests.  It'd then be pretty 
> > > > straightforward to have internal helper functions in that interface for 
> > > > computing things like whether you should use signed or unsigned 
> > > > intrinsics given the desired FixedPointSemantics.
> > >
> > >
> > > This seems like a reasonable thing to do for other reasons as well. Also 
> > > moving the actual APFixedPoint class to LLVM would make it easier to 
> > > reuse the fixedpoint calculation code for constant folding in LLVM, for 
> > > example.
> >
> >
> > Just to say "I told you so", I'm pretty sure I told people this would 
> > happen. :)
>
>
> Well, transferring the fixed point concept over to LLVM felt like it would 
> happen sooner or later, for the reasons we've discussed here as well as for 
> other reasons. I'm not sure that the discrepancies between the Clang and LLVM 
> semantics were predicted to be the driving factor behind the move, though.
>
> >>> My interest here is mainly in (1) keeping IRGen's logic as obviously 
> >>> correct as possible, (2) not hard-coding a bunch of things that really 
> >>> feel like workarounds for backend limitations, and (3) not complicating 
> >>> core abstractions like FixedPointSemantics with unnecessary extra rules 
> >>> for appropriate use, like having to pass an extra "for codegen" flag to 
> >>> get optimal codegen.  If IRGen can just pass down the high-level 
> >>> semantics it wants to some library that will make intelligent decisions 
> >>> about how to emit IR, that seems best.
> >> 
> >> Just to clarify something here; would the interface in LLVM still emit 
> >> signed operations for unsigned with padding?
> > 
> > If that's the best IR pattern to emit, yes.
> > 
> >> If so, why does dealing with the padding bit detail in LLVM rather than 
> >> Clang make more sense?
> > 
> > Because frontends should be able to just say "I have a value of a type with 
> > these semantics, I need you to do these operations, go do them".  The whole 
> > purpose of this interface would be to go down a level of abstraction by 
> > picking the best IR to represent those operations.
> > 
> > Maybe we're not in agreement about what this interface looks like — I'm 
> > imagining something like
> > 
> >   struct FixedPointEmitter {
> > IRBuilder 
> > FixedPointEmitter(IRBuilder ) : B(B) {}
> >   
> > Value *convert(Value *src, FixedPointSemantics srcSemantics, 
> > FixedPointSemantics destSemantics);
> > Value *add(Value *lhs, FixedPointSemantics lhsSemantics, Value *rhs, 
> > FixedPointSemantics rhsSemantics)
> >   };
>
> I've spent some time going over this and trying to figure out how it would 
> work. I think the interface seems fine on the surface, but I don't see how it 
> directly solves the issues at hand. Regardless of whether this is factored 
> out to LLVM, we still have the issue that we have to massage the semantic 
> **somewhere** in order to get different behavior for certain kinds of 
> semantics during binop codegen.
>
> Since the binop functions take two different semantics, it must perform 
> conversions internally to get the values to match up before the operation. 
> This would probably just be to the common semantic between the two, and it 
> would then return the Value in the common semantic (since we don't know what 
> to convert back to).
>
> In order for the binop functions to have special behavior for padded 
> unsigned, they would need to modify the common semantic internally in order 
> to get the conversion right. This means that the semantic of the returned 
> Value will **not** be what you would normally get from `getCommonSemantic`, 
> so the caller of the function will have no idea what the semantic of the 
> returned value is.
>
> Even if we only treat it as an internal detail of the binop functions and 
> never expose this 'modified' semantic externally, this means we might end up 
> with superfluous operations since (for padded saturating unsigned) we will be 
> 

[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-15 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

I applied this patch locally and ran the fuzzer tests.  I get a segfault:

  $ clang++ -fsanitize=fuzzer -g -m32 SimpleHashTest.cpp
  $ gdb --args ./a.out -seed=1
  ...
  (gdb) run
  ...
  Program received signal SIGSEGV, Segmentation fault. 
  0x in ?? ()
  (gdb) bt
  #0  0x in ?? ()
  #1  0x080800b5 in strstr () at 
/usr/local/google/home/mascasa/code/llvm-project/compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:96
  #2  0xf7cc7bf5 in __pthread_initialize_minimal () from 
/lib/i386-linux-gnu/libpthread.so.0
  #3  0xf7cc7014 in _init () from /lib/i386-linux-gnu/libpthread.so.0
  #4  0x0055 in ?? ()
  #5  0xf7fcc6a0 in ?? ()

It looks like the `REAL(strstr)` isn't set up before it's called.  Could you 
please take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


[PATCH] D83120: [Analyzer][StreamChecker] Use BugType::SuppressOnSink at resource leak report.

2020-07-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

In D83120#2152919 , @Szelethus wrote:

> Unless @NoQ has anything else to add :)


@balazske seems innocent indeed! :) :) :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83120



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


[PATCH] D83877: [Analyzer] Changed in SmartPtrModeling to handle Swap

2020-07-15 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:198
 
 void SmartPtrModeling::handleSwap(const CallEvent ,
   CheckerContext ) const {

I think it would be good to add some comments in the body of the function to be 
more explicit about the situation you are handling.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:224-228
+  if (ThisRegionInnerPointerVal) {
+State = State->set(ArgRegion, 
*ThisRegionInnerPointerVal);
+  } else {
+State = State->remove(ArgRegion);
+  }

These two if's are clearly duplicates and it seems like a good candidate for a 
separate function.



Comment at: clang/test/Analysis/smart-ptr.cpp:124
+
+void derefOnStdSwappedNullPtr() {
+  std::unique_ptr P(new A());

xazax.hun wrote:
> This test case is very similar to the first one. Maybe you could move them 
> closer. And you could make both pointers invalid to make them more distinct.
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83877



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


[PATCH] D82317: [Clang/Test]: Update tests where `noundef` attribute is necessary

2020-07-15 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 277992.
guiand added a comment.

Update tests again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82317

Files:
  clang/test/ARCMT/objcmt-instancetype.m
  clang/test/ARCMT/objcmt-instancetype.m.result
  clang/test/ARCMT/objcmt-numeric-literals.m
  clang/test/ARCMT/objcmt-numeric-literals.m.result
  clang/test/AST/ast-dump-openmp-begin-declare-variant_6.c
  clang/test/AST/gen_ast_dump_json_test.py
  clang/test/ASTMerge/unnamed_fields/test.cpp
  clang/test/Analysis/casts.c
  clang/test/Analysis/inlining/DynDispatchBifurcate.m
  clang/test/Analysis/inlining/InlineObjCClassMethod.m
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/missing-bind-temporary.cpp
  clang/test/Analysis/silence-checkers-and-packages-core-all.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
  clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
  clang/test/CXX/drs/dr0xx.cpp
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CXX/special/class.copy/p3.cpp
  clang/test/CodeGen/2004-02-13-Memset.c
  clang/test/CodeGen/2004-06-17-UnorderedCompares.c
  clang/test/CodeGen/2006-05-19-SingleEltReturn.c
  clang/test/CodeGen/2007-02-25-C-DotDotDot.c
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/2008-03-05-syncPtr.c
  clang/test/CodeGen/2008-07-29-override-alias-decl.c
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
  clang/test/CodeGen/2009-02-13-zerosize-union-field.c
  clang/test/CodeGen/2009-05-04-EnumInreg.c
  clang/test/CodeGen/2009-09-24-SqrtErrno.c
  clang/test/CodeGen/3dnow-builtins.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/PR3589-freestanding-libcalls.c
  clang/test/CodeGen/_Bool-conversion.c
  clang/test/CodeGen/aapcs-align.cpp
  clang/test/CodeGen/aapcs-bitfield.c
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-args.cpp
  clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
  clang/test/CodeGen/aarch64-byval-temp.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-dot-product.c
  clang/test/CodeGen/aarch64-neon-extract.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-fp16fml.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/aarch64-varargs-ms.c
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-param.c
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/arc/arguments.c
  clang/test/CodeGen/arc/struct-align.c
  clang/test/CodeGen/arm-aapcs-vfp.c
  clang/test/CodeGen/arm-abi-vector.c
  clang/test/CodeGen/arm-arguments.c
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-byval-align.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/CodeGen/arm-float-helpers.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-homogenous.c
  clang/test/CodeGen/arm-mangle-bf16.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vld24.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-dot-product.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-pcs.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/arm-varargs.c
  clang/test/CodeGen/arm-vector-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/arm64-aapcs-arguments.c
  clang/test/CodeGen/arm64-abi-vector.c
  clang/test/CodeGen/arm64-arguments.c
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/arm64-microsoft-intrinsics.c
  clang/test/CodeGen/arm64-mte.c
  clang/test/CodeGen/arm64_32-vaarg.c
  clang/test/CodeGen/arm64_32.c
  

[PATCH] D83826: [clangd] Don't send invalid messages from remote index

2020-07-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Wrap marshalling into a class, think about filtering vs failing? I think 
filtering should be done on the clangd-indexer side and marshalling should deal 
with **valid** symbols only and shouldn't have to filter them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83826



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


[PATCH] D83550: [PATCH 1/4][Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute

2020-07-15 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

Thanks for the changes @c-rhodes, the use of a LANGOPT for this makes sense to 
me.
With my nits addressed, I'm happy with the patch if @aaron.ballman is.




Comment at: clang/include/clang/Basic/AttrDocs.td:4861
+  let Content = [{
+The ``arm_sve_vector_bits(N)`` attribute is defined by the Arm C Language
+Extensions (ACLE) for SVE. It is used to define fixed-length (VLST) variants of

nit: Can you add a line here to state this feature is still WIP ? (we can 
remove that in a later patch)
I know this is implied by your comment re __ARM_FEATURE_SVE_BITS being defined, 
but I guess it's better to be explicit to avoid confusion.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:381
+  if (Opts.ArmSveVectorBits)
+Builder.defineMacro("__ARM_FEATURE_SVE_BITS__EXPERIMENTAL",
+Twine(Opts.ArmSveVectorBits));

nit: 
`s/__ARM_FEATURE_SVE_BITS__EXPERIMENTAL/__ARM_FEATURE_SVE_BITS_EXPERIMENTAL/` ?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1723
+const Driver  = getToolChain().getDriver();
+if (!Val.equals("128") && !Val.equals("256") && !Val.equals("512") &&
+!Val.equals("1024") && !Val.equals("2048")) {

[feel free to ignore] I don't think it necessarily needs to be restricted to 
this set, it should be able to support any multiple of 128bits. Although if you 
want to limit it for the first implementation that's fine.



Comment at: clang/lib/Sema/SemaType.cpp:7733
   }
+
   // The number of elements must be an ICE.

nit: unrelated change.



Comment at: clang/lib/Sema/SemaType.cpp:7789
+  llvm::APSInt SveVectorSizeInBits(32);
+  if (!validIntegerConstantExpr(S, Attr, SveVectorSizeInBits))
+return;

nit: can you rename this function to something like 
`verifyValidIntegerConstantExpr` to make it clear that that function gives a 
diagnostic if it fails?



Comment at: clang/test/Sema/attr-arm-sve-vector-bits.c:1
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=128 
-fallow-half-arguments-and-returns %s

nit: Given that this test uses `-fsyntax-only`, can you do the same as you did 
for `clang/test/Driver/aarch64-sve-vector-bits.c` and remove 
`aarch64-registered-target` and `#include ` and do the tests on the 
builtin types instead? e.g.

```typedef __SVInt32_t svint32_t;
typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));```


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

https://reviews.llvm.org/D83550



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


[PATCH] D83831: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:63
+trace::Span Tracer("Remote index server Lookup");
+SPAN_ATTACH(Tracer, "LookupRequest", Request->ShortDebugString());
 clangd::LookupRequest Req;

sammccall wrote:
> sammccall wrote:
> > you don't do this on the client side, but could
> prefer DebugString over ShortDebugString, the missing newlines can make it 
> hard to follow
Do you mean logging `RPCRequest` there? Done now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83831



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


[PATCH] D83831: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 278237.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.

Resolve the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83831

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -9,6 +9,8 @@
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/remote/marshalling/Marshalling.h"
+#include "support/Logger.h"
+#include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
@@ -35,6 +37,16 @@
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt TracerFile(
+"tracer-file",
+llvm::cl::desc("Path to the file where tracer logs will be stored"));
+
+llvm::cl::opt PrettyPrint{
+"pretty",
+llvm::cl::desc("Pretty-print JSON output"),
+llvm::cl::init(true),
+};
+
 llvm::cl::opt ServerAddress(
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
@@ -57,21 +69,32 @@
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
+trace::Span Tracer("LookupRequest");
+SPAN_ATTACH(Tracer, "Request", Request->DebugString());
 clangd::LookupRequest Req;
 for (const auto  : Request->ids()) {
   auto SID = SymbolID::fromStr(StringRef(ID));
-  if (!SID)
+  if (!SID) {
+elog("Lookup request cancelled: invalid SymbolID {1}", SID.takeError());
 return grpc::Status::CANCELLED;
+  }
   Req.IDs.insert(*SID);
 }
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
 Index->lookup(Req, [&](const clangd::Symbol ) {
   auto SerializedSymbol = toProtobuf(Sym, IndexedProjectRoot);
-  if (!SerializedSymbol)
+  if (!SerializedSymbol) {
+++FailedToSend;
 return;
+  }
   LookupReply NextMessage;
   *NextMessage.mutable_stream_result() = *SerializedSymbol;
   Reply->Write(NextMessage);
+  ++Sent;
 });
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 LookupReply LastMessage;
 LastMessage.set_final_result(true);
 Reply->Write(LastMessage);
@@ -81,15 +104,24 @@
   grpc::Status FuzzyFind(grpc::ServerContext *Context,
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
+trace::Span Tracer("FuzzyFind");
+SPAN_ATTACH(Tracer, "Request", Request->DebugString());
 const auto Req = fromProtobuf(Request, IndexedProjectRoot);
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
 bool HasMore = Index->fuzzyFind(Req, [&](const clangd::Symbol ) {
   auto SerializedSymbol = toProtobuf(Sym, IndexedProjectRoot);
-  if (!SerializedSymbol)
+  if (!SerializedSymbol) {
+++FailedToSend;
 return;
+  }
   FuzzyFindReply NextMessage;
   *NextMessage.mutable_stream_result() = *SerializedSymbol;
   Reply->Write(NextMessage);
+  ++Sent;
 });
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 FuzzyFindReply LastMessage;
 LastMessage.set_final_result(HasMore);
 Reply->Write(LastMessage);
@@ -98,21 +130,32 @@
 
   grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
 grpc::ServerWriter *Reply) override {
+trace::Span Tracer("Refs");
+SPAN_ATTACH(Tracer, "Request", Request->DebugString());
 clangd::RefsRequest Req;
 for (const auto  : Request->ids()) {
   auto SID = SymbolID::fromStr(StringRef(ID));
-  if (!SID)
+  if (!SID) {
+elog("Refs request cancelled: invalid SymbolID {1}", SID.takeError());
 return grpc::Status::CANCELLED;
+  }
   Req.IDs.insert(*SID);
 }
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
 bool HasMore = Index->refs(Req, [&](const clangd::Ref ) {
   auto SerializedRef = toProtobuf(Reference, IndexedProjectRoot);
-  if (!SerializedRef)
+  if (!SerializedRef) {
+++FailedToSend;
 return;
+  }
   RefsReply NextMessage;
   *NextMessage.mutable_stream_result() = *SerializedRef;
   Reply->Write(NextMessage);
+  ++Sent;
 });
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 RefsReply LastMessage;
 

[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-15 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 278235.
Conanap marked 7 inline comments as done.
Conanap added a comment.

Formatting fixes, fixed test case return type, updated builtins' signatures to 
correct signatures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-shift.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-shift.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-shift.ll
@@ -0,0 +1,47 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+define dso_local <1 x i128> @test_vec_slq(<1 x i128> %a, <1 x i128> %b) #0 {
+; CHECK-LABEL: test_vec_slq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vslq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %slq = call <1 x i128> @llvm.ppc.altivec.vslq(<1 x i128> %a, <1 x i128> %b)
+  ret <1 x i128> %slq
+}
+
+define dso_local <1 x i128> @test_vec_vsrq(<1 x i128> %a, <1 x i128> %b) #0 {
+; CHECK-LABEL: test_vec_vsrq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsrq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %slq = call <1 x i128> @llvm.ppc.altivec.vsrq(<1 x i128> %a, <1 x i128> %b)
+  ret <1 x i128> %slq
+}
+
+define dso_local <1 x i128> @test_vec_vsraq(<1 x i128> %a, <1 x i128> %b) #0 {
+; CHECK-LABEL: test_vec_vsraq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsraq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %slq = call <1 x i128> @llvm.ppc.altivec.vsraq(<1 x i128> %a, <1 x i128> %b)
+  ret <1 x i128> %slq
+}
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vslq(<1 x i128>, <1 x i128>) #1
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vsrq(<1 x i128>, <1 x i128>) #1
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vsraq(<1 x i128>, <1 x i128>) #1
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1027,9 +1027,9 @@
 (ins vrrc:$vA, vrrc:$vB, vrrc:$vDi),
 "vrlqmi $vD, $vA, $vB", IIC_VecFP, []>,
 RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
-  def VSLQ   : VX1_VT5_VA5_VB5<261, "vslq", []>;
-  def VSRAQ  : VX1_VT5_VA5_VB5<773, "vsraq", []>;
-  def VSRQ   : VX1_VT5_VA5_VB5<517, "vsrq", []>;
+  def VSLQ  : VX1_Int_Ty<261, "vslq", int_ppc_altivec_vslq, v1i128>;
+  def VSRAQ : VX1_Int_Ty<773, "vsraq", int_ppc_altivec_vsraq, v1i128>;
+  def VSRQ  : VX1_Int_Ty<517, "vsrq", int_ppc_altivec_vsrq, v1i128>;
   def VRLQ   : VX1_VT5_VA5_VB5<5, "vrlq", []>;
 
   def XSCVQPUQZ : X_VT5_XO5_VB5<63, 0, 836, "xscvqpuqz", []>;
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -797,6 +797,7 @@
 def int_ppc_altivec_vsrv  : PowerPC_Vec_BBB_Intrinsic<"vsrv">;
 def int_ppc_altivec_vslh  : PowerPC_Vec_HHH_Intrinsic<"vslh">;
 def int_ppc_altivec_vslw  : PowerPC_Vec_WWW_Intrinsic<"vslw">;
+def int_ppc_altivec_vslq  : PowerPC_Vec_QQQ_Intrinsic<"vslq">;
 
 // Right Shifts.
 def int_ppc_altivec_vsr   : PowerPC_Vec_WWW_Intrinsic<"vsr">;
@@ -805,9 +806,11 @@
 def int_ppc_altivec_vsrb  : PowerPC_Vec_BBB_Intrinsic<"vsrb">;
 def int_ppc_altivec_vsrh  : PowerPC_Vec_HHH_Intrinsic<"vsrh">;
 def int_ppc_altivec_vsrw  : PowerPC_Vec_WWW_Intrinsic<"vsrw">;
+def int_ppc_altivec_vsrq  : PowerPC_Vec_QQQ_Intrinsic<"vsrq">;
 def int_ppc_altivec_vsrab : PowerPC_Vec_BBB_Intrinsic<"vsrab">;
 def int_ppc_altivec_vsrah : PowerPC_Vec_HHH_Intrinsic<"vsrah">;
 def int_ppc_altivec_vsraw : PowerPC_Vec_WWW_Intrinsic<"vsraw">;
+def int_ppc_altivec_vsraq : PowerPC_Vec_QQQ_Intrinsic<"vsraq">;
 
 // Rotates.
 def int_ppc_altivec_vrlb  : PowerPC_Vec_BBB_Intrinsic<"vrlb">;
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -21,6 +21,7 @@
 vector unsigned int vuia, vuib, vuic;
 vector signed long long vslla, vsllb;
 vector unsigned long long vulla, vullb, vullc;
+vector signed __int128 

[PATCH] D83621: [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json

2020-07-15 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX marked 3 inline comments as done.
ArcsinX added a comment.

As far as I do not have commit access, could you please commit for me?
Aleksandr Platonov 




Comment at: clang/lib/Tooling/FileMatchTrie.cpp:111
+  // As far as we do not support file symlinks we compare
+  // basenames here to avoid expensive request to file system.
+  if (llvm::sys::path::filename(Path) ==

sammccall wrote:
> Here it's really just for consistency - we have a single candidate, and 
> calling equivalent() on a single file isn't expensive. I'd be happy with or 
> without this check, but the comment should mention consistency.
Removed "expensive" word.



Comment at: clang/lib/Tooling/FileMatchTrie.cpp:131
+// We failed to find the file with `Children.find()`.
+// If `ConsumedLength` is equal to 0 then we have tried to find the file
+// with it's basename. Thus, we do not have files with the same

sammccall wrote:
> nit: This is quite a lot of words to come to "we do not support file 
> symlinks" - I think it could be a bit shorter and also get into motivation:
> 
> "If `ConsumedLength` is zero, this is the root and we have no filename match. 
> Give up in this case, we don't try to find symlinks with different names".
Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83621



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


[PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9.

2020-07-15 Thread Ferran Pallarès Roca via Phabricator via cfe-commits
fpallares added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoV.td:99
 // load vd, (rs1), vm
 class VUnitStrideLoad

I believe that with the changes introduced in the encoding of the loads and 
stores we can do without the `mop` parameter in most of the classes here:

| class   | replace `mop` by   |
|---|--|
| `VUnitStrideLoad` | `MOPLDUnitStride` (i.e. `00`) |
| `VStridedLoad` | `MOPLDStrided` (i.e. `10`) |
| `VIndexedLoad` | `MOPLDIndexed` (i.e. `11`) |
| `VUnitStrideStore` | `MOPSTUnitStride` (i.e. `00`) |
| `VStridedStore` | `MOPLDStrided` (i.e. `10`) |

We still need to keep the parameter for the `VIndexedStore` class since it can 
take `MOPSTIndexedOrder` (i.e. `11`) or `MOPSTIndexedUnord` (i.e. `01`).

Does this make sense to you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80802



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this looks pretty good, I think there are a couple of adjustments...




Comment at: clang-tools-extra/clangd/XRefs.cpp:276
getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {

dgoldman wrote:
> sammccall wrote:
> > dgoldman wrote:
> > > sammccall wrote:
> > > > dgoldman wrote:
> > > > > sammccall wrote:
> > > > > > dgoldman wrote:
> > > > > > > Think it would make sense to special case ObjCInterfaceDecl here 
> > > > > > > to get at both the interface definition + implementation if 
> > > > > > > available?
> > > > > > Rather than returning both results, I think it's more consistent to 
> > > > > > return them as a declaration/definition pair.
> > > > > > 
> > > > > > (This means special-casing ObjCImplDecl in namedDecl or at least 
> > > > > > getDeclAsPosition, so you always end up with the ObjCInterfaceDecl 
> > > > > > instead)
> > > > > Whoops, meant to comment here but it was lost. I'm not sure what you 
> > > > > meant here. Should this be done here inside the for loop or in 
> > > > > getDeclAtPosition?
> > > > > 
> > > > > Are you saying that given:
> > > > > 
> > > > > ```
> > > > > @interface Foo // A
> > > > > @end
> > > > > @implementation Foo // B
> > > > > @end
> > > > > ```
> > > > > B --> A here
> > > > > 
> > > > > and similarly
> > > > > 
> > > > > ```
> > > > > @interface Foo // A
> > > > > @end
> > > > > @interface Foo (Ext) // B
> > > > > @end
> > > > > @implementation Foo (Ext) // C
> > > > > @end
> > > > > ```
> > > > > B --> A
> > > > > C --> B (and A? it's unclear how this should map over, e.g. maybe Foo 
> > > > > loc --> A, Ext --> B)
> > > > In the first example, selecting either A or B should yield one 
> > > > LocatedSymbol with {Decl=A, Def=B}. This shouldn't require any 
> > > > special-casing.
> > > > 
> > > > The second example is very similar to template specialization, with 
> > > > exceptions:
> > > >  - there's always a Decl/Def pair you may want to navigate between, 
> > > > whereas in templates there rarely is, so we have ambiguity
> > > >  - there's no AST like there is for template names and args, just a bag 
> > > > of tokens
> > > > 
> > > > I'd suggest, given `@interface Foo (Ext)`:
> > > >  - we produce a LocatedSymbol with {Decl=@interface Foo(Ext), 
> > > > Def=@implementation  Foo(Ext)} - this is the default behavior
> > > >  - if the cursor is exactly on the token `Foo`, we also produce a 
> > > > LocatedSymbol with {Decl=@interface Foo, Def=@implementation Foo} - 
> > > > this is similar to the template special case
> > > >  - if the cursor is exactly on the token Ext... are categories 
> > > > explicitly/separately declared anywhere? I guess not. If they are, we 
> > > > could special case this too.
> > > > And `@implementation Foo(Ext)` should behave in exactly the same way.
> > > Trying this out now, two problems:
> > > 
> > > - getDeclAtPosition will call findTarget. Due to the changes above we map 
> > > `ObjCCategoryImplDecl` to its interface. This is OK but then when we 
> > > check for the loc it's obviously != to the impl's loc. Should I modify 
> > > this to check the contents of the loc for equality?
> > > 
> > > - We call `getDeclAtPosition` only looking for 
> > > DeclRelation::TemplatePattern | DeclRelation::Alias, but this is actually 
> > > a DeclRelation::Underlying. If I don't add that we filter out the 
> > > ObjCCategoryImplDecl. If I add it we get a failure in 
> > > LocateSymbol.TemplateTypedef (we now find another symbol, not sure what 
> > > is intended here)
> > > 
> > > 
> > > getDeclAtPosition will call findTarget. Due to the changes above we map 
> > > ObjCCategoryImplDecl to its interface. This is OK but then when we check 
> > > for the loc it's obviously != to the impl's loc. Should I modify this to 
> > > check the contents of the loc for equality?
> > 
> > Oh right... yes, this seems fine to me (for the ObjCContainerDecl 
> > subclasses only, and with a comment) 
> > 
> > > We call getDeclAtPosition only looking for DeclRelation::TemplatePattern 
> > > | DeclRelation::Alias, but this is actually a DeclRelation::Underlying. 
> > > If I don't add that we filter out the ObjCCategoryImplDecl. If I add it 
> > > we get a failure in LocateSymbol.TemplateTypedef (we now find another 
> > > symbol, not sure what is intended here)
> > 
> > I'm not sure what "this" in "this is actually a DeclRelation::Underlying" 
> > refers to. Do you have a failing testcase?
> > if the cursor is exactly on the token Ext... are categories 
> > explicitly/separately declared anywhere? I guess not. If they are, we could 
> > special case this too.
> 
> Not besides what was mentioned above, so I think it's OK at the moment.
> 
> > I'm not sure what "this" in "this is actually a DeclRelation::Underlying" 
> > refers to. Do you have a failing testcase?

[PATCH] D83877: [Analyzer] Changed in SmartPtrModeling to handle Swap

2020-07-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/test/Analysis/Inputs/system-header-simulator-cxx.h:964-965
+
+  template 
+  void swap(unique_ptr , unique_ptr ) noexcept {
+x.swap(y);

NoQ wrote:
> You seem to be relying on the fact that global `std::swap` is implemented in 
> terms of the member `std::swap`. That's an implementation detail of the 
> standard library; i'm not sure that this is always the case. Ideally we 
> should model the global `std::swap` separately.
I am not sure how reliable cppreference is, but I think this overload might 
actually be guaranteed by the standard: 
https://en.cppreference.com/w/cpp/memory/unique_ptr/swap2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83877



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


[PATCH] D83621: [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json

2020-07-15 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 278230.
ArcsinX added a comment.

Update comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83621

Files:
  clang/lib/Tooling/FileMatchTrie.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -281,6 +281,15 @@
   EXPECT_EQ("Cannot resolve relative paths", Error);
 }
 
+TEST_F(FileMatchTrieTest, SingleFile) {
+  Trie.insert("/root/RootFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+  // Add subpath to avoid `if (Children.empty())` special case
+  // which we hit at previous `find()`.
+  Trie.insert("/root/otherpath/OtherFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+}
+
 TEST(findCompileArgsInJsonDatabase, FindsNothingIfEmpty) {
   std::string ErrorMessage;
   CompileCommand NotFound = findCompileArgsInJsonDatabase(
Index: clang/lib/Tooling/FileMatchTrie.cpp
===
--- clang/lib/Tooling/FileMatchTrie.cpp
+++ clang/lib/Tooling/FileMatchTrie.cpp
@@ -105,8 +105,13 @@
StringRef FileName,
bool ,
unsigned ConsumedLength = 0) const {
+// Note: we support only directory symlinks for performance reasons.
 if (Children.empty()) {
-  if (Comparator.equivalent(StringRef(Path), FileName))
+  // As far as we do not support file symlinks, compare
+  // basenames here to avoid request to file system.
+  if (llvm::sys::path::filename(Path) ==
+  llvm::sys::path::filename(FileName) &&
+  Comparator.equivalent(StringRef(Path), FileName))
 return StringRef(Path);
   return {};
 }
@@ -121,6 +126,13 @@
   if (!Result.empty() || IsAmbiguous)
 return Result;
 }
+
+// If `ConsumedLength` is zero, this is the root and we have no filename
+// match. Give up in this case, we don't try to find symlinks with
+// different names.
+if (ConsumedLength == 0)
+  return {};
+
 std::vector AllChildren;
 getAll(AllChildren, MatchingChild);
 StringRef Result;


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -281,6 +281,15 @@
   EXPECT_EQ("Cannot resolve relative paths", Error);
 }
 
+TEST_F(FileMatchTrieTest, SingleFile) {
+  Trie.insert("/root/RootFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+  // Add subpath to avoid `if (Children.empty())` special case
+  // which we hit at previous `find()`.
+  Trie.insert("/root/otherpath/OtherFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+}
+
 TEST(findCompileArgsInJsonDatabase, FindsNothingIfEmpty) {
   std::string ErrorMessage;
   CompileCommand NotFound = findCompileArgsInJsonDatabase(
Index: clang/lib/Tooling/FileMatchTrie.cpp
===
--- clang/lib/Tooling/FileMatchTrie.cpp
+++ clang/lib/Tooling/FileMatchTrie.cpp
@@ -105,8 +105,13 @@
StringRef FileName,
bool ,
unsigned ConsumedLength = 0) const {
+// Note: we support only directory symlinks for performance reasons.
 if (Children.empty()) {
-  if (Comparator.equivalent(StringRef(Path), FileName))
+  // As far as we do not support file symlinks, compare
+  // basenames here to avoid request to file system.
+  if (llvm::sys::path::filename(Path) ==
+  llvm::sys::path::filename(FileName) &&
+  Comparator.equivalent(StringRef(Path), FileName))
 return StringRef(Path);
   return {};
 }
@@ -121,6 +126,13 @@
   if (!Result.empty() || IsAmbiguous)
 return Result;
 }
+
+// If `ConsumedLength` is zero, this is the root and we have no filename
+// match. Give up in this case, we don't try to find symlinks with
+// different names.
+if (ConsumedLength == 0)
+  return {};
+
 std::vector AllChildren;
 getAll(AllChildren, MatchingChild);
 StringRef Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ef30a00 - [NFC] Add float aggregate ABI test for PowerPC

2020-07-15 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2020-07-16T00:11:09+08:00
New Revision: ef30a00a57c78a91571a66555f2531af0f1f51e5

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

LOG: [NFC] Add float aggregate ABI test for PowerPC

4c5a93bd landed adjustment to handle C++20 no_unique_address attribute
correctly, clang treats empty members in aggregate type differently if
having this attribute. This commit adds necessary test for PowerPC
target to reflect this change.

Added: 
clang/test/CodeGen/ppc-aggregate-abi.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/ppc-aggregate-abi.cpp 
b/clang/test/CodeGen/ppc-aggregate-abi.cpp
new file mode 100644
index ..94afb6ab9e17
--- /dev/null
+++ b/clang/test/CodeGen/ppc-aggregate-abi.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -x c++ \
+// RUN:   -o - %s | FileCheck %s -check-prefix=CHECK-BE
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm -x c++ \
+// RUN:   -o - %s | FileCheck %s -check-prefix=CHECK-LE
+
+class agg_float_class { float a; };
+// CHECK-BE-LABEL: define void 
@_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret 
align 4 %{{.*}}, float inreg %{{.*}})
+// CHECK-LE-LABEL: define [1 x float] 
@_Z20pass_agg_float_class15agg_float_class(float inreg %{{.*}})
+agg_float_class pass_agg_float_class(agg_float_class arg) { return arg; }
+
+class agg_double_class { double a; };
+// CHECK-BE-LABEL: define void 
@_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias 
sret align 8 %{{.*}}, double inreg %{{.*}})
+// CHECK-LE-LABEL: define [1 x double] 
@_Z21pass_agg_double_class16agg_double_class(double inreg %{{.*}})
+agg_double_class pass_agg_double_class(agg_double_class arg) { return arg; }
+
+struct agg_float_cpp { float a; int : 0; };
+// CHECK-BE-LABEL: define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, float inreg %{{.*}})
+// CHECK-LE-LABEL: define [1 x float] 
@_Z18pass_agg_float_cpp13agg_float_cpp(float inreg %{{.*}})
+agg_float_cpp pass_agg_float_cpp(agg_float_cpp arg) { return arg; }
+
+struct empty { };
+struct agg_nofloat_empty { float a; empty dummy; };
+// CHECK-BE-LABEL: define void 
@_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* 
noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// CHECK-LE-LABEL: define i64 
@_Z22pass_agg_nofloat_empty17agg_nofloat_empty(i64 %{{.*}})
+agg_nofloat_empty pass_agg_nofloat_empty(agg_nofloat_empty arg) { return arg; }
+
+struct agg_float_empty { float a; [[no_unique_address]] empty dummy; };
+// CHECK-BE-LABEL: define void 
@_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias 
sret align 4 %{{.*}}, float inreg %{{.*}})
+// CHECK-LE-LABEL: define [1 x float] 
@_Z20pass_agg_float_empty15agg_float_empty(float inreg %{{.*}})
+agg_float_empty pass_agg_float_empty(agg_float_empty arg) { return arg; }
+
+struct agg_nofloat_emptyarray { float a; [[no_unique_address]] empty dummy[3]; 
};
+// CHECK-BE-LABEL: define void 
@_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray*
 noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// CHECK-LE-LABEL: define i64 
@_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(i64 %{{.*}})
+agg_nofloat_emptyarray pass_agg_nofloat_emptyarray(agg_nofloat_emptyarray arg) 
{ return arg; }
+
+struct noemptybase { empty dummy; };
+struct agg_nofloat_emptybase : noemptybase { float a; };
+// CHECK-BE-LABEL: define void 
@_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase*
 noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// CHECK-LE-LABEL: define i64 
@_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(i64 %{{.*}})
+agg_nofloat_emptybase pass_agg_nofloat_emptybase(agg_nofloat_emptybase arg) { 
return arg; }
+
+struct emptybase { [[no_unique_address]] empty dummy; };
+struct agg_float_emptybase : emptybase { float a; };
+// CHECK-BE-LABEL: define void 
@_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* 
noalias sret align 4 %{{.*}}, float inreg %{{.*}})
+// CHECK-LE-LABEL: define [1 x float] 
@_Z24pass_agg_float_emptybase19agg_float_emptybase(float inreg %{{.*}})
+agg_float_emptybase pass_agg_float_emptybase(agg_float_emptybase arg) { return 
arg; }
+
+struct noemptybasearray { [[no_unique_address]] empty dummy[3]; };
+struct agg_nofloat_emptybasearray : noemptybasearray { float a; };
+// CHECK-BE-LABEL: define void 
@_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray*
 noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// CHECK-LE-LABEL: define i64 
@_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(i64 %{{.*}})

[PATCH] D83836: [Analyzer] Implementing checkRegionChanges for SmartPtrModeling

2020-07-15 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:97
 
+// If a region is removed all of the subregions needs to be removed too.
+static ProgramStateRef removeTrackedRegions(ProgramStateRef State,

nit: *need to be removed



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:98
+// If a region is removed all of the subregions needs to be removed too.
+static ProgramStateRef removeTrackedRegions(ProgramStateRef State,
+const MemRegion *Region) {

Maybe `Subregions` would fit better in this name then?



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:186
+  for (const auto *Region : Regions)
+State = removeTrackedRegions(State, Region->getBaseRegion());
+  return State;

It is not critical, but potentially we can allocate/deallocate a whole bunch of 
states here.  We can do the same sort of operation with the map itself 
(`State->get()`), which still have similar problem but to a 
lesser degree.  Additionally, this `get` method is not compile-time, 
it searches for the corresponding map in runtime (also in a map), so you repeat 
that as many times as you have `Regions`.

And super-duper over-optimization note on my part: making the loop over 
`Regions` to be the inner-most is more cache-friendly.  It is not really 
critical here, but it is overall good to have an eye for things like that.



Comment at: clang/test/Analysis/smart-ptr.cpp:190
+/*
+// TODO: Enable this test after '=' operator overloading modeling.
+void derefAfterAssignment() {

Usually we simply add the test with expectations matching current state of 
things, but add a TODO over those particular lines. This way when you fix the 
issue the test will start failing and you won't forget to uncomment it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83836



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


[PATCH] D83550: [PATCH 1/4][Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute

2020-07-15 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 278218.
c-rhodes edited the summary of this revision.
c-rhodes added a comment.
Herald added a subscriber: dang.

Added `-msve-vector-bits=` flag. If specified the 
`__ARM_FEATURE_SVE_BITS__EXPERIMENTAL` macro is defined and a language option 
`ArmSveVectorBits` is set. The language option replaces the macro parsing in 
SemaType for the attributed type and the macro tests have been removed. Now 
that the `-msve-vector-bits` flag is implemented in this patch, the final patch 
in the series is intended to make the feature macro non-experimental.


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

https://reviews.llvm.org/D83550

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Driver/aarch64-sve-vector-bits.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Sema/attr-arm-sve-vector-bits.c

Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- /dev/null
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -0,0 +1,44 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=128 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=256 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=1024 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=2048 -fallow-half-arguments-and-returns %s
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS__EXPERIMENTAL
+
+// Define valid fixed-width SVE types
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint16_t fixed_int16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svuint8_t fixed_uint8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint16_t fixed_uint16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint32_t fixed_uint32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint64_t fixed_uint64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svfloat16_t fixed_float16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat32_t fixed_float32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbfloat16_t fixed_bfloat16_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
+
+// Attribute must have a single argument
+typedef svint8_t no_argument __attribute__((arm_sve_vector_bits)); // expected-error {{'arm_sve_vector_bits' attribute takes one argument}}
+typedef svint8_t two_arguments __attribute__((arm_sve_vector_bits(2, 4))); // expected-error {{'arm_sve_vector_bits' attribute takes one argument}}
+
+// The number of SVE vector bits must be an integer constant expression
+typedef svint8_t non_int_size1 __attribute__((arm_sve_vector_bits(2.0)));   // expected-error {{'arm_sve_vector_bits' attribute requires an integer constant}}
+typedef svint8_t non_int_size2 __attribute__((arm_sve_vector_bits("256"))); // expected-error {{'arm_sve_vector_bits' attribute requires an integer constant}}
+
+// Attribute must be attached to a single SVE vector or predicate type.
+typedef void *badtype1 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'void *'}}
+typedef int badtype2 __attribute__((arm_sve_vector_bits(N)));   // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'int'}}
+typedef float badtype3 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'float'}}
+typedef svint8x2_t badtype4 __attribute__((arm_sve_vector_bits(N)));// expected-error 

[PATCH] D83877: [Analyzer] Changed in SmartPtrModeling to handle Swap

2020-07-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/test/Analysis/Inputs/system-header-simulator-cxx.h:964-965
+
+  template 
+  void swap(unique_ptr , unique_ptr ) noexcept {
+x.swap(y);

You seem to be relying on the fact that global `std::swap` is implemented in 
terms of the member `std::swap`. That's an implementation detail of the 
standard library; i'm not sure that this is always the case. Ideally we should 
model the global `std::swap` separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83877



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


[PATCH] D83772: [Windows] Fix limit on command line size

2020-07-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 278221.
sepavloff added a comment.

Fixed unit test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83772

Files:
  llvm/include/llvm/Support/Program.h
  llvm/lib/Support/Windows/Program.inc
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -763,6 +763,18 @@
 TEST(CommandLineTest, ArgumentLimit) {
   std::string args(32 * 4096, 'a');
   EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
+  std::string args2(256, 'a');
+  EXPECT_TRUE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args2.data()));
+  if (Triple(sys::getProcessTriple()).isOSWindows()) {
+// We use 32000 as a limit for command line length. Program name ('cl'),
+// separating spaces and termination null character occupy 5 symbols.
+std::string long_arg(32000 - 5, 'b');
+EXPECT_TRUE(
+llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data()));
+long_arg += 'b';
+EXPECT_FALSE(
+llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data()));
+  }
 }
 
 TEST(CommandLineTest, ResponseFileWindows) {
Index: llvm/lib/Support/Windows/Program.inc
===
--- llvm/lib/Support/Windows/Program.inc
+++ llvm/lib/Support/Windows/Program.inc
@@ -189,7 +189,14 @@
   // Windows wants a command line, not an array of args, to pass to the new
   // process.  We have to concatenate them all, while quoting the args that
   // have embedded spaces (or are empty).
-  std::string Command = flattenWindowsCommandLine(Args);
+  auto Result = flattenWindowsCommandLine(Args);
+  if (std::error_code ec = Result.getError()) {
+SetLastError(ec.value());
+MakeErrMsg(ErrMsg,
+   std::string("Unable to convert command-line to UTF-16"));
+return false;
+  }
+  std::wstring Command = *Result;
 
   // The pointer to the environment block for the new process.
   std::vector EnvBlock;
@@ -271,14 +278,8 @@
 return false;
   }
 
-  SmallVector CommandUtf16;
-  if (std::error_code ec = windows::UTF8ToUTF16(Command, CommandUtf16)) {
-SetLastError(ec.value());
-MakeErrMsg(ErrMsg,
-   std::string("Unable to convert command-line to UTF-16"));
-return false;
-  }
-
+  std::vector CommandUtf16(Command.size() + 1, 0);
+  std::copy(Command.begin(), Command.end(), CommandUtf16.begin());
   BOOL rc = CreateProcessW(ProgramUtf16.data(), CommandUtf16.data(), 0, 0,
TRUE, CREATE_UNICODE_ENVIRONMENT,
EnvBlock.empty() ? 0 : EnvBlock.data(), 0, ,
@@ -376,7 +377,7 @@
 }
 
 namespace llvm {
-std::string sys::flattenWindowsCommandLine(ArrayRef Args) {
+ErrorOr sys::flattenWindowsCommandLine(ArrayRef Args) {
   std::string Command;
   for (StringRef Arg : Args) {
 if (argNeedsQuotes(Arg))
@@ -387,7 +388,11 @@
 Command.push_back(' ');
   }
 
-  return Command;
+  SmallVector CommandUtf16;
+  if (std::error_code ec = windows::UTF8ToUTF16(Command, CommandUtf16))
+return ec;
+
+  return std::wstring(CommandUtf16.begin(), CommandUtf16.end());
 }
 
 ProcessInfo sys::Wait(const ProcessInfo , unsigned SecondsToWait,
@@ -532,12 +537,16 @@
 
 bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
   ArrayRef Args) {
-  // The documented max length of the command line passed to CreateProcess.
-  static const size_t MaxCommandStringLength = 32768;
+  // The documentation on CreateProcessW states that the size of the argument
+  // lpCommandLine must not be greater than 32767 characters, including the
+  // Unicode terminating null character. We use smaller value to reduce risk
+  // of getting invalid command line due to unaccounted factors.
+  static const size_t MaxCommandStringLength = 32000;
   SmallVector FullArgs;
   FullArgs.push_back(Program);
   FullArgs.append(Args.begin(), Args.end());
-  std::string Result = flattenWindowsCommandLine(FullArgs);
-  return (Result.size() + 1) <= MaxCommandStringLength;
+  auto Result = flattenWindowsCommandLine(FullArgs);
+  assert(!Result.getError());
+  return (Result->size() + 1) <= MaxCommandStringLength;
 }
 }
Index: llvm/include/llvm/Support/Program.h
===
--- llvm/include/llvm/Support/Program.h
+++ llvm/include/llvm/Support/Program.h
@@ -218,7 +218,7 @@
   /// to build a single flat command line appropriate for calling CreateProcess
   /// on
   /// Windows.
-  std::string flattenWindowsCommandLine(ArrayRef Args);
+  ErrorOr flattenWindowsCommandLine(ArrayRef Args);
 #endif
   }
 }
___
cfe-commits mailing list

[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9566
+MEHandler.generateAllInfo(BasePointers, Pointers, Sizes, MapTypes,
+  CapturedVarSet, /*PresentModifierOnly=*/true);
 

jdenny wrote:
> ABataev wrote:
> > jdenny wrote:
> > > In today's OpenMP/LLVM call, it was pointed out that this issue 
> > > represents a general Clang bug for map clauses: map clauses generally 
> > > shouldn't be ignored just because their variables aren't referenced in 
> > > the construct.
> > > 
> > > Here, I tried to handle this issue only in the case of a `present` 
> > > modifier because I previously didn't consider whether the existing 
> > > behavior for other map types was a bug.  My solution here was similar to 
> > > what's done for `omp target data`, which doesn't have captures at all.  
> > > Perhaps, this should generalized to other map types.
> > > 
> > > Another possibility might be to expand what's captured in Sema.
> > It must be fixed in a separate patch. We definitely should not modify sema 
> > here, just the codegen. Currently, it iterates through all captures in 
> > region, also need to iterate through the explicit maps.
> Thanks for the response.  I'd be happy to generalize and extract into a new 
> patch.
> 
> It looks like all I need to extract is the changes to `generateAllInfo` and 
> `emitTargetCall` except I wouldn't have the `PresentModifierOnly` 
> restriction.  Of course, I would need to add tests.  Does all that sound 
> about right?  If so, I'll work on it.
Yes, something like this. Most probably, you won't need to add new tests, just 
modify the existing ones.


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

https://reviews.llvm.org/D83061



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D83501#2148671 , @dgoldman wrote:

> I implemented goto-definition from Foo() --> Foo impl in Xrefs, on the 
> symbolcollector side I don't think there's anything to do?


This can't be done purely in xrefs as the AST may not be available.

A.m: `@class Foo; ^Foo x;` <-- go-to-definition at ^
B.m: `@interface Foo...@end @implementation Foo...@end`

The index needs to know that for the USR associated with the @class (found by 
targetDecl), the canonical decl is the @interface in B and the definition is 
the @implementation in B.
So SymbolCollector needs to see it as a definition. **The tests seem to show it 
does already**, but it's not obvious why from the code. Do you know? Maybe it's 
the fact that they share a USR and thus a symbol ID. This is worth making 
explicit somewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[clang] d6e79e3 - [OpenMP][Docs] Update `present` map type modifier status

2020-07-15 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-15T11:17:00-04:00
New Revision: d6e79e3dd6df63425eb098f482be2c9744ad48eb

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

LOG: [OpenMP][Docs] Update `present` map type modifier status

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 000f23141af3..26fbfab96bc8 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,5 +268,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`claimed`  | 
  |
+| device extension | 'present' map type modifier   
   | :part:`worked on`| D83061, D83062  
  |
 
+--+--+--+---+



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


[PATCH] D83621: [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json

2020-07-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Hmm, there is actually a case the old behavior may have been papering over: 
case-insensitive filesystems. If the real file is foo.cc and we query Foo.cc, 
then the trie would (inefficiently) return the correct file.
It may be a good idea to make the trie case-insensitive for this purpose, but 
maybe we should wait until someone complains. That's a different patch, anyway.




Comment at: clang/lib/Tooling/FileMatchTrie.cpp:111
+  // As far as we do not support file symlinks we compare
+  // basenames here to avoid expensive request to file system.
+  if (llvm::sys::path::filename(Path) ==

Here it's really just for consistency - we have a single candidate, and calling 
equivalent() on a single file isn't expensive. I'd be happy with or without 
this check, but the comment should mention consistency.



Comment at: clang/lib/Tooling/FileMatchTrie.cpp:131
+// We failed to find the file with `Children.find()`.
+// If `ConsumedLength` is equal to 0 then we have tried to find the file
+// with it's basename. Thus, we do not have files with the same

nit: This is quite a lot of words to come to "we do not support file symlinks" 
- I think it could be a bit shorter and also get into motivation:

"If `ConsumedLength` is zero, this is the root and we have no filename match. 
Give up in this case, we don't try to find symlinks with different names".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83621



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


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

2020-07-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D79219#2152747 , @labath wrote:

> I wouldn't mind separate (internal) cache variable, though I am somewhat 
> surprised by this problem. A (non-cache) variable set in one of the parent 
> scopes should still take precedence over a cache variable with the same name. 
> And since config-ix.cmake is included from the top CMakeLists.txt, the value 
> it defines should be available everywhere. Was this a problem for the regular 
> build, or only for some of the more exotic build setups that don't start with 
> llvm/CMakeLists.txt ?


Never mind, it's working as expected. The problem is that we disable zlib 
detection on Windows which I missed before. I'm not sure why that's the case, I 
tested this on Windows and it seems to be working fine, but for now I've kept 
the existing behavior, we can consider enabling zlib on Windows in a follow up 
change.


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

https://reviews.llvm.org/D79219



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


  1   2   3   >