[PATCH] D109625: [compiler-rt] Ensure LIT_TEST_DEP targets are actually built

2021-09-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: compiler-rt/test/CMakeLists.txt:48
+  if (NOT TARGET ${dep})
+llvm_ExternalProject_BuildCmd(build_${dep} ${dep} ${BINARY_DIR})
+add_custom_target(${dep}

This is going to run Ninja in the LLVM build once for each dependency listed 
above, correct? That seems quite expensive.

We already pass most of these to the child build via corresponding CMake 
variables, see 
https://github.com/llvm/llvm-project/blob/ed921282e551f2252ccfcbddd7a85ad8a006ed3f/llvm/cmake/modules/LLVMExternalProjectUtils.cmake#L160

For example, if just need some readelf implementation and not necessarily 
llvm-readelf, it may be better to use the value of `CMAKE_READELF` and 
propagate that down to tests through substitution (that is wherever the tests 
invoke `llvm-readelf`, we would replace it with `%readelf`).

We're still going to need this logic for tools where there's no corresponding 
CMake variable like `FileCheck` but it should be significantly fewer ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109625

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


[PATCH] D109349: [clang][scan-build] Use cc/c++ instead of gcc/g++ on OpenBSD.

2021-09-16 Thread Brad Smith via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb588f5d665aa: [clang][scan-build] Use cc/c++ instead of 
gcc/g++ on OpenBSD. (authored by fcambus, committed by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109349

Files:
  clang/tools/scan-build/libexec/ccc-analyzer


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -80,6 +80,9 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
+} elsif (`uname -a` =~ m/OpenBSD/) {
+  $DefaultCCompiler = 'cc';
+  $DefaultCXXCompiler = 'c++';
 } else {
   $DefaultCCompiler = 'gcc';
   $DefaultCXXCompiler = 'g++';


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -80,6 +80,9 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
+} elsif (`uname -a` =~ m/OpenBSD/) {
+  $DefaultCCompiler = 'cc';
+  $DefaultCXXCompiler = 'c++';
 } else {
   $DefaultCCompiler = 'gcc';
   $DefaultCXXCompiler = 'g++';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b588f5d - [clang][scan-build] Use cc/c++ instead of gcc/g++ on OpenBSD.

2021-09-16 Thread Brad Smith via cfe-commits

Author: Frederic Cambus
Date: 2021-09-17T00:45:11-04:00
New Revision: b588f5d665aa01fe88921fe2ffb7256fdedfbfb0

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

LOG: [clang][scan-build] Use cc/c++ instead of gcc/g++ on OpenBSD.

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

Added: 


Modified: 
clang/tools/scan-build/libexec/ccc-analyzer

Removed: 




diff  --git a/clang/tools/scan-build/libexec/ccc-analyzer 
b/clang/tools/scan-build/libexec/ccc-analyzer
index 800f38b5ba241..ed0d4d3d73f38 100755
--- a/clang/tools/scan-build/libexec/ccc-analyzer
+++ b/clang/tools/scan-build/libexec/ccc-analyzer
@@ -80,6 +80,9 @@ if (`uname -a` =~ m/Darwin/) {
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
+} elsif (`uname -a` =~ m/OpenBSD/) {
+  $DefaultCCompiler = 'cc';
+  $DefaultCXXCompiler = 'c++';
 } else {
   $DefaultCCompiler = 'gcc';
   $DefaultCXXCompiler = 'g++';



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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-16 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 373139.
cchen added a comment.

Fix flang issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1701,6 +1702,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1322,6 +1322,7 @@
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
+CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 

[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D109632#3000709 , @rmaz wrote:

> The speedup is coming from reducing the number of times 
> `Sema::addMethodToGlobalList` is called when looking up methods loaded from 
> modules. From what I can see each serialized module will contain an 
> ObjCMethodList with all the methods from all visible modules at the point of 
> serialization.

Thanks for the explanation! I'm still curious to reproduce the problem locally 
and have created a test case generator 
https://gist.github.com/vsapsai/f9d3603dde95eebd23248da4d7b4f5ec It creates a 
chain of .m -> Synthesized9 -> Synthesized8 -> Synthesized7 ->... Does it 
represent the structure of the code you are dealing with?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109799: [RISCV] add Half-precision test for load/store

2021-09-16 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 373129.
achieveartificialintelligence added a comment.

add Half-precision test for segment load/store


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109799

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics/vleff.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vssseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxseg.c

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


[PATCH] D109943: [Clang] Fix long double availability check

2021-09-16 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
Herald added subscribers: steven.zhang, mstorsjo, jvesely.
qiucf requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

fae0dfa  
changed code to check 128-bit float availability, since it introduced a new 
128-bit double type on PowerPC. However, there're other long float types 
besides IEEE float128 and PPC double-double requiring this feature. This patch 
fixes it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109943

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp


Index: clang/test/OpenMP/amdgcn_ldbl_check.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 
-fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device 
-fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+   return (double)a;
+}
+
+int main()
+{
+   auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+   {
+#pragma omp teams num_teams(1) thread_limit(4)
+   {
+   a += 1._X;
+   }
+   }
+  print(a);
+   return 0;
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@
 bool LongDoubleMismatched = false;
 if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
   const llvm::fltSemantics  = Context.getFloatTypeSemantics(Ty);
-  if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-   != ().getLongDoubleFormat())
+  if (( != ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
+  ( == ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasIbm128Type()))
 LongDoubleMismatched = true;
 }
 


Index: clang/test/OpenMP/amdgcn_ldbl_check.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 -fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+	return (double)a;
+}
+
+int main()
+{
+	auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+	{
+#pragma omp teams num_teams(1) thread_limit(4)
+		{
+			a += 1._X;
+		}
+	}
+  print(a);
+	return 0;
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@
 bool LongDoubleMismatched = false;
 if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
   const llvm::fltSemantics  = Context.getFloatTypeSemantics(Ty);
-  if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-   != ().getLongDoubleFormat())
+  if (( != ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
+  ( == ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasIbm128Type()))
 LongDoubleMismatched = true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-16 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe9e1d4751b54: [X86] Refactor GetSSETypeAtOffset to fix 
pr51813 (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/X86/avx512fp16-abi.c

Index: clang/test/CodeGen/X86/avx512fp16-abi.c
===
--- clang/test/CodeGen/X86/avx512fp16-abi.c
+++ clang/test/CodeGen/X86/avx512fp16-abi.c
@@ -1,11 +1,12 @@
-// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-feature +avx512fp16 < %s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-feature +avx512fp16 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-feature +avx512fp16 -x c++ -std=c++11 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CPP
 
 struct half1 {
   _Float16 a;
 };
 
 struct half1 h1(_Float16 a) {
-  // CHECK: define{{.*}}half @h1
+  // CHECK: define{{.*}}half @
   struct half1 x;
   x.a = a;
   return x;
@@ -17,7 +18,7 @@
 };
 
 struct half2 h2(_Float16 a, _Float16 b) {
-  // CHECK: define{{.*}}<2 x half> @h2
+  // CHECK: define{{.*}}<2 x half> @
   struct half2 x;
   x.a = a;
   x.b = b;
@@ -31,7 +32,7 @@
 };
 
 struct half3 h3(_Float16 a, _Float16 b, _Float16 c) {
-  // CHECK: define{{.*}}<4 x half> @h3
+  // CHECK: define{{.*}}<4 x half> @
   struct half3 x;
   x.a = a;
   x.b = b;
@@ -47,7 +48,7 @@
 };
 
 struct half4 h4(_Float16 a, _Float16 b, _Float16 c, _Float16 d) {
-  // CHECK: define{{.*}}<4 x half> @h4
+  // CHECK: define{{.*}}<4 x half> @
   struct half4 x;
   x.a = a;
   x.b = b;
@@ -62,7 +63,7 @@
 };
 
 struct floathalf fh(float a, _Float16 b) {
-  // CHECK: define{{.*}}<4 x half> @fh
+  // CHECK: define{{.*}}<4 x half> @
   struct floathalf x;
   x.a = a;
   x.b = b;
@@ -76,7 +77,7 @@
 };
 
 struct floathalf2 fh2(float a, _Float16 b, _Float16 c) {
-  // CHECK: define{{.*}}<4 x half> @fh2
+  // CHECK: define{{.*}}<4 x half> @
   struct floathalf2 x;
   x.a = a;
   x.b = b;
@@ -90,7 +91,7 @@
 };
 
 struct halffloat hf(_Float16 a, float b) {
-  // CHECK: define{{.*}}<4 x half> @hf
+  // CHECK: define{{.*}}<4 x half> @
   struct halffloat x;
   x.a = a;
   x.b = b;
@@ -104,7 +105,7 @@
 };
 
 struct half2float h2f(_Float16 a, _Float16 b, float c) {
-  // CHECK: define{{.*}}<4 x half> @h2f
+  // CHECK: define{{.*}}<4 x half> @
   struct half2float x;
   x.a = a;
   x.b = b;
@@ -120,7 +121,7 @@
 };
 
 struct floathalf3 fh3(float a, _Float16 b, _Float16 c, _Float16 d) {
-  // CHECK: define{{.*}}{ <4 x half>, half } @fh3
+  // CHECK: define{{.*}}{ <4 x half>, half } @
   struct floathalf3 x;
   x.a = a;
   x.b = b;
@@ -138,7 +139,7 @@
 };
 
 struct half5 h5(_Float16 a, _Float16 b, _Float16 c, _Float16 d, _Float16 e) {
-  // CHECK: define{{.*}}{ <4 x half>, half } @h5
+  // CHECK: define{{.*}}{ <4 x half>, half } @
   struct half5 x;
   x.a = a;
   x.b = b;
@@ -147,3 +148,52 @@
   x.e = e;
   return x;
 }
+
+struct float2 {
+  struct {} s;
+  float a;
+  float b;
+};
+
+float pr51813(struct float2 s) {
+  // CHECK-C: define{{.*}} @pr51813(<2 x float>
+  // CHECK-CPP: define{{.*}} @_Z7pr518136float2(double {{.*}}, float
+  return s.a;
+}
+
+struct float3 {
+  float a;
+  struct {} s;
+  float b;
+};
+
+float pr51813_2(struct float3 s) {
+  // CHECK-C: define{{.*}} @pr51813_2(<2 x float>
+  // CHECK-CPP: define{{.*}} @_Z9pr51813_26float3(double {{.*}}, float
+  return s.a;
+}
+
+struct shalf2 {
+  struct {} s;
+  _Float16 a;
+  _Float16 b;
+};
+
+_Float16 sf2(struct shalf2 s) {
+  // CHECK-C: define{{.*}} @sf2(<2 x half>
+  // CHECK-CPP: define{{.*}} @_Z3sf26shalf2(double {{.*}}
+  return s.a;
+};
+
+struct halfs2 {
+  _Float16 a;
+  struct {} s1;
+  _Float16 b;
+  struct {} s2;
+};
+
+_Float16 fs2(struct shalf2 s) {
+  // CHECK-C: define{{.*}} @fs2(<2 x half>
+  // CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}}
+  return s.a;
+};
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3407,52 +3407,18 @@
   return false;
 }
 
-/// ContainsFloatAtOffset - Return true if the specified LLVM IR type has a
-/// float member at the specified offset.  For example, {int,{float}} has a
-/// float at offset 4.  It is conservatively correct for this routine to return
-/// false.
-static bool ContainsFloatAtOffset(llvm::Type *IRType, unsigned IROffset,
-  const llvm::DataLayout ) {
-  // Base case if we find a float.
-  if (IROffset == 0 && IRType->isFloatTy())
-return true;
-
-  // If this is a struct, recurse into the field at the specified offset.
-  if (llvm::StructType *STy = dyn_cast(IRType)) {
-const llvm::StructLayout *SL = 

[clang] e9e1d47 - [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-16 Thread via cfe-commits

Author: Wang, Pengfei
Date: 2021-09-17T10:51:59+08:00
New Revision: e9e1d4751b54126743ed72b1a9178ee51200acf6

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

LOG: [X86] Refactor GetSSETypeAtOffset to fix pr51813

D105263 adds support for _Float16 type. It introduced a bug (pr51813) that 
generates a <4 x half> type instead the default double when passing blank 
structure by SSE registers.

Although I doubt it may expose a bug somewhere other than D105263, it's good to 
avoid return half type when no half type in arguments.

Reviewed By: LuoYuanke

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/X86/avx512fp16-abi.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 67d0c2b5c850..58d43bd36565 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -3407,52 +3407,18 @@ static bool BitsContainNoUserData(QualType Ty, unsigned 
StartBit,
   return false;
 }
 
-/// ContainsFloatAtOffset - Return true if the specified LLVM IR type has a
-/// float member at the specified offset.  For example, {int,{float}} has a
-/// float at offset 4.  It is conservatively correct for this routine to return
-/// false.
-static bool ContainsFloatAtOffset(llvm::Type *IRType, unsigned IROffset,
-  const llvm::DataLayout ) {
-  // Base case if we find a float.
-  if (IROffset == 0 && IRType->isFloatTy())
-return true;
-
-  // If this is a struct, recurse into the field at the specified offset.
-  if (llvm::StructType *STy = dyn_cast(IRType)) {
-const llvm::StructLayout *SL = TD.getStructLayout(STy);
-unsigned Elt = SL->getElementContainingOffset(IROffset);
-IROffset -= SL->getElementOffset(Elt);
-return ContainsFloatAtOffset(STy->getElementType(Elt), IROffset, TD);
-  }
-
-  // If this is an array, recurse into the field at the specified offset.
-  if (llvm::ArrayType *ATy = dyn_cast(IRType)) {
-llvm::Type *EltTy = ATy->getElementType();
-unsigned EltSize = TD.getTypeAllocSize(EltTy);
-IROffset -= IROffset/EltSize*EltSize;
-return ContainsFloatAtOffset(EltTy, IROffset, TD);
-  }
-
-  return false;
-}
-
-/// ContainsHalfAtOffset - Return true if the specified LLVM IR type has a
-/// half member at the specified offset.  For example, {int,{half}} has a
-/// half at offset 4.  It is conservatively correct for this routine to return
-/// false.
-/// FIXME: Merge with ContainsFloatAtOffset
-static bool ContainsHalfAtOffset(llvm::Type *IRType, unsigned IROffset,
- const llvm::DataLayout ) {
-  // Base case if we find a float.
-  if (IROffset == 0 && IRType->isHalfTy())
-return true;
+/// getFPTypeAtOffset - Return a floating point type at the specified offset.
+static llvm::Type *getFPTypeAtOffset(llvm::Type *IRType, unsigned IROffset,
+ const llvm::DataLayout ) {
+  if (IROffset == 0 && IRType->isFloatingPointTy())
+return IRType;
 
   // If this is a struct, recurse into the field at the specified offset.
   if (llvm::StructType *STy = dyn_cast(IRType)) {
 const llvm::StructLayout *SL = TD.getStructLayout(STy);
 unsigned Elt = SL->getElementContainingOffset(IROffset);
 IROffset -= SL->getElementOffset(Elt);
-return ContainsHalfAtOffset(STy->getElementType(Elt), IROffset, TD);
+return getFPTypeAtOffset(STy->getElementType(Elt), IROffset, TD);
   }
 
   // If this is an array, recurse into the field at the specified offset.
@@ -3460,10 +3426,10 @@ static bool ContainsHalfAtOffset(llvm::Type *IRType, 
unsigned IROffset,
 llvm::Type *EltTy = ATy->getElementType();
 unsigned EltSize = TD.getTypeAllocSize(EltTy);
 IROffset -= IROffset / EltSize * EltSize;
-return ContainsHalfAtOffset(EltTy, IROffset, TD);
+return getFPTypeAtOffset(EltTy, IROffset, TD);
   }
 
-  return false;
+  return nullptr;
 }
 
 /// GetSSETypeAtOffset - Return a type that will be passed by the backend in 
the
@@ -3471,39 +3437,37 @@ static bool ContainsHalfAtOffset(llvm::Type *IRType, 
unsigned IROffset,
 llvm::Type *X86_64ABIInfo::
 GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
QualType SourceTy, unsigned SourceOffset) const {
-  // If the high 32 bits are not used, we have three choices. Single half,
-  // single float or two halfs.
-  if (BitsContainNoUserData(SourceTy, SourceOffset * 8 + 32,
-SourceOffset * 8 + 64, getContext())) {
-if (ContainsFloatAtOffset(IRType, IROffset, getDataLayout()))
-  return llvm::Type::getFloatTy(getVMContext());
-if (ContainsHalfAtOffset(IRType, IROffset + 2, getDataLayout()))
-  

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-16 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 373125.
cchen added a comment.

Rebase and fix warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1701,6 +1702,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
+  ;
+#pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
+  

[PATCH] D36850: [ThinLTO] Add norecurse function attribute propagation

2021-09-16 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/include/llvm/IR/ModuleSummaryIndex.h:580
+// If there are calls to unknown targets (e.g. indirect)
+unsigned hasUnknownCall : 1;
+

modimo wrote:
> tejohnson wrote:
> > Now that we have MayThrow, can we avoid a separate hasUnknownCall bool and 
> > just conservatively set MayThrow true in that case?
> hasUnknownCall is used for norecurse and other future flags as well to stop 
> propagation.
Ah that makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36850

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


[PATCH] D36850: [ThinLTO] Add norecurse function attribute propagation

2021-09-16 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D36850#3005254 , @tejohnson wrote:

> Ok thanks. I need to go through the propagation code and tests again more 
> closely now, but one question/suggestion below in the meantime.

Thanks!




Comment at: llvm/include/llvm/IR/ModuleSummaryIndex.h:580
+// If there are calls to unknown targets (e.g. indirect)
+unsigned hasUnknownCall : 1;
+

tejohnson wrote:
> Now that we have MayThrow, can we avoid a separate hasUnknownCall bool and 
> just conservatively set MayThrow true in that case?
hasUnknownCall is used for norecurse and other future flags as well to stop 
propagation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36850

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


[PATCH] D109625: [compiler-rt] Ensure LIT_TEST_DEP targets are actually built

2021-09-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109625

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-16 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 373109.
cchen added a comment.

Fix ast errors and add some tiny fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1701,6 +1702,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
+  ;
+#pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; 

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-09-16 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 373107.
ggeorgakoudis added a comment.

Remove unnecessary comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/CodeGenCXX/observe-noexcept.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-09-16 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 373105.
ggeorgakoudis added a comment.

Add previous, upper bound to aggregate for combined distributed directives.
Update tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/CodeGenCXX/observe-noexcept.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen_PR51349.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  

[PATCH] D36850: [ThinLTO] Add norecurse function attribute propagation

2021-09-16 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

Ok thanks. I need to go through the propagation code and tests again more 
closely now, but one question/suggestion below in the meantime.




Comment at: llvm/include/llvm/IR/ModuleSummaryIndex.h:580
+// If there are calls to unknown targets (e.g. indirect)
+unsigned hasUnknownCall : 1;
+

Now that we have MayThrow, can we avoid a separate hasUnknownCall bool and just 
conservatively set MayThrow true in that case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36850

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1434-1436
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}

Hmm, I was imagining that the set would be more encapsulated than this, not 
just stored in the same place.

I'm wondering if the following could be done in a prep commit:

- Change Sema::addMethodToGlobalList to a private member function of 
GlobalMethodPool.
- Make GlobalMethodPool::insert private
- Add `GlobalMethodPool::addMethod(ObjCMethodDecl*,bool,bool)`, which does the 
second half of Sema::AddMethodToGlobalPool (the parts that don't need Sema's 
other fields), and change the latter to call the former.

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-09-16 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev updated this revision to Diff 373076.

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

https://reviews.llvm.org/D106876

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
  clang/test/Modules/add-remove-irrelevant-mobile-map.m
  clang/test/SemaCXX/Inputs/compare.modulemap
  clang/test/SemaCXX/compare-modules-cxx2a.cpp

Index: clang/test/SemaCXX/compare-modules-cxx2a.cpp
===
--- clang/test/SemaCXX/compare-modules-cxx2a.cpp
+++ clang/test/SemaCXX/compare-modules-cxx2a.cpp
@@ -1,15 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
 
-#pragma clang module build compare
-module compare {
-  explicit module cmp {}
-  explicit module other {}
-}
-#pragma clang module contents
-#pragma clang module begin compare.cmp
-#include "std-compare.h"
-#pragma clang module end
-#pragma clang module endbuild
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery -fmodule-map-file=%S/Inputs/compare.modulemap
 
 struct CC { CC(...); };
 
@@ -24,10 +16,10 @@
 
 // expected-note@std-compare.h:* 2+{{not reachable}}
 
-void b() { void(0 <=> 0); } // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+void b() { void(0 <=> 0); } // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 
 struct B {
-  CC operator<=>(const B&) const = default; // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+  CC operator<=>(const B&) const = default; // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 };
 auto vb = B() <=> B(); // expected-note {{required here}}
 
Index: clang/test/SemaCXX/Inputs/compare.modulemap
===
--- /dev/null
+++ clang/test/SemaCXX/Inputs/compare.modulemap
@@ -0,0 +1,6 @@
+module compare {
+  explicit module cmp {
+header "std-compare.h"
+  }
+  explicit module other {}
+}
Index: clang/test/Modules/add-remove-irrelevant-mobile-map.m
===
--- /dev/null
+++ clang/test/Modules/add-remove-irrelevant-mobile-map.m
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
+
+// Build with a.modulemap
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap %s -verify
+// RUN: cp %t.mcp/a.pcm %t/a.pcm
+
+// Build without b.modulemap
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap %s -verify
+// RUN: not diff %t.mcp/a.pcm %t/a.pcm
+
+// expected-no-diagnostics
+
+@import a;
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
@@ -0,0 +1 @@
+module b { }
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
@@ -0,0 +1 @@
+module a { }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -149,6 +149,59 @@
 
 namespace {
 
+std::set GetAllModuleMaps(const HeaderSearch ,
+ Module *RootModule) {
+  std::set ModuleMaps{};
+  std::set ProcessedModules;
+  SmallVector ModulesToProcess{RootModule};
+
+  SmallVector FilesByUID;
+  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+
+  if (FilesByUID.size() > HS.header_file_size())
+FilesByUID.resize(HS.header_file_size());
+
+  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
+const FileEntry *File = FilesByUID[UID];
+if (!File)
+  continue;
+
+const HeaderFileInfo *HFI =
+HS.getExistingFileInfo(File, /*WantExternal*/ false);
+if (!HFI)
+  continue;
+
+const auto KnownHeaders = HS.findAllModulesForHeader(File);
+for (const auto  : KnownHeaders) {
+  if (!KH.getModule())
+

[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-16 Thread Richard Howell via Phabricator via cfe-commits
rmaz updated this revision to Diff 373072.
rmaz added a comment.

Update with single DenseSet per GlobalMethodPool


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclObjC.cpp


Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3302,6 +3302,10 @@
 
 void Sema::addMethodToGlobalList(ObjCMethodList *List,
  ObjCMethodDecl *Method) {
+  // Do not insert duplicate methods into the method pool.
+  if (!MethodPool.addMethod(Method))
+return;
+
   // Record at the head of the list whether there were 0, 1, or >= 2 methods
   // inside categories.
   if (ObjCCategoryDecl *CD =
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1431,9 +1431,13 @@
 }
 int count(Selector Sel) const { return Methods.count(Sel); }
 bool empty() const { return Methods.empty(); }
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}
 
   private:
 llvm::DenseMap Methods;
+llvm::DenseSet AddedMethods;
   };
 
   /// Method Pool - allows efficient lookup when typechecking messages to "id".


Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3302,6 +3302,10 @@
 
 void Sema::addMethodToGlobalList(ObjCMethodList *List,
  ObjCMethodDecl *Method) {
+  // Do not insert duplicate methods into the method pool.
+  if (!MethodPool.addMethod(Method))
+return;
+
   // Record at the head of the list whether there were 0, 1, or >= 2 methods
   // inside categories.
   if (ObjCCategoryDecl *CD =
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1431,9 +1431,13 @@
 }
 int count(Selector Sel) const { return Methods.count(Sel); }
 bool empty() const { return Methods.empty(); }
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}
 
   private:
 llvm::DenseMap Methods;
+llvm::DenseSet AddedMethods;
   };
 
   /// Method Pool - allows efficient lookup when typechecking messages to "id".
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109862: Don't diagnose unused but set when the Cleanup attribute is used.

2021-09-16 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield updated this revision to Diff 373069.
mbenfield added a comment.

Added a test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109862

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-unused-but-set-variables.c


Index: clang/test/Sema/warn-unused-but-set-variables.c
===
--- clang/test/Sema/warn-unused-but-set-variables.c
+++ clang/test/Sema/warn-unused-but-set-variables.c
@@ -49,3 +49,13 @@
   x = 0;
   (void) sizeof(x);
 }
+
+void for_cleanup(int *x) {
+  *x = 0;
+}
+
+void f3(void) {
+  // Don't warn if the __cleanup__ attribute is used.
+  __attribute__((__cleanup__(for_cleanup))) int x;
+  x = 5;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1921,8 +1921,10 @@
 }
 
 void Sema::DiagnoseUnusedButSetDecl(const VarDecl *VD) {
-  // If it's not referenced, it can't be set.
-  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr())
+  // If it's not referenced, it can't be set. If it has the Cleanup attribute,
+  // it's not really unused.
+  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr() ||
+  VD->hasAttr())
 return;
 
   const auto *Ty = VD->getType().getTypePtr()->getBaseElementTypeUnsafe();


Index: clang/test/Sema/warn-unused-but-set-variables.c
===
--- clang/test/Sema/warn-unused-but-set-variables.c
+++ clang/test/Sema/warn-unused-but-set-variables.c
@@ -49,3 +49,13 @@
   x = 0;
   (void) sizeof(x);
 }
+
+void for_cleanup(int *x) {
+  *x = 0;
+}
+
+void f3(void) {
+  // Don't warn if the __cleanup__ attribute is used.
+  __attribute__((__cleanup__(for_cleanup))) int x;
+  x = 5;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1921,8 +1921,10 @@
 }
 
 void Sema::DiagnoseUnusedButSetDecl(const VarDecl *VD) {
-  // If it's not referenced, it can't be set.
-  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr())
+  // If it's not referenced, it can't be set. If it has the Cleanup attribute,
+  // it's not really unused.
+  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr() ||
+  VD->hasAttr())
 return;
 
   const auto *Ty = VD->getType().getTypePtr()->getBaseElementTypeUnsafe();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109898: [clang][NFC] refactor GlobalMethodPool to encapsulate its map

2021-09-16 Thread Daniel Rodríguez Troitiño via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe6020b2a4224: [clang][NFC] refactor GlobalMethodPool to 
encapsulate its map (authored by rmaz, committed by drodriguez).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109898

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8208,8 +8208,9 @@
 return;
 
   Sema  = *getSema();
-  Sema::GlobalMethodPool::iterator Pos
-= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
+  Sema::GlobalMethodPool::iterator Pos =
+  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
+  .first;
 
   Pos->second.first.setBits(Visitor.getInstanceBits());
   
Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3427,8 +3427,10 @@
 
   GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
   if (Pos == MethodPool.end())
-Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
-   GlobalMethods())).first;
+Pos = MethodPool
+  .insert(std::make_pair(Method->getSelector(),
+ GlobalMethodPool::Lists()))
+  .first;
 
   Method->setDefined(impl);
 
@@ -3636,7 +3638,7 @@
   if (Pos == MethodPool.end())
 return nullptr;
 
-  GlobalMethods  = Pos->second;
+  GlobalMethodPool::Lists  = Pos->second;
   for (const ObjCMethodList *Method =  Method;
Method = Method->getNext())
 if (Method->getMethod() &&
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1419,8 +1419,22 @@
   const llvm::MapVector &
   getMismatchingDeleteExpressions() const;
 
-  typedef std::pair GlobalMethods;
-  typedef llvm::DenseMap GlobalMethodPool;
+  class GlobalMethodPool {
+  public:
+using Lists = std::pair;
+using iterator = llvm::DenseMap::iterator;
+iterator begin() { return Methods.begin(); }
+iterator end() { return Methods.end(); }
+iterator find(Selector Sel) { return Methods.find(Sel); }
+std::pair insert(std::pair &) {
+  return Methods.insert(Val);
+}
+int count(Selector Sel) const { return Methods.count(Sel); }
+bool empty() const { return Methods.empty(); }
+
+  private:
+llvm::DenseMap Methods;
+  };
 
   /// Method Pool - allows efficient lookup when typechecking messages to "id".
   /// We need to maintain a list, since selectors can have differing signatures


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8208,8 +8208,9 @@
 return;
 
   Sema  = *getSema();
-  Sema::GlobalMethodPool::iterator Pos
-= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
+  Sema::GlobalMethodPool::iterator Pos =
+  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
+  .first;
 
   Pos->second.first.setBits(Visitor.getInstanceBits());
   Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3427,8 +3427,10 @@
 
   GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
   if (Pos == MethodPool.end())
-Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
-   GlobalMethods())).first;
+Pos = MethodPool
+  .insert(std::make_pair(Method->getSelector(),
+ GlobalMethodPool::Lists()))
+  .first;
 
   Method->setDefined(impl);
 
@@ -3636,7 +3638,7 @@
   if (Pos == MethodPool.end())
 return nullptr;
 
-  GlobalMethods  = Pos->second;
+  GlobalMethodPool::Lists  = Pos->second;
   for (const ObjCMethodList *Method =  Method;
Method = Method->getNext())
 if (Method->getMethod() &&
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1419,8 +1419,22 @@
   const llvm::MapVector &
   getMismatchingDeleteExpressions() const;
 
-  typedef std::pair GlobalMethods;
-  typedef 

[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-16 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 373065.
browneee added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/test/dfsan/Inputs/flags_abilist.txt
  compiler-rt/test/dfsan/force_zero.c
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
  llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s -DSHADOW_XOR_MASK=87960930222080
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+define i32 @function_to_force_zero(i32 %0, i32* %1) {
+  ; CHECK-LABEL: define i32 @function_to_force_zero.dfsan
+  ; CHECK: %[[#SHADOW_XOR:]] = xor i64 {{.*}}, [[SHADOW_XOR_MASK]]
+  ; CHECK: %[[#SHADOW_PTR:]] = inttoptr i64 %[[#SHADOW_XOR]] to i8*
+  ; CHECK: %[[#SHADOW_BITCAST:]] = bitcast i8* %[[#SHADOW_PTR]] to i32*
+  ; CHECK: store i32 0, i32* %[[#SHADOW_BITCAST]]
+  ; CHECK: store i32 %{{.*}}
+  store i32 %0, i32* %1, align 4
+  ; CHECK: store i8 0, {{.*}}@__dfsan_retval_tls
+  ; CHECK: ret i32
+  ret i32 %0
+}
Index: llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===
--- llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -8,3 +8,5 @@
 fun:custom*=custom
 
 fun:uninstrumented*=uninstrumented
+
+fun:function_to_force_zero=force_zero_labels
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -144,8 +144,17 @@
 // to the "native" (i.e. unsanitized) ABI.  Unless the ABI list contains
 // additional annotations for those functions, a call to one of those functions
 // will produce a warning message, as the labelling behaviour of the function is
-// unknown.  The other supported annotations are "functional" and "discard",
-// which are described below under DataFlowSanitizer::WrapperKind.
+// unknown. The other supported annotations for uninstrumented functions are
+// "functional" and "discard", which are described below under
+// DataFlowSanitizer::WrapperKind.
+// Functions will often be labelled with both "uninstrumented" and one of
+// "functional" or "discard". This will leave the function unchanged by this
+// pass, and create a wrapper function with that will call the original.
+//
+// Instrumented functions can also be annotated as "force_zero_labels", which
+// will make all shadow stores and label for return values set zero labels.
+// Functions should never be labelled with both "force_zero_labels" and
+// "uninstrumented" or any of the unistrumented wrapper kinds.
 static cl::list ClABIListFiles(
 "dfsan-abilist",
 cl::desc("File listing native ABI functions and how the pass treats them"),
@@ -469,6 +478,7 @@
   getShadowOriginAddress(Value *Addr, Align InstAlignment, Instruction *Pos);
   bool isInstrumented(const Function *F);
   bool isInstrumented(const GlobalAlias *GA);
+  bool isForceZeroLabels(const Function *F);
   FunctionType *getArgsFunctionType(FunctionType *T);
   FunctionType *getTrampolineFunctionType(FunctionType *T);
   TransformedFunction getCustomFunctionType(FunctionType *T);
@@ -541,6 +551,7 @@
   DominatorTree DT;
   DataFlowSanitizer::InstrumentedABI IA;
   bool IsNativeABI;
+  bool IsForceZeroLabels;
   AllocaInst *LabelReturnAlloca = nullptr;
   AllocaInst *OriginReturnAlloca = nullptr;
   DenseMap ValShadowMap;
@@ -571,8 +582,10 @@
   DenseMap CachedCollapsedShadows;
   DenseMap> ShadowElements;
 
-  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI)
-  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI) {
+  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI,
+bool IsForceZeroLabels)
+  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI),
+IsForceZeroLabels(IsForceZeroLabels) {
 DT.recalculate(*F);
   }
 
@@ -1107,6 +1120,10 @@
   return !ABIList.isIn(*GA, "uninstrumented");
 }
 
+bool DataFlowSanitizer::isForceZeroLabels(const Function *F) {
+  return ABIList.isIn(*F, "force_zero_labels");
+}
+
 DataFlowSanitizer::InstrumentedABI DataFlowSanitizer::getInstrumentedABI() {
   return ClArgsABI ? IA_Args : IA_TLS;
 }
@@ -1197,7 

[clang] e6020b2 - [clang][NFC] refactor GlobalMethodPool to encapsulate its map

2021-09-16 Thread Daniel Rodríguez Troitiño via cfe-commits

Author: Richard Howell
Date: 2021-09-16T14:02:14-07:00
New Revision: e6020b2a42245d888e941eba66fbce9d0c4ab0a8

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

LOG: [clang][NFC] refactor GlobalMethodPool to encapsulate its map

This refactor changes the GlobalMethodPool to a class that contains
the DenseMap of methods. This is to allow for the addition of a
separate DenseSet in a follow-up diff that will handle method
de-duplication when inserting methods into the global method pool.

Changes:
  - the `GlobalMethods` pair becomes `GlobalMethodPool::Lists`
  - the `GlobalMethodPool` becomes a class containing the `DenseMap` of methods
  - pass through methods are added to maintain most of the existing code 
without changing `MethodPool` -> `MethodPool.Methods` everywhere

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6214ef650384..ebe2438141b6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1419,8 +1419,22 @@ class Sema final {
   const llvm::MapVector &
   getMismatchingDeleteExpressions() const;
 
-  typedef std::pair GlobalMethods;
-  typedef llvm::DenseMap GlobalMethodPool;
+  class GlobalMethodPool {
+  public:
+using Lists = std::pair;
+using iterator = llvm::DenseMap::iterator;
+iterator begin() { return Methods.begin(); }
+iterator end() { return Methods.end(); }
+iterator find(Selector Sel) { return Methods.find(Sel); }
+std::pair insert(std::pair &) {
+  return Methods.insert(Val);
+}
+int count(Selector Sel) const { return Methods.count(Sel); }
+bool empty() const { return Methods.empty(); }
+
+  private:
+llvm::DenseMap Methods;
+  };
 
   /// Method Pool - allows efficient lookup when typechecking messages to "id".
   /// We need to maintain a list, since selectors can have 
diff ering signatures

diff  --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index e0f8c6e92d5a..f19a041fa487 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -3427,8 +3427,10 @@ void Sema::AddMethodToGlobalPool(ObjCMethodDecl *Method, 
bool impl,
 
   GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
   if (Pos == MethodPool.end())
-Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
-   GlobalMethods())).first;
+Pos = MethodPool
+  .insert(std::make_pair(Method->getSelector(),
+ GlobalMethodPool::Lists()))
+  .first;
 
   Method->setDefined(impl);
 
@@ -3636,7 +3638,7 @@ ObjCMethodDecl 
*Sema::LookupImplementedMethodInGlobalPool(Selector Sel) {
   if (Pos == MethodPool.end())
 return nullptr;
 
-  GlobalMethods  = Pos->second;
+  GlobalMethodPool::Lists  = Pos->second;
   for (const ObjCMethodList *Method =  Method;
Method = Method->getNext())
 if (Method->getMethod() &&

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 3dbcea766c53..b015ca10dc3a 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8208,8 +8208,9 @@ void ASTReader::ReadMethodPool(Selector Sel) {
 return;
 
   Sema  = *getSema();
-  Sema::GlobalMethodPool::iterator Pos
-= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
+  Sema::GlobalMethodPool::iterator Pos =
+  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
+  .first;
 
   Pos->second.first.setBits(Visitor.getInstanceBits());
   
Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());



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


[PATCH] D109925: [AST] add warnings for out-of-bounds FP values when using relaxed FP math compile flags

2021-09-16 Thread Sanjay Patel via Phabricator via cfe-commits
spatel created this revision.
spatel added reviewers: sepavloff, jyknight, efriedma, dim, kparzysz, rsmith.
Herald added a subscriber: mcrosier.
spatel requested review of this revision.

There's currently ongoing discussion on the dev lists about how to handle 
related cases with isnan() / isinf(), but I don't think the problem addressed 
by this patch is controversial:
If the compile specified loose FP math because special values like NaN / Inf / 
-0.0 are not expected, then we should warn if the code contains an obvious 
occurrence of any of those values.

My understanding of clang isn't good though. Is this the right place to detect 
the unexpected values? I commented in the test file that I don't see the 
expected warnings in all cases before CodeGen. But if we run through to IR 
creation, then I sometimes see duplicate warnings for the same line of code.

For example, I see duplicate 3 warnings on this program based on 
https://llvm.org/PR51775 :

  % cat 51775.c 
  #include 
  #include 
  int main() {
  const double d = strtod("1E+100", NULL);
  return d == HUGE_VAL;
  }



  % clang -O1 -ffast-math 51775.c -S -o -
  51775.c:5:17: warning: floating-point infinity may be optimized out of 
computation or comparison [-Wliteral-range]
  return d == HUGE_VAL;
  ^
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:57:28:
 note: expanded from macro 'HUGE_VAL'
  #   defineHUGE_VAL __builtin_huge_val()
 ^
  51775.c:5:17: warning: floating-point infinity may be optimized out of 
computation or comparison [-Wliteral-range]
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:57:28:
 note: expanded from macro 'HUGE_VAL'
  #   defineHUGE_VAL __builtin_huge_val()
 ^
  51775.c:5:17: warning: floating-point infinity may be optimized out of 
computation or comparison [-Wliteral-range]
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:57:28:
 note: expanded from macro 'HUGE_VAL'
  #   defineHUGE_VAL __builtin_huge_val()
  ...


https://reviews.llvm.org/D109925

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/warn-fp-values.c

Index: clang/test/AST/warn-fp-values.c
===
--- /dev/null
+++ clang/test/AST/warn-fp-values.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -verify -fsyntax-only -ffast-math -Wliteral-range
+
+#define INFINITY_MATH_MACRO  1.0 / 0.0
+
+#define NAN_MATH_MACRO  0.0f / 0.0f
+
+// Infinity
+
+double inf_by_macro() {
+  double d = INFINITY_MATH_MACRO; // expected-warning {{floating-point infinity may be optimized}}
+  return d;
+}
+
+float inf_by_overflow() {
+  const float huge_literal = 10e100f; // expected-warning {{magnitude of floating-point constant too large}} {{floating-point infinity may be optimized}}
+  return huge_literal;
+}
+
+double inf_by_builtin() {
+  double b = __builtin_inf(); // shows warning if compile continues with -emit-llvm
+  return b;
+}
+
+float inf_by_builtin_cast() {
+  float b = __builtin_inf(); // expected-warning {{floating-point infinity may be optimized}}
+  return b;
+}
+
+// NaN
+
+float nan_by_macro() {
+  float f = NAN_MATH_MACRO; // expected-warning {{floating-point NaN may be optimized}}
+  return f;
+}
+
+double nan_by_builtin() {
+  double b = __builtin_nan(""); // shows warning if compile continues with -emit-llvm
+  return b;
+}
+
+float nan_by_builtin_cast() {
+  float b = __builtin_nan(""); // expected-warning {{floating-point NaN may be optimized}}
+  return b;
+}
+
+// -0.0
+
+double neg_zero_literal() {
+  return -0.0; // shows warning if compile continues with -emit-llvm
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -13563,10 +13563,22 @@
 };
 } // end anonymous namespace
 
-static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo ) {
+static bool EvaluateFloat(const Expr *E, APFloat , EvalInfo ) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->isRealFloatingType());
-  return FloatExprEvaluator(Info, Result).Visit(E);
+  bool Status = FloatExprEvaluator(Info, Result).Visit(E);
+
+  // Warn if we encounter a floating-point special value that is potentially
+  // constant-folded by the optimizer.
+  const FPOptions  = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
+  if (Result.isInfinity() && FPO.getNoHonorInfs())
+Info.Ctx.getDiagnostics().Report(E->getExprLoc(), diag::warn_fp_infinity);
+  else if (Result.isNaN() && FPO.getNoHonorNaNs())
+Info.Ctx.getDiagnostics().Report(E->getExprLoc(), diag::warn_fp_nan);
+  else 

[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

Internal linkage detection works great for our purposes but it causes a failure 
in llvm/test/CodeGen/AMDGPU/inline-calls.ll due to `@func_alias` unable to be 
casted into a `Function`. If we pass through that, the `@kernel3` causes the 
error: `scalar registers (98) exceeds limit (96) in function 'kernel3'`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-09-16 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev updated this revision to Diff 373048.

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

https://reviews.llvm.org/D106876

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
  clang/test/Modules/add-remove-irrelevant-mobile-map.m
  clang/test/SemaCXX/Inputs/compare.modulemap
  clang/test/SemaCXX/compare-modules-cxx2a.cpp

Index: clang/test/SemaCXX/compare-modules-cxx2a.cpp
===
--- clang/test/SemaCXX/compare-modules-cxx2a.cpp
+++ clang/test/SemaCXX/compare-modules-cxx2a.cpp
@@ -1,15 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
 
-#pragma clang module build compare
-module compare {
-  explicit module cmp {}
-  explicit module other {}
-}
-#pragma clang module contents
-#pragma clang module begin compare.cmp
-#include "std-compare.h"
-#pragma clang module end
-#pragma clang module endbuild
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery -fmodule-map-file=%S/Inputs/compare.modulemap
 
 struct CC { CC(...); };
 
@@ -24,10 +16,10 @@
 
 // expected-note@std-compare.h:* 2+{{not reachable}}
 
-void b() { void(0 <=> 0); } // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+void b() { void(0 <=> 0); } // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 
 struct B {
-  CC operator<=>(const B&) const = default; // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+  CC operator<=>(const B&) const = default; // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 };
 auto vb = B() <=> B(); // expected-note {{required here}}
 
Index: clang/test/SemaCXX/Inputs/compare.modulemap
===
--- /dev/null
+++ clang/test/SemaCXX/Inputs/compare.modulemap
@@ -0,0 +1,6 @@
+module compare {
+  explicit module cmp {
+header "std-compare.h"
+  }
+  explicit module other {}
+}
Index: clang/test/Modules/add-remove-irrelevant-mobile-map.m
===
--- /dev/null
+++ clang/test/Modules/add-remove-irrelevant-mobile-map.m
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
+
+// Build with a.modulemap
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap %s -verify
+// RUN: cp %t.mcp/a.pcm %t/a.pcm
+
+// Build without b.modulemap
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap %s -verify
+// RUN: not diff %t.mcp/a.pcm %t/a.pcm
+
+// expected-no-diagnostics
+
+@import a;
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
@@ -0,0 +1 @@
+module b { }
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
@@ -0,0 +1 @@
+module a { }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -149,6 +149,59 @@
 
 namespace {
 
+std::set GetAllModuleMaps(const HeaderSearch ,
+ Module *RootModule) {
+  std::set ModuleMaps{};
+  std::set ProcessedModules;
+  SmallVector ModulesToProcess{RootModule};
+
+  SmallVector FilesByUID;
+  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+
+  if (FilesByUID.size() > HS.header_file_size())
+FilesByUID.resize(HS.header_file_size());
+
+  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
+const FileEntry *File = FilesByUID[UID];
+if (!File)
+  continue;
+
+const HeaderFileInfo *HFI =
+HS.getExistingFileInfo(File, /*WantExternal*/ false);
+if (!HFI)
+  continue;
+
+const auto KnownHeaders = HS.findAllModulesForHeader(File);
+for (const auto : KnownHeaders) {
+  if (!KH.getModule())
+continue;

[PATCH] D109902: [PowerPC] Improved codegen related to xscvdpsxws/xscvdpuxws

2021-09-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 373045.
Conanap edited the summary of this revision.
Conanap added a comment.

Removed complexity and restored a test case


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

https://reviews.llvm.org/D109902

Files:
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/test-vector-insert.ll
  llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll

Index: llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
===
--- llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
+++ llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
@@ -13,12 +13,8 @@
 ; CHECK-P8-LABEL: test2elt:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpuxws f1, v2
-; CHECK-P8-NEXT:xscvdpuxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpsxws v2, v2
+; CHECK-P8-NEXT:xscvdpsxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -26,26 +22,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpuxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpuxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpsxws v3, v2
+; CHECK-P9-NEXT:xscvdpsxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpuxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpuxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpsxws v3, v2
+; CHECK-BE-NEXT:xscvdpsxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
@@ -305,12 +293,8 @@
 ; CHECK-P8-LABEL: test2elt_signed:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpsxws f1, v2
-; CHECK-P8-NEXT:xscvdpsxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpsxws v2, v2
+; CHECK-P8-NEXT:xscvdpsxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -318,26 +302,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt_signed:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpsxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpsxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpsxws v3, v2
+; CHECK-P9-NEXT:xscvdpsxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt_signed:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpsxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpsxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpsxws v3, v2
+; CHECK-BE-NEXT:xscvdpsxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
Index: llvm/test/CodeGen/PowerPC/test-vector-insert.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/test-vector-insert.ll
@@ -0,0 +1,172 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; xscvdpsxws and uxws is only available on Power7 and above
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:  < %s | FileCheck %s --check-prefix=CHECK-LE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:  -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-BE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:  -mcpu=pwr7 < %s | FileCheck %s
+
+define dso_local <4 x i32> @test(<4 x i32> %a, double %b) {
+; CHECK-LE-LABEL: test:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:xscvdpsxws 35, 1
+; CHECK-LE-NEXT:addis 3, 2, .LCPI0_0@toc@ha
+; CHECK-LE-NEXT:addi 3, 3, .LCPI0_0@toc@l
+; CHECK-LE-NEXT:lvx 4, 0, 3
+; CHECK-LE-NEXT:vperm 2, 3, 2, 4
+; CHECK-LE-NEXT:blr
+;
+; CHECK-BE-LABEL: test:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:xscvdpsxws 0, 1

[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D109894: [clangd] Bail-out when an empty compile flag is encountered

2021-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

I do half wonder whether we're going to get 3 steps further and then crash 
again when we call `Command.front()` :-)

This change looks good.

It also seems tempting to inject an empty check in GlobalCompilationDatabase 
(where we convert `vector` -> `optional`.
But I can see a perverse situation where e.g. background indexing would "just 
fail" at the driver level today, but the change would lead to using a fallback 
command and attempting to parse some binary file. (Ugh, garbage in 
compile_commands...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109894

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


[clang] 45a8608 - [OpenMP] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build after D109635

2021-09-16 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-09-16T12:36:45-07:00
New Revision: 45a8608d7ba4519ce890b74db20087ba22343c50

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

LOG: [OpenMP] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build after 
D109635

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 3fcc7abca5c5..a22462bd68fc 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -739,6 +739,7 @@ class DSAStackTy {
   for (llvm::omp::TraitProperty Trait : llvm::reverse(Traits)) {
 llvm::omp::TraitProperty Top = ConstructTraits.pop_back_val();
 assert(Top == Trait && "Something left a trait on the stack!");
+(void)Trait;
 (void)Top;
   }
   }



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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:22414
+
+  EXPECT_EQ("int a = (int)b;", format("int a = (\n"
+  "int\n"

can't this just be verifyFormat but with 3 arguments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2021-09-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D92257#3003281 , @byronhe wrote:

> Hi guys,i found `SpacesInLineCommentPrefix` does not support other encoding 
> such as utf8 ,
> I am curious why there is a `isAlphanumeric` limit in 
> `BreakableLineCommentSection::BreakableLineCommentSection()` ?
> I want to make some contribution to make it support utf8, what should i do ?

The `isAlphanumeric` is there to not break doxygen like comments for example.

I'm very interested in how you want to tackle that problem. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D109707#3004108 , @gandhi21299 
wrote:

> @yaxunl Under what criteria should an alias not be removed?

If the linkage of the alias is not internal, then it should not be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D108787: [CUDA] Pass ExecConfig through BuildCallToMemberFunction

2021-09-16 Thread Artem Belevich via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b20ea696356: [CUDA] Pass ExecConfig through 
BuildCallToMemberFunction (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108787

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/kernel-call.cu


Index: clang/test/SemaCUDA/kernel-call.cu
===
--- clang/test/SemaCUDA/kernel-call.cu
+++ clang/test/SemaCUDA/kernel-call.cu
@@ -26,3 +26,34 @@
 
   g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }
+
+// Make sure we can call static member kernels.
+template  struct a0 {
+  template  static __global__ void Call(T);
+};
+struct a1 {
+  template  static __global__ void Call(T);
+};
+template  struct a2 {
+  static __global__ void Call(T);
+};
+struct a3 {
+  static __global__ void Call(int);
+  static __global__ void Call(void*);
+};
+
+struct b {
+  template  void d0(c arg) {
+a0::Call<<<0, 0>>>(arg);
+a1::Call<<<0,0>>>(arg);
+a2::Call<<<0,0>>>(arg);
+a3::Call<<<0, 0>>>(arg);
+  }
+  void d1(void* arg) {
+a0::Call<<<0, 0>>>(arg);
+a1::Call<<<0,0>>>(arg);
+a2::Call<<<0,0>>>(arg);
+a3::Call<<<0, 0>>>(arg);
+  }
+  void e() { d0(1); }
+};
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -14233,6 +14233,7 @@
SourceLocation LParenLoc,
MultiExprArg Args,
SourceLocation RParenLoc,
+   Expr *ExecConfig, bool IsExecConfig,
bool AllowRecovery) {
   assert(MemExprE->getType() == Context.BoundMemberTy ||
  MemExprE->getType() == Context.OverloadTy);
@@ -14428,8 +14429,8 @@
 // If overload resolution picked a static member, build a
 // non-member call based on that function.
 if (Method->isStatic()) {
-  return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
-   RParenLoc);
+  return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args, 
RParenLoc,
+   ExecConfig, IsExecConfig);
 }
 
 MemExpr = cast(MemExprE->IgnoreParens());
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6454,7 +6454,8 @@
 
 if (Fn->getType() == Context.BoundMemberTy) {
   return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
-   RParenLoc, AllowRecovery);
+   RParenLoc, ExecConfig, IsExecConfig,
+   AllowRecovery);
 }
   }
 
@@ -6473,7 +6474,8 @@
 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
 /*AllowTypoCorrection=*/true, find.IsAddressOfOperand);
   return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
-   RParenLoc, AllowRecovery);
+   RParenLoc, ExecConfig, IsExecConfig,
+   AllowRecovery);
 }
   }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3891,6 +3891,8 @@
SourceLocation LParenLoc,
MultiExprArg Args,
SourceLocation RParenLoc,
+   Expr *ExecConfig = nullptr,
+   bool IsExecConfig = false,
bool AllowRecovery = false);
   ExprResult
   BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation 
LParenLoc,


Index: clang/test/SemaCUDA/kernel-call.cu
===
--- clang/test/SemaCUDA/kernel-call.cu
+++ clang/test/SemaCUDA/kernel-call.cu
@@ -26,3 +26,34 @@
 
   g1<<>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
 }
+
+// Make sure we can call static member kernels.
+template  struct a0 {
+  template  static __global__ void Call(T);
+};
+struct a1 {
+  template  static __global__ void Call(T);
+};
+template  struct a2 {
+  static __global__ void Call(T);
+};
+struct a3 {
+  static __global__ void Call(int);
+  static __global__ void Call(void*);
+};
+
+struct b {
+  template  void d0(c arg) {

[clang] 6b20ea6 - [CUDA] Pass ExecConfig through BuildCallToMemberFunction

2021-09-16 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2021-09-16T11:18:12-07:00
New Revision: 6b20ea6963561f2c91490c0993390b7f2ff8f71c

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

LOG: [CUDA] Pass ExecConfig through BuildCallToMemberFunction

Otherwise, we fail to compile calls to CUDA kernels that are static members.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/kernel-call.cu

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 710abeb1ea514..6214ef6503848 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3891,6 +3891,8 @@ class Sema final {
SourceLocation LParenLoc,
MultiExprArg Args,
SourceLocation RParenLoc,
+   Expr *ExecConfig = nullptr,
+   bool IsExecConfig = false,
bool AllowRecovery = false);
   ExprResult
   BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation 
LParenLoc,

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7c8d753730a0a..7991e4c5e8b0a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6454,7 +6454,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
 
 if (Fn->getType() == Context.BoundMemberTy) {
   return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
-   RParenLoc, AllowRecovery);
+   RParenLoc, ExecConfig, IsExecConfig,
+   AllowRecovery);
 }
   }
 
@@ -6473,7 +6474,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
 /*AllowTypoCorrection=*/true, find.IsAddressOfOperand);
   return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
-   RParenLoc, AllowRecovery);
+   RParenLoc, ExecConfig, IsExecConfig,
+   AllowRecovery);
 }
   }
 

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 4b1b61a390276..e12413ca994f4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14233,6 +14233,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, 
Expr *MemExprE,
SourceLocation LParenLoc,
MultiExprArg Args,
SourceLocation RParenLoc,
+   Expr *ExecConfig, bool IsExecConfig,
bool AllowRecovery) {
   assert(MemExprE->getType() == Context.BoundMemberTy ||
  MemExprE->getType() == Context.OverloadTy);
@@ -14428,8 +14429,8 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, 
Expr *MemExprE,
 // If overload resolution picked a static member, build a
 // non-member call based on that function.
 if (Method->isStatic()) {
-  return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
-   RParenLoc);
+  return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args, 
RParenLoc,
+   ExecConfig, IsExecConfig);
 }
 
 MemExpr = cast(MemExprE->IgnoreParens());

diff  --git a/clang/test/SemaCUDA/kernel-call.cu 
b/clang/test/SemaCUDA/kernel-call.cu
index b2433c956e251..136844c7c8d65 100644
--- a/clang/test/SemaCUDA/kernel-call.cu
+++ b/clang/test/SemaCUDA/kernel-call.cu
@@ -26,3 +26,34 @@ int main(void) {
 
   g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }
+
+// Make sure we can call static member kernels.
+template  struct a0 {
+  template  static __global__ void Call(T);
+};
+struct a1 {
+  template  static __global__ void Call(T);
+};
+template  struct a2 {
+  static __global__ void Call(T);
+};
+struct a3 {
+  static __global__ void Call(int);
+  static __global__ void Call(void*);
+};
+
+struct b {
+  template  void d0(c arg) {
+a0::Call<<<0, 0>>>(arg);
+a1::Call<<<0,0>>>(arg);
+a2::Call<<<0,0>>>(arg);
+a3::Call<<<0, 0>>>(arg);
+  }
+  void d1(void* arg) {
+a0::Call<<<0, 0>>>(arg);
+a1::Call<<<0,0>>>(arg);
+a2::Call<<<0,0>>>(arg);
+a3::Call<<<0, 0>>>(arg);
+  }
+  void e() { d0(1); }
+};




[PATCH] D109902: [PowerPC] Improved codegen related to xscvdpsxws/xscvdpuxws

2021-09-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 373009.
Conanap added a comment.

Removed unintended change, moved pattern to more appropriate location, reduced 
added complexity to 600 as it still works.


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

https://reviews.llvm.org/D109902

Files:
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/build-vector-tests.ll
  llvm/test/CodeGen/PowerPC/test-vector-insert.ll
  llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll

Index: llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
===
--- llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
+++ llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
@@ -13,12 +13,8 @@
 ; CHECK-P8-LABEL: test2elt:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpuxws f1, v2
-; CHECK-P8-NEXT:xscvdpuxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpsxws v2, v2
+; CHECK-P8-NEXT:xscvdpsxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -26,26 +22,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpuxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpuxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpsxws v3, v2
+; CHECK-P9-NEXT:xscvdpsxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpuxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpuxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpsxws v3, v2
+; CHECK-BE-NEXT:xscvdpsxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
@@ -305,12 +293,8 @@
 ; CHECK-P8-LABEL: test2elt_signed:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpsxws f1, v2
-; CHECK-P8-NEXT:xscvdpsxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpsxws v2, v2
+; CHECK-P8-NEXT:xscvdpsxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -318,26 +302,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt_signed:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpsxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpsxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpsxws v3, v2
+; CHECK-P9-NEXT:xscvdpsxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt_signed:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpsxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpsxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpsxws v3, v2
+; CHECK-BE-NEXT:xscvdpsxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
Index: llvm/test/CodeGen/PowerPC/test-vector-insert.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/test-vector-insert.ll
@@ -0,0 +1,172 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; xscvdpsxws and uxws is only available on Power7 and above
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:  < %s | FileCheck %s --check-prefix=CHECK-LE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:  -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-BE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:  -mcpu=pwr7 < %s | FileCheck %s
+
+define dso_local <4 x i32> @test(<4 x i32> %a, double %b) {
+; CHECK-LE-LABEL: test:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:xscvdpsxws 35, 1
+; CHECK-LE-NEXT:addis 3, 2, .LCPI0_0@toc@ha
+; CHECK-LE-NEXT:addi 3, 3, .LCPI0_0@toc@l
+; CHECK-LE-NEXT:lvx 4, 0, 3
+; CHECK-LE-NEXT:vperm 2, 3, 2, 4
+; CHECK-LE-NEXT:blr
+;
+; 

[PATCH] D109902: [PowerPC] Improved codegen related to xscvdpsxws/xscvdpuxws

2021-09-16 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: PowerPC, nemanjai, saghir.
Conanap added projects: PowerPC, LLVM, clang.
Herald added subscribers: kbarton, hiraditya.
Conanap requested review of this revision.

This patch removes the uneccessary mf/mtvsr generated in conjunction
with xscvdpsxws/xscvdpuxws.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109902

Files:
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/build-vector-tests.ll
  llvm/test/CodeGen/PowerPC/test-vector-insert.ll
  llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll

Index: llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
===
--- llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
+++ llvm/test/CodeGen/PowerPC/vec_conv_fp64_to_i32_elts.ll
@@ -13,12 +13,8 @@
 ; CHECK-P8-LABEL: test2elt:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpuxws f1, v2
-; CHECK-P8-NEXT:xscvdpuxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpsxws v2, v2
+; CHECK-P8-NEXT:xscvdpsxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -26,26 +22,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpuxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpuxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpsxws v3, v2
+; CHECK-P9-NEXT:xscvdpsxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpuxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpuxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpsxws v3, v2
+; CHECK-BE-NEXT:xscvdpsxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
@@ -305,12 +293,8 @@
 ; CHECK-P8-LABEL: test2elt_signed:
 ; CHECK-P8:   # %bb.0: # %entry
 ; CHECK-P8-NEXT:xxswapd vs0, v2
-; CHECK-P8-NEXT:xscvdpsxws f1, v2
-; CHECK-P8-NEXT:xscvdpsxws f0, f0
-; CHECK-P8-NEXT:mffprwz r3, f1
-; CHECK-P8-NEXT:mtvsrwz v2, r3
-; CHECK-P8-NEXT:mffprwz r4, f0
-; CHECK-P8-NEXT:mtvsrwz v3, r4
+; CHECK-P8-NEXT:xscvdpsxws v2, v2
+; CHECK-P8-NEXT:xscvdpsxws v3, f0
 ; CHECK-P8-NEXT:vmrghw v2, v2, v3
 ; CHECK-P8-NEXT:xxswapd vs0, v2
 ; CHECK-P8-NEXT:mffprd r3, f0
@@ -318,26 +302,18 @@
 ;
 ; CHECK-P9-LABEL: test2elt_signed:
 ; CHECK-P9:   # %bb.0: # %entry
-; CHECK-P9-NEXT:xscvdpsxws f0, v2
-; CHECK-P9-NEXT:mffprwz r3, f0
 ; CHECK-P9-NEXT:xxswapd vs0, v2
-; CHECK-P9-NEXT:mtvsrwz v3, r3
-; CHECK-P9-NEXT:xscvdpsxws f0, f0
-; CHECK-P9-NEXT:mffprwz r3, f0
-; CHECK-P9-NEXT:mtvsrwz v2, r3
+; CHECK-P9-NEXT:xscvdpsxws v3, v2
+; CHECK-P9-NEXT:xscvdpsxws v2, f0
 ; CHECK-P9-NEXT:vmrghw v2, v3, v2
 ; CHECK-P9-NEXT:mfvsrld r3, v2
 ; CHECK-P9-NEXT:blr
 ;
 ; CHECK-BE-LABEL: test2elt_signed:
 ; CHECK-BE:   # %bb.0: # %entry
-; CHECK-BE-NEXT:xscvdpsxws f0, v2
-; CHECK-BE-NEXT:mffprwz r3, f0
 ; CHECK-BE-NEXT:xxswapd vs0, v2
-; CHECK-BE-NEXT:mtvsrwz v3, r3
-; CHECK-BE-NEXT:xscvdpsxws f0, f0
-; CHECK-BE-NEXT:mffprwz r3, f0
-; CHECK-BE-NEXT:mtvsrwz v2, r3
+; CHECK-BE-NEXT:xscvdpsxws v3, v2
+; CHECK-BE-NEXT:xscvdpsxws v2, f0
 ; CHECK-BE-NEXT:vmrgow v2, v3, v2
 ; CHECK-BE-NEXT:mfvsrd r3, v2
 ; CHECK-BE-NEXT:blr
Index: llvm/test/CodeGen/PowerPC/test-vector-insert.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/test-vector-insert.ll
@@ -0,0 +1,172 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; xscvdpsxws and uxws is only available on Power7 and above
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:  < %s | FileCheck %s --check-prefix=CHECK-LE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:  -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-BE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:  -mcpu=pwr7 < %s | FileCheck %s
+
+define dso_local <4 x i32> @test(<4 x i32> %a, double %b) {
+; CHECK-LE-LABEL: test:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:xscvdpsxws 35, 1
+; CHECK-LE-NEXT:addis 3, 2, .LCPI0_0@toc@ha
+; CHECK-LE-NEXT:addi 3, 3, .LCPI0_0@toc@l
+; CHECK-LE-NEXT:

[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-09-16 Thread Ye Luo via Phabricator via cfe-commits
ye-luo requested changes to this revision.
ye-luo added a comment.
This revision now requires changes to proceed.

The fallback opt/rocm is desired. If a module system needs to point to the 
specific rocm installation. Set CMAKE_PREFIX_PATH= in the 
module file.
If you would like to honor ROCM_PATH, then do one find_library with explicit 
ROCM_PATH and another with all the defaults.




Comment at: mlir/lib/Dialect/GPU/CMakeLists.txt:137
   set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

Both ROCM_PATH HIP_PATH are used as hints without verification.
But they are used later for generating include paths. Overall logic is broken.

if ROCM_PATH takes the precedence over everything else
You can do this
if ROCM_PATH defined
find_path(
  HIP_MODULE_FILE_DIR FindHIP.cmake
  HINTS ${ROCM_PATH}
  PATH_SUFFIXES hip/cmake REQUIRED
  NO_DEFAULT_PATH)
else
find_path(
  HIP_MODULE_FILE_DIR FindHIP.cmake
  HINTS $ENV{ROCM_PATH} /opt/rocm
  PATH_SUFFIXES hip/cmake REQUIRED)
endif

by doing this, you can verify that ROCM_PATH is correct if provided and the 
path the hip module file has been verified. then it is safe to do
set(CMAKE_MODULE_PATH "${HIP_MODULE_FILE_DIR}" ${CMAKE_MODULE_PATH})
find_package(HIP)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D109060: [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C support

2021-09-16 Thread Jake Egan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22f01cd4fc5d: [AIX][ZOS] Disable LIT tests on AIX and z/OS 
due to lack of Objective-C support (authored by Jake-Egan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109060

Files:
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Import/forward-declared-objc-class/test.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Import/objc-autoreleasepool/test.m
  clang/test/Import/objc-definitions-in-expression/test.m
  clang/test/Import/objc-method/test.m
  clang/test/Import/objc-param-decl/test.m
  clang/test/Import/objc-try-catch/test.m
  clang/test/Modules/DebugInfoNamespace.cpp
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ExtDebugInfo.m
  clang/test/Modules/ModuleDebugInfoDwoId.cpp
  clang/test/Modules/ModuleModuleDebugInfo.cpp
  clang/test/Modules/autolink.m
  clang/test/Modules/autolinkTBD.m
  clang/test/Modules/cxx-irgen.cpp
  clang/test/Modules/debug-info-moduleimport.m
  clang/test/Modules/direct-module-import.m
  clang/test/Modules/merge-record-definition-nonmodular.m
  clang/test/Modules/merge-record-definition-visibility.m
  clang/test/Modules/merge-record-definition.m
  clang/test/Modules/module_file_info.m
  clang/test/Modules/objc-initializer.m
  clang/test/Modules/pch-used.m
  clang/test/Modules/use-exportas-for-link.m
  clang/test/PCH/externally-retained.m
  clang/test/PCH/irgen-rdar13114142.mm
  clang/test/PCH/objc_container.m
  clang/test/PCH/objc_literals.m
  clang/test/PCH/objc_literals.mm
  clang/test/PCH/objcxx-ivar-class.mm
  clang/test/PCH/pending-ids.m

Index: clang/test/PCH/pending-ids.m
===
--- clang/test/PCH/pending-ids.m
+++ clang/test/PCH/pending-ids.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test for rdar://10278815
 
 // Without PCH
Index: clang/test/PCH/objcxx-ivar-class.mm
===
--- clang/test/PCH/objcxx-ivar-class.mm
+++ clang/test/PCH/objcxx-ivar-class.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s
 
Index: clang/test/PCH/objc_literals.mm
===
--- clang/test/PCH/objc_literals.mm
+++ clang/test/PCH/objc_literals.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_literals.m
===
--- clang/test/PCH/objc_literals.m
+++ clang/test/PCH/objc_literals.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -verify %s
 // RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_container.m
===
--- clang/test/PCH/objc_container.m
+++ clang/test/PCH/objc_container.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objc_container.h -fsyntax-only -verify %s
 
Index: clang/test/PCH/irgen-rdar13114142.mm
===
--- clang/test/PCH/irgen-rdar13114142.mm
+++ clang/test/PCH/irgen-rdar13114142.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-pch -o %t.pch
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -include-pch %t.pch -o - | FileCheck %s
 
Index: clang/test/PCH/externally-retained.m
===
--- clang/test/PCH/externally-retained.m
+++ clang/test/PCH/externally-retained.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test for assertion failure due to objc_externally_retained on a function.
 
 // Without PCH
Index: clang/test/Modules/use-exportas-for-link.m
===
--- clang/test/Modules/use-exportas-for-link.m
+++ clang/test/Modules/use-exportas-for-link.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -DA -fmodules -fimplicit-module-maps -F %S/Inputs/exportas-link %s | FileCheck --check-prefix=CHECK_A %s
 // CHECK_A: !llvm.linker.options = !{![[MODULE:[0-9]+]]}
Index: 

[clang] 22f01cd - [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C support

2021-09-16 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2021-09-16T14:04:42-04:00
New Revision: 22f01cd4fc5d2a02a156722e1dab0398fc860e74

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

LOG: [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C 
support

AIX and z/OS lack Objective-C support, so mark these tests as unsupported for 
AIX and z/OS.

Reviewed By: jsji

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

Added: 
clang/test/CodeGenObjC/lit.local.cfg
clang/test/CodeGenObjCXX/lit.local.cfg

Modified: 
clang/test/Import/forward-declared-objc-class/test.m
clang/test/Import/objc-arc/test-cleanup-object.m
clang/test/Import/objc-autoreleasepool/test.m
clang/test/Import/objc-definitions-in-expression/test.m
clang/test/Import/objc-method/test.m
clang/test/Import/objc-param-decl/test.m
clang/test/Import/objc-try-catch/test.m
clang/test/Modules/DebugInfoNamespace.cpp
clang/test/Modules/DebugInfoTransitiveImport.m
clang/test/Modules/ExtDebugInfo.cpp
clang/test/Modules/ExtDebugInfo.m
clang/test/Modules/ModuleDebugInfoDwoId.cpp
clang/test/Modules/ModuleModuleDebugInfo.cpp
clang/test/Modules/autolink.m
clang/test/Modules/autolinkTBD.m
clang/test/Modules/cxx-irgen.cpp
clang/test/Modules/debug-info-moduleimport.m
clang/test/Modules/direct-module-import.m
clang/test/Modules/merge-record-definition-nonmodular.m
clang/test/Modules/merge-record-definition-visibility.m
clang/test/Modules/merge-record-definition.m
clang/test/Modules/module_file_info.m
clang/test/Modules/objc-initializer.m
clang/test/Modules/pch-used.m
clang/test/Modules/use-exportas-for-link.m
clang/test/PCH/externally-retained.m
clang/test/PCH/irgen-rdar13114142.mm
clang/test/PCH/objc_container.m
clang/test/PCH/objc_literals.m
clang/test/PCH/objc_literals.mm
clang/test/PCH/objcxx-ivar-class.mm
clang/test/PCH/pending-ids.m

Removed: 




diff  --git a/clang/test/CodeGenObjC/lit.local.cfg 
b/clang/test/CodeGenObjC/lit.local.cfg
new file mode 100644
index 0..3957a0545185b
--- /dev/null
+++ b/clang/test/CodeGenObjC/lit.local.cfg
@@ -0,0 +1,2 @@
+if any(target in config.target_triple for target in ('aix', 'zos')):
+  config.unsupported = True

diff  --git a/clang/test/CodeGenObjCXX/lit.local.cfg 
b/clang/test/CodeGenObjCXX/lit.local.cfg
new file mode 100644
index 0..3957a0545185b
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/lit.local.cfg
@@ -0,0 +1,2 @@
+if any(target in config.target_triple for target in ('aix', 'zos')):
+  config.unsupported = True

diff  --git a/clang/test/Import/forward-declared-objc-class/test.m 
b/clang/test/Import/forward-declared-objc-class/test.m
index 098818be3cb0d..da0a5e037367e 100644
--- a/clang/test/Import/forward-declared-objc-class/test.m
+++ b/clang/test/Import/forward-declared-objc-class/test.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: clang-import-test -x objective-c++ -import %S/Inputs/S1.m --import 
%S/Inputs/S2.m --import %S/Inputs/S3.m -expression %s
 void expr() {
   MyClass *c = [MyClass fromInteger:3];

diff  --git a/clang/test/Import/objc-arc/test-cleanup-object.m 
b/clang/test/Import/objc-arc/test-cleanup-object.m
index aab1cd377a2e7..00fe9713b0cef 100644
--- a/clang/test/Import/objc-arc/test-cleanup-object.m
+++ b/clang/test/Import/objc-arc/test-cleanup-object.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: clang-import-test -x objective-c -objc-arc -import 
%S/Inputs/cleanup-objects.m -dump-ast -expression %s | FileCheck %s
 
 // CHECK: FunctionDecl {{.*}} getObj '

diff  --git a/clang/test/Import/objc-autoreleasepool/test.m 
b/clang/test/Import/objc-autoreleasepool/test.m
index f09e7ef4dddfe..52274eb06cdf4 100644
--- a/clang/test/Import/objc-autoreleasepool/test.m
+++ b/clang/test/Import/objc-autoreleasepool/test.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: clang-import-test -dump-ast -x objective-c++ -import %S/Inputs/F.m 
-expression %s | FileCheck %s
 
 // CHECK: ObjCAutoreleasePoolStmt

diff  --git a/clang/test/Import/objc-definitions-in-expression/test.m 
b/clang/test/Import/objc-definitions-in-expression/test.m
index 0c9984731d199..501d82c683433 100644
--- a/clang/test/Import/objc-definitions-in-expression/test.m
+++ b/clang/test/Import/objc-definitions-in-expression/test.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: clang-import-test -x objective-c++ -import %S/Inputs/S.m -expression %s
 @class D;
 

diff  --git a/clang/test/Import/objc-method/test.m 
b/clang/test/Import/objc-method/test.m
index 7707110d82495..293af2957dd2b 100644
--- a/clang/test/Import/objc-method/test.m
+++ b/clang/test/Import/objc-method/test.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: clang-import-test -x 

[PATCH] D109898: [clang][NFC] refactor GlobalMethodPool to encapsulate its map

2021-09-16 Thread Richard Howell via Phabricator via cfe-commits
rmaz updated this revision to Diff 372999.
rmaz added a comment.

- keep `std::pair`, but move to 
`GlobalMethodPool::Lists`
- add `const`
- `val` -> `&`
- move comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109898

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8208,8 +8208,9 @@
 return;
 
   Sema  = *getSema();
-  Sema::GlobalMethodPool::iterator Pos
-= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
+  Sema::GlobalMethodPool::iterator Pos =
+  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
+  .first;
 
   Pos->second.first.setBits(Visitor.getInstanceBits());
   
Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3427,8 +3427,10 @@
 
   GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
   if (Pos == MethodPool.end())
-Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
-   GlobalMethods())).first;
+Pos = MethodPool
+  .insert(std::make_pair(Method->getSelector(),
+ GlobalMethodPool::Lists()))
+  .first;
 
   Method->setDefined(impl);
 
@@ -3636,7 +3638,7 @@
   if (Pos == MethodPool.end())
 return nullptr;
 
-  GlobalMethods  = Pos->second;
+  GlobalMethodPool::Lists  = Pos->second;
   for (const ObjCMethodList *Method =  Method;
Method = Method->getNext())
 if (Method->getMethod() &&
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1419,8 +1419,22 @@
   const llvm::MapVector &
   getMismatchingDeleteExpressions() const;
 
-  typedef std::pair GlobalMethods;
-  typedef llvm::DenseMap GlobalMethodPool;
+  class GlobalMethodPool {
+  public:
+using Lists = std::pair;
+using iterator = llvm::DenseMap::iterator;
+iterator begin() { return Methods.begin(); }
+iterator end() { return Methods.end(); }
+iterator find(Selector Sel) { return Methods.find(Sel); }
+std::pair insert(std::pair &) {
+  return Methods.insert(Val);
+}
+int count(Selector Sel) const { return Methods.count(Sel); }
+bool empty() const { return Methods.empty(); }
+
+  private:
+llvm::DenseMap Methods;
+  };
 
   /// Method Pool - allows efficient lookup when typechecking messages to "id".
   /// We need to maintain a list, since selectors can have differing signatures


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8208,8 +8208,9 @@
 return;
 
   Sema  = *getSema();
-  Sema::GlobalMethodPool::iterator Pos
-= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
+  Sema::GlobalMethodPool::iterator Pos =
+  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
+  .first;
 
   Pos->second.first.setBits(Visitor.getInstanceBits());
   Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3427,8 +3427,10 @@
 
   GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector());
   if (Pos == MethodPool.end())
-Pos = MethodPool.insert(std::make_pair(Method->getSelector(),
-   GlobalMethods())).first;
+Pos = MethodPool
+  .insert(std::make_pair(Method->getSelector(),
+ GlobalMethodPool::Lists()))
+  .first;
 
   Method->setDefined(impl);
 
@@ -3636,7 +3638,7 @@
   if (Pos == MethodPool.end())
 return nullptr;
 
-  GlobalMethods  = Pos->second;
+  GlobalMethodPool::Lists  = Pos->second;
   for (const ObjCMethodList *Method =  Method;
Method = Method->getNext())
 if (Method->getMethod() &&
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1419,8 +1419,22 @@
   const llvm::MapVector &
   getMismatchingDeleteExpressions() const;
 
-  typedef std::pair GlobalMethods;
-  typedef llvm::DenseMap GlobalMethodPool;
+  class 

[PATCH] D109854: Support Unicode 14 identifiers

2021-09-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I committed this on your behalf in afb6223bc53034973379863d08cbee322149569e 
, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109854

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


[clang-tools-extra] f1e8ceb - docs: correct SPHNIX document reference

2021-09-16 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-09-16T17:43:59Z
New Revision: f1e8ceb3054a02f4225ff7ab74cde10b70826707

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

LOG: docs: correct SPHNIX document reference

The trailing `>` was missing, which resulted in the reference not being
processed properly.

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 1b1f00de4d69c..79048ce17f52c 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -91,7 +91,7 @@ New checks
   variables and function parameters only.
 
 
-- New :doc:`readability-data-pointer 
` check.
 
   Finds cases where code could use ``data()`` rather than the address of the
   element at index 0 in a container.



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


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-09-16 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev updated this revision to Diff 372989.
ilyakuteev marked 5 inline comments as done.

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

https://reviews.llvm.org/D106876

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
  clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
  clang/test/Modules/add-remove-irrelevant-mobile-map.m
  clang/test/SemaCXX/Inputs/compare.modulemap
  clang/test/SemaCXX/compare-modules-cxx2a.cpp

Index: clang/test/SemaCXX/compare-modules-cxx2a.cpp
===
--- clang/test/SemaCXX/compare-modules-cxx2a.cpp
+++ clang/test/SemaCXX/compare-modules-cxx2a.cpp
@@ -1,15 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
 
-#pragma clang module build compare
-module compare {
-  explicit module cmp {}
-  explicit module other {}
-}
-#pragma clang module contents
-#pragma clang module begin compare.cmp
-#include "std-compare.h"
-#pragma clang module end
-#pragma clang module endbuild
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery
 
 struct CC { CC(...); };
 
@@ -24,10 +17,10 @@
 
 // expected-note@std-compare.h:* 2+{{not reachable}}
 
-void b() { void(0 <=> 0); } // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+void b() { void(0 <=> 0); } // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 
 struct B {
-  CC operator<=>(const B&) const = default; // expected-error 1+{{missing '#include "std-compare.h"'; 'strong_ordering' must be defined}}
+  CC operator<=>(const B&) const = default; // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
 };
 auto vb = B() <=> B(); // expected-note {{required here}}
 
Index: clang/test/SemaCXX/Inputs/compare.modulemap
===
--- /dev/null
+++ clang/test/SemaCXX/Inputs/compare.modulemap
@@ -0,0 +1,6 @@
+module compare {
+  explicit module cmp {
+header "std-compare.h"
+  }
+  explicit module other {}
+}
Index: clang/test/Modules/add-remove-irrelevant-mobile-map.m
===
--- /dev/null
+++ clang/test/Modules/add-remove-irrelevant-mobile-map.m
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
+
+// Build with a.modulemap
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap %s -verify
+// RUN: cp %t.mcp/a.pcm %t/a.pcm
+
+// Build without b.modulemap
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap %s -verify
+// RUN: not diff %t.mcp/a.pcm %t/a.pcm
+
+// expected-no-diagnostics
+
+@import a;
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap
@@ -0,0 +1 @@
+module b { }
Index: clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap
@@ -0,0 +1 @@
+module a { }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -149,6 +149,59 @@
 
 namespace {
 
+std::set GetAllModuleMaps(const HeaderSearch ,
+ Module *RootModule) {
+  std::set ModuleMaps{};
+  std::set ProcessedModules;
+  SmallVector ModulesToProcess{RootModule};
+
+  SmallVector FilesByUID;
+  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+
+  if (FilesByUID.size() > HS.header_file_size())
+FilesByUID.resize(HS.header_file_size());
+
+  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
+const FileEntry *File = FilesByUID[UID];
+if (!File)
+  continue;
+
+const HeaderFileInfo *HFI =
+HS.getExistingFileInfo(File, /*WantExternal*/ false);
+if (!HFI)
+  continue;
+
+const auto KnownHeaders = HS.findAllModulesForHeader(File);
+for (const auto : KnownHeaders) {
+  if (!KH.getModule())

[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

FWIW, this is almost entirely above my pay grade. Getting rid of that extra 
bool parameter throughout //looks// awesome, though. :)

I do think it might be a good idea to include one or two tests that actually 
run all the way through codegen, e.g. https://godbolt.org/z/54eTrj54M
The scary failure mode here (if you are like me and don't really understand why 
this is impossible ;)) would be if the compiler somehow elided one of the 
implicit conversions without eliding the other one (like how compiler bugs have 
in the past led to eliding a constructor without eliding the matching 
destructor).

Also, is it worth testing anything in constexpr functions? My understanding is 
that constexpr functions never do copy elision, although maybe(?) they're 
permitted to?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-09-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Dropping PATHS /opt/rocm from the openmp parts will break people using an 
existing rocm install with trunk llvm. I think it would be reasonable to look 
at whatever ROCM_PATH is set to instead of assuming /opt/rocm. Is that a 
variable we can pass to find_package?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-16 Thread Mark de Wever via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2c319fdc6b3: [LLVM][CMake][NFC] Resolve FIXME: Rename 
LLVM_CMAKE_PATH to LLVM_CMAKE_DIR… (authored by gAlfonso-bit, committed by 
Mordante).
Herald added a project: LLDB.
Herald added a reviewer: libunwind.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107717

Files:
  clang/CMakeLists.txt
  clang/lib/Basic/CMakeLists.txt
  compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  flang/CMakeLists.txt
  libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
  libunwind/CMakeLists.txt
  lld/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/source/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/include/llvm/Support/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 # This variable makes sure that e.g. llvm-lit is found.
 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 
 # This variable is used by individual runtimes to locate LLVM files.
 set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
Index: llvm/include/llvm/Support/CMakeLists.txt
===
--- llvm/include/llvm/Support/CMakeLists.txt
+++ llvm/include/llvm/Support/CMakeLists.txt
@@ -3,7 +3,7 @@
 # The VC revision include that we want to generate.
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h")
 
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(LLVM_APPEND_VC_REV)
   set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -295,8 +295,8 @@
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
-# Note: LLVM_CMAKE_PATH does not include generated files
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+# Note: LLVM_CMAKE_DIR does not include generated files
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
 set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 
Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lldb_vc AND LLVM_APPEND_VC_REV)
   set(lldb_source_dir ${LLDB_SOURCE_DIR})
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -3,8 +3,8 @@
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH)
 
-# We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc
-set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
+# We set LLVM_CMAKE_DIR so that GetSVN.cmake is found correctly when building SVNVersion.inc
+set(LLVM_CMAKE_DIR ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
 
 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
Index: lld/Common/CMakeLists.txt
===
--- lld/Common/CMakeLists.txt
+++ lld/Common/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lld_vc AND LLVM_APPEND_VC_REV)
   set(lld_source_dir ${LLD_SOURCE_DIR})
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -27,7 +27,7 @@
 
   list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
   list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
-  list(GET LLVM_CONFIG_OUTPUT 

[PATCH] D109898: [clang][NFC] refactor GlobalMethodPool to encapsulate its map

2021-09-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

Thanks for splitting this out -- left some comments inline, LGTM after that.




Comment at: clang/include/clang/Sema/Sema.h:1422-1427
   /// Method Pool - allows efficient lookup when typechecking messages to "id".
   /// We need to maintain a list, since selectors can have differing signatures
   /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
   /// of selectors are "overloaded").
   /// At the head of the list it is recorded whether there were 0, 1, or >= 2
   /// methods inside categories with a particular selector.

This comment should probably be attached to either GlobalMethodPool (the type) 
or MethodPool (the field), not this helper struct. I'd probably leave it 
attached to the field since that's where it was before.



Comment at: clang/include/clang/Sema/Sema.h:1428-1431
+  struct GlobalMethodLists {
+ObjCMethodList InstanceMethods;
+ObjCMethodList ClassMethods;
+  };

Switching away from std::pair adds a lot of churn that's not related to 
encapsulating the pool -- it seems like it touches mostly new lines of code, 
not much crossover. Unless I misdiagnosed, then I think it'd be better to skip 
this change (for now), leaving as a typedef:
```
lang=c++
using GlobalMethodLists = std::pair;
```
(Or, I wonder, should the typedef be moved inside of `GlobalMethodPool` (maybe 
`GlobalMethodPool::Lists`?) to tidy things up further? Up to you.)

(To be clear, switching to a `struct` seems like a great change, I just think 
it'd be better to commit separately. (In that commit, I suggest shorter names 
for the fields -- "Instances" and "Classes" -- but up to you.))



Comment at: clang/include/clang/Sema/Sema.h:1436
+  public:
+typedef llvm::DenseMap::iterator iterator;
+iterator begin() { return Methods.begin(); }

Nit: could use new-style `using iterator = `, but up to you.



Comment at: clang/include/clang/Sema/Sema.h:1441
+std::pair
+insert(std::pair val) {
+  return Methods.insert(val);

A couple of nits:
- `val` should probably be `Val` or `V`
- I think this should be `&&`; it's not obvious from here that ObjCMethodList 
has a cheap copy constructor (it does, but)



Comment at: clang/include/clang/Sema/Sema.h:1444-1445
+}
+int count(Selector Sel) { return Methods.count(Sel); }
+bool empty() { return Methods.empty(); }
+  };

Nit: these should be `const`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109898

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


[clang] afb6223 - Support Unicode 14 identifiers

2021-09-16 Thread Aaron Ballman via cfe-commits

Author: Corentin Jabot
Date: 2021-09-16T13:21:27-04:00
New Revision: afb6223bc53034973379863d08cbee322149569e

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

LOG: Support Unicode 14 identifiers

This update the UAX tables to support new Unicode 14 identifiers.

Added: 


Modified: 
clang/lib/Lex/UnicodeCharSets.h
clang/test/Lexer/unicode.c

Removed: 




diff  --git a/clang/lib/Lex/UnicodeCharSets.h b/clang/lib/Lex/UnicodeCharSets.h
index 33fb4d39ebec2..e79a85bc72b70 100644
--- a/clang/lib/Lex/UnicodeCharSets.h
+++ b/clang/lib/Lex/UnicodeCharSets.h
@@ -10,7 +10,7 @@
 
 #include "llvm/Support/UnicodeCharRanges.h"
 
-// Unicode 13 XID_Start
+// Unicode 14 XID_Start
 static const llvm::sys::UnicodeCharRange XIDStartRanges[] = {
 {0x0041, 0x005A},   {0x0061, 0x007A},   {0x00AA, 0x00AA},
 {0x00B5, 0x00B5},   {0x00BA, 0x00BA},   {0x00C0, 0x00D6},
@@ -28,94 +28,94 @@ static const llvm::sys::UnicodeCharRange XIDStartRanges[] = 
{
 {0x07B1, 0x07B1},   {0x07CA, 0x07EA},   {0x07F4, 0x07F5},
 {0x07FA, 0x07FA},   {0x0800, 0x0815},   {0x081A, 0x081A},
 {0x0824, 0x0824},   {0x0828, 0x0828},   {0x0840, 0x0858},
-{0x0860, 0x086A},   {0x08A0, 0x08B4},   {0x08B6, 0x08C7},
-{0x0904, 0x0939},   {0x093D, 0x093D},   {0x0950, 0x0950},
-{0x0958, 0x0961},   {0x0971, 0x0980},   {0x0985, 0x098C},
-{0x098F, 0x0990},   {0x0993, 0x09A8},   {0x09AA, 0x09B0},
-{0x09B2, 0x09B2},   {0x09B6, 0x09B9},   {0x09BD, 0x09BD},
-{0x09CE, 0x09CE},   {0x09DC, 0x09DD},   {0x09DF, 0x09E1},
-{0x09F0, 0x09F1},   {0x09FC, 0x09FC},   {0x0A05, 0x0A0A},
-{0x0A0F, 0x0A10},   {0x0A13, 0x0A28},   {0x0A2A, 0x0A30},
-{0x0A32, 0x0A33},   {0x0A35, 0x0A36},   {0x0A38, 0x0A39},
-{0x0A59, 0x0A5C},   {0x0A5E, 0x0A5E},   {0x0A72, 0x0A74},
-{0x0A85, 0x0A8D},   {0x0A8F, 0x0A91},   {0x0A93, 0x0AA8},
-{0x0AAA, 0x0AB0},   {0x0AB2, 0x0AB3},   {0x0AB5, 0x0AB9},
-{0x0ABD, 0x0ABD},   {0x0AD0, 0x0AD0},   {0x0AE0, 0x0AE1},
-{0x0AF9, 0x0AF9},   {0x0B05, 0x0B0C},   {0x0B0F, 0x0B10},
-{0x0B13, 0x0B28},   {0x0B2A, 0x0B30},   {0x0B32, 0x0B33},
-{0x0B35, 0x0B39},   {0x0B3D, 0x0B3D},   {0x0B5C, 0x0B5D},
-{0x0B5F, 0x0B61},   {0x0B71, 0x0B71},   {0x0B83, 0x0B83},
-{0x0B85, 0x0B8A},   {0x0B8E, 0x0B90},   {0x0B92, 0x0B95},
-{0x0B99, 0x0B9A},   {0x0B9C, 0x0B9C},   {0x0B9E, 0x0B9F},
-{0x0BA3, 0x0BA4},   {0x0BA8, 0x0BAA},   {0x0BAE, 0x0BB9},
-{0x0BD0, 0x0BD0},   {0x0C05, 0x0C0C},   {0x0C0E, 0x0C10},
-{0x0C12, 0x0C28},   {0x0C2A, 0x0C39},   {0x0C3D, 0x0C3D},
-{0x0C58, 0x0C5A},   {0x0C60, 0x0C61},   {0x0C80, 0x0C80},
-{0x0C85, 0x0C8C},   {0x0C8E, 0x0C90},   {0x0C92, 0x0CA8},
-{0x0CAA, 0x0CB3},   {0x0CB5, 0x0CB9},   {0x0CBD, 0x0CBD},
-{0x0CDE, 0x0CDE},   {0x0CE0, 0x0CE1},   {0x0CF1, 0x0CF2},
-{0x0D04, 0x0D0C},   {0x0D0E, 0x0D10},   {0x0D12, 0x0D3A},
-{0x0D3D, 0x0D3D},   {0x0D4E, 0x0D4E},   {0x0D54, 0x0D56},
-{0x0D5F, 0x0D61},   {0x0D7A, 0x0D7F},   {0x0D85, 0x0D96},
-{0x0D9A, 0x0DB1},   {0x0DB3, 0x0DBB},   {0x0DBD, 0x0DBD},
-{0x0DC0, 0x0DC6},   {0x0E01, 0x0E30},   {0x0E32, 0x0E32},
-{0x0E40, 0x0E46},   {0x0E81, 0x0E82},   {0x0E84, 0x0E84},
-{0x0E86, 0x0E8A},   {0x0E8C, 0x0EA3},   {0x0EA5, 0x0EA5},
-{0x0EA7, 0x0EB0},   {0x0EB2, 0x0EB2},   {0x0EBD, 0x0EBD},
-{0x0EC0, 0x0EC4},   {0x0EC6, 0x0EC6},   {0x0EDC, 0x0EDF},
-{0x0F00, 0x0F00},   {0x0F40, 0x0F47},   {0x0F49, 0x0F6C},
-{0x0F88, 0x0F8C},   {0x1000, 0x102A},   {0x103F, 0x103F},
-{0x1050, 0x1055},   {0x105A, 0x105D},   {0x1061, 0x1061},
-{0x1065, 0x1066},   {0x106E, 0x1070},   {0x1075, 0x1081},
-{0x108E, 0x108E},   {0x10A0, 0x10C5},   {0x10C7, 0x10C7},
-{0x10CD, 0x10CD},   {0x10D0, 0x10FA},   {0x10FC, 0x1248},
-{0x124A, 0x124D},   {0x1250, 0x1256},   {0x1258, 0x1258},
-{0x125A, 0x125D},   {0x1260, 0x1288},   {0x128A, 0x128D},
-{0x1290, 0x12B0},   {0x12B2, 0x12B5},   {0x12B8, 0x12BE},
-{0x12C0, 0x12C0},   {0x12C2, 0x12C5},   {0x12C8, 0x12D6},
-{0x12D8, 0x1310},   {0x1312, 0x1315},   {0x1318, 0x135A},
-{0x1380, 0x138F},   {0x13A0, 0x13F5},   {0x13F8, 0x13FD},
-{0x1401, 0x166C},   {0x166F, 0x167F},   {0x1681, 0x169A},
-{0x16A0, 0x16EA},   {0x16EE, 0x16F8},   {0x1700, 0x170C},
-{0x170E, 0x1711},   {0x1720, 0x1731},   {0x1740, 0x1751},
-{0x1760, 0x176C},   {0x176E, 0x1770},   {0x1780, 0x17B3},
-{0x17D7, 0x17D7},   {0x17DC, 0x17DC},   {0x1820, 0x1878},
-{0x1880, 0x18A8},   {0x18AA, 0x18AA},   {0x18B0, 0x18F5},
-{0x1900, 0x191E},   {0x1950, 0x196D},   {0x1970, 0x1974},
-{0x1980, 0x19AB},   {0x19B0, 0x19C9},   {0x1A00, 0x1A16},
-{0x1A20, 0x1A54},   {0x1AA7, 0x1AA7},   {0x1B05, 0x1B33},
-{0x1B45, 0x1B4B},   {0x1B83, 0x1BA0},   {0x1BAE, 0x1BAF},
-{0x1BBA, 0x1BE5},   {0x1C00, 

[PATCH] D109635: [OpenMP] Support construct trait set for Clang

2021-09-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:741
+llvm::omp::TraitProperty Top = ConstructTraits.pop_back_val();
+assert(Top == Trait && "Something left a trait on the stack!");
+  }

I fixed -Wunused-variable in c5f480fcbec04f46a9cfcad08914665ff83d8d8a


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109635

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


[clang] c5f480f - [OpenMP] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build after D109635

2021-09-16 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-09-16T10:19:35-07:00
New Revision: c5f480fcbec04f46a9cfcad08914665ff83d8d8a

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

LOG: [OpenMP] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build after 
D109635

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 89a6654afdea..3fcc7abca5c5 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -739,6 +739,7 @@ class DSAStackTy {
   for (llvm::omp::TraitProperty Trait : llvm::reverse(Traits)) {
 llvm::omp::TraitProperty Top = ConstructTraits.pop_back_val();
 assert(Top == Trait && "Something left a trait on the stack!");
+(void)Top;
   }
   }
 



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


[clang] aefb81a - Removing some spurious whitespace; NFC

2021-09-16 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-09-16T13:14:08-04:00
New Revision: aefb81a33a6d44048186010677eb1c0e6c6cac12

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

LOG: Removing some spurious whitespace; NFC

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 43c9f8c565da..00ed07ae2fc3 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -385,7 +385,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation 
Loc) {
   } else {
 PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 FileName = PLoc.getFilename();
-
+
 if (FileName.empty()) {
   FileName = TheCU->getFile()->getFilename();
 } else {



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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-16 Thread greg miller via Phabricator via cfe-commits
gregmiller added a comment.

Hello, 
We are maintaining a downstream version of the monorepo based on the LLVM main 
branch. We have not transitioned to the new PM yet. In a recent attempt to 
merge the latest upstream commits into our monorepo we came across the 
following test failures after your commit.



FAIL: llvm_regressions :: Clang/CodeGen/pgo-sample-thinlto-summary.c


Script:
---

: 'RUN: at line 1';   
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/clang -cc1 
-internal-isystem 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/lib/clang/14.0.0/include
 -nostdsysteminc -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -emit-llvm -o - 2>&1 | 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/FileCheck 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -check-prefix=SAMPLEPGO-OLDPM
: 'RUN: at line 2';   
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/clang -cc1 
-internal-isystem 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/lib/clang/14.0.0/include
 -nostdsysteminc -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -emit-llvm -flto=thin -o - 2>&1 | 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/FileCheck 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -check-prefix=THINLTO-OLDPM
: 'RUN: at line 3';   
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/clang -cc1 
-internal-isystem 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/lib/clang/14.0.0/include
 -nostdsysteminc -fdebug-pass-manager -O2 
-fprofile-sample-use=/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -emit-llvm -o - 2>&1 | 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/FileCheck 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -check-prefix=SAMPLEPGO

: 'RUN: at line 4';   
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/clang -cc1 
-internal-isystem 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/lib/clang/14.0.0/include
 -nostdsysteminc -fdebug-pass-manager -O2 
-fprofile-sample-use=/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -emit-llvm -flto=thin -o - 2>&1 | 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/FileCheck 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -check-prefix=THINLTO
-

Exit Code: 1

Command Output (stderr):


+ : 'RUN: at line 1'
+ /scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/clang -cc1 
-internal-isystem 
/scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/lib/clang/14.0.0/include
 -nostdsysteminc -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -emit-llvm -o -
+ /scratch/gmiller/tools5/llvm_cgt/arm-llvm/RelWithAsserts/llvm/bin/FileCheck 
/scratch/gmiller/tools5/llvm_cgt/llvm-project/clang/test/CodeGen/pgo-sample-thinlto-summary.c
 -check-prefix=SAMPLEPGO-OLDPM
+ : 'RUN: at line 2'
+ 

[PATCH] D109060: [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C support

2021-09-16 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 372984.
Jake-Egan added a comment.

Added missing tests:
clang/test/Modules/ModuleDebugInfoDwoId.cpp
clang/test/PCH/externally-retained.m
clang/test/PCH/pending-ids.m


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109060

Files:
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Import/forward-declared-objc-class/test.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Import/objc-autoreleasepool/test.m
  clang/test/Import/objc-definitions-in-expression/test.m
  clang/test/Import/objc-method/test.m
  clang/test/Import/objc-param-decl/test.m
  clang/test/Import/objc-try-catch/test.m
  clang/test/Modules/DebugInfoNamespace.cpp
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ExtDebugInfo.m
  clang/test/Modules/ModuleDebugInfoDwoId.cpp
  clang/test/Modules/ModuleModuleDebugInfo.cpp
  clang/test/Modules/autolink.m
  clang/test/Modules/autolinkTBD.m
  clang/test/Modules/cxx-irgen.cpp
  clang/test/Modules/debug-info-moduleimport.m
  clang/test/Modules/direct-module-import.m
  clang/test/Modules/merge-record-definition-nonmodular.m
  clang/test/Modules/merge-record-definition-visibility.m
  clang/test/Modules/merge-record-definition.m
  clang/test/Modules/module_file_info.m
  clang/test/Modules/objc-initializer.m
  clang/test/Modules/pch-used.m
  clang/test/Modules/use-exportas-for-link.m
  clang/test/PCH/externally-retained.m
  clang/test/PCH/irgen-rdar13114142.mm
  clang/test/PCH/objc_container.m
  clang/test/PCH/objc_literals.m
  clang/test/PCH/objc_literals.mm
  clang/test/PCH/objcxx-ivar-class.mm
  clang/test/PCH/pending-ids.m

Index: clang/test/PCH/pending-ids.m
===
--- clang/test/PCH/pending-ids.m
+++ clang/test/PCH/pending-ids.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test for rdar://10278815
 
 // Without PCH
Index: clang/test/PCH/objcxx-ivar-class.mm
===
--- clang/test/PCH/objcxx-ivar-class.mm
+++ clang/test/PCH/objcxx-ivar-class.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s
 
Index: clang/test/PCH/objc_literals.mm
===
--- clang/test/PCH/objc_literals.mm
+++ clang/test/PCH/objc_literals.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_literals.m
===
--- clang/test/PCH/objc_literals.m
+++ clang/test/PCH/objc_literals.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -verify %s
 // RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_container.m
===
--- clang/test/PCH/objc_container.m
+++ clang/test/PCH/objc_container.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objc_container.h -fsyntax-only -verify %s
 
Index: clang/test/PCH/irgen-rdar13114142.mm
===
--- clang/test/PCH/irgen-rdar13114142.mm
+++ clang/test/PCH/irgen-rdar13114142.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-pch -o %t.pch
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -include-pch %t.pch -o - | FileCheck %s
 
Index: clang/test/PCH/externally-retained.m
===
--- clang/test/PCH/externally-retained.m
+++ clang/test/PCH/externally-retained.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test for assertion failure due to objc_externally_retained on a function.
 
 // Without PCH
Index: clang/test/Modules/use-exportas-for-link.m
===
--- clang/test/Modules/use-exportas-for-link.m
+++ clang/test/Modules/use-exportas-for-link.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -DA -fmodules -fimplicit-module-maps -F %S/Inputs/exportas-link %s | FileCheck --check-prefix=CHECK_A %s
 // CHECK_A: !llvm.linker.options = !{![[MODULE:[0-9]+]]}
Index: 

[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-16 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

I can at least confirm that both the original test case for bug 51862 (from 
https://github.com/Macaulay2/frobby ) and the reduced test case compile 
successfully with this patch added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/target-data.c:256
 
+// RUN: %clang_cc1 -triple s390x-none-zos -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS

If you add so many RUN lines at once, please use unittests instead. This would 
cost some test execution time


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[PATCH] D109898: [clang][NFC] refactor GlobalMethodPool to encapsulate its map

2021-09-16 Thread Richard Howell via Phabricator via cfe-commits
rmaz created this revision.
rmaz added reviewers: dexonsmith, manmanren, vsapsai.
rmaz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This refactor changes the GlobalMethodPool to a class that contains
the DenseMap of methods. This is to allow for the addition of a
separate DenseSet in a follow-up diff that will handle method
de-duplication when inserting methods into the global method pool.

Changes:

- the GlobalMethods pair becomes a GlobalMethodLists struct for better clarity
- the GlobalMethodPool becomes a class containing the DenseMap of methods
- pass through methods are added to maintain most of the existing code without 
changing MethodPool -> MethodPool.Methods everywhere


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109898

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -3122,8 +3122,8 @@
 ObjCMethodList()
   };
   if (F != SemaRef.MethodPool.end()) {
-Data.Instance = F->second.first;
-Data.Factory = F->second.second;
+Data.Instance = F->second.InstanceMethods;
+Data.Factory = F->second.ClassMethods;
   }
   // Only write this selector if it's not in an existing AST or something
   // changed.
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4006,8 +4006,9 @@
 return;
 
   // Retrieve the appropriate method list.
-  ObjCMethodList  = Method->isInstanceMethod()? Known->second.first
-: Known->second.second;
+  ObjCMethodList  = Method->isInstanceMethod()
+  ? Known->second.InstanceMethods
+  : Known->second.ClassMethods;
   bool Found = false;
   for (ObjCMethodList *List =  List; List = List->getNext()) {
 if (!Found) {
@@ -8208,19 +8209,22 @@
 return;
 
   Sema  = *getSema();
-  Sema::GlobalMethodPool::iterator Pos
-= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
+  Sema::GlobalMethodPool::iterator Pos =
+  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodLists())).first;
 
-  Pos->second.first.setBits(Visitor.getInstanceBits());
-  Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
-  Pos->second.second.setBits(Visitor.getFactoryBits());
-  Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());
+  Pos->second.InstanceMethods.setBits(Visitor.getInstanceBits());
+  Pos->second.InstanceMethods.setHasMoreThanOneDecl(
+  Visitor.instanceHasMoreThanOneDecl());
+  Pos->second.ClassMethods.setBits(Visitor.getFactoryBits());
+  Pos->second.ClassMethods.setHasMoreThanOneDecl(
+  Visitor.factoryHasMoreThanOneDecl());
 
   // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
   // when building a module we keep every method individually and may need to
   // update hasMoreThanOneDecl as we add the methods.
-  addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
-  addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
+  addMethodsToPool(S, Visitor.getInstanceMethods(),
+   Pos->second.InstanceMethods);
+  addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.ClassMethods);
 }
 
 void ASTReader::updateOutOfDateSelector(Selector Sel) {
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -1215,13 +1215,13 @@
   for (Sema::GlobalMethodPool::iterator b = S.MethodPool.begin(),
e = S.MethodPool.end(); b != e; b++) {
 // first, instance methods
-ObjCMethodList  = b->second.first;
+ObjCMethodList  = b->second.InstanceMethods;
 if (HelperToDiagnoseMismatchedMethodsInGlobalPool(S, AtLoc, LParenLoc, RParenLoc,
   Method, InstMethList))
   Warned = true;
 
 // second, class methods
-ObjCMethodList  = b->second.second;
+ObjCMethodList  = b->second.ClassMethods;
 if (HelperToDiagnoseMismatchedMethodsInGlobalPool(S, AtLoc, LParenLoc, RParenLoc,
   Method, ClsMethList) || Warned)
   return;
@@ -1262,9 +1262,9 @@
 return nullptr;
 
   ObjCMethodDecl *DirectInstance = LookupDirectMethodInMethodList(
-  S, Sel, Iter->second.first, onlyDirect, anyDirect);
+  S, Sel, 

[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-16 Thread Cameron Mulhern via Phabricator via cfe-commits
csmulhern marked an inline comment as done.
csmulhern added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:22410
+   ");",
+   Style);
+}

MyDeveloperDay wrote:
> Can you assert the cases it won't do (given your description it seem like it 
> would do it for all before ) cases)
> 
> ```
> int a = (int
> ) b;
> ```
> 
> I'm pretty sure it won't but lets me explicit in the tests
> 
> ```
> return (true
> );
> ```
> 
> ```
> void foo(
> );
> ```
> 
> etc..
> 
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-16 Thread Cameron Mulhern via Phabricator via cfe-commits
csmulhern updated this revision to Diff 372979.
csmulhern marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18242,6 +18242,7 @@
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakBeforeClosingParen);
   CHECK_PARSE_BOOL(BreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
@@ -22294,6 +22295,165 @@
   "}";
   EXPECT_EQ(Code, format(Code, Style));
 }
+
+TEST_F(FormatTest, BreakBeforeClosingParen) {
+  auto Style = getLLVMStyle();
+
+  StringRef Short = "functionCall(paramA, paramB, paramC);\n"
+"void functionDecl(int a, int b, int c);";
+
+  StringRef Medium = "functionCall(paramA, paramB, paramC, paramD, paramE, "
+ "paramF, paramG, paramH, paramI);\n"
+ "void functionDecl(int argumentA, int argumentB, int "
+ "argumentC, int argumentD, int argumentE);";
+
+  verifyFormat(Short, Style);
+
+  StringRef NoBreak = "functionCall(paramA, paramB, paramC, paramD, paramE, "
+  "paramF, paramG, paramH,\n"
+  " paramI);\n"
+  "void functionDecl(int argumentA, int argumentB, int "
+  "argumentC, int argumentD,\n"
+  "  int argumentE);";
+
+  EXPECT_EQ(NoBreak, format(Medium, Style));
+  EXPECT_EQ(NoBreak, format("functionCall(\n"
+"paramA,\n"
+"paramB,\n"
+"paramC,\n"
+"paramD,\n"
+"paramE,\n"
+"paramF,\n"
+"paramG,\n"
+"paramH,\n"
+"paramI\n"
+");\n"
+"void functionDecl(\n"
+"int argumentA,\n"
+"int argumentB,\n"
+"int argumentC,\n"
+"int argumentD,\n"
+"int argumentE\n"
+");",
+Style));
+
+  verifyFormat("outerFunctionCall(nestedFunctionCall(argument1),\n"
+   "  nestedLongFunctionCall(argument1, "
+   "argument2, argument3,\n"
+   " argument4, "
+   "argument5));",
+   Style);
+
+  Style.BreakBeforeClosingParen = true;
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ(NoBreak, format(Medium, Style));
+
+  Style.AllowAllArgumentsOnNextLine = false;
+  Style.AllowAllConstructorInitializersOnNextLine = false;
+  Style.AllowAllParametersOfDeclarationOnNextLine = false;
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ(NoBreak, format(Medium, Style));
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ("functionCall(\n"
+"paramA, paramB, paramC, paramD, paramE, paramF, paramG, "
+"paramH, paramI\n"
+");\n"
+"void functionDecl(\n"
+"int argumentA, int argumentB, int argumentC, int argumentD, "
+"int argumentE\n"
+");",
+format(Medium, Style));
+
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ("functionCall(\n"
+"paramA,\n"
+"paramB,\n"
+"paramC,\n"
+"paramD,\n"
+"paramE,\n"
+"paramF,\n"
+"paramG,\n"
+"paramH,\n"
+"paramI\n"
+");\n"
+"void functionDecl(\n"
+"int argumentA,\n"
+"int argumentB,\n"
+"int argumentC,\n"
+"int argumentD,\n"
+"int argumentE\n"
+");",
+format(Medium, Style));
+
+  verifyFormat("outerFunctionCall(\n"
+   "nestedFunctionCall(argument1),\n"
+   "nestedLongFunctionCall(\n"
+   "argument1,\n"
+   "  

[PATCH] D109635: [OpenMP] Support construct trait set for Clang

2021-09-16 Thread Chi Chun Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG976d474bec35: [OpenMP] Support construct trait set for Clang 
(authored by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109635

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_variant_ast_print.c
  clang/test/OpenMP/declare_variant_ast_print.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/declare_variant_messages.c

Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -57,6 +57,12 @@
 #pragma omp declare variant(foo) match(user = {condition()}) // expected-error {{expected expression}} expected-error {{use of undeclared identifier 'expr'}} expected-error {{expected expression}} expected-note {{the ignored selector spans until here}}
 int score_and_cond_non_const();
 
+#pragma omp declare variant(foo) match(construct={teams,parallel,for,simd})
+#pragma omp declare variant(foo) match(construct={target teams}) // expected-error {{expected ')'}} expected-warning {{expected '}' after the context selectors for the context set "construct"; '}' assumed}} expected-note {{to match this '('}}
+#pragma omp declare variant(foo) match(construct={parallel for}) // expected-error {{expected ')'}} expected-warning {{expected '}' after the context selectors for the context set "construct"; '}' assumed}} expected-note {{to match this '('}}
+#pragma omp declare variant(foo) match(construct={for simd}) // expected-error {{expected ')'}} expected-warning {{expected '}' after the context selectors for the context set "construct"; '}' assumed}} expected-note {{to match this '('}}
+int construct(void);
+
 #pragma omp declare variant(foo) match(xxx={}) // expected-warning {{'xxx' is not a valid context set in a `declare variant`; set ignored}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
 int a; // expected-error {{'#pragma omp declare variant' can only be applied to functions}}
 
Index: clang/test/OpenMP/declare_variant_construct_codegen_1.c
===
--- /dev/null
+++ clang/test/OpenMP/declare_variant_construct_codegen_1.c
@@ -0,0 +1,334 @@
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c -triple x86_64-unknown-linux -emit-pch -o %t -fopenmp-version=45 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c -triple x86_64-unknown-linux -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CK1
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c -triple x86_64-unknown-linux -emit-pch -o %t -fopenmp-version=45 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c -triple x86_64-unknown-linux -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -include-pch %t 

[clang] 976d474 - [OpenMP] Support construct trait set for Clang

2021-09-16 Thread via cfe-commits

Author: cchen
Date: 2021-09-16T11:34:31-05:00
New Revision: 976d474bec357d7712884ce4691be45d247325bd

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

LOG: [OpenMP] Support construct trait set for Clang

This patch supports construct trait set selector by using the existed
declare variant infrastructure inside `OMPContext` and simd selector is
currently not supported. The goal of this patch is to pass the declare variant
test inside sollve test suite.

Reviewed By: jdoerfert

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

Added: 
clang/test/OpenMP/declare_variant_construct_codegen_1.c

Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/declare_variant_ast_print.c
clang/test/OpenMP/declare_variant_ast_print.cpp
clang/test/OpenMP/declare_variant_messages.c

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 3b78dc87684f1..749eff57313a8 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -8547,10 +8547,11 @@ llvm::raw_ostream <<(llvm::raw_ostream , 
const OMPTraitInfo *TI);
 
 /// Clang specific specialization of the OMPContext to lookup target features.
 struct TargetOMPContext final : public llvm::omp::OMPContext {
-
   TargetOMPContext(ASTContext ,
std::function &,
-   const FunctionDecl *CurrentFunctionDecl);
+   const FunctionDecl *CurrentFunctionDecl,
+   ArrayRef ConstructTraits);
+
   virtual ~TargetOMPContext() = default;
 
   /// See llvm::omp::OMPContext::matchesISATrait

diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 50f40395a1975..596a55e425feb 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -2342,8 +2342,6 @@ void OMPTraitInfo::getAsVariantMatchInfo(ASTContext 
,
  getOpenMPContextTraitPropertyForSelector(
  Selector.Kind) &&
  "Ill-formed construct selector!");
-
-  VMI.ConstructTraits.push_back(Selector.Properties.front().Kind);
 }
   }
 }
@@ -2474,7 +2472,8 @@ llvm::raw_ostream ::operator<<(llvm::raw_ostream 
,
 
 TargetOMPContext::TargetOMPContext(
 ASTContext , std::function &,
-const FunctionDecl *CurrentFunctionDecl)
+const FunctionDecl *CurrentFunctionDecl,
+ArrayRef ConstructTraits)
 : OMPContext(ASTCtx.getLangOpts().OpenMPIsDevice,
  ASTCtx.getTargetInfo().getTriple()),
   FeatureValidityCheck([&](StringRef FeatureName) {
@@ -2482,6 +2481,9 @@ TargetOMPContext::TargetOMPContext(
   }),
   DiagUnknownTrait(std::move(DiagUnknownTrait)) {
   ASTCtx.getFunctionFeatureMap(FeatureMap, CurrentFunctionDecl);
+
+  for (llvm::omp::TraitProperty Property : ConstructTraits)
+addTrait(Property);
 }
 
 bool TargetOMPContext::matchesISATrait(StringRef RawString) const {

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index e953446cd5bac..fb4c541f1d741 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -828,7 +828,7 @@ static StringRef stringLiteralParser(Parser ) {
 
 static StringRef getNameFromIdOrString(Parser , Token ,
OMPContextLvl Lvl) {
-  if (Tok.is(tok::identifier)) {
+  if (Tok.is(tok::identifier) || Tok.is(tok::kw_for)) {
 llvm::SmallString<16> Buffer;
 StringRef Name = P.getPreprocessor().getSpelling(Tok, Buffer);
 (void)P.ConsumeToken();
@@ -2046,8 +2046,10 @@ Parser::DeclGroupPtrTy 
Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
   // improve the diagnostic location.
   Diag(Loc, diag::warn_unknown_begin_declare_variant_isa_trait) << 
ISATrait;
 };
-TargetOMPContext OMPCtx(ASTCtx, std::move(DiagUnknownTrait),
-/* CurrentFunctionDecl */ nullptr);
+TargetOMPContext OMPCtx(
+ASTCtx, std::move(DiagUnknownTrait),
+/* CurrentFunctionDecl */ nullptr,
+/* ConstructTraits */ ArrayRef());
 
 if (isVariantApplicableInContext(VMI, OMPCtx, /* DeviceSetOnly */ true)) {
   Actions.ActOnOpenMPBeginDeclareVariant(Loc, TI);

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cbfb0dd63b5b2..89a6654afdea0 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -310,6 +310,8 @@ class DSAStackTy {
   /// Vector of previously encountered target directives
   SmallVector TargetLocations;
   SourceLocation AtomicLocation;
+  /// Vector of declare variant construct traits.
+  SmallVector ConstructTraits;
 
 public:
   explicit 

[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

@yaxunl Under what criteria should an alias not be removed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-16 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109857

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


[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-16 Thread Matthew Voss via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG003fed8269b3: [test] Fix test failure in Clang :: 
Lexer/char-escapes-delimited.c (authored by ormris).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109857

Files:
  clang/test/Lexer/char-escapes-delimited.c


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
-// RUN: %clang_cc1 -x c -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
 
 const char *errors =
 "\u{}"  //expected-error {{delimited escape sequence cannot be empty}}


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
 
 const char *errors =
 "\u{}"  //expected-error {{delimited escape sequence cannot be empty}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 003fed8 - [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-16 Thread Matthew Voss via cfe-commits

Author: Matthew Voss
Date: 2021-09-16T09:20:05-07:00
New Revision: 003fed8269b3f6d2b1618b670fc73d28972999e4

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

LOG: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

Specify the C and C++ standards explicitly for this test. This avoids
failures for drivers that default to older standards.

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

Added: 


Modified: 
clang/test/Lexer/char-escapes-delimited.c

Removed: 




diff  --git a/clang/test/Lexer/char-escapes-delimited.c 
b/clang/test/Lexer/char-escapes-delimited.c
index ad413d1843b06..62465db464bce 100644
--- a/clang/test/Lexer/char-escapes-delimited.c
+++ b/clang/test/Lexer/char-escapes-delimited.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
-// RUN: %clang_cc1 -x c -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
 
 const char *errors =
 "\u{}"  //expected-error {{delimited escape sequence cannot be empty}}



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


[PATCH] D109727: [Driver] Remove unneeded *-suse-* triples

2021-09-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D109727#3003498 , @luismarques 
wrote:

> Regarding D74399 , cmake on a fedora RISC-V 
> host still detects a generic triple:
>
>   -- LLVM host triple: riscv64-unknown-linux-gnu
>   -- LLVM default target triple: riscv64-unknown-linux-gnu
>
> as opposed to the `gcc -dumpmachine` triple of `riscv64-redhat-linux` (with 
> the vendor and no `-gnu` suffix), needed for a working toolchain. (I don't 
> know if that cmake behaviour is uncommon or not).

This is due to issues in config.guess. D109837 
 will fix it.

> Are you saying that it's fine for D74399  to 
> remain because of that, or does your argument also imply that D74399 
>  should be reverted? Would the answer change 
> if cmake started detecting the "proper" triple? (and what would the 
> deprecation path for that be, if any?).

The code change of D74399  should be reverted. 
The test can stay, but I won't think we need too many riscv64-$distro-linux-gnu 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109727

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


[PATCH] D58920: [Modules][PR39287] Consolidate multiple std's

2021-09-16 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added inline comments.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3198-3199
 // lookups will find it.
 MergeDC->makeDeclVisibleInContextImpl(New, /*Internal*/true);
+if (isa(New) && Name.getAsString() == "std")
+  if (!Reader.getSema()->StdNamespace)

Don't we also have to check New's context is the global namespace?  What 
happens for something like 'namespace evil::std {};'?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58920

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


[PATCH] D109451: Summary: Introduce a new frontend flag `-fswift-async-fp={auto|always|never}` that controls how code generation sets the Swift extended async frame info bit. There are three possibili

2021-09-16 Thread Arnold Schwaighofer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf670c5aeeef0: Add a new frontend flag 
`-fswift-async-fp={auto|always|never}` (authored by aschwaighofer).

Changed prior to commit:
  https://reviews.llvm.org/D109451?vs=371383=372966#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109451

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/swift-async-extended-fp.c

Index: clang/test/CodeGen/swift-async-extended-fp.c
===
--- /dev/null
+++ clang/test/CodeGen/swift-async-extended-fp.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
+// RUN: %clang_cc1 -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
+// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=NEVER-X86
+// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=NEVER-X86
+// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=AUTO-X86
+// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
+// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
+// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
+
+// RUN: %clang_cc1 -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
+// RUN: %clang_cc1 -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
+// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=AUTO-ARM64
+// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
+// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=NEVER-ARM64
+// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=NEVER-ARM64
+// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
+// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
+
+// REQUIRES: aarch64-registered-target,x86-registered-target
+
+#define SWIFTASYNCCALL __attribute__((swiftasynccall))
+#define ASYNC_CONTEXT __attribute__((swift_async_context))
+
+SWIFTASYNCCALL void async_context_1(ASYNC_CONTEXT void *ctx) {}
+
+// AUTO-X86: _async_context_1:
+// AUTO-X86:	_swift_async_extendedFramePointerFlags
+
+// ALWAYS-X86: _async_context_1:
+// ALWAYS-X86: btsq	$60
+
+// NEVER-X86: _async_context_1:
+// NEVER-X86-NOT:	_swift_async_extendedFramePointerFlags
+// NEVER-X86-NOT: btsq	$60
+
+// AUTO-ARM64: _async_context_1
+// AUTO-ARM64: _swift_async_extendedFramePointerFlags
+
+// ALWAYS-ARM64: _async_context_1
+// ALWAYS-ARM64: orr x29, x29, #0x1000
+
+// NEVER-ARM64: _async_context_1:
+// NEVER-ARM64-NOT:	_swift_async_extendedFramePointerFlags
+// NEVER-ARM64-NOT: orr x29, x29, #0x1000
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5912,6 +5912,8 @@
   RenderSCPOptions(TC, Args, CmdArgs);
   RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
 
+  Args.AddLastArg(CmdArgs, options::OPT_fswift_async_fp_EQ);
+
   // Translate -mstackrealign
   if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
false))
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ 

[clang] f670c5a - Add a new frontend flag `-fswift-async-fp={auto|always|never}`

2021-09-16 Thread Arnold Schwaighofer via cfe-commits

Author: Arnold Schwaighofer
Date: 2021-09-16T08:48:51-07:00
New Revision: f670c5aeeef09cd7b88e72cf8c1f2505d044a8ea

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

LOG: Add a new frontend flag `-fswift-async-fp={auto|always|never}`

Summary:
Introduce a new frontend flag `-fswift-async-fp={auto|always|never}`
that controls how code generation sets the Swift extended async frame
info bit. There are three possibilities:

* `auto`: which determines how to set the bit based on deployment target, either
statically or dynamically via `swift_async_extendedFramePointerFlags`.
* `always`: default, always set the bit statically, regardless of deployment
target.
* `never`: never set the bit, regardless of deployment target.

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

Added: 
clang/test/CodeGen/swift-async-extended-fp.c

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 737d2d70bf46..37900bf3ead1 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -440,6 +440,11 @@ CODEGENOPT(AAPCSBitfieldWidth, 1, 1)
 /// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only)
 CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1)
 
+// Whether to emit Swift Async function extended frame information: auto,
+// never, always.
+ENUM_CODEGENOPT(SwiftAsyncFramePointer, SwiftAsyncFramePointerKind, 2,
+SwiftAsyncFramePointerKind::Always)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 617c255641ef..6a0bce0ad80a 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -125,6 +125,13 @@ class CodeGenOptions : public CodeGenOptionsBase {
 All, // Keep all frame pointers.
   };
 
+  enum class SwiftAsyncFramePointerKind {
+Auto, // Choose Swift async extended frame info based on deployment target.
+Always, // Unconditionally emit Swift async extended frame info.
+Never,  // Don't emit Swift async extended frame info.
+Default = Always,
+  };
+
   enum FiniteLoopsKind {
 Language, // Not specified, use language standard.
 Always,   // All loops are assumed to be finite.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 84b22df09ddd..f0932a0bd1de 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1275,6 +1275,13 @@ def fprofile_list_EQ : Joined<["-"], "fprofile-list=">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Filename defining the list of functions/files to instrument">,
 MarshallingInfoStringVector>;
+def fswift_async_fp_EQ : Joined<["-"], "fswift-async-fp=">,
+Group, Flags<[CC1Option, CC1AsOption, CoreOption]>, 
MetaVarName<"">,
+HelpText<"Control emission of Swift async extended frame info (option: 
auto, always, never)">,
+Values<"auto,always,never">,
+NormalizedValuesScope<"CodeGenOptions::SwiftAsyncFramePointerKind">,
+NormalizedValues<["Auto", "Always", "Never"]>,
+MarshallingInfoEnum, "Always">;
 
 defm addrsig : BoolFOption<"addrsig",
   CodeGenOpts<"Addrsig">, DefaultFalse,

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 2fdad81241c6..e31fa3f9f94d 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -582,6 +582,21 @@ static bool initTargetOptions(DiagnosticsEngine ,
   Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
   Options.LoopAlignment = CodeGenOpts.LoopAlignment;
 
+  switch (CodeGenOpts.getSwiftAsyncFramePointer()) {
+  case CodeGenOptions::SwiftAsyncFramePointerKind::Auto:
+Options.SwiftAsyncFramePointer =
+SwiftAsyncFramePointerMode::DeploymentBased;
+break;
+
+  case CodeGenOptions::SwiftAsyncFramePointerKind::Always:
+Options.SwiftAsyncFramePointer = SwiftAsyncFramePointerMode::Always;
+break;
+
+  case CodeGenOptions::SwiftAsyncFramePointerKind::Never:
+Options.SwiftAsyncFramePointer = SwiftAsyncFramePointerMode::Never;
+break;
+  }
+
   Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 

[PATCH] D109894: [clangd] Bail-out when an empty compile flag is encountered

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Fixes https://github.com/clangd/clangd/issues/865


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109894

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp


Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -396,6 +396,13 @@
   llvm::count_if(Args, [](llvm::StringRef Arg) { return Arg == "-arch"; }),
   1);
 }
+
+TEST(CommandMangler, EmptyArgs) {
+  const auto Mangler = CommandMangler::forTests();
+  std::vector Args = {};
+  // Make sure we don't crash.
+  Mangler.adjust(Args, "foo.cc");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -198,22 +198,26 @@
 void CommandMangler::adjust(std::vector ,
 llvm::StringRef File) const {
   trace::Span S("AdjustCompileFlags");
+  // Most of the modifications below assumes the Cmd starts with a driver name.
+  // We might consider injecting a generic driver name like "cc" or "c++", but
+  // a Cmd missing the driver is probably rare enough in practice and errnous.
+  if (Cmd.empty())
+return;
   auto  = clang::driver::getDriverOptTable();
   // OriginalArgs needs to outlive ArgList.
   llvm::SmallVector OriginalArgs;
   OriginalArgs.reserve(Cmd.size());
   for (const auto  : Cmd)
 OriginalArgs.push_back(S.c_str());
-  bool IsCLMode =
-  !OriginalArgs.empty() &&
-  driver::IsClangCL(driver::getDriverMode(
-  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
+  bool IsCLMode = driver::IsClangCL(driver::getDriverMode(
+  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
   // ParseArgs propagates missig arg/opt counts on error, but preserves
   // everything it could parse in ArgList. So we just ignore those counts.
   unsigned IgnoredCount;
   // Drop the executable name, as ParseArgs doesn't expect it. This means
   // indices are actually of by one between ArgList and OriginalArgs.
-  auto ArgList = OptTable.ParseArgs(
+  llvm::opt::InputArgList ArgList;
+  ArgList = OptTable.ParseArgs(
   llvm::makeArrayRef(OriginalArgs).drop_front(), IgnoredCount, 
IgnoredCount,
   /*FlagsToInclude=*/
   IsCLMode ? (driver::options::CLOption | driver::options::CoreOption)


Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -396,6 +396,13 @@
   llvm::count_if(Args, [](llvm::StringRef Arg) { return Arg == "-arch"; }),
   1);
 }
+
+TEST(CommandMangler, EmptyArgs) {
+  const auto Mangler = CommandMangler::forTests();
+  std::vector Args = {};
+  // Make sure we don't crash.
+  Mangler.adjust(Args, "foo.cc");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -198,22 +198,26 @@
 void CommandMangler::adjust(std::vector ,
 llvm::StringRef File) const {
   trace::Span S("AdjustCompileFlags");
+  // Most of the modifications below assumes the Cmd starts with a driver name.
+  // We might consider injecting a generic driver name like "cc" or "c++", but
+  // a Cmd missing the driver is probably rare enough in practice and errnous.
+  if (Cmd.empty())
+return;
   auto  = clang::driver::getDriverOptTable();
   // OriginalArgs needs to outlive ArgList.
   llvm::SmallVector OriginalArgs;
   OriginalArgs.reserve(Cmd.size());
   for (const auto  : Cmd)
 OriginalArgs.push_back(S.c_str());
-  bool IsCLMode =
-  !OriginalArgs.empty() &&
-  driver::IsClangCL(driver::getDriverMode(
-  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
+  bool IsCLMode = driver::IsClangCL(driver::getDriverMode(
+  OriginalArgs[0], llvm::makeArrayRef(OriginalArgs).slice(1)));
   // ParseArgs propagates missig arg/opt counts on error, but preserves
   // everything it could parse in ArgList. So we just ignore those counts.
   unsigned IgnoredCount;
   // Drop the executable name, as ParseArgs doesn't expect it. This 

[clang] 720766a - Remove trailing whitespace in ASTReaderDecl.cpp

2021-09-16 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-09-16T08:23:28-07:00
New Revision: 720766a50cab7a143f0aa04e3ae344769072511d

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

LOG: Remove trailing whitespace in ASTReaderDecl.cpp

Added: 


Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index ef7921212f21b..97db833d41ca6 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1764,7 +1764,7 @@ void ASTDeclReader::ReadCXXDefinitionData(
   Data.HasODRHash = true;
 
   if (Record.readInt()) {
-Reader.DefinitionSource[D] = 
+Reader.DefinitionSource[D] =
 Loc.F->Kind == ModuleKind::MK_MainFile ||
 Reader.getContext().getLangOpts().BuildingPCHWithObjectFile;
   }



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


[PATCH] D109880: [clangd] PreamblePatch should be no-op if includes arent patched

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rG64fe0458866d: [clangd] PreamblePatch should be no-op if 
includes arent patched (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D109880?vs=372920=372951#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109880

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp


Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -554,6 +554,20 @@
   auto AST = createPatchedAST(Baseline, Modified);
   ASSERT_TRUE(AST);
 }
+
+TEST(PreamblePatch, NoopWhenNotRequested) {
+  llvm::StringLiteral Baseline = "#define M\nint num = M;";
+  llvm::StringLiteral Modified = "#define M\n#include \nint num = M;";
+  auto TU = TestTU::withCode(Baseline);
+  auto BaselinePreamble = TU.preamble();
+  ASSERT_TRUE(BaselinePreamble);
+
+  TU.Code = Modified.str();
+  MockFS FS;
+  auto PP = PreamblePatch::createMacroPatch(testPath(TU.Filename),
+TU.inputs(FS), *BaselinePreamble);
+  EXPECT_TRUE(PP.text().empty());
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -459,7 +459,8 @@
   bool IncludesChanged = BaselineScan->Includes != ModifiedScan->Includes;
   bool DirectivesChanged =
   BaselineScan->TextualDirectives != ModifiedScan->TextualDirectives;
-  if (!IncludesChanged && !DirectivesChanged)
+  if ((PatchType == PatchType::MacroDirectives || !IncludesChanged) &&
+  !DirectivesChanged)
 return PreamblePatch::unmodified(Baseline);
 
   PreamblePatch PP;


Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -554,6 +554,20 @@
   auto AST = createPatchedAST(Baseline, Modified);
   ASSERT_TRUE(AST);
 }
+
+TEST(PreamblePatch, NoopWhenNotRequested) {
+  llvm::StringLiteral Baseline = "#define M\nint num = M;";
+  llvm::StringLiteral Modified = "#define M\n#include \nint num = M;";
+  auto TU = TestTU::withCode(Baseline);
+  auto BaselinePreamble = TU.preamble();
+  ASSERT_TRUE(BaselinePreamble);
+
+  TU.Code = Modified.str();
+  MockFS FS;
+  auto PP = PreamblePatch::createMacroPatch(testPath(TU.Filename),
+TU.inputs(FS), *BaselinePreamble);
+  EXPECT_TRUE(PP.text().empty());
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -459,7 +459,8 @@
   bool IncludesChanged = BaselineScan->Includes != ModifiedScan->Includes;
   bool DirectivesChanged =
   BaselineScan->TextualDirectives != ModifiedScan->TextualDirectives;
-  if (!IncludesChanged && !DirectivesChanged)
+  if ((PatchType == PatchType::MacroDirectives || !IncludesChanged) &&
+  !DirectivesChanged)
 return PreamblePatch::unmodified(Baseline);
 
   PreamblePatch PP;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 64fe045 - [clangd] PreamblePatch should be no-op if includes arent patched

2021-09-16 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-09-16T17:11:31+02:00
New Revision: 64fe0458866d7bcadacb776a1fa7d827ba8ab916

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

LOG: [clangd] PreamblePatch should be no-op if includes arent patched

Don't create a useless functional patch with only filename in it when
there is only include directives to be patched but they're not
requested.

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

Added: 


Modified: 
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/unittests/PreambleTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index 72a53b2fdac5..0feb40113309 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -459,7 +459,8 @@ PreamblePatch PreamblePatch::create(llvm::StringRef 
FileName,
   bool IncludesChanged = BaselineScan->Includes != ModifiedScan->Includes;
   bool DirectivesChanged =
   BaselineScan->TextualDirectives != ModifiedScan->TextualDirectives;
-  if (!IncludesChanged && !DirectivesChanged)
+  if ((PatchType == PatchType::MacroDirectives || !IncludesChanged) &&
+  !DirectivesChanged)
 return PreamblePatch::unmodified(Baseline);
 
   PreamblePatch PP;

diff  --git a/clang-tools-extra/clangd/unittests/PreambleTests.cpp 
b/clang-tools-extra/clangd/unittests/PreambleTests.cpp
index bd9f9893adf9..6001533005c9 100644
--- a/clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ b/clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -554,6 +554,20 @@ TEST(PreamblePatch, MacroLoc) {
   auto AST = createPatchedAST(Baseline, Modified);
   ASSERT_TRUE(AST);
 }
+
+TEST(PreamblePatch, NoopWhenNotRequested) {
+  llvm::StringLiteral Baseline = "#define M\nint num = M;";
+  llvm::StringLiteral Modified = "#define M\n#include \nint num = M;";
+  auto TU = TestTU::withCode(Baseline);
+  auto BaselinePreamble = TU.preamble();
+  ASSERT_TRUE(BaselinePreamble);
+
+  TU.Code = Modified.str();
+  MockFS FS;
+  auto PP = PreamblePatch::createMacroPatch(testPath(TU.Filename),
+TU.inputs(FS), *BaselinePreamble);
+  EXPECT_TRUE(PP.text().empty());
+}
 } // namespace
 } // namespace clangd
 } // namespace clang



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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-16 Thread Richard Howell via Phabricator via cfe-commits
rmaz added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1423-1426
+ObjCMethodList InstanceMethods;
+ObjCMethodList FactoryMethods;
+llvm::DenseSet AddedInstanceMethods;
+llvm::DenseSet AddedFactoryMethods;

dexonsmith wrote:
> Do these two sets really need to be per-selector (per `GlobalMethods` object 
> in GlobalMethodPool)? I feel like they could be global to `Sema`, as long as 
> the same `ObjCMethodDecl` is never added to GlobalMethodPool for more than 
> one selector. (It seems plausible we have that property since presumably 
> ObjCMethodDecl::getSelector is always the key used for inserting into 
> GlobalMethodPool below... can you confirm?)
> 
> Assuming you can pull the sets out to represent the GlobalMethodPool as a 
> whole, then I suggest creating a data structure for GlobalMethodPool that 
> encapsulates the DenseMap and the two sets (maybe: rename "GlobalMethods" to 
> "GlobalMethodLists", rename "GlobalMethodPool" to "GlobalMethods", and give 
> the new data structure the name "GlobalMethodPool"). Best to do it as 
> multiple commits: NFC commit(s) to refactor (renames, create new type update 
> call sites to use new APIs, etc.), and a final commit that changes the 
> functionality (adding the set behaviour) but that doesn't need to touch call 
> sites.
> 
> On the other hand, if the sets really need to be per-selector (please explain 
> why if so...), please use SmallPtrSet here instead of DenseSet to avoid 
> allocation in the common case of 1 decl per selector. I'd suggest 
> encapsulating the list/set together somehow (maybe starting with an NFC 
> refactoring to add a "list/set" data structure at the top-level (maybe rename 
> ObjCMethodList => ObjCMethodListNode, and the new list has a private member 
> called "Head" and necessary APIs for insertion/etc), then in a second commit 
> adding the SmallPtrSet into the list data structure and use it to gate the 
> "insert" operation).
> 
> I feel like they could be global to Sema, as long as the same ObjCMethodDecl 
> is never added to GlobalMethodPool for more than one selector. (It seems 
> plausible we have that property since presumably ObjCMethodDecl::getSelector 
> is always the key used for inserting into GlobalMethodPool below... can you 
> confirm?)

Yes, that is correct. We could also use a single set instead of two as the 
instance and factory methods would have different decls anyway.

> Assuming you can pull the sets out to represent the GlobalMethodPool as a 
> whole, then I suggest creating a data structure for GlobalMethodPool that 
> encapsulates the DenseMap and the two sets

I'll go with this approach with the single set, starting with a data structure 
refactor diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109874: [OpenCL] Defines helper function for OpenCL default address space

2021-09-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 372937.
Topotuna edited the summary of this revision.
Topotuna added reviewers: olestrohm, Anastasia.
Topotuna added a comment.

Code refactored inside `clang/lib/AST/Expr.cpp`. Commit message added.


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

https://reviews.llvm.org/D109874

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, 
LangAS::opencl_generic);
+  if (S.getLangOpts().OpenCL && !ArgType.hasAddressSpace())
+ArgType = S.Context.getAddrSpaceQualType(
+ArgType, S.Context.getDefaultOpenCLAddrSpace());
   ArgType = S.Context.getLValueReferenceType(ArgType);
 }
   } else {
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1430,7 +1430,7 @@
 
 LangAS Sema::getDefaultCXXMethodAddrSpace() const {
   if (getLangOpts().OpenCL)
-return LangAS::opencl_generic;
+return getASTContext().getDefaultOpenCLAddrSpace();
   return LangAS::Default;
 }
 
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3779,11 +3779,7 @@
 // has non-default address space it is not treated as nullptr.
 // (__generic void*)0 in OpenCL 2.0 should not be treated as nullptr
 // since it cannot be assigned to a pointer to constant address space.
-if ((Ctx.getLangOpts().OpenCLVersion >= 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_generic) ||
-(Ctx.getLangOpts().OpenCL &&
- Ctx.getLangOpts().OpenCLVersion < 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_private))
+if (Pointee.getAddressSpace() == Ctx.getDefaultOpenCLAddrSpace())
   Qs.removeAddressSpace();
 
 if (Pointee->isVoidType() && Qs.empty() && // to void*
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -1362,6 +1362,12 @@
   /// Get address space for OpenCL type.
   LangAS getOpenCLTypeAddrSpace(const Type *T) const;
 
+  /// Returns default address space based on OpenCL version and enabled 
features
+  inline LangAS getDefaultOpenCLAddrSpace() {
+return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
+  : LangAS::opencl_private;
+  }
+
   void setcudaConfigureCallDecl(FunctionDecl *FD) {
 cudaConfigureCallDecl = FD;
   }


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, 

[PATCH] D109841: Fix vtbl field addr space

2021-09-16 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabe8b354e37d: Fix vtbl field addr space (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109841

Files:
  clang/lib/CodeGen/CGClass.cpp


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2502,6 +2502,8 @@
 
   // Apply the offsets.
   Address VTableField = LoadCXXThisAddress();
+  unsigned ThisAddrSpace =
+  VTableField.getPointer()->getType()->getPointerAddressSpace();
 
   if (!NonVirtualOffset.isZero() || VirtualOffset)
 VTableField = ApplyNonVirtualAndVirtualOffset(
@@ -2516,12 +2518,11 @@
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
   ->getPointerTo(ProgAS)
   ->getPointerTo(GlobalsAS);
-  // vtable field is is derived from `this` pointer, therefore it should be in
-  // default address space.
-  VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableField, VTablePtrTy->getPointerTo());
-  VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableAddressPoint, VTablePtrTy);
+  // vtable field is is derived from `this` pointer, therefore they should be 
in
+  // the same addr space. Note that this might not be LLVM address space 0.
+  VTableField = Builder.CreateBitCast(VTableField,
+  
VTablePtrTy->getPointerTo(ThisAddrSpace));
+  VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, 
VTableField);
   TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2502,6 +2502,8 @@
 
   // Apply the offsets.
   Address VTableField = LoadCXXThisAddress();
+  unsigned ThisAddrSpace =
+  VTableField.getPointer()->getType()->getPointerAddressSpace();
 
   if (!NonVirtualOffset.isZero() || VirtualOffset)
 VTableField = ApplyNonVirtualAndVirtualOffset(
@@ -2516,12 +2518,11 @@
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
   ->getPointerTo(ProgAS)
   ->getPointerTo(GlobalsAS);
-  // vtable field is is derived from `this` pointer, therefore it should be in
-  // default address space.
-  VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableField, VTablePtrTy->getPointerTo());
-  VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableAddressPoint, VTablePtrTy);
+  // vtable field is is derived from `this` pointer, therefore they should be in
+  // the same addr space. Note that this might not be LLVM address space 0.
+  VTableField = Builder.CreateBitCast(VTableField,
+  VTablePtrTy->getPointerTo(ThisAddrSpace));
+  VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField);
   TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] abe8b35 - Fix vtbl field addr space

2021-09-16 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-09-16T10:57:31-04:00
New Revision: abe8b354e37d8d6a163a6402d8e68ddcfc462dfc

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

LOG: Fix vtbl field addr space

Storing the vtable field of an object should use the same address space as
the this pointer. Currently it is assumed to be addr space 0 but this may not
be true.

This assumption (added in 054cc3b1b469de4b0cb25d1dc3af43c679c5dc44) caused
issues for the out-of-tree CHERI targets.

Reviewed by: John McCall, Alexander Richardson

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

Added: 


Modified: 
clang/lib/CodeGen/CGClass.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 9895a23b7093..828dd7147da5 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2502,6 +2502,8 @@ void CodeGenFunction::InitializeVTablePointer(const VPtr 
) {
 
   // Apply the offsets.
   Address VTableField = LoadCXXThisAddress();
+  unsigned ThisAddrSpace =
+  VTableField.getPointer()->getType()->getPointerAddressSpace();
 
   if (!NonVirtualOffset.isZero() || VirtualOffset)
 VTableField = ApplyNonVirtualAndVirtualOffset(
@@ -2516,12 +2518,11 @@ void CodeGenFunction::InitializeVTablePointer(const 
VPtr ) {
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
   ->getPointerTo(ProgAS)
   ->getPointerTo(GlobalsAS);
-  // vtable field is is derived from `this` pointer, therefore it should be in
-  // default address space.
-  VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableField, VTablePtrTy->getPointerTo());
-  VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableAddressPoint, VTablePtrTy);
+  // vtable field is is derived from `this` pointer, therefore they should be 
in
+  // the same addr space. Note that this might not be LLVM address space 0.
+  VTableField = Builder.CreateBitCast(VTableField,
+  
VTablePtrTy->getPointerTo(ThisAddrSpace));
+  VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, 
VTableField);
   TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);



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


[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea79b77da3ee: [clangd] Dont work on diags if we are not 
going to emit (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109884

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -460,77 +460,6 @@
 Code.substr(FileRange.Begin - 1, FileRange.End - FileRange.Begin + 2));
 EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
   }
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";
-  TU.AdditionalFiles["c.h"] = "";
-  // Make sure replay logic works with patched preambles.
-  llvm::StringLiteral Baseline = R"cpp(
-#include "a.h"
-#include "c.h")cpp";
-  MockFS FS;
-  TU.Code = Baseline.str();
-  auto Inputs = TU.inputs(FS);
-  auto BaselinePreamble = TU.preamble();
-  ASSERT_TRUE(BaselinePreamble);
-
-  // First make sure we don't crash on various modifications to the preamble.
-  llvm::StringLiteral Cases[] = {
-  // clang-format off
-  // New include in middle.
-  R"cpp(
-#include "a.h"
-#include "b.h"
-#include "c.h")cpp",
-  // New include at top.
-  R"cpp(
-#include "b.h"
-#include "a.h"
-#include "c.h")cpp",
-  // New include at bottom.
-  R"cpp(
-#include "a.h"
-#include "c.h"
-#include "b.h")cpp",
-  // Same size with a missing include.
-  R"cpp(
-#include "a.h"
-#include "b.h")cpp",
-  // Smaller with no new includes.
-  R"cpp(
-#include "a.h")cpp",
-  // Smaller with a new includes.
-  R"cpp(
-#include "b.h")cpp",
-  // clang-format on
-  };
-  for (llvm::StringLiteral Case : Cases) {
-TU.Code = Case.str();
-
-IgnoreDiagnostics Diags;
-auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
-   std::move(CI), {}, BaselinePreamble);
-ASSERT_TRUE(PatchedAST);
-EXPECT_FALSE(PatchedAST->getDiagnostics());
-  }
-
-  // Then ensure correctness by making sure includes were seen only once.
-  // Note that we first see the includes from the patch, as preamble includes
-  // are replayed after exiting the built-in file.
-  Includes.clear();
-  TU.Code = R"cpp(
-#include "a.h"
-#include "b.h")cpp";
-  IgnoreDiagnostics Diags;
-  auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-  auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
- std::move(CI), {}, BaselinePreamble);
-  ASSERT_TRUE(PatchedAST);
-  EXPECT_FALSE(PatchedAST->getDiagnostics());
-  EXPECT_THAT(Includes,
-  ElementsAre(WithFileName(testPath("__preamble_patch__.h")),
-  WithFileName("b.h"), WithFileName("a.h")));
 }
 
 TEST(ParsedASTTest, PatchesAdditionalIncludes) {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -283,15 +283,21 @@
 
   llvm::Optional Patch;
   bool PreserveDiags = true;
+  // We might use an ignoring diagnostic consumer if they are going to be
+  // dropped later on to not pay for extra latency by processing them.
+  DiagnosticConsumer *DiagConsumer = 
+  IgnoreDiagnostics DropDiags;
   if (Preamble) {
 Patch = PreamblePatch::createFullPatch(Filename, Inputs, *Preamble);
 Patch->apply(*CI);
 PreserveDiags = Patch->preserveDiagnostics();
+if (!PreserveDiags)
+  DiagConsumer = 
   }
   auto Clang = prepareCompilerInstance(
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
-  ASTDiags);
+  *DiagConsumer);
   if (!Clang) {
 // The last diagnostic contains information about the reason of this
 // failure.
@@ -301,6 +307,10 @@
 : "unknown error");
 return None;
   }
+  if (!PreserveDiags) {
+// Skips some analysis.
+Clang->getDiagnosticOpts().IgnoreWarnings = true;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
@@ -329,7 +339,10 @@
   std::vector> CTChecks;
   ast_matchers::MatchFinder CTFinder;
   llvm::Optional CTContext;
-  {
+  llvm::Optional FixIncludes;
+  // No need to run clang-tidy or IncludeFixerif we are not going to surface
+  // diagnostics.
+  if (PreserveDiags) {
 trace::Span 

[clang-tools-extra] ea79b77 - [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-09-16T16:50:42+02:00
New Revision: ea79b77da3eeba926e16c3dd8a4f6626c139e185

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

LOG: [clangd] Dont work on diags if we are not going to emit

Don't install clang-tidy checks and IncludeFixer or process clang diags
when they're going to be dropped. Also disables analysis for some
warnings completely.

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

Added: 


Modified: 
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index d8351199d100f..9baa7000a18c1 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -283,15 +283,21 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs ,
 
   llvm::Optional Patch;
   bool PreserveDiags = true;
+  // We might use an ignoring diagnostic consumer if they are going to be
+  // dropped later on to not pay for extra latency by processing them.
+  DiagnosticConsumer *DiagConsumer = 
+  IgnoreDiagnostics DropDiags;
   if (Preamble) {
 Patch = PreamblePatch::createFullPatch(Filename, Inputs, *Preamble);
 Patch->apply(*CI);
 PreserveDiags = Patch->preserveDiagnostics();
+if (!PreserveDiags)
+  DiagConsumer = 
   }
   auto Clang = prepareCompilerInstance(
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
-  ASTDiags);
+  *DiagConsumer);
   if (!Clang) {
 // The last diagnostic contains information about the reason of this
 // failure.
@@ -301,6 +307,10 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs ,
 : "unknown error");
 return None;
   }
+  if (!PreserveDiags) {
+// Skips some analysis.
+Clang->getDiagnosticOpts().IgnoreWarnings = true;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
@@ -329,7 +339,10 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs ,
   std::vector> CTChecks;
   ast_matchers::MatchFinder CTFinder;
   llvm::Optional CTContext;
-  {
+  llvm::Optional FixIncludes;
+  // No need to run clang-tidy or IncludeFixerif we are not going to surface
+  // diagnostics.
+  if (PreserveDiags) {
 trace::Span Tracer("ClangTidyInit");
 tidy::ClangTidyOptions ClangTidyOpts =
 getTidyOptionsForFile(Inputs.ClangTidyProvider, Filename);
@@ -389,28 +402,28 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs ,
   }
   return DiagLevel;
 });
-  }
 
-  // Add IncludeFixer which can recover diagnostics caused by missing includes
-  // (e.g. incomplete type) and attach include insertion fixes to diagnostics.
-  llvm::Optional FixIncludes;
-  auto BuildDir = VFS->getCurrentWorkingDirectory();
-  if (Inputs.Index && !BuildDir.getError()) {
-auto Style = getFormatStyleForFile(Filename, Inputs.Contents, *Inputs.TFS);
-auto Inserter = std::make_shared(
-Filename, Inputs.Contents, Style, BuildDir.get(),
->getPreprocessor().getHeaderSearchInfo());
-if (Preamble) {
-  for (const auto  : Preamble->Includes.MainFileIncludes)
-Inserter->addExisting(Inc);
+// Add IncludeFixer which can recover diagnostics caused by missing 
includes
+// (e.g. incomplete type) and attach include insertion fixes to 
diagnostics.
+auto BuildDir = VFS->getCurrentWorkingDirectory();
+if (Inputs.Index && !BuildDir.getError()) {
+  auto Style =
+  getFormatStyleForFile(Filename, Inputs.Contents, *Inputs.TFS);
+  auto Inserter = std::make_shared(
+  Filename, Inputs.Contents, Style, BuildDir.get(),
+  >getPreprocessor().getHeaderSearchInfo());
+  if (Preamble) {
+for (const auto  : Preamble->Includes.MainFileIncludes)
+  Inserter->addExisting(Inc);
+  }
+  FixIncludes.emplace(Filename, Inserter, *Inputs.Index,
+  /*IndexRequestLimit=*/5);
+  ASTDiags.contributeFixes([](DiagnosticsEngine::Level 
DiagLevl,
+  const clang::Diagnostic ) {
+return FixIncludes->fix(DiagLevl, Info);
+  });
+  Clang->setExternalSemaSource(FixIncludes->unresolvedNameRecorder());
 }
-FixIncludes.emplace(Filename, Inserter, *Inputs.Index,
-/*IndexRequestLimit=*/5);
-ASTDiags.contributeFixes([](DiagnosticsEngine::Level DiagLevl,
-const clang::Diagnostic ) {
-  return FixIncludes->fix(DiagLevl, Info);
-});
-

[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-09-16 Thread DineshKumar Bhaskaran via Phabricator via cfe-commits
dbhaskaran created this revision.
dbhaskaran added reviewers: pdhaliwal, csigg, JonChesterfield.
Herald added subscribers: wenzhicui, wrengr, Chia-hungDuan, dcaballe, cota, 
teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, 
Joonsoo, kerbowa, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, guansong, t-tye, tpr, dstuttard, 
yaxunl, mgorny, nhaehnle, jvesely, kzhuravl.
dbhaskaran requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1, 
stephenneuendorffer, nicolasvasilache, wdng.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: herhut.
Herald added projects: clang, OpenMP, MLIR.

This avoids undefined behavior/issues resulting out of unconventional
or co-existing ROCm installations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109885

Files:
  clang/tools/amdgpu-arch/CMakeLists.txt
  mlir/lib/Dialect/GPU/CMakeLists.txt
  mlir/lib/ExecutionEngine/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt


Index: openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
===
--- openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -14,7 +14,7 @@
 

 
 # as of rocm-3.7, hsa is installed with cmake packages and kmt is found via hsa
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX})
 
 if(NOT LIBOMPTARGET_DEP_LIBELF_FOUND)
   libomptarget_say("Not building AMDGPU plugin: LIBELF not found")
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -142,7 +142,7 @@
   # Configure ROCm support.
   if (NOT DEFINED ROCM_PATH)
 if (NOT DEFINED ENV{ROCM_PATH})
-  set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to which ROCm has been 
installed")
+  message(SEND_ERROR "Building mlir with ROCm support requires a working 
ROCm")
 else()
   set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been 
installed")
 endif()
Index: mlir/lib/Dialect/GPU/CMakeLists.txt
===
--- mlir/lib/Dialect/GPU/CMakeLists.txt
+++ mlir/lib/Dialect/GPU/CMakeLists.txt
@@ -127,7 +127,7 @@
   # Configure ROCm support.
   if (NOT DEFINED ROCM_PATH)
 if (NOT DEFINED ENV{ROCM_PATH})
-  set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to which ROCm has been 
installed")
+  message(SEND_ERROR "Building mlir with ROCm support requires a working 
ROCm")
 else()
   set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been 
installed")
 endif()
Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -6,7 +6,7 @@
 # //
 # 
//===--===//
 
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX})
 if (NOT ${hsa-runtime64_FOUND})
   message(STATUS "Not building amdgpu-arch: hsa-runtime64 not found")
   return()


Index: openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
===
--- openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -14,7 +14,7 @@
 
 
 # as of rocm-3.7, hsa is installed with cmake packages and kmt is found via hsa
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX})
 
 if(NOT LIBOMPTARGET_DEP_LIBELF_FOUND)
   libomptarget_say("Not building AMDGPU plugin: LIBELF not found")
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -142,7 +142,7 @@
   # Configure ROCm support.
   if (NOT DEFINED ROCM_PATH)
 if (NOT DEFINED ENV{ROCM_PATH})
-  set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to which ROCm has been installed")
+  message(SEND_ERROR "Building mlir with ROCm support requires a working ROCm")
 else()
   set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
 endif()
Index: mlir/lib/Dialect/GPU/CMakeLists.txt
===
--- mlir/lib/Dialect/GPU/CMakeLists.txt
+++ 

[PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

@ldionne can you please please merge


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

https://reviews.llvm.org/D107717

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I think you may try fixing the following line:

https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp#L97


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative

2021-09-16 Thread Philippe Antoine via Phabricator via cfe-commits
catenacyber added a comment.

Should I propose a simple patch to bump INSTR_PROF_RAW_VERSION ?
Or will it be part of something bigger, taken care of by someone else ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 372947.
kadircet added a comment.

- Revert revert of IncludeFixer changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109884

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -460,77 +460,6 @@
 Code.substr(FileRange.Begin - 1, FileRange.End - FileRange.Begin + 2));
 EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
   }
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";
-  TU.AdditionalFiles["c.h"] = "";
-  // Make sure replay logic works with patched preambles.
-  llvm::StringLiteral Baseline = R"cpp(
-#include "a.h"
-#include "c.h")cpp";
-  MockFS FS;
-  TU.Code = Baseline.str();
-  auto Inputs = TU.inputs(FS);
-  auto BaselinePreamble = TU.preamble();
-  ASSERT_TRUE(BaselinePreamble);
-
-  // First make sure we don't crash on various modifications to the preamble.
-  llvm::StringLiteral Cases[] = {
-  // clang-format off
-  // New include in middle.
-  R"cpp(
-#include "a.h"
-#include "b.h"
-#include "c.h")cpp",
-  // New include at top.
-  R"cpp(
-#include "b.h"
-#include "a.h"
-#include "c.h")cpp",
-  // New include at bottom.
-  R"cpp(
-#include "a.h"
-#include "c.h"
-#include "b.h")cpp",
-  // Same size with a missing include.
-  R"cpp(
-#include "a.h"
-#include "b.h")cpp",
-  // Smaller with no new includes.
-  R"cpp(
-#include "a.h")cpp",
-  // Smaller with a new includes.
-  R"cpp(
-#include "b.h")cpp",
-  // clang-format on
-  };
-  for (llvm::StringLiteral Case : Cases) {
-TU.Code = Case.str();
-
-IgnoreDiagnostics Diags;
-auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
-   std::move(CI), {}, BaselinePreamble);
-ASSERT_TRUE(PatchedAST);
-EXPECT_FALSE(PatchedAST->getDiagnostics());
-  }
-
-  // Then ensure correctness by making sure includes were seen only once.
-  // Note that we first see the includes from the patch, as preamble includes
-  // are replayed after exiting the built-in file.
-  Includes.clear();
-  TU.Code = R"cpp(
-#include "a.h"
-#include "b.h")cpp";
-  IgnoreDiagnostics Diags;
-  auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-  auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
- std::move(CI), {}, BaselinePreamble);
-  ASSERT_TRUE(PatchedAST);
-  EXPECT_FALSE(PatchedAST->getDiagnostics());
-  EXPECT_THAT(Includes,
-  ElementsAre(WithFileName(testPath("__preamble_patch__.h")),
-  WithFileName("b.h"), WithFileName("a.h")));
 }
 
 TEST(ParsedASTTest, PatchesAdditionalIncludes) {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -283,15 +283,21 @@
 
   llvm::Optional Patch;
   bool PreserveDiags = true;
+  // We might use an ignoring diagnostic consumer if they are going to be
+  // dropped later on to not pay for extra latency by processing them.
+  DiagnosticConsumer *DiagConsumer = 
+  IgnoreDiagnostics DropDiags;
   if (Preamble) {
 Patch = PreamblePatch::createFullPatch(Filename, Inputs, *Preamble);
 Patch->apply(*CI);
 PreserveDiags = Patch->preserveDiagnostics();
+if (!PreserveDiags)
+  DiagConsumer = 
   }
   auto Clang = prepareCompilerInstance(
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
-  ASTDiags);
+  *DiagConsumer);
   if (!Clang) {
 // The last diagnostic contains information about the reason of this
 // failure.
@@ -301,6 +307,10 @@
 : "unknown error");
 return None;
   }
+  if (!PreserveDiags) {
+// Skips some analysis.
+Clang->getDiagnosticOpts().IgnoreWarnings = true;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
@@ -329,7 +339,10 @@
   std::vector> CTChecks;
   ast_matchers::MatchFinder CTFinder;
   llvm::Optional CTContext;
-  {
+  llvm::Optional FixIncludes;
+  // No need to run clang-tidy or IncludeFixerif we are not going to surface
+  // diagnostics.
+  if (PreserveDiags) {
 trace::Span Tracer("ClangTidyInit");
 tidy::ClangTidyOptions ClangTidyOpts =
 getTidyOptionsForFile(Inputs.ClangTidyProvider, Filename);
@@ 

[PATCH] D109060: [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C support

2021-09-16 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 372946.
Jake-Egan added a comment.

Revert last ExtDebugInfo.cpp change because 
https://reviews.llvm.org/rG45a738363ee39754a0e93d9f779bda2cad83fa18 has been 
committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109060

Files:
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Import/forward-declared-objc-class/test.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Import/objc-autoreleasepool/test.m
  clang/test/Import/objc-definitions-in-expression/test.m
  clang/test/Import/objc-method/test.m
  clang/test/Import/objc-param-decl/test.m
  clang/test/Import/objc-try-catch/test.m
  clang/test/Modules/DebugInfoNamespace.cpp
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ExtDebugInfo.m
  clang/test/Modules/ModuleModuleDebugInfo.cpp
  clang/test/Modules/autolink.m
  clang/test/Modules/autolinkTBD.m
  clang/test/Modules/cxx-irgen.cpp
  clang/test/Modules/debug-info-moduleimport.m
  clang/test/Modules/direct-module-import.m
  clang/test/Modules/merge-record-definition-nonmodular.m
  clang/test/Modules/merge-record-definition-visibility.m
  clang/test/Modules/merge-record-definition.m
  clang/test/Modules/module_file_info.m
  clang/test/Modules/objc-initializer.m
  clang/test/Modules/pch-used.m
  clang/test/Modules/use-exportas-for-link.m
  clang/test/PCH/irgen-rdar13114142.mm
  clang/test/PCH/objc_container.m
  clang/test/PCH/objc_literals.m
  clang/test/PCH/objc_literals.mm
  clang/test/PCH/objcxx-ivar-class.mm

Index: clang/test/PCH/objcxx-ivar-class.mm
===
--- clang/test/PCH/objcxx-ivar-class.mm
+++ clang/test/PCH/objcxx-ivar-class.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s
 
Index: clang/test/PCH/objc_literals.mm
===
--- clang/test/PCH/objc_literals.mm
+++ clang/test/PCH/objc_literals.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_literals.m
===
--- clang/test/PCH/objc_literals.m
+++ clang/test/PCH/objc_literals.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -verify %s
 // RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_container.m
===
--- clang/test/PCH/objc_container.m
+++ clang/test/PCH/objc_container.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objc_container.h -fsyntax-only -verify %s
 
Index: clang/test/PCH/irgen-rdar13114142.mm
===
--- clang/test/PCH/irgen-rdar13114142.mm
+++ clang/test/PCH/irgen-rdar13114142.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-pch -o %t.pch
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -include-pch %t.pch -o - | FileCheck %s
 
Index: clang/test/Modules/use-exportas-for-link.m
===
--- clang/test/Modules/use-exportas-for-link.m
+++ clang/test/Modules/use-exportas-for-link.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -DA -fmodules -fimplicit-module-maps -F %S/Inputs/exportas-link %s | FileCheck --check-prefix=CHECK_A %s
 // CHECK_A: !llvm.linker.options = !{![[MODULE:[0-9]+]]}
Index: clang/test/Modules/pch-used.m
===
--- clang/test/Modules/pch-used.m
+++ clang/test/Modules/pch-used.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h -o %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include
Index: clang/test/Modules/objc-initializer.m
===
--- clang/test/Modules/objc-initializer.m
+++ clang/test/Modules/objc-initializer.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 

[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 372943.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Get rid of static_casts
- Update comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109884

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -460,77 +460,6 @@
 Code.substr(FileRange.Begin - 1, FileRange.End - FileRange.Begin + 2));
 EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
   }
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";
-  TU.AdditionalFiles["c.h"] = "";
-  // Make sure replay logic works with patched preambles.
-  llvm::StringLiteral Baseline = R"cpp(
-#include "a.h"
-#include "c.h")cpp";
-  MockFS FS;
-  TU.Code = Baseline.str();
-  auto Inputs = TU.inputs(FS);
-  auto BaselinePreamble = TU.preamble();
-  ASSERT_TRUE(BaselinePreamble);
-
-  // First make sure we don't crash on various modifications to the preamble.
-  llvm::StringLiteral Cases[] = {
-  // clang-format off
-  // New include in middle.
-  R"cpp(
-#include "a.h"
-#include "b.h"
-#include "c.h")cpp",
-  // New include at top.
-  R"cpp(
-#include "b.h"
-#include "a.h"
-#include "c.h")cpp",
-  // New include at bottom.
-  R"cpp(
-#include "a.h"
-#include "c.h"
-#include "b.h")cpp",
-  // Same size with a missing include.
-  R"cpp(
-#include "a.h"
-#include "b.h")cpp",
-  // Smaller with no new includes.
-  R"cpp(
-#include "a.h")cpp",
-  // Smaller with a new includes.
-  R"cpp(
-#include "b.h")cpp",
-  // clang-format on
-  };
-  for (llvm::StringLiteral Case : Cases) {
-TU.Code = Case.str();
-
-IgnoreDiagnostics Diags;
-auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
-   std::move(CI), {}, BaselinePreamble);
-ASSERT_TRUE(PatchedAST);
-EXPECT_FALSE(PatchedAST->getDiagnostics());
-  }
-
-  // Then ensure correctness by making sure includes were seen only once.
-  // Note that we first see the includes from the patch, as preamble includes
-  // are replayed after exiting the built-in file.
-  Includes.clear();
-  TU.Code = R"cpp(
-#include "a.h"
-#include "b.h")cpp";
-  IgnoreDiagnostics Diags;
-  auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-  auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
- std::move(CI), {}, BaselinePreamble);
-  ASSERT_TRUE(PatchedAST);
-  EXPECT_FALSE(PatchedAST->getDiagnostics());
-  EXPECT_THAT(Includes,
-  ElementsAre(WithFileName(testPath("__preamble_patch__.h")),
-  WithFileName("b.h"), WithFileName("a.h")));
 }
 
 TEST(ParsedASTTest, PatchesAdditionalIncludes) {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -283,15 +283,21 @@
 
   llvm::Optional Patch;
   bool PreserveDiags = true;
+  // We might use an ignoring diagnostic consumer if they are going to be
+  // dropped later on to not pay for extra latency by processing them.
+  DiagnosticConsumer *DiagConsumer = 
+  IgnoreDiagnostics DropDiags;
   if (Preamble) {
 Patch = PreamblePatch::createFullPatch(Filename, Inputs, *Preamble);
 Patch->apply(*CI);
 PreserveDiags = Patch->preserveDiagnostics();
+if (!PreserveDiags)
+  DiagConsumer = 
   }
   auto Clang = prepareCompilerInstance(
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
-  ASTDiags);
+  *DiagConsumer);
   if (!Clang) {
 // The last diagnostic contains information about the reason of this
 // failure.
@@ -301,6 +307,10 @@
 : "unknown error");
 return None;
   }
+  if (!PreserveDiags) {
+// Skips some analysis.
+Clang->getDiagnosticOpts().IgnoreWarnings = true;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
@@ -329,7 +339,8 @@
   std::vector> CTChecks;
   ast_matchers::MatchFinder CTFinder;
   llvm::Optional CTContext;
-  {
+  // No need to run clang-tidy if we are not going to surface diagnostics.
+  if (PreserveDiags) {
 trace::Span Tracer("ClangTidyInit");
 tidy::ClangTidyOptions ClangTidyOpts =
 getTidyOptionsForFile(Inputs.ClangTidyProvider, Filename);

[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp:464
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";

kadircet wrote:
> sammccall wrote:
> > Why are these tests deleted?
> they rely on the fact that clang-tidy checkers PPcallbacks are run with 
> patched asts, but it is no longer the case, hence it becomes impossible to 
> satisfy them.
> 
> currently we never replay includes with patched preambles, as ReplayPreamble 
> bails out when there are no existing PPCallbacks and that's always the case. 
> we can still try and test it via complicated means like enabling 
> ClangdFeatures to register PPCallbacks, but it will be testing a feature that 
> doesn't exist in practice + would be quite some work for just testing, so I'd 
> rather leave it as-is (probably by adding a comment around 
> ReplayPreamble::attach saying that we should test this once there are 
> non-clang-tidy users).
Oops, I didn't scroll up fast enough (reviewing on phone lol). SGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109884

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


[PATCH] D109880: [clangd] PreamblePatch should be no-op if includes arent patched

2021-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Preamble.cpp:462
   BaselineScan->TextualDirectives != ModifiedScan->TextualDirectives;
-  if (!IncludesChanged && !DirectivesChanged)
+  if ((PatchType != PatchType::All || !IncludesChanged) && !DirectivesChanged)
 return PreamblePatch::unmodified(Baseline);

I think `=MacroDirectives` would be significantly clearer than `!=All`, and a 
little less fragile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109880

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


[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp:464
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";

sammccall wrote:
> Why are these tests deleted?
they rely on the fact that clang-tidy checkers PPcallbacks are run with patched 
asts, but it is no longer the case, hence it becomes impossible to satisfy them.

currently we never replay includes with patched preambles, as ReplayPreamble 
bails out when there are no existing PPCallbacks and that's always the case. we 
can still try and test it via complicated means like enabling ClangdFeatures to 
register PPCallbacks, but it will be testing a feature that doesn't exist in 
practice + would be quite some work for just testing, so I'd rather leave it 
as-is (probably by adding a comment around ReplayPreamble::attach saying that 
we should test this once there are non-clang-tidy users).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109884

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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-09-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 372939.
kito-cheng added a comment.

Changes:

- Rebase to `main`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-arch.c
  clang/test/Driver/riscv-features.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/attribute-with-insts.s
  llvm/test/MC/RISCV/invalid-attribute.s

Index: llvm/test/MC/RISCV/invalid-attribute.s
===
--- llvm/test/MC/RISCV/invalid-attribute.s
+++ llvm/test/MC/RISCV/invalid-attribute.s
@@ -7,10 +7,10 @@
 # RUN: not llvm-mc %s -triple=riscv64 -filetype=asm 2>&1 | FileCheck %s
 
 .attribute arch, "foo"
-# CHECK: [[@LINE-1]]:18: error: bad arch string foo
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'foo', string must begin with rv32{i,e,g} or rv64{i,g}
 
 .attribute arch, "rv32i2p0_y2p0"
-# CHECK: [[@LINE-1]]:18: error: bad arch string y2p0
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'rv32i2p0_y2p0', invalid standard user-level extension 'y'
 
 .attribute stack_align, "16"
 # CHECK: [[@LINE-1]]:25: error: expected numeric constant
Index: llvm/test/MC/RISCV/attribute-with-insts.s
===
--- llvm/test/MC/RISCV/attribute-with-insts.s
+++ llvm/test/MC/RISCV/attribute-with-insts.s
@@ -10,7 +10,7 @@
 # RUN:   | llvm-objdump --triple=riscv64 -d -M no-aliases - \
 # RUN:   | FileCheck -check-prefix=CHECK-INST %s
 
-.attribute arch, "rv64i2p0_m2p0_a2p0_d2p0_c2p0"
+.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 # CHECK-INST: lr.w t0, (t1)
 lr.w t0, (t1)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -9,9 +9,6 @@
 .attribute arch, "rv32i2"
 # CHECK: attribute  5, "rv32i2p0"
 
-.attribute arch, "rv32i2p"
-# CHECK: attribute  5, "rv32i2p0"
-
 .attribute arch, "rv32i2p0"
 # CHECK: attribute  5, "rv32i2p0"
 
@@ -33,14 +30,14 @@
 .attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
-.attribute arch, "rv32ima2p_fdc"
+.attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 .attribute arch, "rv32ib"
 # CHECK: attribute  5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
 
 .attribute arch, "rv32iv"
-# CHECK: attribute  5, "rv32i2p0_v0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
 
 .attribute arch, "rv32izba"
 # CHECK: attribute  5, "rv32i2p0_zba0p93"
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -11,9 +11,11 @@
 //===--===//
 
 #include "RISCVTargetStreamer.h"
+#include "RISCVBaseInfo.h"
 #include "RISCVMCTargetDesc.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/RISCVAttributes.h"
+#include "llvm/Support/RISCVISAInfo.h"
 
 using namespace llvm;
 
@@ -43,57 +45,19 @@
   else
 emitAttribute(RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_16);
 
-  std::string Arch = "rv32";
-  if (STI.hasFeature(RISCV::Feature64Bit))
-Arch = "rv64";
-  if (STI.hasFeature(RISCV::FeatureRV32E))
-Arch += "e1p9";
-  else
-Arch += "i2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtM))
-Arch += "_m2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtA))
-Arch += "_a2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtF))
-Arch += "_f2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtD))
-Arch += "_d2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtC))
-Arch += "_c2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtB))
-Arch += "_b0p93";
-  if (STI.hasFeature(RISCV::FeatureStdExtV))
-Arch += "_v0p10";
-  if (STI.hasFeature(RISCV::FeatureStdExtZfh))
-Arch += "_zfh0p1";
-  if (STI.hasFeature(RISCV::FeatureStdExtZba))
-Arch += "_zba0p93";
-  if (STI.hasFeature(RISCV::FeatureStdExtZbb))
-Arch += "_zbb0p93";
-  if (STI.hasFeature(RISCV::FeatureStdExtZbc))
-Arch += "_zbc0p93";
-  if (STI.hasFeature(RISCV::FeatureStdExtZbe))
-Arch 

[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Great!




Comment at: clang-tools-extra/clangd/ParsedAST.cpp:295
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
-  ASTDiags);
+  PreserveDiags ? static_cast(ASTDiags)
+: static_cast(DropDiags));

These explicit upcasts seem ugly enough that I might extract a pointer var to 
avoid them...



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:338
   llvm::Optional CTContext;
-  {
+  // No need to initalize a clang-tidy context if we are not going to surface
+  // diagnostics.

s/initialize a clang-tidy context/run clang-tidy/



Comment at: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp:464
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";

Why are these tests deleted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109884

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


[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 372938.
kadircet added a comment.

- Disable IncludeFixer too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109884

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -460,77 +460,6 @@
 Code.substr(FileRange.Begin - 1, FileRange.End - FileRange.Begin + 2));
 EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
   }
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";
-  TU.AdditionalFiles["c.h"] = "";
-  // Make sure replay logic works with patched preambles.
-  llvm::StringLiteral Baseline = R"cpp(
-#include "a.h"
-#include "c.h")cpp";
-  MockFS FS;
-  TU.Code = Baseline.str();
-  auto Inputs = TU.inputs(FS);
-  auto BaselinePreamble = TU.preamble();
-  ASSERT_TRUE(BaselinePreamble);
-
-  // First make sure we don't crash on various modifications to the preamble.
-  llvm::StringLiteral Cases[] = {
-  // clang-format off
-  // New include in middle.
-  R"cpp(
-#include "a.h"
-#include "b.h"
-#include "c.h")cpp",
-  // New include at top.
-  R"cpp(
-#include "b.h"
-#include "a.h"
-#include "c.h")cpp",
-  // New include at bottom.
-  R"cpp(
-#include "a.h"
-#include "c.h"
-#include "b.h")cpp",
-  // Same size with a missing include.
-  R"cpp(
-#include "a.h"
-#include "b.h")cpp",
-  // Smaller with no new includes.
-  R"cpp(
-#include "a.h")cpp",
-  // Smaller with a new includes.
-  R"cpp(
-#include "b.h")cpp",
-  // clang-format on
-  };
-  for (llvm::StringLiteral Case : Cases) {
-TU.Code = Case.str();
-
-IgnoreDiagnostics Diags;
-auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
-   std::move(CI), {}, BaselinePreamble);
-ASSERT_TRUE(PatchedAST);
-EXPECT_FALSE(PatchedAST->getDiagnostics());
-  }
-
-  // Then ensure correctness by making sure includes were seen only once.
-  // Note that we first see the includes from the patch, as preamble includes
-  // are replayed after exiting the built-in file.
-  Includes.clear();
-  TU.Code = R"cpp(
-#include "a.h"
-#include "b.h")cpp";
-  IgnoreDiagnostics Diags;
-  auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-  auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
- std::move(CI), {}, BaselinePreamble);
-  ASSERT_TRUE(PatchedAST);
-  EXPECT_FALSE(PatchedAST->getDiagnostics());
-  EXPECT_THAT(Includes,
-  ElementsAre(WithFileName(testPath("__preamble_patch__.h")),
-  WithFileName("b.h"), WithFileName("a.h")));
 }
 
 TEST(ParsedASTTest, PatchesAdditionalIncludes) {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -288,10 +288,12 @@
 Patch->apply(*CI);
 PreserveDiags = Patch->preserveDiagnostics();
   }
+  IgnoreDiagnostics DropDiags;
   auto Clang = prepareCompilerInstance(
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
-  ASTDiags);
+  PreserveDiags ? static_cast(ASTDiags)
+: static_cast(DropDiags));
   if (!Clang) {
 // The last diagnostic contains information about the reason of this
 // failure.
@@ -301,6 +303,10 @@
 : "unknown error");
 return None;
   }
+  if (!PreserveDiags) {
+// Skips some analysis.
+Clang->getDiagnosticOpts().IgnoreWarnings = true;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
@@ -329,7 +335,10 @@
   std::vector> CTChecks;
   ast_matchers::MatchFinder CTFinder;
   llvm::Optional CTContext;
-  {
+  llvm::Optional FixIncludes;
+  // No need to initalize a clang-tidy context and include fixerif we are not
+  // going to surface diagnostics.
+  if (PreserveDiags) {
 trace::Span Tracer("ClangTidyInit");
 tidy::ClangTidyOptions ClangTidyOpts =
 getTidyOptionsForFile(Inputs.ClangTidyProvider, Filename);
@@ -389,28 +398,28 @@
   }
   return DiagLevel;
 });
-  }
 
-  // Add IncludeFixer which can recover diagnostics caused by missing includes
-  // (e.g. incomplete type) and attach include insertion fixes to diagnostics.
-  llvm::Optional FixIncludes;
-  auto BuildDir = 

[PATCH] D109854: Support Unicode 14 identifiers

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

LGTM with a minor comment on comments that I'll handle when I land this.




Comment at: clang/test/Lexer/unicode.c:37-41
+extern int  \u1B4C; //BALINESE LETTER ARCHAIC JNYA - Added in Unicode 14
+extern int  \U00016AA2; //TANGSA LETTER GA - Added in Unicode 14
+// This character doesn't have the XID_Start property
+extern int  \U00016AC0; //TANGSA DIGIT ZERO  // expected-error {{expected 
unqualified-id}}
+extern int _\U00016AC0; //TANGSA DIGIT ZERO

When I land this, I'm going to add extra whitespace between the comment marker 
and the comment content.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109854

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


[PATCH] D109884: [clangd] Dont work on diags if we are not going to emit

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Doesn't install clang-tidy checks & process clang diags when they're
going to be dropped. Also disables analysis for some warnings completely.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109884

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -460,77 +460,6 @@
 Code.substr(FileRange.Begin - 1, FileRange.End - FileRange.Begin + 2));
 EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
   }
-
-  TU.AdditionalFiles["a.h"] = "";
-  TU.AdditionalFiles["b.h"] = "";
-  TU.AdditionalFiles["c.h"] = "";
-  // Make sure replay logic works with patched preambles.
-  llvm::StringLiteral Baseline = R"cpp(
-#include "a.h"
-#include "c.h")cpp";
-  MockFS FS;
-  TU.Code = Baseline.str();
-  auto Inputs = TU.inputs(FS);
-  auto BaselinePreamble = TU.preamble();
-  ASSERT_TRUE(BaselinePreamble);
-
-  // First make sure we don't crash on various modifications to the preamble.
-  llvm::StringLiteral Cases[] = {
-  // clang-format off
-  // New include in middle.
-  R"cpp(
-#include "a.h"
-#include "b.h"
-#include "c.h")cpp",
-  // New include at top.
-  R"cpp(
-#include "b.h"
-#include "a.h"
-#include "c.h")cpp",
-  // New include at bottom.
-  R"cpp(
-#include "a.h"
-#include "c.h"
-#include "b.h")cpp",
-  // Same size with a missing include.
-  R"cpp(
-#include "a.h"
-#include "b.h")cpp",
-  // Smaller with no new includes.
-  R"cpp(
-#include "a.h")cpp",
-  // Smaller with a new includes.
-  R"cpp(
-#include "b.h")cpp",
-  // clang-format on
-  };
-  for (llvm::StringLiteral Case : Cases) {
-TU.Code = Case.str();
-
-IgnoreDiagnostics Diags;
-auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
-   std::move(CI), {}, BaselinePreamble);
-ASSERT_TRUE(PatchedAST);
-EXPECT_FALSE(PatchedAST->getDiagnostics());
-  }
-
-  // Then ensure correctness by making sure includes were seen only once.
-  // Note that we first see the includes from the patch, as preamble includes
-  // are replayed after exiting the built-in file.
-  Includes.clear();
-  TU.Code = R"cpp(
-#include "a.h"
-#include "b.h")cpp";
-  IgnoreDiagnostics Diags;
-  auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
-  auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
- std::move(CI), {}, BaselinePreamble);
-  ASSERT_TRUE(PatchedAST);
-  EXPECT_FALSE(PatchedAST->getDiagnostics());
-  EXPECT_THAT(Includes,
-  ElementsAre(WithFileName(testPath("__preamble_patch__.h")),
-  WithFileName("b.h"), WithFileName("a.h")));
 }
 
 TEST(ParsedASTTest, PatchesAdditionalIncludes) {
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -288,10 +288,12 @@
 Patch->apply(*CI);
 PreserveDiags = Patch->preserveDiagnostics();
   }
+  IgnoreDiagnostics DropDiags;
   auto Clang = prepareCompilerInstance(
   std::move(CI), PreamblePCH,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
-  ASTDiags);
+  PreserveDiags ? static_cast(ASTDiags)
+: static_cast(DropDiags));
   if (!Clang) {
 // The last diagnostic contains information about the reason of this
 // failure.
@@ -301,6 +303,10 @@
 : "unknown error");
 return None;
   }
+  if (!PreserveDiags) {
+// Skips some analysis.
+Clang->getDiagnosticOpts().IgnoreWarnings = true;
+  }
 
   auto Action = std::make_unique();
   const FrontendInputFile  = Clang->getFrontendOpts().Inputs[0];
@@ -329,7 +335,9 @@
   std::vector> CTChecks;
   ast_matchers::MatchFinder CTFinder;
   llvm::Optional CTContext;
-  {
+  // No need to initalize a clang-tidy context if we are not going to surface
+  // diagnostics.
+  if (PreserveDiags) {
 trace::Span Tracer("ClangTidyInit");
 tidy::ClangTidyOptions ClangTidyOpts =
 getTidyOptionsForFile(Inputs.ClangTidyProvider, Filename);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-09-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Seems like conflict with D108187 , will 
update after testing :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2021-09-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Sarif.h:74
+
+  llvm::Optional Index;
+  StringRef URI;

You have a `using namespace llvm;` at the top of the file, so all these 
`llvm::` nested name specifiers can be removed.



Comment at: clang/include/clang/Basic/Sarif.h:77
+
+  SarifArtifactLocation(const StringRef ) : Index(), URI(URI) {}
+

`StringRef` is a non-owning reference object anyway, so there's really no gain 
from passing a const ref to it -- we typically pass it by value. Same 
suggestion applies elsewhere in the patch.

Also, no need to explicitly init things with default constructors that will be 
run, like `Index`.



Comment at: clang/include/clang/Basic/Sarif.h:85
+  SarifArtifactLocation (uint32_t Idx) {
+this->Index = Idx;
+return *this;

Local style is to not use `this->` unless required, so I'd recommend removing 
all of the uses (and potentially renaming some parameters so there's not a 
shadowing issue).



Comment at: clang/include/clang/Basic/Sarif.h:95
+//
+/// Since every in clang artifact MUST have a location (there being no nested
+/// artifacts), the creation method \ref SarifArtifact::create requires a

How do we expect to handle artifact locations that don't correspond directly to 
a file? For example, the user can specify macros on the command line and those 
macros could have a diagnostic result associated with them. Can we handle that 
sort of scenario?



Comment at: clang/include/clang/Basic/Sarif.h:97
+/// artifacts), the creation method \ref SarifArtifact::create requires a
+/// \ref SarifArtifactLocation object
+///





Comment at: clang/include/clang/Basic/Sarif.h:109
+  SarifArtifactLocation Location;
+  SmallVector Roles;
+

What size would you like this `SmallVector` to have?



Comment at: clang/include/clang/Basic/Sarif.h:112
+  SarifArtifact(const SarifArtifactLocation )
+  : Offset(), Length(), MimeType(), Location(Loc), Roles() {}
+





Comment at: clang/include/clang/Basic/Sarif.h:129
+
+  SarifArtifact (const std::initializer_list ) {
+this->Roles.assign(Roles);

This is another lightweight nonowning wrapper type that we don't usually pass 
as a const ref.



Comment at: clang/include/clang/Basic/Sarif.h:134
+
+  SarifArtifact (const StringRef ) {
+this->MimeType = MimeType;





Comment at: clang/include/clang/Basic/Sarif.h:250
+
+  SarifResult() = default;
+

A default constructed `SarifResult` will have an uninitialized `RuleIdx` -- are 
you okay with that?



Comment at: clang/include/clang/Basic/Sarif.h:270-274
+  SarifResult (const ArrayRef ) {
+this->Locations = DiagLocs;
+return *this;
+  }
+  SarifResult (const ArrayRef ) {

Also a nonowning reference type that's meant to be passed by value.



Comment at: clang/include/clang/Basic/Sarif.h:285
+///must ensure that \ref SarifDocumentWriter::createRun is is called before
+///anyother methods.
+/// 2. If SarifDocumentWriter::endRun is called, callers MUST call





Comment at: clang/include/clang/Basic/Sarif.h:297-298
+  /// \internal
+  /// Return a pointer to the current tool. If no run exists, this will
+  /// crash.
+  json::Object *getCurrentTool();





Comment at: clang/include/clang/Basic/Sarif.h:302
+  /// \internal
+  /// Checks if there is a run associated with this document
+  ///





Comment at: clang/include/clang/Basic/Sarif.h:309
+  /// Reset portions of the internal state so that the document is ready to
+  /// recieve data for a new run
+  void reset();





Comment at: clang/include/clang/Basic/Sarif.h:315-316
+  ///
+  /// \note If a run does not exist in the SARIF document, calling this will
+  /// trigger undefined behaviour
+  json::Object *currentRun();





Comment at: clang/include/clang/Basic/Sarif.h:322-323
+  ///
+  /// \note If a run does not exist in the SARIF document, calling this will
+  /// trigger undefined behaviour
+  json::Object createCodeFlow(const ArrayRef );





Comment at: clang/include/clang/Basic/Sarif.h:324
+  /// trigger undefined behaviour
+  json::Object createCodeFlow(const ArrayRef );
+





Comment at: clang/include/clang/Basic/Sarif.h:326
+
+  /// Add the given threadflows to the ones this SARIF document knows about
+  json::Array createThreadFlows(const ArrayRef );





Comment at: clang/include/clang/Basic/Sarif.h:327
+  /// Add the given threadflows to the 

[PATCH] D109541: Increase expected line number for ExtDebugInfo.cpp

2021-09-16 Thread Jake Egan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45a738363ee3: Increase expected line number for 
ExtDebugInfo.cpp (authored by Jake-Egan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109541

Files:
  clang/test/Modules/ExtDebugInfo.cpp


Index: clang/test/Modules/ExtDebugInfo.cpp
===
--- clang/test/Modules/ExtDebugInfo.cpp
+++ clang/test/Modules/ExtDebugInfo.cpp
@@ -24,6 +24,8 @@
 @import DebugCXX;
 #endif
 
+// Set the line number so that the LIT check expected line number doesn't have 
to be updated after adding/removing a line in the RUN section.
+#line 50
 using DebugCXX::Struct;
 
 Struct s;
@@ -204,8 +206,7 @@
 // CHECK: ![[GLOBAL_ANON]] = !DICompositeType(tag: DW_TAG_structure_type,
 // CHECK-SAME:  name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl)
 
-
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
!{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 27)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
!{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 50)
 
 // CHECK: !DICompileUnit(
 // CHECK-SAME:   splitDebugFilename:


Index: clang/test/Modules/ExtDebugInfo.cpp
===
--- clang/test/Modules/ExtDebugInfo.cpp
+++ clang/test/Modules/ExtDebugInfo.cpp
@@ -24,6 +24,8 @@
 @import DebugCXX;
 #endif
 
+// Set the line number so that the LIT check expected line number doesn't have to be updated after adding/removing a line in the RUN section.
+#line 50
 using DebugCXX::Struct;
 
 Struct s;
@@ -204,8 +206,7 @@
 // CHECK: ![[GLOBAL_ANON]] = !DICompositeType(tag: DW_TAG_structure_type,
 // CHECK-SAME:  name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl)
 
-
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 27)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 50)
 
 // CHECK: !DICompileUnit(
 // CHECK-SAME:   splitDebugFilename:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 45a7383 - Increase expected line number for ExtDebugInfo.cpp

2021-09-16 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2021-09-16T10:03:01-04:00
New Revision: 45a738363ee39754a0e93d9f779bda2cad83fa18

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

LOG: Increase expected line number for ExtDebugInfo.cpp

This patch increases the expected line number for one of the checks so that it 
doesn't have to be updated for any added/removed lines in the RUN section.

This change is in preparation for the following patch: 
https://reviews.llvm.org/D109060

Reviewed By: jsji

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

Added: 


Modified: 
clang/test/Modules/ExtDebugInfo.cpp

Removed: 




diff  --git a/clang/test/Modules/ExtDebugInfo.cpp 
b/clang/test/Modules/ExtDebugInfo.cpp
index aff2953b4bb5..00754a90079b 100644
--- a/clang/test/Modules/ExtDebugInfo.cpp
+++ b/clang/test/Modules/ExtDebugInfo.cpp
@@ -24,6 +24,8 @@
 @import DebugCXX;
 #endif
 
+// Set the line number so that the LIT check expected line number doesn't have 
to be updated after adding/removing a line in the RUN section.
+#line 50
 using DebugCXX::Struct;
 
 Struct s;
@@ -204,8 +206,7 @@ void foo() {
 // CHECK: ![[GLOBAL_ANON]] = !DICompositeType(tag: DW_TAG_structure_type,
 // CHECK-SAME:  name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl)
 
-
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
!{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 27)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
!{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 50)
 
 // CHECK: !DICompileUnit(
 // CHECK-SAME:   splitDebugFilename:



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


[PATCH] D109880: [clangd] PreamblePatch should be no-op if includes arent patched

2021-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Don't create a useless functional patch with only filename in it when
there is only include directives to be patched but they're not
requested.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109880

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp


Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -554,6 +554,20 @@
   auto AST = createPatchedAST(Baseline, Modified);
   ASSERT_TRUE(AST);
 }
+
+TEST(PreamblePatch, NoopWhenNotRequested) {
+  llvm::StringLiteral Baseline = "#define M\nint num = M;";
+  llvm::StringLiteral Modified = "#define M\n#include \nint num = M;";
+  auto TU = TestTU::withCode(Baseline);
+  auto BaselinePreamble = TU.preamble();
+  ASSERT_TRUE(BaselinePreamble);
+
+  TU.Code = Modified.str();
+  MockFS FS;
+  auto PP = PreamblePatch::createMacroPatch(testPath(TU.Filename),
+TU.inputs(FS), *BaselinePreamble);
+  EXPECT_TRUE(PP.text().empty());
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -459,7 +459,7 @@
   bool IncludesChanged = BaselineScan->Includes != ModifiedScan->Includes;
   bool DirectivesChanged =
   BaselineScan->TextualDirectives != ModifiedScan->TextualDirectives;
-  if (!IncludesChanged && !DirectivesChanged)
+  if ((PatchType != PatchType::All || !IncludesChanged) && !DirectivesChanged)
 return PreamblePatch::unmodified(Baseline);
 
   PreamblePatch PP;


Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -554,6 +554,20 @@
   auto AST = createPatchedAST(Baseline, Modified);
   ASSERT_TRUE(AST);
 }
+
+TEST(PreamblePatch, NoopWhenNotRequested) {
+  llvm::StringLiteral Baseline = "#define M\nint num = M;";
+  llvm::StringLiteral Modified = "#define M\n#include \nint num = M;";
+  auto TU = TestTU::withCode(Baseline);
+  auto BaselinePreamble = TU.preamble();
+  ASSERT_TRUE(BaselinePreamble);
+
+  TU.Code = Modified.str();
+  MockFS FS;
+  auto PP = PreamblePatch::createMacroPatch(testPath(TU.Filename),
+TU.inputs(FS), *BaselinePreamble);
+  EXPECT_TRUE(PP.text().empty());
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -459,7 +459,7 @@
   bool IncludesChanged = BaselineScan->Includes != ModifiedScan->Includes;
   bool DirectivesChanged =
   BaselineScan->TextualDirectives != ModifiedScan->TextualDirectives;
-  if (!IncludesChanged && !DirectivesChanged)
+  if ((PatchType != PatchType::All || !IncludesChanged) && !DirectivesChanged)
 return PreamblePatch::unmodified(Baseline);
 
   PreamblePatch PP;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >