[PATCH] D105858: opencl-c.h: add 3.0 optional extension support for a few more bits

2021-08-05 Thread Dave Airlie via Phabricator via cfe-commits
airlied updated this revision to Diff 364372.
airlied added a comment.

Added a comment on the subgroups difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105858

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -16011,7 +16011,7 @@
 
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_work_group_collective_functions)
 int __ovld __conv work_group_all(int predicate);
 int __ovld __conv work_group_any(int predicate);
 
@@ -16109,12 +16109,12 @@
 double __ovld __conv work_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif //defined(__opencl_c_work_group_collective_functions)
 
 // OpenCL v2.0 s6.13.16 - Pipe Functions
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_pipes)
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif //defined(__opencl_c_pipes)
 
 
 // OpenCL v2.0 s6.13.17 - Enqueue Kernels
@@ -16151,7 +16151,7 @@
 
 // OpenCL Extension v2.0 s9.17 - Sub-groups
 
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || 
defined(__opencl_c_subgroups)
 // Shared Sub Group Functions
 uint__ovld get_sub_group_size(void);
 uint__ovld get_max_sub_group_size(void);
@@ -16250,7 +16250,7 @@
 double  __ovld __conv sub_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //cl_khr_subgroups cl_intel_subgroups
+#endif //cl_khr_subgroups cl_intel_subgroups __opencl_c_subgroups
 
 #if defined(cl_khr_subgroup_extended_types)
 char __ovld __conv sub_group_broadcast( char value, uint index );
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -333,7 +333,13 @@
   memory_scope_all_devices = memory_scope_all_svm_devices,
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0
 #endif // defined(__opencl_c_atomic_scope_all_devices)
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+/**
+ * Subgroups have different requirements on forward progress, so just test
+ * all the relevant macros.
+ * CL 3.0 sub-groups "they are not guaranteed to make independent forward 
progress"
+ * KHR subgroups "Subgroups within a workgroup are independent, make forward 
progress with respect to each other"
+ */
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || 
defined(__opencl_c_subgroups)
   memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
 #endif
 } memory_scope;


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -16011,7 +16011,7 @@
 
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_work_group_collective_functions)
 int __ovld __conv work_group_all(int predicate);
 int __ovld __conv work_group_any(int predicate);
 
@@ -16109,12 +16109,12 @@
 double __ovld __conv work_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_work_group_collective_functions)
 
 // OpenCL v2.0 s6.13.16 - Pipe Functions
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_pipes)
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_pipes)
 
 
 // OpenCL v2.0 s6.13.17 - Enqueue Kernels
@@ -16151,7 +16151,7 @@
 
 // OpenCL Extension v2.0 s9.17 - Sub-groups
 
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || defined(__opencl_c_subgroups)
 // Shared Sub Group Functions
 uint__ovld get_sub_group_size(void);
 uint__ovld get_max_sub_group_size(void);
@@ -16250,7 +16250,7 @@
 double  __ovld __conv sub_group_scan_inclusive_max(double x);
 #endif //cl_khr_fp64
 
-#endif //cl_khr_subgroups cl_intel_subgroups
+#endif //cl_khr_subgroups cl_intel_subgroups __opencl_c_subgroups
 
 #if defined(cl_khr_subgroup_extended_types)
 char __ovld __conv sub_group_broadcast( char value, uint index );
Index: clang/lib/Headers/opencl-c-base.h
==

[PATCH] D105881: [flang][driver] Refactor boolean options

2021-08-05 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

In D105881#2926523 , @awarzynski 
wrote:

> Yes. Updating printHelp 
> 
>  wouldn't be too difficult. Would you be in favor?

Yes, I think that would make stuff a bit easier to understand.

> I've experimented with a few more approaches and feel that the cleanest 
> approach would be to:
>
> - rename `OptOutFFlag`/`OptInFFlag` as `OptOutCC1FFlag` and `OptInCC1FFlag`
> - introduce `OptOutFC1FFlag` and `OptInFC1FFlag`.
>
> We will end-up with a bit of duplication in Options.td, but the long term 
> goal is to split it into multiple files anyway. Also, I think that in this 
> case code re-use would lead to a rather convoluted implementation. I'm will 
> send an updated patch shortly.

That sounds good to me.

Thanks for seeing this through! LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105881

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


[PATCH] D106823: [analyzer][solver] Iterate to a fixpoint during symbol simplification with constants

2021-08-05 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 4 inline comments as done.
martong added a comment.

Thanks for the review!




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2112-2113
+  assert(ClsMembers.contains(Old));
+  assert(ClsMembers.getHeight() > 1 &&
+ "Class should have at least two members");
+

vsavchenko wrote:
> Maybe after removing you can check that `ClsMembers` is not empty?
> I just don't like relying on `getHeight` because it looks like an 
> implementation detail and shouldn't be used.  We use it only in one place in 
> the whole codebase (in equivalence classes :) ), but since we can re-write 
> this assertion to have a simpler condition, I think that it should be 
> preferred.
Okay, I've also found it inconvenient to use `getHeight` but the API of 
immutable maps is quite sparse, I mean there is no way to query the size. The 
solution you suggest is better in the sense we don't have to use the internal 
API, so I've changed it that way, though, it has the disadvantage that we must 
check the precondition of the function in the middle of it which is weird to 
read. 
What about having a free function that takes a tree as a param and returns 
whether it has two members? Or we could even extend the API of the immutable 
AVL  tree with a new member function.



Comment at: 
clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp:20
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_printState();
+

vsavchenko wrote:
> Do we need to print states in this test?
Good point, I've accidentally left it here.



Comment at: 
clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp:32
+  // CHECK-NEXT:   "equivalence_classes": [
+  // CHECK-NEXT: [ "(reg_$0) != (reg_$2)" ],
+  // CHECK-NEXT: [ "reg_$0", "reg_$2" ]

vsavchenko wrote:
> Same question here
> OK, I understand the next two classes. But how did we produce this one?

Simplification is done on each equivalence class we can find in the state, no 
matter if they are non-trivial or trivial classes.

Here is what happens in this case: We skim through the constraints and try to 
simplify all equivalence classes there. During this we start simplifying the 
trivial equivalence class `((reg_$0) + (reg_$1)) != (reg_$2)`. The first and only member of this class can be simplified with 
`(reg_$0) != (reg_$2)` because `b==0`. Now, we merge the two 
trivial classes of the original non-simplified and the new simplified symbols. 
At this point we receive a non-trivial class with two members: `((reg_$0) + (reg_$1)) != (reg_$2)` and `(reg_$0) != (reg_$2)`. And then we remove the old symbol from the class. That results in a 
non-trivial class with one member: `(reg_$0) != (reg_$2)`.



Comment at: 
clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp:36
+  // CHECK-NEXT:  "equivalence_classes": [
+  // CHECK-NEXT:[ "(reg_$0) != (reg_$3)" ],
+  // CHECK-NEXT:[ "reg_$0", "reg_$3" ],

vsavchenko wrote:
> OK, I understand the next two classes.
> But how did we produce this one?
I am giving an answer to this in the previous test file, because that case is 
shorter and easier to explain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106823

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


[PATCH] D106823: [analyzer][solver] Iterate to a fixpoint during symbol simplification with constants

2021-08-05 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 364373.
martong marked 4 inline comments as done.
martong edited the summary of this revision.
martong added a comment.

- Remove superfluous clang_analyzer_printState
- Assert on isEmpty instead of using getHeight


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106823

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/expr-inspection-printState-eq-classes.c
  clang/test/Analysis/symbol-simplification-disequality-info.cpp
  
clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
  clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
  clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp

Index: clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-two-iterations.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   2>&1 | FileCheck %s
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint. This should be done after TWO iterations.
+
+void clang_analyzer_printState();
+
+void test(int a, int b, int c, int d) {
+  if (a + b + c != d)
+return;
+  if (c + b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:  "constraints": [
+  // CHECK-NEXT:   { "symbol": "(((reg_$0) + (reg_$1)) + (reg_$2)) != (reg_$3)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:   { "symbol": "(reg_$2) + (reg_$1)", "range": "{ [0, 0] }" }
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "equivalence_classes": [
+  // CHECK-NEXT:   [ "((reg_$0) + (reg_$1)) + (reg_$2)", "reg_$3" ]
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Simplification starts here.
+  if (b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:   "constraints": [
+  // CHECK-NEXT:{ "symbol": "(reg_$0) != (reg_$3)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:{ "symbol": "reg_$1", "range": "{ [0, 0] }" },
+  // CHECK-NEXT:{ "symbol": "reg_$2", "range": "{ [0, 0] }" }
+  // CHECK-NEXT:  ],
+  // CHECK-NEXT:  "equivalence_classes": [
+  // CHECK-NEXT:[ "(reg_$0) != (reg_$3)" ],
+  // CHECK-NEXT:[ "reg_$0", "reg_$3" ],
+  // CHECK-NEXT:[ "reg_$2" ]
+  // CHECK-NEXT:  ],
+  // CHECK-NEXT:  "disequality_info": null,
+
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c * d);
+  return;
+}
Index: clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-one-iteration.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   2>&1 | FileCheck %s
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint. This should be done after one iteration.
+
+void clang_analyzer_printState();
+
+void test(int a, int b, int c) {
+  if (a + b != c)
+return;
+  clang_analyzer_printState();
+  // CHECK:  "constraints": [
+  // CHECK-NEXT:   { "symbol": "((reg_$0) + (reg_$1)) != (reg_$2)", "range": "{ [0, 0] }" }
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "equivalence_classes": [
+  // CHECK-NEXT:   [ "(reg_$0) + (reg_$1)", "reg_$2" ]
+  // CHECK-NEXT: ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Simplification starts here.
+  if (b != 0)
+return;
+  clang_analyzer_printState();
+  // CHECK:"constraints": [
+  // CHECK-NEXT: { "symbol": "(reg_$0) != (reg_$2)", "range": "{ [0, 0] }" },
+  // CHECK-NEXT: { "symbol": "reg_$1", "range": "{ [0, 0] }" }
+  // CHECK-NEXT:   ],
+  // CHECK-NEXT:   "equivalence_classes": [
+  // CHECK-NEXT: [ "(reg_$0) != (reg_$2)" ],
+  // CHECK-NEXT: [ "reg_$0", "reg_$2" ]
+  // CHECK-NEXT:   ],
+  // CHECK-NEXT: "disequality_info": null,
+
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c);
+  return;
+}
Index: clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify
+
+// In this test we check whether the solver's symbol simplification mechanism
+// is capable of reaching a fixpoint.
+
+void clang_analyzer_warnIfReached();
+
+void test_contradiction(int a, int b, int c, int d, int x) {
+  if (a + b + c != d)
+return;
+  if (a == d)
+return;

[clang] 39dac1f - [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Anshil Gandhi via cfe-commits

Author: Anshil Gandhi
Date: 2021-08-05T02:08:06-06:00
New Revision: 39dac1f7f65691487dbdc969e343108db5b0f765

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

LOG: [clang] Add clang builtins support for gfx90a

Implement target builtins for gfx90a including fadd64, fadd32, add2h,
max and min on various global, flat and ds address spaces for which
intrinsics are implemented.

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

Added: 
clang/test/CodeGenOpenCL/builtins-amdgcn-fp-atomics-gfx7-err.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-fp-atomics-gfx908-err.cl
clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx1030.cl
clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 3570431d952cb..2e1d3c7ccbff9 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -196,6 +196,19 @@ TARGET_BUILTIN(__builtin_amdgcn_perm, "UiUiUiUi", "nc", 
"gfx8-insts")
 
 TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "", "nc", "gfx9-insts")
 
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f64, "dd*1d", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f32, "ff*1f", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2f16, "V2hV2h*1V2h", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fmin_f64, "dd*1d", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fmax_f64, "dd*1d", "t", 
"gfx90a-insts")
+
+TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_f64, "dd*0d", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fmin_f64, "dd*0d", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fmax_f64, "dd*0d", "t", 
"gfx90a-insts")
+
+TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f64, "dd*3d", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f32, "ff*3f", "t", "gfx8-insts")
+
 
//===--===//
 // Deep learning builtins.
 
//===--===//

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b316a865f2fc7..606689385199a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16197,6 +16197,74 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
 Src0 = Builder.CreatePointerBitCastOrAddrSpaceCast(Src0, PTy);
 return Builder.CreateCall(F, { Src0, Src1, Src2, Src3, Src4 });
   }
+  case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f64:
+  case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f32:
+  case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2f16:
+  case AMDGPU::BI__builtin_amdgcn_global_atomic_fmin_f64:
+  case AMDGPU::BI__builtin_amdgcn_global_atomic_fmax_f64:
+  case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_f64:
+  case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmin_f64:
+  case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmax_f64: {
+Intrinsic::ID IID;
+llvm::Type *ArgTy = llvm::Type::getDoubleTy(getLLVMContext());
+switch (BuiltinID) {
+case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f32:
+  ArgTy = llvm::Type::getFloatTy(getLLVMContext());
+  IID = Intrinsic::amdgcn_global_atomic_fadd;
+  break;
+case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2f16:
+  ArgTy = llvm::FixedVectorType::get(
+  llvm::Type::getHalfTy(getLLVMContext()), 2);
+  IID = Intrinsic::amdgcn_global_atomic_fadd;
+  break;
+case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f64:
+  IID = Intrinsic::amdgcn_global_atomic_fadd;
+  break;
+case AMDGPU::BI__builtin_amdgcn_global_atomic_fmin_f64:
+  IID = Intrinsic::amdgcn_global_atomic_fmin;
+  break;
+case AMDGPU::BI__builtin_amdgcn_global_atomic_fmax_f64:
+  IID = Intrinsic::amdgcn_global_atomic_fmax;
+  break;
+case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_f64:
+  IID = Intrinsic::amdgcn_flat_atomic_fadd;
+  break;
+case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmin_f64:
+  IID = Intrinsic::amdgcn_flat_atomic_fmin;
+  break;
+case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmax_f64:
+  IID = Intrinsic::amdgcn_flat_atomic_fmax;
+  break;
+}
+llvm::Value *Addr = EmitScalarExpr(E->getArg(0));
+llvm::Value *Val = EmitScalarExpr(E->getArg(1));
+llvm::Function *F =
+CGM.getIntrinsic(IID, {ArgTy, Addr->getType(), Val->getType()});
+return Builder.CreateCa

[PATCH] D106862: [clang] Remove misleading assertion in FullSourceLoc

2021-08-05 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Ping.


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

https://reviews.llvm.org/D106862

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


[PATCH] D107539: [OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images

2021-08-05 Thread Dave Airlie via Phabricator via cfe-commits
airlied created this revision.
airlied added a project: clang.
Herald added subscribers: ldrumm, Anastasia, yaxunl.
airlied requested review of this revision.
Herald added a subscriber: cfe-commits.

This wraps the image and rw images usages in the correct macros


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107539

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -11,11 +11,11 @@
 
 #include "opencl-c-base.h"
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_images)
 #ifndef cl_khr_depth_images
 #define cl_khr_depth_images
 #endif //cl_khr_depth_images
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_images)
 
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
 #ifdef cl_khr_3d_image_writes
@@ -15071,6 +15071,7 @@
  * in the description above are undefined.
  */
 
+#if defined(__opencl_c_images)
 float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t sampler, int2 coord);
 float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t sampler, float2 coord);
 
@@ -15255,7 +15256,7 @@
 #endif //cl_khr_fp16
 
 // Image read functions for read_write images
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 float4 __purefn __ovld read_imagef(read_write image1d_t image, int coord);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, int coord);
 uint4 __purefn __ovld read_imageui(read_write image1d_t image, int coord);
@@ -15298,7 +15299,6 @@
 float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, int4 coord, int sample);
 #endif //cl_khr_gl_msaa_sharing
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #ifdef cl_khr_mipmap_image
 float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod);
@@ -15349,7 +15349,6 @@
 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float4 gradientX, float4 gradientY);
 
 #endif //cl_khr_mipmap_image
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
@@ -15360,7 +15359,7 @@
 half4 __purefn __ovld read_imageh(read_write image2d_array_t image, int4 coord);
 half4 __purefn __ovld read_imageh(read_write image1d_buffer_t image, int coord);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_read_write_images
 
 /**
  * Write color value to location specified by coordinate
@@ -16009,6 +16008,8 @@
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #endif
 
+#endif // defined(__opencl_c_images)
+
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
 #if defined(__opencl_c_work_group_collective_functions)
@@ -17247,29 +17248,29 @@
 uint4   __ovld __conv intel_sub_group_block_read4( read_only image2d_t image, int2 coord );
 uint8   __ovld __conv intel_sub_group_block_read8( read_only image2d_t image, int2 coord );
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_images)
 uint__ovld __conv intel_sub_group_block_read(read_write image2d_t image, int2 coord);
 uint2   __ovld __conv intel_sub_group_block_read2(read_write image2d_t image, int2 coord);
 uint4   __ovld __conv intel_sub_group_block_read4(read_write image2d_t image, int2 coord);
 uint8   __ovld __conv intel_sub_group_block_read8(read_write image2d_t image, int2 coord);
-#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif // defined(__opencl_c_images)
 
 uint__ovld __conv intel_sub_group_block_read( const __global uint* p );
 uint2   __ovld __conv intel_sub_group_block_read2( const __global uint* p );
 uint4   __ovld __conv intel_sub_group_block_read4( const __global uint* p );
 uint8   __ovld __conv intel_sub_group_block_read8( const __global uint* p );
 
+#if defined(__opencl_c_images)
 void__ovld __conv intel_sub_group_block_write(write_only image2d_t image, int2 coord, uint data);
 void__ovld __conv intel_sub_group_block_write2(write_only image2d_t image, int2 coord, uint2 data);
 void__ovld __conv intel_sub_group_block_write4(write_only image2d_t image, int2 coord, uint4 data);
 void__ovld __conv intel_sub_group_block_write8(write_only image2d_t image, int2 coord, uint8 data);
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 void__ovld __conv intel_sub_group_block_write(read_write image2d_t image, i

[PATCH] D107540: [OMPBuilder] Clarify CanonicalLoopInfo. NFC.

2021-08-05 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Herald added subscribers: wrengr, Chia-hungDuan, dcaballe, cota, teijeong, 
rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, 
liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, 
rriddle, mehdi_amini, hiraditya.
Herald added a reviewer: ftynse.
Meinersbur requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107540

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -275,10 +275,12 @@
   findAllocaInsertPoint(builder, moduleTranslation);
   llvm::OpenMPIRBuilder::InsertPointTy afterIP;
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
+
+  // TODO: OpenMPIRBuilder::applyWorkshareLoop should take care of the
+  // scheduling clause.
   if (schedule == omp::ClauseScheduleKind::Static) {
-loopInfo = ompBuilder->createStaticWorkshareLoop(ompLoc, loopInfo, allocaIP,
- !loop.nowait(), chunk);
-afterIP = loopInfo->getAfterIP();
+afterIP = ompBuilder->applyStaticWorkshareLoop(
+ompLoc.DL, loopInfo, allocaIP, !loop.nowait(), chunk);
   } else {
 llvm::omp::OMPScheduleType schedType;
 switch (schedule) {
@@ -299,8 +301,8 @@
   break;
 }
 
-afterIP = ompBuilder->createDynamicWorkshareLoop(
-ompLoc, loopInfo, allocaIP, schedType, !loop.nowait(), chunk);
+afterIP = ompBuilder->applyDynamicWorkshareLoop(
+ompLoc.DL, loopInfo, allocaIP, schedType, !loop.nowait(), chunk);
   }
 
   // Continue building IR after the loop.
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1586,6 +1586,7 @@
 CanonicalLoopInfo *Loop =
 OMPBuilder.createCanonicalLoop(Loc, LoopBodyGenCB, StartVal, StopVal,
StepVal, IsSigned, InclusiveStop);
+InsertPointTy AfterIP = Loop->getAfterIP();
 
 // Tile the loop.
 Value *TileSizeVal = ConstantInt::get(LCTy, TileSize);
@@ -1594,7 +1595,7 @@
 
 // Set the insertion pointer to after loop, where the next loop will be
 // emitted.
-Builder.restoreIP(Loop->getAfterIP());
+Builder.restoreIP(AfterIP);
 
 // Extract the trip count.
 CanonicalLoopInfo *FloorLoop = GenLoops[0];
@@ -1663,12 +1664,20 @@
   CanonicalLoopInfo *CLI = OMPBuilder.createCanonicalLoop(
   Loc, LoopBodyGen, StartVal, StopVal, StepVal,
   /*IsSigned=*/false, /*InclusiveStop=*/false);
+  BasicBlock *Preheader = CLI->getPreheader();
+  BasicBlock *Body = CLI->getBody();
+  Value *IV = CLI->getIndVar();
+  BasicBlock *ExitBlock = CLI->getExit();
 
   Builder.SetInsertPoint(BB, BB->getFirstInsertionPt());
   InsertPointTy AllocaIP = Builder.saveIP();
 
-  CLI = OMPBuilder.createStaticWorkshareLoop(Loc, CLI, AllocaIP,
- /*NeedsBarrier=*/true);
+  OMPBuilder.applyStaticWorkshareLoop(DL, CLI, AllocaIP, /*NeedsBarrier=*/true);
+
+  BasicBlock *Cond = Body->getSinglePredecessor();
+  Instruction *Cmp = &*Cond->begin();
+  Value *TripCount = Cmp->getOperand(1);
+
   auto AllocaIter = BB->begin();
   ASSERT_GE(std::distance(BB->begin(), BB->end()), 4);
   AllocaInst *PLastIter = dyn_cast(&*(AllocaIter++));
@@ -1680,10 +1689,8 @@
   EXPECT_NE(PUpperBound, nullptr);
   EXPECT_NE(PStride, nullptr);
 
-  auto PreheaderIter = CLI->getPreheader()->begin();
-  ASSERT_GE(
-  std::distance(CLI->getPreheader()->begin(), CLI->getPreheader()->end()),
-  7);
+  auto PreheaderIter = Preheader->begin();
+  ASSERT_GE(std::distance(Preheader->begin(), Preheader->end()), 7);
   StoreInst *LowerBoundStore = dyn_cast(&*(PreheaderIter++));
   StoreInst *UpperBoundStore = dyn_cast(&*(PreheaderIter++));
   StoreInst *StrideStore = dyn_cast(&*(PreheaderIter++));
@@ -1705,15 +1712,15 @@
 
   // Check that the loop IV is updated to account for the lower bound returned
   // by the OpenMP runtime call.
-  BinaryOperator *Add = dyn_cast(&CLI->getBody()->front());
-  EXPECT_EQ(Add->getOperand(0), CLI->getIndVar());
+  BinaryOperator *Add = dyn_cast(&Body->front());
+  EXPECT_EQ(Add->getOperand(0), IV);
   auto *LoadedLowerBou

[PATCH] D107539: [OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images

2021-08-05 Thread Dave Airlie via Phabricator via cfe-commits
airlied added a subscriber: azabaznov.
airlied added a comment.

Add @azabaznov


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107539

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


[PATCH] D107145: clangd: Add new semantic token modifier "virtual"

2021-08-05 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107145

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


[PATCH] D80878: [clang] Prevent that Decl::dump on a CXXRecordDecl deserialises further declarations.

2021-08-05 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 364385.
teemperor added a comment.

- Make setter propagate 'deserialize' to the node dumper (thanks Volodymyr!)


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

https://reviews.llvm.org/D80878

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/lib/AST/TextNodeDumper.cpp
  clang/test/AST/ast-dump-lambda.cpp
  clang/test/AST/ast-dump-records.cpp
  clang/unittests/AST/ASTDumpTest.cpp
  clang/unittests/AST/CMakeLists.txt

Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -6,6 +6,7 @@
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
+  ASTDumpTest.cpp
   ASTImporterFixtures.cpp
   ASTImporterTest.cpp
   ASTImporterObjCTest.cpp
Index: clang/unittests/AST/ASTDumpTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/ASTDumpTest.cpp
@@ -0,0 +1,182 @@
+//===- unittests/AST/ASTDumpTest.cpp --- Declaration tests ===//
+//
+// 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
+//
+//===--===//
+//
+// Tests Decl::dump().
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceManager.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+namespace clang {
+namespace ast {
+
+namespace {
+/// An ExternalASTSource that asserts if it is queried for information about
+/// any declaration.
+class TrappingExternalASTSource : public ExternalASTSource {
+  ~TrappingExternalASTSource() override = default;
+  bool FindExternalVisibleDeclsByName(const DeclContext *,
+  DeclarationName) override {
+assert(false && "Unexpected call to FindExternalVisibleDeclsByName");
+return true;
+  }
+
+  void FindExternalLexicalDecls(const DeclContext *,
+llvm::function_ref,
+SmallVectorImpl &) override {
+assert(false && "Unexpected call to FindExternalLexicalDecls");
+  }
+
+  void completeVisibleDeclsMap(const DeclContext *) override {
+assert(false && "Unexpected call to completeVisibleDeclsMap");
+  }
+
+  void CompleteRedeclChain(const Decl *) override {
+assert(false && "Unexpected call to CompleteRedeclChain");
+  }
+
+  void CompleteType(TagDecl *) override {
+assert(false && "Unexpected call to CompleteType(Tag Decl*)");
+  }
+
+  void CompleteType(ObjCInterfaceDecl *) override {
+assert(false && "Unexpected call to CompleteType(ObjCInterfaceDecl *)");
+  }
+};
+
+/// An ExternalASTSource that records which DeclContexts were queried so far.
+class RecordingExternalASTSource : public ExternalASTSource {
+public:
+  llvm::DenseSet QueriedDCs;
+  ~RecordingExternalASTSource() override = default;
+
+  void FindExternalLexicalDecls(const DeclContext *DC,
+llvm::function_ref,
+SmallVectorImpl &) override {
+QueriedDCs.insert(DC);
+  }
+};
+
+class ASTDumpTestBase : public ::testing::Test {
+protected:
+  ASTDumpTestBase(clang::ExternalASTSource *Source)
+  : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
+Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
+SourceMgr(Diags, FileMgr), Idents(LangOpts, nullptr),
+Ctxt(LangOpts, SourceMgr, Idents, Sels, Builtins, TU_Complete) {
+Ctxt.setExternalSource(Source);
+  }
+
+  FileSystemOptions FileMgrOpts;
+  FileManager FileMgr;
+  IntrusiveRefCntPtr DiagID;
+  DiagnosticsEngine Diags;
+  SourceManager SourceMgr;
+  LangOptions LangOpts;
+  IdentifierTable Idents;
+  SelectorTable Sels;
+  Builtin::Context Builtins;
+  ASTContext Ctxt;
+};
+
+/// Tests that Decl::dump doesn't load additional declarations from the
+/// ExternalASTSource.
+class NoDeserializeTest : public ASTDumpTestBase {
+protected:
+  NoDeserializeTest() : ASTDumpTestBase(new TrappingExternalASTSource()) {}
+};
+
+/// Tests which declarations Decl::dump deserializes;
+class DeserializeTest : public ASTDumpTestBase {
+protected:
+  DeserializeTest()
+  : ASTDumpTestBase(Recorder = new RecordingExternalASTSource()) {}
+  RecordingExternalASTSource *Recorder;
+};
+} // unnamed namespace
+
+/// Set all flags that activate queries to the ExternalASTSource.
+static void setExternalStorageFlags(DeclContext *DC) {
+  DC->setHasExternalLexicalStorage();
+  DC->setHasExternalVisibleStorage();
+  DC->setMustBuild

[clang] e345b45 - Mark tests as requiring AMDGPU target

2021-08-05 Thread Oliver Stannard via cfe-commits

Author: Oliver Stannard
Date: 2021-08-05T10:02:51+01:00
New Revision: e345b45bf1b5db03f00c3b3612d2653790a2b879

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

LOG: Mark tests as requiring AMDGPU target

Added: 


Modified: 
clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl 
b/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
index 07e3c0944b63d..11854733e153b 100644
--- a/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
+++ b/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
@@ -3,6 +3,8 @@
 // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu 
gfx810 \
 // RUN:   -S -o - %s | FileCheck -check-prefix=GFX8 %s
 
+// REQUIRES: amdgpu-registered-target
+
 // CHECK-LABEL: test_fadd_local
 // CHECK: call float @llvm.amdgcn.ds.fadd.f32(float addrspace(3)* %{{.*}}, 
float %{{.*}}, i32 0, i32 0, i1 false)
 // GFX8-LABEL: test_fadd_local$local:

diff  --git a/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl 
b/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
index f9e44403a679c..198c51fb873ee 100644
--- a/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
+++ b/clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu 
gfx90a \
 // RUN:   -S -o - %s | FileCheck -check-prefix=GFX90A %s
 
+// REQUIRES: amdgpu-registered-target
+
 typedef half __attribute__((ext_vector_type(2))) half2;
 
 // CHECK-LABEL: test_global_add_f64



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


[PATCH] D107366: [analyzer] Adjust JS code of analyzer's HTML report for IE support.

2021-08-05 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko requested changes to this revision.
vsavchenko added a comment.
This revision now requires changes to proceed.

Oh, wait!  I found a bug!


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

https://reviews.llvm.org/D107366

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


[PATCH] D107366: [analyzer] Adjust JS code of analyzer's HTML report for IE support.

2021-08-05 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Now it captures (and makes bold) one extra arrow from the previous note.
Correct example attached!
F18364580: report-e4b488.html 


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

https://reviews.llvm.org/D107366

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


[PATCH] D107366: [analyzer] Adjust JS code of analyzer's HTML report for IE support.

2021-08-05 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:1373
+  var array = [];
+  for (var i = lower; i <= upper; ++i) {
+  array.push(i);

ASDenysPetrov wrote:
> NoQ wrote:
> > Shouldn't it be `i < upper`?
> `[lower, upper).` Sure! Thanks!
And this bug is probably because of this!


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

https://reviews.llvm.org/D107366

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


[PATCH] D107420: [sema] Disallow __builtin_mul_overflow under special condition.

2021-08-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I don't personally care, but i think this diag doesn't make sense.
What is "backend"? Which one? All of them? What happens when one, but not all 
of them supports it?
What if i don't intend to codegen this into an assembly, but only want to 
produce the IR?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107420

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


[PATCH] D107430: [OMPIRBuilder] Add ordered without depend and simd clause to OMPBuilder

2021-08-05 Thread Peixin Qiao via Phabricator via cfe-commits
peixin updated this revision to Diff 364389.
peixin added a comment.

@Meinersbur Thanks for the review.

Removed the typo fixes and gave the alloca register one name.

Also found some typos of invalid case style for variable 'cur' in 
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp and will fix them when pushing 
this patch to main branch.


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

https://reviews.llvm.org/D107430

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/ordered_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -2113,6 +2113,77 @@
   EXPECT_EQ(CriticalEndCI->getArgOperand(2)->getType(), CriticalNamePtrTy);
 }
 
+TEST_F(OpenMPIRBuilderTest, OrderedDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI =
+  Builder.CreateAlloca(F->arg_begin()->getType(), nullptr, "priv.inst");
+
+  BasicBlock *EntryBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock &FiniBB) {
+EntryBB = FiniBB.getUniquePredecessor();
+
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+EXPECT_EQ(EntryBB, CodeGenIPBB);
+
+Builder.restoreIP(CodeGenIP);
+Builder.CreateStore(F->arg_begin(), PrivAI);
+Value *PrivLoad =
+Builder.CreateLoad(PrivAI->getAllocatedType(), PrivAI, "local.use");
+Builder.CreateICmpNE(F->arg_begin(), PrivLoad);
+  };
+
+  auto FiniCB = [&](InsertPointTy IP) {
+BasicBlock *IPBB = IP.getBlock();
+EXPECT_NE(IPBB->end(), IP.getPoint());
+  };
+
+  Builder.restoreIP(OMPBuilder.createOrdered(Builder, BodyGenCB, FiniCB));
+
+  Value *EntryBBTI = EntryBB->getTerminator();
+  EXPECT_EQ(EntryBBTI, nullptr);
+
+  CallInst *OrderedEntryCI = nullptr;
+  for (auto &EI : *EntryBB) {
+Instruction *Cur = &EI;
+if (isa(Cur)) {
+  OrderedEntryCI = cast(Cur);
+  if (OrderedEntryCI->getCalledFunction()->getName() == "__kmpc_ordered")
+break;
+  OrderedEntryCI = nullptr;
+}
+  }
+  EXPECT_NE(OrderedEntryCI, nullptr);
+  EXPECT_EQ(OrderedEntryCI->getNumArgOperands(), 2U);
+  EXPECT_EQ(OrderedEntryCI->getCalledFunction()->getName(), "__kmpc_ordered");
+  EXPECT_TRUE(isa(OrderedEntryCI->getArgOperand(0)));
+
+  CallInst *OrderedEndCI = nullptr;
+  for (auto &FI : *EntryBB) {
+Instruction *Cur = &FI;
+if (isa(Cur)) {
+  OrderedEndCI = cast(Cur);
+  if (OrderedEndCI->getCalledFunction()->getName() == "__kmpc_end_ordered")
+break;
+  OrderedEndCI = nullptr;
+}
+  }
+  EXPECT_NE(OrderedEndCI, nullptr);
+  EXPECT_EQ(OrderedEndCI->getNumArgOperands(), 2U);
+  EXPECT_TRUE(isa(OrderedEndCI->getArgOperand(0)));
+  EXPECT_EQ(OrderedEndCI->getArgOperand(1), OrderedEntryCI->getArgOperand(1));
+}
+
 TEST_F(OpenMPIRBuilderTest, CopyinBlocks) {
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1960,6 +1960,30 @@
   /*Conditional*/ false, /*hasFinalize*/ true);
 }
 
+OpenMPIRBuilder::InsertPointTy
+OpenMPIRBuilder::createOrdered(const LocationDescription &Loc,
+   BodyGenCallbackTy BodyGenCB,
+   FinalizeCallbackTy FiniCB) {
+  if (!updateToLocation(Loc))
+return Loc.IP;
+
+  Directive OMPD = Directive::OMPD_ordered;
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Value *ThreadId = getOrCreateThreadID(Ident);
+  Value *Args[] = {Ident, ThreadId};
+
+  Function *EntryRTLFn = getOrCreateRuntimeFunctionPtr(OMPRTL___kmpc_ordered);
+  Instruction *EntryCall = Builder.CreateCall(EntryRTLFn, Args);
+
+  Function *ExitRTLFn =
+  getOrCreateRuntimeFunctionPtr(OMPRTL___kmpc_end_ordered);
+  Instruction *ExitCall = Builder.CreateCall(ExitRTLFn, Args);
+
+  return EmitOMPInlinedRegion(OMPD, EntryCall, ExitCall, BodyGenCB, FiniCB,
+  /*Conditional*/ false, /*hasFinalize*/ true);
+}
+
 OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::EmitOMPInlinedRegion(
 Directive OMPD, Instruction *EntryCall, Instruction *ExitCall,
 BodyGenCallbackT

[PATCH] D106888: [RISC-V] Implement jump tables for CFI-icall

2021-08-05 Thread Wende Tan via Phabricator via cfe-commits
twd2 added a comment.

Ping?

The build failure is due to the name of the newly introduced 
`kRISCVJumpTableEntrySize`. Though I think we can put these magic numbers (4 
and 8) just into `LowerTypeTestsModule::getJumpTableEntrySize`..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106888

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


[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added a comment.

In D107078#2917892 , @NoQ wrote:

> Y'all writing really good patches lately.

Awesome, thank you!




Comment at: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:397-398
+   Ctx.getLocationContext());
+  Report->addNote("The temporary object gets destroyed at the end of the "
+  "full expression",
+  L);

NoQ wrote:
> This is part of the path, right? We're reporting these bugs at 
> `checkEndFunction` rather than at the store site so the destruction has 
> already happened by the time we report it. In this case it should be a path 
> note, not an extra blue-bubble note.
> 
> As for wording, I suggest `full-expression` with a dash (that's what other 
> clang diagnostics use) and probably drop the initial "The"(?)
> This is part of the path, right? We're reporting these bugs at 
> `checkEndFunction` rather than at the store site so the destruction has 
> already happened by the time we report it. In this case it should be a path 
> note, not an extra blue-bubble note.

I'm not exactly sure how to address this. AFAIK there is no way currently 
detecting the completion of a full-expression.
I was thinking of `Check::RegionChanges`, `Check::PostStmt`, 
`Check::Live`, but none of these fits my needs. Do you have anything specific 
in mind that could help me?

Aside from that, the report looks reasonable even with a 'blue' bubble:
(scan-build): {F18363520}
(CodeChecker): {F18364795}

---

> As for wording, I suggest full-expression with a dash (that's what other 
> clang diagnostics use) and probably drop the initial "The"(?)
I see, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107078

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


[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 364393.
steakhal added a comment.

- `The temporary` -> `Temporary `
- `full expression` -> `full-expression`

I did not fix the extra blue 'bubble' note issue, and I think that is out of 
the scope of this patch.


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

https://reviews.llvm.org/D107078

Files:
  clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  clang/test/Analysis/loop-block-counts.c
  clang/test/Analysis/stack-addr-ps.cpp

Index: clang/test/Analysis/stack-addr-ps.cpp
===
--- clang/test/Analysis/stack-addr-ps.cpp
+++ clang/test/Analysis/stack-addr-ps.cpp
@@ -137,3 +137,28 @@
   }
 }
 
+void write_stack_address_to(char **q) {
+  char local;
+  *q = &local;
+  // expected-warning@-1 {{Address of stack memory associated with local \
+variable 'local' is still referred to by the stack variable 'p' upon \
+returning to the caller}}
+}
+
+void test_stack() {
+  char *p;
+  write_stack_address_to(&p);
+}
+
+struct C {
+  ~C() {} // non-trivial class
+};
+
+C make1() {
+  C c;
+  return c; // no-warning
+}
+
+void test_copy_elision() {
+  C c1 = make1();
+}
Index: clang/test/Analysis/loop-block-counts.c
===
--- clang/test/Analysis/loop-block-counts.c
+++ clang/test/Analysis/loop-block-counts.c
@@ -5,6 +5,9 @@
 void callee(void **p) {
   int x;
   *p = &x;
+  // expected-warning@-1 {{Address of stack memory associated with local \
+variable 'x' is still referred to by the stack variable 'arr' upon \
+returning to the caller}}
 }
 
 void loop() {
Index: clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -71,12 +71,17 @@
   void *allocaPtr;
   int dontGetFilteredByNonPedanticMode = 0;
 
+  // expected-warning-re@+3 {{Address of stack memory allocated by call to \
+alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
+stack upon returning to the caller.  This will be a dangling reference}}
   UntypedAllocaTest() : allocaPtr(__builtin_alloca(sizeof(int))) {
 // All good!
   }
 };
 
 void fUntypedAllocaTest() {
+  // expected-note@+2 {{Temporary object gets destroyed at the end of the \
+full-expression}}
   UntypedAllocaTest();
 }
 
@@ -86,9 +91,14 @@
 
   TypedAllocaTest1() // expected-warning{{1 uninitialized field}}
   : allocaPtr(static_cast(__builtin_alloca(sizeof(int {}
+  // expected-warning-re@-2 {{Address of stack memory allocated by call to \
+alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
+stack upon returning to the caller.  This will be a dangling reference}}
 };
 
 void fTypedAllocaTest1() {
+  // expected-note@+2 {{Temporary object gets destroyed at the end of the \
+full-expression}}
   TypedAllocaTest1();
 }
 
@@ -96,6 +106,9 @@
   int *allocaPtr;
   int dontGetFilteredByNonPedanticMode = 0;
 
+  // expected-warning-re@+5 {{Address of stack memory allocated by call to \
+alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
+stack upon returning to the caller.  This will be a dangling reference}}
   TypedAllocaTest2()
   : allocaPtr(static_cast(__builtin_alloca(sizeof(int {
 *allocaPtr = 5;
@@ -104,6 +117,8 @@
 };
 
 void fTypedAllocaTest2() {
+  // expected-note@+2 {{Temporary object gets destroyed at the end of the \
+full-expression}}
   TypedAllocaTest2();
 }
 
@@ -341,6 +356,9 @@
   void *&&vptrrref; // expected-note {{here}}
 
 public:
+  // expected-warning@+3 {{Address of stack memory associated with local \
+variable 'vptr' is still referred to by a temporary object on the stack \
+upon returning to the caller.  This will be a dangling reference}}
   VoidPointerRRefTest1(void *vptr, char) : vptrrref(static_cast(vptr)) { // expected-warning {{binding reference member 'vptrrref' to stack allocated parameter 'vptr'}}
 // All good!
   }
@@ -349,12 +367,17 @@
 void fVoidPointerRRefTest1() {
   void *vptr = malloc(sizeof(int));
   VoidPointerRRefTest1(vptr, char());
+  // expected-note@-1 {{Temporary object gets destroyed at the end of the \
+full-expression}}
 }
 
 class VoidPointerRRefTest2 {
   void **&&vpptrrref; // expected-note {{here}}
 
 public:
+  // expected-warning@+3 {{Address of stack memory associated with local \
+variable 'vptr' is still referred to by a temporary object on the stack \
+upon returning to the caller.  This will be a dangling reference}}
   VoidPointerRRefTest2(void **vptr, char) : vpptrrref(static_cast(vptr)) { // expected-warning {{binding reference member 'vpptrrref' to stack allocated parameter 'vptr'}}
 // All good!
   }
@@ -363,12 +386,17 @@
 void

[PATCH] D107539: [OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images

2021-08-05 Thread Dave Airlie via Phabricator via cfe-commits
airlied updated this revision to Diff 364395.
airlied added a comment.

found a few more places to replace these and fix them up. there might still be 
some strays in there.


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

https://reviews.llvm.org/D107539

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -11,11 +11,11 @@
 
 #include "opencl-c-base.h"
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_images)
 #ifndef cl_khr_depth_images
 #define cl_khr_depth_images
 #endif //cl_khr_depth_images
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_images)
 
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
 #ifdef cl_khr_3d_image_writes
@@ -15071,6 +15071,7 @@
  * in the description above are undefined.
  */
 
+#if defined(__opencl_c_images)
 float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t sampler, int2 coord);
 float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t sampler, float2 coord);
 
@@ -15255,7 +15256,7 @@
 #endif //cl_khr_fp16
 
 // Image read functions for read_write images
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 float4 __purefn __ovld read_imagef(read_write image1d_t image, int coord);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, int coord);
 uint4 __purefn __ovld read_imageui(read_write image1d_t image, int coord);
@@ -15298,7 +15299,6 @@
 float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, int4 coord, int sample);
 #endif //cl_khr_gl_msaa_sharing
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #ifdef cl_khr_mipmap_image
 float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod);
@@ -15349,7 +15349,6 @@
 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float4 gradientX, float4 gradientY);
 
 #endif //cl_khr_mipmap_image
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
@@ -15360,7 +15359,7 @@
 half4 __purefn __ovld read_imageh(read_write image2d_array_t image, int4 coord);
 half4 __purefn __ovld read_imageh(read_write image1d_buffer_t image, int coord);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_read_write_images
 
 /**
  * Write color value to location specified by coordinate
@@ -15504,7 +15503,7 @@
 #endif //cl_khr_fp16
 
 // Image write functions for read_write images
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 void __ovld write_imagef(read_write image2d_t image, int2 coord, float4 color);
 void __ovld write_imagei(read_write image2d_t image, int2 coord, int4 color);
 void __ovld write_imageui(read_write image2d_t image, int2 coord, uint4 color);
@@ -15536,7 +15535,6 @@
 void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, float color);
 #endif //cl_khr_depth_images
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color);
@@ -15564,7 +15562,6 @@
 #endif //cl_khr_3d_image_writes
 
 #endif //cl_khr_mipmap_image_writes
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15577,7 +15574,7 @@
 void __ovld write_imageh(read_write image2d_array_t image, int4 coord, half4 color);
 void __ovld write_imageh(read_write image1d_buffer_t image, int coord, half4 color);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_read_write_images)
 
 // Note: In OpenCL v1.0/1.1/1.2, image argument of image query builtin functions does not have
 // access qualifier, which by default assume read_only access qualifier. Image query builtin
@@ -15625,7 +15622,7 @@
 int __ovld __cnfn get_image_width(write_only image2d_array_msaa_depth_t image);
 #endif //cl_khr_gl_msaa_sharing
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 int __ovld __cnfn get_image_width(read_write image1d_t image);
 int __ovld __cnfn get_image_width(read_write image1

[PATCH] D107539: [OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images

2021-08-05 Thread Dave Airlie via Phabricator via cfe-commits
airlied updated this revision to Diff 364396.
airlied added a comment.

missed a couple of hunks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107539

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -11,11 +11,11 @@
 
 #include "opencl-c-base.h"
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_images)
 #ifndef cl_khr_depth_images
 #define cl_khr_depth_images
 #endif //cl_khr_depth_images
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_images)
 
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
 #ifdef cl_khr_3d_image_writes
@@ -15071,6 +15071,7 @@
  * in the description above are undefined.
  */
 
+#if defined(__opencl_c_images)
 float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t sampler, int2 coord);
 float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t sampler, float2 coord);
 
@@ -15255,7 +15256,7 @@
 #endif //cl_khr_fp16
 
 // Image read functions for read_write images
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 float4 __purefn __ovld read_imagef(read_write image1d_t image, int coord);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, int coord);
 uint4 __purefn __ovld read_imageui(read_write image1d_t image, int coord);
@@ -15298,7 +15299,6 @@
 float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, int4 coord, int sample);
 #endif //cl_khr_gl_msaa_sharing
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #ifdef cl_khr_mipmap_image
 float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod);
@@ -15349,7 +15349,6 @@
 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float4 gradientX, float4 gradientY);
 
 #endif //cl_khr_mipmap_image
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
@@ -15360,7 +15359,7 @@
 half4 __purefn __ovld read_imageh(read_write image2d_array_t image, int4 coord);
 half4 __purefn __ovld read_imageh(read_write image1d_buffer_t image, int coord);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_read_write_images
 
 /**
  * Write color value to location specified by coordinate
@@ -15504,7 +15503,7 @@
 #endif //cl_khr_fp16
 
 // Image write functions for read_write images
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 void __ovld write_imagef(read_write image2d_t image, int2 coord, float4 color);
 void __ovld write_imagei(read_write image2d_t image, int2 coord, int4 color);
 void __ovld write_imageui(read_write image2d_t image, int2 coord, uint4 color);
@@ -15536,7 +15535,6 @@
 void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, float color);
 #endif //cl_khr_depth_images
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color);
@@ -15564,7 +15562,6 @@
 #endif //cl_khr_3d_image_writes
 
 #endif //cl_khr_mipmap_image_writes
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15577,7 +15574,7 @@
 void __ovld write_imageh(read_write image2d_array_t image, int4 coord, half4 color);
 void __ovld write_imageh(read_write image1d_buffer_t image, int coord, half4 color);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_read_write_images)
 
 // Note: In OpenCL v1.0/1.1/1.2, image argument of image query builtin functions does not have
 // access qualifier, which by default assume read_only access qualifier. Image query builtin
@@ -15625,7 +15622,7 @@
 int __ovld __cnfn get_image_width(write_only image2d_array_msaa_depth_t image);
 #endif //cl_khr_gl_msaa_sharing
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_read_write_images)
 int __ovld __cnfn get_image_width(read_write image1d_t image);
 int __ovld __cnfn get_image_width(read_write image1d_buffer_t image);
 int __ovld __cnfn

[PATCH] D107547: [CodeGen] Align calling convention bit-width to bitcode

2021-08-05 Thread Xinglong Liao via Phabricator via cfe-commits
Xinglong created this revision.
Xinglong added reviewers: rudkx, rjmccall, rsmith.
Xinglong added a project: clang.
Xinglong requested review of this revision.
Herald added a subscriber: cfe-commits.

According to https://reveiws.llvm.org/D13826, bitcode use 10 bits to represent 
calling convention ID, but for clang codegen, we only have 8 bits. so if we use 
a calling convention ID greater than 255, clang will truncate it, and bitcode 
will get an error calling convention ID.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107547

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h


Index: clang/include/clang/CodeGen/CGFunctionInfo.h
===
--- clang/include/clang/CodeGen/CGFunctionInfo.h
+++ clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -552,14 +552,14 @@
 
   /// The LLVM::CallingConv to use for this function (as specified by the
   /// user).
-  unsigned CallingConvention : 8;
+  unsigned CallingConvention : 10;
 
   /// The LLVM::CallingConv to actually use for this function, which may
   /// depend on the ABI.
-  unsigned EffectiveCallingConvention : 8;
+  unsigned EffectiveCallingConvention : 10;
 
   /// The clang::CallingConv that this was originally created with.
-  unsigned ASTCallingConvention : 6;
+  unsigned ASTCallingConvention : 10;
 
   /// Whether this is an instance method.
   unsigned InstanceMethod : 1;


Index: clang/include/clang/CodeGen/CGFunctionInfo.h
===
--- clang/include/clang/CodeGen/CGFunctionInfo.h
+++ clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -552,14 +552,14 @@
 
   /// The LLVM::CallingConv to use for this function (as specified by the
   /// user).
-  unsigned CallingConvention : 8;
+  unsigned CallingConvention : 10;
 
   /// The LLVM::CallingConv to actually use for this function, which may
   /// depend on the ABI.
-  unsigned EffectiveCallingConvention : 8;
+  unsigned EffectiveCallingConvention : 10;
 
   /// The clang::CallingConv that this was originally created with.
-  unsigned ASTCallingConvention : 6;
+  unsigned ASTCallingConvention : 10;
 
   /// Whether this is an instance method.
   unsigned InstanceMethod : 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107347: [Sema] haveSameParameterTypes - fix repeated isNull() test

2021-08-05 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:9528
 QualType T2 = NextParam(F2, I2, I == 0);
-if (!T1.isNull() && !T1.isNull() && !Context.hasSameUnqualifiedType(T1, 
T2))
+if (!T1.isNull() && !T2.isNull() && !Context.hasSameUnqualifiedType(T1, 
T2))
   return false;

@rsmith Can these isNull checks ever fail? Or would we be better off changing 
them into an assert?
```
QualType T1 = NextParam(F1, I1, I == 0);
QualType T2 = NextParam(F2, I2, I == 0);
assert(!T1.isNull() && !T2.isNull() && "Unknown types");
if (!Context.hasSameUnqualifiedType(T1, T2))
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107347

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


[clang] 92b00ff - [OpenCL] Reduce duplicate defs by using multiclasses; NFC

2021-08-05 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-08-05T11:06:33+01:00
New Revision: 92b00ffe0fb3199515c9267a1fad96d3bf44d1ea

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

LOG: [OpenCL] Reduce duplicate defs by using multiclasses; NFC

Builtin definitions with pointer arguments were duplicated to provide
overloads differing in the pointer argument's address space.

Reduce this duplication by capturing the definitions in multiclasses.
This still results in the same number of builtins in the generated
tables, but the description is more concise now.

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

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index cd704fe395a96..f2ab4169efec8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -543,9 +543,10 @@ foreach name = ["fma", "mad"] in {
   def : Builtin;
 }
 
-// --- Version dependent ---
-let MaxVersion = CL20 in {
-  foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
+// The following math builtins take pointer arguments.  Which overloads are
+// available depends on whether the generic address space feature is enabled.
+multiclass MathWithPointer addrspaces> {
+  foreach AS = addrspaces in {
 foreach name = ["fract", "modf", "sincos"] in {
   def : Builtin]>;
 }
@@ -561,19 +562,12 @@ let MaxVersion = CL20 in {
 }
   }
 }
+
+let MaxVersion = CL20 in {
+  defm : MathWithPointer<[GlobalAS, LocalAS, PrivateAS]>;
+}
 let MinVersion = CL20 in {
-  foreach name = ["fract", "modf", "sincos"] in {
-def : Builtin]>;
-  }
-  foreach name = ["frexp", "lgamma_r"] in {
-foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, 
GenTypeHalfVecAndScalar] in {
-  def : Builtin]>;
-}  }
-  foreach name = ["remquo"] in {
-foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, 
GenTypeHalfVecAndScalar] in {
-  def : Builtin]>;
-}
-  }
+  defm : MathWithPointer<[GenericAS]>;
 }
 
 // --- Table 9 ---
@@ -783,10 +777,8 @@ foreach name = ["select"] in {
 // OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and 
Store Functions
 // OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s5.1.6 and 
s6.1.6 - Vector Data Load and Store Functions
 // --- Table 15 ---
-// Variants for OpenCL versions below 2.0, using pointers to the global, local
-// and private address spaces.
-let MaxVersion = CL20 in {
-  foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
+multiclass VloadVstore addrspaces, bit defStores> {
+  foreach AS = addrspaces in {
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vload" # VSize] in {
 def : Builtin, Size, 
PointerType, AS>]>;
@@ -801,116 +793,45 @@ let MaxVersion = CL20 in {
 def : Builtin, Size, 
PointerType, AS>]>;
 def : Builtin, Size, 
PointerType, AS>]>;
   }
-  foreach name = ["vstore" # VSize] in {
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
-  }
   foreach name = ["vloada_half" # VSize] in {
 def : Builtin, Size, 
PointerType, AS>]>;
   }
-  foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
-foreach name = ["vstorea_half" # VSize # rnd] in {
-  def : Builtin, Size, 
PointerType]>;
-  def : Builtin, Size, 
PointerType]>;
+  if defStores then {
+foreach name = ["vstore" # VSize] in {
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+  def : Builtin, Size, 
PointerType]>;
+}
+foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
+  foreach name = ["vstorea_half" # VSize # rnd] in {
+def : Builtin, Size, 
PointerType]>;
+def : Builtin, Size, 
PointerType]>;
+  }
 }
   }
 }
   }
 }
-// Variants for OpenCL versions above 2.0, using pointers

[PATCH] D107151: [OpenCL] Reduce duplicate defs by using multiclasses; NFC

2021-08-05 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92b00ffe0fb3: [OpenCL] Reduce duplicate defs by using 
multiclasses; NFC (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107151

Files:
  clang/lib/Sema/OpenCLBuiltins.td

Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -543,9 +543,10 @@
   def : Builtin;
 }
 
-// --- Version dependent ---
-let MaxVersion = CL20 in {
-  foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
+// The following math builtins take pointer arguments.  Which overloads are
+// available depends on whether the generic address space feature is enabled.
+multiclass MathWithPointer addrspaces> {
+  foreach AS = addrspaces in {
 foreach name = ["fract", "modf", "sincos"] in {
   def : Builtin]>;
 }
@@ -561,19 +562,12 @@
 }
   }
 }
+
+let MaxVersion = CL20 in {
+  defm : MathWithPointer<[GlobalAS, LocalAS, PrivateAS]>;
+}
 let MinVersion = CL20 in {
-  foreach name = ["fract", "modf", "sincos"] in {
-def : Builtin]>;
-  }
-  foreach name = ["frexp", "lgamma_r"] in {
-foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
-  def : Builtin]>;
-}  }
-  foreach name = ["remquo"] in {
-foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
-  def : Builtin]>;
-}
-  }
+  defm : MathWithPointer<[GenericAS]>;
 }
 
 // --- Table 9 ---
@@ -783,10 +777,8 @@
 // OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions
 // OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s5.1.6 and s6.1.6 - Vector Data Load and Store Functions
 // --- Table 15 ---
-// Variants for OpenCL versions below 2.0, using pointers to the global, local
-// and private address spaces.
-let MaxVersion = CL20 in {
-  foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
+multiclass VloadVstore addrspaces, bit defStores> {
+  foreach AS = addrspaces in {
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vload" # VSize] in {
 def : Builtin, Size, PointerType, AS>]>;
@@ -801,116 +793,45 @@
 def : Builtin, Size, PointerType, AS>]>;
 def : Builtin, Size, PointerType, AS>]>;
   }
-  foreach name = ["vstore" # VSize] in {
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-  }
   foreach name = ["vloada_half" # VSize] in {
 def : Builtin, Size, PointerType, AS>]>;
   }
-  foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
-foreach name = ["vstorea_half" # VSize # rnd] in {
-  def : Builtin, Size, PointerType]>;
-  def : Builtin, Size, PointerType]>;
+  if defStores then {
+foreach name = ["vstore" # VSize] in {
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+}
+foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
+  foreach name = ["vstorea_half" # VSize # rnd] in {
+def : Builtin, Size, PointerType]>;
+def : Builtin, Size, PointerType]>;
+  }
 }
   }
 }
   }
 }
-// Variants for OpenCL versions above 2.0, using pointers to the generic
-// address space.
-let MinVersion = CL20 in {
-  foreach VSize = [2, 3, 4, 8, 16] in {
-foreach name = ["vload" # VSize] in {
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def :

[clang] 55a9615 - [flang][driver] Refactor boolean options

2021-08-05 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2021-08-05T10:20:47Z
New Revision: 55a96155995465416118774add8ef09c30dbebda

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

LOG: [flang][driver] Refactor boolean options

For boolean options, e.g. `-fxor-operator`/`-fno-xor-operator`, we ought
to be using TableGen multi-classes. This way, we only have to write one
definition to have both forms auto-generated. This patch refactors all
of Flang's boolean options to use two new multi-classes:
`OptInFC1FFOption` and `OptOutFC1FFOption`. These multi-classes are
based on `OptInFFOption`/`OptOutFFOption`, respectively. I've also
simplified the processing of the updated options in
CompilerInvocation.cpp.

With the new approach, "empty" help text (i.e. no `HelpText`) is now
replaced with an empty string (i.e. HelpText<"">). When running
flang-new --help, that's considered as non-empty help messages, which is
then printed (that's controlled by `printHelp` from
llvm/lib/Option/OptTable.cpp). This means that with this patch,
flang-new --help will start printing e.g. -fno-backslash, even though
there is no actual help text to print for this option (apart from the
empty string ""). Tests are updated accordingly.

Note that with this patch, both `-fxor-operator` and `-fno-xor-operator`
(and other boolean options refactored here) remain available in
`flang-new` and `flang-new -fc1`. In this respect, nothing changes. In a
forthcoming patch, I will refine this so that `flang-new -fc1` only
accepts `-ffoo` (`OptInFC1FFOption`) or `-fno-foo` (`OptOutCC1FFOption`).

For clarity, `OptInFFOption`/`OptOutFFOption` are renamed as
`OptInCC1FFOption`/`OptOutCC1FFOption`, respectively. Otherwise, this is
an NFC from Clang's perspective.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3715172917204..9f42072a92900 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -272,7 +272,7 @@ class MigratorOpts
 // Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
 // This is useful if the option is usually disabled.
 // Use this only when the option cannot be declared via BoolFOption.
-multiclass OptInFFlag flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>,
Group, HelpText;
@@ -283,7 +283,7 @@ multiclass OptInFFlag flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText;
@@ -291,6 +291,27 @@ multiclass OptOutFFlag, HelpText;
 }
 
+// A boolean option which is opt-in in FC1. The positive option exists in FC1 
and
+// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
+// This is useful if the option is usually disabled.
+multiclass OptInFC1FFlag flags=[]> {
+  def f#NAME : Flag<["-"], "f"#name>, Flags<[FC1Option] # flags>,
+   Group, HelpText;
+  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
+  Group, HelpText;
+}
+
+// A boolean option which is opt-out in FC1. The negative option exists in FC1 
and
+// Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled.
+multiclass OptOutFC1FFlag flags=[]> {
+  def f#NAME : Flag<["-"], "f"#name>, Flags,
+   Group, HelpText;
+  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[FC1Option] # flags>,
+  Group, HelpText;
+}
+
 // Creates a positive and negative flags where both of them are prefixed with
 // "m", have help text specified for positive and negative option, and a Group
 // optionally specified by the opt_group argument, otherwise Group.
@@ -1257,7 +1278,7 @@ defm addrsig : BoolFOption<"addrsig",
   CodeGenOpts<"Addrsig">, DefaultFalse,
   PosFlag, NegFlag,
   BothFlags<[CoreOption], " an address-significance table">>;
-defm blocks : OptInFFlag<"blocks", "Enable the 'blocks' language feature", "", 
"", [CoreOption]>;
+defm blocks : OptInCC1FFlag<"blocks", "Enable the 'blocks' language feature", 
"", "", [CoreOption]>;
 def fbootclasspath_EQ : Joined<["-"], "fbootclasspath=">, Group;
 defm borland_extensions : BoolFOption<"borland-extensions",
   LangOpts<"Borland">, DefaultFalse,
@@ -1273,7 +1294,7 @@ def fclang_abi_compat_EQ : Joined<["-"], 
"fclang-abi-compat=">, Group, MetaVarName<"">, 
Values<".,latest">,
   HelpText<"Attempt to match the ABI of Clang ">;
 def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group;
-defm color_diagnostics : OptInFFlag<"color-diagnostics", "Enable", "Disable", 
" colors in diagnostics",
+defm color_diagnostics : OptInC

[PATCH] D105881: [flang][driver] Refactor boolean options

2021-08-05 Thread Andrzej Warzynski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG55a961559954: [flang][driver] Refactor boolean options 
(authored by awarzynski).

Changed prior to commit:
  https://reviews.llvm.org/D105881?vs=364220&id=364401#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105881

Files:
  clang/include/clang/Driver/Options.td
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90

Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -40,7 +40,12 @@
 ! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
-! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
+! HELP-NEXT: -fno-backslash
+! HELP-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
+! HELP-NEXT: -fno-implicit-none
+! HELP-NEXT: -fno-logical-abbreviations
+! HELP-NEXT: {{[[:space:]]$}}
+! HELP-NEXT: -fno-xor-operator
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
@@ -69,6 +74,8 @@
 ! HELP-FC1-NEXT: -E Only run the preprocessor
 ! HELP-FC1-NEXT: -falternative-parameter-statement
 ! HELP-FC1-NEXT: Enable the old style PARAMETER statement
+! HELP-FC1-NEXT: -fanalyzed-objects-for-unparse
+! HELP-FC1-NEXT: {{[[:space:]]$}}
 ! HELP-FC1-NEXT: -fbackslashSpecify that backslash in string introduces an escape character
 ! HELP-FC1-NEXT: -fdebug-dump-all   Dump symbols and the parse tree after the semantic checks
 ! HELP-FC1-NEXT: -fdebug-dump-parse-tree-no-sema
@@ -104,7 +111,12 @@
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse
 ! HELP-FC1-NEXT:Do not use the analyzed objects when unparsing
+! HELP-FC1-NEXT: -fno-backslash
+! HELP-FC1-NEXT: -fno-implicit-none
+! HELP-FC1-NEXT: -fno-logical-abbreviations
+! HELP-FC1-NEXT: {{[[:space:]]$}}
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
+! HELP-FC1-NEXT: -fno-xor-operator
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -40,7 +40,12 @@
 ! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
-! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
+! CHECK-NEXT: -fno-backslash
+! CHECK-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
+! CHECK-NEXT: -fno-implicit-none
+! CHECK-NEXT: -fno-logical-abbreviations
+! CHECK-NEXT: {{[[:space:]]$}}
+! CHECK-NEXT: -fno-xor-operator
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -277,32 +277,27 @@
 }
   }
 
-  if (const llvm::opt::Arg *arg =
-  args.getLastArg(clang::driver::options::OPT_fimplicit_none,
-  clang::driver::options::OPT_fno_implicit_none)) {
-opts.features.Enable(
-Fortran::common::LanguageFeature::ImplicitNoneTypeAlways,
-arg->getOption().matches(clang::driver::options::OPT_fimplicit_none));
-  }
-  if (const llvm::opt::Arg *arg =
-  args.getLastArg(clang::driver::options::OPT_fbackslash,
-  clang::driver::options::OPT_fno_backslash)) {
-opts.features.Enable(Fortran::common::LanguageFeature::BackslashEscapes,
-arg->getOption().matches(clang::driver::options::OPT_fbackslash));
-  }
-  if (const llvm::opt::Arg *arg =
-  args.getLastArg(clang::driver::options::OPT_flogical_abbreviations,
-  clang::driver::options::OPT_fno_logical_abbreviations)) {
-opts.features.

[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

2021-08-05 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 364404.
Sockke added a comment.

format.


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

https://reviews.llvm.org/D107450

Files:
  clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp
@@ -70,7 +70,11 @@
   // CHECK-FIXES: return x3;
 }
 
-A f4(A x4) { return std::move(x4); }
+A f4(A x4) { 
+  return std::move(x4); 
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: passing result of std::move() as a const reference argument; no move will actually happen
+  // CHECK-FIXES: return x4;
+}
 
 A f5(const A x5) {
   return std::move(x5);
@@ -246,3 +250,73 @@
   };
   f(MoveSemantics());
 }
+
+void showInt(int &&) {}
+int testInt() {
+  int a = 10;
+  int b = std::move(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' of the trivially-copyable type 'int' has no effect; remove std::move()
+  // CHECK-FIXES: int b = a;
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' of the trivially-copyable type 'int' has no effect; remove std::move()
+  return std::move(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 'a' of the trivially-copyable type 'int' has no effect; remove std::move()
+  // CHECK-FIXES: return a;
+}
+
+struct Tmp {};
+void showTmp(Tmp &&) {}
+Tmp testTmp() {
+  Tmp t;
+  Tmp t1 = std::move(t);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: std::move of the variable 't' of the trivially-copyable type 'Tmp' has no effect; remove std::move()
+  // CHECK-FIXES: Tmp t1 = t;
+  Tmp t2 = std::move(Tmp());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: std::move of the expression of the trivially-copyable type 'Tmp' has no effect; remove std::move()
+  // CHECK-FIXES: Tmp t2 = Tmp();
+  showTmp(std::move(t));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 't' of the trivially-copyable type 'Tmp' has no effect; remove std::move()
+  return std::move(t);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 't' of the trivially-copyable type 'Tmp' has no effect; remove std::move()
+  // CHECK-FIXES: return t;
+}
+
+struct Tmp_UnTriviallyC {
+  Tmp_UnTriviallyC() {}
+  Tmp_UnTriviallyC(const Tmp_UnTriviallyC &) {}
+};
+void showTmp_UnTriviallyC(Tmp_UnTriviallyC &&) {}
+Tmp_UnTriviallyC testTmp_UnTriviallyC() {
+  Tmp_UnTriviallyC tn;
+  Tmp_UnTriviallyC tn1 = std::move(tn);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: passing result of std::move() as a const reference argument; no move will actually happen
+  // CHECK-FIXES: Tmp_UnTriviallyC tn1 = tn;
+  Tmp_UnTriviallyC tn2 = std::move(Tmp_UnTriviallyC());
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: passing result of std::move() as a const reference argument; no move will actually happen
+  // CHECK-FIXES: Tmp_UnTriviallyC tn2 = Tmp_UnTriviallyC();
+  showTmp_UnTriviallyC(std::move(tn));
+  // Expect no warning given here.
+  return std::move(tn);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: passing result of std::move() as a const reference argument; no move will actually happen 
+  // CHECK-FIXES: return tn;
+}
+
+struct Tmp_UnTriviallyCR {
+  Tmp_UnTriviallyCR() {}
+  Tmp_UnTriviallyCR(const Tmp_UnTriviallyCR &) {}
+  Tmp_UnTriviallyCR(Tmp_UnTriviallyCR &&) {}
+};
+void showTmp_UnTriviallyCR(Tmp_UnTriviallyCR &&) {}
+Tmp_UnTriviallyCR testTmp_UnTriviallyCR() {
+  Tmp_UnTriviallyCR tnr;
+  Tmp_UnTriviallyCR tnr1 = std::move(tnr);
+  // Expect no warning given here.
+  Tmp_UnTriviallyCR tnr2 = std::move(Tmp_UnTriviallyCR());
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: passing result of std::move() as a const reference argument; no move will actually happen
+  // CHECK-FIXES: Tmp_UnTriviallyCR tnr2 = Tmp_UnTriviallyCR();
+  showTmp_UnTriviallyCR(std::move(tnr));
+  // Expect no warning given here.
+  return std::move(tnr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: passing result of std::move() as a const reference argument; no move will actually happen
+  // CHECK-FIXES: return tnr;
+}
Index: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
@@ -45,19 +45,42 @@
unless(isInTemplateInstantiation()))
   .bind("call-move");
 
-  Finder->addMatcher(MoveCallMatcher, this);
+  Finder->addMatcher(
+  returnStmt(
+  hasReturnValue(anyOf(
+  ignoringImplicit(ignoringParenCasts(MoveCallMatcher)),

[clang] 530ea28 - Correct a lot of diagnostic wordings for the driver

2021-08-05 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-08-05T07:04:55-04:00
New Revision: 530ea28fefc4652823a187a149e8001cbf4af18f

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

LOG: Correct a lot of diagnostic wordings for the driver

Clang diagnostics should not start with a capital letter or use
trailing punctuation 
(https://clang.llvm.org/docs/InternalsManual.html#the-format-string),
but quite a few driver diagnostics were not following this advice. This
corrects the grammar and punctuation to improve consistency, but does
not change the circumstances under which the diagnostics are produced.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Cuda.cpp
clang/test/Driver/aarch64-outliner.c
clang/test/Driver/aix-object-mode.c
clang/test/Driver/amdgpu-invalid-target-id.s
clang/test/Driver/amdgpu-openmp-system-arch-fail.c
clang/test/Driver/arm-thumb-only-cores.c
clang/test/Driver/cl-inputs.c
clang/test/Driver/cl-options.c
clang/test/Driver/clang_f_opts.c
clang/test/Driver/cuda-bad-arch.cu
clang/test/Driver/cuda-detect.cu
clang/test/Driver/cuda-omp-unsupported-debug-options.cu
clang/test/Driver/cuda-options-freebsd.cu
clang/test/Driver/cuda-options.cu
clang/test/Driver/cuda-version-check.cu
clang/test/Driver/defsym.s
clang/test/Driver/fuse-ld.c
clang/test/Driver/hip-inputs.hip
clang/test/Driver/hip-invalid-target-id.hip
clang/test/Driver/invalid-target-id.cl
clang/test/Driver/msp430-hwmult.c
clang/test/Driver/openmp-offload-gpu.c
clang/test/Driver/openmp-offload.c
clang/test/Driver/rocm-detect.cl
clang/test/Driver/rocm-detect.hip
clang/test/Driver/rocm-not-found.cl
clang/test/Frontend/invalid-cxx-abi.cpp
clang/test/Frontend/round-trip-cc1-args.c
clang/test/OpenMP/target_messages.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index d27b83ecbe774..78d7ba6b63836 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -52,38 +52,46 @@ def warn_drv_avr_stdlib_not_linked: Warning<
   "standard library not linked and so no interrupt vector table or "
   "compiler runtime routines will be linked">,
   InGroup;
-def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">;
+def err_drv_cuda_bad_gpu_arch : Error<"unsupported CUDA gpu architecture: %0">;
 def err_drv_no_cuda_installation : Error<
-  "cannot find CUDA installation. Provide its path via --cuda-path, or pass "
-  "-nocudainc to build without CUDA includes.">;
+  "cannot find CUDA installation; provide its path via '--cuda-path', or pass "
+  "'-nocudainc' to build without CUDA includes">;
 def err_drv_no_cuda_libdevice : Error<
-  "cannot find libdevice for %0. Provide path to 
diff erent CUDA installation "
-  "via --cuda-path, or pass -nocudalib to build without linking with 
libdevice.">;
+  "cannot find libdevice for %0; provide path to 
diff erent CUDA installation "
+  "via '--cuda-path', or pass '-nocudalib' to build without linking with "
+  "libdevice">;
 
 def err_drv_no_rocm_device_lib : Error<
-  "cannot find ROCm device library%select{| for %1}0. Provide its path via 
--rocm-path or "
-  "--rocm-device-lib-path, or pass -nogpulib to build without ROCm device 
library.">;
+  "cannot find ROCm device library%select{| for %1}0; provide its path via "
+  "'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build "
+  "without ROCm device library">;
 def err_drv_no_hip_runtime : Error<
-  "cannot find HIP runtime. Provide its path via --rocm-path, or pass "
-  "-nogpuinc to build without HIP runtime.">;
+  "cannot find HIP runtime; provide its path via '--rocm-path', or pass "
+  "'-nogpuinc' to build without HIP runtime">;
 
 def err_drv_undetermined_amdgpu_arch : Error<
-  "Cannot determine AMDGPU architecture: %0. Consider passing it via 
--march.">;
+  "cannot determine AMDGPU architecture: %0; consider passing it via "
+  "'--march'">;
 def err_drv_cuda_version_unsupported : Error<
   "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), "
-  "but installation at %3 is %4. Use --cuda-path to specify a 
diff erent CUDA "
-  "install, pass a 
diff erent GPU arch with --cuda-gpu-arch, or pass "
-  "--no-cuda-version-check.">;
+  "but installation at %3 is %4; use '--cuda-path' to specify a 
diff erent CUDA "
+  "install, pass a 
diff erent GPU arch with '--cuda-gpu-arch', or pass "
+  "'--no-cuda-version-check'">;
 def warn_drv_unknown_cuda_version: Warning<
-  "Unknown CUDA version. %0 Assuming the latest supported version %1">,
+  "unknown CUDA version: %0; assum

[PATCH] D107553: [C++4OpenCL] Initialize temporaries in the private address space

2021-08-05 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm created this revision.
olestrohm added reviewers: Anastasia, rjmccall.
olestrohm added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
olestrohm requested review of this revision.
Herald added a subscriber: cfe-commits.

This patch fixes initializing temporaries, which are currently initialized 
without an address space, meaning that no constructor can ever be applicable.
This is also working towards putting temporaries in the private address space.

Fixes the second issue in PR43296.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107553

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
  clang/test/SemaOpenCLCXX/temporaries.clcpp


Index: clang/test/SemaOpenCLCXX/temporaries.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/temporaries.clcpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+struct X {
+  X() __private = default;
+};
+
+// CHECK: VarDecl {{.*}} gx
+// CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+__global X gx = X();
+
+void k() {
+  // CHECK: VarDecl {{.*}} x1
+  // CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+  X x1 = X();
+
+  // CHECK: VarDecl {{.*}} x2
+  // CHECK: CXXConstructExpr {{.*}} 'const __private X'
+  const X x2;
+}
Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -32,6 +32,8 @@
   __local X lx;
   __private X x;
 
+  __private X tx = X();
+
   __private Y py;
   __constant Y cy1; // expected-error{{variable in constant address space must 
be initialized}}
   __constant Y cy2(1); // expected-error{{no matching constructor for 
initialization of '__constant Y'}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1454,7 +1454,8 @@
  "List initialization must have initializer list as expression.");
   SourceRange FullRange = SourceRange(TyBeginLoc, RParenOrBraceLoc);
 
-  InitializedEntity Entity = InitializedEntity::InitializeTemporary(TInfo);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeTemporary(Context, TInfo);
   InitializationKind Kind =
   Exprs.size()
   ? ListInitialization
@@ -5293,7 +5294,8 @@
 S, Sema::ExpressionEvaluationContext::Unevaluated);
 Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/true);
 Sema::ContextRAII TUContext(S, S.Context.getTranslationUnitDecl());
-InitializedEntity To(InitializedEntity::InitializeTemporary(Args[0]));
+InitializedEntity To(
+InitializedEntity::InitializeTemporary(S.Context, Args[0]));
 InitializationKind InitKind(InitializationKind::CreateDirect(KWLoc, KWLoc,
  RParenLoc));
 InitializationSequence Init(S, To, InitKind, ArgExprs);
Index: clang/include/clang/Sema/Initialization.h
===
--- clang/include/clang/Sema/Initialization.h
+++ clang/include/clang/Sema/Initialization.h
@@ -335,8 +335,13 @@
   }
 
   /// Create the initialization entity for a temporary.
-  static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo) {
-return InitializeTemporary(TypeInfo, TypeInfo->getType());
+  static InitializedEntity InitializeTemporary(ASTContext &Context,
+   TypeSourceInfo *TypeInfo) {
+QualType Type = TypeInfo->getType();
+if (Context.getLangOpts().OpenCL && !Type.hasAddressSpace())
+  Type = Context.getAddrSpaceQualType(Type, LangAS::opencl_private);
+
+return InitializeTemporary(TypeInfo, Type);
   }
 
   /// Create the initialization entity for a temporary.


Index: clang/test/SemaOpenCLCXX/temporaries.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/temporaries.clcpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+struct X {
+  X() __private = default;
+};
+
+// CHECK: VarDecl {{.*}} gx
+// CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+__global X gx = X();
+
+void k() {
+  // CHECK: VarDecl {{.*}} x1
+  // CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+  X x1 = X();
+
+  // CHECK: VarDecl {{.*}} x2
+  // CHECK: CXXConstructExpr {{.*}} 'const __private X'
+  const X x2;
+}
Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -32,6 +32,8 @@
   __local X lx;
   __private X x;
 
+  __private X tx = 

[PATCH] D107365: clangd: Make documentation property of completion items more similar

2021-08-05 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 364412.
ckandeler added a comment.

Addressed lint complaints.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107365

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


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -405,8 +405,9 @@
   if (C.IndexResult) {
 SetDoc(C.IndexResult->Documentation);
   } else if (C.SemaResult) {
-SetDoc(getDocComment(*ASTCtx, *C.SemaResult,
- /*CommentsFromHeader=*/false));
+const auto DocComment = getDocComment(*ASTCtx, *C.SemaResult,
+  /*CommentsFromHeader=*/false);
+SetDoc(formatDocumentation(*SemaCCS, DocComment));
   }
 }
   }


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -405,8 +405,9 @@
   if (C.IndexResult) {
 SetDoc(C.IndexResult->Documentation);
   } else if (C.SemaResult) {
-SetDoc(getDocComment(*ASTCtx, *C.SemaResult,
- /*CommentsFromHeader=*/false));
+const auto DocComment = getDocComment(*ASTCtx, *C.SemaResult,
+  /*CommentsFromHeader=*/false);
+SetDoc(formatDocumentation(*SemaCCS, DocComment));
   }
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105426: [clangd] WIP: Unused header warnings

2021-08-05 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 364413.
kbobyrev added a comment.

Significantly decrease the scope of this change. Focus on "IWYU as a library",
do not propagate into the other parts of clangd yet and keep the change
self-contained for the most part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105426

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/IWYU.cpp
  clang-tools-extra/clangd/IWYU.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/IWYUTests.cpp

Index: clang-tools-extra/clangd/unittests/IWYUTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/IWYUTests.cpp
@@ -0,0 +1,98 @@
+//===--- IWYUTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "IWYU.h"
+#include "TestTU.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::ElementsAreArray;
+
+TEST(IWYU, ReferencedLocations) {
+  struct TestCase {
+std::string HeaderCode;
+std::string MainCode;
+  };
+  TestCase Cases[] = {
+  {
+  "int ^x();",
+  "int y = x();",
+  },
+  {
+  "class ^X;",
+  "X *y;",
+  },
+  {
+  "template  class ^X;",
+  "X *y;",
+  },
+  {
+  "using ^Integer = int;",
+  "Integer x;",
+  },
+  {
+  "struct X{int ^a;}; X ^foo();",
+  "int y = foo().a;",
+  },
+  {
+  "class ^X{}; X ^foo();",
+  "auto bar() { return foo(); }",
+  },
+  {
+  "class ^X; class ^X{}; class ^X;",
+  "X *y;",
+  },
+  {
+  "struct ^X { ^X(int) {} int ^foo(); };",
+  "auto x = X(42); auto y = x.foo();",
+  },
+  {
+  "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
+  "auto b = X::foo();",
+  },
+  {
+  "typedef bool ^Y; template  struct ^X {};",
+  "X x;",
+  },
+  {
+  // FIXME(kirillbobyrev): should report the UsingDecl.
+  // This information is not preserved in the AST.
+  // ^
+  "namespace ns { class ^X; }; using ns::X;",
+  "X *y;",
+  }};
+  for (const TestCase &T : Cases) {
+TestTU TU;
+TU.Code = T.MainCode;
+Annotations Header(T.HeaderCode);
+TU.HeaderCode = Header.code().str();
+auto AST = TU.build();
+
+std::vector Points;
+for (const auto &Loc : findReferencedLocations(AST).AllLocations) {
+  if (AST.getSourceManager().getBufferName(Loc).endswith(
+  TU.HeaderFilename)) {
+Points.push_back(offsetToPosition(
+TU.HeaderCode, AST.getSourceManager().getFileOffset(Loc)));
+  }
+}
+llvm::sort(Points);
+
+EXPECT_EQ(Points, Header.points()) << T.HeaderCode << "\n---\n"
+   << T.MainCode;
+  }
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -61,6 +61,7 @@
   IndexActionTests.cpp
   IndexTests.cpp
   InlayHintTests.cpp
+  IWYUTests.cpp
   JSONTransportTests.cpp
   LoggerTests.cpp
   LSPBinderTests.cpp
Index: clang-tools-extra/clangd/ParsedAST.h
===
--- clang-tools-extra/clangd/ParsedAST.h
+++ clang-tools-extra/clangd/ParsedAST.h
@@ -83,6 +83,8 @@
 return getASTContext().getLangOpts();
   }
 
+  void computeUsedIncludes();
+
   /// This function returns top-level decls present in the main file of the AST.
   /// The result does not include the decls that come from the preamble.
   /// (These should be const, but RecursiveASTVisitor requires Decl*).
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -18,6 +18,7 @@
 #include "Features.h"
 #include "Headers.h"
 #include "HeuristicResolver.h"
+#include "IWYU.h"
 #include "IncludeFixer.h"
 #include "Preamble.h"
 #include "SourceCode.h"
@@ -601,5 +602,26 @@
 return llvm::None;
   return llvm::Stri

[PATCH] D107125: [Diagnostic] Split 'qualifier on reference type has no effect' out into a new flag

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the patch! Do you need me to commit it on your behalf? If 
so, what name and email address would you like me to use for patch attribution 
in git?


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

https://reviews.llvm.org/D107125

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


[PATCH] D107497: [PowerPC][AIX] Limit attribute aligned to 4096.

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107497

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


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-08-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1964
 
+Address space removal
+-

Topotuna wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > Maybe we could title it something like:
> > > 
> > > `Address space removal utility`
> > > or
> > > `Address space removal trait`
> > > ?
> > Although we could also be more specific and name it
> > `Remove address space builtin function`?
> `Builtin address space removal utility`?
> 
> I would prefer not to leave wording "Remove address space" in description 
> because it is already what utility name says and so it adds no extra 
> information.
Well the section name is to identify the content and not to provide extra 
information so the closer you are to the actual content the better. I find  
`Remove address space builtin function` much more specific to the content to be 
honest.


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

https://reviews.llvm.org/D106785

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


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

First and foremost, I think this is a great change. I think the diagnostic is 
on the point.
BTW it seems like you missed two notes in `misc-ps-region-store.m` causing a 
test fail:

  error: 'note' diagnostics seen but not expected:
File 
/home/steakhal/git/llvm-project/clang/test/Analysis/misc-ps-region-store.m Line 
464: Original object declared here
File 
/home/steakhal/git/llvm-project/clang/test/Analysis/misc-ps-region-store.m Line 
467: Original object 'test_cwe466_return_outofbounds_pointer_a' is an array of 
10 'int' objects, returned pointer points at index 11
  2 errors generated.



---

The following comments are not about your actual change, I'm rather pointing 
out further possibilities for improving the checker.

The checker seems to cover cases when we see the array, fine.
What about pointers/references to arrays? IMO we should trust those 
declarations about the size of the pointee.

  using size_t = decltype(sizeof 1);
  using int10 = int[10];
  
  template  void clang_analyzer_dump(T);
  size_t clang_analyzer_getExtent(void *);
  int conjure_index();
  
  
  int *test_ptr_to_array(int10 *arr) {
int x = conjure_index();
if (x != 20)
  return *arr; // no-warning
  
clang_analyzer_dump(clang_analyzer_getExtent(*arr));
// expected-warning-re@-1 
{{extent_${{[0-9]+}}{SymRegion{reg_${{[0-9]+}}
// FIXME: Above should be '40 S64b' on Linux x86_64.
  
int *result = *arr + x;
clang_analyzer_dump(result);
// expected-warning-re@-1 {{&Element{SymRegion{reg_${{[0-9]+}}},20 S64b,int}}}
return result; // We should expect a warning here.
  }

Please add this test to your patch.

It seems like the checker would catch it if `MemRegionManager::getStaticSize()` 
would consider the type of the `SymbolicRegion` for `ConstantArray` pointee 
types. I'll have a patch about that.




Comment at: clang/test/Analysis/return-ptr-range.cpp:11
+int *test_global_ptr() {
+  do { // expected-note{{Loop condition is false.  Exiting loop}}
 int x = conjure_index();

I would rather use a simple block `{...}` for opening a scope, but I don't know 
why you don't declare `ptr` in the original scope in the first place.
People usually use `do {} while(0)` constructs if they want to use `break` 
somewhere ~~ like a `goto` OR they implement a macro. You are doing none of 
these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

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


[PATCH] D107366: [analyzer] Adjust JS code of analyzer's HTML report for IE support.

2021-08-05 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D107366#2927842 , @vsavchenko 
wrote:

> Now it captures (and makes bold) one extra arrow from the previous note.
> Correct example attached!
> F18364580: report-e4b488.html 

Damn. I've already fixed it. It returned back after some branch manipulations I 
didn't notice. Thank you!


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

https://reviews.llvm.org/D107366

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


[PATCH] D106343: [OpenCL] Support cl_ext_float_atomics

2021-08-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Headers/opencl-c-base.h:24
 #define cl_khr_subgroup_clustered_reduce 1
+#define cl_ext_float_atomics
+#ifdef cl_khr_fp16

svenvh wrote:
> Should this be defined as `1`?
> 
> Should this define be tested in `clang/test/Headers/opencl-c-header.cl` too?
Actually, now that I think more about this, it seems incorrect to add this here 
without adding the functions to `OpenCLBuiltins.td` because then the feature 
macro will be present without the feature when the default header is used?

So I guess we either need to extend `OpenCLBuiltins.td` with new functions or 
move the new macros into `opencl-c.h`?


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

https://reviews.llvm.org/D106343

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


[PATCH] D107366: [analyzer] Adjust JS code of analyzer's HTML report for IE support.

2021-08-05 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 364418.
ASDenysPetrov added a comment.

Final fixes.


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

https://reviews.llvm.org/D107366

Files:
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp


Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -1289,15 +1289,32 @@
 return out;
 };
 
+var classListAdd = function(el, theClass) {
+  if (!el.className.baseVal)
+el.className += " " + theClass;
+  else
+el.className.baseVal += " " + theClass;
+};
+
+var classListRemove = function(el, theClass) {
+  var className = (!el.className.baseVal) ?
+  el.className : el.className.baseVal;
+className = className.replace(" " + theClass, "");
+  if (!el.className.baseVal)
+el.className = className;
+  else
+el.className.baseVal = className;
+};
+
 var scrollTo = function(el) {
 querySelectorAllArray(".selected").forEach(function(s) {
-s.classList.remove("selected");
+  classListRemove(s, "selected");
 });
-el.classList.add("selected");
+classListAdd(el, "selected");
 window.scrollBy(0, el.getBoundingClientRect().top -
 (window.innerHeight / 2));
 highlightArrowsForSelectedEvent();
-}
+};
 
 var move = function(num, up, numItems) {
   if (num == 1 && up || num == numItems - 1 && !up) {
@@ -1332,9 +1349,11 @@
   if (event.defaultPrevented) {
 return;
   }
-  if (event.key == "j") {
+  // key 'j'
+  if (event.keyCode == 74) {
 navigateTo(/*up=*/false);
-  } else if (event.key == "k") {
+  // key 'k'
+  } else if (event.keyCode == 75) {
 navigateTo(/*up=*/true);
   } else {
 return;
@@ -1350,8 +1369,11 @@
 

[PATCH] D107522: [PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4064-4068
   if (Context.getTargetInfo().isTLSSupported()) {
 unsigned MaxTLSAlign =
 Context.toCharUnitsFromBits(Context.getTargetInfo().getMaxTLSAlign())
 .getQuantity();
 if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&





Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4076
 
+  // On AIX, an aligned attribute can not decrease the alignemnt when applied
+  // to a variable declaration with vector type.





Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4081
+if (Ty->isVectorType() && AlignVal < 16)
+  return;
+  }

This should produce a diagnostic rather than silently drop the attribute. I'd 
recommend `err_alignas_underaligned` if you're willing to make this an error. 
If not, you could add a new warning with the same wording.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107522

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


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-08-05 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 364420.
Topotuna added a comment.

Documentation section title reworded


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

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp

Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_is_same() {
+  static_assert(is_same::value);
+  static_assert(!is_same::value);
+  static_assert(!is_same<__private int, int>::value);
+}
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space::type, int>::value,
+"type without an address space unexpectedly modified by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, int3>::value,
+"__constant address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by __remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,30 @@
 global OnlySL *d,
   );
 
+Remove address space builtin function
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. This utility only affects
+address space qualifiers, therefore, other type qualifiers such as
+``const`` or ``volatile`` remain unchanged.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+T var1; // error - local function variable with global address space
+__private T var2; // error - conflicting address space qualifiers
+__private __remove_address_space var3; // var3 is __private int
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107366: [analyzer] Adjust JS code of analyzer's HTML report for IE support.

2021-08-05 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

F18367476: report-86a04f.html  - Final 
sample file.


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

https://reviews.llvm.org/D107366

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


[PATCH] D107558: [clang] [clang-repl] Fix linking against LLVMLineEditor

2021-08-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: v.g.vassilev, mstorsjo.
mgorny requested review of this revision.

LLVMLineEditor library is part of the LLVM dylib.  Move it into
LLVM_LINK_COMPONENTS to avoid duplicate linking when dylib is being
used.  This fixes building standalone clang against installed LLVM
without static libraries.


https://reviews.llvm.org/D107558

Files:
  clang/tools/clang-repl/CMakeLists.txt


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -1,6 +1,7 @@
 set( LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Core
+  LineEditor
   Option
   OrcJIT
   Support
@@ -14,5 +15,4 @@
   clangBasic
   clangInterpreter
   clangTooling
-  LLVMLineEditor
   )


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -1,6 +1,7 @@
 set( LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Core
+  LineEditor
   Option
   OrcJIT
   Support
@@ -14,5 +15,4 @@
   clangBasic
   clangInterpreter
   clangTooling
-  LLVMLineEditor
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107559: [clang] Fix libclang linking on Solaris

2021-08-05 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: clang, tstellar, MaskRay.
ro added a project: clang.
Herald added subscribers: fedor.sergeev, mgorny, jyknight.
ro requested review of this revision.
Herald added a subscriber: cfe-commits.

Linking `libclang.so` is currently broken on Solaris:

  ld: fatal: option --version-script requires option -z 
gnu-version-script-compat to be specified

While Solaris `ld` supports a considerable subset of `--version-script`, there 
are some
elements of the syntax that aren't.

The fix is equivalent to D78510 .  
Additionally, use C-style comments is a GNU extension
that can easily be avoided by using `#` as comment character.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107559

Files:
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.map


Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -1,10 +1,8 @@
-/* If you add a symbol to this file, make sure to add it with the correct
- * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
- * symbols with the version LLVM_14.
- * On platforms where versions scripts are not used, this file will be used to
- * generate a list of exports for libclang.so
- */
-
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
 
 LLVM_13 {
   global:
@@ -407,10 +405,9 @@
   local: *;
 };
 
-/* Example of how to add a new symbol version entry.  If you do add a new 
symbol
- * version, please update the example to depend on the version you added.
- * LLVM_X {
- * global:
- *clang_newsymbol;
- * };
- */
+# Example of how to add a new symbol version entry.  If you do add a new symbol
+# version, please update the example to depend on the version you added.
+# LLVM_X {
+# global:
+#   clang_newsymbol;
+# };
Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -162,6 +162,11 @@
   endif()
   if (USE_VERSION_SCRIPT)
 target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+# The Solaris 11.4 linker supports a subset of GNU ld version scripts,
+# but requires a special option to enable it.
+if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+  target_link_options(libclang PRIVATE "-Wl,-z,gnu-version-script-compat")
+endif()
 # Ensure that libclang.so gets rebuilt when the linker script changes.
 set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
  OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libclang.map)


Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -1,10 +1,8 @@
-/* If you add a symbol to this file, make sure to add it with the correct
- * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
- * symbols with the version LLVM_14.
- * On platforms where versions scripts are not used, this file will be used to
- * generate a list of exports for libclang.so
- */
-
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
 
 LLVM_13 {
   global:
@@ -407,10 +405,9 @@
   local: *;
 };
 
-/* Example of how to add a new symbol version entry.  If you do add a new symbol
- * version, please update the example to depend on the version you added.
- * LLVM_X {
- * global:
- *clang_newsymbol;
- * };
- */
+# Example of how to add a new symbol version entry.  If you do add a new symbol
+# version, please update the example to depend on the version you added.
+# LLVM_X {
+# global:
+#   clang_newsymbol;
+# };
Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -162,6 +162,11 @@
   endif()
   if (USE_VERSION_SCRIPT)
 target_link_options(libclang PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+# The Solaris 11.4 linker supports a subset of GNU ld version scripts,
+# but requires a special option to enable it.
+if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+  target_link_options(libclang PRIVATE "-Wl,-z,gnu-version

[PATCH] D107528: [llvm][clang][NFC] updates inline licence info

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

There are some spurious whitespace changes that should be dropped, but 
otherwise, this LGTM. Thank you for the cleanup!




Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:115
 return;
-  
   // This has to be delayed as the context hash can change at the start of

Spurious whitespace change.



Comment at: llvm/lib/Analysis/DevelopmentModeInlineAdvisor.cpp:35
 cl::desc(R"(Path to SavedModel from the previous training iteration.
-The directory is also expected to contain a JSON specification of the 
-outputs expected to be logged, where the first entry must be the 
-inlining decision. The file containing the specification should be 
-called output_spec.json. The expected JSON value is an array of 
-dictionaries. Each dictionary should have 2 keys: 
+The directory is also expected to contain a JSON specification of the
+outputs expected to be logged, where the first entry must be the

Unrelated whitespace changes.



Comment at: llvm/lib/BinaryFormat/MsgPackDocumentYAML.cpp:249
 }
-

Unrelated whitespace change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107528

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


[PATCH] D107420: [sema] Disallow __builtin_mul_overflow under special condition.

2021-08-05 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

In D107420#2927856 , @lebedev.ri 
wrote:

> I don't personally care, but i think this diag doesn't make sense.
> What is "backend"? Which one? All of them? What happens when one, but not all 
> of them supports it?
> What if i don't intend to codegen this into an assembly, but only want to 
> produce the IR?

THX for comment. The root cause unable to support this is same as the code 
added before (line 328-329). I'm suppossing we can view this patch as a 
supplementary patch of the old one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107420

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


[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry about the delay here, and welcome back!

The core design looks sensible to me - we talked about making this part of the 
background index (which could reuse more code) but we don't actually want the 
data mixed together.

Main points in the implementation are:

- simplify the exposed interface
- i don't think we need to mess with VFS at all actually
- we should think a little about which index data we actually want to keep/use

Next design questions seem to be about lifetime/triggering:

- how many configurations of stdlib index to have
- when do we build the indexes, and who owns them
- what logic governs whether/which stdlib index is triggered, and where do we 
put it




Comment at: clang-tools-extra/clangd/index/StdLib.cpp:30
+
+const std::string
+StandardLibraryIndex::StdLibHeaderFileName("/stdlibheaders.cpp");

nit: use char[] or llvm::stringliteral for constants to avoid global 
constructors/destructors

(see "static initialization order fiasco" and related destructor issues)



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:31
+const std::string
+StandardLibraryIndex::StdLibHeaderFileName("/stdlibheaders.cpp");
+

this path should probably use native conventions: "/stdlibheaders.cpp" isn't a 
good filename on windows.

Since it doesn't really need to exist, maybe #ifdef _WIN32 like we do for 
testRoot in unittests/TestFS would be nice. Such a virtualRoot() could go in 
FS.h if you like!

Would be nice to have "virtual" in the path so it's clear in e.g. error 
messages that it's not a real path.



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:33
+
+std::string StandardLibraryIndex::generateIncludeHeader() {
+  std::string Includes;

This generates the same result every time, if there's any chance we'll call it 
multiple times (i think there is) maybe rather:

```
llvm::StringRef getIncludeHeader() {
  // construct on first use, never destroy
  static std::string *once = []{
 ...
 return new std::string(std::move(result));
  };
  return *once;
};
```



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:36
+  // gather all the known STL headers in a set for depulication
+  std::set Headers;
+

std::set is a poor (wasteful) data structure.

here a simple reasonably-efficient thing would be
vector Headers = { ... };
llvm::sort(Headers);
llvm::unique(Headers);

Same big-O, still simple, smaller-faster in practice.


The slightly silly thing is doing this at runtime at all, but that would be a 
fair amount of work to avoid.



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:58
+
+  llvm::IntrusiveRefCntPtr viewImpl() const override {
+return FS;

This isn't actually threadsafe though?
Calls to viewImpl() are supposed to return filesystems with independent state 
(workdir).

Maybe it doesn't actually bite us here but I don't see much cost to actually 
building the FS on demand. (The threadsafeFS should own the string and use a 
non-copying buffer)



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:66
+StandardLibraryIndex::buildFilesystem(std::string HeaderSources) {
+  auto FS = llvm::makeIntrusiveRefCnt();
+  auto Now =

this contains only the umbrella headers, and doesn't seem to be overlaid on the 
real filesystem. So how does this work?



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:82
+  // TODO: can we get a real compile command from somewhere?
+  Inputs.CompileCommand = tooling::CompileCommand();
+  Inputs.CompileCommand.Directory = "/";

this is a no-op



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:83
+  Inputs.CompileCommand = tooling::CompileCommand();
+  Inputs.CompileCommand.Directory = "/";
+  Inputs.CompileCommand.Filename = StdLibHeaderFileName;

/ may not be what we want on windows right?



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:85
+  Inputs.CompileCommand.Filename = StdLibHeaderFileName;
+  Inputs.CompileCommand.Output = StdLibHeaderFileName + ".o";
+  Inputs.CompileCommand.CommandLine.push_back("clang++");

this is not used, no need to set it



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:88
+  Inputs.CompileCommand.CommandLine.push_back(Inputs.CompileCommand.Filename);
+  Inputs.CompileCommand.CommandLine.push_back("-o");
+  Inputs.CompileCommand.CommandLine.push_back(Inputs.CompileCommand.Output);

no need for the -o either



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:98
+  auto Buffer = FS->getBufferForFile(StdLibHeaderFileName);
+  if (!Buffer)
+return error("Could not read file from InMemoryFileSystem");

CreateMemBuffer instead to avoid expressing this impossible error condition?



[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

2021-08-05 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone requested changes to this revision.
Quuxplusone added inline comments.
This revision now requires changes to proceed.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:75
+  return std::move(x4); 
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: passing result of std::move() 
as a const reference argument; no move will actually happen
+  // CHECK-FIXES: return x4;

You're right that //some// diagnostic should be given here, but //this// is not 
the right diagnostic. The issue is not that the `std::move` is non-functional, 
but rather that it's superfluous; a move //will// happen, with or without the 
`std::move`. (And the `std::move` prevents move elision, so removing it may 
actually improve codegen.)



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:261
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; remove std::move()
+  return std::move(a);

This warning is incorrect, as indicated in your PR summary. Isn't the point of 
this PR mainly to remove this incorrect warning?


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

https://reviews.llvm.org/D107450

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


[PATCH] D104285: [analyzer][AST] Retrieve value by direct index from list initialization of constant array declaration.

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Expr.h:4959
 
+  /// Return an value-expression under the given index.
+  ///





Comment at: clang/include/clang/AST/Expr.h:4970
+  /// - `this` if there's no expression for the valid index;
+  /// - `nullptr` for invalid index (`i < 0` or `i >= array_size`)
+  ///   or if it is not a list for constant array type.

`i` cannot be `< 0` because the index here is unsigned anyway.



Comment at: clang/include/clang/AST/Expr.h:4973-4975
+  /// This version adapted to treat unsigned integer to distinguish between
+  /// -1 and ULONG_LONG_MAX.
+  const Expr *getExprForConstArrayByRawIndex(int64_t Idx) const;

I don't think this overload adds enough value -- the indexes are naturally 
unsigned, and the caller should validate the behavior if the source expression 
is signed.



Comment at: clang/lib/AST/Expr.cpp:2354-2358
+  if (!isa(T))
+return nullptr;
+
+  SmallVector Extents =
+  cast(T)->getAllExtents();

Hmm, generally speaking, you should not cast an arbitrary type to an array type 
because that won't do the correct thing for qualifiers. Instead, you'd usually 
use `ASTContext::getAsConstantArrayType()` to get the correct type. However, 
because you're just getting the array extent, I don't believe that can be 
impacted. However, `isa` followed by `cast` is a code smell, and that should at 
least be using a `dyn_cast`.

@rsmith, do you have thoughts on this?


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

https://reviews.llvm.org/D104285

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


[PATCH] D107522: [PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

2021-08-05 Thread Sean Fertile via Phabricator via cfe-commits
sfertile updated this revision to Diff 364436.
sfertile added a comment.

- Fixed spelling mistake
- Check that VD is non-nulll earlier.
- added warning that the requested alignment is too small.
- renamed test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107522

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-vector-attr-aligned.c
  clang/test/Sema/aix-attr-aligned-vector-warn.c

Index: clang/test/Sema/aix-attr-aligned-vector-warn.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-aligned-vector-warn.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-feature +altivec -target-cpu pwr7 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-feature +altivec -target-cpu pwr7 -verify -fsyntax-only %s
+
+int escape(vector int*);
+
+typedef vector int __attribute__((aligned(8))) UnderAlignedVI;
+UnderAlignedVI TypedefedGlobal;
+
+vector int V __attribute__((aligned(8))); // expected-warning {{requested alignment is less than minimum alignment of 16 for type '__vector int' (vector of 4 'int' values)}}
+
+int localTypedefed(void) {
+  UnderAlignedVI TypedefedLocal;
+  return escape(&TypedefedLocal); // expected-warning {{passing 8-byte aligned argument to 16-byte aligned parameter 1 of 'escape' may result in an unaligned pointer access}}
+}
Index: clang/test/CodeGen/aix-vector-attr-aligned.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-vector-attr-aligned.c
@@ -0,0 +1,33 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-feature +altivec -target-cpu pwr7 -emit-llvm -o - %s | \
+// RUN:   FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-feature +altivec -target-cpu pwr7 -emit-llvm -o - %s | \
+// RUN:   FileCheck %s
+
+typedef vector int __attribute__((aligned(8))) UnderAlignedVI;
+
+vector int g32 __attribute__((aligned(32)));
+vector int g8 __attribute__((aligned(8)));
+UnderAlignedVI TypedefedGlobal;
+
+int escape(vector int*);
+
+int local32(void) {
+  vector int l32 __attribute__((aligned(32)));
+  return escape(&l32);
+}
+
+int local8(void) {
+  vector int l8 __attribute__((aligned(8)));
+  return escape(&l8);
+}
+
+// CHECK: @g32 = global <4 x i32> zeroinitializer, align 32
+// CHECK: @g8 = global <4 x i32> zeroinitializer, align 16
+// CHECK: @TypedefedGlobal = global <4 x i32> zeroinitializer, align 8
+
+// CHECK-LABEL: @local32
+// CHECK: %l32 = alloca <4 x i32>, align 32
+//
+// CHECK-LABEL: @local8
+// CHECK: %l8 = alloca <4 x i32>, align 16
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4060,12 +4060,12 @@
 return;
   }
 
-  if (Context.getTargetInfo().isTLSSupported()) {
+  const auto *VD = dyn_cast(D);
+  if (VD && Context.getTargetInfo().isTLSSupported()) {
 unsigned MaxTLSAlign =
 Context.toCharUnitsFromBits(Context.getTargetInfo().getMaxTLSAlign())
 .getQuantity();
-const auto *VD = dyn_cast(D);
-if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
+if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
 VD->getTLSKind() != VarDecl::TLS_None) {
   Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
   << (unsigned)AlignVal << VD << MaxTLSAlign;
@@ -4073,6 +4073,17 @@
 }
   }
 
+  // On AIX, an aligned attribute can not decrease the alignment when applied
+  // to a variable declaration with vector type.
+  if (VD && Context.getTargetInfo().getTriple().isOSAIX()) {
+const Type *Ty = VD->getType().getTypePtr();
+if (Ty->isVectorType() && AlignVal < 16) {
+  Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
+  << VD->getType() << 16;
+  return;
+}
+  }
+
   AlignedAttr *AA = ::new (Context) AlignedAttr(Context, CI, true, ICE.get());
   AA->setPackExpansion(IsPackExpansion);
   D->addAttr(AA);
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2986,6 +2986,9 @@
   "redeclaration has different alignment requirement (%1 vs %0)">;
 def err_alignas_underaligned : Error<
   "requested alignment is less than minimum alignment of %1 for type %0">;
+def warn_aligned_attr_underaligned : Warning<
+  "requested alignment is less than minimum alignment of %1 for type %0">,
+  InGroup;
 def err_attribute_sizeless_type : Error<
   "%0 attribute cannot be applied to sizeless type %1">;
 def err_attribute_argument_n_type : Error<
___
cfe-commits

[PATCH] D107522: [PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

2021-08-05 Thread Sean Fertile via Phabricator via cfe-commits
sfertile marked 3 inline comments as done.
sfertile added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4081
+if (Ty->isVectorType() && AlignVal < 16)
+  return;
+  }

aaron.ballman wrote:
> This should produce a diagnostic rather than silently drop the attribute. I'd 
> recommend `err_alignas_underaligned` if you're willing to make this an error. 
> If not, you could add a new warning with the same wording.
Thanks for the feedback Aaron. I think an error is too drastic a difference 
from the other compilers on AIX so I added the warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107522

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


[PATCH] D107522: [PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a minor nit.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2989-2990
   "requested alignment is less than minimum alignment of %1 for type %0">;
+def warn_aligned_attr_underaligned : Warning<
+  "requested alignment is less than minimum alignment of %1 for type %0">,
+  InGroup;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107522

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


[PATCH] D107565: Revert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test"

2021-08-05 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng created this revision.
Herald added a subscriber: krytarowski.
fanbo-meng requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit d91234b21c1a1a34d98157089a8769d8f9a32f06 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107565

Files:
  clang/test/Sema/struct-packed-align.c


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) 
&& !defined(__ANDROID__)))
+#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! 
defined(__ANDROID__) ) )
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) && !defined(__ANDROID__)))
+#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! defined(__ANDROID__) ) )
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

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

How about we just change the NoteTag to this: "Failed stream operation could 
have left the error or eof flags set, or the file position indicator 
indeterminate"? We could add a `NoteTags` to `feof` and `ferror` that narrows 
this down, for example:

  fread(F); // note: Failed stream operation could have left the error or eof 
flags set
  // ...
  if (ferror(F)) // note: Assuming F does not have the error flag set
return;
  fread(F); // warning: Read function called when stream is in EOF state. 
Function has no effect.



  fread(F); // note: Failed stream operation could have left the error or eof 
flags set
  // ...
  if (feof(F)) // note: Assuming F does not have the eof flag set
return;
  fread(F); // warning: Read function called when stream has the error flag 
set. Maybe call clearerr()?



  fseek(F); // note: Failed stream operation could have left the error or eof 
flags set, or the file position indicator indeterminate
  // ...
  if (feof(F)) // note: Assuming F does not have the eof flag set
return;
  //...
  fread(F); // warning: File position of the stream might be 'indeterminate' 
after a failed operation. Can cause undefined behavior.

Seems like solid future proofing is you change your mind on emitting warnings 
on FERROR or we realized if some operation could ensure that the file position 
indicator is determinate.

In D106262#2919967 , @balazske wrote:

>> Do we ever intend to create a warning for FERROR?
>
> Probably not (but there may be some not yet modeled stream operation where 
> this may be useful.). This is when FERROR is set but not the indeterminate 
> position. It indicates that the last operation failed but it is OK to use the 
> stream. But this can be a "ErrorReturn" checker problem (a failed operation 
> was not observed by the program).

I guess its a bad practice to not check whether the stream has FERROR, and I 
guess using another stream operation is as good of a point to check as any, so 
I'd definitely do it here than in ErrorReturn. But for now, alright, lets leave 
this for another day.

In D106262#2919989 , @balazske wrote:

>> Will there ever be a way to get rid of the indeterminate position indicator 
>> tag?
>
> Currently the `fseek` can reset this flag, and the `freopen` is another case 
> for it.

Well, sure, but they would also become the last stream operation. These 
Schrödinger cases are a problem because failed stream operation #1 could leave 
the stream object in a number of error states (e.g. `fseek`), and event #2 
(e.g. checking whether the return value from `fgetc` equals to EOF)  and stream 
operation #3 (e.g. using 
`StreamTesterChecker_remove_indeterminate_file_pos_tag()`) narrowed this down 
to one specific error kind (e.g. its in FERROR). Basically, events #2 and #3 
determine what happened at #1, and since #1 is the error causing event, we need 
to highlight it somehow. If #2 is an `fseek`, `freopen`, or other call that 
resets the entire stream object, then it will become the last event the 
highlight, making #1 no longer interesting at all.

In D106262#2919960 , @balazske wrote:

>> No matter what happens during analysis, as of now, the NoteTag message is 
>> unambiguous at the point of the tags construction.
>
> [...]
> In this code the NoteTag message is unambiguous. The code above is a 
> "compression" of this and at the construction of the NoteTag message is in 
> "superposition" state too (like the error state that determines the message).

Can you give me a few test cases on this patch where the `NoteTag` indeed 
changes on a stream operation? My long comment meant to demonstrate that there 
doesn't exist such, but I'm happy to be proven wrong. My questions are about 
whether there *could* exist such a case in the future.

> `freopen` is a different case: At failure it returns a NULL pointer and the 
> stream becomes in an invalid state. But if the return value of `freopen` is 
> not assigned to it, the stream pointer is not set to NULL:
>
> - `F = freopen(0, "w", F);` F will be NULL at failure, this makes a bug with 
> `BT_FileNull` bug type.
> - `freopen(0, "w", F);` F becomes invalid but not NULL, if used then a 
> `BT_UseAfterOpenFailed` bug is detected (this is the only case for this bug 
> type).
>
> At failure of `freopen` we can not tell which case will occur later (it 
> depends on the analyzed code). (It may be possible to have only one bug for 
> these cases but a differentation is needed to tell the user if a file was 
> NULL or invalid but not NULL.)

Sure, but the `NoteTag` assigned to `freopen` still wouldn't change (it just 
wouldn't show for the former case, as writing to `F` would clear the 
interestingness on it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262


[PATCH] D107294: [clang-tidy] adds warning to suggest users replace symbols with words

2021-08-05 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/AlternativeTokensCheck.cpp:61
+FixItHint AlternativeTokensCheck::createReplacement(SourceLocation Loc,
+StringRef S, int N) const {
+  // Only insert spaces if there aren't already spaces between operators

What's `N`? It's not immediately apparent for me from the callsites of this 
function.



Comment at: 
clang-tools-extra/clang-tidy/readability/AlternativeTokensCheck.cpp:70-71
+void AlternativeTokensCheck::checkSpelling(const UnaryOperator &Op) {
+  SourceLocation Loc = Op.getOperatorLoc();
+  char First = *(SM->getCharacterData(Loc));
+  if (std::isalpha(First) || Loc.isMacroID())

Are we sure these will never return an invalid Loc, or dereference a null? 
Maybe it'd be worth to investigate, add an assertion (to help the people who 
might run static analysis on LLVM, if for nothing else), or an early return.



Comment at: 
clang-tools-extra/clang-tidy/readability/AlternativeTokensCheck.cpp:90-91
+void AlternativeTokensCheck::checkSpelling(const BinaryOperator &Op) {
+  SourceLocation Loc = Op.getOperatorLoc();
+  char First = *(SM->getCharacterData(Loc));
+  if (std::isalpha(First) || Loc.isMacroID())

Same comment as in the `UnaryOperator` case.



Comment at: 
clang-tools-extra/clang-tidy/readability/AlternativeTokensCheck.cpp:124-125
+void AlternativeTokensCheck::checkSpelling(const CXXOperatorCallExpr &Op) {
+  SourceLocation Loc = Op.getOperatorLoc();
+  char First = *(SM->getCharacterData(Loc));
+  if (std::isalpha(First) || Loc.isMacroID())

Ditto. (Usually there might be issues if the location is coming from generated 
code or templates or macros or something... I fear this could be mostly 
prevalent in the user-defined operator case, i.e. this method.)



Comment at: 
clang-tools-extra/clang-tidy/readability/AlternativeTokensCheck.h:20-21
+namespace readability {
+/// Flags uses of symbol-based bitwise and logical operators.
+class AlternativeTokensCheck : public ClangTidyCheck {
+public:

Following from gone thread due to file rename.

>>! In D107294#2923102, @cjdb wrote:
> Not sure I'm following you here: are you suggesting I put the contents of my 
> `rst` file in a comment here?

Not the entire //RST//, but the one-sentence or first-paragraph "pitch". For 
example, let's see `bugprone-branch-clone`'s class's doc-comment:

```
/// A check for detecting if/else if/else chains where two or more branches are
/// Type I clones of each other (that is, they contain identical code), for
/// detecting switch statements where two or more consecutive branches are
/// Type I clones of each other, and for detecting conditional operators where
/// the true and false expressions are Type I clones of each other.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-branch-clone.html
class BranchCloneCheck : public ClangTidyCheck {
```

Or another one selected randomly, `performance-no-automatic-move`:

```
/// Finds local variables that cannot be automatically moved due to constness.
///
/// For the user-facing documentation see:
/// 
http://clang.llvm.org/extra/clang-tidy/checks/performance-no-automatic-move.html
class NoAutomaticMoveCheck : public ClangTidyCheck {
```

So there is a one-paragraph summary of the check itself (it could be shorter 
than here...), and there is a text that's generated from a template (I think 
`add-new-check.py` sets the new check's files as such when you run it), which 
basically just links the upstream official website render of your check's 
documentation HTML.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp:133-134
 "readability-uppercase-literal-suffix");
+CheckFactories.registerCheck(
+"readability-use-alternative-tokens");
 CheckFactories.registerCheck(

cjdb wrote:
> aaron.ballman wrote:
> > I think this might be a case where we want the check to either recommend 
> > using alternative tokens or recommend against using alternative tokens via 
> > a configuration option (so users can control readability in either 
> > direction). If you agree that's a reasonable design, then I'd recommend we 
> > name this `readability-alternative-tokens` to be a bit more generic. (Note, 
> > we can always do the "don't use alternative tokens" implementation in a 
> > follow-up patch if you don't want to do that work immediately.)
> Hrmm I'll do the rename now, but this might be better off as a later 
> patch. I'd rather focus on getting what I have right (along with my teased 
> extensions) and then work on the opposite direction. That will (probably) be 
> an easy slip-in.
(As someone who's had checkers on review for multiple years I've no

[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

2021-08-05 Thread liushuai wang via Phabricator via cfe-commits
MTC added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:75
+  return std::move(x4); 
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: passing result of std::move() 
as a const reference argument; no move will actually happen
+  // CHECK-FIXES: return x4;

Quuxplusone wrote:
> You're right that //some// diagnostic should be given here, but //this// is 
> not the right diagnostic. The issue is not that the `std::move` is 
> non-functional, but rather that it's superfluous; a move //will// happen, 
> with or without the `std::move`. (And the `std::move` prevents move elision, 
> so removing it may actually improve codegen.)
Correct!  @Sockke would you self-examination these cases again? I have checked 
this case, see https://godbolt.org/z/3ch3sbG17.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:261
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; remove std::move()
+  return std::move(a);

Quuxplusone wrote:
> This warning is incorrect, as indicated in your PR summary. Isn't the point 
> of this PR mainly to remove this incorrect warning?
I guess what @Sockke wants to express is that applying `std::move` on the 
integer type makes no sense.


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

https://reviews.llvm.org/D107450

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


[PATCH] D107565: Revert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test"

2021-08-05 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107565

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


[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

2021-08-05 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:51
+  hasReturnValue(anyOf(
+  ignoringImplicit(ignoringParenCasts(MoveCallMatcher)),
+  cxxConstructExpr(hasDeclaration(cxxConstructorDecl(allOf(

I am not sure if `ignoringImplicit(ignoringParenCasts(_))` is the same as 
`ignoringParenImpCasts(_)`, but I've seen the latter one appear many times in 
other matchers.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:261
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; remove std::move()
+  return std::move(a);

MTC wrote:
> Quuxplusone wrote:
> > This warning is incorrect, as indicated in your PR summary. Isn't the point 
> > of this PR mainly to remove this incorrect warning?
> I guess what @Sockke wants to express is that applying `std::move` on the 
> integer type makes no sense.
Yes, but there is no //FixIt// for this warning, but even if the user fixes 
this //manually// according to the warning, it'll result in

> error: cannot bind rvalue reference of type `int&&` to lvalue of type `int`

because `showInt` takes `int&&`!

So this is not just unfixable automatically (hence no `CHECK-FIXES` line), it 
isn't fixable at all.


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

https://reviews.llvm.org/D107450

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


[PATCH] D105263: [X86] AVX512FP16 instructions enabling 1/6

2021-08-05 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:801
   //  0b00010: implied 0F 38 leading opcode bytes
   //  0b00011: implied 0F 3A leading opcode bytes
   //  0b00100-0b1: Reserved for future use

Add comments for map5 and map6?



Comment at: llvm/lib/Target/X86/X86.td:189
+// guarded under condition hasVLX. So we imply it in FeatureFP16 currently.
+// FIXME: FP16 conversion between f16 and i64 customise type v8i64, which is
+// supposed to be guarded under condition hasDQI. So we imply it in FeatureFP16

customize?



Comment at: llvm/lib/Target/X86/X86FastISel.cpp:2291
+  case MVT::i16: Opc = X86::CMOV_GR16;  break;
+  case MVT::f16: Opc = X86::CMOV_FR16X; break;
+  case MVT::i32: Opc = X86::CMOV_GR32;  break;

Also add it in isCMOVPseudo()?



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:1946
+setGroup(VT);
+  }
+  setOperationAction(ISD::SCALAR_TO_VECTOR,   MVT::v8f16,  Legal);

Drop the brace.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:10549
 
-  if (EltVT == MVT::i32 || EltVT == MVT::f32 || EltVT == MVT::f64 ||
-  (EltVT == MVT::i64 && Subtarget.is64Bit())) {
+  if (EltVT == MVT::i32 || EltVT == MVT::f16 || EltVT == MVT::f32 ||
+  EltVT == MVT::f64 || (EltVT == MVT::i64 && Subtarget.is64Bit()) ||

Need check Subtarget.hasFP16()?



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:10551
+  EltVT == MVT::f64 || (EltVT == MVT::i64 && Subtarget.is64Bit()) ||
+  (EltVT == MVT::i16 && Subtarget.hasFP16())) {
 assert((VT.is128BitVector() || VT.is256BitVector() ||

Why handle i16? Isn't it handled by movw?



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:10744
   // For SSE 4.1, use insertps to put the high elements into the low element.
-  if (Subtarget.hasSSE41()) {
+  if (Subtarget.hasSSE41() && EltVT != MVT::f16) {
 SDValue Result;

Why exclude f16? Is there better choice for fp16?



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:19023
 
-// SHUFPS the element to the lowest double word, then movss.
-int Mask[4] = { static_cast(IdxVal), -1, -1, -1 };
+// SHUFPS the element to the lowest double word, then movsh.
+SmallVector Mask(VecVT.getVectorNumElements(), -1);

movss/movsh


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105263

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


[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

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



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:261
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; remove std::move()
+  return std::move(a);

whisperity wrote:
> MTC wrote:
> > Quuxplusone wrote:
> > > This warning is incorrect, as indicated in your PR summary. Isn't the 
> > > point of this PR mainly to remove this incorrect warning?
> > I guess what @Sockke wants to express is that applying `std::move` on the 
> > integer type makes no sense.
> Yes, but there is no //FixIt// for this warning, but even if the user fixes 
> this //manually// according to the warning, it'll result in
> 
> > error: cannot bind rvalue reference of type `int&&` to lvalue of type `int`
> 
> because `showInt` takes `int&&`!
> 
> So this is not just unfixable automatically (hence no `CHECK-FIXES` line), it 
> isn't fixable at all.
At a really high level, yeah, this code is bad code. :) But this is exactly 
Sockke's "case 1":
> A trivially-copyable object wrapped by std::move is passed to the function 
> with rvalue reference parameters. Removing std::move will cause compilation 
> errors.
So a warning here would have to be, like, "`std::move` of `a`, of trivially 
copyable type `int`, has no runtime effect; consider changing `showInt`'s 
parameter from `int&&` to `int`."
Also, should add a test case of the form
```
void showInt(int&&);
template void forwardToShowInt(T&& t) { showInt(static_cast(t)); }
void test() {
int a = 10;
forwardToShowInt(std::move(a));
}
```
to make sure the diagnostic (or lack thereof) plays well with templates. Here, 
refactoring `forwardToShowInt`'s parameter from `T&&` to `T` is unlikely to be 
a realistic option.


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

https://reviews.llvm.org/D107450

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


[clang] 5181be3 - [PowerPC][AIX] Limit attribute aligned to 4096.

2021-08-05 Thread Sean Fertile via cfe-commits

Author: Sean Fertile
Date: 2021-08-05T09:51:16-04:00
New Revision: 5181be344adbf7ba7dffc73526893d4e7750d34c

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

LOG: [PowerPC][AIX] Limit attribute aligned to 4096.

Limit the maximum alignment for attribute aligned to 4096 to match
the limit of the .align pseudo op in the system assembler.

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

Added: 
clang/test/Sema/aix-attr-aligned-limit.c

Modified: 
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 5cc5e5fb24413..e5d03d55a5d6f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4054,6 +4054,9 @@ void Sema::AddAlignedAttr(Decl *D, const 
AttributeCommonInfo &CI, Expr *E,
   unsigned MaximumAlignment = Sema::MaximumAlignment;
   if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF())
 MaximumAlignment = std::min(MaximumAlignment, 8192u);
+  else if (Context.getTargetInfo().getTriple().isOSAIX())
+MaximumAlignment = std::min(MaximumAlignment, 4096u);
+
   if (AlignVal > MaximumAlignment) {
 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
 << MaximumAlignment << E->getSourceRange();

diff  --git a/clang/test/Sema/aix-attr-aligned-limit.c 
b/clang/test/Sema/aix-attr-aligned-limit.c
new file mode 100644
index 0..3c9a0facf9e54
--- /dev/null
+++ b/clang/test/Sema/aix-attr-aligned-limit.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -fsyntax-only -verify %s
+//
+int a __attribute__((aligned(8192))); // expected-error {{requested alignment 
must be 4096 bytes or smaller}}



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


[PATCH] D107497: [PowerPC][AIX] Limit attribute aligned to 4096.

2021-08-05 Thread Sean Fertile via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5181be344adb: [PowerPC][AIX] Limit attribute aligned to 
4096. (authored by sfertile).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107497

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/aix-attr-aligned-limit.c


Index: clang/test/Sema/aix-attr-aligned-limit.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-aligned-limit.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -fsyntax-only -verify %s
+//
+int a __attribute__((aligned(8192))); // expected-error {{requested alignment 
must be 4096 bytes or smaller}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4054,6 +4054,9 @@
   unsigned MaximumAlignment = Sema::MaximumAlignment;
   if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF())
 MaximumAlignment = std::min(MaximumAlignment, 8192u);
+  else if (Context.getTargetInfo().getTriple().isOSAIX())
+MaximumAlignment = std::min(MaximumAlignment, 4096u);
+
   if (AlignVal > MaximumAlignment) {
 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
 << MaximumAlignment << E->getSourceRange();


Index: clang/test/Sema/aix-attr-aligned-limit.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-aligned-limit.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -fsyntax-only -verify %s
+//
+int a __attribute__((aligned(8192))); // expected-error {{requested alignment must be 4096 bytes or smaller}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4054,6 +4054,9 @@
   unsigned MaximumAlignment = Sema::MaximumAlignment;
   if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF())
 MaximumAlignment = std::min(MaximumAlignment, 8192u);
+  else if (Context.getTargetInfo().getTriple().isOSAIX())
+MaximumAlignment = std::min(MaximumAlignment, 4096u);
+
   if (AlignVal > MaximumAlignment) {
 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
 << MaximumAlignment << E->getSourceRange();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

2021-08-05 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:261
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect; remove std::move()
+  return std::move(a);

Quuxplusone wrote:
> whisperity wrote:
> > MTC wrote:
> > > Quuxplusone wrote:
> > > > This warning is incorrect, as indicated in your PR summary. Isn't the 
> > > > point of this PR mainly to remove this incorrect warning?
> > > I guess what @Sockke wants to express is that applying `std::move` on the 
> > > integer type makes no sense.
> > Yes, but there is no //FixIt// for this warning, but even if the user fixes 
> > this //manually// according to the warning, it'll result in
> > 
> > > error: cannot bind rvalue reference of type `int&&` to lvalue of type 
> > > `int`
> > 
> > because `showInt` takes `int&&`!
> > 
> > So this is not just unfixable automatically (hence no `CHECK-FIXES` line), 
> > it isn't fixable at all.
> At a really high level, yeah, this code is bad code. :) But this is exactly 
> Sockke's "case 1":
> > A trivially-copyable object wrapped by std::move is passed to the function 
> > with rvalue reference parameters. Removing std::move will cause compilation 
> > errors.
> So a warning here would have to be, like, "`std::move` of `a`, of trivially 
> copyable type `int`, has no runtime effect; consider changing `showInt`'s 
> parameter from `int&&` to `int`."
> Also, should add a test case of the form
> ```
> void showInt(int&&);
> template void forwardToShowInt(T&& t) { 
> showInt(static_cast(t)); }
> void test() {
> int a = 10;
> forwardToShowInt(std::move(a));
> }
> ```
> to make sure the diagnostic (or lack thereof) plays well with templates. 
> Here, refactoring `forwardToShowInt`'s parameter from `T&&` to `T` is 
> unlikely to be a realistic option.
Yes, I was thinking the same, maybe it could warn about the function (in a note 
or something). But then we reach the point that the check's name is //fuzzy// 
at best... (It has an already outdated name, though.)


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

https://reviews.llvm.org/D107450

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


[PATCH] D106343: [OpenCL] Support cl_ext_float_atomics

2021-08-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh requested changes to this revision.
svenvh added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Headers/opencl-c-base.h:24
 #define cl_khr_subgroup_clustered_reduce 1
+#define cl_ext_float_atomics
+#ifdef cl_khr_fp16

Anastasia wrote:
> svenvh wrote:
> > Should this be defined as `1`?
> > 
> > Should this define be tested in `clang/test/Headers/opencl-c-header.cl` too?
> Actually, now that I think more about this, it seems incorrect to add this 
> here without adding the functions to `OpenCLBuiltins.td` because then the 
> feature macro will be present without the feature when the default header is 
> used?
> 
> So I guess we either need to extend `OpenCLBuiltins.td` with new functions or 
> move the new macros into `opencl-c.h`?
Good catch!  Indeed, adding the define in the shared `opencl-c-base.h` without 
also providing the builtins through `OpenCLBuiltins.td` is incorrect.

The preferred solution would be to add the new builtins to 
`clang/lib/Sema/OpenCLBuiltins.td` too, to avoid diverging the header and 
tablegen-driven code paths.


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

https://reviews.llvm.org/D106343

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


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D107051#2928089 , @steakhal wrote:

> First and foremost, I think this is a great change. I think the diagnostic is 
> on the point.
> BTW it seems like you missed two notes in `misc-ps-region-store.m` causing a 
> test fail:
>
>   error: 'note' diagnostics seen but not expected:
> File 
> /home/steakhal/git/llvm-project/clang/test/Analysis/misc-ps-region-store.m 
> Line 464: Original object declared here
> File 
> /home/steakhal/git/llvm-project/clang/test/Analysis/misc-ps-region-store.m 
> Line 467: Original object 'test_cwe466_return_outofbounds_pointer_a' is an 
> array of 10 'int' objects, returned pointer points at index 11
>   2 errors generated.
>
>
>
> ---
>
> The following comments are not about your actual change, I'm rather pointing 
> out further possibilities for improving the checker.
>
> The checker seems to cover cases when we see the array, fine.
> What about pointers/references to arrays? IMO we should trust those 
> declarations about the size of the pointee.
>
>   using size_t = decltype(sizeof 1);
>   using int10 = int[10];
>   
>   template  void clang_analyzer_dump(T);
>   size_t clang_analyzer_getExtent(void *);
>   int conjure_index();
>   
>   
>   int *test_ptr_to_array(int10 *arr) {
> int x = conjure_index();
> if (x != 20)
>   return *arr; // no-warning
>   
> clang_analyzer_dump(clang_analyzer_getExtent(*arr));
> // expected-warning-re@-1 
> {{extent_${{[0-9]+}}{SymRegion{reg_${{[0-9]+}}
> // FIXME: Above should be '40 S64b' on Linux x86_64.
>   
> int *result = *arr + x;
> clang_analyzer_dump(result);
> // expected-warning-re@-1 {{&Element{SymRegion{reg_${{[0-9]+}} arr>},20 S64b,int}}}
> return result; // We should expect a warning here.
>   }
>
> Please add this test to your patch.
>
> It seems like the checker would catch it if 
> `MemRegionManager::getStaticSize()` would consider the type of the 
> `SymbolicRegion` for `ConstantArray` pointee types. I'll have a patch about 
> that.

It seems like we cannot implement this in a way fitting into the current memory 
model. To be able to do that we should be able to differentiate these two cases:

  void test(int10 *arr) {
clang_analyzer_dump((int*)(arr + 2)); // allow: `arr` might be a pointer to 
an array of `int10[100]`, in which case the resulting pointer is safe to use
clang_analyzer_dump(*arr + 20);   // disallow: `*arr` :: `int[10]`, 
creating a pointer to the 20th element
// Both dumps are the same:  &Element{SymRegion{reg_$0},20 
S64b,int}
  }

So, I'm actually puzzled about this. I think you can leave out the extra test 
case I proposed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

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


[clang] 91e3995 - Revert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test"

2021-08-05 Thread Fanbo Meng via cfe-commits

Author: Fanbo Meng
Date: 2021-08-05T10:14:02-04:00
New Revision: 91e399519580930623e1eb7be43374f0ba8aba41

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

LOG: Revert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) 
value for test"

This reverts commit d91234b21c1a1a34d98157089a8769d8f9a32f06.

Reviewed By: abhina.sreeskantharajan

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

Added: 


Modified: 
clang/test/Sema/struct-packed-align.c

Removed: 




diff  --git a/clang/test/Sema/struct-packed-align.c 
b/clang/test/Sema/struct-packed-align.c
index b4bddebe230e2..03b012e340287 100644
--- a/clang/test/Sema/struct-packed-align.c
+++ b/clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@ extern int e2[__alignof(struct as1) == 8 ? 1 : -1];
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) 
&& !defined(__ANDROID__)))
+#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! 
defined(__ANDROID__) ) )
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else



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


[PATCH] D107565: Revert "[SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test"

2021-08-05 Thread Fanbo Meng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91e399519580: Revert "[SystemZ][z/OS] Update target 
specific __attribute__((aligned)) value… (authored by fanbo-meng).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107565

Files:
  clang/test/Sema/struct-packed-align.c


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) 
&& !defined(__ANDROID__)))
+#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! 
defined(__ANDROID__) ) )
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) && !defined(__ANDROID__)))
+#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! defined(__ANDROID__) ) )
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-08-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks


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

https://reviews.llvm.org/D106785

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 364242.
gandhi21299 added a comment.

- added more negative tests
- fixed some tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx1030.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-unsupported-gfx7.cl
  clang/test/CodeGenOpenCL/unsupported-fadd2f16-gfx908.cl
  clang/test/CodeGenOpenCL/unsupported-fadd32-gfx908.cl
  clang/test/CodeGenOpenCL/unsupported-fadd64-flat-gfx908.cl
  clang/test/CodeGenOpenCL/unsupported-fadd64-gfx908.cl
  clang/test/CodeGenOpenCL/unsupported-fmax64-flat-gfx908.cl
  clang/test/CodeGenOpenCL/unsupported-fmax64-gfx908.cl
  clang/test/CodeGenOpenCL/unsupported-fmin64-flat-gfx908.cl
  clang/test/CodeGenOpenCL/unsupported-fmin64-gfx908.cl

Index: clang/test/CodeGenOpenCL/unsupported-fmin64-gfx908.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/unsupported-fmin64-gfx908.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx908 \
+// RUN:   -verify -S -o - %s
+
+void test_global_min_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmin_f64(addr, x); // expected-error{{'__builtin_amdgcn_global_atomic_fmin_f64' needs target feature gfx90a-insts}}
+}
Index: clang/test/CodeGenOpenCL/unsupported-fmin64-flat-gfx908.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/unsupported-fmin64-flat-gfx908.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx908 \
+// RUN:   -verify -S -o - %s
+
+void test_flat_min_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x); // expected-error{{'__builtin_amdgcn_flat_atomic_fmin_f64' needs target feature gfx90a-insts}}
+}
Index: clang/test/CodeGenOpenCL/unsupported-fmax64-gfx908.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/unsupported-fmax64-gfx908.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx908 \
+// RUN:   -verify -S -o - %s
+
+void test_global_max_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmax_f64(addr, x); // expected-error{{'__builtin_amdgcn_global_atomic_fmax_f64' needs target feature gfx90a-insts}}
+}
Index: clang/test/CodeGenOpenCL/unsupported-fmax64-flat-gfx908.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/unsupported-fmax64-flat-gfx908.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx908 \
+// RUN:   -verify -S -o - %s
+
+void test_flat_max_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmax_f64(addr, x); // expected-error{{'__builtin_amdgcn_flat_atomic_fmax_f64' needs target feature gfx90a-insts}}
+}
Index: clang/test/CodeGenOpenCL/unsupported-fadd64-gfx908.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/unsupported-fadd64-gfx908.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx908 \
+// RUN:   -verify -S -o - %s
+
+void test_global_add_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_f64(addr, x); // expected-error{{'__builtin_amdgcn_global_atomic_fadd_f64' needs target feature gfx90a-insts}}
+}
Index: clang/test/CodeGenOpenCL/unsupported-fadd64-flat-gfx908.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/unsupported-fadd64-flat-gfx908.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx908 \
+// RUN:   -verify -S -o - %s
+
+void test_flat_add_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x); // expected-error{{'__builtin_amdgcn_flat_atomic_fadd_f64' needs target feature gfx90a-insts}}
+}
Index: clang/test/CodeGenOpenCL/unsupported-fadd32-gfx908.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/unsupported-fadd32-gfx908.cl
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %c

[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: clang/test/CodeGenOpenCL/builtins-fp-atomics-unsupported-gfx7.cl:8
+}
\ No newline at end of file


Add new line.



Comment at: clang/test/CodeGenOpenCL/unsupported-fadd2f16-gfx908.cl:1
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu 
gfx908 \

Combine all of these gfx908 error tests into a single file. For example like in 
the builtins-amdgcn-dl-insts-err.cl. It is also better to rename these test 
filenames to follow the existing pattern: builtins-amdgcn-*-err.cl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-05 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 364256.
gandhi21299 added a comment.

- fixed remarks in SIISelLowering for hw instruction generation
- fixed test accordingly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/test/CodeGen/AMDGPU/fp-atomics-remarks-gfx90a.ll
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -16,15 +16,20 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -10,13 +10,18 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -44,6 +44,11 @@
 ; GCN-O0-NEXT:Lower OpenCL enqueued blocks
 ; GCN-O0-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O0-NEXT:FunctionPass Manager
+; GCN-O0-NEXT:  Dominator Tree Construction
+; GCN-O0-NEXT:  Natural Loop Information
+; GCN-O0-NEXT:  Lazy Branch Probability Analysis
+; GCN-O0-NEXT:  Lazy Block Frequency Analysis
+; GCN-O0-NEXT:  Optimization Remark Emitter
 ; GCN-O0-NEXT:  Expand Atomic instructions
 ; GCN-O0-NEXT:  Lower constant intrinsics
 ; GCN-O0-NEXT:  Remove unreachable blocks from the CFG
@@ -180,6 +185,11 @@
 ; GCN-O1-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-NEXT:FunctionPass Manager
 ; GCN-O1-NEXT:  Infer address spaces
+; GCN-O1-NEXT:  Dominator Tree Construction
+; GCN-O1-NEXT:  Natural Loop Information
+; GCN-O1-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-NEXT:  Optimization Remark Emitter
 ; GCN-O1-NEXT:  Expand Atomic instructions
 ; GCN-O1-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-NEXT:  Dominator Tree Construction
@@ -431,6 +441,11 @@
 ; GCN-O1-OPTS-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-OPTS-NEXT:FunctionPass Manager
 ; GCN-O1-OPTS-NEXT:  Infer address spaces
+; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
+; GCN-O1-OPTS-NEXT:  Natural Loop Information
+; GCN-O1-OPTS-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-OPTS-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-OPTS-NEXT:  Optimizatio

[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks for FP atomics

2021-08-05 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12146
+OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+Remark << "A floating-point atomic instruction will generate an unsafe"
+  " hardware instruction";

It would not necessarily generate a HW instruction. There are still cases where 
we return CmpXChg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 364266.
gandhi21299 added a comment.

- combined tests into a single file
- renamed tests for consistency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-fp-atomics-gfx7-err.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-fp-atomics-gfx908-err.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx1030.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl

Index: clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   %s -S -emit-llvm -o - | FileCheck %s -check-prefix=CHECK
+
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   -S -o - %s | FileCheck -check-prefix=GFX90A %s
+
+typedef half __attribute__((ext_vector_type(2))) half2;
+
+// CHECK-LABEL: test_global_add_f64
+// CHECK: call double @llvm.amdgcn.global.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_add_f64$local:
+// GFX90A:  global_atomic_add_f64
+void test_global_add_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_f64(addr, x);
+}
+
+// CHECK-LABEL: test_global_add_half2
+// CHECK: call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1v2f16.v2f16(<2 x half> addrspace(1)* %{{.*}}, <2 x half> %{{.*}})
+// GFX90A-LABEL:  test_global_add_half2
+// GFX90A:  global_atomic_pk_add_f16 v2, v[0:1], v2, off glc
+void test_global_add_half2(__global half2 *addr, half2 x) {
+  half2 *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_v2f16(addr, x);
+}
+
+// CHECK-LABEL: test_global_global_min_f64
+// CHECK: call double @llvm.amdgcn.global.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_global_min_f64$local
+// GFX90A:  global_atomic_min_f64
+void test_global_global_min_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmin_f64(addr, x);
+}
+
+// CHECK-LABEL: test_global_max_f64
+// CHECK: call double @llvm.amdgcn.global.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_max_f64$local
+// GFX90A:  global_atomic_max_f64
+void test_global_max_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmax_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_add_local_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p3f64.f64(double addrspace(3)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_add_local_f64$local
+// GFX90A:  ds_add_rtn_f64
+void test_flat_add_local_f64(__local double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_global_add_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_global_add_f64$local
+// GFX90A:  global_atomic_add_f64
+void test_flat_global_add_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_min_flat_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_min_flat_f64$local
+// GFX90A:  flat_atomic_min_f64
+void test_flat_min_flat_f64(__generic double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_global_min_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_global_min_f64$local
+// GFX90A:  global_atomic_min_f64
+void test_flat_global_min_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_max_flat_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmax.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_max_flat_f64$local
+// GFX90A:  flat_atomic_max_f64
+void test_flat_max_flat_f64(__generic double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmax_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_global_max_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_global_max_f64$local
+// GFX90A:  global_atomic_max_f64
+void test_flat_global_max_f64(__global double *addr, double x){
+  doubl

[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec accepted this revision.
rampitec added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

Thanks a lot for the review, I will merge this patch in :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Anshil Gandhi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39dac1f7f656: [clang] Add clang builtins support for gfx90a 
(authored by gandhi21299).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-fp-atomics-gfx7-err.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-fp-atomics-gfx908-err.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx1030.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx8.cl
  clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl

Index: clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx90a.cl
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   %s -S -emit-llvm -o - | FileCheck %s -check-prefix=CHECK
+
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   -S -o - %s | FileCheck -check-prefix=GFX90A %s
+
+typedef half __attribute__((ext_vector_type(2))) half2;
+
+// CHECK-LABEL: test_global_add_f64
+// CHECK: call double @llvm.amdgcn.global.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_add_f64$local:
+// GFX90A:  global_atomic_add_f64
+void test_global_add_f64(__global double *addr, double x) {
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_f64(addr, x);
+}
+
+// CHECK-LABEL: test_global_add_half2
+// CHECK: call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1v2f16.v2f16(<2 x half> addrspace(1)* %{{.*}}, <2 x half> %{{.*}})
+// GFX90A-LABEL:  test_global_add_half2
+// GFX90A:  global_atomic_pk_add_f16 v2, v[0:1], v2, off glc
+void test_global_add_half2(__global half2 *addr, half2 x) {
+  half2 *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fadd_v2f16(addr, x);
+}
+
+// CHECK-LABEL: test_global_global_min_f64
+// CHECK: call double @llvm.amdgcn.global.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_global_min_f64$local
+// GFX90A:  global_atomic_min_f64
+void test_global_global_min_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmin_f64(addr, x);
+}
+
+// CHECK-LABEL: test_global_max_f64
+// CHECK: call double @llvm.amdgcn.global.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_max_f64$local
+// GFX90A:  global_atomic_max_f64
+void test_global_max_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_global_atomic_fmax_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_add_local_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p3f64.f64(double addrspace(3)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_add_local_f64$local
+// GFX90A:  ds_add_rtn_f64
+void test_flat_add_local_f64(__local double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_global_add_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_global_add_f64$local
+// GFX90A:  global_atomic_add_f64
+void test_flat_global_add_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fadd_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_min_flat_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_min_flat_f64$local
+// GFX90A:  flat_atomic_min_f64
+void test_flat_min_flat_f64(__generic double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_global_min_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_global_min_f64$local
+// GFX90A:  global_atomic_min_f64
+void test_flat_global_min_f64(__global double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmin_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_max_flat_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmax.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_max_flat_f64$local
+// GFX90A:  flat_atomic_max_f64
+void test_flat_max_flat_f64(__generic double *addr, double x){
+  double *rtn;
+  *rtn = __builtin_amdgcn_flat_atomic_fmax_f64(addr, x);
+}
+
+// CHECK-LABEL: test_flat_global_max_f64
+// CHECK: call double @llvm.amdgcn.flat.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_global_max_f64$local
+// GFX90A:  global_atomic_max_f64
+void test_flat_global_max_f64(__global d

[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-08-05 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

I will merge this patch in as soon as the builds are successful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-08-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

If the original memory object is not known the static size is not known too. 
Every pointer with unknown source can point into a bigger data structure.




Comment at: clang/test/Analysis/return-ptr-range.cpp:11
+int *test_global_ptr() {
+  do { // expected-note{{Loop condition is false.  Exiting loop}}
 int x = conjure_index();

steakhal wrote:
> I would rather use a simple block `{...}` for opening a scope, but I don't 
> know why you don't declare `ptr` in the original scope in the first place.
> People usually use `do {} while(0)` constructs if they want to use `break` 
> somewhere ~~ like a `goto` OR they implement a macro. You are doing none of 
> these.
I do not know why these loops are here but did not change the original code. 
Should we change it to simple block?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

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


[PATCH] D107558: [clang] [clang-repl] Fix linking against LLVMLineEditor

2021-08-05 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

Thanks!


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

https://reviews.llvm.org/D107558

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


[PATCH] D107461: [PowerPC] Do not define __PRIVILEGED__

2021-08-05 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

> x64 debian > Clang.Driver::ppc-mprivileged-support-check.c

The changed test is failing ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107461

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


[PATCH] D106550: [PowerPC] Allow MMA builtins to accept restrict qualified pointers

2021-08-05 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 364467.
saghir added a comment.

Addressed review comments. Added another test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106550

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/ppc-pair-mma-types.c


Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -333,3 +333,13 @@
   __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing 
'__vector int' (vector of 4 'int' values) to parameter of incompatible type 
'const __vector_pair *'}}
   __builtin_vsx_stxvp(vp, ll, s);   // expected-error {{passing 
'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
 }
+
+void testRestrictQualifiedPointer1(int *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 
'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+}
+
+void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7324,9 +7324,22 @@
 Expr *Arg = TheCall->getArg(ArgNum);
 QualType ArgType = Arg->getType();
 
-if ((ExpectedType->isVoidPointerType() && !ArgType->isPointerType()) ||
-(!ExpectedType->isVoidPointerType() &&
-   ArgType.getCanonicalType() != ExpectedType))
+// Checks if the argument type is valid. Returns true if it is valid
+// and false if it is not valid.
+auto IsValidType = [ArgType, ExpectedType]() {
+  if (ExpectedType->isVoidPointerType() && !ArgType->isPointerType())
+return false;
+  if (!ExpectedType->isVoidPointerType()) {
+if (ArgType.isRestrictQualified() &&
+ArgType.getCanonicalType().getUnqualifiedType() == ExpectedType)
+  return true;
+if (ArgType.getCanonicalType() != ExpectedType)
+  return false;
+  }
+  return true;
+};
+
+if (!IsValidType())
   return Diag(Arg->getBeginLoc(), diag::err_typecheck_convert_incompatible)
  << ArgType << ExpectedType << 1 << 0 << 0;
 


Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -333,3 +333,13 @@
   __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
   __builtin_vsx_stxvp(vp, ll, s);   // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
 }
+
+void testRestrictQualifiedPointer1(int *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+}
+
+void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
+  vector float arr[4];
+  __builtin_mma_disassemble_acc((void*)arr, acc);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7324,9 +7324,22 @@
 Expr *Arg = TheCall->getArg(ArgNum);
 QualType ArgType = Arg->getType();
 
-if ((ExpectedType->isVoidPointerType() && !ArgType->isPointerType()) ||
-(!ExpectedType->isVoidPointerType() &&
-   ArgType.getCanonicalType() != ExpectedType))
+// Checks if the argument type is valid. Returns true if it is valid
+// and false if it is not valid.
+auto IsValidType = [ArgType, ExpectedType]() {
+  if (ExpectedType->isVoidPointerType() && !ArgType->isPointerType())
+return false;
+  if (!ExpectedType->isVoidPointerType()) {
+if (ArgType.isRestrictQualified() &&
+ArgType.getCanonicalType().getUnqualifiedType() == ExpectedType)
+  return true;
+if (ArgType.getCanonicalType() != ExpectedType)
+  return false;
+  }
+  return true;
+};
+
+if (!IsValidType())
   return Diag(Arg->getBeginLoc(), diag::err_typecheck_convert_incompatible)
  << ArgType << ExpectedType << 1 << 0 << 0;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d99e946 - [clang] [clang-repl] Fix linking against LLVMLineEditor

2021-08-05 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2021-08-05T16:51:47+02:00
New Revision: d99e9461b07988914cba573800cd1862f277e155

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

LOG: [clang] [clang-repl] Fix linking against LLVMLineEditor

LLVMLineEditor library is part of the LLVM dylib.  Move it into
LLVM_LINK_COMPONENTS to avoid duplicate linking when dylib is being
used.  This fixes building standalone clang against installed LLVM
without static libraries.

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

Added: 


Modified: 
clang/tools/clang-repl/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-repl/CMakeLists.txt 
b/clang/tools/clang-repl/CMakeLists.txt
index ae0e4f39be70f..c2576d7c564d9 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -1,6 +1,7 @@
 set( LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Core
+  LineEditor
   Option
   OrcJIT
   Support
@@ -14,5 +15,4 @@ clang_target_link_libraries(clang-repl PUBLIC
   clangBasic
   clangInterpreter
   clangTooling
-  LLVMLineEditor
   )



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


[PATCH] D107558: [clang] [clang-repl] Fix linking against LLVMLineEditor

2021-08-05 Thread Michał Górny via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd99e9461b079: [clang] [clang-repl] Fix linking against 
LLVMLineEditor (authored by mgorny).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107558

Files:
  clang/tools/clang-repl/CMakeLists.txt


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -1,6 +1,7 @@
 set( LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Core
+  LineEditor
   Option
   OrcJIT
   Support
@@ -14,5 +15,4 @@
   clangBasic
   clangInterpreter
   clangTooling
-  LLVMLineEditor
   )


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -1,6 +1,7 @@
 set( LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Core
+  LineEditor
   Option
   OrcJIT
   Support
@@ -14,5 +15,4 @@
   clangBasic
   clangInterpreter
   clangTooling
-  LLVMLineEditor
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D107051#2928536 , @balazske wrote:

> If the original memory object is not known the static size is not known too. 
> Every pointer with unknown source can point into a bigger data structure.

You are right, but IMO pointers to arrays are so rare that we could probably 
trust them. At least, that was my idea.




Comment at: clang/test/Analysis/return-ptr-range.cpp:11
+int *test_global_ptr() {
+  do { // expected-note{{Loop condition is false.  Exiting loop}}
 int x = conjure_index();

balazske wrote:
> steakhal wrote:
> > I would rather use a simple block `{...}` for opening a scope, but I don't 
> > know why you don't declare `ptr` in the original scope in the first place.
> > People usually use `do {} while(0)` constructs if they want to use `break` 
> > somewhere ~~ like a `goto` OR they implement a macro. You are doing none of 
> > these.
> I do not know why these loops are here but did not change the original code. 
> Should we change it to simple block?
Yes, please. The note for the loop is only noise in its current form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

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


[PATCH] D105821: [analyzer] [WIP] Model destructor for std::unique_ptr

2021-08-05 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 364486.
RedDocMD added a comment.

Bug fix in modelling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105821

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -753,10 +753,13 @@
 *Call, *this);
 
   ExplodedNodeSet DstInvalidated;
-  StmtNodeBuilder Bldr(DstPreCall, DstInvalidated, *currBldrCtx);
-  for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E = DstPreCall.end();
-   I != E; ++I)
-defaultEvalCall(Bldr, *I, *Call, CallOpts);
+  // StmtNodeBuilder Bldr(DstPreCall, DstInvalidated, *currBldrCtx);
+  // for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E =
+  // DstPreCall.end();
+  //  I != E; ++I)
+  //   defaultEvalCall(Bldr, *I, *Call, CallOpts);
+  getCheckerManager().runCheckersForEvalCall(DstInvalidated, DstPreCall, *Call,
+ *this, CallOpts);
 
   getCheckerManager().runCheckersForPostCall(Dst, DstInvalidated,
  *Call, *this);
Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -664,14 +664,11 @@
 for (const auto &EvalCallChecker : EvalCallCheckers) {
   // TODO: Support the situation when the call doesn't correspond
   // to any Expr.
-  ProgramPoint L = ProgramPoint::getProgramPoint(
-  Call.getOriginExpr(), ProgramPoint::PostStmtKind,
-  Pred->getLocationContext(), EvalCallChecker.Checker);
   bool evaluated = false;
   { // CheckerContext generates transitions(populates checkDest) on
 // destruction, so introduce the scope to make sure it gets properly
 // populated.
-CheckerContext C(B, Eng, Pred, L);
+CheckerContext C(B, Eng, Pred, Call.getProgramPoint());
 evaluated = EvalCallChecker(Call, C);
   }
   assert(!(evaluated && anyEvaluated)
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -139,7 +139,7 @@
 
   if (RD->getDeclName().isIdentifier()) {
 StringRef Name = RD->getName();
-return Name == "shared_ptr" || Name == "unique_ptr" || Name == "weak_ptr";
+return llvm::is_contained(STD_PTR_NAMES, Name);
   }
   return false;
 }
@@ -275,6 +275,29 @@
  smartptr::isStdSmartPtr(Call.getArgExpr(1));
 }
 
+std::pair
+invalidateInnerPointer(const MemRegion *ThisRegion, ProgramStateRef State,
+   const CallEvent &Call, CheckerContext &C) {
+  const auto *InnerPtrVal = State->get(ThisRegion);
+  if (InnerPtrVal) {
+State = State->invalidateRegions(*InnerPtrVal, nullptr, C.blockCount(),
+ C.getLocationContext(), true);
+
+const QualType &Type = getInnerPointerType(Call, C);
+const auto *RD = Type->getAsCXXRecordDecl();
+if (!RD)
+  return {State, false};
+const auto *DD = RD->getDestructor();
+
+const auto InnerDestrCall =
+C.getStateManager().getCallEventManager().getCXXDestructorCall(
+DD, nullptr, InnerPtrVal->getAsRegion(), RD->bases().empty(), State,
+C.getLocationContext());
+InnerDestrCall->invalidateRegions(C.blockCount(), State);
+  }
+  return {State, true};
+}
+
 bool SmartPtrModeling::evalCall(const CallEvent &Call,
 CheckerContext &C) const {
 
@@ -372,6 +395,23 @@
 }
   }
 
+  if (const auto *DC = dyn_cast(&Call)) {
+const MemRegion *ThisRegion = DC->getCXXThisVal().getAsRegion();
+if (!ThisRegion)
+  return false;
+State = State->remove(ThisRegion);
+bool ShouldGiveUp;
+std::tie(State, ShouldGiveUp) =
+invalidateInnerPointer(ThisRegion, State, Call, C);
+// This tag is required to prevent later crashes due to the non-addition
+// of new States. Having a tag ensures that the call to addTransition
+// actually adds a new state.
+static SimpleProgramPointTag SPPT("SmartPtrModeling",
+  "on destructor modeling");
+C.addTransition(State, &SPPT);
+return !ShouldGiveUp;
+  }
+
   if (!ModelSmartPtrDereference)
 return false;
 
@@ -402,10 +442,14 @@
   }));
 } else {
   const auto *TrackingExpr = Call.getArgExpr(0);
-  assert(Tracki

[clang] f888e44 - [PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

2021-08-05 Thread Sean Fertile via cfe-commits

Author: Sean Fertile
Date: 2021-08-05T11:15:12-04:00
New Revision: f888e442bcc547301b58e77667eb261c0391b897

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

LOG: [PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

On AIX an aligned attribute cannot decrease the alignment of a variable
when placed on a variable declaration of vector type.

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

Added: 
clang/test/CodeGen/aix-vector-attr-aligned.c
clang/test/Sema/aix-attr-aligned-vector-warn.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 71e7ffdbe8a08..247f9d715b846 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2986,6 +2986,8 @@ def err_alignas_mismatch : Error<
   "redeclaration has 
diff erent alignment requirement (%1 vs %0)">;
 def err_alignas_underaligned : Error<
   "requested alignment is less than minimum alignment of %1 for type %0">;
+def warn_aligned_attr_underaligned : Warning,
+  InGroup;
 def err_attribute_sizeless_type : Error<
   "%0 attribute cannot be applied to sizeless type %1">;
 def err_attribute_argument_n_type : Error<

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e5d03d55a5d6f..5098c3900aeb2 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4063,12 +4063,12 @@ void Sema::AddAlignedAttr(Decl *D, const 
AttributeCommonInfo &CI, Expr *E,
 return;
   }
 
-  if (Context.getTargetInfo().isTLSSupported()) {
+  const auto *VD = dyn_cast(D);
+  if (VD && Context.getTargetInfo().isTLSSupported()) {
 unsigned MaxTLSAlign =
 Context.toCharUnitsFromBits(Context.getTargetInfo().getMaxTLSAlign())
 .getQuantity();
-const auto *VD = dyn_cast(D);
-if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
+if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
 VD->getTLSKind() != VarDecl::TLS_None) {
   Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
   << (unsigned)AlignVal << VD << MaxTLSAlign;
@@ -4076,6 +4076,17 @@ void Sema::AddAlignedAttr(Decl *D, const 
AttributeCommonInfo &CI, Expr *E,
 }
   }
 
+  // On AIX, an aligned attribute can not decrease the alignment when applied
+  // to a variable declaration with vector type.
+  if (VD && Context.getTargetInfo().getTriple().isOSAIX()) {
+const Type *Ty = VD->getType().getTypePtr();
+if (Ty->isVectorType() && AlignVal < 16) {
+  Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
+  << VD->getType() << 16;
+  return;
+}
+  }
+
   AlignedAttr *AA = ::new (Context) AlignedAttr(Context, CI, true, ICE.get());
   AA->setPackExpansion(IsPackExpansion);
   D->addAttr(AA);

diff  --git a/clang/test/CodeGen/aix-vector-attr-aligned.c 
b/clang/test/CodeGen/aix-vector-attr-aligned.c
new file mode 100644
index 0..462fb7a3b019c
--- /dev/null
+++ b/clang/test/CodeGen/aix-vector-attr-aligned.c
@@ -0,0 +1,33 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-feature +altivec 
-target-cpu pwr7 -emit-llvm -o - %s | \
+// RUN:   FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-feature +altivec 
-target-cpu pwr7 -emit-llvm -o - %s | \
+// RUN:   FileCheck %s
+
+typedef vector int __attribute__((aligned(8))) UnderAlignedVI;
+
+vector int g32 __attribute__((aligned(32)));
+vector int g8 __attribute__((aligned(8)));
+UnderAlignedVI TypedefedGlobal;
+
+int escape(vector int*);
+
+int local32(void) {
+  vector int l32 __attribute__((aligned(32)));
+  return escape(&l32);
+}
+
+int local8(void) {
+  vector int l8 __attribute__((aligned(8)));
+  return escape(&l8);
+}
+
+// CHECK: @g32 = global <4 x i32> zeroinitializer, align 32
+// CHECK: @g8 = global <4 x i32> zeroinitializer, align 16
+// CHECK: @TypedefedGlobal = global <4 x i32> zeroinitializer, align 8
+
+// CHECK-LABEL: @local32
+// CHECK: %l32 = alloca <4 x i32>, align 32
+//
+// CHECK-LABEL: @local8
+// CHECK: %l8 = alloca <4 x i32>, align 16

diff  --git a/clang/test/Sema/aix-attr-aligned-vector-warn.c 
b/clang/test/Sema/aix-attr-aligned-vector-warn.c
new file mode 100644
index 0..af2e1a89268a2
--- /dev/null
+++ b/clang/test/Sema/aix-attr-aligned-vector-warn.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-feature +altivec 
-target-cpu pwr7 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-feature +altivec 
-target-cpu pwr7 -verify -fsyntax-only %s
+
+int escap

[PATCH] D107522: [PowerPC][AIX] attribute aligned cannot decrease align of a vector var.

2021-08-05 Thread Sean Fertile via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sfertile marked an inline comment as done.
Closed by commit rGf888e442bcc5: [PowerPC][AIX] attribute aligned cannot 
decrease align of a vector var. (authored by sfertile).

Changed prior to commit:
  https://reviews.llvm.org/D107522?vs=364436&id=364489#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107522

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-vector-attr-aligned.c
  clang/test/Sema/aix-attr-aligned-vector-warn.c

Index: clang/test/Sema/aix-attr-aligned-vector-warn.c
===
--- /dev/null
+++ clang/test/Sema/aix-attr-aligned-vector-warn.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-feature +altivec -target-cpu pwr7 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-feature +altivec -target-cpu pwr7 -verify -fsyntax-only %s
+
+int escape(vector int*);
+
+typedef vector int __attribute__((aligned(8))) UnderAlignedVI;
+UnderAlignedVI TypedefedGlobal;
+
+vector int V __attribute__((aligned(8))); // expected-warning {{requested alignment is less than minimum alignment of 16 for type '__vector int' (vector of 4 'int' values)}}
+
+int localTypedefed(void) {
+  UnderAlignedVI TypedefedLocal;
+  return escape(&TypedefedLocal); // expected-warning {{passing 8-byte aligned argument to 16-byte aligned parameter 1 of 'escape' may result in an unaligned pointer access}}
+}
Index: clang/test/CodeGen/aix-vector-attr-aligned.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-vector-attr-aligned.c
@@ -0,0 +1,33 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-feature +altivec -target-cpu pwr7 -emit-llvm -o - %s | \
+// RUN:   FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-feature +altivec -target-cpu pwr7 -emit-llvm -o - %s | \
+// RUN:   FileCheck %s
+
+typedef vector int __attribute__((aligned(8))) UnderAlignedVI;
+
+vector int g32 __attribute__((aligned(32)));
+vector int g8 __attribute__((aligned(8)));
+UnderAlignedVI TypedefedGlobal;
+
+int escape(vector int*);
+
+int local32(void) {
+  vector int l32 __attribute__((aligned(32)));
+  return escape(&l32);
+}
+
+int local8(void) {
+  vector int l8 __attribute__((aligned(8)));
+  return escape(&l8);
+}
+
+// CHECK: @g32 = global <4 x i32> zeroinitializer, align 32
+// CHECK: @g8 = global <4 x i32> zeroinitializer, align 16
+// CHECK: @TypedefedGlobal = global <4 x i32> zeroinitializer, align 8
+
+// CHECK-LABEL: @local32
+// CHECK: %l32 = alloca <4 x i32>, align 32
+//
+// CHECK-LABEL: @local8
+// CHECK: %l8 = alloca <4 x i32>, align 16
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4063,12 +4063,12 @@
 return;
   }
 
-  if (Context.getTargetInfo().isTLSSupported()) {
+  const auto *VD = dyn_cast(D);
+  if (VD && Context.getTargetInfo().isTLSSupported()) {
 unsigned MaxTLSAlign =
 Context.toCharUnitsFromBits(Context.getTargetInfo().getMaxTLSAlign())
 .getQuantity();
-const auto *VD = dyn_cast(D);
-if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
+if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
 VD->getTLSKind() != VarDecl::TLS_None) {
   Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
   << (unsigned)AlignVal << VD << MaxTLSAlign;
@@ -4076,6 +4076,17 @@
 }
   }
 
+  // On AIX, an aligned attribute can not decrease the alignment when applied
+  // to a variable declaration with vector type.
+  if (VD && Context.getTargetInfo().getTriple().isOSAIX()) {
+const Type *Ty = VD->getType().getTypePtr();
+if (Ty->isVectorType() && AlignVal < 16) {
+  Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
+  << VD->getType() << 16;
+  return;
+}
+  }
+
   AlignedAttr *AA = ::new (Context) AlignedAttr(Context, CI, true, ICE.get());
   AA->setPackExpansion(IsPackExpansion);
   D->addAttr(AA);
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2986,6 +2986,8 @@
   "redeclaration has different alignment requirement (%1 vs %0)">;
 def err_alignas_underaligned : Error<
   "requested alignment is less than minimum alignment of %1 for type %0">;
+def warn_aligned_attr_underaligned : Warning,
+  InGroup;
 def err_attribute_sizeless_type : Error<
   "%0 attribute cannot be applied to sizeless type %1">;
 def err_attribute_argument_n_type : Error<
___

[PATCH] D105821: [analyzer] [WIP] Model destructor for std::unique_ptr

2021-08-05 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 364490.
RedDocMD added a comment.

Never gonna give you up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105821

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -753,10 +753,13 @@
 *Call, *this);
 
   ExplodedNodeSet DstInvalidated;
-  StmtNodeBuilder Bldr(DstPreCall, DstInvalidated, *currBldrCtx);
-  for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E = DstPreCall.end();
-   I != E; ++I)
-defaultEvalCall(Bldr, *I, *Call, CallOpts);
+  // StmtNodeBuilder Bldr(DstPreCall, DstInvalidated, *currBldrCtx);
+  // for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E =
+  // DstPreCall.end();
+  //  I != E; ++I)
+  //   defaultEvalCall(Bldr, *I, *Call, CallOpts);
+  getCheckerManager().runCheckersForEvalCall(DstInvalidated, DstPreCall, *Call,
+ *this, CallOpts);
 
   getCheckerManager().runCheckersForPostCall(Dst, DstInvalidated,
  *Call, *this);
Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -664,14 +664,11 @@
 for (const auto &EvalCallChecker : EvalCallCheckers) {
   // TODO: Support the situation when the call doesn't correspond
   // to any Expr.
-  ProgramPoint L = ProgramPoint::getProgramPoint(
-  Call.getOriginExpr(), ProgramPoint::PostStmtKind,
-  Pred->getLocationContext(), EvalCallChecker.Checker);
   bool evaluated = false;
   { // CheckerContext generates transitions(populates checkDest) on
 // destruction, so introduce the scope to make sure it gets properly
 // populated.
-CheckerContext C(B, Eng, Pred, L);
+CheckerContext C(B, Eng, Pred, Call.getProgramPoint());
 evaluated = EvalCallChecker(Call, C);
   }
   assert(!(evaluated && anyEvaluated)
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -139,7 +139,7 @@
 
   if (RD->getDeclName().isIdentifier()) {
 StringRef Name = RD->getName();
-return Name == "shared_ptr" || Name == "unique_ptr" || Name == "weak_ptr";
+return llvm::is_contained(STD_PTR_NAMES, Name);
   }
   return false;
 }
@@ -275,6 +275,29 @@
  smartptr::isStdSmartPtr(Call.getArgExpr(1));
 }
 
+ProgramStateRef
+invalidateInnerPointer(const MemRegion *ThisRegion, ProgramStateRef State,
+   const CallEvent &Call, CheckerContext &C) {
+  const auto *InnerPtrVal = State->get(ThisRegion);
+  if (InnerPtrVal) {
+State = State->invalidateRegions(*InnerPtrVal, nullptr, C.blockCount(),
+ C.getLocationContext(), true);
+
+const QualType &Type = getInnerPointerType(Call, C);
+const auto *RD = Type->getAsCXXRecordDecl();
+if (!RD)
+  return State;
+const auto *DD = RD->getDestructor();
+
+const auto InnerDestrCall =
+C.getStateManager().getCallEventManager().getCXXDestructorCall(
+DD, nullptr, InnerPtrVal->getAsRegion(), RD->bases().empty(), State,
+C.getLocationContext());
+InnerDestrCall->invalidateRegions(C.blockCount(), State);
+  }
+  return State;
+}
+
 bool SmartPtrModeling::evalCall(const CallEvent &Call,
 CheckerContext &C) const {
 
@@ -372,6 +395,21 @@
 }
   }
 
+  if (const auto *DC = dyn_cast(&Call)) {
+const MemRegion *ThisRegion = DC->getCXXThisVal().getAsRegion();
+if (!ThisRegion)
+  return false;
+State = State->remove(ThisRegion);
+State = invalidateInnerPointer(ThisRegion, State, Call, C);
+// This tag is required to prevent later crashes due to the non-addition
+// of new States. Having a tag ensures that the call to addTransition
+// actually adds a new state.
+static SimpleProgramPointTag SPPT("SmartPtrModeling",
+  "on destructor modeling");
+C.addTransition(State, &SPPT);
+return true;
+  }
+
   if (!ModelSmartPtrDereference)
 return false;
 
@@ -402,10 +440,14 @@
   }));
 } else {
   const auto *TrackingExpr = Call.getArgExpr(0);
-  assert(TrackingExpr->getType()->isPointerType() &&
- "Adding a non pointer

[PATCH] D107294: [clang-tidy] adds warning to suggest users replace symbols with words

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp:133-134
 "readability-uppercase-literal-suffix");
+CheckFactories.registerCheck(
+"readability-use-alternative-tokens");
 CheckFactories.registerCheck(

whisperity wrote:
> cjdb wrote:
> > aaron.ballman wrote:
> > > I think this might be a case where we want the check to either recommend 
> > > using alternative tokens or recommend against using alternative tokens 
> > > via a configuration option (so users can control readability in either 
> > > direction). If you agree that's a reasonable design, then I'd recommend 
> > > we name this `readability-alternative-tokens` to be a bit more generic. 
> > > (Note, we can always do the "don't use alternative tokens" implementation 
> > > in a follow-up patch if you don't want to do that work immediately.)
> > Hrmm I'll do the rename now, but this might be better off as a later 
> > patch. I'd rather focus on getting what I have right (along with my teased 
> > extensions) and then work on the opposite direction. That will (probably) 
> > be an easy slip-in.
> (As someone who's had checkers on review for multiple years I've no hard 
> feelings about the scheduling.)
> 
> But please do add a few `FIXME:` or `TODO:` or `IDEA:` or some similar 
> comments to the code somewhere about the suggested follow-ups. (Just so they 
> don't go away when this review is closed.)
Yeah, I wasn't trying to sign you up for the implementation effort, just making 
sure the name is somewhat more future-proofed. Adding a FIXME comment to the 
code to explain the potential next steps would be a good thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107294

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


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-08-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 364495.
balazske added a comment.

Fixes in tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

Files:
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/return-ptr-range.cpp

Index: clang/test/Analysis/return-ptr-range.cpp
===
--- clang/test/Analysis/return-ptr-range.cpp
+++ clang/test/Analysis/return-ptr-range.cpp
@@ -1,29 +1,39 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.ReturnPtrRange -verify %s
-
-int arr[10];
-int *ptr;
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.ReturnPtrRange -analyzer-output text -verify %s
 
 int conjure_index();
 
-int *test_element_index_lifetime() {
-  do {
+namespace test_element_index_lifetime {
+
+int arr[10]; // expected-note{{Original object declared here}} expected-note{{Original object declared here}}
+int *ptr;
+
+int *test_global_ptr() {
+  {
 int x = conjure_index();
-ptr = arr + x;
-if (x != 20)
+ptr = arr + x; // expected-note{{Value assigned to 'ptr'}}
+if (x != 20) // expected-note{{Assuming 'x' is equal to 20}}
+ // expected-note@-1{{Taking false branch}}
   return arr; // no-warning
-  } while (0);
-  return ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  }
+  return ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow) [alpha.security.ReturnPtrRange]}}
+  // expected-note@-1{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  // expected-note@-2{{Original object 'arr' is an array of 10 'int' objects}}
 }
 
-int *test_element_index_lifetime_with_local_ptr() {
+int *test_local_ptr() {
   int *local_ptr;
-  do {
+  {
 int x = conjure_index();
-local_ptr = arr + x;
-if (x != 20)
+local_ptr = arr + x; // expected-note{{Value assigned to 'local_ptr'}}
+if (x != 20) // expected-note{{Assuming 'x' is equal to 20}}
+ // expected-note@-1{{Taking false branch}}
   return arr; // no-warning
-  } while (0);
-  return local_ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  }
+  return local_ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow) [alpha.security.ReturnPtrRange]}}
+// expected-note@-1{{Returned pointer value points outside the original object (potential buffer overflow)}}
+// expected-note@-2{{Original object 'arr' is an array of 10 'int' objects}}
+}
+
 }
 
 template 
@@ -55,17 +65,53 @@
 
 template 
 class BadIterable {
-  int buffer[N];
+  int buffer[N]; // expected-note{{Original object declared here}}
   int *start, *finish;
 
 public:
-  BadIterable() : start(buffer), finish(buffer + N) {}
+  BadIterable() : start(buffer), finish(buffer + N) {} // expected-note{{Value assigned to 'iter.finish'}}
 
   int* begin() { return start; }
-  int* end() { return finish + 1; } // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  int* end() { return finish + 1; } // expected-warning{{Returned pointer value points outside the original object}}
+// expected-note@-1{{Returned pointer value points outside the original object}}
+// expected-note@-2{{Original object 'buffer' is an array of 20 'int' objects, returned pointer points at index 21}}
 };
 
 void use_bad_iterable_object() {
-  BadIterable<20> iter;
-  iter.end();
+  BadIterable<20> iter; // expected-note{{Calling default constructor for 'BadIterable<20>'}}
+// expected-note@-1{{Returning from default constructor for 'BadIterable<20>'}}
+  iter.end(); // expected-note{{Calling 'BadIterable::end'}}
 }
+
+int *test_idx_sym(int I) {
+  static int arr[10]; // expected-note{{Original object declared here}} expected-note{{'arr' initialized here}}
+
+  if (I != 11) // expected-note{{Assuming 'I' is equal to 11}}
+   // expected-note@-1{{Taking false branch}}
+return arr;
+  return arr + I; // expected-warning{{Returned pointer value points outside the original object}}
+  // expected-note@-1{{Returned pointer value points outside the original object}}
+  // expected-note@-2{{Original object 'arr' is an array of 10 'int' objects, returned pointer points at index 11}}
+}
+
+namespace test_array_of_struct {
+
+struct Data {
+  int A;
+  char *B;
+};
+
+Data DataArr[10]; // expected-note{{Original object declared here}}
+
+Data *test_struct_array() {
+  int I = conjure_index();
+

[PATCH] D107559: [clang] Fix libclang linking on Solaris

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



Comment at: clang/tools/libclang/libclang.map:1
-/* If you add a symbol to this file, make sure to add it with the correct
- * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
- * symbols with the version LLVM_14.
- * On platforms where versions scripts are not used, this file will be used to
- * generate a list of exports for libclang.so
- */
-
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new

GNU ld doesn't support `#` comments. ld.lld supports it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107559

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


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:76
+def err_fe_backend_error_attr :
+  Error<"call to %0 declared with attribute error: %1">, BackendInfo;
+def warn_fe_backend_warning_attr :





Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:78
+def warn_fe_backend_warning_attr :
+  Warning<"call to %0 declared with attribute warning: %1">, BackendInfo,
+  InGroup;





Comment at: clang/include/clang/Basic/DiagnosticGroups.td:1205
 def BackendOptimizationFailure : DiagGroup<"pass-failed">;
+def BackendUserDiagnostic : DiagGroup<"user-diagnostic">;
 

nickdesaulniers wrote:
> aaron.ballman wrote:
> > nickdesaulniers wrote:
> > > aaron.ballman wrote:
> > > > nickdesaulniers wrote:
> > > > > aaron.ballman wrote:
> > > > > > nickdesaulniers wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > GCC doesn't seem to support this spelling -- do they have a 
> > > > > > > > different one we should reuse?
> > > > > > > I think these diagnostics don't have corresponding flags in GCC, 
> > > > > > > so they cannot be disabled.
> > > > > > > 
> > > > > > > Without adding this, clang/test/Misc/warning-flags.c would fail, 
> > > > > > > because I was adding a new unnamed warning 
> > > > > > > `warn_fe_backend_user_diagnostic`.  Perhaps I should not be 
> > > > > > > adding this line here, and doing something else?
> > > > > > > 
> > > > > > > That test says we shouldn't be adding new warnings not controlled 
> > > > > > > by flags, but that's very much my intention.
> > > > > > > 
> > > > > > > Though now `-Wno-user-diagnostic` doesn't produce a 
> > > > > > > `-Wunknown-warning-option` diagnostic...
> > > > > > Ah! I think the warning attribute should be controllable via a 
> > > > > > diagnostic flag (we should always be able to disable warnings with 
> > > > > > some sort of flag) and I don't think the error attribute should be 
> > > > > > controllable (an error is an error and should stop translation, 
> > > > > > same as with `#error`).
> > > > > > 
> > > > > > Normally, I'd say "let's use the same flag that controls 
> > > > > > `#warning`" but...
> > > > > > ```
> > > > > > def PoundWarning : DiagGroup<"#warnings">;
> > > > > > ```
> > > > > > That's... not exactly an obvious flag for the warning attribute. So 
> > > > > > I would probably name it `warning-attributes` similar to how we 
> > > > > > have `deprecated-attributes` already.
> > > > > Done, now `-Wno-warning-attributes` doesn't produce 
> > > > > `-Wunknown-warning-option`, but also doesn't disable the diagnostic.  
> > > > > Was there something else I needed to add?
> > > > huh, that sounds suspicious -- you don't need to do anything special 
> > > > for `-Wno-foo` handling, that should be automatically supported via 
> > > > tablegen. I'm not certain why you're not seeing 
> > > > `-Wno-warning-attributes` silencing the warnings.
> > > Ah! Because I was testing `__attribute__((error("")))` not 
> > > `__attribute__((warning("")))`. `-Wno-warning-attributes` only affects 
> > > the latter, not the former.  I should add a test for 
> > > `-Wno-warning-attributes`! Is this something I also need to add 
> > > documentation for?
> > Given that this behavior surprised you, I certainly wouldn't oppose 
> > mentioning it in the documentation, but I also don't think it's strictly 
> > required. That said, I do agree about adding some additional test coverage 
> > for when the warning is disabled.
> > 
> > Just to double-check: do you think this functionality needs an "escape 
> > hatch" for the error case? e.g., should the `error` attribute generate a 
> > warning diagnostic that defaults to being an error, so we have 
> > `-Wno-warning-attributes` to turn off `warning` attribute diagnostics and 
> > `-Wno-error-attributes` to turn off `error` attribute diagnostics?
> Ah, GCC also controls this via `-Wattribute-warning`; let me rename my 
> implementation.
> 
> > do you think this functionality needs an "escape hatch" for the error case?
> 
> No.  If users don't want an error, then they should prefer 
> `__attribute__((warning("")))` to `__attribute__((error("")))`.
Okay, that's fine by me. If we find a need to give API consumers the ability to 
ignore the `error` attribute, we can always add one later.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11172
 
+def err_attribute_removed_on_redeclaration : Error<
+  "'%0' attribute removed from redeclared variable">;

This diagnostic is a bit confusing to me -- should this be a warning about the 
attribute being ignored in this case, rather than an error? Alternatively, 
should this be re-worded to say that the attribute must appear on the first 
declaration? If the latter, we have some diagnostics that could maybe be 
combined into using a `%select` for this: `err_noreturn_missing_on_first

[PATCH] D106644: [clang][analyzer] Add standard streams to alpha.unix.Stream checker.

2021-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ASTLookup.cpp:26
+  // and we have a TypedefDecl with the name 'FILE'.
+  for (Decl *D : LookupRes)
+if (auto *TD = dyn_cast(D))

`Decl *D` -> `const Decl *D`. Same for the other loop.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:225
+
+  Optional FILEType = GetPointer(LookupType("FILE"));
+

You calculate this 3 times now. I mean it's not a big deal, but we could save 
this to do it only once.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:227-236
+  for (Decl *D : LookupRes) {
+D = D->getCanonicalDecl();
+if (!C.getSourceManager().isInSystemHeader(D->getLocation()))
+  continue;
+if (auto *VD = dyn_cast(D)) {
+  if (FILEType && !ACtx.hasSameType(*FILEType, VD->getType()))
+continue;

It will early return and uses one fewer `continue`.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:504
+
+  OrigStdin = findStdStream("stdin", C);
+  OrigStdout = findStdStream("stdout", C);

martong wrote:
> We should be careful, to cache the results (either here, or deeper in the 
> call stack).
> I mean, we certainly don't want to do a lookup of "stdin" every time a 
> function is evaluated. We should do this lazily, only once.
I agree. We should do this only for the first top-level function, instead of 
doing this for every top-level function.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:554
 
+  auto AssumeRetValNotEq = [&C, &StateNotNull, RetVal](SymbolRef StdStream) {
+SVal NotEqS = C.getSValBuilder().evalBinOp(

It might be a personal preference but I think lambdas should be pure in the 
sense that it takes something and produces something else.
Regardless of your choice, the trailing return type would highlight it.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:559-562
+Optional NotEqDef =
+NotEqS.getAs();
+if (!NotEqDef)
+  return;

I think you should be fine with `castAs()`. I'm not expecting this to fail.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:555
+C.getSValBuilder().makeSymbolVal(StdStream),
+C.getASTContext().getLogicalOperationType());
+Optional NotEqDef =

`SValBuilder::getConditionType()`, oh they are the same under the hood. We 
should still probably prefer this one instead.
It might worth hoisting `C.getSValBuilder()` to a local variable though.
The symbol for `StdStream` also deserves a separate variable IMO.



Comment at: clang/test/Analysis/stream.c:276-277
+return;
+  if (F != stdin && F != stdout && F != stderr)
+fclose(F); // no warning: the opened file can not be equal to std streams
+}

How about checking this way instead?
```lang=C++
clang_analyzer_eval(F != stdin);  // TRUE
clang_analyzer_eval(F != stdout); // TRUE
clang_analyzer_eval(F != stderr); // TRUE
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106644

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


[PATCH] D104344: [modules] Track how headers are included by different modules.

2021-08-05 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104344

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


[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

2021-08-05 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Thank you for your reviews, @Quuxplusone, @whisperity, @MTC. I was also 
considering adding new diagnoses to the current check for these special cases, 
but I am not sure how to classify and describe them correctly, and whether they 
need to be added to the new check.
First of all, I want to make sure that the timing of warning and FxiIt in these 
cases is correct? If the above is no problem, I think I need to classify and 
modify the diagnostic information in the next step, is that right?


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

https://reviews.llvm.org/D107450

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


[clang] 6b0f359 - Fix signal during the call to checkOpenMPLoop.

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

Author: Jennifer Yu
Date: 2021-08-05T08:59:35-07:00
New Revision: 6b0f35931a44b0fbd27297f83087d3a4c352e83f

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

LOG: Fix signal during the call to checkOpenMPLoop.

The root problem is a null pointer is accessed during the call to
checkOpenMPLoop, because loop up bound expr is an error expression
due to error diagnostic was emit early.

To fix this, in setLCDeclAndLB, setUB and setStep instead return false,
return true when LB, UB or Step contains Error, so that the checking is
stopped in checkOpenMPLoop.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f093e6263e97d..b09bda1138cc6 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7342,7 +7342,7 @@ bool 
OpenMPIterationSpaceChecker::setLCDeclAndLB(ValueDecl *NewLCDecl,
   // State consistency checking to ensure correct usage.
   assert(LCDecl == nullptr && LB == nullptr && LCRef == nullptr &&
  UB == nullptr && Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
-  if (!NewLCDecl || !NewLB)
+  if (!NewLCDecl || !NewLB || NewLB->containsErrors())
 return true;
   LCDecl = getCanonicalDecl(NewLCDecl);
   LCRef = NewLCRefExpr;
@@ -7365,7 +7365,7 @@ bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB,
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && UB == nullptr &&
  Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
-  if (!NewUB)
+  if (!NewUB || NewUB->containsErrors())
 return true;
   UB = NewUB;
   if (LessOp)
@@ -7380,7 +7380,7 @@ bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB,
 bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) {
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && Step == nullptr);
-  if (!NewStep)
+  if (!NewStep || NewStep->containsErrors())
 return true;
   if (!NewStep->isValueDependent()) {
 // Check that the step is integer expression.

diff  --git a/clang/test/OpenMP/teams_distribute_loop_messages.cpp 
b/clang/test/OpenMP/teams_distribute_loop_messages.cpp
index 36f3830829c5e..e115d7498017e 100644
--- a/clang/test/OpenMP/teams_distribute_loop_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_loop_messages.cpp
@@ -721,4 +721,15 @@ void test_nowait() {
   for (int i = 0; i < 16; ++i)
 ;
 }
+//expected-note@+1 {{candidate function not viable: requires single argument 
'device_Id', but no arguments were provided}}
+int foo(int device_Id) {
+  return 2;
+}
+
+int main() {
+// expected-error@+1 {{no matching function for call to 'foo'}}
+  const int globalWI{ foo() };
+#pragma omp target teams distribute
+  for (int i=0 ; ihttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107385: Fix signal during the call to checkOpenMPLoop.

2021-08-05 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b0f35931a44: Fix signal during the call to checkOpenMPLoop. 
(authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107385

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


Index: clang/test/OpenMP/teams_distribute_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_loop_messages.cpp
@@ -721,4 +721,15 @@
   for (int i = 0; i < 16; ++i)
 ;
 }
+//expected-note@+1 {{candidate function not viable: requires single argument 
'device_Id', but no arguments were provided}}
+int foo(int device_Id) {
+  return 2;
+}
+
+int main() {
+// expected-error@+1 {{no matching function for call to 'foo'}}
+  const int globalWI{ foo() };
+#pragma omp target teams distribute
+  for (int i=0 ; icontainsErrors())
 return true;
   LCDecl = getCanonicalDecl(NewLCDecl);
   LCRef = NewLCRefExpr;
@@ -7365,7 +7365,7 @@
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && UB == nullptr &&
  Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
-  if (!NewUB)
+  if (!NewUB || NewUB->containsErrors())
 return true;
   UB = NewUB;
   if (LessOp)
@@ -7380,7 +7380,7 @@
 bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) {
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && Step == nullptr);
-  if (!NewStep)
+  if (!NewStep || NewStep->containsErrors())
 return true;
   if (!NewStep->isValueDependent()) {
 // Check that the step is integer expression.


Index: clang/test/OpenMP/teams_distribute_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_loop_messages.cpp
@@ -721,4 +721,15 @@
   for (int i = 0; i < 16; ++i)
 ;
 }
+//expected-note@+1 {{candidate function not viable: requires single argument 'device_Id', but no arguments were provided}}
+int foo(int device_Id) {
+  return 2;
+}
+
+int main() {
+// expected-error@+1 {{no matching function for call to 'foo'}}
+  const int globalWI{ foo() };
+#pragma omp target teams distribute
+  for (int i=0 ; icontainsErrors())
 return true;
   LCDecl = getCanonicalDecl(NewLCDecl);
   LCRef = NewLCRefExpr;
@@ -7365,7 +7365,7 @@
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && UB == nullptr &&
  Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
-  if (!NewUB)
+  if (!NewUB || NewUB->containsErrors())
 return true;
   UB = NewUB;
   if (LessOp)
@@ -7380,7 +7380,7 @@
 bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) {
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && Step == nullptr);
-  if (!NewStep)
+  if (!NewStep || NewStep->containsErrors())
 return true;
   if (!NewStep->isValueDependent()) {
 // Check that the step is integer expression.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107559: [clang] Fix libclang linking on Solaris

2021-08-05 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Is there any kind of comment that is supported by all linkers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107559

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


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Aside from the inline nit, I think it's good to go.
Let some time for the others to catch up, they might have objections.




Comment at: clang/test/Analysis/return-ptr-range.cpp:17
   return arr; // no-warning
-  } while (0);
-  return ptr; // expected-warning{{Returned pointer value points outside the 
original object (potential buffer overflow)}}
+  }
+  return ptr; // expected-warning{{Returned pointer value points outside the 
original object (potential buffer overflow) [alpha.security.ReturnPtrRange]}}

I don't think we need this extra scope. Same for the others.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

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


  1   2   >