[PATCH] D139281: [clang-format] Fix an assertion failure in block parsing

2022-12-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D139281#3969880 , 
@HazardyKnusperkeks wrote:

> We should rename, remove, or re add the functionality for this function. Or 
> else someone new will come along and be confused.

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139281

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


[PATCH] D138489: [tsan] Add tsan support for loongarch64

2022-12-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov accepted this revision.
dvyukov added inline comments.



Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1526
+
+  /* if ($a0 != 0)
+   *   return $a0;

Please use C-style one-line comments //


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138489

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


[PATCH] D139302: [RISCV] Add Syntacore SCR1 CPU model

2022-12-05 Thread Dmitrii Petrov via Phabricator via cfe-commits
dnpetrov-sc created this revision.
dnpetrov-sc added reviewers: craig.topper, anton-afanasyev, asi-sc.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, frasercrmck, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb, hiraditya, arichardson.
Herald added a project: All.
dnpetrov-sc requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

[RISCV] Add Syntacore SCR1 CPU model

SCR1 is available at https://github.com/syntacore/scr1

'scr1-min' corresponds to SCR1_CFG_RV32EC_MIN,
'scr1-base' corresponds to SCR1_CFG_RV32IC_BASE,
'scr1-max' corresponds to SCR1_CFG_RV32IMC_MAX.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139302

Files:
  clang/test/Driver/riscv-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVSchedSCR1.td

Index: llvm/lib/Target/RISCV/RISCVSchedSCR1.td
===
--- /dev/null
+++ llvm/lib/Target/RISCV/RISCVSchedSCR1.td
@@ -0,0 +1,207 @@
+//==- RISCVSchedSCR1.td - SCR1 Scheduling Definitions *- tablegen -*-=//
+//
+// 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
+//
+//===--===//
+
+//===--===//
+
+// SCR1: https://github.com/syntacore/scr1
+
+// This model covers SCR1_CFG_RV32IMC_MAX configuration (scr1-max).
+// SCR1_CFG_RV32EC_MIN (scr1-min) and SCR1_CFG_RV32IC_BASE (scr1-base)
+// configurations have essentially same scheduling characteristics.
+
+// SCR1 is single-issue in-order processor
+def SCR1Model : SchedMachineModel {
+  let MicroOpBufferSize = 0;
+  let IssueWidth = 1;
+  let LoadLatency = 2;
+  let MispredictPenalty = 3;
+  let CompleteModel = 0;
+  let UnsupportedFeatures = [HasStdExtZbkb, HasStdExtZbkc, HasStdExtZbkx,
+ HasStdExtZknd, HasStdExtZkne, HasStdExtZknh,
+ HasStdExtZksed, HasStdExtZksh, HasStdExtZkr,
+ HasVInstructions];
+}
+
+let SchedModel = SCR1Model in {
+
+let BufferSize = 0 in {
+def SCR1_ALU : ProcResource<1>;
+def SCR1_LSU : ProcResource<1>;
+def SCR1_MUL : ProcResource<1>;
+def SCR1_DIV : ProcResource<1>;
+def SCR1_CFU : ProcResource<1>;
+}
+
+// Branching
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// Integer arithmetic and logic
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// Integer multiplication: single-cycle multiplier in SCR1_CFG_RV32IMC_MAX
+def : WriteRes;
+def : WriteRes;
+
+// Integer division: latency 33, inverse throughput 33
+let Latency = 33, ResourceCycles = [33] in {
+def : WriteRes;
+def : WriteRes;
+}
+
+// Load/store instructions on SCR1 have latency 2 and inverse throughput 2
+// (SCR1_CFG_RV32IMC_MAX includes TCM)
+let Latency = 2, ResourceCycles=[2] in {
+// Memory
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+}
+
+let Unsupported = true in {
+// Atomic memory
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// FP load/store
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// FP instructions
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+def : WriteRes;
+}
+
+// Others
+def : WriteRes;
+def : WriteRes;
+
+def : InstRW<[WriteIALU], (instrs COPY)>;
+
+//===--===//
+// Bypasses (none)
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : Rea

[clang] 64428c0 - [NFC][clang] Strengthen checks in matrix-type-operators.cpp

2022-12-05 Thread Nuno Lopes via cfe-commits

Author: John McIver
Date: 2022-12-05T10:12:25Z
New Revision: 64428c0ddf55295c270569db7f581ac7bedeff87

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

LOG: [NFC][clang] Strengthen checks in matrix-type-operators.cpp

* Add tbaa attribute checks
* Add end-of-line check to load instructions

Added: 


Modified: 
clang/test/CodeGenCXX/matrix-type-operators.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/matrix-type-operators.cpp 
b/clang/test/CodeGenCXX/matrix-type-operators.cpp
index db10e2d9ce41d..d5d7e2d30a7d5 100644
--- a/clang/test/CodeGenCXX/matrix-type-operators.cpp
+++ b/clang/test/CodeGenCXX/matrix-type-operators.cpp
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 -O0 -fenable-matrix -triple x86_64-apple-darwin %s 
-emit-llvm -disable-llvm-passes -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -O0 -fenable-matrix -triple x86_64-apple-darwin %s 
-emit-llvm -disable-llvm-passes -o - -std=c++11 | FileCheck 
--check-prefixes=CHECK,NOOPT %s
 // RUN: %clang_cc1 -O1 -fenable-matrix -triple x86_64-apple-darwin %s 
-emit-llvm -disable-llvm-passes -o - -std=c++11 | FileCheck 
--check-prefixes=CHECK,OPT %s
-
 typedef double dx5x5_t __attribute__((matrix_type(5, 5)));
 using fx2x3_t = float __attribute__((matrix_type(2, 3)));
 
@@ -21,8 +20,10 @@ void test_add_template() {
   // CHECK:   %call = call noundef <10 x float> 
@_Z3addIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_(ptr noundef nonnull 
align 4 dereferenceable(40) %Mat1, ptr noundef nonnull align 4 
dereferenceable(40) %Mat2)
 
   // CHECK-LABEL: define linkonce_odr noundef <10 x float> 
@_Z3addIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_(
-  // CHECK:   [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4
-  // CHECK:   [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4
+  // NOOPT:   [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}}
+  // NOOPT:   [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}}
+  // OPT: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa 
!{{[0-9]+}}{{$}}
+  // OPT: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa 
!{{[0-9]+}}{{$}}
   // CHECK-NEXT:  [[RES:%.*]] = fadd <10 x float> [[MAT1]], [[MAT2]]
   // CHECK-NEXT:  ret <10 x float> [[RES]]
 
@@ -41,8 +42,10 @@ void test_subtract_template() {
   // CHECK:   %call = call noundef <10 x float> 
@_Z8subtractIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_(ptr noundef 
nonnull align 4 dereferenceable(40) %Mat1, ptr noundef nonnull align 4 
dereferenceable(40) %Mat2)
 
   // CHECK-LABEL: define linkonce_odr noundef <10 x float> 
@_Z8subtractIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_(
-  // CHECK:   [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4
-  // CHECK:   [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4
+  // NOOPT:   [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}}
+  // NOOPT:   [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}}
+  // OPT: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa 
!{{[0-9]+}}{{$}}
+  // OPT: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa 
!{{[0-9]+}}{{$}}
   // CHECK-NEXT:  [[RES:%.*]] = fsub <10 x float> [[MAT1]], [[MAT2]]
   // CHECK-NEXT:  ret <10 x float> [[RES]]
 
@@ -60,8 +63,9 @@ struct DoubleWrapper1 {
 
 void test_DoubleWrapper1_Sub1(MyMatrix &m) {
   // CHECK-LABEL: define{{.*}} void 
@_Z24test_DoubleWrapper1_Sub1R8MyMatrixIdLj10ELj9EE(
-  // CHECK:   [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8
-  // CHECK:   [[SCALAR:%.*]] = call noundef double 
@_ZN14DoubleWrapper1cvdEv(ptr {{[^,]*}} %w1)
+  // NOOPT:   [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8{{$}}
+  // OPT: [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8, 
!tbaa !{{[0-9]+}}{{$}}
+  // CHECK-NEXT:  [[SCALAR:%.*]] = call noundef double 
@_ZN14DoubleWrapper1cvdEv(ptr {{[^,]*}} %w1)
   // CHECK-NEXT:  [[SCALAR_EMBED:%.*]] = insertelement <90 x double> poison, 
double [[SCALAR]], i32 0
   // CHECK-NEXT:  [[SCALAR_EMBED1:%.*]] = shufflevector <90 x double> 
[[SCALAR_EMBED]], <90 x double> poison, <90 x i32> zeroinitializer
   // CHECK-NEXT:  [[RES:%.*]] = fsub <90 x double> [[MATRIX]], 
[[SCALAR_EMBED1]]
@@ -75,7 +79,8 @@ void test_DoubleWrapper1_Sub1(MyMatrix &m) {
 void test_DoubleWrapper1_Sub2(MyMatrix &m) {
   // CHECK-LABEL: define{{.*}} void 
@_Z24test_DoubleWrapper1_Sub2R8MyMatrixIdLj10ELj9EE(
   // CHECK:   [[SCALAR:%.*]] = call noundef double 
@_ZN14DoubleWrapper1cvdEv(ptr {{[^,]*}} %w1)
-  // CHECK:   [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8
+  // NOOPT:   [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8{{$}}
+  // OPT: [[MATRIX:%.*]] = load <90 x double>, ptr {{

[clang] 553bdf4 - [NFC][clang] Strengthen checks in matrix-type-operators.c

2022-12-05 Thread Nuno Lopes via cfe-commits

Author: John McIver
Date: 2022-12-05T10:13:35Z
New Revision: 553bdf4fde5a4638f3a7764a4f6c209b9cd36a09

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

LOG: [NFC][clang] Strengthen checks in matrix-type-operators.c

* Add tbaa attribute checks
* Add end-of-line check to load instructions

Added: 


Modified: 
clang/test/CodeGen/matrix-type-operators.c

Removed: 




diff  --git a/clang/test/CodeGen/matrix-type-operators.c 
b/clang/test/CodeGen/matrix-type-operators.c
index 2e85d6543a31..8f80877b271a 100644
--- a/clang/test/CodeGen/matrix-type-operators.c
+++ b/clang/test/CodeGen/matrix-type-operators.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -no-opaque-pointers -O0 -fenable-matrix -triple 
x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck 
--check-prefixes=CHECK %s
+// RUN: %clang_cc1 -no-opaque-pointers -O0 -fenable-matrix -triple 
x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck 
--check-prefixes=CHECK,NOOPT %s
 // RUN: %clang_cc1 -no-opaque-pointers -O1 -fenable-matrix -triple 
x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck 
--check-prefixes=CHECK,OPT %s
 
+
 typedef double dx5x5_t __attribute__((matrix_type(5, 5)));
 typedef float fx2x3_t __attribute__((matrix_type(2, 3)));
 typedef int ix9x3_t __attribute__((matrix_type(9, 3)));
@@ -10,8 +11,10 @@ typedef unsigned long long ullx4x2_t 
__attribute__((matrix_type(4, 2)));
 
 void add_matrix_matrix_double(dx5x5_t a, dx5x5_t b, dx5x5_t c) {
   // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_double(<25 x double> 
noundef %a, <25 x double> noundef %b, <25 x double> noundef %c)
-  // CHECK:   [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
-  // CHECK-NEXT:  [[C:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
+  // NOOPT:   [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8{{$}}
+  // NOOPT-NEXT:  [[C:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8{{$}}
+  // OPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8, !tbaa !{{[0-9]+}}{{$}}
+  // OPT-NEXT:[[C:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8, !tbaa !{{[0-9]+}}{{$}}
   // CHECK-NEXT:  [[RES:%.*]] = fadd <25 x double> [[B]], [[C]]
   // CHECK-NEXT:  store <25 x double> [[RES]], <25 x double>* {{.*}}, align 8
 
@@ -20,8 +23,10 @@ void add_matrix_matrix_double(dx5x5_t a, dx5x5_t b, dx5x5_t 
c) {
 
 void add_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) {
   // CHECK-LABEL: define{{.*}} void @add_compound_assign_matrix_double(<25 x 
double> noundef %a, <25 x double> noundef %b)
-  // CHECK:   [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
-  // CHECK-NEXT:  [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
+  // NOOPT:   [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8{{$}}
+  // NOOPT-NEXT:  [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8{{$}}
+  // OPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8, !tbaa !{{[0-9]+}}{{$}}
+  // OPT-NEXT:[[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8, !tbaa !{{[0-9]+}}{{$}}
   // CHECK-NEXT:  [[RES:%.*]] = fadd <25 x double> [[A]], [[B]]
   // CHECK-NEXT:  store <25 x double> [[RES]], <25 x double>* {{.*}}, align 8
 
@@ -30,8 +35,10 @@ void add_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) 
{
 
 void subtract_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) {
   // CHECK-LABEL: define{{.*}} void 
@subtract_compound_assign_matrix_double(<25 x double> noundef %a, <25 x double> 
noundef %b)
-  // CHECK:   [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
-  // CHECK-NEXT:  [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
+  // NOOPT:   [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8{{$}}
+  // NOOPT-NEXT:  [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8{{$}}
+  // OPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8, !tbaa !{{[0-9]+}}{{$}}
+  // OPT-NEXT:[[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8, !tbaa !{{[0-9]+}}{{$}}
   // CHECK-NEXT:  [[RES:%.*]] = fsub <25 x double> [[A]], [[B]]
   // CHECK-NEXT:  store <25 x double> [[RES]], <25 x double>* {{.*}}, align 8
 
@@ -40,8 +47,10 @@ void subtract_compound_assign_matrix_double(dx5x5_t a, 
dx5x5_t b) {
 
 void add_matrix_matrix_float(fx2x3_t a, fx2x3_t b, fx2x3_t c) {
   // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_float(<6 x float> 
noundef %a, <6 x float> noundef %b, <6 x float> noundef %c)
-  // CHECK:   [[B:%.*]] = load <6 x float>, <6 x float>* {{.*}}, align 4
-  // CHECK-NEXT:  [[C:%.*]] = load <6 x float>, <6 x float>* {{.*}}, align 4
+  // NOOPT:   [[B:%.*]] =

[PATCH] D136594: [clangd] Add support for semantic token type "operator"

2022-12-05 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594

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


[PATCH] D136809: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2022-12-05 Thread LJC via Phabricator via cfe-commits
paperchalice updated this revision to Diff 480025.
paperchalice added reviewers: tstellar, MaskRay.
paperchalice added a comment.
Herald added a subscriber: StephenFan.

Use genex `$` due to `CMAKE_CFG_INTDIR` is deprecated since cmake 3.21.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136809

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  cmake/Modules/GetClangResourceDir.cmake
  compiler-rt/cmake/base-config-ix.cmake
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake
  openmp/CMakeLists.txt

Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -79,8 +79,8 @@
 if(${OPENMP_STANDALONE_BUILD})
   set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
 else()
-  string(REGEX MATCH "[0-9]+" CLANG_VERSION ${PACKAGE_VERSION})
-  set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include")
+  include(GetClangResourceDir)
+  get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
 endif()
 
 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -257,7 +257,11 @@
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
  ${PACKAGE_VERSION})
-  set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+set(resource_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR})
+  else()
+set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  endif()
   set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
   foreach(type ${flag_types})
 set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})
Index: lldb/unittests/Expression/ClangParserTest.cpp
===
--- lldb/unittests/Expression/ClangParserTest.cpp
+++ lldb/unittests/Expression/ClangParserTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangHost.h"
 #include "TestingSupport/SubsystemRAII.h"
@@ -37,12 +38,16 @@
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
 #if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
-  std::string path_to_clang_dir =
-  "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING;
+  std::string path_to_clang_dir = CLANG_RESOURCE_DIR[0]
+  ? "/foo/bar/bin/" CLANG_RESOURCE_DIR
+  : "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME
+"/clang/" CLANG_VERSION_MAJOR_STRING;
 #else
   std::string path_to_liblldb = "C:\\foo\\bar\\lib";
   std::string path_to_clang_dir =
-  "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
+  CLANG_RESOURCE_DIR[0]
+  ? "C:\\foo\\bar\\bin\\" CLANG_RESOURCE_DIR
+  : "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
 #endif
   EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -54,8 +54,11 @@
 
   static const llvm::StringRef kResourceDirSuffixes[] = {
   // LLVM.org's build of LLDB uses the clang resource directory placed
-  // in $install_dir/lib{,64}/clang/$clang_version.
-  CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING,
+  // in $install_dir/lib{,64}/clang/$clang_version or
+  // $install_dir/bin/$CLANG_RESOURCE_DIR
+  CLANG_RESOURCE_DIR[0] ? "bin/" CLANG_RESOURCE_DIR
+: CLANG_INSTALL_LIBDIR_BASENAME
+  "/clang/" CLANG_VERSION_MAJOR_STRING,
   // swift-lldb uses the clang resource directory copied from swift, which
   // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
   // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -7,6 +

[PATCH] D139274: Store OptTable::Info::Name as a StringRef

2022-12-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Build failure in pre-merge checks:

  FAILED: lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o
  CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/var/lib/buildkite-agent/builds/llvm-project/build/lib/Option 
-I/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option 
-I/var/lib/buildkite-agent/builds/llvm-project/build/include 
-I/var/lib/buildkite-agent/builds/llvm-project/llvm/include -gmlt -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG  -fno-exceptions -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o 
-MF lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o.d -o 
lib/Option/CMakeFiles/LLVMOption.dir/OptTable.cpp.o -c 
/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp
  
/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp:70:15:
 error: no matching function for call to 'StrCmpOptionName'
if (int N = StrCmpOptionName(A.Name, B.Name))
^~~~
  
/var/lib/buildkite-agent/builds/llvm-project/llvm/lib/Option/OptTable.cpp:60:12:
 note: candidate function not viable: no known conversion from 'const 
llvm::StringRef' to 'const char *' for 1st argument
  static int StrCmpOptionName(const char *A, const char *B) {
 ^
  1 error generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139274

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


[clang-tools-extra] fceec8d - Fix MSVC "not all control paths return a value" warning. NFC.

2022-12-05 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-12-05T10:39:54Z
New Revision: fceec8dcd8da66fa611e7fd104052fa37b65aecb

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

LOG: Fix MSVC "not all control paths return a value" warning. NFC.

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp 
b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
index cdfe5fda5e95f..c8b6cc77eb148 100644
--- a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
+++ b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
@@ -53,6 +53,7 @@ std::vector locateSymbol(const Symbol &S) {
   case Symbol::Macro:
 return {SymbolLocation(S.macro().Definition)};
   }
+  llvm_unreachable("Unknown Symbol::Kind enum");
 }
 
 } // namespace clang::include_cleaner



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


[PATCH] D138200: [include-cleaner] Make use of locateSymbol in WalkUsed

2022-12-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

sorry for the delay, just realize it is sitting in the review list, left some 
comments.




Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:25
+// Gets all the providers for a symbol by tarversing each location.
+llvm::SmallVector findAllHeaders(const Symbol &S,
+ const SourceManager &SM,

nit: this name is similar to `findHeaders` (not sure this is intended), I'd 
rather use a different name (something like `headersForSymbol`)



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:44
+
+  // Cache for decl to header mappings, as the same decl might be referenced in
+  // multiple locations and finding providers for each location is expensive.

I agree the place here might be on a performance-critical path, but I think the 
idea of using cache probably needs some bits of design, the current 
implementation seems half baked (there is also a FIXME in the findAllHeaders 
saying we should implement another cache for it, so it is unclear to me what's 
the whole picture).

Can we just leave out all cache in this patch with a FIXME? And having a 
follow-up patch for that?



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:46
+  // multiple locations and finding providers for each location is expensive.
+  std::unordered_map> DeclToHeaders;
   tooling::stdlib::Recognizer Recognizer;

any reason not using `llvm::DenseMap`?



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:52
   SymbolReference SymRef{Loc, ND, RT};
-  if (auto SS = Recognizer(&ND)) {
-// FIXME: Also report forward decls from main-file, so that the caller
-// can decide to insert/ignore a header.
-return CB(SymRef, findHeaders(*SS, SM, PI));
-  }
-  // FIXME: Extract locations from redecls.
-  return CB(SymRef, findHeaders(ND.getLocation(), SM, PI));
+  auto Inserted = DeclToHeaders.try_emplace(&ND);
+  if (Inserted.second)

nit: consider using structure binding to get rid of the `Insert.first`, 
`Insert.second` magic names.



Comment at: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp:141
+
 TEST(WalkUsed, MacroRefs) {
   llvm::Annotations Hdr(R"cpp(

it feels weird that all other tests are using WalkUsedTest, but not this one.

The logic are mostly the same except that this test doesn't need to build the 
AST nodes, if we change  `offsetToProviders` method to 
`offset(llvm::ArrayRef TopLevelDecl, llvm::ArrayRef 
MacroRef, SourceManager &SM)`, I think we can use it in this test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138200

___
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-12-05 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 480029.
TIFitis added a comment.
Herald added a subscriber: Moerafaat.

Changed map_operands to VariadicOfVariadic type.

Variadic Enums are not supported, hence I've changed the map type to 
VariadicOfVariadic which allows to store the entire map clause including types 
and modifiers in a single operand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
  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
@@ -451,6 +451,27 @@
 return
 }
 
+// CHECK-LABEL: omp_target_data
+func.func @omp_target_data (%if_cond : i1, %device : si32, %map: memref) -> () {
+
+//CHECK: omp.target_data
+"omp.target_data"(%if_cond, %device, %map) ({
+}) {operand_segment_sizes = array, map_operand_segments = array } : ( i1, si32, memref ) -> ()
+
+// CHECK: omp.target_enter_data
+"omp.target_enter_data"(%if_cond, %device) {nowait, operand_segment_sizes = array, map_operand_segments = array } : ( i1, si32) -> ()
+
+// CHECK: omp.target_exit_data
+"omp.target_exit_data"(%if_cond, %device) {nowait, operand_segment_sizes = array, map_operand_segments = array } : ( i1, si32) -> ()
+
+// CHECK: omp.barrier
+omp.barrier
+
+   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/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -23,6 +23,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include 
+#include 
 
 #include "mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc"
 #include "mlir/Dialect/OpenMP/OpenMPOpsEnums.cpp.inc"
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -785,6 +785,154 @@
   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 along with it's type and modifiers.
+
+The $map_operand_segments specifies the segment sizes for $map_operands.
+
+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,
+  VariadicOfVariadic:$map_operands,
+  DenseI32ArrayAttr:$map_operand_segments);
+
+  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_operands^ `:` type($map_operands) `)` )?
+$region attr-dict
+  }];
+
+}
+
+//===-===//
+// 2.12.3 target enter data Construct
+//===-===//
+
+def Target_EnterDataOp: OpenMP_Op<"target_enter_data",
+ 

[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-05 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D127284#3969975 , @v.g.vassilev 
wrote:

> In D127284#3969593 , @Michael137 
> wrote:
>
>> In D127284#3969458 , @v.g.vassilev 
>> wrote:
>>
>>> In D127284#3969446 , 
>>> @v.g.vassilev wrote:
>>>
> UPDATE: fails with clean build too
>
> Might be best to revert it for now while we figure out what's wrong

 I fail to reproduce it, can you give me access to some node where I can 
 debug? I suspect that should be something easy to fix.

 UPDATE: Reproduced it. Debugging.
>>>
>>> @Michael137, I think I understand what happens. This patch introduces a new 
>>> language option which is not benign from modules perspective. However, lldb 
>>> sets up modules the old way and then switches to the incremental processing 
>>> mode. We have two ways to fix this:
>>>
>>> - Pass `-Xclang -fincremental-extensions` in `ClangModulesDeclVendor.cpp` 
>>> and delete `instance->getPreprocessor().enableIncrementalProcessing();`; or
>>> - Apply https://reviews.llvm.org/D139258 which already does that.
>>>
>>> Can you check if https://reviews.llvm.org/D139258 passes the lldb 
>>> testsuite. It does pass my reproduction by hand (I still cannot run full of 
>>> the lldb-api tests)?
>>
>> Thanks for taking a look. I tried with the suggested patch on the 
>> Objective-C API tests and there's only 1 test failure remaining there:
>>
>>   lang/objc/modules-compile-error/TestModulesCompileError.py
>>   
>>   Expecting sub string: "module.h:4:1: error: unknown type name 
>> 'syntax_error_for_lldb_to_find'" (was not found)
>>
>> The test expects an error string that looks like `unknown type name 
>> 'syntax_error_for_lldb_to_find'` but gets `use of 'undeclared identifier 
>> 'syntax_error_for_lldb_to_find'`
>>
>> Haven't looked much further than that. Does that sound familiar to you? I 
>> see a similar test fix as part of this patch. Maybe it's just a matter of 
>> fixing up the expected string.
>>
>> I think we should revert for now until https://reviews.llvm.org/D139258 is 
>> ready to go. Just to unblock the buildbot
>
> I have pushed a fix in 
> https://github.com/llvm/llvm-project/commit/c95a0c91c0de66eb1066f23c69332522656f188e
>  That should unblock the bot. If that does not work, I will revert.

Latest test run: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48911/execution/node/74/log/
I modified the expected string slightly to make it work: 
https://reviews.llvm.org/rG811ad246ac7b
Should be all good now. Thanks for looking into this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D139107: [clangd] Allow to build Clangd without decision forest

2022-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 480034.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- Merge DecisionForest.cpp and *_disabled.cpp, change #ifndef to #if
- Add decision_forest to the feature string
- Set Heuristics as the default code completion model in tests
- Do not compile decision forest tests when it's disabled
- Remove the use of preprocessor for defining the default value of 
-ranking-model flag to clangd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139107

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/DecisionForest.cpp
  clang-tools-extra/clangd/Feature.cpp
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/benchmarks/CMakeLists.txt
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -170,6 +170,7 @@
   return S;
 }
 
+#if CLANGD_DECISION_FOREST
 TEST(DecisionForestRankingModel, NameMatchSanityTest) {
   clangd::CodeCompleteOptions Opts;
   Opts.RankingModel = CodeCompleteOptions::DecisionForest;
@@ -203,6 +204,7 @@
   .Completions,
   ElementsAre(named("clangA"), named("clangD")));
 }
+#endif // CLANGD_DECISION_FOREST
 
 TEST(DecisionForestRankingModel, DecisionForestScorerCallbackTest) {
   clangd::CodeCompleteOptions Opts;
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -209,10 +209,10 @@
 "ranking-model",
 cat(Features),
 desc("Model to use to rank code-completion items"),
-values(clEnumValN(CodeCompleteOptions::Heuristics, "heuristics",
-  "Use hueristics to rank code completion items"),
-   clEnumValN(CodeCompleteOptions::DecisionForest, "decision_forest",
-  "Use Decision Forest model to rank completion items")),
+values(clEnumValN(CodeCompleteOptions::DecisionForest, "decision_forest",
+  "Use Decision Forest model to rank completion items"),
+   clEnumValN(CodeCompleteOptions::Heuristics, "heuristics",
+  "Use hueristics to rank code completion items")),
 init(CodeCompleteOptions().RankingModel),
 Hidden,
 };
@@ -797,6 +797,13 @@
 }
   }
 
+#ifndef CLANGD_DECISION_FOREST
+  if (RankingModel == clangd::CodeCompleteOptions::DecisionForest) {
+llvm::errs() << "Clangd was compiled without decision forest support.\n";
+return 1;
+  }
+#endif
+
   // Setup tracing facilities if CLANGD_TRACE is set. In practice enabling a
   // trace flag in your editor's config is annoying, launching with
   // `CLANGD_TRACE=trace.json vim` is easier.
Index: clang-tools-extra/clangd/benchmarks/CMakeLists.txt
===
--- clang-tools-extra/clangd/benchmarks/CMakeLists.txt
+++ clang-tools-extra/clangd/benchmarks/CMakeLists.txt
@@ -1,4 +1,6 @@
-add_subdirectory(CompletionModel)
+if(CLANGD_DECISION_FOREST)
+  add_subdirectory(CompletionModel)
+endif()
 
 add_benchmark(IndexBenchmark IndexBenchmark.cpp)
 
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -9,7 +9,6 @@
 #include "Quality.h"
 #include "AST.h"
 #include "ASTSignals.h"
-#include "CompletionModel.h"
 #include "FileDistance.h"
 #include "SourceCode.h"
 #include "index/Symbol.h"
@@ -529,65 +528,6 @@
   return SymbolQuality * SymbolRelevance;
 }
 
-DecisionForestScores
-evaluateDecisionForest(const SymbolQualitySignals &Quality,
-   const SymbolRelevanceSignals &Relevance, float Base) {
-  Example E;
-  E.setIsDeprecated(Quality.Deprecated);
-  E.setIsReservedName(Quality.ReservedName);
-  E.setIsImplementationDetail(Quality.ImplementationDetail);
-  E.setNumReferences(Quality.References);
-  E.setSymbolCategory(Quality.Category);
-
-  SymbolRelevanceSignals::DerivedSignals Derived =
-  Relevance.calculateDerivedSignals();
-  int NumMatch = 0;
-  if (Relevance.ContextWords) {
-for (const auto &Word : Relevance.ContextWords->keys()) {
-  if (Relevance.Name.contains_insensitive(Word)) {
-++NumMatch;
-  }
-}
-  }
-  E.setIsNameInContext(NumMatch > 0);
-  E.setNumNameInContext(NumMatch);
-  E.setFractionNameInContext(
-  Relevance.ContextWords && !Relevance.ContextWords->empty()
-   

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

2022-12-05 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis marked an inline comment as done.
TIFitis added a comment.

If people are happy with this structure then I'll work on adding a pretty 
printer for the map clause. Please suggest any other changes that are required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

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


[PATCH] D139107: [clangd] Allow to build Clangd without decision forest

2022-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/Features.inc.in:7
 #define CLANGD_TIDY_CHECKS @CLANGD_TIDY_CHECKS@
+#define CLANGD_DECISION_FOREST @CLANGD_DECISION_FOREST@

sammccall wrote:
> we **could** include this in the feature-string too (Feature.cpp) but I think 
> it's probably more noise than signal.
Maybe include only when it's disabled? I've added this to the commit, PTAL.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:215
+   clEnumValN(CodeCompleteOptions::Heuristics, "heuristics",
+  "Use hueristics to rank code completion items")),
+#ifdef CLANGD_DECISION_FOREST

sammccall wrote:
> hmm, while reordering these: hueristics -> heuristics? :-)
I'm not sure how the reordering happened in the first place, TBH 🤔 
I kept it and fixed the typo, but also let me know if I should keep the old 
order instead.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:217
+#ifdef CLANGD_DECISION_FOREST
 init(CodeCompleteOptions().RankingModel),
+#else

sammccall wrote:
> CodeCompleteOptions().RankingModel is also the one used in unit tests.
> I think the default value in the struct should be ifdef'd, or if we 
> **really** want to avoid pp-conditionals in header files, we could have an 
> `Auto` value which acts sa the platform-default.
I have moved it to the `.cpp` file. I think that avoiding conditionals in the 
preprocessor is a good thing definitely.

I also considered putting the constant into `DecisionForest.cpp` to reduce the 
number of files that use `#if CLANGD_DECISION_FOREST`.
But the downside is that definition of the constant gets harder to find, so I 
opted for keeping it in this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139107

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


[clang] 541a137 - Revert "[AArch64] Improve TargetParser API"

2022-12-05 Thread Tomas Matheson via cfe-commits

Author: Tomas Matheson
Date: 2022-12-05T11:09:03Z
New Revision: 541a1371c05d77bb70a6173127d6544b9571dbab

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

LOG: Revert "[AArch64] Improve TargetParser API"

This reverts commit e83f1502f1be7a2a3b9a33f5a73867767e78ba6b.

Did not build with C++20 and caused problems with dynamic libs.

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/include/llvm/Support/AArch64TargetParser.h
llvm/include/llvm/Support/VersionTuple.h
llvm/lib/Support/AArch64TargetParser.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 476bfcf9c41f6..c5fce62bc501f 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -45,6 +45,28 @@ const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = {
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 
+static StringRef getArchVersionString(llvm::AArch64::ArchKind Kind) {
+  switch (Kind) {
+  case llvm::AArch64::ArchKind::ARMV9A:
+  case llvm::AArch64::ArchKind::ARMV9_1A:
+  case llvm::AArch64::ArchKind::ARMV9_2A:
+  case llvm::AArch64::ArchKind::ARMV9_3A:
+  case llvm::AArch64::ArchKind::ARMV9_4A:
+return "9";
+  default:
+return "8";
+  }
+}
+
+StringRef AArch64TargetInfo::getArchProfile() const {
+  switch (ArchKind) {
+  case llvm::AArch64::ArchKind::ARMV8R:
+return "R";
+  default:
+return "A";
+  }
+}
+
 AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
  const TargetOptions &Opts)
 : TargetInfo(Triple), ABI("aapcs") {
@@ -148,7 +170,7 @@ bool AArch64TargetInfo::validateBranchProtection(StringRef 
Spec, StringRef,
 
 bool AArch64TargetInfo::isValidCPUName(StringRef Name) const {
   return Name == "generic" ||
- llvm::AArch64::parseCpu(Name).Arch != llvm::AArch64::INVALID;
+ llvm::AArch64::parseCPUArch(Name) != llvm::AArch64::ArchKind::INVALID;
 }
 
 bool AArch64TargetInfo::setCPU(const std::string &Name) {
@@ -276,10 +298,8 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   // ACLE predefines. Many can only have one possible value on v8 AArch64.
   Builder.defineMacro("__ARM_ACLE", "200");
-  Builder.defineMacro("__ARM_ARCH",
-  std::to_string(ArchInfo->Version.getMajor()));
-  Builder.defineMacro("__ARM_ARCH_PROFILE",
-  std::string("'") + (char)ArchInfo->Profile + "'");
+  Builder.defineMacro("__ARM_ARCH", getArchVersionString(ArchKind));
+  Builder.defineMacro("__ARM_ARCH_PROFILE", "'" + getArchProfile() + "'");
 
   Builder.defineMacro("__ARM_64BIT_STATE", "1");
   Builder.defineMacro("__ARM_PCS_AAPCS64", "1");
@@ -444,34 +464,52 @@ void AArch64TargetInfo::getTargetDefines(const 
LangOptions &Opts,
   if (HasD128)
 Builder.defineMacro("__ARM_FEATURE_SYSREG128", "1");
 
-  if (*ArchInfo == llvm::AArch64::ARMV8_1A)
+  switch (ArchKind) {
+  default:
+break;
+  case llvm::AArch64::ArchKind::ARMV8_1A:
 getTargetDefinesARMV81A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_2A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_2A:
 getTargetDefinesARMV82A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_3A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_3A:
 getTargetDefinesARMV83A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_4A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_4A:
 getTargetDefinesARMV84A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_5A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_5A:
 getTargetDefinesARMV85A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_6A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_6A:
 getTargetDefinesARMV86A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_7A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_7A:
 getTargetDefinesARMV87A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_8A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_8A:
 getTargetDefinesARMV88A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV8_9A)
+break;
+  case llvm::AArch64::ArchKind::ARMV8_9A:
 getTargetDefinesARMV89A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV9A)
+break;
+  case llvm::AArch64::ArchKind::ARMV9A:
 getTargetDefinesARMV9A(Opts, Builder);
-  if (*ArchInfo == llvm::AArch64::ARMV9_1A)
+break;
+  case llvm::AArch64::ArchKind::ARMV9_1A:
 getTargetDefinesARMV91A(Opts, Builder);

[PATCH] D139305: [clang][driver] Support option '-mcpu' on target AVR

2022-12-05 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: aykevl, dylanmckay.
Herald added subscribers: luismarques, s.egerton, Jim, PkmX, simoncook, 
kristof.beyls, arichardson.
Herald added a project: All.
benshi001 requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, jacquesguan, MaskRay.
Herald added a project: clang.

Although there is an option '-mmcu' (inherited from avr-gcc) for selecting
a specific AVR CPU/MCU mode, '-mcpu' is more common on other targets, such
as ARM/RISCV/AArch64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139305

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/avr-mmcu.c

Index: clang/test/Driver/avr-mmcu.c
===
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,81 +1,81 @@
-// A test for the propagation of the -mmcu option to -cc1 and -cc1as
+// A test for the propagation of the -mmcu/-mcpu option to -cc1 and -cc1as
 
 // RUN: %clang -### --target=avr -mmcu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
+// RUN: %clang -### --target=avr -mcpu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
 // CHECK0: "-cc1" {{.*}} "-target-cpu" "attiny11"
 // CHECK0: "-cc1as" {{.*}} "-target-cpu" "attiny11"
 
 // RUN: %clang -### --target=avr -mmcu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
+// RUN: %clang -### --target=avr -mcpu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
 // CHECK1: "-cc1" {{.*}} "-target-cpu" "at90s2313"
 // CHECK1: "-cc1as" {{.*}} "-target-cpu" "at90s2313"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
+// RUN: %clang -### --target=avr -mcpu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
 // CHECK2: "-cc1" {{.*}} "-target-cpu" "at90s8515"
 // CHECK2: "-cc1as" {{.*}} "-target-cpu" "at90s8515"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
+// RUN: %clang -### --target=avr -mcpu=attiny13a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
 // CHECK3: "-cc1" {{.*}} "-target-cpu" "attiny13a"
 // CHECK3: "-cc1as" {{.*}} "-target-cpu" "attiny13a"
 
 // RUN: %clang -### --target=avr -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// RUN: %clang -### --target=avr -mcpu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
 // CHECK4: "-cc1" {{.*}} "-target-cpu" "attiny88"
 // CHECK4: "-cc1as" {{.*}} "-target-cpu" "attiny88"
 
-// RUN: %clang -### --target=avr -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK5 %s
-// CHECK5: "-cc1" {{.*}} "-target-cpu" "attiny88"
-// CHECK5: "-cc1as" {{.*}} "-target-cpu" "attiny88"
-
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK6 %s
+// RUN: %clang -### --target=avr -mcpu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK6 %s
 // CHECK6: "-cc1" {{.*}} "-target-cpu" "atmega8u2"
 // CHECK6: "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
 
-// RUN: %clang -### --target=avr -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK7 %s
-// CHECK7: "-cc1" {{.*}} "-target-cpu" "atmega8u2"
-// CHECK7: "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
-
 // RUN: %clang -### --target=avr -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
+// RUN: %clang -### --target=avr -mcpu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
 // CHECK8: "-cc1" {{.*}} "-target-cpu" "atmega8a"
 // CHECK8: "-cc1as" {{.*}} "-target-cpu" "atmega8a"
 
-// RUN: %clang -### --target=avr -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK9 %s
-// CHECK9: "-cc1" {{.*}} "-target-cpu" "atmega8a"
-// CHECK9: "-cc1as" {{.*}} "-target-cpu" "atmega8a"
-
 // RUN: %clang -### --target=avr -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKa %s
+// RUN: %clang -### --target=avr -mcpu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKa %s
 // CHECKa: "-cc1" {{.*}} "-target-cpu" "atmega16a"
 // CHECKa: "-cc1as" {{.*}} "-target-cpu" "atmega16a"
 
-// RUN: %clang -### --target=avr -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKb %s
-// CHECKb: "-cc1" {{.*}} "-target-cpu" "atmega16a"
-// CHECKb: "-cc1as" {{.*}} "-target-cpu" "atmega16a"
-
 // RUN: %clang -### --target=avr -mmcu=atmega128a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKc %s
+// RUN: %clang -### --target=avr -mcpu=atmega128a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKc %s
 // CHECKc: "-cc1" {{.*}} "-target-cpu" "atmega128a"
 // CHECKc: "-cc1as" {{.*}} "-target-cpu" "atmega128a"
 
 // RUN: %clang -### --target=avr -mmcu=atmega2560 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKd %s
+// RUN: %clang -### --target=avr -mcpu=atmega2560 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKd %s
 // CHECKd: "-cc1" {{.*}} "-target

[PATCH] D139305: [clang][driver] Support option '-mcpu' on target AVR

2022-12-05 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: clang/test/Driver/avr-mmcu.c:48
-// RUN: %clang -### --target=avr -mmcu=atmega16a -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECKb %s
-// CHECKb: "-cc1" {{.*}} "-target-cpu" "atmega16a"
-// CHECKb: "-cc1as" {{.*}} "-target-cpu" "atmega16a"

These 4 tests are redundant with their previous lines, so they should be 
removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139305

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-05 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

> Latest test run: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48911/execution/node/74/log/
> I modified the expected string slightly to make it work: 
> https://reviews.llvm.org/rG811ad246ac7b
> Should be all good now. Thanks for looking into this!

Thanks a lot for pinging! Glad that it worked with a relatively little number 
of iterations considering the nature of this patch ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D139305: [clang][driver] Support option '-mcpu' on target AVR

2022-12-05 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:387
   return A->getValue();
+if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+  return A->getValue();

It looks to me that -mcpu will always take precedence over -mmcu with this code 
even if mmcu comes later in the command line. Wouldn't it make more sense to 
treat them as aliases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139305

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


[clang-tools-extra] 14af1ad - [include-cleaner] Add two command-line flags to the include-cleaner

2022-12-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-12-05T12:20:34+01:00
New Revision: 14af1ad4ee0ab0c453af75e43cf469bd530536cf

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

LOG: [include-cleaner] Add two command-line flags to the include-cleaner
category.

Added: 


Modified: 
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 0a920f6e9ca0a..cdd0ea722f7c5 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -69,11 +69,13 @@ cl::opt Insert{
 "insert",
 cl::desc("Allow header insertions"),
 cl::init(true),
+cl::cat(IncludeCleaner),
 };
 cl::opt Remove{
 "remove",
 cl::desc("Allow header removals"),
 cl::init(true),
+cl::cat(IncludeCleaner),
 };
 
 std::atomic Errors = ATOMIC_VAR_INIT(0);



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


[PATCH] D139305: [clang][driver] Make option '-mmcu' as an alias of option '-mcpu'

2022-12-05 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 480040.
benshi001 retitled this revision from "[clang][driver] Support option '-mcpu' 
on target AVR" to "[clang][driver] Make option '-mmcu' as an alias of option 
'-mcpu'".
Herald added a subscriber: jeroen.dobbelaere.

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

https://reviews.llvm.org/D139305

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/avr-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -206,6 +206,9 @@
 // RUN: %clang -### %s --target=msp430 -mmcu=msp430g2553 \
 // RUN:   --sysroot=%S/Inputs/basic_msp430_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=LD-SCRIPT %s
+// RUN: %clang -### %s --target=msp430 -mcpu=msp430g2553 \
+// RUN:   --sysroot=%S/Inputs/basic_msp430_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=LD-SCRIPT %s
 // LD-SCRIPT: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // LD-SCRIPT: "-L{{.*}}/Inputs/basic_msp430_tree{{/|}}include"
 // LD-SCRIPT: "-Tmsp430g2553.ld"
@@ -214,6 +217,10 @@
 // RUN:   --sysroot=%S/Inputs/basic_msp430_tree \
 // RUN:   -T custom_script.ld 2>&1 \
 // RUN:   | FileCheck -check-prefix=CUSTOM-LD-SCRIPT %s
+// RUN: %clang -### %s --target=msp430 -mcpu=msp430g2553 \
+// RUN:   --sysroot=%S/Inputs/basic_msp430_tree \
+// RUN:   -T custom_script.ld 2>&1 \
+// RUN:   | FileCheck -check-prefix=CUSTOM-LD-SCRIPT %s
 // CUSTOM-LD-SCRIPT: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
 // CUSTOM-LD_SCRIPT-NOT: "-Tmsp430g2553.ld"
 // CUSTOM-LD-SCRIPT: "-T" "custom_script.ld"
@@ -223,6 +230,8 @@
 
 // RUN: %clang -### %s --target=msp430 -mmcu=msp430g2553 \
 // RUN:   -msim -rtlib=libgcc --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
+// RUN: %clang -### %s --target=msp430 -mcpu=msp430g2553 \
+// RUN:   -msim -rtlib=libgcc --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
 // RUN: FileCheck -check-prefix=SIMULATOR-POS %s < %t
 // RUN: FileCheck -check-prefix=SIMULATOR-NEG %s < %t
 // SIMULATOR-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
Index: clang/test/Driver/avr-mmcu.c
===
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,81 +1,81 @@
-// A test for the propagation of the -mmcu option to -cc1 and -cc1as
+// A test for the propagation of the -mmcu/-mcpu option to -cc1 and -cc1as
 
 // RUN: %clang -### --target=avr -mmcu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
+// RUN: %clang -### --target=avr -mcpu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
 // CHECK0: "-cc1" {{.*}} "-target-cpu" "attiny11"
 // CHECK0: "-cc1as" {{.*}} "-target-cpu" "attiny11"
 
 // RUN: %clang -### --target=avr -mmcu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
+// RUN: %clang -### --target=avr -mcpu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
 // CHECK1: "-cc1" {{.*}} "-target-cpu" "at90s2313"
 // CHECK1: "-cc1as" {{.*}} "-target-cpu" "at90s2313"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
+// RUN: %clang -### --target=avr -mcpu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
 // CHECK2: "-cc1" {{.*}} "-target-cpu" "at90s8515"
 // CHECK2: "-cc1as" {{.*}} "-target-cpu" "at90s8515"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
+// RUN: %clang -### --target=avr -mcpu=attiny13a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
 // CHECK3: "-cc1" {{.*}} "-target-cpu" "attiny13a"
 // CHECK3: "-cc1as" {{.*}} "-target-cpu" "attiny13a"
 
 // RUN: %clang -### --target=avr -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// RUN: %clang -### --target=avr -mcpu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
 // CHECK4: "-cc1" {{.*}} "-target-cpu" "attiny88"
 // CHECK4: "-cc1as" {{.*}} "-target-cpu" "attiny88"
 
-// RUN: %clang -### --target=avr -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK5 %s
-// CHECK5: "-cc1" {{.*}} "-target-cpu" "attiny88"
-// CHECK5: "-cc1as" {{.*}} "-target-cpu" "attiny88"
-
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK6 %s
+// RUN: %clang -### --target=avr -mcpu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK6 %s
 // CHECK6: "-cc1" {{.*}} "-target-cpu" "atmega8u2"
 // CHECK6: "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
 
-// RUN: %clang -### --target=avr -mmcu=atmega8

[PATCH] D139305: [clang][driver] Make option '-mmcu' as an alias of option '-mcpu'

2022-12-05 Thread Ben Shi via Phabricator via cfe-commits
benshi001 marked an inline comment as done.
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:387
   return A->getValue();
+if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+  return A->getValue();

arichardson wrote:
> It looks to me that -mcpu will always take precedence over -mmcu with this 
> code even if mmcu comes later in the command line. Wouldn't it make more 
> sense to treat them as aliases?
That's really a good idea. Thanks!


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

https://reviews.llvm.org/D139305

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2022-12-05 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

@MaskRay I reverted that commit because it broke important functionality 
(comparison by address) to fix an issue in an unsupported C++ version, it 
wasn't reviewed, and it was not clear from the commit message what it was 
fixing. I explained this in a comment on the original commit but forgot to add 
it to the message for the revert, sorry.

@saugustine I have reverted the patch while I address the issues that you and 
others have raised. In future if would be helpful if you provided some 
information about how to reproduce the error. However it looks like this is 
also related to C++20, and I would like to understand what the policy is there. 
As far as I am aware this is an untested configuration. If you are building 
with C++20 and any otherwise-good patches that break your build must be 
reverted, then there should be a buildbot covering that configuration. Without 
a buildbot, I think the onus should be on you to suggesting a fix, or at least 
give enough details to reproduce the problem and allow time for a fix. 
Apologies if I have misunderstood something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D138489: [tsan] Add tsan support for loongarch64

2022-12-05 Thread Youling Tang via Phabricator via cfe-commits
tangyouling updated this revision to Diff 480044.
tangyouling added a comment.

Use C-style one-line comments //.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138489

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_linux.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
  compiler-rt/lib/tsan/rtl/CMakeLists.txt
  compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
  compiler-rt/lib/tsan/rtl/tsan_platform.h
  compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
  compiler-rt/lib/tsan/rtl/tsan_rtl.h
  compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
  compiler-rt/test/sanitizer_common/print_address.h
  compiler-rt/test/tsan/map32bit.cpp
  compiler-rt/test/tsan/mmap_large.cpp

Index: compiler-rt/test/tsan/mmap_large.cpp
===
--- compiler-rt/test/tsan/mmap_large.cpp
+++ compiler-rt/test/tsan/mmap_large.cpp
@@ -17,7 +17,7 @@
 int main() {
 #ifdef __x86_64__
   const size_t kLog2Size = 39;
-#elif defined(__mips64) || defined(__aarch64__)
+#elif defined(__mips64) || defined(__aarch64__) || defined(__loongarch_lp64)
   const size_t kLog2Size = 32;
 #elif defined(__powerpc64__)
   const size_t kLog2Size = 39;
Index: compiler-rt/test/tsan/map32bit.cpp
===
--- compiler-rt/test/tsan/map32bit.cpp
+++ compiler-rt/test/tsan/map32bit.cpp
@@ -12,6 +12,7 @@
 // XFAIL: aarch64
 // XFAIL: powerpc64
 // XFAIL: s390x
+// XFAIL: loongarch64
 
 // MAP_32BIT doesn't exist on OS X and NetBSD.
 // UNSUPPORTED: darwin,netbsd
Index: compiler-rt/test/sanitizer_common/print_address.h
===
--- compiler-rt/test/sanitizer_common/print_address.h
+++ compiler-rt/test/sanitizer_common/print_address.h
@@ -7,8 +7,9 @@
   va_start(ap, n);
   while (n--) {
 void *p = va_arg(ap, void *);
-#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
-defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) ||   \
+defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) ||  \
+defined(__loongarch_lp64)
 // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
 // match to the format used in the diagnotic message.
 fprintf(stderr, "0x%012lx ", (unsigned long) p);
Index: compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
===
--- /dev/null
+++ compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
@@ -0,0 +1,196 @@
+#include "sanitizer_common/sanitizer_asm.h"
+
+.section .text
+
+ASM_HIDDEN(__tsan_setjmp)
+.comm _ZN14__interception11real_setjmpE,8,8
+.globl ASM_SYMBOL_INTERCEPTOR(setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
+ASM_SYMBOL_INTERCEPTOR(setjmp):
+  CFI_STARTPROC
+
+  // Save frame pointer and return address register
+  addi.d $sp, $sp, -32
+  st.d $ra, $sp, 24
+  st.d $fp, $sp, 16
+  CFI_DEF_CFA_OFFSET (32)
+  CFI_OFFSET (1, -8)
+  CFI_OFFSET (22, -16)
+
+  // Adjust the SP for previous frame
+  addi.d $fp, $sp, 32
+  CFI_DEF_CFA_REGISTER (22)
+
+  // Save env parameter
+  st.d $a0, $sp, 8
+  CFI_OFFSET (4, -24)
+
+  // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
+  addi.d  $a0, $fp, 0
+
+  // call tsan interceptor
+  bl  ASM_SYMBOL(__tsan_setjmp)
+
+  // Restore env parameter
+  ld.d $a0, $sp, 8
+  CFI_RESTORE (4)
+
+  // Restore frame/link register
+  ld.d $fp, $sp, 16
+  ld.d $ra, $sp, 24
+  addi.d $sp, $sp, 32
+  CFI_RESTORE (22)
+  CFI_RESTORE (1)
+  CFI_DEF_CFA (3, 0)
+
+  // tail jump to libc setjmp
+  la.local $a1, _ZN14__interception11real_setjmpE
+  ld.d $a1, $a1, 0
+  jr $a1
+
+  CFI_ENDPROC
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
+
+.comm _ZN14__interception12real__setjmpE,8,8
+.globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
+ASM_SYMBOL_INTERCEPTOR(_setjmp):
+  CFI_STARTPROC
+
+  // Save frame pointer and return address register
+  addi.d $sp, $sp, -32
+  st.d $ra, $sp, 24
+  st.d $fp, $sp, 16
+  CFI_DEF_CFA_OFFSET (32)
+  CFI_OFFSET (1, -8)
+  CFI_OFFSET (22, -16)
+
+  // Adjust the SP for previous frame
+  addi.d $fp, $sp, 32
+  CFI_DEF_CFA_REGISTER (22)
+
+  // Save env parameter
+  st.d $a0, $sp, 8
+  CFI_OFFSET (4, -24)
+
+  // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
+  addi.d  $a0, $fp, 0
+
+  // call tsan interceptor
+  bl  ASM_SYMBOL(__tsan_setjmp)
+
+  // Restore env parameter
+  ld.d $a0, $sp, 8
+  CFI_RESTORE (4)
+
+  // Restore frame/link register
+  ld.d $fp, $sp, 16
+  ld.d $ra, $sp, 24
+  addi.d 

[PATCH] D139107: [clangd] Allow to build Clangd without decision forest

2022-12-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Looks great, thanks!




Comment at: clang-tools-extra/clangd/CMakeLists.txt:21
 
+option(CLANGD_DECISION_FOREST "Enable decision forest model for ranking code 
completion items" ON)
 option(CLANGD_MALLOC_TRIM "Call malloc_trim(3) periodically in Clangd. (only 
takes effect when using glibc)" ON)

May want to add a motivating comment like "this involves generating and 
compiling large source files, which can run into toolchain limitations"?

(This does violate the convention that build configurations should be as 
mysterious as possible!)



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:26
 #include "FileDistance.h"
 #include "FuzzyMatch.h"
 #include "Headers.h"

Include feature.h instead of relying on it transitively?

(Important here as losing the include changes the behavior)



Comment at: clang-tools-extra/clangd/CodeComplete.h:134
+  };
+  static const CodeCompletionRankingModel DefaultRankingModel;
+  CodeCompletionRankingModel RankingModel = DefaultRankingModel;

Nice, somehow i forgot this was an option



Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:14
 #include "Compiler.h"
 #include "Matchers.h"
 #include "Protocol.h"

Feature.h here too 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139107

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


[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov updated this revision to Diff 480051.
dvyukov added a comment.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Moved tests to compiler-rt and rebased to HEAD.


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
  compiler-rt/test/CMakeLists.txt
  compiler-rt/test/metadata/CMakeLists.txt
  compiler-rt/test/metadata/common.h
  compiler-rt/test/metadata/covered.cpp
  compiler-rt/test/metadata/lit.cfg.py
  compiler-rt/test/metadata/lit.site.cfg.py.in
  compiler-rt/test/metadata/uar.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/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
  llvm/test/CodeGen/AArch64/O0-pipeline.ll
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/CodeGen/M68k/pipeline.ll
  llvm/test/CodeGen/PowerPC/O3-pipeline.ll
  llvm/test/CodeGen/RISCV/O0-pipeline.ll
  llvm/test/CodeGen/RISCV/O3-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -206,6 +206,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   X86 Speculative Execution Side Effect Suppression
 ; CHECK-NEXT:   X86 Indirect Thunks
 ; CHECK-NEXT:   X86 Return Thunks
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -72,6 +72,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   X86 Speculative Execution Side Effect Suppression
 ; CHECK-NEXT:   X86 Indirect Thunks
 ; CHECK-NEXT:   X86 Return Thunks
Index: llvm/test/CodeGen/RISCV/O3-pipeline.ll
===
--- llvm/test/CodeGen/RISCV/O3-pipeline.ll
+++ llvm/test/CodeGen/RISCV/O3-pipeline.ll
@@ -164,6 +164,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT: Machine Outliner
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   RISCV pseudo instruction expansion pass
Index: llvm/test/CodeGen/RISCV/O0-pipeline.ll
===
--- llvm/test/CodeGen/RISCV/O0-pipeline.ll
+++ llvm/test/CodeGen/RISCV/O0-pipeline.ll
@@ -57,6 +57,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   RISCV pseudo instruction expansion pass
 ; CHECK-NEXT:   RISCV atomic pseudo instruction expansion pass
 ; CHECK-NEXT:   Lazy Machine Block Frequency Analysis
Index: llvm/test/CodeGen/PowerPC/O3-pipeline.ll
===
--- llvm/test/CodeGen/PowerPC/O3-pipeline.ll
+++ llvm/test/CodeGen/PowerPC/O3-pipeline.ll
@@ -207,6 +207,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   PowerPC Expand Atomic
 ; CHECK-NEXT:   PowerPC Branch Selector
 ; CHECK-NEXT:   Lazy Machine Block Frequency Analysis
Index: llvm/test/CodeGen/M68k/pipeline.ll
===
--- llvm/test/CodeGen/M68k/pipeline.ll
+++ llvm/test/CodeGen/M68k/pipeline.ll
@@ -131,6 +131,7 @@
 ; CHECK-NEXT:  Contiguously Lay Out Funclets
 ; CHECK-NEXT:  StackMap Liveness Analysis
 ; CHECK-NEXT:  Live DEBUG_VALUE analysis
+; CHECK-NEXT:  Mach

[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

PTAL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D139168: [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency file within P1689 format (4/4)

2022-12-05 Thread Ben Boeckel via Phabricator via cfe-commits
ben.boeckel added inline comments.



Comment at: clang/test/ClangScanDeps/P1689.cppm:155
 
+// CHECK-MAKE: [[PREFIX]]/impl_part.o:
+// CHECK-MAKE:   [[PREFIX]]/impl_part.cppm

ChuanqiXu wrote:
> ben.boeckel wrote:
> > ChuanqiXu wrote:
> > > ben.boeckel wrote:
> > > > For scanning, this cannot be the object file. The output needs to be 
> > > > the P1689 output (or whatever the "main output" for the scanning rule 
> > > > is). This is the purpose behind the `-MT ` flag: to say what 
> > > > goes in this slot. I think it'll be necessary here (even if 
> > > > `clang-scan-deps` learns an `-o` flag because it is the build system 
> > > > that determines the "primary output").
> > > > 
> > > > I don't know if the `-MMD` and `-MD` differences are important or not; 
> > > > I don't think I particularly care which is default (I've used `-MD` 
> > > > FWIW), but it may matter for other situations.
> > > I am confused since the output `[[PREFIX]]/impl_part.o` is the same with 
> > > `P1689` output `[[PREFIX]]/impl_part.o` and the one in the compilation 
> > > database and the one specified in the command line option 
> > > `--p1689-targeted-output`. What's the expected output for you in this 
> > > case? (and the related command line input.)
> > P1689 is about specifying dependencies of *another* rule found by the 
> > dynamic content of some source. `-MF` is about *discovered* dependencies of 
> > *this* rule.
> hmmm sorry, I don't understand it a lot. May you explain your expectation in 
> the form of the input and the corresponding output?
*This* rule outputs `foo.ddi` (in CMake terms). We need to tell make or ninja 
what files, if they change, *this* rule needs rerun for. That is what `-MF` is 
for. What I need is spelled `-MT` "normally".

P1689, what this rule is *doing*, is writing dependencies for the *compile* 
rule, so it is hooked up by *its output*. Two rules cannot have the same 
output, so P1689 and `-MF` have completely different things to put for their 
"output".

You can see here: 
https://gitlab.kitware.com/cmake/cmake/-/blob/master/.gitlab/ci/cxx_modules_rules_gcc.cmake
 where `-MT` gets the `` which is the `-fdep-file=` argument. 
`-fdep-file=` tells GCC what rule the P1689 itself is for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139168

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


[PATCH] D139168: [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency file within P1689 format (4/4)

2022-12-05 Thread Ben Boeckel via Phabricator via cfe-commits
ben.boeckel added inline comments.



Comment at: clang/test/ClangScanDeps/P1689.cppm:155
 
+// CHECK-MAKE: [[PREFIX]]/impl_part.o:
+// CHECK-MAKE:   [[PREFIX]]/impl_part.cppm

ben.boeckel wrote:
> ChuanqiXu wrote:
> > ben.boeckel wrote:
> > > ChuanqiXu wrote:
> > > > ben.boeckel wrote:
> > > > > For scanning, this cannot be the object file. The output needs to be 
> > > > > the P1689 output (or whatever the "main output" for the scanning rule 
> > > > > is). This is the purpose behind the `-MT ` flag: to say what 
> > > > > goes in this slot. I think it'll be necessary here (even if 
> > > > > `clang-scan-deps` learns an `-o` flag because it is the build system 
> > > > > that determines the "primary output").
> > > > > 
> > > > > I don't know if the `-MMD` and `-MD` differences are important or 
> > > > > not; I don't think I particularly care which is default (I've used 
> > > > > `-MD` FWIW), but it may matter for other situations.
> > > > I am confused since the output `[[PREFIX]]/impl_part.o` is the same 
> > > > with `P1689` output `[[PREFIX]]/impl_part.o` and the one in the 
> > > > compilation database and the one specified in the command line option 
> > > > `--p1689-targeted-output`. What's the expected output for you in this 
> > > > case? (and the related command line input.)
> > > P1689 is about specifying dependencies of *another* rule found by the 
> > > dynamic content of some source. `-MF` is about *discovered* dependencies 
> > > of *this* rule.
> > hmmm sorry, I don't understand it a lot. May you explain your expectation 
> > in the form of the input and the corresponding output?
> *This* rule outputs `foo.ddi` (in CMake terms). We need to tell make or ninja 
> what files, if they change, *this* rule needs rerun for. That is what `-MF` 
> is for. What I need is spelled `-MT` "normally".
> 
> P1689, what this rule is *doing*, is writing dependencies for the *compile* 
> rule, so it is hooked up by *its output*. Two rules cannot have the same 
> output, so P1689 and `-MF` have completely different things to put for their 
> "output".
> 
> You can see here: 
> https://gitlab.kitware.com/cmake/cmake/-/blob/master/.gitlab/ci/cxx_modules_rules_gcc.cmake
>  where `-MT` gets the `` which is the `-fdep-file=` argument. 
> `-fdep-file=` tells GCC what rule the P1689 itself is for.
> -fdep-output= tells GCC what rule the P1689 itself is for.

Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139168

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


[PATCH] D136809: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2022-12-05 Thread LJC via Phabricator via cfe-commits
paperchalice updated this revision to Diff 480054.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136809

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  cmake/Modules/GetClangResourceDir.cmake
  compiler-rt/cmake/base-config-ix.cmake
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake
  openmp/CMakeLists.txt

Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -79,8 +79,8 @@
 if(${OPENMP_STANDALONE_BUILD})
   set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
 else()
-  string(REGEX MATCH "[0-9]+" CLANG_VERSION ${PACKAGE_VERSION})
-  set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include")
+  include(GetClangResourceDir)
+  get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
 endif()
 
 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -257,7 +257,11 @@
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
  ${PACKAGE_VERSION})
-  set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+set(resource_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR})
+  else()
+set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
+  endif()
   set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
   foreach(type ${flag_types})
 set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})
Index: lldb/unittests/Expression/ClangParserTest.cpp
===
--- lldb/unittests/Expression/ClangParserTest.cpp
+++ lldb/unittests/Expression/ClangParserTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangHost.h"
 #include "TestingSupport/SubsystemRAII.h"
@@ -37,12 +38,16 @@
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
 #if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
-  std::string path_to_clang_dir =
-  "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING;
+  std::string path_to_clang_dir = CLANG_RESOURCE_DIR[0]
+  ? "/foo/bar/bin/" CLANG_RESOURCE_DIR
+  : "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME
+"/clang/" CLANG_VERSION_MAJOR_STRING;
 #else
   std::string path_to_liblldb = "C:\\foo\\bar\\lib";
   std::string path_to_clang_dir =
-  "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
+  CLANG_RESOURCE_DIR[0]
+  ? "C:\\foo\\bar\\bin\\" CLANG_RESOURCE_DIR
+  : "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
 #endif
   EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -54,8 +54,11 @@
 
   static const llvm::StringRef kResourceDirSuffixes[] = {
   // LLVM.org's build of LLDB uses the clang resource directory placed
-  // in $install_dir/lib{,64}/clang/$clang_version.
-  CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING,
+  // in $install_dir/lib{,64}/clang/$clang_version or
+  // $install_dir/bin/$CLANG_RESOURCE_DIR
+  CLANG_RESOURCE_DIR[0] ? "bin/" CLANG_RESOURCE_DIR
+: CLANG_INSTALL_LIBDIR_BASENAME
+  "/clang/" CLANG_VERSION_MAJOR_STRING,
   // swift-lldb uses the clang resource directory copied from swift, which
   // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
   // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -7,6 +7,7 @@
 include(CheckIncludeFile)
 include(CheckCXXSourceCompiles)
 include(GNUInstallDirs)
+include(GetClangResourceDir)
 include(ExtendPath)
 
 check_include_file(unwind.h HAVE_UNWIND_H)
@@ 

[PATCH] D138861: [Clang] Implement CWG2640 Allow more characters in an n-char sequence

2022-12-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 480062.
cor3ntin added a comment.

Add comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138861

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/Lexer/char-escapes-delimited.c
  clang/test/Lexer/unicode.c
  clang/test/Preprocessor/ucn-pp-identifier.c
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15648,7 +15648,7 @@
 https://wg21.link/cwg2640";>2640
 accepted
 Allow more characters in an n-char sequence
-Unknown
+Clang 16
   
   
 https://wg21.link/cwg2641";>2641
Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -121,17 +121,23 @@
 #define \u{123456789}  // expected-error {{hex escape sequence out of range}} expected-error {{macro name must be an identifier}}
 #define \u{// expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}}
 #define \u{fgh}// expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}}
-#define \N{// expected-warning {{incomplete delimited universal character name; treating as '\' 'N' '{' identifier}} expected-error {{macro name must be an identifier}}
+#define \N{
+// expected-warning@-1 {{incomplete delimited universal character name; treating as '\' 'N' '{' identifier}}
+// expected-error@-2 {{macro name must be an identifier}}
 #define \N{}   // expected-warning {{empty delimited universal character name; treating as '\' 'N' '{' '}'}} expected-error {{macro name must be an identifier}}
 #define \N{NOTATHING}  // expected-error {{'NOTATHING' is not a valid Unicode character name}} \
// expected-error {{macro name must be an identifier}}
 #define \NN// expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{macro name must be an identifier}}
 #define \N{GREEK_SMALL-LETTERALPHA}  // expected-error {{'GREEK_SMALL-LETTERALPHA' is not a valid Unicode character name}} \
  // expected-note {{characters names in Unicode escape sequences are sensitive to case and whitespaces}}
+#define \N{🤡}  // expected-error {{'🤡' is not a valid Unicode character name}} \
+// expected-error {{macro name must be an identifier}}
 
 #define CONCAT(A, B) A##B
-int CONCAT(\N{GREEK, CAPITALLETTERALPHA}); // expected-error{{expected}} \
-   // expected-warning {{incomplete delimited universal character name}}
+int CONCAT(\N{GREEK
+, CAPITALLETTERALPHA});
+// expected-error@-2 {{expected}} \
+// expected-warning@-2 {{incomplete delimited universal character name}}
 
 #ifdef TRIGRAPHS
 int \N?? = 0; // expected-warning{{extension}} cxx2b-warning {{before C++2b}} \
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -43,6 +43,7 @@
 extern int  \U0001E4D0; // 𞓐 NAG MUNDARI LETTER O - Added in Unicode 15
 extern int _\N{TANGSA LETTER GA};
 extern int _\N{TANGSALETTERGA}; // expected-error {{'TANGSALETTERGA' is not a valid Unicode character name}} \
+// expected-error {{expected ';' after top level declarator}} \
 // expected-note {{characters names in Unicode escape sequences are sensitive to case and whitespace}}
 
 
Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -96,6 +96,11 @@
   unsigned i = u'\N{GREEK CAPITAL LETTER DELTA}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   char j = '\NN'; // expected-error {{expected '{' after '\N' escape sequence}} expected-warning {{multi-character character constant}}
   unsigned k = u'\N{LOTUS';   // expected-error {{incomplete universal character name}}
+
+  const char* emoji = "\N{🤡}"; // expected-error {{'🤡' is not a valid Unicode character name}} \
+// expected-note 5{{did you mean}}
+  const char* nested = "\N{\N{SPARKLE}}"; // expected-error {{'\N{SPARKLE' is not a valid Unicode character name}} \
+  // expected

[clang] a446827 - [NFC][Clang][Driver][AMDGPU] Avoid temporary copies of std::string by using Twine and StringRef

2022-12-05 Thread Juan Manuel MARTINEZ CAAMAÑO via cfe-commits

Author: Juan Manuel MARTINEZ CAAMAÑO
Date: 2022-12-05T07:27:10-06:00
New Revision: a446827249bdeb2f27e55a9f4942bd7425ecb0ff

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

LOG: [NFC][Clang][Driver][AMDGPU] Avoid temporary copies of std::string by 
using Twine and StringRef

Reviewed By: tra

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/lib/Driver/ToolChains/ROCm.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index f3ac7d2ab735..ff77969bbec5 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -854,7 +854,7 @@ void ROCMToolChain::addClangTargetOptions(
   const StringRef GpuArch = getGPUArch(DriverArgs);
   auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
   const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
-  std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
+  StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
   auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
   getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
   if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
@@ -946,7 +946,7 @@ ROCMToolChain::getCommonDeviceLibNames(const 
llvm::opt::ArgList &DriverArgs,
   auto Kind = llvm::AMDGPU::parseArchAMDGCN(GPUArch);
   const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
 
-  std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
+  StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
   auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
   getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
   if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,

diff  --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp 
b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index c64421d259ce..a555fe5830e0 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -237,7 +237,7 @@ void HIPAMDToolChain::addClangTargetOptions(
   DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);
   if (!MaxThreadsPerBlock.empty()) {
 std::string ArgStr =
-std::string("--gpu-max-threads-per-block=") + MaxThreadsPerBlock.str();
+(Twine("--gpu-max-threads-per-block=") + MaxThreadsPerBlock).str();
 CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
   }
 
@@ -344,7 +344,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList 
&DriverArgs) const {
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
-  for (auto Path : RocmInstallation.getRocmDeviceLibPathArg())
+  for (StringRef Path : RocmInstallation.getRocmDeviceLibPathArg())
 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
 
   addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
@@ -354,7 +354,7 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList 
&DriverArgs) const {
   if (!BCLibArgs.empty()) {
 llvm::for_each(BCLibArgs, [&](StringRef BCName) {
   StringRef FullName;
-  for (std::string LibraryPath : LibraryPaths) {
+  for (StringRef LibraryPath : LibraryPaths) {
 SmallString<128> Path(LibraryPath);
 llvm::sys::path::append(Path, BCName);
 FullName = Path;
@@ -387,15 +387,15 @@ HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList 
&DriverArgs) const {
 getDriver().Diag(DiagID);
 return {};
   } else
-BCLibs.push_back({AsanRTL.str(), /*ShouldInternalize=*/false});
+BCLibs.emplace_back(AsanRTL, /*ShouldInternalize=*/false);
 }
 
 // Add the HIP specific bitcode library.
 BCLibs.push_back(RocmInstallation.getHIPPath());
 
 // Add common device libraries like ocml etc.
-for (auto N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
-  BCLibs.push_back(StringRef(N));
+for (StringRef N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
+  BCLibs.emplace_back(N);
 
 // Add instrument lib.
 auto InstLib =

diff  --git a/clang/lib/Driver/ToolChains/ROCm.h 
b/clang/lib/Driver/ToolChains/ROCm.h
index b16deecdebec..600c8b39f4b3 100644
--- a/clang/lib/Driver/ToolChains/ROCm.h
+++ b/clang/lib/Driver/ToolChains/ROCm.h
@@ -252,8 +252,11 @@ class RocmInstallationDetector {
   }
 
   /// Get libdevice file for given architecture
-  std::string getLibDeviceFile(StringRef Gpu) const {
-return LibDeviceMap.lookup(Gpu);
+  StringRef getLibDeviceFile(StringRef Gpu) const {
+auto Loc = LibDeviceMap.find(Gpu);
+if (Loc == LibDeviceMap.end())
+  return "";
+return Loc->se

[PATCH] D139023: [NFC][Clang][Driver][AMDGPU] Avoid temporary copies of std::string by using Twine and StringRef

2022-12-05 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa446827249bd: [NFC][Clang][Driver][AMDGPU] Avoid temporary 
copies of std::string by using… (authored by jmmartinez).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139023

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/ROCm.h

Index: clang/lib/Driver/ToolChains/ROCm.h
===
--- clang/lib/Driver/ToolChains/ROCm.h
+++ clang/lib/Driver/ToolChains/ROCm.h
@@ -252,8 +252,11 @@
   }
 
   /// Get libdevice file for given architecture
-  std::string getLibDeviceFile(StringRef Gpu) const {
-return LibDeviceMap.lookup(Gpu);
+  StringRef getLibDeviceFile(StringRef Gpu) const {
+auto Loc = LibDeviceMap.find(Gpu);
+if (Loc == LibDeviceMap.end())
+  return "";
+return Loc->second;
   }
 
   void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
@@ -263,7 +266,7 @@
   void detectHIPRuntime();
 
   /// Get the values for --rocm-device-lib-path arguments
-  std::vector getRocmDeviceLibPathArg() const {
+  const ArrayRef getRocmDeviceLibPathArg() const {
 return RocmDeviceLibPathArg;
   }
 
@@ -273,7 +276,7 @@
   /// Get the value for --hip-version argument
   StringRef getHIPVersionArg() const { return HIPVersionArg; }
 
-  std::string getHIPVersion() const { return DetectedVersion; }
+  StringRef getHIPVersion() const { return DetectedVersion; }
 };
 
 } // end namespace driver
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -237,7 +237,7 @@
   DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);
   if (!MaxThreadsPerBlock.empty()) {
 std::string ArgStr =
-std::string("--gpu-max-threads-per-block=") + MaxThreadsPerBlock.str();
+(Twine("--gpu-max-threads-per-block=") + MaxThreadsPerBlock).str();
 CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
   }
 
@@ -344,7 +344,7 @@
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
-  for (auto Path : RocmInstallation.getRocmDeviceLibPathArg())
+  for (StringRef Path : RocmInstallation.getRocmDeviceLibPathArg())
 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
 
   addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
@@ -354,7 +354,7 @@
   if (!BCLibArgs.empty()) {
 llvm::for_each(BCLibArgs, [&](StringRef BCName) {
   StringRef FullName;
-  for (std::string LibraryPath : LibraryPaths) {
+  for (StringRef LibraryPath : LibraryPaths) {
 SmallString<128> Path(LibraryPath);
 llvm::sys::path::append(Path, BCName);
 FullName = Path;
@@ -387,15 +387,15 @@
 getDriver().Diag(DiagID);
 return {};
   } else
-BCLibs.push_back({AsanRTL.str(), /*ShouldInternalize=*/false});
+BCLibs.emplace_back(AsanRTL, /*ShouldInternalize=*/false);
 }
 
 // Add the HIP specific bitcode library.
 BCLibs.push_back(RocmInstallation.getHIPPath());
 
 // Add common device libraries like ocml etc.
-for (auto N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
-  BCLibs.push_back(StringRef(N));
+for (StringRef N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
+  BCLibs.emplace_back(N);
 
 // Add instrument lib.
 auto InstLib =
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -854,7 +854,7 @@
   const StringRef GpuArch = getGPUArch(DriverArgs);
   auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
   const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
-  std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
+  StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
   auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
   getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
   if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
@@ -946,7 +946,7 @@
   auto Kind = llvm::AMDGPU::parseArchAMDGCN(GPUArch);
   const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
 
-  std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
+  StringRef LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
   auto ABIVer = DeviceLibABIVersion::fromCodeObjectVersion(
   getAMDGPUCodeObjectVersion(getDriver(), DriverArgs));
   if (!RocmInstallation.checkCommonBitcodeLibs(CanonArch, LibDeviceFile,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinf

[PATCH] D139023: [NFC][Clang][Driver][AMDGPU] Avoid temporary copies of std::string by using Twine and StringRef

2022-12-05 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez added a comment.

@tra Thanks for the review! I double checked with ASAN and there were no issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139023

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


[clang] dbe8c2c - Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov via cfe-commits

Author: Dmitry Vyukov
Date: 2022-12-05T14:40:31+01:00
New Revision: dbe8c2c316c40b25a0a37b91f1a1a02a55182378

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

LOG: Use-after-return sanitizer binary metadata

Currently per-function metadata consists of:
(start-pc, size, features)

This adds a new UAR feature and if it's set an additional element:
(start-pc, size, features, stack-args-size)

Reviewed By: melver

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

Added: 
compiler-rt/test/metadata/CMakeLists.txt
compiler-rt/test/metadata/common.h
compiler-rt/test/metadata/covered.cpp
compiler-rt/test/metadata/lit.cfg.py
compiler-rt/test/metadata/lit.site.cfg.py.in
compiler-rt/test/metadata/uar.cpp
llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp

Modified: 
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
compiler-rt/test/CMakeLists.txt
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/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
llvm/test/CodeGen/AArch64/O0-pipeline.ll
llvm/test/CodeGen/AArch64/O3-pipeline.ll
llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
llvm/test/CodeGen/ARM/O3-pipeline.ll
llvm/test/CodeGen/M68k/pipeline.ll
llvm/test/CodeGen/PowerPC/O3-pipeline.ll
llvm/test/CodeGen/RISCV/O0-pipeline.ll
llvm/test/CodeGen/RISCV/O3-pipeline.ll
llvm/test/CodeGen/X86/O0-pipeline.ll
llvm/test/CodeGen/X86/opt-pipeline.ll

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 43521b76652db..81d5ccd4856d4 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -288,6 +288,8 @@ CODEGENOPT(SanitizeCoverageTraceLoads, 1, 0) ///< Enable 
tracing of loads.
 CODEGENOPT(SanitizeCoverageTraceStores, 1, 0) ///< Enable tracing of stores.
 CODEGENOPT(SanitizeBinaryMetadataCovered, 1, 0) ///< Emit PCs for covered 
functions.
 CODEGENOPT(SanitizeBinaryMetadataAtomics, 1, 0) ///< Emit PCs for atomic 
operations.
+CODEGENOPT(SanitizeBinaryMetadataUAR, 1, 0) ///< Emit PCs for start of 
functions
+///< that are subject for 
use-after-return checking.
 CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
 CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.
 CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 24cc56c8e05df..d34ed1d6d4919 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -497,7 +497,8 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
   // Check if any one of SanitizeBinaryMetadata* is enabled.
   bool hasSanitizeBinaryMetadata() const {
-return SanitizeBinaryMetadataCovered || SanitizeBinaryMetadataAtomics;
+return SanitizeBinaryMetadataCovered || SanitizeBinaryMetadataAtomics ||
+   SanitizeBinaryMetadataUAR;
   }
 };
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 11f6253db7445..c888d4f6194ab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5582,6 +5582,10 @@ def fexperimental_sanitize_metadata_EQ_atomics
 : Flag<["-"], "fexperimental-sanitize-metadata=atomics">,
   HelpText<"Emit PCs for atomic operations used by binary analysis 
sanitizers">,
   MarshallingInfoFlag>;
+def fexperimental_sanitize_metadata_EQ_uar
+: Flag<["-"], "fexperimental-sanitize-metadata=uar">,
+  HelpText<"Emit PCs for start of functions that are subject for 
use-after-return checking.">,
+  MarshallingInfoFlag>;
 def fpatchable_function_entry_offset_EQ
 : Joined<["-"], "fpatchable-function-entry-offset=">, MetaVarName<"">,
   HelpText<"Generate M NOPs before function entry">,

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index b18ead066c6d2..16b48c6dc1d18 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -235,6 +235,7 @@ getSanitizerBinaryMetadataOptions(const CodeGenOptions 
&CGOpts) {
   

[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov 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 rGdbe8c2c316c4: Use-after-return sanitizer binary metadata 
(authored by dvyukov).

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
  compiler-rt/test/CMakeLists.txt
  compiler-rt/test/metadata/CMakeLists.txt
  compiler-rt/test/metadata/common.h
  compiler-rt/test/metadata/covered.cpp
  compiler-rt/test/metadata/lit.cfg.py
  compiler-rt/test/metadata/lit.site.cfg.py.in
  compiler-rt/test/metadata/uar.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/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
  llvm/test/CodeGen/AArch64/O0-pipeline.ll
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/CodeGen/M68k/pipeline.ll
  llvm/test/CodeGen/PowerPC/O3-pipeline.ll
  llvm/test/CodeGen/RISCV/O0-pipeline.ll
  llvm/test/CodeGen/RISCV/O3-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -206,6 +206,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   X86 Speculative Execution Side Effect Suppression
 ; CHECK-NEXT:   X86 Indirect Thunks
 ; CHECK-NEXT:   X86 Return Thunks
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -72,6 +72,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   X86 Speculative Execution Side Effect Suppression
 ; CHECK-NEXT:   X86 Indirect Thunks
 ; CHECK-NEXT:   X86 Return Thunks
Index: llvm/test/CodeGen/RISCV/O3-pipeline.ll
===
--- llvm/test/CodeGen/RISCV/O3-pipeline.ll
+++ llvm/test/CodeGen/RISCV/O3-pipeline.ll
@@ -164,6 +164,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT: Machine Outliner
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   RISCV pseudo instruction expansion pass
Index: llvm/test/CodeGen/RISCV/O0-pipeline.ll
===
--- llvm/test/CodeGen/RISCV/O0-pipeline.ll
+++ llvm/test/CodeGen/RISCV/O0-pipeline.ll
@@ -57,6 +57,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   RISCV pseudo instruction expansion pass
 ; CHECK-NEXT:   RISCV atomic pseudo instruction expansion pass
 ; CHECK-NEXT:   Lazy Machine Block Frequency Analysis
Index: llvm/test/CodeGen/PowerPC/O3-pipeline.ll
===
--- llvm/test/CodeGen/PowerPC/O3-pipeline.ll
+++ llvm/test/CodeGen/PowerPC/O3-pipeline.ll
@@ -207,6 +207,7 @@
 ; CHECK-NEXT:   Contiguously Lay Out Funclets
 ; CHECK-NEXT:   StackMap Liveness Analysis
 ; CHECK-NEXT:   Live DEBUG_VALUE analysis
+; CHECK-NEXT:   Machine Sanitizer Binary Metadata
 ; CHECK-NEXT:   PowerPC Expand Atomic
 ; CHECK-NEXT:   PowerPC Branch Selector
 ; CHECK-NEXT:   Lazy Machine Block Frequency Analysis
Index: llvm/test/CodeGen/M68k/pipeline.ll
===
--- llvm/test/CodeGen/M68k/pipeline.ll
+++ llvm/test/CodeGen/M68k/pipeline.ll
@@ -131,6 +131,7 @@
 ; CHECK-NEXT:  Contiguously Lay Out Funclets
 ; CHECK-NEXT:  StackMap Liveness Analysis
 ; CHECK-NEXT:  Live DEBUG_VALUE

[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-12-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/test/CodeGen/windows-seh-EHa-CppCondiTemps.cpp:3
 
+// FIXME: this check appears to be miscompiled?
+// XFAIL: *

tentzen wrote:
> lebedev.ri wrote:
> > This test broke once we always started adding (outermost) UB scope for 
> > nounwind functions.
> > I don't quite get what is going wrong. It could be a bug in SEH handling.
> > Can someone who has some idea about that code take a look and suggest a fix?
> > @tentzen ?
> By definition, non-unwind function I think is for Synchronous EH. So this 
> Sanitizer check should exclude Asynchronous EH functions, those with option 
> -fasync-exceptions.
>  
I do not understand.
If the function can unwind, then why is it marked `nounwind`?
This kind of thing is exactly what i was afraid of with those SEH patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[clang] df41577 - [LinkerWrapper] Fix use-after-free when using JIT

2022-12-05 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-12-05T07:51:20-06:00
New Revision: df415774d2a584fb6a62bedf9a4ee936396a0e41

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

LOG: [LinkerWrapper] Fix use-after-free when using JIT

Summary:
This portion of the code was unused until now and wasn't properly
updated after we moved to using `StringRef`.

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 844927d04cc4d..3920c4e4549de 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -876,7 +876,7 @@ Error linkBitcodeFiles(SmallVectorImpl 
&InputFiles,
 if (BitcodeOutput.size() != 1 || !SingleOutput)
   return createStringError(inconvertibleErrorCode(),
"Cannot embed bitcode with multiple files.");
-OutputFiles.push_back(static_cast(BitcodeOutput.front()));
+OutputFiles.push_back(Args.MakeArgString(BitcodeOutput.front()));
 return Error::success();
   }
 
@@ -1187,7 +1187,8 @@ linkAndWrapDeviceFiles(SmallVectorImpl 
&LinkerInputFiles,
 return createFileError(*OutputOrErr, EC);
 
   OffloadingImage TheImage{};
-  TheImage.TheImageKind = IMG_Object;
+  TheImage.TheImageKind =
+  Args.hasArg(OPT_embed_bitcode) ? IMG_Bitcode : IMG_Object;
   TheImage.TheOffloadKind = Kind;
   TheImage.StringData = {
   {"triple",



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


[clang] 0b01e3d - clang: Convert builtins test to opaque pointers

2022-12-05 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2022-12-05T09:01:52-05:00
New Revision: 0b01e3d0ae1f81b7e823397ed5a452025e8a751b

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

LOG: clang: Convert builtins test to opaque pointers

Added: 


Modified: 
clang/test/CodeGen/builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index eb522db917ae..9420b26da329 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -o %t %s
+// RUN: %clang_cc1 -emit-llvm -o %t %s
 // RUN: not grep __builtin %t
-// RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -triple 
x86_64-darwin-apple | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-darwin-apple -o - %s | FileCheck 
%s
 
 int printf(const char *, ...);
 
@@ -433,10 +433,10 @@ void test_float_builtin_ops(float F, double D, long 
double LD) {
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
 #ifdef __x86_64__
 
-// CHECK-LABEL: define{{.*}} void @test_builtin_longjmp
+// CHECK-LABEL: define{{.*}} void @test_builtin_longjmp(ptr{{.*}}
 void test_builtin_longjmp(void **buffer) {
-  // CHECK: [[BITCAST:%.*]] = bitcast
-  // CHECK-NEXT: call void @llvm.eh.sjlj.longjmp(i8* [[BITCAST]])
+  // CHECK: [[LOAD:%[a-z0-9]+]] = load ptr, ptr
+  // CHECK-NEXT: call void @llvm.eh.sjlj.longjmp(ptr [[LOAD]])
   __builtin_longjmp(buffer, 1);
   // CHECK-NEXT: unreachable
 }
@@ -445,13 +445,13 @@ void test_builtin_longjmp(void **buffer) {
 
 // CHECK-LABEL: define{{.*}} void @test_memory_builtins
 void test_memory_builtins(int n) {
-  // CHECK: call i8* @malloc
+  // CHECK: call ptr @malloc
   void * p = __builtin_malloc(n);
   // CHECK: call void @free
   __builtin_free(p);
-  // CHECK: call i8* @calloc
+  // CHECK: call ptr @calloc
   p = __builtin_calloc(1, n);
-  // CHECK: call i8* @realloc
+  // CHECK: call ptr @realloc
   p = __builtin_realloc(p, n);
   // CHECK: call void @free
   __builtin_free(p);
@@ -466,9 +466,9 @@ long long test_builtin_readcyclecounter(void) {
 /// __builtin_launder should be a NOP in C since there are no vtables.
 // CHECK-LABEL: define{{.*}} void @test_builtin_launder
 void test_builtin_launder(int *p) {
-  // CHECK: [[TMP:%.*]] = load i32*,
+  // CHECK: [[TMP:%.*]] = load ptr,
   // CHECK-NOT: @llvm.launder
-  // CHECK: store i32* [[TMP]],
+  // CHECK: store ptr [[TMP]],
   int *d = __builtin_launder(p);
 }
 
@@ -483,27 +483,27 @@ void test___warn_memset_zero_len(void) {
 #ifdef __x86_64__
 
 // CHECK-LABEL: define{{.*}} void @test_builtin_os_log
-// CHECK: (i8* noundef %[[BUF:.*]], i32 noundef %[[I:.*]], i8* noundef 
%[[DATA:.*]])
+// CHECK: (ptr noundef %[[BUF:.*]], i32 noundef %[[I:.*]], ptr noundef 
%[[DATA:.*]])
 void test_builtin_os_log(void *buf, int i, const char *data) {
   volatile int len;
-  // CHECK: %[[BUF_ADDR:.*]] = alloca i8*, align 8
+  // CHECK: %[[BUF_ADDR:.*]] = alloca ptr, align 8
   // CHECK: %[[I_ADDR:.*]] = alloca i32, align 4
-  // CHECK: %[[DATA_ADDR:.*]] = alloca i8*, align 8
+  // CHECK: %[[DATA_ADDR:.*]] = alloca ptr, align 8
   // CHECK: %[[LEN:.*]] = alloca i32, align 4
-  // CHECK: store i8* %[[BUF]], i8** %[[BUF_ADDR]], align 8
-  // CHECK: store i32 %[[I]], i32* %[[I_ADDR]], align 4
-  // CHECK: store i8* %[[DATA]], i8** %[[DATA_ADDR]], align 8
+  // CHECK: store ptr %[[BUF]], ptr %[[BUF_ADDR]], align 8
+  // CHECK: store i32 %[[I]], ptr %[[I_ADDR]], align 4
+  // CHECK: store ptr %[[DATA]], ptr %[[DATA_ADDR]], align 8
 
-  // CHECK: store volatile i32 34, i32* %[[LEN]]
+  // CHECK: store volatile i32 34, ptr %[[LEN]]
   len = __builtin_os_log_format_buffer_size("%d %{public}s %{private}.16P", i, 
data, data);
 
-  // CHECK: %[[V1:.*]] = load i8*, i8** %[[BUF_ADDR]]
-  // CHECK: %[[V2:.*]] = load i32, i32* %[[I_ADDR]]
-  // CHECK: %[[V3:.*]] = load i8*, i8** %[[DATA_ADDR]]
-  // CHECK: %[[V4:.*]] = ptrtoint i8* %[[V3]] to i64
-  // CHECK: %[[V5:.*]] = load i8*, i8** %[[DATA_ADDR]]
-  // CHECK: %[[V6:.*]] = ptrtoint i8* %[[V5]] to i64
-  // CHECK: call void @__os_log_helper_1_3_4_4_0_8_34_4_17_8_49(i8* noundef 
%[[V1]], i32 noundef %[[V2]], i64 noundef %[[V4]], i32 noundef 16, i64 noundef 
%[[V6]])
+  // CHECK: %[[V1:.*]] = load ptr, ptr %[[BUF_ADDR]]
+  // CHECK: %[[V2:.*]] = load i32, ptr %[[I_ADDR]]
+  // CHECK: %[[V3:.*]] = load ptr, ptr %[[DATA_ADDR]]
+  // CHECK: %[[V4:.*]] = ptrtoint ptr %[[V3]] to i64
+  // CHECK: %[[V5:.*]] = load ptr, ptr %[[DATA_ADDR]]
+  // CHECK: %[[V6:.*]] = ptrtoint ptr %[[V5]] to i64
+  // CHECK: call void @__os_log_helper_1_3_4_4_0_8_34_4_17_8_49(ptr noundef 
%[[V1]], i32 noundef %[[V2]], i64 noundef %[[V4]], i32 noundef 16, i64 noundef 
%[[V6]])
   __builtin_os_log_format(buf, "%d %{public}s %{priv

[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to break tests: http://45.33.8.238/linux/93224/step_12.txt

Can you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

In D136078#3970792 , @thakis wrote:

> This seems to break tests: http://45.33.8.238/linux/93224/step_12.txt
>
> Can you take a look?

Looking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D124351: [Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2

2022-12-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D124351#3950805 , @cor3ntin wrote:

> Rebase. This is still a bit rough, I have a few tests to fix
> and some dead code to remove.
>
> ---
>
> @erichkeane  I wouldn't mind picking your brain on this.
> Consider:
>
>   template 
>   void dependent_init_capture(T x = 0) {
> [y = x] () requires (decltype(y){1}) {
>   return y;
> }();
>   }
>   
>   void test_dependent() {
> dependent_init_capture(0);
>   }
>
> This used to ""work"" in the previous iteration of the patch,
> but with the late concept checking it seems more involved.
>
> My understanding so far is that in `CheckFunctionConstraints` 
> we can't find an instanciated declaration of `y` (so it asserts in 
> `LocalInstantiationScope::findInstantiationOf`).
>
> I'm not 100% sure of what's the correct approach here would be. 
> My guess is that we might need to retransform the captures  in the 
> instanciation scope used 
> for constraint checking? 
> I'm not actually sure whether an instanciation of the lambda does exist at 
> that point in some other scope, 
> though. Ideally we would not instannciate lambdas more times than needed.
>
> Another issue is that there is no way to walk back from a call expression to 
> a lambda expression,
> so we might need to add that.

We shouldnn't -re-transform' the capture, but we need to make sure we get it 
into the current scope.  I haven't looked at lambda instantiation much, so I 
don't know where that 'y' usually ends up?  Can you do a run of it when it 
WORKS and see where it finds that when calling `FindInstantiatedDecl`.  I'm 
guessing we are currently counting on that coming from a PARENT of the 
`CurrentInstantiationScope` (one of the `Outer`s), which we can no longer count 
on.

`FindInstantiatedDecl` needs some unfortunate amount of work around lambdas, I 
found similar issues when working on https://reviews.llvm.org/D138148 which I 
need to get back to when I re-start work next year.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

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


[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

Fix for:

  -- Supported architectures for crt: aarch64
  CMake Error at compiler-rt/cmake/config-ix.cmake:244 (message):
Unsupported architecture: x86_64
  Call Stack (most recent call first):
compiler-rt/cmake/config-ix.cmake:280 (get_target_flags_for_arch)
compiler-rt/test/metadata/CMakeLists.txt:7 (get_test_cc_for_arch)
  -- Configuring incomplete, errors occurred!

https://reviews.llvm.org/D139323


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

In D136078#3970792 , @thakis wrote:

> This seems to break tests: http://45.33.8.238/linux/93224/step_12.txt
>
> Can you take a look?

Sent a fix: https://reviews.llvm.org/D139325


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D138939: [WIP][clang] adds a way to provide user-oriented reasons

2022-12-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/Frontend/sarif-reason.cpp:15
+void g() {
+  f1<0>(); // expected-error{{no matching function for call to 'f1'}}
+  f1(); // expected-error{{no matching function for call to 'f1'}}

cjdb wrote:
> erichkeane wrote:
> > This is definitely a case where I'd love the diagnostics formatted/arranged 
> > differently here.  If you can use the #BOOKMARK style to make sure errors 
> > and notes are together, it would better illustrate what you're trying to do 
> > here.
> This is maybe done? I'm not sure if this is the #BOOKMARK style you're 
> referring to, but it should capture the same intent. Lemme know if you had 
> something else in mind and I'll happily change it 🙂 
It isn't exactly (in that it is using line-numbers instead of bookmarks), but 
the ordering is fine for me.

The bookmarking is something like:

```
LineThatHasNote; // #NoteLine
...
LineThatCausesError;
// expected-error@-1 {{Some Error}}
// expected-note@#NoteLine {{The Note}}
```

However, what I REALLY care about is that the notes and errors are 'next' to 
eachother, since they are easier to read that way




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138939

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


[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

FTR 2 breakage fixes merged:
https://github.com/llvm/llvm-project/commit/2a05bd212e3e8aaed818ee23464f4d1fe0b0596d
https://github.com/llvm/llvm-project/commit/08742e72a34e835e6fc3c696eabe6045c78d6289


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D139326: [clang] Add test for CWG952

2022-12-05 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : // CWG952  is 
resolved by refining the definition of “naming class” per Richard’s suggestion 
in “CWG1621 and [class.static/2” 
.//
Wording:

- [class.static]/2 removed;
- [class.access.base]/5 rephrased.

Currently behavior is the following: unqualified names undergo //unqualified 
name lookup// [1], which perform //unqualified search// in immediate scope [2]. 
This scope is the scope the definition of //naming class// [3] refers to. 
`A::I` is not //accessible// when named in classes `C` and `D` per [3]. In 
particular, the last item regarding base class ([class.access.base]/5.4) is not 
applicable, because class `A` is not //accessible// in both classes `C` and `D` 
per [4].

References:

1. basic.lookup.unqual/4 

2. basic.lookup.unqual/3 
3. class.access.base/5 
4. class.access.base/4 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139326

Files:
  clang/test/CXX/drs/dr9xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -5520,7 +5520,7 @@
 https://wg21.link/cwg952";>952
 CD6
 Insufficient description of “naming class”
-Unknown
+Yes
   
   
 https://wg21.link/cwg953";>953
Index: clang/test/CXX/drs/dr9xx.cpp
===
--- clang/test/CXX/drs/dr9xx.cpp
+++ clang/test/CXX/drs/dr9xx.cpp
@@ -1,11 +1,9 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-
-#if __cplusplus < 201103L
-// expected-no-diagnostics
-#endif
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 namespace std {
   __extension__ typedef __SIZE_TYPE__ size_t;
@@ -74,6 +72,34 @@
 #endif
 }
 
+namespace dr952 { // dr952: yes
+struct A {
+  typedef int I; // #dr952-typedef-decl
+};
+struct B : private A { // #dr952-inheritance
+};
+struct C : B {
+  void f() {
+I i1; // expected-error {{private member}}
+// expected-note@#dr952-inheritance {{constrained by private inheritance}}
+// expected-note@#dr952-typedef-decl {{declared here}}
+  }
+  I i2; // expected-error {{private member}}
+  // expected-note@#dr952-inheritance {{constrained by private inheritance}}
+  // expected-note@#dr952-typedef-decl {{declared here}}
+  struct D {
+I i3; // expected-error {{private member}}
+// expected-note@#dr952-inheritance {{constrained by private inheritance}}
+// expected-note@#dr952-typedef-decl {{declared here}}
+void g() {
+  I i4; // expected-error {{private member}}
+  // expected-note@#dr952-inheritance {{constrained by private 
inheritance}}
+  // expected-note@#dr952-typedef-decl {{declared here}}
+}
+  };
+};
+} // namespace dr952
+
 namespace dr974 { // dr974: yes
 #if __cplusplus >= 201103L
   void test() {


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -5520,7 +5520,7 @@
 https://wg21.link/cwg952";>952
 CD6
 Insufficient description of “naming class”
-Unknown
+Yes
   
   
 https://wg21.link/cwg953";>953
Index: clang/test/CXX/drs/dr9xx.cpp
===
--- clang/test/CXX/drs/dr9xx.cpp
+++ clang/test/CXX/drs/dr9xx.cpp
@@ -1,11 +1,9 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-
-#if __cplusplus < 201103L
-// expected-no-diagnostics
-#endif
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions 

[PATCH] D139173: [clang] Add test for CWG600

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

LGTM!


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

https://reviews.llvm.org/D139173

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


[PATCH] D139086: [AArch64] Implement __arm_rsr128/__arm_wsr128

2022-12-05 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.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139086

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


[PATCH] D139125: [clang] Correctly handle by-reference capture with an initializer that is a pack expansion in lambdas.

2022-12-05 Thread Jens Massberg via Phabricator via cfe-commits
massberg added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:13156
   getSema().buildLambdaInitCaptureInitialization(
-  C->getLocation(), OldVD->getType()->isReferenceType(),
+  C->getLocation(), isReferenceType,
   EllipsisLoc, NumExpansions, OldVD->getIdentifier(),

ilya-biryukov wrote:
> Could we use `C->getCaptureKind() == LCK_ByRef` instead?
> 
> It seems like that was the intention of the function in the first place 
> (that's was the other callsite from the parser is doing): pass what was 
> written by the user and let the function figure out how to actually build the 
> types.
> Normally we want to unify the code that parser uses for non-dependent code 
> and the tree-transforms where possible.
`C-getCaptureKind` is equal to `LCK_ByCopy`, even if the expansion pack is 
passed by refernece.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139125

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


[PATCH] D139326: [clang] Add test for CWG952

2022-12-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This appears right to me!  I'd like others to take a look though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139326

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


[PATCH] D139095: [clang] Add test for CWG405

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

LGTM




Comment at: clang/test/CXX/drs/dr4xx.cpp:99
+void test3(A::S as) { using A::f; f(as); } // ok
+void test4(A::S as) { using B::f; f(as); } // ok
+void test5(A::S as) { int f; f(as); } // expected-error {{called object 
type 'int'}}

Endill wrote:
> I'm surprised that local function declaration prevents ADL, but 
> //using-declaration// doesn't. It has been working this way all along, so I 
> guess I better take a note of this.
A using-declaration is the idiomatic way to use ADL: 
https://en.cppreference.com/w/cpp/language/adl (see just after the Notes 
heading), but pretty much everything about ADL is a surprise to most folks. :-)


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

https://reviews.llvm.org/D139095

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Why do we have the JIT in the nextgen plugins? I figured that JIT would be 
handled by `libomptarget` proper rather than the plugins. I guess this is 
needed for per-kernel specialization? My idea of the rough pseudocode would be 
like this and we wouldn't need a complex class heirarchy. Also I don't know if 
we can skip `ptxas` by giving CUDA the ptx directly, we probably will need to 
invoke `lld` on the command line however right.

  for each image:
if image is bitcode
  image = compile(image)
   register(image)




Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:879
"Cannot embed bitcode with multiple files.");
-OutputFiles.push_back(static_cast(BitcodeOutput.front()));
+OutputFiles.push_back(Args.MakeArgString(BitcodeOutput.front()));
 return Error::success();

tianshilei1992 wrote:
> This will be pushed by Joseph in another patch.
Did that this morning.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt:24
 # Plugin Interface library.
-add_library(PluginInterface OBJECT PluginInterface.cpp GlobalHandler.cpp)
+add_llvm_library(PluginInterface OBJECT PluginInterface.cpp GlobalHandler.cpp 
JIT.cpp)
 

tianshilei1992 wrote:
> I guess this might cause the issue of non-protected global symbols.
Should we be able to put all this in the `add_llvm_library`?



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:47-51
+  InitializeAllTargetInfos();
+  InitializeAllTargets();
+  InitializeAllTargetMCs();
+  InitializeAllAsmParsers();
+  InitializeAllAsmPrinters();

We could probably limit these to the ones we actually care about since we know 
the triples. Not sure if it would save us much runtime.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:184
+
+  auto AddStream =
+  [&](size_t Task,

tianshilei1992 wrote:
> Is there any way that we don't write it to a file here?
Why do we need to invoke LTO here? I figured that we could call the backend 
directly since we have no need to actually link any filies, and we may not have 
a need to run more expensive optimizations when the bitcode is already 
optimized. If you do that then you should be able to just use a 
`raw_svector_ostream` as your output stream and get the compiled output written 
to that buffer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D137996: Add support for a backdoor driver option that enables emitting header usage information in JSON to a file

2022-12-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 480101.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Add another environment variable `CC_PRINT_HEADERS_FILTERING`, which can be 
used to specify whether header information should be filtered or not.

Currently, `CC_PRINT_HEADERS_FORMAT=json, CC_PRINT_HEADERS_FILTERING=on` and 
`CC_PRINT_HEADERS_FORMAT=textual, CC_PRINT_HEADERS_FILTERING=off` are allowed. 
`CC_PRINT_HEADERS=1` gets translated to `CC_PRINT_HEADERS_FORMAT=textual, 
CC_PRINT_HEADERS_FILTERING=off`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137996

Files:
  clang/include/clang/Basic/HeaderIncludeFormatKind.h
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/DependencyOutputOptions.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/test/Preprocessor/Inputs/print-header-json/header0.h
  clang/test/Preprocessor/Inputs/print-header-json/header1.h
  clang/test/Preprocessor/Inputs/print-header-json/header2.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system0.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system1.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system2.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system3.h
  clang/test/Preprocessor/print-header-json.c
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -13,6 +13,7 @@
 
 #include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/HeaderIncludeFormatKind.h"
 #include "clang/Basic/Stack.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
@@ -243,29 +244,54 @@
   *NumberSignPtr = '=';
 }
 
-static void SetBackdoorDriverOutputsFromEnvVars(Driver &TheDriver) {
-  auto CheckEnvVar = [](const char *EnvOptSet, const char *EnvOptFile,
-std::string &OptFile) {
-bool OptSet = !!::getenv(EnvOptSet);
-if (OptSet) {
-  if (const char *Var = ::getenv(EnvOptFile))
-OptFile = Var;
-}
-return OptSet;
-  };
+template 
+static T checkEnvVar(const char *EnvOptSet, const char *EnvOptFile,
+ std::string &OptFile) {
+  T OptVal = ::getenv(EnvOptSet);
+  if (OptVal) {
+if (const char *Var = ::getenv(EnvOptFile))
+  OptFile = Var;
+  }
+  return OptVal;
+}
 
+static bool SetBackdoorDriverOutputsFromEnvVars(Driver &TheDriver) {
   TheDriver.CCPrintOptions =
-  CheckEnvVar("CC_PRINT_OPTIONS", "CC_PRINT_OPTIONS_FILE",
-  TheDriver.CCPrintOptionsFilename);
-  TheDriver.CCPrintHeaders =
-  CheckEnvVar("CC_PRINT_HEADERS", "CC_PRINT_HEADERS_FILE",
-  TheDriver.CCPrintHeadersFilename);
+  checkEnvVar("CC_PRINT_OPTIONS", "CC_PRINT_OPTIONS_FILE",
+TheDriver.CCPrintOptionsFilename);
+  if (checkEnvVar("CC_PRINT_HEADERS", "CC_PRINT_HEADERS_FILE",
+TheDriver.CCPrintHeadersFilename)) {
+TheDriver.CCPrintHeadersFormat = HIF_Textual;
+TheDriver.CCPrintHeadersFiltering = false;
+  } else if (const char *EnvVar = checkEnvVar(
+ "CC_PRINT_HEADERS_FORMAT", "CC_PRINT_HEADERS_FILE",
+ TheDriver.CCPrintHeadersFilename)) {
+TheDriver.CCPrintHeadersFormat = stringToHeaderIncludeFormatKind(EnvVar);
+const char *FilteringStr = ::getenv("CC_PRINT_HEADERS_FILTERING");
+unsigned Filtering;
+if (!stringToHeaderIncludeFiltering(FilteringStr, Filtering)) {
+  llvm::errs() << "error: CC_PRINT_HEADERS_FILTERING incorrect or not set";
+  return false;
+}
+if ((TheDriver.CCPrintHeadersFormat == HIF_Textual && Filtering) ||
+(TheDriver.CCPrintHeadersFormat == HIF_JSON && !Filtering)) {
+  llvm::errs()
+  << "error: unsupported configuration: "
+ "(CC_PRINT_HEADERS_FORMAT, CC_PRINT_HEADERS_FILTERING) = ("
+  << EnvVar << ", " << FilteringStr << ")\n";
+  return false;
+}
+TheDriver.CCPrintHeadersFiltering = Filtering;
+  }
+
   TheDriver.CCLogDiagnostics =
-  CheckEnvVar("CC_LOG_DIAGNOSTICS", "CC_LOG_DIAGNOSTICS_FILE",
-  TheDriver.CCLogDiagnosticsFilename);
+  checkEnvVar("CC_LOG_DIAGNOSTICS", "CC_LOG_DIAGNOSTICS_FILE",
+TheDriver.CCLogDiagnosticsFilename);
   TheDriver.CCPrintProcessStats =
-  CheckEnvVar("CC_PRINT_PROC_STAT", "CC_PRINT_PROC_STAT_FILE",
-  TheDriver.CCPrintStatReportFilename);
+  checkEnvVar("CC_PRINT_PROC_STAT", "CC_PRINT_PROC_STAT_FILE",
+TheDriver.CCPrintStatReportFilename);
+
+  return true;
 }
 
 static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
@@ -480,7 +506,8 @@
 

[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-05 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D139287#3970996 , @jhuber6 wrote:

> Why do we have the JIT in the nextgen plugins? I figured that JIT would be 
> handled by `libomptarget` proper rather than the plugins. I guess this is 
> needed for per-kernel specialization? My idea of the rough pseudocode would 
> be like this and we wouldn't need a complex class heirarchy. Also I don't 
> know if we can skip `ptxas` by giving CUDA the ptx directly, we probably will 
> need to invoke `lld` on the command line however right.
>
>   for each image:
> if image is bitcode
>   image = compile(image)
>register(image)

We could handle them in `libomptarget`, but that's gonna require we add another 
two interface functions: `is_valid_bitcode_image`, and `compile_bitcode_image`. 
It is doable. Handling them in plugin as a separate module can just reuse the 
two existing interfaces.

> Also I don't know if we can skip `ptxas` by giving CUDA the ptx directly, we 
> probably will need to invoke `lld` on the command line however right.
>
>   for each image:
> if image is bitcode
>   image = compile(image)
>register(image)

We can give CUDA PTX directly, since the CUDA JIT is to just call `ptxas` 
instead of `ptxas -c`, which requires `nvlink` afterwards.




Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:184
+
+  auto AddStream =
+  [&](size_t Task,

jhuber6 wrote:
> tianshilei1992 wrote:
> > Is there any way that we don't write it to a file here?
> Why do we need to invoke LTO here? I figured that we could call the backend 
> directly since we have no need to actually link any filies, and we may not 
> have a need to run more expensive optimizations when the bitcode is already 
> optimized. If you do that then you should be able to just use a 
> `raw_svector_ostream` as your output stream and get the compiled output 
> written to that buffer.
For the purpose of this basic JIT support, we indeed just need backend. 
However, since we have the plan for super optimization, etc., having an 
optimization pipeline here is also useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-05 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

> I am bit afraid about release builds:
>
> if (!Initializer)
>
>   return;
>
> Is this semantically incorrect?

I think so. And now I think I see a path where the proposed `assert` is 
incorrect as well. The `else` branches at lines 5919, 5921, and 5923 appear to 
handle cases where `Initializer` may be null.

  clang/lib/Sema/SemaInit.cpp:
   5824   // Handle default initialization.
   5825   if (Kind.getKind() == InitializationKind::IK_Default) {
   5826 TryDefaultInitialization(S, Entity, Kind, *this);
   5827 return;
   5828   }
  
   
   5835   if (const ArrayType *DestAT = Context.getAsArrayType(DestType)) {
   5836 if (Initializer && isa(DestAT)) {
   
   5912 else if (S.getLangOpts().CPlusPlus &&
   5913  Entity.getKind() == InitializedEntity::EK_Member &&
   5914  Initializer && isa(Initializer)) {
   
   5918 } else if (DestAT->getElementType()->isCharType())
   5919   SetFailed(FK_ArrayNeedsInitListOrStringLiteral);
   5920 else if (IsWideCharCompatible(DestAT->getElementType(), Context))
   5921   SetFailed(FK_ArrayNeedsInitListOrWideStringLiteral);
   5922 else
   5923   SetFailed(FK_ArrayNeedsInitList);
   5924
   5925 return;
   5926   }

Perhaps the` assert` should be added after line 5926 above. I would be 
concerned about adding a return statement conditional on `Initializer` being 
null there though. If the intention is that an initializer must be present 
after that point, an early return could result in a miscompile; I'd rather have 
a crash.

I think the checks for `Initializer` being non-null following the addition of 
an `assert` should be removed.


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

https://reviews.llvm.org/D139148

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D139287#3971024 , @tianshilei1992 
wrote:

> In D139287#3970996 , @jhuber6 wrote:
>
>> Why do we have the JIT in the nextgen plugins? I figured that JIT would be 
>> handled by `libomptarget` proper rather than the plugins. I guess this is 
>> needed for per-kernel specialization? My idea of the rough pseudocode would 
>> be like this and we wouldn't need a complex class heirarchy. Also I don't 
>> know if we can skip `ptxas` by giving CUDA the ptx directly, we probably 
>> will need to invoke `lld` on the command line however right.
>>
>>   for each image:
>> if image is bitcode
>>   image = compile(image)
>>register(image)
>
> We could handle them in `libomptarget`, but that's gonna require we add 
> another two interface functions: `is_valid_bitcode_image`, and 
> `compile_bitcode_image`. It is doable. Handling them in plugin as a separate 
> module can just reuse the two existing interfaces.

Would we need to consult the plugin? We can just check the `magic` directly, if 
it's bitcode we just compile it for its triple. If this was wrong then when the 
plugin gets the compiled image it will error.

>> Also I don't know if we can skip `ptxas` by giving CUDA the ptx directly, we 
>> probably will need to invoke `lld` on the command line however right.
>>
>>   for each image:
>> if image is bitcode
>>   image = compile(image)
>>register(image)
>
> We can give CUDA PTX directly, since the CUDA JIT is to just call `ptxas` 
> instead of `ptxas -c`, which requires `nvlink` afterwards.

That makes it easier for us, so the only command line tool we need to call is 
`lld` for AMDGPU.




Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:184
+
+  auto AddStream =
+  [&](size_t Task,

tianshilei1992 wrote:
> jhuber6 wrote:
> > tianshilei1992 wrote:
> > > Is there any way that we don't write it to a file here?
> > Why do we need to invoke LTO here? I figured that we could call the backend 
> > directly since we have no need to actually link any filies, and we may not 
> > have a need to run more expensive optimizations when the bitcode is already 
> > optimized. If you do that then you should be able to just use a 
> > `raw_svector_ostream` as your output stream and get the compiled output 
> > written to that buffer.
> For the purpose of this basic JIT support, we indeed just need backend. 
> However, since we have the plan for super optimization, etc., having an 
> optimization pipeline here is also useful.
We should be able to configure our own optimization pipeline in that case, we 
might want the extra control as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-05 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D139287#3971062 , @jhuber6 wrote:

> In D139287#3971024 , 
> @tianshilei1992 wrote:
>
>> In D139287#3970996 , @jhuber6 
>> wrote:
>>
>>> Why do we have the JIT in the nextgen plugins? I figured that JIT would be 
>>> handled by `libomptarget` proper rather than the plugins. I guess this is 
>>> needed for per-kernel specialization? My idea of the rough pseudocode would 
>>> be like this and we wouldn't need a complex class heirarchy. Also I don't 
>>> know if we can skip `ptxas` by giving CUDA the ptx directly, we probably 
>>> will need to invoke `lld` on the command line however right.
>>>
>>>   for each image:
>>> if image is bitcode
>>>   image = compile(image)
>>>register(image)
>>
>> We could handle them in `libomptarget`, but that's gonna require we add 
>> another two interface functions: `is_valid_bitcode_image`, and 
>> `compile_bitcode_image`. It is doable. Handling them in plugin as a separate 
>> module can just reuse the two existing interfaces.
>
> Would we need to consult the plugin? We can just check the `magic` directly, 
> if it's bitcode we just compile it for its triple. If this was wrong then 
> when the plugin gets the compiled image it will error.

I prefer error out at earlier stage, especially if we have a bitcode image, and 
both Nvidia and AMD support JIT, then both NVIDIA and AMD will report a valid 
binary, thus continue compiling the image, initializing the plugin, etc., which 
could give us the wrong results.

>>> Also I don't know if we can skip `ptxas` by giving CUDA the ptx directly, 
>>> we probably will need to invoke `lld` on the command line however right.
>>>
>>>   for each image:
>>> if image is bitcode
>>>   image = compile(image)
>>>register(image)
>>
>> We can give CUDA PTX directly, since the CUDA JIT is to just call `ptxas` 
>> instead of `ptxas -c`, which requires `nvlink` afterwards.
>
> That makes it easier for us, so the only command line tool we need to call is 
> `lld` for AMDGPU.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-05 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:184
+
+  auto AddStream =
+  [&](size_t Task,

jhuber6 wrote:
> tianshilei1992 wrote:
> > jhuber6 wrote:
> > > tianshilei1992 wrote:
> > > > Is there any way that we don't write it to a file here?
> > > Why do we need to invoke LTO here? I figured that we could call the 
> > > backend directly since we have no need to actually link any filies, and 
> > > we may not have a need to run more expensive optimizations when the 
> > > bitcode is already optimized. If you do that then you should be able to 
> > > just use a `raw_svector_ostream` as your output stream and get the 
> > > compiled output written to that buffer.
> > For the purpose of this basic JIT support, we indeed just need backend. 
> > However, since we have the plan for super optimization, etc., having an 
> > optimization pipeline here is also useful.
> We should be able to configure our own optimization pipeline in that case, we 
> might want the extra control as well.
which means we basically rewrite the function `opt` and `backend` in `LTO.cpp`. 
I thought about just invoking backend before, especially using LTO requires us 
to build the resolution table. However, after a second thought, I think it 
would be better to just use LTO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp:184
+
+  auto AddStream =
+  [&](size_t Task,

tianshilei1992 wrote:
> jhuber6 wrote:
> > tianshilei1992 wrote:
> > > jhuber6 wrote:
> > > > tianshilei1992 wrote:
> > > > > Is there any way that we don't write it to a file here?
> > > > Why do we need to invoke LTO here? I figured that we could call the 
> > > > backend directly since we have no need to actually link any filies, and 
> > > > we may not have a need to run more expensive optimizations when the 
> > > > bitcode is already optimized. If you do that then you should be able to 
> > > > just use a `raw_svector_ostream` as your output stream and get the 
> > > > compiled output written to that buffer.
> > > For the purpose of this basic JIT support, we indeed just need backend. 
> > > However, since we have the plan for super optimization, etc., having an 
> > > optimization pipeline here is also useful.
> > We should be able to configure our own optimization pipeline in that case, 
> > we might want the extra control as well.
> which means we basically rewrite the function `opt` and `backend` in 
> `LTO.cpp`. I thought about just invoking backend before, especially using LTO 
> requires us to build the resolution table. However, after a second thought, I 
> think it would be better to just use LTO.
Building the passes isn't too complicated, it would take up the same amount of 
space as the symbol resolutions and has the advantage that we don't need to 
write the output to a file. I could write an implementation for this to see how 
well it works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[clang] d4f1f35 - [clang][Interp][NFC] Move to std::optional

2022-12-05 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-12-05T17:31:49+01:00
New Revision: d4f1f35978c2593f7c52452d699a96899725452e

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

LOG: [clang][Interp][NFC] Move to std::optional

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeEmitter.h
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/lib/AST/Interp/ByteCodeStmtGen.h
clang/lib/AST/Interp/Context.cpp
clang/lib/AST/Interp/Context.h
clang/lib/AST/Interp/EvalEmitter.cpp
clang/lib/AST/Interp/EvalEmitter.h
clang/lib/AST/Interp/InterpBlock.h
clang/lib/AST/Interp/Pointer.h
clang/lib/AST/Interp/Program.cpp
clang/lib/AST/Interp/Program.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.h 
b/clang/lib/AST/Interp/ByteCodeEmitter.h
index e560d0ef38dd..30da06b20250 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.h
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.h
@@ -83,7 +83,7 @@ class ByteCodeEmitter {
   /// Offset of the next local variable.
   unsigned NextLocalOffset = 0;
   /// Location of a failure.
-  llvm::Optional BailLocation;
+  std::optional BailLocation;
   /// Label information for linker.
   llvm::DenseMap LabelOffsets;
   /// Location of label relocations.

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 48d4e98bf2eb..0c2eaac0e4e7 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -21,7 +21,6 @@ using namespace clang::interp;
 
 using APSInt = llvm::APSInt;
 template  using Expected = llvm::Expected;
-template  using Optional = llvm::Optional;
 
 namespace clang {
 namespace interp {
@@ -51,7 +50,7 @@ template  class OptionScope {
   : Ctx(Ctx), OldDiscardResult(Ctx->DiscardResult),
 OldInitFn(std::move(Ctx->InitFn)) {
 Ctx->DiscardResult = NewDiscardResult;
-Ctx->InitFn = llvm::Optional{};
+Ctx->InitFn = std::optional{};
   }
 
   /// Root constructor, setting up compilation state.
@@ -81,7 +80,7 @@ template  class OptionScope {
   /// Old discard flag to restore.
   bool OldDiscardResult;
   /// Old pointer emitter to restore.
-  llvm::Optional OldInitFn;
+  std::optional OldInitFn;
 };
 
 } // namespace interp
@@ -135,8 +134,8 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr 
*CE) {
 
   case CK_IntegralToBoolean:
   case CK_IntegralCast: {
-Optional FromT = classify(SubExpr->getType());
-Optional ToT = classify(CE->getType());
+std::optional FromT = classify(SubExpr->getType());
+std::optional ToT = classify(CE->getType());
 if (!FromT || !ToT)
   return false;
 
@@ -187,9 +186,9 @@ bool ByteCodeExprGen::VisitBinaryOperator(const 
BinaryOperator *BO) {
   }
 
   // Typecheck the args.
-  Optional LT = classify(LHS->getType());
-  Optional RT = classify(RHS->getType());
-  Optional T = classify(BO->getType());
+  std::optional LT = classify(LHS->getType());
+  std::optional RT = classify(RHS->getType());
+  std::optional T = classify(BO->getType());
   if (!LT || !RT || !T) {
 return this->bail(BO);
   }
@@ -267,8 +266,8 @@ bool ByteCodeExprGen::VisitPointerArithBinOp(const 
BinaryOperator *E) {
   (!LHS->getType()->isPointerType() && !RHS->getType()->isPointerType()))
 return false;
 
-  Optional LT = classify(LHS);
-  Optional RT = classify(RHS);
+  std::optional LT = classify(LHS);
+  std::optional RT = classify(RHS);
 
   if (!LT || !RT)
 return false;
@@ -307,7 +306,7 @@ bool ByteCodeExprGen::VisitPointerArithBinOp(const 
BinaryOperator *E) {
 
 template 
 bool ByteCodeExprGen::VisitImplicitValueInitExpr(const 
ImplicitValueInitExpr *E) {
-  if (Optional T = classify(E))
+  if (std::optional T = classify(E))
 return this->emitZero(*T, E);
 
   return false;
@@ -526,8 +525,8 @@ bool ByteCodeExprGen::VisitCompoundAssignOperator(
 const CompoundAssignOperator *E) {
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
-  Optional LT = classify(E->getLHS()->getType());
-  Optional RT = classify(E->getRHS()->getType());
+  std::optional LT = classify(E->getLHS()->getType());
+  std::optional RT = classify(E->getRHS()->getType());
 
   if (!LT || !RT)
 return false;
@@ -591,7 +590,7 @@ bool ByteCodeExprGen::visit(const Expr *E) {
 
 template 
 bool ByteCodeExprGen::visitBool(const Expr *E) {
-  if (Optional T = classify(E->getType())) {
+  if (std::optional T = classify(E->getType())) {
 return visit(E);
   } else {
 return this->bail(E);
@@ -629,7 +628,7 @@ template 
 bool ByteCodeExprGen::dereference(
 const Expr *LV, DerefKind AK, llvm::function_ref Direct,
 llvm::function_ref Indirect) {
-  if (Optional T = classify(LV->getType())) {
+ 

[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-12-05 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 480130.
francii marked an inline comment as not done.
francii added a comment.

Remove -p references


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,4 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,4 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138862: [Clang] Do not set offload kind in a freestanding build

2022-12-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D138862#3955581 , @tra wrote:

> OK. So, we do need a flag, at least for now. I think we'll need a new one, 
> because `-freestanding` will likely do a lot of things we don't actually want 
> on the host side.
> How about `--offload-generic`  or `--[no-]offload-runtime`.

I figured this was fine since we can specify it only for the device if we use 
`-Xopenmp-target=`. But I suppose we are overloading some behavior of 
freestanding here, I'm not exactly sure what `-ffreestanding` implies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138862

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


[PATCH] D138788: [SVE] Change some bfloat lane intrinsics to use i32 immediates

2022-12-05 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:2527
 
-def int_aarch64_sve_bfdot_lane   : SVE_4Vec_BF16_Indexed;
-def int_aarch64_sve_bfmlalb_lane : SVE_4Vec_BF16_Indexed;
-def int_aarch64_sve_bfmlalt_lane : SVE_4Vec_BF16_Indexed;
+def int_aarch64_sve_bfdot_lane   : SVE_4Vec_BF16_Indexed;
+def int_aarch64_sve_bfdot_lane_i32   : SVE_4Vec_BF16_Indexed_I32;

david-arm wrote:
> sdesmalen wrote:
> > do you also want to remove the old intrinsics?
> Good spot! Turns out that not only had I done this wrong, but I'd also missed 
> out upgrades for bfmlalb/t too. :)
Having `_i32` in the name is confusing because it'll come out as `.i32` when 
printed in IR, which looks like a type suffix but in this case it's actually 
part of the name.

With that said, do you have to change the name?  That seems unfortunate given 
this is a bug fix.

If it's absolutely necessary then I suggestion using `_v2` to signify this is 
the second version of this intrinsic.


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

https://reviews.llvm.org/D138788

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


[PATCH] D138511: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

2022-12-05 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

pin~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138511

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks!

I have two major comments and also inline NITs. Not sure if we should block on 
those, just wanted to hear your opinions:

- `InitListExpr` and `CXXParenInitListExpr` have some code in common. Code 
duplication is substantial and I think sharing the common implementation is 
warranted. E.g. if some code would want to change something with `ArrayFiller` 
or make a use of it, the work will probably need to be duplicated. To reiterate 
what I mentioned earlier, I believe deriving `CXXParenInitListExpr` from 
`InitListExpr` is not a very good option, but we might explore other 
possibilities: a base class or factoring out common code in a separate struct. 
I believe this could be done with a follow-up change, though, as the amount of 
changes required does not seem too big, I would be happy with first landing 
this patch and then cleaning up with a follow-up change.
- Did we explore the possibility of modelling this differently and somehow 
avoiding making `CXXParenInitListExpr` an expression. This seems to borrow from 
`InitListExpr`, but maybe for the wrong reasons.  Braced initializers can 
actually occur in expressions positions, e.g. `int a = {123}`. However, 
`CXXParenInistListExpr` cannot occur in expression positions outside 
initializations, e.g. having `CXXFunctionalCastExpr` for 
`aggregate_struct(123)` feels somewhat wrong to me and seems to lead to 
confusing error messages too. Maybe we should model it as a new expression that 
contains both the type and the argument list? I.e. more similar to 
`CXXConstructExpr`?




Comment at: clang/lib/Sema/SemaInit.cpp:5455
+  // All of the initialized entities are explicitly initialized by
+  // expressionse in the CXXParenListInitExpr. The semantic form is the
+  // same as the syntatic form

NIT: s/expressionse/expressions



Comment at: clang/lib/Sema/SemaInit.cpp:9803
+TryOrBuildParenListInitialization(S, Entity, Kind, Args, *this,
+  /*VerifyOnly=*/false);
   }

NIT: add break 



Comment at: clang/lib/Sema/TreeTransform.h:14040
+  ArrayRef InitExprs = E->getInitExprs();
+  if (TransformExprs(reinterpret_cast(InitExprs.data()),
+ InitExprs.size(), true, TransformedInits))

`reinterpret_cast` seems redundant here or am I missing something?



Comment at: clang/lib/Serialization/ASTReaderStmt.cpp:2172
+  VisitExpr(E);
+  unsigned expectedNumExprs = Record.readInt();
+  assert(E->NumExprs == expectedNumExprs &&

NIT: `ExpectedNumExprs`




Comment at: clang/lib/Serialization/ASTReaderStmt.cpp:2181
+E->getTrailingObjects()[I] = Record.readSubExpr();
+  E->updateDependence();
+

NIT: maybe add a comment that dependence does not depend on filler or syntactic 
form. This might be non-obvious for someone who did not look into the 
implementation.

Alternatively, you could run this at the end of this function, it should not be 
confusing to anyone that certain properties get computed *after* the expression 
was fully deserialized. 



Comment at: clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:106
   Cmp() <=> Cmp(), // expected-note-re {{in defaulted three-way 
comparison operator for '{{.*}}Cmp<{{.*}}G2>' first required here}}j
-  // expected-error@#cmp {{no matching conversion for static_cast from 
'void' to 'std::strong_ordering'}}
+  // expected-error@#cmp {{static_cast from 'void' to 
'std::strong_ordering' is not allowed}}
   Cmp() <=> Cmp(), // expected-note-re {{in defaulted three-way 
comparison operator for '{{.*}}Cmp<{{.*}}H>' first required here}}j

Do you have any idea why did this diagnostic change?



Comment at: clang/test/CXX/drs/dr2xx.cpp:161
+void test6(A::S as) { struct f {}; (void) f(as); } // pre20-error {{no 
matching conversion}} pre20-note +{{}}
+// post20-error@-1 {{functional-style cast from 'A::S' to 'f' is not 
allowed}}
   };

This might be related to other diagnostic change.
Why do we see the new behavior here? Do you think we should keep the old 
behavior maybe? 
I feel that both errors are communicating the same thing and probably keeping 
the current state is acceptable, just want to better understand how we got 
there.

It definitely has something to do with the initialization code, but I struggle 
to understand what exactly changed



Comment at: clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp:131
+// pre20-error@-2 {{no matching constructor for initialization of 'B'}}
+// post20-error@-3 {{excess elements in struct initializer}}
+// post20-error@-4 {{excess elements in struct initializer}}

Given how pervasive this error is right now, I feel that we want to add a name 
of the struct to this message.
This case is also a g

[PATCH] D139343: [Driver][PPC] Support -mtune=auto

2022-12-05 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 created this revision.
qiongsiwu1 added reviewers: w2yehia, nemanjai, MaskRay.
qiongsiwu1 added projects: clang, PowerPC.
Herald added subscribers: StephenFan, shchenz, kbarton.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added a subscriber: cfe-commits.

This patch teaches `clang` to recognize the `auto` option for `-mtune`. The 
option is identical to the `mtune` option `native`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139343

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ppc-cpus.c


Index: clang/test/Driver/ppc-cpus.c
===
--- clang/test/Driver/ppc-cpus.c
+++ clang/test/Driver/ppc-cpus.c
@@ -22,3 +22,5 @@
 
 // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | 
FileCheck %s --check-prefix=TUNE
 // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9"
+// RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=auto 2>&1 | 
FileCheck %s --check-prefix=NO_AUTO
+// NO_AUTO-NOT: "-target-cpu" "ppc64" "-tune-cpu" "auto"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1990,7 +1990,8 @@
  ArgStringList &CmdArgs) const {
   if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
 CmdArgs.push_back("-tune-cpu");
-if (strcmp(A->getValue(), "native") == 0)
+if (strcmp(A->getValue(), "native") == 0 ||
+strcmp(A->getValue(), "auto") == 0)
   CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName()));
 else
   CmdArgs.push_back(A->getValue());


Index: clang/test/Driver/ppc-cpus.c
===
--- clang/test/Driver/ppc-cpus.c
+++ clang/test/Driver/ppc-cpus.c
@@ -22,3 +22,5 @@
 
 // RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=pwr9 2>&1 | FileCheck %s --check-prefix=TUNE
 // TUNE: "-target-cpu" "ppc64" "-tune-cpu" "pwr9"
+// RUN: %clang -### -c --target=powerpc64 %s -mcpu=generic -mtune=auto 2>&1 | FileCheck %s --check-prefix=NO_AUTO
+// NO_AUTO-NOT: "-target-cpu" "ppc64" "-tune-cpu" "auto"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1990,7 +1990,8 @@
  ArgStringList &CmdArgs) const {
   if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
 CmdArgs.push_back("-tune-cpu");
-if (strcmp(A->getValue(), "native") == 0)
+if (strcmp(A->getValue(), "native") == 0 ||
+strcmp(A->getValue(), "auto") == 0)
   CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName()));
 else
   CmdArgs.push_back(A->getValue());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-12-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/CodeGen/windows-seh-EHa-CppCondiTemps.cpp:3
 
+// FIXME: this check appears to be miscompiled?
+// XFAIL: *

lebedev.ri wrote:
> tentzen wrote:
> > lebedev.ri wrote:
> > > This test broke once we always started adding (outermost) UB scope for 
> > > nounwind functions.
> > > I don't quite get what is going wrong. It could be a bug in SEH handling.
> > > Can someone who has some idea about that code take a look and suggest a 
> > > fix?
> > > @tentzen ?
> > By definition, non-unwind function I think is for Synchronous EH. So this 
> > Sanitizer check should exclude Asynchronous EH functions, those with option 
> > -fasync-exceptions.
> >  
> I do not understand.
> If the function can unwind, then why is it marked `nounwind`?
> This kind of thing is exactly what i was afraid of with those SEH patches.
clang should not be marking functions "nounwind" in -fasync-exceptions mode; if 
it is, I'd consider that a bug.  (I assume someone just forgot to add a check 
to some code that adds nounwind.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-12-05 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo updated this revision to Diff 480159.
abidmalikwaterloo marked 3 inline comments as done.
abidmalikwaterloo added a comment.

Update the patch based on the feedback and comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
  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
@@ -133,6 +133,18 @@
   return
 }
 
+// CHECK-LABEL: omp_DistributeOp
+func.func @omp_DistributeOp(%lb : index, %ub : index, %step : index, %data_var : memref, %chunk_var : i32) -> () {
+// CHECK: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
+  "omp.distribute" (%lb, %ub, %step) ({
+^bb0(%iv: index):
+ omp.yield 
+  }) {operand_segment_sizes = array} :
+(index, index, index) -> ()
+ 
+ return
+ }
+
 // CHECK-LABEL: omp_wsloop
 func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memref, %linear_var : i32, %chunk_var : i32) -> () {
 
Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -281,6 +281,20 @@
   return success();
 }
 
+//===-===//
+// Verifier for Dristribute Op
+//===-===//
+
+LogicalResult DistributeOp::verify(){
+  if (this->getLowerBound().empty()) 
+return emitOpError() << "empty lowerbound for distribute loop operation";
+  
+  if (this->getUpperBound().empty()) 
+return emitOpError() << "empty upperbound for distribute loop operation";
+  
+  return success();	
+}
+
 /// schedule ::= `schedule` `(` sched-list `)`
 /// sched-list ::= sched-val | sched-val sched-list |
 ///sched-val `,` sched-modifier
@@ -590,7 +604,7 @@
 }
 
 //===--===//
-// WsLoopOp
+// LoopControl
 //===--===//
 
 /// loop-control ::= `(` ssa-id-list `)` `:` type `=`  loop-bounds
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -452,7 +452,7 @@
 def YieldOp : OpenMP_Op<"yield",
 [Pure, ReturnLike, Terminator,
  ParentOneOf<["WsLoopOp", "ReductionDeclareOp",
- "AtomicUpdateOp", "SimdLoopOp"]>]> {
+ "AtomicUpdateOp", "SimdLoopOp","DistributeOp"]>]> {
   let summary = "loop yield and termination operation";
   let description = [{
 "omp.yield" yields SSA values from the OpenMP dialect op region and
@@ -469,6 +469,65 @@
   let assemblyFormat = [{ ( `(` $results^ `:` type($results) `)` )? attr-dict}];
 }
 
+//===--===//
+// 2.9.4.1 distribute Construct
+//===--===//
+
+def DistributeOp : OpenMP_Op<"distribute", [AttrSizedOperandSegments,
+AllTypesMatch<["lowerBound", "upperBound", "step"]>]> {
+  let summary = "distribute loop construct";
+  let description = [{ 
+The distribute construct specifies that the iterations of one or more loop
+will be executed by the initial teams in the context of their implicit 
+tasks. The iterations are distributed across the initial threads of all 
+initial teams that execute the teams region to which the distribute region 
+binds.
+
+The distribute loop construct specifies that the iterations of the loop(s)
+will be executed in parallel by threads in the current context. These
+iterations are spread across threads that already exist in the enclosing
+region. The lower and upper bounds specify a half-open range: the
+range includes the lower bound but does not include the upper bound. If the
+`inclusive` attribute is specified then the upper bound is also included.
+
+// TODO: 	private_var, firstprivate_var and lastprivate_var variables 
+// will be defined later
+
+The `static_dist_schedule` attribute specifies the  schedule for this
+loop, determining how the loop is distributed across the parallel threads.
+The optional `schedule_chunk` associated with this determines further
+controls this distribution.
+
+// TODO: collapse
+  }];
+
+  let arguments = (ins Variadic:$lowerBound,
+ Variadic:$upperBound,
+ Variadic:$step,
+ UnitAttr:$static_dist_schedule,
+ Optional:

[PATCH] D139343: [Driver][PPC] Support -mtune=auto

2022-12-05 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 abandoned this revision.
qiongsiwu1 added a comment.

It is decided that we no longer need this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139343

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


[PATCH] D139172: [clang] Mark CWG554 as N/A

2022-12-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139172

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


[PATCH] D139326: [clang] Add test for CWG952

2022-12-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, though I would appreciate another test (that I expect to pass).




Comment at: clang/test/CXX/drs/dr9xx.cpp:76
+namespace dr952 { // dr952: yes
+struct A {
+  typedef int I; // #dr952-typedef-decl

I wouldn't mind another test case:
```
struct A {
protected:
  static int x;
};
struct B : A {
  friend int get(B) { return x; }
};
```
this was something Richard had pointed out needs to still work as part of the 
reflector discussions of this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139326

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


[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-12-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked 2 inline comments as done.
lebedev.ri added inline comments.



Comment at: clang/test/CodeGen/windows-seh-EHa-CppCondiTemps.cpp:3
 
+// FIXME: this check appears to be miscompiled?
+// XFAIL: *

efriedma wrote:
> lebedev.ri wrote:
> > tentzen wrote:
> > > lebedev.ri wrote:
> > > > This test broke once we always started adding (outermost) UB scope for 
> > > > nounwind functions.
> > > > I don't quite get what is going wrong. It could be a bug in SEH 
> > > > handling.
> > > > Can someone who has some idea about that code take a look and suggest a 
> > > > fix?
> > > > @tentzen ?
> > > By definition, non-unwind function I think is for Synchronous EH. So this 
> > > Sanitizer check should exclude Asynchronous EH functions, those with 
> > > option -fasync-exceptions.
> > >  
> > I do not understand.
> > If the function can unwind, then why is it marked `nounwind`?
> > This kind of thing is exactly what i was afraid of with those SEH patches.
> clang should not be marking functions "nounwind" in -fasync-exceptions mode; 
> if it is, I'd consider that a bug.  (I assume someone just forgot to add a 
> check to some code that adds nounwind.)
My thoughts precisely. @tentzen please fix :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[PATCH] D137020: [clang][AST] Handle variable declaration with unknown typedef in C

2022-12-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseStmt.cpp:177-178
+  case tok::kw___attribute:
+  case tok::kw_const:
+  case tok::kw_volatile:
+  case tok::star:

urazoff wrote:
> aaron.ballman wrote:
> > What about other qualifiers? `_Nullable` and `restrict` and whatnot?
> I think `restrict` can not go just after type name.
It can when you consider typedefs, as in: https://godbolt.org/z/hjK9f3xEc


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

https://reviews.llvm.org/D137020

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-05 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao marked 4 inline comments as done.
ayzhao added a comment.

In D129531#3971392 , @ilya-biryukov 
wrote:

> Thanks!
>
> I have two major comments and also inline NITs. Not sure if we should block 
> on those, just wanted to hear your opinions:
>
> - `InitListExpr` and `CXXParenInitListExpr` have some code in common. Code 
> duplication is substantial and I think sharing the common implementation is 
> warranted. E.g. if some code would want to change something with 
> `ArrayFiller` or make a use of it, the work will probably need to be 
> duplicated. To reiterate what I mentioned earlier, I believe deriving 
> `CXXParenInitListExpr` from `InitListExpr` is not a very good option, but we 
> might explore other possibilities: a base class or factoring out common code 
> in a separate struct. I believe this could be done with a follow-up change, 
> though, as the amount of changes required does not seem too big, I would be 
> happy with first landing this patch and then cleaning up with a follow-up 
> change.
> - Did we explore the possibility of modelling this differently and somehow 
> avoiding making `CXXParenInitListExpr` an expression. This seems to borrow 
> from `InitListExpr`, but maybe for the wrong reasons.  Braced initializers 
> can actually occur in expressions positions, e.g. `int a = {123}`. However, 
> `CXXParenInistListExpr` cannot occur in expression positions outside 
> initializations, e.g. having `CXXFunctionalCastExpr` for 
> `aggregate_struct(123)` feels somewhat wrong to me and seems to lead to 
> confusing error messages too. Maybe we should model it as a new expression 
> that contains both the type and the argument list? I.e. more similar to 
> `CXXConstructExpr`?

As discussed offline, let's keep the current implementation as is for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-05 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 480184.
ayzhao added a comment.

use NumUserSpecifiedExprs instead of syntatic/semantic forms, also address some 
comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  clang/test/CodeGen/paren-list-agg-init.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/PCH/cxx_paren_init.cpp
  clang/test/PCH/cxx_paren_init.h
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1156,7 +1156,7 @@
 
   Parenthesized initialization of aggregates
   https://wg21.link/p0960r3";>P0960R3
-  No
+  Clang 16
 

 https://wg21.link/p1975r0";>P1975R0
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,10 @@
 K = CXCursor_RequiresExpr;
 break;
 
+  case Stmt::CXXParenListInitExprClass:
+K = CXCursor_CXXParenListInitExpr;
+break;
+
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2139,6 +2139,7 @@
   void VisitLambdaExpr(const LambdaExpr *E);
   void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E);
   void VisitRequiresExpr(const RequiresExpr *E);
+  void VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D);
   void VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *D);
   void VisitOMPLoopDirective(const OMPLoopDirective *D);
@@ -3006,6 +3007,9 @@
   for (ParmVarDecl *VD : E->getLocalParameters())
 AddDecl(VD);
 }
+void EnqueueVisitor::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E) {
+  EnqueueChildren(E);
+}
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
   Visit(E->getSyntacticForm());
@@ -5587,6 +5591,8 @@
 return cxstring::createRef("ConceptSpecializationExpr");
   case CXCursor_RequiresExpr:
 return cxstring::createRef("RequiresExpr");
+  case CXCursor_CXXParenListInitExpr:
+return cxstring::createRef("CXXParenListInitExpr");
   case CXCursor_UnexposedStmt:
 return cxstring::createRef("UnexposedStmt");
   case CXCursor_DeclStmt:
Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+// RUN: %clang_cc1 -verify=expected,beforecxx20 -Wc++20-extensions -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 4{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b[20];
+  int &&c; // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 2{{candidate constructor}}
+  A a;
+  int b[20];
+};
+
+struct D : public C, public A {
+  int a;
+};
+
+struct E { // expected-note 3{{candidate constructor}}
+  struct F {
+F(int, int);
+  };
+  int a;
+  F f;
+};
+
+int getint(); // expected-note {{declared here}}
+
+struct F {
+  int a;
+  i

[PATCH] D138958: [clang] Better UX for Clang’s unwind-affecting attributes

2022-12-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

(ping, maybe)

In D138958#3968118 , @lebedev.ri 
wrote:

> I've been thinking, and it seems to me that explicitly opting into
> `__attribute__((nounwind))`-provided semantics should override
> the `__attribute__((nothrow))`/`noexcept` semantics.
> So looks like i should look into exception specification handling.

I've looked, and unless told otherwise, it seems like we
shouldn't add new exception specification for this attribute,
but special-case the attribute where it matters,
but i may be wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138958

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


[PATCH] D139261: [Clang] Modify sanity check assert in AggExprEmitter::VisitInitListExpr to cover anonymous struct in a union GNU extension

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

LGTM with a formatting nit fixed, but you should add a release note for the fix 
when landing.




Comment at: clang/lib/CodeGen/CGExprAgg.cpp:1688
   for (const auto *Field : record->fields())
-assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed");
+assert((Field->isUnnamedBitfield() || 
Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or ananymous 
class allowed");
 #endif

Guessing at the way to solve the 80-col limit issue, but do whatever 
clang-format says.


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

https://reviews.llvm.org/D139261

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


[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-05 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added inline comments.



Comment at: clang/lib/CodeGen/CGExprAgg.cpp:581
+  Expr *filler = nullptr;
+  if (auto *ILE = dyn_cast(ExprToVisit))
+filler = ILE->getArrayFiller();

ayzhao wrote:
> ilya-biryukov wrote:
> > ilya-biryukov wrote:
> > > ayzhao wrote:
> > > > ilya-biryukov wrote:
> > > > > - Should we have a filler for `CXXParenInitListExpr` too?
> > > > >   It seems like an important optimization and could have large effect 
> > > > > on compile times if we don't 
> > > > > 
> > > > > - Same question for semantic and syntactic-form (similar to 
> > > > > `InitListExpr`): should we have it here?
> > > > >   I am not sure if it's semantically required (probably not?), but 
> > > > > that's definitely something that `clang-tidy` and other source tools 
> > > > > will rely on.
> > > > > 
> > > > > We should probably share the code there, I suggest moving it to a 
> > > > > shared base class and using it where appropriate instead of the 
> > > > > derived classes.
> > > > > Should we have a filler for CXXParenInitListExpr too? It seems like 
> > > > > an important optimization and could have large effect on compile 
> > > > > times if we don't
> > > > 
> > > > This feels like premature optimization - presumably, wouldn't this only 
> > > > be an issue with extraordinarily large (say, O(1000)) arrays?
> > > > 
> > > > > Same question for semantic and syntactic-form (similar to 
> > > > > InitListExpr): should we have it here? I am not sure if it's 
> > > > > semantically required (probably not?), but that's definitely 
> > > > > something that clang-tidy and other source tools will rely on
> > > > 
> > > > IIRC this doesn't apply to paren list aggregate expressions, as the 
> > > > syntatic form would be the enclosing `ParenListExpr`.
> > > > This feels like premature optimization - presumably, wouldn't this only 
> > > > be an issue with extraordinarily large (say, O(1000)) arrays?
> > > Yes, this should only happen with large arrays. Normally I would agree, 
> > > but it's surprising that changing `{}` to `()` in the compiler would lead 
> > > to performance degradation.
> > > In that sense, this premature optimization is already implemented, we are 
> > > rather degrading performance for a different syntax to do the same thing.
> > > 
> > > Although we could also land without it, but in that case could you open a 
> > > GH issue and add a FIXME to track the implementation of this particular 
> > > optimization?
> > > This should increase the chances of users finding the root cause of the 
> > > issue if they happen to hit it.
> > > 
> > > > IIRC this doesn't apply to paren list aggregate expressions, as the 
> > > > syntatic form would be the enclosing ParenListExpr.
> > > Do we even have the enclosing `ParenListExpr`? If I dump the AST with 
> > > `clang -fsyntax-only -Xclang=-ast-dump ...`  for the following code:
> > > ```
> > > struct pair { int a; int b = 2; };
> > > int main() {
> > >   pair(1); pair p(1);
> > >   pair b{1}; pair{1};
> > > }
> > > ```
> > > 
> > > I get 
> > > ```
> > > `-FunctionDecl 0x557d79717e98  line:2:5 main 'int ()'
> > >   `-CompoundStmt 0x557d797369d0 
> > > |-CXXFunctionalCastExpr 0x557d79718528  
> > > 'pair':'pair' functional cast to pair 
> > > | `-CXXParenListInitExpr 0x557d79718500  'pair':'pair'
> > > |   |-IntegerLiteral 0x557d79718010  'int' 1
> > > |   `-IntegerLiteral 0x557d79717e18  'int' 2
> > > |-DeclStmt 0x557d79718650 
> > > | `-VarDecl 0x557d79718568  col:17 p 'pair':'pair' 
> > > parenlistinit
> > > |   `-CXXParenListInitExpr 0x557d79718610  'pair':'pair'
> > > | |-IntegerLiteral 0x557d797185d0  'int' 1
> > > | `-IntegerLiteral 0x557d79717e18  'int' 2
> > > |-DeclStmt 0x557d797187d8 
> > > | `-VarDecl 0x557d79718680  col:8 b 'pair':'pair' 
> > > listinit
> > > |   `-InitListExpr 0x557d79718750  'pair':'pair'
> > > | |-IntegerLiteral 0x557d797186e8  'int' 1
> > > | `-CXXDefaultInitExpr 0x557d797187a0  'int'
> > > `-CXXFunctionalCastExpr 0x557d797369a8  'pair':'pair' 
> > > functional cast to pair 
> > >   `-InitListExpr 0x557d79718868  'pair':'pair'
> > > |-IntegerLiteral 0x557d79718800  'int' 1
> > > `-CXXDefaultInitExpr 0x557d797188b8  'int'
> > > ```
> > > It feels like the `ParentListExpr` is replaced during semantic analysis 
> > > and there is no way to get it back. I also tried running `clang-query` 
> > > and trying to `match parenListExpr()` and go 0 results. Is it just 
> > > missing in the AST dump and I run `clang-query` incorrectly or do we 
> > > actually not have the syntactic form of this expression after all?
> > Another important thing to address from the dump: notice how braced 
> > initialization creates `CXXDefaultInitExpr` and `CXXParenListInitExpr` 
> > copies the default argument expression directly. It's really important to 
> > use the former form, here's the example that currently breaks:
>

[PATCH] D129531: [clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values

2022-12-05 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 480189.
ayzhao marked 2 inline comments as done.
ayzhao added a comment.

add missing EOF newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  clang/test/CodeGen/paren-list-agg-init.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/PCH/cxx_paren_init.cpp
  clang/test/PCH/cxx_paren_init.h
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1156,7 +1156,7 @@
 
   Parenthesized initialization of aggregates
   https://wg21.link/p0960r3";>P0960R3
-  No
+  Clang 16
 

 https://wg21.link/p1975r0";>P1975R0
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,10 @@
 K = CXCursor_RequiresExpr;
 break;
 
+  case Stmt::CXXParenListInitExprClass:
+K = CXCursor_CXXParenListInitExpr;
+break;
+
   case Stmt::MSDependentExistsStmtClass:
 K = CXCursor_UnexposedStmt;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2139,6 +2139,7 @@
   void VisitLambdaExpr(const LambdaExpr *E);
   void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E);
   void VisitRequiresExpr(const RequiresExpr *E);
+  void VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D);
   void VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *D);
   void VisitOMPLoopDirective(const OMPLoopDirective *D);
@@ -3006,6 +3007,9 @@
   for (ParmVarDecl *VD : E->getLocalParameters())
 AddDecl(VD);
 }
+void EnqueueVisitor::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E) {
+  EnqueueChildren(E);
+}
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
   Visit(E->getSyntacticForm());
@@ -5587,6 +5591,8 @@
 return cxstring::createRef("ConceptSpecializationExpr");
   case CXCursor_RequiresExpr:
 return cxstring::createRef("RequiresExpr");
+  case CXCursor_CXXParenListInitExpr:
+return cxstring::createRef("CXXParenListInitExpr");
   case CXCursor_UnexposedStmt:
 return cxstring::createRef("UnexposedStmt");
   case CXCursor_DeclStmt:
Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s -fsyntax-only
+// RUN: %clang_cc1 -verify=expected,beforecxx20 -Wc++20-extensions -std=c++20 %s -fsyntax-only
+
+struct A { // expected-note 4{{candidate constructor}}
+  char i;
+  double j;
+};
+
+struct B {
+  A a;
+  int b[20];
+  int &&c; // expected-note {{reference member declared here}}
+};
+
+struct C { // expected-note 2{{candidate constructor}}
+  A a;
+  int b[20];
+};
+
+struct D : public C, public A {
+  int a;
+};
+
+struct E { // expected-note 3{{candidate constructor}}
+  struct F {
+F(int, int);
+  };
+  int a;
+  F f;
+};
+
+int getint(); // expected-note {{declared here}}
+
+struct F {
+  int a;
+  int b = getint(); // expec

[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-12-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

See `clang/lib/Driver/ToolChains/Clang.cpp:6191` `if (TC.SupportsProfiling()) 
{`. You can define `SupportsProfiling` as false for zos. It's a 
`-Wunused-command-line-argument` warning, not an error, but may be good enough. 
 `-p` has already been handled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137756

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


[PATCH] D136176: Implement support for option 'fexcess-precision'.

2022-12-05 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 480198.
zahiraam edited the summary of this revision.
Herald added subscribers: pcwang-thead, nlopes, abrachet, sstefan1, phosek, 
s.egerton, ormris, mstorsjo, simoncook, fedor.sergeev, aheejin, dschuff.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sscalpone.

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

https://reviews.llvm.org/D136176

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/X86/fexcess-precision.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fexcess-precision.c
  precision-12.5.patch

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


[PATCH] D138511: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

2022-12-05 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Please don't ping every day.  We haven't lost track of your patch, we're just 
busy reviewing other things.

This seems reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138511

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


[PATCH] D139360: [clang][dataflow] Support (in)equality operators in `optional` model.

2022-12-05 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, sgatev.
Herald added subscribers: martong, rnkovacs.
Herald added a reviewer: NoQ.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

This patch adds interpretation of the overloaded equality and inequality
operators available for the optional types.

Fixes issue #57253.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139360

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -762,6 +762,29 @@
 constexpr optional make_optional(std::initializer_list il,
 Args&&... args);
 
+template 
+constexpr bool operator==(const optional &lhs, const optional &rhs);
+template 
+constexpr bool operator!=(const optional &lhs, const optional &rhs);
+
+template 
+constexpr bool operator==(const optional &opt, nullopt_t);
+template 
+constexpr bool operator==(nullopt_t, const optional &opt);
+template 
+constexpr bool operator!=(const optional &opt, nullopt_t);
+template 
+constexpr bool operator!=(nullopt_t, const optional &opt);
+
+template 
+constexpr bool operator==(const optional &opt, const U &value);
+template 
+constexpr bool operator==(const T &value, const optional &opt);
+template 
+constexpr bool operator!=(const optional &opt, const U &value);
+template 
+constexpr bool operator!=(const T &value, const optional &opt);
+
 } // namespace std
 )";
 
@@ -984,6 +1007,29 @@
 constexpr optional make_optional(std::initializer_list il,
 Args&&... args);
 
+template 
+constexpr bool operator==(const optional &lhs, const optional &rhs);
+template 
+constexpr bool operator!=(const optional &lhs, const optional &rhs);
+
+template 
+constexpr bool operator==(const optional &opt, nullopt_t);
+template 
+constexpr bool operator==(nullopt_t, const optional &opt);
+template 
+constexpr bool operator!=(const optional &opt, nullopt_t);
+template 
+constexpr bool operator!=(nullopt_t, const optional &opt);
+
+template 
+constexpr bool operator==(const optional &opt, const U &value);
+template 
+constexpr bool operator==(const T &value, const optional &opt);
+template 
+constexpr bool operator!=(const optional &opt, const U &value);
+template 
+constexpr bool operator!=(const T &value, const optional &opt);
+
 } // namespace absl
 )";
 
@@ -1177,6 +1223,29 @@
 constexpr Optional make_optional(std::initializer_list il,
 Args&&... args);
 
+template 
+constexpr bool operator==(const Optional &lhs, const Optional &rhs);
+template 
+constexpr bool operator!=(const Optional &lhs, const Optional &rhs);
+
+template 
+constexpr bool operator==(const Optional &opt, nullopt_t);
+template 
+constexpr bool operator==(nullopt_t, const Optional &opt);
+template 
+constexpr bool operator!=(const Optional &opt, nullopt_t);
+template 
+constexpr bool operator!=(nullopt_t, const Optional &opt);
+
+template 
+constexpr bool operator==(const Optional &opt, const U &value);
+template 
+constexpr bool operator==(const T &value, const Optional &opt);
+template 
+constexpr bool operator!=(const Optional &opt, const U &value);
+template 
+constexpr bool operator!=(const T &value, const Optional &opt);
+
 } // namespace base
 )";
 
@@ -2117,6 +2186,325 @@
   )");
 }
 
+
+TEST_P(UncheckedOptionalAccessTest, EqualityCheckLeftSet) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+void target() {
+  $ns::$optional opt1 = 3;
+  $ns::$optional opt2 = Make<$ns::$optional>();
+
+  if (opt1 == opt2) {
+opt2.value();
+  } else {
+opt2.value(); // [[unsafe]]
+  }
+}
+  )");
+}
+
+TEST_P(UncheckedOptionalAccessTest, EqualityCheckRightSet) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+void target() {
+  $ns::$optional opt1 = 3;
+  $ns::$optional opt2 = Make<$ns::$optional>();
+
+  if (opt2 == opt1) {
+opt2.value();
+  } else {
+opt2.value(); // [[unsafe]]
+  }
+}
+  )");
+}
+
+TEST_P(UncheckedOptionalAccessTest, EqualityCheckVerifySetAfterEq) {
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+void target() {
+  $ns::$optional opt1 = Make<$ns::$optional>();
+  $ns::$optional opt2 = Make<$ns::$optional>();
+
+  if (opt1 == opt2) {
+if (opt1.has_value())
+  opt2.value();
+if (opt2.has_value())
+  opt1.value();
+  }
+}
+  )");
+}
+
+TEST_P(UncheckedOptional

[PATCH] D138337: Add support for kcfi-seal optimization with LTO

2022-12-05 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Can't this be implicit if LTO is being used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138337

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


[PATCH] D139038: [Clang] Don't consider default constructors ineligible if the more constrained constructor is a template

2022-12-05 Thread Roy Jacobson 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 rG7d58c95635cc: [Clang] Don't consider default 
constructors ineligible if the more constrained… (authored by royjacobson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139038

Files:
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/constrained-special-member-functions.cpp


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -225,3 +225,43 @@
   S<2, 2> s2;
 }
 }
+
+namespace GH59206 {
+
+struct A {
+  A() = default; //eligible, second constructor unsatisfied
+  template
+  A(Args&&... args) requires (sizeof...(Args) > 0) {}
+};
+
+struct B {
+  B() = default; //ineligible, second constructor more constrained
+  template
+  B(Args&&... args) requires (sizeof...(Args) == 0) {}
+};
+
+struct C {
+  C() = default; //eligible, but
+  template //also eligible and non-trivial
+  C(Args&&... args) {}
+};
+
+struct D : B {};
+
+static_assert(__is_trivially_copyable(A), "");
+static_assert(__is_trivially_copyable(B), "");
+static_assert(__is_trivially_copyable(C), "");
+static_assert(__is_trivially_copyable(D), "");
+
+// FIXME: Update when https://github.com/llvm/llvm-project/issues/59206 is
+// resolved.
+static_assert(!__is_trivial(A), "");
+static_assert(!__is_trivial(B), "");
+static_assert(!__is_trivial(C), "");
+static_assert(__is_trivial(D), "");
+static_assert(__is_trivially_constructible(A), "");
+static_assert(__is_trivially_constructible(B), "");
+static_assert(__is_trivially_constructible(C), "");
+static_assert(__is_trivially_constructible(D), "");
+
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -18193,8 +18193,11 @@
   CXXMethodDecl *M1,
   CXXMethodDecl *M2,
   Sema::CXXSpecialMember CSM) {
+  // We don't want to compare templates to non-templates: See
+  // https://github.com/llvm/llvm-project/issues/59206
   if (CSM == Sema::CXXDefaultConstructor)
-return true;
+return bool(M1->getDescribedFunctionTemplate()) ==
+   bool(M2->getDescribedFunctionTemplate());
   if (!Context.hasSameType(M1->getParamDecl(0)->getType(),
M2->getParamDecl(0)->getType()))
 return false;
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -1378,7 +1378,11 @@
 }
 
 void CXXRecordDecl::addedEligibleSpecialMemberFunction(const CXXMethodDecl *MD,
-   unsigned SMKind) {
+   unsigned SMKind) {
+  // FIXME: We shouldn't change DeclaredNonTrivialSpecialMembers if `MD` is
+  // a function template, but this needs CWG attention before we break ABI.
+  // See https://github.com/llvm/llvm-project/issues/59206
+
   if (const auto *DD = dyn_cast(MD)) {
 if (DD->isUserProvided())
   data().HasIrrelevantDestructor = false;


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -225,3 +225,43 @@
   S<2, 2> s2;
 }
 }
+
+namespace GH59206 {
+
+struct A {
+  A() = default; //eligible, second constructor unsatisfied
+  template
+  A(Args&&... args) requires (sizeof...(Args) > 0) {}
+};
+
+struct B {
+  B() = default; //ineligible, second constructor more constrained
+  template
+  B(Args&&... args) requires (sizeof...(Args) == 0) {}
+};
+
+struct C {
+  C() = default; //eligible, but
+  template //also eligible and non-trivial
+  C(Args&&... args) {}
+};
+
+struct D : B {};
+
+static_assert(__is_trivially_copyable(A), "");
+static_assert(__is_trivially_copyable(B), "");
+static_assert(__is_trivially_copyable(C), "");
+static_assert(__is_trivially_copyable(D), "");
+
+// FIXME: Update when https://github.com/llvm/llvm-project/issues/59206 is
+// resolved.
+static_assert(!__is_trivial(A), "");
+static_assert(!__is_trivial(B), "");
+static_assert(!__is_trivial(C), "");
+static_assert(__is_trivial(D), "");
+static_assert(__is_trivially_constructible(A), "");
+static_assert(__is_trivially_constructible(B), "");
+static_assert(__is_trivially_constructible(C), "");
+static_assert(__is_trivially_constructible(D), "");
+
+}
Index: clang/lib/Sema/SemaDecl.cpp

[clang] 7d58c95 - [Clang] Don't consider default constructors ineligible if the more constrained constructor is a template

2022-12-05 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2022-12-05T23:02:37+02:00
New Revision: 7d58c95635cce63ce6acd43c953b57f10bf5c686

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

LOG: [Clang] Don't consider default constructors ineligible if the more 
constrained constructor is a template

Partially solves https://github.com/llvm/llvm-project/issues/59206:

We now mark trivial constructors as eligible even if there's a more constrained 
templated default constructor. Although technically non-conformant, this solves 
problems with pretty reasonable uses cases like
```
template
struct Foo {
constexpr Foo() = default;

template
Foo(Ts... vals) requires(sizeof...(Ts) == n) {}
};
```
where we currently consider the default constructor to be ineligible and 
therefor inheriting/containing classes have non trivial constructors. This is 
aligned with GCC: 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c75ebe76ae12ac4020f20a24f34606a594a40d15

This doesn't change `__is_trivial`. Although we're technically standard 
conformant in this regard, GCC/MSVC exhibit different behaviors that seem to 
make more sense. An issue has been filed to CWG and we await their response.

Reviewed By: erichkeane, #clang-language-wg

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

Added: 


Modified: 
clang/lib/AST/DeclCXX.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/constrained-special-member-functions.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index bc7589e418f2c..603075702a837 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1378,7 +1378,11 @@ void 
CXXRecordDecl::addedSelectedDestructor(CXXDestructorDecl *DD) {
 }
 
 void CXXRecordDecl::addedEligibleSpecialMemberFunction(const CXXMethodDecl *MD,
-   unsigned SMKind) {
+   unsigned SMKind) {
+  // FIXME: We shouldn't change DeclaredNonTrivialSpecialMembers if `MD` is
+  // a function template, but this needs CWG attention before we break ABI.
+  // See https://github.com/llvm/llvm-project/issues/59206
+
   if (const auto *DD = dyn_cast(MD)) {
 if (DD->isUserProvided())
   data().HasIrrelevantDestructor = false;

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 96ea3fb402e74..0b6e2e5564870 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -18193,8 +18193,11 @@ static bool 
AreSpecialMemberFunctionsSameKind(ASTContext &Context,
   CXXMethodDecl *M1,
   CXXMethodDecl *M2,
   Sema::CXXSpecialMember CSM) {
+  // We don't want to compare templates to non-templates: See
+  // https://github.com/llvm/llvm-project/issues/59206
   if (CSM == Sema::CXXDefaultConstructor)
-return true;
+return bool(M1->getDescribedFunctionTemplate()) ==
+   bool(M2->getDescribedFunctionTemplate());
   if (!Context.hasSameType(M1->getParamDecl(0)->getType(),
M2->getParamDecl(0)->getType()))
 return false;

diff  --git a/clang/test/SemaCXX/constrained-special-member-functions.cpp 
b/clang/test/SemaCXX/constrained-special-member-functions.cpp
index 33ed4050553b8..69d50eb04c572 100644
--- a/clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ b/clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -225,3 +225,43 @@ void func() {
   S<2, 2> s2;
 }
 }
+
+namespace GH59206 {
+
+struct A {
+  A() = default; //eligible, second constructor unsatisfied
+  template
+  A(Args&&... args) requires (sizeof...(Args) > 0) {}
+};
+
+struct B {
+  B() = default; //ineligible, second constructor more constrained
+  template
+  B(Args&&... args) requires (sizeof...(Args) == 0) {}
+};
+
+struct C {
+  C() = default; //eligible, but
+  template //also eligible and non-trivial
+  C(Args&&... args) {}
+};
+
+struct D : B {};
+
+static_assert(__is_trivially_copyable(A), "");
+static_assert(__is_trivially_copyable(B), "");
+static_assert(__is_trivially_copyable(C), "");
+static_assert(__is_trivially_copyable(D), "");
+
+// FIXME: Update when https://github.com/llvm/llvm-project/issues/59206 is
+// resolved.
+static_assert(!__is_trivial(A), "");
+static_assert(!__is_trivial(B), "");
+static_assert(!__is_trivial(C), "");
+static_assert(__is_trivial(D), "");
+static_assert(__is_trivially_constructible(A), "");
+static_assert(__is_trivially_constructible(B), "");
+static_assert(__is_trivially_constructible(C), "");
+static_assert(__is_trivially_constructible(D), "");
+
+}



___
cfe-commits mailing list
cfe-commits@l

[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-05 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 480217.
schittir added a comment.

Move the assert to after the branches that handle the cases where Initializer 
may be null


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

https://reviews.llvm.org/D139148

Files:
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5925,6 +5925,8 @@
 return;
   }
 
+  assert(Initializer && "Intializer must be non-null");
+
   // Determine whether we should consider writeback conversions for
   // Objective-C ARC.
   bool allowObjCWritebackConversion = S.getLangOpts().ObjCAutoRefCount &&


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5925,6 +5925,8 @@
 return;
   }
 
+  assert(Initializer && "Intializer must be non-null");
+
   // Determine whether we should consider writeback conversions for
   // Objective-C ARC.
   bool allowObjCWritebackConversion = S.getLangOpts().ObjCAutoRefCount &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139360: [clang][dataflow] Support (in)equality operators in `optional` model.

2022-12-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun 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/D139360/new/

https://reviews.llvm.org/D139360

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


[PATCH] D139137: add floor library function

2022-12-05 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 480218.
bob80905 added a comment.

- update with clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139137

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/floor.hlsl

Index: clang/test/CodeGenHLSL/builtins/floor.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/floor.hlsl
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+using hlsl::floor;
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.floor.f16(
+// NO_HALF: define noundef float @"?test_floor_half@@YA$halff@$halff@@Z"(
+// NO_HALF: call float @llvm.floor.f32(float %0)
+half test_floor_half ( half p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.floor.v2f16(
+// NO_HALF: define noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.floor.v2f32(
+half2 test_floor_half2 ( half2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.floor.v3f16(
+// NO_HALF: define noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.floor.v3f32(
+half3 test_floor_half3 ( half3 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.floor.v4f16(
+// NO_HALF: define noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.floor.v4f32(
+half4 test_floor_half4 ( half4 p0 ) {
+  return floor ( p0 );
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.floor.f32(
+float test_floor_float ( float p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.floor.v2f32(
+float2 test_floor_float2 ( float2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.floor.v3f32(
+float3 test_floor_float3 ( float3 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <4 x float> @
+// CHECK: call <4 x float> @llvm.floor.v4f32(
+float4 test_floor_float4 ( float4 p0 ) {
+  return floor ( p0 );
+}
+
+// CHECK: define noundef double @
+// CHECK: call double @llvm.floor.f64(
+double test_floor_double ( double p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <2 x double> @
+// CHECK: call <2 x double> @llvm.floor.v2f64(
+double2 test_floor_double2 ( double2 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <3 x double> @
+// CHECK: call <3 x double> @llvm.floor.v3f64(
+double3 test_floor_double3 ( double3 p0 ) {
+  return floor ( p0 );
+}
+// CHECK: define noundef <4 x double> @
+// CHECK: call <4 x double> @llvm.floor.v4f64(
+double4 test_floor_double4 ( double4 p0 ) {
+  return floor ( p0 );
+}
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -101,6 +101,36 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
 double4 ceil(double4);
 
+// floor builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half floor(half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half2 floor(half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half3 floor(half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+half4 floor(half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) float
+floor(float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float2 floor(float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float3 floor(float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+float4 floor(float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) double
+floor(double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double2 floor(double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double3 floor(double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_floor)))
+double4 floor(double4);
+
 // cos builtins
 #ifdef __HLSL_ENABLE_16_BIT
 __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) half cos(half);
__

[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-05 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added a comment.



> Perhaps the` assert` should be added after line 5926 above.

Done.

> I think the checks for `Initializer` being non-null following the addition of 
> an `assert` should be removed.

I don't see any after this point.


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

https://reviews.llvm.org/D139148

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


[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-05 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added a comment.

In D139148#3969383 , @tahonermann 
wrote:

> When committing changes to address Coverity reported issues, I think it would 
> be useful to include the Coverity analysis in the commit message. A textual 
> representation can be obtained using `cov-format-errors --emacs-style` from 
> the command line with access to the intermediate directory. I'm not sure if a 
> textual representation can be obtained through the Coverity UI though.

Couldn't find a way to do this via the UI, so I am trying the command line way.


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

https://reviews.llvm.org/D139148

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


[PATCH] D138337: Add support for kcfi-seal optimization with LTO

2022-12-05 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen added a comment.

In D138337#3972009 , @pcc wrote:

> Can't this be implicit if LTO is being used?

I would prefer to keep this behind a flag (similarly to `-mibt-seal`), so we 
can better control when and where the optimization enabled. For example, 
enabling this implicitly would currently break LTO+KCFI kernel builds as the 
kernel has global functions that are not address-taken in C code, but still end 
up being indirect called because their addresses were taken in assembly code 
that wasn't visible to LTO (e.g. arm64's `alternative_cb` mechanism).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138337

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


[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-05 Thread Kevin Athey via Phabricator via cfe-commits
kda added a comment.

Is there a risk of this being too strict for standard C?

Should there be a test case for our specific problem?  (C calling C++)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139296

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


[PATCH] D137996: Add support for a backdoor driver option that enables emitting header usage information in JSON to a file

2022-12-05 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5660
+"-header-include-filtering=" +
+std::string(D.CCPrintHeadersFiltering ? "on" : "off")));
   }

Let's change "on" to something that won't interfere with potential future 
filters. How about "no-transitive-system"? (or "only-direct-system" if that 
better fits the semantics)

Same for the command-line counterpart.



Comment at: clang/lib/Frontend/HeaderIncludeGen.cpp:161
+  case HIF_Textual: {
+assert(!DepOpts.HeaderIncludeFiltering &&
+   "header filtering is currently always disabled when output format 
is"

I don't think asserting on invalid user input is a good strategy. Let's emit a 
diagnostic and exit gracefully instead.



Comment at: clang/tools/driver/driver.cpp:278
+(TheDriver.CCPrintHeadersFormat == HIF_JSON && !Filtering)) {
+  llvm::errs()
+  << "error: unsupported configuration: "

This should probably be a proper diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137996

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


[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

(-Wglobal-constructors warning is still not implemented.)




Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:572
 PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
+  } else if (D->hasConstantInitialization() && !(D->hasAttr())) 
{
+OrderGlobalInitsOrStermFinalizers Key(201,

How is ConstInitAttr relevant here?



Comment at: clang/test/Sema/dllimport.c:41
 // Address of variables can't be used for initialization in C language modes.
-int *VarForInit = &GlobalDecl; // expected-error{{initializer element is not a 
compile-time constant}}
+int *VarForInit = &GlobalDecl;
 

Like I mentioned before, we might want to restrict this feature to C++.


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

https://reviews.llvm.org/D137107

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


[libunwind] 96d6399 - Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"

2022-12-05 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-12-05T22:20:51Z
New Revision: 96d63993dd3698bbf2d6a83c035cd05faed7317b

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

LOG: Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"

This reverts commit bec8a372fc0db95852748691c0f4933044026b25.

This causes many of these errors to appear when rebuilding runtimes part
of fuchsia's toolchain:

ld.lld: error:
/usr/local/google/home/paulkirth/llvm-upstream/build/lib/x86_64-unknown-linux-gnu/libunwind.a(libunwind.cpp.o)
is incompatible with elf64-x86-64

This can be reproduced by making a complete toolchain, saving any source
file with no changes, then rerunning ninja distribution.

Added: 


Modified: 
compiler-rt/cmake/config-ix.cmake
libc/lib/CMakeLists.txt
libcxx/CMakeLists.txt
libcxx/docs/BuildingLibcxx.rst
libcxx/lib/abi/CMakeLists.txt
libcxx/test/CMakeLists.txt
libcxxabi/CMakeLists.txt
libcxxabi/test/CMakeLists.txt
libunwind/CMakeLists.txt
libunwind/test/CMakeLists.txt
llvm/cmake/modules/LLVMExternalProjectUtils.cmake
llvm/runtimes/CMakeLists.txt
runtimes/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index 9eb48b8f2ba5..fd7daa50bdd9 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -689,8 +689,8 @@ else()
   set(CAN_SYMBOLIZE 1)
 endif()
 
-find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_TARGET_TRIPLE}-ld.bfd ld.bfd DOC 
"GNU ld")
-find_program(GOLD_EXECUTABLE NAMES ${LLVM_TARGET_TRIPLE}-ld.gold ld.gold DOC 
"GNU gold")
+find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd 
ld.bfd DOC "GNU ld")
+find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold 
ld.gold DOC "GNU gold")
 
 if(COMPILER_RT_SUPPORTED_ARCH)
   list(REMOVE_DUPLICATES COMPILER_RT_SUPPORTED_ARCH)

diff  --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt
index 1080fdf00931..b7eb0a133a17 100644
--- a/libc/lib/CMakeLists.txt
+++ b/libc/lib/CMakeLists.txt
@@ -10,7 +10,7 @@ set_target_properties(
 )
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
-  set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE})
+  set(LIBC_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
 else()
   set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX})
 endif()

diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 437c4b2f87a0..454caedcdf3f 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -413,12 +413,12 @@ set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output 
name for the shared lib
 set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static 
libc++ runtime library.")
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-  set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_TARGET_TRIPLE})
+  set(LIBCXX_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
   set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
-  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LLVM_TARGET_TRIPLE}/c++/v1")
-  set(LIBCXX_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE} CACHE PATH
+  set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR 
"${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+  set(LIBCXX_INSTALL_LIBRARY_DIR 
lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
   "Path where built libc++ libraries should be installed.")
-  set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR 
"${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_TARGET_TRIPLE}/c++/v1" CACHE PATH
+  set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR 
"${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
   "Path where target-specific libc++ headers should be installed.")
   if(LIBCXX_LIBDIR_SUBDIR)
 string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})

diff  --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index 5d51088f71ad..59c695efe44e 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -281,7 +281,7 @@ libc++ specific options
 .. option:: LIBCXX_INSTALL_INCLUDE_TARGET_DIR:PATH
 
   **Default**: ``include/c++/v1`` or
-  ``include/${LLVM_TARGET_TRIPLE}/c++/v1``
+  ``include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1``
 
   Path where target-specific libc++ headers should be installed. If a relative
   path, relative to ``CMAKE_INSTALL_PREFIX``.

diff  --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt
index a40794c54c3e..7c08bd06c50b 100644
--- a/libcxx/lib/abi/CMakeLists.txt
+++ b/libcxx/lib/abi/CMakeLists.txt
@@ -43,7 +43,7 @@ endfunction()
 if (CMAKE_CXX_COMPILER_TARGET)
   set(triple "${CMAKE_CXX_COMPILER_TARGET}")
 else()
-  set(triple "${L

[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D139296#3972142 , @kda wrote:

> Is there a risk of this being too strict for standard C?
>
> Should there be a test case for our specific problem?  (C calling C++)

Probably not. It's cross module mismatch. To reproduce we need two module and 
one of them will do about the same as the current msan-param-retval.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139296

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


[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-05 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

> I don't see any after this point.

You're right! I thought I had seen some, but upon checking, I agree. That is a 
good sign we're on the right path!


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

https://reviews.llvm.org/D139148

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


  1   2   >