[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs

2022-10-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked an inline comment as done.
mgorny added a comment.

In D134337#3863744 , @tstellar wrote:

> In what scenarios will clang load the clang.cfg file?

It will load it if all of the following are true:

1. `--no-default-config` is **not** passed.
2. a more specific `-clang.cfg` is not found.
3. `--driver-mode=gcc` is in effect **or** the executable is named `clang` or 
`*-clang` and `--driver-mode=` did not select another config file.




Comment at: clang/docs/UsersManual.rst:954
+
+For example, ``x86_64-pc-linux-gnu-clang-g++`` will attempt to load two
+configuration files named respectively::

tstellar wrote:
> Is `x86_64-pc-linux-gnu-clang-g++ ` being passed to --driver= in this example?
I don't understand your question. `x86_64-pc-linux-gnu-clang-g++` is the 
executable (symlink) name here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134337

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


[PATCH] D127403: [clangd] Implement semantic token modifier "definition"

2022-10-18 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

In D127403#3863713 , @nridge wrote:

> In D127403#3863686 , @thakis wrote:
>
>> In D127403#3863641 , @nridge wrote:
>>
>>> Landed https://reviews.llvm.org/rGc93430bae4fc
>>
>> Still failing with that: http://45.33.8.238/linux/89240/step_9.txt
>
> Fixed in https://reviews.llvm.org/rGd5a99bf5e134, and confirmed via a local 
> build and test run that the tests are passing. Apologies for the breakage.

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127403

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


[PATCH] D136124: [clang][deps] Remove unintentional `move`

2022-10-18 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp:400
+auto OverlayFS =
+llvm::makeIntrusiveRefCnt(BaseFS);
 auto InMemoryFS =

Is this equivalent?
```
auto OverlayFS = BaseFS;
```
Given that BaseFS is already `IntrusiveRefCntPtr`.



Comment at: clang/test/ClangScanDeps/modules-full-by-mod-name.cpp:18
 //
-// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 4 -format 
experimental-full \
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -format 
experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > 
%t_clangcl.result

Would it help to have one be j1 and one j4, any extra coverage by doing that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136124

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


[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-18 Thread Daniel Ruoso via Phabricator via cfe-commits
ruoso added a comment.

FWIW, having a differently named argument for output files and input files is 
very important for tooling.

In particular, in the case of remote execution, it makes a huge difference 
being able to tell what are the inputs and outputs by looking at the arguments 
alone, so I would like to make the case for an explicit output argument.

In fact, this is something I'll request on GCC as well, since it currently uses 
the module mapper to figure out both the input and the output BMI files.


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

https://reviews.llvm.org/D134267

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


[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-18 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D134267#3864368 , @ruoso wrote:

> FWIW, having a differently named argument for output files and input files is 
> very important for tooling.
>
> In particular, in the case of remote execution, it makes a huge difference 
> being able to tell what are the inputs and outputs by looking at the 
> arguments alone, so I would like to make the case for an explicit output 
> argument.
>
> In fact, this is something I'll request on GCC as well, since it currently 
> uses the module mapper to figure out both the input and the output BMI files.

Is this a consensus of SG15?


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

https://reviews.llvm.org/D134267

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


[PATCH] D131915: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2022-10-18 Thread Raghu via Phabricator via cfe-commits
raghavendhra updated this revision to Diff 468448.
raghavendhra added a comment.
Herald added projects: clang, LLVM, Flang.
Herald added subscribers: llvm-commits, cfe-commits.

Seperated map_operands with map-type and map-type-modifier as enum attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/test/Dialect/OpenMP/ops.mlir

Index: mlir/test/Dialect/OpenMP/ops.mlir
===
--- mlir/test/Dialect/OpenMP/ops.mlir
+++ mlir/test/Dialect/OpenMP/ops.mlir
@@ -400,6 +400,26 @@
 return
 }
 
+// CHECK-LABEL: omp_target_data
+func.func @omp_target_data (%if_cond : i1, %device : si32,  %data1: memref, %data2: memref, %data3: memref) -> () {
+
+// CHECK: omp.target_data if(%arg0) device(%arg1 : si32) use_device_ptr(%arg2 : memref) use_device_addr(%arg3 : memref) map( present, tofrom : %arg4 : memref) {
+"omp.target_data"(%if_cond, %device, %data1, %data2, %data3) ({
+   // CHECK: omp.terminator
+   omp.terminator
+}) {nowait, operand_segment_sizes = array, map_type_modifier_val = #omp, map_type_val = #omp} : ( i1, si32, memref, memref, memref ) -> ()
+
+// CHECK: omp.target_enter_data if(%arg0) device(%arg1 : si32) nowait map( always,  to : %arg2 : memref)
+"omp.target_enter_data"(%if_cond, %device, %data1)  {nowait, operand_segment_sizes = array, map_type_modifier_val = #omp, map_type_val = #omp} : ( i1, si32, memref ) -> ()
+   
+// CHECK: omp.target_exit_data if(%arg0) device(%arg1 : si32) nowait map( close,  from : %arg2 : memref)
+"omp.target_exit_data"(%if_cond, %device, %data1)  {nowait, operand_segment_sizes = array, map_type_modifier_val = #omp, map_type_val = #omp} : ( i1, si32, memref ) -> ()
+
+   return
+}
+
+
+
 // CHECK-LABEL: omp_target_pretty
 func.func @omp_target_pretty(%if_cond : i1, %device : si32,  %num_threads : i32) -> () {
 // CHECK: omp.target if({{.*}}) device({{.*}})
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -770,6 +770,169 @@
   let assemblyFormat = "attr-dict";
 }
 
+//===-===//
+// 2.12.2 target data Construct 
+//===-===//
+
+def Target_Data: OpenMP_Op<"target_data", [AttrSizedOperandSegments]>{
+  let summary = "target data construct";
+  let description = [{
+Map variables to a device data environment for the extent of the region.
+
+The omp target data directive maps variables to a device data 
+environment, and defines the lexical scope of the data environment 
+that is created. The omp target data directive can reduce data copies 
+to and from the offloading device when multiple target regions are using 
+the same data.
+
+The optional $if_expr parameter specifies a boolean result of a
+conditional check. If this value is 1 or is not provided then the target
+region runs on a device, if it is 0 then the target region is executed 
+on the host device.
+
+The optional $device parameter specifies the device number for the target 
+region.
+
+The optional $use_device_ptr specifies the device pointers to the 
+corresponding list items in the device data environment.
+
+The optional $use_device_addr specifies the address of the objects in the 
+device data enviornment.
+
+The $map_operands specifies operands in map clause.
+
+The $map_type specifies map-type within map clause and can take values to,
+from, tofrom or alloc.
+
+The $map_type_modifier specifies the modifier and can be always, close,
+present, iterator and mapper.
+
+TODO:  depend clause and map_type_modifier values iterator and mapper.
+  }];
+
+  let arguments = (ins Optional:$if_expr,
+ Optional:$device,
+ Variadic:$use_device_ptr,
+ Variadic:$use_device_addr,
+ MapTypeModifierAttr:$map_type_modifier_val,
+ MapTypeAttr:$map_type_val,
+ Variadic:$map_operands);
+   
+  let regions = (region AnyRegion:$region); 
+  
+  let assemblyFormat = [{
+(`if` `(` $if_expr^ `)` )?
+(`device` `(` $device^ `:` type($device) `)` )?
+(`use_device_ptr` `(` $use_device_ptr^ `:` type($use_device_ptr) `)` )?
+(`use_device_addr` `(` $use_device_addr^ `:` type($use_device_addr) `)` )?
+(`map` `(` $map_type_modifier_val `,` $map_type_val `:` $map_operands^ `:` type($map_operands) `)` )?
+$region attr-dict
+  }];  
+  
+}
+
+//===

[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-18 Thread Daniel Ruoso via Phabricator via cfe-commits
ruoso added a comment.

Currently, no. I think we do need a paper to discuss the requirements of the 
remote execution protocol and how they relate to the implementation of C++ 
modules.

The simple summary is that one way that remote execution is implemented is by 
just wrapping the compiler execution, creating a Merkle tree with all the 
inputs, identify all outputs, ship that to a remote worker, and return another 
Merkle tree with the outputs.


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

https://reviews.llvm.org/D134267

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


[clang] 09aaf19 - [AArch64] Make ACLE intrinsics always available part MTE

2022-10-18 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2022-10-18T10:35:40+02:00
New Revision: 09aaf190d93393d9e29d29a033cc3979589c5e84

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

LOG: [AArch64] Make ACLE intrinsics always available part MTE

Make MTE intrinsics available in function scope too.
Followup from D133359.

Reviewed By: dmgreen

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm64-mte.c
clang/test/Sema/builtins-arm64-mte.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index e6e375bc2b83a..bc8ab4eade91a 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -59,15 +59,15 @@ TARGET_BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc", "crc")
 TARGET_BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc", "crc")
 
 // Memory Tagging Extensions (MTE)
-BUILTIN(__builtin_arm_irg, "v*v*Ui", "t")
-BUILTIN(__builtin_arm_addg, "v*v*Ui", "t")
-BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t")
-BUILTIN(__builtin_arm_ldg, "v*v*", "t")
-BUILTIN(__builtin_arm_stg, "vv*", "t")
-BUILTIN(__builtin_arm_subp, "Uiv*v*", "t")
+TARGET_BUILTIN(__builtin_arm_irg, "v*v*Ui", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_addg, "v*v*Ui", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_ldg, "v*v*", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_stg, "vv*", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_subp, "Uiv*v*", "t", "mte")
 
 // Memory Operations
-BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "")
+TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
 
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")

diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index d73b6bf82d699..b30010274392c 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -722,17 +722,15 @@ __arm_st64bv0(void *__addr, data512_t __value) {
 #define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, 
__builtin_bit_cast(uint64_t, v))
 
 /* Memory Tagging Extensions (MTE) Intrinsics */
-#if defined(__ARM_FEATURE_MEMORY_TAGGING) && __ARM_FEATURE_MEMORY_TAGGING
+#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE
 #define __arm_mte_create_random_tag(__ptr, __mask)  __builtin_arm_irg(__ptr, 
__mask)
 #define __arm_mte_increment_tag(__ptr, __tag_offset)  
__builtin_arm_addg(__ptr, __tag_offset)
 #define __arm_mte_exclude_tag(__ptr, __excluded)  __builtin_arm_gmi(__ptr, 
__excluded)
 #define __arm_mte_get_tag(__ptr) __builtin_arm_ldg(__ptr)
 #define __arm_mte_set_tag(__ptr) __builtin_arm_stg(__ptr)
 #define __arm_mte_ptr
diff (__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb)
-#endif
 
 /* Memory Operations Intrinsics */
-#if defined(__ARM_FEATURE_MOPS) && __ARM_FEATURE_MOPS && 
defined(__ARM_FEATURE_MEMORY_TAGGING) && __ARM_FEATURE_MEMORY_TAGGING
 #define __arm_mops_memset_tag(__tagged_address, __value, __size)\
   __builtin_arm_mops_memset_tag(__tagged_address, __value, __size)
 #endif

diff  --git a/clang/test/CodeGen/arm64-mte.c b/clang/test/CodeGen/arm64-mte.c
index 12b568b2ece76..1c65d6a626dda 100644
--- a/clang/test/CodeGen/arm64-mte.c
+++ b/clang/test/CodeGen/arm64-mte.c
@@ -1,9 +1,17 @@
 // Test memory tagging extension intrinsics
 // RUN: %clang_cc1 -triple aarch64-none-linux-eabi -target-feature +mte -O3 -S 
-emit-llvm -o - %s  | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-eabi -DMTE -O3 -S -emit-llvm -o 
- %s  | FileCheck %s
 #include 
 #include 
 
+#ifdef MTE
+#define attribute  __attribute__((target("mte")))
+#else
+#define attribute
+#endif
+
 // CHECK-LABEL: define{{.*}} ptr @create_tag1
+attribute
 int *create_tag1(int *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -11,6 +19,7 @@ int *create_tag1(int *a, unsigned b) {
 }
 
 // CHECK-LABEL: define{{.*}} ptr @create_tag2
+attribute
 short *create_tag2(short *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -18,6 +27,7 @@ short *create_tag2(short *a, unsigned b) {
 }
 
 // CHECK-LABEL: define{{.*}} ptr @create_tag3
+attribute
 char *create_tag3(char *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -26,18 +36,21 @@ char *create_tag3(char *a, unsigned b) {
 }
 
 // CHECK-LABEL: define{{.*}} ptr @increment_tag1
+attribute
 char *increment_tag1(char *a) {
 // CHECK: call ptr @llvm.aarch64.addg(ptr %a, i64 3)
 return __

[PATCH] D136062: [AArch64] Make ACLE intrinsics always available part MTE

2022-10-18 Thread Daniel Kiss 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 rG09aaf190d933: [AArch64] Make ACLE intrinsics always 
available part MTE (authored by danielkiss).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136062

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm64-mte.c
  clang/test/Sema/builtins-arm64-mte.c

Index: clang/test/Sema/builtins-arm64-mte.c
===
--- clang/test/Sema/builtins-arm64-mte.c
+++ clang/test/Sema/builtins-arm64-mte.c
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -fsyntax-only -verify
 // RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -x c++ -fsyntax-only -verify
+// RUN: %clang_cc1 -triple arm64-arm-eabi %s -DNO_MTE -x c++ -S -emit-llvm  -verify
 #include 
 #include 
 
+#ifndef NO_MTE
 int  *create_tag1(int a, unsigned b) {
   // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
   return __arm_mte_create_random_tag(a,b);
@@ -134,3 +136,10 @@
   return __arm_mte_ptrdiff(nullptr, nullptr);
 }
 #endif
+
+#else
+int *create_tag1(int *a, unsigned b) {
+  // expected-error@+1 {{'__builtin_arm_irg' needs target feature mte}}
+  return __arm_mte_create_random_tag(a,b);
+}
+#endif
\ No newline at end of file
Index: clang/test/CodeGen/arm64-mte.c
===
--- clang/test/CodeGen/arm64-mte.c
+++ clang/test/CodeGen/arm64-mte.c
@@ -1,9 +1,17 @@
 // Test memory tagging extension intrinsics
 // RUN: %clang_cc1 -triple aarch64-none-linux-eabi -target-feature +mte -O3 -S -emit-llvm -o - %s  | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-eabi -DMTE -O3 -S -emit-llvm -o - %s  | FileCheck %s
 #include 
 #include 
 
+#ifdef MTE
+#define attribute  __attribute__((target("mte")))
+#else
+#define attribute
+#endif
+
 // CHECK-LABEL: define{{.*}} ptr @create_tag1
+attribute
 int *create_tag1(int *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -11,6 +19,7 @@
 }
 
 // CHECK-LABEL: define{{.*}} ptr @create_tag2
+attribute
 short *create_tag2(short *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -18,6 +27,7 @@
 }
 
 // CHECK-LABEL: define{{.*}} ptr @create_tag3
+attribute
 char *create_tag3(char *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -26,18 +36,21 @@
 }
 
 // CHECK-LABEL: define{{.*}} ptr @increment_tag1
+attribute
 char *increment_tag1(char *a) {
 // CHECK: call ptr @llvm.aarch64.addg(ptr %a, i64 3)
 return __arm_mte_increment_tag(a,3);
 }
 
 // CHECK-LABEL: define{{.*}} ptr @increment_tag2
+attribute
 short *increment_tag2(short *a) {
 // CHECK: [[T1:%[0-9]+]] = tail call ptr @llvm.aarch64.addg(ptr %a, i64 3)
 return __arm_mte_increment_tag(a,3);
 }
 
 // CHECK-LABEL: define{{.*}} i32 @exclude_tag
+attribute
 unsigned exclude_tag(int *a, unsigned m) {
 // CHECK: [[T0:%[0-9]+]] = zext i32 %m to i64
 // CHECK: [[T2:%[0-9]+]] = tail call i64 @llvm.aarch64.gmi(ptr %a, i64 [[T0]])
@@ -46,24 +59,28 @@
 }
 
 // CHECK-LABEL: define{{.*}} ptr @get_tag1
+attribute
 int *get_tag1(int *a) {
 // CHECK: [[T1:%[0-9]+]] = tail call ptr @llvm.aarch64.ldg(ptr %a, ptr %a)
return __arm_mte_get_tag(a);
 }
 
 // CHECK-LABEL: define{{.*}} ptr @get_tag2
+attribute
 short *get_tag2(short *a) {
 // CHECK: [[T1:%[0-9]+]] = tail call ptr @llvm.aarch64.ldg(ptr %a, ptr %a)
return __arm_mte_get_tag(a);
 }
 
 // CHECK-LABEL: define{{.*}} void @set_tag1
+attribute
 void set_tag1(int *a) {
 // CHECK: tail call void @llvm.aarch64.stg(ptr %a, ptr %a)
__arm_mte_set_tag(a);
 }
 
 // CHECK-LABEL: define{{.*}} i64 @subtract_pointers
+attribute
 ptrdiff_t subtract_pointers(int *a, int *b) {
 // CHECK: [[T2:%[0-9]+]] = tail call i64 @llvm.aarch64.subp(ptr %a, ptr %b)
 // CHECK: ret i64 [[T2]]
@@ -71,6 +88,7 @@
 }
 
 // CHECK-LABEL: define{{.*}} i64 @subtract_pointers_null_1
+attribute
 ptrdiff_t subtract_pointers_null_1(int *a) {
 // CHECK: [[T1:%[0-9]+]] = tail call i64 @llvm.aarch64.subp(ptr %a, ptr null)
 // CHECK: ret i64 [[T1]]
@@ -78,6 +96,7 @@
 }
 
 // CHECK-LABEL: define{{.*}} i64 @subtract_pointers_null_2
+attribute
 ptrdiff_t subtract_pointers_null_2(int *a) {
 // CHECK: [[T1:%[0-9]+]] = tail call i64 @llvm.aarch64.subp(ptr null, ptr %a)
 // CHECK: ret i64 [[T1]]
@@ -86,6 +105,7 @@
 
 // Check arithmetic promotion on return type
 // CHECK-LABEL: define{{.*}} i32 @subtract_pointers

[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-18 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D134267#3864416 , @ruoso wrote:

> Currently, no. I think we do need a paper to discuss the requirements of the 
> remote execution protocol and how they relate to the implementation of C++ 
> modules.
>
> The simple summary is that one way that remote execution is implemented is by 
> just wrapping the compiler execution, creating a Merkle tree with all the 
> inputs, identify all outputs, ship that to a remote worker, and return 
> another Merkle tree with the outputs.

Yeah, it is always better to have standard protocols. So the current state 
about the suffixes of modules (or `a differently named argument for output 
files` in your terms) is still need to be discussed. Personally, I agree with 
the special suffix for the sake of readability. @iains I think your draft 
patches may be better to be suspended until the SG15 get consensus. From my 
understanding, the problem may not be related with the client/server modes, 
right? So I guess this may not block your future works.


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

https://reviews.llvm.org/D134267

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


[clang] a175d8b - Revert "[AArch64] Make ACLE intrinsics always available part MTE"

2022-10-18 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2022-10-18T10:45:32+02:00
New Revision: a175d8b1772f729b2caf95a1b755cb9a59563e21

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

LOG: Revert "[AArch64] Make ACLE intrinsics always available part MTE"

This reverts commit 09aaf190d93393d9e29d29a033cc3979589c5e84.

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm64-mte.c
clang/test/Sema/builtins-arm64-mte.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index bc8ab4eade91a..e6e375bc2b83a 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -59,15 +59,15 @@ TARGET_BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc", "crc")
 TARGET_BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc", "crc")
 
 // Memory Tagging Extensions (MTE)
-TARGET_BUILTIN(__builtin_arm_irg, "v*v*Ui", "t", "mte")
-TARGET_BUILTIN(__builtin_arm_addg, "v*v*Ui", "t", "mte")
-TARGET_BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t", "mte")
-TARGET_BUILTIN(__builtin_arm_ldg, "v*v*", "t", "mte")
-TARGET_BUILTIN(__builtin_arm_stg, "vv*", "t", "mte")
-TARGET_BUILTIN(__builtin_arm_subp, "Uiv*v*", "t", "mte")
+BUILTIN(__builtin_arm_irg, "v*v*Ui", "t")
+BUILTIN(__builtin_arm_addg, "v*v*Ui", "t")
+BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t")
+BUILTIN(__builtin_arm_ldg, "v*v*", "t")
+BUILTIN(__builtin_arm_stg, "vv*", "t")
+BUILTIN(__builtin_arm_subp, "Uiv*v*", "t")
 
 // Memory Operations
-TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
+BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "")
 
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")

diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index b30010274392c..d73b6bf82d699 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -722,15 +722,17 @@ __arm_st64bv0(void *__addr, data512_t __value) {
 #define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, 
__builtin_bit_cast(uint64_t, v))
 
 /* Memory Tagging Extensions (MTE) Intrinsics */
-#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE
+#if defined(__ARM_FEATURE_MEMORY_TAGGING) && __ARM_FEATURE_MEMORY_TAGGING
 #define __arm_mte_create_random_tag(__ptr, __mask)  __builtin_arm_irg(__ptr, 
__mask)
 #define __arm_mte_increment_tag(__ptr, __tag_offset)  
__builtin_arm_addg(__ptr, __tag_offset)
 #define __arm_mte_exclude_tag(__ptr, __excluded)  __builtin_arm_gmi(__ptr, 
__excluded)
 #define __arm_mte_get_tag(__ptr) __builtin_arm_ldg(__ptr)
 #define __arm_mte_set_tag(__ptr) __builtin_arm_stg(__ptr)
 #define __arm_mte_ptr
diff (__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb)
+#endif
 
 /* Memory Operations Intrinsics */
+#if defined(__ARM_FEATURE_MOPS) && __ARM_FEATURE_MOPS && 
defined(__ARM_FEATURE_MEMORY_TAGGING) && __ARM_FEATURE_MEMORY_TAGGING
 #define __arm_mops_memset_tag(__tagged_address, __value, __size)\
   __builtin_arm_mops_memset_tag(__tagged_address, __value, __size)
 #endif

diff  --git a/clang/test/CodeGen/arm64-mte.c b/clang/test/CodeGen/arm64-mte.c
index 1c65d6a626dda..12b568b2ece76 100644
--- a/clang/test/CodeGen/arm64-mte.c
+++ b/clang/test/CodeGen/arm64-mte.c
@@ -1,17 +1,9 @@
 // Test memory tagging extension intrinsics
 // RUN: %clang_cc1 -triple aarch64-none-linux-eabi -target-feature +mte -O3 -S 
-emit-llvm -o - %s  | FileCheck %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-eabi -DMTE -O3 -S -emit-llvm -o 
- %s  | FileCheck %s
 #include 
 #include 
 
-#ifdef MTE
-#define attribute  __attribute__((target("mte")))
-#else
-#define attribute
-#endif
-
 // CHECK-LABEL: define{{.*}} ptr @create_tag1
-attribute
 int *create_tag1(int *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -19,7 +11,6 @@ int *create_tag1(int *a, unsigned b) {
 }
 
 // CHECK-LABEL: define{{.*}} ptr @create_tag2
-attribute
 short *create_tag2(short *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -27,7 +18,6 @@ short *create_tag2(short *a, unsigned b) {
 }
 
 // CHECK-LABEL: define{{.*}} ptr @create_tag3
-attribute
 char *create_tag3(char *a, unsigned b) {
 // CHECK: [[T1:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[T2:%[0-9]+]] = tail call ptr @llvm.aarch64.irg(ptr %a, i64 [[T1]])
@@ -36,21 +26,18 @@ char *create_tag3(char *a, unsigned b) {
 }
 
 // CHECK-LABEL: define{{.*}} ptr @increment_tag1
-attribute
 char *increment_tag1(char *a) {
 // CHECK: call ptr @llvm.aarch64.addg(ptr %a, i64 3)
 return __arm_mte_increment_tag(a,3);
 }
 
 // CHECK-LABEL: define{{.*}} ptr @increment_tag2
-

[PATCH] D136106: [clang][RISCV] Set vscale_range attribute based on VLEN

2022-10-18 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck accepted this revision.
frasercrmck added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D136106

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


[clang] 0d0ca64 - [AArch64] Make ACLE intrinsics always available part MTE

2022-10-18 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2022-10-18T11:03:02+02:00
New Revision: 0d0ca64356ff1a9e3427660732da033a14521e5b

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

LOG: [AArch64] Make ACLE intrinsics always available part MTE

Make MTE intrinsics available in function scope too.
Followup from D133359.

Reviewed By: dmgreen

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/aarch64-mops.c
clang/test/CodeGen/arm64-mte.c
clang/test/Sema/builtins-arm64-mte.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index e6e375bc2b83a..bc8ab4eade91a 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -59,15 +59,15 @@ TARGET_BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc", "crc")
 TARGET_BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc", "crc")
 
 // Memory Tagging Extensions (MTE)
-BUILTIN(__builtin_arm_irg, "v*v*Ui", "t")
-BUILTIN(__builtin_arm_addg, "v*v*Ui", "t")
-BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t")
-BUILTIN(__builtin_arm_ldg, "v*v*", "t")
-BUILTIN(__builtin_arm_stg, "vv*", "t")
-BUILTIN(__builtin_arm_subp, "Uiv*v*", "t")
+TARGET_BUILTIN(__builtin_arm_irg, "v*v*Ui", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_addg, "v*v*Ui", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_ldg, "v*v*", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_stg, "vv*", "t", "mte")
+TARGET_BUILTIN(__builtin_arm_subp, "Uiv*v*", "t", "mte")
 
 // Memory Operations
-BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "")
+TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
 
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")

diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index d73b6bf82d699..b30010274392c 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -722,17 +722,15 @@ __arm_st64bv0(void *__addr, data512_t __value) {
 #define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, 
__builtin_bit_cast(uint64_t, v))
 
 /* Memory Tagging Extensions (MTE) Intrinsics */
-#if defined(__ARM_FEATURE_MEMORY_TAGGING) && __ARM_FEATURE_MEMORY_TAGGING
+#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE
 #define __arm_mte_create_random_tag(__ptr, __mask)  __builtin_arm_irg(__ptr, 
__mask)
 #define __arm_mte_increment_tag(__ptr, __tag_offset)  
__builtin_arm_addg(__ptr, __tag_offset)
 #define __arm_mte_exclude_tag(__ptr, __excluded)  __builtin_arm_gmi(__ptr, 
__excluded)
 #define __arm_mte_get_tag(__ptr) __builtin_arm_ldg(__ptr)
 #define __arm_mte_set_tag(__ptr) __builtin_arm_stg(__ptr)
 #define __arm_mte_ptr
diff (__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb)
-#endif
 
 /* Memory Operations Intrinsics */
-#if defined(__ARM_FEATURE_MOPS) && __ARM_FEATURE_MOPS && 
defined(__ARM_FEATURE_MEMORY_TAGGING) && __ARM_FEATURE_MEMORY_TAGGING
 #define __arm_mops_memset_tag(__tagged_address, __value, __size)\
   __builtin_arm_mops_memset_tag(__tagged_address, __value, __size)
 #endif

diff  --git a/clang/test/CodeGen/aarch64-mops.c 
b/clang/test/CodeGen/aarch64-mops.c
index f7efb1635185d..c0f151837c751 100644
--- a/clang/test/CodeGen/aarch64-mops.c
+++ b/clang/test/CodeGen/aarch64-mops.c
@@ -1,77 +1,68 @@
 // RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion 
-target-feature +mops -target-feature +mte -w -S -emit-llvm -o - %s  | 
FileCheck --check-prefix=CHECK-MOPS   %s
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion 
-target-feature +mops -Wno-implicit-function-declaration -w -S -emit-llvm -o - 
%s  | FileCheck --check-prefix=CHECK-NOMOPS %s
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion 
-Wno-implicit-function-declaration -target-feature +mte -w -S -emit-llvm -o - 
%s  | FileCheck --check-prefix=CHECK-NOMOPS %s
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion 
-Wno-implicit-function-declaration -w -S -emit-llvm -o - %s  | FileCheck 
--check-prefix=CHECK-NOMOPS %s
+// RUN: not %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion 
-target-feature +mops -Wno-implicit-function-declaration -w -S -emit-llvm -o - 
%s 2>&1  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: not %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion 
-Wno-implicit-function-declaration -target-feature +mte -w -S -emit-llvm -o - 
%s 2>&1 | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: not %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion 
-Wno-implicit-function-declaration -w -S -emit-llvm -o - %s 2>&1 | FileCheck 
--check-prefix=CHECK-NOMOPS %s
 

[PATCH] D136145: [IR][RFC] Restrict read only when cache type of llvm.prefetch is instruction

2022-10-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei created this revision.
pengfei added reviewers: craig.topper, uweigand, lenary, efriedma.
Herald added subscribers: StephenFan, jdoerfert, hiraditya.
Herald added a project: All.
pengfei requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

LLVM backends like X86 always lowers prefetch intrinsics into similar
type if the desired one is not available.
For example, T2 hint -> T1 or write hint -> read. See 
llvm/test/CodeGen/X86/prefetch.ll
However, it's not clear for backend to choose between "write data" or "read
instruction" if there is no native "write instruction" instructions.
As far as I know, there's no upstream target that has supported "write
instruction" at the moment. So there should be no real impact by this
patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136145

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-arm.c
  clang/test/Sema/builtin-prefetch.c
  llvm/docs/LangRef.rst
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/X86/X86Instr3DNow.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/test/CodeGen/SystemZ/prefetch-01.ll
  llvm/test/CodeGen/X86/prefetch.ll

Index: llvm/test/CodeGen/X86/prefetch.ll
===
--- llvm/test/CodeGen/X86/prefetch.ll
+++ llvm/test/CodeGen/X86/prefetch.ll
@@ -21,7 +21,7 @@
 
 ; rdar://10538297
 
-define void @t(ptr %ptr) nounwind  {
+define dso_local void @t(ptr %ptr) nounwind  {
 ; SSE-LABEL: t:
 ; SSE:   # %bb.0: # %entry
 ; SSE-NEXT:movl {{[0-9]+}}(%esp), %eax
@@ -33,6 +33,10 @@
 ; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:prefetcht0 (%eax)
 ; SSE-NEXT:prefetchnta (%eax)
+; SSE-NEXT:prefetcht1 (%eax)
+; SSE-NEXT:prefetcht0 (%eax)
+; SSE-NEXT:prefetcht1 t
+; SSE-NEXT:prefetcht0 ext
 ; SSE-NEXT:retl
 ;
 ; PRFCHWSSE-LABEL: t:
@@ -46,6 +50,10 @@
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
+; PRFCHWSSE-NEXT:prefetcht1 (%eax)
+; PRFCHWSSE-NEXT:prefetcht0 (%eax)
+; PRFCHWSSE-NEXT:prefetcht1 t
+; PRFCHWSSE-NEXT:prefetcht0 ext
 ; PRFCHWSSE-NEXT:retl
 ;
 ; PREFETCHWT1-LABEL: t:
@@ -59,6 +67,10 @@
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
 ; PREFETCHWT1-NEXT:prefetchw (%eax)
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
+; PREFETCHWT1-NEXT:prefetcht1 (%eax)
+; PREFETCHWT1-NEXT:prefetcht0 (%eax)
+; PREFETCHWT1-NEXT:prefetcht1 t
+; PREFETCHWT1-NEXT:prefetcht0 ext
 ; PREFETCHWT1-NEXT:retl
 ;
 ; 3DNOW-LABEL: t:
@@ -72,6 +84,10 @@
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
+; 3DNOW-NEXT:prefetch t
+; 3DNOW-NEXT:prefetch ext
 ; 3DNOW-NEXT:retl
 entry:
 	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 1, i32 1 )
@@ -82,7 +98,12 @@
 	tail call void @llvm.prefetch( ptr %ptr, i32 1, i32 2, i32 1 )
 	tail call void @llvm.prefetch( ptr %ptr, i32 1, i32 3, i32 1 )
 	tail call void @llvm.prefetch( ptr %ptr, i32 1, i32 0, i32 1 )
+	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 2, i32 0 )
+	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 3, i32 0 )
+	tail call void @llvm.prefetch( ptr @t,   i32 0, i32 2, i32 0 )
+	tail call void @llvm.prefetch( ptr @ext, i32 0, i32 3, i32 0 )
 	ret void
 }
 
+declare dso_local void @ext() nounwind
 declare void @llvm.prefetch(ptr, i32, i32, i32) nounwind
Index: llvm/test/CodeGen/SystemZ/prefetch-01.ll
===
--- llvm/test/CodeGen/SystemZ/prefetch-01.ll
+++ llvm/test/CodeGen/SystemZ/prefetch-01.ll
@@ -15,14 +15,11 @@
   ret void
 }
 
-; Check that instruction write prefetches are ignored.
-define dso_local void @f2(ptr %ptr) {
-; CHECK-LABEL: f2:
-; CHECK-NOT: %r2
-; CHECK: br %r14
-  call void @llvm.prefetch(ptr %ptr, i32 1, i32 0, i32 0)
-  ret void
-}
+; Instruction write prefetches are invalid.
+; define dso_local void @f2(ptr %ptr) {
+;   call void @llvm.prefetch(ptr %ptr, i32 1, i32 0, i32 0)
+;   ret void
+; }
 
 ; Check data read prefetches.
 define dso_local void @f3(ptr %ptr) {
Index: llvm/lib/Target/X86/X86InstrSSE.td
===
--- llvm/lib/Target/X86/X86InstrSSE.td
+++ llvm/lib/Target/X86/X86InstrSSE.td
@@ -3201,13 +3201,13 @@
 // Prefetch intrinsic.
 let Predicates = [HasSSEPrefetch], SchedRW = [WriteLoad] in {
 def PREFETCHT0   : I<0x18, MRM1m, (outs), (ins i8mem:$src),
-"prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3), (i32 1))]>, TB;
+"prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3), imm)]>, TB;
 def PREFETCHT1   : I<0x18, MRM2m, (outs), (ins i8mem:$src),
-"prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2), (i32 1))]>, TB;
+"prefet

[PATCH] D136146: [Clang][LoongArch] Handle -march/-m{single,double,soft}-float/-mfpu options

2022-10-18 Thread Lu Weining via Phabricator via cfe-commits
SixWeining created this revision.
SixWeining added reviewers: xen0n, xry111, MaskRay, wangleiat, gonglingqin.
Herald added subscribers: StephenFan, atanasyan, hiraditya, arichardson, 
sdardis.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch adds options -march, -msingle-float, -mdouble-float,
-msoft-float and -mfpu for LoongArch.

Clang options `msingle_float` and `mdouble_float` are moved from
`m_mips_Features_Group` to `m_Group` because now more than targets use
them.

Reference:
https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-toolchain-conventions-EN.adoc

TODO: add -mtune.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136146

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/loongarch-default-features.c
  clang/test/Driver/loongarch-march-error.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-mfpu-error.c
  clang/test/Driver/loongarch-mfpu.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c
  llvm/include/llvm/Support/LoongArchTargetParser.def
  llvm/include/llvm/Support/LoongArchTargetParser.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/LoongArchTargetParser.cpp

Index: llvm/lib/Support/LoongArchTargetParser.cpp
===
--- /dev/null
+++ llvm/lib/Support/LoongArchTargetParser.cpp
@@ -0,0 +1,53 @@
+//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- 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
+//
+//===--===//
+//
+// This file implements a target parser to recognise LoongArch hardware features
+// such as CPU/ARCH and extension names.
+//
+//===--===//
+
+#include "llvm/Support/LoongArchTargetParser.h"
+#include "llvm/ADT/StringSwitch.h"
+
+using namespace llvm;
+using namespace llvm::LoongArch;
+
+const FeatureInfo AllFeatures[] = {
+#define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
+#include "llvm/Support/LoongArchTargetParser.def"
+};
+
+const ArchInfo AllArchs[] = {
+#define LOONGARCH_ARCH(NAME, KIND, FEATURES)   \
+  {NAME, LoongArch::ArchKind::KIND, FEATURES},
+#include "llvm/Support/LoongArchTargetParser.def"
+};
+
+LoongArch::ArchKind LoongArch::parseArch(StringRef Arch) {
+  for (const auto A : AllArchs) {
+if (A.Name == Arch)
+  return A.Kind;
+  }
+
+  return LoongArch::ArchKind::AK_INVALID;
+}
+
+bool LoongArch::getArchFeatures(StringRef Arch,
+std::vector &Features) {
+  for (const auto A : AllArchs) {
+if (A.Name == Arch) {
+  for (const auto F : AllFeatures) {
+if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID) {
+  Features.push_back(F.Name);
+}
+  }
+  return true;
+}
+  }
+  return false;
+}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -188,6 +188,7 @@
   LineIterator.cpp
   Locale.cpp
   LockFileManager.cpp
+  LoongArchTargetParser.cpp
   LowLevelType.cpp
   ManagedStatic.cpp
   MathExtras.cpp
Index: llvm/include/llvm/Support/LoongArchTargetParser.h
===
--- /dev/null
+++ llvm/include/llvm/Support/LoongArchTargetParser.h
@@ -0,0 +1,74 @@
+//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- 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
+//
+//===--===//
+//
+// This file implements a target parser to recognise LoongArch hardware features
+// such as CPU/ARCH and extension names.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#define LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+
+#include "llvm/ADT/Triple.h"
+#include 
+
+namespace llvm {
+class StringRef;
+
+namespace LoongArch {
+
+enum FeatureKind : uint32_t {
+  FK_INVALID = 0,
+  FK_NONE = 1,
+
+  // 64-bit ISA is available.
+  FK_64BIT = 1 << 1,
+
+  // Single-pr

[PATCH] D136040: [X86] Support PREFETCHI instructions

2022-10-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D136040#3862551 , @uweigand wrote:

> In D136040#3862386 , @pengfei wrote:
>
>> Sure, it is possible. But at least for now, there's no real target requires 
>> it. Checked with `grep -rwn 'llvm.prefetch.*i32 0\s*)' llvm/test/CodeGen/`.
>
> But that's just within the LLVM sources.  My point was that -up to now- this 
> was part of the public LLVM IR spec, so there could by other LLVM users out 
> there creating this IR, which would now suddenly break.  Not sure what the 
> rules are for breaking IR changes, but that would presumably need some wider 
> discussion.

Thanks @uweigand, you are right. I have split D136145 
 and put it in Discourse for broad discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136040

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


[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-18 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/test/MC/X86/x86-64-cmpccxadd-att.s:1
+// RUN: llvm-mc -triple x86_64 --show-encoding %s | FileCheck %s
+

Drop the -att.s and add intel test coverage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-18 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

once again we are getting off topic for this patch :)

We (compiler engineers) will have to cater for multiple models used by 
different build systems.

SG15 might give guidance/recommendations,  but in the end the standard's 
normative text is not likely to make a 'discovery-based' scheme like build2 
non-conforming.
So, course, it is possible to make a GCC bugzilla requesting that it is 
possible to give a module output filename as a command line option (hopefully 
using the same option spelling as clang).  Allowing both compilers to operate 
with each other's [C++20] command lines is a great objective ..


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

https://reviews.llvm.org/D134267

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


[PATCH] D135110: [NFC] [HLSL] Move common metadata to LLVMFrontend

2022-10-18 Thread Mariusz Sikora via Phabricator via cfe-commits
mariusz-sikora-at-amd added a comment.

In D135110#3859844 , @mstorsjo wrote:

> I don't quite know why, but it seems like this new library breaks tests of 
> llvm-config; if I start out with an empty build directory and run `ninja 
> check-llvm` (or `ninja llvm-test-depends`), then this library doesn't get 
> built, and llvm-config prints `llvm-config: error: missing: 
> $HOME/code/llvm-project/llvm/build/lib/libLLVMFrontendHLSL.a` - and that 
> breaks `tools/llvm-config/booleans.test` and 
> `tools/llvm-config/system-libs.test`.

I see the same issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135110

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


[PATCH] D134267: [C++] [Modules] Support one phase compilation model for named modules

2022-10-18 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

> once again we are getting off topic for this patch :)

Yeah, let's wait for @dblaikie's opinion on the flag name : )

The remained question: To use `-fc++-module-bmi-output=` or 
`-fc++-module-filename=`, or anything else (maybe `-fc++-module-output=`)


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

https://reviews.llvm.org/D134267

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


[PATCH] D135938: [X86] Add AVX-VNNI-INT8 instructions.

2022-10-18 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Can you fix the MC + disasm test file names - drop att/intel and ensure you 
test both syntaxes for 32 and 64 bits.

Ideally the 32/64 bit names should be close to each other in a file list (e.g. 
avx-vnni-int8-32.s + avx-vnni-int8-64.s ?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135938

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


[PATCH] D135937: [X86] Support -march=meteorlake

2022-10-18 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Please can you update the summary now that raptorlake + meteorlake are in the 
same patch?




Comment at: clang/test/Preprocessor/predefined-arch-macros.c:2233
 
+// RUN: %clang -march=raptorlake -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \

(pedantic) Probably better to put these after the alderlake tests so its easier 
to find?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135937

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


[PATCH] D136040: [X86] Support PREFETCHI instructions

2022-10-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 468463.
pengfei added a comment.

Rebased on D136145  and split RIP 
optimization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136040

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/prfchiintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/test/CodeGen/X86/prefetchi-builtins.c
  clang/test/Driver/x86-target-features.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86DiscriminateMemOps.cpp
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/prefetch.ll
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/PREFETCH-64.s

Index: llvm/test/MC/X86/PREFETCH-64.s
===
--- llvm/test/MC/X86/PREFETCH-64.s
+++ llvm/test/MC/X86/PREFETCH-64.s
@@ -168,3 +168,50 @@
 // CHECK: encoding: [0x0f,0x0d,0x12]
 prefetchwt1 (%rdx) 
 
+// CHECK: prefetchit0 485498096
+// CHECK: encoding: [0x0f,0x18,0x3c,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit0 485498096
+
+// CHECK: prefetchit0 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x7a,0x40]
+prefetchit0 64(%rdx)
+
+// CHECK: prefetchit0 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0x40]
+prefetchit0 64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0xc0]
+prefetchit0 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x02,0x40]
+prefetchit0 64(%rdx,%rax)
+
+// CHECK: prefetchit0 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x3a]
+prefetchit0 (%rdx)
+
+// CHECK: prefetchit1 485498096
+// CHECK: encoding: [0x0f,0x18,0x34,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit1 485498096
+
+// CHECK: prefetchit1 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x72,0x40]
+prefetchit1 64(%rdx)
+
+// CHECK: prefetchit1 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0x40]
+prefetchit1 64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0xc0]
+prefetchit1 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x74,0x02,0x40]
+prefetchit1 64(%rdx,%rax)
+
+// CHECK: prefetchit1 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x32]
+prefetchit1 (%rdx)
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -761,3 +761,9 @@
 
 # CHECK: rdpru
 0x0f,0x01,0xfd
+
+# CHECK: prefetchit0 (%rip)
+0x0f,0x18,0x3d,0x00,0x00,0x00,0x00
+
+# CHECK: prefetchit1 (%rip)
+0x0f,0x18,0x35,0x00,0x00,0x00,0x00
Index: llvm/test/CodeGen/X86/prefetch.ll
===
--- llvm/test/CodeGen/X86/prefetch.ll
+++ llvm/test/CodeGen/X86/prefetch.ll
@@ -11,6 +11,8 @@
 ; RUN: llc < %s -mtriple=i686-- -mattr=-sse,+3dnow,+prefetchwt1 | FileCheck %s -check-prefix=PREFETCHWT1
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow | FileCheck %s -check-prefix=3DNOW
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow,+prfchw | FileCheck %s -check-prefix=3DNOW
+; RUN: llc < %s -mtriple=i686-- -mattr=+sse,+prefetchi | FileCheck %s -check-prefix=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+prefetchi | FileCheck %s -check-prefix=PREFETCHI
 
 ; Rules:
 ; 3dnow by itself get you just the single prefetch instruction with no hints
@@ -89,6 +91,22 @@
 ; 3DNOW-NEXT:prefetch t
 ; 3DNOW-NEXT:prefetch ext
 ; 3DNOW-NEXT:retl
+;
+; PREFETCHI-LABEL: t:
+; PREFETCHI:   # %bb.0: # %entry
+; PREFETCHI-NEXT:prefetcht2 (%rdi)
+; PREFETCHI-NEXT:prefetcht1 (%rdi)
+; PREFETCHI-NEXT:prefetcht0 (%rdi)
+; PREFETCHI-NEXT:prefetchnta (%rdi)
+; PREFETCHI-NEXT:prefetcht2 (%rdi)
+; PREFETCHI-NEXT:prefetcht1 (%rdi)
+; PREFETCHI-NEXT:prefetcht0 (%rdi)
+; PREFETCHI-NEXT:prefetchnta (%rdi)
+; PREFETCHI-NEXT:prefetchit1 (%rdi)
+; PREFETCHI-NEXT:prefetchit0 (%rdi)
+; PREFETCHI-NEXT:prefetchit1 t(%rip)
+; PREFETCHI-NEXT:prefetchit0 ext(%rip)
+; PREFETCHI-NEXT:retq
 entry:
 	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 1, i32 1 )
 	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 2, i32 1 )
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -221,7 +221,8 @@
 // We implicitly enable these when we have a write prefix supporting cache
 // level OR if we have prfchw, but don't already have a read prefetch from
 // 3dnow.
-return hasSSE1(

[PATCH] D135930: [X86] Add AVX-NE-CONVERT instructions.

2022-10-18 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

merge att/intel test coverage files and rename the 32/64 bit files so that they 
are close together in the file lists


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135930

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


[PATCH] D134853: [clang-format] Correctly annotate UDLs as OverloadedOperator

2022-10-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2126
   return false;
 
 FormatToken *LeftOfParens = Tok.MatchingParen->getPreviousNonComment();

Perhaps add:
```
if (Tok.MatchingParen->is(TT_OverloadedOperatorLParen))
  return false;
```



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:413
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::identifier, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);

rymiel wrote:
> owenpan wrote:
> > We need/should not annotate the suffix.
> Unless I change the logic in `rParenEndsCast`, the suffix does need to be an 
> OverloadedOperator, since it goes off of the token immediately before left 
> paren (https://reviews.llvm.org/D134853#3822842)
After we annotate `""` as `TT_OverloadedOperator`, `rParenEndsCast()` returns 
false, at least for your test cases and the example in 
https://github.com/llvm/llvm-project/issues/58035. If you can come up with test 
cases that still confuses `rParenEndsCast()`, we can add a simple check near 
the beginning of `rParenEndsCast()`. See line 2126 above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134853

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


[PATCH] D134728: [clangd] Add highlighting modifier "constructorOrDestructor"

2022-10-18 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 468465.
ckandeler retitled this revision from "[clangd] Add highlighting modifiers 
"constructor" and "destructor"" to "[clangd] Add highlighting modifier 
"constructorOrDestructor"".
ckandeler edited the summary of this revision.
ckandeler added a comment.

Now uses just one modifier instead of two, as discussed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134728

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -142,16 +142,16 @@
   $Namespace[[abc]]::$Class[[A]] $Variable_def[[AA]];
   typedef $Namespace[[abc]]::$Class[[A]] $Class_decl[[AAA]];
   struct $Class_def[[B]] {
-$Class_decl[[B]]();
-~$Class[[B]](); // FIXME: inconsistent with constructor
+$Class_decl_constrDestr[[B]]();
+~$Class_decl_constrDestr[[B]]();
 void operator<<($Class[[B]]);
 $Class[[AAA]] $Field_decl[[AA]];
   };
-  $Class[[B]]::$Class_def[[B]]() {}
-  $Class[[B]]::~$Class[[B]]() {} // FIXME: inconsistent with constructor
+  $Class[[B]]::$Class_def_constrDestr[[B]]() {}
+  $Class[[B]]::~$Class_def_constrDestr[[B]]() {}
   void $Function_def[[f]] () {
 $Class[[B]] $LocalVariable_def[[BB]] = $Class[[B]]();
-$LocalVariable[[BB]].~$Class[[B]]();
+$LocalVariable[[BB]].~$Class_constrDestr[[B]]();
 $Class[[B]]();
   }
 )cpp",
@@ -310,13 +310,13 @@
 $Class[[Foo]] $Field_decl[[Fo]];
 $Enum[[En]] $Field_decl[[E]];
 int $Field_decl[[I]];
-$Class_def[[Bar]] ($Class[[Foo]] $Parameter_def[[F]],
+$Class_def_constrDestr[[Bar]] ($Class[[Foo]] $Parameter_def[[F]],
 $Enum[[En]] $Parameter_def[[E]])
 : $Field[[Fo]] ($Parameter[[F]]), $Field[[E]] ($Parameter[[E]]),
   $Field[[I]] (123) {}
   };
   class $Class_def[[Bar2]] : public $Class[[Bar]] {
-$Class_def[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant_readonly[[EC]]) {}
+$Class_def_constrDestr[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant_readonly[[EC]]) {}
   };
 )cpp",
   R"cpp(
@@ -757,7 +757,7 @@
 static inline int $StaticField_def_static[[j]] = 0;
 };
 struct $Class_def[[ClassWithRefMembers]] {
-  $Class_def[[ClassWithRefMembers]](int $Parameter_def[[i]])
+  $Class_def_constrDestr[[ClassWithRefMembers]](int $Parameter_def[[i]])
 : $Field[[i1]]($Parameter[[i]]),
   $Field_readonly[[i2]]($Parameter[[i]]),
   $Field[[i3]]($Parameter_usedAsMutableReference[[i]]),
@@ -803,7 +803,7 @@
   $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_def[[S]] {
-  $Class_def[[S]](int&) {
+  $Class_def_constrDestr[[S]](int&) {
 $Class[[S]] $LocalVariable_def[[s1]]($Field_usedAsMutableReference[[field]]);
 $Class[[S]] $LocalVariable_def[[s2]]($LocalVariable[[s1]].$Field_usedAsMutableReference[[field]]);
 
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387
+# CHECK-NEXT:  32771
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "1"
 # CHECK-NEXT:  }
@@ -49,7 +49,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387
+# CHECK-NEXT:  32771
 # CHECK-NEXT:],
 #Inserted at position 1
 # CHECK-NEXT:"deleteCount": 0,
@@ -72,12 +72,12 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387,
+# CHECK-NEXT:  32771,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387
+# CHECK-NEXT:  32771
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "3"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -68,6 +68,7 @@
 # CHECK-NEXT:"dependentName",
 # CHECK-NEXT:

[PATCH] D136145: [IR][RFC] Restrict read only when cache type of llvm.prefetch is instruction

2022-10-18 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

The Arm changes (for tests) here are reasonable, and indeed both arm 
architectures do not allocate encoding space for instruction write.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136145

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


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-10-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Is the pre-commit CI failure here related to the patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D135110: [NFC] [HLSL] Move common metadata to LLVMFrontend

2022-10-18 Thread David Stuttard via Phabricator via cfe-commits
dstuttard added a comment.

I think that the reason we don't see the same failure for e.g. OpenACC is that 
there's a unittest/Frontend that requires OpenACC - if I comment out that 
subdir in the unittests/CMakeLists.txt it fails llvm-config test in the same 
way for OpenACC. Similarly, if I add FrontendHLSL as an LLVM_LINK_COMPONENT in 
unittests/Frontend/CMakeLists.txt (even though it isn't), the static lib is 
generated and llvm-lit llvm-config test passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135110

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


[PATCH] D136154: Fix the continuation indenter

2022-10-18 Thread Henrik Lafrenz via Phabricator via cfe-commits
hel-ableton created this revision.
hel-ableton added reviewers: JonasToth, MyDeveloperDay, owenpan.
hel-ableton added a project: clang-format.
Herald added a project: All.
hel-ableton requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When Style.BreakBeforeBinaryOperators is set to FormatStyle::BOS_NonAssignment, 
arguments following after a line break should be indented further, which they 
are
currently not. This attempts to fix that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136154

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6594,6 +6594,32 @@
"(someOtherLongishConditionPart1 || "
"someOtherEvenLongerNestedConditionPart2);",
Style));
+
+  Style = getLLVMStyle();
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BinPackParameters = false;
+  Style.ContinuationIndentWidth = 2;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  EXPECT_EQ(
+  "struct Derived {\n"
+  "  Derived(\n"
+  "int firstArgWithLongName,\n"
+  "int secondArgWithLongName,\n"
+  "int thirdArgWithLongName,\n"
+  "int fourthArgWithLongName)\n"
+  "  : Base(\n"
+  "  firstArgWithLongName,\n"
+  "  secondArgWithLongName,\n"
+  "  thirdArgWithLongName,\n"
+  "  fourthArgWithLongName) {}\n"
+  "};",
+  format("struct Derived {"
+ "  Derived(int firstArgWithLongName, int secondArgWithLongName, "
+ "int thirdArgWithLongName, int fourthArgWithLongName)"
+ ": Base(firstArgWithLongName, secondArgWithLongName, "
+ "thirdArgWithLongName, fourthArgWithLongName) {}"
+ "};",
+ Style));
 }
 
 TEST_F(FormatTest, ExpressionIndentationStrictAlign) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -809,7 +809,8 @@
 // Indent relative to the RHS of the expression unless this is a simple
 // assignment without binary expression on the RHS. Also indent relative to
 // unary operators and the colons of constructor initializers.
-if (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None)
+if (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
++   Style.BreakBeforeBinaryOperators == FormatStyle::BOS_NonAssignment)
   CurrentState.LastSpace = State.Column;
   } else if (Previous.is(TT_InheritanceColon)) {
 CurrentState.Indent = State.Column;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6594,6 +6594,32 @@
"(someOtherLongishConditionPart1 || "
"someOtherEvenLongerNestedConditionPart2);",
Style));
+
+  Style = getLLVMStyle();
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BinPackParameters = false;
+  Style.ContinuationIndentWidth = 2;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  EXPECT_EQ(
+  "struct Derived {\n"
+  "  Derived(\n"
+  "int firstArgWithLongName,\n"
+  "int secondArgWithLongName,\n"
+  "int thirdArgWithLongName,\n"
+  "int fourthArgWithLongName)\n"
+  "  : Base(\n"
+  "  firstArgWithLongName,\n"
+  "  secondArgWithLongName,\n"
+  "  thirdArgWithLongName,\n"
+  "  fourthArgWithLongName) {}\n"
+  "};",
+  format("struct Derived {"
+ "  Derived(int firstArgWithLongName, int secondArgWithLongName, "
+ "int thirdArgWithLongName, int fourthArgWithLongName)"
+ ": Base(firstArgWithLongName, secondArgWithLongName, "
+ "thirdArgWithLongName, fourthArgWithLongName) {}"
+ "};",
+ Style));
 }
 
 TEST_F(FormatTest, ExpressionIndentationStrictAlign) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -809,7 +809,8 @@
 // Indent relative to the RHS of the expression unless this is a simple
 // assignment without binary expression on the RHS. Also indent relative to
 // unary operators and the colons of constructor initializers.
-if (Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None)
+if (Style.BreakBeforeBinaryOperators == Forma

[PATCH] D135956: [include-cleaner] Add include-cleaner tool, with initial HTML report

2022-10-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

It looks good to me.

As discussed offline, would be nice to show line number for each line of code 
in the html dump.




Comment at: clang-tools-extra/include-cleaner/lib/HTMLReport.cpp:90
+  std::vector Targets;
+  std::vector> Refs;
+

This is for main-file right? worth a comment.



Comment at: clang-tools-extra/include-cleaner/lib/HTMLReport.cpp:97
+  void addRef(SourceLocation Loc, const NamedDecl &D) {
+auto Coords = SM.getDecomposedLoc(SM.getFileLoc(Loc));
+if (Coords.first != File)

using `auto [RefFileID, Offset] = SM.getDecomposedLoc(SM.getFileLoc(Loc));` is 
more readable, comparing the following `.first`, `.second` usage.



Comment at: clang-tools-extra/include-cleaner/lib/HTMLReport.cpp:101
+Targets.push_back({&D});
+Refs.push_back({Coords.second, Targets.size() - 1});
+  }

If I read this code correctly, `Refs` should only collect main-file refs, if so 
then we should bailout if `Coords.first != File`.



Comment at: clang-tools-extra/include-cleaner/unittests/RecordTest.cpp:1
+#include "clang-include-cleaner/Record.h"
+#include "clang/Frontend/FrontendAction.h"

nit: missing a file comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135956

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


[PATCH] D134853: [clang-format] Correctly annotate UDLs as OverloadedOperator

2022-10-18 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 468473.
rymiel marked 4 inline comments as done.
rymiel added a comment.

Do not annotate the trailing identifier of an UDL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134853

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -390,6 +390,55 @@
   EXPECT_TOKEN(Tokens[11], tok::amp, TT_PointerOrReference);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) {
+  auto Tokens = annotate("x.operator+()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::plus, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator=()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::equal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator+=()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::plusequal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator,()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::comma, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator()()");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::r_paren, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator[]()");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  // EXPECT_TOKEN(Tokens[3], tok::l_square, TT_OverloadedOperator);
+  // EXPECT_TOKEN(Tokens[4], tok::r_square, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator\"\"_a()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator\"\" _a()");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator\"\"if()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator\"\"s()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator\"\" s()");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) {
   auto Tokens = annotate("template \n"
  "concept C = (Foo && Bar) && (Bar && Baz);");
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10153,6 +10153,14 @@
   // verifyFormat("void f() { operator*(a & a); }");
   // verifyFormat("void f() { operator&(a, b * b); }");
 
+  verifyFormat("void f() { return operator()(x) * b; }");
+  verifyFormat("void f() { return operator[](x) * b; }");
+  verifyFormat("void f() { return operator\"\"_a(x) * b; }");
+  verifyFormat("void f() { return operator\"\" _a(x) * b; }");
+  verifyFormat("void f() { return operator\"\"s(x) * b; }");
+  verifyFormat("void f() { return operator\"\" s(x) * b; }");
+  verifyFormat("void f() { return operator\"\"if(x) * b; }");
+
   verifyFormat("::operator delete(foo);");
   verifyFormat("::operator new(n * sizeof(foo));");
   verifyFormat("foo() { ::operator delete(foo); }");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1176,13 +1176,17 @@
 if (CurrentToken->isOneOf(tok::star, tok::amp))
   CurrentToken->setType(TT_PointerOrReference);
 consumeToken();
-if (CurrentToken && CurrentToken->is(tok::comma) &&
+if (!CurrentToken)
+  continue;
+if (CurrentT

[PATCH] D134853: [clang-format] Correctly annotate UDLs as OverloadedOperator

2022-10-18 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel marked 2 inline comments as done.
rymiel added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2126
   return false;
 
 FormatToken *LeftOfParens = Tok.MatchingParen->getPreviousNonComment();

owenpan wrote:
> Perhaps add:
> ```
> if (Tok.MatchingParen->is(TT_OverloadedOperatorLParen))
>   return false;
> ```
Note that in testing, adding `isNot(TT_Unknown)` did not cause any issues in 
tests, but that change felt a little too drastic



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:413
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::identifier, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_OverloadedOperatorLParen);

owenpan wrote:
> rymiel wrote:
> > owenpan wrote:
> > > We need/should not annotate the suffix.
> > Unless I change the logic in `rParenEndsCast`, the suffix does need to be 
> > an OverloadedOperator, since it goes off of the token immediately before 
> > left paren (https://reviews.llvm.org/D134853#3822842)
> After we annotate `""` as `TT_OverloadedOperator`, `rParenEndsCast()` returns 
> false, at least for your test cases and the example in 
> https://github.com/llvm/llvm-project/issues/58035. If you can come up with 
> test cases that still confuses `rParenEndsCast()`, we can add a simple check 
> near the beginning of `rParenEndsCast()`. See line 2126 above.
Oh, you are right; I did not notice the extra check which disallows identifiers 
in front of casts



Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:415-423
+  Tokens = annotate("x.operator\"\"_long_literal()");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);
+  EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_OverloadedOperatorLParen);
+  Tokens = annotate("x.operator\"\" _long_literal()");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::string_literal, TT_OverloadedOperator);

owenpan wrote:
> IMO they are redundant as both `_a` and `_long_literal` are identifiers 
> starting with an underscore.
I wanted to avoid all the tests being single-character names, as 
"single-character name" was sort of an issue for one format bug; but actually 
this isn't even single character anyway so you are right


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134853

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


[PATCH] D136145: [IR][RFC] Restrict read only when cache type of llvm.prefetch is instruction

2022-10-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D136145#3864584 , @lenary wrote:

> The Arm changes (for tests) here are reasonable, and indeed both arm 
> architectures do not allocate encoding space for instruction write.

Thanks @lenary for confirmation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136145

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


[PATCH] D136080: [flang] Add -ffp-contract option processing

2022-10-18 Thread Tom Eccles via Phabricator via cfe-commits
tblah marked 5 inline comments as done.
tblah added a comment.

Thanks for taking a look. I've updated accordingly and will upload the patch 
soon.

> are you confident that we will need LangOptions.def?

Clang places this flag (and many other floating point options) in LangOptions 
so I thought I would follow the same convention here. Is there somewhere more 
appropriate to put them?




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:85-86
+ArgStringList &CmdArgs) {
+  // TODO: share RenderFloatingPointOptions from ./Clang.cpp and use that
+  // instead of duplicating code here
+  StringRef FPContract;

awarzynski wrote:
> What's RenderFloatingPointOptions?
It is a static function in clang/lib/Driver/ToolChains/Clang.cpp which does the 
same job as AddFloatingPointOptions, except for clang. I couldn't use it right 
away because not all of the options it it processes are supported in flang, but 
once we get there it would make sense to share code.


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

https://reviews.llvm.org/D136080

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


[PATCH] D136145: [IR][RFC] Restrict read only when cache type of llvm.prefetch is instruction

2022-10-18 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added inline comments.



Comment at: llvm/test/CodeGen/SystemZ/prefetch-01.ll:18
 
-; Check that instruction write prefetches are ignored.
-define dso_local void @f2(ptr %ptr) {
-; CHECK-LABEL: f2:
-; CHECK-NOT: %r2
-; CHECK: br %r14
-  call void @llvm.prefetch(ptr %ptr, i32 1, i32 0, i32 0)
-  ret void
-}
+; Instruction write prefetches are invalid.
+; define dso_local void @f2(ptr %ptr) {

If we decide to declare this invalid, then I'd prefer to remove the test 
instead of commenting it out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136145

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


[PATCH] D136080: [flang] Add -ffp-contract option processing

2022-10-18 Thread Tom Eccles via Phabricator via cfe-commits
tblah updated this revision to Diff 468475.

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

https://reviews.llvm.org/D136080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/LangOptions.def
  flang/include/flang/Frontend/LangOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/LangOptions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/flang_fp_opts.f90
  flang/test/Driver/frontend-forwarding.f90

Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -8,6 +8,7 @@
 ! RUN: -fdefault-real-8 \
 ! RUN: -flarge-sizes \
 ! RUN: -fconvert=little-endian \
+! RUN: -ffp-contract=fast \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -18,5 +19,6 @@
 ! CHECK: "-fdefault-integer-8"
 ! CHECK: "-fdefault-real-8"
 ! CHECK: "-flarge-sizes"
+! CHECK: "-ffp-contract=fast"
 ! CHECK: "-fconvert=little-endian"
 ! CHECK:  "-mllvm" "-print-before-all"
Index: flang/test/Driver/flang_fp_opts.f90
===
--- /dev/null
+++ flang/test/Driver/flang_fp_opts.f90
@@ -0,0 +1,5 @@
+! Test for passing of floating point options between the compiler and frontend
+! drivers.
+
+! RUN: %flang_fc1 -ffp-contract=fast %s 2>&1 | FileCheck %s
+! CHECK: ffp-contract= is not currently implemented
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -31,6 +31,7 @@
 ! HELP-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-NEXT: -ffixed-line-length=
 ! HELP-NEXT: Use  as character line width in fixed mode
+! HELP-NEXT: -ffp-contract= Form fused FP ops (e.g. FMAs): fast (fuses across statements disregarding pragmas) | on (only fuses in the same statement unless dictated by pragmas) | off (never fuses) | fast-honor-pragmas (fuses across statements unless diectated by pragmas). Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' otherwise.
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
@@ -105,6 +106,7 @@
 ! HELP-FC1-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-FC1-NEXT: -ffixed-line-length=
 ! HELP-FC1-NEXT: Use  as character line width in fixed mode
+! HELP-FC1-NEXT: -ffp-contract= Form fused FP ops (e.g. FMAs): fast (fuses across statements disregarding pragmas) | on (only fuses in the same statement unless dictated by pragmas) | off (never fuses) | fast-honor-pragmas (fuses across statements unless diectated by pragmas). Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' otherwise.
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fget-definition   
 ! HELP-FC1-NEXT:Get the symbol definition from   
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -31,6 +31,7 @@
 ! CHECK-NEXT: -ffixed-form   Process source files in fixed form
 ! CHECK-NEXT: -ffixed-line-length=
 ! CHECK-NEXT: Use  as character line width in fixed mode
+! CHECK-NEXT: -ffp-contract= Form fused FP ops (e.g. FMAs): fast (fuses across statements disregarding pragmas) | on (only fuses in the same statement unless dictated by pragmas) | off (never fuses) | fast-honor-pragmas (fuses across statements unless diectated by pragmas). Default is 'fast' for CUDA, 'fast-honor-pragmas' for HIP, and 'on' otherwise.
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
Index: flang/lib/Frontend/LangOptions.cpp
===
--- /dev/null
+++ flang/lib/Frontend/LangOptions.cpp
@@ -0,0 +1,24 @@
+//===-- LangOptions.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Coding style: http

RE: [clang] 0674f2e - [NFC] Fix warning on no return after switch.

2022-10-18 Thread stan li via cfe-commits
Thanks for the suggestion.

Updated llvm_unreachable.

The static_cast not only check the switch cases all covered, also make sure 2 
enums not out of sync.



Sent from Mail for Windows

From: David Blaikie
Sent: Monday, October 17, 2022 5:42 PM
To: Xiang Li; Xiang 
Li
Cc: cfe-commits@lists.llvm.org
Subject: Re: [clang] 0674f2e - [NFC] Fix warning on no return after switch.

Also the static_assert is probably not needed - Clang builds with
-Wswitch-enum, which will warn if a switch over an enum doesn't cover
all the enumerators. We have lots of other switches over enums that
depend on this warning to detect code that needs to be updated when an
enum is modified.

On Mon, Oct 17, 2022 at 5:40 PM David Blaikie  wrote:
>
> If the switch is exhaustive (covers all the enumerators in an
> enumeration), we usually use an llvm_unreachable at the end, rather
> than a return. Could you change this to an llvm_unreachable?
>
> On Mon, Oct 17, 2022 at 3:52 PM Xiang Li via cfe-commits
>  wrote:
> >
> >
> > Author: Xiang Li
> > Date: 2022-10-17T15:52:23-07:00
> > New Revision: 0674f2ec96422131abde0c042fbf2c11267db210
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/0674f2ec96422131abde0c042fbf2c11267db210.diff
> >
> > LOG: [NFC] Fix warning on no return after switch.
> >
> > Added:
> >
> >
> > Modified:
> > clang/lib/CodeGen/CGHLSLRuntime.cpp
> >
> > Removed:
> >
> >
> >
> > 
> > diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
> > b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > index 7a80dedb8133..6f32136b49de 100644
> > --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
> > @@ -270,6 +270,7 @@ 
> > castResourceShapeToResourceKind(HLSLResourceAttr::ResourceKind RK) {
> >static_cast(
> >HLSLResourceAttr::ResourceKind::FeedbackTexture2DArray) ==
> >(static_cast(llvm::hlsl::ResourceKind::NumEntries) - 2));
> > +  return llvm::hlsl::ResourceKind::Invalid;
> >  }
> >
> >  void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable 
> > *GV) {
> >
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D136018: [Clang] Fix crash when checking misaligned member with dependent type

2022-10-18 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/D136018/new/

https://reviews.llvm.org/D136018

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


[PATCH] D136041: [clang][DebugInfo] Emit DISubprogram for extern functions with reserved names

2022-10-18 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added a comment.

In D136041#3863748 , @dblaikie wrote:

> Hmm - this does mean linking IR can produce invalid code, though, right (you 
> link in a definition of the function, so what was valid is now invalid - 
> because it now has a definition, can be inlined, etc)? Is that new? 
> concerning?

As far as I understand this 

 discussion the check in question is "best effort".
My change further narrows conditions when verifier would report an error, thus 
it should not add any new failures to the existing code.
But yes, hypothetically there might be a situation when old version of the 
check would have caught a miss-behaving transformation at an earlier stage 
(before linking IR rather then after).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136041

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


[PATCH] D136160: [Attr][Doc] Fix pragma unroll documentation.

2022-10-18 Thread Alexey Bader via Phabricator via cfe-commits
bader created this revision.
bader added a reviewer: aaron.ballman.
Herald added a subscriber: ebevhan.
Herald added a project: All.
bader requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is a contradiction in the #pragma unroll behavior documentation.
It says that specifying `#pragma unroll` without a parameter directs the
loop unroller to attempt to partially unroll the loop if the trip count
is not known at compile time. At the same time later it states that
`#pragma unroll` has identical semantics to `#pragma clang loop
unroll(full)`, which doesn't attempt to unroll partially if the trip
count is not known at compile time.

If unroll(enable) is specified the unroller will attempt to fully unroll the 
loop if the trip count is known at compile time. If the fully unrolled code 
size is greater than an internal limit the loop will be partially unrolled up 
to this limit. If the trip count is not known at compile time the loop will be 
partially unrolled with a heuristically chosen unroll factor.

If unroll(full) is specified the unroller will attempt to fully unroll the loop 
if the trip count is known at compile time identically to unroll(enable). 
However, with unroll(full) the loop will not be unrolled if the loop count is 
not known at compile time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136160

Files:
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3569,7 +3569,7 @@
   }
 
 ``#pragma unroll`` and ``#pragma unroll _value_`` have identical semantics to
-``#pragma clang loop unroll(full)`` and
+``#pragma clang loop unroll(enable)`` and
 ``#pragma clang loop unroll_count(_value_)`` respectively. ``#pragma nounroll``
 is equivalent to ``#pragma clang loop unroll(disable)``. See
 `language extensions


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3569,7 +3569,7 @@
   }
 
 ``#pragma unroll`` and ``#pragma unroll _value_`` have identical semantics to
-``#pragma clang loop unroll(full)`` and
+``#pragma clang loop unroll(enable)`` and
 ``#pragma clang loop unroll_count(_value_)`` respectively. ``#pragma nounroll``
 is equivalent to ``#pragma clang loop unroll(disable)``. See
 `language extensions
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136145: [IR][RFC] Restrict read only when cache type of llvm.prefetch is instruction

2022-10-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 468486.
pengfei marked an inline comment as done.
pengfei added a comment.

Remove instruction write prefetch test from SystemZ.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136145

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-arm.c
  clang/test/Sema/builtin-prefetch.c
  llvm/docs/LangRef.rst
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/X86/X86Instr3DNow.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/test/CodeGen/SystemZ/prefetch-01.ll
  llvm/test/CodeGen/X86/prefetch.ll

Index: llvm/test/CodeGen/X86/prefetch.ll
===
--- llvm/test/CodeGen/X86/prefetch.ll
+++ llvm/test/CodeGen/X86/prefetch.ll
@@ -21,7 +21,7 @@
 
 ; rdar://10538297
 
-define void @t(ptr %ptr) nounwind  {
+define dso_local void @t(ptr %ptr) nounwind  {
 ; SSE-LABEL: t:
 ; SSE:   # %bb.0: # %entry
 ; SSE-NEXT:movl {{[0-9]+}}(%esp), %eax
@@ -33,6 +33,10 @@
 ; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:prefetcht0 (%eax)
 ; SSE-NEXT:prefetchnta (%eax)
+; SSE-NEXT:prefetcht1 (%eax)
+; SSE-NEXT:prefetcht0 (%eax)
+; SSE-NEXT:prefetcht1 t
+; SSE-NEXT:prefetcht0 ext
 ; SSE-NEXT:retl
 ;
 ; PRFCHWSSE-LABEL: t:
@@ -46,6 +50,10 @@
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
+; PRFCHWSSE-NEXT:prefetcht1 (%eax)
+; PRFCHWSSE-NEXT:prefetcht0 (%eax)
+; PRFCHWSSE-NEXT:prefetcht1 t
+; PRFCHWSSE-NEXT:prefetcht0 ext
 ; PRFCHWSSE-NEXT:retl
 ;
 ; PREFETCHWT1-LABEL: t:
@@ -59,6 +67,10 @@
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
 ; PREFETCHWT1-NEXT:prefetchw (%eax)
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
+; PREFETCHWT1-NEXT:prefetcht1 (%eax)
+; PREFETCHWT1-NEXT:prefetcht0 (%eax)
+; PREFETCHWT1-NEXT:prefetcht1 t
+; PREFETCHWT1-NEXT:prefetcht0 ext
 ; PREFETCHWT1-NEXT:retl
 ;
 ; 3DNOW-LABEL: t:
@@ -72,6 +84,10 @@
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
+; 3DNOW-NEXT:prefetch t
+; 3DNOW-NEXT:prefetch ext
 ; 3DNOW-NEXT:retl
 entry:
 	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 1, i32 1 )
@@ -82,7 +98,12 @@
 	tail call void @llvm.prefetch( ptr %ptr, i32 1, i32 2, i32 1 )
 	tail call void @llvm.prefetch( ptr %ptr, i32 1, i32 3, i32 1 )
 	tail call void @llvm.prefetch( ptr %ptr, i32 1, i32 0, i32 1 )
+	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 2, i32 0 )
+	tail call void @llvm.prefetch( ptr %ptr, i32 0, i32 3, i32 0 )
+	tail call void @llvm.prefetch( ptr @t,   i32 0, i32 2, i32 0 )
+	tail call void @llvm.prefetch( ptr @ext, i32 0, i32 3, i32 0 )
 	ret void
 }
 
+declare dso_local void @ext() nounwind
 declare void @llvm.prefetch(ptr, i32, i32, i32) nounwind
Index: llvm/test/CodeGen/SystemZ/prefetch-01.ll
===
--- llvm/test/CodeGen/SystemZ/prefetch-01.ll
+++ llvm/test/CodeGen/SystemZ/prefetch-01.ll
@@ -15,15 +15,6 @@
   ret void
 }
 
-; Check that instruction write prefetches are ignored.
-define dso_local void @f2(ptr %ptr) {
-; CHECK-LABEL: f2:
-; CHECK-NOT: %r2
-; CHECK: br %r14
-  call void @llvm.prefetch(ptr %ptr, i32 1, i32 0, i32 0)
-  ret void
-}
-
 ; Check data read prefetches.
 define dso_local void @f3(ptr %ptr) {
 ; CHECK-LABEL: f3:
Index: llvm/lib/Target/X86/X86InstrSSE.td
===
--- llvm/lib/Target/X86/X86InstrSSE.td
+++ llvm/lib/Target/X86/X86InstrSSE.td
@@ -3201,13 +3201,13 @@
 // Prefetch intrinsic.
 let Predicates = [HasSSEPrefetch], SchedRW = [WriteLoad] in {
 def PREFETCHT0   : I<0x18, MRM1m, (outs), (ins i8mem:$src),
-"prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3), (i32 1))]>, TB;
+"prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3), imm)]>, TB;
 def PREFETCHT1   : I<0x18, MRM2m, (outs), (ins i8mem:$src),
-"prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2), (i32 1))]>, TB;
+"prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2), imm)]>, TB;
 def PREFETCHT2   : I<0x18, MRM3m, (outs), (ins i8mem:$src),
-"prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1), (i32 1))]>, TB;
+"prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1), imm)]>, TB;
 def PREFETCHNTA  : I<0x18, MRM0m, (outs), (ins i8mem:$src),
-"prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0), (i32 1))]>, TB;
+"prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0), imm)]>, TB;
 }
 
 // FIXME: How should flush instruction be modeled?
Index: llvm/lib/Target/X86/X86Instr3DNow.td
===
--- llvm/lib/Target/X86/X86Instr3DNow.td
+++ llvm/lib/Target/X86/X86Instr

[PATCH] D136160: [Attr][Doc] Fix pragma unroll documentation.

2022-10-18 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 468487.
bader added a comment.

Update commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136160

Files:
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3569,7 +3569,7 @@
   }
 
 ``#pragma unroll`` and ``#pragma unroll _value_`` have identical semantics to
-``#pragma clang loop unroll(full)`` and
+``#pragma clang loop unroll(enable)`` and
 ``#pragma clang loop unroll_count(_value_)`` respectively. ``#pragma nounroll``
 is equivalent to ``#pragma clang loop unroll(disable)``. See
 `language extensions


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3569,7 +3569,7 @@
   }
 
 ``#pragma unroll`` and ``#pragma unroll _value_`` have identical semantics to
-``#pragma clang loop unroll(full)`` and
+``#pragma clang loop unroll(enable)`` and
 ``#pragma clang loop unroll_count(_value_)`` respectively. ``#pragma nounroll``
 is equivalent to ``#pragma clang loop unroll(disable)``. See
 `language extensions
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133248: [clang] Fix crash upon stray coloncolon token in C2x mode

2022-10-18 Thread Hu Jialun via Phabricator via cfe-commits
SuibianP updated this revision to Diff 468488.
SuibianP added a comment.

Remove superfluous parentheses


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133248

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/c2x-attributes.c


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot 
appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as 
scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2080,9 +2080,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope 
either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5411,6 +5411,8 @@
 return isDeclarationSpecifier(AllowImplicitTypename);
 
   case tok::coloncolon:   // ::foo::bar
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// ::new
 NextToken().is(tok::kw_delete))   // ::delete
   return false;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -866,10 +866,11 @@
   bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
 
   bool MightBeCXXScopeToken() {
-return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
-   (Tok.is(tok::annot_template_id) &&
-NextToken().is(tok::coloncolon)) ||
-   Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
+return getLangOpts().CPlusPlus &&
+   (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
+(Tok.is(tok::annot_template_id) &&
+ NextToken().is(tok::coloncolon)) ||
+Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
   }
   bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext = false) {
 return MightBeCXXScopeToken() && TryAnnotateCXXScopeToken(EnteringContext);


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2080,9 +2080,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5411,6 +5411,8 @@
 return isDeclarationSpecifier(AllowImplicitTypename);
 
   case tok::coloncolon:   // ::foo::bar
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// ::new
 NextToken().is(tok::kw_delete))   // ::delete
   return false;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -866,10 +866,11 @@
   bool TryAnnotateCXXScopeToken(

[PATCH] D135680: [clang][ARM] follow GCC behavior for defining __SOFTFP__

2022-10-18 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 468495.
stuij added a comment.

addressed review comment by adding test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135680

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/init-arm.c

Index: clang/test/Preprocessor/init-arm.c
===
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -395,199 +395,593 @@
 // ARM-BE:#define __arm 1
 // ARM-BE:#define __arm__ 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABISOFTFP %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABISOFT %s
 //
-// ARMEABISOFTFP-NOT:#define _LP64
-// ARMEABISOFTFP:#define __APCS_32__ 1
-// ARMEABISOFTFP-NOT:#define __ARMEB__ 1
-// ARMEABISOFTFP:#define __ARMEL__ 1
-// ARMEABISOFTFP:#define __ARM_ARCH 4
-// ARMEABISOFTFP:#define __ARM_ARCH_4T__ 1
-// ARMEABISOFTFP-NOT:#define __ARM_BIG_ENDIAN 1
-// ARMEABISOFTFP:#define __ARM_EABI__ 1
-// ARMEABISOFTFP:#define __ARM_PCS 1
-// ARMEABISOFTFP-NOT:#define __ARM_PCS_VFP 1
-// ARMEABISOFTFP:#define __BIGGEST_ALIGNMENT__ 8
-// ARMEABISOFTFP:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
-// ARMEABISOFTFP:#define __CHAR16_TYPE__ unsigned short
-// ARMEABISOFTFP:#define __CHAR32_TYPE__ unsigned int
-// ARMEABISOFTFP:#define __CHAR_BIT__ 8
-// ARMEABISOFTFP:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// ARMEABISOFTFP:#define __DBL_DIG__ 15
-// ARMEABISOFTFP:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// ARMEABISOFTFP:#define __DBL_HAS_DENORM__ 1
-// ARMEABISOFTFP:#define __DBL_HAS_INFINITY__ 1
-// ARMEABISOFTFP:#define __DBL_HAS_QUIET_NAN__ 1
-// ARMEABISOFTFP:#define __DBL_MANT_DIG__ 53
-// ARMEABISOFTFP:#define __DBL_MAX_10_EXP__ 308
-// ARMEABISOFTFP:#define __DBL_MAX_EXP__ 1024
-// ARMEABISOFTFP:#define __DBL_MAX__ 1.7976931348623157e+308
-// ARMEABISOFTFP:#define __DBL_MIN_10_EXP__ (-307)
-// ARMEABISOFTFP:#define __DBL_MIN_EXP__ (-1021)
-// ARMEABISOFTFP:#define __DBL_MIN__ 2.2250738585072014e-308
-// ARMEABISOFTFP:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
-// ARMEABISOFTFP:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// ARMEABISOFTFP:#define __FLT_DIG__ 6
-// ARMEABISOFTFP:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARMEABISOFTFP:#define __FLT_HAS_DENORM__ 1
-// ARMEABISOFTFP:#define __FLT_HAS_INFINITY__ 1
-// ARMEABISOFTFP:#define __FLT_HAS_QUIET_NAN__ 1
-// ARMEABISOFTFP:#define __FLT_MANT_DIG__ 24
-// ARMEABISOFTFP:#define __FLT_MAX_10_EXP__ 38
-// ARMEABISOFTFP:#define __FLT_MAX_EXP__ 128
-// ARMEABISOFTFP:#define __FLT_MAX__ 3.40282347e+38F
-// ARMEABISOFTFP:#define __FLT_MIN_10_EXP__ (-37)
-// ARMEABISOFTFP:#define __FLT_MIN_EXP__ (-125)
-// ARMEABISOFTFP:#define __FLT_MIN__ 1.17549435e-38F
-// ARMEABISOFTFP:#define __FLT_RADIX__ 2
-// ARMEABISOFTFP:#define __INT16_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT16_FMTd__ "hd"
-// ARMEABISOFTFP:#define __INT16_FMTi__ "hi"
-// ARMEABISOFTFP:#define __INT16_MAX__ 32767
-// ARMEABISOFTFP:#define __INT16_TYPE__ short
-// ARMEABISOFTFP:#define __INT32_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT32_FMTd__ "d"
-// ARMEABISOFTFP:#define __INT32_FMTi__ "i"
-// ARMEABISOFTFP:#define __INT32_MAX__ 2147483647
-// ARMEABISOFTFP:#define __INT32_TYPE__ int
-// ARMEABISOFTFP:#define __INT64_C_SUFFIX__ LL
-// ARMEABISOFTFP:#define __INT64_FMTd__ "lld"
-// ARMEABISOFTFP:#define __INT64_FMTi__ "lli"
-// ARMEABISOFTFP:#define __INT64_MAX__ 9223372036854775807LL
-// ARMEABISOFTFP:#define __INT64_TYPE__ long long int
-// ARMEABISOFTFP:#define __INT8_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT8_FMTd__ "hhd"
-// ARMEABISOFTFP:#define __INT8_FMTi__ "hhi"
-// ARMEABISOFTFP:#define __INT8_MAX__ 127
-// ARMEABISOFTFP:#define __INT8_TYPE__ signed char
-// ARMEABISOFTFP:#define __INTMAX_C_SUFFIX__ LL
-// ARMEABISOFTFP:#define __INTMAX_FMTd__ "lld"
-// ARMEABISOFTFP:#define __INTMAX_FMTi__ "lli"
-// ARMEABISOFTFP:#define __INTMAX_MAX__ 9223372036854775807LL
-// ARMEABISOFTFP:#define __INTMAX_TYPE__ long long int
-// ARMEABISOFTFP:#define __INTMAX_WIDTH__ 64
-// ARMEABISOFTFP:#define __INTPTR_FMTd__ "d"
-// ARMEABISOFTFP:#define __INTPTR_FMTi__ "i"
-// ARMEABISOFTFP:#define __INTPTR_MAX__ 2147483647
-// ARMEABISOFTFP:#define __INTPTR_TYPE__ int
-// ARMEABISOFTFP:#define __INTPTR_WIDTH__ 32
-// ARMEABISOFTFP:#define __INT_FAST16_FMTd__ "hd"
-// ARMEABISOFTFP:#define __INT_FAST16_FMTi__ "hi"
-// ARMEABISOFTFP:#define __INT_FAST16_MAX__ 32767
-// ARMEABISOFTFP:#define __INT_FAST16_TYPE__ short
-// ARMEABISOFTFP:#define __INT_FAST32_FMTd__ "d"
-// ARMEABISOFTFP:#define __INT_FAST32_FMTi__ "i"
-// ARMEABISOFTFP:#define __INT_FAST32_MAX__ 2147483647
-

[PATCH] D135680: [clang][ARM] follow GCC behavior for defining __SOFTFP__

2022-10-18 Thread Ties Stuij via Phabricator via cfe-commits
stuij marked an inline comment as done.
stuij added inline comments.



Comment at: clang/test/Preprocessor/init-arm.c:404
+//   is specified
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi 
-target-feature +soft-float -target-feature +soft-float-abi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARMEABISOFTFP_NOFP %s
 //

pratlucas wrote:
> I believe this RUN line won't covered the new condition added to 
> `clang/lib/Basic/Targets/ARM.cpp` above, as it sets `+soft-float`.
> Can you add an extra test without that option enabled?
ah yes, thanks! added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135680

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


[PATCH] D136162: [analyzer] Fix assertion failure in RegionStore within bindArray()

2022-10-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, martong, Szelethus, ASDenysPetrov, 
tomasz-kaminski-sonarsource, xazax.hun, isuckatcs.
Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It turns out we can reach the `Init.castAs()`
expression with other kinds of SVals. Such as by `nonloc::ConcreteInt`
in this example: https://godbolt.org/z/s4fdxrcs9

  int buffer[10];
  void b();
  void top() {
b(&buffer);
  }
  void b(int *c) {
*c = 42; // would crash
  }

In this example, we try to store `42` to the `Elem{buffer, 0}`.
A similar situation could happen if we reinterpret cast pointers, etc.
so the situation is not limited to conflicting function prototypes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136162

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/region-store.c


Index: clang/test/Analysis/region-store.c
===
--- clang/test/Analysis/region-store.c
+++ clang/test/Analysis/region-store.c
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection 
-verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection \
+// RUN:-verify -analyzer-config eagerly-assume=false -std=c99 %s \
+// RUN:-Wno-implicit-function-declaration
 
 int printf(const char *restrict,...);
 
@@ -54,3 +56,13 @@
 clang_analyzer_eval(values[0] == 4);// expected-warning {{UNKNOWN}}
   }
 }
+
+int buffer[10];
+void b(); // expected-warning {{a function declaration without a prototype is 
deprecated in all versions of C and is treated as a zero-parameter prototype in 
C2x, conflicting with a subsequent definition}}
+void top() {
+  // expected-warning@+1 {{passing arguments to 'b' without a prototype is 
deprecated in all versions of C and is not supported in C2x}}
+  b(&buffer);
+}
+void b(int *c) { // expected-note {{conflicting prototype is here}}
+  *c = 42; // no-crash
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2497,8 +2497,8 @@
 return bindAggregate(B, R, Init);
   }
 
-  if (Init.isUnknown())
-return bindAggregate(B, R, UnknownVal());
+  if (!isa(Init))
+return bindAggregate(B, R, Init);
 
   // Remaining case: explicit compound values.
   const nonloc::CompoundVal& CV = Init.castAs();


Index: clang/test/Analysis/region-store.c
===
--- clang/test/Analysis/region-store.c
+++ clang/test/Analysis/region-store.c
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection \
+// RUN:-verify -analyzer-config eagerly-assume=false -std=c99 %s \
+// RUN:-Wno-implicit-function-declaration
 
 int printf(const char *restrict,...);
 
@@ -54,3 +56,13 @@
 clang_analyzer_eval(values[0] == 4);// expected-warning {{UNKNOWN}}
   }
 }
+
+int buffer[10];
+void b(); // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C2x, conflicting with a subsequent definition}}
+void top() {
+  // expected-warning@+1 {{passing arguments to 'b' without a prototype is deprecated in all versions of C and is not supported in C2x}}
+  b(&buffer);
+}
+void b(int *c) { // expected-note {{conflicting prototype is here}}
+  *c = 42; // no-crash
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2497,8 +2497,8 @@
 return bindAggregate(B, R, Init);
   }
 
-  if (Init.isUnknown())
-return bindAggregate(B, R, UnknownVal());
+  if (!isa(Init))
+return bindAggregate(B, R, Init);
 
   // Remaining case: explicit compound values.
   const nonloc::CompoundVal& CV = Init.castAs();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135680: [clang][ARM] follow GCC behavior for defining __SOFTFP__

2022-10-18 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas accepted this revision.
pratlucas added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135680

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


[PATCH] D136080: [flang] Add -ffp-contract option processing

2022-10-18 Thread Tom Eccles via Phabricator via cfe-commits
tblah added a comment.

Linux CI is passing. I suspect the CI failure on windows is unrelated to my 
code: the test failure is for clang-scan-deps and the previous version of the 
patch passed CI.


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

https://reviews.llvm.org/D136080

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


[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic

2022-10-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/array-bounds.cpp:240
 
-((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 32768 elements)}}
+((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 32768 
is past the end of the array (which contains 4096 elements)}}
 

void wrote:
> serge-sans-paille wrote:
> > kees wrote:
> > > serge-sans-paille wrote:
> > > > I find this new message quite confusing, because the array index is 
> > > > given in terms of char elements, while the array size is given in terms 
> > > > of double elements. I actually find the original message more 
> > > > consistent to that respect.
> > > Perhaps show both element count and byte offset?
> > > 
> > > `array index $count is $(bytes - end_of_array_in_bytes) past the end of 
> > > the array (which contains $end_of_array_in_bytes bytes of 
> > > $array_max_index elements)`
> > if we have no cast, I find the version without the patch  just fine.
> > 
> > If we have a cast, I suggest we just express the result in bytes, something 
> > along those lines (inspired by your suggestion):
> > 
> > array index $count is $(bytes - end_of_array_in_bytes) bytes past the 
> > end of the allocated memory for that array (which contains 
> > $end_of_array_in_bytes bytes)
> I so far have this. It looks not too bad even for the non-cast. Thoughts?
> 
> ```
> $ cat ab.c
> void test_pr10771() {
> double foo[4096];  // expected-note {{array 'foo' declared here}}
> 
> ((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 
> 32768 is past the end of the array (which contains 4096 elements of type 
> 'double[4096])}}
> foo[4098] = '\0';  // expected-warning {{array index 32768 is past the 
> end of the array (which contains 4096 elements of type 'double[4096])}}
> }
> $ clang++ -x c++ -o /dev/null -S -std=c++14 ~/llvm/ab.c
> /home/morbo/llvm/ab.c:4:13: warning: array index 32768 is 0 bytes past the 
> end of the array (that has type 'double[4096]') [-Warray-bounds]
> ((char*)foo)[sizeof(foo)] = '\0';  // expected-warning {{array index 
> 32768 is past the end of the array (which contains 4096 elements of type 
> 'double[4096])}}
> ^~~~
> /home/morbo/llvm/ab.c:2:5: note: array 'foo' declared here
> double foo[4096];  // expected-note {{array 'foo' declared here}}
> ^
> /home/morbo/llvm/ab.c:5:5: warning: array index 4098 is 16 bytes past the end 
> of the array (that has type 'double[4096]') [-Warray-bounds]
> foo[4098] = '\0';  // expected-warning {{array index 32768 is past the 
> end of the array (which contains 4096 elements of type 'double[4096])}}
> ^   
> /home/morbo/llvm/ab.c:2:5: note: array 'foo' declared here
> double foo[4096];  // expected-note {{array 'foo' declared here}}
> ^
> 2 warnings generated.
> ```
The part I struggle with is the "is 0 bytes past the end of the array" -- that 
reads as if it's not past the end of the array at all because it's saying 
"You've accessed right up to the end of the array; congratulations on your very 
careful use!".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135920

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


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-10-18 Thread Yusuke Kadowaki via Phabricator via cfe-commits
yusuke-kadowaki added a comment.

Thank you for all the reviews. Appreciate it.

So will some of you land this or am I supposed to do something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[PATCH] D135025: [clang][Interp] Support base class constructors

2022-10-18 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.

Okay, this is incremental progress, so LGTM!


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

https://reviews.llvm.org/D135025

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


[PATCH] D133248: [clang] Fix crash upon stray coloncolon token in C2x mode

2022-10-18 Thread Hu Jialun via Phabricator via cfe-commits
SuibianP updated this revision to Diff 468509.
SuibianP added a comment.

Add release note entry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133248

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/c2x-attributes.c


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot 
appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as 
scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2080,9 +2080,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope 
either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5411,6 +5411,8 @@
 return isDeclarationSpecifier(AllowImplicitTypename);
 
   case tok::coloncolon:   // ::foo::bar
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// ::new
 NextToken().is(tok::kw_delete))   // ::delete
   return false;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -866,10 +866,11 @@
   bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
 
   bool MightBeCXXScopeToken() {
-return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
-   (Tok.is(tok::annot_template_id) &&
-NextToken().is(tok::coloncolon)) ||
-   Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
+return getLangOpts().CPlusPlus &&
+   (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
+(Tok.is(tok::annot_template_id) &&
+ NextToken().is(tok::coloncolon)) ||
+Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
   }
   bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext = false) {
 return MightBeCXXScopeToken() && TryAnnotateCXXScopeToken(EnteringContext);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -251,6 +251,7 @@
 - Address the thread identification problems in coroutines.
   `Issue 47177 `_
   `Issue 47179 `_
+- Fix a crash upon stray coloncolon token in C2x mode.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2080,9 +2080,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5411,

[PATCH] D136133: [Clang] update cxx_dr_status.html by running make_cxx_dr_status

2022-10-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Thank you so much for doing this.  I'm hopeful our hackery can go away sometime 
soon.




Comment at: clang/test/CXX/drs/dr25xx.cpp:3
 
-namespace dr2565 { // dr252: 16
+namespace dr2565 { // dr2565: partial
   template

If you could add a comment explaining this status for me, I would be grateful:

// We've implemented DR2565 as proposed (that is, a substitution failure in a 
requires parameter list causes the requires clause to evaluate as false) as it 
seems to make the most sense, and fit best into our implementation. If this 
issue gets accepted as-is, this can be marked as complete.



Comment at: clang/www/make_cxx_dr_status:161
 continue
-  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
+  if dr.issue in (1432,2565):
+row_style = ' class="open"'

I guess this is OK, its a shame we have to custom-tag these, but I guess I'm 
1/2 responsible here :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136133

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


[clang] 2946b25 - [Clang] Fix crash when checking misaligned member with dependent type

2022-10-18 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-10-18T21:05:49+08:00
New Revision: 2946b252993d9b4c12479bf318b648bed2c0427a

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

LOG: [Clang] Fix crash when checking misaligned member with dependent type

If the type is dependent, we should just discard it and not checking its
alignment as it doesn't exisit yet.
Fixes https://github.com/llvm/llvm-project/issues/58370

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

Added: 
clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp

Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index c0ecd7b091000..9d8640a6a057a 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -17387,15 +17387,15 @@ void Sema::DiagnoseMisalignedMembers() {
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
   E = E->IgnoreParens();
-  if (!T->isPointerType() && !T->isIntegerType())
+  if (!T->isPointerType() && !T->isIntegerType() && !T->isDependentType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
-  auto MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
+  auto *MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  (T->isIntegerType() ||
+  (T->isDependentType() || T->isIntegerType() ||
(T->isPointerType() && (T->getPointeeType()->isIncompleteType() ||
Context.getTypeAlignInChars(
T->getPointeeType()) <= 
MA->Alignment

diff  --git a/clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp 
b/clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
new file mode 100644
index 0..cd4768350bab4
--- /dev/null
+++ b/clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct __attribute__((packed)) {
+  unsigned options;
+  template 
+  void getOptions() {
+  (T *)&options;
+  }
+  template 
+   void getOptions2() {
+  (U)&options;
+   }
+} s;
+
+struct __attribute__((packed)) { // expected-error {{anonymous structs and 
classes must be class members}}
+   unsigned options ;
+  template  getOptions() // expected-error {{a type specifier is 
required for all declarations}}
+{
+  (T *) & options;
+}
+};



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


[PATCH] D136018: [Clang] Fix crash when checking misaligned member with dependent type

2022-10-18 Thread Jun Zhang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
junaire marked an inline comment as done.
Closed by commit rG2946b252993d: [Clang] Fix crash when checking misaligned 
member with dependent type (authored by junaire).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136018

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp


Index: clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct __attribute__((packed)) {
+  unsigned options;
+  template 
+  void getOptions() {
+  (T *)&options;
+  }
+  template 
+   void getOptions2() {
+  (U)&options;
+   }
+} s;
+
+struct __attribute__((packed)) { // expected-error {{anonymous structs and 
classes must be class members}}
+   unsigned options ;
+  template  getOptions() // expected-error {{a type specifier is 
required for all declarations}}
+{
+  (T *) & options;
+}
+};
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -17387,15 +17387,15 @@
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
   E = E->IgnoreParens();
-  if (!T->isPointerType() && !T->isIntegerType())
+  if (!T->isPointerType() && !T->isIntegerType() && !T->isDependentType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
-  auto MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
+  auto *MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  (T->isIntegerType() ||
+  (T->isDependentType() || T->isIntegerType() ||
(T->isPointerType() && (T->getPointeeType()->isIncompleteType() ||
Context.getTypeAlignInChars(
T->getPointeeType()) <= 
MA->Alignment


Index: clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/misaligned-member-with-depdent-type.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct __attribute__((packed)) {
+  unsigned options;
+  template 
+  void getOptions() {
+  (T *)&options;
+  }
+  template 
+	void getOptions2() {
+  (U)&options;
+	}
+} s;
+
+struct __attribute__((packed)) { // expected-error {{anonymous structs and classes must be class members}}
+   unsigned options ;
+  template  getOptions() // expected-error {{a type specifier is required for all declarations}}
+{
+  (T *) & options;
+}
+};
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -17387,15 +17387,15 @@
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
   E = E->IgnoreParens();
-  if (!T->isPointerType() && !T->isIntegerType())
+  if (!T->isPointerType() && !T->isIntegerType() && !T->isDependentType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
-  auto MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
+  auto *MA = llvm::find(MisalignedMembers, MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  (T->isIntegerType() ||
+  (T->isDependentType() || T->isIntegerType() ||
(T->isPointerType() && (T->getPointeeType()->isIncompleteType() ||
Context.getTypeAlignInChars(
T->getPointeeType()) <= MA->Alignment
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4bcb85c - Stop evaluating trailing requires clause after overload resolution

2022-10-18 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-10-18T06:08:10-07:00
New Revision: 4bcb85c638c1c1719c5c01a70ee2e376e4032d2a

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

LOG: Stop evaluating trailing requires clause after overload resolution

Reported as it showed up as a constriants failure after the deferred
instantiation patch, we were checking constraints TWICE after overload
resolution.  The first is during overload resolution, the second is when
diagnosing a use.

This patch modifies DiagnoseUseOfDecl to skip the trailing requires
clause check in some cases. First, of course, after choosing a candidate
after overload resolution.

The second is when evaluating a shadow using constructor, which had its
constraints checked when picking a constructor (as this is ALWAYS an
overload situation!).

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaTemplate/concepts.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a7f3ac1f57c31..6b422c3897c38 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5304,11 +5304,22 @@ class Sema final {
   // Expression Parsing Callbacks: SemaExpr.cpp.
 
   bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
+  // A version of DiagnoseUseOfDecl that should be used if overload resolution
+  // has been used to find this declaration, which means we don't have to 
bother
+  // checking the trailing requires clause.
+  bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc) {
+return DiagnoseUseOfDecl(
+D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
+/*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
+/*SkipTrailingRequiresClause=*/true);
+  }
+
   bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef Locs,
  const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
  bool ObjCPropertyAccess = false,
  bool AvoidPartialAvailabilityChecks = false,
- ObjCInterfaceDecl *ClassReciever = nullptr);
+ ObjCInterfaceDecl *ClassReciever = nullptr,
+ bool SkipTrailingRequiresClause = false);
   void NoteDeletedFunction(FunctionDecl *FD);
   void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD);
   bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 280af69da6a2b..5fe6f82fe3d08 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -15551,7 +15551,10 @@ Sema::BuildCXXConstructExpr(SourceLocation 
ConstructLoc, QualType DeclInitType,
 SourceRange ParenRange) {
   if (auto *Shadow = dyn_cast(FoundDecl)) {
 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
-if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
+// The only way to get here is if we did overlaod resolution to find the
+// shadow decl, so we don't need to worry about re-checking the trailing
+// requires clause.
+if (DiagnoseUseOfOverloadedDecl(Constructor, ConstructLoc))
   return ExprError();
   }
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7faae7e7ee430..f950e4313f5e9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -222,7 +222,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef Locs,
  const ObjCInterfaceDecl *UnknownObjCClass,
  bool ObjCPropertyAccess,
  bool AvoidPartialAvailabilityChecks,
- ObjCInterfaceDecl *ClassReceiver) {
+ ObjCInterfaceDecl *ClassReceiver,
+ bool SkipTrailingRequiresClause) {
   SourceLocation Loc = Locs.front();
   if (getLangOpts().CPlusPlus && isa(D)) {
 // If there were any diagnostics suppressed by template argument deduction,
@@ -281,7 +282,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef Locs,
 // See if this is a function with constraints that need to be satisfied.
 // Check this before deducing the return type, as it might instantiate the
 // definition.
-if (FD->getTrailingRequiresClause()) {
+if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
   ConstraintSatisfaction Satisfaction;
   if (CheckFunctionConstraints(FD, Satisfaction, Loc,
/*ForOverloadResolution*/ t

[PATCH] D135772: Stop evaluating trailing requires clause after overload resolution

2022-10-18 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bcb85c638c1: Stop evaluating trailing requires clause after 
overload resolution (authored by erichkeane).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135772

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaTemplate/concepts.cpp

Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -708,3 +708,60 @@
 // expected-note@#CMVT_REQ{{because 'sizeof(int) == arity' (4 == 5) evaluated to false}}
 } // namespace ConstrainedMemberVarTemplate 
 
+// These should not diagnose, where we were unintentionally doing so before by
+// checking trailing requires clause twice, yet not having the ability to the
+// 2nd time, since it was no longer a dependent variant.
+namespace InheritedFromPartialSpec {
+template
+constexpr bool Check = true;
+
+template
+struct Foo {
+  template
+Foo(U&&) requires (Check){}
+  template
+void MemFunc(U&&) requires (Check){}
+  template
+static void StaticMemFunc(U&&) requires (Check){}
+  ~Foo() requires (Check){}
+};
+
+template<>
+  struct Foo : Foo {
+using Foo::Foo;
+using Foo::MemFunc;
+using Foo::StaticMemFunc;
+  };
+
+void use() {
+  Foo F {1.1};
+  F.MemFunc(1.1);
+  Foo::StaticMemFunc(1.1);
+}
+
+template
+struct counted_iterator {
+  constexpr auto operator->() const noexcept requires false {
+return T::Invalid;
+  };
+};
+
+template
+concept __has_member_pointer = requires { typename _Ip::pointer; };
+
+template
+struct __iterator_traits_member_pointer_or_arrow_or_void { using type = void; };
+template<__has_member_pointer _Ip>
+struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typename _Ip::pointer; };
+
+template
+  requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
+struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
+  using type = decltype(declval<_Ip&>().operator->());
+};
+
+
+void use2() {
+  __iterator_traits_member_pointer_or_arrow_or_void> f;
+}
+}// namespace InheritedFromPartialSpec 
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -14680,7 +14680,7 @@
   Method = cast(Best->Function);
   FoundDecl = Best->FoundDecl;
   CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
-  if (DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->getNameLoc()))
+  if (DiagnoseUseOfOverloadedDecl(Best->FoundDecl, UnresExpr->getNameLoc()))
 break;
   // If FoundDecl is different from Method (such as if one is a template
   // and the other a specialization), make sure DiagnoseUseOfDecl is
@@ -14689,7 +14689,7 @@
   // DiagnoseUseOfDecl to accept both the FoundDecl and the decl
   // being used.
   if (Method != FoundDecl.getDecl() &&
-  DiagnoseUseOfDecl(Method, UnresExpr->getNameLoc()))
+  DiagnoseUseOfOverloadedDecl(Method, UnresExpr->getNameLoc()))
 break;
   Succeeded = true;
   break;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -222,7 +222,8 @@
  const ObjCInterfaceDecl *UnknownObjCClass,
  bool ObjCPropertyAccess,
  bool AvoidPartialAvailabilityChecks,
- ObjCInterfaceDecl *ClassReceiver) {
+ ObjCInterfaceDecl *ClassReceiver,
+ bool SkipTrailingRequiresClause) {
   SourceLocation Loc = Locs.front();
   if (getLangOpts().CPlusPlus && isa(D)) {
 // If there were any diagnostics suppressed by template argument deduction,
@@ -281,7 +282,7 @@
 // See if this is a function with constraints that need to be satisfied.
 // Check this before deducing the return type, as it might instantiate the
 // definition.
-if (FD->getTrailingRequiresClause()) {
+if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
   ConstraintSatisfaction Satisfaction;
   if (CheckFunctionConstraints(FD, Satisfaction, Loc,
/*ForOverloadResolution*/ true))
@@ -6761,8 +6762,8 @@
 nullptr, DRE->isNonOdrUse());
   }
 }
-  } else if (isa(NakedFn))
-NDecl = cast(NakedFn)->getMemberDecl();
+  } else if (auto *ME = dyn_cast(NakedFn))
+NDecl = ME->getMemberDecl();
 
   if (FunctionDecl *FD = dyn_cast_or_null(NDecl)) {
 if (CallingNDeclIndirectly && !che

[PATCH] D135136: [analyzer] Make directly bounded LazyCompoundVal as lazily copied

2022-10-18 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2843
-// subregions of the `LCS.getRegion()` also lazily copied.
-if (const MemRegion *R = LCS->getRegion())
-  SymReaper.markLazilyCopied(R);

tomasz-kaminski-sonarsource wrote:
> martong wrote:
> > Why can we remove this line?
> > If `LCS->getRegion()` returns a non-null unconditionally then please add an 
> > `assert`.
> The interface of the `LazyCompoundVal` is already marked as returning 
> non-null, and this is why we removed the if condition:
> ```
>   LLVM_ATTRIBUTE_RETURNS_NONNULL
>   const TypedValueRegion *getRegion() const;
> ```
Ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135136

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


[PATCH] D136041: [clang][DebugInfo] Emit DISubprogram for extern functions with reserved names

2022-10-18 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 updated this revision to Diff 468514.
eddyz87 added a comment.

Split the original commit in two to separate clang and llvm parts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136041

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/callsite-dbgloc.ll


Index: llvm/test/Verifier/callsite-dbgloc.ll
===
--- llvm/test/Verifier/callsite-dbgloc.ll
+++ llvm/test/Verifier/callsite-dbgloc.ll
@@ -45,6 +45,9 @@
   call void @j()
 ; CHECK: inlinable function call in a function with debug info must have a 
!dbg location
   call void @k()
+; CHECK-NOT: inlinable function call in a function with debug info must have a 
!dbg location
+; CHECK-NOT: @i
+  call void (...) @i()
   ret void, !dbg !13
 }
 
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -3466,9 +3466,11 @@
   // Verify that each inlinable callsite of a debug-info-bearing function in a
   // debug-info-bearing function has a debug location attached to it. Failure 
to
   // do so causes assertion failures when the inliner sets up inline scope info
-  // (Interposable functions are not inlinable).
+  // (Interposable functions are not inlinable as are functions w/o
+  //  declarations).
   if (Call.getFunction()->getSubprogram() && Call.getCalledFunction() &&
   !Call.getCalledFunction()->isInterposable() &&
+  !Call.getCalledFunction()->isDeclaration() &&
   Call.getCalledFunction()->getSubprogram())
 CheckDI(Call.getDebugLoc(),
 "inlinable function call in a function with "
Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -29,8 +29,8 @@
 // DECLS-FOR-EXTERN: [[FN1_TYPES]] = !{[[X_TYPE:![0-9]+]],
 // DECLS-FOR-EXTERN: [[X_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: 
"x",
 // DECLS-FOR-EXTERN-SAME: baseType: [[INT_TYPE]])
-// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
-// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
+// DECLS-FOR-EXTERN: !DISubprogram(name: "memcmp"
+// DECLS-FOR-EXTERN: !DISubprogram(name: "__some_reserved_name"
 
 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "fn1"
 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4228,17 +4228,11 @@
   if (Func->getSubprogram())
 return;
 
-  // Do not emit a declaration subprogram for a builtin, a function with 
nodebug
-  // attribute, or if call site info isn't required. Also, elide declarations
-  // for functions with reserved names, as call site-related features aren't
-  // interesting in this case (& also, the compiler may emit calls to these
-  // functions without debug locations, which makes the verifier complain).
-  if (CalleeDecl->getBuiltinID() != 0 || CalleeDecl->hasAttr() ||
+  // Do not emit a declaration subprogram for a function with nodebug
+  // attribute, or if call site info isn't required.
+  if (CalleeDecl->hasAttr() ||
   getCallSiteRelatedAttrs() == llvm::DINode::FlagZero)
 return;
-  if (CalleeDecl->isReserved(CGM.getLangOpts()) !=
-  ReservedIdentifierStatus::NotReserved)
-return;
 
   // If there is no DISubprogram attached to the function being called,
   // create the one describing the function in order to have complete


Index: llvm/test/Verifier/callsite-dbgloc.ll
===
--- llvm/test/Verifier/callsite-dbgloc.ll
+++ llvm/test/Verifier/callsite-dbgloc.ll
@@ -45,6 +45,9 @@
   call void @j()
 ; CHECK: inlinable function call in a function with debug info must have a !dbg location
   call void @k()
+; CHECK-NOT: inlinable function call in a function with debug info must have a !dbg location
+; CHECK-NOT: @i
+  call void (...) @i()
   ret void, !dbg !13
 }
 
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -3466,9 +3466,11 @@
   // Verify that each inlinable callsite of a debug-info-bearing function in a
   // debug-info-bearing function has a debug location attached to it. Failure to
   // do so causes assertion failures when the inliner sets up inline scope info
-  // (Interposable functions are not inlinable).
+  // (Interposable functions are not inlinable as are functions w/o
+  //  declarations).
   if (Call.getFunction()->getSubprogram() && Call.getCalledFunction() &&
   !Call.getCalledFunction()->isIn

[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-10-18 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

Please provide a name and an email so someone could commit it on your behalf


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[clang] bb3c90d - [OpenMP] Make device functions have hidden visibility

2022-10-18 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-10-18T08:15:39-05:00
New Revision: bb3c90d3ecd142e60cf994338bdd4b59d8788cd3

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

LOG: [OpenMP] Make device functions have hidden visibility

In OpenMP target offloading an in other offloading languages, we
maintain a difference between device functions and kernel functions.
Kernel functions must be visible to the host and act as the entry point
to the target device. Device functions however cannot be called directly
by the host and must be called by a kernel function. Currently, we make
all definitions on the device protected by default. Because device
functions cannot be called or used by the host they should have hidden
visibility. This allows for the definitions to be better optimized via
LTO or other passes.

This patch marks every device function in the AST as having `hidden`
visibility. The kernel function is generated later at code-gen and we
set its visibility explicitly so it should not be affected. This
prevents the user from overriding the visibility, but since the user
can't do anything with these symbols anyway there is no point exporting
them right now.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
clang/test/OpenMP/target_attribute_convergent.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index d1dd93b0a5b6b..510910b34fadc 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -835,6 +835,15 @@ LinkageComputer::getLVForNamespaceScopeDecl(const 
NamedDecl *D,
 if (Function->getStorageClass() == SC_PrivateExtern)
   LV.mergeVisibility(HiddenVisibility, true);
 
+// OpenMP target declare device functions are not callable from the host so
+// they should not be exported from the device image. This applies to all
+// functions as the host-callable kernel functions are emitted at codegen.
+if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice &&
+((Context.getTargetInfo().getTriple().isAMDGPU() ||
+  Context.getTargetInfo().getTriple().isNVPTX()) ||
+ OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Function)))
+  LV.mergeVisibility(HiddenVisibility, /*newExplicit=*/false);
+
 // Note that Sema::MergeCompatibleFunctionDecls already takes care of
 // merging storage classes and visibility attributes, so we don't have to
 // look at previous decls in here.

diff  --git a/clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp 
b/clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
index 7f6f9a0bc5b9a..c38e958f74f36 100644
--- a/clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ b/clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -34,12 +34,12 @@ int car() { return 0; }
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[FOO:@.*foo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAZ:@.*caz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAR:@.*bar.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[DOO:@.*doo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[CAR:@.*car.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[CAZ:@.*caz.*]]()
 
 static int c = foo() + bar() + baz();
 #pragma omp declare target (c)

diff  --git a/clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp 
b/clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
index cfc86359de947..1db4f26f0c811 100644
--- a/clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ b/clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -34,18 +34,18 @@ struct T1 {
 #pragma omp declare target
 T a = T();
 T f = a;
-// CHECK: define{{ protected | }}void @{{.+}}foo{{.+}}([[T]]* noundef 
byval([[T]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo{{.+}}([[T]]* noundef 
byval([[T]]) align {{.+}})
 void foo(T a = T()) {
   return;
 }
-// CHECK: define{{ protected | }}[6 x i64] @{{.+}}bar{{.+}}()
+// CHECK: define{{ hidden | }}[6 x i64] @{{.+}}bar{{.+}}()
 T bar() {
 // CHECK:  bitcast [[T]]* %{{.+}} to [6 x i64]*
 // CHECK-NEXT: load [6 x i64], [6 x i64]* %{{.+}},
 // CHECK-

[PATCH] D136111: [OpenMP] Make device functions have hidden visibility

2022-10-18 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb3c90d3ecd1: [OpenMP] Make device functions have hidden 
visibility (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136111

Files:
  clang/lib/AST/Decl.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/target_attribute_convergent.cpp

Index: clang/test/OpenMP/target_attribute_convergent.cpp
===
--- clang/test/OpenMP/target_attribute_convergent.cpp
+++ clang/test/OpenMP/target_attribute_convergent.cpp
@@ -9,5 +9,5 @@
 #pragma omp end declare target
 
 // CHECK: Function Attrs: {{.*}}convergent{{.*}}
-// CHECK: define protected void @_Z3foov() [[ATTRIBUTE_NUMBER:#[0-9]+]]
+// CHECK: define hidden void @_Z3foov() [[ATTRIBUTE_NUMBER:#[0-9]+]]
 // CHECK: attributes [[ATTRIBUTE_NUMBER]] = { {{.*}}convergent{{.*}} }
Index: clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -34,18 +34,18 @@
 #pragma omp declare target
 T a = T();
 T f = a;
-// CHECK: define{{ protected | }}void @{{.+}}foo{{.+}}([[T]]* noundef byval([[T]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo{{.+}}([[T]]* noundef byval([[T]]) align {{.+}})
 void foo(T a = T()) {
   return;
 }
-// CHECK: define{{ protected | }}[6 x i64] @{{.+}}bar{{.+}}()
+// CHECK: define{{ hidden | }}[6 x i64] @{{.+}}bar{{.+}}()
 T bar() {
 // CHECK:  bitcast [[T]]* %{{.+}} to [6 x i64]*
 // CHECK-NEXT: load [6 x i64], [6 x i64]* %{{.+}},
 // CHECK-NEXT: ret [6 x i64]
   return T();
 }
-// CHECK: define{{ protected | }}void @{{.+}}baz{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz{{.+}}()
 void baz() {
 // CHECK:  call [6 x i64] @{{.+}}bar{{.+}}()
 // CHECK-NEXT: bitcast [[T]]* %{{.+}} to [6 x i64]*
@@ -54,17 +54,17 @@
 }
 T1 a1 = T1();
 T1 f1 = a1;
-// CHECK: define{{ protected | }}void @{{.+}}foo1{{.+}}([[T1]]* noundef byval([[T1]]) align {{.+}})
+// CHECK: define{{ hidden | }}void @{{.+}}foo1{{.+}}([[T1]]* noundef byval([[T1]]) align {{.+}})
 void foo1(T1 a = T1()) {
   return;
 }
-// CHECK: define{{ protected | }}[[T1]] @{{.+}}bar1{{.+}}()
+// CHECK: define{{ hidden | }}[[T1]] @{{.+}}bar1{{.+}}()
 T1 bar1() {
 // CHECK:  load [[T1]], [[T1]]*
 // CHECK-NEXT: ret [[T1]]
   return T1();
 }
-// CHECK: define{{ protected | }}void @{{.+}}baz1{{.+}}()
+// CHECK: define{{ hidden | }}void @{{.+}}baz1{{.+}}()
 void baz1() {
 // CHECK: call [[T1]] @{{.+}}bar1{{.+}}()
   T1 t = bar1();
Index: clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
===
--- clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -34,12 +34,12 @@
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[FOO:@.*foo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ protected | }}noundef i32 [[CAZ:@.*caz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAR:@.*bar.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[DOO:@.*doo.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[CAR:@.*car.*]]()
+// DEVICE-DAG: define hidden noundef i32 [[CAZ:@.*caz.*]]()
 
 static int c = foo() + bar() + baz();
 #pragma omp declare target (c)
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -835,6 +835,15 @@
 if (Function->getStorageClass() == SC_PrivateExtern)
   LV.mergeVisibility(HiddenVisibility, true);
 
+// OpenMP target declare device functions are not callable from the host so
+// they should not be exported from the device image. This applies to all
+// functions as the host-callable kernel functions are emitted at codegen.
+if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice &&
+((Context.getTargetInfo().getTriple().isAMDGPU() ||
+  Context.getTargetInfo().getTriple().isNVPTX()) ||
+ OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Function)))
+  LV.mergeVisibility(HiddenVisibility, /*newExplicit=*/false);
+
 // Note that Sema::MergeCompatibleFunctionDecls already takes care o

[PATCH] D136013: [clang][Interp] Fix ignoring expression return values

2022-10-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/AST/Interp/records.cpp:208
+
+struct S {
+  int a = 0;

Hmmm, this feels related to the discarded value results changes, but it might 
be a test case for a different scenario as well, so take this or leave it:
```
struct S {
  int &Ref;
  constexpr S(int &R) : Ref(R) { Ref = 0; }
  constexpr ~S() { Ref = 12; }
};

constexpr S get_s(int &i) { return S{i}; }

constexpr int func() {
  int i = 1;
  {
get_s(i);
  }
  return i;
}

static_assert(func() == 12);
```
The idea behind the test is -- we construct the `S` object but discard its 
results in the compound block, but the dtor still runs as expected.


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

https://reviews.llvm.org/D136013

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


[PATCH] D133248: [clang] Fix crash upon stray coloncolon token in C2x mode

2022-10-18 Thread Hu Jialun via Phabricator via cfe-commits
SuibianP added a comment.

@aaron.ballman Thanks for the guidance! I have rectified the parentheses and 
appended to the release notes. Please feel free to point out any additional 
issues with the Differential.

If all is good, I would like to have the patch attributed to `Jialun Hu 
`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133248

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


[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

2022-10-18 Thread Liming Liu via Phabricator via cfe-commits
lime added a comment.

> which isn't clear to me what you mean

- In the function `Sema::CheckTemplateArgument` at line 5725, `Params` has been 
substituted in a way all `TemplateTypeParmDecl`s are instantiated with a 
smaller depth, and so are constraints of them at 
SemaTemplateInstantiateDecl.cpp:2769, while the requires clause remains the 
same.
- Then `CheckTemplateArgument` calls `CheckTemplateTemplateArgument` which 
calls `IsAtLeastAsConstrained` with the original declaration and the 
constraints collected from `Params`. Thus, in `IsAtLeastAsConstrained`, a depth 
calculated from the declaration will not reflect the depth in the constraint.
- It should be fine to not adjust the depths between two constraints passed to 
`IsAtLeastAsConstrained` if the requires clause is not parsed, as they are 
already the same. But it is not the case when the constraint is from a requires 
clause, as requires clauses are not substituted. However, calculating from 
declarations will break the original case.

> I wouldn't expect the requires clause (nor any other concept related AST 
> node) to be instantiated at all until it is going through 'checking'

The function `TemplateDeclInstantiator::SubstTemplateParams` instantiates 
constraints like `template  class>`, so it is already happened.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134128

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


[PATCH] D135110: [NFC] [HLSL] Move common metadata to LLVMFrontend

2022-10-18 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I think I have a fix for this and I'll get it up today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135110

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


[clang] 95bbe9a - [clang][ARM] follow GCC behavior for defining __SOFTFP__

2022-10-18 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2022-10-18T14:38:03+01:00
New Revision: 95bbe9a1930886cffc79f1f5b953f5aafff1557f

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

LOG: [clang][ARM] follow GCC behavior for defining __SOFTFP__

GCC behavior regarding defining __SOFTFP__ when (implicitly) specifying
-mfloat-abi=softfp:
- compile without (implicit) FP: define __SOFTFP__
- compile with (implicit) FP: don't define __SOFTFP__

Currently Clang doesn't define __SOFTFP__ when softfp is specified, either with
or without FP. This patch brings Clang in line with GCC behavior.

This was raised by itaig1 over on Github:
https://github.com/llvm/llvm-project/issues/55755

Reviewed By: pratlucas

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

Added: 


Modified: 
clang/lib/Basic/Targets/ARM.cpp
clang/test/Preprocessor/init-arm.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 948f0bae4f0f8..c750a3cf126c6 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -801,7 +801,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if ((!SoftFloat && !SoftFloatABI) || ABI == "aapcs-vfp" || ABI == "aapcs16")
 Builder.defineMacro("__ARM_PCS_VFP", "1");
 
-  if (SoftFloat)
+  if (SoftFloat || (SoftFloatABI && !FPU))
 Builder.defineMacro("__SOFTFP__");
 
   // ACLE position independent code macros.

diff  --git a/clang/test/Preprocessor/init-arm.c 
b/clang/test/Preprocessor/init-arm.c
index 58ee6981bfb47..e317ffa67393d 100644
--- a/clang/test/Preprocessor/init-arm.c
+++ b/clang/test/Preprocessor/init-arm.c
@@ -395,199 +395,593 @@
 // ARM-BE:#define __arm 1
 // ARM-BE:#define __arm__ 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi 
-target-feature +soft-float -target-feature +soft-float-abi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARMEABISOFTFP %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi 
-target-feature +soft-float -target-feature +soft-float-abi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARMEABISOFT %s
 //
-// ARMEABISOFTFP-NOT:#define _LP64
-// ARMEABISOFTFP:#define __APCS_32__ 1
-// ARMEABISOFTFP-NOT:#define __ARMEB__ 1
-// ARMEABISOFTFP:#define __ARMEL__ 1
-// ARMEABISOFTFP:#define __ARM_ARCH 4
-// ARMEABISOFTFP:#define __ARM_ARCH_4T__ 1
-// ARMEABISOFTFP-NOT:#define __ARM_BIG_ENDIAN 1
-// ARMEABISOFTFP:#define __ARM_EABI__ 1
-// ARMEABISOFTFP:#define __ARM_PCS 1
-// ARMEABISOFTFP-NOT:#define __ARM_PCS_VFP 1
-// ARMEABISOFTFP:#define __BIGGEST_ALIGNMENT__ 8
-// ARMEABISOFTFP:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
-// ARMEABISOFTFP:#define __CHAR16_TYPE__ unsigned short
-// ARMEABISOFTFP:#define __CHAR32_TYPE__ unsigned int
-// ARMEABISOFTFP:#define __CHAR_BIT__ 8
-// ARMEABISOFTFP:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// ARMEABISOFTFP:#define __DBL_DIG__ 15
-// ARMEABISOFTFP:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// ARMEABISOFTFP:#define __DBL_HAS_DENORM__ 1
-// ARMEABISOFTFP:#define __DBL_HAS_INFINITY__ 1
-// ARMEABISOFTFP:#define __DBL_HAS_QUIET_NAN__ 1
-// ARMEABISOFTFP:#define __DBL_MANT_DIG__ 53
-// ARMEABISOFTFP:#define __DBL_MAX_10_EXP__ 308
-// ARMEABISOFTFP:#define __DBL_MAX_EXP__ 1024
-// ARMEABISOFTFP:#define __DBL_MAX__ 1.7976931348623157e+308
-// ARMEABISOFTFP:#define __DBL_MIN_10_EXP__ (-307)
-// ARMEABISOFTFP:#define __DBL_MIN_EXP__ (-1021)
-// ARMEABISOFTFP:#define __DBL_MIN__ 2.2250738585072014e-308
-// ARMEABISOFTFP:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
-// ARMEABISOFTFP:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// ARMEABISOFTFP:#define __FLT_DIG__ 6
-// ARMEABISOFTFP:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARMEABISOFTFP:#define __FLT_HAS_DENORM__ 1
-// ARMEABISOFTFP:#define __FLT_HAS_INFINITY__ 1
-// ARMEABISOFTFP:#define __FLT_HAS_QUIET_NAN__ 1
-// ARMEABISOFTFP:#define __FLT_MANT_DIG__ 24
-// ARMEABISOFTFP:#define __FLT_MAX_10_EXP__ 38
-// ARMEABISOFTFP:#define __FLT_MAX_EXP__ 128
-// ARMEABISOFTFP:#define __FLT_MAX__ 3.40282347e+38F
-// ARMEABISOFTFP:#define __FLT_MIN_10_EXP__ (-37)
-// ARMEABISOFTFP:#define __FLT_MIN_EXP__ (-125)
-// ARMEABISOFTFP:#define __FLT_MIN__ 1.17549435e-38F
-// ARMEABISOFTFP:#define __FLT_RADIX__ 2
-// ARMEABISOFTFP:#define __INT16_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT16_FMTd__ "hd"
-// ARMEABISOFTFP:#define __INT16_FMTi__ "hi"
-// ARMEABISOFTFP:#define __INT16_MAX__ 32767
-// ARMEABISOFTFP:#define __INT16_TYPE__ short
-// ARMEABISOFTFP:#define __INT32_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT32_FMTd__ "d"
-// ARMEABISOFTFP:#define __INT32_FMTi__ "i"
-// ARMEABISOFTFP:#define __INT32_MAX__ 2147483647
-// ARMEABISOFTFP:#define __INT32_TYPE__ int
-// ARMEABISOFTFP:#define __INT64_C_SUFFIX__ LL
-// ARMEABISO

[PATCH] D135680: [clang][ARM] follow GCC behavior for defining __SOFTFP__

2022-10-18 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
stuij marked an inline comment as done.
Closed by commit rG95bbe9a19308: [clang][ARM] follow GCC behavior for defining 
__SOFTFP__ (authored by stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135680

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/init-arm.c

Index: clang/test/Preprocessor/init-arm.c
===
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -395,199 +395,593 @@
 // ARM-BE:#define __arm 1
 // ARM-BE:#define __arm__ 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABISOFTFP %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABISOFT %s
 //
-// ARMEABISOFTFP-NOT:#define _LP64
-// ARMEABISOFTFP:#define __APCS_32__ 1
-// ARMEABISOFTFP-NOT:#define __ARMEB__ 1
-// ARMEABISOFTFP:#define __ARMEL__ 1
-// ARMEABISOFTFP:#define __ARM_ARCH 4
-// ARMEABISOFTFP:#define __ARM_ARCH_4T__ 1
-// ARMEABISOFTFP-NOT:#define __ARM_BIG_ENDIAN 1
-// ARMEABISOFTFP:#define __ARM_EABI__ 1
-// ARMEABISOFTFP:#define __ARM_PCS 1
-// ARMEABISOFTFP-NOT:#define __ARM_PCS_VFP 1
-// ARMEABISOFTFP:#define __BIGGEST_ALIGNMENT__ 8
-// ARMEABISOFTFP:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
-// ARMEABISOFTFP:#define __CHAR16_TYPE__ unsigned short
-// ARMEABISOFTFP:#define __CHAR32_TYPE__ unsigned int
-// ARMEABISOFTFP:#define __CHAR_BIT__ 8
-// ARMEABISOFTFP:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// ARMEABISOFTFP:#define __DBL_DIG__ 15
-// ARMEABISOFTFP:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// ARMEABISOFTFP:#define __DBL_HAS_DENORM__ 1
-// ARMEABISOFTFP:#define __DBL_HAS_INFINITY__ 1
-// ARMEABISOFTFP:#define __DBL_HAS_QUIET_NAN__ 1
-// ARMEABISOFTFP:#define __DBL_MANT_DIG__ 53
-// ARMEABISOFTFP:#define __DBL_MAX_10_EXP__ 308
-// ARMEABISOFTFP:#define __DBL_MAX_EXP__ 1024
-// ARMEABISOFTFP:#define __DBL_MAX__ 1.7976931348623157e+308
-// ARMEABISOFTFP:#define __DBL_MIN_10_EXP__ (-307)
-// ARMEABISOFTFP:#define __DBL_MIN_EXP__ (-1021)
-// ARMEABISOFTFP:#define __DBL_MIN__ 2.2250738585072014e-308
-// ARMEABISOFTFP:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
-// ARMEABISOFTFP:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// ARMEABISOFTFP:#define __FLT_DIG__ 6
-// ARMEABISOFTFP:#define __FLT_EPSILON__ 1.19209290e-7F
-// ARMEABISOFTFP:#define __FLT_HAS_DENORM__ 1
-// ARMEABISOFTFP:#define __FLT_HAS_INFINITY__ 1
-// ARMEABISOFTFP:#define __FLT_HAS_QUIET_NAN__ 1
-// ARMEABISOFTFP:#define __FLT_MANT_DIG__ 24
-// ARMEABISOFTFP:#define __FLT_MAX_10_EXP__ 38
-// ARMEABISOFTFP:#define __FLT_MAX_EXP__ 128
-// ARMEABISOFTFP:#define __FLT_MAX__ 3.40282347e+38F
-// ARMEABISOFTFP:#define __FLT_MIN_10_EXP__ (-37)
-// ARMEABISOFTFP:#define __FLT_MIN_EXP__ (-125)
-// ARMEABISOFTFP:#define __FLT_MIN__ 1.17549435e-38F
-// ARMEABISOFTFP:#define __FLT_RADIX__ 2
-// ARMEABISOFTFP:#define __INT16_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT16_FMTd__ "hd"
-// ARMEABISOFTFP:#define __INT16_FMTi__ "hi"
-// ARMEABISOFTFP:#define __INT16_MAX__ 32767
-// ARMEABISOFTFP:#define __INT16_TYPE__ short
-// ARMEABISOFTFP:#define __INT32_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT32_FMTd__ "d"
-// ARMEABISOFTFP:#define __INT32_FMTi__ "i"
-// ARMEABISOFTFP:#define __INT32_MAX__ 2147483647
-// ARMEABISOFTFP:#define __INT32_TYPE__ int
-// ARMEABISOFTFP:#define __INT64_C_SUFFIX__ LL
-// ARMEABISOFTFP:#define __INT64_FMTd__ "lld"
-// ARMEABISOFTFP:#define __INT64_FMTi__ "lli"
-// ARMEABISOFTFP:#define __INT64_MAX__ 9223372036854775807LL
-// ARMEABISOFTFP:#define __INT64_TYPE__ long long int
-// ARMEABISOFTFP:#define __INT8_C_SUFFIX__
-// ARMEABISOFTFP:#define __INT8_FMTd__ "hhd"
-// ARMEABISOFTFP:#define __INT8_FMTi__ "hhi"
-// ARMEABISOFTFP:#define __INT8_MAX__ 127
-// ARMEABISOFTFP:#define __INT8_TYPE__ signed char
-// ARMEABISOFTFP:#define __INTMAX_C_SUFFIX__ LL
-// ARMEABISOFTFP:#define __INTMAX_FMTd__ "lld"
-// ARMEABISOFTFP:#define __INTMAX_FMTi__ "lli"
-// ARMEABISOFTFP:#define __INTMAX_MAX__ 9223372036854775807LL
-// ARMEABISOFTFP:#define __INTMAX_TYPE__ long long int
-// ARMEABISOFTFP:#define __INTMAX_WIDTH__ 64
-// ARMEABISOFTFP:#define __INTPTR_FMTd__ "d"
-// ARMEABISOFTFP:#define __INTPTR_FMTi__ "i"
-// ARMEABISOFTFP:#define __INTPTR_MAX__ 2147483647
-// ARMEABISOFTFP:#define __INTPTR_TYPE__ int
-// ARMEABISOFTFP:#define __INTPTR_WIDTH__ 32
-// ARMEABISOFTFP:#define __INT_FAST16_FMTd__ "hd"
-// ARMEABISOFTFP:#define __INT_FAST16_FMTi__ "hi"
-// ARMEABISOFTFP:#define __INT_FAST16_MAX__ 32767
-// ARMEABISOFTFP:#define __INT_FAST16_TYPE__ short
-// ARMEABISOFTFP:#define __INT_FAST32_F

[PATCH] D136162: [analyzer] Fix assertion failure in RegionStore within bindArray()

2022-10-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Hmm, seems like the conflicting prototype (i.e. the obsolescent use of zero 
parameters) is needed to reproduce the assertion failure. That makes me wonder, 
how does the redecl chain of `b` looks like? Is `void b()` chained with `void 
b(int*)`, or are they represented independently from each other? I guess they 
form the same redecl chain. Which drives us to the next questions.
When the analyzer reaches the CallExpr `b(&buffer)` which FunctionDecl does it 
see? Is it `b()` or `b(int*)`? My bet, it sees and works with `b()`. Could we 
detect if the arguments of the CallExpr does not match the parameters of the 
FunctionDecl? And if that is the case, could we iterate through the redecl 
chain to find an appropriate matching FunctionDecl? That would be `b(int*)` in 
this case ... and the original `bindArray()` should work then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136162

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


[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

2022-10-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D134128#3865063 , @lime wrote:

>> which isn't clear to me what you mean
>
> - In the function `Sema::CheckTemplateArgument` at line 5725, `Params` has 
> been substituted in a way all `TemplateTypeParmDecl`s are instantiated with a 
> smaller depth, and so are constraints of them at 
> SemaTemplateInstantiateDecl.cpp:2769, while the requires clause remains the 
> same.
> - Then `CheckTemplateArgument` calls `CheckTemplateTemplateArgument` which 
> calls `IsAtLeastAsConstrained` with the original declaration and the 
> constraints collected from `Params`. Thus, in `IsAtLeastAsConstrained`, a 
> depth calculated from the declaration will not reflect the depth in the 
> constraint.
> - It should be fine to not adjust the depths between two constraints passed 
> to `IsAtLeastAsConstrained` if the requires clause is not parsed, as they are 
> already the same. But it is not the case when the constraint is from a 
> requires clause, as requires clauses are not substituted. However, 
> calculating from declarations will break the original case.

It sounds like perhaps we've instantiated constraints we shouldn't have in the 
case of template-template parameters.  Based on what you're saying, I'm 
concerned then that perhaps the deferred concept instantiation didn't work 
right for template-template constraints? That might require more work on that 
then before anything could happen here.

Otherwise, I would expect calculating from the Template Template Decl to work, 
(though its likely it doesn't actually 'add' a layer yet, since I don't think 
we've needed that yet, so an extra bit of work there would need to be done).

>> I wouldn't expect the requires clause (nor any other concept related AST 
>> node) to be instantiated at all until it is going through 'checking'
>
> The function `TemplateDeclInstantiator::SubstTemplateParams` instantiates 
> constraints like `template  class>`, so it is already happened.

If that is happening outside of a constraint evaluation, that is likely 
incorrect, and perhaps part of the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134128

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


[PATCH] D136162: [analyzer] Fix assertion failure in RegionStore within bindArray()

2022-10-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> A similar situation could happen if we reinterpret cast pointers, etc. so the 
> situation is not limited to conflicting function prototypes.

Please provide tests for those cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136162

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


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-10-18 Thread Yusuke Kadowaki via Phabricator via cfe-commits
yusuke-kadowaki added a comment.

In D132131#3865004 , @rymiel wrote:

> Please provide a name and an email so someone could commit it on your behalf

name: Yusuke Kadowaki
email: yusuke.kadowaki.1...@gmail.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[PATCH] D135908: [clang][LTO] Setting Desired Default AIX Debugging Options

2022-10-18 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 468525.
qiongsiwu1 added a comment.

Address a review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135908

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto-aix.c


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 
-gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 
2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX:"-bplugin_opt:-debugger-tune=dbx"
+// GDB:"-bplugin_opt:-debugger-tune=gdb"
+// NODEBUGGER-TUNE-NOT: "-bplugin_opt:-debugger-tune="
+//
+// STRICT:   "-bplugin_opt:-strict-dwarf=true"
+// NOSTRICT-NOT: "-bplugin_opt:-strict-dwarf=true"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -589,6 +589,18 @@
   Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
   }
 
+  if (IsOSAIX) {
+// On AIX, clang assumes strict-dwarf is true if any debug option is
+// specified, unless it is told explicitly not to assume so.
+Arg *A = Args.getLastArg(options::OPT_g_Group);
+bool EnableDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+   !A->getOption().matches(options::OPT_ggdb0);
+if (EnableDebugInfo && Args.hasFlag(options::OPT_gstrict_dwarf,
+options::OPT_gno_strict_dwarf, true))
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine(PluginOptPrefix) + "-strict-dwarf=true"));
+  }
+
   bool UseSeparateSections =
   isUseSeparateSections(ToolChain.getEffectiveTriple());
 


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX:"-bplugin_opt:-debugger-tune=dbx"
+// GDB:"-bplugin_opt:-debugger-tune=gdb"
+// NODEBUGGER-TUNE-NOT: "-bplugin_opt:-debugger-tune="
+//
+// STRICT:   "-bplugin_opt:-strict-dwarf=true"
+// NOS

[PATCH] D135885: [clang][LTO][NFC] Adding More Tests for AIX Options

2022-10-18 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

@w2yehia @daltenty may I ask for a review? Thanks so much!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135885

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


[clang] 94e8bd0 - [clang] Fix crash upon stray coloncolon token in C2x mode

2022-10-18 Thread YingChi Long via cfe-commits

Author: Jialun Hu
Date: 2022-10-18T21:57:32+08:00
New Revision: 94e8bd002c81ace308ddac9b66385ef932655fd3

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

LOG: [clang] Fix crash upon stray coloncolon token in C2x mode

The parser assumes that the lexer never emits coloncolon token for C code, but 
this assumption no longer holds in C2x attribute namespaces. As a result, stray 
coloncolon tokens out of attributes cause assertion failures and hangs in 
release build, which this patch tries to handle.

Crash input minimal example: `T n::v`

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/Parser.cpp
clang/test/Parser/c2x-attributes.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6eaec2a5f3e9f..9fe63dd5de840 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -251,6 +251,7 @@ Bug Fixes
 - Address the thread identification problems in coroutines.
   `Issue 47177 `_
   `Issue 47179 `_
+- Fix a crash upon stray coloncolon token in C2x mode.
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index c518ce5487bd8..d70f36daa891f 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -866,10 +866,11 @@ class Parser : public CodeCompletionHandler {
   bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
 
   bool MightBeCXXScopeToken() {
-return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
-   (Tok.is(tok::annot_template_id) &&
-NextToken().is(tok::coloncolon)) ||
-   Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
+return getLangOpts().CPlusPlus &&
+   (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
+(Tok.is(tok::annot_template_id) &&
+ NextToken().is(tok::coloncolon)) ||
+Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
   }
   bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext = false) {
 return MightBeCXXScopeToken() && TryAnnotateCXXScopeToken(EnteringContext);

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ddb83a8c6694d..e15a6ffa8d689 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5411,6 +5411,8 @@ bool Parser::isDeclarationSpecifier(
 return isDeclarationSpecifier(AllowImplicitTypename);
 
   case tok::coloncolon:   // ::foo::bar
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// ::new
 NextToken().is(tok::kw_delete))   // ::delete
   return false;

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 79528d25be21f..8fcd02146ba5c 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -2080,9 +2080,9 @@ bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope 
either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 

diff  --git a/clang/test/Parser/c2x-attributes.c 
b/clang/test/Parser/c2x-attributes.c
index f8ed1eda14886..e3201e2315d2f 100644
--- a/clang/test/Parser/c2x-attributes.c
+++ b/clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@ void test_asm(void) {
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot 
appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as 
scope
+double n::v; // expected-error {{expected ';' after top level declarator}}



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


[PATCH] D133248: [clang] Fix crash upon stray coloncolon token in C2x mode

2022-10-18 Thread YingChi Long 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 rG94e8bd002c81: [clang] Fix crash upon stray coloncolon token 
in C2x mode (authored by Jialun Hu , committed by 
inclyc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133248

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/c2x-attributes.c


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot 
appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as 
scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2080,9 +2080,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope 
either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5411,6 +5411,8 @@
 return isDeclarationSpecifier(AllowImplicitTypename);
 
   case tok::coloncolon:   // ::foo::bar
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// ::new
 NextToken().is(tok::kw_delete))   // ::delete
   return false;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -866,10 +866,11 @@
   bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
 
   bool MightBeCXXScopeToken() {
-return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
-   (Tok.is(tok::annot_template_id) &&
-NextToken().is(tok::coloncolon)) ||
-   Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
+return getLangOpts().CPlusPlus &&
+   (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
+(Tok.is(tok::annot_template_id) &&
+ NextToken().is(tok::coloncolon)) ||
+Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
   }
   bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext = false) {
 return MightBeCXXScopeToken() && TryAnnotateCXXScopeToken(EnteringContext);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -251,6 +251,7 @@
 - Address the thread identification problems in coroutines.
   `Issue 47177 `_
   `Issue 47179 `_
+- Fix a crash upon stray coloncolon token in C2x mode.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2080,9 +2080,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false

[PATCH] D133248: [clang] Fix crash upon stray coloncolon token in C2x mode

2022-10-18 Thread YingChi Long via Phabricator via cfe-commits
inclyc added a comment.

In D133248#3865010 , @SuibianP wrote:

> @aaron.ballman Thanks for the guidance! I have rectified the parentheses and 
> appended to the release notes. Please feel free to point out any additional 
> issues with the Differential.
>
> If all is good, I would like to have the patch attributed to `Jialun Hu 
> `.

Thanks @SuibianP ! I've committed this for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133248

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


[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

2022-10-18 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D136100#3863427 , @MyDeveloperDay 
wrote:

> Pretty interesting, it looks ok from what I can tell, let the others take a 
> look

Thanks, I was originally hoping I could avoid adding a new boolean for 
`InPragma` by asking something like `Line.startswith(tok::pp_pragma)` but that 
didn't seem to work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[clang] 04615b6 - [clang][LTO] Setting Desired Default AIX Debugging Options

2022-10-18 Thread Qiongsi Wu via cfe-commits

Author: Qiongsi Wu
Date: 2022-10-18T10:43:19-04:00
New Revision: 04615b695aadf5f3860e3be9631131518227f410

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

LOG: [clang][LTO] Setting Desired Default AIX Debugging Options

On AIX, `strict-dwarf` defaults to `true`.  This patch implement this default 
behaviour. Additionally, it adds debug tuning tests.

Reviewed By: shchenz

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/lto-aix.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index ca8fc7b93972f..58e452418fa26 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -589,6 +589,18 @@ void tools::addLTOOptions(const ToolChain &ToolChain, 
const ArgList &Args,
   Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
   }
 
+  if (IsOSAIX) {
+// On AIX, clang assumes strict-dwarf is true if any debug option is
+// specified, unless it is told explicitly not to assume so.
+Arg *A = Args.getLastArg(options::OPT_g_Group);
+bool EnableDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+   !A->getOption().matches(options::OPT_ggdb0);
+if (EnableDebugInfo && Args.hasFlag(options::OPT_gstrict_dwarf,
+options::OPT_gno_strict_dwarf, true))
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine(PluginOptPrefix) + "-strict-dwarf=true"));
+  }
+
   bool UseSeparateSections =
   isUseSeparateSections(ToolChain.getEffectiveTriple());
 

diff  --git a/clang/test/Driver/lto-aix.c b/clang/test/Driver/lto-aix.c
index 89b5d5aeb8ef5..1689c2638410f 100644
--- a/clang/test/Driver/lto-aix.c
+++ b/clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 
-gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 
2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX:"-bplugin_opt:-debugger-tune=dbx"
+// GDB:"-bplugin_opt:-debugger-tune=gdb"
+// NODEBUGGER-TUNE-NOT: "-bplugin_opt:-debugger-tune="
+//
+// STRICT:   "-bplugin_opt:-strict-dwarf=true"
+// NOSTRICT-NOT: "-bplugin_opt:-strict-dwarf=true"



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


[PATCH] D135908: [clang][LTO] Setting Desired Default AIX Debugging Options

2022-10-18 Thread 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 rG04615b695aad: [clang][LTO] Setting Desired Default AIX 
Debugging Options (authored by Qiongsi Wu ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135908

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto-aix.c


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 
-gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 
2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX:"-bplugin_opt:-debugger-tune=dbx"
+// GDB:"-bplugin_opt:-debugger-tune=gdb"
+// NODEBUGGER-TUNE-NOT: "-bplugin_opt:-debugger-tune="
+//
+// STRICT:   "-bplugin_opt:-strict-dwarf=true"
+// NOSTRICT-NOT: "-bplugin_opt:-strict-dwarf=true"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -589,6 +589,18 @@
   Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
   }
 
+  if (IsOSAIX) {
+// On AIX, clang assumes strict-dwarf is true if any debug option is
+// specified, unless it is told explicitly not to assume so.
+Arg *A = Args.getLastArg(options::OPT_g_Group);
+bool EnableDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+   !A->getOption().matches(options::OPT_ggdb0);
+if (EnableDebugInfo && Args.hasFlag(options::OPT_gstrict_dwarf,
+options::OPT_gno_strict_dwarf, true))
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine(PluginOptPrefix) + "-strict-dwarf=true"));
+  }
+
   bool UseSeparateSections =
   isUseSeparateSections(ToolChain.getEffectiveTriple());
 


Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN:   | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -g -gno-strict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang --target=powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX:"-bplugin_opt:-debugger-tune=dbx"

[PATCH] D136071: [include-cleaner] WIP: Add PragmaIncludes which handles include-mapping pragmas.

2022-10-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:38
+// spelling header rather than the header directly defines the symbol.
+class PragmaIncludes {
+public:

sammccall wrote:
> IWYU pragmas requires a PP listener, we'll also need PP events for other 
> purposes (determining which files are self-contained, finding #includes in 
> the main file). Should these be the same listener and write into the same 
> class?
> 
> The argument for fewer components is usability: the embedder (standalone 
> tool, clangd, clang-tidy) is responsible for connecting these hooks to the 
> compiler and feeding the results back into the analysis.
> 
> So the library is somewhat simpler to use if the number of parts is small.
> We need (I think) at least one for the AST and one for the preprocessor, 
> because they need to be connected at different parts of the lifecycle.
> 
> How much do we gain by splitting up further than that?
After discussing offline: I think we expect this to be reused in clangd so 
separating it from the bits that won't is useful.
I don't think the scope is exactly clear though: which of these should we 
bundle together?

 - IWYU pragmas related to headers (private, export)
 - IWYU pragmas related to the main file (keep/no_include)
 - other equivalent things like `#pragma include_instead`
 - tracking whether headers are self-contained
 - recording `#include` graph (not sure IWYU even needs this)
 - tracking macro occurrences in the main file
 - details of `#include` directives from the main file

I'm tempted to say 1/2/3/4 are in-scope (since they're all gathered from 
roughly the same source and needed for the same thing) and so `PragmaIncludes` 
seems a little too narrow. Suggest `HeaderQuirks` maybe?



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Hooks.h:53
+  // Main file headers that should be kept, decorated by "IWYU pragma: keep".
+  llvm::DenseSet ShouldKeep; // FIXME: implement
+

sammccall wrote:
> Why are these UniqueID rather than FileEntry*? Is the idea to try to use this 
> in clangd?
> 
> We hadn't planned on doing this, because pushing clangd's weird requirements 
> around not using FileEntry's to the library, ability to clone the data 
> structure etc seemed pretty intrusive. Since we switched from name-based to 
> UniqueID it might be doable...
After discussing offline, using UniqueID to ensure the results are usable 
across FileManagers seems reasonable, but I think it needs to be documented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136071

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


[PATCH] D135269: [AMDGPU] Disable bool range metadata to workaround backend issue

2022-10-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D135269#3863470 , @nikic wrote:

> Checking back here, have you made any progress on reducing the issue?
>
> cc @arsenm for awareness

No. I am busy with other work and have not got time to get back on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135269

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


[PATCH] D135110: [NFC] [HLSL] Move common metadata to LLVMFrontend

2022-10-18 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

The llvm-config test issue should be resolved in rGa4b010034f57 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135110

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


[PATCH] D129755: Thread safety analysis: Support copy-elided production of scoped capabilities through arbitrary calls

2022-10-18 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

I'm seeing a fair number of breakages from this patch (not really sure how many 
we truly have, I've hit ~5-10 so far in widely used libraries, but I suspect we 
have far more in the long tail). They're all valid (most are just adding 
missing thread safety annotations, etc., so far one breakage caught a real 
bug), but it would help if we could disable just these new ones. How 
invasive/annoying would it be to carve out a subwarning for this category of 
bugs and call it something like `-Wthread-safety-elision`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129755

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


[PATCH] D136124: [clang][deps] Remove unintentional `move`

2022-10-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp:400
+auto OverlayFS =
+llvm::makeIntrusiveRefCnt(BaseFS);
 auto InMemoryFS =

DavidSpickett wrote:
> Is this equivalent?
> ```
> auto OverlayFS = BaseFS;
> ```
> Given that BaseFS is already `IntrusiveRefCntPtr`.
It's not, because `BaseFS` is pointer to the `llvm::vfs::FileSystem` interface. 
Here we need to call members of `llvm::vfs::OverlayFileSystem` specifically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136124

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


[PATCH] D136124: [clang][deps] Remove unintentional `move`

2022-10-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 468555.
jansvoboda11 added a comment.

Use both `-j 1` and `-j 4` in tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136124

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/modules-full-by-mod-name.cpp


Index: clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
===
--- clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
+++ clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
@@ -11,7 +11,7 @@
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_by_mod_name.json > 
%t.cdb
 // RUN: sed -e "s|DIR|%/t.dir|g" 
%S/Inputs/modules_cdb_clangcl_by_mod_name.json > %t_clangcl.cdb
 //
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format 
experimental-full \
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format 
experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > 
%t.result
 // RUN: cat %t.result | sed 's:\?:/:g' | FileCheck -DPREFIX=%/t.dir 
--check-prefixes=CHECK %s
 //
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -396,8 +396,8 @@
 ModifiedCommandLine = CommandLine;
 ModifiedCommandLine->emplace_back(*ModuleName);
 
-auto OverlayFS = llvm::makeIntrusiveRefCnt(
-std::move(BaseFS));
+auto OverlayFS =
+llvm::makeIntrusiveRefCnt(BaseFS);
 auto InMemoryFS =
 llvm::makeIntrusiveRefCnt();
 InMemoryFS->setCurrentWorkingDirectory(WorkingDirectory);


Index: clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
===
--- clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
+++ clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
@@ -11,7 +11,7 @@
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_by_mod_name.json > %t.cdb
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_clangcl_by_mod_name.json > %t_clangcl.cdb
 //
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format experimental-full \
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > %t.result
 // RUN: cat %t.result | sed 's:\?:/:g' | FileCheck -DPREFIX=%/t.dir --check-prefixes=CHECK %s
 //
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -396,8 +396,8 @@
 ModifiedCommandLine = CommandLine;
 ModifiedCommandLine->emplace_back(*ModuleName);
 
-auto OverlayFS = llvm::makeIntrusiveRefCnt(
-std::move(BaseFS));
+auto OverlayFS =
+llvm::makeIntrusiveRefCnt(BaseFS);
 auto InMemoryFS =
 llvm::makeIntrusiveRefCnt();
 InMemoryFS->setCurrentWorkingDirectory(WorkingDirectory);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136124: [clang][deps] Remove unintentional `move`

2022-10-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/ClangScanDeps/modules-full-by-mod-name.cpp:18
 //
-// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 4 -format 
experimental-full \
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -format 
experimental-full \
 // RUN:   -mode preprocess-dependency-directives -module-name=header1 > 
%t_clangcl.result

DavidSpickett wrote:
> Would it help to have one be j1 and one j4, any extra coverage by doing that?
Technically that does give us extra coverage. Let's do it if you feel more 
comfortable that way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136124

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


[PATCH] D135657: add time traces for AST serialization

2022-10-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

This looks good to me in principle. It would be nice to have a simple test that 
shows what kind of output we get. Can you add that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135657

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


[PATCH] D135247: [clang][analyzer] Add stream functions to StdLibraryFunctionsChecker.

2022-10-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Probably if the `StdLibraryFunctionsChecker` object can be get from 
`StreamChecker` (a new function is needed) it is possible to check the option 
and use `CheckerManager::reportInvalidCheckerOptionValue` (for the 
`StdLibraryFunctionsChecker`). But not sure if it does what we want here.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1060-1064
+} else if (NewState == State) {
+  if (const auto *D = dyn_cast_or_null(Call.getDecl()))
+if (const NoteTag *NT =
+Case.getErrnoConstraint().describe(C, D->getNameAsString()))
+  C.addTransition(NewState, NT);

martong wrote:
> Why do we need this change?
It is possible that only the errno related state is changed, no new constraints 
are added (if the constraint is already here from `evalCall` but the errno was 
not set there, for example at `fclose` or other stream functions maybe no new 
state is created here). In such case the note tag is still needed.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:604-613
+  // Return 0 on success, EOF on failure.
+  SValBuilder &SVB = C.getSValBuilder();
+  ProgramStateRef StateSuccess = State->BindExpr(
+  CE, C.getLocationContext(), SVB.makeIntVal(0, C.getASTContext().IntTy));
+  ProgramStateRef StateFailure =
+  State->BindExpr(CE, C.getLocationContext(),
+  SVB.makeIntVal(*EofVal, C.getASTContext().IntTy));

martong wrote:
> This is redundant with the summary in the `StdLibraryFunctionsChecker`. Why 
> do we need this as well?
It is probably needed to have a (any) bound value to the `fclose` function 
call, otherwise setting constraints in the other checker do not work. It may 
work to bind only a conjured value but it looks better if the correct return 
value is used. This makes less inter-dependence between the two checkers 
(`StdLibraryFunctionChecker` sets only the errno state as far as possible).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135247

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


[clang] 10c0eca - [clang][Lexer] Speed up HeaderSearch when there are many HeaderMaps

2022-10-18 Thread Troy Johnson via cfe-commits

Author: Troy Johnson
Date: 2022-10-18T08:21:14-07:00
New Revision: 10c0eca25523e3bf1872522bde4693aaa55513e0

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

LOG: [clang][Lexer] Speed up HeaderSearch when there are many HeaderMaps

HeaderSearch already uses a caching system to avoid duplicate searches,
but the initial cold miss can take a long time if a build system has
supplied thousands of HeaderMaps. For this case, the SearchDirs vector
begins with those HeaderMaps, so a cache miss requires testing if the
sought filename is present in each of those maps. Instead, we can
consolidate the keys of those HeaderMaps into one StringMap and then
each cache miss can skip directly to the correct HeaderMap or continue
its search beyond the initial sequence of HeaderMaps. In testing on TUs
with ~15000 SearchDirs where the initial 99% are HeaderMaps, time spent
in Clang was reduced by 15%. This patch is expected to be neutral for
SearchDir vectors that do not begin with HeaderMaps.

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

Added: 


Modified: 
clang/include/clang/Lex/HeaderMap.h
clang/include/clang/Lex/HeaderSearch.h
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/HeaderMap.h 
b/clang/include/clang/Lex/HeaderMap.h
index ca6a49bae3bfe..7930cb83598ca 100644
--- a/clang/include/clang/Lex/HeaderMap.h
+++ b/clang/include/clang/Lex/HeaderMap.h
@@ -15,6 +15,7 @@
 
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Lex/HeaderMapTypes.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Compiler.h"
@@ -39,6 +40,21 @@ class HeaderMapImpl {
   // Check for a valid header and extract the byte swap.
   static bool checkHeader(const llvm::MemoryBuffer &File, bool &NeedsByteSwap);
 
+  // Make a call for every Key in the map.
+  template  void forEachKey(Func Callback) const {
+const HMapHeader &Hdr = getHeader();
+unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets);
+
+for (unsigned Bucket = 0; Bucket < NumBuckets; ++Bucket) {
+  HMapBucket B = getBucket(Bucket);
+  if (B.Key != HMAP_EmptyBucketKey) {
+Optional Key = getString(B.Key);
+if (Key)
+  Callback(Key.value());
+  }
+}
+  }
+
   /// If the specified relative filename is located in this HeaderMap return
   /// the filename it is mapped to, otherwise return an empty StringRef.
   StringRef lookupFilename(StringRef Filename,
@@ -78,6 +94,7 @@ class HeaderMap : private HeaderMapImpl {
FileManager &FM);
 
   using HeaderMapImpl::dump;
+  using HeaderMapImpl::forEachKey;
   using HeaderMapImpl::getFileName;
   using HeaderMapImpl::lookupFilename;
   using HeaderMapImpl::reverseLookupFilename;

diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index d4b2306096972..4684f554dc24d 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -249,6 +249,14 @@ class HeaderSearch {
   unsigned SystemDirIdx = 0;
   bool NoCurDirSearch = false;
 
+  /// Maps HeaderMap keys to SearchDir indices. When HeaderMaps are used
+  /// heavily, SearchDirs can start with thousands of HeaderMaps, so this Index
+  /// lets us avoid scanning them all to find a match.
+  llvm::StringMap SearchDirHeaderMapIndex;
+
+  /// The index of the first SearchDir that isn't a header map.
+  unsigned FirstNonHeaderMapSearchDirIdx = 0;
+
   /// \#include prefixes for which the 'system header' property is
   /// overridden.
   ///
@@ -330,6 +338,10 @@ class HeaderSearch {
   /// Entity used to look up stored header file information.
   ExternalHeaderFileInfoSource *ExternalSource = nullptr;
 
+  /// Scan all of the header maps at the beginning of SearchDirs and
+  /// map their keys to the SearchDir index of their header map.
+  void indexInitialHeaderMaps();
+
 public:
   HeaderSearch(std::shared_ptr HSOpts,
SourceManager &SourceMgr, DiagnosticsEngine &Diags,
@@ -801,6 +813,10 @@ class HeaderSearch {
   }
 
   ConstSearchDirIterator search_dir_begin() const { return quoted_dir_begin(); 
}
+  ConstSearchDirIterator search_dir_nth(size_t n) const {
+assert(n < SearchDirs.size());
+return {*this, n};
+  }
   ConstSearchDirIterator search_dir_end() const { return system_dir_end(); }
   ConstSearchDirRange search_dir_range() const {
 return {search_dir_begin(), search_dir_end()};

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index bd69d8f697de8..dd82f4280edb5 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -116,6 +116,7 @@ void HeaderSearch::SetSearchPaths(
   NoCurDirSearch = n

[PATCH] D135801: [clang][Lexer] Speedup HeaderSearch when there are many HeaderMaps

2022-10-18 Thread Troy Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10c0eca25523: [clang][Lexer] Speed up HeaderSearch when 
there are many HeaderMaps (authored by troyj).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135801

Files:
  clang/include/clang/Lex/HeaderMap.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -116,6 +116,7 @@
   NoCurDirSearch = noCurDirSearch;
   SearchDirToHSEntry = std::move(searchDirToHSEntry);
   //LookupFileCache.clear();
+  indexInitialHeaderMaps();
 }
 
 void HeaderSearch::AddSearchPath(const DirectoryLookup &dir, bool isAngled) {
@@ -372,6 +373,29 @@
   return Module;
 }
 
+void HeaderSearch::indexInitialHeaderMaps() {
+  llvm::StringMap Index(SearchDirs.size());
+
+  // Iterate over all filename keys and associate them with the index i.
+  unsigned i = 0;
+  for (; i != SearchDirs.size(); ++i) {
+auto &Dir = SearchDirs[i];
+
+// We're concerned with only the initial contiguous run of header
+// maps within SearchDirs, which can be 99% of SearchDirs when
+// SearchDirs.size() is ~1.
+if (!Dir.isHeaderMap())
+  break;
+
+// Give earlier keys precedence over identical later keys.
+auto Callback = [&](StringRef Filename) { Index.try_emplace(Filename, i); };
+Dir.getHeaderMap()->forEachKey(Callback);
+  }
+
+  SearchDirHeaderMapIndex = std::move(Index);
+  FirstNonHeaderMapSearchDirIdx = i;
+}
+
 //===--===//
 // File lookup within a DirectoryLookup scope
 //===--===//
@@ -977,24 +1001,37 @@
 
   ConstSearchDirIterator NextIt = std::next(It);
 
-  // If the entry has been previously looked up, the first value will be
-  // non-zero.  If the value is equal to i (the start point of our search), then
-  // this is a matching hit.
-  if (!SkipCache && CacheLookup.StartIt == NextIt) {
-// Skip querying potentially lots of directories for this lookup.
-if (CacheLookup.HitIt)
-  It = CacheLookup.HitIt;
-if (CacheLookup.MappedName) {
-  Filename = CacheLookup.MappedName;
-  if (IsMapped)
-*IsMapped = true;
+  if (!SkipCache) {
+if (CacheLookup.StartIt == NextIt) {
+  // HIT: Skip querying potentially lots of directories for this lookup.
+  if (CacheLookup.HitIt)
+It = CacheLookup.HitIt;
+  if (CacheLookup.MappedName) {
+Filename = CacheLookup.MappedName;
+if (IsMapped)
+  *IsMapped = true;
+  }
+} else {
+  // MISS: This is the first query, or the previous query didn't match
+  // our search start.  We will fill in our found location below, so prime
+  // the start point value.
+  CacheLookup.reset(/*NewStartIt=*/NextIt);
+
+  if (It == search_dir_begin() && FirstNonHeaderMapSearchDirIdx > 0) {
+// Handle cold misses of user includes in the presence of many header
+// maps.  We avoid searching perhaps thousands of header maps by
+// jumping directly to the correct one or jumping beyond all of them.
+auto Iter = SearchDirHeaderMapIndex.find(Filename);
+if (Iter == SearchDirHeaderMapIndex.end())
+  // Not in index => Skip to first SearchDir after initial header maps
+  It = search_dir_nth(FirstNonHeaderMapSearchDirIdx);
+else
+  // In index => Start with a specific header map
+  It = search_dir_nth(Iter->second);
+  }
 }
-  } else {
-// Otherwise, this is the first query, or the previous query didn't match
-// our search start.  We will fill in our found location below, so prime the
-// start point value.
+  } else
 CacheLookup.reset(/*NewStartIt=*/NextIt);
-  }
 
   SmallString<64> MappedName;
 
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -249,6 +249,14 @@
   unsigned SystemDirIdx = 0;
   bool NoCurDirSearch = false;
 
+  /// Maps HeaderMap keys to SearchDir indices. When HeaderMaps are used
+  /// heavily, SearchDirs can start with thousands of HeaderMaps, so this Index
+  /// lets us avoid scanning them all to find a match.
+  llvm::StringMap SearchDirHeaderMapIndex;
+
+  /// The index of the first SearchDir that isn't a header map.
+  unsigned FirstNonHeaderMapSearchDirIdx = 0;
+
   /// \#include prefixes for which the 'system header' property is
   /// overridden.
   ///
@@ -330,6 +338,10 @@
   /// Entity used to look up stored header file information.
   ExternalHeaderFileInfoSource *ExternalSource = nullptr;
 
+  /// Scan all of th

[PATCH] D136078: [RFC] Use-after-return binary metadata.

2022-10-18 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov updated this revision to Diff 468562.
dvyukov added a comment.
Herald added subscribers: llvm-commits, Enna1, hiraditya.
Herald added a project: LLVM.

WIP


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
  llvm/include/llvm/CodeGen/MachinePassRegistry.def
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/SanitizerMetadata.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp

Index: llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
@@ -51,6 +51,9 @@
 
 constexpr uint32_t kVersionBase = 1;// occupies lower 16 bits
 constexpr uint32_t kVersionPtrSizeRel = (1u << 16); // offsets are pointer-sized
+constexpr uint32_t kFeatureNone = 0;
+constexpr uint32_t kFeatureAtomics = 1 << 0;
+constexpr uint32_t kFeatureUAR = 1 << 1;
 constexpr int kCtorDtorPriority = 2;
 
 // Pairs of names of initialization callback functions and which section
@@ -67,14 +70,14 @@
 private:
   // Forbid construction elsewhere.
   explicit constexpr MetadataInfo(StringRef FunctionPrefix,
-  StringRef SectionSuffix, int Feature)
+  StringRef SectionSuffix, uint32_t Feature)
   : FunctionPrefix(FunctionPrefix), SectionSuffix(SectionSuffix),
-FeatureMask(Feature != -1 ? (1u << Feature) : 0) {}
+FeatureMask(Feature) {}
 };
 const MetadataInfo MetadataInfo::Covered{"__sanitizer_metadata_covered",
- "sanmd_covered", -1};
+ "sanmd_covered", kFeatureNone};
 const MetadataInfo MetadataInfo::Atomics{"__sanitizer_metadata_atomics",
- "sanmd_atomics", 0};
+ "sanmd_atomics", kFeatureAtomics};
 
 // The only instances of MetadataInfo are the constants above, so a set of
 // them may simply store pointers to them. To deterministically generate code,
@@ -89,11 +92,16 @@
 cl::opt ClEmitAtomics("sanitizer-metadata-atomics",
 cl::desc("Emit PCs for atomic operations."),
 cl::Hidden, cl::init(false));
+cl::opt ClEmitUAR("sanitizer-metadata-uar",
+cl::desc("Emit PCs for start of functions that are "
+ "subject for use-after-return checking"),
+cl::Hidden, cl::init(false));
 
 //===--- Statistics ---===//
 
 STATISTIC(NumMetadataCovered, "Metadata attached to covered functions");
 STATISTIC(NumMetadataAtomics, "Metadata attached to atomics");
+STATISTIC(NumMetadataUAR, "Metadata attached to UAR functions");
 
 //===--===//
 
@@ -102,6 +110,7 @@
 transformOptionsFromCl(SanitizerBinaryMetadataOptions &&Opts) {
   Opts.Covered |= ClEmitCovered;
   Opts.Atomics |= ClEmitAtomics;
+  Opts.UAR |= ClEmitUAR;
   return std::move(Opts);
 }
 
@@ -142,7 +151,8 @@
   // function with memory operations (atomic or not) requires covered metadata
   // to determine if a memory operation is atomic or not in modules compiled
   // with SanitizerBinaryMetadata.
-  bool runOn(Instruction &I, MetadataInfoSet &MIS, MDBuilder &MDB);
+  bool runOn(Instruction &I, MetadataInfoSet &MIS, MDBuilder &MDB,
+ uint32_t &PerInstrFeatureMask);
 
   // Get start/end section marker pointer.
   GlobalVariable *getSectionMarker(const Twine &MarkerName, Type *Ty);
@@ -235,12 +245,17 @@
   uint32_t PerInstrFeatureMask = getEnabledPerInstructionFeature();
   // Don't emit unnecessary covered metadata for all functions to save space.
   bool RequiresCovered = false;
-  if (PerInstrFeatureMask) {
+  if (PerInstrFeatureMask || Options.UAR) {
 for (BasicBlock &BB : F)
   for (Instruction &I : BB)
-RequiresCovered |= runOn(I, MIS, MDB);
+RequiresCovered |= runOn(I, MIS, MDB, PerInstrFeatureMask);
   }
 
+  if (F.isVarArg())
+PerInstrFeatureMask &= ~kFeatureUAR;
+  if (PerInstrFeatureMask & kFeatureUAR)
+NumMetadataUAR++;
+
   // Covered metadata is always emitted if explicitly requested, otherwise only
   // if some other metadata requires it to unam

[PATCH] D136124: [clang][deps] Remove unintentional `move`

2022-10-18 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM

As it happens the bot that found this has been moved to silent for other 
reasons. I'll let you know if we see any further issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136124

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


[clang] 57ba07c - [clang] fix typo in unit test

2022-10-18 Thread Nuno Lopes via cfe-commits

Author: Susana Monteiro
Date: 2022-10-18T16:32:13+01:00
New Revision: 57ba07c06f8b68d401f47ab115259fa2dd3d7136

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

LOG: [clang] fix typo in unit test

Added: 


Modified: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git 
a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index bf06953394692..96f87a8ed555d 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -462,7 +462,7 @@ TEST_F(JoinFlowConditionsTest, 
JoinDistinctButProvablyEquivalentValues) {
 EXPECT_FALSE(Env1.flowConditionImplies(*GetFooValue(Env1)));
 EXPECT_TRUE(Env2.flowConditionImplies(*GetFooValue(Env2)));
 EXPECT_TRUE(Env3.flowConditionImplies(*GetFooValue(Env3)));
-EXPECT_TRUE(Env4.flowConditionImplies(*GetFooValue(Env3)));
+EXPECT_TRUE(Env4.flowConditionImplies(*GetFooValue(Env4)));
   });
 }
 



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


[PATCH] D135192: Fix incorrect check for running out of source locations.

2022-10-18 Thread Paul Pluzhnikov via Phabricator via cfe-commits
ppluzhnikov added a comment.

Richard, ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135192

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


[PATCH] D135220: [clang] Update ModuleMap::getModuleMapFile* to use FileEntryRef

2022-10-18 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

(catching up after I was away last week) I agree with @dexonsmith's analysis 
above. One historical note:

> As a heuristic on top of (4), "last-ref" (before this patch) probably gets 
> the answer the user expects more often than "first-ref" (this patch) does, 
> which I assume is why it was originally implemented.

It was originally implemented this way because it works out more often for 
module-related files, and vfs overlays; debug info and preprocessor output of 
this kind was not considered. This is part of a workaround for lack of proper 
FileEntryRef support across the compiler that we should unwind over time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135220

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


[PATCH] D136041: [clang][DebugInfo] Emit DISubprogram for extern functions with reserved names

2022-10-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.

In D136041#3864171 , @yonghong-song 
wrote:

> In D136041#3863748 , @dblaikie 
> wrote:
>
>> Hmm - this does mean linking IR can produce invalid code, though, right (you 
>> link in a definition of the function, so what was valid is now invalid - 
>> because it now has a definition, can be inlined, etc)? Is that new? 
>> concerning?
>
> @dblaikie do you have a concrete example to illustrate the problem?

One translation unit with a call to a function declaration, that call has no 
!dbg attachment.
Another translation unit with the definition of that declared function.

As-is, this would not cause any verifier error or backend debug info assertion.
Link the two together and now it's a verifier error - and, depending on the 
contents of the function definition, maybe a backend debug info assertion.

In D136041#3864782 , @eddyz87 wrote:

> In D136041#3863748 , @dblaikie 
> wrote:
>
>> Hmm - this does mean linking IR can produce invalid code, though, right (you 
>> link in a definition of the function, so what was valid is now invalid - 
>> because it now has a definition, can be inlined, etc)? Is that new? 
>> concerning?
>
> As far as I understand this 
> 
>  discussion the check in question is "best effort".

Fair point

> My change further narrows conditions when verifier would report an error, 
> thus it should not add any new failures to the existing code.

No, the opposite.

> But yes, hypothetically there might be a situation when old version of the 
> check would have caught a miss-behaving transformation at an earlier stage 
> (before linking IR rather then after).

Right - now things that were invalid categorically, are now valid, unless you 
link them. Which is a bit tricky.

Ah well, as you say - it's best effort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136041

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


[PATCH] D136120: [Clang] follow-up D128745, remove ClangABICompat checks

2022-10-18 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

The code changes look good to me. I offered a suggested rewording of the 
release note.




Comment at: clang/docs/ReleaseNotes.rst:499-501
+- Implemented DR692, DR1395 and DR1432. Note that the fix for DR1432 is 
speculative
+  that there is no wording or even resolution for this issue. A speculative 
fix for
+  DR1432 is needed because it fixes regressions caused by DR692.

- Implemented
  `DR692 `_,
  `DR1395 `_, and
  `DR1432`_.
  The fix for DR1432 is speculative since the issue is still open and has no 
proposed resolution at this time.
  A speculative fix for DR1432 is needed to prevent regressions that would 
otherwise occur due to DR692.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136120

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


[PATCH] D135657: add time traces for AST serialization

2022-10-18 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

It looks like this:
F24958018: image.png 
F24958020: image.png 
There is a generic test for the TimeTraceScope functionality.
Other than that there's only this one I found in 
https://reviews.llvm.org/D135658#change-sRvmpoTP4Jas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135657

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


  1   2   3   >