[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-04-15 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4537
+  CGM.getLangOpts().Optimize) {
+for (auto  : DeclCache) {
+  auto *D = SP.first;

Just looking at the type declarations in CGDebugInfo.h: Why not iterate over 
the `SPCache`  directly? Shouldn't that contain all Function declarations only?



Comment at: lib/CodeGen/CGDebugInfo.cpp:4541
+const Stmt *FuncBody = (*FD).getBody();
+for(auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());

clang-format please



Comment at: lib/CodeGen/CGDebugInfo.cpp:4546
+if (I != ParmCache.end()) {
+  auto *DIParm = dyn_cast(I->second);
+  DIParm->setIsNotModified();

Could this be a `cast<>`?


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

https://reviews.llvm.org/D58035



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


[PATCH] D58033: Add option for emitting dbg info for call sites

2019-04-15 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: include/clang/Driver/Options.td:919
   HelpText<"Do not use jump tables for lowering switches">;
+def emit_param_entry_values : Joined<["-"], "femit-param-entry-values">,
+   Group,

I assume that this is the same -f option that GCC uses?


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

https://reviews.llvm.org/D58033



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


[PATCH] D60749: [Test] Remove obsolete test.

2019-04-15 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added reviewers: hfinkel, aaron.ballman, tyler.nowicki, TylerNowicki.
Meinersbur added a project: clang.

The FIXME of this test case has been addressed in r335084/r338800. Its 
execution still does not succeed because of multiple syntax errors.

First, the "clang" namespace is missing on each of the 4 pragmas. Second, the 
pragma for defining the vector width is "vectorize_width(4)" instead of 
"vectorize(4)". Third, the pragma for defining the interleave factor is 
"interleave_count(8)" instead of "interleave(8)".

The file was already using the wrong syntax when added in r210925 2014-06-13. 
The file ast-print-pragmas.cpp already checks for the correct pragma order, 
making this test redundant even if fixed.


Repository:
  rC Clang

https://reviews.llvm.org/D60749

Files:
  test/AST/ast-print-pragmas-xfail.cpp


Index: test/AST/ast-print-pragmas-xfail.cpp
===
--- test/AST/ast-print-pragmas-xfail.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 %s -ast-print -o - | FileCheck %s
-
-// FIXME: Test fails because attribute order is reversed by ParsedAttributes.
-// XFAIL: *
-
-void run1(int *List, int Length) {
-  int i = 0;
-// CHECK: #pragma loop vectorize(4)
-// CHECK-NEXT: #pragma loop interleave(8)
-// CHECK-NEXT: #pragma loop vectorize(enable)
-// CHECK-NEXT: #pragma loop interleave(enable)
-#pragma loop vectorize(4)
-#pragma loop interleave(8)
-#pragma loop vectorize(enable)
-#pragma loop interleave(enable)
-// CHECK-NEXT: while (i < Length)
-  while (i < Length) {
-List[i] = i;
-i++;
-  }
-}


Index: test/AST/ast-print-pragmas-xfail.cpp
===
--- test/AST/ast-print-pragmas-xfail.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 %s -ast-print -o - | FileCheck %s
-
-// FIXME: Test fails because attribute order is reversed by ParsedAttributes.
-// XFAIL: *
-
-void run1(int *List, int Length) {
-  int i = 0;
-// CHECK: #pragma loop vectorize(4)
-// CHECK-NEXT: #pragma loop interleave(8)
-// CHECK-NEXT: #pragma loop vectorize(enable)
-// CHECK-NEXT: #pragma loop interleave(enable)
-#pragma loop vectorize(4)
-#pragma loop interleave(8)
-#pragma loop vectorize(enable)
-#pragma loop interleave(enable)
-// CHECK-NEXT: while (i < Length)
-  while (i < Length) {
-List[i] = i;
-i++;
-  }
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r358355 - [c++20] Enable driver and frontend support for building and using

2019-04-15 Thread via cfe-commits
Both work, although using -### requires a few more changes to the test than 
just changing –c to –S because all arguments are enclosed in double quotes. I 
think it would be simplest to just change “-c” to “-S” , and if that is okay 
with you, I can make the change.

Douglas Yung

From: Richard Smith 
Sent: Monday, April 15, 2019 19:12
To: Yung, Douglas 
Cc: cfe-commits 
Subject: Re: r358355 - [c++20] Enable driver and frontend support for building 
and using

On Mon, 15 Apr 2019, 19:08 via cfe-commits, 
mailto:cfe-commits@lists.llvm.org>> wrote:
Hi Richard,

That helps a little bit! Our main problem is that the environment where the 
compiler is built and tested (using lit) does not have the external assembler 
installed, so all of the compiler commands which try to use "-c" fail when 
trying to run the external assembler. I find that if I change the test to use 
"-S" instead of "-c" it will pass in our build environment. Would that change 
defeat the purpose of the test?

That's fine. You could also try changing the -c tests from using -v to using 
-### so they don't actually run the compilation step, but we do need to run the 
steps that produce .pcm files or the later steps will fail.

Douglas Yung

-Original Message-
From: Richard Smith mailto:rich...@metafoo.co.uk>>
Sent: Monday, April 15, 2019 18:44
To: Yung, Douglas mailto:douglas.y...@sony.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r358355 - [c++20] Enable driver and frontend support for building 
and using

On Mon, 15 Apr 2019 at 18:14, via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Hi Richard,
>
> The driver test you added (modules.cpp) seems to fail if the compiler 
> configuration uses an external assembler. Is there any way that the test can 
> be rewritten so that it works with both the integrated and an external 
> assembler configurations?

Sorry about that. r358470 fixes the test to pass if I add -fno-integrated-as to 
all the clang invocations. Does that resolve the problem you're seeing?

> Douglas Yung
>
> -Original Message-
> From: cfe-commits 
> mailto:cfe-commits-boun...@lists.llvm.org>>
>  On Behalf Of
> Richard Smith via cfe-commits
> Sent: Sunday, April 14, 2019 4:12
> To: cfe-commits@lists.llvm.org
> Subject: r358355 - [c++20] Enable driver and frontend support for
> building and using
>
> Author: rsmith
> Date: Sun Apr 14 04:11:37 2019
> New Revision: 358355
>
> URL: http://llvm.org/viewvc/llvm-project?rev=358355=rev
> Log:
> [c++20] Enable driver and frontend support for building and using modules 
> when -std=c++2a is specified.
>
> Added:
> cfe/trunk/test/CXX/module/module.unit/p8.cpp
> cfe/trunk/test/Driver/modules.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/FrontendActions.cpp
> cfe/trunk/lib/Parse/Parser.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticFrontendKinds.td?rev=358355=358354=358355=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Sun Apr
> +++ 14
> +++ 04:11:37 2019
> @@ -173,10 +173,11 @@ def note_incompatible_analyzer_plugin_ap
>
>  def err_module_build_requires_fmodules : Error<
>"module compilation requires '-fmodules'">; -def
> err_module_interface_requires_modules_ts : Error<
> -  "module interface compilation requires '-fmodules-ts'">;
> +def err_module_interface_requires_cpp_modules : Error<
> +  "module interface compilation requires '-std=c++2a' or
> +'-fmodules-ts'">;
>  def err_header_module_requires_modules : Error<
> -  "header module compilation requires '-fmodules' or
> '-fmodules-ts'">;
> +  "header module compilation requires '-fmodules', '-std=c++2a', or "
> +  "'-fmodules-ts'">;
>  def warn_module_config_mismatch : Warning<
>"module file %0 cannot be loaded due to a configuration mismatch with the 
> current "
>"compilation">, InGroup>,
> DefaultError;
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cl
> ang.cpp?rev=358355=358354=358355=diff
> ==
> 
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sun Apr 14 04:11:37 2019
> @@ -2721,7 +2721,7 @@ static void RenderModulesOptions(Compila
>  }
>}
>
> -  HaveModules = HaveClangModules;
> +  HaveModules |= HaveClangModules;
>if (Args.hasArg(options::OPT_fmodules_ts)) {
>  CmdArgs.push_back("-fmodules-ts");
>  HaveModules = true;
> @@ -4259,7 +4259,8 @@ void Clang::ConstructJob(Compilation ,
>

[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-04-15 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 created this revision.
wxiao3 added reviewers: annita.zhang, LuoYuanke, smaslov, hjl.tools, RKSimon, 
rnk, andreadb.
wxiao3 added a project: clang.
Herald added a subscriber: cfe-commits.

According to i386 System V ABI 2.1: Structures and unions assume the alignment
of their most strictly aligned component. But current implementation always
takes them as 4-byte aligned which will result in incorrect code, e.g:

  1 #include 
  2 typedef union {
  3 int d[4];
  4 __m128 m;
  5 } M128;
  6 extern void foo(int, ...);
  7 void test(void)
  8 {
  9   M128 a;

10   foo(1, a);
 11   foo(1, a.m);
 12 }

The first call (line 10) takes the second arg as 4-byte aligned while the
second call (line 11) takes the second arg as 16-byte aligned. There is
oxymoron for the alignment of the 2 calls because they should be the same.

This patch fixes the bug by following i386 System V ABI.


Repository:
  rC Clang

https://reviews.llvm.org/D60748

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/x86_32-align-linux.c
  test/CodeGen/x86_32-arguments-linux.c

Index: test/CodeGen/x86_32-arguments-linux.c
===
--- test/CodeGen/x86_32-arguments-linux.c
+++ test/CodeGen/x86_32-arguments-linux.c
@@ -3,21 +3,21 @@
 
 // CHECK-LABEL: define void @f56(
 // CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
-// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 4,
-// CHECK: <1 x double> %a4, %struct.s56_2* byval align 4,
-// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 4,
-// CHECK: <2 x double> %a8, %struct.s56_4* byval align 4,
-// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 4,
-// CHECK: <4 x double> %a12, %struct.s56_6* byval align 4)
+// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 8 %a3,
+// CHECK: <1 x double> %a4, %struct.s56_2* byval align 8 %a5,
+// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 16 %a7,
+// CHECK: <2 x double> %a8, %struct.s56_4* byval align 16 %a9,
+// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 32 %a11,
+// CHECK: <4 x double> %a12, %struct.s56_6* byval align 32 %a13)
 
 // CHECK: call void (i32, ...) @f56_0(i32 1,
 // CHECK: i32 %{{.*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
-// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
-// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
-// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 4 %{{[^ ]*}},
-// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 4 %{{[^ ]*}},
-// CHECK: <8 x i32> %{{[^ ]*}}, %struct.s56_5* byval align 4 %{{[^ ]*}},
-// CHECK: <4 x double> %{{[^ ]*}}, %struct.s56_6* byval align 4 %{{[^ ]*}})
+// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 8 %{{[^ ]*}},
+// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 8 %{{[^ ]*}},
+// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 16 %{{[^ ]*}},
+// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 16 %{{[^ ]*}},
+// CHECK: <8 x i32> %{{[^ ]*}}, %struct.s56_5* byval align 32 %{{[^ ]*}},
+// CHECK: <4 x double> %{{[^ ]*}}, %struct.s56_6* byval align 32 %{{[^ ]*}})
 // CHECK: }
 //
 //  [i386] clang misaligns long double in structures
Index: test/CodeGen/x86_32-align-linux.c
===
--- /dev/null
+++ test/CodeGen/x86_32-align-linux.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+
+#include 
+
+typedef union {
+int d[4];
+__m128 m;
+} M128;
+
+extern void foo(int, ...);
+
+M128 a;
+
+// CHECK-LABEL: define void @test
+// CHECK: entry:
+// CHECK: call void (i32, ...) @foo(i32 1, %union.M128* byval align 16
+// CHECK: call void (i32, ...) @foo(i32 1, <4 x float>
+
+void test(void)
+{
+  foo(1, a);
+  foo(1, a.m);
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1492,18 +1492,18 @@
   if (Align <= MinABIStackAlignInBytes)
 return 0; // Use default alignment.
 
-  // On non-Darwin, the stack type alignment is always 4.
-  if (!IsDarwinVectorABI) {
-// Set explicit alignment, since we may need to realign the top.
+  if (IsDarwinVectorABI) {
+// On Darwin, if the type contains an SSE vector type, the alignment is 16.
+if (Align >= 16 && (isSSEVectorType(getContext(), Ty) ||
+  isRecordWithSSEVectorType(getContext(), Ty)))
+  return 16;
+return MinABIStackAlignInBytes;
+  } else if (IsWin32StructABI) {
 return MinABIStackAlignInBytes;
   }
-
-  // Otherwise, if the type contains an SSE vector type, the alignment is 16.
-  if (Align >= 16 && (isSSEVectorType(getContext(), Ty) ||
-  isRecordWithSSEVectorType(getContext(), Ty)))
-return 16;
-
-  return MinABIStackAlignInBytes;
+  // i386 System V ABI 2.1: Structures and unions assume the alignment of 

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-04-15 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 updated this revision to Diff 195291.

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

https://reviews.llvm.org/D59744

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/vector.c
  test/CodeGen/x86_32-arguments-darwin.c
  test/CodeGen/x86_32-arguments-linux.c
  test/CodeGen/x86_32-m64.c

Index: test/CodeGen/x86_32-m64.c
===
--- /dev/null
+++ test/CodeGen/x86_32-m64.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -w -O2 -fblocks -triple i386-pc-linux-gnu -target-cpu pentium4 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LINUX
+// RUN: %clang_cc1 -w -O2 -fblocks -triple i386-apple-darwin9 -target-cpu yonah -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,DARWIN
+// RUN: %clang_cc1 -w -O2 -fblocks -triple i386-pc-elfiamcu -mfloat-abi soft -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,IAMCU
+// RUN: %clang_cc1 -w -O2 -fblocks -triple i386-pc-win32 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN32
+
+#include 
+__m64 m64;
+void callee(__m64 __m1, __m64 __m2);
+__m64 caller(__m64 __m1, __m64 __m2)
+{
+// LINUX-LABEL: define x86_mmx @caller(x86_mmx %__m1.coerce, x86_mmx %__m2.coerce)
+// LINUX: tail call void @callee(x86_mmx %__m2.coerce, x86_mmx %__m1.coerce)
+// LINUX: ret x86_mmx
+// DARWIN-LABEL: define i64 @caller(i64 %__m1.coerce, i64 %__m2.coerce)
+// DARWIN: tail call void @callee(i64 %__m2.coerce, i64 %__m1.coerce)
+// DARWIN: ret i64
+// IAMCU-LABEL: define <1 x i64> @caller(i64 %__m1.coerce, i64 %__m2.coerce)
+// IAMCU: tail call void @callee(i64 %__m2.coerce, i64 %__m1.coerce)
+// IAMCU: ret <1 x i64>
+// WIN32-LABEL: define dso_local <1 x i64> @caller(i64 %__m1.coerce, i64 %__m2.coerce)
+// WIN32: call void @callee(i64 %__m2.coerce, i64 %__m1.coerce)
+// WIN32: ret <1 x i64>
+  callee(__m2, __m1);
+  return m64;
+}
Index: test/CodeGen/x86_32-arguments-linux.c
===
--- test/CodeGen/x86_32-arguments-linux.c
+++ test/CodeGen/x86_32-arguments-linux.c
@@ -3,7 +3,7 @@
 
 // CHECK-LABEL: define void @f56(
 // CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
-// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 4,
+// CHECK: x86_mmx %a2.coerce, %struct.s56_1* byval align 4,
 // CHECK: <1 x double> %a4, %struct.s56_2* byval align 4,
 // CHECK: <4 x i32> %a6, %struct.s56_3* byval align 4,
 // CHECK: <2 x double> %a8, %struct.s56_4* byval align 4,
@@ -12,7 +12,7 @@
 
 // CHECK: call void (i32, ...) @f56_0(i32 1,
 // CHECK: i32 %{{.*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
-// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
+// CHECK: x86_mmx %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
 // CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
 // CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 4 %{{[^ ]*}},
 // CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 4 %{{[^ ]*}},
Index: test/CodeGen/x86_32-arguments-darwin.c
===
--- test/CodeGen/x86_32-arguments-darwin.c
+++ test/CodeGen/x86_32-arguments-darwin.c
@@ -229,7 +229,7 @@
 
 // CHECK-LABEL: define void @f56(
 // CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
-// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 4,
+// CHECK: x86_mmx %a2.coerce, %struct.s56_1* byval align 4,
 // CHECK: i64 %a4.coerce, %struct.s56_2* byval align 4,
 // CHECK: <4 x i32> %a6, %struct.s56_3* byval align 16 %a7,
 // CHECK: <2 x double> %a8, %struct.s56_4* byval align 16 %a9,
@@ -238,7 +238,7 @@
 
 // CHECK:   call void (i32, ...) @f56_0(i32 1,
 // CHECK: i32 %{{[^ ]*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
-// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
+// CHECK: x86_mmx %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
 // CHECK: i64 %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
 // CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 16 %{{[^ ]*}},
 // CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 16 %{{[^ ]*}},
Index: test/CodeGen/vector.c
===
--- test/CodeGen/vector.c
+++ test/CodeGen/vector.c
@@ -78,5 +78,5 @@
   return y;
 }
 
-// CHECK: define void @lax_vector_compare2(<2 x i32>* {{.*sret.*}}, i64 {{.*}}, i64 {{.*}})
+// CHECK: define void @lax_vector_compare2(<2 x i32>* {{.*sret.*}}, i64 {{.*}}, x86_mmx {{.*}})
 // CHECK: icmp eq <2 x i32>
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -917,10 +917,10 @@
 
 /// IsX86_MMXType - Return true if this is an MMX type.
 bool IsX86_MMXType(llvm::Type *IRType) {
-  // Return true if the type is an MMX type <2 x i32>, <4 x i16>, or <8 x i8>.
+  // Return true if the type is an MMX type <1 x i64>, <2 x i32>, <4 x i16>,
+  // or <8 x i8>.
   return IRType->isVectorTy() && 

Re: r357340 - Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps.

2019-04-15 Thread Aras Pranckevicius via cfe-commits
>
>
> *Ideas on how to improve the backend situation:*
> *- Let FPPassManager::runOnFunction() call*
> *if (ProfileTime)*
> *llvm::timeTraceProfilerBegin("RunPass", FP->getPassName());*
> *  for each pass so that it's visible which path the time goes into*
>

In my tests (which I admittedly only tried for "slow to compile things" at
work), even the one single timer scope per function was already "not
terribly useful" -- most of our code ends up being lots of functions, but
at that point there's no easy way to e.g. group them by
class/namespace/etc. Digging deep into individual passes inside each
function might be useful for very slow to compile functions, but I haven't
ran into that yet -- that's the only reason why I haven't added the scopes.


*- Have a thing _somewhere_ (in clang? in chrome's about:tracing? a
> standalone tool?) that makes it possible to look at a flame graph view of
> the trace. A flame graph is a trace that's sorted by call stack, not by
> time, so that all the same stacks are next to each other, which makes it
> easy to see things like "30% of time is spent in function X" – together
> with the first suggestion it'd make the slowest path visible.*
>

The excellent https://www.speedscope.app/ can already do that for any
Chrome Tracing profile file -- just switch to "Left Heavy" view.


-- 
Aras Pranckevičius
work: https://unity3d.com
home: https://aras-p.info
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r358355 - [c++20] Enable driver and frontend support for building and using

2019-04-15 Thread Richard Smith via cfe-commits
On Mon, 15 Apr 2019, 19:08 via cfe-commits, 
wrote:

> Hi Richard,
>
> That helps a little bit! Our main problem is that the environment where
> the compiler is built and tested (using lit) does not have the external
> assembler installed, so all of the compiler commands which try to use "-c"
> fail when trying to run the external assembler. I find that if I change the
> test to use "-S" instead of "-c" it will pass in our build environment.
> Would that change defeat the purpose of the test?
>

That's fine. You could also try changing the -c tests from using -v to
using -### so they don't actually run the compilation step, but we do need
to run the steps that produce .pcm files or the later steps will fail.

Douglas Yung
>
> -Original Message-
> From: Richard Smith 
> Sent: Monday, April 15, 2019 18:44
> To: Yung, Douglas 
> Cc: cfe-commits 
> Subject: Re: r358355 - [c++20] Enable driver and frontend support for
> building and using
>
> On Mon, 15 Apr 2019 at 18:14, via cfe-commits 
> wrote:
> >
> > Hi Richard,
> >
> > The driver test you added (modules.cpp) seems to fail if the compiler
> configuration uses an external assembler. Is there any way that the test
> can be rewritten so that it works with both the integrated and an external
> assembler configurations?
>
> Sorry about that. r358470 fixes the test to pass if I add
> -fno-integrated-as to all the clang invocations. Does that resolve the
> problem you're seeing?
>
> > Douglas Yung
> >
> > -Original Message-
> > From: cfe-commits  On Behalf Of
> > Richard Smith via cfe-commits
> > Sent: Sunday, April 14, 2019 4:12
> > To: cfe-commits@lists.llvm.org
> > Subject: r358355 - [c++20] Enable driver and frontend support for
> > building and using
> >
> > Author: rsmith
> > Date: Sun Apr 14 04:11:37 2019
> > New Revision: 358355
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=358355=rev
> > Log:
> > [c++20] Enable driver and frontend support for building and using
> modules when -std=c++2a is specified.
> >
> > Added:
> > cfe/trunk/test/CXX/module/module.unit/p8.cpp
> > cfe/trunk/test/Driver/modules.cpp
> > Modified:
> > cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> > cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> > cfe/trunk/lib/Frontend/FrontendActions.cpp
> > cfe/trunk/lib/Parse/Parser.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> > nosticFrontendKinds.td?rev=358355=358354=358355=diff
> > ==
> > 
> > --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> > (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Sun Apr
> > +++ 14
> > +++ 04:11:37 2019
> > @@ -173,10 +173,11 @@ def note_incompatible_analyzer_plugin_ap
> >
> >  def err_module_build_requires_fmodules : Error<
> >"module compilation requires '-fmodules'">; -def
> > err_module_interface_requires_modules_ts : Error<
> > -  "module interface compilation requires '-fmodules-ts'">;
> > +def err_module_interface_requires_cpp_modules : Error<
> > +  "module interface compilation requires '-std=c++2a' or
> > +'-fmodules-ts'">;
> >  def err_header_module_requires_modules : Error<
> > -  "header module compilation requires '-fmodules' or
> > '-fmodules-ts'">;
> > +  "header module compilation requires '-fmodules', '-std=c++2a', or "
> > +  "'-fmodules-ts'">;
> >  def warn_module_config_mismatch : Warning<
> >"module file %0 cannot be loaded due to a configuration mismatch with
> the current "
> >"compilation">, InGroup>,
> > DefaultError;
> >
> > Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cl
> > ang.cpp?rev=358355=358354=358355=diff
> > ==
> > 
> > --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> > +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sun Apr 14 04:11:37 2019
> > @@ -2721,7 +2721,7 @@ static void RenderModulesOptions(Compila
> >  }
> >}
> >
> > -  HaveModules = HaveClangModules;
> > +  HaveModules |= HaveClangModules;
> >if (Args.hasArg(options::OPT_fmodules_ts)) {
> >  CmdArgs.push_back("-fmodules-ts");
> >  HaveModules = true;
> > @@ -4259,7 +4259,8 @@ void Clang::ConstructJob(Compilation ,
> >// If a std is supplied, only add -trigraphs if it follows the
> >// option.
> >bool ImplyVCPPCXXVer = false;
> > -  if (Arg *Std = Args.getLastArg(options::OPT_std_EQ,
> > options::OPT_ansi)) {
> > +  const Arg *Std = Args.getLastArg(options::OPT_std_EQ,
> > + options::OPT_ansi);  if (Std) {
> >  if (Std->getOption().matches(options::OPT_ansi))
> >if (types::isCXX(InputType))
> >  CmdArgs.push_back("-std=c++98"); @@ -4696,9 +4697,6 @@ void
> Clang::ConstructJob(Compilation ,
> >

RE: r358355 - [c++20] Enable driver and frontend support for building and using

2019-04-15 Thread via cfe-commits
Hi Richard,

That helps a little bit! Our main problem is that the environment where the 
compiler is built and tested (using lit) does not have the external assembler 
installed, so all of the compiler commands which try to use "-c" fail when 
trying to run the external assembler. I find that if I change the test to use 
"-S" instead of "-c" it will pass in our build environment. Would that change 
defeat the purpose of the test?

Douglas Yung

-Original Message-
From: Richard Smith  
Sent: Monday, April 15, 2019 18:44
To: Yung, Douglas 
Cc: cfe-commits 
Subject: Re: r358355 - [c++20] Enable driver and frontend support for building 
and using

On Mon, 15 Apr 2019 at 18:14, via cfe-commits  
wrote:
>
> Hi Richard,
>
> The driver test you added (modules.cpp) seems to fail if the compiler 
> configuration uses an external assembler. Is there any way that the test can 
> be rewritten so that it works with both the integrated and an external 
> assembler configurations?

Sorry about that. r358470 fixes the test to pass if I add -fno-integrated-as to 
all the clang invocations. Does that resolve the problem you're seeing?

> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of 
> Richard Smith via cfe-commits
> Sent: Sunday, April 14, 2019 4:12
> To: cfe-commits@lists.llvm.org
> Subject: r358355 - [c++20] Enable driver and frontend support for 
> building and using
>
> Author: rsmith
> Date: Sun Apr 14 04:11:37 2019
> New Revision: 358355
>
> URL: http://llvm.org/viewvc/llvm-project?rev=358355=rev
> Log:
> [c++20] Enable driver and frontend support for building and using modules 
> when -std=c++2a is specified.
>
> Added:
> cfe/trunk/test/CXX/module/module.unit/p8.cpp
> cfe/trunk/test/Driver/modules.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/FrontendActions.cpp
> cfe/trunk/lib/Parse/Parser.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticFrontendKinds.td?rev=358355=358354=358355=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td 
> (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Sun Apr 
> +++ 14
> +++ 04:11:37 2019
> @@ -173,10 +173,11 @@ def note_incompatible_analyzer_plugin_ap
>
>  def err_module_build_requires_fmodules : Error<
>"module compilation requires '-fmodules'">; -def 
> err_module_interface_requires_modules_ts : Error<
> -  "module interface compilation requires '-fmodules-ts'">;
> +def err_module_interface_requires_cpp_modules : Error<
> +  "module interface compilation requires '-std=c++2a' or 
> +'-fmodules-ts'">;
>  def err_header_module_requires_modules : Error<
> -  "header module compilation requires '-fmodules' or 
> '-fmodules-ts'">;
> +  "header module compilation requires '-fmodules', '-std=c++2a', or "
> +  "'-fmodules-ts'">;
>  def warn_module_config_mismatch : Warning<
>"module file %0 cannot be loaded due to a configuration mismatch with the 
> current "
>"compilation">, InGroup>, 
> DefaultError;
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cl
> ang.cpp?rev=358355=358354=358355=diff
> ==
> 
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sun Apr 14 04:11:37 2019
> @@ -2721,7 +2721,7 @@ static void RenderModulesOptions(Compila
>  }
>}
>
> -  HaveModules = HaveClangModules;
> +  HaveModules |= HaveClangModules;
>if (Args.hasArg(options::OPT_fmodules_ts)) {
>  CmdArgs.push_back("-fmodules-ts");
>  HaveModules = true;
> @@ -4259,7 +4259,8 @@ void Clang::ConstructJob(Compilation ,
>// If a std is supplied, only add -trigraphs if it follows the
>// option.
>bool ImplyVCPPCXXVer = false;
> -  if (Arg *Std = Args.getLastArg(options::OPT_std_EQ, 
> options::OPT_ansi)) {
> +  const Arg *Std = Args.getLastArg(options::OPT_std_EQ,
> + options::OPT_ansi);  if (Std) {
>  if (Std->getOption().matches(options::OPT_ansi))
>if (types::isCXX(InputType))
>  CmdArgs.push_back("-std=c++98"); @@ -4696,9 +4697,6 @@ void 
> Clang::ConstructJob(Compilation ,
>Args.AddLastArg(CmdArgs, options::OPT_fdouble_square_bracket_attributes,
>options::OPT_fno_double_square_bracket_attributes);
>
> -  bool HaveModules = false;
> -  RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, 
> HaveModules);
> -
>// -faccess-control is default.
>if (Args.hasFlag(options::OPT_fno_access_control,
> options::OPT_faccess_control, false)) @@ -4765,6 +4763,7 
> @@ void Clang::ConstructJob(Compilation ,

[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-04-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:2017
 
+  auto LastIdx = Field != FieldEnd
+ ? Field->getFieldIndex()

Please use an actual type rather than `auto` here and below.



Comment at: clang/lib/Sema/SemaInit.cpp:2046
+  SemaRef.getLangOpts().CPlusPlus2a) {
+SemaRef.Diag(Init->getBeginLoc(), diag::ext_designated_init)
+<< Init->getSourceRange();

This should use a distinct diagnostic that says what part is an extension.



Comment at: clang/lib/Sema/SemaInit.cpp:3096
+HasArrayDesignator) {
+  Diag(DIE->getBeginLoc(), diag::ext_designated_init)
+  << DIE->getSourceRange();

Likewise here, we should say what specifically is an extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59754



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


Re: r358355 - [c++20] Enable driver and frontend support for building and using

2019-04-15 Thread Richard Smith via cfe-commits
On Mon, 15 Apr 2019 at 18:14, via cfe-commits
 wrote:
>
> Hi Richard,
>
> The driver test you added (modules.cpp) seems to fail if the compiler 
> configuration uses an external assembler. Is there any way that the test can 
> be rewritten so that it works with both the integrated and an external 
> assembler configurations?

Sorry about that. r358470 fixes the test to pass if I add
-fno-integrated-as to all the clang invocations. Does that resolve the
problem you're seeing?

> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of Richard 
> Smith via cfe-commits
> Sent: Sunday, April 14, 2019 4:12
> To: cfe-commits@lists.llvm.org
> Subject: r358355 - [c++20] Enable driver and frontend support for building 
> and using
>
> Author: rsmith
> Date: Sun Apr 14 04:11:37 2019
> New Revision: 358355
>
> URL: http://llvm.org/viewvc/llvm-project?rev=358355=rev
> Log:
> [c++20] Enable driver and frontend support for building and using modules 
> when -std=c++2a is specified.
>
> Added:
> cfe/trunk/test/CXX/module/module.unit/p8.cpp
> cfe/trunk/test/Driver/modules.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/FrontendActions.cpp
> cfe/trunk/lib/Parse/Parser.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=358355=358354=358355=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Sun Apr 14
> +++ 04:11:37 2019
> @@ -173,10 +173,11 @@ def note_incompatible_analyzer_plugin_ap
>
>  def err_module_build_requires_fmodules : Error<
>"module compilation requires '-fmodules'">; -def 
> err_module_interface_requires_modules_ts : Error<
> -  "module interface compilation requires '-fmodules-ts'">;
> +def err_module_interface_requires_cpp_modules : Error<
> +  "module interface compilation requires '-std=c++2a' or
> +'-fmodules-ts'">;
>  def err_header_module_requires_modules : Error<
> -  "header module compilation requires '-fmodules' or '-fmodules-ts'">;
> +  "header module compilation requires '-fmodules', '-std=c++2a', or "
> +  "'-fmodules-ts'">;
>  def warn_module_config_mismatch : Warning<
>"module file %0 cannot be loaded due to a configuration mismatch with the 
> current "
>"compilation">, InGroup>, 
> DefaultError;
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=358355=358354=358355=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sun Apr 14 04:11:37 2019
> @@ -2721,7 +2721,7 @@ static void RenderModulesOptions(Compila
>  }
>}
>
> -  HaveModules = HaveClangModules;
> +  HaveModules |= HaveClangModules;
>if (Args.hasArg(options::OPT_fmodules_ts)) {
>  CmdArgs.push_back("-fmodules-ts");
>  HaveModules = true;
> @@ -4259,7 +4259,8 @@ void Clang::ConstructJob(Compilation ,
>// If a std is supplied, only add -trigraphs if it follows the
>// option.
>bool ImplyVCPPCXXVer = false;
> -  if (Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) {
> +  const Arg *Std = Args.getLastArg(options::OPT_std_EQ,
> + options::OPT_ansi);  if (Std) {
>  if (Std->getOption().matches(options::OPT_ansi))
>if (types::isCXX(InputType))
>  CmdArgs.push_back("-std=c++98"); @@ -4696,9 +4697,6 @@ void 
> Clang::ConstructJob(Compilation ,
>Args.AddLastArg(CmdArgs, options::OPT_fdouble_square_bracket_attributes,
>options::OPT_fno_double_square_bracket_attributes);
>
> -  bool HaveModules = false;
> -  RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules);
> -
>// -faccess-control is default.
>if (Args.hasFlag(options::OPT_fno_access_control,
> options::OPT_faccess_control, false)) @@ -4765,6 +4763,7 
> @@ void Clang::ConstructJob(Compilation ,
>if (ImplyVCPPCXXVer) {
>  StringRef LanguageStandard;
>  if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
> +  Std = StdArg;
>LanguageStandard = llvm::StringSwitch(StdArg->getValue())
>   .Case("c++14", "-std=c++14")
>   .Case("c++17", "-std=c++17") @@ -4830,6 
> +4829,12 @@ void Clang::ConstructJob(Compilation ,
> options::OPT_fno_inline_functions))
>  InlineArg->render(Args, CmdArgs);
>
> +  // FIXME: Find a better way to determine whether the language has
> + modules  // support by default, or just assume that all languages do.
> +  bool 

r358470 - Tweak test to pass when using a non-integrated assembler.

2019-04-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 15 18:44:53 2019
New Revision: 358470

URL: http://llvm.org/viewvc/llvm-project?rev=358470=rev
Log:
Tweak test to pass when using a non-integrated assembler.

Modified:
cfe/trunk/test/Driver/modules.cpp

Modified: cfe/trunk/test/Driver/modules.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/modules.cpp?rev=358470=358469=358470=diff
==
--- cfe/trunk/test/Driver/modules.cpp (original)
+++ cfe/trunk/test/Driver/modules.cpp Mon Apr 15 18:44:53 2019
@@ -14,8 +14,8 @@
 //
 // RUN: %clang -std=c++2a %t/module.pcm -c -o %t/module.pcm.o -v 2>&1 | 
FileCheck %s --check-prefix=CHECK-COMPILE
 //
-// CHECK-COMPILE: -cc1 {{.*}} -emit-obj
-// CHECK-COMPILE-SAME: -o {{.*}}.pcm.o
+// CHECK-COMPILE: -cc1 {{.*}} {{-emit-obj|-S}}
+// CHECK-COMPILE-SAME: -o {{.*}}.{{pcm.o|s}}
 // CHECK-COMPILE-SAME: -x pcm
 // CHECK-COMPILE-SAME: {{.*}}.pcm
 
@@ -24,9 +24,9 @@
 // RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -c -o 
%t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
 // CHECK-USE: -cc1
-// CHECK-USE-SAME: -emit-obj
+// CHECK-USE-SAME: {{-emit-obj|-S}}
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
-// CHECK-USE-SAME: -o {{.*}}.o{{"?}} {{.*}}-x c++
+// CHECK-USE-SAME: -o {{.*}}.{{o|s}}{{"?}} {{.*}}-x c++
 // CHECK-USE-SAME: modules.cpp
 
 // Check combining precompile and compile steps works.


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


RE: r358355 - [c++20] Enable driver and frontend support for building and using

2019-04-15 Thread via cfe-commits
Hi Richard,

The driver test you added (modules.cpp) seems to fail if the compiler 
configuration uses an external assembler. Is there any way that the test can be 
rewritten so that it works with both the integrated and an external assembler 
configurations?

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Richard 
Smith via cfe-commits
Sent: Sunday, April 14, 2019 4:12
To: cfe-commits@lists.llvm.org
Subject: r358355 - [c++20] Enable driver and frontend support for building and 
using

Author: rsmith
Date: Sun Apr 14 04:11:37 2019
New Revision: 358355

URL: http://llvm.org/viewvc/llvm-project?rev=358355=rev
Log:
[c++20] Enable driver and frontend support for building and using modules when 
-std=c++2a is specified.

Added:
cfe/trunk/test/CXX/module/module.unit/p8.cpp
cfe/trunk/test/Driver/modules.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=358355=358354=358355=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Sun Apr 14 
+++ 04:11:37 2019
@@ -173,10 +173,11 @@ def note_incompatible_analyzer_plugin_ap
 
 def err_module_build_requires_fmodules : Error<
   "module compilation requires '-fmodules'">; -def 
err_module_interface_requires_modules_ts : Error<
-  "module interface compilation requires '-fmodules-ts'">;
+def err_module_interface_requires_cpp_modules : Error<
+  "module interface compilation requires '-std=c++2a' or 
+'-fmodules-ts'">;
 def err_header_module_requires_modules : Error<
-  "header module compilation requires '-fmodules' or '-fmodules-ts'">;
+  "header module compilation requires '-fmodules', '-std=c++2a', or "
+  "'-fmodules-ts'">;
 def warn_module_config_mismatch : Warning<
   "module file %0 cannot be loaded due to a configuration mismatch with the 
current "
   "compilation">, InGroup>, 
DefaultError;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=358355=358354=358355=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sun Apr 14 04:11:37 2019
@@ -2721,7 +2721,7 @@ static void RenderModulesOptions(Compila
 }
   }
 
-  HaveModules = HaveClangModules;
+  HaveModules |= HaveClangModules;
   if (Args.hasArg(options::OPT_fmodules_ts)) {
 CmdArgs.push_back("-fmodules-ts");
 HaveModules = true;
@@ -4259,7 +4259,8 @@ void Clang::ConstructJob(Compilation ,
   // If a std is supplied, only add -trigraphs if it follows the
   // option.
   bool ImplyVCPPCXXVer = false;
-  if (Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) {
+  const Arg *Std = Args.getLastArg(options::OPT_std_EQ, 
+ options::OPT_ansi);  if (Std) {
 if (Std->getOption().matches(options::OPT_ansi))
   if (types::isCXX(InputType))
 CmdArgs.push_back("-std=c++98"); @@ -4696,9 +4697,6 @@ void 
Clang::ConstructJob(Compilation ,
   Args.AddLastArg(CmdArgs, options::OPT_fdouble_square_bracket_attributes,
   options::OPT_fno_double_square_bracket_attributes);
 
-  bool HaveModules = false;
-  RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules);
-
   // -faccess-control is default.
   if (Args.hasFlag(options::OPT_fno_access_control,
options::OPT_faccess_control, false)) @@ -4765,6 +4763,7 @@ 
void Clang::ConstructJob(Compilation ,
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
+  Std = StdArg;
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
  .Case("c++17", "-std=c++17") @@ -4830,6 +4829,12 
@@ void Clang::ConstructJob(Compilation ,
options::OPT_fno_inline_functions))
 InlineArg->render(Args, CmdArgs);
 
+  // FIXME: Find a better way to determine whether the language has 
+ modules  // support by default, or just assume that all languages do.
+  bool HaveModules =
+  Std && (Std->containsValue("c++2a") || 
+ Std->containsValue("c++latest"));  RenderModulesOptions(C, D, Args, 
+ Input, Output, CmdArgs, HaveModules);
+
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
   options::OPT_fno_experimental_new_pass_manager);
 

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 

[PATCH] D60742: [analyzer] RegionStore: Enable loading default bindings from variables.

2019-04-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/unittests/StaticAnalyzer/StoreTest.cpp:20
+// back from that variable. Test what happens if default bindings are used.
+class VariableBindConsumer : public ExprEngineConsumer {
+  void performTest(const Decl *D) {

It is awesome to see unit tests for this!


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

https://reviews.llvm.org/D60742



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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Ronan Keryell via Phabricator via cfe-commits
keryell accepted this revision.
keryell added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1000
+def SYCLDevice : InheritableAttr {
+  let Spellings = [GNU<"sycl_device">];
+  let Subjects = SubjectList<[Function, Var]>;

aaron.ballman wrote:
> aaron.ballman wrote:
> > keryell wrote:
> > > Fznamznon wrote:
> > > > aaron.ballman wrote:
> > > > > Is there a reason to not also introduce a C++11 and C2x style 
> > > > > spelling in the `clang` namespace? e.g., `[[clang::sycl_device]]`
> > > > I don't think that it makes sense because these attributes not for 
> > > > public consumption. These attributes is needed to separate code which 
> > > > is supposed to be offloaded from regular host code. I think SYCLDevice 
> > > > attribute actually doesn't need a spelling because it will be added 
> > > > only implicitly by compiler.
> > > 
> > > If we go towards this direction, `[[clang::sycl::device]]` or 
> > > `[[clang::sycl::kernel]]` look more compatible with the concept of name 
> > > space.
> > > While not a public interface, if we have a kind of "standard" outlining 
> > > in Clang/LLVM, some people might want to use it in some other contexts 
> > > too.
> > If these are only being added implicitly by the compiler, then they should 
> > not be given any `Spelling`. See `AlignMac68k` for an example.
> I'm still confused -- are these created implicitly or are they spelled out by 
> the user explicitly? Right now, it looks like they're spelled out explicitly, 
> but I was under the impression they are only intended to be created 
> implicitly by the compiler.
> 
> If they are expected to be explicitly specified by the user, the spelling 
> should be using `Clang<>` instead of using `GNU<>`, `C2x<>`, and `CXX11<>` 
> explicitly.
> 
> > If we go towards this direction, [[clang::sycl::device]] or 
> > [[clang::sycl::kernel]] look more compatible with the concept of name space.
> 
> Attribute namespaces do not work that way. There is the vendor namespace and 
> then the attribute name.
> Attribute namespaces do not work that way. There is the vendor namespace and 
> then the attribute name.

After diving into "9.11.1 Attribute syntax and semantics [dcl.attr.grammar]" of 
the latest C++ draft standard, it looks you are right... There is only 1 level 
of `::` allowed. :-(



Comment at: clang/include/clang/Basic/AttrDocs.td:286
+help.
+  }];
+}

aaron.ballman wrote:
> I'm still not entirely certain how I would know what to mark and how. From 
> the description, it sounds like whoever authors `parallel_for` needs to do 
> this marking, or it somehow happens automatically?
> 
> (I'll do another editorial pass once I understand the intended behavior a bit 
> better -- I expect there will be a few more wording issues to address.)
In normal SYCL it happens automatically.
In the compiler unit-tests it is done manually to exercise the framework.
I am the one who suggested that in some other contexts, it could be used 
manually for some special purpose like using some weird hardware, but I do not 
want to derail the main review with this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


r358467 - PR41192: fix cases where "missing '; ' after class" error would

2019-04-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 15 17:47:45 2019
New Revision: 358467

URL: http://llvm.org/viewvc/llvm-project?rev=358467=rev
Log:
PR41192: fix cases where "missing ';' after class" error would
incorrectly fire.

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/CXX/cpp/cpp.module/p2.cpp
cfe/trunk/test/Parser/cxx-class.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=358467=358466=358467=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Apr 15 17:47:45 2019
@@ -1248,9 +1248,11 @@ bool Parser::isValidAfterTypeSpecifier(b
   case tok::ampamp: // struct foo {...} &&R = ...
   case tok::identifier: // struct foo {...} V ;
   case tok::r_paren://(struct foo {...} ) {4}
+  case tok::coloncolon: // struct foo {...} ::a::b;
   case tok::annot_cxxscope: // struct foo {...} a::   b;
   case tok::annot_typename: // struct foo {...} a ::b;
   case tok::annot_template_id:  // struct foo {...} a::b;
+  case tok::kw_decltype:// struct foo {...} decltype  (a)::b;
   case tok::l_paren:// struct foo {...} ( x);
   case tok::comma:  // __builtin_offsetof(struct foo{...} ,
   case tok::kw_operator:// struct foo   operator  ++() {...}

Modified: cfe/trunk/test/CXX/cpp/cpp.module/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/cpp/cpp.module/p2.cpp?rev=358467=358466=358467=diff
==
--- cfe/trunk/test/CXX/cpp/cpp.module/p2.cpp (original)
+++ cfe/trunk/test/CXX/cpp/cpp.module/p2.cpp Mon Apr 15 17:47:45 2019
@@ -13,10 +13,9 @@ template<> struct import<0> {
 };
 
 // OK, not an import-declaration.
-// FIXME: This is valid, see PR41192
-struct A {} // FIXME expected-error {{expected ';'}}
+struct A {}
 ::import
-::a; // FIXME expected-error {{requires a type specifier}}
+::a;
 
 // This is invalid: the tokens after 'import' are a header-name, so cannot be
 // parsed as a template-argument-list.

Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=358467=358466=358467=diff
==
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Mon Apr 15 17:47:45 2019
@@ -272,6 +272,17 @@ class BadExceptionSpec {
   ));
 };
 
+namespace PR41192 {
+extern struct A a;
+struct A {} ::PR41192::a; // ok, no missing ';' here  expected-warning {{extra 
qualification}}
+
+#if __cplusplus >= 201103L
+struct C;
+struct D { static C c; };
+struct C {} decltype(D())::c; // expected-error {{'decltype' cannot be used to 
name a declaration}}
+#endif
+}
+
 // PR11109 must appear at the end of the source file
 class pr11109r3 { // expected-note{{to match this '{'}}
   public // expected-error{{expected ':'}} expected-error{{expected '}'}} 
expected-error{{expected ';' after class}}


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


[PATCH] D60742: [analyzer] RegionStore: Enable loading default bindings from variables.

2019-04-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 195280.
NoQ added a comment.

Whoops, copy-paste error.

So, like, the reason why i added a unittest was that i wanted to test 
separation of concerns: that it's specifically our Store that works correctly, 
not only the system as a whole.


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

https://reviews.llvm.org/D60742

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/string.c
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/StoreTest.cpp

Index: clang/unittests/StaticAnalyzer/StoreTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/StoreTest.cpp
@@ -0,0 +1,107 @@
+//===- unittests/StaticAnalyzer/StoreTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusables.h"
+
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+// Test that we can put a value into an int-type variable and load it
+// back from that variable. Test what happens if default bindings are used.
+class VariableBindConsumer : public ExprEngineConsumer {
+  void performTest(const Decl *D) {
+StoreManager  = Eng.getStoreManager();
+SValBuilder  = Eng.getSValBuilder();
+MemRegionManager  = StMgr.getRegionManager();
+const ASTContext  = Eng.getContext();
+
+const auto *VDX0 = findDeclByName(D, "x0");
+const auto *VDY0 = findDeclByName(D, "y0");
+const auto *VDZ0 = findDeclByName(D, "z0");
+const auto *VDX1 = findDeclByName(D, "x1");
+const auto *VDY1 = findDeclByName(D, "y1");
+assert(VDX0 && VDY0 && VDZ0 && VDX1 && VDY1);
+
+const StackFrameContext *SFC =
+Eng.getAnalysisDeclContextManager().getStackFrame(D);
+
+Loc LX0 = loc::MemRegionVal(MRMgr.getVarRegion(VDX0, SFC));
+Loc LY0 = loc::MemRegionVal(MRMgr.getVarRegion(VDY0, SFC));
+Loc LZ0 = loc::MemRegionVal(MRMgr.getVarRegion(VDZ0, SFC));
+Loc LX1 = loc::MemRegionVal(MRMgr.getVarRegion(VDX1, SFC));
+Loc LY1 = loc::MemRegionVal(MRMgr.getVarRegion(VDY1, SFC));
+
+Store StInit = StMgr.getInitialStore(SFC).getStore();
+SVal Zero = SVB.makeZeroVal(ACtx.IntTy);
+SVal One = SVB.makeIntVal(1, ACtx.IntTy);
+SVal NarrowZero = SVB.makeZeroVal(ACtx.CharTy);
+
+// Bind(Zero)
+Store StX0 =
+StMgr.Bind(StInit, LX0, Zero).getStore();
+ASSERT_EQ(Zero, StMgr.getBinding(StX0, LX0, ACtx.IntTy));
+
+// BindDefaultInitial(Zero)
+Store StY0 =
+StMgr.BindDefaultInitial(StInit, LY0.getAsRegion(), Zero).getStore();
+ASSERT_EQ(Zero, StMgr.getBinding(StY0, LY0, ACtx.IntTy));
+ASSERT_EQ(Zero, *StMgr.getDefaultBinding(StY0, LY0.getAsRegion()));
+
+// BindDefaultZero()
+Store StZ0 =
+StMgr.BindDefaultZero(StInit, LZ0.getAsRegion()).getStore();
+// BindDefaultZero wipes the region with '0 S8b', not with out Zero.
+// Direct load, however, does give us back the object of the type
+// that we specify for loading.
+ASSERT_EQ(Zero, StMgr.getBinding(StZ0, LZ0, ACtx.IntTy));
+ASSERT_EQ(NarrowZero, *StMgr.getDefaultBinding(StZ0, LZ0.getAsRegion()));
+
+// Bind(One)
+Store StX1 =
+StMgr.Bind(StInit, LX1, One).getStore();
+ASSERT_EQ(One, StMgr.getBinding(StX1, LX1, ACtx.IntTy));
+
+// BindDefaultInitial(One)
+Store StY1 =
+StMgr.BindDefaultInitial(StInit, LY1.getAsRegion(), One).getStore();
+ASSERT_EQ(One, StMgr.getBinding(StY1, LY1, ACtx.IntTy));
+ASSERT_EQ(One, *StMgr.getDefaultBinding(StY1, LY1.getAsRegion()));
+  }
+
+public:
+  VariableBindConsumer(CompilerInstance ) : ExprEngineConsumer(C) {}
+  ~VariableBindConsumer() override {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (const auto *D : DG)
+  performTest(D);
+return true;
+  }
+};
+
+class VariableBindAction : public ASTFrontendAction {
+public:
+  VariableBindAction() {}
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef File) override {
+return llvm::make_unique(Compiler);
+  }
+};
+
+TEST(Store, VariableBind) {
+  EXPECT_TRUE(tooling::runToolOnCode(
+  new VariableBindAction, "void foo() { int x0, y0, z0, x1, y1; }"));
+}
+
+} // namespace
+} // namespace ento
+} // namespace clang
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  StoreTest.cpp
   

[PATCH] D60742: [analyzer] RegionStore: Enable loading default bindings from variables.

2019-04-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 195279.
NoQ added a comment.

Fix test file name in the top comment.


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

https://reviews.llvm.org/D60742

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/string.c
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/StoreTest.cpp

Index: clang/unittests/StaticAnalyzer/StoreTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/StoreTest.cpp
@@ -0,0 +1,108 @@
+//===- unittests/StaticAnalyzer/StoreTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusables.h"
+
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+// Test that we can put a value into an int-type variable and load it
+// back from that variable. Test what happens if default bindings are used.
+class VariableBindConsumer : public ExprEngineConsumer {
+  void performTest(const Decl *D) {
+StoreManager  = Eng.getStoreManager();
+SValBuilder  = Eng.getSValBuilder();
+MemRegionManager  = StMgr.getRegionManager();
+const ASTContext  = Eng.getContext();
+
+const auto *VDX0 = findDeclByName(D, "x0");
+const auto *VDY0 = findDeclByName(D, "y0");
+const auto *VDZ0 = findDeclByName(D, "z0");
+const auto *VDX1 = findDeclByName(D, "x1");
+const auto *VDY1 = findDeclByName(D, "y1");
+assert(VDX0 && VDY0 && VDZ0 && VDX1 && VDY1);
+
+const StackFrameContext *SFC =
+Eng.getAnalysisDeclContextManager().getStackFrame(D);
+
+Loc LX0 = loc::MemRegionVal(MRMgr.getVarRegion(VDX0, SFC));
+Loc LY0 = loc::MemRegionVal(MRMgr.getVarRegion(VDY0, SFC));
+Loc LZ0 = loc::MemRegionVal(MRMgr.getVarRegion(VDZ0, SFC));
+Loc LX1 = loc::MemRegionVal(MRMgr.getVarRegion(VDX1, SFC));
+Loc LY1 = loc::MemRegionVal(MRMgr.getVarRegion(VDY1, SFC));
+
+Store StInit = StMgr.getInitialStore(SFC).getStore();
+SVal Zero = SVB.makeZeroVal(ACtx.IntTy);
+SVal One = SVB.makeIntVal(1, ACtx.IntTy);
+SVal NarrowZero = SVB.makeZeroVal(ACtx.CharTy);
+
+// Bind(Zero)
+Store StX0 =
+StMgr.Bind(StInit, LX0, Zero).getStore();
+ASSERT_EQ(Zero, StMgr.getBinding(StX0, LX0, ACtx.IntTy));
+
+// BindDefaultInitial(Zero)
+Store StY0 =
+StMgr.BindDefaultInitial(StInit, LY0.getAsRegion(), Zero).getStore();
+ASSERT_EQ(Zero, StMgr.getBinding(StY0, LY0, ACtx.IntTy));
+ASSERT_EQ(Zero, *StMgr.getDefaultBinding(StY0, LY0.getAsRegion()));
+
+// BindDefaultZero()
+Store StZ0 =
+StMgr.BindDefaultZero(StInit, LZ0.getAsRegion()).getStore();
+// BindDefaultZero wipes the region with '0 S8b', not with out Zero.
+// Direct load, however, does give us back the object of the type
+// that we specify for loading.
+ASSERT_EQ(Zero, StMgr.getBinding(StZ0, LZ0, ACtx.IntTy));
+ASSERT_EQ(NarrowZero, *StMgr.getDefaultBinding(StZ0, LZ0.getAsRegion()));
+
+// Bind(One)
+Store StX1 =
+StMgr.Bind(StInit, LX1, One).getStore();
+ASSERT_EQ(One, StMgr.getBinding(StX1, LX1, ACtx.IntTy));
+
+// BindDefaultInitial(One)
+Store StY1 =
+StMgr.BindDefaultInitial(StInit, LY1.getAsRegion(), One).getStore();
+ASSERT_EQ(One, StMgr.getBinding(StY1, LY1, ACtx.IntTy));
+ASSERT_EQ(One, *StMgr.getDefaultBinding(StY1, LY1.getAsRegion()));
+  }
+
+public:
+  VariableBindConsumer(CompilerInstance ) : ExprEngineConsumer(C) {}
+  ~VariableBindConsumer() override {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (const auto *D : DG)
+  performTest(D);
+return true;
+  }
+};
+
+class VariableBindAction : public ASTFrontendAction {
+public:
+  VariableBindAction() {}
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef File) override {
+return llvm::make_unique(Compiler);
+  }
+};
+
+// Test that marking s.x as live would also make s live.
+TEST(Store, VariableBind) {
+  EXPECT_TRUE(tooling::runToolOnCode(
+  new VariableBindAction, "void foo() { int x0, y0, z0, x1, y1; }"));
+}
+
+} // namespace
+} // namespace ento
+} // namespace clang
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  StoreTest.cpp
   RegisterCustomCheckersTest.cpp
   SymbolReaperTest.cpp
   )
Index: clang/test/Analysis/string.c

[PATCH] D60742: [analyzer] RegionStore: Enable loading default bindings from variables.

2019-04-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet, 
mgorny.
Herald added a project: clang.

D44934  added modeling for `memset()` that, 
for the case of setting memory to 0, boils down to default-binding a concrete 0 
to the memory region.

Surprisingly, in some cases RegionStore fails to load default bindings from a 
region. That is, it assumes that the region either has a direct binding (i.e., 
initialized via assignment), or it is uninitialized. In particular, this 
applies to local variables regions of integer/pointer/float types.

It seems that a lot of code (eg., `invalidateRegions()`) carefully works around 
this problem by adding either a direct binding or a default binding, depending 
on what `RegionStore` expects. This essentially duplicates `RegionStore`'s 
already-convoluted logic on this subject on the caller side.

Our options are:

1. Duplicate this logic again in `CStringChecker`.
2. Let `RegionStore` automatically do the direct binding for such plain 
integers.
3. Add support for loading default bindings from variables.

Option 1 is a failure to improve checker API in an aspect in which it's already 
very bad, so i didn't go for it. In options 2 and 3 the difference is entirely 
within `RegionStore`. I believe that option 2 is slightly superior because it 
produces a more "normalized" data structure and, additionally, because stores 
are more rare than loads (unless they are "dead stores"^^), so it should be 
slightly more performant. But it is also harder to implement, as it requires 
gathering the logic of when exactly do we need a direct binding in one place, 
so i went for option 3 in order to address the regression and simplify that 
logic. I did not yet try to see how other callers of `bindDefault***()` can be 
simplified.


Repository:
  rC Clang

https://reviews.llvm.org/D60742

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/string.c
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/StoreTest.cpp

Index: clang/unittests/StaticAnalyzer/StoreTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/StoreTest.cpp
@@ -0,0 +1,108 @@
+//===- unittests/StaticAnalyzer/RegionStoreTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusables.h"
+
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+// Test that we can put a value into an int-type variable and load it
+// back from that variable. Test what happens if default bindings are used.
+class VariableBindConsumer : public ExprEngineConsumer {
+  void performTest(const Decl *D) {
+StoreManager  = Eng.getStoreManager();
+SValBuilder  = Eng.getSValBuilder();
+MemRegionManager  = StMgr.getRegionManager();
+const ASTContext  = Eng.getContext();
+
+const auto *VDX0 = findDeclByName(D, "x0");
+const auto *VDY0 = findDeclByName(D, "y0");
+const auto *VDZ0 = findDeclByName(D, "z0");
+const auto *VDX1 = findDeclByName(D, "x1");
+const auto *VDY1 = findDeclByName(D, "y1");
+assert(VDX0 && VDY0 && VDZ0 && VDX1 && VDY1);
+
+const StackFrameContext *SFC =
+Eng.getAnalysisDeclContextManager().getStackFrame(D);
+
+Loc LX0 = loc::MemRegionVal(MRMgr.getVarRegion(VDX0, SFC));
+Loc LY0 = loc::MemRegionVal(MRMgr.getVarRegion(VDY0, SFC));
+Loc LZ0 = loc::MemRegionVal(MRMgr.getVarRegion(VDZ0, SFC));
+Loc LX1 = loc::MemRegionVal(MRMgr.getVarRegion(VDX1, SFC));
+Loc LY1 = loc::MemRegionVal(MRMgr.getVarRegion(VDY1, SFC));
+
+Store StInit = StMgr.getInitialStore(SFC).getStore();
+SVal Zero = SVB.makeZeroVal(ACtx.IntTy);
+SVal One = SVB.makeIntVal(1, ACtx.IntTy);
+SVal NarrowZero = SVB.makeZeroVal(ACtx.CharTy);
+
+// Bind(Zero)
+Store StX0 =
+StMgr.Bind(StInit, LX0, Zero).getStore();
+ASSERT_EQ(Zero, StMgr.getBinding(StX0, LX0, ACtx.IntTy));
+
+// BindDefaultInitial(Zero)
+Store StY0 =
+StMgr.BindDefaultInitial(StInit, LY0.getAsRegion(), Zero).getStore();
+ASSERT_EQ(Zero, StMgr.getBinding(StY0, LY0, ACtx.IntTy));
+ASSERT_EQ(Zero, *StMgr.getDefaultBinding(StY0, LY0.getAsRegion()));
+
+// BindDefaultZero()
+Store StZ0 =
+StMgr.BindDefaultZero(StInit, LZ0.getAsRegion()).getStore();
+// BindDefaultZero wipes the region with '0 S8b', not with out Zero.
+// Direct load, however, does give us back the object of the type
+// that 

[PATCH] D60629: [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 195278.
hintonda added a comment.

- Change `llvm_checker` to `llvm_check`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60629

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.h
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.h
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
@@ -3,7 +3,7 @@
 #include "llvm/IncludeOrderCheck.h"
 #include "gtest/gtest.h"
 
-using namespace clang::tidy::llvm;
+using namespace clang::tidy::llvm_check;
 
 namespace clang {
 namespace tidy {
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -14,6 +14,18 @@
 import re
 
 
+def replaceInFileRegex(fileName, sFrom, sTo):
+  if sFrom == sTo:
+return
+  txt = None
+  with open(fileName, "r") as f:
+txt = f.read()
+
+  txt = re.sub(sFrom, sTo, txt)
+  print("Replacing '%s' -> '%s' in '%s'..." % (sFrom, sTo, fileName))
+  with open(fileName, "w") as f:
+f.write(txt)
+
 def replaceInFile(fileName, sFrom, sTo):
   if sFrom == sTo:
 return
@@ -203,6 +215,8 @@
   clang_tidy_path = os.path.dirname(__file__)
 
   header_guard_variants = [
+  (args.old_check_name.replace('-', '_') + '_Check').upper(),
+  (old_module + '_' + check_name_camel).upper(),
   (old_module + '_' + new_check_name_camel).upper(),
   args.old_check_name.replace('-', '_').upper()]
   header_guard_new = (new_module + '_' + new_check_name_camel).upper()
@@ -210,18 +224,19 @@
   old_module_path = os.path.join(clang_tidy_path, old_module)
   new_module_path = os.path.join(clang_tidy_path, new_module)
 
-  # Remove the check from the old module.
-  cmake_lists = os.path.join(old_module_path, 'CMakeLists.txt')
-  check_found = deleteMatchingLines(cmake_lists, '\\b' + check_name_camel)
-  if not check_found:
-print("Check name '%s' not found in %s. Exiting." %
+  if (args.old_check_name != args.new_check_name):
+# Remove the check from the old module.
+cmake_lists = os.path.join(old_module_path, 'CMakeLists.txt')
+check_found = deleteMatchingLines(cmake_lists, '\\b' + check_name_camel)
+if not check_found:
+  print("Check name '%s' not found in %s. Exiting." %
 (check_name_camel, cmake_lists))
-return 1
+  return 1
 
-  modulecpp = filter(
-  lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
-  os.listdir(old_module_path))[0]
-  deleteMatchingLines(os.path.join(old_module_path, modulecpp),
+modulecpp = filter(
+lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
+os.listdir(old_module_path))[0]
+deleteMatchingLines(os.path.join(old_module_path, modulecpp),
   '\\b' + check_name_camel + '|\\b' + args.old_check_name)
 
   for filename in getListOfFiles(clang_tidy_path):
@@ -249,14 +264,21 @@
   new_module + '/' + new_check_name_camel)
 replaceInFile(filename, check_name_camel, new_check_name_camel)
 
-  if old_module != new_module:
+  if old_module != new_module or new_module == 'llvm' or new_module == 'clang':
+if new_module == 'llvm' or new_module -- 'clang':
+  new_namespace = new_module + '_check'
+else:
+  new_namespace = new_module
 check_implementation_files = glob.glob(
 os.path.join(old_module_path, new_check_name_camel + '*'))
 for filename in check_implementation_files:
   # Move check implementation to the directory of the new module.
   filename = fileRename(filename, old_module_path, new_module_path)
-  replaceInFile(filename, 'namespace ' + old_module,
-'namespace ' + new_module)
+  replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
+ 'namespace ' + new_namespace)
+
+  if (args.old_check_name == args.new_check_name):
+return
 
   # Add check to the new module.
   adapt_cmake(new_module_path, new_check_name_camel)
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.h
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.h
+++ 

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-04-15 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D56571#1467358 , @craig.topper 
wrote:

> I think things don't work right unless you disable the integrated assembler. 
> I'm not sure why though.


Using `-no-integrated-as` does allow it to compile, but it doesn't link (with 
ld.lld) if LTO is specified. Is there an equivalent flag / plugin-opt for lld?


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

https://reviews.llvm.org/D56571



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


[PATCH] D59806: [clang-tidy] Add a check for [super self] in initializers 

2019-04-15 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added inline comments.



Comment at: clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp:57
+/// \endcode
+AST_MATCHER_P(ObjCImplementationDecl, isSubclassOf,
+  ast_matchers::internal::Matcher,

stephanemoore wrote:
> aaron.ballman wrote:
> > This matcher seems like it would be generally useful -- would you mind 
> > adding it to the AST matcher interface rather than local to this check? It 
> > doesn't have to be done as part of this patch (we can leave the matcher 
> > here for the moment).
> Definitely agreed. I will send out a followup for a new AST matcher.
Sent out https://reviews.llvm.org/D60543.



Comment at: clang-tools-extra/test/clang-tidy/objc-super-self.m:41
+  INITIALIZER_IMPL();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: suspicious invocation of 'self' in 
initializer; did you mean to invoke a superclass initializer? [objc-super-self]
+}

aaron.ballman wrote:
> stephanemoore wrote:
> > aaron.ballman wrote:
> > > Are you missing a `CHECK-FIXES` here?
> > > 
> > > Personally, I don't think we should try to generate a fixit for this 
> > > case, so I would expect a CHECK-FIXES that ensures this doesn't get 
> > > modified.
> > No fix is currently generated for this case which is why there is no 
> > `CHECK-FIXES`. I also agree that no fix should be generated for this case.
> > 
> > I must confess that I have yet to fully understand why the fix for this 
> > case is discarded (though I am grateful for the behavior). Let me dig 
> > around to try to better understand why no fixit is generated for this case 
> > and assess adding a condition for emitting the fixit.
> Our typical way to check that a fix is not applied is to use `// CHECK-FIXES: 
> ` to test that the fix was not applied.
Gotcha. Added `CHECK-FIXES` to verify original code is preserved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59806



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


r358464 - DebugInfo: Default to standalone debug when tuning for LLDB

2019-04-15 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Apr 15 17:16:29 2019
New Revision: 358464

URL: http://llvm.org/viewvc/llvm-project?rev=358464=rev
Log:
DebugInfo: Default to standalone debug when tuning for LLDB

LLDB can't currently handle Clang's default (limit/no-standalone) DWARF,
so platforms that default to LLDB (Darwin) or anyone else manually
requesting LLDB tuning, should also get standalone DWARF.

That doesn't mean a user can't explicitly enable (because they have
other reasons to prefer standalone DWARF (such as that they're only
building half their application with debug info enabled, and half
without - or because they're tuning for GDB, but want to be able to use
it under LLDB too (this is the default on FreeBSD))) or disable (testing
LLDB fixes/improvements that handle no-standalone mode, building C code,
perhaps, which wouldn't have the LLDB<>no-standalone conflict, etc) the
feature regardless of the tuning.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=358464=358463=358464=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Apr 15 17:16:29 2019
@@ -3295,9 +3295,10 @@ static void RenderDebugOptions(const Too
   // figure out if we need to "upgrade" it to standalone debug info.
   // We parse these two '-f' options whether or not they will be used,
   // to claim them even if you wrote "-fstandalone-debug -gline-tables-only"
-  bool NeedFullDebug = Args.hasFlag(options::OPT_fstandalone_debug,
-options::OPT_fno_standalone_debug,
-TC.GetDefaultStandaloneDebug());
+  bool NeedFullDebug = Args.hasFlag(
+  options::OPT_fstandalone_debug, options::OPT_fno_standalone_debug,
+  DebuggerTuning == llvm::DebuggerKind::LLDB ||
+  TC.GetDefaultStandaloneDebug());
   if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug))
 (void)checkDebugInfoOption(A, Args, D, TC);
   if (DebugInfoKind == codegenoptions::LimitedDebugInfo && NeedFullDebug)

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=358464=358463=358464=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Mon Apr 15 17:16:29 2019
@@ -3,26 +3,26 @@
 
 // Linux.
 // RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
+// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
 // RUN: %clang -### -c -g2 %s -target x86_64-linux-gnu 2>&1 \
-// RUN: | FileCheck -check-prefix=G %s
+// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
 // RUN: %clang -### -c -g3 %s -target x86_64-linux-gnu 2>&1 \
-// RUN: | FileCheck -check-prefix=G %s
+// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
 // RUN: %clang -### -c -ggdb %s -target x86_64-linux-gnu 2>&1 \
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
+// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
 // RUN: %clang -### -c -ggdb1 %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_GDB %s
 // RUN: %clang -### -c -ggdb3 %s -target x86_64-linux-gnu 2>&1 \
-// RUN: | FileCheck -check-prefix=G %s
+// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
+// RUN: | FileCheck -check-prefix=G_STANDALONE 
-check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_SCE %s
 
 // Android.
 // Android should always generate DWARF4.
 // RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
+// RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DWARF4 
%s
 
 // Darwin.
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin14 2>&1 \
@@ -231,9 +231,6 @@
 // RUN: %clang -### -target %itanium_abi_triple -gmodules 
-gline-directives-only %s 2>&1 \
 // RUN:| FileCheck -check-prefix=GLIO_ONLY %s
 //
-// G: "-cc1"
-// G: "-debug-info-kind=limited"
-//
 // NOG_PS4: "-cc1"
 // NOG_PS4-NOT "-dwarf-version=
 // NOG_PS4: "-generate-arange-section"
@@ -277,6 +274,8 @@
 //
 // 

[PATCH] D60739: [analyzer] NFC: Re-use reusable unittest mocks.

2019-04-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.
Herald added a project: clang.

Put them into a dedicated header, as i'm about to write my second unittest.


Repository:
  rC Clang

https://reviews.llvm.org/D60739

Files:
  clang/unittests/StaticAnalyzer/Reusables.h
  clang/unittests/StaticAnalyzer/SymbolReaperTest.cpp

Index: clang/unittests/StaticAnalyzer/SymbolReaperTest.cpp
===
--- clang/unittests/StaticAnalyzer/SymbolReaperTest.cpp
+++ clang/unittests/StaticAnalyzer/SymbolReaperTest.cpp
@@ -6,13 +6,8 @@
 //
 //===--===//
 
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
-#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
-#include "clang/CrossTU/CrossTranslationUnit.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
-#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#include "Reusables.h"
+
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
 
@@ -20,50 +15,6 @@
 namespace ento {
 namespace {
 
-using namespace ast_matchers;
-
-// A re-usable consumer that constructs ExprEngine out of CompilerInvocation.
-// TODO: Actually re-use it when we write our second test.
-class ExprEngineConsumer : public ASTConsumer {
-protected:
-  CompilerInstance 
-
-private:
-  // We need to construct all of these in order to construct ExprEngine.
-  CheckerManager ChkMgr;
-  cross_tu::CrossTranslationUnitContext CTU;
-  PathDiagnosticConsumers Consumers;
-  AnalysisManager AMgr;
-  SetOfConstDecls VisitedCallees;
-  FunctionSummariesTy FS;
-
-protected:
-  ExprEngine Eng;
-
-  // Find a declaration in the current AST by name. This has nothing to do
-  // with ExprEngine but turns out to be handy.
-  // TODO: There's probably a better place for it.
-  template 
-  const T *findDeclByName(const Decl *Where, StringRef Name) {
-auto Matcher = decl(hasDescendant(namedDecl(hasName(Name)).bind("d")));
-auto Matches = match(Matcher, *Where, Eng.getContext());
-assert(Matches.size() == 1 && "Ambiguous name!");
-const T *Node = selectFirst("d", Matches);
-assert(Node && "Name not found!");
-return Node;
-  }
-
-public:
-  ExprEngineConsumer(CompilerInstance )
-  : C(C), ChkMgr(C.getASTContext(), *C.getAnalyzerOpts()), CTU(C),
-Consumers(),
-AMgr(C.getASTContext(), C.getDiagnostics(), Consumers,
- CreateRegionStoreManager, CreateRangeConstraintManager, ,
- *C.getAnalyzerOpts()),
-VisitedCallees(), FS(),
-Eng(CTU, AMgr, , , ExprEngine::Inline_Regular) {}
-};
-
 class SuperRegionLivenessConsumer : public ExprEngineConsumer {
   void performTest(const Decl *D) {
 const auto *FD = findDeclByName(D, "x");
@@ -99,7 +50,7 @@
   }
 };
 
-class SuperRegionLivenessAction: public ASTFrontendAction {
+class SuperRegionLivenessAction : public ASTFrontendAction {
 public:
   SuperRegionLivenessAction() {}
   std::unique_ptr CreateASTConsumer(CompilerInstance ,
Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -0,0 +1,58 @@
+//===- unittests/StaticAnalyzer/Reusables.h ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+namespace clang {
+namespace ento {
+
+// Find a declaration in the current AST by name.
+template 
+const T *findDeclByName(const Decl *Where, StringRef Name) {
+  using namespace ast_matchers;
+  auto Matcher = decl(hasDescendant(namedDecl(hasName(Name)).bind("d")));
+  auto Matches = match(Matcher, *Where, Where->getASTContext());
+  assert(Matches.size() == 1 && "Ambiguous name!");
+  const T *Node = selectFirst("d", Matches);
+  assert(Node && "Name not found!");
+  return Node;
+}
+
+// A re-usable consumer that constructs ExprEngine out of CompilerInvocation.
+class ExprEngineConsumer : public ASTConsumer {
+protected:
+  CompilerInstance 
+
+private:
+  // We need to construct all of these in order to construct ExprEngine.
+  CheckerManager ChkMgr;
+  cross_tu::CrossTranslationUnitContext CTU;
+  PathDiagnosticConsumers Consumers;
+  AnalysisManager AMgr;
+  

[PATCH] D60736: [Sema][ObjC] Don't warn about a block implicitly retaining self if the block is marked noescape

2019-04-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Akira and I were just talking about an alternative approach to this: Keep a 
vector of pairs of BlockDecls and SourceLocations in the enclosing method's 
FunctionScopeInfo, and emit any unsuppressed  diagnostics when popping the 
method. This would avoid having to traverse all the blocks in methods in ARC 
mode, at the cost of a small amount of memory.




Comment at: lib/Sema/Sema.cpp:1682-1687
+  void VisitBlockDecl(const BlockDecl *BD) {
+bool OldVisitingEscapingBlock = VisitingEscapingBlock;
+VisitingEscapingBlock = VisitingEscapingBlock || !BD->doesNotEscape();
+Visit(BD->getBody());
+VisitingEscapingBlock = OldVisitingEscapingBlock;
+  }

Maybe call this "diagnoseBlockDecl" or something so it doesn't sounds like a 
CRTP-overridden method.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60736



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


r358463 - Simplify diagnosis of misplaced attributes in module-declarations.

2019-04-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 15 16:55:58 2019
New Revision: 358463

URL: http://llvm.org/viewvc/llvm-project?rev=358463=rev
Log:
Simplify diagnosis of misplaced attributes in module-declarations.

No functional change intended.

Modified:
cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=358463=358462=358463=diff
==
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Apr 15 16:55:58 2019
@@ -2170,8 +2170,8 @@ Parser::DeclGroupPtrTy Parser::ParseModu
   SourceLocation ModuleLoc = ConsumeToken();
 
   // Attributes appear after the module name, not before.
-  if (Tok.is(tok::l_square))
-CheckProhibitedCXX11Attribute();
+  // FIXME: Suggest moving the attributes later with a fixit.
+  DiagnoseAndSkipCXX11Attributes();
 
   // Parse a global-module-fragment, if present.
   if (getLangOpts().CPlusPlusModules && Tok.is(tok::semi)) {
@@ -2197,8 +2197,7 @@ Parser::DeclGroupPtrTy Parser::ParseModu
 }
 ConsumeToken();
 SourceLocation PrivateLoc = ConsumeToken();
-if (Tok.is(tok::l_square))
-  CheckProhibitedCXX11Attribute();
+DiagnoseAndSkipCXX11Attributes();
 ExpectAndConsumeSemi(diag::err_private_module_fragment_expected_semi);
 return Actions.ActOnPrivateModuleFragmentDecl(ModuleLoc, PrivateLoc);
   }


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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 195270.
hintonda added a comment.

- Alphabetize registration calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802

Files:
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
  clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvm-prefer-isa-or-dyn-cast-in-conditionals.rst
  
clang-tools-extra/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp

Index: clang-tools-extra/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp
@@ -0,0 +1,132 @@
+// RUN: %check_clang_tidy %s llvm-prefer-isa-or-dyn-cast-in-conditionals %t
+
+struct X;
+struct Y;
+struct Z {
+  int foo();
+  X *bar();
+  X *cast(Y*);
+  bool baz(Y*);
+};
+
+template 
+bool isa(Y *);
+template 
+X *cast(Y *);
+template 
+X *dyn_cast(Y *);
+template 
+X *dyn_cast_or_null(Y *);
+
+bool foo(Y *y, Z *z) {
+  if (auto x = cast(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: cast<> in conditional will assert rather than return a null pointer [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (auto x = dyn_cast(y))
+
+  while (auto x = cast(y))
+break;
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: cast<> in conditional
+  // CHECK-FIXES: while (auto x = dyn_cast(y))
+
+  if (cast(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: cast<> in conditional
+  // CHECK-FIXES: if (isa(y))
+
+  while (cast(y))
+break;
+  // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: cast<> in conditional
+  // CHECK-FIXES: while (isa(y))
+
+  do {
+break;
+  } while (cast(y));
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: cast<> in conditional
+  // CHECK-FIXES: while (isa(y));
+
+  if (dyn_cast(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: return value from dyn_cast<> not used [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (isa(y))
+
+  while (dyn_cast(y))
+break;
+  // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: return value from dyn_cast<> not used
+  // CHECK-FIXES: while (isa(y))
+
+  do {
+break;
+  } while (dyn_cast(y));
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: return value from dyn_cast<> not used
+  // CHECK-FIXES: while (isa(y));
+
+  if (y && isa(y))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (isa_and_nonnull(y))
+
+  if (z->bar() && isa(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning:  isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  if (z->bar() && cast(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  if (z->bar() && dyn_cast(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  if (z->bar() && dyn_cast_or_null(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+
+  bool b = z->bar() && cast(z->bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: isa_and_nonnull<> is preferred
+  // CHECK-FIXES: bool b = isa_and_nonnull(z->bar());
+
+  // These don't trigger a warning.
+  if (auto x = cast(y)->foo())
+return true;
+  if (auto x = z->cast(y))
+return true;
+  while (auto x = cast(y)->foo())
+break;
+  if (cast(y)->foo())
+return true;
+  if (z->cast(y))
+return true;
+  while (cast(y)->foo())
+break;
+  if (y && cast(z->bar()))
+return true;
+  if (z && cast(y)->foo())
+return true;
+  bool b2 = y && cast(z);
+  if(z->cast(y))
+return true;
+  if (z->baz(cast(z)))
+return true;
+
+#define CAST(T, Obj) cast(Obj)
+#define AUTO_VAR_CAST(X, Y, Z) auto X = cast(Z)
+#define ISA(T, Obj) isa(Obj)
+#define ISA_OR_NULL(T, Obj) Obj &(Obj)
+
+  // Macros don't trigger warning.
+  if (auto x = CAST(X, y))
+return true;
+  if (AUTO_VAR_CAST(x, X, z))
+return true;
+  if (z->bar() && ISA(Y, z->bar()))
+return true;
+  if (ISA_OR_NULL(Y, z->bar()))
+return true;
+
+  return false;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/llvm-prefer-isa-or-dyn-cast-in-conditionals.rst

[PATCH] D60736: [Sema][ObjC] Don't warn about a block implicitly retaining self if the block is marked noescape

2019-04-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Sorry, clang was failing to diagnose `self` referenced inside a c++ lambda that 
was nested inside a block.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60736



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


[PATCH] D60674: [X86] Restore the pavg intrinsics.

2019-04-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Okay, thanks.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60674



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


[PATCH] D60543: [clang] Add matcher for subclasses of Objective-C interfaces 

2019-04-15 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore planned changes to this revision.
stephanemoore added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:1479
+/// \endcode
+AST_MATCHER_P(ObjCInterfaceDecl, isSubclassOfInterface,
+  internal::Matcher,

aaron.ballman wrote:
> stephanemoore wrote:
> > I am still uncertain about the naming.
> > 
> > `isSubclassOf` seemed too generic as that could apply to C++ classes.
> > `objcIsSubclassOf` seemed unconventional as a matcher name.
> > `isSubclassOfObjCInterface` and `isSubclassOfObjCClass` seemed awkwardly 
> > lengthy.
> > Creating a new namespace `clang::ast_matchers::objc` seemed unprecedented.
> > 
> > I am happy to change the name if you think another name would be more 
> > appropriate.
> Does ObjC use the term "derived" by any chance? We already have 
> `isDerivedFrom`, so I'm wondering if we can use that to also match on an 
> `ObjCInterfaceDecl`?
Objective-C doesn't generally use the term "derived" (for example, see archive 
of [Programming With Objective-C > Defining 
Classes](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/DefiningClasses/DefiningClasses.html#//apple_ref/doc/uid/TP40011210-CH3-SW1)).
 With that said, I don't think it's unreasonable or incorrect to use the term 
"derived" to describe inheritance in Objective-C. The behavior of this matcher 
is also consistent with the behavior of `isDerivedFrom`. In order to change 
`isDerivedFrom`, I would also need to update `isSameOrDerivedFrom`. That would 
probably be a good thing so that derivation matching feature set is consistent 
for C++ and Objective-C language variants.

Let me take a crack at merging this into `isDerivedFrom`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543



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


[PATCH] D40381: Parse concept definition

2019-04-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks!

Please revert the (presumably unintended) mode changes to the `ptxas` 
executables.




Comment at: include/clang/AST/DeclTemplate.h:3035
+  SourceRange getSourceRange() const override LLVM_READONLY {
+return SourceRange(getLocation(), getLocation());
+  }

saar.raz wrote:
> rsmith wrote:
> > faisalv wrote:
> > > why not just fix it now?
> > >   return SourceRange(getTemplateParameters()->getTemplateLoc(), 
> > > ConstraintExpr->getLocEnd(); 
> > > 
> > > ?
> > There's a bigger problem here:
> > 
> > ```
> > TemplateDecl *TD = /*some ConceptDecl*/;
> > auto SR = TD->getSourceRange(); // crash
> > ```
> > 
> > `TemplateDecl` has a hard assumption that it contains a `TemplatedDecl`. 
> > So, three options:
> > 
> > 1) Change `TemplateDecl` and all its users to remove this assumption (hard 
> > and leads to an awkward-to-use AST)
> > 2) Add a `Decl` subclass that acts as the templated declaration in a 
> > concept declaration (corresponding to the C++ grammar's 
> > //concept-definition// production)
> > 3) Make `ConceptDecl` //not// derive from a `TemplateDecl` at all
> > 
> > I think option 2 is my preference, but option 3 is also somewhat appealing 
> > (there are other ways in which a concept is not a template: for instance, 
> > it cannot be constrained, and it cannot be classified as either a type 
> > template or a non-type template, because its kind depends on the context in 
> > which it appears).
> > 
> > Of course, this leads to one of the Hard Problems Of Computer Science: 
> > naming things. `ConceptDecl` for a //concept-definition// and 
> > `ConceptTemplateDecl` for the //template-head concept-definition// would be 
> > consistent with the rest of the AST. It's a little unfortunate for the 
> > longer name to be the AST node that we actually interact with, but the 
> > consistency is probably worth the cost.
> The dummy decl is pretty confusing and will be a very weird decl in and of 
> itself. I can't think of a good name right now, but your proposed naming will 
> be pretty confusing given that a ConceptTemplateDecl does not template a 
> concept declaration given the meaning of the phrase in the standard... Maybe 
> ConceptBodyDecl? ConceptDummyDecl? ConceptDefinitionDecl? We need something 
> that screams "this is not interesting" for the AST usage to be reasonable. 
> Option 3 feels like loads of code duplication.
> I'm not entirely sure how many blind (through TemplateDecl) uses of 
> getTemplatedDecl there are, but there might not be that many, in which case 
> the first option might be the lesser of all these evils.
Faisal's comment is marked "Done" but not done.

`ConceptBodyDecl` or something like it seems reasonable. But I think we can 
consider that after landing this patch, and leave the templated declaration 
null for now.



Comment at: include/clang/AST/DeclTemplate.h:3016
+// \brief Declaration of a C++2a concept.
+class ConceptDecl : public TemplateDecl {
+protected:

This should also derive from `Mergeable`, since we are permitted 
to merge multiple definitions of the same concept across translation units by 
C++20 [basic.def.odr]/12.



Comment at: include/clang/Basic/DiagnosticParseKinds.td:1260-1270
+
+def err_concept_definition_unexpected_scope_spec : Error<
+  "unexpected namespace scope before concept name; concepts must be defined "
+  "inside their namespace, if any">;
+
+def err_concept_definition_not_identifier : Error<
+  "name defined in concept definition must be an identifier">;

Generally we don't leave blank lines between diagnostic definitions, and 
instead use the continuation indent to visually separate them.



Comment at: include/clang/Basic/DiagnosticParseKinds.td:1261-1263
+def err_concept_definition_unexpected_scope_spec : Error<
+  "unexpected namespace scope before concept name; concepts must be defined "
+  "inside their namespace, if any">;

The phrasing of this (particularly the "if any") is a little confusing. I think 
it's fine to just use the `err_concept_definition_not_identifier` diagnostic 
for this case.



Comment at: include/clang/Basic/DiagnosticParseKinds.td:1269
+def err_concept_legacy_bool_keyword : Error<
+  "'bool' keyword after 'concept' is no longer valid in C++2a; remove it">;
+

I'd probably phrase this as

"ISO C++2a does not permit the 'bool' keyword after 'concept'"

(The Concepts TS isn't really the past -- TSes are more like an alternative 
reality -- so "no longer" is a bit odd.) I'd also be tempted to turn this into 
an `ExtWarn` so that we can accept code targeting the Concepts TS with a 
warning.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2443
+  "concept template parameter list must have at least one parameter; explicit "
+  "specialization of concepts is not allowed, did you attempt this?">;

[PATCH] D60735: [FileSystemStatCache] Return std::error_code from stat cache methods

2019-04-15 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

LGTM, but I'd appreciate someone who has worked on this more recently taking a 
look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60735



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


[PATCH] D60736: [Sema][ObjC] Don't warn about a block implicitly retaining self if the block is marked noescape

2019-04-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, erik.pilkington, arphaman.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

If the block implicitly referencing `self` doesn't escape, there is no risk of 
creating retain cycles, so clang shouldn't diagnose it and force users to add 
`self->` to silence the diagnostic.

Also, fix a bug where clang was failing to diagnose `self` referenced inside a 
block that was nested inside a c++ lambda.

rdar://problem/25059955


Repository:
  rC Clang

https://reviews.llvm.org/D60736

Files:
  include/clang/Sema/ScopeInfo.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  test/SemaObjC/warn-implicit-self-in-block.m
  test/SemaObjCXX/warn-implicit-self-in-block.mm

Index: test/SemaObjCXX/warn-implicit-self-in-block.mm
===
--- /dev/null
+++ test/SemaObjCXX/warn-implicit-self-in-block.mm
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fobjc-arc -fblocks -Wimplicit-retain-self -verify %s
+// rdar://11194874
+
+typedef void (^BlockTy)();
+
+void noescapeFunc(__attribute__((noescape)) BlockTy);
+void escapeFunc(BlockTy);
+
+@interface Root @end
+
+@interface I : Root
+{
+  int _bar;
+}
+@end
+
+@implementation I
+  - (void)foo{
+  ^{
+   _bar = 3; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}
+   }();
+  }
+
+  - (void)testNested{
+noescapeFunc(^{
+  (void)_bar;
+  escapeFunc(^{
+(void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}
+noescapeFunc(^{
+  (void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}
+});
+(void)_bar; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}
+  });
+  (void)_bar;
+});
+  }
+
+  - (void)testLambdaInBlock{
+noescapeFunc(^{ [&](){ (void)_bar; }(); });
+escapeFunc(^{ [&](){ (void)_bar; }(); }); // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}
+  }
+@end
Index: test/SemaObjC/warn-implicit-self-in-block.m
===
--- test/SemaObjC/warn-implicit-self-in-block.m
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -x objective-c -fobjc-arc -fblocks -Wimplicit-retain-self -verify %s
-// rdar://11194874
-
-@interface Root @end
-
-@interface I : Root
-{
-  int _bar;
-}
-@end
-
-@implementation I
-  - (void)foo{
-  ^{
-   _bar = 3; // expected-warning {{block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior}}
-   }();
-  }
-@end
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -2575,11 +2575,6 @@
 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
   getCurFunction()->recordUseOfWeak(Result);
   }
-  if (getLangOpts().ObjCAutoRefCount) {
-if (CurContext->isClosure())
-  Diag(Loc, diag::warn_implicitly_retains_self)
-<< FixItHint::CreateInsertion(Loc, "self->");
-  }
 
   return Result;
 }
@@ -13652,6 +13647,9 @@
 }
   }
 
+  if (getCurFunction())
+getCurFunction()->addBlock(Block, /*IsIntroducedInCurrentScope*/true);
+
   PushBlockScope(CurScope, Block);
   CurContext->addDecl(Block);
   if (CurScope)
@@ -13913,9 +13911,6 @@
 }
   }
 
-  if (getCurFunction())
-getCurFunction()->addBlock(BD);
-
   return Result;
 }
 
Index: lib/Sema/SemaDeclObjC.cpp
===
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -378,6 +378,7 @@
   // Allow all of Sema to see that we are entering a method definition.
   PushDeclContext(FnBodyScope, MDecl);
   PushFunctionScope();
+  getCurFunction()->setIsObjCMethod();
 
   // Create Decl objects for each parameter, entrring them in the scope for
   // binding to their use.
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/AST/StmtCXX.h"
+#include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/TargetInfo.h"
@@ -1636,10 +1637,16 @@
 static void markEscapingByrefs(const FunctionScopeInfo , Sema ) {
   // Set the EscapingByref flag of __block variables captured by
   // escaping blocks.
-  for (const BlockDecl *BD : FSI.Blocks) {
-if (BD->doesNotEscape())
+ 

[PATCH] D60735: [FileSystemStatCache] Return std::error_code from stat cache methods

2019-04-15 Thread Harlan Haskins via Phabricator via cfe-commits
harlanhaskins created this revision.
harlanhaskins added a reviewer: benlangmuir.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Previously, we would return true/false signifying if the cache/lookup
succeeded or failed. Instead, provide clients with the underlying error
that was thrown while attempting to look up in the cache.

Since clang::FileManager doesn't make use of this information, it discards the
error that's received and casts away to bool.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60735

Files:
  clang/include/clang/Basic/FileSystemStatCache.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/FileSystemStatCache.cpp

Index: clang/lib/Basic/FileSystemStatCache.cpp
===
--- clang/lib/Basic/FileSystemStatCache.cpp
+++ clang/lib/Basic/FileSystemStatCache.cpp
@@ -30,25 +30,24 @@
 /// success for directories (not files).  On a successful file lookup, the
 /// implementation can optionally fill in FileDescriptor with a valid
 /// descriptor and the client guarantees that it will close it.
-bool FileSystemStatCache::get(StringRef Path, llvm::vfs::Status ,
-  bool isFile,
-  std::unique_ptr *F,
-  FileSystemStatCache *Cache,
-  llvm::vfs::FileSystem ) {
-  LookupResult R;
+std::error_code
+FileSystemStatCache::get(StringRef Path, llvm::vfs::Status ,
+ bool isFile, std::unique_ptr *F,
+ FileSystemStatCache *Cache,
+ llvm::vfs::FileSystem ) {
   bool isForDir = !isFile;
+  std::error_code RetCode;
 
   // If we have a cache, use it to resolve the stat query.
   if (Cache)
-R = Cache->getStat(Path, Status, isFile, F, FS);
+RetCode = Cache->getStat(Path, Status, isFile, F, FS);
   else if (isForDir || !F) {
 // If this is a directory or a file descriptor is not needed and we have
 // no cache, just go to the file system.
 llvm::ErrorOr StatusOrErr = FS.status(Path);
 if (!StatusOrErr) {
-  R = CacheMissing;
+  RetCode = StatusOrErr.getError();
 } else {
-  R = CacheExists;
   Status = *StatusOrErr;
 }
   } else {
@@ -63,27 +62,27 @@
 
 if (!OwnedFile) {
   // If the open fails, our "stat" fails.
-  R = CacheMissing;
+  RetCode = OwnedFile.getError();
 } else {
   // Otherwise, the open succeeded.  Do an fstat to get the information
   // about the file.  We'll end up returning the open file descriptor to the
   // client to do what they please with it.
   llvm::ErrorOr StatusOrErr = (*OwnedFile)->status();
   if (StatusOrErr) {
-R = CacheExists;
 Status = *StatusOrErr;
 *F = std::move(*OwnedFile);
   } else {
 // fstat rarely fails.  If it does, claim the initial open didn't
 // succeed.
-R = CacheMissing;
 *F = nullptr;
+RetCode = StatusOrErr.getError();
   }
 }
   }
 
   // If the path doesn't exist, return failure.
-  if (R == CacheMissing) return true;
+  if (RetCode)
+return RetCode;
 
   // If the path exists, make sure that its "directoryness" matches the clients
   // demands.
@@ -91,29 +90,31 @@
 // If not, close the file if opened.
 if (F)
   *F = nullptr;
-
-return true;
+return std::make_error_code(
+Status.isDirectory() ?
+std::errc::is_a_directory : std::errc::not_a_directory);
   }
 
-  return false;
+  return std::error_code();
 }
 
-MemorizeStatCalls::LookupResult
+std::error_code
 MemorizeStatCalls::getStat(StringRef Path, llvm::vfs::Status ,
bool isFile,
std::unique_ptr *F,
llvm::vfs::FileSystem ) {
-  if (get(Path, Status, isFile, F, nullptr, FS)) {
+  auto err = get(Path, Status, isFile, F, nullptr, FS);
+  if (err) {
 // Do not cache failed stats, it is easy to construct common inconsistent
 // situations if we do, and they are not important for PCH performance
 // (which currently only needs the stats to construct the initial
 // FileManager entries).
-return CacheMissing;
+return err;
   }
 
   // Cache file 'stat' results and directories with absolutely paths.
   if (!Status.isDirectory() || llvm::sys::path::is_absolute(Path))
 StatCalls[Path] = Status;
 
-  return CacheExists;
+  return std::error_code();
 }
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -429,13 +429,14 @@
   // FIXME: FileSystemOpts shouldn't be passed in here, all paths should be
   // absolute!
   if (FileSystemOpts.WorkingDir.empty())
-return FileSystemStatCache::get(Path, Status, isFile, F,StatCache.get(), *FS);
+return 

[PATCH] D60732: [analyzer] NFC: Use -verify=... in MoveChecker tests.

2019-04-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

This is also very useful to test that a given warning is only emitted in c++xx. 
Funnily when grepping for `verify=` in `test/` most matches are from tests 
exercising this functionality.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60732



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


[PATCH] D60732: [analyzer] NFC: Use -verify=... in MoveChecker tests.

2019-04-15 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added a comment.
This revision is now accepted and ready to land.

I think this functionality is unused because you would split the file into six 
to reduce the overhead/scroll and that is it.

It is a cool reveal, could you provide a documentation?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60732



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


[PATCH] D60732: [analyzer] NFC: Use -verify=... in MoveChecker tests.

2019-04-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso, jdenny.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.
Herald added a project: clang.

Just wanted to give a bit more visibility to the underrated technology of 
writing `-verify=a,b,c` instead of the `#ifdef`clutter.

It's also a bit wonky because it seems that you have to write an exponential 
number of flags to verify in order to have full flexibility (which is why i 
didn't update the `#ifdef DFS` test), but it still seems to be much better in 
most cases.


Repository:
  rC Clang

https://reviews.llvm.org/D60732

Files:
  clang/test/Analysis/use-after-move.cpp

Index: clang/test/Analysis/use-after-move.cpp
===
--- clang/test/Analysis/use-after-move.cpp
+++ clang/test/Analysis/use-after-move.cpp
@@ -1,31 +1,37 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
-// RUN:  -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
+// RUN:  -analyzer-checker debug.ExprInspection\
+// RUN:  -verify=expected,peaceful,non-aggressive
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
-// RUN:  -analyzer-config exploration_strategy=dfs -DDFS=1\
-// RUN:  -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
+// RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
+// RUN:  -analyzer-checker debug.ExprInspection\
+// RUN:  -verify=expected,peaceful,non-aggressive
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
-// RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly -DPEACEFUL\
-// RUN:  -analyzer-checker debug.ExprInspection
+// RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly\
+// RUN:  -analyzer-checker debug.ExprInspection\
+// RUN:  -verify=expected,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
-// RUN:  -analyzer-config exploration_strategy=dfs -DDFS=1\
-// RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly -DPEACEFUL\
-// RUN:  -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
+// RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
+// RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly\
+// RUN:  -analyzer-checker debug.ExprInspection\
+// RUN:  -verify=expected,non-aggressive
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
-// RUN:  -analyzer-config cplusplus.Move:WarnOn=All -DAGGRESSIVE\
-// RUN:  -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
+// RUN:  -analyzer-config cplusplus.Move:WarnOn=All\
+// RUN:  -analyzer-checker debug.ExprInspection\
+// RUN:  -verify=expected,peaceful,aggressive
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
-// RUN:  -analyzer-config exploration_strategy=dfs -DDFS=1\
-// RUN:  -analyzer-config cplusplus.Move:WarnOn=All -DAGGRESSIVE\
-// RUN:  -analyzer-checker debug.ExprInspection
+// RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
+// RUN:  -analyzer-config cplusplus.Move:WarnOn=All\
+// RUN:  -analyzer-checker debug.ExprInspection\
+// RUN:  -verify=expected,peaceful,aggressive
 
 // RUN: not %clang_analyze_cc1 -verify %s \
 // RUN:   -analyzer-checker=core \
@@ -75,10 +81,7 @@
 moveconstruct(std::move(*a));
   }
   A(const A ) : i(other.i), d(other.d), b(other.b) {}
-  A(A &) : i(other.i), d(other.d), b(std::move(other.b)) {
-#ifdef AGGRESSIVE
-// expected-note@-2{{Object 'b' is moved}}
-#endif
+  A(A &) : i(other.i), d(other.d), b(std::move(other.b)) { // aggressive-note{{Object 'b' is moved}}
   }
   A(A &, char *k) {
 moveconstruct(std::move(other));
@@ -141,33 +144,21 @@
 void simpleMoveCtorTest() {
   {
 A a;
-A b = std::move(a);
-a.foo();
-#ifndef PEACEFUL
-// expected-note@-3 {{Object 'a' is moved}}
-// expected-warning@-3 {{Method called on moved-from object 'a'}}
-// expected-note@-4{{Method called on moved-from object 'a'}}

[PATCH] D59673: [Driver] Allow setting the DWO name DWARF attribute separately

2019-04-15 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D59673#1465975 , @aaronpuchert 
wrote:

> In D59673#1461983 , @dblaikie wrote:
>
> > Sure, I think the naming's a bit weird (but hard to come up with good names 
> > for any of this)
>
>
> Agreed, `-split-dwarf-output` is pretty clear, but `-split-dwarf-file` could 
> be both the actual filename or the attribute.
>
> There is `test/CodeGen/split-debug-filename.c` checking that we emit 
> `!DICompileUnit({{.*}}, splitDebugFilename: "foo.dwo"` into the IR under some 
> circumstances, but I'm not sure why. It seems to be ignored by `llc`.


For implicit modular debug info I think it probably isn't ignored. See 
DwarfDebug.cpp:~630.

> What's the intended use for this? Your commit message in rC301063 
>  suggests that this is needed for implicit 
> modules. How does this work? I'm asking of course because I'm not sure 
> whether we might need to emit both file names there.

So implicit modules can use a sort of pseudo-split DWARF. The .pcm (module 
file) itself is an object file in this mode - with the split DWARF and a 
section containing the AST bitcode. Then in the normal source files that use 
the .pcm, they get the usual non-split DWARF, plus skeleton CUs that reference 
the .pcm file (& contain some other attributes for regenerating it in case it's 
been cleaned up from the module cache). This is why the file name can be (& has 
to be) passed down through the IR - it /can/ be, because this compilation isn't 
choosing tnhe file name (so there's no issue with the .dwo file name changing 
between IR generation and object generation (as there is with LTO - where the 
compilation doesn't know the final object name, only the linker knows that)) 
and it /must/ be done this way due to multiple skeleton CUs if the main CU 
references multiple .pcm debug info.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59673



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


[PATCH] D60629: [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/add_new_check.py:382
+  if module == 'llvm' or module == 'clang':
+namespace = module + '_checker'
+  else:

aaron.ballman wrote:
> I thought we were going with `llvm_check`?
Just typo on my part.  I the options mentioned before where things like 
`llvm_project` or `llvm_proj`, etc.  I just settled on `llvm_check` because it 
sounded better -- then actually typed `checker`.  

I'll fix it this afternoon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60629



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


[PATCH] D60663: Time profiler: small fixes and optimizations

2019-04-15 Thread Anton Afanasyev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358448: Time profiler: small fixes and optimizations 
(authored by anton-afanasyev, committed by ).
Herald added a subscriber: kristina.

Changed prior to commit:
  https://reviews.llvm.org/D60663?vs=195069=195244#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60663

Files:
  cfe/trunk/tools/driver/cc1_main.cpp
  llvm/trunk/include/llvm/Support/TimeProfiler.h
  llvm/trunk/lib/Support/TimeProfiler.cpp

Index: llvm/trunk/include/llvm/Support/TimeProfiler.h
===
--- llvm/trunk/include/llvm/Support/TimeProfiler.h
+++ llvm/trunk/include/llvm/Support/TimeProfiler.h
@@ -1,9 +1,8 @@
 //===- llvm/Support/TimeProfiler.h - Hierarchical Time Profiler -*- C++ -*-===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===--===//
 
@@ -33,7 +32,7 @@
 /// Write profiling data to output file.
 /// Data produced is JSON, in Chrome "Trace Event" format, see
 /// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
-void timeTraceProfilerWrite(std::unique_ptr );
+void timeTraceProfilerWrite(raw_pwrite_stream );
 
 /// Manually begin a time section, with the given \p Name and \p Detail.
 /// Profiler copies the string data, so the pointers can be given into
@@ -51,6 +50,13 @@
 /// the section; and when it is destroyed, it stops it. If the time profiler
 /// is not initialized, the overhead is a single branch.
 struct TimeTraceScope {
+
+  TimeTraceScope() = delete;
+  TimeTraceScope(const TimeTraceScope &) = delete;
+  TimeTraceScope =(const TimeTraceScope &) = delete;
+  TimeTraceScope(TimeTraceScope &&) = delete;
+  TimeTraceScope =(TimeTraceScope &&) = delete;
+
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (TimeTraceProfilerInstance != nullptr)
   timeTraceProfilerBegin(Name, Detail);
Index: llvm/trunk/lib/Support/TimeProfiler.cpp
===
--- llvm/trunk/lib/Support/TimeProfiler.cpp
+++ llvm/trunk/lib/Support/TimeProfiler.cpp
@@ -1,30 +1,35 @@
 //===-- TimeProfiler.cpp - Hierarchical Time Profiler -===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===--===//
 //
-/// \file Hierarchical time profiler implementation.
+// This file implements hierarchical time profiler.
 //
 //===--===//
 
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include 
 #include 
 #include 
-#include 
 #include 
 
 using namespace std::chrono;
 
 namespace llvm {
 
+static cl::opt TimeTraceGranularity(
+"time-trace-granularity",
+cl::desc(
+"Minimum time granularity (in microseconds) traced by time profiler"),
+cl::init(500));
+
 TimeTraceProfiler *TimeTraceProfilerInstance = nullptr;
 
 static std::string escapeString(StringRef Src) {
@@ -61,18 +66,21 @@
   DurationType Duration;
   std::string Name;
   std::string Detail;
+
+  Entry(time_point &, DurationType &, std::string &,
+std::string &)
+  : Start(std::move(S)), Duration(std::move(D)), Name(std::move(N)),
+Detail(std::move(Dt)){};
 };
 
 struct TimeTraceProfiler {
   TimeTraceProfiler() {
-Stack.reserve(8);
-Entries.reserve(128);
 StartTime = steady_clock::now();
   }
 
   void begin(std::string Name, llvm::function_ref Detail) {
-Entry E = {steady_clock::now(), {}, Name, Detail()};
-Stack.push_back(std::move(E));
+Stack.emplace_back(steady_clock::now(), DurationType{}, std::move(Name),
+   Detail());
   }
 
   void end() {
@@ -80,8 +88,8 @@
 auto  = Stack.back();
 E.Duration = steady_clock::now() - E.Start;
 
-// Only include sections longer than 500us.
-if (duration_cast(E.Duration).count() > 500)
+// Only include sections longer than TimeTraceGranularity msec.
+if (duration_cast(E.Duration).count() > 

[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added a comment.

In D59802#1467363 , @aaron.ballman 
wrote:

> LGTM aside from a nit and the ultimate name for the `isa_and_nonnull<>` API.


Thanks.  I'll ping the list again at the end of the week, then make whatever 
change is necessary.

Btw, the current iteration replaces all `v && isa(v)` instances with 
`isa_and_nonnull(v)`.  Is that still okay, or should it just do method calls?




Comment at: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp:27-28
 CheckFactories.registerCheck("llvm-include-order");
+CheckFactories.registerCheck(
+"llvm-prefer-isa-or-dyn-cast-in-conditionals");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> Please keep this list sorted alphabetically.
I think this is where add_new_check.py put it, but I'll alphabetize.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


r358448 - Time profiler: small fixes and optimizations

2019-04-15 Thread Anton Afanasyev via cfe-commits
Author: anton-afanasyev
Date: Mon Apr 15 14:02:47 2019
New Revision: 358448

URL: http://llvm.org/viewvc/llvm-project?rev=358448=rev
Log:
Time profiler: small fixes and optimizations

Summary: Fixes from Roman's review here: https://reviews.llvm.org/D58675#1465336

Reviewers: lebedev.ri

Subscribers: hiraditya, mgrang, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/tools/driver/cc1_main.cpp

Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=358448=358447=358448=diff
==
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Mon Apr 15 14:02:47 2019
@@ -239,7 +239,7 @@ int cc1_main(ArrayRef Argv
 /*Extension=*/"json",
 /*useTemporary=*/false);
 
-llvm::timeTraceProfilerWrite(profilerOutput);
+llvm::timeTraceProfilerWrite(*profilerOutput);
 llvm::timeTraceProfilerCleanup();
   }
 


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


r358445 - [OPENMP][NVPTX]Run parallel regions with num_threads clauses in SPMD

2019-04-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Apr 15 13:38:10 2019
New Revision: 358445

URL: http://llvm.org/viewvc/llvm-project?rev=358445=rev
Log:
[OPENMP][NVPTX]Run parallel regions with num_threads clauses in SPMD
mode.

After the previous patch with the more correct handling of the number of
threads in parallel regions, the parallel regions with num_threads
clauses can be executed in SPMD mode.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=358445=358444=358445=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Apr 15 13:38:10 2019
@@ -715,12 +715,9 @@ getDataSharingMode(CodeGenModule ) {
 }
 
 /// Check if the parallel directive has an 'if' clause with non-constant or
-/// false condition. Also, check if the number of threads is strictly specified
-/// and run those directives in non-SPMD mode.
-static bool hasParallelIfNumThreadsClause(ASTContext ,
-  const OMPExecutableDirective ) {
-  if (D.hasClausesOfKind())
-return true;
+/// false condition.
+static bool hasParallelIfClause(ASTContext ,
+const OMPExecutableDirective ) {
   for (const auto *C : D.getClausesOfKind()) {
 OpenMPDirectiveKind NameModifier = C->getNameModifier();
 if (NameModifier != OMPD_parallel && NameModifier != OMPD_unknown)
@@ -747,7 +744,7 @@ static bool hasNestedSPMDDirective(ASTCo
 switch (D.getDirectiveKind()) {
 case OMPD_target:
   if (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfNumThreadsClause(Ctx, *NestedDir))
+  !hasParallelIfClause(Ctx, *NestedDir))
 return true;
   if (DKind == OMPD_teams) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers(
@@ -759,14 +756,14 @@ static bool hasNestedSPMDDirective(ASTCo
 dyn_cast_or_null(ChildStmt)) {
   DKind = NND->getDirectiveKind();
   if (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfNumThreadsClause(Ctx, *NND))
+  !hasParallelIfClause(Ctx, *NND))
 return true;
 }
   }
   return false;
 case OMPD_target_teams:
   return isOpenMPParallelDirective(DKind) &&
- !hasParallelIfNumThreadsClause(Ctx, *NestedDir);
+ !hasParallelIfClause(Ctx, *NestedDir);
 case OMPD_target_simd:
 case OMPD_target_parallel:
 case OMPD_target_parallel_for:
@@ -840,7 +837,7 @@ static bool supportsSPMDExecutionMode(AS
   case OMPD_target_parallel_for_simd:
   case OMPD_target_teams_distribute_parallel_for:
   case OMPD_target_teams_distribute_parallel_for_simd:
-return !hasParallelIfNumThreadsClause(Ctx, D);
+return !hasParallelIfClause(Ctx, D);
   case OMPD_target_simd:
   case OMPD_target_teams_distribute:
   case OMPD_target_teams_distribute_simd:

Modified: cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp?rev=358445=358444=358445=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp Mon Apr 15 13:38:10 2019
@@ -5,21 +5,20 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix 
CHECK --check-prefix CHECK-32
 // RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ 
-triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck 
%s --check-prefix CHECK --check-prefix CHECK-32
 // expected-no-diagnostics
+
 #ifndef HEADER
 #define HEADER
 
 // Check that the execution mode of all 7 target regions is set to Generic 
Mode.
 // CHECK-DAG: [[NONSPMD:@.+]] = private unnamed_addr constant %struct.ident_t 
{ i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds
 // CHECK-DAG: [[UNKNOWN:@.+]] = private unnamed_addr constant %struct.ident_t 
{ i32 0, i32 2, i32 2, i32 0, i8* getelementptr inbounds
-// CHECK-DAG: {{@__omp_offloading_.+l59}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l137}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l214}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l324}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l362}}_exec_mode = weak constant i8 1
-// CHECK-DAG: 

[PATCH] D60726: Fixed -Wconversion-null warning in GCC.

2019-04-15 Thread Reuben Thomas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358441: [clang-format] Fix -Wconversion-null warning in GCC 
(authored by reuk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60726?vs=195224=195240#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60726

Files:
  cfe/trunk/unittests/Format/FormatTest.cpp


Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11393,6 +11393,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
@@ -11566,12 +11567,6 @@
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
-  Style.SpaceAfterLogicalNot = false;
-  CHECK_PARSE("SpaceAfterLogicalNot: true", SpaceAfterLogicalNot,
-  true);
-  CHECK_PARSE("SpaceAfterLogicalNot: false", SpaceAfterLogicalNot,
-  false);
-
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);


Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11393,6 +11393,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
@@ -11566,12 +11567,6 @@
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
-  Style.SpaceAfterLogicalNot = false;
-  CHECK_PARSE("SpaceAfterLogicalNot: true", SpaceAfterLogicalNot,
-  true);
-  CHECK_PARSE("SpaceAfterLogicalNot: false", SpaceAfterLogicalNot,
-  false);
-
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r358441 - [clang-format] Fix -Wconversion-null warning in GCC

2019-04-15 Thread Reuben Thomas via cfe-commits
Author: reuk
Date: Mon Apr 15 13:13:20 2019
New Revision: 358441

URL: http://llvm.org/viewvc/llvm-project?rev=358441=rev
Log:
[clang-format] Fix -Wconversion-null warning in GCC

GCC -Wconversion-null warning appeared after 
9a63380260860b657b72f07c4f0e61e382ab934a.
There was a similar problem already in the past:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20131230/096230.html

Patch committed on behalf of @dendibakh

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

Modified:
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=358441=358440=358441=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 15 13:13:20 2019
@@ -11393,6 +11393,7 @@ TEST_F(FormatTest, ParsesConfigurationBo
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
@@ -11566,12 +11567,6 @@ TEST_F(FormatTest, ParsesConfiguration)
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
-  Style.SpaceAfterLogicalNot = false;
-  CHECK_PARSE("SpaceAfterLogicalNot: true", SpaceAfterLogicalNot,
-  true);
-  CHECK_PARSE("SpaceAfterLogicalNot: false", SpaceAfterLogicalNot,
-  false);
-
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);


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


[PATCH] D60629: [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_checker'

2019-04-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

No opposition from me regarding `llvm_check`, though I think `llvm_tidy` might 
also be a reasonable option. I'm a bit less keen on `llvm_checker` as the name, 
but not strongly opposed.




Comment at: clang-tools-extra/clang-tidy/add_new_check.py:382
+  if module == 'llvm' or module == 'clang':
+namespace = module + '_checker'
+  else:

I thought we were going with `llvm_check`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60629



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

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

LGTM aside from a nit and the ultimate name for the `isa_and_nonnull<>` API.




Comment at: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp:27-28
 CheckFactories.registerCheck("llvm-include-order");
+CheckFactories.registerCheck(
+"llvm-prefer-isa-or-dyn-cast-in-conditionals");
 CheckFactories.registerCheck(

Please keep this list sorted alphabetically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


[PATCH] D60674: [X86] Restore the pavg intrinsics.

2019-04-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D60674#1467349 , @efriedma wrote:

> > Though I modified the avx512 intrinsics to not have masking built in.
>
> Do we need autoupgrade support from the old avx512 intrinsics to the new 
> avx512 intrinsics?


Yes, and the code at 1548 in AutoUpgrade.cpp does that. There are existing 
tests in avx512bw-intrinsics-upgrade.ll and avx512bwvl-intrinsics-upgrade.ll 
that were previously testing upgrade from old intrinsics to pure IR that now 
just test old intrinsics to new intrinsics. The codegen is the same so they 
weren't affected by the patch.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60674



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-04-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D56571#1467333 , @void wrote:

> This code:
>
>   ; ModuleID = 'arch_static_branch.bc'
>   source_filename = "arch/x86/entry/vsyscall/vsyscall_64.c"
>   target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>   target triple = "x86_64-grtev4-linux-gnu"
>  
>   %struct.atomic_t = type { i32 }
>   %struct.jump_entry = type { i64, i64, i64 }
>   %struct.tracepoint_func = type { i8*, i8*, i32 }
>   %struct.static_key = type { %struct.atomic_t, %union.anon }
>   %union.anon = type { i64 }
>  
>   @__tracepoint_emulate_vsyscall = external hidden global { i8*, { 
> %struct.atomic_t, { %struct.jump_entry* } }, i32 ()*, void ()*, 
> %struct.tracepoint_func* }, section "__tracepoints", align 8
>  
>   ; Function Attrs: alwaysinline noredzone nounwind sspstrong
>   define zeroext i1 @arch_static_branch(%struct.static_key* nocapture 
> readnone %key, i1 zeroext %branch) {
>   entry:
> callbr void asm sideeffect "1:.byte 
> 0x0f,0x1f,0x44,0x00,0\0A\09.pushsection __jump_table,  \22aw\22 \0A\09 
> .balign 8 \0A\09 .quad 1b, ${2:l}, ${0:c} + ${1:c} \0A\09.popsection \0A\09", 
> "i,i,X,~{dirflag},~{fpsr},~{flags}"(%struct.static_key* bitcast (i32* 
> getelementptr inbounds ({ i8*, { %struct.atomic_t, { %struct.jump_entry* } }, 
> i32 ()*, void ()*, %struct.tracepoint_func* }, { i8*, { %struct.atomic_t, { 
> %struct.j
>   ump_entry* } }, i32 ()*, void ()*, %struct.tracepoint_func* }* 
> @__tracepoint_emulate_vsyscall, i64 0, i32 1, i32 0, i32 0) to 
> %struct.static_key*), i1 false, i8* blockaddress(@arch_static_branch, 
> %return))
> to label %asm.fallthrough [label %return]
>  
>   asm.fallthrough:  ; preds = %entry
> call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
> br label %return
>  
>   return:   ; preds = 
> %asm.fallthrough, %entry
> %retval.0 = phi i1 [ false, %asm.fallthrough ], [ true, %entry ]
> ret i1 %retval.0
>   }
>
>
> gives me this with the asm-goto patches:
>
>   $ clang -o /dev/null arch_static_branch.ll
>   warning: overriding the module target triple with x86_64-unknown-linux-gnu 
> [-Woverride-module]
>   :4:15: error: expected a symbol reference in '.quad' directive
>.quad 1b, "", __tracepoint_emulate_vsyscall+8 + 0 
>^
>   error: cannot compile inline asm
>   1 warning and 1 error generated.
>


I think things don't work right unless you disable the integrated assembler. 
I'm not sure why though.


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

https://reviews.llvm.org/D56571



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


[PATCH] D59924: [PowerPC] [Clang] Port MMX intrinsics and basic test cases to Power

2019-04-15 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision.
jsji added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for porting!


Repository:
  rC Clang

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

https://reviews.llvm.org/D59924



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


[PATCH] D60674: [X86] Restore the pavg intrinsics.

2019-04-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Though I modified the avx512 intrinsics to not have masking built in.

Do we need autoupgrade support from the old avx512 intrinsics to the new avx512 
intrinsics?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60674



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


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:87
+  TextGenerator Replacement;
+  TextGenerator Explanation;
+};

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > ymandel wrote:
> > > > ilya-biryukov wrote:
> > > > > ymandel wrote:
> > > > > > ilya-biryukov wrote:
> > > > > > > I would've expected explanation to be the trait of the rewrite 
> > > > > > > rule, since all changes have to be applied.
> > > > > > > What's the reasoning behind having it at the level of separate 
> > > > > > > changes? How would this explanation be used? For debugging 
> > > > > > > purposes or displaying that to the user?
> > > > > > I think that for most cases, one explanation sufficies for the 
> > > > > > whole transformation. However, there are some tidies that emit 
> > > > > > multiple diagnoses (for example if changing before a declaration 
> > > > > > and a definition).   Would it help if I clarify in the comments?
> > > > > Yeah, absolutely! Please document what it's used for and that would 
> > > > > clear that up for me.
> > > > > I actually thing that explaining every part of the transformation is 
> > > > > probably too complicated, so most of the time you would want to have 
> > > > > an explanation for the `RewriteRule`, not for each individual change.
> > > > > 
> > > > > The other challenge that I see is show to display these explanations 
> > > > > to the user, i.e. how should the clients combine these explanations 
> > > > > in order to get the full one? Should the `RewriteRule` have an 
> > > > > explanation of the full transformation too?
> > > > I've revised the comments, changed the name to "Note" and put 
> > > > "Explanation" back into RewriteRule.
> > > > 
> > > > As for how to display these, I imagine an interface like clang tidy's 
> > > > fixit hints.  The Explanation (if any) will be associated with the span 
> > > > of the entire match.  The Notes will be associated with the target node 
> > > > span of each annotated change.  WDYT?
> > > Do we really need the AST information to expose the edits to the users?
> > > IIUC, clang-tidy uses the information from textual replacements to render 
> > > the changes produced by the fix-its today.
> > > 
> > > I guess it might be useful to add extra notes to clang-tidy warnings that 
> > > have corresponding fix-its, but is the transformers library the right 
> > > layer to produce those? 
> > > I haven't seen the proposed glue to clang-tidy yet, maybe that would make 
> > > more sense when I see it.
> > > 
> > > One of the other reasons I ask this is that it seems that without `Note` 
> > > we don't strictly `ASTEditBuilder`, we could replace
> > > ```
> > > change("ref").to("something"); // without nodepart
> > > change("ref", NodePart::Member).to("something");
> > > ```
> > > with
> > > ```
> > > change("ref", "something")
> > > change("ref", NodePart::Member, "something");
> > > ```
> > > That would remove the boilerplate of the builder, simplifying the code a 
> > > bit.
> > > 
> > > That trick would be hard to pull if we have a `Note` field inside, we'll 
> > > need more overloads and having note and replacement after each other 
> > > might be confusing (they have the same type, might be hard to read 
> > > without the guiding `.to()` and `.because()`)
> > Breaking this explicitly into two questions:
> > 1. Do Notes belong here?
> > 2. Can we drop the builder?
> > 
> > 1. Do Notes belong here?
> > I think so.  When users provide a diagnostic, they are specifying its 
> > location. So, we don't quite need the AST but we do need location info.  
> > The diagnostic generator does take information from the replacements 
> > themselves, but that's not alone. For example: 
> > clang-tidy/readability/ConstReturnTypeCheck.cpp:104.  That demos both the 
> > diagnostic construction and multiple diagnostics in a single tidy result.
> > 
> > Given that, i think that RewriteRules are the appropriate place. The goal 
> > is that they be self contained, so I think the explanations should be 
> > bundled with the description of that actual change.  An example approach to 
> > merging with clang tidy is here: 
> > https://github.com/ymand/llvm-project/blob/transformer/clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
> >  (although that's based on a somewhat different version of the Transformer 
> > library; it should make clear what I have in mind).
> > 
> > 2. Do we need the builder?
> > No, despite my opinion that notes belong.  Given the explanation on 
> > RewriteRule, I think notes will be used only rarely (like in the example 
> > clang-tidy above; but that's not standard practice).  So, we can provide 
> > the two overloads of `change` that you mention and then let users assign 
> > the note directly in those rare cases they need it. then, we can drop the 
> > builder.
> > 
> > So, I propose keeping the note 

[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 195235.
ymandel added a comment.

Fix include ordering (bad clang-format config).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60408

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -13,36 +13,11 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace tooling {
-namespace {
-using ast_matchers::anyOf;
-using ast_matchers::argumentCountIs;
-using ast_matchers::callee;
-using ast_matchers::callExpr;
-using ast_matchers::cxxMemberCallExpr;
-using ast_matchers::cxxMethodDecl;
-using ast_matchers::cxxRecordDecl;
-using ast_matchers::declRefExpr;
-using ast_matchers::expr;
-using ast_matchers::functionDecl;
-using ast_matchers::hasAnyName;
-using ast_matchers::hasArgument;
-using ast_matchers::hasDeclaration;
-using ast_matchers::hasElse;
-using ast_matchers::hasName;
-using ast_matchers::hasType;
-using ast_matchers::ifStmt;
-using ast_matchers::member;
-using ast_matchers::memberExpr;
-using ast_matchers::namedDecl;
-using ast_matchers::on;
-using ast_matchers::pointsTo;
-using ast_matchers::to;
-using ast_matchers::unless;
-
-using llvm::StringRef;
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
 
+namespace {
 constexpr char KHeaderContents[] = R"cc(
   struct string {
 string(const char*);
@@ -59,6 +34,9 @@
 PCFProto& GetProto();
   };
   }  // namespace proto
+  class Logger {};
+  void operator<<(Logger& l, string msg);
+  Logger& log(int level);
 )cc";
 
 static ast_matchers::internal::Matcher
@@ -141,18 +119,15 @@
 static RewriteRule ruleStrlenSize() {
   StringRef StringExpr = "strexpr";
   auto StringType = namedDecl(hasAnyName("::basic_string", "::string"));
-  return buildRule(
- callExpr(
- callee(functionDecl(hasName("strlen"))),
- hasArgument(0, cxxMemberCallExpr(
-on(expr(hasType(isOrPointsTo(StringType)))
-   .bind(StringExpr)),
-callee(cxxMethodDecl(hasName("c_str")))
-  // Specify the intended type explicitly, because the matcher "type" of
-  // `callExpr()` is `Stmt`, not `Expr`.
-  .as()
-  .replaceWith("REPLACED")
-  .because("Use size() method directly on string.");
+  auto R = makeRule(
+  callExpr(callee(functionDecl(hasName("strlen"))),
+   hasArgument(0, cxxMemberCallExpr(
+  on(expr(hasType(isOrPointsTo(StringType)))
+ .bind(StringExpr)),
+  callee(cxxMethodDecl(hasName("c_str")),
+  changeMatched("REPLACED"));
+  R.Explanation = text("Use size() method directly on string.");
+  return R;
 }
 
 TEST_F(TransformerTest, StrlenSize) {
@@ -181,15 +156,12 @@
 // Tests replacing an expression.
 TEST_F(TransformerTest, Flag) {
   StringRef Flag = "flag";
-  RewriteRule Rule =
-  buildRule(
-  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(hasName(
-"proto::ProtoCommandLineFlag"
-   .bind(Flag)),
-unless(callee(cxxMethodDecl(hasName("GetProto"))
-  .change(Flag)
-  .replaceWith("EXPR")
-  .because("Use GetProto() to access proto fields.");
+  RewriteRule Rule = makeRule(
+  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(
+hasName("proto::ProtoCommandLineFlag"
+   .bind(Flag)),
+unless(callee(cxxMethodDecl(hasName("GetProto"),
+  change(Flag, "EXPR"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -207,9 +179,9 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule = buildRule(functionDecl(hasName("bad")).bind(Fun))
- .change(Fun, NodePart::Name)
- .replaceWith("good");
+  RewriteRule Rule =
+  makeRule(functionDecl(hasName("bad")).bind(Fun),
+   change(Fun, NodePart::Name, "good"));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -240,9 +212,8 @@
   )cc";
 
   StringRef Ref = "ref";
-  testRule(buildRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref))
-   .change(Ref, NodePart::Name)
-   .replaceWith("good"),
+  testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
+change(Ref, NodePart::Name, "good")),
   

[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 195234.
ymandel marked 2 inline comments as done.
ymandel added a comment.

Deleted ASTEdit builder; added more `change` overloads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60408

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -13,36 +13,11 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace tooling {
-namespace {
-using ast_matchers::anyOf;
-using ast_matchers::argumentCountIs;
-using ast_matchers::callee;
-using ast_matchers::callExpr;
-using ast_matchers::cxxMemberCallExpr;
-using ast_matchers::cxxMethodDecl;
-using ast_matchers::cxxRecordDecl;
-using ast_matchers::declRefExpr;
-using ast_matchers::expr;
-using ast_matchers::functionDecl;
-using ast_matchers::hasAnyName;
-using ast_matchers::hasArgument;
-using ast_matchers::hasDeclaration;
-using ast_matchers::hasElse;
-using ast_matchers::hasName;
-using ast_matchers::hasType;
-using ast_matchers::ifStmt;
-using ast_matchers::member;
-using ast_matchers::memberExpr;
-using ast_matchers::namedDecl;
-using ast_matchers::on;
-using ast_matchers::pointsTo;
-using ast_matchers::to;
-using ast_matchers::unless;
-
-using llvm::StringRef;
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
 
+namespace {
 constexpr char KHeaderContents[] = R"cc(
   struct string {
 string(const char*);
@@ -59,6 +34,9 @@
 PCFProto& GetProto();
   };
   }  // namespace proto
+  class Logger {};
+  void operator<<(Logger& l, string msg);
+  Logger& log(int level);
 )cc";
 
 static ast_matchers::internal::Matcher
@@ -141,18 +119,15 @@
 static RewriteRule ruleStrlenSize() {
   StringRef StringExpr = "strexpr";
   auto StringType = namedDecl(hasAnyName("::basic_string", "::string"));
-  return buildRule(
- callExpr(
- callee(functionDecl(hasName("strlen"))),
- hasArgument(0, cxxMemberCallExpr(
-on(expr(hasType(isOrPointsTo(StringType)))
-   .bind(StringExpr)),
-callee(cxxMethodDecl(hasName("c_str")))
-  // Specify the intended type explicitly, because the matcher "type" of
-  // `callExpr()` is `Stmt`, not `Expr`.
-  .as()
-  .replaceWith("REPLACED")
-  .because("Use size() method directly on string.");
+  auto R = makeRule(
+  callExpr(callee(functionDecl(hasName("strlen"))),
+   hasArgument(0, cxxMemberCallExpr(
+  on(expr(hasType(isOrPointsTo(StringType)))
+ .bind(StringExpr)),
+  callee(cxxMethodDecl(hasName("c_str")),
+  changeMatched("REPLACED"));
+  R.Explanation = text("Use size() method directly on string.");
+  return R;
 }
 
 TEST_F(TransformerTest, StrlenSize) {
@@ -181,15 +156,12 @@
 // Tests replacing an expression.
 TEST_F(TransformerTest, Flag) {
   StringRef Flag = "flag";
-  RewriteRule Rule =
-  buildRule(
-  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(hasName(
-"proto::ProtoCommandLineFlag"
-   .bind(Flag)),
-unless(callee(cxxMethodDecl(hasName("GetProto"))
-  .change(Flag)
-  .replaceWith("EXPR")
-  .because("Use GetProto() to access proto fields.");
+  RewriteRule Rule = makeRule(
+  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(
+hasName("proto::ProtoCommandLineFlag"
+   .bind(Flag)),
+unless(callee(cxxMethodDecl(hasName("GetProto"),
+  change(Flag, "EXPR"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -207,9 +179,9 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule = buildRule(functionDecl(hasName("bad")).bind(Fun))
- .change(Fun, NodePart::Name)
- .replaceWith("good");
+  RewriteRule Rule =
+  makeRule(functionDecl(hasName("bad")).bind(Fun),
+   change(Fun, NodePart::Name, "good"));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -240,9 +212,8 @@
   )cc";
 
   StringRef Ref = "ref";
-  testRule(buildRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref))
-   .change(Ref, NodePart::Name)
-   .replaceWith("good"),
+  testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
+   

[PATCH] D60663: Time profiler: small fixes and optimizations

2019-04-15 Thread Aras Pranckevičius via Phabricator via cfe-commits
aras-p added a comment.

> So i can't and won't claim any legal knowledge, but it maybe would be good 
> for him to at least comment here, that he is ok with this?

Yes, absolutely fine. The only reason why some files started with the old 
license blurb is because I started the branch before licensing switch kicked in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60663



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-04-15 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.



  ; ModuleID = 'arch_static_branch.bc'
  source_filename = "arch/x86/entry/vsyscall/vsyscall_64.c"
  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-grtev4-linux-gnu"
  
  %struct.atomic_t = type { i32 }
  %struct.jump_entry = type { i64, i64, i64 }
  %struct.tracepoint_func = type { i8*, i8*, i32 }
  %struct.static_key = type { %struct.atomic_t, %union.anon }
  %union.anon = type { i64 }
  
  @__tracepoint_emulate_vsyscall = external hidden global { i8*, { 
%struct.atomic_t, { %struct.jump_entry* } }, i32 ()*, void ()*, 
%struct.tracepoint_func* }, section "__tracepoints", align 8
  
  ; Function Attrs: alwaysinline noredzone nounwind sspstrong
  define zeroext i1 @arch_static_branch(%struct.static_key* nocapture readnone 
%key, i1 zeroext %branch) {
  entry:
callbr void asm sideeffect "1:.byte 0x0f,0x1f,0x44,0x00,0\0A\09.pushsection 
__jump_table,  \22aw\22 \0A\09 .balign 8 \0A\09 .quad 1b, ${2:l}, ${0:c} + 
${1:c} \0A\09.popsection \0A\09", 
"i,i,X,~{dirflag},~{fpsr},~{flags}"(%struct.static_key* bitcast (i32* 
getelementptr inbounds ({ i8*, { %struct.atomic_t, { %struct.jump_entry* } }, 
i32 ()*, void ()*, %struct.tracepoint_func* }, { i8*, { %struct.atomic_t, { 
%struct.j
  ump_entry* } }, i32 ()*, void ()*, %struct.tracepoint_func* }* 
@__tracepoint_emulate_vsyscall, i64 0, i32 1, i32 0, i32 0) to 
%struct.static_key*), i1 false, i8* blockaddress(@arch_static_branch, %return))
to label %asm.fallthrough [label %return]
  
  asm.fallthrough:  ; preds = %entry
call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
br label %return
  
  return:   ; preds = %asm.fallthrough, 
%entry
%retval.0 = phi i1 [ false, %asm.fallthrough ], [ true, %entry ]
ret i1 %retval.0
  }


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

https://reviews.llvm.org/D56571



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


[PATCH] D60663: Time profiler: small fixes and optimizations

2019-04-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Ok, LG, thank you!




Comment at: llvm/lib/Support/TimeProfiler.cpp:30
+cl::desc(
+"Minimum time granularity (in microsecons) traced by time profiler"),
+cl::init(500));

microsecon*d*s



Comment at: llvm/lib/Support/TimeProfiler.cpp:70-71
+
+  Entry(time_point &, DurationType &, std::string &,
+std::string &)
+  : Start(std::move(S)), Duration(std::move(D)), Name(std::move(N)),

I *think* `&&` are not needed.



Comment at: llvm/lib/Support/TimeProfiler.cpp:92
+// Only include sections longer than TimeTraceGranularity.
+if (duration_cast(E.Duration).count() > TimeTraceGranularity)
   Entries.emplace_back(E);

This will only track events that are **longer** than `TimeTraceGranularity`, 
which i think conflicts
with the `"Minimum time granularity (in microseconds) traced by time profiler"`
So either `>=` or reword the description a bit?



Comment at: llvm/lib/Support/TimeProfiler.cpp:156-157
 
-  std::vector Stack;
-  std::vector Entries;
+  SmallVector Stack;
+  SmallVector Entries;
   StringMap CountAndTotalPerName;

Since `TimeTraceProfiler` will be always heap-allocated (so stack usage is not 
a concern)
i think this is safe, and maybe even bump it a bit, depending on the values you 
see in average profiles?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60663



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


[PATCH] D60626: [clang] Aligned allocation is actually supported in macosx 10.13

2019-04-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Reverted in r358437 because of unforeseen CI failures. The failures I was 
expecting are in libc++, not in compiler-rt. I'll investigate locally and 
re-apply.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60626



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


r358437 - Revert "[clang] Aligned allocation is actually supported in macosx 10.13"

2019-04-15 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Mon Apr 15 12:08:52 2019
New Revision: 358437

URL: http://llvm.org/viewvc/llvm-project?rev=358437=rev
Log:
Revert "[clang] Aligned allocation is actually supported in macosx 10.13"

This reverts r358409, which I think broke the bots in compiler-rt.
Since I'm having trouble reproducing the failure, I'm reverting this
until I can investigate locally.

Modified:
cfe/trunk/include/clang/Basic/AlignedAllocation.h
cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp

Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AlignedAllocation.h?rev=358437=358436=358437=diff
==
--- cfe/trunk/include/clang/Basic/AlignedAllocation.h (original)
+++ cfe/trunk/include/clang/Basic/AlignedAllocation.h Mon Apr 15 12:08:52 2019
@@ -26,8 +26,8 @@ inline llvm::VersionTuple alignedAllocMi
   default:
 break;
   case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
-return llvm::VersionTuple(10U, 13U);
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
+return llvm::VersionTuple(10U, 14U);
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
 return llvm::VersionTuple(11U);

Modified: cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp?rev=358437=358436=358437=diff
==
--- cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp Mon Apr 15 
12:08:52 2019
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 //
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
-// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
@@ -54,10 +54,10 @@
 // Check that passing -faligned-allocation or -fno-aligned-allocation stops the
 // driver from passing -faligned-alloc-unavailable to cc1.
 //
-// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### 
%s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -faligned-allocation -c -### 
%s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
-// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c 
-### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c 
-### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 
 // AVAILABLE-NOT: "-faligned-alloc-unavailable"

Modified: cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp?rev=358437=358436=358437=diff
==
--- cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp Mon Apr 15 
12:08:52 2019
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
@@ -117,8 +117,8 @@ void testOveralignedCheckOS() {
 // expected-error@-13 {{aligned allocation function of type 'void *(unsigned 
long, enum std::align_val_t)' is only available on watchOS 4 or newer}}}
 // expected-error@-14 {{aligned deallocation function of type 'void (void *, 
enum std::align_val_t) noexcept' is only available on 

[PATCH] D60663: Time profiler: small fixes and optimizations

2019-04-15 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev added a comment.

In D60663#1465721 , @lebedev.ri wrote:

> Looks good ignoring the json bits.
>
> Re license:
>
> > https://reviews.llvm.org/D58675
> >  This is the first part of time tracing system, I have splitted them cause 
> > this part is mostly written by Aras Pranckevicius except of several minor 
> > fixes concerning formatting.
>
> So i can't and won't claim any legal knowledge, but it maybe would be good 
> for him to at least comment here, that he is ok with this?


I've communicated to Aras by mail, he is ok with new license header:

> "Sure! I started my branch before the LLVM license change. The new one is 
> fine."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60663



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


[PATCH] D60726: Fixed -Wconversion-null warning in GCC.

2019-04-15 Thread Denis Bakhvalov via Phabricator via cfe-commits
dendibakh added a comment.

@reuk , can you please commit this patch on my behalf?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60726



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


[PATCH] D60726: Fixed -Wconversion-null warning in GCC.

2019-04-15 Thread Reuben Thomas via Phabricator via cfe-commits
reuk accepted this revision.
reuk added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D60726



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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

In D60455#1464324 , @Fznamznon wrote:

> Applied comments from @aaron.ballman and @keryell
>
> - Introduced a C++11 and C2x style spelling in the clang namespace. I didn't 
> find path to add two namespaces to attribute (like [[clang::sycl::device]]) 
> so [[clang::sycl_device]] spelling is added.
> - Since both attributes have spellings and possible can be used as some 
> "standard" outlining in Clang/LLVM I added documetation.
> - Added more test cases.
> - As @bader mentioned sycl_device can be used to mark functions, which are 
> called from the different translation units so I added simple handling of 
> this attribute in Sema.


I'm confused -- I thought @bader also said "...SYCL is not supposed to expose 
any non-standard extensions to a user." -- these attributes are not standards 
based (WG21 and WG14 have nothing to say about them), so are these attributes 
considered "non-standard extensions" or not?

I'm still wondering what the actual semantics are for the attribute. Right now, 
these are being parsed and ignored -- are there future plans here?




Comment at: clang/include/clang/Basic/Attr.td:1000
+def SYCLDevice : InheritableAttr {
+  let Spellings = [GNU<"sycl_device">];
+  let Subjects = SubjectList<[Function, Var]>;

aaron.ballman wrote:
> keryell wrote:
> > Fznamznon wrote:
> > > aaron.ballman wrote:
> > > > Is there a reason to not also introduce a C++11 and C2x style spelling 
> > > > in the `clang` namespace? e.g., `[[clang::sycl_device]]`
> > > I don't think that it makes sense because these attributes not for public 
> > > consumption. These attributes is needed to separate code which is 
> > > supposed to be offloaded from regular host code. I think SYCLDevice 
> > > attribute actually doesn't need a spelling because it will be added only 
> > > implicitly by compiler.
> > 
> > If we go towards this direction, `[[clang::sycl::device]]` or 
> > `[[clang::sycl::kernel]]` look more compatible with the concept of name 
> > space.
> > While not a public interface, if we have a kind of "standard" outlining in 
> > Clang/LLVM, some people might want to use it in some other contexts too.
> If these are only being added implicitly by the compiler, then they should 
> not be given any `Spelling`. See `AlignMac68k` for an example.
I'm still confused -- are these created implicitly or are they spelled out by 
the user explicitly? Right now, it looks like they're spelled out explicitly, 
but I was under the impression they are only intended to be created implicitly 
by the compiler.

If they are expected to be explicitly specified by the user, the spelling 
should be using `Clang<>` instead of using `GNU<>`, `C2x<>`, and `CXX11<>` 
explicitly.

> If we go towards this direction, [[clang::sycl::device]] or 
> [[clang::sycl::kernel]] look more compatible with the concept of name space.

Attribute namespaces do not work that way. There is the vendor namespace and 
then the attribute name.



Comment at: clang/include/clang/Basic/AttrDocs.td:259
+  let Content = [{
+The sycl_device attribute specifies function which is supposed to be compiled
+for the device and cannot be directly called by the host. Here is code example

specifies function which is -> specifies that a function is

Also, please put backticks around `sycl_device`.



Comment at: clang/include/clang/Basic/AttrDocs.td:260
+The sycl_device attribute specifies function which is supposed to be compiled
+for the device and cannot be directly called by the host. Here is code example
+of the SYCL program, which demonstrates the need for this attribute:

is code example -> is a code example



Comment at: clang/include/clang/Basic/AttrDocs.td:261
+for the device and cannot be directly called by the host. Here is code example
+of the SYCL program, which demonstrates the need for this attribute:
+

the SYCL program, which -> a SYLC program that

(Note, I also removed the comma.)



Comment at: clang/include/clang/Basic/AttrDocs.td:277
+
+Code is passed to parallel_for is called "kernel function" and defines some
+entry point to device code i.e. will be called by host in run time. Compiler

Code -> Do you mean the lambda? If so, perhaps "The lambda that is passed to 
the `parallel_for`" (add backticks around parallel_for too, please).

is called "kernel function" -> is called a "kernel function"



Comment at: clang/include/clang/Basic/AttrDocs.td:286
+help.
+  }];
+}

I'm still not entirely certain how I would know what to mark and how. From the 
description, it sounds like whoever authors `parallel_for` needs to do this 
marking, or it somehow happens automatically?

(I'll do another 

[PATCH] D59264: [Driver] Support compiler-rt crtbegin.o/crtend.o for Linux

2019-04-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@MaskRay can you review this again now that there's just a single `crtbegin.o` 
and `crtend.o` version?


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

https://reviews.llvm.org/D59264



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


r358435 - [X86] Improve avx512-kconstraints-att_inline_asm.c to not be easily defeated by deadcode elimination. Improve CHECK lines to check IR types used. NFC

2019-04-15 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr 15 11:39:36 2019
New Revision: 358435

URL: http://llvm.org/viewvc/llvm-project?rev=358435=rev
Log:
[X86] Improve avx512-kconstraints-att_inline_asm.c to not be easily defeated by 
deadcode elimination. Improve CHECK lines to check IR types used. NFC

I plan to use this as the basis for backend IR test cases. We currently crash 
hard for using 32 or 64 bit mask registers without avx512bw.

Modified:
cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c

Modified: cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c?rev=358435=358434=358435=diff
==
--- cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c (original)
+++ cfe/trunk/test/CodeGen/avx512-kconstraints-att_inline_asm.c Mon Apr 15 
11:39:36 2019
@@ -1,59 +1,77 @@
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-cpu 
skylake-avx512 -emit-llvm -o - -Wall -Werror |opt -instnamer -S |FileCheck %s
+// RUN: %clang_cc1 %s -O0 -ffreestanding -triple=x86_64-apple-darwin 
-target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror |opt -instnamer -S 
|FileCheck %s
 // This test checks validity of att\gcc style inline assmebly for avx512 k and 
Yk constraints.
 // Also checks mask register allows flexible type (size <= 64 bit)
 
-void mask_Yk_i8(char msk){ 
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
- asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   : "Yk" (msk));   //inputs
-}
-
-void mask_Yk_i16(short msk){
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
- asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   :  "Yk" (msk));  //inputs
-}
-
-void mask_Yk_i32(int msk){
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
-asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   :  "Yk" (msk));   //inputs
-}
+#include 
 
-void mask_Yk_i64(long long msk){
-//CHECK: vpaddb\09 %xmm1, %xmm0, %xmm1 {$0}\09
- asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
-   ://output
-   :  "Yk" (msk));   //inputs
-}
-
-void k_wise_op_i8(char msk_dst,char msk_src1,char msk_src2){
-//CHECK: kandw\09$2, $1, $0
- asm ("kandw\t%2, %1, %0"
+__m512i mask_Yk_i8(char msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddq\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i8 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddq\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+__m512i mask_Yk_i16(short msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddd\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i16 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddd\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+__m512i mask_Yk_i32(int msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddw\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddw\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+__m512i mask_Yk_i64(long long msk, __m512i x, __m512i y){
+// CHECK: <8 x i64> asm "vpaddb\09$3, $2, $0 {$1}", 
"=x,^Yk,x,x,~{dirflag},~{fpsr},~{flags}"(i64 %{{.*}}, <8 x i64> %{{.*}}, <8 x 
i64> %{{.*}})
+  __m512i dst;
+  asm ("vpaddb\t%3, %2, %0 %{%1%}"
+   : "=x" (dst)  //output
+   : "Yk" (msk), "x" (x), "x" (y));   //inputs
+  return dst;
+}
+
+char k_wise_op_i8(char msk_src1,char msk_src2){
+//CHECK: i8 asm "kandb\09$2, $1, $0", "=k,k,k,~{dirflag},~{fpsr},~{flags}"(i8 
%{{.*}}, i8 %{{.*}})
+  char msk_dst;
+  asm ("kandb\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
+  return msk_dst;
 }
 
-void k_wise_op_i16(short msk_dst, short msk_src1, short msk_src2){
-//CHECK: kandw\09$2, $1, $0
+short k_wise_op_i16(short msk_src1, short msk_src2){
+//CHECK: i16 asm "kandw\09$2, $1, $0", 
"=k,k,k,~{dirflag},~{fpsr},~{flags}"(i16 %{{.*}}, i16 %{{.*}})
+  short msk_dst;
   asm ("kandw\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
+  return msk_dst;
 }
 
-void k_wise_op_i32(int msk_dst, int msk_src1, int msk_src2){
-//CHECK: kandw\09$2, $1, $0
-  asm ("kandw\t%2, %1, %0"
+int k_wise_op_i32(int msk_src1, int msk_src2){
+//CHECK: i32 asm "kandd\09$2, $1, $0", 
"=k,k,k,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}})
+  int msk_dst;
+  asm ("kandd\t%2, %1, %0"
: "=k" (msk_dst)
: "k" (msk_src1), "k" (msk_src2));
+  return msk_dst;
 }
 
-void k_wise_op_i64(long long msk_dst, long long msk_src1, long long msk_src2){
-//CHECK: 

[PATCH] D60728: [clang] [test] Add a (xfailing) test for PR41027

2019-04-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, joerg, hans, rsmith.

Add a test for tracking PR41027 (8.0 regression breaking assembly code
relying on __builtin_constant_p() to identify compile-time constants).
Mark it as expected to fail everywhere.


https://reviews.llvm.org/D60728

Files:
  clang/test/Sema/pr41027.c


Index: clang/test/Sema/pr41027.c
===
--- /dev/null
+++ clang/test/Sema/pr41027.c
@@ -0,0 +1,9 @@
+// XFAIL: *
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
+inline void pr41027(unsigned a, unsigned b) {
+  if (__builtin_constant_p(a)) {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
+  } else {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
+  }
+}


Index: clang/test/Sema/pr41027.c
===
--- /dev/null
+++ clang/test/Sema/pr41027.c
@@ -0,0 +1,9 @@
+// XFAIL: *
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
+inline void pr41027(unsigned a, unsigned b) {
+  if (__builtin_constant_p(a)) {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
+  } else {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-04-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D60233#1467092 , @trixirt wrote:

> A comment by whisperity in the origin WIP did not seem to be addressed.
>  Have you looked at IWYU 
> https://github.com/include-what-you-use/include-what-you-use ?
>  The end goals of clang-scan-deps and iwyu seem similar so their 
> implementation problems would also be similar.
>  The iwyu problems doc is 
> https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYUIsDifficult.md


IWYU doesn't seem related to me.  My understanding is:

- IWYU checks that semantic dependencies between source files is reflected by 
the file dependencies (e.g., semantic dependencies should have matching 
`#include`s).
- `clang-scan-deps` discovers the transitive file dependencies of a TU.

IIUC, IWYU's implementation challenges are related to mapping/discovering 
semantic dependencies between source files, which is something that 
`clang-scan-deps` doesn't care about at all.  Can you clarify what link you see?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60233



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


[PATCH] D60726: Fixed -Wconversion-null warning in GCC.

2019-04-15 Thread Denis Bakhvalov via Phabricator via cfe-commits
dendibakh created this revision.
dendibakh added a reviewer: reuk.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC -Wconversion-null warning appeared after 
9a63380260860b657b72f07c4f0e61e382ab934a.
There was a similar problem already in the past:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20131230/096230.html


Repository:
  rC Clang

https://reviews.llvm.org/D60726

Files:
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11393,6 +11393,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
@@ -11566,12 +11567,6 @@
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
-  Style.SpaceAfterLogicalNot = false;
-  CHECK_PARSE("SpaceAfterLogicalNot: true", SpaceAfterLogicalNot,
-  true);
-  CHECK_PARSE("SpaceAfterLogicalNot: false", SpaceAfterLogicalNot,
-  false);
-
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11393,6 +11393,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
+  CHECK_PARSE_BOOL(SpaceAfterLogicalNot);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
   CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
@@ -11566,12 +11567,6 @@
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
-  Style.SpaceAfterLogicalNot = false;
-  CHECK_PARSE("SpaceAfterLogicalNot: true", SpaceAfterLogicalNot,
-  true);
-  CHECK_PARSE("SpaceAfterLogicalNot: false", SpaceAfterLogicalNot,
-  false);
-
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

A few quick responses, will take a closer look again tomorrow.




Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:87
+  TextGenerator Replacement;
+  TextGenerator Explanation;
+};

ymandel wrote:
> ilya-biryukov wrote:
> > ymandel wrote:
> > > ilya-biryukov wrote:
> > > > ymandel wrote:
> > > > > ilya-biryukov wrote:
> > > > > > I would've expected explanation to be the trait of the rewrite 
> > > > > > rule, since all changes have to be applied.
> > > > > > What's the reasoning behind having it at the level of separate 
> > > > > > changes? How would this explanation be used? For debugging purposes 
> > > > > > or displaying that to the user?
> > > > > I think that for most cases, one explanation sufficies for the whole 
> > > > > transformation. However, there are some tidies that emit multiple 
> > > > > diagnoses (for example if changing before a declaration and a 
> > > > > definition).   Would it help if I clarify in the comments?
> > > > Yeah, absolutely! Please document what it's used for and that would 
> > > > clear that up for me.
> > > > I actually thing that explaining every part of the transformation is 
> > > > probably too complicated, so most of the time you would want to have an 
> > > > explanation for the `RewriteRule`, not for each individual change.
> > > > 
> > > > The other challenge that I see is show to display these explanations to 
> > > > the user, i.e. how should the clients combine these explanations in 
> > > > order to get the full one? Should the `RewriteRule` have an explanation 
> > > > of the full transformation too?
> > > I've revised the comments, changed the name to "Note" and put 
> > > "Explanation" back into RewriteRule.
> > > 
> > > As for how to display these, I imagine an interface like clang tidy's 
> > > fixit hints.  The Explanation (if any) will be associated with the span 
> > > of the entire match.  The Notes will be associated with the target node 
> > > span of each annotated change.  WDYT?
> > Do we really need the AST information to expose the edits to the users?
> > IIUC, clang-tidy uses the information from textual replacements to render 
> > the changes produced by the fix-its today.
> > 
> > I guess it might be useful to add extra notes to clang-tidy warnings that 
> > have corresponding fix-its, but is the transformers library the right layer 
> > to produce those? 
> > I haven't seen the proposed glue to clang-tidy yet, maybe that would make 
> > more sense when I see it.
> > 
> > One of the other reasons I ask this is that it seems that without `Note` we 
> > don't strictly `ASTEditBuilder`, we could replace
> > ```
> > change("ref").to("something"); // without nodepart
> > change("ref", NodePart::Member).to("something");
> > ```
> > with
> > ```
> > change("ref", "something")
> > change("ref", NodePart::Member, "something");
> > ```
> > That would remove the boilerplate of the builder, simplifying the code a 
> > bit.
> > 
> > That trick would be hard to pull if we have a `Note` field inside, we'll 
> > need more overloads and having note and replacement after each other might 
> > be confusing (they have the same type, might be hard to read without the 
> > guiding `.to()` and `.because()`)
> Breaking this explicitly into two questions:
> 1. Do Notes belong here?
> 2. Can we drop the builder?
> 
> 1. Do Notes belong here?
> I think so.  When users provide a diagnostic, they are specifying its 
> location. So, we don't quite need the AST but we do need location info.  The 
> diagnostic generator does take information from the replacements themselves, 
> but that's not alone. For example: 
> clang-tidy/readability/ConstReturnTypeCheck.cpp:104.  That demos both the 
> diagnostic construction and multiple diagnostics in a single tidy result.
> 
> Given that, i think that RewriteRules are the appropriate place. The goal is 
> that they be self contained, so I think the explanations should be bundled 
> with the description of that actual change.  An example approach to merging 
> with clang tidy is here: 
> https://github.com/ymand/llvm-project/blob/transformer/clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
>  (although that's based on a somewhat different version of the Transformer 
> library; it should make clear what I have in mind).
> 
> 2. Do we need the builder?
> No, despite my opinion that notes belong.  Given the explanation on 
> RewriteRule, I think notes will be used only rarely (like in the example 
> clang-tidy above; but that's not standard practice).  So, we can provide the 
> two overloads of `change` that you mention and then let users assign the note 
> directly in those rare cases they need it. then, we can drop the builder.
> 
> So, I propose keeping the note but dropping the builder. WDYT?
Thanks for pointing out how this usage in clang-tidy. Seems to be the only way 
to put it into clang-tidy (and there are good reasons for that, 

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-04-15 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: test/CodeGen/x86_32-m64-darwin.c:1
+// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -target-cpu yonah 
-target-feature +mmx -emit-llvm -O2 -o - %s | FileCheck %s
+

You should be able to merge all of these triples into the same test file, each 
with their own RUN: line, you will need to add a FileCheck prefix, something 
like:
```
| FileCheck %s --check-prefixes=CHECK,DARWIN
| FileCheck %s --check-prefixes=CHECK,IAMCU
| FileCheck %s --check-prefixes=CHECK,LINUX
| FileCheck %s --check-prefixes=CHECK,WIN32
```


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

https://reviews.llvm.org/D59744



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


[PATCH] D60674: [X86] Restore the pavg intrinsics.

2019-04-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358427: [X86] Restore the pavg intrinsics. (authored by 
ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60674?vs=195090=195219#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60674

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/Headers/avx2intrin.h
  cfe/trunk/lib/Headers/avx512bwintrin.h
  cfe/trunk/lib/Headers/emmintrin.h
  cfe/trunk/test/CodeGen/avx2-builtins.c
  cfe/trunk/test/CodeGen/avx512bw-builtins.c
  cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
  cfe/trunk/test/CodeGen/sse2-builtins.c
  llvm/trunk/include/llvm/IR/IntrinsicsX86.td
  llvm/trunk/lib/IR/AutoUpgrade.cpp
  llvm/trunk/lib/Target/X86/X86IntrinsicsInfo.h
  llvm/trunk/test/CodeGen/X86/avx2-intrinsics-fast-isel.ll
  llvm/trunk/test/CodeGen/X86/avx2-intrinsics-x86-upgrade.ll
  llvm/trunk/test/CodeGen/X86/avx2-intrinsics-x86.ll
  llvm/trunk/test/CodeGen/X86/avx512bw-intrinsics.ll
  llvm/trunk/test/CodeGen/X86/avx512bwvl-intrinsics.ll
  llvm/trunk/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
  llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll
  llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86.ll

Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -263,6 +263,8 @@
 TARGET_BUILTIN(__builtin_ia32_psubusb128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psubusw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmulhw128, "V8sV8sV8s", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgb128, "V16cV16cV16c", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxub128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pminub128, "V16cV16cV16c", "ncV:128:", "sse2")
@@ -574,6 +576,8 @@
 TARGET_BUILTIN(__builtin_ia32_psubusb256, "V32cV32cV32c", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psubusw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_palignr256, "V32cV32cV32cIi", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgb256, "V32cV32cV32c", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendw256, "V16sV16sV16sIi", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "ncV:256:", "avx2")
@@ -1053,6 +1057,8 @@
 TARGET_BUILTIN(__builtin_ia32_paddsw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxub512, "V64cV64cV64c", "ncV:512:", "avx512bw")
Index: cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
+++ cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
@@ -1179,101 +1179,49 @@
 }
 __m128i test_mm_mask_avg_epu8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_avg_epu8
-  // CHECK-NOT: @llvm.x86.sse2.pavg.b
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
-  // CHECK: add <16 x i16> %{{.*}}, 
-  // CHECK: lshr <16 x i16> %{{.*}}, 
-  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
+  // CHECK: @llvm.x86.sse2.pavg.b
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_mask_avg_epu8(__W,__U,__A,__B); 
 }
 __m128i test_mm_maskz_avg_epu8(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_avg_epu8
-  // CHECK-NOT: @llvm.x86.sse2.pavg.b
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
-  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
-  // CHECK: add <16 x i16> %{{.*}}, 
-  // CHECK: lshr <16 x i16> %{{.*}}, 
-  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
-  // CHECK: store <2 x i64> zeroinitializer
+  // CHECK: @llvm.x86.sse2.pavg.b
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_maskz_avg_epu8(__U,__A,__B); 
 }
 __m256i 

[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358428: [CommandLineParser] Add DefaultOption flag (authored 
by dhinton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59746?vs=195218=195220#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59746

Files:
  cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
  llvm/trunk/docs/CommandLine.rst
  llvm/trunk/include/llvm/Support/CommandLine.h
  llvm/trunk/lib/Support/CommandLine.cpp
  llvm/trunk/test/Support/check-default-options.txt
  llvm/trunk/tools/llvm-opt-report/OptReport.cpp
  llvm/trunk/unittests/Support/CommandLineTest.cpp

Index: llvm/trunk/lib/Support/CommandLine.cpp
===
--- llvm/trunk/lib/Support/CommandLine.cpp
+++ llvm/trunk/lib/Support/CommandLine.cpp
@@ -98,6 +98,11 @@
   // This collects additional help to be printed.
   std::vector MoreHelp;
 
+  // This collects Options added with the cl::DefaultOption flag. Since they can
+  // be overridden, they are not added to the appropriate SubCommands until
+  // ParseCommandLineOptions actually runs.
+  SmallVector DefaultOptions;
+
   // This collects the different option categories that have been registered.
   SmallPtrSet RegisteredOptionCategories;
 
@@ -146,6 +151,11 @@
   void addOption(Option *O, SubCommand *SC) {
 bool HadErrors = false;
 if (O->hasArgStr()) {
+  // If it's a DefaultOption, check to make sure it isn't already there.
+  if (O->isDefaultOption() &&
+  SC->OptionsMap.find(O->ArgStr) != SC->OptionsMap.end())
+return;
+
   // Add argument to the argument map!
   if (!SC->OptionsMap.insert(std::make_pair(O->ArgStr, O)).second) {
 errs() << ProgramName << ": CommandLine Error: Option '" << O->ArgStr
@@ -185,7 +195,12 @@
 }
   }
 
-  void addOption(Option *O) {
+  void addOption(Option *O, bool ProcessDefaultOption = false) {
+if (!ProcessDefaultOption && O->isDefaultOption()) {
+  DefaultOptions.push_back(O);
+  return;
+}
+
 if (O->Subs.empty()) {
   addOption(O, &*TopLevelSubCommand);
 } else {
@@ -201,8 +216,12 @@
   OptionNames.push_back(O->ArgStr);
 
 SubCommand  = *SC;
-for (auto Name : OptionNames)
-  Sub.OptionsMap.erase(Name);
+auto End = Sub.OptionsMap.end();
+for (auto Name : OptionNames) {
+  auto I = Sub.OptionsMap.find(Name);
+  if (I != End && I->getValue() == O)
+Sub.OptionsMap.erase(I);
+  }
 
 if (O->getFormattingFlag() == cl::Positional)
   for (auto Opt = Sub.PositionalOpts.begin();
@@ -266,8 +285,13 @@
 if (O->Subs.empty())
   updateArgStr(O, NewName, &*TopLevelSubCommand);
 else {
-  for (auto SC : O->Subs)
-updateArgStr(O, NewName, SC);
+  if (O->isInAllSubCommands()) {
+for (auto SC : RegisteredSubCommands)
+  updateArgStr(O, NewName, SC);
+  } else {
+for (auto SC : O->Subs)
+  updateArgStr(O, NewName, SC);
+  }
 }
   }
 
@@ -331,6 +355,8 @@
 AllSubCommands->reset();
 registerSubCommand(&*TopLevelSubCommand);
 registerSubCommand(&*AllSubCommands);
+
+DefaultOptions.clear();
   }
 
 private:
@@ -366,6 +392,13 @@
   ArgStr = S;
 }
 
+void Option::reset() {
+  NumOccurrences = 0;
+  setDefault();
+  if (isDefaultOption())
+removeArgument();
+}
+
 // Initialise the general option category.
 OptionCategory llvm::cl::GeneralCategory("General options");
 
@@ -1167,6 +1200,10 @@
   auto  = ChosenSubCommand->SinkOpts;
   auto  = ChosenSubCommand->OptionsMap;
 
+  for (auto O: DefaultOptions) {
+addOption(O, true);
+  }
+
   if (ConsumeAfterOpt) {
 assert(PositionalOpts.size() > 0 &&
"Cannot specify cl::ConsumeAfter without a positional argument!");
@@ -2146,6 +2183,9 @@
 cl::location(WrappedNormalPrinter), cl::ValueDisallowed,
 cl::cat(GenericCategory), cl::sub(*AllSubCommands));
 
+static cl::alias HOpA("h", cl::desc("Alias for -help"), cl::aliasopt(HOp),
+  cl::DefaultOption);
+
 static cl::opt>
 HHOp("help-hidden", cl::desc("Display all available options"),
  cl::location(WrappedHiddenPrinter), cl::Hidden, cl::ValueDisallowed,
Index: llvm/trunk/unittests/Support/CommandLineTest.cpp
===
--- llvm/trunk/unittests/Support/CommandLineTest.cpp
+++ llvm/trunk/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,68 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+cl::DefaultOption);

r358428 - [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Mon Apr 15 10:18:10 2019
New Revision: 358428

URL: http://llvm.org/viewvc/llvm-project?rev=358428=rev
Log:
[CommandLineParser] Add DefaultOption flag

Summary: Add DefaultOption flag to CommandLineParser which provides a
default option or alias, but allows users to override it for some
other purpose as needed.

Also, add `-h` as a default alias to `-help`, which can be seamlessly
overridden by applications like llvm-objdump and llvm-readobj which
use `-h` as an alias for other options.

(relanding after revert, r358414)
Added DefaultOptions.clear() to reset().

Reviewers: alexfh, klimek

Reviewed By: klimek

Subscribers: kristina, MaskRay, mehdi_amini, inglorion, dexonsmith, hiraditya, 
llvm-commits, jhenderson, arphaman, cfe-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/lib/Tooling/CommonOptionsParser.cpp

Modified: cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CommonOptionsParser.cpp?rev=358428=358427=358428=diff
==
--- cfe/trunk/lib/Tooling/CommonOptionsParser.cpp (original)
+++ cfe/trunk/lib/Tooling/CommonOptionsParser.cpp Mon Apr 15 10:18:10 2019
@@ -83,8 +83,6 @@ std::vector ArgumentsAdj
 llvm::Error CommonOptionsParser::init(
 int , const char **argv, cl::OptionCategory ,
 llvm::cl::NumOccurrencesFlag OccurrencesFlag, const char *Overview) {
-  static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden,
-cl::sub(*cl::AllSubCommands));
 
   static cl::opt BuildPath("p", cl::desc("Build path"),
 cl::Optional, cl::cat(Category),


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


r358427 - [X86] Restore the pavg intrinsics.

2019-04-15 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr 15 10:17:35 2019
New Revision: 358427

URL: http://llvm.org/viewvc/llvm-project?rev=358427=rev
Log:
[X86] Restore the pavg intrinsics.

The pattern we replaced these with may be too hard to match as demonstrated by
PR41496 and PR41316.

This patch restores the intrinsics and then we can start focusing
on the optimizing the intrinsics.

I've mostly reverted the original patch that removed them. Though I modified
the avx512 intrinsics to not have masking built in.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/test/CodeGen/avx2-builtins.c
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=358427=358426=358427=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 15 10:17:35 2019
@@ -263,6 +263,8 @@ TARGET_BUILTIN(__builtin_ia32_paddusw128
 TARGET_BUILTIN(__builtin_ia32_psubusb128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psubusw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmulhw128, "V8sV8sV8s", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgb128, "V16cV16cV16c", "ncV:128:", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pavgw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxub128, "V16cV16cV16c", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw128, "V8sV8sV8s", "ncV:128:", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pminub128, "V16cV16cV16c", "ncV:128:", "sse2")
@@ -574,6 +576,8 @@ TARGET_BUILTIN(__builtin_ia32_paddusw256
 TARGET_BUILTIN(__builtin_ia32_psubusb256, "V32cV32cV32c", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psubusw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_palignr256, "V32cV32cV32cIi", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgb256, "V32cV32cV32c", "ncV:256:", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pavgw256, "V16sV16sV16s", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "ncV:256:", 
"avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendw256, "V16sV16sV16sIi", "ncV:256:", "avx2")
 TARGET_BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "ncV:256:", "avx2")
@@ -1053,6 +1057,8 @@ TARGET_BUILTIN(__builtin_ia32_paddsb512,
 TARGET_BUILTIN(__builtin_ia32_paddsw512, "V32sV32sV32s", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusb512, "V64cV64cV64c", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusw512, "V32sV32sV32s", "ncV:512:", 
"avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgb512, "V64cV64cV64c", "ncV:512:", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pavgw512, "V32sV32sV32s", "ncV:512:", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsb512, "V64cV64cV64c", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxsw512, "V32sV32sV32s", "ncV:512:", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmaxub512, "V64cV64cV64c", "ncV:512:", 
"avx512bw")

Modified: cfe/trunk/lib/Headers/avx2intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=358427=358426=358427=diff
==
--- cfe/trunk/lib/Headers/avx2intrin.h (original)
+++ cfe/trunk/lib/Headers/avx2intrin.h Mon Apr 15 10:17:35 2019
@@ -132,21 +132,13 @@ _mm256_andnot_si256(__m256i __a, __m256i
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_avg_epu8(__m256i __a, __m256i __b)
 {
-  typedef unsigned short __v32hu __attribute__((__vector_size__(64)));
-  return (__m256i)__builtin_convertvector(
-   ((__builtin_convertvector((__v32qu)__a, __v32hu) +
- __builtin_convertvector((__v32qu)__b, __v32hu)) + 1)
- >> 1, __v32qu);
+  return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_avg_epu16(__m256i __a, __m256i __b)
 {
-  typedef unsigned int __v16su __attribute__((__vector_size__(64)));
-  return (__m256i)__builtin_convertvector(
-   ((__builtin_convertvector((__v16hu)__a, __v16su) +
- __builtin_convertvector((__v16hu)__b, __v16su)) + 1)
- >> 1, __v16hu);
+  return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS256

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=358427=358426=358427=diff

[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 195218.
hintonda added a comment.

- Add new test back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746

Files:
  clang/lib/Tooling/CommonOptionsParser.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/test/Support/check-default-options.txt
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,68 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+cl::DefaultOption);
+  StackOption Foo_Alias("f", cl::desc("Alias for -foo"),
+ cl::aliasopt(Foo), cl::DefaultOption);
+
+  StackSubCommand SC1("sc1", "First Subcommand");
+  // Override "-b" and change type in sc1 SubCommand.
+  StackOption SC1_B("b", cl::sub(SC1), cl::init(false));
+  StackSubCommand SC2("sc2", "Second subcommand");
+  // Override "-foo" and change type in sc2 SubCommand.  Note that this does not
+  // affect "-f" alias, which continues to work correctly.
+  StackOption SC2_Foo("foo", cl::sub(SC2));
+
+  const char *args0[] = {"prog", "-b", "args0 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args0) / sizeof(char *), args0,
+  StringRef(), ::nulls()));
+  EXPECT_TRUE(Bar == "args0 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args1[] = {"prog", "sc1", "-b", "-bar", "args1 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args1) / sizeof(char *), args1,
+  StringRef(), ::nulls()));
+  EXPECT_TRUE(Bar == "args1 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_TRUE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc1", S->getName());
+}
+  }
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args2[] = {"prog", "sc2", "-b", "args2 bar string",
+ "-f", "-foo", "foo string"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args2) / sizeof(char *), args2,
+  StringRef(), ::nulls()));
+  EXPECT_TRUE(Bar == "args2 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo == "foo string");
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc2", S->getName());
+}
+  }
+  cl::ResetCommandLineParser();
+}
+
 TEST(CommandLineTest, ArgumentLimit) {
   std::string args(32 * 4096, 'a');
   EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
Index: llvm/tools/llvm-opt-report/OptReport.cpp
===
--- llvm/tools/llvm-opt-report/OptReport.cpp
+++ llvm/tools/llvm-opt-report/OptReport.cpp
@@ -36,8 +36,6 @@
 using namespace llvm;
 using namespace llvm::yaml;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
 // Mark all our options with this category, everything else (except for -version
 // and -help) will be hidden.
 static cl::OptionCategory
@@ -440,11 +438,6 @@
   "A tool to generate an optimization report from YAML optimization"
   " record files.\n");
 
-  if (Help) {
-cl::PrintHelpMessage();
-return 0;
-  }
-
   LocationInfoTy LocationInfo;
   if (!readLocationInfo(LocationInfo))
 return 1;
Index: llvm/test/Support/check-default-options.txt
===
--- /dev/null
+++ llvm/test/Support/check-default-options.txt
@@ -0,0 +1,18 @@
+# RUN: llvm-objdump -help-hidden %t | FileCheck --check-prefix=CHECK-OBJDUMP %s
+# RUN: llvm-readobj -help-hidden %t | FileCheck --check-prefix=CHECK-READOBJ %s
+# RUN: llvm-tblgen -help-hidden %t | FileCheck --check-prefix=CHECK-TBLGEN %s
+# RUN: llvm-opt-report -help-hidden %t | FileCheck --check-prefix=CHECK-OPT-RPT %s
+# RUN: llvm-dwarfdump -help-hidden %t | FileCheck --check-prefix=CHECK-DWARF %s
+# RUN: llvm-dwarfdump -h %t | FileCheck --check-prefix=CHECK-DWARF-H %s
+
+
+# CHECK-OBJDUMP: -h  - Alias for --section-headers
+# CHECK-READOBJ: -h  - Alias for --file-headers
+# CHECK-TBLGEN:  -h  - Alias for -help
+# CHECK-OPT-RPT: -h  - Alias for -help
+# CHECK-DWARF:   -h  - Alias for -help

[PATCH] D58236: Make address space conversions a bit stricter.

2019-04-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D58236#1466263 , @ebevhan wrote:

> Well, it doesn't seem to me like there is consensus on prohibiting nested 
> address space conversion like this.
>
> I can simply redo the patch to only include the bugfix on implicit 
> conversions and drop the nesting level checks.


I thought the conclusion is:

- Explicit conversions allowed for nested pointers with a warning.
- Implicit conversions are disallowed for nested pointers with an error.

Do you not see it this way?


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

https://reviews.llvm.org/D58236



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


[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 195217.
hintonda added a comment.

- Original patch, r358337, that was reverted.
- Make sure to clear DefaultOptions on reset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746

Files:
  clang/lib/Tooling/CommonOptionsParser.cpp
  llvm/docs/CommandLine.rst
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -620,6 +620,68 @@
   }
 }
 
+TEST(CommandLineTest, DefaultOptions) {
+  cl::ResetCommandLineParser();
+
+  StackOption Bar("bar", cl::sub(*cl::AllSubCommands),
+   cl::DefaultOption);
+  StackOption Bar_Alias(
+  "b", cl::desc("Alias for -bar"), cl::aliasopt(Bar), cl::DefaultOption);
+
+  StackOption Foo("foo", cl::init(false), cl::sub(*cl::AllSubCommands),
+cl::DefaultOption);
+  StackOption Foo_Alias("f", cl::desc("Alias for -foo"),
+ cl::aliasopt(Foo), cl::DefaultOption);
+
+  StackSubCommand SC1("sc1", "First Subcommand");
+  // Override "-b" and change type in sc1 SubCommand.
+  StackOption SC1_B("b", cl::sub(SC1), cl::init(false));
+  StackSubCommand SC2("sc2", "Second subcommand");
+  // Override "-foo" and change type in sc2 SubCommand.  Note that this does not
+  // affect "-f" alias, which continues to work correctly.
+  StackOption SC2_Foo("foo", cl::sub(SC2));
+
+  const char *args0[] = {"prog", "-b", "args0 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args0) / sizeof(char *), args0,
+  StringRef(), ::nulls()));
+  EXPECT_TRUE(Bar == "args0 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args1[] = {"prog", "sc1", "-b", "-bar", "args1 bar string", "-f"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args1) / sizeof(char *), args1,
+  StringRef(), ::nulls()));
+  EXPECT_TRUE(Bar == "args1 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_TRUE(SC1_B);
+  EXPECT_TRUE(SC2_Foo.empty());
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc1", S->getName());
+}
+  }
+
+  cl::ResetAllOptionOccurrences();
+
+  const char *args2[] = {"prog", "sc2", "-b", "args2 bar string",
+ "-f", "-foo", "foo string"};
+  EXPECT_TRUE(cl::ParseCommandLineOptions(sizeof(args2) / sizeof(char *), args2,
+  StringRef(), ::nulls()));
+  EXPECT_TRUE(Bar == "args2 bar string");
+  EXPECT_TRUE(Foo);
+  EXPECT_FALSE(SC1_B);
+  EXPECT_TRUE(SC2_Foo == "foo string");
+  for (auto *S : cl::getRegisteredSubcommands()) {
+if (*S) {
+  EXPECT_EQ("sc2", S->getName());
+}
+  }
+  cl::ResetCommandLineParser();
+}
+
 TEST(CommandLineTest, ArgumentLimit) {
   std::string args(32 * 4096, 'a');
   EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
Index: llvm/tools/llvm-opt-report/OptReport.cpp
===
--- llvm/tools/llvm-opt-report/OptReport.cpp
+++ llvm/tools/llvm-opt-report/OptReport.cpp
@@ -36,8 +36,6 @@
 using namespace llvm;
 using namespace llvm::yaml;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
 // Mark all our options with this category, everything else (except for -version
 // and -help) will be hidden.
 static cl::OptionCategory
@@ -440,11 +438,6 @@
   "A tool to generate an optimization report from YAML optimization"
   " record files.\n");
 
-  if (Help) {
-cl::PrintHelpMessage();
-return 0;
-  }
-
   LocationInfoTy LocationInfo;
   if (!readLocationInfo(LocationInfo))
 return 1;
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -98,6 +98,11 @@
   // This collects additional help to be printed.
   std::vector MoreHelp;
 
+  // This collects Options added with the cl::DefaultOption flag. Since they can
+  // be overridden, they are not added to the appropriate SubCommands until
+  // ParseCommandLineOptions actually runs.
+  SmallVector DefaultOptions;
+
   // This collects the different option categories that have been registered.
   SmallPtrSet RegisteredOptionCategories;
 
@@ -146,6 +151,11 @@
   void addOption(Option *O, SubCommand *SC) {
 bool HadErrors = false;
 if (O->hasArgStr()) {
+  // If it's a DefaultOption, check to make sure it isn't already there.
+  if (O->isDefaultOption() &&

[PATCH] D59919: [Attributor] Deduce "returned" argument attribute

2019-04-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:495
+  virtual size_t getNumReturnValues() const override {
+return isValidState() ? ReturnedValues.size() : -1;
+  }

This should probably call `llvm_unreachable` with a message instead of 
returning -1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59919



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


[PATCH] D60721: [ARM] Check codegen of v8.2a intrinsics

2019-04-15 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard requested changes to this revision.
ostannard added a comment.
This revision now requires changes to proceed.

Clang tests should just cover the C->IR translation, and not depend on the LLVM 
backends. This should instead be an IR->asm test in the LLVM repository.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60721



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


[PATCH] D60721: [ARM] Check codegen of v8.2a intrinsics

2019-04-15 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio created this revision.
dnsampaio added reviewers: olista01, miyuki.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.
dnsampaio added a parent revision: D60720: [ARM] Add v4f16 and v8f16 types to 
the CallingConv.
ostannard requested changes to this revision.
ostannard added a comment.
This revision now requires changes to proceed.

Clang tests should just cover the C->IR translation, and not depend on the LLVM 
backends. This should instead be an IR->asm test in the LLVM repository.


This patch adds a assembly check for the
ARM v8.2-A intrinsics.


Repository:
  rC Clang

https://reviews.llvm.org/D60721

Files:
  test/CodeGen/arm-v8.2a-neon-intrinsics.c
  test/CodeGen/arm-v8.2a-neon-intrinsics.c.asm

Index: test/CodeGen/arm-v8.2a-neon-intrinsics.c.asm
===
--- /dev/null
+++ test/CodeGen/arm-v8.2a-neon-intrinsics.c.asm
@@ -0,0 +1,1000 @@
+// CHECK-LABEL: test_vabs_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vabs.f16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vabsq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vabs.f16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vceqz_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vceq.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vceqzq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vceq.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgez_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcge.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgezq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcge.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgtz_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcgt.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcgtzq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcgt.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vclez_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcle.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vclezq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcle.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcltz_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vclt.f16	d16, d16, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcltzq_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vclt.f16	q8, q8, #0
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_f16_s16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.s16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvtq_f16_s16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.s16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_f16_u16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.u16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvtq_f16_u16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.f16.u16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_s16_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.s16.f16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvtq_s16_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d17, r2, r3
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.s16.f16	q8, q8
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	vmov	r2, r3, d17
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: test_vcvt_u16_f16:
+// CHECK:	.fnstart
+// CHECK-NEXT:	vmov	d16, r0, r1
+// CHECK-NEXT:	vcvt.u16.f16	d16, d16
+// CHECK-NEXT:	vmov	r0, r1, d16
+// CHECK-NEXT:	bx	lr
+// CHECK-LABEL: 

[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-04-15 Thread Tom Rix via Phabricator via cfe-commits
trixirt added a comment.

A comment by whisperity in the origin WIP did not seem to be addressed.
Have you looked at IWYU 
https://github.com/include-what-you-use/include-what-you-use ?
The end goals of clang-scan-deps and iwyu seem similar so their implementation 
problems would also be similar.
The iwyu problems doc is 
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYUIsDifficult.md


Repository:
  rC Clang

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

https://reviews.llvm.org/D60233



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


Re: r358402 - clang-format vs plugin: Visual Studio 2019 support

2019-04-15 Thread Nico Weber via cfe-commits
Nice! Is adding compat to
https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain=false#overview
equally easy?

On Mon, Apr 15, 2019 at 9:01 AM Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hans
> Date: Mon Apr 15 06:02:03 2019
> New Revision: 358402
>
> URL: http://llvm.org/viewvc/llvm-project?rev=358402=rev
> Log:
> clang-format vs plugin: Visual Studio 2019 support
>
> Modified:
> cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
>
> Modified: cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in?rev=358402=358401=358402=diff
>
> ==
> --- cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
> (original)
> +++ cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in Mon
> Apr 15 06:02:03 2019
> @@ -8,7 +8,7 @@
>  license.txt
>
>
> -
> +
>
>
>   DisplayName="Visual Studio MPF" />
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60719: Fixing freestanding for memcpy.

2019-04-15 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60719

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5464,6 +5464,14 @@
   }
 }
 
+static bool IsForceInlineLibc(const SelectionDAG ) {
+  const Module *M = DAG.getMachineFunction().getFunction().getParent();
+  if (auto *MD = mdconst::extract_or_null(
+  M->getModuleFlag("force-inline-libc")))
+return MD->getZExtValue();
+  return false;
+}
+
 /// Lower the call to the specified intrinsic function. If we want to emit this
 /// as a call to a named external function, return the name. Otherwise, lower 
it
 /// and return null.
@@ -5537,10 +5545,11 @@
 unsigned Align = MinAlign(DstAlign, SrcAlign);
 bool isVol = MCI.isVolatile();
 bool isTC = I.isTailCall() && isInTailCallPosition(, DAG.getTarget());
+bool IsAlwaysInline = IsForceInlineLibc(DAG);
 // FIXME: Support passing different dest/src alignments to the memcpy DAG
 // node.
 SDValue MC = DAG.getMemcpy(getRoot(), sdl, Op1, Op2, Op3, Align, isVol,
-   false, isTC,
+   IsAlwaysInline, isTC,
MachinePointerInfo(I.getArgOperand(0)),
MachinePointerInfo(I.getArgOperand(1)));
 updateDAGForMaybeTailCall(MC);
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6090,6 +6090,9 @@
   // beyond the given memory regions. But fixing this isn't easy, and most
   // people don't care.
 
+  assert(MF->getFunction().getParent()->getModuleFlag("force-inline-libc") ==
+ nullptr);
+
   // Emit a library call.
   TargetLowering::ArgListTy Args;
   TargetLowering::ArgListEntry Entry;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -596,6 +596,10 @@
   if (!getCodeGenOpts().RecordCommandLine.empty())
 EmitCommandLineMetadata();
 
+  if (LangOpts.Freestanding) {
+getModule().addModuleFlag(llvm::Module::Override, "force-inline-libc", 1);
+  }
+
   EmitTargetMetadata();
 }
 


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5464,6 +5464,14 @@
   }
 }
 
+static bool IsForceInlineLibc(const SelectionDAG ) {
+  const Module *M = DAG.getMachineFunction().getFunction().getParent();
+  if (auto *MD = mdconst::extract_or_null(
+  M->getModuleFlag("force-inline-libc")))
+return MD->getZExtValue();
+  return false;
+}
+
 /// Lower the call to the specified intrinsic function. If we want to emit this
 /// as a call to a named external function, return the name. Otherwise, lower it
 /// and return null.
@@ -5537,10 +5545,11 @@
 unsigned Align = MinAlign(DstAlign, SrcAlign);
 bool isVol = MCI.isVolatile();
 bool isTC = I.isTailCall() && isInTailCallPosition(, DAG.getTarget());
+bool IsAlwaysInline = IsForceInlineLibc(DAG);
 // FIXME: Support passing different dest/src alignments to the memcpy DAG
 // node.
 SDValue MC = DAG.getMemcpy(getRoot(), sdl, Op1, Op2, Op3, Align, isVol,
-   false, isTC,
+   IsAlwaysInline, isTC,
MachinePointerInfo(I.getArgOperand(0)),
MachinePointerInfo(I.getArgOperand(1)));
 updateDAGForMaybeTailCall(MC);
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6090,6 +6090,9 @@
   // beyond the given memory regions. But fixing this isn't easy, and most
   // people don't care.
 
+  assert(MF->getFunction().getParent()->getModuleFlag("force-inline-libc") ==
+ nullptr);
+
   // Emit a library call.
   TargetLowering::ArgListTy Args;
   TargetLowering::ArgListEntry Entry;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ 

[PATCH] D59746: [CommandLineParser] Add DefaultOption flag

2019-04-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda reopened this revision.
hintonda added a comment.
This revision is now accepted and ready to land.

Reopen to track fix after buildbot failure and revert -- r358414.

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190415/644037.html


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59746



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


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:87
+  TextGenerator Replacement;
+  TextGenerator Explanation;
+};

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > ymandel wrote:
> > > > ilya-biryukov wrote:
> > > > > I would've expected explanation to be the trait of the rewrite rule, 
> > > > > since all changes have to be applied.
> > > > > What's the reasoning behind having it at the level of separate 
> > > > > changes? How would this explanation be used? For debugging purposes 
> > > > > or displaying that to the user?
> > > > I think that for most cases, one explanation sufficies for the whole 
> > > > transformation. However, there are some tidies that emit multiple 
> > > > diagnoses (for example if changing before a declaration and a 
> > > > definition).   Would it help if I clarify in the comments?
> > > Yeah, absolutely! Please document what it's used for and that would clear 
> > > that up for me.
> > > I actually thing that explaining every part of the transformation is 
> > > probably too complicated, so most of the time you would want to have an 
> > > explanation for the `RewriteRule`, not for each individual change.
> > > 
> > > The other challenge that I see is show to display these explanations to 
> > > the user, i.e. how should the clients combine these explanations in order 
> > > to get the full one? Should the `RewriteRule` have an explanation of the 
> > > full transformation too?
> > I've revised the comments, changed the name to "Note" and put "Explanation" 
> > back into RewriteRule.
> > 
> > As for how to display these, I imagine an interface like clang tidy's fixit 
> > hints.  The Explanation (if any) will be associated with the span of the 
> > entire match.  The Notes will be associated with the target node span of 
> > each annotated change.  WDYT?
> Do we really need the AST information to expose the edits to the users?
> IIUC, clang-tidy uses the information from textual replacements to render the 
> changes produced by the fix-its today.
> 
> I guess it might be useful to add extra notes to clang-tidy warnings that 
> have corresponding fix-its, but is the transformers library the right layer 
> to produce those? 
> I haven't seen the proposed glue to clang-tidy yet, maybe that would make 
> more sense when I see it.
> 
> One of the other reasons I ask this is that it seems that without `Note` we 
> don't strictly `ASTEditBuilder`, we could replace
> ```
> change("ref").to("something"); // without nodepart
> change("ref", NodePart::Member).to("something");
> ```
> with
> ```
> change("ref", "something")
> change("ref", NodePart::Member, "something");
> ```
> That would remove the boilerplate of the builder, simplifying the code a bit.
> 
> That trick would be hard to pull if we have a `Note` field inside, we'll need 
> more overloads and having note and replacement after each other might be 
> confusing (they have the same type, might be hard to read without the guiding 
> `.to()` and `.because()`)
Breaking this explicitly into two questions:
1. Do Notes belong here?
2. Can we drop the builder?

1. Do Notes belong here?
I think so.  When users provide a diagnostic, they are specifying its location. 
So, we don't quite need the AST but we do need location info.  The diagnostic 
generator does take information from the replacements themselves, but that's 
not alone. For example: clang-tidy/readability/ConstReturnTypeCheck.cpp:104.  
That demos both the diagnostic construction and multiple diagnostics in a 
single tidy result.

Given that, i think that RewriteRules are the appropriate place. The goal is 
that they be self contained, so I think the explanations should be bundled with 
the description of that actual change.  An example approach to merging with 
clang tidy is here: 
https://github.com/ymand/llvm-project/blob/transformer/clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
 (although that's based on a somewhat different version of the Transformer 
library; it should make clear what I have in mind).

2. Do we need the builder?
No, despite my opinion that notes belong.  Given the explanation on 
RewriteRule, I think notes will be used only rarely (like in the example 
clang-tidy above; but that's not standard practice).  So, we can provide the 
two overloads of `change` that you mention and then let users assign the note 
directly in those rare cases they need it. then, we can drop the builder.

So, I propose keeping the note but dropping the builder. WDYT?



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:204
+applyRewriteRule(const ast_matchers::MatchFinder::MatchResult ,
+ llvm::ArrayRef Changes);
 

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > Why would we change the interface here? Rewrite rule seemed like a 
> > > perfect input to this function
> > Good 

[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> Our current approach is to add an attribute, which SYCL runtime will use to 
> mark code passed to `cl::sycl::handler::parallel_for` as "kernel functions". 
> Obviously runtime library can't mark `foo` as "device" code - this is a 
> compiler job: to traverse all symbols accessible from kernel functions and 
> add them to the "device part" of the code.
> 
> Here is a link to the code in the SYCL runtime using `sycl_kernel` attribute: 
> https://github.com/intel/llvm/blob/sycl/sycl/include/CL/sycl/handler.hpp#L267
> 
> I'm quite sure something similar should happen for other "single source" 
> programming models like OpenMP/CUDA, except these attributes are exposed to 
> the user and there is a specific requirement on attributes/pragma/keyword 
> names.

Just to understand how this will work. I would imagine you can have a device 
function definition preceding its use. When the function is being parsed it's 
not known yet whether it will be called from the device or not, so it won't be 
possible to set the language mode correctly and hence provide the right 
diagnostics. So is the plan to launch a separate parsing phase then just to 
extract the call graph and annotate the device functions?

> NOTE2: @Anastasia, https://reviews.llvm.org/D60454 makes impossible to 
> replace `sycl_kernel` attribute with `__kernel` attribute. I mean we still 
> can enable it for SYCL extension, but we will need SYCL specific 
> customization in this case as we apply `kernel` attribute to a template 
> function.

Ok, my question is whether you are planning to duplicate the same logic as for 
OpenCL kernel which doesn't really seem like an ideal design choice. Is this 
the only difference then we can simply add an extra check for SYCL compilation 
mode in this template handling case. The overall interaction between OpenCL and 
SYCL implementation is still a very big unknown to me so it's not very easy to 
judge about the implementations details...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: test/OpenMP/openmp_offload_registration.cpp:38
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void

ABataev wrote:
> Add a test where the unified memory flag is used
Agreed. More test will be coming anyway. There are a lot of regression tests 
which need to be updated.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 195201.
ymandel marked 10 inline comments as done.
ymandel added a comment.

Clarified comments for `translateEdits` function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60408

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -13,36 +13,11 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-namespace clang {
-namespace tooling {
-namespace {
-using ast_matchers::anyOf;
-using ast_matchers::argumentCountIs;
-using ast_matchers::callee;
-using ast_matchers::callExpr;
-using ast_matchers::cxxMemberCallExpr;
-using ast_matchers::cxxMethodDecl;
-using ast_matchers::cxxRecordDecl;
-using ast_matchers::declRefExpr;
-using ast_matchers::expr;
-using ast_matchers::functionDecl;
-using ast_matchers::hasAnyName;
-using ast_matchers::hasArgument;
-using ast_matchers::hasDeclaration;
-using ast_matchers::hasElse;
-using ast_matchers::hasName;
-using ast_matchers::hasType;
-using ast_matchers::ifStmt;
-using ast_matchers::member;
-using ast_matchers::memberExpr;
-using ast_matchers::namedDecl;
-using ast_matchers::on;
-using ast_matchers::pointsTo;
-using ast_matchers::to;
-using ast_matchers::unless;
-
-using llvm::StringRef;
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
 
+namespace {
 constexpr char KHeaderContents[] = R"cc(
   struct string {
 string(const char*);
@@ -59,6 +34,9 @@
 PCFProto& GetProto();
   };
   }  // namespace proto
+  class Logger {};
+  void operator<<(Logger& l, string msg);
+  Logger& log(int level);
 )cc";
 
 static ast_matchers::internal::Matcher
@@ -141,18 +119,16 @@
 static RewriteRule ruleStrlenSize() {
   StringRef StringExpr = "strexpr";
   auto StringType = namedDecl(hasAnyName("::basic_string", "::string"));
-  return buildRule(
- callExpr(
- callee(functionDecl(hasName("strlen"))),
- hasArgument(0, cxxMemberCallExpr(
-on(expr(hasType(isOrPointsTo(StringType)))
-   .bind(StringExpr)),
-callee(cxxMethodDecl(hasName("c_str")))
-  // Specify the intended type explicitly, because the matcher "type" of
-  // `callExpr()` is `Stmt`, not `Expr`.
-  .as()
-  .replaceWith("REPLACED")
-  .because("Use size() method directly on string.");
+  auto R = makeRule(
+  callExpr(callee(functionDecl(hasName("strlen"))),
+   hasArgument(0, cxxMemberCallExpr(
+  on(expr(hasType(isOrPointsTo(StringType)))
+ .bind(StringExpr)),
+  callee(cxxMethodDecl(hasName("c_str")),
+  changeRoot()
+  .to("REPLACED"));
+  R.Explanation = text("Use size() method directly on string.");
+  return R;
 }
 
 TEST_F(TransformerTest, StrlenSize) {
@@ -181,15 +157,12 @@
 // Tests replacing an expression.
 TEST_F(TransformerTest, Flag) {
   StringRef Flag = "flag";
-  RewriteRule Rule =
-  buildRule(
-  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(hasName(
-"proto::ProtoCommandLineFlag"
-   .bind(Flag)),
-unless(callee(cxxMethodDecl(hasName("GetProto"))
-  .change(Flag)
-  .replaceWith("EXPR")
-  .because("Use GetProto() to access proto fields.");
+  RewriteRule Rule = makeRule(
+  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(
+hasName("proto::ProtoCommandLineFlag"
+   .bind(Flag)),
+unless(callee(cxxMethodDecl(hasName("GetProto"),
+  change(Flag).to("EXPR"));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -207,9 +180,9 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule = buildRule(functionDecl(hasName("bad")).bind(Fun))
- .change(Fun, NodePart::Name)
- .replaceWith("good");
+  RewriteRule Rule =
+  makeRule(functionDecl(hasName("bad")).bind(Fun),
+   change(Fun, NodePart::Name).to("good"));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -240,9 +213,8 @@
   )cc";
 
   StringRef Ref = "ref";
-  testRule(buildRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref))
-   .change(Ref, NodePart::Name)
-   .replaceWith("good"),
+  testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
+

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

gtbercea wrote:
> gtbercea wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > Just `HasRequiresUnifiedSharedMemory = true;`
> > > Not done
> > Ah I misunderstood your initial comment. I thought you were complaining 
> > about the break being in there.
> Because the member is non-static I have to provide the CGM.getOpenMPRuntime() 
> part.
Because the member function is non-static and the member data is non-static, 
you can just use `HasRequiresUnifiedSharedMemory = true;`



Comment at: test/OpenMP/openmp_offload_registration.cpp:38
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void

Add a test where the unified memory flag is used


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195200.
gtbercea added a comment.

- Remove const.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -383,7 +383,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const override;
+  void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) override;
 
   /// Returns default address space for the constant firstprivates, __constant__
   /// address space by default.
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4942,7 +4942,7 @@
 /// Check to see if target architecture supports unified addressing which is
 /// a restriction for OpenMP requires clause "unified_shared_memory".
 void CGOpenMPRuntimeNVPTX::checkArchForUnifiedAddressing(
-const OMPRequiresDecl *D) const {
+const OMPRequiresDecl *D) {
   for (const OMPClause *Clause : D->clauselists()) {
 if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
   switch (getCudaArch(CGM)) {
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   

[PATCH] D58043: Add experimental options for call site related dbg info

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195198.
djtodoro retitled this revision from "Add option for emitting 
DW_OP_entry_values" to "Add experimental options for call site related dbg 
info".
djtodoro edited the summary of this revision.

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

https://reviews.llvm.org/D58043

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_emit_param_entry_values))
+  if (Args.hasArg(options::OPT_emit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-emit-param-entry-values-cc1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_emit_param_entry_values))
+  if (Args.hasArg(options::OPT_emit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-emit-param-entry-values-cc1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 2 inline comments as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

ABataev wrote:
> ABataev wrote:
> > Just `HasRequiresUnifiedSharedMemory = true;`
> Not done
Ah I misunderstood your initial comment. I thought you were complaining about 
the break being in there.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

gtbercea wrote:
> ABataev wrote:
> > ABataev wrote:
> > > Just `HasRequiresUnifiedSharedMemory = true;`
> > Not done
> Ah I misunderstood your initial comment. I thought you were complaining about 
> the break being in there.
Because the member is non-static I have to provide the CGM.getOpenMPRuntime() 
part.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 2 inline comments as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:1438
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+

ABataev wrote:
> ABataev wrote:
> > Why do you need this vertual funtion? I think static local is going to be 
> > enough
> Can you make it `const` member function?
Cannot add that due to createRuntimeFunction not being const.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195195.
gtbercea added a comment.

- Add break.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,24 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 0x001,
+  

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195192.
djtodoro added a comment.

-Rebase
-Use `ExprMutationAnalyzer` for parameter's modification check


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

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto  : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for(auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = dyn_cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto  : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for(auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = dyn_cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195190.
gtbercea added a comment.

- Fix type.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,24 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 0x001,
+  /// 

[PATCH] D58033: Add option for emitting dbg info for call sites

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195188.
djtodoro edited the summary of this revision.
djtodoro added a comment.

-Rebase
-Add all_call_sites flag in the case of GNU extensions


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

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_emit_param_entry_values_cc1);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionlaity.
+  if (Args.hasArg(options::OPT_emit_param_entry_values))
+CmdArgs.push_back("-emit-param-entry-values-cc1");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -916,6 +916,10 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def emit_param_entry_values : Joined<["-"], "femit-param-entry-values">,
+   Group,
+   Flags<[CC1Option]>,
+   HelpText<"Enables debug info about call site and call 
site parameters">;
 def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enable support for int128_t type">;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -359,6 +359,9 @@
 def flto_visibility_public_std:
 Flag<["-"], "flto-visibility-public-std">,
 HelpText<"Use public LTO visibility for classes in std and stdext 
namespaces">;
+def emit_param_entry_values_cc1:
+Flag<["-"], "emit-param-entry-values-cc1">,
+HelpText<"Enables debug info about call site and call site parameters">;
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableParamEntryValues, 1, 0) ///< Emit any call site dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8970
+if (Clause->getClauseKind() == OMPC_unified_shared_memory)
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  }

You can do `break;` here, no need for further analysis



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:9050
+CGF.StartFunction(GlobalDecl(), C.VoidTy, RequiresRegFn, FI, {});
+int64_t Flags = OMP_REQ_NONE;
+//TODO: check for other requires clauses.

Change the type from `int64_t` to `OpenMPOffloadingRequiresDirFlags`



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8978
+if (Clause->getClauseKind() == OMPC_unified_shared_memory) {
+  CGM.getOpenMPRuntime().HasRequiresUnifiedSharedMemory = true;
+  break;

ABataev wrote:
> Just `HasRequiresUnifiedSharedMemory = true;`
Not done



Comment at: lib/CodeGen/CGOpenMPRuntime.h:641
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+

AlexEichenberger wrote:
> Don't you need a bool for each characteristics? Your intention is to have one 
> bit vector for each characteristics that matter to the compiler?
> 
> Also, it is my belief that you need to record 2 states: 
> unmaterialized (meaning I have not processed any target yet, so I should 
> record any requires as they arrive)
> finalized (I am processing a target, so the state is now fixed)
> 
> you need this in case you have an input like this:
> 
> declare target
> int x
> end declare target
> 
> requires unified memory
> 
> which is illegal
What about this comment?



Comment at: lib/CodeGen/CGOpenMPRuntime.h:1438
+  /// requires directives was used in the current module.
+  virtual llvm::Function *emitRequiresDirectiveRegFun();
+

ABataev wrote:
> Why do you need this vertual funtion? I think static local is going to be 
> enough
Can you make it `const` member function?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195186.
gtbercea added a comment.

- Remove atomic flags.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,24 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195185.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp

Index: test/OpenMP/openmp_offload_registration.cpp
===
--- test/OpenMP/openmp_offload_registration.cpp
+++ test/OpenMP/openmp_offload_registration.cpp
@@ -26,7 +26,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 2, [[DEVTY]]* getelementptr inbounds ([2 x [[DEVTY]]], [2 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 // Check presence of foo() and the outlined target region
 // CHECK: define void [[FOO:@.+]]()
@@ -34,6 +34,11 @@
 
 // Check registration and unregistration code.
 
+// CHECK: define internal void @.omp_offloading.requires_reg()
+// CHECK: call void @__tgt_register_requires(i64 0)
+// CHECK: ret void
+// CHECK: declare void @__tgt_register_requires(i64)
+
 // CHECK: define internal void @[[UNREGFN:.+]](i8*)
 // CHECK-SAME: comdat($[[REGFN]]) {
 // CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -410,6 +410,10 @@
   AddGlobalCtor(CudaCtorFunction);
   }
   if (OpenMPRuntime) {
+if (llvm::Function *OpenMPRequiresDirectiveRegFun =
+OpenMPRuntime->emitRequiresDirectiveRegFun()) {
+  AddGlobalCtor(OpenMPRequiresDirectiveRegFun, 0);
+}
 if (llvm::Function *OpenMPRegistrationFunction =
 OpenMPRuntime->emitRegistrationFunction()) {
   auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4987,6 +4987,7 @@
   }
 }
   }
+  CGOpenMPRuntime::checkArchForUnifiedAddressing(D);
 }
 
 /// Get number of SMs and number of blocks per SM.
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -636,6 +636,10 @@
   /// must be emitted.
   llvm::SmallDenseSet DeferredGlobalVariables;
 
+  /// Flag for keeping track of weather a requires unified_shared_memory
+  /// directive is present.
+  bool HasRequiresUnifiedSharedMemory = false;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1429,6 +1433,10 @@
   /// \param GD Global to scan.
   virtual bool emitTargetGlobal(GlobalDecl GD);
 
+  /// Creates and returns a registration function for when at least one
+  /// requires directives was used in the current module.
+  llvm::Function *emitRequiresDirectiveRegFun();
+
   /// Creates the offloading descriptor in the event any target region
   /// was emitted in the current module and return the function that registers
   /// it.
@@ -1597,7 +1605,7 @@
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const;
 
   /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
   /// the predefined allocator and translates it into the corresponding address
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -457,6 +457,30 @@
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
+namespace {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+/// Values for bit flags for marking which requires clauses have been used.
+enum OpenMPOffloadingRequiresDirFlags : int64_t {
+  /// no requires directive present.
+  OMP_REQ_NONE= 0x000,
+  /// reverse_offload clause.
+  OMP_REQ_REVERSE_OFFLOAD = 

  1   2   >