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

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

I found that there are a few more patterns that can be salvaged. Will create a 
patch for them.




Comment at: llvm/test/Transforms/InstCombine/and.ll:898
 ; CHECK-NEXT:[[Y:%.*]] = icmp ugt i72 [[C:%.*]], 42
-; CHECK-NEXT:[[AND:%.*]] = and i1 [[X]], [[Y]]
 ; CHECK-NEXT:ret i1 [[AND]]

This can be resurrected.



Comment at: llvm/test/Transforms/InstCombine/and.ll:1033
 ; CHECK-NEXT:[[Y:%.*]] = icmp ugt i32 [[C:%.*]], 42
-; CHECK-NEXT:[[AND:%.*]] = and i1 [[Y]], [[X_INV]]
 ; CHECK-NEXT:ret i1 [[AND]]

This can be resurrected as well.



Comment at: llvm/test/Transforms/InstCombine/and2.ll:51
-; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP1]], [[B:%.*]]
-; CHECK-NEXT:ret i1 [[TMP2]]
 ;

This one too



Comment at: llvm/test/Transforms/PGOProfile/chr.ll:1374
 ; CHECK-NEXT:[[V0:%.*]] = icmp eq i32 [[Z:%.*]], 0
-; CHECK-NEXT:[[V3:%.*]] = and i1 [[V0]], [[PRED:%.*]]
 ; CHECK-NEXT:br i1 [[V3]], label [[BB0:%.*]], label [[BB1:%.*]], !prof !16

This one as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D101595: [Clang][OpenMP] Allow unified_shared_memory for Pascal-generation GPUs.

2021-05-01 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 342190.
Meinersbur edited the summary of this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

- Fix test case

Will wait for D101498  is resolved, otherwise 
I cannot test this anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101595

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/requires_codegen.cpp


Index: clang/test/OpenMP/requires_codegen.cpp
===
--- clang/test/OpenMP/requires_codegen.cpp
+++ clang/test/OpenMP/requires_codegen.cpp
@@ -8,9 +8,9 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_50 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_52 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_53 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_60 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_61 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_62 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_60 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_61 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_62 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_70 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_72 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda 
-fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_75 -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll 
-DREGION_DEVICE_NO_ERR
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -4441,10 +4441,7 @@
   case CudaArch::SM_37:
   case CudaArch::SM_50:
   case CudaArch::SM_52:
-  case CudaArch::SM_53:
-  case CudaArch::SM_60:
-  case CudaArch::SM_61:
-  case CudaArch::SM_62: {
+  case CudaArch::SM_53: {
 SmallString<256> Buffer;
 llvm::raw_svector_ostream Out(Buffer);
 Out << "Target architecture " << CudaArchToString(Arch)
@@ -4452,6 +4449,9 @@
 CGM.Error(Clause->getBeginLoc(), Out.str());
 return;
   }
+  case CudaArch::SM_60:
+  case CudaArch::SM_61:
+  case CudaArch::SM_62:
   case CudaArch::SM_70:
   case CudaArch::SM_72:
   case CudaArch::SM_75:


Index: clang/test/OpenMP/requires_codegen.cpp
===
--- clang/test/OpenMP/requires_codegen.cpp
+++ clang/test/OpenMP/requires_codegen.cpp
@@ -8,9 +8,9 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_50 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple 

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

2021-05-01 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added a comment.
This revision is now accepted and ready to land.

Wow these are really a lot of instructions!




Comment at: clang/test/Headers/wasm.c:2
+// REQUIRES: webassembly-registered-target
 // expected-no-diagnostics
 

Now that we have `CHECK` lines, we don't need this



Comment at: clang/test/Headers/wasm.c:1060-1069
+// CHECK-LABEL: test_i64x2_abs:
+// CHECK:  local.get 0{{$}}
+// CHECK-NEXT: local.get 0{{$}}
+// CHECK-NEXT: i32.const 63{{$}}
+// CHECK-NEXT: i64x2.shr_s{{$}}
+// CHECK-NEXT: local.tee 1{{$}}
+// CHECK-NEXT: i64x2.add{{$}}

Why can't this be done in a single instruction and what is the `FIXME` for? 
Maybe a bit of more explanation would help.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101684

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


[PATCH] D101654: [HIP] Fix device lib selection

2021-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc58a6a6fb411: [HIP] Fix device lib selection (authored by 
yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101654

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/CodeGenCUDA/correctly-rounded-div.cu
  clang/test/Driver/hip-device-libs.hip

Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -113,6 +113,30 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,INST
 
+// Test -fast-math
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -ffast-math --rocm-path=%S/Inputs/rocm \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=FAST
+
+// Test -ffinite-math-only
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -ffinite-math-only --rocm-path=%S/Inputs/rocm \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=FINITE
+
+// Test -funsafe-math-optimizations
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -funsafe-math-optimizations --rocm-path=%S/Inputs/rocm \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=UNSAFE
+
+// Test -fno-hip-fp32-correctly-rounded-divide-sqrt
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -fno-hip-fp32-correctly-rounded-divide-sqrt \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=DIVSQRT
+
 // ALL-NOT: error:
 // ALL: {{"[^"]*clang[^"]*"}}
 // ALL-SAME: "-mlink-builtin-bitcode" "{{.*}}hip.bc"
@@ -128,3 +152,23 @@
 // ALL-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_wavefrontsize64_on.bc"
 // ALL-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_isa_version_{{[0-9]+}}.bc"
 // INST-SAME: "-mlink-builtin-bitcode" "{{.*}}instrument.bc"
+
+// FAST: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
+// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
+// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
+
+// FINITE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
+// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
+// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
+
+// UNSAFE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
+// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
+// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
+
+// DIVSQRT: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
+// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
+// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_off.bc"
Index: clang/test/CodeGenCUDA/correctly-rounded-div.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/correctly-rounded-div.cu
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple -amdgcn-amd-amdhsa \
+// RUN:  -target-cpu gfx906 -fcuda-is-device -x hip \
+// RUN:  | FileCheck --check-prefixes=COMMON,CRDIV %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple -amdgcn-amd-amdhsa \
+// RUN:  -target-cpu gfx906 -fcuda-is-device -x hip \
+// RUN:  -fno-hip-fp32-correctly-rounded-divide-sqrt \
+// RUN:  | FileCheck --check-prefixes=COMMON,NCRDIV %s
+
+#include "Inputs/cuda.h"
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+// COMMON-LABEL: @_Z11spscalardiv
+// COMMON: fdiv{{.*}},
+// NCRDIV: !fpmath ![[MD:[0-9]+]]
+// CRDIV-NOT: !fpmath
+__device__ float spscalardiv(float a, float b) {
+  return a / b;
+}
+
+// COMMON-LABEL: @_Z11spvectordiv
+// COMMON: fdiv{{.*}},
+// NCRDIV: !fpmath ![[MD]]
+// CRDIV-NOT: !fpmath
+__device__ float4 spvectordiv(float4 a, float4 b) {
+  return a / b;
+}
+
+// COMMON-LABEL: @_Z11dpscalardiv
+// COMMON-NOT: !fpmath
+__device__ double dpscalardiv(double a, double b) {
+  return a / b;
+}
+
+// NCRDIV: ![[MD]] = !{float 2.50e+00}
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp

[clang] c58a6a6 - [HIP] Fix device lib selection

2021-05-01 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-05-01T20:31:11-04:00
New Revision: c58a6a6fb4110ee1ffd0e45ad98872e55855b310

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

LOG: [HIP] Fix device lib selection

Choose optimized device lib bitcode by fp options
for performance.

Reviewed by: Artem Belevich, Fangrui Song

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

Added: 
clang/test/CodeGenCUDA/correctly-rounded-div.cu

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-device-libs.hip

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index e0bfcf6ef3e4c..4b1ff8e70afd2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -172,7 +172,8 @@ CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug 
info should contain
 CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
 CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is 
defined.
-CODEGENOPT(CorrectlyRoundedDivSqrt, 1, 0) ///< 
-cl-fp32-correctly-rounded-divide-sqrt
+CODEGENOPT(OpenCLCorrectlyRoundedDivSqrt, 1, 0) ///< 
-cl-fp32-correctly-rounded-divide-sqrt
+CODEGENOPT(HIPCorrectlyRoundedDivSqrt, 1, 1) ///< 
-fno-hip-fp32-correctly-rounded-divide-sqrt
 CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get 
unique names.
 CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using 
profile information.
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a8a7177c82cc9..ea1c861f4ac35 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -834,7 +834,7 @@ def cl_denorms_are_zero : Flag<["-"], 
"cl-denorms-are-zero">, Group;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], 
"cl-fp32-correctly-rounded-divide-sqrt">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. Specify that single precision floating-point divide 
and sqrt used in the program source are correctly rounded.">,
-  MarshallingInfoFlag>;
+  MarshallingInfoFlag>;
 def cl_uniform_work_group_size : Flag<["-"], "cl-uniform-work-group-size">, 
Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Defines that the global work-size be a multiple of 
the work-group size specified to clEnqueueNDRangeKernel">,
   MarshallingInfoFlag>;
@@ -939,6 +939,13 @@ defm hip_new_launch_api : BoolFOption<"hip-new-launch-api",
   LangOpts<"HIPUseNewLaunchAPI">, DefaultFalse,
   PosFlag, NegFlag,
   BothFlags<[], " new kernel launching API for HIP">>;
+defm hip_fp32_correctly_rounded_divide_sqrt : 
BoolFOption<"hip-fp32-correctly-rounded-divide-sqrt",
+  CodeGenOpts<"HIPCorrectlyRoundedDivSqrt">, DefaultTrue,
+  PosFlag,
+  NegFlag,
+  BothFlags<[], " that single precision floating-point divide and sqrt used in 
"
+  "the program source are correctly rounded (HIP device compilation only)">>,
+  ShouldParseIf;
 defm gpu_allow_device_init : BoolFOption<"gpu-allow-device-init",
   LangOpts<"GPUAllowDeviceInit">, DefaultFalse,
   PosFlag, NegFlag,

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 42d07c1f5233f..b469a4454f158 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3216,8 +3216,10 @@ Value *ScalarExprEmitter::EmitDiv(const BinOpInfo ) {
 llvm::Value *Val;
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Ops.FPFeatures);
 Val = Builder.CreateFDiv(Ops.LHS, Ops.RHS, "div");
-if (CGF.getLangOpts().OpenCL &&
-!CGF.CGM.getCodeGenOpts().CorrectlyRoundedDivSqrt) {
+if ((CGF.getLangOpts().OpenCL &&
+ !CGF.CGM.getCodeGenOpts().OpenCLCorrectlyRoundedDivSqrt) ||
+(CGF.getLangOpts().HIP && CGF.getLangOpts().CUDAIsDevice &&
+ !CGF.CGM.getCodeGenOpts().HIPCorrectlyRoundedDivSqrt)) {
   // OpenCL v1.1 s7.4: minimum accuracy of single precision / is 2.5ulp
   // OpenCL v1.2 s5.6.4.2: The -cl-fp32-correctly-rounded-divide-sqrt
   // build option allows an application to specify that single precision

diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index 126eb65e3c4db..e483102593e13 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -404,11 +404,17 @@ HIPToolChain::getHIPDeviceLibs(const llvm::opt::ArgList 
) const {
 bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
 

[clang] 1fcf924 - [Cuda] Internalize a struct and a global variable

2021-05-01 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-05-01T16:24:39-07:00
New Revision: 1fcf9247de05bfd960a35c691b9cc47b6a94cd2b

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

LOG: [Cuda] Internalize a struct and a global variable

Added: 


Modified: 
clang/lib/Basic/Cuda.cpp

Removed: 




diff  --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 29c09915f631a..da3bbe110d107 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -57,18 +57,20 @@ CudaVersion CudaStringToVersion(const llvm::Twine ) {
   .Default(CudaVersion::UNKNOWN);
 }
 
+namespace {
 struct CudaArchToStringMap {
   CudaArch arch;
   const char *arch_name;
   const char *virtual_arch_name;
 };
+} // namespace
 
 #define SM2(sm, ca)
\
   { CudaArch::SM_##sm, "sm_" #sm, ca }
 #define SM(sm) SM2(sm, "compute_" #sm)
 #define GFX(gpu)   
\
   { CudaArch::GFX##gpu, "gfx" #gpu, "compute_amdgcn" }
-CudaArchToStringMap arch_names[] = {
+static const CudaArchToStringMap arch_names[] = {
 // clang-format off
 {CudaArch::UNUSED, "", ""},
 SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi



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


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

2021-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 342182.
yaxunl edited the summary of this revision.
yaxunl added a comment.
Herald added a subscriber: dang.

added option -fhip-bundle-device-output


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

https://reviews.llvm.org/D101630

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -117,6 +117,9 @@
 /// The index of the host input in the list of inputs.
 static unsigned HostInputIndex = ~0u;
 
+/// Whether not having host target is allowed.
+static bool AllowNoHost = false;
+
 /// Path to the current binary.
 static std::string BundlerExecutable;
 
@@ -857,9 +860,10 @@
   }
 
   // Get the file handler. We use the host buffer as reference.
-  assert(HostInputIndex != ~0u && "Host input index undefined??");
+  assert((HostInputIndex != ~0u || AllowNoHost) &&
+ "Host input index undefined??");
   Expected> FileHandlerOrErr =
-  CreateFileHandler(*InputBuffers[HostInputIndex]);
+  CreateFileHandler(*InputBuffers[AllowNoHost ? 0 : HostInputIndex]);
   if (!FileHandlerOrErr)
 return FileHandlerOrErr.takeError();
 
@@ -1126,6 +1130,7 @@
   // have exactly one host target.
   unsigned Index = 0u;
   unsigned HostTargetNum = 0u;
+  bool HIPOnly = true;
   llvm::DenseSet ParsedTargets;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
@@ -1167,12 +1172,21 @@
   HostInputIndex = Index;
 }
 
+if (Kind != "hip" && Kind != "hipv4")
+  HIPOnly = false;
+
 ++Index;
   }
 
+  // HIP uses clang-offload-bundler to bundle device-only compilation results
+  // for multiple GPU archs, therefore allow no host target if all entries
+  // are for HIP.
+  AllowNoHost = HIPOnly;
+
   // Host triple is not really needed for unbundling operation, so do not
   // treat missing host triple as error if we do unbundling.
-  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
+  if ((Unbundle && HostTargetNum > 1) ||
+  (!Unbundle && HostTargetNum != 1 && !AllowNoHost)) {
 reportError(createStringError(errc::invalid_argument,
   "expecting exactly one host target but got " +
   Twine(HostTargetNum)));
Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- clang/test/Driver/hip-rdc-device-only.hip
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -56,8 +56,8 @@
 // COMMON-SAME: "-fapply-global-visibility-to-externs"
 // COMMON-SAME: "-target-cpu" "gfx803"
 // COMMON-SAME: "-fgpu-rdc"
-// EMITBC-SAME: {{.*}} "-o" {{"a.*bc"}} "-x" "hip"
-// EMITLL-SAME: {{.*}} "-o" {{"a.*ll"}} "-x" "hip"
+// EMITBC-SAME: {{.*}} "-o" {{".*a.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{".*a.*ll"}} "-x" "hip"
 // CHECK-SAME: {{.*}} {{".*a.cu"}}
 
 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -69,10 +69,14 @@
 // COMMON-SAME: "-fapply-global-visibility-to-externs"
 // COMMON-SAME: "-target-cpu" "gfx900"
 // COMMON-SAME: "-fgpu-rdc"
-// EMITBC-SAME: {{.*}} "-o" {{"a.*bc"}} "-x" "hip"
-// EMITLL-SAME: {{.*}} "-o" {{"a.*ll"}} "-x" "hip"
+// EMITBC-SAME: {{.*}} "-o" {{".*a.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{".*a.*ll"}} "-x" "hip"
 // COMMON-SAME: {{.*}} {{".*a.cu"}}
 
+// COMMON: "{{.*}}clang-offload-bundler" "-type={{(bc|ll)}}"
+// COMMON-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
+// COMMON-SAME: "-outputs=a-hip-amdgcn-amd-amdhsa.{{(bc|ll)}}"
+
 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // EMITBC-SAME: "-emit-llvm-bc"
@@ -82,8 +86,8 @@
 // COMMON-SAME: "-fapply-global-visibility-to-externs"
 // COMMON-SAME: "-target-cpu" "gfx803"
 // COMMON-SAME: "-fgpu-rdc"
-// EMITBC-SAME: {{.*}} "-o" {{"b.*bc"}} "-x" "hip"
-// EMITLL-SAME: {{.*}} "-o" {{"b.*ll"}} "-x" "hip"
+// EMITBC-SAME: {{.*}} "-o" {{".*b.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{".*b.*ll"}} "-x" "hip"
 // COMMON-SAME: {{.*}} {{".*b.hip"}}
 
 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -95,10 +99,14 @@
 // COMMON-SAME: "-fapply-global-visibility-to-externs"
 // COMMON-SAME: "-target-cpu" "gfx900"
 // COMMON-SAME: "-fgpu-rdc"
-// EMITBC-SAME: {{.*}} "-o" {{"b.*bc"}} "-x" "hip"
-// EMITLL-SAME: {{.*}} "-o" {{"b.*ll"}} "-x" "hip"
+// EMITBC-SAME: {{.*}} "-o" {{".*b.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} 

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

2021-05-01 Thread Eliza via Phabricator via cfe-commits
exv created this revision.
exv added reviewers: krasimir, MyDeveloperDay.
exv requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This adds support for the null-coalescing assignment and null-forgiving
oeprators.

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101702

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

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -358,6 +358,21 @@
   verifyFormat("return _name ?? \"DEF\";");
 }
 
+TEST_F(FormatTestCSharp, CSharpNullCoalescingAssignment) {
+  verifyFormat("test \?\?= ABC;");
+  verifyFormat("test \?\?= true;");
+}
+
+TEST_F(FormatTestCSharp, CSharpNullForgiving) {
+  verifyFormat("var test = null!;");
+  verifyFormat("string test = someFunctionCall()! + \"ABC\"!");
+  verifyFormat("int test = (1! + 2 + bar! + foo())!");
+  verifyFormat("test \?\?= !foo!;");
+  verifyFormat("test = !bar! \?\? !foo!;");
+  verifyFormat("bool test = !(!true || !null! || !false && !false! && !bar()! "
+   "+ (!foo()))!");
+}
+
 TEST_F(FormatTestCSharp, AttributesIndentation) {
   FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
   Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1579,24 +1579,29 @@
   }
 }
 
-if (Style.Language == FormatStyle::LK_JavaScript) {
-  if (Current.is(tok::exclaim)) {
-if (Current.Previous &&
-(Keywords.IsJavaScriptIdentifier(
- *Current.Previous, /* AcceptIdentifierName= */ true) ||
- Current.Previous->isOneOf(
- tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
- Keywords.kw_type, Keywords.kw_get, Keywords.kw_set) ||
- Current.Previous->Tok.isLiteral())) {
-  Current.setType(TT_JsNonNullAssertion);
-  return;
-}
-if (Current.Next &&
-Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
+if ((Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) &&
+Current.is(tok::exclaim)) {
+  if (Current.Previous) {
+bool isIdentifier =
+Style.Language == FormatStyle::LK_JavaScript
+? Keywords.IsJavaScriptIdentifier(
+  *Current.Previous, /* AcceptIdentifierName= */ true)
+: Current.Previous->is(tok::identifier);
+if (isIdentifier ||
+Current.Previous->isOneOf(
+tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
+tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
+Keywords.kw_set) ||
+Current.Previous->Tok.isLiteral()) {
   Current.setType(TT_JsNonNullAssertion);
   return;
 }
   }
+  if (Current.Next &&
+  Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
+Current.setType(TT_JsNonNullAssertion);
+return;
+  }
 }
 
 // Line.MightBeFunctionDecl can only be true after the parentheses of a
@@ -3186,6 +3191,15 @@
 if (Left.is(TT_CSharpNullCoalescing) || Right.is(TT_CSharpNullCoalescing))
   return true;
 
+// Space before and after '??='.
+if (Left.is(TT_CSharpNullCoalescingAssignment) ||
+Right.is(TT_CSharpNullCoalescingAssignment))
+  return true;
+
+// No space before null forgiving '!'.
+if (Right.is(TT_JsNonNullAssertion))
+  return false;
+
 // No space before '?['.
 if (Right.is(TT_CSharpNullConditionalLSquare))
   return false;
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -54,7 +54,8 @@
   bool tryMergeJSPrivateIdentifier();
   bool tryMergeCSharpStringLiteral();
   bool tryMergeCSharpKeywordVariables();
-  bool tryMergeCSharpDoubleQuestion();
+  bool tryMergeCSharpNullCoalescing();
+  bool tryMergeCSharpNullCoalescingAssignment();
   bool tryMergeCSharpNullConditional();
   bool tryTransformCSharpForEach();
   bool tryMergeForEach();
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ 

[PATCH] D99741: [RISCV][Clang] Add some RVV Floating-Point intrinsic functions. (vfclass, vfmerge, vfrec7, vfrsqrt7, vfsqrt)

2021-05-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D99741#2730989 , @thakis wrote:

>> ! In D99741#2721669 , @craig.topper 
>> wrote:
>>  We're preparing a patch to remove to stop testing both rv32 and rv64 on 
>> every test. That should reduce the time by half. What is an acceptable 
>> number?
>
> You tell me. I'd say well below 1%?
>
> I wanted to prepare a graph that shows check-clang time over the last year – 
> it stayed basically constant and the jumped by 20% (now 10% now that half the 
> tests are disabled). It'd look dramatic, but I haven't had time to make a 
> graph. I'm sure you can imagine it though :) (Also, I feel the burden of 
> proof shouldn't be on people pointing out regressions.)
>
> @rnk suggested putting these tests behind some kind of `REQUIRES: 
> expensive-checks` thing that's off by default, instead of reverting 
> everything, until perf is sorted out. That sounds like a great idea to me – 
> wdyt?

I just uploaded D101700  which takes lit on 
`clang/test/CodeGen/RISCV/rvv*` from ~8 seconds to ~5.5 seconds as measured on 
a 48 core server I use at work. Not sure how that translates to a less capable 
machine with less cores, slower disk, etc.

For comparison, here are some times for running lit on subsets of tests on this 
machine before the patch. Mostly looked at clang/test/CodeGen as I was curious 
to see how close we are to other targets.

  clang/test/ - 68.75 seconds
  clang/test/CodeGen  - 24.59 seconds
  clang/test/CodeGen/X86  - 2.68 seconds
  clang/test/CodeGen/aarch64* - 12.33 seconds
  clang/test/CodeGen/arm* - 2.04 seconds

We're also considering D100529  to further 
reduce the RISCV test time. Another option we've talked about is concatenating 
some of the tests into a single file to cut down the number of times we parse 
riscv_vector.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99741

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


[PATCH] D101700: [RISCV] Reoreder masked builtin operands. Use clang_builtin_alias for all overloaded vector builtins.

2021-05-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:192
 
-  // When the order of the parameters of clang builtin do not match the order 
of
-  // C/C++ api, we use permutation index to mapping the operand from clang

I remove this and added a couple ManualCodeGen blocks to permute builtin to IR 
intrinsics operand order to make up for it. I could have used PermuteOperands 
but then we would have had to translate it into C code to do the permutation in 
CGBuiltin.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101700

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


[PATCH] D101700: [RISCV] Reoreder masked builtin operands. Use clang_builtin_alias for all overloaded vector builtins.

2021-05-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: arcbbb, khchen, HsiangKai, evandro, rogfer01, 
frasercrmck.
Herald added subscribers: StephenFan, vkmr, dexonsmith, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, 
niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

This patch makes the builtin operand order match the C operand order
for all intrinsics. With this we can use clang_builtin_alias for
all overloaded intrinsics.

This should further reduce the test time for vector intrinsics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101700

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcompress.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfabs.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfclass.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfirst.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfncvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfneg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrec7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsqrt7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsgnj.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsqrt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/viota.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfeq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfge.c
  

[PATCH] D101387: [Clang] remove text extension from diag::err_drv_invalid_value_with_suggestion

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



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:218
+def err_drv_invalid_value_with_suggestion : Error<
+"invalid value '%1' in '%0', valid values to '%0' are: %2">;
 def err_drv_invalid_remap_file : Error<

Note %0 is duplicated in ` valid values to '%0'` - elsewhere we use `, expected 
...` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101387

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


[PATCH] D100727: [clang-format] Add options to AllowShortIfStatementsOnASingleLine to apply to "else if" and "else".

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

I went a different way in order to keep backward compatibility.
I renamed Alwayss to OnlyFirstIf  and added AllIfsAndElse that behaves as 
Always in my initial patch.
@MyDeveloperDay, please have another look.

Names of the options can certainly be improved, but I'm currently short on 
ideas. Any help is welcome.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100727

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


[PATCH] D101696: [Matrix] Implement C-style explicit type conversions in CXX for matrix types

2021-05-01 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha created this revision.
Herald added a subscriber: tschuett.
SaurabhJha requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements C-style explicit type conversions in CXX for matrix 
types. It is part of fixing https://bugs.llvm.org/show_bug.cgi?id=47141


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101696

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/CodeGenCXX/matrix-casts.cpp
  clang/test/SemaCXX/matrix-casts.cpp

Index: clang/test/SemaCXX/matrix-casts.cpp
===
--- clang/test/SemaCXX/matrix-casts.cpp
+++ clang/test/SemaCXX/matrix-casts.cpp
@@ -14,7 +14,6 @@
 typedef int vec __attribute__((vector_size(4)));
 
 void f1() {
-  // TODO: Update this test once the support of C-style casts for C++ is implemented.
   matrix_4_4 m1;
   matrix_4_4 m2;
   matrix_4_4 m3;
@@ -23,45 +22,45 @@
   vec v;
   test_struct *s;
 
-  (matrix_4_4)m1;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'char __attribute__((matrix_type(4, \
-4)))') to 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_4_4)m2; // expected-error {{C-style cast from 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, \
-4)))') to 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_5_5)m3;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, \
-4)))') to 'matrix_5_5' (aka 'int __attribute__((matrix_type(5, 5)))') is not allowed}}
+  m2 = (matrix_4_4)m1;
+  m3 = (matrix_4_4)m2;
+  (matrix_5_5)m3; // expected-error {{conversion between matrix types 'matrix_5_5' (aka 'int __attribute__\
+((matrix_type(5, 5)))') and 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') of different size is not\
+ allowed}}
 
-  (int)m3;// expected-error {{C-style cast from 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, \
-4)))') to 'int'}}
-  (matrix_4_4)i; // expected-error {{C-style cast from 'int' to 'matrix_4_4' (aka 'int __attribute__((\
-matrix_type(4, 4)))') is not allowed}}
+  (int)m3;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'short __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
+  (matrix_4_4)i; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
 
-  (vec) m2;// expected-error {{C-style cast from 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') \
-to 'vec' (vector of 1 'int' value) is not allowed}}
-  (matrix_4_4)v; // expected-error {{C-style cast from 'vec' (vector of 1 'int' value) to 'matrix_4_4' \
-(aka 'char __attribute__((matrix_type(4, 4)))') is not allowed}}
+  (vec) m2;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
+  (matrix_4_4)v; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
 
-  (test_struct *)m1;// expected-error {{cannot cast from type 'matrix_4_4' (aka 'char __attribute__\
-((matrix_type(4, 4)))') to pointer type 'test_struct *}}'
-  (matrix_5_5)s; // expected-error {{C-style cast from 'test_struct *' to 'matrix_5_5' (aka 'float __attribute__\
-((matrix_type(5, 5)))') is not allowed}}'
+  (test_struct *)m1;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'test_struct *' is not allowed}}'
+  (matrix_5_5)s; // expected-error {{conversion between matrix type 'matrix_5_5' (aka 'float __attribute__\
+((matrix_type(5, 5)))') and incompatible type 'test_struct *' is not allowed}}'
 }
 
 void f2() {
-  // TODO: Update this test once the support of C-style casts for C++ is implemented.
   matrix_4_4 m1;
-  matrix_5_5 m2;
-  matrix_5_5 m3;
-  matrix_4_4 m4;
+  matrix_4_4 m2;
+  matrix_5_5 m3;
+  matrix_5_5 m4;
+  matrix_4_4 m5;
+  matrix_5_5 m6;
   float f;
 
-  (matrix_4_4)m1;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'float __attribute__\
-((matrix_type(4, 4)))') to 'matrix_4_4' (aka 'double __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_5_5)m2;// expected-error {{C-style cast from 'matrix_5_5' (aka 'double __attribute__\
-((matrix_type(5, 5)))') to 'matrix_5_5' (aka 'float __attribute__((matrix_type(5, 5)))') is not allowed}}
-  (matrix_5_5)m3; // expected-error {{C-style cast from 'matrix_5_5' (aka 'int __attribute__\
-((matrix_type(5, 5)))') to 'matrix_5_5' (aka 'unsigned int __attribute__((matrix_type(5, 5)))') \
-is not allowed}}
-  (matrix_4_4)m4;  // expected-error {{C-style cast from 

[PATCH] D100727: [clang-format] Correctly apply AllowShortIfStatementsOnASingleLine: Always to else branch.

2021-05-01 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 342170.
curdeius added a comment.
This revision is now accepted and ready to land.

- [clang-format] Apply AllowShortIfStatementsOnASingleLine: AllIfsAndElse to 
"else if" and "else". Keep backward-compatibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100727

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -461,6 +461,69 @@
"  }\n"
"g();");
 
+  verifyFormat("if (a)\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g()\n"
+   "};");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else if (b)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b) {\n"
+   "  g();\n"
+   "} else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b)\n"
+   "  g();\n"
+   "else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else if (b) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+
   FormatStyle AllowsMergedIf = getLLVMStyle();
   AllowsMergedIf.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   AllowsMergedIf.AllowShortIfStatementsOnASingleLine =
@@ -510,6 +573,59 @@
 
   AllowsMergedIf.ColumnLimit = 13;
   verifyFormat("if (a)\n  return;", AllowsMergedIf);
+
+  FormatStyle AllowsMergedIfElse = getLLVMStyle();
+  AllowsMergedIfElse.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_AllIfsAndElse;
+  verifyFormat("if (a)\n"
+   "  // comment\n"
+   "  f();\n"
+   "else\n"
+   "  // comment\n"
+   "  f();",
+   AllowsMergedIfElse);
+  verifyFormat("{\n"
+   "  if (a)\n"
+   "  label:\n"
+   "f();\n"
+   "  else\n"
+   "  label:\n"
+   "f();\n"
+   "}",
+   AllowsMergedIfElse);
+  verifyFormat("if (a)\n"
+   "  ;\n"
+   "else\n"
+   "  ;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else {\n"
+   "}",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) return;\n"
+   "else if (b) return;\n"
+   "else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else if (b) return;\n"
+   "else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) return;\n"
+   "else if (b) {\n"
+   "} else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a)\n"
+   "  if (b) return;\n"
+   "  else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if constexpr (a)\n"
+   "  if constexpr (b) return;\n"
+   "  else if constexpr (c) return;\n"
+   "  else return;",
+   AllowsMergedIfElse);
 }
 
 TEST_F(FormatTest, FormatIfWithoutCompoundStatementButElseWith) {
@@ -529,7 +645,166 @@
"  g();\n",
AllowsMergedIf);
 
-  AllowsMergedIf.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Always;
+  verifyFormat("if (a) g();", AllowsMergedIf);
+  verifyFormat("if (a) {\n"
+   "  g()\n"
+   "};",
+   AllowsMergedIf);
+  verifyFormat("if (a)\n"
+   "  g();\n"
+  

[clang] f36e6e1 - [RISCV] Add missing frontend tests for vcompress intrinsics.

2021-05-01 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-05-01T13:07:28-07:00
New Revision: f36e6e16a86eceaab39b0ac38517feb04775e0d4

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

LOG: [RISCV] Add missing frontend tests for vcompress intrinsics.

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcompress.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vcompress.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcompress.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcompress.c
new file mode 100644
index 0..049e69f110553
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcompress.c
@@ -0,0 +1,485 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i8mf8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv1i8.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) 
#[[ATTR8:[0-9]+]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf8_t test_vcompress_vm_i8mf8 (vbool64_t mask, vint8mf8_t dest, 
vint8mf8_t src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i8mf4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv2i8.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf4_t test_vcompress_vm_i8mf4 (vbool32_t mask, vint8mf4_t dest, 
vint8mf4_t src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i8mf2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv4i8.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8mf2_t test_vcompress_vm_i8mf2 (vbool16_t mask, vint8mf2_t dest, 
vint8mf2_t src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i8m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv8i8.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m1_t test_vcompress_vm_i8m1 (vbool8_t mask, vint8m1_t dest, vint8m1_t 
src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i8m2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv16i8.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m2_t test_vcompress_vm_i8m2 (vbool4_t mask, vint8m2_t dest, vint8m2_t 
src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i8m4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv32i8.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m4_t test_vcompress_vm_i8m4 (vbool2_t mask, vint8m4_t dest, vint8m4_t 
src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i8m8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv64i8.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m8_t test_vcompress_vm_i8m8 (vbool1_t mask, vint8m8_t dest, vint8m8_t 
src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i16mf4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv1i16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint16mf4_t test_vcompress_vm_i16mf4 (vbool64_t mask, vint16mf4_t dest, 
vint16mf4_t src, size_t vl) {
+  return vcompress(mask, dest, src, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vcompress_vm_i16mf2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vcompress.nxv2i16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]]) #[[ATTR8]]
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint16mf2_t test_vcompress_vm_i16mf2 (vbool32_t mask, vint16mf2_t dest, 
vint16mf2_t src, size_t vl) {
+  return vcompress(mask, dest, src, 

[PATCH] D101387: [Clang] remove text extension from diag::err_drv_invalid_value_with_suggestion

2021-05-01 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D101387#2730043 , @nickdesaulniers 
wrote:

> @FarisRehman when I run `llvm-lit -vv 
> flang/test/Driver/fixed-line-length.f90` I see:
>
>   UNSUPPORTED: Flang :: Driver/fixed-line-length.f90 (1 of 1)
>
> This is with `-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;flang"` used, and 
> a `flang` binary produced.  Does `REQUIRES: new-flang-driver` imply I should 
> be doing something else?

Currently `flang` is just a bash script that's a wrapper for the old driver. 
The new driver is only enabled conditionally - you have to set 
`FLANG_BUILD_NEW_DRIVER` to build it. The binary is called `flang-new` 
(hopefully soon it will be renamed as `flang`).

The changes in Flang LGTM, thanks for working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101387

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


[PATCH] D36368: Fix type printing of array template args

2021-05-01 Thread Vassil Vassilev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8518742104ab: Fix type printing of array template args 
(authored by reikdas, committed by v.g.vassilev).
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36368

Files:
  clang/lib/AST/TemplateBase.cpp
  clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
@@ -77,3 +77,40 @@
   };
   void f(C ca) { ca.f({}, 0); }
 }
+
+using FourChars = const char[4];
+constexpr FourChars kEta = "Eta";
+constexpr const char kDes[4] = "Des";
+constexpr const char *kNull = "Phi";
+constexpr const char **kZero[] = {};
+
+template  class Column {};
+template  class Dolumn {};
+template  class Folumn {};
+template  class Golumn {};
+template  class Holumn {};
+template  class Jolumn {};
+template  class Iolumn {};
+
+class container {
+public:
+  int a;
+};
+template  class Kolumn {};
+
+void lookup() {
+  Column().ls();// expected-error {{().ls();// expected-error {{().ls(); // expected-error {{().ls();// expected-error {{().ls();// expected-error {{().ls();   // expected-error {{<,}}
+  Folumn<, double>().ls();   // expected-error {{<,}}
+  Golumn<, double>().ls();   // expected-error {{<,}}
+  Golumn<, double>().ls();   // expected-error {{<,}}
+  Holumn<, double>().ls();  // expected-error {{<,}}
+  Jolumn().ls();   // expected-error {{().ls();  // expected-error {{<,}}
+  Kolumn<::a>().ls();   // expected-error {{<::a}}
+  Kolumn().ls(); // expected-error {{();
 // CHECK-DAG: "fn_tmpl"
 
+template 
+void fn_tmpl_typecheck() {}
+
+template void fn_tmpl_typecheck();
+// CHECK-DAG: "fn_tmpl_typecheck"
+
 template  struct ClassTemplate { A a; B b; C c; };
 ClassTemplate > f;
 // This will only show up in normal debug builds.  The space in `> >` is
Index: clang/lib/AST/TemplateBase.cpp
===
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -80,6 +80,26 @@
   }
 }
 
+static unsigned getArrayDepth(QualType type) {
+  unsigned count = 0;
+  while (const auto *arrayType = type->getAsArrayTypeUnsafe()) {
+count++;
+type = arrayType->getElementType();
+  }
+  return count;
+}
+
+static bool needsAmpersandOnTemplateArg(QualType paramType, QualType argType) {
+  // Generally, if the parameter type is a pointer, we must be taking the
+  // address of something and need a &.  However, if the argument is an array,
+  // this could be implicit via array-to-pointer decay.
+  if (!paramType->isPointerType())
+return paramType->isMemberPointerType();
+  if (argType->isArrayType())
+return getArrayDepth(argType) == getArrayDepth(paramType->getPointeeType());
+  return true;
+}
+
 //===--===//
 // TemplateArgument Implementation
 //===--===//
@@ -363,8 +383,10 @@
 break;
   }
 }
-if (!getParamTypeForDecl()->isReferenceType())
-  Out << '&';
+if (auto *VD = dyn_cast(ND)) {
+  if (needsAmpersandOnTemplateArg(getParamTypeForDecl(), VD->getType()))
+Out << "&";
+}
 ND->printQualifiedName(Out);
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8518742 - Fix type printing of array template args

2021-05-01 Thread Vassil Vassilev via cfe-commits

Author: Pratyush Das
Date: 2021-05-01T18:50:09Z
New Revision: 8518742104ab075296722ef6151f65aee7a0646d

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

LOG: Fix type printing of array template args

The code example:
```
constexpr const char kEta[] = "Eta";
template  class Column {};
using quick = Column;

void lookup() {
  quick c1;
  c1.ls();
}
```

emits error: no member named 'ls' in 'Column<, double>'. The patch fixes
the printed type name by not printing the ampersand for array types.

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

Added: 


Modified: 
clang/lib/AST/TemplateBase.cpp
clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp

Removed: 




diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index baf62bd115a85..b1816ff8aeb16 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -80,6 +80,26 @@ static void printIntegral(const TemplateArgument ,
   }
 }
 
+static unsigned getArrayDepth(QualType type) {
+  unsigned count = 0;
+  while (const auto *arrayType = type->getAsArrayTypeUnsafe()) {
+count++;
+type = arrayType->getElementType();
+  }
+  return count;
+}
+
+static bool needsAmpersandOnTemplateArg(QualType paramType, QualType argType) {
+  // Generally, if the parameter type is a pointer, we must be taking the
+  // address of something and need a &.  However, if the argument is an array,
+  // this could be implicit via array-to-pointer decay.
+  if (!paramType->isPointerType())
+return paramType->isMemberPointerType();
+  if (argType->isArrayType())
+return getArrayDepth(argType) == 
getArrayDepth(paramType->getPointeeType());
+  return true;
+}
+
 
//===--===//
 // TemplateArgument Implementation
 
//===--===//
@@ -363,8 +383,10 @@ void TemplateArgument::print(const PrintingPolicy ,
 break;
   }
 }
-if (!getParamTypeForDecl()->isReferenceType())
-  Out << '&';
+if (auto *VD = dyn_cast(ND)) {
+  if (needsAmpersandOnTemplateArg(getParamTypeForDecl(), VD->getType()))
+Out << "&";
+}
 ND->printQualifiedName(Out);
 break;
   }

diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
index 4f85effdc700f..055ac64b9955d 100644
--- a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -86,6 +86,12 @@ void fn_tmpl() {}
 template void fn_tmpl();
 // CHECK-DAG: "fn_tmpl"
 
+template 
+void fn_tmpl_typecheck() {}
+
+template void fn_tmpl_typecheck();
+// CHECK-DAG: "fn_tmpl_typecheck"
+
 template  struct ClassTemplate { A a; B b; 
C c; };
 ClassTemplate > f;
 // This will only show up in normal debug builds.  The space in `> >` is

diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
index 522835f33454c..5752cbac0291d 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
@@ -77,3 +77,40 @@ namespace ReferenceToConstexpr {
   };
   void f(C ca) { ca.f({}, 0); }
 }
+
+using FourChars = const char[4];
+constexpr FourChars kEta = "Eta";
+constexpr const char kDes[4] = "Des";
+constexpr const char *kNull = "Phi";
+constexpr const char **kZero[] = {};
+
+template  class Column {};
+template  class Dolumn {};
+template  class Folumn {};
+template  class Golumn {};
+template  class Holumn {};
+template  class Jolumn {};
+template  class Iolumn {};
+
+class container {
+public:
+  int a;
+};
+template  class Kolumn {};
+
+void lookup() {
+  Column().ls();// expected-error {{().ls();// expected-error {{().ls(); // expected-error {{().ls();// expected-error {{().ls();// expected-error {{().ls();   // expected-error {{<,}}
+  Folumn<, double>().ls();   // expected-error {{<,}}
+  Golumn<, double>().ls();   // expected-error {{<,}}
+  Golumn<, double>().ls();   // expected-error {{<,}}
+  Holumn<, double>().ls();  // expected-error {{<,}}
+  Jolumn().ls();   // expected-error {{().ls();  // expected-error {{<,}}
+  Kolumn<::a>().ls();   // expected-error {{<::a}}
+  Kolumn().ls(); // expected-error {{https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101654: [HIP] Fix device lib selection

2021-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 342156.
yaxunl marked an inline comment as done.
yaxunl added a comment.
Herald added a subscriber: dexonsmith.

revise test by Fangrui's comment. Also fix test failure


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

https://reviews.llvm.org/D101654

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/CodeGenCUDA/correctly-rounded-div.cu
  clang/test/Driver/hip-device-libs.hip

Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -113,6 +113,30 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,INST
 
+// Test -fast-math
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -ffast-math --rocm-path=%S/Inputs/rocm \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=FAST
+
+// Test -ffinite-math-only
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -ffinite-math-only --rocm-path=%S/Inputs/rocm \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=FINITE
+
+// Test -funsafe-math-optimizations
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -funsafe-math-optimizations --rocm-path=%S/Inputs/rocm \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=UNSAFE
+
+// Test -fno-hip-fp32-correctly-rounded-divide-sqrt
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -fno-hip-fp32-correctly-rounded-divide-sqrt \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=DIVSQRT
+
 // ALL-NOT: error:
 // ALL: {{"[^"]*clang[^"]*"}}
 // ALL-SAME: "-mlink-builtin-bitcode" "{{.*}}hip.bc"
@@ -128,3 +152,23 @@
 // ALL-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_wavefrontsize64_on.bc"
 // ALL-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_isa_version_{{[0-9]+}}.bc"
 // INST-SAME: "-mlink-builtin-bitcode" "{{.*}}instrument.bc"
+
+// FAST: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
+// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
+// FAST-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
+
+// FINITE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
+// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_on.bc"
+// FINITE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
+
+// UNSAFE: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_on.bc"
+// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
+// UNSAFE-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_on.bc"
+
+// DIVSQRT: "-mlink-builtin-bitcode" "{{.*}}oclc_daz_opt_off.bc"
+// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_unsafe_math_off.bc"
+// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_finite_only_off.bc"
+// DIVSQRT-SAME: "-mlink-builtin-bitcode" "{{.*}}oclc_correctly_rounded_sqrt_off.bc"
Index: clang/test/CodeGenCUDA/correctly-rounded-div.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/correctly-rounded-div.cu
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple -amdgcn-amd-amdhsa \
+// RUN:  -target-cpu gfx906 -fcuda-is-device -x hip \
+// RUN:  | FileCheck --check-prefixes=COMMON,CRDIV %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple -amdgcn-amd-amdhsa \
+// RUN:  -target-cpu gfx906 -fcuda-is-device -x hip \
+// RUN:  -fno-hip-fp32-correctly-rounded-divide-sqrt \
+// RUN:  | FileCheck --check-prefixes=COMMON,NCRDIV %s
+
+#include "Inputs/cuda.h"
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+// COMMON-LABEL: @_Z11spscalardiv
+// COMMON: fdiv{{.*}},
+// NCRDIV: !fpmath ![[MD:[0-9]+]]
+// CRDIV-NOT: !fpmath
+__device__ float spscalardiv(float a, float b) {
+  return a / b;
+}
+
+// COMMON-LABEL: @_Z11spvectordiv
+// COMMON: fdiv{{.*}},
+// NCRDIV: !fpmath ![[MD]]
+// CRDIV-NOT: !fpmath
+__device__ float4 spvectordiv(float4 a, float4 b) {
+  return a / b;
+}
+
+// COMMON-LABEL: @_Z11dpscalardiv
+// COMMON-NOT: !fpmath
+__device__ double dpscalardiv(double a, double b) {
+  return a / b;
+}
+
+// NCRDIV: ![[MD]] = !{float 2.50e+00}
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -404,11 +404,17 @@

[PATCH] D101259: [clang-tidy] Fix cppcoreguidelines-pro-type-vararg false positives with __builtin_ms_va_list

2021-05-01 Thread Georgy Komarov via Phabricator via cfe-commits
jubnzv updated this revision to Diff 342155.

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

https://reviews.llvm.org/D101259

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -58,3 +58,11 @@
   (void)__builtin_isinf_sign(0.f);
   (void)__builtin_prefetch(nullptr);
 }
+
+// Some implementations of __builtin_va_list and __builtin_ms_va_list desugared
+// as 'char *' or 'void *'. This test checks whether we are handling this case
+// correctly and not generating false positives.
+void no_false_positive_desugar_va_list(char *in) {
+  char *tmp1 = in;
+  void *tmp2 = in;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg-ms.cpp
@@ -0,0 +1,26 @@
+// Purpose:
+// Ensure that the 'cppcoreguidelines-pro-type-vararg' check works with the
+// built-in va_list on Windows systems.
+
+// REQUIRES: system-windows
+
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-vararg %t
+
+void test_ms_va_list(int a, ...) {
+  __builtin_ms_va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+  __builtin_ms_va_start(ap, a);
+  int b = __builtin_va_arg(ap, int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define c-style vararg functions; use variadic templates instead
+  __builtin_ms_va_end(ap);
+}
+
+void test_typedefs(int a, ...) {
+  typedef __builtin_ms_va_list my_va_list1;
+  my_va_list1 ap1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+
+  using my_va_list2 = __builtin_ms_va_list;
+  my_va_list2 ap2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang::ast_matchers;
 
@@ -60,8 +61,45 @@
 AST_MATCHER(QualType, isVAList) {
   ASTContext  = Finder->getASTContext();
   QualType Desugar = Node.getDesugaredType(Context);
-  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
- Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+  QualType NodeTy = Node.getUnqualifiedType();
+
+  auto CheckVaList = [](QualType NodeTy, QualType Expected,
+const ASTContext ) {
+if (NodeTy == Expected)
+  return true;
+QualType Desugar = NodeTy;
+QualType Ty;
+do {
+  Ty = Desugar;
+  Desugar = Ty.getSingleStepDesugaredType(Context);
+  if (Desugar == Expected)
+return true;
+} while (Desugar != Ty);
+return false;
+  };
+
+  // The internal implementation of __builtin_va_list depends on the target
+  // type. Some targets implements va_list as 'char *' or 'void *'.
+  // In these cases we need to remove all typedefs one by one to check this.
+  using BuiltinVaListKind = TargetInfo::BuiltinVaListKind;
+  BuiltinVaListKind VaListKind = Context.getTargetInfo().getBuiltinVaListKind();
+  if (VaListKind == BuiltinVaListKind::CharPtrBuiltinVaList ||
+  VaListKind == BuiltinVaListKind::VoidPtrBuiltinVaList) {
+if (CheckVaList(NodeTy, Context.getBuiltinVaListType(), Context))
+  return true;
+  } else if (Desugar ==
+ Context.getBuiltinVaListType().getDesugaredType(Context)) {
+return true;
+  }
+
+  // We also need to check the implementation of __builtin_ms_va_list in the
+  // same way, because it may differ from the va_list implementation.
+  if (Desugar == Context.getBuiltinMSVaListType().getDesugaredType(Context) &&
+  CheckVaList(NodeTy, Context.getBuiltinMSVaListType(), Context)) {
+return true;
+  }
+
+  return false;
 }
 
 AST_MATCHER_P(AdjustedType, hasOriginalType,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D101614: [clang-tidy][NFC] Simplify a lot of bugprone-sizeof-expression matchers

2021-05-01 Thread Stephen Kelly via Phabricator via cfe-commits
steveire accepted this revision.
steveire added a comment.
This revision is now accepted and ready to land.

LGTM, but I think you could split it into 3 commits with a commit message 
saying what each is doing. "Simplify a lot of" doesn't say anything specific 
about what this patch does. It looks like you could split it into

- "Remove obsolete `expr()`" (because of the ones in `hasLHS` and `hasRHS`)
- "Simplify `anyOf(integerLiteral()...)` to `integerLiteral(anyOf())`"
- "Use `hasArgumentOfType` matcher with `sizeOfExpr`"

I'm not sure if this patch does anything else than those 3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101614

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


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

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



Comment at: clang/lib/Driver/ToolChain.cpp:401
 return "aix";
+  case llvm::Triple::Darwin:
+return "darwin";

arphaman wrote:
> Should this also apply to `llvm::Triple::MacOSX` , `iOS`, and other Darwin 
> OSes?
Good catch. I've fixed this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

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


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

2021-05-01 Thread Dan Liew via Phabricator via cfe-commits
delcypher updated this revision to Diff 342152.
delcypher added a comment.

- Support other Apple target triples.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101682

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


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


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

[PATCH] D77013: [AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee

2021-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0175999805cf: [AMDGPU] Add options -mamdgpu-ieee 
-mno-amdgpu-ieee (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenOpenCL/amdgpu-ieee.cl

Index: clang/test/CodeGenOpenCL/amdgpu-ieee.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/amdgpu-ieee.cl
@@ -0,0 +1,47 @@
+// REQUIRES: amdgpu-registered-target
+//
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   | FileCheck -check-prefixes=COMMON,ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mno-amdgpu-ieee -menable-no-nans \
+// RUN:   | FileCheck -check-prefixes=COMMON,OFF %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mno-amdgpu-ieee -cl-fast-relaxed-math \
+// RUN:   | FileCheck -check-prefixes=COMMON,OFF %s
+
+// Check AMDGCN ISA generation.
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O3 -S -o - %s \
+// RUN:   | FileCheck -check-prefixes=ISA-ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O3 -S -o - %s \
+// RUN:   -mno-amdgpu-ieee -menable-no-nans \
+// RUN:   | FileCheck -check-prefixes=ISA-OFF %s
+
+// Check diagnostics when using -mno-amdgpu-ieee without NoHonorNaNs.
+
+// RUN: not %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mno-amdgpu-ieee 2>&1 | FileCheck -check-prefixes=DIAG %s
+
+// COMMON: define{{.*}} amdgpu_kernel void @kern{{.*}} [[ATTRS1:#[0-9]+]]
+// ISA-ON: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-ON: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-ON: v_min_f32_e32
+// ISA-ON: ; IeeeMode: 1
+// ISA-OFF-NOT: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-OFF-NOT: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-OFF: v_min_f32_e32
+// ISA-OFF: ; IeeeMode: 0
+kernel void kern(global float *x, float y, float z) {
+  *x = __builtin_fmin(y, z);
+}
+
+// COMMON: define{{.*}}void @fun() [[ATTRS2:#[0-9]+]]
+void fun() {
+}
+
+// ON-NOT: attributes [[ATTRS1]] = {{.*}} "amdgpu-ieee"
+// OFF: attributes [[ATTRS1]] = {{.*}} "amdgpu-ieee"="false"{{.*}}"no-nans-fp-math"="true"{{.*}}"no-trapping-math"="true"
+// ON-NOT: attributes [[ATTRS2]] = {{.*}} "amdgpu-ieee"
+// OFF: attributes [[ATTRS2]] = {{.*}} "amdgpu-ieee"="false"{{.*}}"no-nans-fp-math"="true"{{.*}}"no-trapping-math"="true"
+
+// DIAG: invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN handling
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1944,6 +1944,11 @@
   else if (Args.hasArg(options::OPT_fno_finite_loops))
 Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Never;
 
+  Opts.EmitIEEENaNCompliantInsts =
+  Args.hasFlag(options::OPT_mamdgpu_ieee, options::OPT_mno_amdgpu_ieee);
+  if (!Opts.EmitIEEENaNCompliantInsts && !LangOptsRef.NoHonorNaNs)
+Diags.Report(diag::err_drv_amdgpu_ieee_without_no_honor_nans);
+
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9166,6 +9166,9 @@
 
   if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics())
 F->addFnAttr("amdgpu-unsafe-fp-atomics", "true");
+
+  if (!getABIInfo().getCodeGenOpts().EmitIEEENaNCompliantInsts)
+F->addFnAttr("amdgpu-ieee", "false");
 }
 
 unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3177,6 +3177,14 @@
  Values<"command,reactor">,
  HelpText<"Execution model (WebAssembly only)">;
 
+defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
+  CodeGenOpts<"EmitIEEENaNCompliantInsts">, DefaultTrue,
+  PosFlag,
+  NegFlag>, Group;
+
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group,
   HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -129,6 +129,8 @@
   

[clang] 0175999 - [AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee

2021-05-01 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-05-01T09:02:55-04:00
New Revision: 0175999805cf05d91c8a127ebd8c9d54a640abe9

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

LOG: [AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee

AMDGPU backend need to know whether floating point opcodes that support 
exception
flag gathering quiet and propagate signaling NaN inputs per IEEE754-2008, which 
is
conveyed by a function attribute "amdgpu-ieee". "amdgpu-ieee"="false" turns 
this off.
Without this function attribute backend assumes it is on for compute functions.

-mamdgpu-ieee and -mno-amdgpu-ieee are added to Clang to control this function 
attribute.
By default it is on. -mno-amdgpu-ieee requires -fno-honor-nans or equivalent.

Reviewed by: Matt Arsenault

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

Added: 
clang/test/CodeGenOpenCL/amdgpu-ieee.cl

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d30dca5b18dab..e0bfcf6ef3e4c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -426,6 +426,11 @@ CODEGENOPT(PassByValueIsNoAlias, 1, 0)
 /// according to the field declaring type width.
 CODEGENOPT(AAPCSBitfieldWidth, 1, 1)
 
+/// Sets the IEEE bit in the expected default floating point mode register.
+/// Floating point opcodes that support exception flag gathering quiet and
+/// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only)
+CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index a2ffe1378cb6d..1ae0df3633b35 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -129,6 +129,8 @@ def err_drv_invalid_Xopenmp_target_with_args : Error<
   "invalid -Xopenmp-target argument: '%0', options requiring arguments are 
unsupported">;
 def err_drv_argument_only_allowed_with : Error<
   "invalid argument '%0' only allowed with '%1'">;
+def err_drv_amdgpu_ieee_without_no_honor_nans : Error<
+  "invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN 
handling">;
 def err_drv_argument_not_allowed_with : Error<
   "invalid argument '%0' not allowed with '%1'">;
 def err_drv_invalid_version_number : Error<

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8c9033ded10b6..a8a7177c82cc9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3177,6 +3177,14 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group,
  HelpText<"Execution model (WebAssembly only)">;
 
+defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
+  CodeGenOpts<"EmitIEEENaNCompliantInsts">, DefaultTrue,
+  PosFlag,
+  NegFlag>, Group;
+
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
   HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 52dce97605ea9..9577b61ca6d00 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -9166,6 +9166,9 @@ void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 
   if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics())
 F->addFnAttr("amdgpu-unsafe-fp-atomics", "true");
+
+  if (!getABIInfo().getCodeGenOpts().EmitIEEENaNCompliantInsts)
+F->addFnAttr("amdgpu-ieee", "false");
 }
 
 unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 2578c8cc0b952..b3e1e06bf8a25 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1944,6 +1944,11 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions 
, ArgList ,
   else if (Args.hasArg(options::OPT_fno_finite_loops))
 Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Never;
 
+  Opts.EmitIEEENaNCompliantInsts =
+  Args.hasFlag(options::OPT_mamdgpu_ieee, options::OPT_mno_amdgpu_ieee);
+  if (!Opts.EmitIEEENaNCompliantInsts && !LangOptsRef.NoHonorNaNs)
+Diags.Report(diag::err_drv_amdgpu_ieee_without_no_honor_nans);
+
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 

diff  --git 

[PATCH] D101635: [analyzer] Fix assertion in SVals.h

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

I don't know how did we miss this. I run your patch on several projects and it 
seemed good. Does anyone have an idea how to prevent such a silly mistake from 
happening again? I was thinking of coverage data, but that wouldn't be enough 
for this example.




Comment at: clang/test/Analysis/casts.c:254-268
+// See PR50179.
+// Just don't crash.
+typedef struct taskS {
+  void *pJob;
+} taskS;
+
+typedef struct workS {

Please, @ASDenysPetrov investigate this.
I also think that this test case could be simplified, and a no-crash comment 
would be also appreciated at the corresponding line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101635

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


[PATCH] D101614: [clang-tidy][NFC] Simplify a lot of bugprone-sizeof-expression matchers

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

Update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101614

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -90,11 +90,8 @@
   const auto IntegerCallExpr = ignoringParenImpCasts(
   callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
unless(isInTemplateInstantiation(;
-  const auto SizeOfExpr = expr(anyOf(
-  sizeOfExpr(
-  has(hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type",
-  sizeOfExpr(has(expr(hasType(
-  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
+  const auto SizeOfExpr = sizeOfExpr(hasArgumentOfType(
+  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
   const auto SizeOfZero =
   sizeOfExpr(has(ignoringParenImpCasts(integerLiteral(equals(0);
 
@@ -184,9 +181,8 @@
 Finder->addMatcher(
 binaryOperator(matchers::isRelationalOperator(),
hasOperands(ignoringParenImpCasts(SizeOfExpr),
-   ignoringParenImpCasts(anyOf(
-   integerLiteral(equals(0)),
-   
integerLiteral(isBiggerThan(0x8))
+   ignoringParenImpCasts(integerLiteral(anyOf(
+   equals(0), isBiggerThan(0x8))
 .bind("sizeof-compare-constant"),
 this);
   }
@@ -207,18 +203,15 @@
   const auto ElemType =
   arrayType(hasElementType(recordType().bind("elem-type")));
   const auto ElemPtrType = pointerType(pointee(type().bind("elem-ptr-type")));
-  const auto NumType = hasCanonicalType(
-  type(anyOf(ElemType, ElemPtrType, type())).bind("num-type"));
-  const auto DenomType = hasCanonicalType(type().bind("denom-type"));
 
   Finder->addMatcher(
-  binaryOperator(hasOperatorName("/"),
- hasLHS(expr(ignoringParenImpCasts(
- anyOf(sizeOfExpr(has(NumType)),
-   sizeOfExpr(has(expr(hasType(NumType,
- hasRHS(expr(ignoringParenImpCasts(
- anyOf(sizeOfExpr(has(DenomType)),
-   sizeOfExpr(has(expr(hasType(DenomType)
+  binaryOperator(
+  hasOperatorName("/"),
+  hasLHS(ignoringParenImpCasts(sizeOfExpr(hasArgumentOfType(
+  hasCanonicalType(type(anyOf(ElemType, ElemPtrType, type()))
+   .bind("num-type")),
+  hasRHS(ignoringParenImpCasts(sizeOfExpr(
+  
hasArgumentOfType(hasCanonicalType(type().bind("denom-type")))
   .bind("sizeof-divide-expr"),
   this);
 


Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -90,11 +90,8 @@
   const auto IntegerCallExpr = ignoringParenImpCasts(
   callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
unless(isInTemplateInstantiation(;
-  const auto SizeOfExpr = expr(anyOf(
-  sizeOfExpr(
-  has(hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type",
-  sizeOfExpr(has(expr(hasType(
-  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
+  const auto SizeOfExpr = sizeOfExpr(hasArgumentOfType(
+  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
   const auto SizeOfZero =
   sizeOfExpr(has(ignoringParenImpCasts(integerLiteral(equals(0);
 
@@ -184,9 +181,8 @@
 Finder->addMatcher(
 binaryOperator(matchers::isRelationalOperator(),
hasOperands(ignoringParenImpCasts(SizeOfExpr),
-   ignoringParenImpCasts(anyOf(
-   integerLiteral(equals(0)),
-   integerLiteral(isBiggerThan(0x8))
+   ignoringParenImpCasts(integerLiteral(anyOf(
+   equals(0), isBiggerThan(0x8))
 .bind("sizeof-compare-constant"),
 this);
   }
@@ -207,18 +203,15 @@
   const auto ElemType =
   arrayType(hasElementType(recordType().bind("elem-type")));
   const auto ElemPtrType = pointerType(pointee(type().bind("elem-ptr-type")));
-  const auto NumType = hasCanonicalType(
-  type(anyOf(ElemType, ElemPtrType, 

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2021-05-01 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Sorry, I thought this landed months ago. I'll take a proper look again next 
week.




Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:158
+/// name \p LocalName shoud not present.
+void diagnoseInvalidConfigOption(StringRef LocalName) const;
+

This isn't really needed, you can just call `configurationDiag` directly.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:450
+if (!isHungarianNotationSupportedStyle(I) && HPTOpt.hasValue())
+  Options.diagnoseInvalidConfigOption(StyleString);
+StyleString.resize(StyleSize);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[clang-tools-extra] 172a801 - [clang-tidy][NFC] Remove redudnant expr and qualType matchers from bugprone-sizeof-expression.

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

Author: Nathan James
Date: 2021-05-01T08:54:00+01:00
New Revision: 172a8016788c08fff6eed71f0a8eccf0ce1ef26d

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

LOG: [clang-tidy][NFC] Remove redudnant expr and qualType matchers from 
bugprone-sizeof-expression.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
index 1123c7c77be3c..8a6f7da361967 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -84,19 +84,19 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
   // positives if sizeof is applied on template argument.
 
   const auto IntegerExpr = ignoringParenImpCasts(integerLiteral());
-  const auto ConstantExpr = expr(ignoringParenImpCasts(
+  const auto ConstantExpr = ignoringParenImpCasts(
   anyOf(integerLiteral(), unaryOperator(hasUnaryOperand(IntegerExpr)),
-binaryOperator(hasLHS(IntegerExpr), hasRHS(IntegerExpr);
-  const auto IntegerCallExpr = expr(ignoringParenImpCasts(
+binaryOperator(hasLHS(IntegerExpr), hasRHS(IntegerExpr;
+  const auto IntegerCallExpr = ignoringParenImpCasts(
   callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
-   unless(isInTemplateInstantiation();
+   unless(isInTemplateInstantiation(;
   const auto SizeOfExpr = expr(anyOf(
   sizeOfExpr(
   has(hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type",
   sizeOfExpr(has(expr(hasType(
   hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
-  const auto SizeOfZero = expr(
-  sizeOfExpr(has(ignoringParenImpCasts(expr(integerLiteral(equals(0)));
+  const auto SizeOfZero =
+  sizeOfExpr(has(ignoringParenImpCasts(integerLiteral(equals(0);
 
   // Detect expression like: sizeof(ARRAYLEN);
   // Note: The expression 'sizeof(sizeof(0))' is a portable trick used to know
@@ -111,74 +111,69 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
 
   // Detect sizeof(f())
   if (WarnOnSizeOfIntegerExpression) {
-Finder->addMatcher(
-expr(sizeOfExpr(ignoringParenImpCasts(has(IntegerCallExpr
-.bind("sizeof-integer-call"),
-this);
+Finder->addMatcher(sizeOfExpr(ignoringParenImpCasts(has(IntegerCallExpr)))
+   .bind("sizeof-integer-call"),
+   this);
   }
 
   // Detect expression like: sizeof(this);
   if (WarnOnSizeOfThis) {
-Finder->addMatcher(
-expr(sizeOfExpr(has(ignoringParenImpCasts(expr(cxxThisExpr())
-.bind("sizeof-this"),
-this);
+Finder->addMatcher(sizeOfExpr(has(ignoringParenImpCasts(cxxThisExpr(
+   .bind("sizeof-this"),
+   this);
   }
 
   // Detect sizeof(kPtr) where kPtr is 'const char* kPtr = "abc"';
   const auto CharPtrType = pointerType(pointee(isAnyCharacter()));
   const auto ConstStrLiteralDecl =
-  varDecl(isDefinition(), hasType(qualType(hasCanonicalType(CharPtrType))),
+  varDecl(isDefinition(), hasType(hasCanonicalType(CharPtrType)),
   hasInitializer(ignoringParenImpCasts(stringLiteral(;
-  Finder->addMatcher(expr(sizeOfExpr(has(ignoringParenImpCasts(expr(
-  hasType(qualType(hasCanonicalType(CharPtrType))),
-  ignoringParenImpCasts(declRefExpr(
-  hasDeclaration(ConstStrLiteralDecl
- .bind("sizeof-charp"),
- this);
+  Finder->addMatcher(
+  sizeOfExpr(has(ignoringParenImpCasts(
+ expr(hasType(hasCanonicalType(CharPtrType)),
+  ignoringParenImpCasts(declRefExpr(
+  hasDeclaration(ConstStrLiteralDecl)))
+  .bind("sizeof-charp"),
+  this);
 
   // Detect sizeof(ptr) where ptr points to an aggregate (i.e. sizeof()).
   // Do not find it if RHS of a 'sizeof(arr) / sizeof(arr[0])' expression.
-  const auto ArrayExpr = expr(ignoringParenImpCasts(
-  expr(hasType(qualType(hasCanonicalType(arrayType()));
+  const auto ArrayExpr =
+  ignoringParenImpCasts(hasType(hasCanonicalType(arrayType(;
   const auto ArrayCastExpr = expr(anyOf(
   unaryOperator(hasUnaryOperand(ArrayExpr), unless(hasOperatorName("*"))),
   binaryOperator(hasEitherOperand(ArrayExpr)),
   castExpr(hasSourceExpression(ArrayExpr;
-  const auto PointerToArrayExpr = expr(ignoringParenImpCasts(expr(
-